@umijs/core 4.6.63 → 4.6.64
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/config/config.js +13 -13
- package/dist/service/command.js +7 -0
- package/dist/service/env.js +1 -2
- package/dist/service/hook.js +5 -0
- package/dist/service/plugin.js +16 -13
- package/dist/service/pluginAPI.js +4 -0
- package/dist/service/telemetry.js +10 -10
- package/package.json +3 -3
package/dist/config/config.js
CHANGED
|
@@ -42,20 +42,23 @@ var import_just_diff = require("../../compiled/just-diff");
|
|
|
42
42
|
var import_constants = require("../constants");
|
|
43
43
|
var import_types = require("../types");
|
|
44
44
|
var import_utils2 = require("./utils");
|
|
45
|
-
var Config = class {
|
|
45
|
+
var Config = class _Config {
|
|
46
|
+
opts;
|
|
47
|
+
mainConfigFile;
|
|
48
|
+
prevConfig;
|
|
49
|
+
files = [];
|
|
46
50
|
constructor(opts) {
|
|
47
|
-
this.files = [];
|
|
48
51
|
this.opts = opts;
|
|
49
|
-
this.mainConfigFile =
|
|
52
|
+
this.mainConfigFile = _Config.getMainConfigFile(this.opts);
|
|
50
53
|
this.prevConfig = null;
|
|
51
54
|
}
|
|
52
55
|
getUserConfig() {
|
|
53
|
-
const configFiles =
|
|
56
|
+
const configFiles = _Config.getConfigFiles({
|
|
54
57
|
mainConfigFile: this.mainConfigFile,
|
|
55
58
|
env: this.opts.env,
|
|
56
59
|
specifiedEnv: this.opts.specifiedEnv
|
|
57
60
|
});
|
|
58
|
-
return
|
|
61
|
+
return _Config.getUserConfig({
|
|
59
62
|
configFiles: (0, import_utils2.getAbsFiles)({
|
|
60
63
|
files: configFiles,
|
|
61
64
|
cwd: this.opts.cwd
|
|
@@ -64,7 +67,7 @@ var Config = class {
|
|
|
64
67
|
}
|
|
65
68
|
getConfig(opts) {
|
|
66
69
|
const { config, files } = this.getUserConfig();
|
|
67
|
-
|
|
70
|
+
_Config.validateConfig({ config, schemas: opts.schemas });
|
|
68
71
|
this.files = files;
|
|
69
72
|
return this.prevConfig = {
|
|
70
73
|
config,
|
|
@@ -93,7 +96,7 @@ var Config = class {
|
|
|
93
96
|
schemas: opts.schemas
|
|
94
97
|
});
|
|
95
98
|
watcher.add(files);
|
|
96
|
-
const data =
|
|
99
|
+
const data = _Config.diffConfigs({
|
|
97
100
|
origin,
|
|
98
101
|
updated,
|
|
99
102
|
onChangeTypes: opts.onChangeTypes
|
|
@@ -181,21 +184,18 @@ var Config = class {
|
|
|
181
184
|
const configKeys = new Set(Object.keys(opts.config));
|
|
182
185
|
for (const key of Object.keys(opts.schemas)) {
|
|
183
186
|
configKeys.delete(key);
|
|
184
|
-
if (!opts.config[key])
|
|
185
|
-
continue;
|
|
187
|
+
if (!opts.config[key]) continue;
|
|
186
188
|
const schema = opts.schemas[key]({ ...import_joi.default, zod: import_utils.zod });
|
|
187
189
|
if (import_joi.default.isSchema(schema)) {
|
|
188
190
|
const { error } = schema.validate(opts.config[key]);
|
|
189
|
-
if (error)
|
|
190
|
-
errors.set(key, error);
|
|
191
|
+
if (error) errors.set(key, error);
|
|
191
192
|
} else {
|
|
192
193
|
(0, import_assert.default)(
|
|
193
194
|
(0, import_utils.isZodSchema)(schema),
|
|
194
195
|
`schema for config ${key} is not valid, neither joi nor zod.`
|
|
195
196
|
);
|
|
196
197
|
const { error } = schema.safeParse(opts.config[key]);
|
|
197
|
-
if (error)
|
|
198
|
-
errors.set(key, error);
|
|
198
|
+
if (error) errors.set(key, error);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
(0, import_assert.default)(
|
package/dist/service/command.js
CHANGED
|
@@ -23,6 +23,13 @@ __export(command_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(command_exports);
|
|
25
25
|
var Command = class {
|
|
26
|
+
name;
|
|
27
|
+
description;
|
|
28
|
+
options;
|
|
29
|
+
details;
|
|
30
|
+
configResolveMode;
|
|
31
|
+
fn;
|
|
32
|
+
plugin;
|
|
26
33
|
constructor(opts) {
|
|
27
34
|
this.name = opts.name;
|
|
28
35
|
this.description = opts.description;
|
package/dist/service/env.js
CHANGED
|
@@ -32,8 +32,7 @@ function loadEnv(opts) {
|
|
|
32
32
|
(0, import_path.join)(opts.cwd, `${opts.envFile}.local`)
|
|
33
33
|
];
|
|
34
34
|
for (const file of files) {
|
|
35
|
-
if (!(0, import_fs.existsSync)(file))
|
|
36
|
-
continue;
|
|
35
|
+
if (!(0, import_fs.existsSync)(file)) continue;
|
|
37
36
|
const parsed = (0, import_dotenv.parse)((0, import_fs.readFileSync)(file)) || {};
|
|
38
37
|
(0, import_dotenv_expand.expand)({ parsed, ignoreProcessEnv: true });
|
|
39
38
|
for (const key of Object.keys(parsed)) {
|
package/dist/service/hook.js
CHANGED
|
@@ -34,6 +34,11 @@ __export(hook_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(hook_exports);
|
|
35
35
|
var import_assert = __toESM(require("assert"));
|
|
36
36
|
var Hook = class {
|
|
37
|
+
plugin;
|
|
38
|
+
key;
|
|
39
|
+
fn;
|
|
40
|
+
before;
|
|
41
|
+
stage;
|
|
37
42
|
constructor(opts) {
|
|
38
43
|
(0, import_assert.default)(
|
|
39
44
|
opts.key && opts.fn,
|
package/dist/service/plugin.js
CHANGED
|
@@ -42,11 +42,17 @@ var RE = {
|
|
|
42
42
|
plugin: /^(@umijs\/|umi-)plugin-/,
|
|
43
43
|
preset: /^(@umijs\/|umi-)preset-/
|
|
44
44
|
};
|
|
45
|
-
var Plugin = class {
|
|
45
|
+
var Plugin = class _Plugin {
|
|
46
|
+
cwd;
|
|
47
|
+
type;
|
|
48
|
+
path;
|
|
49
|
+
id;
|
|
50
|
+
key;
|
|
51
|
+
apply;
|
|
52
|
+
config = {};
|
|
53
|
+
time = { hooks: {} };
|
|
54
|
+
enableBy = import_types.EnableBy.register;
|
|
46
55
|
constructor(opts) {
|
|
47
|
-
this.config = {};
|
|
48
|
-
this.time = { hooks: {} };
|
|
49
|
-
this.enableBy = import_types.EnableBy.register;
|
|
50
56
|
this.type = opts.type;
|
|
51
57
|
this.path = (0, import_utils.winPath)(opts.path);
|
|
52
58
|
this.cwd = opts.cwd;
|
|
@@ -84,12 +90,9 @@ var Plugin = class {
|
|
|
84
90
|
};
|
|
85
91
|
}
|
|
86
92
|
merge(opts) {
|
|
87
|
-
if (opts.key)
|
|
88
|
-
|
|
89
|
-
if (opts.
|
|
90
|
-
this.config = opts.config;
|
|
91
|
-
if (opts.enableBy)
|
|
92
|
-
this.enableBy = opts.enableBy;
|
|
93
|
+
if (opts.key) this.key = opts.key;
|
|
94
|
+
if (opts.config) this.config = opts.config;
|
|
95
|
+
if (opts.enableBy) this.enableBy = opts.enableBy;
|
|
93
96
|
}
|
|
94
97
|
getId(opts) {
|
|
95
98
|
let id;
|
|
@@ -113,11 +116,11 @@ var Plugin = class {
|
|
|
113
116
|
return name.split(".").map((part) => import_utils.lodash.camelCase(part)).join(".");
|
|
114
117
|
}
|
|
115
118
|
return nameToKey(
|
|
116
|
-
opts.isPkgEntry ?
|
|
119
|
+
opts.isPkgEntry ? _Plugin.stripNoneUmiScope(opts.pkg.name).replace(RE[this.type], "") : (0, import_path.basename)(this.path, (0, import_path.extname)(this.path))
|
|
117
120
|
);
|
|
118
121
|
}
|
|
119
122
|
static isPluginOrPreset(type, name) {
|
|
120
|
-
return RE[type].test(
|
|
123
|
+
return RE[type].test(_Plugin.stripNoneUmiScope(name));
|
|
121
124
|
}
|
|
122
125
|
static stripNoneUmiScope(name) {
|
|
123
126
|
if (name.charAt(0) === "@" && !name.startsWith("@umijs/")) {
|
|
@@ -155,7 +158,7 @@ var Plugin = class {
|
|
|
155
158
|
cause: _e
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
|
-
return new
|
|
161
|
+
return new _Plugin({
|
|
159
162
|
path: resolved,
|
|
160
163
|
type,
|
|
161
164
|
cwd: opts.cwd
|
|
@@ -42,6 +42,10 @@ var import_plugin = require("./plugin");
|
|
|
42
42
|
var import_utils2 = require("./utils");
|
|
43
43
|
var resolveConfigModes = ["strict", "loose"];
|
|
44
44
|
var PluginAPI = class {
|
|
45
|
+
service;
|
|
46
|
+
plugin;
|
|
47
|
+
logger;
|
|
48
|
+
telemetry;
|
|
45
49
|
constructor(opts) {
|
|
46
50
|
this.service = opts.service;
|
|
47
51
|
this.plugin = opts.plugin;
|
|
@@ -24,17 +24,9 @@ __export(telemetry_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(telemetry_exports);
|
|
26
26
|
var Telemetry = class {
|
|
27
|
+
queuedEvents = [];
|
|
28
|
+
storage = new NoopStorage();
|
|
27
29
|
constructor() {
|
|
28
|
-
this.queuedEvents = [];
|
|
29
|
-
this.storage = new NoopStorage();
|
|
30
|
-
this.afterFlush = () => {
|
|
31
|
-
const un = this.unFinishedEvents();
|
|
32
|
-
if (un.length) {
|
|
33
|
-
this.scheduleFlush();
|
|
34
|
-
} else {
|
|
35
|
-
this.queuedEvents = [];
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
30
|
}
|
|
39
31
|
prefixWith(prefix) {
|
|
40
32
|
const upStream = this;
|
|
@@ -99,6 +91,14 @@ var Telemetry = class {
|
|
|
99
91
|
this.flush().then(this.afterFlush, this.afterFlush);
|
|
100
92
|
}, 5e3);
|
|
101
93
|
}
|
|
94
|
+
afterFlush = () => {
|
|
95
|
+
const un = this.unFinishedEvents();
|
|
96
|
+
if (un.length) {
|
|
97
|
+
this.scheduleFlush();
|
|
98
|
+
} else {
|
|
99
|
+
this.queuedEvents = [];
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
102
|
unFinishedEvents() {
|
|
103
103
|
return this.queuedEvents.filter((e) => {
|
|
104
104
|
if (e.status === "sent") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.64",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
6
|
"repository": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"compiled"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@umijs/bundler-utils": "4.6.
|
|
19
|
-
"@umijs/utils": "4.6.
|
|
18
|
+
"@umijs/bundler-utils": "4.6.64",
|
|
19
|
+
"@umijs/utils": "4.6.64"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"dotenv": "16.0.0",
|