@umijs/core 3.5.20 → 4.0.0-beta.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.
Files changed (84) hide show
  1. package/README.md +2 -0
  2. package/dist/config/config.d.ts +63 -0
  3. package/dist/config/config.js +178 -0
  4. package/dist/config/utils.d.ts +8 -0
  5. package/dist/config/utils.js +15 -0
  6. package/dist/constants.d.ts +9 -0
  7. package/dist/constants.js +12 -0
  8. package/dist/index.d.ts +5 -0
  9. package/dist/index.js +19 -0
  10. package/dist/route/defineRoutes.d.ts +1 -0
  11. package/dist/route/defineRoutes.js +28 -0
  12. package/dist/route/route.d.ts +2 -0
  13. package/dist/route/route.js +18 -0
  14. package/dist/route/routeUtils.d.ts +7 -0
  15. package/dist/route/routeUtils.js +21 -0
  16. package/dist/route/routesConfig.d.ts +0 -0
  17. package/dist/route/routesConfig.js +1 -0
  18. package/dist/route/routesConvention.d.ts +3 -0
  19. package/dist/route/routesConvention.js +73 -0
  20. package/dist/route/utils.d.ts +7 -0
  21. package/dist/route/utils.js +26 -0
  22. package/dist/service/command.d.ts +27 -0
  23. package/dist/service/command.js +14 -0
  24. package/dist/service/env.d.ts +4 -0
  25. package/dist/service/env.js +21 -0
  26. package/dist/service/hook.d.ts +16 -0
  27. package/dist/service/hook.js +18 -0
  28. package/dist/service/path.d.ts +13 -0
  29. package/dist/service/path.js +31 -0
  30. package/dist/service/plugin.d.ts +53 -0
  31. package/dist/service/plugin.js +137 -0
  32. package/dist/service/pluginAPI.d.ts +35 -0
  33. package/dist/service/pluginAPI.js +120 -0
  34. package/dist/service/service.d.ts +91 -0
  35. package/dist/service/service.js +361 -0
  36. package/dist/service/servicePlugin.d.ts +3 -0
  37. package/dist/service/servicePlugin.js +14 -0
  38. package/dist/service/utils.d.ts +2 -0
  39. package/dist/service/utils.js +12 -0
  40. package/dist/types.d.ts +108 -0
  41. package/dist/types.js +42 -0
  42. package/package.json +35 -15
  43. package/lib/Config/Config.d.ts +0 -39
  44. package/lib/Config/Config.js +0 -348
  45. package/lib/Config/types.d.ts +0 -21
  46. package/lib/Config/utils/configUtils.d.ts +0 -9
  47. package/lib/Config/utils/configUtils.js +0 -54
  48. package/lib/Config/utils/isEqual.d.ts +0 -1
  49. package/lib/Config/utils/isEqual.js +0 -45
  50. package/lib/Config/utils/mergeDefault.d.ts +0 -6
  51. package/lib/Config/utils/mergeDefault.js +0 -41
  52. package/lib/Html/Html.d.ts +0 -16
  53. package/lib/Html/Html.js +0 -292
  54. package/lib/Html/document.ejs +0 -12
  55. package/lib/Html/types.d.ts +0 -55
  56. package/lib/Logger/Common.d.ts +0 -13
  57. package/lib/Logger/Common.js +0 -53
  58. package/lib/Logger/Logger.d.ts +0 -17
  59. package/lib/Logger/Logger.js +0 -87
  60. package/lib/Route/Route.d.ts +0 -32
  61. package/lib/Route/Route.js +0 -228
  62. package/lib/Route/getConventionalRoutes.d.ts +0 -10
  63. package/lib/Route/getConventionalRoutes.js +0 -259
  64. package/lib/Route/routesToJSON.d.ts +0 -9
  65. package/lib/Route/routesToJSON.js +0 -140
  66. package/lib/Route/types.d.ts +0 -11
  67. package/lib/Service/PluginAPI.d.ts +0 -38
  68. package/lib/Service/PluginAPI.js +0 -193
  69. package/lib/Service/Service.d.ts +0 -96
  70. package/lib/Service/Service.js +0 -694
  71. package/lib/Service/enums.d.ts +0 -29
  72. package/lib/Service/enums.js +0 -67
  73. package/lib/Service/getPaths.d.ts +0 -6
  74. package/lib/Service/getPaths.js +0 -79
  75. package/lib/Service/types.d.ts +0 -52
  76. package/lib/Service/types.js +0 -17
  77. package/lib/Service/utils/isPromise.d.ts +0 -1
  78. package/lib/Service/utils/isPromise.js +0 -22
  79. package/lib/Service/utils/loadDotEnv.d.ts +0 -5
  80. package/lib/Service/utils/loadDotEnv.js +0 -54
  81. package/lib/Service/utils/pluginUtils.d.ts +0 -42
  82. package/lib/Service/utils/pluginUtils.js +0 -201
  83. package/lib/index.d.ts +0 -14
  84. package/lib/index.js +0 -81
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.Service = void 0;
35
+ const utils_1 = require("@umijs/utils");
36
+ const assert_1 = __importDefault(require("assert"));
37
+ const fs_1 = require("fs");
38
+ const path_1 = require("path");
39
+ const process = __importStar(require("process"));
40
+ const tapable_1 = require("../../compiled/tapable");
41
+ const config_1 = require("../config/config");
42
+ const constants_1 = require("../constants");
43
+ const types_1 = require("../types");
44
+ const env_1 = require("./env");
45
+ const path_2 = require("./path");
46
+ const plugin_1 = require("./plugin");
47
+ const pluginAPI_1 = require("./pluginAPI");
48
+ const utils_2 = require("./utils");
49
+ class Service {
50
+ constructor(opts) {
51
+ this.appData = {};
52
+ this.args = { _: [], $0: '' };
53
+ this.commands = {};
54
+ this.config = {};
55
+ this.configSchemas = {};
56
+ this.configDefaults = {};
57
+ this.configOnChanges = {};
58
+ this.hooks = {};
59
+ this.name = '';
60
+ this.paths = {};
61
+ // preset is plugin with different type
62
+ this.plugins = {};
63
+ this.pluginMethods = {};
64
+ this.skipPluginIds = new Set();
65
+ this.stage = types_1.ServiceStage.uninitialized;
66
+ this.userConfig = {};
67
+ this.configManager = null;
68
+ this.pkg = {};
69
+ this.cwd = opts.cwd;
70
+ this.env = opts.env;
71
+ this.opts = opts;
72
+ (0, assert_1.default)((0, fs_1.existsSync)(this.cwd), `Invalid cwd ${this.cwd}, it's not found.`);
73
+ }
74
+ applyPlugins(opts) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const hooks = this.hooks[opts.key] || [];
77
+ let type = opts.type;
78
+ // guess type from key
79
+ if (!type) {
80
+ if (opts.key.startsWith('on')) {
81
+ type = types_1.ApplyPluginsType.event;
82
+ }
83
+ else if (opts.key.startsWith('modify')) {
84
+ type = types_1.ApplyPluginsType.modify;
85
+ }
86
+ else if (opts.key.startsWith('add')) {
87
+ type = types_1.ApplyPluginsType.add;
88
+ }
89
+ else {
90
+ throw new Error(`Invalid applyPlugins arguments, type must be supplied for key ${opts.key}.`);
91
+ }
92
+ }
93
+ switch (type) {
94
+ case types_1.ApplyPluginsType.add:
95
+ (0, assert_1.default)(!('initialValue' in opts) || Array.isArray(opts.initialValue), `applyPlugins failed, opts.initialValue must be Array if opts.type is add.`);
96
+ const tAdd = new tapable_1.AsyncSeriesWaterfallHook(['memo']);
97
+ for (const hook of hooks) {
98
+ if (!this.isPluginEnable(hook))
99
+ continue;
100
+ tAdd.tapPromise({
101
+ name: hook.plugin.id,
102
+ stage: hook.stage,
103
+ before: hook.before,
104
+ }, (memo) => __awaiter(this, void 0, void 0, function* () {
105
+ const items = yield hook.fn(opts.args);
106
+ return memo.concat(items);
107
+ }));
108
+ }
109
+ return (yield tAdd.promise(opts.initialValue || []));
110
+ case types_1.ApplyPluginsType.modify:
111
+ const tModify = new tapable_1.AsyncSeriesWaterfallHook(['memo']);
112
+ for (const hook of hooks) {
113
+ if (!this.isPluginEnable(hook))
114
+ continue;
115
+ tModify.tapPromise({
116
+ name: hook.plugin.id,
117
+ stage: hook.stage,
118
+ before: hook.before,
119
+ }, (memo) => __awaiter(this, void 0, void 0, function* () {
120
+ return yield hook.fn(memo, opts.args);
121
+ }));
122
+ }
123
+ return (yield tModify.promise(opts.initialValue));
124
+ case types_1.ApplyPluginsType.event:
125
+ const tEvent = new tapable_1.AsyncSeriesWaterfallHook(['_']);
126
+ for (const hook of hooks) {
127
+ if (!this.isPluginEnable(hook))
128
+ continue;
129
+ tEvent.tapPromise({
130
+ name: hook.plugin.id,
131
+ stage: hook.stage || 0,
132
+ before: hook.before,
133
+ }, () => __awaiter(this, void 0, void 0, function* () {
134
+ yield hook.fn(opts.args);
135
+ }));
136
+ }
137
+ return (yield tEvent.promise(1));
138
+ default:
139
+ throw new Error(`applyPlugins failed, type is not defined or is not matched, got ${opts.type}.`);
140
+ }
141
+ });
142
+ }
143
+ run(opts) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const { name, args = {} } = opts;
146
+ args._ = args._ || [];
147
+ // shift the command itself
148
+ if (args._[0] === name)
149
+ args._.shift();
150
+ this.args = args;
151
+ this.name = name;
152
+ // loadEnv
153
+ this.stage = types_1.ServiceStage.init;
154
+ (0, env_1.loadEnv)({ cwd: this.cwd, envFile: '.env' });
155
+ // get pkg from package.json
156
+ let pkg = {};
157
+ try {
158
+ pkg = require((0, path_1.join)(this.cwd, 'package.json'));
159
+ }
160
+ catch (_e) {
161
+ // APP_ROOT
162
+ if (this.cwd !== process.cwd()) {
163
+ try {
164
+ pkg = require((0, path_1.join)(process.cwd(), 'package.json'));
165
+ }
166
+ catch (_e) { }
167
+ }
168
+ }
169
+ this.pkg = pkg;
170
+ // get user config
171
+ const configManager = new config_1.Config({
172
+ cwd: this.cwd,
173
+ env: this.env,
174
+ defaultConfigFiles: this.opts.defaultConfigFiles,
175
+ });
176
+ this.configManager = configManager;
177
+ this.userConfig = configManager.getUserConfig().config;
178
+ // get paths (move after?)
179
+ // resolve initial presets and plugins
180
+ const { plugins, presets } = plugin_1.Plugin.getPluginsAndPresets({
181
+ cwd: this.cwd,
182
+ pkg,
183
+ plugins: this.opts.plugins || [],
184
+ presets: [require.resolve('./servicePlugin')].concat(this.opts.presets || []),
185
+ userConfig: this.userConfig,
186
+ prefix: this.opts.frameworkName || constants_1.DEFAULT_FRAMEWORK_NAME,
187
+ });
188
+ // register presets and plugins
189
+ this.stage = types_1.ServiceStage.initPresets;
190
+ while (presets.length) {
191
+ yield this.initPreset({ preset: presets.shift(), presets, plugins });
192
+ }
193
+ this.stage = types_1.ServiceStage.initPlugins;
194
+ while (plugins.length) {
195
+ yield this.initPlugin({ plugin: plugins.shift(), plugins });
196
+ }
197
+ // collect configSchemas and configDefaults
198
+ for (const id of Object.keys(this.plugins)) {
199
+ const { config, key } = this.plugins[id];
200
+ if (config.schema)
201
+ this.configSchemas[key] = config.schema;
202
+ if (config.default !== undefined) {
203
+ this.configDefaults[key] = config.default;
204
+ }
205
+ this.configOnChanges[key] = config.onChange || types_1.ConfigChangeType.reload;
206
+ }
207
+ // setup api.config from modifyConfig and modifyDefaultConfig
208
+ this.stage = types_1.ServiceStage.resolveConfig;
209
+ const config = yield this.applyPlugins({
210
+ key: 'modifyConfig',
211
+ initialValue: configManager.getConfig({
212
+ schemas: this.configSchemas,
213
+ }).config,
214
+ });
215
+ const defaultConfig = yield this.applyPlugins({
216
+ key: 'modifyDefaultConfig',
217
+ initialValue: this.configDefaults,
218
+ });
219
+ this.config = utils_1.lodash.merge(defaultConfig, config);
220
+ const paths = (0, path_2.getPaths)({
221
+ cwd: this.cwd,
222
+ env: this.env,
223
+ prefix: this.opts.frameworkName || constants_1.DEFAULT_FRAMEWORK_NAME,
224
+ });
225
+ if (this.config.outputPath) {
226
+ paths.absOutputPath = (0, path_1.join)(this.cwd, this.config.outputPath);
227
+ }
228
+ this.paths = yield this.applyPlugins({
229
+ key: 'modifyPaths',
230
+ initialValue: paths,
231
+ });
232
+ // applyPlugin collect app data
233
+ // TODO: some data is mutable
234
+ this.stage = types_1.ServiceStage.collectAppData;
235
+ this.appData = yield this.applyPlugins({
236
+ key: 'modifyAppData',
237
+ initialValue: {
238
+ // base
239
+ cwd: this.cwd,
240
+ pkg,
241
+ plugins,
242
+ presets,
243
+ name,
244
+ args,
245
+ // config
246
+ userConfig: this.userConfig,
247
+ mainConfigFile: configManager.mainConfigFile,
248
+ config,
249
+ defaultConfig: defaultConfig,
250
+ // TODO
251
+ // moduleGraph,
252
+ // routes,
253
+ // npmClient,
254
+ // nodeVersion,
255
+ // gitInfo,
256
+ // gitBranch,
257
+ // debugger info,
258
+ // devPort,
259
+ // devHost,
260
+ // env
261
+ },
262
+ });
263
+ // applyPlugin onCheck
264
+ this.stage = types_1.ServiceStage.onCheck;
265
+ yield this.applyPlugins({
266
+ key: 'onCheck',
267
+ });
268
+ // applyPlugin onStart
269
+ this.stage = types_1.ServiceStage.onStart;
270
+ yield this.applyPlugins({
271
+ key: 'onStart',
272
+ });
273
+ // run command
274
+ this.stage = types_1.ServiceStage.runCommand;
275
+ const command = this.commands[name];
276
+ (0, assert_1.default)(command, `Invalid command ${name}, it's not registered.`);
277
+ return command.fn({ args });
278
+ });
279
+ }
280
+ initPreset(opts) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const { presets, plugins } = yield this.initPlugin({
283
+ plugin: opts.preset,
284
+ presets: opts.presets,
285
+ plugins: opts.plugins,
286
+ });
287
+ opts.presets.unshift(...(presets || []));
288
+ opts.plugins.unshift(...(plugins || []));
289
+ });
290
+ }
291
+ initPlugin(opts) {
292
+ var _a;
293
+ return __awaiter(this, void 0, void 0, function* () {
294
+ // register to this.plugins
295
+ (0, assert_1.default)(!this.plugins[opts.plugin.id], `${opts.plugin.type} ${opts.plugin.id} is already registered by ${(_a = this.plugins[opts.plugin.id]) === null || _a === void 0 ? void 0 : _a.path}, ${opts.plugin.type} from ${opts.plugin.path} register failed.`);
296
+ this.plugins[opts.plugin.id] = opts.plugin;
297
+ // apply with PluginAPI
298
+ const pluginAPI = new pluginAPI_1.PluginAPI({
299
+ plugin: opts.plugin,
300
+ service: this,
301
+ });
302
+ pluginAPI.registerPresets = pluginAPI.registerPresets.bind(pluginAPI, opts.presets || []);
303
+ pluginAPI.registerPlugins = pluginAPI.registerPlugins.bind(pluginAPI, opts.plugins);
304
+ const proxyPluginAPI = pluginAPI_1.PluginAPI.proxyPluginAPI({
305
+ service: this,
306
+ pluginAPI,
307
+ serviceProps: [
308
+ 'appData',
309
+ 'applyPlugins',
310
+ 'args',
311
+ 'config',
312
+ 'cwd',
313
+ 'pkg',
314
+ 'name',
315
+ 'paths',
316
+ 'userConfig',
317
+ ],
318
+ staticProps: {
319
+ ApplyPluginsType: types_1.ApplyPluginsType,
320
+ ConfigChangeType: types_1.ConfigChangeType,
321
+ EnableBy: types_1.EnableBy,
322
+ ServiceStage: types_1.ServiceStage,
323
+ service: this,
324
+ },
325
+ });
326
+ let ret = opts.plugin.apply()(proxyPluginAPI);
327
+ if ((0, utils_2.isPromise)(ret)) {
328
+ ret = yield ret;
329
+ }
330
+ if (ret === null || ret === void 0 ? void 0 : ret.presets) {
331
+ ret.presets = ret.presets.map((preset) => new plugin_1.Plugin({
332
+ path: preset,
333
+ type: types_1.PluginType.preset,
334
+ cwd: this.cwd,
335
+ }));
336
+ }
337
+ if (ret === null || ret === void 0 ? void 0 : ret.plugins) {
338
+ ret.plugins = ret.plugins.map((plugin) => new plugin_1.Plugin({
339
+ path: plugin,
340
+ type: types_1.PluginType.plugin,
341
+ cwd: this.cwd,
342
+ }));
343
+ }
344
+ return ret || {};
345
+ });
346
+ }
347
+ isPluginEnable(hook) {
348
+ const { id, key, enableBy } = hook.plugin;
349
+ if (this.skipPluginIds.has(id))
350
+ return false;
351
+ if (this.userConfig[key] === false)
352
+ return false;
353
+ if (enableBy === types_1.EnableBy.config && !(key in this.config))
354
+ return false;
355
+ if (typeof enableBy === 'function')
356
+ return enableBy();
357
+ // EnableBy.register
358
+ return true;
359
+ }
360
+ }
361
+ exports.Service = Service;
@@ -0,0 +1,3 @@
1
+ import { PluginAPI } from './pluginAPI';
2
+ declare const _default: (api: PluginAPI) => void;
3
+ export default _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (api) => {
4
+ [
5
+ 'onCheck',
6
+ 'onStart',
7
+ 'modifyAppData',
8
+ 'modifyConfig',
9
+ 'modifyDefaultConfig',
10
+ 'modifyPaths',
11
+ ].forEach((name) => {
12
+ api.registerMethod({ name });
13
+ });
14
+ };
@@ -0,0 +1,2 @@
1
+ export declare function isPromise(obj: any): boolean;
2
+ export declare function makeArray(item: any): any[];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeArray = exports.isPromise = void 0;
4
+ function isPromise(obj) {
5
+ return ((typeof obj === 'object' || typeof obj === 'function') &&
6
+ typeof obj.then === 'function');
7
+ }
8
+ exports.isPromise = isPromise;
9
+ function makeArray(item) {
10
+ return Array.isArray(item) ? item : [item];
11
+ }
12
+ exports.makeArray = makeArray;
@@ -0,0 +1,108 @@
1
+ import joi from '../compiled/@hapi/joi';
2
+ export declare enum Env {
3
+ development = "development",
4
+ production = "production",
5
+ test = "test"
6
+ }
7
+ export declare enum PluginType {
8
+ preset = "preset",
9
+ plugin = "plugin"
10
+ }
11
+ export interface IPluginConfig {
12
+ default?: any;
13
+ schema?: {
14
+ (joi: joi.Root): joi.Schema;
15
+ };
16
+ onChange?: string | Function;
17
+ }
18
+ export declare enum ServiceStage {
19
+ uninitialized = 0,
20
+ init = 1,
21
+ initPresets = 2,
22
+ initPlugins = 3,
23
+ resolveConfig = 4,
24
+ collectAppData = 5,
25
+ onCheck = 6,
26
+ onStart = 7,
27
+ runCommand = 8
28
+ }
29
+ export declare enum ConfigChangeType {
30
+ reload = "reload",
31
+ regenerateTmpFiles = "regenerateTmpFiles"
32
+ }
33
+ export declare enum ApplyPluginsType {
34
+ add = "add",
35
+ modify = "modify",
36
+ event = "event"
37
+ }
38
+ export declare enum EnableBy {
39
+ register = "register",
40
+ config = "config"
41
+ }
42
+ export interface IRoute {
43
+ path: string;
44
+ file: string;
45
+ id: string;
46
+ parentId?: string;
47
+ }
48
+ export interface IEvent<T> {
49
+ (fn: {
50
+ (args: T): void;
51
+ }): void;
52
+ (args: {
53
+ fn: {
54
+ (args: T): void;
55
+ };
56
+ name?: string;
57
+ before?: string | string[];
58
+ stage?: number;
59
+ }): void;
60
+ }
61
+ export interface IModify<T, U> {
62
+ (fn: {
63
+ (initialValue: T, args: U): T;
64
+ }): void;
65
+ (fn: {
66
+ (initialValue: T, args: U): Promise<T>;
67
+ }): void;
68
+ (args: {
69
+ fn: {
70
+ (initialValue: T, args: U): T;
71
+ };
72
+ name?: string;
73
+ before?: string | string[];
74
+ stage?: number;
75
+ }): void;
76
+ (args: {
77
+ fn: {
78
+ (initialValue: T, args: U): Promise<T>;
79
+ };
80
+ name?: string;
81
+ before?: string | string[];
82
+ stage?: number;
83
+ }): void;
84
+ }
85
+ export interface IAdd<T, U> {
86
+ (fn: {
87
+ (args: T): U | U[];
88
+ }): void;
89
+ (fn: {
90
+ (args: T): Promise<U | U[]>;
91
+ }): void;
92
+ (args: {
93
+ fn: {
94
+ (args: T): U | U[];
95
+ };
96
+ name?: string;
97
+ before?: string | string[];
98
+ stage?: number;
99
+ }): void;
100
+ (args: {
101
+ fn: {
102
+ (args: T): Promise<U | U[]>;
103
+ name?: string;
104
+ before?: string | string[];
105
+ stage?: number;
106
+ };
107
+ }): void;
108
+ }
package/dist/types.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnableBy = exports.ApplyPluginsType = exports.ConfigChangeType = exports.ServiceStage = exports.PluginType = exports.Env = void 0;
4
+ var Env;
5
+ (function (Env) {
6
+ Env["development"] = "development";
7
+ Env["production"] = "production";
8
+ Env["test"] = "test";
9
+ })(Env = exports.Env || (exports.Env = {}));
10
+ var PluginType;
11
+ (function (PluginType) {
12
+ PluginType["preset"] = "preset";
13
+ PluginType["plugin"] = "plugin";
14
+ })(PluginType = exports.PluginType || (exports.PluginType = {}));
15
+ var ServiceStage;
16
+ (function (ServiceStage) {
17
+ ServiceStage[ServiceStage["uninitialized"] = 0] = "uninitialized";
18
+ ServiceStage[ServiceStage["init"] = 1] = "init";
19
+ ServiceStage[ServiceStage["initPresets"] = 2] = "initPresets";
20
+ ServiceStage[ServiceStage["initPlugins"] = 3] = "initPlugins";
21
+ ServiceStage[ServiceStage["resolveConfig"] = 4] = "resolveConfig";
22
+ ServiceStage[ServiceStage["collectAppData"] = 5] = "collectAppData";
23
+ ServiceStage[ServiceStage["onCheck"] = 6] = "onCheck";
24
+ ServiceStage[ServiceStage["onStart"] = 7] = "onStart";
25
+ ServiceStage[ServiceStage["runCommand"] = 8] = "runCommand";
26
+ })(ServiceStage = exports.ServiceStage || (exports.ServiceStage = {}));
27
+ var ConfigChangeType;
28
+ (function (ConfigChangeType) {
29
+ ConfigChangeType["reload"] = "reload";
30
+ ConfigChangeType["regenerateTmpFiles"] = "regenerateTmpFiles";
31
+ })(ConfigChangeType = exports.ConfigChangeType || (exports.ConfigChangeType = {}));
32
+ var ApplyPluginsType;
33
+ (function (ApplyPluginsType) {
34
+ ApplyPluginsType["add"] = "add";
35
+ ApplyPluginsType["modify"] = "modify";
36
+ ApplyPluginsType["event"] = "event";
37
+ })(ApplyPluginsType = exports.ApplyPluginsType || (exports.ApplyPluginsType = {}));
38
+ var EnableBy;
39
+ (function (EnableBy) {
40
+ EnableBy["register"] = "register";
41
+ EnableBy["config"] = "config";
42
+ })(EnableBy = exports.EnableBy || (exports.EnableBy = {}));
package/package.json CHANGED
@@ -1,32 +1,52 @@
1
1
  {
2
2
  "name": "@umijs/core",
3
- "version": "3.5.20",
4
- "description": "@umijs/core",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
3
+ "version": "4.0.0-beta.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
7
6
  "files": [
8
- "lib"
7
+ "dist"
9
8
  ],
9
+ "scripts": {
10
+ "build": "pnpm tsc",
11
+ "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
12
+ "dev": "pnpm build -- --watch"
13
+ },
10
14
  "repository": {
11
15
  "type": "git",
12
- "url": "https://github.com/umijs/umi"
16
+ "url": "https://github.com/umijs/umi-next"
13
17
  },
14
- "keywords": [
15
- "umi"
16
- ],
17
18
  "authors": [
18
19
  "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
19
20
  ],
20
21
  "license": "MIT",
21
- "bugs": "http://github.com/umijs/umi/issues",
22
- "homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
22
+ "bugs": "https://github.com/umijs/umi-next/issues",
23
+ "homepage": "https://github.com/umijs/umi-next/tree/master/packages/core#readme",
23
24
  "publishConfig": {
24
25
  "access": "public"
25
26
  },
26
27
  "dependencies": {
27
- "@umijs/ast": "3.5.20",
28
- "@umijs/babel-preset-umi": "3.5.20",
29
- "@umijs/deps": "3.5.20",
30
- "@umijs/utils": "3.5.20"
28
+ "@umijs/bundler-utils": "4.0.0-beta.1",
29
+ "@umijs/utils": "4.0.0-beta.1"
30
+ },
31
+ "devDependencies": {
32
+ "@hapi/joi": "17.1.1",
33
+ "@types/hapi__joi": "17.1.7",
34
+ "dotenv": "10.0.0",
35
+ "just-diff": "3.1.1",
36
+ "tapable": "2.2.1"
37
+ },
38
+ "compiledConfig": {
39
+ "deps": [
40
+ "@hapi/joi",
41
+ "dotenv",
42
+ "just-diff",
43
+ "tapable"
44
+ ],
45
+ "externals": {
46
+ "@hapi/joi": "$$LOCAL",
47
+ "dotenv": "$$LOCAL",
48
+ "just-diff": "$$LOCAL",
49
+ "tapable": "$$LOCAL"
50
+ }
31
51
  }
32
52
  }
@@ -1,39 +0,0 @@
1
- import Service from '../Service/Service';
2
- interface IChanged {
3
- key: string;
4
- pluginId: string;
5
- }
6
- interface IOpts {
7
- cwd: string;
8
- service: Service;
9
- localConfig?: boolean;
10
- configFiles?: string[];
11
- }
12
- export default class Config {
13
- cwd: string;
14
- service: Service;
15
- config?: object;
16
- localConfig?: boolean;
17
- configFile?: string | null;
18
- configFiles: string[];
19
- constructor(opts: IOpts);
20
- getDefaultConfig(): Promise<{}>;
21
- getConfig({ defaultConfig }: {
22
- defaultConfig: object;
23
- }): {};
24
- getUserConfig(): {};
25
- addAffix(file: string, affix: string): string;
26
- requireConfigs(configFiles: string[]): any[];
27
- mergeConfig(...configs: object[]): {};
28
- getConfigFile(): string | null;
29
- getWatchFilesAndDirectories(): string[];
30
- watch(opts: {
31
- userConfig: object;
32
- onChange: (args: {
33
- userConfig: any;
34
- pluginChanged: IChanged[];
35
- valueChanged: IChanged[];
36
- }) => void;
37
- }): () => void;
38
- }
39
- export {};