@umijs/utils 4.0.57 → 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.
- 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/dist/getFileGitIno.d.ts +47 -0
- package/dist/getFileGitIno.js +130 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/package.json +8 -8
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ import updatePackageJSON from './updatePackageJSON';
|
|
|
38
38
|
export * as aliasUtils from './aliasUtils';
|
|
39
39
|
export * from './getCorejsVersion';
|
|
40
40
|
export * from './getDevBanner';
|
|
41
|
+
export * as git from './getFileGitIno';
|
|
41
42
|
export * from './importLazy';
|
|
42
43
|
export * from './isLocalDev';
|
|
43
44
|
export * from './isMonorepo';
|
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,
|
|
@@ -111,6 +112,7 @@ var import_updatePackageJSON = __toESM(require("./updatePackageJSON"));
|
|
|
111
112
|
var aliasUtils = __toESM(require("./aliasUtils"));
|
|
112
113
|
__reExport(src_exports, require("./getCorejsVersion"), module.exports);
|
|
113
114
|
__reExport(src_exports, require("./getDevBanner"), module.exports);
|
|
115
|
+
var git = __toESM(require("./getFileGitIno"));
|
|
114
116
|
__reExport(src_exports, require("./importLazy"), module.exports);
|
|
115
117
|
__reExport(src_exports, require("./isLocalDev"), module.exports);
|
|
116
118
|
__reExport(src_exports, require("./isMonorepo"), module.exports);
|
|
@@ -146,6 +148,7 @@ __reExport(src_exports, require("./zod/zod2string"), module.exports);
|
|
|
146
148
|
fsExtra,
|
|
147
149
|
generateFile,
|
|
148
150
|
getGitInfo,
|
|
151
|
+
git,
|
|
149
152
|
glob,
|
|
150
153
|
gzipSize,
|
|
151
154
|
installDeps,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/utils",
|
|
3
|
-
"version": "4.0.
|
|
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"
|
|
@@ -132,5 +126,11 @@
|
|
|
132
126
|
"@hapi/joi": "$$LOCAL",
|
|
133
127
|
"tsconfig-paths": "$$LOCAL"
|
|
134
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"
|
|
135
135
|
}
|
|
136
|
-
}
|
|
136
|
+
}
|