@modern-js/core 1.7.1 → 1.9.1
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 +1 -0
- package/CHANGELOG.md +47 -0
- package/bin/modern-js.js +1 -1
- package/compiled/ajv/codegen.js +1 -0
- package/compiled/ajv/dist/ajv.d.ts +16 -0
- package/compiled/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/compiled/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/ajv/dist/compile/ref_error.d.ts +6 -0
- package/compiled/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/ajv/dist/core.d.ts +173 -0
- package/compiled/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/ajv/dist/types/index.d.ts +183 -0
- package/compiled/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/ajv/dist/types/jtd-schema.d.ts +169 -0
- package/compiled/ajv/index.js +9 -0
- package/compiled/ajv/license +22 -0
- package/compiled/ajv/package.json +1 -0
- package/compiled/ajv/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/ajv-keywords/ajv/dist/ajv.d.ts +16 -0
- package/compiled/ajv-keywords/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/compiled/ajv-keywords/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/ajv-keywords/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/ajv-keywords/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/ajv-keywords/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/ajv-keywords/ajv/dist/compile/ref_error.d.ts +6 -0
- package/compiled/ajv-keywords/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/ajv-keywords/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/ajv-keywords/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/ajv-keywords/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/ajv-keywords/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/ajv-keywords/ajv/dist/core.d.ts +173 -0
- package/compiled/ajv-keywords/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/ajv-keywords/ajv/dist/types/index.d.ts +183 -0
- package/compiled/ajv-keywords/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/ajv-keywords/ajv/dist/types/jtd-schema.d.ts +169 -0
- package/compiled/ajv-keywords/dist/index.d.ts +4 -0
- package/compiled/ajv-keywords/index.js +1 -0
- package/compiled/ajv-keywords/license +21 -0
- package/compiled/ajv-keywords/package.json +1 -0
- package/compiled/ajv-keywords/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/better-ajv-errors/ajv/dist/ajv.d.ts +16 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/ref_error.d.ts +6 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/better-ajv-errors/ajv/dist/core.d.ts +173 -0
- package/compiled/better-ajv-errors/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/better-ajv-errors/ajv/dist/types/index.d.ts +183 -0
- package/compiled/better-ajv-errors/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/better-ajv-errors/ajv/dist/types/jtd-schema.d.ts +169 -0
- package/compiled/better-ajv-errors/index.js +1 -0
- package/compiled/better-ajv-errors/license +13 -0
- package/compiled/better-ajv-errors/package.json +1 -0
- package/compiled/better-ajv-errors/typings.d.ts +24 -0
- package/compiled/better-ajv-errors/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/v8-compile-cache/index.js +1 -0
- package/compiled/v8-compile-cache/license +21 -0
- package/compiled/v8-compile-cache/package.json +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +33 -0
- package/dist/config/defaults.d.ts +28 -0
- package/dist/config/defaults.js +98 -0
- package/dist/{types/config → config}/index.d.ts +2 -2
- package/dist/config/index.js +120 -0
- package/dist/config/mergeConfig.d.ts +30 -0
- package/dist/config/mergeConfig.js +26 -0
- package/dist/config/schema/deploy.d.ts +16 -0
- package/dist/config/schema/deploy.js +16 -0
- package/dist/config/schema/index.d.ts +466 -0
- package/dist/config/schema/index.js +95 -0
- package/dist/config/schema/output.d.ts +146 -0
- package/dist/config/schema/output.js +68 -0
- package/dist/config/schema/server.d.ts +182 -0
- package/dist/config/schema/server.js +107 -0
- package/dist/config/schema/source.d.ts +58 -0
- package/dist/config/schema/source.js +36 -0
- package/dist/config/schema/tools.d.ts +36 -0
- package/dist/config/schema/tools.js +19 -0
- package/dist/config/types/electron.d.ts +13 -0
- package/dist/config/types/electron.js +2 -0
- package/dist/config/types/index.d.ts +240 -0
- package/dist/config/types/index.js +2 -0
- package/dist/config/types/less.d.ts +10 -0
- package/dist/config/types/less.js +2 -0
- package/dist/config/types/sass.d.ts +8 -0
- package/dist/config/types/sass.js +2 -0
- package/dist/{types/config → config}/types/ssg.d.ts +8 -8
- package/dist/config/types/ssg.js +2 -0
- package/dist/config/types/test.d.ts +14 -0
- package/dist/config/types/test.js +2 -0
- package/dist/config/types/unbundle.d.ts +25 -0
- package/dist/config/types/unbundle.js +2 -0
- package/dist/{types/context.d.ts → context.d.ts} +12 -22
- package/dist/context.js +59 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +177 -0
- package/dist/{types/initWatcher.d.ts → initWatcher.d.ts} +1 -1
- package/dist/initWatcher.js +75 -0
- package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
- package/dist/loadEnv.js +21 -0
- package/dist/{types/loadPlugins.d.ts → loadPlugins.d.ts} +15 -15
- package/dist/loadPlugins.js +109 -0
- package/dist/manager.d.ts +72 -0
- package/dist/manager.js +24 -0
- package/dist/{types/pluginAPI.d.ts → pluginAPI.d.ts} +5 -6
- package/dist/pluginAPI.js +16 -0
- package/dist/{types/utils → utils}/commander.d.ts +1 -1
- package/dist/utils/commander.js +20 -0
- package/dist/{types/utils → utils}/repeatKeyWarning.d.ts +1 -1
- package/dist/utils/repeatKeyWarning.js +22 -0
- package/package.json +16 -29
- package/tsconfig.json +3 -4
- package/dist/js/modern/cli.js +0 -29
- package/dist/js/modern/config/defaults.js +0 -103
- package/dist/js/modern/config/index.js +0 -115
- package/dist/js/modern/config/mergeConfig.js +0 -22
- package/dist/js/modern/config/schema/deploy.js +0 -17
- package/dist/js/modern/config/schema/index.js +0 -107
- package/dist/js/modern/config/schema/output.js +0 -147
- package/dist/js/modern/config/schema/server.js +0 -170
- package/dist/js/modern/config/schema/source.js +0 -59
- package/dist/js/modern/config/schema/tools.js +0 -36
- package/dist/js/modern/config/types/index.js +0 -1
- package/dist/js/modern/config/types/less.js +0 -0
- package/dist/js/modern/config/types/sass.js +0 -0
- package/dist/js/modern/config/types/ssg.js +0 -0
- package/dist/js/modern/config/types/test.js +0 -0
- package/dist/js/modern/config/types/unbundle.js +0 -0
- package/dist/js/modern/context.js +0 -63
- package/dist/js/modern/index.js +0 -168
- package/dist/js/modern/initWatcher.js +0 -62
- package/dist/js/modern/loadEnv.js +0 -14
- package/dist/js/modern/loadPlugins.js +0 -117
- package/dist/js/modern/manager.js +0 -28
- package/dist/js/modern/pluginAPI.js +0 -11
- package/dist/js/modern/utils/commander.js +0 -19
- package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
- package/dist/js/node/cli.js +0 -35
- package/dist/js/node/config/defaults.js +0 -110
- package/dist/js/node/config/index.js +0 -182
- package/dist/js/node/config/mergeConfig.js +0 -32
- package/dist/js/node/config/schema/deploy.js +0 -26
- package/dist/js/node/config/schema/index.js +0 -127
- package/dist/js/node/config/schema/output.js +0 -156
- package/dist/js/node/config/schema/server.js +0 -179
- package/dist/js/node/config/schema/source.js +0 -68
- package/dist/js/node/config/schema/tools.js +0 -43
- package/dist/js/node/config/types/index.js +0 -5
- package/dist/js/node/config/types/less.js +0 -0
- package/dist/js/node/config/types/sass.js +0 -0
- package/dist/js/node/config/types/ssg.js +0 -0
- package/dist/js/node/config/types/test.js +0 -0
- package/dist/js/node/config/types/unbundle.js +0 -0
- package/dist/js/node/context.js +0 -93
- package/dist/js/node/index.js +0 -328
- package/dist/js/node/initWatcher.js +0 -82
- package/dist/js/node/loadEnv.js +0 -30
- package/dist/js/node/loadPlugins.js +0 -129
- package/dist/js/node/manager.js +0 -45
- package/dist/js/node/pluginAPI.js +0 -54
- package/dist/js/node/utils/commander.js +0 -32
- package/dist/js/node/utils/repeatKeyWarning.js +0 -31
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/config/defaults.d.ts +0 -28
- package/dist/types/config/mergeConfig.d.ts +0 -31
- package/dist/types/config/schema/deploy.d.ts +0 -16
- package/dist/types/config/schema/index.d.ts +0 -466
- package/dist/types/config/schema/output.d.ts +0 -146
- package/dist/types/config/schema/server.d.ts +0 -182
- package/dist/types/config/schema/source.d.ts +0 -58
- package/dist/types/config/schema/tools.d.ts +0 -36
- package/dist/types/config/types/index.d.ts +0 -239
- package/dist/types/config/types/less.d.ts +0 -10
- package/dist/types/config/types/sass.d.ts +0 -8
- package/dist/types/config/types/test.d.ts +0 -15
- package/dist/types/config/types/unbundle.d.ts +0 -28
- package/dist/types/index.d.ts +0 -61
- package/dist/types/manager.d.ts +0 -74
- package/modern.config.js +0 -6
- package/tests/.eslintrc.js +0 -6
- package/tests/btsm.test.ts +0 -20
- package/tests/config.test.ts +0 -146
- package/tests/context.test.ts +0 -85
- package/tests/fixtures/index-test/modern.server-runtime.config.js +0 -0
- package/tests/fixtures/index-test/package.json +0 -3
- package/tests/fixtures/load-plugin/not-found/package.json +0 -3
- package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +0 -1
- package/tests/fixtures/load-plugin/user-plugins/package.json +0 -3
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +0 -1
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +0 -3
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-c.js +0 -3
- package/tests/index.test.ts +0 -83
- package/tests/initWatcher.test.ts +0 -63
- package/tests/loadEnv.test.ts +0 -173
- package/tests/loadPlugin.test.ts +0 -116
- package/tests/mergeConfig.test.ts +0 -97
- package/tests/pluginAPI.test.ts +0 -19
- package/tests/repeatKeyWarning.test.ts +0 -68
- package/tests/schema.test.ts +0 -107
- package/tests/tsconfig.json +0 -11
- package/tests/utils.test.ts +0 -7
package/dist/js/node/index.js
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
mergeOptions: true,
|
|
8
|
-
cli: true,
|
|
9
|
-
initAppDir: true,
|
|
10
|
-
initAppContext: true,
|
|
11
|
-
manager: true,
|
|
12
|
-
mountHook: true,
|
|
13
|
-
usePlugins: true,
|
|
14
|
-
createPlugin: true,
|
|
15
|
-
registerHook: true,
|
|
16
|
-
AppContext: true,
|
|
17
|
-
ConfigContext: true,
|
|
18
|
-
ResolvedConfigContext: true,
|
|
19
|
-
useAppContext: true,
|
|
20
|
-
useConfigContext: true,
|
|
21
|
-
useResolvedConfigContext: true
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "AppContext", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return _pluginAPI.AppContext;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "ConfigContext", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _pluginAPI.ConfigContext;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, "ResolvedConfigContext", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () {
|
|
38
|
-
return _pluginAPI.ResolvedConfigContext;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
exports.cli = void 0;
|
|
42
|
-
Object.defineProperty(exports, "createPlugin", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _manager.createPlugin;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "initAppContext", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _context.initAppContext;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
exports.initAppDir = void 0;
|
|
55
|
-
Object.defineProperty(exports, "manager", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () {
|
|
58
|
-
return _manager.manager;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
exports.mergeOptions = void 0;
|
|
62
|
-
Object.defineProperty(exports, "mountHook", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function () {
|
|
65
|
-
return _manager.mountHook;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "registerHook", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function () {
|
|
71
|
-
return _manager.registerHook;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, "useAppContext", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return _pluginAPI.useAppContext;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, "useConfigContext", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function () {
|
|
83
|
-
return _pluginAPI.useConfigContext;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, "usePlugins", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function () {
|
|
89
|
-
return _manager.usePlugins;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, "useResolvedConfigContext", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () {
|
|
95
|
-
return _pluginAPI.useResolvedConfigContext;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
var _path = _interopRequireDefault(require("path"));
|
|
100
|
-
|
|
101
|
-
var _utils = require("@modern-js/utils");
|
|
102
|
-
|
|
103
|
-
var _node = require("@modern-js/plugin/node");
|
|
104
|
-
|
|
105
|
-
Object.keys(_node).forEach(function (key) {
|
|
106
|
-
if (key === "default" || key === "__esModule") return;
|
|
107
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
108
|
-
if (key in exports && exports[key] === _node[key]) return;
|
|
109
|
-
Object.defineProperty(exports, key, {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () {
|
|
112
|
-
return _node[key];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
var _commander = require("./utils/commander");
|
|
118
|
-
|
|
119
|
-
var _config = require("./config");
|
|
120
|
-
|
|
121
|
-
Object.keys(_config).forEach(function (key) {
|
|
122
|
-
if (key === "default" || key === "__esModule") return;
|
|
123
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
124
|
-
if (key in exports && exports[key] === _config[key]) return;
|
|
125
|
-
Object.defineProperty(exports, key, {
|
|
126
|
-
enumerable: true,
|
|
127
|
-
get: function () {
|
|
128
|
-
return _config[key];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
var _loadPlugins = require("./loadPlugins");
|
|
134
|
-
|
|
135
|
-
var _context = require("./context");
|
|
136
|
-
|
|
137
|
-
var _initWatcher = require("./initWatcher");
|
|
138
|
-
|
|
139
|
-
var _loadEnv = require("./loadEnv");
|
|
140
|
-
|
|
141
|
-
var _manager = require("./manager");
|
|
142
|
-
|
|
143
|
-
var _plugin = require("@modern-js/plugin");
|
|
144
|
-
|
|
145
|
-
Object.keys(_plugin).forEach(function (key) {
|
|
146
|
-
if (key === "default" || key === "__esModule") return;
|
|
147
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
148
|
-
if (key in exports && exports[key] === _plugin[key]) return;
|
|
149
|
-
Object.defineProperty(exports, key, {
|
|
150
|
-
enumerable: true,
|
|
151
|
-
get: function () {
|
|
152
|
-
return _plugin[key];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
var _pluginAPI = require("./pluginAPI");
|
|
158
|
-
|
|
159
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
160
|
-
|
|
161
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
162
|
-
|
|
163
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
164
|
-
|
|
165
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
166
|
-
|
|
167
|
-
_utils.program.name('modern').usage('<command> [options]').version(process.env.MODERN_JS_VERSION || '0.1.0');
|
|
168
|
-
|
|
169
|
-
const initAppDir = async cwd => {
|
|
170
|
-
if (!cwd) {
|
|
171
|
-
// eslint-disable-next-line no-param-reassign
|
|
172
|
-
cwd = process.cwd();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const pkg = await (0, _utils.pkgUp)({
|
|
176
|
-
cwd
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
if (!pkg) {
|
|
180
|
-
throw new Error(`no package.json found in current work dir: ${cwd}`);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return _path.default.dirname(pkg);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
exports.initAppDir = initAppDir;
|
|
187
|
-
|
|
188
|
-
const mergeOptions = options => {
|
|
189
|
-
const defaultOptions = {
|
|
190
|
-
serverConfigFile: _utils.DEFAULT_SERVER_CONFIG
|
|
191
|
-
};
|
|
192
|
-
return _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
exports.mergeOptions = mergeOptions;
|
|
196
|
-
|
|
197
|
-
const createCli = () => {
|
|
198
|
-
let hooksRunner;
|
|
199
|
-
let isRestart = false;
|
|
200
|
-
let restartWithExistingPort = 0;
|
|
201
|
-
let restartOptions;
|
|
202
|
-
|
|
203
|
-
const init = async (argv = [], options) => {
|
|
204
|
-
var _mergedOptions$option, _mergedOptions$option2;
|
|
205
|
-
|
|
206
|
-
(0, _node.enable)();
|
|
207
|
-
|
|
208
|
-
_manager.manager.clear();
|
|
209
|
-
|
|
210
|
-
const mergedOptions = mergeOptions(options);
|
|
211
|
-
restartOptions = mergedOptions;
|
|
212
|
-
const appDirectory = await initAppDir();
|
|
213
|
-
(0, _commander.initCommandsMap)();
|
|
214
|
-
const metaName = (_mergedOptions$option = mergedOptions === null || mergedOptions === void 0 ? void 0 : (_mergedOptions$option2 = mergedOptions.options) === null || _mergedOptions$option2 === void 0 ? void 0 : _mergedOptions$option2.metaName) !== null && _mergedOptions$option !== void 0 ? _mergedOptions$option : 'MODERN';
|
|
215
|
-
(0, _loadEnv.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
|
|
216
|
-
const loaded = await (0, _config.loadUserConfig)(appDirectory, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.configFile, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.packageJsonConfig);
|
|
217
|
-
const plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config, {
|
|
218
|
-
internalPlugins: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.plugins
|
|
219
|
-
});
|
|
220
|
-
plugins.forEach(plugin => plugin.cli && _manager.manager.usePlugin(plugin.cli));
|
|
221
|
-
const appContext = (0, _context.initAppContext)({
|
|
222
|
-
appDirectory,
|
|
223
|
-
plugins,
|
|
224
|
-
configFile: loaded.filePath,
|
|
225
|
-
options: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.options,
|
|
226
|
-
serverConfigFile: mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.serverConfigFile
|
|
227
|
-
}); // 将 server.config 加入到 loaded.dependencies,以便对文件监听做热更新
|
|
228
|
-
|
|
229
|
-
(0, _config.addServerConfigToDeps)(loaded.dependencies, appDirectory, mergedOptions.serverConfigFile);
|
|
230
|
-
|
|
231
|
-
_manager.manager.run(() => {
|
|
232
|
-
_context.ConfigContext.set(loaded.config);
|
|
233
|
-
|
|
234
|
-
_context.AppContext.set(appContext);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
hooksRunner = await _manager.manager.init();
|
|
238
|
-
['SIGINT', 'SIGTERM', 'unhandledRejection', 'uncaughtException'].forEach(event => {
|
|
239
|
-
process.on(event, async err => {
|
|
240
|
-
await hooksRunner.beforeExit();
|
|
241
|
-
|
|
242
|
-
if (err instanceof Error) {
|
|
243
|
-
_utils.logger.error(err.stack);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
process.nextTick(() => {
|
|
247
|
-
// eslint-disable-next-line no-process-exit
|
|
248
|
-
process.exit(1);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
const extraConfigs = await hooksRunner.config();
|
|
253
|
-
const extraSchemas = await hooksRunner.validateSchema();
|
|
254
|
-
const config = await (0, _config.resolveConfig)(loaded, extraConfigs, extraSchemas, restartWithExistingPort, argv, options === null || options === void 0 ? void 0 : options.onSchemaError);
|
|
255
|
-
const {
|
|
256
|
-
resolved
|
|
257
|
-
} = await hooksRunner.resolvedConfig({
|
|
258
|
-
resolved: config
|
|
259
|
-
}); // update context value
|
|
260
|
-
|
|
261
|
-
_manager.manager.run(() => {
|
|
262
|
-
_context.ConfigContext.set(loaded.config);
|
|
263
|
-
|
|
264
|
-
_context.ResolvedConfigContext.set(resolved);
|
|
265
|
-
|
|
266
|
-
_context.AppContext.set(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
267
|
-
port: resolved.server.port,
|
|
268
|
-
distDirectory: (0, _utils.ensureAbsolutePath)(appDirectory, resolved.output.path)
|
|
269
|
-
}));
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
await hooksRunner.prepare();
|
|
273
|
-
return {
|
|
274
|
-
loadedConfig: loaded,
|
|
275
|
-
appContext,
|
|
276
|
-
resolved
|
|
277
|
-
};
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
async function run(argv, options) {
|
|
281
|
-
const {
|
|
282
|
-
loadedConfig,
|
|
283
|
-
appContext,
|
|
284
|
-
resolved
|
|
285
|
-
} = await init(argv, options);
|
|
286
|
-
await hooksRunner.commands({
|
|
287
|
-
program: _utils.program
|
|
288
|
-
});
|
|
289
|
-
(0, _initWatcher.initWatcher)(loadedConfig, appContext.appDirectory, resolved.source.configDir, hooksRunner, argv);
|
|
290
|
-
|
|
291
|
-
_manager.manager.run(() => _utils.program.parse(process.argv));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
async function restart() {
|
|
295
|
-
var _AppContext$use$value, _AppContext$use$value2;
|
|
296
|
-
|
|
297
|
-
isRestart = true;
|
|
298
|
-
restartWithExistingPort = isRestart ? (_AppContext$use$value = (_AppContext$use$value2 = _context.AppContext.use().value) === null || _AppContext$use$value2 === void 0 ? void 0 : _AppContext$use$value2.port) !== null && _AppContext$use$value !== void 0 ? _AppContext$use$value : 0 : 0;
|
|
299
|
-
|
|
300
|
-
_utils.logger.info('Restart...\n');
|
|
301
|
-
|
|
302
|
-
let hasGetError = false;
|
|
303
|
-
|
|
304
|
-
const runner = _manager.manager.useRunner();
|
|
305
|
-
|
|
306
|
-
await runner.beforeRestart();
|
|
307
|
-
|
|
308
|
-
try {
|
|
309
|
-
await init(process.argv.slice(2), restartOptions);
|
|
310
|
-
} catch (err) {
|
|
311
|
-
console.error(err);
|
|
312
|
-
hasGetError = true;
|
|
313
|
-
} finally {
|
|
314
|
-
if (!hasGetError) {
|
|
315
|
-
_manager.manager.run(() => _utils.program.parse(process.argv));
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return {
|
|
321
|
-
init,
|
|
322
|
-
run,
|
|
323
|
-
restart
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
const cli = createCli();
|
|
328
|
-
exports.cli = cli;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.initWatcher = void 0;
|
|
7
|
-
|
|
8
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
9
|
-
|
|
10
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
-
|
|
12
|
-
var _path = _interopRequireDefault(require("path"));
|
|
13
|
-
|
|
14
|
-
var _utils = require("@modern-js/utils");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const debug = (0, _utils.createDebugger)('watch-files');
|
|
19
|
-
|
|
20
|
-
const md5 = data => _crypto.default.createHash('md5').update(data).digest('hex');
|
|
21
|
-
|
|
22
|
-
const hashMap = new Map();
|
|
23
|
-
|
|
24
|
-
const initWatcher = async (loaded, appDirectory, configDir, hooksRunner, argv) => {
|
|
25
|
-
// only add fs watcher on dev mode.
|
|
26
|
-
if (((0, _utils.isDev)() || (0, _utils.isTest)()) && argv[0] === 'dev') {
|
|
27
|
-
const extraFiles = await hooksRunner.watchFiles();
|
|
28
|
-
|
|
29
|
-
const configPath = _path.default.join(appDirectory, configDir);
|
|
30
|
-
|
|
31
|
-
const watched = [`${configPath}/html`, ...extraFiles, loaded === null || loaded === void 0 ? void 0 : loaded.filePath, ...loaded.dependencies].filter(Boolean);
|
|
32
|
-
debug(`watched: %o`, watched);
|
|
33
|
-
|
|
34
|
-
const watcher = _utils.chokidar.watch(watched, {
|
|
35
|
-
cwd: appDirectory,
|
|
36
|
-
ignoreInitial: true,
|
|
37
|
-
ignorePermissionErrors: true,
|
|
38
|
-
ignored: [/node_modules/, '**/__test__/**', '**/*.test.(js|jsx|ts|tsx)', '**/*.spec.(js|jsx|ts|tsx)', '**/*.stories.(js|jsx|ts|tsx)']
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
watcher.on('change', changed => {
|
|
42
|
-
const lastHash = hashMap.get(changed);
|
|
43
|
-
const currentHash = md5(_fs.default.readFileSync(_path.default.join(appDirectory, changed), 'utf8'));
|
|
44
|
-
|
|
45
|
-
if (currentHash !== lastHash) {
|
|
46
|
-
debug(`file change: %s`, changed);
|
|
47
|
-
hashMap.set(changed, currentHash);
|
|
48
|
-
hooksRunner.fileChange({
|
|
49
|
-
filename: changed,
|
|
50
|
-
eventType: 'change'
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
watcher.on('add', name => {
|
|
55
|
-
debug(`add file: %s`, name);
|
|
56
|
-
const currentHash = md5(_fs.default.readFileSync(_path.default.join(appDirectory, name), 'utf8'));
|
|
57
|
-
hashMap.set(name, currentHash);
|
|
58
|
-
hooksRunner.fileChange({
|
|
59
|
-
filename: name,
|
|
60
|
-
eventType: 'add'
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
watcher.on('unlink', name => {
|
|
64
|
-
debug(`remove file: %s`, name);
|
|
65
|
-
|
|
66
|
-
if (hashMap.has(name)) {
|
|
67
|
-
hashMap.delete(name);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
hooksRunner.fileChange({
|
|
71
|
-
filename: name,
|
|
72
|
-
eventType: 'unlink'
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
watcher.on('error', err => {
|
|
76
|
-
throw err;
|
|
77
|
-
});
|
|
78
|
-
return watcher;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
exports.initWatcher = initWatcher;
|
package/dist/js/node/loadEnv.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.loadEnv = void 0;
|
|
7
|
-
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
13
|
-
|
|
14
|
-
var _dotenvExpand = _interopRequireDefault(require("dotenv-expand"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const loadEnv = (appDirectory, mode = process.env.NODE_ENV) => {
|
|
19
|
-
// Don't change the order of the filenames, since they are ordered by the priority.
|
|
20
|
-
// Files on the left have more priority than files on the right.
|
|
21
|
-
[`.env.${mode}.local`, '.env.local', `.env.${mode}`, '.env'].map(name => _path.default.resolve(appDirectory, name)).filter(filePath => _fs.default.existsSync(filePath) && !_fs.default.statSync(filePath).isDirectory()).forEach(filePath => {
|
|
22
|
-
const envConfig = _dotenv.default.config({
|
|
23
|
-
path: filePath
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
(0, _dotenvExpand.default)(envConfig);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.loadEnv = loadEnv;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAppPlugins = getAppPlugins;
|
|
7
|
-
exports.loadPlugins = void 0;
|
|
8
|
-
|
|
9
|
-
var _utils = require("@modern-js/utils");
|
|
10
|
-
|
|
11
|
-
var _manager = require("./manager");
|
|
12
|
-
|
|
13
|
-
const debug = (0, _utils.createDebugger)('load-plugins');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Try to resolve plugin entry file path.
|
|
17
|
-
* @param name - Plugin name.
|
|
18
|
-
* @param appDirectory - Application root directory.
|
|
19
|
-
* @returns Resolved file path.
|
|
20
|
-
*/
|
|
21
|
-
const tryResolve = (name, appDirectory) => {
|
|
22
|
-
let filePath = '';
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
filePath = require.resolve(name, {
|
|
26
|
-
paths: [appDirectory]
|
|
27
|
-
});
|
|
28
|
-
delete require.cache[filePath];
|
|
29
|
-
} catch (err) {
|
|
30
|
-
if (err.code === 'MODULE_NOT_FOUND') {
|
|
31
|
-
throw new Error(`Can not find plugin ${name}.`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return filePath;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
|
|
41
|
-
const allPlugins = internalPlugins || _utils.INTERNAL_PLUGINS;
|
|
42
|
-
const appPlugins = [...Object.keys(allPlugins).filter(name => {
|
|
43
|
-
const config = allPlugins[name];
|
|
44
|
-
|
|
45
|
-
if (config.forced === true) {
|
|
46
|
-
// 参考 packages/cli/core/src/cli.ts 文件
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (0, _utils.isDepExists)(appDirectory, name);
|
|
51
|
-
}).map(name => allPlugins[name]), ...oldPluginConfig];
|
|
52
|
-
return appPlugins;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const resolveCliPlugin = (p, appDirectory) => {
|
|
56
|
-
const pkg = typeof p === 'string' ? p : p[0];
|
|
57
|
-
const path = tryResolve(pkg, appDirectory);
|
|
58
|
-
const module = (0, _utils.compatRequire)(path);
|
|
59
|
-
|
|
60
|
-
if (typeof module === 'function') {
|
|
61
|
-
const pluginOptions = Array.isArray(p) ? p[1] : undefined;
|
|
62
|
-
const result = module(pluginOptions);
|
|
63
|
-
return (0, _manager.createPlugin)(result.setup, result);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return module;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const isOldPluginConfig = config => Array.isArray(config) && config.some(item => {
|
|
70
|
-
if (typeof item === 'string' || Array.isArray(item)) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return 'cli' in item || 'server' in item;
|
|
75
|
-
});
|
|
76
|
-
/**
|
|
77
|
-
* Load internal plugins which in @modern-js scope and user's custom plugins.
|
|
78
|
-
* @param appDirectory - Application root directory.
|
|
79
|
-
* @param userConfig - Resolved user config.
|
|
80
|
-
* @param options.internalPlugins - Internal plugins.
|
|
81
|
-
* @returns Plugin Objects has been required.
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const loadPlugins = (appDirectory, userConfig, options = {}) => {
|
|
86
|
-
const pluginConfig = userConfig.plugins;
|
|
87
|
-
const plugins = getAppPlugins(appDirectory, isOldPluginConfig(pluginConfig) ? pluginConfig : [], options.internalPlugins);
|
|
88
|
-
const loadedPlugins = plugins.map(plugin => {
|
|
89
|
-
const _plugin = typeof plugin === 'string' || Array.isArray(plugin) ? {
|
|
90
|
-
cli: plugin
|
|
91
|
-
} : plugin;
|
|
92
|
-
|
|
93
|
-
const {
|
|
94
|
-
cli,
|
|
95
|
-
server
|
|
96
|
-
} = _plugin;
|
|
97
|
-
const loadedPlugin = {};
|
|
98
|
-
|
|
99
|
-
if (cli) {
|
|
100
|
-
loadedPlugin.cli = resolveCliPlugin(cli, appDirectory);
|
|
101
|
-
} // server plugins don't support to accept params
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (server && typeof server === 'string') {
|
|
105
|
-
loadedPlugin.server = server;
|
|
106
|
-
loadedPlugin.serverPkg = server;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
debug(`resolve plugin %s: %s`, plugin, {
|
|
110
|
-
cli: loadedPlugin.cli,
|
|
111
|
-
server: loadedPlugin.server
|
|
112
|
-
});
|
|
113
|
-
return loadedPlugin;
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
if (!isOldPluginConfig(pluginConfig)) {
|
|
117
|
-
const cliPlugins = Array.isArray(pluginConfig) ? pluginConfig : pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.cli;
|
|
118
|
-
|
|
119
|
-
if (cliPlugins !== null && cliPlugins !== void 0 && cliPlugins.length) {
|
|
120
|
-
loadedPlugins.push(...cliPlugins.map(item => ({
|
|
121
|
-
cli: (0, _manager.createPlugin)(item.setup, item)
|
|
122
|
-
})));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return loadedPlugins;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
exports.loadPlugins = loadPlugins;
|
package/dist/js/node/manager.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.usePlugins = exports.registerHook = exports.mountHook = exports.manager = exports.createPlugin = void 0;
|
|
7
|
-
|
|
8
|
-
var _plugin = require("@modern-js/plugin");
|
|
9
|
-
|
|
10
|
-
var _utils = require("@modern-js/utils");
|
|
11
|
-
|
|
12
|
-
var _pluginAPI = require("./pluginAPI");
|
|
13
|
-
|
|
14
|
-
const baseHooks = {
|
|
15
|
-
config: (0, _plugin.createParallelWorkflow)(),
|
|
16
|
-
resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
|
|
17
|
-
validateSchema: (0, _plugin.createParallelWorkflow)(),
|
|
18
|
-
prepare: (0, _plugin.createAsyncWorkflow)(),
|
|
19
|
-
commands: (0, _plugin.createAsyncWorkflow)(),
|
|
20
|
-
watchFiles: (0, _plugin.createParallelWorkflow)(),
|
|
21
|
-
fileChange: (0, _plugin.createAsyncWorkflow)(),
|
|
22
|
-
beforeExit: (0, _plugin.createAsyncWorkflow)(),
|
|
23
|
-
beforeRestart: (0, _plugin.createAsyncWorkflow)()
|
|
24
|
-
};
|
|
25
|
-
/** All hooks of cli plugin. */
|
|
26
|
-
|
|
27
|
-
const manager = (0, _plugin.createAsyncManager)(baseHooks, _pluginAPI.pluginAPI);
|
|
28
|
-
/** Plugin options of a cli plugin. */
|
|
29
|
-
|
|
30
|
-
exports.manager = manager;
|
|
31
|
-
const {
|
|
32
|
-
createPlugin,
|
|
33
|
-
registerHook,
|
|
34
|
-
useRunner: mountHook
|
|
35
|
-
} = manager;
|
|
36
|
-
exports.mountHook = mountHook;
|
|
37
|
-
exports.registerHook = registerHook;
|
|
38
|
-
exports.createPlugin = createPlugin;
|
|
39
|
-
|
|
40
|
-
const usePlugins = plugins => plugins.forEach(pluginPath => {
|
|
41
|
-
const module = (0, _utils.compatRequire)(require.resolve(pluginPath));
|
|
42
|
-
manager.usePlugin(module);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
exports.usePlugins = usePlugins;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "AppContext", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _context.AppContext;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ConfigContext", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _context.ConfigContext;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "ResolvedConfigContext", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _context.ResolvedConfigContext;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
exports.pluginAPI = void 0;
|
|
25
|
-
Object.defineProperty(exports, "useAppContext", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _context.useAppContext;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "useConfigContext", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _context.useConfigContext;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "useResolvedConfigContext", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return _context.useResolvedConfigContext;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
var _context = require("./context");
|
|
45
|
-
|
|
46
|
-
const pluginAPI = {
|
|
47
|
-
setAppContext: _context.setAppContext,
|
|
48
|
-
useAppContext: _context.useAppContext,
|
|
49
|
-
useConfigContext: _context.useConfigContext,
|
|
50
|
-
useResolvedConfigContext: _context.useResolvedConfigContext
|
|
51
|
-
};
|
|
52
|
-
/** all apis for cli plugin */
|
|
53
|
-
|
|
54
|
-
exports.pluginAPI = pluginAPI;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.initCommandsMap = initCommandsMap;
|
|
7
|
-
Object.defineProperty(exports, "program", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _utils.program;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
var _utils = require("@modern-js/utils");
|
|
15
|
-
|
|
16
|
-
function initCommandsMap() {
|
|
17
|
-
if (!_utils.program.hasOwnProperty('commandsMap')) {
|
|
18
|
-
Object.defineProperty(_utils.program, 'commandsMap', {
|
|
19
|
-
get() {
|
|
20
|
-
const map = new Map();
|
|
21
|
-
|
|
22
|
-
for (const command of _utils.program.commands) {
|
|
23
|
-
map.set(command._name, command);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return map;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
configurable: false
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|