umi 4.0.0-canary.20220428.1 → 4.0.0-canary.20220429.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umi",
3
- "version": "4.0.0-canary.20220428.1",
3
+ "version": "4.0.0-canary.20220429.2",
4
4
  "description": "umi",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/umi#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -37,14 +37,15 @@
37
37
  "test": "umi-scripts jest-turbo"
38
38
  },
39
39
  "dependencies": {
40
- "@umijs/bundler-utils": "4.0.0-canary.20220428.1",
41
- "@umijs/bundler-webpack": "4.0.0-canary.20220428.1",
42
- "@umijs/core": "4.0.0-canary.20220428.1",
43
- "@umijs/lint": "4.0.0-canary.20220428.1",
44
- "@umijs/preset-umi": "4.0.0-canary.20220428.1",
45
- "@umijs/renderer-react": "4.0.0-canary.20220428.1",
46
- "@umijs/test": "4.0.0-canary.20220428.1",
47
- "@umijs/utils": "4.0.0-canary.20220428.1",
40
+ "@umijs/bundler-utils": "4.0.0-canary.20220429.2",
41
+ "@umijs/bundler-webpack": "4.0.0-canary.20220429.2",
42
+ "@umijs/core": "4.0.0-canary.20220429.2",
43
+ "@umijs/lint": "4.0.0-canary.20220429.2",
44
+ "@umijs/preset-umi": "4.0.0-canary.20220429.2",
45
+ "@umijs/renderer-react": "4.0.0-canary.20220429.2",
46
+ "@umijs/server": "4.0.0-canary.20220429.2",
47
+ "@umijs/test": "4.0.0-canary.20220429.2",
48
+ "@umijs/utils": "4.0.0-canary.20220429.2",
48
49
  "prettier-plugin-organize-imports": "^2.3.4",
49
50
  "prettier-plugin-packagejson": "^2.2.17"
50
51
  },
