Skip to content

Commit

Permalink
Deprecated: Remove devtools to deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed May 27, 2018
1 parent d45bf7a commit a93d934
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ module.exports = {
message: 'Use @wordpress/date as import path instead.',
},
{
selector: 'ImportDeclaration[source.value=/^devtools$/]',
message: 'Use @wordpress/devtools as import path instead.',
selector: 'ImportDeclaration[source.value=/^deprecated/]',
message: 'Use @wordpress/deprecated as import path instead.',
},
{
selector: 'ImportDeclaration[source.value=/^dom$/]',
Expand Down
2 changes: 1 addition & 1 deletion blocks/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { get, set, isFunction, some } from 'lodash';
*/
import { applyFilters } from '@wordpress/hooks';
import { select, dispatch } from '@wordpress/data';
import { deprecated } from '@wordpress/devtools';
import deprecated from '@wordpress/deprecated';

/**
* Defined behavior of a block type.
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
setDefaultBlockName,
setUnknownTypeHandlerName,
} from '@wordpress/blocks';
import { deprecated } from '@wordpress/devtools';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion data/persist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { deprecated } from '@wordpress/devtools';
import deprecated from '@wordpress/deprecated';

/**
* External dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo

- `wp.data.withRehydratation` has been renamed to `wp.data.withRehydration`.
- The `wp.editor.ImagePlaceholder` component is removed. Please use `wp.editor.MediaPlaceholder` instead.
- `wp.utils.deprecated` function removed. Please use `wp.devtools.deprecated` instead.
- `wp.utils.deprecated` function removed. Please use `wp.deprecated` instead.

## 3.1.0

Expand Down
2 changes: 1 addition & 1 deletion editor/components/image-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { deprecated } from '@wordpress/devtools';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion editor/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
getRectangleFromRange,
getScrollContainer,
} from '@wordpress/dom';
import { deprecated } from '@wordpress/devtools';
import deprecated from '@wordpress/deprecated';
import {
keycodes,
createBlobURL,
Expand Down
2 changes: 1 addition & 1 deletion editor/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { forEach } from 'lodash';
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { deprecated } from '@wordpress/devtools';
import deprecated from '@wordpress/deprecated';
import { withSelect } from '@wordpress/data';

import {
Expand Down
16 changes: 8 additions & 8 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ function gutenberg_register_scripts_and_styles() {

// Editor Scripts.
wp_register_script(
'wp-devtools',
gutenberg_url( 'build/devtools/index.js' ),
'wp-deprecated',
gutenberg_url( 'build/deprecated/index.js' ),
array(),
filemtime( gutenberg_dir_path() . 'build/devtools/index.js' ),
filemtime( gutenberg_dir_path() . 'build/deprecated/index.js' ),
true
);
wp_register_script(
'wp-data',
gutenberg_url( 'build/data/index.js' ),
array( 'wp-devtools', 'wp-element', 'wp-is-shallow-equal', 'lodash' ),
array( 'wp-deprecated', 'wp-element', 'wp-is-shallow-equal', 'lodash' ),
filemtime( gutenberg_dir_path() . 'build/data/index.js' ),
true
);
Expand All @@ -146,7 +146,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-utils',
gutenberg_url( 'build/utils/index.js' ),
array( 'lodash', 'wp-devtools', 'wp-dom' ),
array( 'lodash', 'wp-deprecated', 'wp-dom' ),
filemtime( gutenberg_dir_path() . 'build/utils/index.js' ),
true
);
Expand Down Expand Up @@ -213,7 +213,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-blocks',
gutenberg_url( 'build/blocks/index.js' ),
array( 'wp-devtools', 'wp-dom', 'wp-element', 'wp-utils', 'wp-hooks', 'wp-i18n', 'shortcode', 'wp-data', 'lodash' ),
array( 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-utils', 'wp-hooks', 'wp-i18n', 'shortcode', 'wp-data', 'lodash' ),
filemtime( gutenberg_dir_path() . 'build/blocks/index.js' ),
true
);
Expand Down Expand Up @@ -241,7 +241,7 @@ function gutenberg_register_scripts_and_styles() {
'wp-blocks',
'wp-components',
'wp-core-data',
'wp-devtools',
'wp-deprecated',
'wp-element',
'wp-editor',
'wp-i18n',
Expand Down Expand Up @@ -335,7 +335,7 @@ function gutenberg_register_scripts_and_styles() {
'wp-core-data',
'wp-data',
'wp-date',
'wp-devtools',
'wp-deprecated',
'wp-dom',
'wp-i18n',
'wp-element',
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions packages/deprecated/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# @wordpress/deprecated

Logs a message to notify developers about a deprecated feature.

## Installation

Install the module

```bash
npm install @wordpress/deprecated@next --save
```

## Usage

```js
import deprecated from '@wordpress/deprecated';

deprecated( 'Eating meat', {
version: 'the future',
alternative: 'vegetables',
plugin: 'the earth',
hint: 'You may find it beneficial to transition gradually.',
} );

// Logs: 'Eating meat is deprecated and will be removed from the earth in the future. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
```

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@wordpress/devtools",
"name": "@wordpress/deprecated",
"version": "0.0.1",
"description": "Devtools module for WordPress",
"description": "Deprecation utility for WordPress",
"author": "WordPress",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"devtools"
"deprecated"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/devtools/README.md",
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/deprecated/README.md",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/gutenberg.git"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @param {?string} options.link Link to documentation
* @param {?string} options.hint Additional message to help transition away from the deprecated feature.
*/
export function deprecated( feature, { version, alternative, plugin, link, hint } = {} ) {
export default function deprecated( feature, { version, alternative, plugin, link, hint } = {} ) {
const pluginMessage = plugin ? ` from ${ plugin }` : '';
const versionMessage = version ? `${ pluginMessage } in ${ version }` : '';
const useInsteadMessage = alternative ? ` Please use ${ alternative } instead.` : '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { deprecated } from '../';
import deprecated from '../';

describe( 'deprecated', () => {
it( 'should show a deprecation warning', () => {
Expand Down
13 changes: 0 additions & 13 deletions packages/devtools/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion test/unit/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"moduleNameMapper": {
"@wordpress\\/(blocks|components|editor|data|utils|edit-post|viewport|plugins|core-data|core-blocks)$": "$1",
"@wordpress\\/(date|dom|devtools|element)$": "packages/$1/src"
"@wordpress\\/(date|dom|deprecated|element)$": "packages/$1/src"
},
"preset": "@wordpress/jest-preset-default",
"setupFiles": [
Expand Down
4 changes: 2 additions & 2 deletions utils/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import * as dom from '@wordpress/dom';
import { deprecated as originalDeprecated } from '@wordpress/devtools';
import originalDeprecated from '@wordpress/deprecated';

const wrapFunction = ( functionName, source = dom ) => ( ...args ) => {
originalDeprecated( 'wp.utils.' + functionName, {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const unwrap = wrapFunction( 'unwrap' );
export function deprecated( ...params ) {
originalDeprecated( 'wp.utils.deprecated', {
version: '3.2',
alternative: 'wp.devtools.deprecated',
alternative: 'wp.deprecated',
plugin: 'Gutenberg',
} );

Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const entryPointNames = [

const gutenbergPackages = [
'date',
'devtools',
'deprecated',
'dom',
'element',
];
Expand Down Expand Up @@ -276,7 +276,7 @@ const config = {
return path;
},
} ),
new LibraryExportDefaultPlugin( [ 'dom-ready' ].map( camelCaseDash ) ),
new LibraryExportDefaultPlugin( [ 'deprecated', 'dom-ready' ].map( camelCaseDash ) ),
],
stats: {
children: false,
Expand Down

0 comments on commit a93d934

Please sign in to comment.