@umijs/utils 4.0.0-beta.8 → 4.0.0-canary-20240513.3
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/compiled/@ampproject/remapping/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +70 -0
- package/compiled/@ampproject/remapping/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/@ampproject/remapping/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/@ampproject/remapping/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/@ampproject/remapping/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/@ampproject/remapping/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/@ampproject/remapping/LICENSE +202 -0
- package/compiled/@ampproject/remapping/dist/types/remapping.d.ts +19 -0
- package/compiled/@ampproject/remapping/dist/types/source-map.d.ts +17 -0
- package/compiled/@ampproject/remapping/dist/types/types.d.ts +14 -0
- package/compiled/@ampproject/remapping/index.js +1 -0
- package/compiled/@ampproject/remapping/package.json +1 -0
- package/compiled/@clack/prompts/LICENSE +23 -0
- package/compiled/@clack/prompts/dist/index.d.ts +38 -0
- package/compiled/@clack/prompts/index.js +1 -0
- package/compiled/@clack/prompts/package.json +1 -0
- package/compiled/@hapi/joi/index.d.ts +2218 -0
- package/compiled/@hapi/joi/index.js +1 -0
- package/compiled/@hapi/joi/package.json +1 -0
- package/compiled/axios/index.d.ts +29 -14
- package/compiled/axios/index.js +1 -1
- package/compiled/chalk/LICENSE +1 -1
- package/compiled/chalk/index.js +1 -1
- package/compiled/chalk/package.json +1 -1
- package/compiled/chalk/source/index.d.ts +318 -0
- package/compiled/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/compiled/color/color-convert/conversions.d.ts +87 -87
- package/compiled/color/color-convert/index.d.ts +75 -60
- package/compiled/color/color-convert/route.d.ts +271 -271
- package/compiled/color/index.d.ts +118 -121
- package/compiled/color/index.js +1 -1
- package/compiled/color/package.json +1 -4
- package/compiled/debug/LICENSE +10 -9
- package/compiled/debug/index.js +1 -1
- package/compiled/debug/package.json +1 -1
- package/compiled/execa/index.d.ts +467 -445
- package/compiled/execa/index.js +1 -1
- package/compiled/fastest-levenshtein/index.js +1 -0
- package/compiled/fastest-levenshtein/mod.d.ts +3 -0
- package/compiled/fastest-levenshtein/package.json +1 -0
- package/compiled/filesize/LICENSE +28 -0
- package/compiled/filesize/filesize.d.ts +131 -0
- package/compiled/filesize/index.js +8 -0
- package/compiled/filesize/package.json +1 -0
- package/compiled/filesize/types/filesize.d.ts +46 -0
- package/compiled/fs-extra/index.d.ts +930 -253
- package/compiled/fs-extra/index.js +1 -1
- package/compiled/fs-extra/jsonfile/index.d.ts +78 -0
- package/compiled/fs-extra/package.json +1 -1
- package/compiled/glob/LICENSE +1 -7
- package/compiled/glob/index.d.ts +3 -1
- package/compiled/glob/index.js +1 -1
- package/compiled/glob/package.json +1 -1
- package/compiled/gzip-size/LICENSE +9 -0
- package/compiled/gzip-size/index.d.ts +103 -0
- package/compiled/gzip-size/index.js +1 -0
- package/compiled/gzip-size/package.json +1 -0
- package/compiled/lodash/common/array.d.ts +0 -0
- package/compiled/lodash/common/collection.d.ts +0 -0
- package/compiled/lodash/common/common.d.ts +0 -0
- package/compiled/lodash/common/date.d.ts +0 -0
- package/compiled/lodash/common/function.d.ts +0 -0
- package/compiled/lodash/common/lang.d.ts +0 -0
- package/compiled/lodash/common/math.d.ts +0 -0
- package/compiled/lodash/common/number.d.ts +0 -0
- package/compiled/lodash/common/object.d.ts +0 -0
- package/compiled/lodash/common/seq.d.ts +0 -0
- package/compiled/lodash/common/string.d.ts +0 -0
- package/compiled/lodash/common/util.d.ts +0 -0
- package/compiled/magic-string/LICENSE +7 -0
- package/compiled/magic-string/index.d.ts +250 -0
- package/compiled/magic-string/index.js +1 -0
- package/compiled/magic-string/package.json +1 -0
- package/compiled/pirates/LICENSE +21 -0
- package/compiled/pirates/index.d.ts +82 -0
- package/compiled/pirates/index.js +1 -0
- package/compiled/pirates/package.json +1 -0
- package/compiled/pkg-up/LICENSE +1 -1
- package/compiled/pkg-up/index.d.ts +55 -44
- package/compiled/pkg-up/index.js +1 -1
- package/compiled/pkg-up/package.json +1 -1
- package/compiled/portfinder/index.js +1 -1
- package/compiled/portfinder/lib/portfinder.d.ts +16 -1
- package/compiled/portfinder/package.json +1 -1
- package/compiled/prettier/index.d.ts +568 -679
- package/compiled/prettier/index.js +62 -274
- package/compiled/prettier/package.json +1 -5
- package/compiled/resolve/index.js +1 -1
- package/compiled/semver/classes/range.d.ts +1 -1
- package/compiled/semver/classes/semver.d.ts +1 -1
- package/compiled/semver/functions/compare-build.d.ts +6 -1
- package/compiled/semver/functions/diff.d.ts +1 -5
- package/compiled/semver/functions/satisfies.d.ts +1 -1
- package/compiled/semver/index.d.ts +3 -0
- package/compiled/semver/index.js +1 -1
- package/compiled/semver/package.json +1 -1
- package/compiled/semver/ranges/gtr.d.ts +1 -1
- package/compiled/semver/ranges/intersects.d.ts +1 -1
- package/compiled/semver/ranges/ltr.d.ts +1 -1
- package/compiled/semver/ranges/max-satisfying.d.ts +1 -1
- package/compiled/semver/ranges/min-satisfying.d.ts +1 -1
- package/compiled/semver/ranges/outside.d.ts +1 -1
- package/compiled/semver/ranges/subset.d.ts +1 -5
- package/compiled/semver/ranges/valid.d.ts +1 -1
- package/compiled/strip-ansi/LICENSE +1 -1
- package/compiled/strip-ansi/index.d.ts +2 -4
- package/compiled/strip-ansi/index.js +1 -1
- package/compiled/strip-ansi/package.json +1 -1
- package/compiled/tar/LICENSE +15 -0
- package/compiled/tar/index.d.ts +943 -0
- package/compiled/tar/index.js +1 -0
- package/compiled/tar/minipass/index.d.ts +150 -0
- package/compiled/tar/package.json +1 -0
- package/compiled/tsconfig-paths/LICENSE +21 -0
- package/compiled/tsconfig-paths/index.js +1 -0
- package/compiled/tsconfig-paths/lib/index.d.ts +5 -0
- package/compiled/tsconfig-paths/package.json +1 -0
- package/compiled/yargs-parser/index.js +1 -1
- package/compiled/yargs-parser/package.json +1 -1
- package/compiled/zod/LICENSE +21 -0
- package/compiled/zod/index.d.ts +2 -0
- package/compiled/zod/index.js +1 -0
- package/compiled/zod/lib/ZodError.d.ts +159 -0
- package/compiled/zod/lib/__tests__/Mocker.d.ts +17 -0
- package/compiled/zod/lib/benchmarks/discriminatedUnion.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/index.d.ts +1 -0
- package/compiled/zod/lib/benchmarks/object.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/primitives.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/realworld.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/string.d.ts +5 -0
- package/compiled/zod/lib/benchmarks/union.d.ts +5 -0
- package/compiled/zod/lib/errors.d.ts +5 -0
- package/compiled/zod/lib/external.d.ts +6 -0
- package/compiled/zod/lib/helpers/enumUtil.d.ts +8 -0
- package/compiled/zod/lib/helpers/errorUtil.d.ts +9 -0
- package/compiled/zod/lib/helpers/parseUtil.d.ts +78 -0
- package/compiled/zod/lib/helpers/partialUtil.d.ts +8 -0
- package/compiled/zod/lib/helpers/typeAliases.d.ts +2 -0
- package/compiled/zod/lib/helpers/util.d.ts +47 -0
- package/compiled/zod/lib/index.d.ts +4 -0
- package/compiled/zod/lib/locales/en.d.ts +3 -0
- package/compiled/zod/lib/types.d.ts +975 -0
- package/compiled/zod/package.json +1 -0
- package/dist/BaseGenerator/BaseGenerator.d.ts +3 -3
- package/dist/BaseGenerator/BaseGenerator.js +78 -54
- package/dist/BaseGenerator/generateFile.d.ts +2 -1
- package/dist/BaseGenerator/generateFile.js +49 -22
- package/dist/Generator/Generator.d.ts +18 -14
- package/dist/Generator/Generator.js +97 -70
- package/dist/aliasUtils/getAliasValue.d.ts +4 -0
- package/dist/aliasUtils/getAliasValue.js +66 -0
- package/dist/aliasUtils/index.d.ts +2 -0
- package/dist/aliasUtils/index.js +32 -0
- package/dist/aliasUtils/parseCircleAlias.d.ts +4 -0
- package/dist/aliasUtils/parseCircleAlias.js +66 -0
- package/dist/getCorejsVersion.d.ts +1 -0
- package/dist/getCorejsVersion.js +35 -0
- package/dist/getDevBanner.d.ts +5 -0
- package/dist/getDevBanner.js +81 -0
- package/dist/getFileGitIno.d.ts +47 -0
- package/dist/getFileGitIno.js +130 -0
- package/dist/getGitInfo.d.ts +6 -0
- package/dist/getGitInfo.js +50 -0
- package/dist/importLazy.js +42 -14
- package/dist/index.d.ts +26 -3
- package/dist/index.js +185 -86
- package/dist/installDeps.js +69 -37
- package/dist/isJavaScriptFile.d.ts +1 -0
- package/dist/isJavaScriptFile.js +32 -0
- package/dist/isLocalDev.d.ts +4 -0
- package/dist/isLocalDev.js +36 -0
- package/dist/isMonorepo.d.ts +5 -0
- package/dist/isMonorepo.js +44 -0
- package/dist/isStyleFile.d.ts +5 -0
- package/dist/isStyleFile.js +44 -0
- package/dist/logger.d.ts +13 -6
- package/dist/logger.js +166 -25
- package/dist/node.d.ts +4 -0
- package/dist/node.js +61 -0
- package/dist/npmClient.d.ts +3 -2
- package/dist/npmClient.js +86 -40
- package/dist/printHelp.d.ts +2 -0
- package/dist/printHelp.js +64 -0
- package/dist/randomColor/randomColor.js +47 -16
- package/dist/readDirFiles.d.ts +9 -0
- package/dist/readDirFiles.js +62 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +75 -37
- package/dist/setNoDeprecation.d.ts +1 -0
- package/dist/setNoDeprecation.js +31 -0
- package/dist/tryPaths.d.ts +1 -0
- package/dist/tryPaths.js +35 -0
- package/dist/updatePackageJSON.js +50 -19
- package/dist/winPath.js +33 -9
- package/dist/zod/isZodSchema.d.ts +2 -0
- package/dist/zod/isZodSchema.js +31 -0
- package/package.json +70 -44
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"zod","version":"3.20.6","author":"Colin McDonnell <colin@colinhacks.com>","license":"MIT","types":"./index.d.ts"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import prompts from '../../compiled/prompts';
|
|
2
|
-
import Generator from '../Generator/Generator';
|
|
3
|
-
interface
|
|
2
|
+
import Generator, { type IGeneratorOpts } from '../Generator/Generator';
|
|
3
|
+
interface IBaseGeneratorOpts extends Partial<Omit<IGeneratorOpts, 'args'>> {
|
|
4
4
|
path: string;
|
|
5
5
|
target: string;
|
|
6
6
|
data?: any;
|
|
@@ -11,7 +11,7 @@ export default class BaseGenerator extends Generator {
|
|
|
11
11
|
target: string;
|
|
12
12
|
data: any;
|
|
13
13
|
questions: prompts.PromptObject[];
|
|
14
|
-
constructor({ path, target, data, questions }:
|
|
14
|
+
constructor({ path, target, data, questions, baseDir, slient, }: IBaseGeneratorOpts);
|
|
15
15
|
prompting(): prompts.PromptObject<string>[];
|
|
16
16
|
writing(): Promise<void>;
|
|
17
17
|
}
|
|
@@ -1,58 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
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
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
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;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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/BaseGenerator/BaseGenerator.ts
|
|
30
|
+
var BaseGenerator_exports = {};
|
|
31
|
+
__export(BaseGenerator_exports, {
|
|
32
|
+
default: () => BaseGenerator
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(BaseGenerator_exports);
|
|
35
|
+
var import_fs = require("fs");
|
|
36
|
+
var import_path = require("path");
|
|
37
|
+
var import_fs_extra = __toESM(require("../../compiled/fs-extra"));
|
|
38
|
+
var import_Generator = __toESM(require("../Generator/Generator"));
|
|
39
|
+
var BaseGenerator = class extends import_Generator.default {
|
|
40
|
+
constructor({
|
|
41
|
+
path,
|
|
42
|
+
target,
|
|
43
|
+
data,
|
|
44
|
+
questions,
|
|
45
|
+
baseDir,
|
|
46
|
+
slient
|
|
47
|
+
}) {
|
|
48
|
+
super({ baseDir: baseDir || target, args: data, slient });
|
|
49
|
+
this.path = path;
|
|
50
|
+
this.target = target;
|
|
51
|
+
this.data = data;
|
|
52
|
+
this.questions = questions || [];
|
|
53
|
+
}
|
|
54
|
+
prompting() {
|
|
55
|
+
return this.questions;
|
|
56
|
+
}
|
|
57
|
+
async writing() {
|
|
58
|
+
const context = {
|
|
59
|
+
...this.data,
|
|
60
|
+
...this.prompts
|
|
61
|
+
};
|
|
62
|
+
if ((0, import_fs.statSync)(this.path).isDirectory()) {
|
|
63
|
+
this.copyDirectory({
|
|
64
|
+
context,
|
|
65
|
+
path: this.path,
|
|
66
|
+
target: this.target
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
if (this.path.endsWith(".tpl")) {
|
|
70
|
+
this.copyTpl({
|
|
71
|
+
templatePath: this.path,
|
|
72
|
+
target: this.target,
|
|
73
|
+
context
|
|
55
74
|
});
|
|
75
|
+
} else {
|
|
76
|
+
const absTarget = this.target;
|
|
77
|
+
import_fs_extra.default.mkdirpSync((0, import_path.dirname)(absTarget));
|
|
78
|
+
(0, import_fs.copyFileSync)(this.path, absTarget);
|
|
79
|
+
}
|
|
56
80
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import prompts from '../../compiled/prompts';
|
|
2
|
-
declare const generateFile: ({ path, target, data, questions, }: {
|
|
2
|
+
declare const generateFile: ({ path, target, baseDir, data, questions, }: {
|
|
3
3
|
path: string;
|
|
4
4
|
target: string;
|
|
5
|
+
baseDir?: string | undefined;
|
|
5
6
|
data?: any;
|
|
6
7
|
questions?: prompts.PromptObject<string>[] | undefined;
|
|
7
8
|
}) => Promise<void>;
|
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
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
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
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;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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/BaseGenerator/generateFile.ts
|
|
30
|
+
var generateFile_exports = {};
|
|
31
|
+
__export(generateFile_exports, {
|
|
32
|
+
default: () => generateFile_default
|
|
24
33
|
});
|
|
25
|
-
exports
|
|
34
|
+
module.exports = __toCommonJS(generateFile_exports);
|
|
35
|
+
var import_BaseGenerator = __toESM(require("./BaseGenerator"));
|
|
36
|
+
var generateFile = async ({
|
|
37
|
+
path,
|
|
38
|
+
target,
|
|
39
|
+
baseDir,
|
|
40
|
+
data,
|
|
41
|
+
questions
|
|
42
|
+
}) => {
|
|
43
|
+
const generator = new import_BaseGenerator.default({
|
|
44
|
+
path,
|
|
45
|
+
target,
|
|
46
|
+
baseDir,
|
|
47
|
+
data,
|
|
48
|
+
questions
|
|
49
|
+
});
|
|
50
|
+
await generator.run();
|
|
51
|
+
};
|
|
52
|
+
var generateFile_default = generateFile;
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import yParser from '../../compiled/yargs-parser';
|
|
2
|
-
interface
|
|
3
|
-
|
|
2
|
+
export interface IGeneratorOpts {
|
|
3
|
+
baseDir: string;
|
|
4
4
|
args: yParser.Arguments;
|
|
5
|
+
slient?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface IGeneratorBaseOpts {
|
|
8
|
+
context: Record<string, any>;
|
|
9
|
+
target: string;
|
|
10
|
+
}
|
|
11
|
+
interface IGeneratorCopyTplOpts extends IGeneratorBaseOpts {
|
|
12
|
+
templatePath: string;
|
|
13
|
+
}
|
|
14
|
+
interface IGeneratorCopyDirectoryOpts extends IGeneratorBaseOpts {
|
|
15
|
+
path: string;
|
|
5
16
|
}
|
|
6
17
|
declare class Generator {
|
|
7
|
-
|
|
18
|
+
baseDir: string;
|
|
8
19
|
args: yParser.Arguments;
|
|
20
|
+
slient: boolean;
|
|
9
21
|
prompts: any;
|
|
10
|
-
constructor({
|
|
22
|
+
constructor({ baseDir, args, slient }: IGeneratorOpts);
|
|
11
23
|
run(): Promise<void>;
|
|
12
24
|
prompting(): any;
|
|
13
25
|
writing(): Promise<void>;
|
|
14
|
-
copyTpl(opts:
|
|
15
|
-
|
|
16
|
-
target: string;
|
|
17
|
-
context: object;
|
|
18
|
-
}): void;
|
|
19
|
-
copyDirectory(opts: {
|
|
20
|
-
path: string;
|
|
21
|
-
context: object;
|
|
22
|
-
target: string;
|
|
23
|
-
}): void;
|
|
26
|
+
copyTpl(opts: IGeneratorCopyTplOpts): void;
|
|
27
|
+
copyDirectory(opts: IGeneratorCopyDirectoryOpts): void;
|
|
24
28
|
}
|
|
25
29
|
export default Generator;
|
|
@@ -1,74 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
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
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
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;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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/Generator/Generator.ts
|
|
30
|
+
var Generator_exports = {};
|
|
31
|
+
__export(Generator_exports, {
|
|
32
|
+
default: () => Generator_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Generator_exports);
|
|
35
|
+
var import_fs = require("fs");
|
|
36
|
+
var import_path = require("path");
|
|
37
|
+
var import_chalk = __toESM(require("../../compiled/chalk"));
|
|
38
|
+
var import_fs_extra = __toESM(require("../../compiled/fs-extra"));
|
|
39
|
+
var import_glob = __toESM(require("../../compiled/glob"));
|
|
40
|
+
var import_mustache = __toESM(require("../../compiled/mustache"));
|
|
41
|
+
var import_prompts = __toESM(require("../../compiled/prompts"));
|
|
42
|
+
var Generator = class {
|
|
43
|
+
constructor({ baseDir, args, slient }) {
|
|
44
|
+
this.baseDir = baseDir;
|
|
45
|
+
this.args = args;
|
|
46
|
+
this.slient = !!slient;
|
|
47
|
+
this.prompts = {};
|
|
48
|
+
}
|
|
49
|
+
async run() {
|
|
50
|
+
const questions = this.prompting();
|
|
51
|
+
this.prompts = await (0, import_prompts.default)(questions, {
|
|
52
|
+
onCancel() {
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
await this.writing();
|
|
57
|
+
}
|
|
58
|
+
prompting() {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
async writing() {
|
|
62
|
+
}
|
|
63
|
+
copyTpl(opts) {
|
|
64
|
+
const tpl = (0, import_fs.readFileSync)(opts.templatePath, "utf-8");
|
|
65
|
+
const content = import_mustache.default.render(tpl, opts.context);
|
|
66
|
+
import_fs_extra.default.mkdirpSync((0, import_path.dirname)(opts.target));
|
|
67
|
+
if (!this.slient) {
|
|
68
|
+
console.log(
|
|
69
|
+
`${import_chalk.default.green("Write:")} ${(0, import_path.relative)(this.baseDir, opts.target)}`
|
|
70
|
+
);
|
|
47
71
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
else {
|
|
66
|
-
console.log(`${chalk_1.default.green('Copy: ')} ${file}`);
|
|
67
|
-
const absTarget = (0, path_1.join)(opts.target, file);
|
|
68
|
-
fs_extra_1.default.mkdirpSync((0, path_1.dirname)(absTarget));
|
|
69
|
-
(0, fs_1.copyFileSync)(absFile, absTarget);
|
|
70
|
-
}
|
|
72
|
+
(0, import_fs.writeFileSync)(opts.target, content, "utf-8");
|
|
73
|
+
}
|
|
74
|
+
copyDirectory(opts) {
|
|
75
|
+
const files = import_glob.default.sync("**/*", {
|
|
76
|
+
cwd: opts.path,
|
|
77
|
+
dot: true,
|
|
78
|
+
ignore: ["**/node_modules/**"]
|
|
79
|
+
});
|
|
80
|
+
files.forEach((file) => {
|
|
81
|
+
const absFile = (0, import_path.join)(opts.path, file);
|
|
82
|
+
if ((0, import_fs.statSync)(absFile).isDirectory())
|
|
83
|
+
return;
|
|
84
|
+
if (file.endsWith(".tpl")) {
|
|
85
|
+
this.copyTpl({
|
|
86
|
+
templatePath: absFile,
|
|
87
|
+
target: (0, import_path.join)(opts.target, file.replace(/\.tpl$/, "")),
|
|
88
|
+
context: opts.context
|
|
71
89
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
} else {
|
|
91
|
+
if (!this.slient) {
|
|
92
|
+
console.log(`${import_chalk.default.green("Copy: ")} ${file}`);
|
|
93
|
+
}
|
|
94
|
+
const absTarget = (0, import_path.join)(opts.target, file);
|
|
95
|
+
import_fs_extra.default.mkdirpSync((0, import_path.dirname)(absTarget));
|
|
96
|
+
(0, import_fs.copyFileSync)(absFile, absTarget);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var Generator_default = Generator;
|
|
@@ -0,0 +1,66 @@
|
|
|
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/aliasUtils/getAliasValue.ts
|
|
30
|
+
var getAliasValue_exports = {};
|
|
31
|
+
__export(getAliasValue_exports, {
|
|
32
|
+
getAliasValue: () => getAliasValue
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(getAliasValue_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
function getAliasValue(opts) {
|
|
37
|
+
const { imported, alias } = opts;
|
|
38
|
+
if (alias[imported]) {
|
|
39
|
+
return alias[imported];
|
|
40
|
+
}
|
|
41
|
+
for (const key of Object.keys(alias)) {
|
|
42
|
+
const value = alias[key];
|
|
43
|
+
if (key.endsWith("$")) {
|
|
44
|
+
if (imported === key.slice(0, -1)) {
|
|
45
|
+
return value;
|
|
46
|
+
} else {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const keyWithLastSlash = addLastSlash(key);
|
|
51
|
+
if (imported.startsWith(keyWithLastSlash)) {
|
|
52
|
+
const isWinPath = process.platform === "win32" && value.includes(import_path.default.sep);
|
|
53
|
+
if (isWinPath) {
|
|
54
|
+
return import_path.default.join(value, imported.slice(keyWithLastSlash.length));
|
|
55
|
+
}
|
|
56
|
+
return imported.replace(keyWithLastSlash, addLastSlash(value));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function addLastSlash(value) {
|
|
61
|
+
return value.endsWith("/") ? value : `${value}/`;
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
getAliasValue
|
|
66
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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/aliasUtils/index.ts
|
|
20
|
+
var aliasUtils_exports = {};
|
|
21
|
+
__export(aliasUtils_exports, {
|
|
22
|
+
getAliasValue: () => import_getAliasValue.getAliasValue,
|
|
23
|
+
parseCircleAlias: () => import_parseCircleAlias.parseCircleAlias
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(aliasUtils_exports);
|
|
26
|
+
var import_getAliasValue = require("./getAliasValue");
|
|
27
|
+
var import_parseCircleAlias = require("./parseCircleAlias");
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
getAliasValue,
|
|
31
|
+
parseCircleAlias
|
|
32
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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/aliasUtils/parseCircleAlias.ts
|
|
20
|
+
var parseCircleAlias_exports = {};
|
|
21
|
+
__export(parseCircleAlias_exports, {
|
|
22
|
+
parseCircleAlias: () => parseCircleAlias
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(parseCircleAlias_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_fs_extra = require("../../compiled/fs-extra");
|
|
27
|
+
var import_getAliasValue = require("./getAliasValue");
|
|
28
|
+
var DEFAULT_MAX_DEPTH = 5;
|
|
29
|
+
var parseCircleAlias = (opts) => {
|
|
30
|
+
const { alias, maxDepth = DEFAULT_MAX_DEPTH } = opts;
|
|
31
|
+
const isExist = (value) => {
|
|
32
|
+
return value.startsWith(".") || (0, import_path.isAbsolute)(value) || (0, import_fs_extra.existsSync)(value);
|
|
33
|
+
};
|
|
34
|
+
const parsed = {};
|
|
35
|
+
Object.entries(alias).forEach(([key, value]) => {
|
|
36
|
+
if (isExist(value)) {
|
|
37
|
+
parsed[key] = value;
|
|
38
|
+
} else {
|
|
39
|
+
let realPath = value;
|
|
40
|
+
for (let i = 0; i < maxDepth; i++) {
|
|
41
|
+
const deeperPath = (0, import_getAliasValue.getAliasValue)({ imported: realPath, alias });
|
|
42
|
+
if (!deeperPath) {
|
|
43
|
+
parsed[key] = realPath;
|
|
44
|
+
break;
|
|
45
|
+
} else {
|
|
46
|
+
if (isExist(deeperPath)) {
|
|
47
|
+
parsed[key] = deeperPath;
|
|
48
|
+
break;
|
|
49
|
+
} else {
|
|
50
|
+
realPath = deeperPath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (i === maxDepth - 1) {
|
|
54
|
+
throw Error(
|
|
55
|
+
`endless loop detected in resolve alias for '${key}': '${value}', please check your alias config.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return parsed;
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
parseCircleAlias
|
|
66
|
+
});
|