@umijs/utils 4.2.6-alpha.6 → 4.2.6-alpha.9

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 (59) hide show
  1. package/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
  2. package/dist/BaseGenerator/BaseGenerator.js +82 -0
  3. package/dist/BaseGenerator/generateFile.d.ts +9 -0
  4. package/dist/BaseGenerator/generateFile.js +52 -0
  5. package/dist/Generator/Generator.d.ts +29 -0
  6. package/dist/Generator/Generator.js +101 -0
  7. package/dist/aliasUtils/getAliasValue.d.ts +4 -0
  8. package/dist/aliasUtils/getAliasValue.js +66 -0
  9. package/dist/aliasUtils/index.d.ts +2 -0
  10. package/dist/aliasUtils/index.js +32 -0
  11. package/dist/aliasUtils/parseCircleAlias.d.ts +4 -0
  12. package/dist/aliasUtils/parseCircleAlias.js +66 -0
  13. package/dist/getCorejsVersion.d.ts +1 -0
  14. package/dist/getCorejsVersion.js +35 -0
  15. package/dist/getDevBanner.d.ts +5 -0
  16. package/dist/getDevBanner.js +81 -0
  17. package/dist/getFileGitIno.d.ts +47 -0
  18. package/dist/getFileGitIno.js +130 -0
  19. package/dist/getGitInfo.d.ts +6 -0
  20. package/dist/getGitInfo.js +50 -0
  21. package/dist/importLazy.d.ts +6 -0
  22. package/dist/importLazy.js +45 -0
  23. package/dist/index.d.ts +56 -0
  24. package/dist/index.js +187 -0
  25. package/dist/installDeps.d.ts +9 -0
  26. package/dist/installDeps.js +71 -0
  27. package/dist/isJavaScriptFile.d.ts +1 -0
  28. package/dist/isJavaScriptFile.js +32 -0
  29. package/dist/isLocalDev.d.ts +4 -0
  30. package/dist/isLocalDev.js +36 -0
  31. package/dist/isMonorepo.d.ts +5 -0
  32. package/dist/isMonorepo.js +44 -0
  33. package/dist/isStyleFile.d.ts +5 -0
  34. package/dist/isStyleFile.js +44 -0
  35. package/dist/logger.d.ts +21 -0
  36. package/dist/logger.js +180 -0
  37. package/dist/node.d.ts +4 -0
  38. package/dist/node.js +61 -0
  39. package/dist/npmClient.d.ts +16 -0
  40. package/dist/npmClient.js +89 -0
  41. package/dist/printHelp.d.ts +2 -0
  42. package/dist/printHelp.js +64 -0
  43. package/dist/randomColor/randomColor.d.ts +6 -0
  44. package/dist/randomColor/randomColor.js +50 -0
  45. package/dist/readDirFiles.d.ts +9 -0
  46. package/dist/readDirFiles.js +62 -0
  47. package/dist/register.d.ts +7 -0
  48. package/dist/register.js +85 -0
  49. package/dist/setNoDeprecation.d.ts +1 -0
  50. package/dist/setNoDeprecation.js +31 -0
  51. package/dist/tryPaths.d.ts +1 -0
  52. package/dist/tryPaths.js +35 -0
  53. package/dist/updatePackageJSON.d.ts +5 -0
  54. package/dist/updatePackageJSON.js +52 -0
  55. package/dist/winPath.d.ts +1 -0
  56. package/dist/winPath.js +35 -0
  57. package/dist/zod/isZodSchema.d.ts +2 -0
  58. package/dist/zod/isZodSchema.js +31 -0
  59. package/package.json +1 -1
