@umijs/utils 4.2.6-alpha.6 → 4.2.6
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/dist/BaseGenerator/BaseGenerator.d.ts +18 -0
- package/dist/BaseGenerator/BaseGenerator.js +82 -0
- package/dist/BaseGenerator/generateFile.d.ts +9 -0
- package/dist/BaseGenerator/generateFile.js +52 -0
- package/dist/Generator/Generator.d.ts +29 -0
- package/dist/Generator/Generator.js +101 -0
- 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.d.ts +6 -0
- package/dist/importLazy.js +45 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +187 -0
- package/dist/installDeps.d.ts +9 -0
- package/dist/installDeps.js +71 -0
- 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 +21 -0
- package/dist/logger.js +180 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.js +61 -0
- package/dist/npmClient.d.ts +16 -0
- package/dist/npmClient.js +89 -0
- package/dist/printHelp.d.ts +2 -0
- package/dist/printHelp.js +64 -0
- package/dist/randomColor/randomColor.d.ts +6 -0
- package/dist/randomColor/randomColor.js +50 -0
- package/dist/readDirFiles.d.ts +9 -0
- package/dist/readDirFiles.js +62 -0
- package/dist/register.d.ts +7 -0
- package/dist/register.js +85 -0
- 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.d.ts +5 -0
- package/dist/updatePackageJSON.js +52 -0
- package/dist/winPath.d.ts +1 -0
- package/dist/winPath.js +35 -0
- package/dist/zod/isZodSchema.d.ts +2 -0
- package/dist/zod/isZodSchema.js +31 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import prompts from '../../compiled/prompts';
|
|
2
|
+
import Generator, { type IGeneratorOpts } from '../Generator/Generator';
|
|
3
|
+
interface IBaseGeneratorOpts extends Partial<Omit<IGeneratorOpts, 'args'>> {
|
|
4
|
+
path: string;
|
|
5
|
+
target: string;
|
|
6
|
+
data?: any;
|
|
7
|
+
questions?: prompts.PromptObject[];
|
|
8
|
+
}
|
|
9
|
+
export default class BaseGenerator extends Generator {
|
|
10
|
+
path: string;
|
|
11
|
+
target: string;
|
|
12
|
+
data: any;
|
|
13
|
+
questions: prompts.PromptObject[];
|
|
14
|
+
constructor({ path, target, data, questions, baseDir, slient, }: IBaseGeneratorOpts);
|
|
15
|
+
prompting(): prompts.PromptObject<string>[];
|
|
16
|
+
writing(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
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/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
|
|
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
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import prompts from '../../compiled/prompts';
|
|
2
|
+
declare const generateFile: ({ path, target, baseDir, data, questions, }: {
|
|
3
|
+
path: string;
|
|
4
|
+
target: string;
|
|
5
|
+
baseDir?: string | undefined;
|
|
6
|
+
data?: any;
|
|
7
|
+
questions?: prompts.PromptObject<string>[] | undefined;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
export default generateFile;
|
|
@@ -0,0 +1,52 @@
|
|
|
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/BaseGenerator/generateFile.ts
|
|
30
|
+
var generateFile_exports = {};
|
|
31
|
+
__export(generateFile_exports, {
|
|
32
|
+
default: () => generateFile_default
|
|
33
|
+
});
|
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import yParser from '../../compiled/yargs-parser';
|
|
2
|
+
export interface IGeneratorOpts {
|
|
3
|
+
baseDir: string;
|
|
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;
|
|
16
|
+
}
|
|
17
|
+
declare class Generator {
|
|
18
|
+
baseDir: string;
|
|
19
|
+
args: yParser.Arguments;
|
|
20
|
+
slient: boolean;
|
|
21
|
+
prompts: any;
|
|
22
|
+
constructor({ baseDir, args, slient }: IGeneratorOpts);
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
prompting(): any;
|
|
25
|
+
writing(): Promise<void>;
|
|
26
|
+
copyTpl(opts: IGeneratorCopyTplOpts): void;
|
|
27
|
+
copyDirectory(opts: IGeneratorCopyDirectoryOpts): void;
|
|
28
|
+
}
|
|
29
|
+
export default Generator;
|
|
@@ -0,0 +1,101 @@
|
|
|
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/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
|
+
);
|
|
71
|
+
}
|
|
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
|
|
89
|
+
});
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCorejsVersion: (pkgPath: string) => any;
|
|
@@ -0,0 +1,35 @@
|
|
|
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/getCorejsVersion.ts
|
|
20
|
+
var getCorejsVersion_exports = {};
|
|
21
|
+
__export(getCorejsVersion_exports, {
|
|
22
|
+
getCorejsVersion: () => getCorejsVersion
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getCorejsVersion_exports);
|
|
25
|
+
var import_fs_extra = require("../compiled/fs-extra");
|
|
26
|
+
var getCorejsVersion = (pkgPath) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const pkg = (0, import_fs_extra.readJsonSync)(pkgPath, { encoding: "utf-8" });
|
|
29
|
+
const version = ((_a = pkg.dependencies["core-js"]) == null ? void 0 : _a.split(".").slice(0, 2).join(".")) || "3";
|
|
30
|
+
return version;
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
getCorejsVersion
|
|
35
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
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/getDevBanner.ts
|
|
30
|
+
var getDevBanner_exports = {};
|
|
31
|
+
__export(getDevBanner_exports, {
|
|
32
|
+
getDevBanner: () => getDevBanner
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(getDevBanner_exports);
|
|
35
|
+
var import_address = __toESM(require("../compiled/address"));
|
|
36
|
+
var import_chalk = __toESM(require("../compiled/chalk"));
|
|
37
|
+
var import_strip_ansi = __toESM(require("../compiled/strip-ansi"));
|
|
38
|
+
var BORDERS = {
|
|
39
|
+
TL: import_chalk.default.gray.dim("╔"),
|
|
40
|
+
TR: import_chalk.default.gray.dim("╗"),
|
|
41
|
+
BL: import_chalk.default.gray.dim("╚"),
|
|
42
|
+
BR: import_chalk.default.gray.dim("╝"),
|
|
43
|
+
V: import_chalk.default.gray.dim("║"),
|
|
44
|
+
H_PURE: "═"
|
|
45
|
+
};
|
|
46
|
+
function getDevBanner(protocol, host = "0.0.0.0", port, offset = 8) {
|
|
47
|
+
const header = " App listening at:";
|
|
48
|
+
const footer = import_chalk.default.bold(
|
|
49
|
+
" Now you can open browser with the above addresses↑ "
|
|
50
|
+
);
|
|
51
|
+
const local = ` ${import_chalk.default.gray(">")} Local: ${import_chalk.default.green(
|
|
52
|
+
`${protocol}//${host === "0.0.0.0" ? "localhost" : host}:${port}`
|
|
53
|
+
)} `;
|
|
54
|
+
const ip = import_address.default.ip();
|
|
55
|
+
const network = ` ${import_chalk.default.gray(">")} Network: ${ip ? import_chalk.default.green(`${protocol}//${ip}:${port}`) : import_chalk.default.gray("Not available")} `;
|
|
56
|
+
const maxLen = Math.max(
|
|
57
|
+
...[header, footer, local, network].map((x) => (0, import_strip_ansi.default)(x).length)
|
|
58
|
+
);
|
|
59
|
+
const beforeLines = [
|
|
60
|
+
`${BORDERS.TL}${import_chalk.default.gray.dim("".padStart(maxLen, BORDERS.H_PURE))}${BORDERS.TR}`,
|
|
61
|
+
`${BORDERS.V}${header}${"".padStart(maxLen - header.length)}${BORDERS.V}`,
|
|
62
|
+
`${BORDERS.V}${local}${"".padStart(maxLen - (0, import_strip_ansi.default)(local).length)}${BORDERS.V}`
|
|
63
|
+
];
|
|
64
|
+
const mainLine = `${BORDERS.V}${network}${"".padStart(
|
|
65
|
+
maxLen - (0, import_strip_ansi.default)(network).length
|
|
66
|
+
)}${BORDERS.V}`;
|
|
67
|
+
const afterLines = [
|
|
68
|
+
`${BORDERS.V}${"".padStart(maxLen)}${BORDERS.V}`,
|
|
69
|
+
`${BORDERS.V}${footer}${"".padStart(maxLen - (0, import_strip_ansi.default)(footer).length)}${BORDERS.V}`,
|
|
70
|
+
`${BORDERS.BL}${import_chalk.default.gray.dim("".padStart(maxLen, BORDERS.H_PURE))}${BORDERS.BR}`
|
|
71
|
+
];
|
|
72
|
+
return {
|
|
73
|
+
before: beforeLines.map((l) => l.padStart(l.length + offset)).join("\n"),
|
|
74
|
+
main: mainLine,
|
|
75
|
+
after: afterLines.map((l) => l.padStart(l.length + offset)).join("\n")
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
getDevBanner
|
|
81
|
+
});
|
|
@@ -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>;
|