From fcae5ba3c6481ccdbd03a152454316e47d6e8f4c Mon Sep 17 00:00:00 2001 From: Jon Palmer <328224+jonspalmer@users.noreply.github.com> Date: Tue, 25 Feb 2020 11:48:51 -0500 Subject: [PATCH 1/3] Remove deprecated decorators and loaders --- MIGRATION.md | 31 +++++++++++++++++++++++ addons/a11y/package.json | 4 +-- addons/a11y/src/index.ts | 35 +------------------------- addons/a11y/src/preset/addDecorator.ts | 4 +-- addons/backgrounds/package.json | 4 +-- addons/backgrounds/src/index.ts | 17 ------------- addons/centered/package.json | 3 +-- addons/centered/src/index.ts | 21 ---------------- addons/storysource/package.json | 3 +-- addons/storysource/src/index.ts | 3 +-- addons/storysource/src/preview.ts | 11 -------- 11 files changed, 39 insertions(+), 97 deletions(-) delete mode 100644 addons/storysource/src/preview.ts diff --git a/MIGRATION.md b/MIGRATION.md index f4cbe745d89c..7a4dd0e5af6e 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -3,6 +3,7 @@ - [Migration](#migration) - [From version 5.3.x to 6.0.x](#from-version-53x-to-60x) - [New addon presets](#new-addon-presets) + - [Removed Legacy Addon Decorators and Loaders](#removed-legacy-addon-decorators-and-loaders) - [Client API changes](#client-api-changes) - [Removed legacy story APIs](#removed-legacy-story-apis) - [Can no longer add decorators/parameters after stories](#can-no-longer-add-decorators-parameters-after-stories) @@ -129,6 +130,36 @@ MyNonCheckedStory.story = { }; ``` +### Removed Legacy Addon Decorators and Loaders + +In 6.0 we removed a11y and centered addon decorators that were previously deprecated. + +#### a11y, background and storysource addons + +See the migration guides for further details: +[Addon a11y uses parameters, decorator renamed](#addon-a11y-uses-parameters-decorator-renamed) +[Addon backgrounds uses parameters](#addon-backgrounds-uses-parameters) +[Source-loader](#source-loader) + +#### centered addon + +If you previously had: +```js +import centered from '@storybook/addon-centered' +``` + +You should replace it with the React or Vue version as appropriate + +```js +import centered from '@storybook/addon-centered/react' +``` + +or + +```js +import centered from '@storybook/addon-centered/vue' +``` + ### Client API changes #### Removed Legacy Story APIs diff --git a/addons/a11y/package.json b/addons/a11y/package.json index 21bdb805015d..32cfa13598da 100644 --- a/addons/a11y/package.json +++ b/addons/a11y/package.json @@ -48,9 +48,7 @@ "react-redux": "^7.0.2", "react-sizeme": "^2.5.2", "redux": "^4.0.1", - "regenerator-runtime": "^0.13.3", - "ts-dedent": "^1.1.1", - "util-deprecate": "^1.0.2" + "regenerator-runtime": "^0.13.3" }, "devDependencies": { "@types/react-redux": "^7.0.6", diff --git a/addons/a11y/src/index.ts b/addons/a11y/src/index.ts index f96d86cb0d07..d3e3b5bbce65 100644 --- a/addons/a11y/src/index.ts +++ b/addons/a11y/src/index.ts @@ -1,7 +1,5 @@ import { document } from 'global'; import axe, { AxeResults, ElementContext, RunOptions, Spec } from 'axe-core'; -import deprecate from 'util-deprecate'; -import dedent from 'ts-dedent'; import addons, { makeDecorator } from '@storybook/addons'; import { EVENTS, PARAM_KEY } from './constants'; @@ -14,7 +12,7 @@ interface Setup { manual: boolean; } -let setup: Setup = { element: undefined, config: {}, options: {}, manual: false }; +const setup: Setup = { element: undefined, config: {}, options: {}, manual: false }; const getElement = () => { const storyRoot = document.getElementById('story-root'); @@ -74,34 +72,3 @@ export const withA11y = makeDecorator({ return getStory(context); }, }); - -// TODO: REMOVE at v6.0.0 -export const withA11Y = deprecate( - // @ts-ignore - (...args: any[]) => withA11y(...args), - 'withA11Y has been renamed withA11y' -); - -// TODO: REMOVE at v6.0.0 -export const checkA11y = deprecate( - // @ts-ignore - (...args: any[]) => withA11y(...args), - 'checkA11y has been renamed withA11y' -); - -// TODO: REMOVE at v6.0.0 -export const configureA11y = deprecate( - (config: any) => { - setup = config; - }, - dedent` - configureA11y is deprecated, please configure addon-a11y using the addParameter api: - - addParameters({ - a11y: { - // ... axe options - element: '#root', // optional selector which element to inspect - }, - }); - ` -); diff --git a/addons/a11y/src/preset/addDecorator.ts b/addons/a11y/src/preset/addDecorator.ts index d4cef2e81112..be3b27b26f7a 100644 --- a/addons/a11y/src/preset/addDecorator.ts +++ b/addons/a11y/src/preset/addDecorator.ts @@ -1,3 +1,3 @@ -import { withA11Y } from '../index'; +import { withA11y } from '../index'; -export const decorators = [withA11Y]; +export const decorators = [withA11y]; diff --git a/addons/backgrounds/package.json b/addons/backgrounds/package.json index 5ec560375e42..29c57516fe8a 100644 --- a/addons/backgrounds/package.json +++ b/addons/backgrounds/package.json @@ -41,11 +41,9 @@ "core-js": "^3.0.1", "memoizerific": "^1.11.3", "react": "^16.8.3", - "regenerator-runtime": "^0.13.3", - "util-deprecate": "^1.0.2" + "regenerator-runtime": "^0.13.3" }, "devDependencies": { - "@types/util-deprecate": "^1.0.0", "@types/webpack-env": "^1.15.1" }, "peerDependencies": { diff --git a/addons/backgrounds/src/index.ts b/addons/backgrounds/src/index.ts index 9352400fe35c..b9ba57b91818 100644 --- a/addons/backgrounds/src/index.ts +++ b/addons/backgrounds/src/index.ts @@ -1,20 +1,3 @@ -import { makeDecorator, StoryContext, StoryGetter } from '@storybook/addons'; -import deprecate from 'util-deprecate'; - -// This decorator is kept purely so we produce a decorator that is compatible with both -// `addDecorator(withBackgrounds(...))` and `addDecorator(withBackgrounds)` -export const withBackgrounds = deprecate( - makeDecorator({ - name: 'withBackgrounds', - parameterName: 'backgrounds', - wrapper: (getStory: StoryGetter, context: StoryContext) => { - return getStory(context); - }, - }), - `Note that withBackgrounds(options) has been replaced by addParameters({ backgrounds: options}) -Read more about it in the migration guide: https://github.com/storybookjs/storybook/blob/master/MIGRATION.md` -); - if (module && module.hot && module.hot.decline) { module.hot.decline(); } diff --git a/addons/centered/package.json b/addons/centered/package.json index a3f858893873..8b6350210a10 100644 --- a/addons/centered/package.json +++ b/addons/centered/package.json @@ -33,8 +33,7 @@ "@storybook/addons": "6.0.0-alpha.19", "core-js": "^3.0.1", "global": "^4.3.2", - "regenerator-runtime": "^0.13.3", - "util-deprecate": "^1.0.2" + "regenerator-runtime": "^0.13.3" }, "devDependencies": { "@types/mithril": "^1.1.16", diff --git a/addons/centered/src/index.ts b/addons/centered/src/index.ts index 1bb9f82933ae..b9ba57b91818 100644 --- a/addons/centered/src/index.ts +++ b/addons/centered/src/index.ts @@ -1,24 +1,3 @@ -import { window } from 'global'; -import deprecate from 'util-deprecate'; - -import ReactCentered from './react'; -import VueCentered from './vue'; - -// TODO: REMOVE this entire file in V6.0.0 - -const Centered = deprecate( - () => (window.STORYBOOK_ENV === 'vue' ? VueCentered : ReactCentered), - ` - Using "import centered from '@storybook/addon-centered'" is deprecated. - Please use either: - "import centered from '@storybook/addon-centered/react'" - or - "import centered from '@storybook/addon-centered/vue'" -` -)(); - -export default Centered; - if (module && module.hot && module.hot.decline) { module.hot.decline(); } diff --git a/addons/storysource/package.json b/addons/storysource/package.json index 49ca8bedd5e7..c41d659e2552 100644 --- a/addons/storysource/package.json +++ b/addons/storysource/package.json @@ -43,8 +43,7 @@ "prop-types": "^15.7.2", "react": "^16.9.17", "react-syntax-highlighter": "^11.0.2", - "regenerator-runtime": "^0.13.3", - "util-deprecate": "^1.0.2" + "regenerator-runtime": "^0.13.3" }, "devDependencies": { "@types/react": "^16.9.19", diff --git a/addons/storysource/src/index.ts b/addons/storysource/src/index.ts index 6f62c1dcf725..a5cd9202f547 100644 --- a/addons/storysource/src/index.ts +++ b/addons/storysource/src/index.ts @@ -1,7 +1,6 @@ import { ADDON_ID, PANEL_ID } from './events'; -import { withStorySource } from './preview'; -export { ADDON_ID, PANEL_ID, withStorySource }; +export { ADDON_ID, PANEL_ID }; if (module && module.hot && module.hot.decline) { module.hot.decline(); diff --git a/addons/storysource/src/preview.ts b/addons/storysource/src/preview.ts deleted file mode 100644 index e36004385aec..000000000000 --- a/addons/storysource/src/preview.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { logger } from '@storybook/client-logger'; - -export function withStorySource(source: string, locationsMap = {}) { - logger.error( - '@storybook/addon-storysource/withStorySource is deprecated, please use paramaters instead.' - ); - - return (storyFn: (context: any) => React.ReactNode, context: any) => { - return storyFn(context); - }; -} From d8eb21b7ffa20be482d73ee79f8dcdc2f3625a86 Mon Sep 17 00:00:00 2001 From: Jon Palmer <328224+jonspalmer@users.noreply.github.com> Date: Tue, 25 Feb 2020 13:59:42 -0500 Subject: [PATCH 2/3] remove the legacy makePreset --- MIGRATION.md | 55 ++++++++++--------- addons/docs/angular/preset.js | 1 - addons/docs/html/preset.js | 1 - addons/docs/react/preset.js | 1 - .../docs/src/frameworks/common/makePreset.ts | 17 ------ addons/docs/vue/preset.js | 1 - addons/docs/web-components/preset.js | 1 - 7 files changed, 28 insertions(+), 49 deletions(-) delete mode 100644 addons/docs/angular/preset.js delete mode 100644 addons/docs/html/preset.js delete mode 100644 addons/docs/react/preset.js delete mode 100644 addons/docs/src/frameworks/common/makePreset.ts delete mode 100644 addons/docs/vue/preset.js delete mode 100644 addons/docs/web-components/preset.js diff --git a/MIGRATION.md b/MIGRATION.md index 7a4dd0e5af6e..55e8be429664 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -3,7 +3,7 @@ - [Migration](#migration) - [From version 5.3.x to 6.0.x](#from-version-53x-to-60x) - [New addon presets](#new-addon-presets) - - [Removed Legacy Addon Decorators and Loaders](#removed-legacy-addon-decorators-and-loaders) + - [Removed Deprecated APIs](#Removed-deprecated-apis) - [Client API changes](#client-api-changes) - [Removed legacy story APIs](#removed-legacy-story-apis) - [Can no longer add decorators/parameters after stories](#can-no-longer-add-decorators-parameters-after-stories) @@ -42,6 +42,7 @@ - [Addon cssresources name attribute renamed](#addon-cssresources-name-attribute-renamed) - [Addon viewport uses parameters](#addon-viewport-uses-parameters) - [Addon a11y uses parameters, decorator renamed](#addon-a11y-uses-parameters-decorator-renamed) + - [Addon centered decorator deprecated](#addon-centered-decorator-deprecated) - [New keyboard shortcuts defaults](#new-keyboard-shortcuts-defaults) - [New URL structure](#new-url-structure) - [Rename of the `--secure` cli parameter to `--https`](#rename-of-the---secure-cli-parameter-to---https) @@ -130,35 +131,16 @@ MyNonCheckedStory.story = { }; ``` -### Removed Legacy Addon Decorators and Loaders +### Removed Deprecated APIs -In 6.0 we removed a11y and centered addon decorators that were previously deprecated. - -#### a11y, background and storysource addons +In 6.0 we removed a number of APIs that were previously deprecated. See the migration guides for further details: -[Addon a11y uses parameters, decorator renamed](#addon-a11y-uses-parameters-decorator-renamed) -[Addon backgrounds uses parameters](#addon-backgrounds-uses-parameters) -[Source-loader](#source-loader) - -#### centered addon - -If you previously had: -```js -import centered from '@storybook/addon-centered' -``` - -You should replace it with the React or Vue version as appropriate - -```js -import centered from '@storybook/addon-centered/react' -``` - -or - -```js -import centered from '@storybook/addon-centered/vue' -``` +* [Addon a11y uses parameters, decorator renamed](#addon-a11y-uses-parameters-decorator-renamed) +* [Addon backgrounds uses parameters](#addon-backgrounds-uses-parameters) +* [Source-loader](#source-loader) +* [Unified docs preset](#unified-docs-preset) +* [Addon centered decorator deprecated](#addon-centered-decorator-deprecated) ### Client API changes @@ -781,6 +763,25 @@ Furthermore, the decorator `checkA11y` has been deprecated and renamed to `withA See the [a11y addon README](https://github.com/storybookjs/storybook/blob/master/addons/a11y/README.md) for more information. +### Addon centered decorator deprecated + +If you previously had: +```js +import centered from '@storybook/addon-centered' +``` + +You should replace it with the React or Vue version as appropriate + +```js +import centered from '@storybook/addon-centered/react' +``` + +or + +```js +import centered from '@storybook/addon-centered/vue' +``` + ### New keyboard shortcuts defaults Storybook's keyboard shortcuts are updated in 5.0, but they are configurable via the menu so if you want to set them back you can: diff --git a/addons/docs/angular/preset.js b/addons/docs/angular/preset.js deleted file mode 100644 index 8d573804f8bf..000000000000 --- a/addons/docs/angular/preset.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../dist/frameworks/common/makePreset').default('angular'); diff --git a/addons/docs/html/preset.js b/addons/docs/html/preset.js deleted file mode 100644 index c8e7b0564571..000000000000 --- a/addons/docs/html/preset.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../dist/frameworks/common/makePreset').default('html'); diff --git a/addons/docs/react/preset.js b/addons/docs/react/preset.js deleted file mode 100644 index c92d21ffca5c..000000000000 --- a/addons/docs/react/preset.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../dist/frameworks/common/makePreset').default('react'); diff --git a/addons/docs/src/frameworks/common/makePreset.ts b/addons/docs/src/frameworks/common/makePreset.ts deleted file mode 100644 index 08654c15063b..000000000000 --- a/addons/docs/src/frameworks/common/makePreset.ts +++ /dev/null @@ -1,17 +0,0 @@ -import deprecate from 'util-deprecate'; -import dedent from 'ts-dedent'; -import * as common from '../../preset'; - -const makePreset = (framework: string) => { - deprecate( - () => {}, - dedent` - Framework-specific presets are no longer-needed as of Storybook 5.3 and will be removed in 6.0. - - Please use '@storybook/addon-docs/preset' instead of '@storybook/addon-docs/${framework}/preset'. - ` - )(); - return common; -}; - -export default makePreset; diff --git a/addons/docs/vue/preset.js b/addons/docs/vue/preset.js deleted file mode 100644 index 09cb6c49e5e5..000000000000 --- a/addons/docs/vue/preset.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../dist/frameworks/common/makePreset').default('vue'); diff --git a/addons/docs/web-components/preset.js b/addons/docs/web-components/preset.js deleted file mode 100644 index bb92eefa1c08..000000000000 --- a/addons/docs/web-components/preset.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../dist/frameworks/common/makePreset').default('web-components'); From 969907e7bbe6257149b79c28a28de6214644a328 Mon Sep 17 00:00:00 2001 From: Jon Palmer <328224+jonspalmer@users.noreply.github.com> Date: Tue, 25 Feb 2020 14:47:50 -0500 Subject: [PATCH 3/3] remove loader --- addons/storysource/loader.js | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 addons/storysource/loader.js diff --git a/addons/storysource/loader.js b/addons/storysource/loader.js deleted file mode 100644 index cde76952e169..000000000000 --- a/addons/storysource/loader.js +++ /dev/null @@ -1,6 +0,0 @@ -const deprecate = require('util-deprecate'); - -deprecate(() => {}, -'@storybook/addon-storysource/loader is deprecated, please use @storybook/source-loader instead.')(); - -module.exports = require('@storybook/source-loader');