@storybook/angular 8.1.0 → 8.1.2
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/dist/builders/build-storybook/index.js +47 -63
- package/dist/builders/start-storybook/index.js +60 -82
- package/dist/builders/utils/run-compodoc.d.ts +1 -2
- package/dist/builders/utils/run-compodoc.js +16 -21
- package/dist/builders/utils/run-compodoc.spec.js +10 -21
- package/dist/builders/utils/setup.d.ts +26 -0
- package/dist/builders/utils/setup.js +71 -0
- package/dist/builders/utils/standalone-options.d.ts +3 -7
- package/dist/server/angular-cli-webpack.js +7 -3
- package/dist/server/framework-preset-angular-cli.js +2 -48
- package/dist/server/preset-options.d.ts +2 -6
- package/dist/types.d.ts +3 -2
- package/package.json +12 -12
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const architect_1 = require("@angular-devkit/architect");
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
4
|
const find_up_1 = require("find-up");
|
|
7
5
|
const read_pkg_up_1 = require("read-pkg-up");
|
|
8
6
|
const core_common_1 = require("@storybook/core-common");
|
|
@@ -10,69 +8,55 @@ const telemetry_1 = require("@storybook/telemetry");
|
|
|
10
8
|
const core_server_1 = require("@storybook/core-server");
|
|
11
9
|
const run_compodoc_1 = require("../utils/run-compodoc");
|
|
12
10
|
const error_handler_1 = require("../utils/error-handler");
|
|
11
|
+
const setup_1 = require("../utils/setup");
|
|
13
12
|
(0, telemetry_1.addToGlobalContext)('cliVersion', core_common_1.versions.storybook);
|
|
14
|
-
const commandBuilder = (options, context) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
previewUrl,
|
|
51
|
-
};
|
|
52
|
-
return standaloneOptions;
|
|
53
|
-
}), (0, operators_1.switchMap)((standaloneOptions) => runInstance({ ...standaloneOptions, mode: 'static' })), (0, operators_1.map)(() => {
|
|
54
|
-
return { success: true };
|
|
55
|
-
}));
|
|
56
|
-
return builder;
|
|
13
|
+
const commandBuilder = async (options, context) => {
|
|
14
|
+
const { tsConfig, angularBuilderContext, angularBuilderOptions } = await (0, setup_1.setup)(options, context);
|
|
15
|
+
const docTSConfig = (0, find_up_1.sync)('tsconfig.doc.json', { cwd: options.configDir });
|
|
16
|
+
if (options.compodoc) {
|
|
17
|
+
await (0, run_compodoc_1.runCompodoc)({ compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig }, context);
|
|
18
|
+
}
|
|
19
|
+
(0, core_common_1.getEnvConfig)(options, {
|
|
20
|
+
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
21
|
+
outputDir: 'SBCONFIG_OUTPUT_DIR',
|
|
22
|
+
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
23
|
+
});
|
|
24
|
+
const { configDir, docs, loglevel, test, outputDir, quiet, enableProdMode = true, webpackStatsJson, statsJson, debugWebpack, disableTelemetry, previewUrl, } = options;
|
|
25
|
+
const standaloneOptions = {
|
|
26
|
+
packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
|
|
27
|
+
configDir,
|
|
28
|
+
...(docs ? { docs } : {}),
|
|
29
|
+
excludeChunks: angularBuilderOptions.styles
|
|
30
|
+
?.filter((style) => typeof style !== 'string' && style.inject === false)
|
|
31
|
+
.map((s) => s.bundleName),
|
|
32
|
+
loglevel,
|
|
33
|
+
outputDir,
|
|
34
|
+
test,
|
|
35
|
+
quiet,
|
|
36
|
+
enableProdMode,
|
|
37
|
+
disableTelemetry,
|
|
38
|
+
angularBrowserTarget: options.browserTarget,
|
|
39
|
+
angularBuilderContext,
|
|
40
|
+
angularBuilderOptions,
|
|
41
|
+
tsConfig,
|
|
42
|
+
webpackStatsJson,
|
|
43
|
+
statsJson,
|
|
44
|
+
debugWebpack,
|
|
45
|
+
previewUrl,
|
|
46
|
+
};
|
|
47
|
+
await runInstance({ ...standaloneOptions, mode: 'static' });
|
|
48
|
+
return { success: true };
|
|
57
49
|
};
|
|
58
50
|
exports.default = (0, architect_1.createBuilder)(commandBuilder);
|
|
59
|
-
async function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
async function runInstance(options) {
|
|
52
|
+
try {
|
|
53
|
+
await (0, core_server_1.withTelemetry)('build', {
|
|
54
|
+
cliOptions: options,
|
|
55
|
+
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
56
|
+
printError: error_handler_1.printErrorDetails,
|
|
57
|
+
}, () => (0, core_server_1.buildStaticStandalone)(options));
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
throw new Error((0, error_handler_1.errorSummary)(error));
|
|
65
61
|
}
|
|
66
|
-
return {
|
|
67
|
-
tsConfig: options.tsConfig ??
|
|
68
|
-
(0, find_up_1.sync)('tsconfig.json', { cwd: options.configDir }) ??
|
|
69
|
-
browserOptions.tsConfig,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function runInstance(options) {
|
|
73
|
-
return (0, rxjs_1.from)((0, core_server_1.withTelemetry)('build', {
|
|
74
|
-
cliOptions: options,
|
|
75
|
-
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
76
|
-
printError: error_handler_1.printErrorDetails,
|
|
77
|
-
}, () => (0, core_server_1.buildStaticStandalone)(options))).pipe((0, operators_1.catchError)((error) => (0, rxjs_1.throwError)((0, error_handler_1.errorSummary)(error))));
|
|
78
62
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const architect_1 = require("@angular-devkit/architect");
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
4
|
const find_up_1 = require("find-up");
|
|
7
5
|
const read_pkg_up_1 = require("read-pkg-up");
|
|
8
6
|
const core_common_1 = require("@storybook/core-common");
|
|
@@ -10,90 +8,70 @@ const telemetry_1 = require("@storybook/telemetry");
|
|
|
10
8
|
const core_server_1 = require("@storybook/core-server");
|
|
11
9
|
const run_compodoc_1 = require("../utils/run-compodoc");
|
|
12
10
|
const error_handler_1 = require("../utils/error-handler");
|
|
11
|
+
const setup_1 = require("../utils/setup");
|
|
13
12
|
(0, telemetry_1.addToGlobalContext)('cliVersion', core_common_1.versions.storybook);
|
|
14
|
-
const commandBuilder = (options, context) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
: (0, rxjs_1.of)({});
|
|
23
|
-
return runCompodoc$.pipe((0, operators_1.mapTo)({ tsConfig }));
|
|
24
|
-
}), (0, operators_1.map)(({ tsConfig }) => {
|
|
25
|
-
(0, core_common_1.getEnvConfig)(options, {
|
|
26
|
-
port: 'SBCONFIG_PORT',
|
|
27
|
-
host: 'SBCONFIG_HOSTNAME',
|
|
28
|
-
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
29
|
-
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
30
|
-
ci: 'CI',
|
|
31
|
-
});
|
|
32
|
-
options.port = parseInt(`${options.port}`, 10);
|
|
33
|
-
const { browserTarget, stylePreprocessorOptions, styles, ci, configDir, docs, host, https, port, quiet, enableProdMode = false, smokeTest, sslCa, sslCert, sslKey, disableTelemetry, assets, initialPath, open, debugWebpack, loglevel, webpackStatsJson, statsJson, previewUrl, sourceMap = false, } = options;
|
|
34
|
-
const standaloneOptions = {
|
|
35
|
-
packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
|
|
36
|
-
ci,
|
|
37
|
-
configDir,
|
|
38
|
-
...(docs ? { docs } : {}),
|
|
39
|
-
host,
|
|
40
|
-
https,
|
|
41
|
-
port,
|
|
42
|
-
quiet,
|
|
43
|
-
enableProdMode,
|
|
44
|
-
smokeTest,
|
|
45
|
-
sslCa,
|
|
46
|
-
sslCert,
|
|
47
|
-
sslKey,
|
|
48
|
-
disableTelemetry,
|
|
49
|
-
angularBrowserTarget: browserTarget,
|
|
50
|
-
angularBuilderContext: context,
|
|
51
|
-
angularBuilderOptions: {
|
|
52
|
-
...(stylePreprocessorOptions ? { stylePreprocessorOptions } : {}),
|
|
53
|
-
...(styles ? { styles } : {}),
|
|
54
|
-
...(assets ? { assets } : {}),
|
|
55
|
-
sourceMap,
|
|
56
|
-
},
|
|
57
|
-
tsConfig,
|
|
58
|
-
initialPath,
|
|
59
|
-
open,
|
|
60
|
-
debugWebpack,
|
|
61
|
-
webpackStatsJson,
|
|
62
|
-
statsJson,
|
|
63
|
-
loglevel,
|
|
64
|
-
previewUrl,
|
|
65
|
-
};
|
|
66
|
-
return standaloneOptions;
|
|
67
|
-
}), (0, operators_1.switchMap)((standaloneOptions) => runInstance(standaloneOptions)), (0, operators_1.map)((port) => {
|
|
68
|
-
return { success: true, info: { port } };
|
|
69
|
-
}));
|
|
70
|
-
return builder;
|
|
71
|
-
};
|
|
72
|
-
exports.default = (0, architect_1.createBuilder)(commandBuilder);
|
|
73
|
-
async function setup(options, context) {
|
|
74
|
-
let browserOptions;
|
|
75
|
-
let browserTarget;
|
|
76
|
-
if (options.browserTarget) {
|
|
77
|
-
browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
|
|
78
|
-
browserOptions = await context.validateOptions(await context.getTargetOptions(browserTarget), await context.getBuilderNameForTarget(browserTarget));
|
|
13
|
+
const commandBuilder = async (options, context) => {
|
|
14
|
+
const { tsConfig, angularBuilderContext, angularBuilderOptions } = await (0, setup_1.setup)(options, context);
|
|
15
|
+
const docTSConfig = (0, find_up_1.sync)('tsconfig.doc.json', { cwd: options.configDir });
|
|
16
|
+
if (options.compodoc) {
|
|
17
|
+
await (0, run_compodoc_1.runCompodoc)({
|
|
18
|
+
compodocArgs: [...options.compodocArgs, ...(options.quiet ? ['--silent'] : [])],
|
|
19
|
+
tsconfig: docTSConfig ?? tsConfig,
|
|
20
|
+
}, context);
|
|
79
21
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
22
|
+
(0, core_common_1.getEnvConfig)(options, {
|
|
23
|
+
port: 'SBCONFIG_PORT',
|
|
24
|
+
host: 'SBCONFIG_HOSTNAME',
|
|
25
|
+
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
26
|
+
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
27
|
+
ci: 'CI',
|
|
28
|
+
});
|
|
29
|
+
options.port = parseInt(`${options.port}`, 10);
|
|
30
|
+
const { browserTarget, ci, configDir, docs, host, https, port, quiet, enableProdMode = false, smokeTest, sslCa, sslCert, sslKey, disableTelemetry, initialPath, open, debugWebpack, loglevel, webpackStatsJson, statsJson, previewUrl, } = options;
|
|
31
|
+
const standaloneOptions = {
|
|
32
|
+
packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
|
|
33
|
+
ci,
|
|
34
|
+
configDir,
|
|
35
|
+
...(docs ? { docs } : {}),
|
|
36
|
+
excludeChunks: angularBuilderOptions.styles
|
|
37
|
+
?.filter((style) => typeof style !== 'string' && style.inject === false)
|
|
38
|
+
.map((s) => s.bundleName),
|
|
39
|
+
host,
|
|
40
|
+
https,
|
|
41
|
+
port,
|
|
42
|
+
quiet,
|
|
43
|
+
enableProdMode,
|
|
44
|
+
smokeTest,
|
|
45
|
+
sslCa,
|
|
46
|
+
sslCert,
|
|
47
|
+
sslKey,
|
|
48
|
+
disableTelemetry,
|
|
49
|
+
angularBrowserTarget: browserTarget,
|
|
50
|
+
angularBuilderContext,
|
|
51
|
+
angularBuilderOptions,
|
|
52
|
+
tsConfig,
|
|
53
|
+
initialPath,
|
|
54
|
+
open,
|
|
55
|
+
debugWebpack,
|
|
56
|
+
webpackStatsJson,
|
|
57
|
+
statsJson,
|
|
58
|
+
loglevel,
|
|
59
|
+
previewUrl,
|
|
84
60
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
61
|
+
const devPort = await runInstance(standaloneOptions);
|
|
62
|
+
return { success: true, info: { port: devPort } };
|
|
63
|
+
};
|
|
64
|
+
exports.default = (0, architect_1.createBuilder)(commandBuilder);
|
|
65
|
+
async function runInstance(options) {
|
|
66
|
+
try {
|
|
67
|
+
const { port } = await (0, core_server_1.withTelemetry)('dev', {
|
|
90
68
|
cliOptions: options,
|
|
91
69
|
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
92
70
|
printError: error_handler_1.printErrorDetails,
|
|
93
|
-
}, () => (0, core_server_1.buildDevStandalone)(options))
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
71
|
+
}, () => (0, core_server_1.buildDevStandalone)(options));
|
|
72
|
+
return port;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw new Error((0, error_handler_1.errorSummary)(error));
|
|
76
|
+
}
|
|
99
77
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
2
|
export declare const runCompodoc: ({ compodocArgs, tsconfig }: {
|
|
4
3
|
compodocArgs: string[];
|
|
5
4
|
tsconfig: string;
|
|
6
|
-
}, context: BuilderContext) =>
|
|
5
|
+
}, context: BuilderContext) => Promise<void>;
|
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.runCompodoc = void 0;
|
|
27
|
-
const rxjs_1 = require("rxjs");
|
|
28
27
|
const path = __importStar(require("path"));
|
|
29
28
|
const core_common_1 = require("@storybook/core-common");
|
|
30
29
|
const hasTsConfigArg = (args) => args.indexOf('-p') !== -1;
|
|
@@ -34,25 +33,21 @@ const hasOutputArg = (args) => args.indexOf('-d') !== -1 || args.indexOf('--outp
|
|
|
34
33
|
const toRelativePath = (pathToTsConfig) => {
|
|
35
34
|
return path.isAbsolute(pathToTsConfig) ? path.relative('.', pathToTsConfig) : pathToTsConfig;
|
|
36
35
|
};
|
|
37
|
-
const runCompodoc = ({ compodocArgs, tsconfig }, context) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
context.logger.error(e);
|
|
54
|
-
observer.error();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
36
|
+
const runCompodoc = async ({ compodocArgs, tsconfig }, context) => {
|
|
37
|
+
const tsConfigPath = toRelativePath(tsconfig);
|
|
38
|
+
const finalCompodocArgs = [
|
|
39
|
+
...(hasTsConfigArg(compodocArgs) ? [] : ['-p', tsConfigPath]),
|
|
40
|
+
...(hasOutputArg(compodocArgs) ? [] : ['-d', `${context.workspaceRoot || '.'}`]),
|
|
41
|
+
...compodocArgs,
|
|
42
|
+
];
|
|
43
|
+
const packageManager = core_common_1.JsPackageManagerFactory.getPackageManager();
|
|
44
|
+
try {
|
|
45
|
+
const stdout = packageManager.runPackageCommandSync('compodoc', finalCompodocArgs, context.workspaceRoot, 'inherit');
|
|
46
|
+
context.logger.info(stdout);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
context.logger.error(e);
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
57
52
|
};
|
|
58
53
|
exports.runCompodoc = runCompodoc;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
4
|
const vitest_1 = require("vitest");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
5
|
const run_compodoc_1 = require("./run-compodoc");
|
|
7
6
|
const mockRunScript = vitest_1.vi.fn();
|
|
8
7
|
vitest_1.vi.mock('@storybook/core-common', () => ({
|
|
@@ -30,48 +29,38 @@ const builderContextLoggerMock = {
|
|
|
30
29
|
logger: builderContextLoggerMock,
|
|
31
30
|
};
|
|
32
31
|
(0, vitest_1.it)('should run compodoc with tsconfig from context', async () => {
|
|
33
|
-
(0, run_compodoc_1.runCompodoc)({
|
|
32
|
+
await (0, run_compodoc_1.runCompodoc)({
|
|
34
33
|
compodocArgs: [],
|
|
35
34
|
tsconfig: 'path/to/tsconfig.json',
|
|
36
|
-
}, builderContextMock)
|
|
37
|
-
.pipe((0, operators_1.take)(1))
|
|
38
|
-
.subscribe();
|
|
35
|
+
}, builderContextMock);
|
|
39
36
|
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
|
|
40
37
|
});
|
|
41
38
|
(0, vitest_1.it)('should run compodoc with tsconfig from compodocArgs', async () => {
|
|
42
|
-
(0, run_compodoc_1.runCompodoc)({
|
|
39
|
+
await (0, run_compodoc_1.runCompodoc)({
|
|
43
40
|
compodocArgs: ['-p', 'path/to/tsconfig.stories.json'],
|
|
44
41
|
tsconfig: 'path/to/tsconfig.json',
|
|
45
|
-
}, builderContextMock)
|
|
46
|
-
.pipe((0, operators_1.take)(1))
|
|
47
|
-
.subscribe();
|
|
42
|
+
}, builderContextMock);
|
|
48
43
|
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-d', 'path/to/project', '-p', 'path/to/tsconfig.stories.json'], 'path/to/project', 'inherit');
|
|
49
44
|
});
|
|
50
45
|
(0, vitest_1.it)('should run compodoc with default output folder.', async () => {
|
|
51
|
-
(0, run_compodoc_1.runCompodoc)({
|
|
46
|
+
await (0, run_compodoc_1.runCompodoc)({
|
|
52
47
|
compodocArgs: [],
|
|
53
48
|
tsconfig: 'path/to/tsconfig.json',
|
|
54
|
-
}, builderContextMock)
|
|
55
|
-
.pipe((0, operators_1.take)(1))
|
|
56
|
-
.subscribe();
|
|
49
|
+
}, builderContextMock);
|
|
57
50
|
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
|
|
58
51
|
});
|
|
59
52
|
(0, vitest_1.it)('should run with custom output folder specified with --output compodocArgs', async () => {
|
|
60
|
-
(0, run_compodoc_1.runCompodoc)({
|
|
53
|
+
await (0, run_compodoc_1.runCompodoc)({
|
|
61
54
|
compodocArgs: ['--output', 'path/to/customFolder'],
|
|
62
55
|
tsconfig: 'path/to/tsconfig.json',
|
|
63
|
-
}, builderContextMock)
|
|
64
|
-
.pipe((0, operators_1.take)(1))
|
|
65
|
-
.subscribe();
|
|
56
|
+
}, builderContextMock);
|
|
66
57
|
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '--output', 'path/to/customFolder'], 'path/to/project', 'inherit');
|
|
67
58
|
});
|
|
68
59
|
(0, vitest_1.it)('should run with custom output folder specified with -d compodocArgs', async () => {
|
|
69
|
-
(0, run_compodoc_1.runCompodoc)({
|
|
60
|
+
await (0, run_compodoc_1.runCompodoc)({
|
|
70
61
|
compodocArgs: ['-d', 'path/to/customFolder'],
|
|
71
62
|
tsconfig: 'path/to/tsconfig.json',
|
|
72
|
-
}, builderContextMock)
|
|
73
|
-
.pipe((0, operators_1.take)(1))
|
|
74
|
-
.subscribe();
|
|
63
|
+
}, builderContextMock);
|
|
75
64
|
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/customFolder'], 'path/to/project', 'inherit');
|
|
76
65
|
});
|
|
77
66
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BuilderContext } from '@angular-devkit/architect';
|
|
2
|
+
import { StylePreprocessorOptions } from '@angular-devkit/build-angular';
|
|
3
|
+
import { AssetPattern, SourceMapUnion, StyleElement } from '@angular-devkit/build-angular/src/builders/browser/schema';
|
|
4
|
+
type AngularBuilderOptions = {
|
|
5
|
+
stylePreprocessorOptions?: StylePreprocessorOptions;
|
|
6
|
+
styles?: StyleElement[];
|
|
7
|
+
assets?: AssetPattern[];
|
|
8
|
+
sourceMap?: SourceMapUnion;
|
|
9
|
+
};
|
|
10
|
+
type Options = AngularBuilderOptions & {
|
|
11
|
+
browserTarget?: string | null;
|
|
12
|
+
tsConfig?: string;
|
|
13
|
+
configDir?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function setup(options: Options, context: BuilderContext): Promise<{
|
|
16
|
+
tsConfig: string;
|
|
17
|
+
angularBuilderContext: BuilderContext;
|
|
18
|
+
angularBuilderOptions: {
|
|
19
|
+
tsConfig: string;
|
|
20
|
+
stylePreprocessorOptions?: StylePreprocessorOptions | undefined;
|
|
21
|
+
styles?: StyleElement[] | undefined;
|
|
22
|
+
assets?: AssetPattern[] | undefined;
|
|
23
|
+
sourceMap?: SourceMapUnion | undefined;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setup = void 0;
|
|
4
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
5
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
|
+
const find_up_1 = require("find-up");
|
|
7
|
+
const node_logger_1 = require("@storybook/node-logger");
|
|
8
|
+
async function setup(options, context) {
|
|
9
|
+
let browserOptions;
|
|
10
|
+
let browserTarget;
|
|
11
|
+
if (options.browserTarget) {
|
|
12
|
+
browserTarget = (0, architect_1.targetFromTargetString)(options.browserTarget);
|
|
13
|
+
browserOptions = await context.validateOptions(await context.getTargetOptions(browserTarget), await context.getBuilderNameForTarget(browserTarget));
|
|
14
|
+
}
|
|
15
|
+
const tsConfig = options.tsConfig ??
|
|
16
|
+
(0, find_up_1.sync)('tsconfig.json', { cwd: options.configDir }) ??
|
|
17
|
+
browserOptions.tsConfig;
|
|
18
|
+
const angularBuilderContext = getBuilderContext(context);
|
|
19
|
+
const angularBuilderOptions = await getBuilderOptions(options.browserTarget, {
|
|
20
|
+
...(options.stylePreprocessorOptions
|
|
21
|
+
? { stylePreprocessorOptions: options.stylePreprocessorOptions }
|
|
22
|
+
: {}),
|
|
23
|
+
...(options.styles ? { styles: options.styles } : {}),
|
|
24
|
+
...(options.assets ? { assets: options.assets } : {}),
|
|
25
|
+
sourceMap: options.sourceMap ?? false,
|
|
26
|
+
}, tsConfig, options.configDir, angularBuilderContext);
|
|
27
|
+
return {
|
|
28
|
+
tsConfig,
|
|
29
|
+
angularBuilderContext,
|
|
30
|
+
angularBuilderOptions,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.setup = setup;
|
|
34
|
+
/**
|
|
35
|
+
* Get Builder Context
|
|
36
|
+
* If storybook is not start by angular builder create dumb BuilderContext
|
|
37
|
+
*/
|
|
38
|
+
function getBuilderContext(builderContext) {
|
|
39
|
+
return (builderContext ??
|
|
40
|
+
{
|
|
41
|
+
target: { project: 'noop-project', builder: '', options: {} },
|
|
42
|
+
workspaceRoot: process.cwd(),
|
|
43
|
+
getProjectMetadata: () => ({}),
|
|
44
|
+
getTargetOptions: () => ({}),
|
|
45
|
+
logger: new core_1.logging.Logger('Storybook'),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get builder options
|
|
50
|
+
* Merge target options from browser target and from storybook options
|
|
51
|
+
*/
|
|
52
|
+
async function getBuilderOptions(angularBrowserTarget, angularBuilderOptions, tsConfig, configDir, builderContext) {
|
|
53
|
+
/**
|
|
54
|
+
* Get Browser Target options
|
|
55
|
+
*/
|
|
56
|
+
let browserTargetOptions = {};
|
|
57
|
+
if (angularBrowserTarget) {
|
|
58
|
+
const browserTarget = (0, architect_1.targetFromTargetString)(angularBrowserTarget);
|
|
59
|
+
browserTargetOptions = await builderContext.getTargetOptions(browserTarget);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Merge target options from browser target options and from storybook options
|
|
63
|
+
*/
|
|
64
|
+
const builderOptions = {
|
|
65
|
+
...browserTargetOptions,
|
|
66
|
+
...angularBuilderOptions,
|
|
67
|
+
tsConfig: tsConfig ?? (0, find_up_1.sync)('tsconfig.json', { cwd: configDir }) ?? browserTargetOptions.tsConfig,
|
|
68
|
+
};
|
|
69
|
+
node_logger_1.logger.info(`=> Using angular project with "tsConfig:${builderOptions.tsConfig}"`);
|
|
70
|
+
return builderOptions;
|
|
71
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
2
|
-
import { AssetPattern, SourceMapUnion, StyleElement, StylePreprocessorOptions } from '@angular-devkit/build-angular/src/builders/browser/schema';
|
|
3
2
|
import { LoadOptions, CLIOptions, BuilderOptions } from '@storybook/types';
|
|
3
|
+
import { AngularBuilderOptions } from '../../server/framework-preset-angular-cli';
|
|
4
4
|
export type StandaloneOptions = CLIOptions & LoadOptions & BuilderOptions & {
|
|
5
5
|
mode?: 'static' | 'dev';
|
|
6
6
|
enableProdMode: boolean;
|
|
7
7
|
angularBrowserTarget?: string | null;
|
|
8
|
-
angularBuilderOptions?:
|
|
9
|
-
styles?: StyleElement[];
|
|
10
|
-
stylePreprocessorOptions?: StylePreprocessorOptions;
|
|
11
|
-
assets?: AssetPattern[];
|
|
12
|
-
sourceMap?: SourceMapUnion;
|
|
13
|
-
};
|
|
8
|
+
angularBuilderOptions?: AngularBuilderOptions;
|
|
14
9
|
angularBuilderContext?: BuilderContext | null;
|
|
15
10
|
tsConfig?: string;
|
|
11
|
+
excludeChunks?: string[];
|
|
16
12
|
};
|
|
@@ -46,9 +46,13 @@ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }
|
|
|
46
46
|
outputPath: 'noop-out',
|
|
47
47
|
// Options provided by user
|
|
48
48
|
...builderOptions,
|
|
49
|
-
styles: builderOptions.styles
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
styles: builderOptions.styles?.map((style) => typeof style === 'string'
|
|
50
|
+
? {
|
|
51
|
+
input: style,
|
|
52
|
+
inject: true,
|
|
53
|
+
bundleName: style.split('/').pop(),
|
|
54
|
+
}
|
|
55
|
+
: style),
|
|
52
56
|
// Fixed options
|
|
53
57
|
optimization: false,
|
|
54
58
|
namedChunks: false,
|
|
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.webpackFinal = void 0;
|
|
4
4
|
const node_logger_1 = require("@storybook/node-logger");
|
|
5
5
|
const server_errors_1 = require("@storybook/core-events/server-errors");
|
|
6
|
-
const architect_1 = require("@angular-devkit/architect");
|
|
7
|
-
const find_up_1 = require("find-up");
|
|
8
|
-
const core_1 = require("@angular-devkit/core");
|
|
9
6
|
const angular_cli_webpack_1 = require("./angular-cli-webpack");
|
|
10
7
|
const module_is_available_1 = require("./utils/module-is-available");
|
|
11
8
|
async function webpackFinal(baseConfig, options) {
|
|
@@ -14,58 +11,15 @@ async function webpackFinal(baseConfig, options) {
|
|
|
14
11
|
return baseConfig;
|
|
15
12
|
}
|
|
16
13
|
checkForLegacyBuildOptions(options);
|
|
17
|
-
const builderContext = getBuilderContext(options);
|
|
18
|
-
const builderOptions = await getBuilderOptions(options, builderContext);
|
|
19
14
|
return (0, angular_cli_webpack_1.getWebpackConfig)(baseConfig, {
|
|
20
15
|
builderOptions: {
|
|
21
16
|
watch: options.configType === 'DEVELOPMENT',
|
|
22
|
-
...
|
|
17
|
+
...options.angularBuilderOptions,
|
|
23
18
|
},
|
|
24
|
-
builderContext,
|
|
19
|
+
builderContext: options.angularBuilderContext,
|
|
25
20
|
});
|
|
26
21
|
}
|
|
27
22
|
exports.webpackFinal = webpackFinal;
|
|
28
|
-
/**
|
|
29
|
-
* Get Builder Context
|
|
30
|
-
* If storybook is not start by angular builder create dumb BuilderContext
|
|
31
|
-
*/
|
|
32
|
-
function getBuilderContext(options) {
|
|
33
|
-
return (options.angularBuilderContext ??
|
|
34
|
-
{
|
|
35
|
-
target: { project: 'noop-project', builder: '', options: {} },
|
|
36
|
-
workspaceRoot: process.cwd(),
|
|
37
|
-
getProjectMetadata: () => ({}),
|
|
38
|
-
getTargetOptions: () => ({}),
|
|
39
|
-
logger: new core_1.logging.Logger('Storybook'),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get builder options
|
|
44
|
-
* Merge target options from browser target and from storybook options
|
|
45
|
-
*/
|
|
46
|
-
async function getBuilderOptions(options, builderContext) {
|
|
47
|
-
/**
|
|
48
|
-
* Get Browser Target options
|
|
49
|
-
*/
|
|
50
|
-
let browserTargetOptions = {};
|
|
51
|
-
if (options.angularBrowserTarget) {
|
|
52
|
-
const browserTarget = (0, architect_1.targetFromTargetString)(options.angularBrowserTarget);
|
|
53
|
-
node_logger_1.logger.info(`=> Using angular browser target options from "${browserTarget.project}:${browserTarget.target}${browserTarget.configuration ? `:${browserTarget.configuration}` : ''}"`);
|
|
54
|
-
browserTargetOptions = await builderContext.getTargetOptions(browserTarget);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Merge target options from browser target options and from storybook options
|
|
58
|
-
*/
|
|
59
|
-
const builderOptions = {
|
|
60
|
-
...browserTargetOptions,
|
|
61
|
-
...options.angularBuilderOptions,
|
|
62
|
-
tsConfig: options.tsConfig ??
|
|
63
|
-
(0, find_up_1.sync)('tsconfig.json', { cwd: options.configDir }) ??
|
|
64
|
-
browserTargetOptions.tsConfig,
|
|
65
|
-
};
|
|
66
|
-
node_logger_1.logger.info(`=> Using angular project with "tsConfig:${builderOptions.tsConfig}"`);
|
|
67
|
-
return builderOptions;
|
|
68
|
-
}
|
|
69
23
|
/**
|
|
70
24
|
* Checks if using legacy configuration that doesn't use builder and logs message referring to migration docs.
|
|
71
25
|
*/
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { Options as CoreOptions } from '@storybook/types';
|
|
2
2
|
import { BuilderContext } from '@angular-devkit/architect';
|
|
3
|
-
import {
|
|
4
|
-
import { StyleElement } from '@angular-devkit/build-angular/src/builders/browser/schema';
|
|
3
|
+
import { JsonObject } from '@angular-devkit/core';
|
|
5
4
|
export type PresetOptions = CoreOptions & {
|
|
6
5
|
angularBrowserTarget?: string | null;
|
|
7
|
-
angularBuilderOptions?:
|
|
8
|
-
styles?: StyleElement[];
|
|
9
|
-
stylePreprocessorOptions?: StylePreprocessorOptions;
|
|
10
|
-
};
|
|
6
|
+
angularBuilderOptions?: JsonObject;
|
|
11
7
|
angularBuilderContext?: BuilderContext | null;
|
|
12
8
|
tsConfig?: string;
|
|
13
9
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { StorybookConfig as StorybookConfigBase, TypescriptOptions as TypescriptOptionsReact } from '@storybook/core-webpack';
|
|
2
2
|
import { StorybookConfigWebpack, BuilderOptions, TypescriptOptions as TypescriptOptionsBuilder } from '@storybook/builder-webpack5';
|
|
3
|
-
|
|
4
|
-
type
|
|
3
|
+
import { CompatibleString } from '@storybook/types';
|
|
4
|
+
type FrameworkName = CompatibleString<'@storybook/angular'>;
|
|
5
|
+
type BuilderName = CompatibleString<'@storybook/builder-webpack5'>;
|
|
5
6
|
export type FrameworkOptions = AngularOptions & {
|
|
6
7
|
builder?: BuilderOptions;
|
|
7
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.2",
|
|
4
4
|
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"prep": "rimraf dist && node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/tsc.ts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@storybook/builder-webpack5": "8.1.
|
|
41
|
-
"@storybook/client-logger": "8.1.
|
|
42
|
-
"@storybook/core-common": "8.1.
|
|
43
|
-
"@storybook/core-events": "8.1.
|
|
44
|
-
"@storybook/core-server": "8.1.
|
|
45
|
-
"@storybook/core-webpack": "8.1.
|
|
46
|
-
"@storybook/docs-tools": "8.1.
|
|
40
|
+
"@storybook/builder-webpack5": "8.1.2",
|
|
41
|
+
"@storybook/client-logger": "8.1.2",
|
|
42
|
+
"@storybook/core-common": "8.1.2",
|
|
43
|
+
"@storybook/core-events": "8.1.2",
|
|
44
|
+
"@storybook/core-server": "8.1.2",
|
|
45
|
+
"@storybook/core-webpack": "8.1.2",
|
|
46
|
+
"@storybook/docs-tools": "8.1.2",
|
|
47
47
|
"@storybook/global": "^5.0.0",
|
|
48
|
-
"@storybook/node-logger": "8.1.
|
|
49
|
-
"@storybook/preview-api": "8.1.
|
|
50
|
-
"@storybook/telemetry": "8.1.
|
|
51
|
-
"@storybook/types": "8.1.
|
|
48
|
+
"@storybook/node-logger": "8.1.2",
|
|
49
|
+
"@storybook/preview-api": "8.1.2",
|
|
50
|
+
"@storybook/telemetry": "8.1.2",
|
|
51
|
+
"@storybook/types": "8.1.2",
|
|
52
52
|
"@types/node": "^18.0.0",
|
|
53
53
|
"@types/react": "^18.0.37",
|
|
54
54
|
"@types/react-dom": "^18.0.11",
|