@umijs/utils 4.0.56 → 4.0.58

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 (56) hide show
  1. package/compiled/lodash/common/array.d.ts +0 -0
  2. package/compiled/lodash/common/collection.d.ts +0 -0
  3. package/compiled/lodash/common/common.d.ts +0 -0
  4. package/compiled/lodash/common/date.d.ts +0 -0
  5. package/compiled/lodash/common/function.d.ts +0 -0
  6. package/compiled/lodash/common/lang.d.ts +0 -0
  7. package/compiled/lodash/common/math.d.ts +0 -0
  8. package/compiled/lodash/common/number.d.ts +0 -0
  9. package/compiled/lodash/common/object.d.ts +0 -0
  10. package/compiled/lodash/common/seq.d.ts +0 -0
  11. package/compiled/lodash/common/string.d.ts +0 -0
  12. package/compiled/lodash/common/util.d.ts +0 -0
  13. package/compiled/zod/LICENSE +21 -0
  14. package/compiled/zod/index.d.ts +2 -0
  15. package/compiled/zod/index.js +1 -0
  16. package/compiled/zod/lib/ZodError.d.ts +159 -0
  17. package/compiled/zod/lib/__tests__/Mocker.d.ts +17 -0
  18. package/compiled/zod/lib/benchmarks/discriminatedUnion.d.ts +5 -0
  19. package/compiled/zod/lib/benchmarks/index.d.ts +1 -0
  20. package/compiled/zod/lib/benchmarks/object.d.ts +5 -0
  21. package/compiled/zod/lib/benchmarks/primitives.d.ts +5 -0
  22. package/compiled/zod/lib/benchmarks/realworld.d.ts +5 -0
  23. package/compiled/zod/lib/benchmarks/string.d.ts +5 -0
  24. package/compiled/zod/lib/benchmarks/union.d.ts +5 -0
  25. package/compiled/zod/lib/errors.d.ts +5 -0
  26. package/compiled/zod/lib/external.d.ts +6 -0
  27. package/compiled/zod/lib/helpers/enumUtil.d.ts +8 -0
  28. package/compiled/zod/lib/helpers/errorUtil.d.ts +9 -0
  29. package/compiled/zod/lib/helpers/parseUtil.d.ts +78 -0
  30. package/compiled/zod/lib/helpers/partialUtil.d.ts +8 -0
  31. package/compiled/zod/lib/helpers/typeAliases.d.ts +2 -0
  32. package/compiled/zod/lib/helpers/util.d.ts +47 -0
  33. package/compiled/zod/lib/index.d.ts +4 -0
  34. package/compiled/zod/lib/locales/en.d.ts +3 -0
  35. package/compiled/zod/lib/types.d.ts +975 -0
  36. package/compiled/zod/package.json +1 -0
  37. package/dist/BaseGenerator/BaseGenerator.js +4 -0
  38. package/dist/BaseGenerator/generateFile.js +1 -4
  39. package/dist/Generator/Generator.js +4 -0
  40. package/dist/getDevBanner.js +11 -22
  41. package/dist/getFileGitIno.d.ts +47 -0
  42. package/dist/getFileGitIno.js +130 -0
  43. package/dist/getGitInfo.js +1 -4
  44. package/dist/importLazy.js +2 -7
  45. package/dist/index.d.ts +5 -1
  46. package/dist/index.js +10 -2
  47. package/dist/installDeps.js +10 -16
  48. package/dist/npmClient.js +4 -0
  49. package/dist/printHelp.js +2 -7
  50. package/dist/randomColor/randomColor.js +1 -4
  51. package/dist/register.js +2 -0
  52. package/dist/zod/isZodSchema.d.ts +2 -0
  53. package/dist/zod/isZodSchema.js +31 -0
  54. package/dist/zod/zod2string.d.ts +2 -0
  55. package/dist/zod/zod2string.js +49 -0
  56. package/package.json +12 -10
@@ -0,0 +1 @@
1
+ {"name":"zod","version":"3.20.6","author":"Colin McDonnell <colin@colinhacks.com>","license":"MIT","types":"./index.d.ts"}
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
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.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/BaseGenerator/generateFile.ts
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
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.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/getDevBanner.ts
@@ -32,34 +29,26 @@ var import_address = __toESM(require("../compiled/address"));
32
29
  var import_chalk = __toESM(require("../compiled/chalk"));
