umi 4.3.21 → 4.3.23
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/cli/cli.d.ts +5 -0
- package/dist/cli/cli.js +70 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/dev.js +52 -0
- package/dist/cli/fork.d.ts +6 -0
- package/dist/cli/fork.js +90 -0
- package/dist/cli/forkedDev.d.ts +1 -0
- package/dist/cli/forkedDev.js +36 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +46 -0
- package/dist/defineConfig.d.ts +10 -0
- package/dist/defineConfig.js +31 -0
- package/dist/defineMock.d.ts +8 -0
- package/dist/defineMock.js +31 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +41 -0
- package/dist/pluginUtils.d.ts +5 -0
- package/dist/pluginUtils.js +48 -0
- package/dist/service/cwd.d.ts +1 -0
- package/dist/service/cwd.js +37 -0
- package/dist/service/requireHook.d.ts +1 -0
- package/dist/service/requireHook.js +14 -0
- package/dist/service/service.d.ts +8 -0
- package/dist/service/service.js +71 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +3 -0
- package/dist/test.d.ts +119 -0
- package/dist/test.js +82 -0
- package/package.json +10 -10
package/dist/cli/cli.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/cli/cli.ts
|
|
20
|
+
var cli_exports = {};
|
|
21
|
+
__export(cli_exports, {
|
|
22
|
+
run: () => run
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cli_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var import_constants = require("../constants");
|
|
27
|
+
var import_service = require("../service/service");
|
|
28
|
+
var import_dev = require("./dev");
|
|
29
|
+
(0, import_utils.catchUnhandledRejection)();
|
|
30
|
+
async function run(opts) {
|
|
31
|
+
(0, import_utils.checkVersion)(import_constants.MIN_NODE_VERSION);
|
|
32
|
+
(0, import_utils.checkLocal)();
|
|
33
|
+
(0, import_utils.setNodeTitle)(import_constants.FRAMEWORK_NAME);
|
|
34
|
+
(0, import_utils.setNoDeprecation)();
|
|
35
|
+
const args = (0, import_utils.yParser)(process.argv.slice(2), {
|
|
36
|
+
alias: {
|
|
37
|
+
version: ["v"],
|
|
38
|
+
help: ["h"]
|
|
39
|
+
},
|
|
40
|
+
boolean: ["version"]
|
|
41
|
+
});
|
|
42
|
+
const command = args._[0];
|
|
43
|
+
const FEATURE_COMMANDS = ["mfsu", "setup", "deadcode"];
|
|
44
|
+
if ([import_constants.DEV_COMMAND, ...FEATURE_COMMANDS].includes(command)) {
|
|
45
|
+
process.env.NODE_ENV = "development";
|
|
46
|
+
} else if (command === "build") {
|
|
47
|
+
process.env.NODE_ENV = "production";
|
|
48
|
+
}
|
|
49
|
+
if (opts == null ? void 0 : opts.presets) {
|
|
50
|
+
process.env[`${import_constants.FRAMEWORK_NAME}_PRESETS`.toUpperCase()] = opts.presets.join(",");
|
|
51
|
+
}
|
|
52
|
+
if (command === import_constants.DEV_COMMAND) {
|
|
53
|
+
(0, import_dev.dev)();
|
|
54
|
+
} else {
|
|
55
|
+
try {
|
|
56
|
+
await new import_service.Service().run2({
|
|
57
|
+
name: args._[0],
|
|
58
|
+
args
|
|
59
|
+
});
|
|
60
|
+
} catch (e) {
|
|
61
|
+
import_utils.logger.fatal(e);
|
|
62
|
+
import_utils.printHelp.exit();
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
run
|
|
70
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dev(): void;
|
package/dist/cli/dev.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/cli/dev.ts
|
|
30
|
+
var dev_exports = {};
|
|
31
|
+
__export(dev_exports, {
|
|
32
|
+
dev: () => dev
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(dev_exports);
|
|
35
|
+
var import_fork = __toESM(require("./fork"));
|
|
36
|
+
function dev() {
|
|
37
|
+
const child = (0, import_fork.default)({
|
|
38
|
+
scriptPath: require.resolve("../../bin/forkedDev")
|
|
39
|
+
});
|
|
40
|
+
process.on("SIGINT", () => {
|
|
41
|
+
child.kill("SIGINT");
|
|
42
|
+
process.exit(0);
|
|
43
|
+
});
|
|
44
|
+
process.on("SIGTERM", () => {
|
|
45
|
+
child.kill("SIGTERM");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
dev
|
|
52
|
+
});
|
package/dist/cli/fork.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/cli/fork.ts
|
|
20
|
+
var fork_exports = {};
|
|
21
|
+
__export(fork_exports, {
|
|
22
|
+
default: () => start
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(fork_exports);
|
|
25
|
+
var import_child_process = require("child_process");
|
|
26
|
+
var import_utils = require("@umijs/utils");
|
|
27
|
+
var usedPorts = [];
|
|
28
|
+
function start({ scriptPath }) {
|
|
29
|
+
const execArgv = process.execArgv.slice(0);
|
|
30
|
+
const inspectArgvIndex = execArgv.findIndex(
|
|
31
|
+
(argv) => argv.includes("--inspect-brk")
|
|
32
|
+
);
|
|
33
|
+
if (inspectArgvIndex > -1) {
|
|
34
|
+
const inspectArgv = execArgv[inspectArgvIndex];
|
|
35
|
+
execArgv.splice(
|
|
36
|
+
inspectArgvIndex,
|
|
37
|
+
1,
|
|
38
|
+
inspectArgv.replace(/--inspect-brk=(.*)/, (_match, s1) => {
|
|
39
|
+
let port;
|
|
40
|
+
try {
|
|
41
|
+
port = parseInt(s1) + 1;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
port = 9230;
|
|
44
|
+
}
|
|
45
|
+
if (usedPorts.includes(port)) {
|
|
46
|
+
port += 1;
|
|
47
|
+
}
|
|
48
|
+
usedPorts.push(port);
|
|
49
|
+
return `--inspect-brk=${port}`;
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const child = (0, import_child_process.fork)(scriptPath, process.argv.slice(2), { execArgv });
|
|
54
|
+
child.on("message", (data) => {
|
|
55
|
+
var _a;
|
|
56
|
+
const { type, payload } = data || {};
|
|
57
|
+
if (type === "RESTART") {
|
|
58
|
+
child.kill();
|
|
59
|
+
if (payload == null ? void 0 : payload.port) {
|
|
60
|
+
utilPortValid(payload.port, 20, () => {
|
|
61
|
+
process.env.PORT = payload.port;
|
|
62
|
+
start({ scriptPath });
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
start({ scriptPath });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
(_a = process.send) == null ? void 0 : _a.call(process, data);
|
|
69
|
+
});
|
|
70
|
+
return child;
|
|
71
|
+
}
|
|
72
|
+
function utilPortValid(port, totalTry, callback) {
|
|
73
|
+
import_utils.portfinder.getPort({ startPort: port }, (err, findPort) => {
|
|
74
|
+
if (err)
|
|
75
|
+
callback(err);
|
|
76
|
+
else {
|
|
77
|
+
if (findPort === port) {
|
|
78
|
+
callback();
|
|
79
|
+
} else {
|
|
80
|
+
if (totalTry > 0) {
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
utilPortValid(port, totalTry - 1, callback);
|
|
83
|
+
}, 100);
|
|
84
|
+
} else {
|
|
85
|
+
callback(new Error(`Port ${port} is occupied`));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/cli/forkedDev.ts
|
|
2
|
+
var import_utils = require("@umijs/utils");
|
|
3
|
+
var import_constants = require("../constants");
|
|
4
|
+
var import_service = require("../service/service");
|
|
5
|
+
(0, import_utils.setNodeTitle)(`${import_constants.FRAMEWORK_NAME}-dev`);
|
|
6
|
+
(0, import_utils.setNoDeprecation)();
|
|
7
|
+
(async () => {
|
|
8
|
+
try {
|
|
9
|
+
let onSignal = function(signal) {
|
|
10
|
+
if (closed)
|
|
11
|
+
return;
|
|
12
|
+
closed = true;
|
|
13
|
+
service.applyPlugins({
|
|
14
|
+
key: "onExit",
|
|
15
|
+
args: {
|
|
16
|
+
signal
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
process.exit(0);
|
|
20
|
+
};
|
|
21
|
+
const args = (0, import_utils.yParser)(process.argv.slice(2));
|
|
22
|
+
const service = new import_service.Service();
|
|
23
|
+
await service.run2({
|
|
24
|
+
name: import_constants.DEV_COMMAND,
|
|
25
|
+
args
|
|
26
|
+
});
|
|
27
|
+
let closed = false;
|
|
28
|
+
process.once("SIGINT", () => onSignal("SIGINT"));
|
|
29
|
+
process.once("SIGQUIT", () => onSignal("SIGQUIT"));
|
|
30
|
+
process.once("SIGTERM", () => onSignal("SIGTERM"));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
import_utils.logger.fatal(e);
|
|
33
|
+
import_utils.printHelp.exit();
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/constants.ts
|
|
20
|
+
var constants_exports = {};
|
|
21
|
+
__export(constants_exports, {
|
|
22
|
+
DEFAULT_CONFIG_FILES: () => DEFAULT_CONFIG_FILES,
|
|
23
|
+
DEV_COMMAND: () => DEV_COMMAND,
|
|
24
|
+
FRAMEWORK_NAME: () => FRAMEWORK_NAME,
|
|
25
|
+
MIN_NODE_VERSION: () => MIN_NODE_VERSION,
|
|
26
|
+
RUNTIME_TYPE_FILE_NAME: () => RUNTIME_TYPE_FILE_NAME
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
var MIN_NODE_VERSION = 14;
|
|
30
|
+
var DEV_COMMAND = "dev";
|
|
31
|
+
var FRAMEWORK_NAME = process.env.FRAMEWORK_NAME || "umi";
|
|
32
|
+
var DEFAULT_CONFIG_FILES = [
|
|
33
|
+
`.${FRAMEWORK_NAME}rc.ts`,
|
|
34
|
+
`.${FRAMEWORK_NAME}rc.js`,
|
|
35
|
+
"config/config.ts",
|
|
36
|
+
"config/config.js"
|
|
37
|
+
];
|
|
38
|
+
var RUNTIME_TYPE_FILE_NAME = "runtimeConfig.d.ts";
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
DEFAULT_CONFIG_FILES,
|
|
42
|
+
DEV_COMMAND,
|
|
43
|
+
FRAMEWORK_NAME,
|
|
44
|
+
MIN_NODE_VERSION,
|
|
45
|
+
RUNTIME_TYPE_FILE_NAME
|
|
46
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IConfigFromPlugins } from '@@/core/pluginConfig';
|
|
2
|
+
import type { IConfig } from '@umijs/preset-umi';
|
|
3
|
+
declare type ConfigType = IConfigFromPlugins & IConfig;
|
|
4
|
+
/**
|
|
5
|
+
* 通过方法的方式配置umi,能带来更好的 typescript 体验
|
|
6
|
+
* @param {ConfigType} config
|
|
7
|
+
* @returns ConfigType
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineConfig(config: ConfigType): ConfigType;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/defineConfig.ts
|
|
20
|
+
var defineConfig_exports = {};
|
|
21
|
+
__export(defineConfig_exports, {
|
|
22
|
+
defineConfig: () => defineConfig
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(defineConfig_exports);
|
|
25
|
+
function defineConfig(config) {
|
|
26
|
+
return config;
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
defineConfig
|
|
31
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RequestHandler } from '@umijs/bundler-webpack/compiled/express';
|
|
2
|
+
declare type MockDeclare = string | number | null | undefined | boolean | Record<string, any> | RequestHandler;
|
|
3
|
+
export declare function defineMock(mockData: {
|
|
4
|
+
[key: string]: MockDeclare;
|
|
5
|
+
}): {
|
|
6
|
+
[key: string]: MockDeclare;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/defineMock.ts
|
|
20
|
+
var defineMock_exports = {};
|
|
21
|
+
__export(defineMock_exports, {
|
|
22
|
+
defineMock: () => defineMock
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(defineMock_exports);
|
|
25
|
+
function defineMock(mockData) {
|
|
26
|
+
return mockData;
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
defineMock
|
|
31
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IServicePluginAPI, PluginAPI } from '@umijs/core';
|
|
2
|
+
export { run } from './cli/cli';
|
|
3
|
+
export { RUNTIME_TYPE_FILE_NAME } from './constants';
|
|
4
|
+
export { defineConfig } from './defineConfig';
|
|
5
|
+
export { defineMock } from './defineMock';
|
|
6
|
+
export * from './service/service';
|
|
7
|
+
export declare type IApi = PluginAPI & IServicePluginAPI;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
RUNTIME_TYPE_FILE_NAME: () => import_constants.RUNTIME_TYPE_FILE_NAME,
|
|
24
|
+
defineConfig: () => import_defineConfig.defineConfig,
|
|
25
|
+
defineMock: () => import_defineMock.defineMock,
|
|
26
|
+
run: () => import_cli.run
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(src_exports);
|
|
29
|
+
var import_cli = require("./cli/cli");
|
|
30
|
+
var import_constants = require("./constants");
|
|
31
|
+
var import_defineConfig = require("./defineConfig");
|
|
32
|
+
var import_defineMock = require("./defineMock");
|
|
33
|
+
__reExport(src_exports, require("./service/service"), module.exports);
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
RUNTIME_TYPE_FILE_NAME,
|
|
37
|
+
defineConfig,
|
|
38
|
+
defineMock,
|
|
39
|
+
run,
|
|
40
|
+
...require("./service/service")
|
|
41
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import express from '@umijs/bundler-utils/compiled/express';
|
|
2
|
+
import * as httpProxyMiddleware from '@umijs/bundler-utils/compiled/http-proxy-middleware';
|
|
3
|
+
export { createServerRoutes } from '@umijs/server';
|
|
4
|
+
export * from '@umijs/utils';
|
|
5
|
+
export { httpProxyMiddleware, express };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/pluginUtils.ts
|
|
31
|
+
var pluginUtils_exports = {};
|
|
32
|
+
__export(pluginUtils_exports, {
|
|
33
|
+
createServerRoutes: () => import_server.createServerRoutes,
|
|
34
|
+
express: () => import_express.default,
|
|
35
|
+
httpProxyMiddleware: () => httpProxyMiddleware
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(pluginUtils_exports);
|
|
38
|
+
var import_express = __toESM(require("@umijs/bundler-utils/compiled/express"));
|
|
39
|
+
var httpProxyMiddleware = __toESM(require("@umijs/bundler-utils/compiled/http-proxy-middleware"));
|
|
40
|
+
var import_server = require("@umijs/server");
|
|
41
|
+
__reExport(pluginUtils_exports, require("@umijs/utils"), module.exports);
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
createServerRoutes,
|
|
45
|
+
express,
|
|
46
|
+
httpProxyMiddleware,
|
|
47
|
+
...require("@umijs/utils")
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCwd(): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/service/cwd.ts
|
|
20
|
+
var cwd_exports = {};
|
|
21
|
+
__export(cwd_exports, {
|
|
22
|
+
getCwd: () => getCwd
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cwd_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
function getCwd() {
|
|
27
|
+
const cwd = process.cwd();
|
|
28
|
+
const appRoot = process.env.APP_ROOT;
|
|
29
|
+
if (appRoot) {
|
|
30
|
+
return (0, import_path.isAbsolute)(appRoot) ? appRoot : (0, import_path.join)(cwd, appRoot);
|
|
31
|
+
}
|
|
32
|
+
return cwd;
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
getCwd
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/service/requireHook.ts
|
|
2
|
+
var import_path = require("path");
|
|
3
|
+
var hookPropertyMap = /* @__PURE__ */ new Map([
|
|
4
|
+
["umi", (0, import_path.join)(__dirname, "../index.js")],
|
|
5
|
+
["umi/plugin-utils", (0, import_path.join)(__dirname, "../../plugin-utils.js")]
|
|
6
|
+
]);
|
|
7
|
+
var mod = require("module");
|
|
8
|
+
var resolveFilename = mod._resolveFilename;
|
|
9
|
+
mod._resolveFilename = function(request, parent, isMain, options) {
|
|
10
|
+
const hookResolved = hookPropertyMap.get(request);
|
|
11
|
+
if (hookResolved)
|
|
12
|
+
request = hookResolved;
|
|
13
|
+
return resolveFilename.call(mod, request, parent, isMain, options);
|
|
14
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/service/service.ts
|
|
30
|
+
var service_exports = {};
|
|
31
|
+
__export(service_exports, {
|
|
32
|
+
Service: () => Service
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(service_exports);
|
|
35
|
+
var import_core = require("@umijs/core");
|
|
36
|
+
var import_fs = require("fs");
|
|
37
|
+
var import_path = require("path");
|
|
38
|
+
var import_constants = require("../constants");
|
|
39
|
+
var import_cwd = require("./cwd");
|
|
40
|
+
var Service = class extends import_core.Service {
|
|
41
|
+
constructor(opts) {
|
|
42
|
+
process.env.UMI_DIR = (0, import_path.dirname)(require.resolve("../../package"));
|
|
43
|
+
const cwd = (0, import_cwd.getCwd)();
|
|
44
|
+
require("./requireHook");
|
|
45
|
+
super({
|
|
46
|
+
...opts,
|
|
47
|
+
env: process.env.NODE_ENV,
|
|
48
|
+
cwd,
|
|
49
|
+
defaultConfigFiles: (opts == null ? void 0 : opts.defaultConfigFiles) || import_constants.DEFAULT_CONFIG_FILES,
|
|
50
|
+
frameworkName: (opts == null ? void 0 : opts.frameworkName) || import_constants.FRAMEWORK_NAME,
|
|
51
|
+
presets: [require.resolve("@umijs/preset-umi"), ...(opts == null ? void 0 : opts.presets) || []],
|
|
52
|
+
plugins: [
|
|
53
|
+
(0, import_fs.existsSync)((0, import_path.join)(cwd, "plugin.ts")) && (0, import_path.join)(cwd, "plugin.ts"),
|
|
54
|
+
(0, import_fs.existsSync)((0, import_path.join)(cwd, "plugin.js")) && (0, import_path.join)(cwd, "plugin.js")
|
|
55
|
+
].filter(Boolean)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async run2(opts) {
|
|
59
|
+
let name = opts.name;
|
|
60
|
+
if ((opts == null ? void 0 : opts.args.version) || name === "v") {
|
|
61
|
+
name = "version";
|
|
62
|
+
} else if ((opts == null ? void 0 : opts.args.help) || !name || name === "h") {
|
|
63
|
+
name = "help";
|
|
64
|
+
}
|
|
65
|
+
return await this.run({ ...opts, name });
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
Service
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Config } from '@umijs/test';
|
|
2
|
+
export * from '@umijs/test';
|
|
3
|
+
export declare function getAliasPathWithKey(alias: Record<string, string>, key: string): string;
|
|
4
|
+
export declare function getUmiAlias(): Promise<any>;
|
|
5
|
+
export declare function configUmiAlias(config: Config.InitialOptions): Promise<Partial<{
|
|
6
|
+
automock: boolean;
|
|
7
|
+
bail: number | boolean;
|
|
8
|
+
cache: boolean;
|
|
9
|
+
cacheDirectory: string;
|
|
10
|
+
ci: boolean;
|
|
11
|
+
clearMocks: boolean;
|
|
12
|
+
changedFilesWithAncestor: boolean;
|
|
13
|
+
changedSince: string;
|
|
14
|
+
collectCoverage: boolean;
|
|
15
|
+
collectCoverageFrom: string[];
|
|
16
|
+
collectCoverageOnlyFrom: {
|
|
17
|
+
[key: string]: boolean;
|
|
18
|
+
};
|
|
19
|
+
coverageDirectory: string;
|
|
20
|
+
coveragePathIgnorePatterns: string[];
|
|
21
|
+
coverageProvider: "babel" | "v8";
|
|
22
|
+
coverageReporters: Config.CoverageReporters;
|
|
23
|
+
coverageThreshold: {
|
|
24
|
+
[path: string]: Config.CoverageThresholdValue;
|
|
25
|
+
global: Config.CoverageThresholdValue;
|
|
26
|
+
};
|
|
27
|
+
dependencyExtractor: string;
|
|
28
|
+
detectLeaks: boolean;
|
|
29
|
+
detectOpenHandles: boolean;
|
|
30
|
+
displayName: string | Config.DisplayName;
|
|
31
|
+
expand: boolean;
|
|
32
|
+
extensionsToTreatAsEsm: string[];
|
|
33
|
+
extraGlobals: string[];
|
|
34
|
+
filter: string;
|
|
35
|
+
findRelatedTests: boolean;
|
|
36
|
+
forceCoverageMatch: string[];
|
|
37
|
+
forceExit: boolean;
|
|
38
|
+
json: boolean;
|
|
39
|
+
globals: Config.ConfigGlobals;
|
|
40
|
+
globalSetup: string | null | undefined;
|
|
41
|
+
globalTeardown: string | null | undefined;
|
|
42
|
+
haste: Config.HasteConfig;
|
|
43
|
+
injectGlobals: boolean;
|
|
44
|
+
reporters: (string | Config.ReporterConfig)[];
|
|
45
|
+
logHeapUsage: boolean;
|
|
46
|
+
lastCommit: boolean;
|
|
47
|
+
listTests: boolean;
|
|
48
|
+
maxConcurrency: number;
|
|
49
|
+
maxWorkers: string | number;
|
|
50
|
+
moduleDirectories: string[];
|
|
51
|
+
moduleFileExtensions: string[];
|
|
52
|
+
moduleLoader: string;
|
|
53
|
+
moduleNameMapper: {
|
|
54
|
+
[key: string]: string | string[];
|
|
55
|
+
};
|
|
56
|
+
modulePathIgnorePatterns: string[];
|
|
57
|
+
modulePaths: string[];
|
|
58
|
+
name: string;
|
|
59
|
+
noStackTrace: boolean;
|
|
60
|
+
notify: boolean;
|
|
61
|
+
notifyMode: string;
|
|
62
|
+
onlyChanged: boolean;
|
|
63
|
+
onlyFailures: boolean;
|
|
64
|
+
outputFile: string;
|
|
65
|
+
passWithNoTests: boolean;
|
|
66
|
+
preprocessorIgnorePatterns: string[];
|
|
67
|
+
preset: string | null | undefined;
|
|
68
|
+
prettierPath: string | null | undefined;
|
|
69
|
+
projects: (string | Config.InitialProjectOptions)[];
|
|
70
|
+
replname: string | null | undefined;
|
|
71
|
+
resetMocks: boolean;
|
|
72
|
+
resetModules: boolean;
|
|
73
|
+
resolver: string | null | undefined;
|
|
74
|
+
restoreMocks: boolean;
|
|
75
|
+
rootDir: string;
|
|
76
|
+
roots: string[];
|
|
77
|
+
runner: string;
|
|
78
|
+
runTestsByPath: boolean;
|
|
79
|
+
scriptPreprocessor: string;
|
|
80
|
+
setupFiles: string[];
|
|
81
|
+
setupTestFrameworkScriptFile: string;
|
|
82
|
+
setupFilesAfterEnv: string[];
|
|
83
|
+
silent: boolean;
|
|
84
|
+
skipFilter: boolean;
|
|
85
|
+
skipNodeResolution: boolean;
|
|
86
|
+
slowTestThreshold: number;
|
|
87
|
+
snapshotResolver: string;
|
|
88
|
+
snapshotSerializers: string[];
|
|
89
|
+
snapshotFormat: Config.PrettyFormatOptions;
|
|
90
|
+
errorOnDeprecated: boolean;
|
|
91
|
+
testEnvironment: string;
|
|
92
|
+
testEnvironmentOptions: Record<string, unknown>;
|
|
93
|
+
testFailureExitCode: string | number;
|
|
94
|
+
testLocationInResults: boolean;
|
|
95
|
+
testMatch: string[];
|
|
96
|
+
testNamePattern: string;
|
|
97
|
+
testPathDirs: string[];
|
|
98
|
+
testPathIgnorePatterns: string[];
|
|
99
|
+
testRegex: string | string[];
|
|
100
|
+
testResultsProcessor: string;
|
|
101
|
+
testRunner: string;
|
|
102
|
+
testSequencer: string;
|
|
103
|
+
testURL: string;
|
|
104
|
+
testTimeout: number;
|
|
105
|
+
timers: "real" | "fake" | "modern" | "legacy";
|
|
106
|
+
transform: {
|
|
107
|
+
[regex: string]: string | Config.TransformerConfig;
|
|
108
|
+
};
|
|
109
|
+
transformIgnorePatterns: string[];
|
|
110
|
+
watchPathIgnorePatterns: string[];
|
|
111
|
+
unmockedModulePathPatterns: string[];
|
|
112
|
+
updateSnapshot: boolean;
|
|
113
|
+
useStderr: boolean;
|
|
114
|
+
verbose?: boolean | undefined;
|
|
115
|
+
watch: boolean;
|
|
116
|
+
watchAll: boolean;
|
|
117
|
+
watchman: boolean;
|
|
118
|
+
watchPlugins: (string | [string, Record<string, unknown>])[];
|
|
119
|
+
}>>;
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/test.ts
|
|
21
|
+
var test_exports = {};
|
|
22
|
+
__export(test_exports, {
|
|
23
|
+
configUmiAlias: () => configUmiAlias,
|
|
24
|
+
getAliasPathWithKey: () => getAliasPathWithKey,
|
|
25
|
+
getUmiAlias: () => getUmiAlias
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(test_exports);
|
|
28
|
+
var import_utils = require("@umijs/utils");
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_service = require("./service/service");
|
|
31
|
+
__reExport(test_exports, require("@umijs/test"), module.exports);
|
|
32
|
+
function getAliasPathWithKey(alias, key) {
|
|
33
|
+
if (alias[key]) {
|
|
34
|
+
return getAliasPathWithKey(alias, alias[key]);
|
|
35
|
+
}
|
|
36
|
+
const aliasKeys = Object.keys(alias);
|
|
37
|
+
const keyStartedWith = aliasKeys.find(
|
|
38
|
+
(k) => !k.endsWith("$") && key.startsWith(`${k}/`)
|
|
39
|
+
);
|
|
40
|
+
if (keyStartedWith) {
|
|
41
|
+
const realPath = alias[keyStartedWith];
|
|
42
|
+
const newKey = realPath + key.slice(keyStartedWith.length);
|
|
43
|
+
return getAliasPathWithKey(alias, newKey);
|
|
44
|
+
} else {
|
|
45
|
+
return key;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var service;
|
|
49
|
+
async function getUmiAlias() {
|
|
50
|
+
if (!service) {
|
|
51
|
+
service = new import_service.Service();
|
|
52
|
+
await service.run2({
|
|
53
|
+
name: "setup",
|
|
54
|
+
args: { quiet: true }
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return service.config.alias;
|
|
58
|
+
}
|
|
59
|
+
async function configUmiAlias(config) {
|
|
60
|
+
(0, import_utils.setNoDeprecation)();
|
|
61
|
+
config.moduleNameMapper || (config.moduleNameMapper = {});
|
|
62
|
+
const alias = await getUmiAlias();
|
|
63
|
+
for (const key of Object.keys(alias)) {
|
|
64
|
+
const aliasPath = getAliasPathWithKey(alias, key);
|
|
65
|
+
if (key.endsWith("$")) {
|
|
66
|
+
config.moduleNameMapper[`^${key}`] = aliasPath;
|
|
67
|
+
} else if ((0, import_fs.existsSync)(aliasPath) && (0, import_fs.statSync)(aliasPath).isDirectory()) {
|
|
68
|
+
config.moduleNameMapper[`^${key}/(.*)$`] = `${aliasPath}/$1`;
|
|
69
|
+
config.moduleNameMapper[`^${key}$`] = aliasPath;
|
|
70
|
+
} else {
|
|
71
|
+
config.moduleNameMapper[`^${key}$`] = aliasPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return config;
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
configUmiAlias,
|
|
79
|
+
getAliasPathWithKey,
|
|
80
|
+
getUmiAlias,
|
|
81
|
+
...require("@umijs/test")
|
|
82
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umi",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.23",
|
|
4
4
|
"description": "umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"@babel/runtime": "7.23.6",
|
|
35
35
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
36
36
|
"prettier-plugin-packagejson": "2.4.3",
|
|
37
|
-
"@umijs/
|
|
38
|
-
"@umijs/
|
|
39
|
-
"@umijs/
|
|
40
|
-
"@umijs/
|
|
41
|
-
"@umijs/
|
|
42
|
-
"@umijs/
|
|
43
|
-
"@umijs/server": "4.3.
|
|
44
|
-
"@umijs/utils": "4.3.
|
|
45
|
-
"@umijs/test": "4.3.
|
|
37
|
+
"@umijs/bundler-utils": "4.3.23",
|
|
38
|
+
"@umijs/lint": "4.3.23",
|
|
39
|
+
"@umijs/renderer-react": "4.3.23",
|
|
40
|
+
"@umijs/core": "4.3.23",
|
|
41
|
+
"@umijs/bundler-webpack": "4.3.23",
|
|
42
|
+
"@umijs/preset-umi": "4.3.23",
|
|
43
|
+
"@umijs/server": "4.3.23",
|
|
44
|
+
"@umijs/utils": "4.3.23",
|
|
45
|
+
"@umijs/test": "4.3.23"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=14"
|