@nx/storybook 23.0.0-beta.2 → 23.0.0-beta.20
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/migrations.json +2 -1
- package/package.json +8 -8
- package/src/executors/build-storybook/build-storybook.impl.d.ts.map +1 -1
- package/src/executors/build-storybook/build-storybook.impl.js +2 -0
- package/src/executors/build-storybook/schema.json +1 -0
- package/src/executors/storybook/schema.json +1 -0
- package/src/executors/storybook/storybook.impl.d.ts.map +1 -1
- package/src/executors/storybook/storybook.impl.js +2 -0
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +4 -2
- package/src/generators/configuration/lib/util-functions.d.ts.map +1 -1
- package/src/generators/configuration/lib/util-functions.js +39 -35
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +4 -5
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts +1 -1
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.js +5 -5
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts +1 -1
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.js +3 -3
- package/src/generators/convert-to-inferred/lib/utils.d.ts +1 -1
- package/src/generators/convert-to-inferred/lib/utils.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/lib/utils.js +2 -2
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +4 -6
- package/src/generators/migrate-10/migrate-10.d.ts.map +1 -1
- package/src/generators/migrate-10/migrate-10.js +3 -0
- package/src/generators/migrate-10/schema.d.ts +1 -0
- package/src/generators/migrate-10/schema.json +5 -0
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts +1 -1
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts.map +1 -1
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.js +1 -4
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +61 -27
- package/src/utils/deprecation.d.ts +6 -0
- package/src/utils/deprecation.d.ts.map +1 -0
- package/src/utils/deprecation.js +21 -0
package/migrations.json
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"storybook": ">=10.0.0"
|
|
20
20
|
},
|
|
21
21
|
"description": "Update workspace to use Storybook v10",
|
|
22
|
-
"implementation": "./src/migrations/update-22-1-0/migrate-to-storybook-10"
|
|
22
|
+
"implementation": "./src/migrations/update-22-1-0/migrate-to-storybook-10",
|
|
23
|
+
"prompt": "./src/generators/migrate-10/files/ai-instructions-for-cjs-esm.md"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
26
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"migrations": "./migrations.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "23.0.0-beta.
|
|
38
|
-
"@phenomnomnominal/tsquery": "~6.
|
|
37
|
+
"@nx/devkit": "23.0.0-beta.20",
|
|
38
|
+
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
39
39
|
"semver": "^7.6.3",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
|
-
"@nx/cypress": "23.0.0-beta.
|
|
42
|
-
"@nx/js": "23.0.0-beta.
|
|
43
|
-
"@nx/eslint": "23.0.0-beta.
|
|
41
|
+
"@nx/cypress": "23.0.0-beta.20",
|
|
42
|
+
"@nx/js": "23.0.0-beta.20",
|
|
43
|
+
"@nx/eslint": "23.0.0-beta.20"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"nx": "23.0.0-beta.
|
|
46
|
+
"nx": "23.0.0-beta.20",
|
|
47
47
|
"storybook": "9.0.6"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@nx/web": "23.0.0-beta.
|
|
50
|
+
"@nx/web": "23.0.0-beta.20",
|
|
51
51
|
"storybook": ">=7.0.0 <11.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/build-storybook/build-storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"build-storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/build-storybook/build-storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAU3D,wBAA8B,sBAAsB,CAClD,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe;;GAgBzB"}
|
|
@@ -37,7 +37,9 @@ exports.default = buildStorybookExecutor;
|
|
|
37
37
|
const devkit_1 = require("@nx/devkit");
|
|
38
38
|
const utilities_1 = require("../../utils/utilities");
|
|
39
39
|
const semver_1 = require("semver");
|
|
40
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
40
41
|
async function buildStorybookExecutor(options, context) {
|
|
42
|
+
(0, deprecation_1.warnStorybookBuildExecutorDeprecation)();
|
|
41
43
|
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
42
44
|
const storybookMajor = (0, utilities_1.storybookMajorVersion)();
|
|
43
45
|
if (storybookMajor > 0 && storybookMajor <= 7) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"cli": "nx",
|
|
6
6
|
"description": "Build storybook in production mode.",
|
|
7
7
|
"type": "object",
|
|
8
|
+
"x-deprecated": "The `@nx/storybook:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` to migrate to the `@nx/storybook/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
|
|
8
9
|
"presets": [
|
|
9
10
|
{
|
|
10
11
|
"name": "Default minimum setup",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"cli": "nx",
|
|
7
7
|
"description": "Serve up Storybook in development mode.",
|
|
8
8
|
"type": "object",
|
|
9
|
+
"x-deprecated": "The `@nx/storybook:storybook` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` to migrate to the `@nx/storybook/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
|
|
9
10
|
"presets": [
|
|
10
11
|
{
|
|
11
12
|
"name": "Default minimum setup",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAOrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"storybook.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAOrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAI3D,wBAA+B,iBAAiB,CAC9C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC,CAqBD"}
|
|
@@ -36,7 +36,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.default = storybookExecutor;
|
|
37
37
|
const utilities_1 = require("../../utils/utilities");
|
|
38
38
|
const semver_1 = require("semver");
|
|
39
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
39
40
|
async function* storybookExecutor(options, context) {
|
|
41
|
+
(0, deprecation_1.warnStorybookExecutorDeprecation)();
|
|
40
42
|
const storybookMajor = (0, utilities_1.storybookMajorVersion)();
|
|
41
43
|
if (storybookMajor > 0 && storybookMajor <= 7) {
|
|
42
44
|
throw (0, utilities_1.pleaseUpgrade)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAwCpD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,wBAAwB,8BAGjC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,wBAAwB,8BA6KpC;AAwBD,eAAe,sBAAsB,CAAC"}
|
|
@@ -5,12 +5,13 @@ exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
7
|
const init_1 = require("../init/init");
|
|
8
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
8
9
|
const util_functions_1 = require("./lib/util-functions");
|
|
9
10
|
const utilities_1 = require("../../utils/utilities");
|
|
10
11
|
const versions_1 = require("../../utils/versions");
|
|
11
12
|
const ensure_dependencies_1 = require("./lib/ensure-dependencies");
|
|
12
13
|
const edit_root_tsconfig_1 = require("./lib/edit-root-tsconfig");
|
|
13
|
-
const
|
|
14
|
+
const internal_1 = require("@nx/js/internal");
|
|
14
15
|
function configurationGenerator(tree, schema) {
|
|
15
16
|
return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
16
17
|
}
|
|
@@ -62,7 +63,7 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
62
63
|
? p === '@nx/storybook/plugin'
|
|
63
64
|
: p.plugin === '@nx/storybook/plugin');
|
|
64
65
|
const mainDir = !!nextConfigFilePath &&
|
|
65
|
-
(0,
|
|
66
|
+
(0, internal_1.getProjectType)(tree, root, projectType) === 'application'
|
|
66
67
|
? 'components'
|
|
67
68
|
: 'src';
|
|
68
69
|
const usesVite = !!viteConfigFilePath || schema.uiFramework?.endsWith('-vite');
|
|
@@ -82,6 +83,7 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
82
83
|
}
|
|
83
84
|
let devDeps = {};
|
|
84
85
|
if (!hasPlugin || schema.addExplicitTargets) {
|
|
86
|
+
(0, deprecation_1.warnStorybookExecutorGenerating)();
|
|
85
87
|
if (schema.uiFramework === '@storybook/angular') {
|
|
86
88
|
(0, util_functions_1.addAngularStorybookTarget)(tree, schema.project, schema.interactionTests);
|
|
87
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util-functions.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,IAAI,EAML,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"util-functions.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/util-functions.ts"],"names":[],"mappings":"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"}
|
|
@@ -25,9 +25,9 @@ const devkit_1 = require("@nx/devkit");
|
|
|
25
25
|
const path_1 = require("path");
|
|
26
26
|
const utilities_1 = require("../../../utils/utilities");
|
|
27
27
|
const versions_1 = require("../../../utils/versions");
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
28
|
+
const internal_1 = require("@nx/eslint/internal");
|
|
29
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
30
|
+
const internal_3 = require("@nx/js/internal");
|
|
31
31
|
const DEFAULT_PORT = 4400;
|
|
32
32
|
function addStorybookTarget(tree, projectName, uiFramework, interactionTests) {
|
|
33
33
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
@@ -126,7 +126,7 @@ async function addStaticTarget(tree, opts) {
|
|
|
126
126
|
function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
|
|
127
127
|
const storybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
|
|
128
128
|
const offset = (0, devkit_1.offsetFromRoot)(projectRoot);
|
|
129
|
-
const useTsSolution = (0,
|
|
129
|
+
const useTsSolution = (0, internal_3.isUsingTsSolutionSetup)(tree);
|
|
130
130
|
// First let's check if old configuration file exists
|
|
131
131
|
// If it exists, let's rename it and move it to the new location
|
|
132
132
|
const oldStorybookTsConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, '.storybook/tsconfig.json');
|
|
@@ -175,7 +175,7 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
|
|
|
175
175
|
],
|
|
176
176
|
};
|
|
177
177
|
if (useTsSolution) {
|
|
178
|
-
const runtimeConfig = (0,
|
|
178
|
+
const runtimeConfig = (0, internal_3.findRuntimeTsConfigName)(projectRoot, tree);
|
|
179
179
|
if (runtimeConfig) {
|
|
180
180
|
storybookTsConfig.references ??= [];
|
|
181
181
|
storybookTsConfig.references.push({
|
|
@@ -287,14 +287,14 @@ function configureTsSolutionConfig(tree, schema) {
|
|
|
287
287
|
function updateLintConfig(tree, schema) {
|
|
288
288
|
const { project: projectName } = schema;
|
|
289
289
|
const { root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
290
|
-
const eslintFile = (0,
|
|
290
|
+
const eslintFile = (0, internal_1.findEslintFile)(tree, root);
|
|
291
291
|
if (!eslintFile) {
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
294
|
const parserConfigPath = (0, path_1.join)(root, schema.uiFramework === '@storybook/angular'
|
|
295
295
|
? '.storybook/tsconfig.json'
|
|
296
296
|
: 'tsconfig.storybook.json');
|
|
297
|
-
if ((0,
|
|
297
|
+
if ((0, internal_1.useFlatConfig)(tree)) {
|
|
298
298
|
let config = tree.read(eslintFile, 'utf-8');
|
|
299
299
|
const projectRegex = RegExp(/project:\s?\[?['"](.*)['"]\]?/g);
|
|
300
300
|
let match;
|
|
@@ -372,34 +372,38 @@ function addStorybookToNamedInputs(tree) {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
function addStorybookToTargetDefaults(tree, setCache = true) {
|
|
375
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
376
|
-
nxJson.targetDefaults
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
//
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
375
|
+
const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
|
|
376
|
+
const existing = (0, internal_2.normalizeTargetDefaults)(nxJson.targetDefaults).find((e) => e.target === 'build-storybook' &&
|
|
377
|
+
e.executor === undefined &&
|
|
378
|
+
e.projects === undefined &&
|
|
379
|
+
e.plugin === undefined);
|
|
380
|
+
const inputs = existing?.inputs
|
|
381
|
+
? [...existing.inputs]
|
|
382
|
+
: [
|
|
383
|
+
'default',
|
|
384
|
+
nxJson.namedInputs && 'production' in nxJson.namedInputs
|
|
385
|
+
? '^production'
|
|
386
|
+
: '^default',
|
|
387
|
+
];
|
|
388
|
+
if (!inputs.includes('{projectRoot}/.storybook/**/*')) {
|
|
389
|
+
inputs.push('{projectRoot}/.storybook/**/*');
|
|
390
|
+
}
|
|
391
|
+
// Drop the negation glob so Storybook rebuilds when .storybook changes.
|
|
392
|
+
const negatedIndex = inputs.indexOf('!{projectRoot}/.storybook/**/*');
|
|
393
|
+
if (negatedIndex !== -1)
|
|
394
|
+
inputs.splice(negatedIndex, 1);
|
|
395
|
+
if (!inputs.includes('{projectRoot}/tsconfig.storybook.json')) {
|
|
396
|
+
inputs.push('{projectRoot}/tsconfig.storybook.json');
|
|
397
|
+
}
|
|
398
|
+
(0, internal_2.upsertTargetDefault)(tree, nxJson, {
|
|
399
|
+
target: 'build-storybook',
|
|
400
|
+
...(setCache && existing?.cache === undefined ? { cache: true } : {}),
|
|
401
|
+
inputs,
|
|
402
|
+
});
|
|
399
403
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
400
404
|
}
|
|
401
405
|
function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfiguration, root, projectType, projectIsRootProjectInStandaloneWorkspace, interactionTests, mainDir, isNextJs, usesSwc, usesVite, viteConfigFilePath, hasPlugin, viteConfigFileName, usesReactNative) {
|
|
402
|
-
let projectDirectory = (0,
|
|
406
|
+
let projectDirectory = (0, internal_3.getProjectType)(tree, root, projectType) ===
|
|
403
407
|
'application'
|
|
404
408
|
? isNextJs
|
|
405
409
|
? 'components'
|
|
@@ -427,7 +431,7 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
427
431
|
interactionTests,
|
|
428
432
|
mainDir,
|
|
429
433
|
isNextJs: isNextJs &&
|
|
430
|
-
(0,
|
|
434
|
+
(0, internal_3.getProjectType)(tree, root, projectType) ===
|
|
431
435
|
'application',
|
|
432
436
|
usesSwc,
|
|
433
437
|
usesVite,
|
|
@@ -454,7 +458,7 @@ function getTsConfigPath(tree, projectName, path) {
|
|
|
454
458
|
const { root, projectType } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
455
459
|
return (0, path_1.join)(root, path?.length > 0
|
|
456
460
|
? path
|
|
457
|
-
: (0,
|
|
461
|
+
: (0, internal_3.getProjectType)(tree, root, projectType) === 'application'
|
|
458
462
|
? 'tsconfig.app.json'
|
|
459
463
|
: 'tsconfig.lib.json');
|
|
460
464
|
}
|
|
@@ -564,7 +568,7 @@ function renameAndMoveOldTsConfig(projectRoot, pathToStorybookConfigFile, tree)
|
|
|
564
568
|
return json;
|
|
565
569
|
});
|
|
566
570
|
}
|
|
567
|
-
const eslintFile = (0,
|
|
571
|
+
const eslintFile = (0, internal_1.findEslintFile)(tree, projectRoot);
|
|
568
572
|
if (eslintFile) {
|
|
569
573
|
const fileName = (0, devkit_1.joinPathFragments)(projectRoot, eslintFile);
|
|
570
574
|
const config = tree.read(fileName, 'utf-8');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAMpB,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mDAkDlE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertToInferred = convertToInferred;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const aggregate_log_util_1 = require("@nx/devkit/src/generators/plugin-migrations/aggregate-log-util");
|
|
6
|
-
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
|
7
6
|
const build_post_target_transformer_1 = require("./lib/build-post-target-transformer");
|
|
8
7
|
const serve_post_target_transformer_1 = require("./lib/serve-post-target-transformer");
|
|
9
8
|
const plugin_1 = require("../../plugins/plugin");
|
|
10
9
|
const versions_1 = require("../../utils/versions");
|
|
11
10
|
async function convertToInferred(tree, options) {
|
|
12
11
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
13
|
-
const migrationLogs = new
|
|
14
|
-
const migratedProjects = await (0,
|
|
12
|
+
const migrationLogs = new internal_1.AggregatedLog();
|
|
13
|
+
const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/storybook/plugin', plugin_1.createNodesV2, {
|
|
15
14
|
buildStorybookTargetName: 'build-storybook',
|
|
16
15
|
serveStorybookTargetName: 'storybook',
|
|
17
16
|
staticStorybookTargetName: 'static-storybook',
|
|
@@ -33,7 +32,7 @@ async function convertToInferred(tree, options) {
|
|
|
33
32
|
},
|
|
34
33
|
], options.project);
|
|
35
34
|
if (migratedProjects.size === 0) {
|
|
36
|
-
throw new
|
|
35
|
+
throw new internal_1.NoTargetsToMigrateError();
|
|
37
36
|
}
|
|
38
37
|
if (!options.skipFormat) {
|
|
39
38
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
-
import { AggregatedLog } from '@nx/devkit/
|
|
2
|
+
import { AggregatedLog } from '@nx/devkit/internal';
|
|
3
3
|
export declare function buildPostTargetTransformer(migrationLogs: AggregatedLog): (target: TargetConfiguration, tree: Tree, projectDetails: {
|
|
4
4
|
projectName: string;
|
|
5
5
|
root: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-post-target-transformer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/convert-to-inferred/lib/build-post-target-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"build-post-target-transformer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/convert-to-inferred/lib/build-post-target-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAGL,aAAa,EACd,MAAM,qBAAqB,CAAC;AAY7B,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,aAAa,IAEnE,QAAQ,mBAAmB,EAC3B,MAAM,IAAI,EACV,gBAAgB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACrD,6BAA6B,mBAAmB,8BAgHnD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildPostTargetTransformer = buildPostTargetTransformer;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const utils_2 = require("./utils");
|
|
@@ -28,7 +28,7 @@ function buildPostTargetTransformer(migrationLogs) {
|
|
|
28
28
|
const configuration = target.configurations[configurationName];
|
|
29
29
|
if (configuration.configDir &&
|
|
30
30
|
configuration.configDir !==
|
|
31
|
-
(0,
|
|
31
|
+
(0, internal_1.toProjectRelativePath)(defaultConfigDir, projectDetails.root)) {
|
|
32
32
|
const configFilePath = (0, utils_1.getConfigFilePath)(tree, (0, devkit_1.joinPathFragments)(projectDetails.root, configuration.configDir));
|
|
33
33
|
(0, utils_1.addConfigValuesToConfigFile)(tree, configFilePath, configValues);
|
|
34
34
|
(0, utils_1.ensureViteConfigPathIsRelative)(tree, configFilePath, projectDetails.projectName, projectDetails.root, '@nx/storybook:build', migrationLogs);
|
|
@@ -50,7 +50,7 @@ function buildPostTargetTransformer(migrationLogs) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
if (target.outputs) {
|
|
53
|
-
(0,
|
|
53
|
+
(0, internal_1.processTargetOutputs)(target, [{ newName: 'output-dir', oldName: 'outputDir' }], inferredTargetConfiguration, {
|
|
54
54
|
projectName: projectDetails.projectName,
|
|
55
55
|
projectRoot: projectDetails.root,
|
|
56
56
|
});
|
|
@@ -66,10 +66,10 @@ function handlePropertiesFromTargetOptions(tree, options, defaultConfigDir, proj
|
|
|
66
66
|
if (options.configDir !== defaultConfigDir) {
|
|
67
67
|
configDir = options.configDir;
|
|
68
68
|
}
|
|
69
|
-
options.configDir = (0,
|
|
69
|
+
options.configDir = (0, internal_1.toProjectRelativePath)(options.configDir, projectRoot);
|
|
70
70
|
}
|
|
71
71
|
if (options.outputDir) {
|
|
72
|
-
options.outputDir = (0,
|
|
72
|
+
options.outputDir = (0, internal_1.toProjectRelativePath)(options.outputDir, projectRoot);
|
|
73
73
|
}
|
|
74
74
|
if ('styles' in options) {
|
|
75
75
|
delete options.styles;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
-
import { AggregatedLog } from '@nx/devkit/
|
|
2
|
+
import { AggregatedLog } from '@nx/devkit/internal';
|
|
3
3
|
export declare function servePostTargetTransformer(migrationLogs: AggregatedLog): (target: TargetConfiguration, tree: Tree, projectDetails: {
|
|
4
4
|
projectName: string;
|
|
5
5
|
root: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-post-target-transformer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/convert-to-inferred/lib/serve-post-target-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"serve-post-target-transformer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/convert-to-inferred/lib/serve-post-target-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAyB,MAAM,qBAAqB,CAAC;AAO3E,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,aAAa,IAEnE,QAAQ,mBAAmB,EAC3B,MAAM,IAAI,EACV,gBAAgB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACrD,6BAA6B,mBAAmB,8BAyEnD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.servePostTargetTransformer = servePostTargetTransformer;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
function servePostTargetTransformer(migrationLogs) {
|
|
8
8
|
return (target, tree, projectDetails, inferredTargetConfiguration) => {
|
|
@@ -39,10 +39,10 @@ function servePostTargetTransformer(migrationLogs) {
|
|
|
39
39
|
}
|
|
40
40
|
function handlePropertiesFromTargetOptions(tree, options, projectName, projectRoot, migrationLogs) {
|
|
41
41
|
if ('configDir' in options) {
|
|
42
|
-
options.configDir = (0,
|
|
42
|
+
options.configDir = (0, internal_1.toProjectRelativePath)(options.configDir, projectRoot);
|
|
43
43
|
}
|
|
44
44
|
if (options.outputDir) {
|
|
45
|
-
options.outputDir = (0,
|
|
45
|
+
options.outputDir = (0, internal_1.toProjectRelativePath)(options.outputDir, projectRoot);
|
|
46
46
|
}
|
|
47
47
|
if ('uiFramework' in options) {
|
|
48
48
|
delete options.uiFramework;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
import { AggregatedLog } from '@nx/devkit/
|
|
2
|
+
import { AggregatedLog } from '@nx/devkit/internal';
|
|
3
3
|
export declare function getConfigFilePath(tree: Tree, configDir: string): string;
|
|
4
4
|
export declare function addConfigValuesToConfigFile(tree: Tree, configFile: string, configValues: Record<string, Record<string, unknown>>): void;
|
|
5
5
|
export declare const STORYBOOK_PROP_MAPPINGS: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/convert-to-inferred/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/convert-to-inferred/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAyB,MAAM,qBAAqB,CAAC;AAI3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAS9D;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAgCtD;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCnC,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,QAmE7B;AAED,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAGf;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM;;;EAKzE"}
|
|
@@ -8,7 +8,7 @@ exports.getInstalledPackageVersion = getInstalledPackageVersion;
|
|
|
8
8
|
exports.getInstalledPackageVersionInfo = getInstalledPackageVersionInfo;
|
|
9
9
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
10
10
|
const devkit_1 = require("@nx/devkit");
|
|
11
|
-
const
|
|
11
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
const semver_1 = require("semver");
|
|
13
13
|
function getConfigFilePath(tree, configDir) {
|
|
14
14
|
return [
|
|
@@ -122,7 +122,7 @@ function ensureViteConfigPathIsRelative(tree, configPath, projectName, projectRo
|
|
|
122
122
|
if (pathToViteConfig.match(/^(\.\.\/|\.\/)/)) {
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
const relativePathToViteConfig = (0,
|
|
125
|
+
const relativePathToViteConfig = (0, internal_1.toProjectRelativePath)(pathToViteConfig, projectRoot);
|
|
126
126
|
tree.write(configPath, `${configFileContents.slice(0, viteConfigPathNode.getStart() + 1)}${relativePathToViteConfig}${configFileContents.slice(viteConfigPathNode.getEnd() - 1)}`);
|
|
127
127
|
}
|
|
128
128
|
function getInstalledPackageVersion(tree, pkgName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA2DlC,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAEvD;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BAiErE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initGenerator = initGenerator;
|
|
4
4
|
exports.initGeneratorInternal = initGeneratorInternal;
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
7
|
const plugin_1 = require("../../plugins/plugin");
|
|
8
8
|
const utilities_1 = require("../../utils/utilities");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
@@ -18,14 +18,12 @@ function checkDependenciesInstalled(host, schema) {
|
|
|
18
18
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
19
19
|
}
|
|
20
20
|
function addCacheableOperation(tree) {
|
|
21
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
21
|
+
const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
|
|
22
22
|
const cacheableOperations = nxJson.tasksRunnerOptions?.default?.options?.cacheableOperations;
|
|
23
23
|
if (cacheableOperations && !cacheableOperations.includes('build-storybook')) {
|
|
24
24
|
nxJson.tasksRunnerOptions.default.options.cacheableOperations.push('build-storybook');
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
nxJson.targetDefaults['build-storybook'] ??= {};
|
|
28
|
-
nxJson.targetDefaults['build-storybook'].cache = true;
|
|
26
|
+
(0, internal_1.upsertTargetDefault)(tree, nxJson, { target: 'build-storybook', cache: true });
|
|
29
27
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
30
28
|
}
|
|
31
29
|
function moveToDevDependencies(tree) {
|
|
@@ -52,7 +50,7 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
52
50
|
nxJson.useInferencePlugins !== false;
|
|
53
51
|
schema.addPlugin ??= addPluginDefault;
|
|
54
52
|
if (schema.addPlugin) {
|
|
55
|
-
await (0,
|
|
53
|
+
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/storybook/plugin', plugin_1.createNodesV2, {
|
|
56
54
|
serveStorybookTargetName: [
|
|
57
55
|
'storybook',
|
|
58
56
|
'serve:storybook',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/migrate-10/migrate-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,IAAI,EAAE,MAAM,YAAY,CAAC;AAIjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"migrate-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/migrate-10/migrate-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,IAAI,EAAE,MAAM,YAAY,CAAC;AAIjE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAmClE;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -19,6 +19,9 @@ async function migrate10Generator(tree, schema) {
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
(0, calling_storybook_cli_1.callUpgrade)(schema);
|
|
22
|
+
if (schema.skipAiInstructions) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
22
25
|
const pathToAiInstructions = (0, path_1.join)(__dirname, 'files', 'ai-instructions-for-cjs-esm.md');
|
|
23
26
|
if (!(0, fs_1.existsSync)(pathToAiInstructions)) {
|
|
24
27
|
return;
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"type": "array",
|
|
15
15
|
"description": "Directory(ies) where to load Storybook configurations from. Use this if you want to customize the Storybook projects you'd like to migrate.",
|
|
16
16
|
"default": []
|
|
17
|
+
},
|
|
18
|
+
"skipAiInstructions": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"description": "Skip writing the AI migration instructions file to `tools/ai-migrations/`.",
|
|
21
|
+
"default": false
|
|
17
22
|
}
|
|
18
23
|
},
|
|
19
24
|
"examplesFile": "../../../docs/migrate-10-generator-examples.md"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-to-storybook-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/migrations/update-22-1-0/migrate-to-storybook-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"migrate-to-storybook-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/migrations/update-22-1-0/migrate-to-storybook-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,wBAA8B,oBAAoB,CAAC,IAAI,EAAE,IAAI,iBAc5D"}
|
|
@@ -16,9 +16,6 @@ async function migrateToStorybook10(tree) {
|
|
|
16
16
|
});
|
|
17
17
|
await (0, migrate_10_1.default)(tree, {
|
|
18
18
|
autoAcceptAllPrompts: true,
|
|
19
|
+
skipAiInstructions: true,
|
|
19
20
|
});
|
|
20
|
-
return [
|
|
21
|
-
`Storybook 10 requires Storybook Configs to use ESM.`,
|
|
22
|
-
`We created 'tools/ai-migrations/MIGRATE_STORYBOOK_10.md' with instructions for an AI Agent to convert CJS Storybook Configs to ESM in your workspace.`,
|
|
23
|
-
];
|
|
24
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/plugins/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/plugins/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,kBAAkB,EAIlB,aAAa,EAMd,MAAM,YAAY,CAAC;AAUpB,MAAM,WAAW,sBAAsB;IACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAID;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,sBAAsB,CA+D7D,CAAC;AAEF,eAAO,MAAM,aAAa,uCAAc,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
6
|
const path_1 = require("path");
|
|
6
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
9
8
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
10
9
|
const js_1 = require("@nx/js");
|
|
11
|
-
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
12
10
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
13
11
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
14
|
-
const
|
|
15
|
-
function readTargetsCache(cachePath) {
|
|
16
|
-
return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
17
|
-
}
|
|
18
|
-
function writeTargetsToCache(cachePath, results) {
|
|
19
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
20
|
-
}
|
|
12
|
+
const internal_2 = require("@nx/js/internal");
|
|
21
13
|
/**
|
|
22
14
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
23
15
|
*/
|
|
@@ -32,18 +24,40 @@ exports.createNodes = [
|
|
|
32
24
|
const normalizedOptions = normalizeOptions(options);
|
|
33
25
|
const optionsHash = (0, file_hasher_1.hashObject)(normalizedOptions);
|
|
34
26
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `storybook-${optionsHash}.hash`);
|
|
35
|
-
const targetsCache =
|
|
36
|
-
const
|
|
27
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
28
|
+
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
29
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
30
|
+
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
37
31
|
try {
|
|
38
|
-
|
|
32
|
+
const { entries, preErrors } = await filterStorybookConfigs(configFilePaths, context);
|
|
33
|
+
const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), normalizedOptions, context, entries.map(() => [lockFileName]));
|
|
34
|
+
let results = [];
|
|
35
|
+
let nodeErrors = [];
|
|
36
|
+
try {
|
|
37
|
+
results = await (0, devkit_1.createNodesFromFiles)((configFile, _, ctx, idx) => createNodesInternal(configFile, normalizedOptions, ctx, targetsCache, pmc, entries[idx].projectRoot, projectHashes[idx]), entries.map((e) => e.configFile), normalizedOptions, context);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (e instanceof devkit_1.AggregateCreateNodesError) {
|
|
41
|
+
results = e.partialResults ?? [];
|
|
42
|
+
nodeErrors = e.errors;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const allErrors = [...preErrors, ...nodeErrors];
|
|
49
|
+
if (allErrors.length > 0) {
|
|
50
|
+
throw new devkit_1.AggregateCreateNodesError(allErrors, results);
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
39
53
|
}
|
|
40
54
|
finally {
|
|
41
|
-
|
|
55
|
+
targetsCache.writeToDisk();
|
|
42
56
|
}
|
|
43
57
|
},
|
|
44
58
|
];
|
|
45
59
|
exports.createNodesV2 = exports.createNodes;
|
|
46
|
-
|
|
60
|
+
function getProjectRootFromConfigPath(configFilePath) {
|
|
47
61
|
let projectRoot = '';
|
|
48
62
|
if (configFilePath.includes('/.storybook')) {
|
|
49
63
|
projectRoot = (0, path_1.dirname)(configFilePath).replace('/.storybook', '');
|
|
@@ -54,20 +68,18 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
54
68
|
if (projectRoot === '') {
|
|
55
69
|
projectRoot = '.';
|
|
56
70
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
!siblingFiles.includes('project.json')) {
|
|
61
|
-
return {};
|
|
62
|
-
}
|
|
63
|
-
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
71
|
+
return projectRoot;
|
|
72
|
+
}
|
|
73
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache, pmc, projectRoot, hash) {
|
|
64
74
|
const projectName = buildProjectName(projectRoot, context.workspaceRoot);
|
|
65
|
-
targetsCache
|
|
75
|
+
if (!targetsCache.has(hash)) {
|
|
76
|
+
targetsCache.set(hash, await buildStorybookTargets(configFilePath, projectRoot, options, context, projectName, pmc));
|
|
77
|
+
}
|
|
66
78
|
const result = {
|
|
67
79
|
projects: {
|
|
68
80
|
[projectRoot]: {
|
|
69
81
|
root: projectRoot,
|
|
70
|
-
targets: targetsCache
|
|
82
|
+
targets: targetsCache.get(hash),
|
|
71
83
|
},
|
|
72
84
|
},
|
|
73
85
|
};
|
|
@@ -75,7 +87,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
75
87
|
}
|
|
76
88
|
async function buildStorybookTargets(configFilePath, projectRoot, options, context, projectName, pmc) {
|
|
77
89
|
const buildOutputs = getOutputs();
|
|
78
|
-
const namedInputs = (0,
|
|
90
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
79
91
|
// First attempt to do a very fast lookup for the framework
|
|
80
92
|
// If that fails, the framework might be inherited, so do a very heavyweight lookup
|
|
81
93
|
const storybookFramework = (await getStorybookFramework(configFilePath, context)) ||
|
|
@@ -91,7 +103,7 @@ async function buildStorybookTargets(configFilePath, projectRoot, options, conte
|
|
|
91
103
|
targets[options.testStorybookTargetName] = testTarget(projectRoot);
|
|
92
104
|
}
|
|
93
105
|
targets[options.staticStorybookTargetName] = serveStaticTarget(options, projectRoot);
|
|
94
|
-
(0,
|
|
106
|
+
(0, internal_2.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
|
|
95
107
|
return targets;
|
|
96
108
|
}
|
|
97
109
|
function buildTarget(namedInputs, outputs, projectRoot, frameworkIsAngular, projectName, configFilePath) {
|
|
@@ -220,7 +232,7 @@ function parseFrameworkName(mainTsJs) {
|
|
|
220
232
|
}
|
|
221
233
|
async function getStorybookFullyResolvedFramework(configFilePath, context) {
|
|
222
234
|
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
223
|
-
const { framework } = await (0,
|
|
235
|
+
const { framework } = await (0, internal_1.loadConfigFile)(resolvedPath);
|
|
224
236
|
return typeof framework === 'string' ? framework : framework.name;
|
|
225
237
|
}
|
|
226
238
|
function getOutputs() {
|
|
@@ -232,6 +244,28 @@ function getOutputs() {
|
|
|
232
244
|
];
|
|
233
245
|
return outputs;
|
|
234
246
|
}
|
|
247
|
+
async function filterStorybookConfigs(configFiles, context) {
|
|
248
|
+
const preErrors = [];
|
|
249
|
+
const candidates = await Promise.all(configFiles.map(async (configFile) => {
|
|
250
|
+
try {
|
|
251
|
+
const projectRoot = getProjectRootFromConfigPath(configFile);
|
|
252
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
253
|
+
if (!siblingFiles.includes('package.json') &&
|
|
254
|
+
!siblingFiles.includes('project.json')) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
return { configFile, projectRoot };
|
|
258
|
+
}
|
|
259
|
+
catch (e) {
|
|
260
|
+
preErrors.push([configFile, e]);
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
}));
|
|
264
|
+
return {
|
|
265
|
+
entries: candidates.filter((c) => c !== null),
|
|
266
|
+
preErrors,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
235
269
|
function normalizeOptions(options) {
|
|
236
270
|
return {
|
|
237
271
|
buildStorybookTargetName: options.buildStorybookTargetName ?? 'build-storybook',
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const STORYBOOK_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/storybook:storybook` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` to migrate to the `@nx/storybook/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
2
|
+
export declare const STORYBOOK_BUILD_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/storybook:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` to migrate to the `@nx/storybook/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
3
|
+
export declare function warnStorybookExecutorDeprecation(): void;
|
|
4
|
+
export declare function warnStorybookBuildExecutorDeprecation(): void;
|
|
5
|
+
export declare function warnStorybookExecutorGenerating(): void;
|
|
6
|
+
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/deprecation.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sCAAsC,+QAC2N,CAAC;AAE/Q,eAAO,MAAM,4CAA4C,2QACiN,CAAC;AAE3Q,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED,wBAAgB,qCAAqC,IAAI,IAAI,CAE5D;AAED,wBAAgB,+BAA+B,IAAI,IAAI,CAItD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STORYBOOK_BUILD_EXECUTOR_DEPRECATION_MESSAGE = exports.STORYBOOK_EXECUTOR_DEPRECATION_MESSAGE = void 0;
|
|
4
|
+
exports.warnStorybookExecutorDeprecation = warnStorybookExecutorDeprecation;
|
|
5
|
+
exports.warnStorybookBuildExecutorDeprecation = warnStorybookBuildExecutorDeprecation;
|
|
6
|
+
exports.warnStorybookExecutorGenerating = warnStorybookExecutorGenerating;
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
// TODO(v24): Remove the @nx/storybook:storybook and @nx/storybook:build
|
|
9
|
+
// executors. The inferred plugin (@nx/storybook/plugin) and the
|
|
10
|
+
// convert-to-inferred generator stay supported.
|
|
11
|
+
exports.STORYBOOK_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/storybook:storybook` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` to migrate to the `@nx/storybook/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
12
|
+
exports.STORYBOOK_BUILD_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/storybook:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` to migrate to the `@nx/storybook/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
13
|
+
function warnStorybookExecutorDeprecation() {
|
|
14
|
+
devkit_1.logger.warn(exports.STORYBOOK_EXECUTOR_DEPRECATION_MESSAGE);
|
|
15
|
+
}
|
|
16
|
+
function warnStorybookBuildExecutorDeprecation() {
|
|
17
|
+
devkit_1.logger.warn(exports.STORYBOOK_BUILD_EXECUTOR_DEPRECATION_MESSAGE);
|
|
18
|
+
}
|
|
19
|
+
function warnStorybookExecutorGenerating() {
|
|
20
|
+
devkit_1.logger.warn('Generating targets that use the deprecated `@nx/storybook:storybook` and `@nx/storybook:build` executors. These executors will be removed in Nx v24. Run `nx g @nx/storybook:convert-to-inferred` next to migrate these targets to the `@nx/storybook/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
21
|
+
}
|