33
30
  var import_strip_ansi = __toESM(require("../compiled/strip-ansi"));
34
31
  var BORDERS = {
35
- TL: import_chalk.default.gray.dim(""),
36
- TR: import_chalk.default.gray.dim(""),
37
- BL: import_chalk.default.gray.dim(""),
38
- BR: import_chalk.default.gray.dim(""),
39
- V: import_chalk.default.gray.dim(""),
40
- H_PURE: ""
32
+ TL: import_chalk.default.gray.dim("\u2554"),
33
+ TR: import_chalk.default.gray.dim("\u2557"),
34
+ BL: import_chalk.default.gray.dim("\u255A"),
35
+ BR: import_chalk.default.gray.dim("\u255D"),
36
+ V: import_chalk.default.gray.dim("\u2551"),
37
+ H_PURE: "\u2550"
41
38
  };
42
39
  function getDevBanner(protocol, host = "0.0.0.0", port, offset = 8) {
43
40
  const header = " App listening at:";
44
- const footer = import_chalk.default.bold(
45
- " Now you can open browser with the above addresses↑ "
46
- );
47
- const local = ` ${import_chalk.default.gray(">")} Local: ${import_chalk.default.green(
48
- `${protocol}//${host === "0.0.0.0" ? "localhost" : host}:${port}`
49
- )} `;
41
+ const footer = import_chalk.default.bold(" Now you can open browser with the above addresses\u2191 ");
42
+ const local = ` ${import_chalk.default.gray(">")} Local: ${import_chalk.default.green(`${protocol}//${host === "0.0.0.0" ? "localhost" : host}:${port}`)} `;
50
43
  const ip = import_address.default.ip();
51
44
  const network = ` ${import_chalk.default.gray(">")} Network: ${ip ? import_chalk.default.green(`${protocol}//${ip}:${port}`) : import_chalk.default.gray("Not available")} `;
52
- const maxLen = Math.max(
53
- ...[header, footer, local, network].map((x) => (0, import_strip_ansi.default)(x).length)
54
- );
45
+ const maxLen = Math.max(...[header, footer, local, network].map((x) => (0, import_strip_ansi.default)(x).length));
55
46
  const beforeLines = [
56
47
  `${BORDERS.TL}${import_chalk.default.gray.dim("".padStart(maxLen, BORDERS.H_PURE))}${BORDERS.TR}`,
57
48
  `${BORDERS.V}${header}${"".padStart(maxLen - header.length)}${BORDERS.V}`,
58
49
  `${BORDERS.V}${local}${"".padStart(maxLen - (0, import_strip_ansi.default)(local).length)}${BORDERS.V}`
59
50
  ];
60
- const mainLine = `${BORDERS.V}${network}${"".padStart(
61
- maxLen - (0, import_strip_ansi.default)(network).length
62
- )}${BORDERS.V}`;
51
+ const mainLine = `${BORDERS.V}${network}${"".padStart(maxLen - (0, import_strip_ansi.default)(network).length)}${BORDERS.V}`;
63
52
  const afterLines = [
64
53
  `${BORDERS.V}${"".padStart(maxLen)}${BORDERS.V}`,
65
54
  `${BORDERS.V}${footer}${"".padStart(maxLen - (0, import_strip_ansi.default)(footer).length)}${BORDERS.V}`,
@@ -0,0 +1,47 @@
1
+ export interface ICreateInfo {
2
+ createTime?: string;
3
+ creator?: string;
4
+ creatorEmail?: string;
5
+ createSince?: string;
6
+ }
7
+ export interface IModifyInfo {
8
+ modifyTime?: string;
9
+ modifier?: string;
10
+ modifierEmail?: string;
11
+ modifySince?: string;
12
+ }
13
+ /**
14
+ * 获取文件创建信息
15
+ * @param filePath 文件路径,绝对或相对 .git
16
+ * @param gitDirPath .git路径
17
+ * @returns
18
+ */
19
+ export declare const getFileCreateInfo: (filePath: string, gitDirPath?: string) => Promise<{
20
+ createTime: string | undefined;
21
+ creator: string | undefined;
22
+ creatorEmail: string | undefined;
23
+ createSince: string | undefined;
24
+ } | {
25
+ createTime?: undefined;
26
+ creator?: undefined;
27
+ creatorEmail?: undefined;
28
+ createSince?: undefined;
29
+ }>;
30
+ /**
31
+ * 获取文件最新修改信息
32
+ * @param filePath 文件路径,绝对或相对 .git
33
+ * @param gitDirPath .git路径
34
+ * @returns
35
+ */
36
+ export declare const getFileLastModifyInfo: (filePath: string, gitDirPath?: string) => Promise<{
37
+ modifyTime: string | undefined;
38
+ modifier: string | undefined;
39
+ modifierEmail: string | undefined;
40
+ modifySince: string | undefined;
41
+ } | {
42
+ modifyTime?: undefined;
43
+ modifier?: undefined;
44
+ modifierEmail?: undefined;
45
+ modifySince?: undefined;
46
+ }>;
47
+ export declare const isGitRepo: () => Promise<boolean>;
@@ -0,0 +1,130 @@
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/getFileGitIno.ts
30
+ var getFileGitIno_exports = {};
31
+ __export(getFileGitIno_exports, {
32
+ getFileCreateInfo: () => getFileCreateInfo,
33
+ getFileLastModifyInfo: () => getFileLastModifyInfo,
34
+ isGitRepo: () => isGitRepo
35
+ });
36
+ module.exports = __toCommonJS(getFileGitIno_exports);
37
+ var import_cross_spawn = __toESM(require("cross-spawn"));
38
+ var import_execa = require("../compiled/execa");
39
+ var promisifySpawn = (cmd, args, {
40
+ onlyOnce,
41
+ ...rest
42
+ }) => new Promise((resolve, reject) => {
43
+ var _a;
44
+ const cp = (0, import_cross_spawn.default)(cmd, args, rest);
45
+ const error = [];
46
+ const stdout = [];
47
+ (_a = cp.stdout) == null ? void 0 : _a.on("data", (data) => {
48
+ stdout.push(data.toString());
49
+ if (onlyOnce) {
50
+ cp.kill("SIGKILL");
51
+ }
52
+ });
53
+ cp.on("error", (e) => {
54
+ error.push(e.toString());
55
+ });
56
+ cp.on("close", () => {
57
+ if (error.length) {
58
+ reject(error.join(""));
59
+ } else {
60
+ resolve(stdout);
61
+ }
62
+ });
63
+ });
64
+ var getFileCreateInfo = async (filePath, gitDirPath) => {
65
+ try {
66
+ const info = await promisifySpawn(
67
+ "git",
68
+ // time|name|email|since
69
+ ["log", "--reverse", "-1000000", "--pretty='%ad|%an|%ae|%ar'", filePath],
70
+ {
71
+ cwd: gitDirPath,
72
+ onlyOnce: true,
73
+ shell: true
74
+ }
75
+ );
76
+ if (info.length && info[0]) {
77
+ const firstCommit = info[0].slice(0, info[0].indexOf("\n")).split("|");
78
+ return {
79
+ createTime: firstCommit.at(0),
80
+ creator: firstCommit.at(1),
81
+ creatorEmail: firstCommit.at(2),
82
+ createSince: firstCommit.at(3)
83
+ };
84
+ } else {
85
+ return {};
86
+ }
87
+ } catch (err) {
88
+ throw new Error(`get file ${filePath} git info failed`);
89
+ }
90
+ };
91
+ var getFileLastModifyInfo = async (filePath, gitDirPath) => {
92
+ try {
93
+ const info = await promisifySpawn(
94
+ "git",
95
+ ["log", "-1", "--pretty='%ad|%an|%ae|%ar'", filePath],
96
+ {
97
+ cwd: gitDirPath,
98
+ onlyOnce: true,
99
+ shell: true
100
+ }
101
+ );
102
+ if (info.length && info[0]) {
103
+ const firstCommit = info[0].slice(0, info[0].indexOf("\n")).split("|");
104
+ return {
105
+ modifyTime: firstCommit.at(0),
106
+ modifier: firstCommit.at(1),
107
+ modifierEmail: firstCommit.at(2),
108
+ modifySince: firstCommit.at(3)
109
+ };
110
+ } else {
111
+ return {};
112
+ }
113
+ } catch (err) {
114
+ throw new Error(`get file ${filePath} git info failed`);
115
+ }
116
+ };
117
+ var isGitRepo = async () => {
118
+ try {
119
+ const res = await (0, import_execa.execa)("git", ["rev-parse", "--is-inside-work-tree"]);
120
+ return res.stdout.includes("true");
121
+ } catch (e) {
122
+ return false;
123
+ }
124
+ };
125
+ // Annotate the CommonJS export names for ESM import in node:
126
+ 0 && (module.exports = {
127
+ getFileCreateInfo,
128
+ getFileLastModifyInfo,
129
+ isGitRepo
130
+ });
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/getGitInfo.ts
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/importLazy.ts
@@ -30,9 +27,7 @@ __export(importLazy_exports, {
30
27
  module.exports = __toCommonJS(importLazy_exports);
31
28
  var import_import_lazy = __toESM(require("../compiled/import-lazy"));
32
29
  function importLazy(moduleName, requireFn) {
33
- const importLazyLocal = (0, import_import_lazy.default)(
34
- requireFn || require
35
- );
30
+ const importLazyLocal = (0, import_import_lazy.default)(requireFn || require);
36
31
  return importLazyLocal(moduleName);
37
32
  }
38
33
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ import semver from '../compiled/semver';
26
26
  import stripAnsi from '../compiled/strip-ansi';
27
27
  import * as tsconfigPaths from '../compiled/tsconfig-paths';
28
28
  import yParser from '../compiled/yargs-parser';
29
+ import { z } from '../compiled/zod';
29
30
  import BaseGenerator from './BaseGenerator/BaseGenerator';
30
31
  import generateFile from './BaseGenerator/generateFile';
31
32
  import Generator from './Generator/Generator';
@@ -37,6 +38,7 @@ import updatePackageJSON from './updatePackageJSON';
37
38
  export * as aliasUtils from './aliasUtils';
38
39
  export * from './getCorejsVersion';
39
40
  export * from './getDevBanner';
41
+ export * as git from './getFileGitIno';
40
42
  export * from './importLazy';
41
43
  export * from './isLocalDev';
42
44
  export * from './isMonorepo';
@@ -48,4 +50,6 @@ export * as register from './register';
48
50
  export * from './setNoDeprecation';
49
51
  export * from './tryPaths';
50
52
  export * from './winPath';
51
- export { address, axios, chalk, cheerio, chokidar, crossSpawn, debug, deepmerge, execa, fsExtra, glob, Generator, BaseGenerator, generateFile, installDeps, lodash, logger, Mustache, pkgUp, portfinder, prompts, resolve, rimraf, semver, stripAnsi, updatePackageJSON, yParser, getGitInfo, printHelp, filesize, gzipSize, fastestLevenshtein, clackPrompts, MagicString, remapping, tsconfigPaths, };
53
+ export * from './zod/isZodSchema';
54
+ export * from './zod/zod2string';
55
+ export { address, axios, chalk, cheerio, chokidar, crossSpawn, debug, deepmerge, execa, fsExtra, glob, Generator, BaseGenerator, generateFile, installDeps, lodash, logger, Mustache, pkgUp, portfinder, prompts, resolve, rimraf, semver, stripAnsi, updatePackageJSON, yParser, getGitInfo, printHelp, filesize, gzipSize, fastestLevenshtein, clackPrompts, MagicString, remapping, tsconfigPaths, z as zod, };
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ __export(src_exports, {
50
50
  fsExtra: () => import_fs_extra.default,
51
51
  generateFile: () => import_generateFile.default,
52
52
  getGitInfo: () => import_getGitInfo.default,
53
+ git: () => git,
53
54
  glob: () => import_glob.default,
54
55
  gzipSize: () => gzipSize,
55
56
  installDeps: () => import_installDeps.default,
@@ -67,7 +68,8 @@ __export(src_exports, {
67
68
  stripAnsi: () => import_strip_ansi.default,
68
69
  tsconfigPaths: () => tsconfigPaths,
69
70
  updatePackageJSON: () => import_updatePackageJSON.default,
70
- yParser: () => import_yargs_parser.default
71
+ yParser: () => import_yargs_parser.default,
72
+ zod: () => import_zod.z
71
73
  });
72
74
  module.exports = __toCommonJS(src_exports);
73
75
  var chokidar = __toESM(require("chokidar"));
@@ -98,6 +100,7 @@ var import_semver = __toESM(require("../compiled/semver"));
98
100
  var import_strip_ansi = __toESM(require("../compiled/strip-ansi"));
99
101
  var tsconfigPaths = __toESM(require("../compiled/tsconfig-paths"));
100
102
  var import_yargs_parser = __toESM(require("../compiled/yargs-parser"));
103
+ var import_zod = require("../compiled/zod");
101
104
  var import_BaseGenerator = __toESM(require("./BaseGenerator/BaseGenerator"));
102
105
  var import_generateFile = __toESM(require("./BaseGenerator/generateFile"));
103
106
  var import_Generator = __toESM(require("./Generator/Generator"));
@@ -109,6 +112,7 @@ var import_updatePackageJSON = __toESM(require("./updatePackageJSON"));
109
112
  var aliasUtils = __toESM(require("./aliasUtils"));
110
113
  __reExport(src_exports, require("./getCorejsVersion"), module.exports);
111
114
  __reExport(src_exports, require("./getDevBanner"), module.exports);
115
+ var git = __toESM(require("./getFileGitIno"));
112
116
  __reExport(src_exports, require("./importLazy"), module.exports);
113
117
  __reExport(src_exports, require("./isLocalDev"), module.exports);
114
118
  __reExport(src_exports, require("./isMonorepo"), module.exports);
@@ -120,6 +124,8 @@ var register = __toESM(require("./register"));
120
124
  __reExport(src_exports, require("./setNoDeprecation"), module.exports);
121
125
  __reExport(src_exports, require("./tryPaths"), module.exports);
122
126
  __reExport(src_exports, require("./winPath"), module.exports);
127
+ __reExport(src_exports, require("./zod/isZodSchema"), module.exports);
128
+ __reExport(src_exports, require("./zod/zod2string"), module.exports);
123
129
  // Annotate the CommonJS export names for ESM import in node:
124
130
  0 && (module.exports = {
125
131
  BaseGenerator,
@@ -142,6 +148,7 @@ __reExport(src_exports, require("./winPath"), module.exports);
142
148
  fsExtra,
143
149
  generateFile,
144
150
  getGitInfo,
151
+ git,
145
152
  glob,
146
153
  gzipSize,
147
154
  installDeps,
@@ -159,5 +166,6 @@ __reExport(src_exports, require("./winPath"), module.exports);
159
166
  stripAnsi,
160
167
  tsconfigPaths,
161
168
  updatePackageJSON,
162
- yParser
169
+ yParser,
170
+ zod
163
171
  });
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/installDeps.ts
@@ -43,18 +40,15 @@ function installDeps({
43
40
  const devTag = useYarn || usePnpm ? "--D" : "--save-dev";
44
41
  const installDependencies = (deps, npmStr, insStr, devStr) => {
45
42
  console.log(`${npmStr} install dependencies packages:${deps.join(" ")}`);
46
- execa.execaCommandSync(
47
- [npmStr, insStr, devStr].concat(deps).filter((n) => n).join(" "),
48
- {
49
- encoding: "utf8",
50
- cwd,
51
- env: {
52
- ...process.env
53
- },
54
- stderr: "pipe",
55
- stdout: "pipe"
56
- }
57
- );
43
+ execa.execaCommandSync([npmStr, insStr, devStr].concat(deps).filter((n) => n).join(" "), {
44
+ encoding: "utf8",
45
+ cwd,
46
+ env: {
47
+ ...process.env
48
+ },
49
+ stderr: "pipe",
50
+ stdout: "pipe"
51
+ });
58
52
  console.log(`install dependencies packages success`);
59
53
  };
60
54
  if (dependencies) {
package/dist/npmClient.js CHANGED
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
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.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
package/dist/printHelp.js CHANGED
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/printHelp.ts
@@ -36,9 +33,7 @@ function exit() {
36
33
  logger.fatal("A complete log of this run can be found in:");
37
34
  logger.fatal(loggerPath);
38
35
  }
39
- logger.fatal(
40
- "Consider reporting a GitHub issue on https://github.com/umijs/umi/issues"
41
- );
36
+ logger.fatal("Consider reporting a GitHub issue on https://github.com/umijs/umi/issues");
42
37
  }
43
38
  function runtime(e) {
44
39
  logger.error(e);
@@ -16,10 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
23
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
21
 
25
22
  // src/randomColor/randomColor.ts
package/dist/register.js CHANGED
@@ -42,6 +42,8 @@ function transform(opts) {
42
42
  return implementor.transformSync(code, {
43
43
  sourcefile: filename,
44
44
  loader: ext.slice(1),
45
+ // consistent with `tsconfig.base.json`
46
+ // https://github.com/umijs/umi-next/pull/729
45
47
  target: "es2019",
46
48
  format: "cjs",
47
49
  logLevel: "error"
@@ -0,0 +1,2 @@
1
+ import { z } from '../../compiled/zod';
2
+ export declare function isZodSchema<T extends z.ZodType<any>>(schema: T): boolean;
@@ -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/zod/isZodSchema.ts
20
+ var isZodSchema_exports = {};
21
+ __export(isZodSchema_exports, {
22
+ isZodSchema: () => isZodSchema
23
+ });
24
+ module.exports = __toCommonJS(isZodSchema_exports);
25
+ function isZodSchema(schema) {
26
+ return "safeParse" in schema;
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ isZodSchema
31
+ });
@@ -0,0 +1,2 @@
1
+ import { z } from '../../compiled/zod';
2
+ export declare function zod2string<T extends z.ZodType<any>>(schema: T): string;
@@ -0,0 +1,49 @@
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/zod/zod2string.ts
20
+ var zod2string_exports = {};
21
+ __export(zod2string_exports, {
22
+ zod2string: () => zod2string
23
+ });
24
+ module.exports = __toCommonJS(zod2string_exports);
25
+ var import_zod = require("../../compiled/zod");
26
+ function zod2string(schema) {
27
+ if (schema instanceof import_zod.z.ZodObject) {
28
+ const keys = Object.keys(schema.shape);
29
+ const properties = keys.map((key) => `${key}: ${zod2string(schema.shape[key])}`).join(", ");
30
+ return `z.object({${properties}})`;
31
+ } else if (schema instanceof import_zod.z.ZodArray) {
32
+ return `z.array(${zod2string(schema._def.type)})`;
33
+ } else if (schema instanceof import_zod.z.ZodOptional) {
34
+ return `z.optional(${zod2string(schema._def.innerType)})`;
35
+ } else {
36
+ const { typeName, checks } = schema._def;
37
+ let str = `z.${typeName.replace("Zod", "").toLowerCase()}()`;
38
+ if (checks && checks.length > 0) {
39
+ checks.forEach((i) => {
40
+ str += `.${i.kind}(${(i == null ? void 0 : i.value) || ""})`;
41
+ });
42
+ }
43
+ return str;
44
+ }
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ zod2string
49
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/utils",
3
- "version": "4.0.56",
3
+ "version": "4.0.58",
4
4
  "homepage": "https://github.com/umijs/umi/tree/master/packages/utils#readme",
5
5
  "bugs": "https://github.com/umijs/umi/issues",
6
6
  "repository": {
@@ -14,12 +14,6 @@
14
14
  "dist",
15
15
  "compiled"
16
16
  ],
17
- "scripts": {
18
- "build": "umi-scripts father build",
19
- "build:deps": "umi-scripts bundleDeps",
20
- "dev": "umi-scripts father dev",
21
- "test": "umi-scripts jest-turbo"
22
- },
23
17
  "dependencies": {
24
18
  "chokidar": "3.5.3",
25
19
  "pino": "7.11.0"
@@ -67,7 +61,8 @@
67
61
  "semver": "7.3.8",
68
62
  "strip-ansi": "7.0.1",
69
63
  "tsconfig-paths": "4.1.2",
70
- "yargs-parser": "21.1.1"
64
+ "yargs-parser": "21.1.1",
65
+ "zod": "3.20.6"
71
66
  },
72
67
  "publishConfig": {
73
68
  "access": "public"
@@ -105,7 +100,8 @@
105
100
  "@clack/prompts",
106
101
  "magic-string",
107
102
  "@ampproject/remapping",
108
- "tsconfig-paths"
103
+ "tsconfig-paths",
104
+ "zod"
109
105
  ],
110
106
  "externals": {
111
107
  "address": "$$LOCAL",
@@ -130,5 +126,11 @@
130
126
  "@hapi/joi": "$$LOCAL",
131
127
  "tsconfig-paths": "$$LOCAL"
132
128
  }
129
+ },
130
+ "scripts": {
131
+ "build": "umi-scripts father build",
132
+ "build:deps": "umi-scripts bundleDeps",
133
+ "dev": "umi-scripts father dev",
134
+ "test": "umi-scripts jest-turbo"
133
135
  }
134
- }
136
+ }