@@ -0,0 +1,44 @@
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/isMonorepo.ts
20
+ var isMonorepo_exports = {};
21
+ __export(isMonorepo_exports, {
22
+ isMonorepo: () => isMonorepo
23
+ });
24
+ module.exports = __toCommonJS(isMonorepo_exports);
25
+ var import_path = require("path");
26
+ var import_fs = require("fs");
27
+ var MONOREPO_FILE = ["pnpm-workspace.yaml", "lerna.json"];
28
+ function isMonorepo(opts) {
29
+ const pkgPath = (0, import_path.join)(opts.root, "package.json");
30
+ let pkg = {};
31
+ try {
32
+ pkg = require(pkgPath);
33
+ } catch (e) {
34
+ }
35
+ const pkgExist = (0, import_fs.existsSync)(pkgPath);
36
+ return pkgExist && (MONOREPO_FILE.some((file) => {
37
+ return (0, import_fs.existsSync)((0, import_path.join)(opts.root, file));
38
+ }) || // npm workspaces
39
+ (pkg == null ? void 0 : pkg.workspaces));
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ isMonorepo
44
+ });
@@ -0,0 +1,5 @@
1
+ export declare const AUTO_CSS_MODULE_EXTS: string[];
2
+ export declare const isStyleFile: ({ filename, }: {
3
+ filename?: string | undefined;
4
+ ext?: string | undefined;
5
+ }) => boolean | "" | undefined;
@@ -0,0 +1,44 @@
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/isStyleFile.ts
20
+ var isStyleFile_exports = {};
21
+ __export(isStyleFile_exports, {
22
+ AUTO_CSS_MODULE_EXTS: () => AUTO_CSS_MODULE_EXTS,
23
+ isStyleFile: () => isStyleFile
24
+ });
25
+ module.exports = __toCommonJS(isStyleFile_exports);
26
+ var AUTO_CSS_MODULE_EXTS = [
27
+ ".css",
28
+ ".less",
29
+ ".sass",
30
+ ".scss",
31
+ ".stylus",
32
+ ".styl"
33
+ ];
34
+ var STYLE_EXT_REGX = /\.(:?css|less|scss|sass|stylus|styl)$/;
35
+ var isStyleFile = ({
36
+ filename
37
+ }) => {
38
+ return filename && STYLE_EXT_REGX.test(filename);
39
+ };
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ AUTO_CSS_MODULE_EXTS,
43
+ isStyleFile
44
+ });
@@ -0,0 +1,21 @@
1
+ export declare const prefixes: {
2
+ wait: string;
3
+ error: string;
4
+ fatal: string;
5
+ warn: string;
6
+ ready: string;
7
+ info: string;
8
+ event: string;
9
+ debug: string;
10
+ profile: string;
11
+ };
12
+ export declare function wait(...message: any[]): void;
13
+ export declare function error(...message: any[]): void;
14
+ export declare function warn(...message: any[]): void;
15
+ export declare function ready(...message: any[]): void;
16
+ export declare function info(...message: any[]): void;
17
+ export declare function event(...message: any[]): void;
18
+ export declare function debug(...message: any[]): void;
19
+ export declare function fatal(...message: any[]): void;
20
+ export declare function profile(id: string, ...message: any[]): void;
21
+ export declare function getLatestLogFilePath(): string | null;
package/dist/logger.js ADDED
@@ -0,0 +1,180 @@
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/logger.ts
30
+ var logger_exports = {};
31
+ __export(logger_exports, {
32
+ debug: () => debug,
33
+ error: () => error,
34
+ event: () => event,
35
+ fatal: () => fatal,
36
+ getLatestLogFilePath: () => getLatestLogFilePath,
37
+ info: () => info,
38
+ prefixes: () => prefixes,
39
+ profile: () => profile,
40
+ ready: () => ready,
41
+ wait: () => wait,
42
+ warn: () => warn
43
+ });
44
+ module.exports = __toCommonJS(logger_exports);
45
+ var import_path = require("path");
46
+ var import_chalk = __toESM(require("../compiled/chalk"));
47
+ var import_fs_extra = __toESM(require("../compiled/fs-extra"));
48
+ var import_pkg_up = require("../compiled/pkg-up");
49
+ var import_importLazy = require("./importLazy");
50
+ var enableFSLogger = process.env.FS_LOGGER !== "none" && !process.versions.webcontainer;
51
+ var profilers = {};
52
+ var loggerDir = findLoggerDir();
53
+ var loggerPath = (0, import_path.join)(loggerDir, "umi.log");
54
+ var prefixes = {
55
+ wait: import_chalk.default.cyan("wait") + " -",
56
+ error: import_chalk.default.red("error") + " -",
57
+ fatal: import_chalk.default.red("fatal") + " -",
58
+ warn: import_chalk.default.yellow("warn") + " -",
59
+ ready: import_chalk.default.green("ready") + " -",
60
+ info: import_chalk.default.cyan("info") + " -",
61
+ event: import_chalk.default.magenta("event") + " -",
62
+ debug: import_chalk.default.gray("debug") + " -",
63
+ profile: import_chalk.default.blue("profile") + " -"
64
+ };
65
+ var pinoModule = (0, import_importLazy.importLazy)(require.resolve("pino"));
66
+ var logger;
67
+ if (enableFSLogger) {
68
+ const pino = pinoModule.default;
69
+ import_fs_extra.default.mkdirpSync(loggerDir);
70
+ const customLevels = {
71
+ ready: 31,
72
+ event: 32,
73
+ wait: 55,
74
+ // 虽然这里设置了 debug 为 30,但日志中还是 20,符合预期
75
+ // 这里不加会不生成到 umi.log,transport 的 level 配置没有生效,原因不明
76
+ debug: 30
77
+ };
78
+ logger = pino(
79
+ {
80
+ customLevels
81
+ },
82
+ pino.transport({
83
+ targets: [
84
+ {
85
+ target: require.resolve("pino/file"),
86
+ options: {
87
+ destination: loggerPath
88
+ },
89
+ level: "trace"
90
+ }
91
+ ]
92
+ })
93
+ );
94
+ } else {
95
+ logger = {};
96
+ Object.keys(prefixes).forEach((key) => {
97
+ logger[key] = () => {
98
+ };
99
+ });
100
+ }
101
+ function wait(...message) {
102
+ console.log(prefixes.wait, ...message);
103
+ logger.wait(message[0]);
104
+ }
105
+ function error(...message) {
106
+ console.error(prefixes.error, ...message);
107
+ logger.error(message[0]);
108
+ }
109
+ function warn(...message) {
110
+ console.warn(prefixes.warn, ...message);
111
+ logger.warn(message[0]);
112
+ }
113
+ function ready(...message) {
114
+ console.log(prefixes.ready, ...message);
115
+ logger.ready(message[0]);
116
+ }
117
+ function info(...message) {
118
+ console.log(prefixes.info, ...message);
119
+ logger.info(message[0]);
120
+ }
121
+ function event(...message) {
122
+ console.log(prefixes.event, ...message);
123
+ logger.event(message[0]);
124
+ }
125
+ function debug(...message) {
126
+ if (process.env.DEBUG) {
127
+ console.log(prefixes.debug, ...message);
128
+ }
129
+ logger.debug(message[0]);
130
+ }
131
+ function fatal(...message) {
132
+ console.error(prefixes.fatal, ...message);
133
+ logger.fatal(message[0]);
134
+ }
135
+ function profile(id, ...message) {
136
+ if (process.env.IS_UMI_BUILD_WORKER && !process.env.DEBUG) {
137
+ return;
138
+ }
139
+ if (!profilers[id]) {
140
+ profilers[id] = {
141
+ startTime: Date.now()
142
+ };
143
+ console.log(prefixes.profile, import_chalk.default.green(id), ...message);
144
+ return;
145
+ }
146
+ const endTime = Date.now();
147
+ const { startTime } = profilers[id];
148
+ console.log(
149
+ prefixes.profile,
150
+ import_chalk.default.green(id),
151
+ `Completed in ${import_chalk.default.cyan(`${endTime - startTime}ms`)}`,
152
+ ...message
153
+ );
154
+ delete profilers[id];
155
+ }
156
+ function getLatestLogFilePath() {
157
+ return enableFSLogger ? loggerPath : null;
158
+ }
159
+ function findLoggerDir() {
160
+ let baseDir = process.cwd();
161
+ const pkg = (0, import_pkg_up.pkgUpSync)({ cwd: baseDir });
162
+ if (pkg) {
163
+ baseDir = (0, import_path.dirname)(pkg);
164
+ }
165
+ return (0, import_path.join)(baseDir, "node_modules/.cache/logger");
166
+ }
167
+ // Annotate the CommonJS export names for ESM import in node:
168
+ 0 && (module.exports = {
169
+ debug,
170
+ error,
171
+ event,
172
+ fatal,
173
+ getLatestLogFilePath,
174
+ info,
175
+ prefixes,
176
+ profile,
177
+ ready,
178
+ wait,
179
+ warn
180
+ });
package/dist/node.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function checkVersion(minVersion: number, message?: string): void;
2
+ export declare function checkLocal(): void;
3
+ export declare function setNodeTitle(name: string): void;
4
+ export declare function catchUnhandledRejection(): void;
package/dist/node.js ADDED
@@ -0,0 +1,61 @@
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/node.ts
20
+ var node_exports = {};
21
+ __export(node_exports, {
22
+ catchUnhandledRejection: () => catchUnhandledRejection,
23
+ checkLocal: () => checkLocal,
24
+ checkVersion: () => checkVersion,
25
+ setNodeTitle: () => setNodeTitle
26
+ });
27
+ module.exports = __toCommonJS(node_exports);
28
+ var import__ = require("./");
29
+ var ver = parseInt(process.version.slice(1));
30
+ function checkVersion(minVersion, message) {
31
+ if (ver < minVersion || ver === 15 || ver === 17 || ver === 19) {
32
+ import__.logger.error(
33
+ message || `Your node version ${ver} is not supported, please upgrade to ${minVersion} or above except 15 or 17.`
34
+ );
35
+ process.exit(1);
36
+ }
37
+ }
38
+ function checkLocal() {
39
+ if ((0, import__.isLocalDev)()) {
40
+ import__.logger.info("@local");
41
+ }
42
+ }
43
+ function setNodeTitle(name) {
44
+ if (process.title === "node") {
45
+ process.title = name;
46
+ }
47
+ }
48
+ function catchUnhandledRejection() {
49
+ if (ver <= 14) {
50
+ process.on("unhandledRejection", (err) => {
51
+ throw err;
52
+ });
53
+ }
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ catchUnhandledRejection,
58
+ checkLocal,
59
+ checkVersion,
60
+ setNodeTitle
61
+ });
@@ -0,0 +1,16 @@
1
+ export declare type NpmClient = 'npm' | 'cnpm' | 'tnpm' | 'yarn' | 'pnpm';
2
+ export declare const npmClients: string[];
3
+ export declare enum NpmClientEnum {
4
+ pnpm = "pnpm",
5
+ tnpm = "tnpm",
6
+ cnpm = "cnpm",
7
+ yarn = "yarn",
8
+ npm = "npm"
9
+ }
10
+ export declare const getNpmClient: (opts: {
11
+ cwd: string;
12
+ }) => NpmClient;
13
+ export declare const installWithNpmClient: ({ npmClient, cwd, }: {
14
+ npmClient: NpmClient;
15
+ cwd?: string | undefined;
16
+ }) => void;
@@ -0,0 +1,89 @@
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/npmClient.ts
30
+ var npmClient_exports = {};
31
+ __export(npmClient_exports, {
32
+ NpmClientEnum: () => NpmClientEnum,
33
+ getNpmClient: () => getNpmClient,
34
+ installWithNpmClient: () => installWithNpmClient,
35
+ npmClients: () => npmClients
36
+ });
37
+ module.exports = __toCommonJS(npmClient_exports);
38
+ var import_fs = require("fs");
39
+ var import_path = require("path");
40
+ var npmClients = ["pnpm", "tnpm", "cnpm", "yarn", "npm"];
41
+ var NpmClientEnum = /* @__PURE__ */ ((NpmClientEnum2) => {
42
+ NpmClientEnum2["pnpm"] = "pnpm";
43
+ NpmClientEnum2["tnpm"] = "tnpm";
44
+ NpmClientEnum2["cnpm"] = "cnpm";
45
+ NpmClientEnum2["yarn"] = "yarn";
46
+ NpmClientEnum2["npm"] = "npm";
47
+ return NpmClientEnum2;
48
+ })(NpmClientEnum || {});
49
+ var getNpmClient = (opts) => {
50
+ const tnpmRegistries = [".alibaba-inc.", ".antgroup-inc."];
51
+ const tcnpmLockPath = (0, import_path.join)(opts.cwd, "node_modules", ".package-lock.json");
52
+ const chokidarPkg = require("chokidar/package.json");
53
+ if (chokidarPkg._resolved) {
54
+ return tnpmRegistries.some((r) => chokidarPkg._resolved.includes(r)) ? "tnpm" : "cnpm";
55
+ } else if ((0, import_fs.existsSync)(tcnpmLockPath)) {
56
+ const tcnpmLock = (0, import_fs.readFileSync)(tcnpmLockPath, "utf-8");
57
+ return tnpmRegistries.some((r) => tcnpmLock.includes(r)) ? "tnpm" : "cnpm";
58
+ }
59
+ const chokidarPath = require.resolve("chokidar");
60
+ if (chokidarPath.includes(".pnpm") || (0, import_fs.existsSync)((0, import_path.join)(opts.cwd, "node_modules", ".pnpm"))) {
61
+ return "pnpm";
62
+ }
63
+ if ((0, import_fs.existsSync)((0, import_path.join)(opts.cwd, "yarn.lock")) || (0, import_fs.existsSync)((0, import_path.join)(opts.cwd, "node_modules", ".yarn-integrity"))) {
64
+ return "yarn";
65
+ }
66
+ return "npm";
67
+ };
68
+ var installWithNpmClient = ({
69
+ npmClient,
70
+ cwd
71
+ }) => {
72
+ const { sync } = require("../compiled/cross-spawn");
73
+ const { NODE_ENV: _, ...env } = process.env;
74
+ const npm = sync(npmClient, [npmClient === "yarn" ? "" : "install"], {
75
+ stdio: "inherit",
76
+ cwd,
77
+ env
78
+ });
79
+ if (npm.error) {
80
+ throw npm.error;
81
+ }
82
+ };
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ NpmClientEnum,
86
+ getNpmClient,
87
+ installWithNpmClient,
88
+ npmClients
89
+ });
@@ -0,0 +1,2 @@
1
+ export declare function exit(): void;
2
+ export declare function runtime(e: Error): void;
@@ -0,0 +1,64 @@
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/printHelp.ts
30
+ var printHelp_exports = {};
31
+ __export(printHelp_exports, {
32
+ exit: () => exit,
33
+ runtime: () => runtime
34
+ });
35
+ module.exports = __toCommonJS(printHelp_exports);
36
+ var logger = __toESM(require("./logger"));
37
+ var FEEDBACK_MESSAGE = "如果你需要进交流群,请访问 https://fb.umijs.org 。";
38
+ function exit() {
39
+ const loggerPath = logger.getLatestLogFilePath();
40
+ if (loggerPath) {
41
+ logger.fatal("A complete log of this run can be found in:");
42
+ logger.fatal(loggerPath);
43
+ }
44
+ logger.fatal(
45
+ "Consider reporting a GitHub issue on https://github.com/umijs/umi/issues"
46
+ );
47
+ const binFile = process.argv[1];
48
+ const isUmi = binFile.endsWith("bin/umi.js");
49
+ const isMax = binFile.endsWith("bin/max.js");
50
+ if (process.env.FATAL_GUIDE_MESSAGE !== "none" && (isUmi || isMax)) {
51
+ logger.fatal(FEEDBACK_MESSAGE);
52
+ }
53
+ if (process.env.FATAL_GUIDE_MESSAGE && process.env.FATAL_GUIDE_MESSAGE !== "none") {
54
+ logger.fatal(process.env.FATAL_GUIDE_MESSAGE);
55
+ }
56
+ }
57
+ function runtime(e) {
58
+ logger.error(e);
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ exit,
63
+ runtime
64
+ });
@@ -0,0 +1,6 @@
1
+ import color from '../../compiled/color';
2
+ export declare function randomColor(saturation?: number, value?: number): color<{
3
+ h: number;
4
+ s: number;
5
+ v: number;
6
+ }>;
@@ -0,0 +1,50 @@
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/randomColor/randomColor.ts
30
+ var randomColor_exports = {};
31
+ __export(randomColor_exports, {
32
+ randomColor: () => randomColor
33
+ });
34
+ module.exports = __toCommonJS(randomColor_exports);
35
+ var import_color = __toESM(require("../../compiled/color"));
36
+ var ratio = 0.618033988749895;
37
+ var hue = Math.random();
38
+ function randomColor(saturation = 0.5, value = 0.95) {
39
+ hue += ratio;
40
+ hue %= 1;
41
+ return (0, import_color.default)({
42
+ h: hue * 360,
43
+ s: saturation * 100,
44
+ v: value * 100
45
+ });
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ randomColor
50
+ });
@@ -0,0 +1,9 @@
1
+ interface FileItem {
2
+ filePath: string;
3
+ name: string;
4
+ }
5
+ export declare const readDirFiles: (opts: {
6
+ dir: string;
7
+ exclude?: RegExp[];
8
+ }) => FileItem[];
9
+ export {};
@@ -0,0 +1,62 @@
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/readDirFiles.ts
20
+ var readDirFiles_exports = {};
21
+ __export(readDirFiles_exports, {
22
+ readDirFiles: () => readDirFiles
23
+ });
24
+ module.exports = __toCommonJS(readDirFiles_exports);
25
+ var import_path = require("path");
26
+ var import_fs_extra = require("../compiled/fs-extra");
27
+ var readDirFiles = (opts) => {
28
+ const { dir, exclude = [] } = opts;
29
+ const list = [];
30
+ const recursiveReadFiles = (p) => {
31
+ if (!(0, import_fs_extra.existsSync)(p)) {
32
+ return;
33
+ }
34
+ const isFile = (0, import_fs_extra.statSync)(p).isFile();
35
+ if (isFile) {
36
+ const name = (0, import_path.basename)(p);
37
+ list.push({
38
+ filePath: p,
39
+ name
40
+ });
41
+ return;
42
+ }
43
+ const files = (0, import_fs_extra.readdirSync)(p).filter((name) => {
44
+ return name !== ".DS_Store";
45
+ }).map((file) => {
46
+ const absolutePath = (0, import_path.join)(p, file);
47
+ return absolutePath;
48
+ }).filter((file) => {
49
+ const isExclude = exclude.some((reg) => reg.test(file));
50
+ return !isExclude;
51
+ });
52
+ files.forEach((file) => {
53
+ recursiveReadFiles(file);
54
+ });
55
+ };
56
+ recursiveReadFiles(dir);
57
+ return list;
58
+ };
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ readDirFiles
62
+ });
@@ -0,0 +1,7 @@
1
+ export declare function register(opts: {
2
+ implementor: any;
3
+ exts?: string[];
4
+ }): void;
5
+ export declare function getFiles(): string[];
6
+ export declare function clearFiles(): void;
7
+ export declare function restore(): void;