@storybook/cli 7.0.0-alpha.31 → 7.0.0-alpha.34
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/.eslintrc.js +35 -0
- package/bin/index.js +1 -1
- package/dist/generate.d.ts +1 -0
- package/dist/generate.js +265 -0
- package/dist/generate.mjs +265 -0
- package/package.json +18 -12
- package/rendererAssets/svelte/Button.svelte +4 -3
- package/{dist/cjs/generators/ANGULAR → templates/angular}/template-csf/.storybook/tsconfig.json +0 -0
- package/{dist/cjs/generators/ANGULAR → templates/angular}/template-csf/.storybook/typings.d.ts +0 -0
- package/{dist/cjs/generators/AURELIA → templates/aurelia}/template-csf/.storybook/tsconfig.json +0 -0
- package/{dist/cjs/generators/AURELIA → templates/aurelia}/template-csf/.storybook/typings.d.ts +0 -0
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/addons.js +1 -1
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/index.js +13 -6
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/rn-addons.js +1 -1
- package/templates/react-native/template-csf/storybook/stories/Button/Button.stories.js +20 -0
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/Button/index.js +8 -10
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/CenterView/index.js +8 -9
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/CenterView/style.js +3 -3
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/Welcome/Welcome.stories.js +2 -3
- package/templates/react-native/template-csf/storybook/stories/Welcome/index.js +57 -0
- package/templates/react-native/template-csf/storybook/stories/index.js +2 -0
- package/templates/server/template-csf/.storybook/preview.js +5 -0
- package/dist/cjs/NpmOptions.js +0 -1
- package/dist/cjs/add.js +0 -149
- package/dist/cjs/automigrate/fixes/angular12.js +0 -74
- package/dist/cjs/automigrate/fixes/builder-vite.js +0 -118
- package/dist/cjs/automigrate/fixes/cra5.js +0 -82
- package/dist/cjs/automigrate/fixes/eslint-plugin.js +0 -126
- package/dist/cjs/automigrate/fixes/index.js +0 -45
- package/dist/cjs/automigrate/fixes/mainjsFramework.js +0 -94
- package/dist/cjs/automigrate/fixes/new-frameworks.js +0 -258
- package/dist/cjs/automigrate/fixes/npm7.js +0 -57
- package/dist/cjs/automigrate/fixes/sb-scripts.js +0 -140
- package/dist/cjs/automigrate/fixes/vue3.js +0 -77
- package/dist/cjs/automigrate/fixes/webpack5.js +0 -151
- package/dist/cjs/automigrate/helpers/getEslintInfo.js +0 -28
- package/dist/cjs/automigrate/index.js +0 -98
- package/dist/cjs/automigrate/types.js +0 -5
- package/dist/cjs/babel-config.js +0 -65
- package/dist/cjs/build.js +0 -36
- package/dist/cjs/detect-nextjs.js +0 -33
- package/dist/cjs/detect-webpack.js +0 -39
- package/dist/cjs/detect.js +0 -179
- package/dist/cjs/dev.js +0 -66
- package/dist/cjs/dirs.js +0 -12
- package/dist/cjs/extract.js +0 -93
- package/dist/cjs/generate.js +0 -215
- package/dist/cjs/generators/ANGULAR/angular-helpers.js +0 -106
- package/dist/cjs/generators/ANGULAR/index.js +0 -95
- package/dist/cjs/generators/AURELIA/index.js +0 -41
- package/dist/cjs/generators/EMBER/index.js +0 -20
- package/dist/cjs/generators/HTML/index.js +0 -15
- package/dist/cjs/generators/MARIONETTE/index.js +0 -15
- package/dist/cjs/generators/MARKO/index.js +0 -15
- package/dist/cjs/generators/MITHRIL/index.js +0 -15
- package/dist/cjs/generators/PREACT/index.js +0 -15
- package/dist/cjs/generators/RAX/index.js +0 -28
- package/dist/cjs/generators/REACT/index.js +0 -15
- package/dist/cjs/generators/REACT_NATIVE/index.js +0 -55
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/addons.js +0 -7
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/index.js +0 -31
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/rn-addons.js +0 -5
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Button/Button.stories.js +0 -23
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Button/index.js +0 -32
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/CenterView/index.js +0 -31
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/CenterView/style.js +0 -15
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/Welcome.stories.js +0 -15
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/index.js +0 -68
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/index.js +0 -5
- package/dist/cjs/generators/REACT_SCRIPTS/index.js +0 -68
- package/dist/cjs/generators/RIOT/index.js +0 -17
- package/dist/cjs/generators/SERVER/index.js +0 -20
- package/dist/cjs/generators/SERVER/template-csf/.storybook/preview.js +0 -12
- package/dist/cjs/generators/SFC_VUE/index.js +0 -15
- package/dist/cjs/generators/SVELTE/index.js +0 -59
- package/dist/cjs/generators/VUE/index.js +0 -17
- package/dist/cjs/generators/VUE3/index.js +0 -17
- package/dist/cjs/generators/WEB-COMPONENTS/index.js +0 -17
- package/dist/cjs/generators/WEBPACK_REACT/index.js +0 -15
- package/dist/cjs/generators/baseGenerator.js +0 -208
- package/dist/cjs/generators/configure.js +0 -83
- package/dist/cjs/generators/types.js +0 -5
- package/dist/cjs/helpers.js +0 -258
- package/dist/cjs/initiate.js +0 -295
- package/dist/cjs/js-package-manager/JsPackageManager.js +0 -358
- package/dist/cjs/js-package-manager/JsPackageManagerFactory.js +0 -71
- package/dist/cjs/js-package-manager/NPMProxy.js +0 -112
- package/dist/cjs/js-package-manager/PackageJson.js +0 -5
- package/dist/cjs/js-package-manager/Yarn1Proxy.js +0 -72
- package/dist/cjs/js-package-manager/Yarn2Proxy.js +0 -68
- package/dist/cjs/js-package-manager/index.js +0 -44
- package/dist/cjs/link.js +0 -99
- package/dist/cjs/migrate.js +0 -33
- package/dist/cjs/project_types.js +0 -263
- package/dist/cjs/repro-generators/configs.js +0 -201
- package/dist/cjs/repro-generators/scripts.js +0 -338
- package/dist/cjs/repro-next.js +0 -182
- package/dist/cjs/repro-templates.js +0 -103
- package/dist/cjs/repro.js +0 -194
- package/dist/cjs/typings.d.ts +0 -3
- package/dist/cjs/upgrade.js +0 -170
- package/dist/cjs/utils.js +0 -22
- package/dist/cjs/versions.js +0 -89
- package/dist/cjs/warn.js +0 -32
- package/dist/cjs/window.d.js +0 -5
- package/dist/esm/NpmOptions.js +0 -0
- package/dist/esm/add.js +0 -121
- package/dist/esm/automigrate/fixes/angular12.js +0 -58
- package/dist/esm/automigrate/fixes/builder-vite.js +0 -103
- package/dist/esm/automigrate/fixes/cra5.js +0 -66
- package/dist/esm/automigrate/fixes/eslint-plugin.js +0 -111
- package/dist/esm/automigrate/fixes/index.js +0 -12
- package/dist/esm/automigrate/fixes/mainjsFramework.js +0 -76
- package/dist/esm/automigrate/fixes/new-frameworks.js +0 -234
- package/dist/esm/automigrate/fixes/npm7.js +0 -45
- package/dist/esm/automigrate/fixes/sb-scripts.js +0 -119
- package/dist/esm/automigrate/fixes/vue3.js +0 -60
- package/dist/esm/automigrate/fixes/webpack5.js +0 -131
- package/dist/esm/automigrate/helpers/getEslintInfo.js +0 -14
- package/dist/esm/automigrate/index.js +0 -80
- package/dist/esm/automigrate/types.js +0 -1
- package/dist/esm/babel-config.js +0 -42
- package/dist/esm/build.js +0 -22
- package/dist/esm/detect-nextjs.js +0 -24
- package/dist/esm/detect-webpack.js +0 -30
- package/dist/esm/detect.js +0 -152
- package/dist/esm/dev.js +0 -47
- package/dist/esm/dirs.js +0 -4
- package/dist/esm/extract.js +0 -77
- package/dist/esm/generate.js +0 -162
- package/dist/esm/generators/ANGULAR/angular-helpers.js +0 -82
- package/dist/esm/generators/ANGULAR/index.js +0 -76
- package/dist/esm/generators/ANGULAR/template-csf/.storybook/tsconfig.json +0 -10
- package/dist/esm/generators/ANGULAR/template-csf/.storybook/typings.d.ts +0 -4
- package/dist/esm/generators/AURELIA/index.js +0 -32
- package/dist/esm/generators/AURELIA/template-csf/.storybook/tsconfig.json +0 -9
- package/dist/esm/generators/AURELIA/template-csf/.storybook/typings.d.ts +0 -4
- package/dist/esm/generators/EMBER/index.js +0 -12
- package/dist/esm/generators/HTML/index.js +0 -7
- package/dist/esm/generators/MARIONETTE/index.js +0 -7
- package/dist/esm/generators/MARKO/index.js +0 -7
- package/dist/esm/generators/MITHRIL/index.js +0 -7
- package/dist/esm/generators/PREACT/index.js +0 -7
- package/dist/esm/generators/RAX/index.js +0 -20
- package/dist/esm/generators/REACT/index.js +0 -7
- package/dist/esm/generators/REACT_NATIVE/index.js +0 -42
- package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/Button/Button.stories.js +0 -12
- package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/index.js +0 -54
- package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/index.js +0 -2
- package/dist/esm/generators/REACT_SCRIPTS/index.js +0 -49
- package/dist/esm/generators/RIOT/index.js +0 -9
- package/dist/esm/generators/SERVER/index.js +0 -11
- package/dist/esm/generators/SERVER/template-csf/.storybook/preview.js +0 -5
- package/dist/esm/generators/SFC_VUE/index.js +0 -7
- package/dist/esm/generators/SVELTE/index.js +0 -44
- package/dist/esm/generators/VUE/index.js +0 -9
- package/dist/esm/generators/VUE3/index.js +0 -9
- package/dist/esm/generators/WEB-COMPONENTS/index.js +0 -9
- package/dist/esm/generators/WEBPACK_REACT/index.js +0 -7
- package/dist/esm/generators/baseGenerator.js +0 -191
- package/dist/esm/generators/configure.js +0 -69
- package/dist/esm/generators/types.js +0 -1
- package/dist/esm/helpers.js +0 -207
- package/dist/esm/initiate.js +0 -254
- package/dist/esm/js-package-manager/JsPackageManager.js +0 -334
- package/dist/esm/js-package-manager/JsPackageManagerFactory.js +0 -57
- package/dist/esm/js-package-manager/NPMProxy.js +0 -99
- package/dist/esm/js-package-manager/PackageJson.js +0 -1
- package/dist/esm/js-package-manager/Yarn1Proxy.js +0 -62
- package/dist/esm/js-package-manager/Yarn2Proxy.js +0 -58
- package/dist/esm/js-package-manager/index.js +0 -3
- package/dist/esm/link.js +0 -69
- package/dist/esm/migrate.js +0 -25
- package/dist/esm/project_types.js +0 -248
- package/dist/esm/repro-generators/configs.js +0 -174
- package/dist/esm/repro-generators/scripts.js +0 -307
- package/dist/esm/repro-next.js +0 -163
- package/dist/esm/repro-templates.js +0 -94
- package/dist/esm/repro.js +0 -170
- package/dist/esm/typings.d.ts +0 -3
- package/dist/esm/upgrade.js +0 -132
- package/dist/esm/utils.js +0 -13
- package/dist/esm/versions.js +0 -82
- package/dist/esm/warn.js +0 -16
- package/dist/esm/window.d.js +0 -1
- package/dist/types/NpmOptions.d.ts +0 -4
- package/dist/types/add.d.ts +0 -10
- package/dist/types/automigrate/fixes/angular12.d.ts +0 -15
- package/dist/types/automigrate/fixes/builder-vite.d.ts +0 -19
- package/dist/types/automigrate/fixes/cra5.d.ts +0 -15
- package/dist/types/automigrate/fixes/eslint-plugin.d.ts +0 -15
- package/dist/types/automigrate/fixes/index.d.ts +0 -3
- package/dist/types/automigrate/fixes/mainjsFramework.d.ts +0 -8
- package/dist/types/automigrate/fixes/new-frameworks.d.ts +0 -31
- package/dist/types/automigrate/fixes/npm7.d.ts +0 -9
- package/dist/types/automigrate/fixes/sb-scripts.d.ts +0 -23
- package/dist/types/automigrate/fixes/vue3.d.ts +0 -15
- package/dist/types/automigrate/fixes/webpack5.d.ts +0 -26
- package/dist/types/automigrate/helpers/getEslintInfo.d.ts +0 -2
- package/dist/types/automigrate/index.d.ts +0 -7
- package/dist/types/automigrate/types.d.ts +0 -15
- package/dist/types/babel-config.d.ts +0 -4
- package/dist/types/build.d.ts +0 -1
- package/dist/types/detect-nextjs.d.ts +0 -2
- package/dist/types/detect-webpack.d.ts +0 -2
- package/dist/types/detect.d.ts +0 -16
- package/dist/types/dev.d.ts +0 -1
- package/dist/types/dirs.d.ts +0 -1
- package/dist/types/extract.d.ts +0 -1
- package/dist/types/generate.d.ts +0 -1
- package/dist/types/generators/ANGULAR/angular-helpers.d.ts +0 -6
- package/dist/types/generators/ANGULAR/index.d.ts +0 -3
- package/dist/types/generators/AURELIA/index.d.ts +0 -3
- package/dist/types/generators/EMBER/index.d.ts +0 -3
- package/dist/types/generators/HTML/index.d.ts +0 -3
- package/dist/types/generators/MARIONETTE/index.d.ts +0 -3
- package/dist/types/generators/MARKO/index.d.ts +0 -3
- package/dist/types/generators/MITHRIL/index.d.ts +0 -3
- package/dist/types/generators/PREACT/index.d.ts +0 -3
- package/dist/types/generators/RAX/index.d.ts +0 -3
- package/dist/types/generators/REACT/index.d.ts +0 -3
- package/dist/types/generators/REACT_NATIVE/index.d.ts +0 -4
- package/dist/types/generators/REACT_SCRIPTS/index.d.ts +0 -3
- package/dist/types/generators/RIOT/index.d.ts +0 -3
- package/dist/types/generators/SERVER/index.d.ts +0 -3
- package/dist/types/generators/SFC_VUE/index.d.ts +0 -3
- package/dist/types/generators/SVELTE/index.d.ts +0 -3
- package/dist/types/generators/VUE/index.d.ts +0 -3
- package/dist/types/generators/VUE3/index.d.ts +0 -3
- package/dist/types/generators/WEB-COMPONENTS/index.d.ts +0 -3
- package/dist/types/generators/WEBPACK_REACT/index.d.ts +0 -3
- package/dist/types/generators/baseGenerator.d.ts +0 -5
- package/dist/types/generators/configure.d.ts +0 -19
- package/dist/types/generators/types.d.ts +0 -38
- package/dist/types/helpers.d.ts +0 -26
- package/dist/types/initiate.d.ts +0 -3
- package/dist/types/js-package-manager/JsPackageManager.d.ts +0 -118
- package/dist/types/js-package-manager/JsPackageManagerFactory.d.ts +0 -4
- package/dist/types/js-package-manager/NPMProxy.d.ts +0 -23
- package/dist/types/js-package-manager/PackageJson.d.ts +0 -4
- package/dist/types/js-package-manager/Yarn1Proxy.d.ts +0 -17
- package/dist/types/js-package-manager/Yarn2Proxy.d.ts +0 -17
- package/dist/types/js-package-manager/index.d.ts +0 -3
- package/dist/types/link.d.ts +0 -7
- package/dist/types/migrate.d.ts +0 -1
- package/dist/types/project_types.d.ts +0 -64
- package/dist/types/repro-generators/configs.d.ts +0 -44
- package/dist/types/repro-generators/scripts.d.ts +0 -44
- package/dist/types/repro-next.d.ts +0 -8
- package/dist/types/repro-templates.d.ts +0 -73
- package/dist/types/repro.d.ts +0 -14
- package/dist/types/upgrade.d.ts +0 -19
- package/dist/types/utils.d.ts +0 -2
- package/dist/types/versions.d.ts +0 -82
- package/dist/types/warn.d.ts +0 -5
package/dist/cjs/detect.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.detect = detect;
|
|
7
|
-
exports.detectBuilder = detectBuilder;
|
|
8
|
-
exports.detectFrameworkPreset = detectFrameworkPreset;
|
|
9
|
-
exports.detectLanguage = detectLanguage;
|
|
10
|
-
exports.isStorybookInstalled = isStorybookInstalled;
|
|
11
|
-
|
|
12
|
-
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
|
|
14
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
15
|
-
|
|
16
|
-
var _findUp = _interopRequireDefault(require("find-up"));
|
|
17
|
-
|
|
18
|
-
var _project_types = require("./project_types");
|
|
19
|
-
|
|
20
|
-
var _helpers = require("./helpers");
|
|
21
|
-
|
|
22
|
-
var _detectNextjs = require("./detect-nextjs");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
const viteConfigFiles = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];
|
|
27
|
-
|
|
28
|
-
const hasDependency = (packageJson, name, matcher) => {
|
|
29
|
-
var _packageJson$dependen, _packageJson$devDepen;
|
|
30
|
-
|
|
31
|
-
const version = ((_packageJson$dependen = packageJson.dependencies) === null || _packageJson$dependen === void 0 ? void 0 : _packageJson$dependen[name]) || ((_packageJson$devDepen = packageJson.devDependencies) === null || _packageJson$devDepen === void 0 ? void 0 : _packageJson$devDepen[name]);
|
|
32
|
-
|
|
33
|
-
if (version && typeof matcher === 'function') {
|
|
34
|
-
return matcher(version);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return !!version;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const hasPeerDependency = (packageJson, name, matcher) => {
|
|
41
|
-
var _packageJson$peerDepe;
|
|
42
|
-
|
|
43
|
-
const version = (_packageJson$peerDepe = packageJson.peerDependencies) === null || _packageJson$peerDepe === void 0 ? void 0 : _packageJson$peerDepe[name];
|
|
44
|
-
|
|
45
|
-
if (version && typeof matcher === 'function') {
|
|
46
|
-
return matcher(version);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return !!version;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const getFrameworkPreset = (packageJson, framework) => {
|
|
53
|
-
const matcher = {
|
|
54
|
-
dependencies: [false],
|
|
55
|
-
peerDependencies: [false],
|
|
56
|
-
files: [false]
|
|
57
|
-
};
|
|
58
|
-
const {
|
|
59
|
-
preset,
|
|
60
|
-
files,
|
|
61
|
-
dependencies,
|
|
62
|
-
peerDependencies,
|
|
63
|
-
matcherFunction
|
|
64
|
-
} = framework;
|
|
65
|
-
let dependencySearches = [];
|
|
66
|
-
|
|
67
|
-
if (Array.isArray(dependencies)) {
|
|
68
|
-
dependencySearches = dependencies.map(name => [name, undefined]);
|
|
69
|
-
} else if (typeof dependencies === 'object') {
|
|
70
|
-
dependencySearches = Object.entries(dependencies);
|
|
71
|
-
} // Must check the length so the `[false]` isn't overwritten if `{ dependencies: [] }`
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (dependencySearches.length > 0) {
|
|
75
|
-
matcher.dependencies = dependencySearches.map(([name, matchFn]) => hasDependency(packageJson, name, matchFn));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let peerDependencySearches = [];
|
|
79
|
-
|
|
80
|
-
if (Array.isArray(peerDependencies)) {
|
|
81
|
-
peerDependencySearches = peerDependencies.map(name => [name, undefined]);
|
|
82
|
-
} else if (typeof peerDependencies === 'object') {
|
|
83
|
-
peerDependencySearches = Object.entries(peerDependencies);
|
|
84
|
-
} // Must check the length so the `[false]` isn't overwritten if `{ peerDependencies: [] }`
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (peerDependencySearches.length > 0) {
|
|
88
|
-
matcher.peerDependencies = peerDependencySearches.map(([name, matchFn]) => hasPeerDependency(packageJson, name, matchFn));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (Array.isArray(files) && files.length > 0) {
|
|
92
|
-
matcher.files = files.map(name => _fs.default.existsSync(_path.default.join(process.cwd(), name)));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return matcherFunction(matcher) ? preset : null;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
function detectFrameworkPreset(packageJson = {}) {
|
|
99
|
-
const result = [..._project_types.supportedTemplates, _project_types.unsupportedTemplate].find(framework => {
|
|
100
|
-
return getFrameworkPreset(packageJson, framework) !== null;
|
|
101
|
-
});
|
|
102
|
-
return result ? result.preset : _project_types.ProjectType.UNDETECTED;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Attempts to detect which builder to use, by searching for a vite config file. If one is found, the vite builder
|
|
106
|
-
* will be used, otherwise, webpack5 is the default.
|
|
107
|
-
*
|
|
108
|
-
* @returns CoreBuilder
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
function detectBuilder(packageManager) {
|
|
113
|
-
const viteConfig = _findUp.default.sync(viteConfigFiles);
|
|
114
|
-
|
|
115
|
-
if (viteConfig) {
|
|
116
|
-
(0, _helpers.paddedLog)('Detected vite project, setting builder to @storybook/builder-vite');
|
|
117
|
-
return _project_types.CoreBuilder.Vite;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const nextJSVersion = (0, _detectNextjs.detectNextJS)(packageManager);
|
|
121
|
-
|
|
122
|
-
if (nextJSVersion) {
|
|
123
|
-
if (nextJSVersion >= 11) {
|
|
124
|
-
return _project_types.CoreBuilder.Webpack5;
|
|
125
|
-
}
|
|
126
|
-
} // Fallback to webpack5
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return _project_types.CoreBuilder.Webpack5;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function isStorybookInstalled(dependencies, force) {
|
|
133
|
-
if (!dependencies) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!force && dependencies.devDependencies) {
|
|
138
|
-
if (_project_types.SUPPORTED_RENDERERS.reduce((storybookPresent, framework) => storybookPresent || !!dependencies.devDependencies[`@storybook/${framework}`], false)) {
|
|
139
|
-
return _project_types.ProjectType.ALREADY_HAS_STORYBOOK;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function detectLanguage(packageJson) {
|
|
147
|
-
let language = _project_types.SupportedLanguage.JAVASCRIPT;
|
|
148
|
-
const bowerJson = (0, _helpers.getBowerJson)();
|
|
149
|
-
|
|
150
|
-
if (!packageJson && !bowerJson) {
|
|
151
|
-
return language;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (hasDependency(packageJson || bowerJson, 'typescript')) {
|
|
155
|
-
language = _project_types.SupportedLanguage.TYPESCRIPT;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return language;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function detect(packageJson, options = {}) {
|
|
162
|
-
const bowerJson = (0, _helpers.getBowerJson)();
|
|
163
|
-
|
|
164
|
-
if (!packageJson && !bowerJson) {
|
|
165
|
-
return _project_types.ProjectType.UNDETECTED;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const storyBookInstalled = isStorybookInstalled(packageJson, options.force);
|
|
169
|
-
|
|
170
|
-
if (storyBookInstalled) {
|
|
171
|
-
return storyBookInstalled;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (options.html) {
|
|
175
|
-
return _project_types.ProjectType.HTML;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return detectFrameworkPreset(packageJson || bowerJson);
|
|
179
|
-
}
|
package/dist/cjs/dev.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dev = void 0;
|
|
7
|
-
|
|
8
|
-
var _tsDedent = require("ts-dedent");
|
|
9
|
-
|
|
10
|
-
var _readPkgUp = require("read-pkg-up");
|
|
11
|
-
|
|
12
|
-
var _nodeLogger = require("@storybook/node-logger");
|
|
13
|
-
|
|
14
|
-
var _coreServer = require("@storybook/core-server");
|
|
15
|
-
|
|
16
|
-
var _coreCommon = require("@storybook/core-common");
|
|
17
|
-
|
|
18
|
-
const dev = async cliOptions => {
|
|
19
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await (0, _coreServer.buildDevStandalone)(Object.assign({}, cliOptions, {
|
|
23
|
-
configDir: cliOptions.configDir || './.storybook',
|
|
24
|
-
configType: 'DEVELOPMENT',
|
|
25
|
-
ignorePreview: !!cliOptions.previewUrl && !cliOptions.forceBuildPreview,
|
|
26
|
-
docsMode: !!cliOptions.docs,
|
|
27
|
-
cache: _coreCommon.cache,
|
|
28
|
-
packageJson: (0, _readPkgUp.sync)({
|
|
29
|
-
cwd: __dirname
|
|
30
|
-
}).packageJson
|
|
31
|
-
}));
|
|
32
|
-
} catch (error) {
|
|
33
|
-
var _error$compilation;
|
|
34
|
-
|
|
35
|
-
// this is a weird bugfix, somehow 'node-pre-gyp' is polluting the npmLog header
|
|
36
|
-
_nodeLogger.instance.heading = '';
|
|
37
|
-
|
|
38
|
-
if (error instanceof Error) {
|
|
39
|
-
if (error.error) {
|
|
40
|
-
_nodeLogger.logger.error(error.error);
|
|
41
|
-
} else if (error.stats && error.stats.compilation.errors) {
|
|
42
|
-
error.stats.compilation.errors.forEach(e => _nodeLogger.logger.plain(e));
|
|
43
|
-
} else {
|
|
44
|
-
_nodeLogger.logger.error(error);
|
|
45
|
-
}
|
|
46
|
-
} else if ((_error$compilation = error.compilation) !== null && _error$compilation !== void 0 && _error$compilation.errors) {
|
|
47
|
-
error.compilation.errors.forEach(e => _nodeLogger.logger.plain(e));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_nodeLogger.logger.line();
|
|
51
|
-
|
|
52
|
-
_nodeLogger.logger.warn(error.close ? (0, _tsDedent.dedent)`
|
|
53
|
-
FATAL broken build!, will close the process,
|
|
54
|
-
Fix the error below and restart storybook.
|
|
55
|
-
` : (0, _tsDedent.dedent)`
|
|
56
|
-
Broken build, fix the error above.
|
|
57
|
-
You may need to refresh the browser.
|
|
58
|
-
`);
|
|
59
|
-
|
|
60
|
-
_nodeLogger.logger.line();
|
|
61
|
-
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
exports.dev = dev;
|
package/dist/cjs/dirs.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBaseDir = getBaseDir;
|
|
7
|
-
|
|
8
|
-
var _path = require("path");
|
|
9
|
-
|
|
10
|
-
function getBaseDir() {
|
|
11
|
-
return (0, _path.dirname)(require.resolve('@storybook/cli/package.json'));
|
|
12
|
-
}
|
package/dist/cjs/extract.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.extract = extract;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _fsExtra = require("fs-extra");
|
|
11
|
-
|
|
12
|
-
var _puppeteerCore = _interopRequireDefault(require("puppeteer-core"));
|
|
13
|
-
|
|
14
|
-
var _express = _interopRequireDefault(require("express"));
|
|
15
|
-
|
|
16
|
-
var _getPort = _interopRequireDefault(require("get-port"));
|
|
17
|
-
|
|
18
|
-
var _nodeLogger = require("@storybook/node-logger");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
const read = async url => {
|
|
23
|
-
const browser = await usePuppeteerBrowser();
|
|
24
|
-
const page = await browser.newPage();
|
|
25
|
-
await page.goto(url); // we don't know whether we are running against a new or old storybook
|
|
26
|
-
// FIXME: add tests for both
|
|
27
|
-
|
|
28
|
-
await page.waitForFunction(`
|
|
29
|
-
(window.__STORYBOOK_PREVIEW__ && window.__STORYBOOK_PREVIEW__.extract && window.__STORYBOOK_PREVIEW__.extract()) ||
|
|
30
|
-
(window.__STORYBOOK_STORY_STORE__ && window.__STORYBOOK_STORY_STORE__.extract && window.__STORYBOOK_STORY_STORE__.extract())
|
|
31
|
-
`);
|
|
32
|
-
const data = JSON.parse(await page.evaluate(async () => {
|
|
33
|
-
return JSON.stringify(window.__STORYBOOK_STORY_STORE__.getStoriesJsonData(), null, 2);
|
|
34
|
-
}));
|
|
35
|
-
setImmediate(() => {
|
|
36
|
-
browser.close();
|
|
37
|
-
});
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const useLocation = async input => {
|
|
42
|
-
// check for input's existence
|
|
43
|
-
await (0, _fsExtra.stat)(_path.default.resolve(input));
|
|
44
|
-
|
|
45
|
-
if (input.match(/^http/)) {
|
|
46
|
-
return [input, async () => {}];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const app = (0, _express.default)();
|
|
50
|
-
app.use(_express.default.static(input));
|
|
51
|
-
const port = await (0, _getPort.default)();
|
|
52
|
-
return new Promise(resolve => {
|
|
53
|
-
const server = app.listen(port, () => {
|
|
54
|
-
const result = `http://localhost:${port}/iframe.html`;
|
|
55
|
-
|
|
56
|
-
_nodeLogger.logger.info(`connecting to: ${result}`);
|
|
57
|
-
|
|
58
|
-
resolve([result, server.close.bind(server)]);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const usePuppeteerBrowser = async () => {
|
|
64
|
-
const args = ['--no-sandbox ', '--disable-setuid-sandbox'];
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
return await _puppeteerCore.default.launch({
|
|
68
|
-
args,
|
|
69
|
-
executablePath: process.env.SB_CHROMIUM_PATH
|
|
70
|
-
});
|
|
71
|
-
} catch (e) {
|
|
72
|
-
// it's not installed
|
|
73
|
-
_nodeLogger.logger.info('installing puppeteer...');
|
|
74
|
-
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
// eslint-disable-next-line global-require
|
|
77
|
-
require('child_process').exec(`node ${require.resolve(_path.default.join('puppeteer-core', 'install.js'))}`, error => error ? reject(error) : resolve(_puppeteerCore.default.launch({
|
|
78
|
-
args
|
|
79
|
-
})));
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
async function extract(input, targetPath) {
|
|
85
|
-
if (input && targetPath) {
|
|
86
|
-
const [location, exit] = await useLocation(input);
|
|
87
|
-
const data = await read(location);
|
|
88
|
-
await (0, _fsExtra.writeFile)(targetPath, JSON.stringify(data, null, 2));
|
|
89
|
-
await exit();
|
|
90
|
-
} else {
|
|
91
|
-
throw new Error('Extract: please specify a path where your built-storybook is (can be a public url) and a target directory');
|
|
92
|
-
}
|
|
93
|
-
}
|
package/dist/cjs/generate.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _commander = _interopRequireDefault(require("commander"));
|
|
4
|
-
|
|
5
|
-
var _path = _interopRequireDefault(require("path"));
|
|
6
|
-
|
|
7
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
-
|
|
9
|
-
var _envinfo = _interopRequireDefault(require("envinfo"));
|
|
10
|
-
|
|
11
|
-
var _leven = _interopRequireDefault(require("leven"));
|
|
12
|
-
|
|
13
|
-
var _readPkgUp = require("read-pkg-up");
|
|
14
|
-
|
|
15
|
-
var _nodeLogger = require("@storybook/node-logger");
|
|
16
|
-
|
|
17
|
-
var _initiate = require("./initiate");
|
|
18
|
-
|
|
19
|
-
var _add = require("./add");
|
|
20
|
-
|
|
21
|
-
var _migrate = require("./migrate");
|
|
22
|
-
|
|
23
|
-
var _extract = require("./extract");
|
|
24
|
-
|
|
25
|
-
var _upgrade = require("./upgrade");
|
|
26
|
-
|
|
27
|
-
var _repro = require("./repro");
|
|
28
|
-
|
|
29
|
-
var _reproNext = require("./repro-next");
|
|
30
|
-
|
|
31
|
-
var _link = require("./link");
|
|
32
|
-
|
|
33
|
-
var _automigrate = require("./automigrate");
|
|
34
|
-
|
|
35
|
-
var _babelConfig = require("./babel-config");
|
|
36
|
-
|
|
37
|
-
var _dev = require("./dev");
|
|
38
|
-
|
|
39
|
-
var _build = require("./build");
|
|
40
|
-
|
|
41
|
-
var _utils = require("./utils");
|
|
42
|
-
|
|
43
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
|
-
|
|
45
|
-
const pkg = (0, _readPkgUp.sync)({
|
|
46
|
-
cwd: __dirname
|
|
47
|
-
}).packageJson;
|
|
48
|
-
const consoleLogger = console;
|
|
49
|
-
|
|
50
|
-
_commander.default.option('--disable-telemetry', 'disable sending telemetry data', // default value is false, but if the user sets STORYBOOK_DISABLE_TELEMETRY, it can be true
|
|
51
|
-
process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMETRY !== 'false');
|
|
52
|
-
|
|
53
|
-
_commander.default.option('--enable-crash-reports', 'enable sending crash reports to telemetry data');
|
|
54
|
-
|
|
55
|
-
_commander.default.command('init').description('Initialize Storybook into your project.').option('-f --force', 'Force add Storybook').option('-s --skip-install', 'Skip installing deps').option('-N --use-npm', 'Use npm to install deps').option('--use-pnp', 'Enable pnp mode').option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser').option('-t --type <type>', 'Add Storybook for a specific project type').option('-y --yes', 'Answer yes to all prompts').option('-b --builder <builder>', 'Builder library').option('-l --linkable', 'Prepare installation for link (contributor helper)').action(options => (0, _initiate.initiate)(options, pkg).catch(err => {
|
|
56
|
-
_nodeLogger.logger.error(err);
|
|
57
|
-
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}));
|
|
60
|
-
|
|
61
|
-
_commander.default.command('add <addon>').description('Add an addon to your Storybook').option('-N --use-npm', 'Use NPM to build the Storybook server').option('-s --skip-postinstall', 'Skip package specific postinstall config modifications').action((addonName, options) => (0, _add.add)(addonName, options));
|
|
62
|
-
|
|
63
|
-
_commander.default.command('babelrc').description('generate the default storybook babel config into your current working directory').action(() => (0, _babelConfig.generateStorybookBabelConfigInCWD)());
|
|
64
|
-
|
|
65
|
-
_commander.default.command('upgrade').description('Upgrade your Storybook packages to the latest').option('-N --use-npm', 'Use NPM to build the Storybook server').option('-y --yes', 'Skip prompting the user').option('-n --dry-run', 'Only check for upgrades, do not install').option('-p --prerelease', 'Upgrade to the pre-release packages').option('-s --skip-check', 'Skip postinstall version and automigration checks').action(options => (0, _upgrade.upgrade)(options));
|
|
66
|
-
|
|
67
|
-
_commander.default.command('info').description('Prints debugging information about the local environment').action(() => {
|
|
68
|
-
consoleLogger.log(_chalk.default.bold('\nEnvironment Info:'));
|
|
69
|
-
|
|
70
|
-
_envinfo.default.run({
|
|
71
|
-
System: ['OS', 'CPU'],
|
|
72
|
-
Binaries: ['Node', 'Yarn', 'npm'],
|
|
73
|
-
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
|
74
|
-
npmPackages: '@storybook/*',
|
|
75
|
-
npmGlobalPackages: '@storybook/*'
|
|
76
|
-
}).then(consoleLogger.log);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
_commander.default.command('migrate [migration]').description('Run a Storybook codemod migration on your source files').option('-l --list', 'List available migrations').option('-g --glob <glob>', 'Glob for files upon which to apply the migration', '**/*.js').option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser').option('-n --dry-run', 'Dry run: verify the migration exists and show the files to which it will be applied').option('-r --rename <from-to>', 'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"').action((migration, {
|
|
80
|
-
configDir,
|
|
81
|
-
glob,
|
|
82
|
-
dryRun,
|
|
83
|
-
list,
|
|
84
|
-
rename,
|
|
85
|
-
parser
|
|
86
|
-
}) => {
|
|
87
|
-
(0, _migrate.migrate)(migration, {
|
|
88
|
-
configDir,
|
|
89
|
-
glob,
|
|
90
|
-
dryRun,
|
|
91
|
-
list,
|
|
92
|
-
rename,
|
|
93
|
-
parser,
|
|
94
|
-
logger: consoleLogger
|
|
95
|
-
}).catch(err => {
|
|
96
|
-
_nodeLogger.logger.error(err);
|
|
97
|
-
|
|
98
|
-
process.exit(1);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
_commander.default.command('extract [location] [output]').description('extract stories.json from a built version').action((location = 'storybook-static', output = _path.default.join(location, 'stories.json')) => (0, _extract.extract)(location, output).catch(e => {
|
|
103
|
-
_nodeLogger.logger.error(e);
|
|
104
|
-
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
_commander.default.command('repro [outputDirectory]').description('Create a reproduction from a set of possible templates').option('-f --renderer <renderer>', 'Filter on given renderer').option('-t --template <template>', 'Use the given template').option('-l --list', 'List available templates').option('-g --generator <generator>', 'Use custom generator command').option('--registry <registry>', 'which registry to use for storybook packages').option('--pnp', "Use Yarn Plug'n'Play mode instead of node_modules one").option('--local', "use storybook's local packages instead of yarn's registry").option('--e2e', 'Used in e2e context').action((outputDirectory, {
|
|
109
|
-
renderer,
|
|
110
|
-
template,
|
|
111
|
-
list,
|
|
112
|
-
e2e,
|
|
113
|
-
generator,
|
|
114
|
-
pnp,
|
|
115
|
-
local
|
|
116
|
-
}) => (0, _repro.repro)({
|
|
117
|
-
outputDirectory,
|
|
118
|
-
renderer,
|
|
119
|
-
template,
|
|
120
|
-
list,
|
|
121
|
-
e2e,
|
|
122
|
-
local,
|
|
123
|
-
generator,
|
|
124
|
-
pnp
|
|
125
|
-
}).catch(e => {
|
|
126
|
-
_nodeLogger.logger.error(e);
|
|
127
|
-
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}));
|
|
130
|
-
|
|
131
|
-
_commander.default.command('repro-next [filterValue]').description('Create a reproduction from a set of possible templates').option('-o --output <outDir>', 'Define an output directory').option('-b --branch <branch>', 'Define the branch to degit from', 'next').option('--no-init', 'Whether to download a template without an initialized Storybook', false).action((filterValue, options) => (0, _reproNext.reproNext)(Object.assign({
|
|
132
|
-
filterValue
|
|
133
|
-
}, options)).catch(e => {
|
|
134
|
-
_nodeLogger.logger.error(e);
|
|
135
|
-
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}));
|
|
138
|
-
|
|
139
|
-
_commander.default.command('link <repo-url-or-directory>').description('Pull down a repro from a URL (or a local directory), link it, and run storybook').option('--local', 'Link a local directory already in your file system').option('--no-start', 'Start the storybook', true).action((target, {
|
|
140
|
-
local,
|
|
141
|
-
start
|
|
142
|
-
}) => (0, _link.link)({
|
|
143
|
-
target,
|
|
144
|
-
local,
|
|
145
|
-
start
|
|
146
|
-
}).catch(e => {
|
|
147
|
-
_nodeLogger.logger.error(e);
|
|
148
|
-
|
|
149
|
-
process.exit(1);
|
|
150
|
-
}));
|
|
151
|
-
|
|
152
|
-
_commander.default.command('automigrate [fixId]').description('Check storybook for known problems or migrations and apply fixes').option('-y --yes', 'Skip prompting the user').option('-n --dry-run', 'Only check for fixes, do not actually run them').action((fixId, options) => (0, _automigrate.automigrate)(Object.assign({
|
|
153
|
-
fixId
|
|
154
|
-
}, options)).catch(e => {
|
|
155
|
-
_nodeLogger.logger.error(e);
|
|
156
|
-
|
|
157
|
-
process.exit(1);
|
|
158
|
-
}));
|
|
159
|
-
|
|
160
|
-
_commander.default.command('dev').option('-p, --port <number>', 'Port to run Storybook', str => parseInt(str, 10)).option('-h, --host <string>', 'Host to run Storybook').option('-s, --static-dir <dir-names>', 'Directory where to load static files from', _utils.parseList).option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from').option('--https', 'Serve Storybook over HTTPS. Note: You must provide your own certificate information.').option('--ssl-ca <ca>', 'Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)', _utils.parseList).option('--ssl-cert <cert>', 'Provide an SSL certificate. (Required with --https)').option('--ssl-key <key>', 'Provide an SSL key. (Required with --https)').option('--smoke-test', 'Exit after successful start').option('--ci', "CI mode (skip interactive prompts, don't open browser)").option('--no-open', 'Do not open Storybook automatically in the browser').option('--loglevel <level>', 'Control level of logging during build').option('--quiet', 'Suppress verbose build output').option('--no-version-updates', 'Suppress update check', true).option('--no-release-notes', 'Suppress automatic redirects to the release notes after upgrading', true).option('--no-manager-cache', 'Do not cache the manager UI').option('--debug-webpack', 'Display final webpack configurations for debugging purposes').option('--webpack-stats-json [directory]', 'Write Webpack Stats JSON to disk').option('--preview-url <string>', 'Disables the default storybook preview and lets your use your own').option('--force-build-preview', 'Build the preview iframe even if you are using --preview-url').option('--docs', 'Build a documentation-only site using addon-docs').action(options => {
|
|
161
|
-
_nodeLogger.logger.setLevel(_commander.default.loglevel);
|
|
162
|
-
|
|
163
|
-
consoleLogger.log(_chalk.default.bold(`${pkg.name} v${pkg.version}`) + _chalk.default.reset('\n')); // The key is the field created in `program` variable for
|
|
164
|
-
// each command line argument. Value is the env variable.
|
|
165
|
-
|
|
166
|
-
(0, _utils.getEnvConfig)(_commander.default, {
|
|
167
|
-
port: 'SBCONFIG_PORT',
|
|
168
|
-
host: 'SBCONFIG_HOSTNAME',
|
|
169
|
-
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
170
|
-
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
171
|
-
ci: 'CI'
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
if (typeof _commander.default.port === 'string' && _commander.default.port.length > 0) {
|
|
175
|
-
_commander.default.port = parseInt(_commander.default.port, 10);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
(0, _dev.dev)(Object.assign({}, options, {
|
|
179
|
-
packageJson: pkg
|
|
180
|
-
}));
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
_commander.default.command('build').option('-s, --static-dir <dir-names>', 'Directory where to load static files from', _utils.parseList).option('-o, --output-dir <dir-name>', 'Directory where to store built files').option('-c, --config-dir <dir-name>', 'Directory where to load Storybook configurations from').option('--quiet', 'Suppress verbose build output').option('--loglevel <level>', 'Control level of logging during build').option('--debug-webpack', 'Display final webpack configurations for debugging purposes').option('--webpack-stats-json [directory]', 'Write Webpack Stats JSON to disk').option('--preview-url <string>', 'Disables the default storybook preview and lets your use your own').option('--force-build-preview', 'Build the preview iframe even if you are using --preview-url').option('--docs', 'Build a documentation-only site using addon-docs').option('--no-manager-cache', 'Do not cache the manager UI').action(options => {
|
|
184
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
185
|
-
|
|
186
|
-
_nodeLogger.logger.setLevel(_commander.default.loglevel);
|
|
187
|
-
|
|
188
|
-
consoleLogger.log(_chalk.default.bold(`${pkg.name} v${pkg.version}\n`)); // The key is the field created in `program` variable for
|
|
189
|
-
// each command line argument. Value is the env variable.
|
|
190
|
-
|
|
191
|
-
(0, _utils.getEnvConfig)(_commander.default, {
|
|
192
|
-
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
193
|
-
outputDir: 'SBCONFIG_OUTPUT_DIR',
|
|
194
|
-
configDir: 'SBCONFIG_CONFIG_DIR'
|
|
195
|
-
});
|
|
196
|
-
(0, _build.build)(Object.assign({}, options, {
|
|
197
|
-
packageJson: pkg
|
|
198
|
-
}));
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
_commander.default.on('command:*', ([invalidCmd]) => {
|
|
202
|
-
consoleLogger.error(' Invalid command: %s.\n See --help for a list of available commands.', invalidCmd); // eslint-disable-next-line
|
|
203
|
-
|
|
204
|
-
const availableCommands = _commander.default.commands.map(cmd => cmd._name);
|
|
205
|
-
|
|
206
|
-
const suggestion = availableCommands.find(cmd => (0, _leven.default)(cmd, invalidCmd) < 3);
|
|
207
|
-
|
|
208
|
-
if (suggestion) {
|
|
209
|
-
consoleLogger.info(`\n Did you mean ${suggestion}?`);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
process.exit(1);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
_commander.default.usage('<command> [options]').version(pkg.version).parse(process.argv);
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.checkForProjects = checkForProjects;
|
|
7
|
-
exports.editStorybookTsConfig = editStorybookTsConfig;
|
|
8
|
-
exports.getAngularAppTsConfigJson = getAngularAppTsConfigJson;
|
|
9
|
-
exports.getAngularAppTsConfigPath = getAngularAppTsConfigPath;
|
|
10
|
-
exports.getBaseTsConfigName = getBaseTsConfigName;
|
|
11
|
-
exports.getDefaultProjectName = getDefaultProjectName;
|
|
12
|
-
|
|
13
|
-
var path = _interopRequireWildcard(require("path"));
|
|
14
|
-
|
|
15
|
-
var fs = _interopRequireWildcard(require("fs"));
|
|
16
|
-
|
|
17
|
-
var _fsExtra = require("fs-extra");
|
|
18
|
-
|
|
19
|
-
var _helpers = require("../../helpers");
|
|
20
|
-
|
|
21
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
-
|
|
23
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
-
|
|
25
|
-
function getAngularAppTsConfigPath() {
|
|
26
|
-
const angularJson = (0, _helpers.readFileAsJson)('angular.json', true);
|
|
27
|
-
const defaultProject = getDefaultProjectName(angularJson);
|
|
28
|
-
const tsConfigPath = angularJson.projects[defaultProject].architect.build.options.tsConfig;
|
|
29
|
-
|
|
30
|
-
if (!tsConfigPath || !fs.existsSync(path.resolve(tsConfigPath))) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return tsConfigPath;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getAngularAppTsConfigJson() {
|
|
38
|
-
const tsConfigPath = getAngularAppTsConfigPath();
|
|
39
|
-
|
|
40
|
-
if (!tsConfigPath) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (0, _helpers.readFileAsJson)(tsConfigPath, true);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function setStorybookTsconfigExtendsPath(tsconfigJson) {
|
|
48
|
-
const angularProjectTsConfigPath = getAngularAppTsConfigPath();
|
|
49
|
-
const newTsconfigJson = Object.assign({}, tsconfigJson);
|
|
50
|
-
newTsconfigJson.extends = `../${angularProjectTsConfigPath}`;
|
|
51
|
-
return newTsconfigJson;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function editStorybookTsConfig(tsconfigPath) {
|
|
55
|
-
let tsConfigJson;
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
tsConfigJson = (0, _helpers.readFileAsJson)(tsconfigPath);
|
|
59
|
-
} catch (e) {
|
|
60
|
-
if (e.name === 'SyntaxError' && e.message.indexOf('Unexpected token /') > -1) {
|
|
61
|
-
throw new Error(`Comments are disallowed in ${tsconfigPath}`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
throw e;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
tsConfigJson = setStorybookTsconfigExtendsPath(tsConfigJson);
|
|
68
|
-
(0, _helpers.writeFileAsJson)(tsconfigPath, tsConfigJson);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function getDefaultProjectName(angularJson) {
|
|
72
|
-
const {
|
|
73
|
-
defaultProject,
|
|
74
|
-
projects
|
|
75
|
-
} = angularJson;
|
|
76
|
-
|
|
77
|
-
if (projects !== null && projects !== void 0 && projects.storybook) {
|
|
78
|
-
return 'storybook';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (defaultProject) {
|
|
82
|
-
return defaultProject;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const firstProjectName = projects ? Object.keys(projects)[0] : undefined;
|
|
86
|
-
|
|
87
|
-
if (firstProjectName) {
|
|
88
|
-
return firstProjectName;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function checkForProjects() {
|
|
95
|
-
const {
|
|
96
|
-
projects
|
|
97
|
-
} = (0, _helpers.readFileAsJson)('angular.json', true);
|
|
98
|
-
|
|
99
|
-
if (!projects || Object.keys(projects).length === 0) {
|
|
100
|
-
throw new Error('Could not find a project in your Angular workspace. \nAdd a project and re-run the installation');
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function getBaseTsConfigName() {
|
|
105
|
-
return (await (0, _fsExtra.pathExists)('./tsconfig.base.json')) ? 'tsconfig.base.json' : 'tsconfig.json';
|
|
106
|
-
}
|