@nx/storybook 16.0.0-beta.1

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/executors.json +26 -0
  5. package/generators.json +58 -0
  6. package/index.d.ts +3 -0
  7. package/index.js +10 -0
  8. package/index.js.map +1 -0
  9. package/migrations.json +294 -0
  10. package/package.json +49 -0
  11. package/presets/cypress.d.ts +22 -0
  12. package/presets/cypress.js +9 -0
  13. package/presets/cypress.js.map +1 -0
  14. package/src/executors/build-storybook/build-storybook.impl.d.ts +7 -0
  15. package/src/executors/build-storybook/build-storybook.impl.js +58 -0
  16. package/src/executors/build-storybook/build-storybook.impl.js.map +1 -0
  17. package/src/executors/build-storybook/compat.d.ts +2 -0
  18. package/src/executors/build-storybook/compat.js +6 -0
  19. package/src/executors/build-storybook/compat.js.map +1 -0
  20. package/src/executors/build-storybook/schema.json +122 -0
  21. package/src/executors/storybook/compat.d.ts +2 -0
  22. package/src/executors/storybook/compat.js +6 -0
  23. package/src/executors/storybook/compat.js.map +1 -0
  24. package/src/executors/storybook/schema.json +94 -0
  25. package/src/executors/storybook/storybook.impl.d.ts +11 -0
  26. package/src/executors/storybook/storybook.impl.js +53 -0
  27. package/src/executors/storybook/storybook.impl.js.map +1 -0
  28. package/src/executors/utils.d.ts +12 -0
  29. package/src/executors/utils.js +148 -0
  30. package/src/executors/utils.js.map +1 -0
  31. package/src/generators/configuration/configuration.d.ts +5 -0
  32. package/src/generators/configuration/configuration.js +191 -0
  33. package/src/generators/configuration/configuration.js.map +1 -0
  34. package/src/generators/configuration/lib/user-prompts.d.ts +6 -0
  35. package/src/generators/configuration/lib/user-prompts.js +90 -0
  36. package/src/generators/configuration/lib/user-prompts.js.map +1 -0
  37. package/src/generators/configuration/lib/util-functions.d.ts +27 -0
  38. package/src/generators/configuration/lib/util-functions.js +359 -0
  39. package/src/generators/configuration/lib/util-functions.js.map +1 -0
  40. package/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +46 -0
  41. package/src/generators/configuration/project-files/.storybook/preview.js__tmpl__ +0 -0
  42. package/src/generators/configuration/project-files/.storybook/tsconfig.json__tmpl__ +26 -0
  43. package/src/generators/configuration/project-files-7/.storybook/main.js__tmpl__ +34 -0
  44. package/src/generators/configuration/project-files-7/.storybook/preview.js__tmpl__ +0 -0
  45. package/src/generators/configuration/project-files-7/.storybook/tsconfig.json__tmpl__ +26 -0
  46. package/src/generators/configuration/project-files-7-ts/.storybook/main.ts__tmpl__ +36 -0
  47. package/src/generators/configuration/project-files-7-ts/.storybook/preview.ts__tmpl__ +0 -0
  48. package/src/generators/configuration/project-files-7-ts/.storybook/tsconfig.json__tmpl__ +28 -0
  49. package/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__ +49 -0
  50. package/src/generators/configuration/project-files-ts/.storybook/preview.ts__tmpl__ +0 -0
  51. package/src/generators/configuration/project-files-ts/.storybook/tsconfig.json__tmpl__ +28 -0
  52. package/src/generators/configuration/schema.d.ts +19 -0
  53. package/src/generators/configuration/schema.json +124 -0
  54. package/src/generators/cypress-project/cypress-project.d.ts +14 -0
  55. package/src/generators/cypress-project/cypress-project.js +98 -0
  56. package/src/generators/cypress-project/cypress-project.js.map +1 -0
  57. package/src/generators/cypress-project/files/cypress.config.ts__tpl__ +6 -0
  58. package/src/generators/cypress-project/schema.json +55 -0
  59. package/src/generators/init/init.d.ts +5 -0
  60. package/src/generators/init/init.js +181 -0
  61. package/src/generators/init/init.js.map +1 -0
  62. package/src/generators/init/schema.d.ts +8 -0
  63. package/src/generators/init/schema.json +60 -0
  64. package/src/generators/migrate-7/calling-storybook-cli.d.ts +13 -0
  65. package/src/generators/migrate-7/calling-storybook-cli.js +85 -0
  66. package/src/generators/migrate-7/calling-storybook-cli.js.map +1 -0
  67. package/src/generators/migrate-7/files/storybook-migration-summary.md__tmpl__ +80 -0
  68. package/src/generators/migrate-7/helper-functions.d.ts +69 -0
  69. package/src/generators/migrate-7/helper-functions.js +449 -0
  70. package/src/generators/migrate-7/helper-functions.js.map +1 -0
  71. package/src/generators/migrate-7/migrate-7.d.ts +5 -0
  72. package/src/generators/migrate-7/migrate-7.js +73 -0
  73. package/src/generators/migrate-7/migrate-7.js.map +1 -0
  74. package/src/generators/migrate-7/schema.d.ts +9 -0
  75. package/src/generators/migrate-7/schema.json +35 -0
  76. package/src/migrations/update-13-4-6/set-project-build-config.d.ts +2 -0
  77. package/src/migrations/update-13-4-6/set-project-build-config.js +61 -0
  78. package/src/migrations/update-13-4-6/set-project-build-config.js.map +1 -0
  79. package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.d.ts +6 -0
  80. package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.js +120 -0
  81. package/src/migrations/update-14-0-0/migrate-defaults-5-to-6/migrate-defaults-5-to-6.js.map +1 -0
  82. package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.d.ts +8 -0
  83. package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.js +294 -0
  84. package/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.js.map +1 -0
  85. package/src/migrations/update-14-0-0/migrate-to-storybook-6.d.ts +2 -0
  86. package/src/migrations/update-14-0-0/migrate-to-storybook-6.js +13 -0
  87. package/src/migrations/update-14-0-0/migrate-to-storybook-6.js.map +1 -0
  88. package/src/migrations/update-14-1-8/change-storybook-targets-generator.d.ts +4 -0
  89. package/src/migrations/update-14-1-8/change-storybook-targets-generator.js +105 -0
  90. package/src/migrations/update-14-1-8/change-storybook-targets-generator.js.map +1 -0
  91. package/src/migrations/update-14-1-8/change-storybook-targets.d.ts +2 -0
  92. package/src/migrations/update-14-1-8/change-storybook-targets.js +11 -0
  93. package/src/migrations/update-14-1-8/change-storybook-targets.js.map +1 -0
  94. package/src/migrations/update-15-0-0/add-storybook-inputs.d.ts +2 -0
  95. package/src/migrations/update-15-0-0/add-storybook-inputs.js +47 -0
  96. package/src/migrations/update-15-0-0/add-storybook-inputs.js.map +1 -0
  97. package/src/migrations/update-15-4-6/refactor-executor-options.d.ts +2 -0
  98. package/src/migrations/update-15-4-6/refactor-executor-options.js +67 -0
  99. package/src/migrations/update-15-4-6/refactor-executor-options.js.map +1 -0
  100. package/src/migrations/update-15-5-3/ensure-webpack-package.d.ts +2 -0
  101. package/src/migrations/update-15-5-3/ensure-webpack-package.js +33 -0
  102. package/src/migrations/update-15-5-3/ensure-webpack-package.js.map +1 -0
  103. package/src/migrations/update-15-7-0/add-addon-essentials-to-all.d.ts +24 -0
  104. package/src/migrations/update-15-7-0/add-addon-essentials-to-all.js +278 -0
  105. package/src/migrations/update-15-7-0/add-addon-essentials-to-all.js.map +1 -0
  106. package/src/migrations/update-15-7-0/remove-root-config.d.ts +14 -0
  107. package/src/migrations/update-15-7-0/remove-root-config.js +210 -0
  108. package/src/migrations/update-15-7-0/remove-root-config.js.map +1 -0
  109. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  110. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  111. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  112. package/src/utils/models.d.ts +5 -0
  113. package/src/utils/models.js +3 -0
  114. package/src/utils/models.js.map +1 -0
  115. package/src/utils/test-configs/.storybook/main.js +8 -0
  116. package/src/utils/test-configs/.storybook/tsconfig.json +19 -0
  117. package/src/utils/testing.d.ts +3 -0
  118. package/src/utils/testing.js +38 -0
  119. package/src/utils/testing.js.map +1 -0
  120. package/src/utils/utilities.d.ts +53 -0
  121. package/src/utils/utilities.js +255 -0
  122. package/src/utils/utilities.js.map +1 -0
  123. package/src/utils/versions.d.ts +20 -0
  124. package/src/utils/versions.js +24 -0
  125. package/src/utils/versions.js.map +1 -0
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const build_storybook_impl_1 = require("./build-storybook.impl");
5
+ exports.default = (0, devkit_1.convertNxExecutor)(build_storybook_impl_1.default);
6
+ //# sourceMappingURL=compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/build-storybook/compat.ts"],"names":[],"mappings":";;AAAA,uCAA+C;AAC/C,iEAA4D;AAE5D,kBAAe,IAAA,0BAAiB,EAAC,8BAAsB,CAAC,CAAC"}
@@ -0,0 +1,122 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Storybook Builder",
5
+ "cli": "nx",
6
+ "description": "Build storybook in production mode.",
7
+ "type": "object",
8
+ "presets": [
9
+ {
10
+ "name": "Default minimum setup",
11
+ "keys": ["uiFramework", "outputDir", "configDir"]
12
+ }
13
+ ],
14
+ "properties": {
15
+ "uiFramework": {
16
+ "type": "string",
17
+ "description": "Storybook framework npm package.",
18
+ "enum": [
19
+ "@storybook/react",
20
+ "@storybook/html",
21
+ "@storybook/web-components",
22
+ "@storybook/vue",
23
+ "@storybook/vue3",
24
+ "@storybook/svelte"
25
+ ],
26
+ "default": "@storybook/react",
27
+ "x-priority": "important"
28
+ },
29
+ "outputDir": {
30
+ "type": "string",
31
+ "description": "Directory where to store built files.",
32
+ "x-completion-type": "directory"
33
+ },
34
+ "styles": {
35
+ "type": "array",
36
+ "description": "Global styles to be included in the build.",
37
+ "items": {
38
+ "$ref": "#/definitions/extraEntryPoint"
39
+ }
40
+ },
41
+ "stylePreprocessorOptions": {
42
+ "type": "object",
43
+ "description": "Options to pass to style preprocessors.",
44
+ "properties": {
45
+ "includePaths": {
46
+ "type": "array",
47
+ "description": "The paths to include. Paths will be resolved to workspace root.",
48
+ "items": {
49
+ "type": "string"
50
+ }
51
+ }
52
+ }
53
+ },
54
+ "docsMode": {
55
+ "type": "boolean",
56
+ "description": "Build a documentation-only site using addon-docs.",
57
+ "default": false
58
+ },
59
+ "staticDir": {
60
+ "type": "array",
61
+ "description": "Directory where to load static files from, array of strings.",
62
+ "items": {
63
+ "type": "string"
64
+ },
65
+ "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."
66
+ },
67
+ "configDir": {
68
+ "type": "string",
69
+ "description": "Directory where to load Storybook configurations from.",
70
+ "x-completion-type": "directory",
71
+ "x-priority": "important"
72
+ },
73
+ "loglevel": {
74
+ "type": "string",
75
+ "description": "Controls level of logging during build. Can be one of: [silly, verbose, info (default), warn, error, silent].",
76
+ "pattern": "(silly|verbose|info|warn|silent)"
77
+ },
78
+ "quiet": {
79
+ "type": "boolean",
80
+ "description": "Suppress verbose build output."
81
+ },
82
+ "docs": {
83
+ "type": "boolean",
84
+ "description": "Starts Storybook in documentation mode. Learn more about it : https://storybook.js.org/docs/react/writing-docs/build-documentation#preview-storybooks-documentation."
85
+ }
86
+ },
87
+ "definitions": {
88
+ "extraEntryPoint": {
89
+ "oneOf": [
90
+ {
91
+ "type": "object",
92
+ "properties": {
93
+ "input": {
94
+ "type": "string",
95
+ "description": "The file to include.",
96
+ "x-completion-type": "file"
97
+ },
98
+ "bundleName": {
99
+ "type": "string",
100
+ "pattern": "^[\\w\\-.]*$",
101
+ "description": "The bundle name for this extra entry point."
102
+ },
103
+ "inject": {
104
+ "type": "boolean",
105
+ "description": "If the bundle will be referenced in the HTML file.",
106
+ "default": true
107
+ }
108
+ },
109
+ "additionalProperties": false,
110
+ "required": ["input"]
111
+ },
112
+ {
113
+ "type": "string",
114
+ "description": "The file to include."
115
+ }
116
+ ]
117
+ }
118
+ },
119
+ "additionalProperties": true,
120
+ "required": ["uiFramework", "configDir"],
121
+ "examplesFile": "../../../docs/build-storybook-executor-examples.md"
122
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const storybook_impl_1 = require("./storybook.impl");
5
+ exports.default = (0, devkit_1.convertNxExecutor)(storybook_impl_1.default);
6
+ //# sourceMappingURL=compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/storybook/compat.ts"],"names":[],"mappings":";;AAAA,uCAA+C;AAC/C,qDAAiD;AAEjD,kBAAe,IAAA,0BAAiB,EAAC,wBAAiB,CAAC,CAAC"}
@@ -0,0 +1,94 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Storybook Dev Builder",
5
+ "cli": "nx",
6
+ "description": "Serve up Storybook in development mode.",
7
+ "type": "object",
8
+ "presets": [
9
+ {
10
+ "name": "Default minimum setup",
11
+ "keys": ["uiFramework", "port", "configDir"]
12
+ }
13
+ ],
14
+ "properties": {
15
+ "uiFramework": {
16
+ "type": "string",
17
+ "description": "Storybook framework npm package.",
18
+ "enum": [
19
+ "@storybook/react",
20
+ "@storybook/html",
21
+ "@storybook/web-components",
22
+ "@storybook/vue",
23
+ "@storybook/vue3",
24
+ "@storybook/svelte"
25
+ ],
26
+ "default": "@storybook/react",
27
+ "x-priority": "important"
28
+ },
29
+ "port": {
30
+ "type": "number",
31
+ "description": "Port to listen on.",
32
+ "default": 9009
33
+ },
34
+ "previewUrl": {
35
+ "type": "string",
36
+ "description": "Preview URL."
37
+ },
38
+ "host": {
39
+ "type": "string",
40
+ "description": "Host to listen on.",
41
+ "default": "localhost"
42
+ },
43
+ "staticDir": {
44
+ "type": "array",
45
+ "description": "Directory where to load static files from, array of strings.",
46
+ "items": {
47
+ "type": "string"
48
+ },
49
+ "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."
50
+ },
51
+ "configDir": {
52
+ "type": "string",
53
+ "description": "Directory where to load Storybook configurations from.",
54
+ "x-completion-type": "directory",
55
+ "x-priority": "important"
56
+ },
57
+ "https": {
58
+ "type": "boolean",
59
+ "description": "Serve Storybook over HTTPS. Note: You must provide your own certificate information.",
60
+ "default": false
61
+ },
62
+ "open": {
63
+ "type": "boolean",
64
+ "description": "Open browser window automatically."
65
+ },
66
+ "ci": {
67
+ "type": "boolean",
68
+ "description": "CI mode (skip interactive prompts, don't open browser).",
69
+ "default": false
70
+ },
71
+ "loglevel": {
72
+ "type": "string",
73
+ "description": "Controls level of logging during build. Can be one of: [silly, verbose, info (default), warn, error, silent].",
74
+ "pattern": "(silly|verbose|info|warn|silent)"
75
+ },
76
+ "quiet": {
77
+ "type": "boolean",
78
+ "description": "Suppress verbose build output."
79
+ },
80
+ "docs": {
81
+ "type": "boolean",
82
+ "description": "Starts Storybook in documentation mode. Learn more about it : https://storybook.js.org/docs/react/writing-docs/build-documentation#preview-storybooks-documentation."
83
+ },
84
+ "docsMode": {
85
+ "type": "boolean",
86
+ "description": "Starts Storybook in documentation mode. Learn more about it : https://storybook.js.org/docs/react/writing-docs/build-documentation#preview-storybooks-documentation.",
87
+ "default": false
88
+ }
89
+ },
90
+ "additionalProperties": true,
91
+ "definitions": {},
92
+ "required": ["uiFramework", "configDir"],
93
+ "examplesFile": "../../../docs/storybook-executor-examples.md"
94
+ }
@@ -0,0 +1,11 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import 'dotenv/config';
3
+ import { CLIOptions } from '@storybook/types';
4
+ import { CommonNxStorybookConfig } from '../../utils/models';
5
+ export default function storybookExecutor(options: CLIOptions & CommonNxStorybookConfig, context: ExecutorContext): AsyncGenerator<{
6
+ success: boolean;
7
+ info?: {
8
+ port: number;
9
+ baseUrl?: string;
10
+ };
11
+ }>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const build = require("@storybook/core-server");
5
+ require("dotenv/config");
6
+ const utilities_1 = require("../../utils/utilities");
7
+ const utils_1 = require("../utils");
8
+ function storybookExecutor(options, context) {
9
+ var _a;
10
+ return tslib_1.__asyncGenerator(this, arguments, function* storybookExecutor_1() {
11
+ var _b;
12
+ const storybook7 = (0, utilities_1.isStorybookV7)();
13
+ (0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
14
+ if (storybook7) {
15
+ const buildOptions = options;
16
+ const result = yield tslib_1.__await(runInstance(buildOptions, storybook7));
17
+ yield yield tslib_1.__await({
18
+ success: true,
19
+ info: {
20
+ port: result === null || result === void 0 ? void 0 : result.port,
21
+ baseUrl: `${options.https ? 'https' : 'http'}://${(_a = options.host) !== null && _a !== void 0 ? _a : 'localhost'}:${result === null || result === void 0 ? void 0 : result.port}`,
22
+ },
23
+ });
24
+ yield tslib_1.__await(new Promise(() => { }));
25
+ }
26
+ else {
27
+ // TODO(katerina): Remove when Storybook 7
28
+ // print warnings
29
+ (0, utils_1.runStorybookSetupCheck)(options);
30
+ (0, utils_1.pleaseUpgrade)();
31
+ let frameworkPath = (0, utils_1.getStorybookFrameworkPath)(options.uiFramework);
32
+ const frameworkOptions = (yield tslib_1.__await((_b = frameworkPath, Promise.resolve().then(() => require(_b))))).default;
33
+ const buildOptions = Object.assign(Object.assign(Object.assign({}, options), frameworkOptions), { frameworkPresets: [...(frameworkOptions.frameworkPresets || [])] });
34
+ yield tslib_1.__await(runInstance(buildOptions, storybook7));
35
+ yield yield tslib_1.__await({ success: true });
36
+ yield tslib_1.__await(new Promise(() => { }));
37
+ }
38
+ });
39
+ }
40
+ exports.default = storybookExecutor;
41
+ function runInstance(options, storybook7) {
42
+ var _a;
43
+ const env = (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : 'development';
44
+ process.env.NODE_ENV = env;
45
+ if (storybook7) {
46
+ return build['build'](Object.assign(Object.assign({}, options), { mode: 'dev' })); // TODO(katerina): Change to actual types when Storybook 7
47
+ }
48
+ else {
49
+ // TODO(katerina): Remove when Storybook 7
50
+ return build.buildDev(Object.assign(Object.assign({}, options), { configType: env.toUpperCase(), mode: 'dev' }));
51
+ }
52
+ }
53
+ //# sourceMappingURL=storybook.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook.impl.js","sourceRoot":"","sources":["../../../../../../packages/storybook/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":";;;AACA,gDAAgD;AAChD,yBAAuB;AACvB,qDAG+B;AAC/B,oCAIkB;AAIlB,SAA+B,iBAAiB,CAC9C,OAA6C,EAC7C,OAAwB;;;;QAKxB,MAAM,UAAU,GAAG,IAAA,yBAAa,GAAE,CAAC;QACnC,IAAA,sCAA0B,EAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACnE,IAAI,UAAU,EAAE;YACd,MAAM,YAAY,GAAe,OAAO,CAAC;YACzC,MAAM,MAAM,GAAqB,sBAAM,WAAW,CAChD,YAAY,EACZ,UAAU,CACX,CAAA,CAAC;YACF,4BAAM;gBACJ,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI;oBAClB,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAC1C,MAAA,OAAO,CAAC,IAAI,mCAAI,WAClB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,EAAE;iBACnB;aACF,CAAA,CAAC;YACF,sBAAM,IAAI,OAAO,CAAuB,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA,CAAC;SACnD;aAAM;YACL,0CAA0C;YAC1C,iBAAiB;YACjB,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;YAChC,IAAA,qBAAa,GAAE,CAAC;YAEhB,IAAI,aAAa,GAAG,IAAA,iCAAyB,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACnE,MAAM,gBAAgB,GAAG,CAAC,4BAAa,aAAa,6CAAC,CAAC,CAAC,OAAO,CAAC;YAC/D,MAAM,YAAY,iDACb,OAAO,GACP,gBAAgB,KACnB,gBAAgB,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,GACjE,CAAC;YAEF,sBAAM,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA,CAAC;YAC5C,4BAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA,CAAC;YACxB,sBAAM,IAAI,OAAO,CAAuB,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA,CAAC;SACnD;;CACF;AA3CD,oCA2CC;AAED,SAAS,WAAW,CAAC,OAAmB,EAAE,UAAmB;;IAC3D,MAAM,GAAG,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,aAAa,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC;IAE3B,IAAI,UAAU,EAAE;QACd,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,gCACjB,OAAO,KACV,IAAI,EAAE,KAAK,GACL,CAAC,CAAC,CAAC,0DAA0D;KACtE;SAAM;QACL,0CAA0C;QAC1C,OAAO,KAAK,CAAC,QAAQ,CAAC,gCACjB,OAAO,KACV,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,EAC7B,IAAI,EAAE,KAAK,GACL,CAAC,CAAC;KACX;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import 'dotenv/config';
2
+ import ts = require('typescript');
3
+ import { CommonNxStorybookConfig, UiFramework } from '../utils/models';
4
+ import { CLIOptions } from '@storybook/types';
5
+ export interface NodePackage {
6
+ name: string;
7
+ version: string;
8
+ }
9
+ export declare function getStorybookFrameworkPath(uiFramework: UiFramework): any;
10
+ export declare function runStorybookSetupCheck(options: CLIOptions & CommonNxStorybookConfig): void;
11
+ export declare function pleaseUpgrade(): void;
12
+ export declare function builderIsWebpackButNotWebpack5(storybookConfig: ts.SourceFile): boolean;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.builderIsWebpackButNotWebpack5 = exports.pleaseUpgrade = exports.runStorybookSetupCheck = exports.getStorybookFrameworkPath = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const typescript_1 = require("nx/src/utils/typescript");
6
+ require("dotenv/config");
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ const semver_1 = require("semver");
10
+ const ts = require("typescript");
11
+ // TODO(katerina): Remove when Storybook 7
12
+ function getStorybookFrameworkPath(uiFramework) {
13
+ const serverOptionsPaths = {
14
+ '@storybook/react': '@storybook/react/dist/cjs/server/options',
15
+ '@storybook/html': '@storybook/html/dist/cjs/server/options',
16
+ '@storybook/vue': '@storybook/vue/dist/cjs/server/options',
17
+ '@storybook/vue3': '@storybook/vue3/dist/cjs/server/options',
18
+ '@storybook/web-components': '@storybook/web-components/dist/cjs/server/options',
19
+ '@storybook/svelte': '@storybook/svelte/dist/cjs/server/options',
20
+ };
21
+ if (isStorybookV62onwards(uiFramework)) {
22
+ return serverOptionsPaths[uiFramework];
23
+ }
24
+ else {
25
+ return `${uiFramework}/dist/server/options`;
26
+ }
27
+ }
28
+ exports.getStorybookFrameworkPath = getStorybookFrameworkPath;
29
+ // TODO(katerina): Remove when Storybook 7
30
+ function isStorybookV62onwards(uiFramework) {
31
+ try {
32
+ const storybookPackageVersion = require((0, path_1.join)(uiFramework, 'package.json')).version;
33
+ return (0, semver_1.gte)(storybookPackageVersion, '6.2.0-rc.4');
34
+ }
35
+ catch (e) {
36
+ try {
37
+ const storybookPackageVersion = require((0, path_1.join)('@storybook/core-server', 'package.json')).version;
38
+ return (0, semver_1.gte)(storybookPackageVersion, '6.2.0-rc.4');
39
+ }
40
+ catch (e) {
41
+ throw new Error(`Error: ${e}
42
+
43
+ It looks like you don\'t have Storybook installed.
44
+ Please run the @nrwl/storybook:configuration generator,
45
+ or run "npm/yarn" again to install your dependencies.`);
46
+ }
47
+ }
48
+ }
49
+ // TODO(katerina): Remove when Storybook 7
50
+ function runStorybookSetupCheck(options) {
51
+ webpackFinalPropertyCheck(options);
52
+ reactWebpack5Check(options);
53
+ }
54
+ exports.runStorybookSetupCheck = runStorybookSetupCheck;
55
+ function pleaseUpgrade() {
56
+ devkit_1.logger.warn(`
57
+ Please consider upgrading to Storybook version 7,
58
+ as version 6 is no longer maintained.
59
+
60
+ Here is a guide on how to upgrade:
61
+ https://nx.dev/packages/storybook/generators/migrate-7
62
+ `);
63
+ }
64
+ exports.pleaseUpgrade = pleaseUpgrade;
65
+ // TODO(katerina): Remove when Storybook 7
66
+ function reactWebpack5Check(options) {
67
+ if (options.uiFramework === '@storybook/react') {
68
+ const source = mainJsTsFileContent(options.configDir);
69
+ const rootSource = mainJsTsFileContent('.storybook');
70
+ // check whether the current Storybook configuration has the webpack 5 builder enabled
71
+ if (builderIsWebpackButNotWebpack5(source) &&
72
+ builderIsWebpackButNotWebpack5(rootSource)) {
73
+ devkit_1.logger.warn(`
74
+ It looks like you use Webpack 5 but your Storybook setup is not configured to leverage that
75
+ and thus falls back to Webpack 4.
76
+ Make sure you upgrade your Storybook config to use Webpack 5.
77
+
78
+ - https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#upgrade
79
+
80
+ `);
81
+ }
82
+ }
83
+ }
84
+ // TODO(katerina): Remove when Storybook 7
85
+ function mainJsTsFileContent(configFolder) {
86
+ let storybookConfigFilePath = (0, devkit_1.joinPathFragments)(configFolder, 'main.js');
87
+ if (!(0, fs_1.existsSync)(storybookConfigFilePath)) {
88
+ storybookConfigFilePath = (0, devkit_1.joinPathFragments)(configFolder, 'main.ts');
89
+ }
90
+ if (!(0, fs_1.existsSync)(storybookConfigFilePath)) {
91
+ // looks like there's no main config file, so skip
92
+ return;
93
+ }
94
+ const storybookConfig = (0, fs_1.readFileSync)(storybookConfigFilePath, {
95
+ encoding: 'utf8',
96
+ });
97
+ return ts.createSourceFile(storybookConfigFilePath, storybookConfig, ts.ScriptTarget.Latest, true);
98
+ }
99
+ // TODO(katerina): Remove when Storybook 7
100
+ function webpackFinalPropertyCheck(options) {
101
+ let placesToCheck = [
102
+ {
103
+ path: (0, devkit_1.joinPathFragments)('.storybook', 'webpack.config.js'),
104
+ result: false,
105
+ },
106
+ {
107
+ path: (0, devkit_1.joinPathFragments)(options.configDir, 'webpack.config.js'),
108
+ result: false,
109
+ },
110
+ ];
111
+ placesToCheck = placesToCheck
112
+ .map((entry) => {
113
+ return Object.assign(Object.assign({}, entry), { result: (0, fs_1.existsSync)(entry.path) });
114
+ })
115
+ .filter((x) => x.result === true);
116
+ if (placesToCheck.length > 0) {
117
+ devkit_1.logger.warn(`
118
+ You have a webpack.config.js files in your Storybook configuration:
119
+ ${placesToCheck.map((x) => `- "${x.path}"`).join('\n ')}
120
+
121
+ Consider switching to the "webpackFinal" property declared in "main.js" (or "main.ts") instead.
122
+ ${options.uiFramework === '@storybook/react'
123
+ ? 'https://nx.dev/storybook/migrate-webpack-final-react'
124
+ : 'https://nx.dev/storybook/migrate-webpack-final-angular'}
125
+ `);
126
+ }
127
+ }
128
+ // TODO(katerina): Remove when Storybook 7
129
+ function builderIsWebpackButNotWebpack5(storybookConfig) {
130
+ const importArray = (0, typescript_1.findNodes)(storybookConfig, [
131
+ ts.SyntaxKind.PropertyAssignment,
132
+ ]);
133
+ let builderIsWebpackNot5 = false;
134
+ importArray.forEach((parent) => {
135
+ var _a, _b, _c;
136
+ const identifier = (0, typescript_1.findNodes)(parent, ts.SyntaxKind.Identifier);
137
+ const sbBuilder = (0, typescript_1.findNodes)(parent, ts.SyntaxKind.StringLiteral);
138
+ const builderText = (_b = (_a = sbBuilder === null || sbBuilder === void 0 ? void 0 : sbBuilder[0]) === null || _a === void 0 ? void 0 : _a.getText()) !== null && _b !== void 0 ? _b : '';
139
+ if (((_c = identifier === null || identifier === void 0 ? void 0 : identifier[0]) === null || _c === void 0 ? void 0 : _c.getText()) === 'builder' &&
140
+ builderText.includes('webpack') &&
141
+ !builderText.includes('webpack5')) {
142
+ builderIsWebpackNot5 = true;
143
+ }
144
+ });
145
+ return builderIsWebpackNot5;
146
+ }
147
+ exports.builderIsWebpackButNotWebpack5 = builderIsWebpackButNotWebpack5;
148
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../packages/storybook/src/executors/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAuD;AACvD,wDAAoD;AACpD,yBAAuB;AACvB,2BAA8C;AAC9C,+BAA4B;AAC5B,mCAA6B;AAC7B,iCAAkC;AASlC,0CAA0C;AAC1C,SAAgB,yBAAyB,CAAC,WAAwB;IAChE,MAAM,kBAAkB,GAAG;QACzB,kBAAkB,EAAE,0CAA0C;QAC9D,iBAAiB,EAAE,yCAAyC;QAC5D,gBAAgB,EAAE,wCAAwC;QAC1D,iBAAiB,EAAE,yCAAyC;QAC5D,2BAA2B,EACzB,mDAAmD;QACrD,mBAAmB,EAAE,2CAA2C;KACjE,CAAC;IAEF,IAAI,qBAAqB,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAC;KACxC;SAAM;QACL,OAAO,GAAG,WAAW,sBAAsB,CAAC;KAC7C;AACH,CAAC;AAhBD,8DAgBC;AAED,0CAA0C;AAC1C,SAAS,qBAAqB,CAAC,WAAmB;IAChD,IAAI;QACF,MAAM,uBAAuB,GAAG,OAAO,CAAC,IAAA,WAAI,EAC1C,WAAW,EACX,cAAc,CACf,CAAC,CAAC,OAAO,CAAC;QACX,OAAO,IAAA,YAAG,EAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;KACnD;IAAC,OAAO,CAAC,EAAE;QACV,IAAI;YACF,MAAM,uBAAuB,GAAG,OAAO,CAAC,I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CAAC,UAAU,CAAC,kBAAkB;KACjC,CAAC,CAAC;IACH,IAAI,oBAAoB,GAAG,KAAK,CAAC;IACjC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;;QAC7B,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,IAAA,sBAAS,EAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,CAAC,CAAC,0CAAE,OAAO,EAAE,mCAAI,EAAE,CAAC;QACpD,IACE,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,CAAC,CAAC,0CAAE,OAAO,EAAE,MAAK,SAAS;YACxC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC/B,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EACjC;YACA,oBAAoB,GAAG,IAAI,CAAC;SAC7B;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AArBD,wEAqBC"}
@@ -0,0 +1,5 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { StorybookConfigureSchema } from './schema';
3
+ export declare function configurationGenerator(tree: Tree, rawSchema: StorybookConfigureSchema): Promise<GeneratorCallback>;
4
+ export default configurationGenerator;
5
+ export declare const configurationSchematic: (generatorOptions: StorybookConfigureSchema) => (tree: any, context: any) => Promise<any>;