@nx/storybook 23.0.0-beta.23 → 23.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.d.ts → dist/index.d.ts} +0 -1
- package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
- package/{presets → dist/presets}/cypress.d.ts +0 -1
- package/{src → dist/src}/executors/build-storybook/build-storybook.impl.d.ts +0 -1
- package/dist/src/executors/build-storybook/build-storybook.impl.js +32 -0
- package/{src → dist/src}/executors/storybook/storybook.impl.d.ts +0 -1
- package/dist/src/executors/storybook/storybook.impl.js +35 -0
- package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/edit-root-tsconfig.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/ensure-dependencies.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/util-functions.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/schema.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/schema.json +0 -6
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/utils.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.d.ts +0 -1
- package/{src → dist/src}/generators/init/lib/update-gitignore.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-10/calling-storybook-cli.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-10/migrate-10.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-8/calling-storybook-cli.d.ts +0 -1
- package/{src/generators/migrate-9 → dist/src/generators/migrate-8}/helper-functions.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-8/migrate-8.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-9/calling-storybook-cli.d.ts +0 -1
- package/{src/generators/migrate-8 → dist/src/generators/migrate-9}/helper-functions.d.ts +0 -1
- package/{src → dist/src}/generators/migrate-9/migrate-9.d.ts +0 -1
- package/{src → dist/src}/migrations/update-21-1-0/update-sb-9.d.ts +0 -1
- package/{src → dist/src}/migrations/update-21-2-0/remove-addon-dependencies.d.ts +0 -1
- package/{src → dist/src}/migrations/update-22-1-0/migrate-to-storybook-10.d.ts +0 -1
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.d.ts +9 -0
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.js +136 -0
- package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md +25 -0
- package/{src → dist/src}/plugins/plugin.d.ts +0 -1
- package/{src → dist/src}/utils/assert-supported-storybook-version.d.ts +0 -1
- package/{src → dist/src}/utils/deprecation.d.ts +0 -1
- package/{src → dist/src}/utils/models.d.ts +0 -1
- package/{src → dist/src}/utils/testing.d.ts +0 -1
- package/{src → dist/src}/utils/utilities.d.ts +0 -1
- package/{src → dist/src}/utils/versions.d.ts +0 -1
- package/{src → dist/src}/utils/versions.js +1 -1
- package/executors.json +4 -4
- package/generators.json +12 -12
- package/migrations.json +10 -4
- package/package.json +67 -12
- package/index.d.ts.map +0 -1
- package/plugin.d.ts.map +0 -1
- package/presets/cypress.d.ts.map +0 -1
- package/src/executors/build-storybook/build-storybook.impl.d.ts.map +0 -1
- package/src/executors/build-storybook/build-storybook.impl.js +0 -63
- package/src/executors/storybook/storybook.impl.d.ts.map +0 -1
- package/src/executors/storybook/storybook.impl.js +0 -66
- package/src/generators/configuration/configuration.d.ts.map +0 -1
- package/src/generators/configuration/lib/edit-root-tsconfig.d.ts.map +0 -1
- package/src/generators/configuration/lib/ensure-dependencies.d.ts.map +0 -1
- package/src/generators/configuration/lib/util-functions.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/utils.d.ts.map +0 -1
- package/src/generators/init/init.d.ts.map +0 -1
- package/src/generators/init/lib/update-gitignore.d.ts.map +0 -1
- package/src/generators/migrate-10/calling-storybook-cli.d.ts.map +0 -1
- package/src/generators/migrate-10/migrate-10.d.ts.map +0 -1
- package/src/generators/migrate-8/calling-storybook-cli.d.ts.map +0 -1
- package/src/generators/migrate-8/helper-functions.d.ts.map +0 -1
- package/src/generators/migrate-8/migrate-8.d.ts.map +0 -1
- package/src/generators/migrate-9/calling-storybook-cli.d.ts.map +0 -1
- package/src/generators/migrate-9/helper-functions.d.ts.map +0 -1
- package/src/generators/migrate-9/migrate-9.d.ts.map +0 -1
- package/src/migrations/update-21-1-0/update-sb-9.d.ts.map +0 -1
- package/src/migrations/update-21-2-0/remove-addon-dependencies.d.ts.map +0 -1
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts.map +0 -1
- package/src/plugins/plugin.d.ts.map +0 -1
- package/src/utils/assert-supported-storybook-version.d.ts.map +0 -1
- package/src/utils/deprecation.d.ts.map +0 -1
- package/src/utils/models.d.ts.map +0 -1
- package/src/utils/testing.d.ts.map +0 -1
- package/src/utils/utilities.d.ts.map +0 -1
- package/src/utils/versions.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{plugin.js → dist/plugin.js} +0 -0
- /package/{presets → dist/presets}/cypress.js +0 -0
- /package/{src → dist/src}/executors/build-storybook/schema.json +0 -0
- /package/{src → dist/src}/executors/storybook/schema.json +0 -0
- /package/{src → dist/src}/generators/configuration/configuration.js +0 -0
- /package/{src → dist/src}/generators/configuration/files/v10/project-files/.storybook/main.js__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v10/project-files/.storybook/preview.js__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v10/project-files/.storybook/tsconfig.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v10/project-files-ts/.storybook/main.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v10/project-files-ts/.storybook/preview.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v10/project-files-ts/.storybook/tsconfig.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v9/project-files/.storybook/main.js__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v9/project-files/.storybook/preview.js__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v9/project-files/.storybook/tsconfig.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v9/project-files-ts/.storybook/main.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v9/project-files-ts/.storybook/preview.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/v9/project-files-ts/.storybook/tsconfig.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/lib/edit-root-tsconfig.js +0 -0
- /package/{src → dist/src}/generators/configuration/lib/ensure-dependencies.js +0 -0
- /package/{src → dist/src}/generators/configuration/lib/util-functions.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/build-post-target-transformer.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/serve-post-target-transformer.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/utils.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
- /package/{src → dist/src}/generators/init/init.js +0 -0
- /package/{src → dist/src}/generators/init/lib/update-gitignore.js +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/init/schema.json +0 -0
- /package/{src → dist/src}/generators/migrate-10/calling-storybook-cli.js +0 -0
- /package/{src → dist/src}/generators/migrate-10/files/ai-instructions-for-cjs-esm.md +0 -0
- /package/{src → dist/src}/generators/migrate-10/migrate-10.js +0 -0
- /package/{src → dist/src}/generators/migrate-10/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/migrate-10/schema.json +0 -0
- /package/{src → dist/src}/generators/migrate-8/calling-storybook-cli.js +0 -0
- /package/{src → dist/src}/generators/migrate-8/files/storybook-migration-summary.md__tmpl__ +0 -0
- /package/{src → dist/src}/generators/migrate-8/helper-functions.js +0 -0
- /package/{src → dist/src}/generators/migrate-8/migrate-8.js +0 -0
- /package/{src → dist/src}/generators/migrate-8/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/migrate-8/schema.json +0 -0
- /package/{src → dist/src}/generators/migrate-9/calling-storybook-cli.js +0 -0
- /package/{src → dist/src}/generators/migrate-9/files/storybook-migration-summary.md__tmpl__ +0 -0
- /package/{src → dist/src}/generators/migrate-9/helper-functions.js +0 -0
- /package/{src → dist/src}/generators/migrate-9/migrate-9.js +0 -0
- /package/{src → dist/src}/generators/migrate-9/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/migrate-9/schema.json +0 -0
- /package/{src → dist/src}/migrations/update-21-1-0/update-sb-9.js +0 -0
- /package/{src → dist/src}/migrations/update-21-2-0/remove-addon-dependencies.js +0 -0
- /package/{src → dist/src}/migrations/update-22-1-0/migrate-to-storybook-10.js +0 -0
- /package/{src → dist/src}/plugins/plugin.js +0 -0
- /package/{src → dist/src}/utils/assert-supported-storybook-version.js +0 -0
- /package/{src → dist/src}/utils/deprecation.js +0 -0
- /package/{src → dist/src}/utils/models.js +0 -0
- /package/{src → dist/src}/utils/testing.js +0 -0
- /package/{src → dist/src}/utils/utilities.js +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = buildStorybookExecutor;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const utilities_1 = require("../../utils/utilities");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
8
|
+
async function buildStorybookExecutor(options, context) {
|
|
9
|
+
(0, deprecation_1.warnStorybookBuildExecutorDeprecation)();
|
|
10
|
+
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
11
|
+
const buildOptions = options;
|
|
12
|
+
devkit_1.logger.info(`NX Storybook builder starting ...`);
|
|
13
|
+
await runInstance(buildOptions);
|
|
14
|
+
devkit_1.logger.info(`NX Storybook builder finished ...`);
|
|
15
|
+
devkit_1.logger.info(`NX Storybook files available in ${buildOptions.outputDir}`);
|
|
16
|
+
return { success: true };
|
|
17
|
+
}
|
|
18
|
+
async function runInstance(options) {
|
|
19
|
+
const installedStorybookVersion = (0, utilities_1.getInstalledStorybookVersion)();
|
|
20
|
+
const hasCoreServerInStorybookPackage = (0, semver_1.gte)(installedStorybookVersion, '8.2.0');
|
|
21
|
+
const storybookCore = await (hasCoreServerInStorybookPackage
|
|
22
|
+
? import('storybook/internal/core-server')
|
|
23
|
+
: // This is needed for backwards compatibility - but we do not have the package installed in the nx repo
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
import('@storybook/core-server'));
|
|
26
|
+
const env = process.env.NODE_ENV ?? 'production';
|
|
27
|
+
process.env.NODE_ENV = env;
|
|
28
|
+
return storybookCore.build({
|
|
29
|
+
...options,
|
|
30
|
+
mode: 'static',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = storybookExecutor;
|
|
4
|
+
const utilities_1 = require("../../utils/utilities");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
7
|
+
async function* storybookExecutor(options, context) {
|
|
8
|
+
(0, deprecation_1.warnStorybookExecutorDeprecation)();
|
|
9
|
+
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
10
|
+
const buildOptions = options;
|
|
11
|
+
const result = await runInstance(buildOptions);
|
|
12
|
+
yield {
|
|
13
|
+
success: true,
|
|
14
|
+
info: {
|
|
15
|
+
port: result?.['port'],
|
|
16
|
+
baseUrl: `${options.https ? 'https' : 'http'}://${options.host ?? 'localhost'}:${result?.['port']}`,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
await new Promise(() => { });
|
|
20
|
+
}
|
|
21
|
+
async function runInstance(options) {
|
|
22
|
+
const installedStorybookVersion = (0, utilities_1.getInstalledStorybookVersion)();
|
|
23
|
+
const hasCoreServerInStorybookPackage = (0, semver_1.gte)(installedStorybookVersion, '8.2.0');
|
|
24
|
+
const storybookCore = await (hasCoreServerInStorybookPackage
|
|
25
|
+
? import('storybook/internal/core-server')
|
|
26
|
+
: // This is needed for backwards compatibility - but we do not have the package installed in the nx repo
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
import('@storybook/core-server'));
|
|
29
|
+
const env = process.env.NODE_ENV ?? 'development';
|
|
30
|
+
process.env.NODE_ENV = env;
|
|
31
|
+
return storybookCore.build({
|
|
32
|
+
...options,
|
|
33
|
+
mode: 'dev',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -3,4 +3,3 @@ import { StorybookConfigureSchema } from './schema';
|
|
|
3
3
|
export declare function configurationGenerator(tree: Tree, schema: StorybookConfigureSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export declare function configurationGeneratorInternal(tree: Tree, rawSchema: StorybookConfigureSchema): Promise<GeneratorCallback>;
|
|
5
5
|
export default configurationGenerator;
|
|
6
|
-
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -4,4 +4,3 @@ export type EnsureDependenciesOptions = {
|
|
|
4
4
|
uiFramework?: StorybookConfigureSchema['uiFramework'];
|
|
5
5
|
};
|
|
6
6
|
export declare function ensureDependencies(tree: Tree, options: EnsureDependenciesOptions): import("@nx/devkit").GeneratorCallback;
|
|
7
|
-
//# sourceMappingURL=ensure-dependencies.d.ts.map
|
|
@@ -32,4 +32,3 @@ export declare function findViteConfig(tree: Tree, projectRoot: string): {
|
|
|
32
32
|
export declare function findNextConfig(tree: Tree, projectRoot: string): string | undefined;
|
|
33
33
|
export declare function isUsingReactNative(projectName: string): boolean;
|
|
34
34
|
export declare function renameAndMoveOldTsConfig(projectRoot: string, pathToStorybookConfigFile: string, tree: Tree): void;
|
|
35
|
-
//# sourceMappingURL=util-functions.d.ts.map
|
|
@@ -42,12 +42,6 @@
|
|
|
42
42
|
"default": true,
|
|
43
43
|
"x-priority": "important"
|
|
44
44
|
},
|
|
45
|
-
"standaloneConfig": {
|
|
46
|
-
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
47
|
-
"type": "boolean",
|
|
48
|
-
"default": true,
|
|
49
|
-
"x-deprecated": "Nx only supports standaloneConfig"
|
|
50
|
-
},
|
|
51
45
|
"configureStaticServe": {
|
|
52
46
|
"type": "boolean",
|
|
53
47
|
"description": "Add a static-storybook to serve the static storybook built files.",
|
|
@@ -3,4 +3,3 @@ import { Schema } from './schema';
|
|
|
3
3
|
export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
4
|
export declare function initGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
5
5
|
export default initGenerator;
|
|
6
|
-
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export default function migrateCreateNodesV2ToCreateNodes(tree: Tree): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
|
|
5
|
+
* when they come from one of the given module specifiers. Only the named
|
|
6
|
+
* bindings are touched — the module specifier, the `import`/`export` keyword,
|
|
7
|
+
* any `type` modifier, and any default import are left untouched.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rewriteCreateNodesV2Imports(source: string, specifiers: ReadonlySet<string>): string;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateCreateNodesV2ToCreateNodes;
|
|
4
|
+
exports.rewriteCreateNodesV2Imports = rewriteCreateNodesV2Imports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const DEPRECATED_NAME = 'createNodesV2';
|
|
8
|
+
const CANONICAL_NAME = 'createNodes';
|
|
9
|
+
// Module specifiers from which `@nx/storybook` publicly exposes `createNodesV2`.
|
|
10
|
+
// A named import or re-export of `createNodesV2` from one of these is rewritten
|
|
11
|
+
// to the canonical `createNodes` export.
|
|
12
|
+
const TARGET_SPECIFIERS = new Set([
|
|
13
|
+
'@nx/storybook/plugin',
|
|
14
|
+
]);
|
|
15
|
+
let ts;
|
|
16
|
+
async function migrateCreateNodesV2ToCreateNodes(tree) {
|
|
17
|
+
let touchedCount = 0;
|
|
18
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
19
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const original = tree.read(filePath, 'utf-8');
|
|
23
|
+
if (!original || !original.includes(DEPRECATED_NAME)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const updated = rewriteCreateNodesV2Imports(original, TARGET_SPECIFIERS);
|
|
27
|
+
if (updated !== original) {
|
|
28
|
+
tree.write(filePath, updated);
|
|
29
|
+
touchedCount += 1;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (touchedCount > 0) {
|
|
33
|
+
devkit_1.logger.info(`Renamed \`${DEPRECATED_NAME}\` imports to \`${CANONICAL_NAME}\` in ${touchedCount} file(s).`);
|
|
34
|
+
}
|
|
35
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
|
|
39
|
+
* when they come from one of the given module specifiers. Only the named
|
|
40
|
+
* bindings are touched — the module specifier, the `import`/`export` keyword,
|
|
41
|
+
* any `type` modifier, and any default import are left untouched.
|
|
42
|
+
*/
|
|
43
|
+
function rewriteCreateNodesV2Imports(source, specifiers) {
|
|
44
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
45
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
46
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
47
|
+
const changes = [];
|
|
48
|
+
for (const stmt of sourceFile.statements) {
|
|
49
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
50
|
+
collectImportRewrite(sourceFile, stmt, specifiers, changes);
|
|
51
|
+
}
|
|
52
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
53
|
+
collectExportRewrite(sourceFile, stmt, specifiers, changes);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
57
|
+
}
|
|
58
|
+
function isTargetSpecifier(node, specifiers) {
|
|
59
|
+
return ts.isStringLiteral(node) && specifiers.has(node.text);
|
|
60
|
+
}
|
|
61
|
+
function collectImportRewrite(sourceFile, stmt, specifiers, changes) {
|
|
62
|
+
if (!isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const namedBindings = stmt.importClause?.namedBindings;
|
|
66
|
+
// Only `import { ... }` carries renameable named bindings. `import x`,
|
|
67
|
+
// `import * as ns`, and side-effect imports reference the module wholesale
|
|
68
|
+
// and keep working through the `createNodesV2` runtime alias, so we leave
|
|
69
|
+
// them be. A mixed `import def, { createNodesV2 }` still has its named
|
|
70
|
+
// bindings rewritten below — the default binding is untouched.
|
|
71
|
+
if (!namedBindings || !ts.isNamedImports(namedBindings)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
rewriteNamedBindings(sourceFile, namedBindings, changes);
|
|
75
|
+
}
|
|
76
|
+
function collectExportRewrite(sourceFile, stmt, specifiers, changes) {
|
|
77
|
+
if (!stmt.moduleSpecifier ||
|
|
78
|
+
!isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// `export { ... } from '...'` can be rewritten; `export * from '...'` has no
|
|
82
|
+
// named bindings to rename.
|
|
83
|
+
if (!stmt.exportClause || !ts.isNamedExports(stmt.exportClause)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
rewriteNamedBindings(sourceFile, stmt.exportClause, changes);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Re-renders the `{ ... }` of a named import/export, renaming any
|
|
90
|
+
* `createNodesV2` specifier to `createNodes`. If renaming would collide with a
|
|
91
|
+
* `createNodes` that is already present (e.g. `{ createNodes, createNodesV2 }`),
|
|
92
|
+
* the duplicate is dropped. Returns without recording a change when the binding
|
|
93
|
+
* list contains no `createNodesV2`.
|
|
94
|
+
*/
|
|
95
|
+
function rewriteNamedBindings(sourceFile, namedBindings, changes) {
|
|
96
|
+
const elements = namedBindings.elements;
|
|
97
|
+
const hasDeprecated = elements.some((el) => (el.propertyName ?? el.name).text === DEPRECATED_NAME);
|
|
98
|
+
if (!hasDeprecated) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const seen = new Set();
|
|
102
|
+
const rendered = [];
|
|
103
|
+
for (const el of elements) {
|
|
104
|
+
const text = renderSpecifier(el);
|
|
105
|
+
if (!seen.has(text)) {
|
|
106
|
+
seen.add(text);
|
|
107
|
+
rendered.push(text);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const start = namedBindings.getStart(sourceFile);
|
|
111
|
+
changes.push({
|
|
112
|
+
type: devkit_1.ChangeType.Delete,
|
|
113
|
+
start,
|
|
114
|
+
length: namedBindings.getEnd() - start,
|
|
115
|
+
}, {
|
|
116
|
+
type: devkit_1.ChangeType.Insert,
|
|
117
|
+
index: start,
|
|
118
|
+
text: `{ ${rendered.join(', ')} }`,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function renderSpecifier(el) {
|
|
122
|
+
const typePrefix = el.isTypeOnly ? 'type ' : '';
|
|
123
|
+
const rename = (name) => name === DEPRECATED_NAME ? CANONICAL_NAME : name;
|
|
124
|
+
// `{ name }` — no alias, so the local binding follows the rename.
|
|
125
|
+
if (!el.propertyName) {
|
|
126
|
+
return `${typePrefix}${rename(el.name.text)}`;
|
|
127
|
+
}
|
|
128
|
+
// `{ propertyName as name }` — only the imported (left) side is renamed; the
|
|
129
|
+
// local alias is preserved. A now-redundant alias such as
|
|
130
|
+
// `createNodesV2 as createNodes` collapses to `createNodes`.
|
|
131
|
+
const canonicalImported = rename(el.propertyName.text);
|
|
132
|
+
const localName = el.name.text;
|
|
133
|
+
return canonicalImported === localName
|
|
134
|
+
? `${typePrefix}${localName}`
|
|
135
|
+
: `${typePrefix}${canonicalImported} as ${localName}`;
|
|
136
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#### Rename `createNodesV2` imports to `createNodes`
|
|
2
|
+
|
|
3
|
+
`@nx/storybook` renamed its primary inferred-plugin export from `createNodesV2` to `createNodes`. The `createNodesV2` name is preserved as a deprecated alias for now, but new code should use `createNodes`.
|
|
4
|
+
|
|
5
|
+
This migration scans every `.ts`, `.tsx`, `.cts`, and `.mts` file in your workspace and rewrites named imports and re-exports of `createNodesV2` from `@nx/storybook/plugin` to `createNodes`.
|
|
6
|
+
|
|
7
|
+
#### Sample Code Changes
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createNodesV2 } from '@nx/storybook/plugin';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
##### After
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createNodes } from '@nx/storybook/plugin';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Aliases are preserved (`createNodesV2 as cn` becomes `createNodes as cn`), and if a file already imports both names (`{ createNodes, createNodesV2 }`) the redundant binding is dropped.
|
|
22
|
+
|
|
23
|
+
#### What is not rewritten
|
|
24
|
+
|
|
25
|
+
Only static `import`/`export` named bindings from `@nx/storybook/plugin` are rewritten. Namespace imports, dynamic `import(...)`, `require(...)` destructuring, and property access such as `plugin.createNodesV2` are left untouched — they keep working through the `createNodesV2` runtime alias. Update those by hand if you want to drop the deprecated name everywhere.
|
|
@@ -13,4 +13,3 @@ export interface StorybookPluginOptions {
|
|
|
13
13
|
export declare const createDependencies: CreateDependencies;
|
|
14
14
|
export declare const createNodes: CreateNodes<StorybookPluginOptions>;
|
|
15
15
|
export declare const createNodesV2: CreateNodes<StorybookPluginOptions>;
|
|
16
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -3,4 +3,3 @@ export declare const STORYBOOK_BUILD_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/st
|
|
|
3
3
|
export declare function warnStorybookExecutorDeprecation(): void;
|
|
4
4
|
export declare function warnStorybookBuildExecutorDeprecation(): void;
|
|
5
5
|
export declare function warnStorybookExecutorGenerating(): void;
|
|
6
|
-
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
export type UiFramework = '@storybook/angular' | '@storybook/html-webpack5' | '@storybook/nextjs' | '@storybook/preact-webpack5' | '@storybook/react-webpack5' | '@storybook/react-vite' | '@storybook/server-webpack5' | '@storybook/svelte-webpack5' | '@storybook/svelte-vite' | '@storybook/sveltekit' | '@storybook/vue-webpack5' | '@storybook/vue-vite' | '@storybook/vue3-webpack5' | '@storybook/vue3-vite' | '@storybook/web-components-webpack5' | '@storybook/web-components-vite';
|
|
2
|
-
//# sourceMappingURL=models.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
export declare function createTestUILibNoNgDevkit(appTree: Tree, libName: string): Promise<Tree>;
|
|
3
3
|
export declare function deleteNewConfigurationAndCreateNew(appTree: Tree, projectStorybookRoot: string): Tree;
|
|
4
|
-
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -38,4 +38,3 @@ export declare function findStorybookAndBuildTargetsAndCompiler(targets: {
|
|
|
38
38
|
};
|
|
39
39
|
export declare function isTheFileAStory(tree: Tree, path: string): boolean;
|
|
40
40
|
export declare function getTsSourceFile(host: Tree, path: string): ts.SourceFile;
|
|
41
|
-
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -15,4 +15,3 @@ export declare function versions(tree: Tree): StorybookVersions;
|
|
|
15
15
|
export declare function storybookMajorVersion(tree?: Tree): number | undefined;
|
|
16
16
|
export declare function getInstalledStorybookVersion(tree?: Tree): string | undefined;
|
|
17
17
|
export {};
|
|
18
|
-
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -7,7 +7,7 @@ exports.getInstalledStorybookVersion = getInstalledStorybookVersion;
|
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const semver_1 = require("semver");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
-
exports.nxVersion = require('
|
|
10
|
+
exports.nxVersion = require((0, path_1.join)('@nx/storybook', 'package.json')).version;
|
|
11
11
|
exports.litVersion = '^2.6.1';
|
|
12
12
|
exports.tsNodeVersion = '10.9.1';
|
|
13
13
|
exports.tsLibVersion = '^2.3.0';
|
package/executors.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"executors": {
|
|
3
3
|
"storybook": {
|
|
4
|
-
"implementation": "./src/executors/storybook/storybook.impl",
|
|
5
|
-
"schema": "./src/executors/storybook/schema.json",
|
|
4
|
+
"implementation": "./dist/src/executors/storybook/storybook.impl",
|
|
5
|
+
"schema": "./dist/src/executors/storybook/schema.json",
|
|
6
6
|
"description": "Serve Storybook."
|
|
7
7
|
},
|
|
8
8
|
"build": {
|
|
9
|
-
"implementation": "./src/executors/build-storybook/build-storybook.impl",
|
|
10
|
-
"schema": "./src/executors/build-storybook/schema.json",
|
|
9
|
+
"implementation": "./dist/src/executors/build-storybook/build-storybook.impl",
|
|
10
|
+
"schema": "./dist/src/executors/build-storybook/schema.json",
|
|
11
11
|
"description": "Build Storybook."
|
|
12
12
|
}
|
|
13
13
|
}
|
package/generators.json
CHANGED
|
@@ -3,38 +3,38 @@
|
|
|
3
3
|
"version": "0.1",
|
|
4
4
|
"generators": {
|
|
5
5
|
"init": {
|
|
6
|
-
"factory": "./src/generators/init/init#initGeneratorInternal",
|
|
7
|
-
"schema": "./src/generators/init/schema.json",
|
|
6
|
+
"factory": "./dist/src/generators/init/init#initGeneratorInternal",
|
|
7
|
+
"schema": "./dist/src/generators/init/schema.json",
|
|
8
8
|
"description": "Add Storybook configuration to the workspace.",
|
|
9
9
|
"aliases": ["ng-add"],
|
|
10
10
|
"hidden": true
|
|
11
11
|
},
|
|
12
12
|
"configuration": {
|
|
13
|
-
"factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
|
|
14
|
-
"schema": "./src/generators/configuration/schema.json",
|
|
13
|
+
"factory": "./dist/src/generators/configuration/configuration#configurationGeneratorInternal",
|
|
14
|
+
"schema": "./dist/src/generators/configuration/schema.json",
|
|
15
15
|
"description": "Add Storybook configuration to a UI library or an application.",
|
|
16
16
|
"hidden": false
|
|
17
17
|
},
|
|
18
18
|
"convert-to-inferred": {
|
|
19
|
-
"factory": "./src/generators/convert-to-inferred/convert-to-inferred",
|
|
20
|
-
"schema": "./src/generators/convert-to-inferred/schema.json",
|
|
19
|
+
"factory": "./dist/src/generators/convert-to-inferred/convert-to-inferred",
|
|
20
|
+
"schema": "./dist/src/generators/convert-to-inferred/schema.json",
|
|
21
21
|
"description": "Convert existing Storybook project(s) using `@nx/storybook:*` executors to use `@nx/storybook/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target."
|
|
22
22
|
},
|
|
23
23
|
"migrate-8": {
|
|
24
|
-
"factory": "./src/generators/migrate-8/migrate-8",
|
|
25
|
-
"schema": "./src/generators/migrate-8/schema.json",
|
|
24
|
+
"factory": "./dist/src/generators/migrate-8/migrate-8",
|
|
25
|
+
"schema": "./dist/src/generators/migrate-8/schema.json",
|
|
26
26
|
"description": "Migrate to Storybook version 8.",
|
|
27
27
|
"hidden": false
|
|
28
28
|
},
|
|
29
29
|
"migrate-9": {
|
|
30
|
-
"factory": "./src/generators/migrate-9/migrate-9",
|
|
31
|
-
"schema": "./src/generators/migrate-9/schema.json",
|
|
30
|
+
"factory": "./dist/src/generators/migrate-9/migrate-9",
|
|
31
|
+
"schema": "./dist/src/generators/migrate-9/schema.json",
|
|
32
32
|
"description": "Migrate to Storybook version 9.",
|
|
33
33
|
"hidden": false
|
|
34
34
|
},
|
|
35
35
|
"migrate-10": {
|
|
36
|
-
"factory": "./src/generators/migrate-10/migrate-10",
|
|
37
|
-
"schema": "./src/generators/migrate-10/schema.json",
|
|
36
|
+
"factory": "./dist/src/generators/migrate-10/migrate-10",
|
|
37
|
+
"schema": "./dist/src/generators/migrate-10/schema.json",
|
|
38
38
|
"description": "Migrate to Storybook version 10.",
|
|
39
39
|
"hidden": false
|
|
40
40
|
}
|
package/migrations.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"storybook": ">=9.0.0 <10.0.0"
|
|
8
8
|
},
|
|
9
9
|
"description": "Update workspace to use Storybook v9",
|
|
10
|
-
"implementation": "./src/migrations/update-21-1-0/update-sb-9"
|
|
10
|
+
"implementation": "./dist/src/migrations/update-21-1-0/update-sb-9"
|
|
11
11
|
},
|
|
12
12
|
"update-21-2-0-remove-addon-dependencies": {
|
|
13
13
|
"cli": "nx",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"storybook": ">=9.0.0 <10.0.0"
|
|
17
17
|
},
|
|
18
18
|
"description": "Remove deprecated Storybook addon dependencies",
|
|
19
|
-
"implementation": "./src/migrations/update-21-2-0/remove-addon-dependencies"
|
|
19
|
+
"implementation": "./dist/src/migrations/update-21-2-0/remove-addon-dependencies"
|
|
20
20
|
},
|
|
21
21
|
"update-22-1-0-migrate-storybook-v10": {
|
|
22
22
|
"cli": "nx",
|
|
@@ -25,8 +25,14 @@
|
|
|
25
25
|
"storybook": ">=10.0.0"
|
|
26
26
|
},
|
|
27
27
|
"description": "Update workspace to use Storybook v10",
|
|
28
|
-
"implementation": "./src/migrations/update-22-1-0/migrate-to-storybook-10",
|
|
29
|
-
"prompt": "./src/generators/migrate-10/files/ai-instructions-for-cjs-esm.md"
|
|
28
|
+
"implementation": "./dist/src/migrations/update-22-1-0/migrate-to-storybook-10",
|
|
29
|
+
"prompt": "./dist/src/generators/migrate-10/files/ai-instructions-for-cjs-esm.md"
|
|
30
|
+
},
|
|
31
|
+
"update-23-0-0-migrate-create-nodes-v2-import": {
|
|
32
|
+
"version": "23.0.0-beta.24",
|
|
33
|
+
"description": "Rename imports of `createNodesV2` from `@nx/storybook/plugin` to the canonical `createNodes` export.",
|
|
34
|
+
"implementation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes",
|
|
35
|
+
"documentation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md"
|
|
30
36
|
}
|
|
31
37
|
},
|
|
32
38
|
"packageJsonUpdates": {
|