@umijs/utils 4.0.0-canary.20230315.1 → 4.0.0-canary.20230315.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.
@@ -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
@@ -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}`,
@@ -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
@@ -51,4 +51,5 @@ export * from './setNoDeprecation';
51
51
  export * from './tryPaths';
52
52
  export * from './winPath';
53
53
  export * from './zod/isZodSchema';
54
+ export * from './zod/zod2string';
54
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
@@ -125,6 +125,7 @@ __reExport(src_exports, require("./setNoDeprecation"), module.exports);
125
125
  __reExport(src_exports, require("./tryPaths"), module.exports);
126
126
  __reExport(src_exports, require("./winPath"), module.exports);
127
127
  __reExport(src_exports, require("./zod/isZodSchema"), module.exports);
128
+ __reExport(src_exports, require("./zod/zod2string"), module.exports);
128
129
  // Annotate the CommonJS export names for ESM import in node:
129
130
  0 && (module.exports = {
130
131
  BaseGenerator,
@@ -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/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
@@ -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.0-canary.20230315.1",
3
+ "version": "4.0.0-canary.20230315.2",
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": {