@modern-js/core 2.26.0 → 2.27.0
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/CHANGELOG.md +14 -0
- package/dist/bin.d.ts +1 -1
- package/dist/bin.js +5 -3
- package/dist/config/createDefaultConfig.d.ts +1 -1
- package/dist/config/createDefaultConfig.js +12 -6
- package/dist/config/createLoadedConfig.d.ts +1 -1
- package/dist/config/createLoadedConfig.js +80 -73
- package/dist/config/createResolvedConfig.d.ts +1 -1
- package/dist/config/createResolvedConfig.js +59 -72
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +7 -18
- package/dist/config/loadConfig.d.ts +5 -5
- package/dist/config/loadConfig.js +115 -112
- package/dist/context.d.ts +21 -14
- package/dist/context.js +74 -60
- package/dist/createCli.d.ts +13 -13
- package/dist/createCli.js +134 -113
- package/dist/index.d.ts +16 -16
- package/dist/index.js +59 -35
- package/dist/loadEnv.d.ts +1 -1
- package/dist/loadEnv.js +23 -17
- package/dist/loadPlugins.d.ts +4 -4
- package/dist/loadPlugins.js +54 -54
- package/dist/manager.d.ts +62 -62
- package/dist/manager.js +40 -23
- package/dist/nodeApi.d.ts +1 -1
- package/dist/nodeApi.js +25 -9
- package/dist/runBin.d.ts +2 -2
- package/dist/runBin.js +56 -53
- package/dist/schema/patchSchema.d.ts +15 -15
- package/dist/schema/patchSchema.js +56 -53
- package/dist/schema/testing.d.ts +11 -11
- package/dist/schema/testing.js +26 -8
- package/dist/schema/traverseSchema.d.ts +1 -1
- package/dist/schema/traverseSchema.js +25 -17
- package/dist/types/config/index.d.ts +37 -37
- package/dist/types/config/index.js +3 -1
- package/dist/types/config/testing.d.ts +11 -11
- package/dist/types/config/testing.js +3 -1
- package/dist/types/context.d.ts +27 -27
- package/dist/types/context.js +3 -1
- package/dist/types/coreOptions.d.ts +22 -22
- package/dist/types/coreOptions.js +3 -1
- package/dist/types/hooks.d.ts +41 -41
- package/dist/types/hooks.js +3 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +10 -21
- package/dist/types/plugin.d.ts +10 -10
- package/dist/types/plugin.js +3 -1
- package/dist/types/pluginAPI.d.ts +10 -10
- package/dist/types/pluginAPI.js +3 -1
- package/dist/utils/checkIsDuplicationPlugin.d.ts +1 -1
- package/dist/utils/checkIsDuplicationPlugin.js +24 -21
- package/dist/utils/commander.d.ts +1 -1
- package/dist/utils/commander.js +31 -17
- package/dist/utils/createFileWatcher.d.ts +1 -1
- package/dist/utils/createFileWatcher.js +85 -106
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +10 -21
- package/dist/utils/initAppDir.d.ts +1 -1
- package/dist/utils/initAppDir.js +22 -17
- package/dist/utils/mergeConfig.d.ts +1 -1
- package/dist/utils/mergeConfig.js +37 -27
- package/dist/utils/repeatKeyWarning.d.ts +1 -1
- package/dist/utils/repeatKeyWarning.js +29 -16
- package/package.json +11 -10
package/dist/manager.d.ts
CHANGED
|
@@ -1,141 +1,141 @@
|
|
|
1
1
|
import { BasePluginAPI } from './types';
|
|
2
2
|
export declare const manager: import("@modern-js/plugin").AsyncManager<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
4
|
+
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
|
|
5
|
+
resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
|
|
6
|
+
resolved: import("./types").NormalizedConfig<{}>;
|
|
7
|
+
}>;
|
|
8
|
+
validateSchema: import("@modern-js/plugin").ParallelWorkflow<void>;
|
|
9
|
+
prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
10
|
+
afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
11
|
+
watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, string[] | {
|
|
12
|
+
files: string[];
|
|
13
|
+
isPrivate: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
fileChange: import("@modern-js/plugin").AsyncWorkflow<{
|
|
16
|
+
filename: string;
|
|
17
|
+
eventType: "add" | "unlink" | "change";
|
|
18
|
+
isPrivate: boolean;
|
|
19
|
+
}, void>;
|
|
20
|
+
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
21
|
+
program: import("@modern-js/utils").Command;
|
|
22
|
+
}, void>;
|
|
23
|
+
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
24
|
+
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
25
25
|
}, BasePluginAPI<{}>>;
|
|
26
26
|
export declare const createPlugin: (setup?: import("@modern-js/plugin").AsyncSetup<{
|
|
27
27
|
beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
28
28
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
|
|
29
29
|
resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
|
|
30
|
-
|
|
30
|
+
resolved: import("./types").NormalizedConfig<{}>;
|
|
31
31
|
}>;
|
|
32
32
|
validateSchema: import("@modern-js/plugin").ParallelWorkflow<void>;
|
|
33
33
|
prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
34
34
|
afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
35
35
|
watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, string[] | {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
files: string[];
|
|
37
|
+
isPrivate: boolean;
|
|
38
38
|
}>;
|
|
39
39
|
fileChange: import("@modern-js/plugin").AsyncWorkflow<{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
filename: string;
|
|
41
|
+
eventType: "add" | "unlink" | "change";
|
|
42
|
+
isPrivate: boolean;
|
|
43
43
|
}, void>;
|
|
44
44
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
45
|
-
|
|
45
|
+
program: import("@modern-js/utils").Command;
|
|
46
46
|
}, void>;
|
|
47
47
|
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
48
48
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
49
|
-
}, BasePluginAPI<{}>> | undefined, options?: import("@modern-js/plugin").PluginOptions<{
|
|
49
|
+
}, BasePluginAPI<{}>> | undefined, options?: import("@modern-js/plugin").PluginOptions<{
|
|
50
50
|
beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
51
51
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
|
|
52
52
|
resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
|
|
53
|
-
|
|
53
|
+
resolved: import("./types").NormalizedConfig<{}>;
|
|
54
54
|
}>;
|
|
55
55
|
validateSchema: import("@modern-js/plugin").ParallelWorkflow<void>;
|
|
56
56
|
prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
57
57
|
afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
58
58
|
watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, string[] | {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
files: string[];
|
|
60
|
+
isPrivate: boolean;
|
|
61
61
|
}>;
|
|
62
62
|
fileChange: import("@modern-js/plugin").AsyncWorkflow<{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
filename: string;
|
|
64
|
+
eventType: "add" | "unlink" | "change";
|
|
65
|
+
isPrivate: boolean;
|
|
66
66
|
}, void>;
|
|
67
67
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
68
|
-
|
|
68
|
+
program: import("@modern-js/utils").Command;
|
|
69
69
|
}, void>;
|
|
70
70
|
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
71
71
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
72
|
-
}, import("@modern-js/plugin").AsyncSetup<{
|
|
72
|
+
}, import("@modern-js/plugin").AsyncSetup<{
|
|
73
73
|
beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
74
74
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
|
|
75
75
|
resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
|
|
76
|
-
|
|
76
|
+
resolved: import("./types").NormalizedConfig<{}>;
|
|
77
77
|
}>;
|
|
78
78
|
validateSchema: import("@modern-js/plugin").ParallelWorkflow<void>;
|
|
79
79
|
prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
80
80
|
afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
81
81
|
watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, string[] | {
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
files: string[];
|
|
83
|
+
isPrivate: boolean;
|
|
84
84
|
}>;
|
|
85
85
|
fileChange: import("@modern-js/plugin").AsyncWorkflow<{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
filename: string;
|
|
87
|
+
eventType: "add" | "unlink" | "change";
|
|
88
|
+
isPrivate: boolean;
|
|
89
89
|
}, void>;
|
|
90
90
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
91
|
-
|
|
91
|
+
program: import("@modern-js/utils").Command;
|
|
92
92
|
}, void>;
|
|
93
93
|
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
94
94
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
95
|
-
}, BasePluginAPI<{}>>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
|
|
95
|
+
}, BasePluginAPI<{}>>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
|
|
96
96
|
beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
97
97
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
|
|
98
98
|
resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
|
|
99
|
-
|
|
99
|
+
resolved: import("./types").NormalizedConfig<{}>;
|
|
100
100
|
}>;
|
|
101
101
|
validateSchema: import("@modern-js/plugin").ParallelWorkflow<void>;
|
|
102
102
|
prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
103
103
|
afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
104
104
|
watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, string[] | {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
files: string[];
|
|
106
|
+
isPrivate: boolean;
|
|
107
107
|
}>;
|
|
108
108
|
fileChange: import("@modern-js/plugin").AsyncWorkflow<{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
filename: string;
|
|
110
|
+
eventType: "add" | "unlink" | "change";
|
|
111
|
+
isPrivate: boolean;
|
|
112
112
|
}, void>;
|
|
113
113
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
114
|
-
|
|
114
|
+
program: import("@modern-js/utils").Command;
|
|
115
115
|
}, void>;
|
|
116
116
|
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
117
117
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
118
|
-
}, BasePluginAPI<{}>>, registerHook: (newHooks: Partial<{
|
|
118
|
+
}, BasePluginAPI<{}>>, registerHook: (newHooks: Partial<{
|
|
119
119
|
beforeConfig: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
120
120
|
config: import("@modern-js/plugin").ParallelWorkflow<void, import("./types").UserConfig<{}>>;
|
|
121
121
|
resolvedConfig: import("@modern-js/plugin").AsyncWaterfall<{
|
|
122
|
-
|
|
122
|
+
resolved: import("./types").NormalizedConfig<{}>;
|
|
123
123
|
}>;
|
|
124
124
|
validateSchema: import("@modern-js/plugin").ParallelWorkflow<void>;
|
|
125
125
|
prepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
126
126
|
afterPrepare: import("@modern-js/plugin").AsyncWorkflow<void, void>;
|
|
127
127
|
watchFiles: import("@modern-js/plugin").ParallelWorkflow<void, string[] | {
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
files: string[];
|
|
129
|
+
isPrivate: boolean;
|
|
130
130
|
}>;
|
|
131
131
|
fileChange: import("@modern-js/plugin").AsyncWorkflow<{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
filename: string;
|
|
133
|
+
eventType: "add" | "unlink" | "change";
|
|
134
|
+
isPrivate: boolean;
|
|
135
135
|
}, void>;
|
|
136
136
|
commands: import("@modern-js/plugin").AsyncWorkflow<{
|
|
137
|
-
|
|
137
|
+
program: import("@modern-js/utils").Command;
|
|
138
138
|
}, void>;
|
|
139
139
|
beforeExit: import("@modern-js/plugin").Workflow<void, void>;
|
|
140
140
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
141
|
-
}>) => void;
|
|
141
|
+
}>) => void;
|
package/dist/manager.js
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
manager: function() {
|
|
14
|
+
return manager;
|
|
15
|
+
},
|
|
16
|
+
createPlugin: function() {
|
|
17
|
+
return createPlugin;
|
|
18
|
+
},
|
|
19
|
+
registerHook: function() {
|
|
20
|
+
return registerHook;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _plugin = require("@modern-js/plugin");
|
|
24
|
+
const _context = require("./context");
|
|
7
25
|
const baseHooks = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
beforeConfig: (0, _plugin.createAsyncWorkflow)(),
|
|
27
|
+
config: (0, _plugin.createParallelWorkflow)(),
|
|
28
|
+
resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
|
|
29
|
+
validateSchema: (0, _plugin.createParallelWorkflow)(),
|
|
30
|
+
prepare: (0, _plugin.createAsyncWorkflow)(),
|
|
31
|
+
afterPrepare: (0, _plugin.createAsyncWorkflow)(),
|
|
32
|
+
commands: (0, _plugin.createAsyncWorkflow)(),
|
|
33
|
+
watchFiles: (0, _plugin.createParallelWorkflow)(),
|
|
34
|
+
fileChange: (0, _plugin.createAsyncWorkflow)(),
|
|
35
|
+
beforeExit: (0, _plugin.createWorkflow)(),
|
|
36
|
+
addRuntimeExports: (0, _plugin.createAsyncWaterfall)()
|
|
19
37
|
};
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
21
38
|
const pluginAPI = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
39
|
+
setAppContext: _context.setAppContext,
|
|
40
|
+
useAppContext: _context.useAppContext,
|
|
41
|
+
useConfigContext: _context.useConfigContext,
|
|
42
|
+
useResolvedConfigContext: _context.useResolvedConfigContext
|
|
26
43
|
};
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
const manager = (0, _plugin.createAsyncManager)(baseHooks, pluginAPI);
|
|
45
|
+
const { createPlugin, registerHook } = manager;
|
package/dist/nodeApi.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CoreOptions } from '.';
|
|
2
2
|
export declare const dev: (options?: CoreOptions, commandOptions?: string[]) => void;
|
|
3
3
|
export declare const build: (options?: CoreOptions, commandOptions?: string[]) => void;
|
|
4
|
-
export declare const deploy: (options?: CoreOptions, commandOptions?: string[]) => void;
|
|
4
|
+
export declare const deploy: (options?: CoreOptions, commandOptions?: string[]) => void;
|
package/dist/nodeApi.js
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
dev: function() {
|
|
14
|
+
return dev;
|
|
15
|
+
},
|
|
16
|
+
build: function() {
|
|
17
|
+
return build;
|
|
18
|
+
},
|
|
19
|
+
deploy: function() {
|
|
20
|
+
return deploy;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _ = require(".");
|
|
5
24
|
const dev = (options, commandOptions = []) => {
|
|
6
|
-
|
|
25
|
+
_.cli.runCommand("dev", commandOptions, options);
|
|
7
26
|
};
|
|
8
|
-
exports.dev = dev;
|
|
9
27
|
const build = (options, commandOptions = []) => {
|
|
10
|
-
|
|
28
|
+
_.cli.runCommand("build", commandOptions, options);
|
|
11
29
|
};
|
|
12
|
-
exports.build = build;
|
|
13
30
|
const deploy = (options, commandOptions = []) => {
|
|
14
|
-
|
|
31
|
+
_.cli.runCommand("deploy", commandOptions, options);
|
|
15
32
|
};
|
|
16
|
-
exports.deploy = deploy;
|
package/dist/runBin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { CoreOptions } from '.';
|
|
3
3
|
export declare const run: (otherCoreOptions?: CoreOptions, options?: {
|
|
4
|
-
|
|
5
|
-
}) => Promise<void>;
|
|
4
|
+
override?: boolean | ((coreOptions: CoreOptions) => Promise<CoreOptions> | CoreOptions) | undefined;
|
|
5
|
+
}) => Promise<void>;
|
package/dist/runBin.js
CHANGED
|
@@ -1,58 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "run", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return run;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const _utils = require("@modern-js/utils");
|
|
13
|
+
const _ = require(".");
|
|
7
14
|
const run = async (otherCoreOptions = {}, options = {}) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const cliParams = (0, utils_1.minimist)(process.argv.slice(2));
|
|
22
|
-
const runOptions = {
|
|
23
|
-
version,
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Commands that support specify config files
|
|
27
|
-
* `new` command need to use `--config-file` params,because `--config` is already used
|
|
28
|
-
*/
|
|
29
|
-
const SUPPORT_CONFIG_PARAM_COMMANDS = [
|
|
30
|
-
'dev',
|
|
31
|
-
'build',
|
|
32
|
-
'deploy',
|
|
33
|
-
'start',
|
|
34
|
-
'serve',
|
|
35
|
-
'inspect',
|
|
36
|
-
'upgrade',
|
|
37
|
-
];
|
|
38
|
-
let customConfigFile;
|
|
39
|
-
if (SUPPORT_CONFIG_PARAM_COMMANDS.includes(command)) {
|
|
40
|
-
customConfigFile = cliParams.config || cliParams.c;
|
|
41
|
-
}
|
|
42
|
-
if (command === 'new') {
|
|
43
|
-
customConfigFile = cliParams['config-file'];
|
|
44
|
-
}
|
|
45
|
-
if (customConfigFile) {
|
|
46
|
-
runOptions.configFile = customConfigFile;
|
|
47
|
-
}
|
|
48
|
-
if (typeof options.override === 'boolean' && options.override) {
|
|
49
|
-
await _1.cli.run(otherCoreOptions);
|
|
50
|
-
}
|
|
51
|
-
else if (typeof (options === null || options === void 0 ? void 0 : options.override) === 'function') {
|
|
52
|
-
await _1.cli.run(await options.override(runOptions));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
await _1.cli.run(utils_1.lodash.merge({}, runOptions, otherCoreOptions));
|
|
15
|
+
const command = process.argv[2];
|
|
16
|
+
if (!process.env.NODE_ENV) {
|
|
17
|
+
if ([
|
|
18
|
+
"build",
|
|
19
|
+
"serve",
|
|
20
|
+
"deploy",
|
|
21
|
+
"release"
|
|
22
|
+
].includes(command)) {
|
|
23
|
+
process.env.NODE_ENV = "production";
|
|
24
|
+
} else if (command === "test") {
|
|
25
|
+
process.env.NODE_ENV = "test";
|
|
26
|
+
} else {
|
|
27
|
+
process.env.NODE_ENV = "development";
|
|
56
28
|
}
|
|
29
|
+
}
|
|
30
|
+
const { version } = require("../package.json");
|
|
31
|
+
const cliParams = (0, _utils.minimist)(process.argv.slice(2));
|
|
32
|
+
const runOptions = {
|
|
33
|
+
version
|
|
34
|
+
};
|
|
35
|
+
const SUPPORT_CONFIG_PARAM_COMMANDS = [
|
|
36
|
+
"dev",
|
|
37
|
+
"build",
|
|
38
|
+
"deploy",
|
|
39
|
+
"start",
|
|
40
|
+
"serve",
|
|
41
|
+
"inspect",
|
|
42
|
+
"upgrade"
|
|
43
|
+
];
|
|
44
|
+
let customConfigFile;
|
|
45
|
+
if (SUPPORT_CONFIG_PARAM_COMMANDS.includes(command)) {
|
|
46
|
+
customConfigFile = cliParams.config || cliParams.c;
|
|
47
|
+
}
|
|
48
|
+
if (command === "new") {
|
|
49
|
+
customConfigFile = cliParams["config-file"];
|
|
50
|
+
}
|
|
51
|
+
if (customConfigFile) {
|
|
52
|
+
runOptions.configFile = customConfigFile;
|
|
53
|
+
}
|
|
54
|
+
if (typeof options.override === "boolean" && options.override) {
|
|
55
|
+
await _.cli.run(otherCoreOptions);
|
|
56
|
+
} else if (typeof (options === null || options === void 0 ? void 0 : options.override) === "function") {
|
|
57
|
+
await _.cli.run(await options.override(runOptions));
|
|
58
|
+
} else {
|
|
59
|
+
await _.cli.run(_utils.lodash.merge({}, runOptions, otherCoreOptions));
|
|
60
|
+
}
|
|
57
61
|
};
|
|
58
|
-
exports.run = run;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { PluginValidateSchema } from '../types';
|
|
2
2
|
export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | PluginValidateSchema[]>) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
jest: {
|
|
14
|
-
typeof: string[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
3
|
+
type: string;
|
|
4
|
+
properties: {
|
|
5
|
+
testing: {
|
|
6
|
+
type: string;
|
|
7
|
+
additionalProperties: boolean;
|
|
8
|
+
properties: {
|
|
9
|
+
transformer: {
|
|
10
|
+
type: string;
|
|
11
|
+
enum: string[];
|
|
17
12
|
};
|
|
13
|
+
jest: {
|
|
14
|
+
typeof: string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
18
17
|
};
|
|
19
|
-
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -1,57 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "patchSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return patchSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _utils = require("@modern-js/utils");
|
|
12
|
+
const _lodash = require("@modern-js/utils/lodash");
|
|
13
|
+
const _testing = require("./testing");
|
|
14
|
+
const debug = (0, _utils.createDebugger)("validate-schema");
|
|
8
15
|
const patchSchema = (pluginSchemas) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const findTargetNode = (props) => {
|
|
16
|
-
let node = finalSchema.properties;
|
|
17
|
-
for (const prop of props) {
|
|
18
|
-
if (!node[prop]) {
|
|
19
|
-
node[prop] = {
|
|
20
|
-
type: 'object',
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
node = node[prop];
|
|
24
|
-
if (!node || !(0, utils_1.isObject)(node)) {
|
|
25
|
-
throw new Error(`add schema ${props.join('.')} error`);
|
|
26
|
-
}
|
|
27
|
-
node.properties = node.hasOwnProperty('properties')
|
|
28
|
-
? node.properties
|
|
29
|
-
: {};
|
|
30
|
-
node = node.properties;
|
|
31
|
-
}
|
|
32
|
-
return node;
|
|
33
|
-
};
|
|
34
|
-
const finalPluginSchemas = [];
|
|
35
|
-
pluginSchemas.forEach(item => {
|
|
36
|
-
if (Array.isArray(item)) {
|
|
37
|
-
finalPluginSchemas.push(...item);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
finalPluginSchemas.push(item);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
for (const { target, schema } of finalPluginSchemas) {
|
|
44
|
-
if (!target) {
|
|
45
|
-
throw new Error(`should return target property in plugin schema.`);
|
|
46
|
-
}
|
|
47
|
-
const props = target.split('.');
|
|
48
|
-
const mountProperty = props.pop();
|
|
49
|
-
const targetNode = findTargetNode(props);
|
|
50
|
-
if (!targetNode.hasOwnProperty(mountProperty)) {
|
|
51
|
-
targetNode[mountProperty] = (0, lodash_1.cloneDeep)(schema);
|
|
52
|
-
}
|
|
16
|
+
const finalSchema = (0, _lodash.cloneDeep)({
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
testing: _testing.testing
|
|
53
20
|
}
|
|
54
|
-
|
|
55
|
-
|
|
21
|
+
});
|
|
22
|
+
const findTargetNode = (props) => {
|
|
23
|
+
let node = finalSchema.properties;
|
|
24
|
+
for (const prop of props) {
|
|
25
|
+
if (!node[prop]) {
|
|
26
|
+
node[prop] = {
|
|
27
|
+
type: "object"
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
node = node[prop];
|
|
31
|
+
if (!node || !(0, _utils.isObject)(node)) {
|
|
32
|
+
throw new Error(`add schema ${props.join(".")} error`);
|
|
33
|
+
}
|
|
34
|
+
node.properties = node.hasOwnProperty("properties") ? node.properties : {};
|
|
35
|
+
node = node.properties;
|
|
36
|
+
}
|
|
37
|
+
return node;
|
|
38
|
+
};
|
|
39
|
+
const finalPluginSchemas = [];
|
|
40
|
+
pluginSchemas.forEach((item) => {
|
|
41
|
+
if (Array.isArray(item)) {
|
|
42
|
+
finalPluginSchemas.push(...item);
|
|
43
|
+
} else {
|
|
44
|
+
finalPluginSchemas.push(item);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
for (const { target, schema } of finalPluginSchemas) {
|
|
48
|
+
if (!target) {
|
|
49
|
+
throw new Error(`should return target property in plugin schema.`);
|
|
50
|
+
}
|
|
51
|
+
const props = target.split(".");
|
|
52
|
+
const mountProperty = props.pop();
|
|
53
|
+
const targetNode = findTargetNode(props);
|
|
54
|
+
if (!targetNode.hasOwnProperty(mountProperty)) {
|
|
55
|
+
targetNode[mountProperty] = (0, _lodash.cloneDeep)(schema);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
debug(`final validate schema: %o`, finalSchema);
|
|
59
|
+
return finalSchema;
|
|
56
60
|
};
|
|
57
|
-
exports.patchSchema = patchSchema;
|
package/dist/schema/testing.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const testing: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
jest: {
|
|
10
|
-
typeof: string[];
|
|
11
|
-
};
|
|
2
|
+
type: string;
|
|
3
|
+
additionalProperties: boolean;
|
|
4
|
+
properties: {
|
|
5
|
+
transformer: {
|
|
6
|
+
type: string;
|
|
7
|
+
enum: string[];
|
|
12
8
|
};
|
|
13
|
-
|
|
9
|
+
jest: {
|
|
10
|
+
typeof: string[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
package/dist/schema/testing.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "testing", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return testing;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const testing = {
|
|
12
|
+
type: "object",
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties: {
|
|
15
|
+
transformer: {
|
|
16
|
+
type: "string",
|
|
17
|
+
enum: [
|
|
18
|
+
"babel-jest",
|
|
19
|
+
"ts-jest"
|
|
20
|
+
]
|
|
10
21
|
},
|
|
22
|
+
jest: {
|
|
23
|
+
typeof: [
|
|
24
|
+
"object",
|
|
25
|
+
"function"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
11
29
|
};
|