From deebf4d3e543d399f73bad831d82ac028efe106a Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Thu, 28 Apr 2022 17:10:13 +0800 Subject: [PATCH 1/4] Frameworks: Remove standalone build API --- MIGRATION.md | 21 +++++++++++++++++++++ app/ember/package.json | 1 - app/ember/standalone.js | 7 ------- app/html/package.json | 1 - app/html/standalone.js | 7 ------- app/preact/package.json | 1 - app/preact/standalone.js | 7 ------- app/react/package.json | 1 - app/react/standalone.js | 7 ------- app/server/package.json | 1 - app/server/standalone.js | 7 ------- app/standalone.test.ts | 28 ---------------------------- app/svelte/package.json | 1 - app/svelte/standalone.js | 7 ------- app/vue/package.json | 1 - app/vue/standalone.js | 7 ------- app/vue3/package.json | 1 - app/vue3/standalone.js | 7 ------- app/web-components/package.json | 1 - app/web-components/standalone.js | 7 ------- yarn.lock | 10 ---------- 21 files changed, 21 insertions(+), 110 deletions(-) delete mode 100644 app/ember/standalone.js delete mode 100644 app/html/standalone.js delete mode 100644 app/preact/standalone.js delete mode 100644 app/react/standalone.js delete mode 100644 app/server/standalone.js delete mode 100644 app/standalone.test.ts delete mode 100644 app/svelte/standalone.js delete mode 100644 app/vue/standalone.js delete mode 100644 app/vue3/standalone.js delete mode 100644 app/web-components/standalone.js diff --git a/MIGRATION.md b/MIGRATION.md index 8de7439091b8..17f2f3a1b29d 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -4,6 +4,7 @@ - [Breaking changes](#breaking-changes) - [Framework field mandatory](#framework-field-mandatory) - [frameworkOptions renamed](#frameworkoptions-renamed) + - [Framework standalone build moved](#framework-standalone-build-moved) - [From version 6.4.x to 6.5.0](#from-version-64x-to-650) - [React18 new root API](#react18-new-root-api) - [Deprecated register.js](#deprecated-registerjs) @@ -223,6 +224,26 @@ module.exports = { } ``` +#### Framework standalone build moved + +In 7.0 the location of the standalone node API has moved to `@storybook/core-server`. + +If you used the React standalone API, for example, you might have written: + +```js +const { buildStandalone } = require('@storybook/react/standalone'); +const options = {}; +buildStandalone(options).then(() => console.log('done')); +``` + +In 7.0, you would now use: + +```js +const build = require('@storybook/core-server/standalone'); +const options = {}; +build(options).then(() => console.log('done')); +``` + ## From version 6.4.x to 6.5.0 ### React18 new root API diff --git a/app/ember/package.json b/app/ember/package.json index 7ba131cf6259..75e67a34792e 100644 --- a/app/ember/package.json +++ b/app/ember/package.json @@ -38,7 +38,6 @@ "dependencies": { "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/store": "6.5.0-beta.1", "core-js": "^3.8.2", diff --git a/app/ember/standalone.js b/app/ember/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/ember/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/html/package.json b/app/html/package.json index b5c38805acba..ec6c8a639ae1 100644 --- a/app/html/package.json +++ b/app/html/package.json @@ -42,7 +42,6 @@ "@storybook/addons": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/preview-web": "6.5.0-beta.1", diff --git a/app/html/standalone.js b/app/html/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/html/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/preact/package.json b/app/preact/package.json index aa505a2d4929..4c074a6b6802 100644 --- a/app/preact/package.json +++ b/app/preact/package.json @@ -43,7 +43,6 @@ "@storybook/addons": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/store": "6.5.0-beta.1", "@types/node": "^14.14.20 || ^16.0.0", diff --git a/app/preact/standalone.js b/app/preact/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/preact/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/react/package.json b/app/react/package.json index c8787268f2c8..10f7d8e4f547 100644 --- a/app/react/package.json +++ b/app/react/package.json @@ -47,7 +47,6 @@ "@storybook/client-logger": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/node-logger": "6.5.0-beta.1", diff --git a/app/react/standalone.js b/app/react/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/react/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/server/package.json b/app/server/package.json index a7438f653f09..823bde7f4f6c 100644 --- a/app/server/package.json +++ b/app/server/package.json @@ -44,7 +44,6 @@ "@storybook/client-api": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/node-logger": "6.5.0-beta.1", "@storybook/preview-web": "6.5.0-beta.1", diff --git a/app/server/standalone.js b/app/server/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/server/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/standalone.test.ts b/app/standalone.test.ts deleted file mode 100644 index cc4d74af969c..000000000000 --- a/app/standalone.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import build from '@storybook/core-server/standalone'; - -jest.mock('@storybook/core-server/standalone'); - -describe.each([ - ['angular'], - ['ember'], - ['html'], - ['preact'], - ['react'], - ['server'], - ['svelte'], - ['vue'], - ['vue3'], - ['web-components'], -])('%s', (app) => { - it('should run standalone', async () => { - // eslint-disable-next-line import/no-dynamic-require, global-require - const storybook = require(`@storybook/${app}/standalone`); - - await storybook({ - mode: 'static', - outputDir: '', - }); - - expect(build).toHaveBeenCalled(); - }); -}); diff --git a/app/svelte/package.json b/app/svelte/package.json index 3152512b1132..dfeb3e69e023 100644 --- a/app/svelte/package.json +++ b/app/svelte/package.json @@ -44,7 +44,6 @@ "@storybook/client-logger": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/node-logger": "6.5.0-beta.1", diff --git a/app/svelte/standalone.js b/app/svelte/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/svelte/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/vue/package.json b/app/vue/package.json index 5d047a8afdfd..b9b0b27f9e83 100644 --- a/app/vue/package.json +++ b/app/vue/package.json @@ -43,7 +43,6 @@ "@storybook/client-logger": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/store": "6.5.0-beta.1", diff --git a/app/vue/standalone.js b/app/vue/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/vue/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/vue3/package.json b/app/vue3/package.json index 2552f3d143f4..6663fd7ac0e2 100644 --- a/app/vue3/package.json +++ b/app/vue3/package.json @@ -42,7 +42,6 @@ "@storybook/addons": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/store": "6.5.0-beta.1", diff --git a/app/vue3/standalone.js b/app/vue3/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/vue3/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/app/web-components/package.json b/app/web-components/package.json index a55096731249..cce8c8823251 100644 --- a/app/web-components/package.json +++ b/app/web-components/package.json @@ -49,7 +49,6 @@ "@storybook/client-logger": "6.5.0-beta.1", "@storybook/core-client": "6.5.0-beta.1", "@storybook/core-common": "6.5.0-beta.1", - "@storybook/core-server": "6.5.0-beta.1", "@storybook/csf": "0.0.2--canary.4566f4d.1", "@storybook/docs-tools": "6.5.0-beta.1", "@storybook/preview-web": "6.5.0-beta.1", diff --git a/app/web-components/standalone.js b/app/web-components/standalone.js deleted file mode 100644 index de7f65371d4a..000000000000 --- a/app/web-components/standalone.js +++ /dev/null @@ -1,7 +0,0 @@ -const build = require('@storybook/core-server/standalone'); - -async function buildStandalone(options) { - return build(options); -} - -module.exports = buildStandalone; diff --git a/yarn.lock b/yarn.lock index 8a6394ca9257..ff12b6b40cc5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7072,7 +7072,6 @@ __metadata: "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 "@storybook/core-events": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/node-logger": 6.5.0-beta.1 @@ -7830,7 +7829,6 @@ __metadata: dependencies: "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/store": 6.5.0-beta.1 core-js: ^3.8.2 @@ -7935,7 +7933,6 @@ __metadata: "@storybook/addons": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/preview-web": 6.5.0-beta.1 @@ -8200,7 +8197,6 @@ __metadata: "@storybook/addons": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/store": 6.5.0-beta.1 "@types/node": ^14.14.20 || ^16.0.0 @@ -8306,7 +8302,6 @@ __metadata: "@storybook/client-logger": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/node-logger": 6.5.0-beta.1 @@ -8671,7 +8666,6 @@ __metadata: "@storybook/client-api": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/node-logger": 6.5.0-beta.1 "@storybook/preview-web": 6.5.0-beta.1 @@ -8745,7 +8739,6 @@ __metadata: "@storybook/client-logger": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/node-logger": 6.5.0-beta.1 @@ -8893,7 +8886,6 @@ __metadata: "@storybook/addons": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/store": 6.5.0-beta.1 @@ -8929,7 +8921,6 @@ __metadata: "@storybook/client-logger": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/store": 6.5.0-beta.1 @@ -8971,7 +8962,6 @@ __metadata: "@storybook/client-logger": 6.5.0-beta.1 "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 - "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/preview-web": 6.5.0-beta.1 From 706ae0c992b4cfe6b8e118d88b2018e5c389b19d Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Thu, 28 Apr 2022 17:23:57 +0800 Subject: [PATCH 2/4] Update yarn.lock --- yarn.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn.lock b/yarn.lock index ff12b6b40cc5..420a04cbb9e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7072,6 +7072,7 @@ __metadata: "@storybook/core-client": 6.5.0-beta.1 "@storybook/core-common": 6.5.0-beta.1 "@storybook/core-events": 6.5.0-beta.1 + "@storybook/core-server": 6.5.0-beta.1 "@storybook/csf": 0.0.2--canary.4566f4d.1 "@storybook/docs-tools": 6.5.0-beta.1 "@storybook/node-logger": 6.5.0-beta.1 From 6517b3950020883961167bb171055fbb32561b4b Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Sun, 19 Jun 2022 17:00:58 +0800 Subject: [PATCH 3/4] Fix deepscan --- frameworks/angular/src/builders/start-storybook/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/angular/src/builders/start-storybook/index.ts b/frameworks/angular/src/builders/start-storybook/index.ts index fe3516189d69..a7b0386213a6 100644 --- a/frameworks/angular/src/builders/start-storybook/index.ts +++ b/frameworks/angular/src/builders/start-storybook/index.ts @@ -12,7 +12,7 @@ import { StylePreprocessorOptions, } from '@angular-devkit/build-angular'; import { from, Observable, of } from 'rxjs'; -import type { CLIOptions, LoadOptions, BuilderOptions } from '@storybook/core-common'; +import type { CLIOptions } from '@storybook/core-common'; import { map, switchMap, mapTo } from 'rxjs/operators'; import { sync as findUpSync } from 'find-up'; From 033235ff65af9b22ced4ef4409692dcf3cad28ec Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Sun, 19 Jun 2022 17:22:05 +0800 Subject: [PATCH 4/4] Angular: Fix packageJson in CLI --- frameworks/angular/src/builders/build-storybook/index.ts | 2 ++ frameworks/angular/src/builders/start-storybook/index.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/frameworks/angular/src/builders/build-storybook/index.ts b/frameworks/angular/src/builders/build-storybook/index.ts index e583ed9daf2e..e049c05b0407 100644 --- a/frameworks/angular/src/builders/build-storybook/index.ts +++ b/frameworks/angular/src/builders/build-storybook/index.ts @@ -10,6 +10,7 @@ import { from, Observable, of, throwError } from 'rxjs'; import type { CLIOptions } from '@storybook/core-common'; import { catchError, map, mapTo, switchMap } from 'rxjs/operators'; import { sync as findUpSync } from 'find-up'; +import { sync as readUpSync } from 'read-pkg-up'; import { BrowserBuilderOptions, ExtraEntryPoint, @@ -66,6 +67,7 @@ function commandBuilder( } = options; const standaloneOptions: StandaloneOptions = { + packageJson: readUpSync({ cwd: __dirname }).packageJson, configDir, docs, loglevel, diff --git a/frameworks/angular/src/builders/start-storybook/index.ts b/frameworks/angular/src/builders/start-storybook/index.ts index a7b0386213a6..ba3e5ca66ee4 100644 --- a/frameworks/angular/src/builders/start-storybook/index.ts +++ b/frameworks/angular/src/builders/start-storybook/index.ts @@ -15,6 +15,7 @@ import { from, Observable, of } from 'rxjs'; import type { CLIOptions } from '@storybook/core-common'; import { map, switchMap, mapTo } from 'rxjs/operators'; import { sync as findUpSync } from 'find-up'; +import { sync as readUpSync } from 'read-pkg-up'; import { buildDevStandalone } from '@storybook/core-server'; import type { StandaloneOptions } from '../utils/standalone-options'; @@ -81,6 +82,7 @@ function commandBuilder( } = options; const standaloneOptions: StandaloneOptions = { + packageJson: readUpSync({ cwd: __dirname }).packageJson, ci, configDir, docs,