package/dist/cli/cli.d.ts DELETED
@@ -1,5 +0,0 @@
1
- interface IOpts {
2
- presets?: string[];
3
- }
4
- export declare function run(opts?: IOpts): Promise<void>;
5
- export {};
package/dist/cli/cli.js DELETED
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.run = void 0;
13
- const utils_1 = require("@umijs/utils");
14
- const constants_1 = require("../constants");
15
- const service_1 = require("../service/service");
16
- const dev_1 = require("./dev");
17
- const node_1 = require("./node");
18
- function run(opts) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- (0, node_1.checkVersion)();
21
- (0, node_1.checkLocal)();
22
- (0, node_1.setNodeTitle)();
23
- (0, node_1.setNoDeprecation)();
24
- const args = (0, utils_1.yParser)(process.argv.slice(2), {
25
- alias: {
26
- version: ['v'],
27
- help: ['h'],
28
- },
29
- boolean: ['version'],
30
- });
31
- const command = args._[0];
32
- if ([constants_1.DEV_COMMAND, 'setup'].includes(command)) {
33
- process.env.NODE_ENV = 'development';
34
- }
35
- else if (command === 'build') {
36
- process.env.NODE_ENV = 'production';
37
- }
38
- if (opts === null || opts === void 0 ? void 0 : opts.presets) {
39
- process.env.UMI_PRESETS = opts.presets.join(',');
40
- }
41
- if (command === constants_1.DEV_COMMAND) {
42
- (0, dev_1.dev)();
43
- }
44
- else {
45
- try {
46
- yield new service_1.Service().run2({
47
- name: args._[0],
48
- args,
49
- });
50
- }
51
- catch (e) {
52
- utils_1.logger.error(e);
53
- process.exit(1);
54
- }
55
- }
56
- });
57
- }
58
- exports.run = run;
package/dist/cli/dev.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function dev(): void;
package/dist/cli/dev.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.dev = void 0;
7
- const fork_1 = __importDefault(require("./fork"));
8
- function dev() {
9
- const child = (0, fork_1.default)({
10
- scriptPath: require.resolve('../../bin/forkedDev'),
11
- });
12
- // ref:
13
- // http://nodejs.cn/api/process/signal_events.html
14
- // https://lisk.io/blog/development/why-we-stopped-using-npm-start-child-processes
15
- process.on('SIGINT', () => {
16
- child.kill('SIGINT');
17
- // ref:
18
- // https://github.com/umijs/umi/issues/6009
19
- process.exit(0);
20
- });
21
- process.on('SIGTERM', () => {
22
- child.kill('SIGTERM');
23
- process.exit(1);
24
- });
25
- }
26
- exports.dev = dev;
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- interface IOpts {
3
- scriptPath: string;
4
- }
5
- export default function start({ scriptPath }: IOpts): import("child_process").ChildProcess;
6
- export {};
package/dist/cli/fork.js DELETED
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- const usedPorts = [];
5
- function start({ scriptPath }) {
6
- const execArgv = process.execArgv.slice(0);
7
- const inspectArgvIndex = execArgv.findIndex((argv) => argv.includes('--inspect-brk'));
8
- if (inspectArgvIndex > -1) {
9
- const inspectArgv = execArgv[inspectArgvIndex];
10
- execArgv.splice(inspectArgvIndex, 1, inspectArgv.replace(/--inspect-brk=(.*)/, (_match, s1) => {
11
- let port;
12
- try {
13
- port = parseInt(s1) + 1;
14
- }
15
- catch (e) {
16
- port = 9230; // node default inspect port plus 1.
17
- }
18
- if (usedPorts.includes(port)) {
19
- port += 1;
20
- }
21
- usedPorts.push(port);
22
- return `--inspect-brk=${port}`;
23
- }));
24
- }
25
- const child = (0, child_process_1.fork)(scriptPath, process.argv.slice(2), { execArgv });
26
- child.on('message', (data) => {
27
- var _a;
28
- const { type, payload } = data || {};
29
- if (type === 'RESTART') {
30
- child.kill();
31
- if (payload === null || payload === void 0 ? void 0 : payload.port) {
32
- process.env.PORT = payload.port;
33
- }
34
- start({ scriptPath });
35
- }
36
- (_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, data);
37
- });
38
- return child;
39
- }
40
- exports.default = start;
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const utils_1 = require("@umijs/utils");
13
- const constants_1 = require("../constants");
14
- const service_1 = require("../service/service");
15
- const node_1 = require("./node");
16
- (0, node_1.setNodeTitle)(`${constants_1.FRAMEWORK_NAME}-dev`);
17
- (0, node_1.setNoDeprecation)();
18
- (() => __awaiter(void 0, void 0, void 0, function* () {
19
- try {
20
- const args = (0, utils_1.yParser)(process.argv.slice(2));
21
- const service = new service_1.Service();
22
- yield service.run2({
23
- name: constants_1.DEV_COMMAND,
24
- args,
25
- });
26
- let closed = false;
27
- // kill(2) Ctrl-C
28
- process.once('SIGINT', () => onSignal('SIGINT'));
29
- // kill(3) Ctrl-\
30
- process.once('SIGQUIT', () => onSignal('SIGQUIT'));
31
- // kill(15) default
32
- process.once('SIGTERM', () => onSignal('SIGTERM'));
33
- function onSignal(signal) {
34
- if (closed)
35
- return;
36
- closed = true;
37
- // 退出时触发插件中的 onExit 事件
38
- service.applyPlugins({
39
- key: 'onExit',
40
- args: {
41
- signal,
42
- },
43
- });
44
- process.exit(0);
45
- }
46
- }
47
- catch (e) {
48
- utils_1.logger.error(e);
49
- process.exit(1);
50
- }
51
- }))();
@@ -1,4 +0,0 @@
1
- export declare function checkVersion(): void;
2
- export declare function checkLocal(): void;
3
- export declare function setNodeTitle(name?: string): void;
4
- export declare function setNoDeprecation(): void;
package/dist/cli/node.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setNoDeprecation = exports.setNodeTitle = exports.checkLocal = exports.checkVersion = void 0;
4
- const utils_1 = require("@umijs/utils");
5
- const constants_1 = require("../constants");
6
- function checkVersion() {
7
- const v = parseInt(process.version.slice(1));
8
- if (v < constants_1.MIN_NODE_VERSION || v === 15 || v === 17) {
9
- utils_1.logger.error(`Your node version ${v} is not supported, please upgrade to ${constants_1.MIN_NODE_VERSION} or above except 15 or 17.`);
10
- process.exit(1);
11
- }
12
- }
13
- exports.checkVersion = checkVersion;
14
- function checkLocal() {
15
- if (__filename.includes(`packages/${constants_1.FRAMEWORK_NAME}`)) {
16
- utils_1.logger.info('@local');
17
- }
18
- }
19
- exports.checkLocal = checkLocal;
20
- function setNodeTitle(name) {
21
- if (process.title === 'node') {
22
- process.title = name || constants_1.FRAMEWORK_NAME;
23
- }
24
- }
25
- exports.setNodeTitle = setNodeTitle;
26
- function setNoDeprecation() {
27
- // Use magic to suppress node deprecation warnings
28
- // See: https://github.com/nodejs/node/blob/master/lib/internal/process/warning.js#L77
29
- // @ts-ignore
30
- process.noDeprecation = '1';
31
- }
32
- exports.setNoDeprecation = setNoDeprecation;
@@ -1,34 +0,0 @@
1
- export declare enum ApplyPluginsType {
2
- compose = "compose",
3
- modify = "modify",
4
- event = "event"
5
- }
6
- interface IPlugin {
7
- path?: string;
8
- apply: Record<string, any>;
9
- }
10
- export declare class PluginManager {
11
- opts: {
12
- validKeys: string[];
13
- };
14
- hooks: {
15
- [key: string]: any;
16
- };
17
- constructor(opts: {
18
- validKeys: string[];
19
- });
20
- register(plugin: IPlugin): void;
21
- getHooks(keyWithDot: string): any;
22
- applyPlugins({ key, type, initialValue, args, async, }: {
23
- key: string;
24
- type: ApplyPluginsType;
25
- initialValue?: any;
26
- args?: object;
27
- async?: boolean;
28
- }): any;
29
- static create(opts: {
30
- validKeys: string[];
31
- plugins: IPlugin[];
32
- }): PluginManager;
33
- }
34
- export {};
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PluginManager = exports.ApplyPluginsType = void 0;
13
- const utils_1 = require("./utils");
14
- var ApplyPluginsType;
15
- (function (ApplyPluginsType) {
16
- ApplyPluginsType["compose"] = "compose";
17
- ApplyPluginsType["modify"] = "modify";
18
- ApplyPluginsType["event"] = "event";
19
- })(ApplyPluginsType = exports.ApplyPluginsType || (exports.ApplyPluginsType = {}));
20
- class PluginManager {
21
- constructor(opts) {
22
- this.hooks = {};
23
- this.opts = opts;
24
- }
25
- register(plugin) {
26
- (0, utils_1.assert)(plugin.apply && plugin.path, `plugin register failed, apply and path must supplied`);
27
- Object.keys(plugin.apply).forEach((key) => {
28
- (0, utils_1.assert)(this.opts.validKeys.indexOf(key) > -1, `register failed, invalid key ${key} from plugin ${plugin.path}.`);
29
- this.hooks[key] = (this.hooks[key] || []).concat(plugin.apply[key]);
30
- });
31
- }
32
- getHooks(keyWithDot) {
33
- const [key, ...memberKeys] = keyWithDot.split('.');
34
- let hooks = this.hooks[key] || [];
35
- if (memberKeys.length) {
36
- hooks = hooks
37
- .map((hook) => {
38
- try {
39
- let ret = hook;
40
- for (const memberKey of memberKeys) {
41
- ret = ret[memberKey];
42
- }
43
- return ret;
44
- }
45
- catch (e) {
46
- return null;
47
- }
48
- })
49
- .filter(Boolean);
50
- }
51
- return hooks;
52
- }
53
- applyPlugins({ key, type, initialValue, args, async, }) {
54
- const hooks = this.getHooks(key) || [];
55
- if (args) {
56
- (0, utils_1.assert)(typeof args === 'object', `applyPlugins failed, args must be plain object.`);
57
- }
58
- if (async) {
59
- (0, utils_1.assert)(type === ApplyPluginsType.modify || type === ApplyPluginsType.event, `async only works with modify and event type.`);
60
- }
61
- switch (type) {
62
- case ApplyPluginsType.modify:
63
- if (async) {
64
- return hooks.reduce((memo, hook) => __awaiter(this, void 0, void 0, function* () {
65
- (0, utils_1.assert)(typeof hook === 'function' ||
66
- typeof hook === 'object' ||
67
- (0, utils_1.isPromiseLike)(hook), `applyPlugins failed, all hooks for key ${key} must be function, plain object or Promise.`);
68
- if ((0, utils_1.isPromiseLike)(memo)) {
69
- memo = yield memo;
70
- }
71
- if (typeof hook === 'function') {
72
- const ret = hook(memo, args);
73
- if ((0, utils_1.isPromiseLike)(ret)) {
74
- return yield ret;
75
- }
76
- else {
77
- return ret;
78
- }
79
- }
80
- else {
81
- if ((0, utils_1.isPromiseLike)(hook)) {
82
- hook = yield hook;
83
- }
84
- return Object.assign(Object.assign({}, memo), hook);
85
- }
86
- }), (0, utils_1.isPromiseLike)(initialValue)
87
- ? initialValue
88
- : Promise.resolve(initialValue));
89
- }
90
- else {
91
- return hooks.reduce((memo, hook) => {
92
- (0, utils_1.assert)(typeof hook === 'function' || typeof hook === 'object', `applyPlugins failed, all hooks for key ${key} must be function or plain object.`);
93
- if (typeof hook === 'function') {
94
- return hook(memo, args);
95
- }
96
- else {
97
- // TODO: deepmerge?
98
- return Object.assign(Object.assign({}, memo), hook);
99
- }
100
- }, initialValue);
101
- }
102
- case ApplyPluginsType.event:
103
- return (() => __awaiter(this, void 0, void 0, function* () {
104
- for (const hook of hooks) {
105
- (0, utils_1.assert)(typeof hook === 'function', `applyPlugins failed, all hooks for key ${key} must be function.`);
106
- const ret = hook(args);
107
- if (async && (0, utils_1.isPromiseLike)(ret)) {
108
- yield ret;
109
- }
110
- }
111
- }))();
112
- case ApplyPluginsType.compose:
113
- return () => {
114
- return (0, utils_1.compose)({
115
- fns: hooks.concat(initialValue),
116
- args,
117
- })();
118
- };
119
- }
120
- }
121
- static create(opts) {
122
- const pluginManager = new PluginManager({
123
- validKeys: opts.validKeys,
124
- });
125
- opts.plugins.forEach((plugin) => {
126
- pluginManager.register(plugin);
127
- });
128
- return pluginManager;
129
- }
130
- }
131
- exports.PluginManager = PluginManager;
132
- // plugins meta info (in tmp file)
133
- // hooks api: usePlugin
@@ -1,6 +0,0 @@
1
- export declare function assert(value: unknown, message: string): void;
2
- export declare function compose({ fns, args, }: {
3
- fns: (Function | any)[];
4
- args?: object;
5
- }): any;
6
- export declare function isPromiseLike(obj: any): boolean;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPromiseLike = exports.compose = exports.assert = void 0;
4
- function assert(value, message) {
5
- if (!value)
6
- throw new Error(message);
7
- }
8
- exports.assert = assert;
9
- function compose({ fns, args, }) {
10
- if (fns.length === 1) {
11
- return fns[0];
12
- }
13
- const last = fns.pop();
14
- return fns.reduce((a, b) => () => b(a, args), last);
15
- }
16
- exports.compose = compose;
17
- function isPromiseLike(obj) {
18
- return !!obj && typeof obj === 'object' && typeof obj.then === 'function';
19
- }
20
- exports.isPromiseLike = isPromiseLike;
@@ -1,4 +0,0 @@
1
- export declare const MIN_NODE_VERSION = 14;
2
- export declare const DEV_COMMAND = "dev";
3
- export declare const DEFAULT_CONFIG_FILES: string[];
4
- export declare const FRAMEWORK_NAME = "umi";
package/dist/constants.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FRAMEWORK_NAME = exports.DEFAULT_CONFIG_FILES = exports.DEV_COMMAND = exports.MIN_NODE_VERSION = void 0;
4
- exports.MIN_NODE_VERSION = 14;
5
- exports.DEV_COMMAND = 'dev';
6
- exports.DEFAULT_CONFIG_FILES = [
7
- '.umirc.ts',
8
- '.umirc.js',
9
- 'config/config.ts',
10
- 'config/config.js',
11
- ];
12
- exports.FRAMEWORK_NAME = 'umi';
@@ -1,5 +0,0 @@
1
- import { IConfigFromPlugins } from '@@/core/pluginConfig';
2
- import type { IConfig } from '@umijs/preset-umi';
3
- declare type ConfigType = IConfigFromPlugins & IConfig;
4
- export declare function defineConfig(config: ConfigType): ConfigType;
5
- export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineConfig = void 0;
4
- function defineConfig(config) {
5
- return config;
6
- }
7
- exports.defineConfig = defineConfig;
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { IServicePluginAPI, PluginAPI } from '@umijs/core';
2
- export { run } from './cli/cli';
3
- export { defineConfig } from './defineConfig';
4
- export * from './service/service';
5
- export declare type IApi = PluginAPI & IServicePluginAPI;
package/dist/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.defineConfig = exports.run = void 0;
18
- var cli_1 = require("./cli/cli");
19
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return cli_1.run; } });
20
- var defineConfig_1 = require("./defineConfig");
21
- Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return defineConfig_1.defineConfig; } });
22
- __exportStar(require("./service/service"), exports);
@@ -1,4 +0,0 @@
1
- import express from '@umijs/bundler-utils/compiled/express';
2
- import * as httpProxyMiddleware from '@umijs/bundler-webpack/compiled/http-proxy-middleware';
3
- export * from '@umijs/utils';
4
- export { httpProxyMiddleware, express };
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.express = exports.httpProxyMiddleware = void 0;
33
- const express_1 = __importDefault(require("@umijs/bundler-utils/compiled/express"));
34
- exports.express = express_1.default;
35
- const httpProxyMiddleware = __importStar(require("@umijs/bundler-webpack/compiled/http-proxy-middleware"));
36
- exports.httpProxyMiddleware = httpProxyMiddleware;
37
- __exportStar(require("@umijs/utils"), exports);
@@ -1 +0,0 @@
1
- export declare function getCwd(): string;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCwd = void 0;
4
- const path_1 = require("path");
5
- function getCwd() {
6
- const cwd = process.cwd();
7
- const appRoot = process.env.APP_ROOT;
8
- if (appRoot) {
9
- return (0, path_1.isAbsolute)(appRoot) ? appRoot : (0, path_1.join)(cwd, appRoot);
10
- }
11
- return cwd;
12
- }
13
- exports.getCwd = getCwd;
@@ -1,8 +0,0 @@
1
- import { Service as CoreService } from '@umijs/core';
2
- export declare class Service extends CoreService {
3
- constructor(opts?: any);
4
- run2(opts: {
5
- name: string;
6
- args?: any;
7
- }): Promise<void>;
8
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Service = void 0;
13
- const core_1 = require("@umijs/core");
14
- const fs_1 = require("fs");
15
- const path_1 = require("path");
16
- const constants_1 = require("../constants");
17
- const cwd_1 = require("./cwd");
18
- class Service extends core_1.Service {
19
- constructor(opts) {
20
- process.env.UMI_DIR = (0, path_1.dirname)(require.resolve('../../package'));
21
- const cwd = (0, cwd_1.getCwd)();
22
- super(Object.assign(Object.assign({}, opts), { env: process.env.NODE_ENV, cwd, defaultConfigFiles: constants_1.DEFAULT_CONFIG_FILES, frameworkName: constants_1.FRAMEWORK_NAME, presets: [require.resolve('@umijs/preset-umi'), ...((opts === null || opts === void 0 ? void 0 : opts.presets) || [])], plugins: [
23
- (0, fs_1.existsSync)((0, path_1.join)(cwd, 'plugin.ts')) && (0, path_1.join)(cwd, 'plugin.ts'),
24
- (0, fs_1.existsSync)((0, path_1.join)(cwd, 'plugin.js')) && (0, path_1.join)(cwd, 'plugin.js'),
25
- ].filter(Boolean) }));
26
- }
27
- run2(opts) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- let name = opts.name;
30
- if ((opts === null || opts === void 0 ? void 0 : opts.args.version) || name === 'v') {
31
- name = 'version';
32
- }
33
- else if ((opts === null || opts === void 0 ? void 0 : opts.args.help) || !name || name === 'h') {
34
- name = 'help';
35
- }
36
- // TODO
37
- // initWebpack
38
- return yield this.run(Object.assign(Object.assign({}, opts), { name }));
39
- });
40
- }
41
- }
42
- exports.Service = Service;
package/dist/test.d.ts DELETED
@@ -1,117 +0,0 @@
1
- import { Config } from '@umijs/test';
2
- export * from '@umijs/test';
3
- export declare function configUmiAlias(config: Config.InitialOptions): Promise<Partial<{
4
- automock: boolean;
5
- bail: number | boolean;
6
- cache: boolean;
7
- cacheDirectory: string;
8
- ci: boolean;
9
- clearMocks: boolean;
10
- changedFilesWithAncestor: boolean;
11
- changedSince: string;
12
- collectCoverage: boolean;
13
- collectCoverageFrom: string[];
14
- collectCoverageOnlyFrom: {
15
- [key: string]: boolean;
16
- };
17
- coverageDirectory: string;
18
- coveragePathIgnorePatterns: string[];
19
- coverageProvider: "babel" | "v8";
20
- coverageReporters: Config.CoverageReporters;
21
- coverageThreshold: {
22
- [path: string]: Config.CoverageThresholdValue;
23
- global: Config.CoverageThresholdValue;
24
- };
25
- dependencyExtractor: string;
26
- detectLeaks: boolean;
27
- detectOpenHandles: boolean;
28
- displayName: string | Config.DisplayName;
29
- expand: boolean;
30
- extensionsToTreatAsEsm: string[];
31
- extraGlobals: string[];
32
- filter: string;
33
- findRelatedTests: boolean;
34
- forceCoverageMatch: string[];
35
- forceExit: boolean;
36
- json: boolean;
37
- globals: Config.ConfigGlobals;
38
- globalSetup: string | null | undefined;
39
- globalTeardown: string | null | undefined;
40
- haste: Config.HasteConfig;
41
- injectGlobals: boolean;
42
- reporters: (string | Config.ReporterConfig)[];
43
- logHeapUsage: boolean;
44
- lastCommit: boolean;
45
- listTests: boolean;
46
- maxConcurrency: number;
47
- maxWorkers: string | number;
48
- moduleDirectories: string[];
49
- moduleFileExtensions: string[];
50
- moduleLoader: string;
51
- moduleNameMapper: {
52
- [key: string]: string | string[];
53
- };
54
- modulePathIgnorePatterns: string[];
55
- modulePaths: string[];
56
- name: string;
57
- noStackTrace: boolean;
58
- notify: boolean;
59
- notifyMode: string;
60
- onlyChanged: boolean;
61
- onlyFailures: boolean;
62
- outputFile: string;
63
- passWithNoTests: boolean;
64
- preprocessorIgnorePatterns: string[];
65
- preset: string | null | undefined;
66
- prettierPath: string | null | undefined;
67
- projects: (string | Config.InitialProjectOptions)[];
68
- replname: string | null | undefined;
69
- resetMocks: boolean;
70
- resetModules: boolean;
71
- resolver: string | null | undefined;
72
- restoreMocks: boolean;
73
- rootDir: string;
74
- roots: string[];
75
- runner: string;
76
- runTestsByPath: boolean;
77
- scriptPreprocessor: string;
78
- setupFiles: string[];
79
- setupTestFrameworkScriptFile: string;
80
- setupFilesAfterEnv: string[];
81
- silent: boolean;
82
- skipFilter: boolean;
83
- skipNodeResolution: boolean;
84
- slowTestThreshold: number;
85
- snapshotResolver: string;
86
- snapshotSerializers: string[];
87
- snapshotFormat: Config.PrettyFormatOptions;
88
- errorOnDeprecated: boolean;
89
- testEnvironment: string;
90
- testEnvironmentOptions: Record<string, unknown>;
91
- testFailureExitCode: string | number;
92
- testLocationInResults: boolean;
93
- testMatch: string[];
94
- testNamePattern: string;
95
- testPathDirs: string[];
96
- testPathIgnorePatterns: string[];
97
- testRegex: string | string[];
98
- testResultsProcessor: string;
99
- testRunner: string;
100
- testSequencer: string;
101
- testURL: string;
102
- testTimeout: number;
103
- timers: "real" | "fake" | "modern" | "legacy";
104
- transform: {
105
- [regex: string]: string | Config.TransformerConfig;
106
- };
107
- transformIgnorePatterns: string[];
108
- watchPathIgnorePatterns: string[];
109
- unmockedModulePathPatterns: string[];
110
- updateSnapshot: boolean;
111
- useStderr: boolean;
112
- verbose?: boolean | undefined;
113
- watch: boolean;
114
- watchAll: boolean;
115
- watchman: boolean;
116
- watchPlugins: (string | [string, Record<string, unknown>])[];
117
- }>>;
package/dist/test.js DELETED
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.configUmiAlias = void 0;
27
- const fs_1 = require("fs");
28
- const service_1 = require("./service/service");
29
- __exportStar(require("@umijs/test"), exports);
30
- function getAliasPathWithKey(alias, key) {
31
- const thePath = alias[key];
32
- if (alias[thePath]) {
33
- return getAliasPathWithKey(alias, thePath);
34
- }
35
- return thePath;
36
- }
37
- let service;
38
- function configUmiAlias(config) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- if (!service) {
41
- service = new service_1.Service();
42
- yield service.run2({
43
- name: 'setup',
44
- args: { quiet: true },
45
- });
46
- }
47
- config.moduleNameMapper || (config.moduleNameMapper = {});
48
- const { alias } = service.config;
49
- for (const key of Object.keys(alias)) {
50
- const aliasPath = getAliasPathWithKey(alias, key);
51
- if ((0, fs_1.existsSync)(aliasPath) && (0, fs_1.statSync)(aliasPath).isDirectory()) {
52
- config.moduleNameMapper[`^${key}/(.*)$`] = `${aliasPath}/$1`;
53
- config.moduleNameMapper[`^${key}$`] = aliasPath;
54
- }
55
- else {
56
- config.moduleNameMapper[`^${key}$`] = aliasPath;
57
- }
58
- }
59
- return config;
60
- });
61
- }
62
- exports.configUmiAlias = configUmiAlias;