@umijs/core 4.0.41 → 4.0.43
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){var e={
|
|
1
|
+
(function(){var e={696:function(e){e.exports={diff:diff,jsonPatchPathConverter:jsonPatchPathConverter};function diff(e,r,t){if(!e||typeof e!="object"||!r||typeof r!="object"){throw new Error("both arguments must be objects or arrays")}t||(t=function(e){return e});function getDiff(e,r,a,n){var o=Object.keys(e);var c=o.length;var i=Object.keys(r);var f=i.length;var u;for(var p=0;p<c;p++){var s=Array.isArray(e)?Number(o[p]):o[p];if(!(s in r)){u=a.concat(s);n.remove.push({op:"remove",path:t(u)})}}for(var p=0;p<f;p++){var s=Array.isArray(r)?Number(i[p]):i[p];var v=e[s];var _=r[s];if(!(s in e)){u=a.concat(s);var h=r[s];n.add.push({op:"add",path:t(u),value:h})}else if(v!==_){if(Object(v)!==v||Object(_)!==_){u=pushReplace(u,a,s,n,t,r)}else{if(!Object.keys(v).length&&!Object.keys(_).length&&String(v)!=String(_)){u=pushReplace(u,a,s,n,t,r)}else{getDiff(e[s],r[s],a.concat(s),n)}}}}return n}const a=getDiff(e,r,[],{remove:[],replace:[],add:[]});return a.remove.reverse().concat(a.replace).concat(a.add)}function pushReplace(e,r,t,a,n,o){e=r.concat(t);a.replace.push({op:"replace",path:n(e),value:o[t]});return e}function jsonPatchPathConverter(e){return[""].concat(e).join("/")}}};var r={};function __nccwpck_require__(t){var a=r[t];if(a!==undefined){return a.exports}var n=r[t]={exports:{}};var o=true;try{e[t](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete r[t]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(696);module.exports=t})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"just-diff","author":"Angus Croll","license":"MIT","types":"index.d.ts"}
|
|
1
|
+
{"name":"just-diff","version":"5.2.0","author":"Angus Croll","license":"MIT","types":"index.d.ts"}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Env } from '../types';
|
|
1
|
+
import { Env, type IOnChangeTypes } from '../types';
|
|
2
2
|
interface IOpts {
|
|
3
3
|
cwd: string;
|
|
4
4
|
env: Env;
|
|
@@ -6,7 +6,6 @@ interface IOpts {
|
|
|
6
6
|
defaultConfigFiles?: string[];
|
|
7
7
|
}
|
|
8
8
|
declare type ISchema = Record<string, any>;
|
|
9
|
-
declare type IOnChangeTypes = Record<string, string | Function>;
|
|
10
9
|
export declare class Config {
|
|
11
10
|
opts: IOpts;
|
|
12
11
|
mainConfigFile: string | null;
|
package/dist/config/config.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/config/config.ts
|
|
@@ -65,35 +68,41 @@ var Config = class {
|
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
watch(opts) {
|
|
68
|
-
const watcher = import_utils.chokidar.watch(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const watcher = import_utils.chokidar.watch(
|
|
72
|
+
[
|
|
73
|
+
...this.files,
|
|
74
|
+
...this.mainConfigFile ? [] : (0, import_utils2.getAbsFiles)({
|
|
75
|
+
files: this.opts.defaultConfigFiles || import_constants.DEFAULT_CONFIG_FILES,
|
|
76
|
+
cwd: this.opts.cwd
|
|
77
|
+
})
|
|
78
|
+
],
|
|
79
|
+
{
|
|
80
|
+
ignoreInitial: true,
|
|
72
81
|
cwd: this.opts.cwd
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
watcher.on(
|
|
85
|
+
"all",
|
|
86
|
+
import_utils.lodash.debounce((event, path) => {
|
|
87
|
+
const { config: origin } = this.prevConfig;
|
|
88
|
+
const { config: updated, files } = this.getConfig({
|
|
89
|
+
schemas: opts.schemas
|
|
90
|
+
});
|
|
91
|
+
watcher.add(files);
|
|
92
|
+
const data = Config.diffConfigs({
|
|
93
|
+
origin,
|
|
94
|
+
updated,
|
|
95
|
+
onChangeTypes: opts.onChangeTypes
|
|
96
|
+
});
|
|
97
|
+
opts.onChange({
|
|
98
|
+
data,
|
|
99
|
+
event,
|
|
100
|
+
path
|
|
101
|
+
}).catch((e) => {
|
|
102
|
+
throw e;
|
|
103
|
+
});
|
|
104
|
+
}, import_constants.WATCH_DEBOUNCE_STEP)
|
|
105
|
+
);
|
|
97
106
|
return () => watcher.close();
|
|
98
107
|
}
|
|
99
108
|
static getMainConfigFile(opts) {
|
|
@@ -113,15 +122,17 @@ var Config = class {
|
|
|
113
122
|
const specifiedEnv = opts.specifiedEnv || "";
|
|
114
123
|
if (mainConfigFile) {
|
|
115
124
|
const env = import_constants.SHORT_ENV[opts.env] || opts.env;
|
|
116
|
-
ret.push(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
ret.push(
|
|
126
|
+
...[
|
|
127
|
+
mainConfigFile,
|
|
128
|
+
specifiedEnv && (0, import_utils2.addExt)({ file: mainConfigFile, ext: `.${specifiedEnv}` }),
|
|
129
|
+
(0, import_utils2.addExt)({ file: mainConfigFile, ext: `.${env}` }),
|
|
130
|
+
specifiedEnv && (0, import_utils2.addExt)({
|
|
131
|
+
file: mainConfigFile,
|
|
132
|
+
ext: `.${env}.${specifiedEnv}`
|
|
133
|
+
})
|
|
134
|
+
].filter(Boolean)
|
|
135
|
+
);
|
|
125
136
|
if (opts.env === import_types.Env.development) {
|
|
126
137
|
ret.push((0, import_utils2.addExt)({ file: mainConfigFile, ext: import_constants.LOCAL_EXT }));
|
|
127
138
|
}
|
|
@@ -174,12 +185,18 @@ var Config = class {
|
|
|
174
185
|
if (error)
|
|
175
186
|
errors.set(key, error);
|
|
176
187
|
}
|
|
177
|
-
(0, import_assert.default)(
|
|
188
|
+
(0, import_assert.default)(
|
|
189
|
+
errors.size === 0,
|
|
190
|
+
`Invalid config values: ${Array.from(errors.keys()).join(", ")}
|
|
178
191
|
${Array.from(errors.keys()).map((key) => {
|
|
179
|
-
|
|
192
|
+
return `Invalid value for ${key}:
|
|
180
193
|
${errors.get(key).message}`;
|
|
181
|
-
|
|
182
|
-
|
|
194
|
+
})}`
|
|
195
|
+
);
|
|
196
|
+
(0, import_assert.default)(
|
|
197
|
+
configKeys.size === 0,
|
|
198
|
+
`Invalid config keys: ${Array.from(configKeys).join(", ")}`
|
|
199
|
+
);
|
|
183
200
|
}
|
|
184
201
|
static diffConfigs(opts) {
|
|
185
202
|
const patch = (0, import_just_diff.diff)(opts.origin, opts.updated);
|
package/dist/service/plugin.js
CHANGED
|
@@ -63,7 +63,7 @@ var Plugin = class {
|
|
|
63
63
|
try {
|
|
64
64
|
ret = require(this.path);
|
|
65
65
|
} catch (e) {
|
|
66
|
-
throw new Error(`Register ${this.type} ${this.path} failed, since ${e.message}
|
|
66
|
+
throw new Error(`Register ${this.type} ${this.path} failed, since ${e.message}`, { cause: e });
|
|
67
67
|
} finally {
|
|
68
68
|
import_utils.register.restore();
|
|
69
69
|
}
|
|
@@ -124,7 +124,9 @@ var Plugin = class {
|
|
|
124
124
|
extensions: [".tsx", ".ts", ".mjs", ".jsx", ".js"]
|
|
125
125
|
});
|
|
126
126
|
} catch (_e) {
|
|
127
|
-
throw new Error(`Invalid plugin ${path}, can not be resolved
|
|
127
|
+
throw new Error(`Invalid plugin ${path}, can not be resolved.`, {
|
|
128
|
+
cause: _e
|
|
129
|
+
});
|
|
128
130
|
}
|
|
129
131
|
return new Plugin({
|
|
130
132
|
path: resolved,
|
package/dist/types.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export declare enum ConfigChangeType {
|
|
|
30
30
|
reload = "reload",
|
|
31
31
|
regenerateTmpFiles = "regenerateTmpFiles"
|
|
32
32
|
}
|
|
33
|
+
export declare type ChangeTypeValue = string | `${ConfigChangeType}` | Function;
|
|
34
|
+
export declare type IOnChangeTypes = Record<string, ChangeTypeValue>;
|
|
33
35
|
export declare enum ApplyPluginsType {
|
|
34
36
|
add = "add",
|
|
35
37
|
modify = "modify",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.43",
|
|
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": {
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"test": "umi-scripts jest-turbo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-utils": "4.0.
|
|
25
|
-
"@umijs/utils": "4.0.
|
|
24
|
+
"@umijs/bundler-utils": "4.0.43",
|
|
25
|
+
"@umijs/utils": "4.0.43"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"dotenv": "16.0.0",
|
|
29
29
|
"dotenv-expand": "8.0.3",
|
|
30
|
-
"just-diff": "5.0
|
|
30
|
+
"just-diff": "5.2.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|