@modern-js/core 0.0.0-options-202112061443 → 0.0.0-options-202112061447
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/js/modern/index.js +10 -4
- package/dist/js/node/index.js +9 -3
- package/dist/types/index.d.ts +17 -2
- package/package.json +1 -1
package/dist/js/modern/index.js
CHANGED
|
@@ -6,7 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { compatRequire, pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
|
|
9
|
-
import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow } from '@modern-js/plugin';
|
|
9
|
+
import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow, createAsyncWaterfall } from '@modern-js/plugin';
|
|
10
10
|
import { enable } from '@modern-js/plugin/node';
|
|
11
11
|
import { program } from "./utils/commander";
|
|
12
12
|
import { resolveConfig, defineConfig, loadUserConfig } from "./config";
|
|
@@ -20,6 +20,7 @@ export * from '@modern-js/plugin/node';
|
|
|
20
20
|
program.name('modern').usage('<command> [options]').version(process.env.MODERN_JS_VERSION || '0.1.0');
|
|
21
21
|
const hooksMap = {
|
|
22
22
|
config: createParallelWorkflow(),
|
|
23
|
+
resolvedConfig: createAsyncWaterfall(),
|
|
23
24
|
validateSchema: createParallelWorkflow(),
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
25
26
|
prepare: createAsyncWorkflow(),
|
|
@@ -59,8 +60,8 @@ const createCli = () => {
|
|
|
59
60
|
manager.clear();
|
|
60
61
|
const appDirectory = await initAppDir();
|
|
61
62
|
loadEnv(appDirectory);
|
|
62
|
-
const loaded = await loadUserConfig(appDirectory);
|
|
63
|
-
let plugins = loadPlugins(appDirectory, loaded.config.plugins || []);
|
|
63
|
+
const loaded = await loadUserConfig(appDirectory, options === null || options === void 0 ? void 0 : options.configFile);
|
|
64
|
+
let plugins = loadPlugins(appDirectory, loaded.config.plugins || [], options === null || options === void 0 ? void 0 : options.plugins);
|
|
64
65
|
|
|
65
66
|
if (options !== null && options !== void 0 && options.beforeUsePlugins) {
|
|
66
67
|
plugins = options.beforeUsePlugins(plugins, loaded.config);
|
|
@@ -89,7 +90,12 @@ const createCli = () => {
|
|
|
89
90
|
});
|
|
90
91
|
const extraConfigs = await hooksRunner.config();
|
|
91
92
|
const extraSchemas = await hooksRunner.validateSchema();
|
|
92
|
-
const
|
|
93
|
+
const config = await resolveConfig(loaded, extraConfigs, extraSchemas, isRestart, argv);
|
|
94
|
+
const {
|
|
95
|
+
resolved
|
|
96
|
+
} = await hooksRunner.resolvedConfig({
|
|
97
|
+
resolved: config
|
|
98
|
+
}); // update context value
|
|
93
99
|
|
|
94
100
|
manager.run(() => {
|
|
95
101
|
ConfigContext.set(loaded.config);
|
package/dist/js/node/index.js
CHANGED
|
@@ -137,6 +137,7 @@ _commander.program.name('modern').usage('<command> [options]').version(process.e
|
|
|
137
137
|
|
|
138
138
|
const hooksMap = {
|
|
139
139
|
config: (0, _plugin.createParallelWorkflow)(),
|
|
140
|
+
resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
|
|
140
141
|
validateSchema: (0, _plugin.createParallelWorkflow)(),
|
|
141
142
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
142
143
|
prepare: (0, _plugin.createAsyncWorkflow)(),
|
|
@@ -184,8 +185,8 @@ const createCli = () => {
|
|
|
184
185
|
manager.clear();
|
|
185
186
|
const appDirectory = await initAppDir();
|
|
186
187
|
(0, _loadEnv.loadEnv)(appDirectory);
|
|
187
|
-
const loaded = await (0, _config.loadUserConfig)(appDirectory);
|
|
188
|
-
let plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config.plugins || []);
|
|
188
|
+
const loaded = await (0, _config.loadUserConfig)(appDirectory, options === null || options === void 0 ? void 0 : options.configFile);
|
|
189
|
+
let plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config.plugins || [], options === null || options === void 0 ? void 0 : options.plugins);
|
|
189
190
|
|
|
190
191
|
if (options !== null && options !== void 0 && options.beforeUsePlugins) {
|
|
191
192
|
plugins = options.beforeUsePlugins(plugins, loaded.config);
|
|
@@ -215,7 +216,12 @@ const createCli = () => {
|
|
|
215
216
|
});
|
|
216
217
|
const extraConfigs = await hooksRunner.config();
|
|
217
218
|
const extraSchemas = await hooksRunner.validateSchema();
|
|
218
|
-
const
|
|
219
|
+
const config = await (0, _config.resolveConfig)(loaded, extraConfigs, extraSchemas, isRestart, argv);
|
|
220
|
+
const {
|
|
221
|
+
resolved
|
|
222
|
+
} = await hooksRunner.resolvedConfig({
|
|
223
|
+
resolved: config
|
|
224
|
+
}); // update context value
|
|
219
225
|
|
|
220
226
|
manager.run(() => {
|
|
221
227
|
_context.ConfigContext.set(loaded.config);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
2
|
-
import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners } from '@modern-js/plugin';
|
|
2
|
+
import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners, AsyncWaterfall } from '@modern-js/plugin';
|
|
3
3
|
import type { Hooks } from '@modern-js/types';
|
|
4
4
|
import { Command } from './utils/commander';
|
|
5
5
|
import { defineConfig, loadUserConfig, UserConfig, ToolsConfig } from './config';
|
|
@@ -11,6 +11,9 @@ export * from '@modern-js/plugin';
|
|
|
11
11
|
export * from '@modern-js/plugin/node';
|
|
12
12
|
export declare type HooksRunner = Progresses2Runners<{
|
|
13
13
|
config: ParallelWorkflow<void>;
|
|
14
|
+
resolvedConfig: AsyncWaterfall<{
|
|
15
|
+
resolved: NormalizedConfig;
|
|
16
|
+
}>;
|
|
14
17
|
validateSchema: ParallelWorkflow<void>;
|
|
15
18
|
prepare: AsyncWorkflow<void, void>;
|
|
16
19
|
commands: AsyncWorkflow<{
|
|
@@ -24,6 +27,9 @@ export declare type HooksRunner = Progresses2Runners<{
|
|
|
24
27
|
}>;
|
|
25
28
|
export declare const manager: import("@modern-js/plugin").AsyncManager<Hooks, {
|
|
26
29
|
config: ParallelWorkflow<void, unknown>;
|
|
30
|
+
resolvedConfig: AsyncWaterfall<{
|
|
31
|
+
resolved: NormalizedConfig;
|
|
32
|
+
}>;
|
|
27
33
|
validateSchema: ParallelWorkflow<void, unknown>;
|
|
28
34
|
prepare: AsyncWorkflow<void, void>;
|
|
29
35
|
commands: AsyncWorkflow<{
|
|
@@ -37,6 +43,9 @@ export declare const manager: import("@modern-js/plugin").AsyncManager<Hooks, {
|
|
|
37
43
|
}>;
|
|
38
44
|
export declare const createPlugin: (initializer: import("@modern-js/plugin").AsyncInitializer<Partial<import("@modern-js/plugin").Progresses2Threads<{
|
|
39
45
|
config: ParallelWorkflow<void, unknown>;
|
|
46
|
+
resolvedConfig: AsyncWaterfall<{
|
|
47
|
+
resolved: NormalizedConfig;
|
|
48
|
+
}>;
|
|
40
49
|
validateSchema: ParallelWorkflow<void, unknown>;
|
|
41
50
|
prepare: AsyncWorkflow<void, void>;
|
|
42
51
|
commands: AsyncWorkflow<{
|
|
@@ -49,6 +58,9 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
|
|
|
49
58
|
beforeExit: AsyncWorkflow<void, void>;
|
|
50
59
|
} & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, options?: import("@modern-js/plugin").PluginOptions | undefined) => import("@modern-js/plugin").AsyncPlugin<Partial<import("@modern-js/plugin").Progresses2Threads<{
|
|
51
60
|
config: ParallelWorkflow<void, unknown>;
|
|
61
|
+
resolvedConfig: AsyncWaterfall<{
|
|
62
|
+
resolved: NormalizedConfig;
|
|
63
|
+
}>;
|
|
52
64
|
validateSchema: ParallelWorkflow<void, unknown>;
|
|
53
65
|
prepare: AsyncWorkflow<void, void>;
|
|
54
66
|
commands: AsyncWorkflow<{
|
|
@@ -61,6 +73,9 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
|
|
|
61
73
|
beforeExit: AsyncWorkflow<void, void>;
|
|
62
74
|
} & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, registerHook: (newShape: Partial<Hooks>) => void, mountHook: () => Progresses2Runners<{
|
|
63
75
|
config: ParallelWorkflow<void, unknown>;
|
|
76
|
+
resolvedConfig: AsyncWaterfall<{
|
|
77
|
+
resolved: NormalizedConfig;
|
|
78
|
+
}>;
|
|
64
79
|
validateSchema: ParallelWorkflow<void, unknown>;
|
|
65
80
|
prepare: AsyncWorkflow<void, void>;
|
|
66
81
|
commands: AsyncWorkflow<{
|
|
@@ -77,7 +92,7 @@ export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedC
|
|
|
77
92
|
export type { NormalizedConfig, IAppContext, UserConfig, ToolsConfig };
|
|
78
93
|
declare const initAppDir: () => Promise<string>;
|
|
79
94
|
export interface CoreOptions {
|
|
80
|
-
|
|
95
|
+
configFile?: string;
|
|
81
96
|
plugins?: typeof INTERNAL_PLUGINS;
|
|
82
97
|
beforeUsePlugins: (plugins: any, config: any) => {
|
|
83
98
|
cli: any;
|
package/package.json
CHANGED