@nx/storybook 22.1.0-beta.2 → 22.1.0-beta.4
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/generators.json +6 -0
- package/migrations.json +112 -1
- package/package.json +7 -7
- package/src/executors/build-storybook/build-storybook.impl.d.ts.map +1 -1
- package/src/executors/build-storybook/build-storybook.impl.js +1 -4
- package/src/executors/build-storybook/schema.json +0 -8
- package/src/executors/storybook/schema.json +0 -8
- package/src/executors/storybook/storybook.impl.d.ts.map +1 -1
- package/src/executors/storybook/storybook.impl.js +1 -5
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +2 -2
- package/src/generators/configuration/files/v10/project-files/.storybook/main.js__tmpl__ +93 -0
- package/src/generators/configuration/files/v10/project-files-ts/.storybook/main.ts__tmpl__ +94 -0
- package/src/generators/configuration/files/v9/project-files/.storybook/preview.js__tmpl__ +0 -0
- package/src/generators/configuration/files/v9/project-files/.storybook/tsconfig.json__tmpl__ +15 -0
- package/src/generators/configuration/files/v9/project-files-ts/.storybook/preview.ts__tmpl__ +0 -0
- package/src/generators/configuration/files/v9/project-files-ts/.storybook/tsconfig.json__tmpl__ +16 -0
- package/src/generators/configuration/lib/edit-root-tsconfig.d.ts.map +1 -1
- package/src/generators/configuration/lib/edit-root-tsconfig.js +5 -0
- package/src/generators/configuration/lib/ensure-dependencies.d.ts.map +1 -1
- package/src/generators/configuration/lib/ensure-dependencies.js +2 -7
- package/src/generators/configuration/lib/util-functions.d.ts.map +1 -1
- package/src/generators/configuration/lib/util-functions.js +5 -3
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +1 -7
- package/src/generators/migrate-10/calling-storybook-cli.d.ts +4 -0
- package/src/generators/migrate-10/calling-storybook-cli.d.ts.map +1 -0
- package/src/generators/migrate-10/calling-storybook-cli.js +51 -0
- package/src/generators/migrate-10/migrate-10.d.ts +5 -0
- package/src/generators/migrate-10/migrate-10.d.ts.map +1 -0
- package/src/generators/migrate-10/migrate-10.js +22 -0
- package/src/generators/migrate-10/schema.d.ts +4 -0
- package/src/generators/migrate-10/schema.json +19 -0
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts +3 -0
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.d.ts.map +1 -0
- package/src/migrations/update-22-1-0/migrate-to-storybook-10.js +19 -0
- package/src/utils/utilities.d.ts +3 -2
- package/src/utils/utilities.d.ts.map +1 -1
- package/src/utils/utilities.js +42 -2
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +1 -1
- /package/src/generators/configuration/{project-files → files/v10/project-files}/.storybook/preview.js__tmpl__ +0 -0
- /package/src/generators/configuration/{project-files → files/v10/project-files}/.storybook/tsconfig.json__tmpl__ +0 -0
- /package/src/generators/configuration/{project-files-ts → files/v10/project-files-ts}/.storybook/preview.ts__tmpl__ +0 -0
- /package/src/generators/configuration/{project-files-ts → files/v10/project-files-ts}/.storybook/tsconfig.json__tmpl__ +0 -0
- /package/src/generators/configuration/{project-files → files/v9/project-files}/.storybook/main.js__tmpl__ +0 -0
- /package/src/generators/configuration/{project-files-ts → files/v9/project-files-ts}/.storybook/main.ts__tmpl__ +0 -0
package/generators.json
CHANGED
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
"schema": "./src/generators/migrate-9/schema.json",
|
|
32
32
|
"description": "Migrate to Storybook version 9.",
|
|
33
33
|
"hidden": false
|
|
34
|
+
},
|
|
35
|
+
"migrate-10": {
|
|
36
|
+
"factory": "./src/generators/migrate-10/migrate-10",
|
|
37
|
+
"schema": "./src/generators/migrate-10/schema.json",
|
|
38
|
+
"description": "Migrate to Storybook version 10.",
|
|
39
|
+
"hidden": false
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
}
|
package/migrations.json
CHANGED
|
@@ -11,6 +11,15 @@
|
|
|
11
11
|
"version": "21.2.0-beta.3",
|
|
12
12
|
"description": "Remove deprecated Storybook addon dependencies",
|
|
13
13
|
"implementation": "./src/migrations/update-21-2-0/remove-addon-dependencies"
|
|
14
|
+
},
|
|
15
|
+
"update-22-1-0-migrate-storybook-v10": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "22.1.0-beta.3",
|
|
18
|
+
"requires": {
|
|
19
|
+
"storybook": ">=10.0.0"
|
|
20
|
+
},
|
|
21
|
+
"description": "Update workspce to use Storybok v10",
|
|
22
|
+
"implementation": "./src/migrations/update-22-1-0/migrate-to-storybook-10"
|
|
14
23
|
}
|
|
15
24
|
},
|
|
16
25
|
"packageJsonUpdates": {
|
|
@@ -529,7 +538,7 @@
|
|
|
529
538
|
}
|
|
530
539
|
},
|
|
531
540
|
"21.1.0": {
|
|
532
|
-
"version": "
|
|
541
|
+
"version": "22.1.0-beta.3",
|
|
533
542
|
"packages": {
|
|
534
543
|
"@storybook/angular": {
|
|
535
544
|
"version": "^9.0.5",
|
|
@@ -624,6 +633,108 @@
|
|
|
624
633
|
"alwaysAddToPackageJson": false
|
|
625
634
|
}
|
|
626
635
|
}
|
|
636
|
+
},
|
|
637
|
+
"21.2.0": {
|
|
638
|
+
"version": "21.2.0-beta.3",
|
|
639
|
+
"x-prompt": "Do you want to update Storybook to version 10?",
|
|
640
|
+
"implementation": "./src/migrations/update-21-2-0/migrate-to-storybook-10",
|
|
641
|
+
"requires": {
|
|
642
|
+
"storybook": ">=9.0.0 <10.0.0"
|
|
643
|
+
},
|
|
644
|
+
"packages": {
|
|
645
|
+
"@storybook/angular": {
|
|
646
|
+
"version": "^10.0.0",
|
|
647
|
+
"alwaysAddToPackageJson": false
|
|
648
|
+
},
|
|
649
|
+
"@storybook/react": {
|
|
650
|
+
"version": "^10.0.0",
|
|
651
|
+
"alwaysAddToPackageJson": false
|
|
652
|
+
},
|
|
653
|
+
"storybook": {
|
|
654
|
+
"version": "^10.0.0",
|
|
655
|
+
"alwaysAddToPackageJson": true
|
|
656
|
+
},
|
|
657
|
+
"@storybook/addon-onboarding": {
|
|
658
|
+
"version": "^10.0.0",
|
|
659
|
+
"alwaysAddToPackageJson": false
|
|
660
|
+
},
|
|
661
|
+
"@storybook/addon-themes": {
|
|
662
|
+
"version": "^10.0.0",
|
|
663
|
+
"alwaysAddToPackageJson": false
|
|
664
|
+
},
|
|
665
|
+
"@storybook/builder-webpack5": {
|
|
666
|
+
"version": "^10.0.0",
|
|
667
|
+
"alwaysAddToPackageJson": false
|
|
668
|
+
},
|
|
669
|
+
"@storybook/core-webpack": {
|
|
670
|
+
"version": "^10.0.0",
|
|
671
|
+
"alwaysAddToPackageJson": false
|
|
672
|
+
},
|
|
673
|
+
"@storybook/html": {
|
|
674
|
+
"version": "^10.0.0",
|
|
675
|
+
"alwaysAddToPackageJson": false
|
|
676
|
+
},
|
|
677
|
+
"@storybook/html-vite": {
|
|
678
|
+
"version": "^10.0.0",
|
|
679
|
+
"alwaysAddToPackageJson": false
|
|
680
|
+
},
|
|
681
|
+
"@storybook/nextjs": {
|
|
682
|
+
"version": "^10.0.0",
|
|
683
|
+
"alwaysAddToPackageJson": false
|
|
684
|
+
},
|
|
685
|
+
"@storybook/preact": {
|
|
686
|
+
"version": "^10.0.0",
|
|
687
|
+
"alwaysAddToPackageJson": false
|
|
688
|
+
},
|
|
689
|
+
"@storybook/preact-vite": {
|
|
690
|
+
"version": "^10.0.0",
|
|
691
|
+
"alwaysAddToPackageJson": false
|
|
692
|
+
},
|
|
693
|
+
"@storybook/react-vite": {
|
|
694
|
+
"version": "^10.0.0",
|
|
695
|
+
"alwaysAddToPackageJson": false
|
|
696
|
+
},
|
|
697
|
+
"@storybook/react-webpack5": {
|
|
698
|
+
"version": "^10.0.0",
|
|
699
|
+
"alwaysAddToPackageJson": false
|
|
700
|
+
},
|
|
701
|
+
"@storybook/server": {
|
|
702
|
+
"version": "^10.0.0",
|
|
703
|
+
"alwaysAddToPackageJson": false
|
|
704
|
+
},
|
|
705
|
+
"@storybook/server-webpack5": {
|
|
706
|
+
"version": "^10.0.0",
|
|
707
|
+
"alwaysAddToPackageJson": false
|
|
708
|
+
},
|
|
709
|
+
"@storybook/svelte": {
|
|
710
|
+
"version": "^10.0.0",
|
|
711
|
+
"alwaysAddToPackageJson": false
|
|
712
|
+
},
|
|
713
|
+
"@storybook/svelte-vite": {
|
|
714
|
+
"version": "^10.0.0",
|
|
715
|
+
"alwaysAddToPackageJson": false
|
|
716
|
+
},
|
|
717
|
+
"@storybook/sveltekit": {
|
|
718
|
+
"version": "^10.0.0",
|
|
719
|
+
"alwaysAddToPackageJson": false
|
|
720
|
+
},
|
|
721
|
+
"@storybook/vue3": {
|
|
722
|
+
"version": "^10.0.0",
|
|
723
|
+
"alwaysAddToPackageJson": false
|
|
724
|
+
},
|
|
725
|
+
"@storybook/vue3-vite": {
|
|
726
|
+
"version": "^10.0.0",
|
|
727
|
+
"alwaysAddToPackageJson": false
|
|
728
|
+
},
|
|
729
|
+
"@storybook/web-components": {
|
|
730
|
+
"version": "^10.0.0",
|
|
731
|
+
"alwaysAddToPackageJson": false
|
|
732
|
+
},
|
|
733
|
+
"@storybook/web-components-vite": {
|
|
734
|
+
"version": "^10.0.0",
|
|
735
|
+
"alwaysAddToPackageJson": false
|
|
736
|
+
}
|
|
737
|
+
}
|
|
627
738
|
}
|
|
628
739
|
}
|
|
629
740
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "22.1.0-beta.
|
|
3
|
+
"version": "22.1.0-beta.4",
|
|
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": {
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"migrations": "./migrations.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nx/devkit": "22.1.0-beta.
|
|
36
|
+
"@nx/devkit": "22.1.0-beta.4",
|
|
37
37
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
38
38
|
"semver": "^7.6.3",
|
|
39
39
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/cypress": "22.1.0-beta.
|
|
41
|
-
"@nx/js": "22.1.0-beta.
|
|
42
|
-
"@nx/eslint": "22.1.0-beta.
|
|
40
|
+
"@nx/cypress": "22.1.0-beta.4",
|
|
41
|
+
"@nx/js": "22.1.0-beta.4",
|
|
42
|
+
"@nx/eslint": "22.1.0-beta.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"nx": "22.1.0-beta.
|
|
45
|
+
"nx": "22.1.0-beta.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"storybook": ">=7.0.0 <
|
|
48
|
+
"storybook": ">=7.0.0 <11.0.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
@@ -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;AAS3D,wBAA8B,sBAAsB,CAClD,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe;;
|
|
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;AAS3D,wBAA8B,sBAAsB,CAClD,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,eAAe;;GAczB"}
|
|
@@ -7,12 +7,9 @@ const semver_1 = require("semver");
|
|
|
7
7
|
async function buildStorybookExecutor(options, context) {
|
|
8
8
|
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
9
9
|
const storybookMajor = (0, utilities_1.storybookMajorVersion)();
|
|
10
|
-
if (storybookMajor > 0 && storybookMajor <=
|
|
10
|
+
if (storybookMajor > 0 && storybookMajor <= 7) {
|
|
11
11
|
throw (0, utilities_1.pleaseUpgrade)();
|
|
12
12
|
}
|
|
13
|
-
else if (storybookMajor === 7) {
|
|
14
|
-
devkit_1.logger.warn(`Support for Storybook 7 is deprecated. Please upgrade to Storybook 8. See https://nx.dev/nx-api/storybook/generators/migrate-8 for more details.`);
|
|
15
|
-
}
|
|
16
13
|
const buildOptions = options;
|
|
17
14
|
devkit_1.logger.info(`NX Storybook builder starting ...`);
|
|
18
15
|
await runInstance(buildOptions);
|
|
@@ -42,14 +42,6 @@
|
|
|
42
42
|
"description": "Build a documentation-only site using addon-docs.",
|
|
43
43
|
"default": false
|
|
44
44
|
},
|
|
45
|
-
"staticDir": {
|
|
46
|
-
"type": "array",
|
|
47
|
-
"description": "Directory where to load static files from, array of strings.",
|
|
48
|
-
"items": {
|
|
49
|
-
"type": "string"
|
|
50
|
-
},
|
|
51
|
-
"x-deprecated": "In Storybook 6.4 the `--static-dir` CLI flag has been replaced with the the `staticDirs` field in `.storybook/main.js`. It will be removed completely in Storybook 7.0."
|
|
52
|
-
},
|
|
53
45
|
"configDir": {
|
|
54
46
|
"type": "string",
|
|
55
47
|
"description": "Directory where to load Storybook configurations from.",
|
|
@@ -26,14 +26,6 @@
|
|
|
26
26
|
"type": "string",
|
|
27
27
|
"description": "Host to listen on."
|
|
28
28
|
},
|
|
29
|
-
"staticDir": {
|
|
30
|
-
"type": "array",
|
|
31
|
-
"description": "Directory where to load static files from, array of strings.",
|
|
32
|
-
"items": {
|
|
33
|
-
"type": "string"
|
|
34
|
-
},
|
|
35
|
-
"x-deprecated": "In Storybook 6.4 the `--static-dir` CLI flag has been replaced with the the `staticDirs` field in `.storybook/main.js`. It will be removed completely in Storybook 7.0."
|
|
36
|
-
},
|
|
37
29
|
"configDir": {
|
|
38
30
|
"type": "string",
|
|
39
31
|
"description": "Directory where to load Storybook configurations from.",
|
|
@@ -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;AAG3D,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,
|
|
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;AAG3D,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,CAmBD"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = storybookExecutor;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const utilities_1 = require("../../utils/utilities");
|
|
6
5
|
const semver_1 = require("semver");
|
|
7
6
|
async function* storybookExecutor(options, context) {
|
|
8
7
|
const storybookMajor = (0, utilities_1.storybookMajorVersion)();
|
|
9
|
-
if (storybookMajor > 0 && storybookMajor <=
|
|
8
|
+
if (storybookMajor > 0 && storybookMajor <= 7) {
|
|
10
9
|
throw (0, utilities_1.pleaseUpgrade)();
|
|
11
10
|
}
|
|
12
|
-
else if (storybookMajor === 7) {
|
|
13
|
-
devkit_1.logger.warn(`Support for Storybook 7 is deprecated. Please upgrade to Storybook 8. See https://nx.dev/nx-api/storybook/generators/migrate-8 for more details.`);
|
|
14
|
-
}
|
|
15
11
|
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
|
|
16
12
|
const buildOptions = options;
|
|
17
13
|
const result = await runInstance(buildOptions);
|
|
@@ -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;AAuCpD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,wBAAwB,8BAGjC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,wBAAwB,8BA4KpC;AAwBD,eAAe,sBAAsB,CAAC"}
|
|
@@ -15,7 +15,7 @@ function configurationGenerator(tree, schema) {
|
|
|
15
15
|
return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
16
16
|
}
|
|
17
17
|
async function configurationGeneratorInternal(tree, rawSchema) {
|
|
18
|
-
const storybookMajor = (0, utilities_1.storybookMajorVersion)();
|
|
18
|
+
const storybookMajor = (0, utilities_1.storybookMajorVersion)(tree);
|
|
19
19
|
if (storybookMajor > 0 && storybookMajor === 7) {
|
|
20
20
|
throw new Error((0, utilities_1.pleaseUpgrade)());
|
|
21
21
|
}
|
|
@@ -93,7 +93,7 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
|
-
devDeps['storybook'] =
|
|
96
|
+
devDeps['storybook'] = (0, utilities_1.getStorybookVersionToInstall)(tree);
|
|
97
97
|
}
|
|
98
98
|
if (schema.tsConfiguration) {
|
|
99
99
|
devDeps['ts-node'] = versions_1.tsNodeVersion;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
|
|
4
|
+
<% if (usesVite && !viteConfigFilePath) { %>
|
|
5
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
6
|
+
import { mergeConfig } from 'vite';
|
|
7
|
+
<% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %>
|
|
8
|
+
|
|
9
|
+
const config = {
|
|
10
|
+
stories: [
|
|
11
|
+
<% if((uiFramework === '@storybook/angular' && projectType === 'library') || uiFramework === '@storybook/nextjs') { %>
|
|
12
|
+
'../**/*.@(mdx|stories.@(js|jsx|ts|tsx))' <% } else { %>
|
|
13
|
+
'../<%= projectDirectory %>/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'
|
|
14
|
+
<% } %>],
|
|
15
|
+
addons: [<% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %>],
|
|
16
|
+
framework: {
|
|
17
|
+
name: <% if(uiFramework !== '@storybook/angular') { %>getAbsolutePath(<% } %>'<%= uiFramework %>'<% if(uiFramework !== '@storybook/angular') { %>)<% } %>,
|
|
18
|
+
options: {
|
|
19
|
+
<% if (usesVite && viteConfigFilePath && hasPlugin) { %>
|
|
20
|
+
builder: {
|
|
21
|
+
viteConfigPath: '<%= viteConfigFileName %>',
|
|
22
|
+
},
|
|
23
|
+
<% } %>
|
|
24
|
+
<% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
|
|
25
|
+
builder: {
|
|
26
|
+
viteConfigPath: '<%= viteConfigFilePath %>',
|
|
27
|
+
},
|
|
28
|
+
<% } %>
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
<% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
|
|
32
|
+
if (config.resolve) {
|
|
33
|
+
config.resolve.alias = {
|
|
34
|
+
...config.resolve.alias,
|
|
35
|
+
'react-native$': 'react-native-web',
|
|
36
|
+
};
|
|
37
|
+
config.resolve.extensions = [
|
|
38
|
+
'.web.tsx',
|
|
39
|
+
'.web.ts',
|
|
40
|
+
'.web.jsx',
|
|
41
|
+
'.web.js',
|
|
42
|
+
...(config.resolve.extensions ?? []),
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return config;
|
|
46
|
+
},<% } %><% if (usesVite && !viteConfigFilePath) { %>
|
|
47
|
+
viteFinal: async (config) =>
|
|
48
|
+
mergeConfig(config, {
|
|
49
|
+
<% if (usesReactNative) { %>define: {
|
|
50
|
+
global: 'window',
|
|
51
|
+
},
|
|
52
|
+
resolve: {
|
|
53
|
+
extensions: [
|
|
54
|
+
'.mjs',
|
|
55
|
+
'.web.tsx',
|
|
56
|
+
'.tsx',
|
|
57
|
+
'.web.ts',
|
|
58
|
+
'.ts',
|
|
59
|
+
'.web.jsx',
|
|
60
|
+
'.jsx',
|
|
61
|
+
'.web.js',
|
|
62
|
+
'.js',
|
|
63
|
+
'.css',
|
|
64
|
+
'.json',
|
|
65
|
+
...(config.resolve?.extensions ?? []),
|
|
66
|
+
],
|
|
67
|
+
alias: {
|
|
68
|
+
'react-native': 'react-native-web',
|
|
69
|
+
},
|
|
70
|
+
},<% } %>
|
|
71
|
+
plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %>nxViteTsPaths()],
|
|
72
|
+
}),
|
|
73
|
+
<% } %>
|
|
74
|
+
};
|
|
75
|
+
<% if(uiFramework !== '@storybook/angular') { %>
|
|
76
|
+
function getAbsolutePath(value: string): any {
|
|
77
|
+
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
|
78
|
+
}
|
|
79
|
+
<% } %>
|
|
80
|
+
|
|
81
|
+
export default config;
|
|
82
|
+
|
|
83
|
+
<% if(!usesVite) { %>
|
|
84
|
+
// To customize your webpack configuration you can use the webpackFinal field.
|
|
85
|
+
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
|
|
86
|
+
// and https://nx.dev/recipes/storybook/custom-builder-configs
|
|
87
|
+
<% } %>
|
|
88
|
+
|
|
89
|
+
<% if(usesVite) { %>
|
|
90
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
91
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
92
|
+
// and https://nx.dev/recipes/storybook/custom-builder-configs
|
|
93
|
+
<% } %>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
|
|
4
|
+
import type { StorybookConfig } from '<%= uiFramework %>';
|
|
5
|
+
<% if (usesVite && !viteConfigFilePath) { %>
|
|
6
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
7
|
+
import { mergeConfig } from 'vite';
|
|
8
|
+
<% } %><% if (uiFramework === '@storybook/vue3-vite' && !viteConfigFilePath) { %>import vue from '@vitejs/plugin-vue'<% } %><% if (uiFramework === '@storybook/react-vite' && !viteConfigFilePath) { %>import react from '@vitejs/plugin-react'<% } %>
|
|
9
|
+
|
|
10
|
+
const config: StorybookConfig = {
|
|
11
|
+
stories: [
|
|
12
|
+
<% if((uiFramework === '@storybook/angular' && projectType === 'library') || uiFramework === '@storybook/nextjs') { %>
|
|
13
|
+
'../**/*.@(mdx|stories.@(js|jsx|ts|tsx))' <% } else { %>
|
|
14
|
+
'../<%= projectDirectory %>/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'
|
|
15
|
+
<% } %>],
|
|
16
|
+
addons: [<% if(uiFramework === '@storybook/react-webpack5') { %>, '@nx/react/plugins/storybook' <% } %>],
|
|
17
|
+
framework: {
|
|
18
|
+
name: <% if(uiFramework !== '@storybook/angular') { %>getAbsolutePath(<% } %>'<%= uiFramework %>'<% if(uiFramework !== '@storybook/angular') { %>)<% } %>,
|
|
19
|
+
options: {
|
|
20
|
+
<% if (usesVite && viteConfigFilePath && hasPlugin) { %>
|
|
21
|
+
builder: {
|
|
22
|
+
viteConfigPath: '<%= viteConfigFileName %>',
|
|
23
|
+
},
|
|
24
|
+
<% } %><% if (usesVite && viteConfigFilePath && !hasPlugin) { %>
|
|
25
|
+
builder: {
|
|
26
|
+
viteConfigPath: '<%= viteConfigFilePath %>',
|
|
27
|
+
},
|
|
28
|
+
<% } %>
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
<% if (usesReactNative && uiFramework === '@storybook/react-webpack5') { %>webpackFinal: async (config) => {
|
|
32
|
+
if (config.resolve) {
|
|
33
|
+
config.resolve.alias = {
|
|
34
|
+
...config.resolve.alias,
|
|
35
|
+
'react-native$': 'react-native-web',
|
|
36
|
+
};
|
|
37
|
+
config.resolve.extensions = [
|
|
38
|
+
'.web.tsx',
|
|
39
|
+
'.web.ts',
|
|
40
|
+
'.web.jsx',
|
|
41
|
+
'.web.js',
|
|
42
|
+
...(config.resolve.extensions ?? []),
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
return config;
|
|
46
|
+
},<% } %><% if (usesVite && !viteConfigFilePath) { %>
|
|
47
|
+
viteFinal: async (config) =>
|
|
48
|
+
mergeConfig(config, {
|
|
49
|
+
<% if (usesReactNative) { %>define: {
|
|
50
|
+
global: 'window',
|
|
51
|
+
},
|
|
52
|
+
resolve: {
|
|
53
|
+
extensions: [
|
|
54
|
+
'.mjs',
|
|
55
|
+
'.web.tsx',
|
|
56
|
+
'.tsx',
|
|
57
|
+
'.web.ts',
|
|
58
|
+
'.ts',
|
|
59
|
+
'.web.jsx',
|
|
60
|
+
'.jsx',
|
|
61
|
+
'.web.js',
|
|
62
|
+
'.js',
|
|
63
|
+
'.css',
|
|
64
|
+
'.json',
|
|
65
|
+
...(config.resolve?.extensions ?? []),
|
|
66
|
+
],
|
|
67
|
+
alias: {
|
|
68
|
+
'react-native': 'react-native-web',
|
|
69
|
+
},
|
|
70
|
+
},<% } %>
|
|
71
|
+
plugins: [<% if(uiFramework === '@storybook/vue3-vite') { %>vue(), <% } %><% if(uiFramework === '@storybook/react-vite') { %>react(), <% } %>nxViteTsPaths()],
|
|
72
|
+
}),
|
|
73
|
+
<% } %>
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
<% if(uiFramework !== '@storybook/angular') { %>
|
|
77
|
+
function getAbsolutePath(value: string): any {
|
|
78
|
+
return dirname(fileURLToPath(import.meta.resolve(`${value}/package.json`)));
|
|
79
|
+
}
|
|
80
|
+
<% } %>
|
|
81
|
+
|
|
82
|
+
export default config;
|
|
83
|
+
|
|
84
|
+
<% if(!usesVite) { %>
|
|
85
|
+
// To customize your webpack configuration you can use the webpackFinal field.
|
|
86
|
+
// Check https://storybook.js.org/docs/react/builders/webpack#extending-storybooks-webpack-config
|
|
87
|
+
// and https://nx.dev/recipes/storybook/custom-builder-configs
|
|
88
|
+
<% } %>
|
|
89
|
+
|
|
90
|
+
<% if(usesVite) { %>
|
|
91
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
92
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
93
|
+
// and https://nx.dev/recipes/storybook/custom-builder-configs
|
|
94
|
+
<% } %>
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"emitDecoratorMetadata": true
|
|
5
|
+
},
|
|
6
|
+
"exclude": ["../**/*.spec.ts"],
|
|
7
|
+
"include": [
|
|
8
|
+
"../src/**/*.stories.ts",
|
|
9
|
+
"../src/**/*.stories.js",
|
|
10
|
+
"../src/**/*.stories.jsx",
|
|
11
|
+
"../src/**/*.stories.tsx",
|
|
12
|
+
"../src/**/*.stories.mdx",
|
|
13
|
+
"*.js"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
File without changes
|
package/src/generators/configuration/files/v9/project-files-ts/.storybook/tsconfig.json__tmpl__
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"emitDecoratorMetadata": true
|
|
5
|
+
},
|
|
6
|
+
"exclude": ["../**/*.spec.ts"],
|
|
7
|
+
"include": [
|
|
8
|
+
"../src/**/*.stories.ts",
|
|
9
|
+
"../src/**/*.stories.js",
|
|
10
|
+
"../src/**/*.stories.jsx",
|
|
11
|
+
"../src/**/*.stories.tsx",
|
|
12
|
+
"../src/**/*.stories.mdx",
|
|
13
|
+
"*.js",
|
|
14
|
+
"*.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-root-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/edit-root-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"edit-root-tsconfig.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/edit-root-tsconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAI7D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,QA8B1C"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.editRootTsConfig = editRootTsConfig;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
|
+
const utilities_1 = require("../../../utils/utilities");
|
|
6
7
|
/**
|
|
7
8
|
* This is a temporary fix for Storybook to support TypeScript configuration files.
|
|
8
9
|
* The issue is that if there is a root tsconfig.json file, Storybook will use it, and
|
|
@@ -13,6 +14,10 @@ function editRootTsConfig(tree) {
|
|
|
13
14
|
if (!tree.exists('tsconfig.json')) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
17
|
+
if ((0, utilities_1.storybookMajorVersion)(tree) >= 10) {
|
|
18
|
+
// This is not needed from storybook 10+
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
16
21
|
(0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
|
|
17
22
|
json['ts-node'] ??= {};
|
|
18
23
|
json['ts-node'].compilerOptions ??= {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,CAAC,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,CAAC,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CACvD,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,0CAuFnC"}
|
|
@@ -6,13 +6,8 @@ const semver_1 = require("semver");
|
|
|
6
6
|
const utilities_1 = require("../../../utils/utilities");
|
|
7
7
|
const versions_1 = require("../../../utils/versions");
|
|
8
8
|
function ensureDependencies(tree, options) {
|
|
9
|
-
|
|
10
|
-
const installedStorybookMajorVersion = (0, utilities_1.storybookMajorVersion)();
|
|
11
|
-
if (installedStorybookMajorVersion >= 7 &&
|
|
12
|
-
(0, utilities_1.getInstalledStorybookVersion)() &&
|
|
13
|
-
(0, semver_1.gte)((0, utilities_1.getInstalledStorybookVersion)(), '7.0.0')) {
|
|
14
|
-
storybookVersionToInstall = (0, utilities_1.getInstalledStorybookVersion)();
|
|
15
|
-
}
|
|
9
|
+
const storybookVersionToInstall = (0, utilities_1.getInstalledStorybookVersion)(tree);
|
|
10
|
+
const installedStorybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
|
|
16
11
|
const dependencies = {};
|
|
17
12
|
const devDependencies = installedStorybookMajorVersion < 9
|
|
18
13
|
? {
|
|
@@ -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;
|
|
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;AAYpD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,OAAO,QAwC1B;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,OAAO,QAmD1B;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,wBAAwB,iBAqB/B;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,YAAY,GAAG,KAAK,QAuH9B;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAe9C;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,wBAAwB,QAoCjC;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,wBAAwB,QAqCjC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,QAqE5E;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,GAC/B,wBAAwB,CAU1B;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,QAoCnD;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,UAAO,QA8CvE;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,EAAE,EAAE,OAAO,EACX,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,yCAAyC,EAAE,OAAO,EAClD,gBAAgB,EAAE,OAAO,EACzB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,OAAO,EAClB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,SAAS,CAAC,EAAE,OAAO,EACnB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,eAAe,CAAC,EAAE,OAAO,QAmE1B;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAUR;AAED,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,IAAI,QAehE;AAED,wBAAgB,yCAAyC,CAAC,WAAW,EAAE,MAAM,WAE5E;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,WAEjD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,OAAO,GACvB,OAAO,CAkBT;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB;IACD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,CAYA;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAS/D;AAED,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,yBAAyB,EAAE,MAAM,EACjC,IAAI,EAAE,IAAI,QAmEX"}
|
|
@@ -124,6 +124,7 @@ async function addStaticTarget(tree, opts) {
|
|
|
124
124
|
(0, devkit_1.updateProjectConfiguration)(tree, opts.project, projectConfig);
|
|
125
125
|
}
|
|
126
126
|
function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProject, mainDir) {
|
|
127
|
+
const storybookMajorVersion = (0, utilities_1.storybookMajorVersion)(tree);
|
|
127
128
|
const offset = (0, devkit_1.offsetFromRoot)(projectRoot);
|
|
128
129
|
const useTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
129
130
|
// First let's check if old configuration file exists
|
|
@@ -156,8 +157,8 @@ function createStorybookTsconfigFile(tree, projectRoot, uiFramework, isRootProje
|
|
|
156
157
|
uiFramework === '@storybook/react-vite'
|
|
157
158
|
? ''
|
|
158
159
|
: undefined,
|
|
159
|
-
module: useTsSolution ? 'esnext' : undefined,
|
|
160
|
-
moduleResolution: useTsSolution ? 'bundler' : undefined,
|
|
160
|
+
module: storybookMajorVersion === 10 || useTsSolution ? 'esnext' : undefined,
|
|
161
|
+
moduleResolution: storybookMajorVersion === 10 || useTsSolution ? 'bundler' : undefined,
|
|
161
162
|
jsx: useTsSolution && uiFramework !== '@storybook/angular'
|
|
162
163
|
? 'preserve'
|
|
163
164
|
: undefined,
|
|
@@ -415,7 +416,8 @@ function createProjectStorybookDir(tree, projectName, uiFramework, js, tsConfigu
|
|
|
415
416
|
devkit_1.logger.warn(`Storybook configuration files already exist for ${projectName}!`);
|
|
416
417
|
return;
|
|
417
418
|
}
|
|
418
|
-
const
|
|
419
|
+
const storybookMajor = ((0, utilities_1.storybookMajorVersion)(tree) ?? 10) <= 9 ? 9 : 10;
|
|
420
|
+
const templatePath = (0, path_1.join)(__dirname, `../files/v${storybookMajor}/project-files${tsConfiguration ? '-ts' : ''}`);
|
|
419
421
|
(0, devkit_1.generateFiles)(tree, templatePath, root, {
|
|
420
422
|
tmpl: '',
|
|
421
423
|
uiFramework,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAUpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA8DlC,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"}
|
|
@@ -4,7 +4,6 @@ exports.initGenerator = initGenerator;
|
|
|
4
4
|
exports.initGeneratorInternal = initGeneratorInternal;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
|
-
const semver_1 = require("semver");
|
|
8
7
|
const plugin_1 = require("../../plugins/plugin");
|
|
9
8
|
const utilities_1 = require("../../utils/utilities");
|
|
10
9
|
const versions_1 = require("../../utils/versions");
|
|
@@ -14,12 +13,7 @@ function checkDependenciesInstalled(host, schema) {
|
|
|
14
13
|
'@nx/storybook': versions_1.nxVersion,
|
|
15
14
|
'@nx/web': versions_1.nxVersion,
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
if ((0, utilities_1.storybookMajorVersion)() >= 7 &&
|
|
19
|
-
(0, utilities_1.getInstalledStorybookVersion)() &&
|
|
20
|
-
(0, semver_1.gte)((0, utilities_1.getInstalledStorybookVersion)(), '7.0.0')) {
|
|
21
|
-
storybookVersionToInstall = (0, utilities_1.getInstalledStorybookVersion)();
|
|
22
|
-
}
|
|
16
|
+
const storybookVersionToInstall = (0, utilities_1.getStorybookVersionToInstall)(host);
|
|
23
17
|
devDependencies['storybook'] = storybookVersionToInstall;
|
|
24
18
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
25
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calling-storybook-cli.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/migrate-10/calling-storybook-cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,MAAM,CA4CtD;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC/B,OAAO,CAOT"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callUpgrade = callUpgrade;
|
|
4
|
+
exports.checkStorybookInstalled = checkStorybookInstalled;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
function callUpgrade(schema) {
|
|
8
|
+
const packageManager = (0, devkit_1.detectPackageManager)();
|
|
9
|
+
const pm = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
10
|
+
try {
|
|
11
|
+
devkit_1.output.log({
|
|
12
|
+
title: `Calling sb upgrade`,
|
|
13
|
+
bodyLines: [
|
|
14
|
+
`ℹ️ Nx will call the Storybook CLI to upgrade your @storybook/* packages to the latest version.`,
|
|
15
|
+
`📖 You can read more about the Storybook upgrade command here: https://storybook.js.org/docs/react/configure/upgrading`,
|
|
16
|
+
],
|
|
17
|
+
color: 'blue',
|
|
18
|
+
});
|
|
19
|
+
(0, child_process_1.execSync)(`${pm.dlx} ${packageManager === 'yarn' ? 'storybook' : 'storybook@latest'} upgrade ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, {
|
|
20
|
+
stdio: [0, 1, 2],
|
|
21
|
+
windowsHide: false,
|
|
22
|
+
});
|
|
23
|
+
devkit_1.output.log({
|
|
24
|
+
title: `Storybook packages upgraded.`,
|
|
25
|
+
bodyLines: [
|
|
26
|
+
`☑️ The upgrade command was successful.`,
|
|
27
|
+
`Your Storybook packages are now at the latest version.`,
|
|
28
|
+
],
|
|
29
|
+
color: 'green',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
devkit_1.output.log({
|
|
34
|
+
title: 'Migration failed',
|
|
35
|
+
bodyLines: [
|
|
36
|
+
`🚨 The Storybook CLI failed to upgrade your @storybook/* packages to the latest version.`,
|
|
37
|
+
`Please try running the sb upgrade command manually:`,
|
|
38
|
+
`${pm.exec} storybook@latest upgrade`,
|
|
39
|
+
],
|
|
40
|
+
color: 'red',
|
|
41
|
+
});
|
|
42
|
+
console.log(e);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function checkStorybookInstalled(packageJson) {
|
|
47
|
+
return ((packageJson.dependencies['storybook'] ||
|
|
48
|
+
packageJson.devDependencies['storybook']) &&
|
|
49
|
+
(packageJson.dependencies['@nx/storybook'] ||
|
|
50
|
+
packageJson.devDependencies['@nx/storybook']));
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-10.d.ts","sourceRoot":"","sources":["../../../../../../packages/storybook/src/generators/migrate-10/migrate-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,IAAI,EAAE,MAAM,YAAY,CAAC;AAIzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAgBlE;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrate10Generator = migrate10Generator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const output_1 = require("nx/src/utils/output");
|
|
6
|
+
const calling_storybook_cli_1 = require("./calling-storybook-cli");
|
|
7
|
+
async function migrate10Generator(tree, schema) {
|
|
8
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
9
|
+
if (!(0, calling_storybook_cli_1.checkStorybookInstalled)(packageJson)) {
|
|
10
|
+
output_1.output.error({
|
|
11
|
+
title: 'No Storybook packages installed',
|
|
12
|
+
bodyLines: [
|
|
13
|
+
`🚨 Nx did not find any Storybook packages installed in your workspace.`,
|
|
14
|
+
`So no migration is necessary.`,
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
(0, calling_storybook_cli_1.callUpgrade)(schema);
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
21
|
+
}
|
|
22
|
+
exports.default = migrate10Generator;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cli": "nx",
|
|
3
|
+
"title": "Migrate Storybook to version 10.",
|
|
4
|
+
"description": "Migrate Storybook to version 10.",
|
|
5
|
+
"$id": "migrate-10",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"autoAcceptAllPrompts": {
|
|
9
|
+
"type": "boolean",
|
|
10
|
+
"description": "Say yes to all the prompts from the Storybook CLI migration scripts.",
|
|
11
|
+
"default": false
|
|
12
|
+
},
|
|
13
|
+
"configDir": {
|
|
14
|
+
"type": "array",
|
|
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
|
+
"default": []
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +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;AAKlC,wBAA8B,oBAAoB,CAAC,IAAI,EAAE,IAAI,iBAa5D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateToStorybook10;
|
|
4
|
+
const output_1 = require("nx/src/utils/output");
|
|
5
|
+
const migrate_10_1 = require("../../generators/migrate-10/migrate-10");
|
|
6
|
+
async function migrateToStorybook10(tree) {
|
|
7
|
+
output_1.output.log({
|
|
8
|
+
title: 'Migrating Storybook to v10',
|
|
9
|
+
bodyLines: [
|
|
10
|
+
`🚀 This migration will update your Storybook configuration to v10.`,
|
|
11
|
+
`It will call the @nx/storybook:migrate-10 generator for you.`,
|
|
12
|
+
`You can read more about the migration and how this generator works here:`,
|
|
13
|
+
`https://nx.dev/nx-api/storybook/generators/migrate-10`,
|
|
14
|
+
],
|
|
15
|
+
});
|
|
16
|
+
return (0, migrate_10_1.default)(tree, {
|
|
17
|
+
autoAcceptAllPrompts: true,
|
|
18
|
+
});
|
|
19
|
+
}
|
package/src/utils/utilities.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ export declare const Constants: {
|
|
|
11
11
|
coreAddonPrefix: string;
|
|
12
12
|
uiFrameworks7: string[];
|
|
13
13
|
};
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
14
|
+
export declare function getStorybookVersionToInstall(tree: Tree): string;
|
|
15
|
+
export declare function storybookMajorVersion(tree?: Tree): number | undefined;
|
|
16
|
+
export declare function getInstalledStorybookVersion(tree?: Tree): string | undefined;
|
|
16
17
|
export declare function safeFileDelete(tree: Tree, path: string): boolean;
|
|
17
18
|
export type TsConfig = {
|
|
18
19
|
extends: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,mBAAmB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAKlC,eAAO,MAAM,SAAS;;;;;;;;;CA0BrB,CAAC;AAGF,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,UAYtD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAwBrE;AAED,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAsB5E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAOhE;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,IAAI,CAYN;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAEnC;AAED,wBAAgB,uCAAuC,CAAC,OAAO,EAAE;IAC/D,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAAC;CAC3C,GAAG;IACF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CA2EA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA4CjE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAcvE;AAED,wBAAgB,aAAa,IAAI,MAAM,CAQtC"}
|
package/src/utils/utilities.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Constants = void 0;
|
|
4
|
+
exports.getStorybookVersionToInstall = getStorybookVersionToInstall;
|
|
4
5
|
exports.storybookMajorVersion = storybookMajorVersion;
|
|
5
6
|
exports.getInstalledStorybookVersion = getInstalledStorybookVersion;
|
|
6
7
|
exports.safeFileDelete = safeFileDelete;
|
|
@@ -10,11 +11,13 @@ exports.findStorybookAndBuildTargetsAndCompiler = findStorybookAndBuildTargetsAn
|
|
|
10
11
|
exports.isTheFileAStory = isTheFileAStory;
|
|
11
12
|
exports.getTsSourceFile = getTsSourceFile;
|
|
12
13
|
exports.pleaseUpgrade = pleaseUpgrade;
|
|
14
|
+
const devkit_1 = require("@nx/devkit");
|
|
13
15
|
const fs_1 = require("fs");
|
|
14
16
|
const js_1 = require("@nx/js");
|
|
15
17
|
const ts = require("typescript");
|
|
16
18
|
const semver_1 = require("semver");
|
|
17
19
|
const path_1 = require("path");
|
|
20
|
+
const versions_1 = require("./versions");
|
|
18
21
|
exports.Constants = {
|
|
19
22
|
addonDependencies: ['@storybook/addons'],
|
|
20
23
|
tsConfigExclusions: ['stories', '**/*.stories.ts'],
|
|
@@ -42,7 +45,33 @@ exports.Constants = {
|
|
|
42
45
|
'@storybook/web-components-vite',
|
|
43
46
|
],
|
|
44
47
|
};
|
|
45
|
-
function
|
|
48
|
+
function getStorybookVersionToInstall(tree) {
|
|
49
|
+
let storybookVersionToInstall = versions_1.storybookVersion;
|
|
50
|
+
const installedStorybookMajorVersion = storybookMajorVersion(tree);
|
|
51
|
+
const installedStorybookVersion = getInstalledStorybookVersion(tree);
|
|
52
|
+
if (installedStorybookMajorVersion >= 7 &&
|
|
53
|
+
installedStorybookVersion &&
|
|
54
|
+
(0, semver_1.gte)(installedStorybookVersion, '7.0.0')) {
|
|
55
|
+
storybookVersionToInstall = installedStorybookVersion;
|
|
56
|
+
}
|
|
57
|
+
return storybookVersionToInstall;
|
|
58
|
+
}
|
|
59
|
+
function storybookMajorVersion(tree) {
|
|
60
|
+
let foundStorybookPackageVersion;
|
|
61
|
+
if (tree) {
|
|
62
|
+
const rootPkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
63
|
+
foundStorybookPackageVersion =
|
|
64
|
+
rootPkgJson?.dependencies?.['storybook'] ||
|
|
65
|
+
rootPkgJson?.devDependencies?.['storybook'];
|
|
66
|
+
}
|
|
67
|
+
if (foundStorybookPackageVersion) {
|
|
68
|
+
try {
|
|
69
|
+
return (0, semver_1.major)(foundStorybookPackageVersion);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// unable to parse, fallback to requiring version from disk
|
|
73
|
+
}
|
|
74
|
+
}
|
|
46
75
|
try {
|
|
47
76
|
const storybookPackageVersion = require((0, path_1.join)('storybook', 'package.json')).version;
|
|
48
77
|
return (0, semver_1.major)(storybookPackageVersion);
|
|
@@ -51,7 +80,18 @@ function storybookMajorVersion() {
|
|
|
51
80
|
return undefined;
|
|
52
81
|
}
|
|
53
82
|
}
|
|
54
|
-
function getInstalledStorybookVersion() {
|
|
83
|
+
function getInstalledStorybookVersion(tree) {
|
|
84
|
+
let foundStorybookPackageVersion;
|
|
85
|
+
if (tree) {
|
|
86
|
+
const rootPkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
87
|
+
foundStorybookPackageVersion =
|
|
88
|
+
rootPkgJson?.dependencies?.['storybook'] ||
|
|
89
|
+
rootPkgJson?.devDependencies?.['storybook'];
|
|
90
|
+
}
|
|
91
|
+
if (foundStorybookPackageVersion) {
|
|
92
|
+
return foundStorybookPackageVersion;
|
|
93
|
+
}
|
|
94
|
+
// unable to find in root packageJson, fallback to requiring version from disk
|
|
55
95
|
try {
|
|
56
96
|
const storybookPackageVersion = require((0, path_1.join)('storybook', 'package.json')).version;
|
|
57
97
|
return storybookPackageVersion;
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare const nxVersion: any;
|
|
|
2
2
|
export declare const litVersion = "^2.6.1";
|
|
3
3
|
export declare const tsNodeVersion = "10.9.1";
|
|
4
4
|
export declare const tsLibVersion = "^2.3.0";
|
|
5
|
-
export declare const storybookVersion = "^
|
|
5
|
+
export declare const storybookVersion = "^10.0.0";
|
|
6
6
|
export declare const reactVersion = "^18.2.0";
|
|
7
7
|
export declare const viteVersion = "^6.0.0";
|
|
8
8
|
export declare const coreJsVersion = "^3.36.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/storybook/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,aAAa,YAAY,CAAC"}
|
package/src/utils/versions.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.nxVersion = require('../../package.json').version;
|
|
|
5
5
|
exports.litVersion = '^2.6.1';
|
|
6
6
|
exports.tsNodeVersion = '10.9.1';
|
|
7
7
|
exports.tsLibVersion = '^2.3.0';
|
|
8
|
-
exports.storybookVersion = '^
|
|
8
|
+
exports.storybookVersion = '^10.0.0';
|
|
9
9
|
exports.reactVersion = '^18.2.0';
|
|
10
10
|
exports.viteVersion = '^6.0.0';
|
|
11
11
|
exports.coreJsVersion = '^3.36.1';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|