@modern-js/plugin-v2 2.67.8 → 2.67.9
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/cjs/cli/index.js +3 -0
- package/dist/cjs/cli/run/create.js +41 -2
- package/dist/esm/cli/index.js +2 -0
- package/dist/esm/cli/run/create.js +144 -1
- package/dist/esm-node/cli/index.js +2 -0
- package/dist/esm-node/cli/run/create.js +39 -1
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/run/create.d.ts +6 -0
- package/package.json +6 -6
package/dist/cjs/cli/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(cli_exports, {
|
|
|
22
22
|
createCli: () => import_run.createCli,
|
|
23
23
|
createContext: () => import_context.createContext,
|
|
24
24
|
createLoadedConfig: () => import_run.createLoadedConfig,
|
|
25
|
+
createStorybookOptions: () => import_create.createStorybookOptions,
|
|
25
26
|
initAppContext: () => import_context.initAppContext,
|
|
26
27
|
initAppDir: () => import_run.initAppDir,
|
|
27
28
|
initHooks: () => import_hooks.initHooks,
|
|
@@ -33,12 +34,14 @@ var import_api = require("./api");
|
|
|
33
34
|
var import_context = require("./context");
|
|
34
35
|
var import_hooks = require("./hooks");
|
|
35
36
|
var import_run = require("./run");
|
|
37
|
+
var import_create = require("./run/create");
|
|
36
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
39
|
0 && (module.exports = {
|
|
38
40
|
cli,
|
|
39
41
|
createCli,
|
|
40
42
|
createContext,
|
|
41
43
|
createLoadedConfig,
|
|
44
|
+
createStorybookOptions,
|
|
42
45
|
initAppContext,
|
|
43
46
|
initAppDir,
|
|
44
47
|
initHooks,
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var create_exports = {};
|
|
20
20
|
__export(create_exports, {
|
|
21
|
-
createCli: () => createCli
|
|
21
|
+
createCli: () => createCli,
|
|
22
|
+
createStorybookOptions: () => createStorybookOptions
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(create_exports);
|
|
24
25
|
var import_utils = require("@modern-js/utils");
|
|
@@ -139,7 +140,45 @@ const createCli = () => {
|
|
|
139
140
|
getPrevInitOptions: () => initOptions
|
|
140
141
|
};
|
|
141
142
|
};
|
|
143
|
+
const createStorybookOptions = async (options) => {
|
|
144
|
+
const pluginManager = (0, import_manager.createPluginManager)();
|
|
145
|
+
pluginManager.clear();
|
|
146
|
+
const { configFile, cwd, metaName = "modern-js" } = options;
|
|
147
|
+
const appDirectory = await (0, import_initAppDir.initAppDir)(cwd);
|
|
148
|
+
const loaded = await (0, import_createLoadedConfig.createLoadedConfig)(appDirectory, configFile);
|
|
149
|
+
pluginManager.addPlugins(loaded.config.plugins || []);
|
|
150
|
+
const plugins = await pluginManager.getPlugins();
|
|
151
|
+
const context = await (0, import_context.createContext)({
|
|
152
|
+
appContext: (0, import_context.initAppContext)({
|
|
153
|
+
packageName: loaded.packageName,
|
|
154
|
+
configFile: loaded.configFile,
|
|
155
|
+
command: "storybook",
|
|
156
|
+
appDirectory,
|
|
157
|
+
plugins,
|
|
158
|
+
metaName
|
|
159
|
+
}),
|
|
160
|
+
config: loaded.config,
|
|
161
|
+
normalizedConfig: {}
|
|
162
|
+
});
|
|
163
|
+
const pluginAPI = (0, import_api.initPluginAPI)({
|
|
164
|
+
context,
|
|
165
|
+
pluginManager
|
|
166
|
+
});
|
|
167
|
+
context.pluginAPI = pluginAPI;
|
|
168
|
+
for (const plugin of plugins) {
|
|
169
|
+
var _plugin_setup;
|
|
170
|
+
await ((_plugin_setup = plugin.setup) === null || _plugin_setup === void 0 ? void 0 : _plugin_setup.call(plugin, pluginAPI));
|
|
171
|
+
}
|
|
172
|
+
const extraConfigs = await context.hooks.config.call();
|
|
173
|
+
const normalizedConfig = await (0, import_createResolvedConfig.createResolveConfig)(loaded, extraConfigs);
|
|
174
|
+
const resolved = await context.hooks.modifyResolvedConfig.call(normalizedConfig);
|
|
175
|
+
return {
|
|
176
|
+
config: resolved || normalizedConfig,
|
|
177
|
+
getAppContext: () => pluginAPI.getAppContext()
|
|
178
|
+
};
|
|
179
|
+
};
|
|
142
180
|
// Annotate the CommonJS export names for ESM import in node:
|
|
143
181
|
0 && (module.exports = {
|
|
144
|
-
createCli
|
|
182
|
+
createCli,
|
|
183
|
+
createStorybookOptions
|
|
145
184
|
});
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -2,11 +2,13 @@ import { initPluginAPI } from "./api";
|
|
|
2
2
|
import { initAppContext, createContext } from "./context";
|
|
3
3
|
import { initHooks } from "./hooks";
|
|
4
4
|
import { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from "./run";
|
|
5
|
+
import { createStorybookOptions } from "./run/create";
|
|
5
6
|
export {
|
|
6
7
|
cli,
|
|
7
8
|
createCli,
|
|
8
9
|
createContext,
|
|
9
10
|
createLoadedConfig,
|
|
11
|
+
createStorybookOptions,
|
|
10
12
|
initAppContext,
|
|
11
13
|
initAppDir,
|
|
12
14
|
initHooks,
|
|
@@ -297,6 +297,149 @@ var createCli = function() {
|
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
299
|
};
|
|
300
|
+
var createStorybookOptions = function() {
|
|
301
|
+
var _ref = _async_to_generator(function(options) {
|
|
302
|
+
var pluginManager, configFile, cwd, _options_metaName, metaName, appDirectory, loaded, plugins, context, pluginAPI, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _plugin_setup, err, extraConfigs, normalizedConfig, resolved;
|
|
303
|
+
return _ts_generator(this, function(_state) {
|
|
304
|
+
switch (_state.label) {
|
|
305
|
+
case 0:
|
|
306
|
+
pluginManager = createPluginManager();
|
|
307
|
+
pluginManager.clear();
|
|
308
|
+
configFile = options.configFile, cwd = options.cwd, _options_metaName = options.metaName, metaName = _options_metaName === void 0 ? "modern-js" : _options_metaName;
|
|
309
|
+
return [
|
|
310
|
+
4,
|
|
311
|
+
initAppDir(cwd)
|
|
312
|
+
];
|
|
313
|
+
case 1:
|
|
314
|
+
appDirectory = _state.sent();
|
|
315
|
+
return [
|
|
316
|
+
4,
|
|
317
|
+
createLoadedConfig(appDirectory, configFile)
|
|
318
|
+
];
|
|
319
|
+
case 2:
|
|
320
|
+
loaded = _state.sent();
|
|
321
|
+
pluginManager.addPlugins(loaded.config.plugins || []);
|
|
322
|
+
return [
|
|
323
|
+
4,
|
|
324
|
+
pluginManager.getPlugins()
|
|
325
|
+
];
|
|
326
|
+
case 3:
|
|
327
|
+
plugins = _state.sent();
|
|
328
|
+
return [
|
|
329
|
+
4,
|
|
330
|
+
createContext({
|
|
331
|
+
appContext: initAppContext({
|
|
332
|
+
packageName: loaded.packageName,
|
|
333
|
+
configFile: loaded.configFile,
|
|
334
|
+
command: "storybook",
|
|
335
|
+
appDirectory,
|
|
336
|
+
plugins,
|
|
337
|
+
metaName
|
|
338
|
+
}),
|
|
339
|
+
config: loaded.config,
|
|
340
|
+
normalizedConfig: {}
|
|
341
|
+
})
|
|
342
|
+
];
|
|
343
|
+
case 4:
|
|
344
|
+
context = _state.sent();
|
|
345
|
+
pluginAPI = initPluginAPI({
|
|
346
|
+
context,
|
|
347
|
+
pluginManager
|
|
348
|
+
});
|
|
349
|
+
context.pluginAPI = pluginAPI;
|
|
350
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
351
|
+
_state.label = 5;
|
|
352
|
+
case 5:
|
|
353
|
+
_state.trys.push([
|
|
354
|
+
5,
|
|
355
|
+
10,
|
|
356
|
+
11,
|
|
357
|
+
12
|
|
358
|
+
]);
|
|
359
|
+
_iterator = plugins[Symbol.iterator]();
|
|
360
|
+
_state.label = 6;
|
|
361
|
+
case 6:
|
|
362
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
|
|
363
|
+
return [
|
|
364
|
+
3,
|
|
365
|
+
9
|
|
366
|
+
];
|
|
367
|
+
plugin = _step.value;
|
|
368
|
+
return [
|
|
369
|
+
4,
|
|
370
|
+
(_plugin_setup = plugin.setup) === null || _plugin_setup === void 0 ? void 0 : _plugin_setup.call(plugin, pluginAPI)
|
|
371
|
+
];
|
|
372
|
+
case 7:
|
|
373
|
+
_state.sent();
|
|
374
|
+
_state.label = 8;
|
|
375
|
+
case 8:
|
|
376
|
+
_iteratorNormalCompletion = true;
|
|
377
|
+
return [
|
|
378
|
+
3,
|
|
379
|
+
6
|
|
380
|
+
];
|
|
381
|
+
case 9:
|
|
382
|
+
return [
|
|
383
|
+
3,
|
|
384
|
+
12
|
|
385
|
+
];
|
|
386
|
+
case 10:
|
|
387
|
+
err = _state.sent();
|
|
388
|
+
_didIteratorError = true;
|
|
389
|
+
_iteratorError = err;
|
|
390
|
+
return [
|
|
391
|
+
3,
|
|
392
|
+
12
|
|
393
|
+
];
|
|
394
|
+
case 11:
|
|
395
|
+
try {
|
|
396
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
397
|
+
_iterator.return();
|
|
398
|
+
}
|
|
399
|
+
} finally {
|
|
400
|
+
if (_didIteratorError) {
|
|
401
|
+
throw _iteratorError;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return [
|
|
405
|
+
7
|
|
406
|
+
];
|
|
407
|
+
case 12:
|
|
408
|
+
return [
|
|
409
|
+
4,
|
|
410
|
+
context.hooks.config.call()
|
|
411
|
+
];
|
|
412
|
+
case 13:
|
|
413
|
+
extraConfigs = _state.sent();
|
|
414
|
+
return [
|
|
415
|
+
4,
|
|
416
|
+
createResolveConfig(loaded, extraConfigs)
|
|
417
|
+
];
|
|
418
|
+
case 14:
|
|
419
|
+
normalizedConfig = _state.sent();
|
|
420
|
+
return [
|
|
421
|
+
4,
|
|
422
|
+
context.hooks.modifyResolvedConfig.call(normalizedConfig)
|
|
423
|
+
];
|
|
424
|
+
case 15:
|
|
425
|
+
resolved = _state.sent();
|
|
426
|
+
return [
|
|
427
|
+
2,
|
|
428
|
+
{
|
|
429
|
+
config: resolved || normalizedConfig,
|
|
430
|
+
getAppContext: function() {
|
|
431
|
+
return pluginAPI.getAppContext();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
];
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
return function createStorybookOptions2(options) {
|
|
439
|
+
return _ref.apply(this, arguments);
|
|
440
|
+
};
|
|
441
|
+
}();
|
|
300
442
|
export {
|
|
301
|
-
createCli
|
|
443
|
+
createCli,
|
|
444
|
+
createStorybookOptions
|
|
302
445
|
};
|
|
@@ -2,11 +2,13 @@ import { initPluginAPI } from "./api";
|
|
|
2
2
|
import { initAppContext, createContext } from "./context";
|
|
3
3
|
import { initHooks } from "./hooks";
|
|
4
4
|
import { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from "./run";
|
|
5
|
+
import { createStorybookOptions } from "./run/create";
|
|
5
6
|
export {
|
|
6
7
|
cli,
|
|
7
8
|
createCli,
|
|
8
9
|
createContext,
|
|
9
10
|
createLoadedConfig,
|
|
11
|
+
createStorybookOptions,
|
|
10
12
|
initAppContext,
|
|
11
13
|
initAppDir,
|
|
12
14
|
initHooks,
|
|
@@ -116,6 +116,44 @@ const createCli = () => {
|
|
|
116
116
|
getPrevInitOptions: () => initOptions
|
|
117
117
|
};
|
|
118
118
|
};
|
|
119
|
+
const createStorybookOptions = async (options) => {
|
|
120
|
+
const pluginManager = createPluginManager();
|
|
121
|
+
pluginManager.clear();
|
|
122
|
+
const { configFile, cwd, metaName = "modern-js" } = options;
|
|
123
|
+
const appDirectory = await initAppDir(cwd);
|
|
124
|
+
const loaded = await createLoadedConfig(appDirectory, configFile);
|
|
125
|
+
pluginManager.addPlugins(loaded.config.plugins || []);
|
|
126
|
+
const plugins = await pluginManager.getPlugins();
|
|
127
|
+
const context = await createContext({
|
|
128
|
+
appContext: initAppContext({
|
|
129
|
+
packageName: loaded.packageName,
|
|
130
|
+
configFile: loaded.configFile,
|
|
131
|
+
command: "storybook",
|
|
132
|
+
appDirectory,
|
|
133
|
+
plugins,
|
|
134
|
+
metaName
|
|
135
|
+
}),
|
|
136
|
+
config: loaded.config,
|
|
137
|
+
normalizedConfig: {}
|
|
138
|
+
});
|
|
139
|
+
const pluginAPI = initPluginAPI({
|
|
140
|
+
context,
|
|
141
|
+
pluginManager
|
|
142
|
+
});
|
|
143
|
+
context.pluginAPI = pluginAPI;
|
|
144
|
+
for (const plugin of plugins) {
|
|
145
|
+
var _plugin_setup;
|
|
146
|
+
await ((_plugin_setup = plugin.setup) === null || _plugin_setup === void 0 ? void 0 : _plugin_setup.call(plugin, pluginAPI));
|
|
147
|
+
}
|
|
148
|
+
const extraConfigs = await context.hooks.config.call();
|
|
149
|
+
const normalizedConfig = await createResolveConfig(loaded, extraConfigs);
|
|
150
|
+
const resolved = await context.hooks.modifyResolvedConfig.call(normalizedConfig);
|
|
151
|
+
return {
|
|
152
|
+
config: resolved || normalizedConfig,
|
|
153
|
+
getAppContext: () => pluginAPI.getAppContext()
|
|
154
|
+
};
|
|
155
|
+
};
|
|
119
156
|
export {
|
|
120
|
-
createCli
|
|
157
|
+
createCli,
|
|
158
|
+
createStorybookOptions
|
|
121
159
|
};
|
|
@@ -2,3 +2,4 @@ export { initPluginAPI } from './api';
|
|
|
2
2
|
export { initAppContext, createContext } from './context';
|
|
3
3
|
export { initHooks, type Hooks, type OnAfterBuildFn, type OnAfterCreateCompilerFn, type OnBeforeBuildFn, type OnBeforeCreateCompilerFn, type OnDevCompileDoneFn, type AddCommandFn, type AddWatchFilesFn, type ConfigFn, type ModifyBundlerChainFn, type ModifyConfigFn, type ModifyHtmlPartialsFn, type ModifyResolvedConfigFn, type ModifyRsbuildConfigFn, type ModifyRspackConfigFn, type ModifyWebpackChainFn, type ModifyWebpackConfigFn, type OnAfterDeployFn, type OnBeforeDeployFn, type OnBeforeDevFn, type OnAfterDevFn, type OnBeforeExitFn, type OnBeforeRestartFn, type OnFileChangedFn, type OnPrepareFn, type InternalRuntimePluginsFn, type InternalServerPluginsFn, type ModifyServerRoutesFn, type RuntimePluginConfig, type ServerPluginConfig, } from './hooks';
|
|
4
4
|
export { cli, createLoadedConfig, initAppDir, createCli, loadEnv } from './run';
|
|
5
|
+
export { createStorybookOptions } from './run/create';
|
|
@@ -8,3 +8,9 @@ export declare const createCli: <Extends extends CLIPluginExtends>() => {
|
|
|
8
8
|
run: (options: CLIRunOptions<Extends>) => Promise<void>;
|
|
9
9
|
getPrevInitOptions: () => CLIRunOptions<Extends>;
|
|
10
10
|
};
|
|
11
|
+
type UselessOptions = 'handleSetupResult' | 'command' | 'internalPlugins';
|
|
12
|
+
export declare const createStorybookOptions: <Extends extends CLIPluginExtends>(options: Omit<CLIRunOptions<Extends>, UselessOptions>) => Promise<{
|
|
13
|
+
config: Awaited<Extends["normalizedConfig"]> | NonNullable<Awaited<import("../../types/utils").UnwrapPromise<Extends["normalizedConfig"]>>>;
|
|
14
|
+
getAppContext: () => Readonly<import("../../types/cli/context").AppContext<Extends> & Extends["extendContext"]>;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.67.
|
|
18
|
+
"version": "2.67.9",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -81,18 +81,18 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@swc/helpers": "^0.5.17",
|
|
83
83
|
"jiti": "1.21.7",
|
|
84
|
-
"@
|
|
85
|
-
"@modern-js/utils": "2.67.
|
|
84
|
+
"@rsbuild/core": "1.3.22",
|
|
85
|
+
"@modern-js/runtime-utils": "2.67.9",
|
|
86
|
+
"@modern-js/utils": "2.67.9",
|
|
87
|
+
"@modern-js/types": "2.67.9"
|
|
86
88
|
},
|
|
87
89
|
"devDependencies": {
|
|
88
|
-
"@rsbuild/core": "1.3.22",
|
|
89
90
|
"@types/jest": "^29",
|
|
90
91
|
"@types/node": "^14",
|
|
91
92
|
"@types/react": "^18.3.11",
|
|
92
93
|
"jest": "^29",
|
|
93
94
|
"typescript": "^5",
|
|
94
|
-
"@modern-js/uni-builder": "2.67.
|
|
95
|
-
"@modern-js/types": "2.67.8",
|
|
95
|
+
"@modern-js/uni-builder": "2.67.9",
|
|
96
96
|
"@scripts/build": "2.66.0",
|
|
97
97
|
"@scripts/jest-config": "2.66.0"
|
|
98
98
|
},
|