@done-coding/cli-utils 0.8.1 → 0.8.2-alpha.0
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/es/index.mjs +177 -161
- package/package.json +3 -3
- package/types/index.d.ts +75 -25
package/es/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import q from "chalk";
|
|
3
|
-
import
|
|
4
|
-
import m, { existsSync as v, mkdirSync as z, writeFileSync as
|
|
3
|
+
import f from "node:path";
|
|
4
|
+
import m, { existsSync as v, mkdirSync as z, writeFileSync as b, readFileSync as _ } from "node:fs";
|
|
5
5
|
import R from "crypto";
|
|
6
6
|
import Q from "prompts";
|
|
7
7
|
import Z from "yargs";
|
|
@@ -9,17 +9,17 @@ import { hideBin as tt } from "yargs/helpers";
|
|
|
9
9
|
import { execSync as g } from "node:child_process";
|
|
10
10
|
import F from "json5";
|
|
11
11
|
export * from "json5";
|
|
12
|
-
import { default as
|
|
12
|
+
import { default as we } from "json5";
|
|
13
13
|
import et from "lodash.merge";
|
|
14
14
|
import rt from "semver";
|
|
15
15
|
import { tmpdir as st, homedir as nt } from "node:os";
|
|
16
16
|
import { v4 as ot } from "uuid";
|
|
17
|
-
import { v4 as
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
21
|
-
import
|
|
22
|
-
const
|
|
17
|
+
import { v4 as Ne } from "uuid";
|
|
18
|
+
import { default as Le } from "lodash.get";
|
|
19
|
+
import { default as Fe } from "lodash.set";
|
|
20
|
+
import { default as je } from "lodash.curry";
|
|
21
|
+
import E from "pinyin";
|
|
22
|
+
const x = (t) => {
|
|
23
23
|
const e = (...[r, ...n]) => t(q[r](...n));
|
|
24
24
|
return Object.assign(e, {
|
|
25
25
|
/** 成功 */
|
|
@@ -35,20 +35,20 @@ const G = (t) => {
|
|
|
35
35
|
/** 跳过 */
|
|
36
36
|
skip: (...r) => e("gray", ...r)
|
|
37
37
|
});
|
|
38
|
-
}, a =
|
|
38
|
+
}, a = x(console.log), ee = x((t) => t), re = (t, {
|
|
39
39
|
/** 当前目录 */
|
|
40
40
|
currentDir: e = process.cwd(),
|
|
41
41
|
/** 优先找最远的父目录 */
|
|
42
42
|
isFindFarthest: r = !0
|
|
43
43
|
} = {}) => {
|
|
44
|
-
const n =
|
|
44
|
+
const n = f.resolve(e).split(f.sep).map((s, o, c) => c.slice(0, o).concat(s).join(f.sep) || f.sep);
|
|
45
45
|
for (; n.length; ) {
|
|
46
|
-
const s = r ? n.shift() : n.pop(), o =
|
|
46
|
+
const s = r ? n.shift() : n.pop(), o = f.join(s, t);
|
|
47
47
|
if (m.existsSync(o))
|
|
48
48
|
return s;
|
|
49
49
|
}
|
|
50
|
-
},
|
|
51
|
-
function
|
|
50
|
+
}, j = "aes-256-cbc", k = 16, C = "hex", T = ":";
|
|
51
|
+
function U(t) {
|
|
52
52
|
return R.pbkdf2Sync(
|
|
53
53
|
t,
|
|
54
54
|
"done-coding-cli-salt",
|
|
@@ -60,33 +60,33 @@ function j(t) {
|
|
|
60
60
|
"sha256"
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function se({
|
|
64
64
|
text: t,
|
|
65
65
|
secretKey: e
|
|
66
66
|
}) {
|
|
67
67
|
try {
|
|
68
|
-
const r =
|
|
68
|
+
const r = U(e), n = R.randomBytes(k), s = R.createCipheriv(j, r, n);
|
|
69
69
|
let o = s.update(t);
|
|
70
70
|
o = Buffer.concat([o, s.final()]);
|
|
71
71
|
const c = n.toString(C), i = o.toString(C);
|
|
72
|
-
return `${c}${
|
|
72
|
+
return `${c}${T}${i}`;
|
|
73
73
|
} catch (r) {
|
|
74
74
|
return a.error(
|
|
75
75
|
`加密失败: ${r instanceof Error ? r.message : String(r)}`
|
|
76
76
|
), "";
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function ne({
|
|
80
80
|
encryptedText: t,
|
|
81
81
|
secretKey: e
|
|
82
82
|
}) {
|
|
83
83
|
try {
|
|
84
|
-
if (!t.includes(
|
|
84
|
+
if (!t.includes(T))
|
|
85
85
|
return "";
|
|
86
|
-
const r =
|
|
87
|
-
if (n.length !==
|
|
86
|
+
const r = U(e), [n, s] = t.split(T);
|
|
87
|
+
if (n.length !== k * 2)
|
|
88
88
|
return "";
|
|
89
|
-
const o = Buffer.from(n, C), c = Buffer.from(s, C), i = R.createDecipheriv(
|
|
89
|
+
const o = Buffer.from(n, C), c = Buffer.from(s, C), i = R.createDecipheriv(j, r, o);
|
|
90
90
|
let u = i.update(c);
|
|
91
91
|
return u = Buffer.concat([u, i.final()]), u.toString();
|
|
92
92
|
} catch (r) {
|
|
@@ -95,7 +95,7 @@ function re({
|
|
|
95
95
|
), "";
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const I = (...t) => {
|
|
99
99
|
const [e, r = {}] = t;
|
|
100
100
|
return Q(e, {
|
|
101
101
|
onCancel(n) {
|
|
@@ -103,12 +103,24 @@ const U = (...t) => {
|
|
|
103
103
|
},
|
|
104
104
|
...r
|
|
105
105
|
});
|
|
106
|
-
},
|
|
106
|
+
}, oe = async ({
|
|
107
|
+
isMCP: t,
|
|
108
|
+
key: e,
|
|
109
|
+
presetAnswer: r,
|
|
110
|
+
defaultValue: n,
|
|
111
|
+
questionConfig: s
|
|
112
|
+
}) => {
|
|
113
|
+
if (t) {
|
|
114
|
+
const o = r == null ? void 0 : r[e];
|
|
115
|
+
return o === void 0 ? (a.error("MCP场景的约束值不能为空"), process.exit(1)) : o;
|
|
116
|
+
} else
|
|
117
|
+
return (r == null ? void 0 : r[e]) ?? n ?? (await I(s))[e];
|
|
118
|
+
}, ie = async (t, e) => (await I(e))[t], it = (t, e) => {
|
|
107
119
|
t ? a.error(t) : a.error(e.message), e != null && e.stack && a.error(e.stack), process.exit(1);
|
|
108
120
|
}, ct = () => {
|
|
109
121
|
const t = tt(process.argv);
|
|
110
122
|
return Z(t);
|
|
111
|
-
},
|
|
123
|
+
}, ce = ({
|
|
112
124
|
rootScriptName: t,
|
|
113
125
|
packageJson: e
|
|
114
126
|
}) => {
|
|
@@ -137,16 +149,16 @@ const U = (...t) => {
|
|
|
137
149
|
subcommands: c,
|
|
138
150
|
rootScriptName: i
|
|
139
151
|
}, u) => {
|
|
140
|
-
let
|
|
141
|
-
e && (
|
|
152
|
+
let l = t.strict();
|
|
153
|
+
e && (l = l.usage(`Usage: ${e}`)), n && (l = l.demandCommand(n));
|
|
142
154
|
const p = "help";
|
|
143
|
-
return
|
|
144
|
-
},
|
|
155
|
+
return l = l.help(p), r ? l = l.version(r).alias("h", p).alias("v", "version") : l = l.alias("h", p), s && (l = l.options(s)), o && (l = Object.entries(o).reduce((S, [M, h]) => S.positional(M, h), l)), c && (l = l.command(c)), u && i && (l = l.scriptName(i)), l;
|
|
156
|
+
}, ae = async ({ handler: t, ...e }) => {
|
|
145
157
|
const r = await H(ct(), e, !0).fail(
|
|
146
158
|
it
|
|
147
159
|
).argv;
|
|
148
160
|
return t ? t(r) : r;
|
|
149
|
-
},
|
|
161
|
+
}, fe = (t) => {
|
|
150
162
|
const { command: e, describe: r, handler: n = () => {
|
|
151
163
|
}, ...s } = t;
|
|
152
164
|
return {
|
|
@@ -160,7 +172,7 @@ const U = (...t) => {
|
|
|
160
172
|
};
|
|
161
173
|
var at = /* @__PURE__ */ ((t) => (t.VSCODE = "VsCode", t.CURSOR = "Cursor", t.OTHER = "其他", t))(at || {});
|
|
162
174
|
const ft = async () => {
|
|
163
|
-
const { editorType: t } = await
|
|
175
|
+
const { editorType: t } = await I([
|
|
164
176
|
{
|
|
165
177
|
name: "editorType",
|
|
166
178
|
type: "select",
|
|
@@ -211,7 +223,7 @@ const ft = async () => {
|
|
|
211
223
|
/** 必须设置默认值 */
|
|
212
224
|
default: t
|
|
213
225
|
}
|
|
214
|
-
}),
|
|
226
|
+
}), le = ({
|
|
215
227
|
configPathDefault: t,
|
|
216
228
|
rootDirDefault: e
|
|
217
229
|
}) => ({
|
|
@@ -226,11 +238,11 @@ const ft = async () => {
|
|
|
226
238
|
default: t
|
|
227
239
|
}
|
|
228
240
|
}), pt = async (t, e) => {
|
|
229
|
-
const { configPath: r, rootDir: n } = e, s =
|
|
241
|
+
const { configPath: r, rootDir: n } = e, s = f.resolve(n, r), o = f.dirname(s);
|
|
230
242
|
return v(o) || z(o, {
|
|
231
243
|
recursive: !0
|
|
232
|
-
}), s.endsWith(".json5") ? (a.info(`json5模式写入 ${s}`),
|
|
233
|
-
},
|
|
244
|
+
}), s.endsWith(".json5") ? (a.info(`json5模式写入 ${s}`), b(s, F.stringify(t, null, 2)), s) : (a.info(`json模式写入 ${s}`), b(s, JSON.stringify(t, null, 2)), s);
|
|
245
|
+
}, ue = async (t, e, {
|
|
234
246
|
onFileGenerated: r,
|
|
235
247
|
edit: n = !1
|
|
236
248
|
} = {}) => {
|
|
@@ -239,8 +251,8 @@ const ft = async () => {
|
|
|
239
251
|
const o = await ft();
|
|
240
252
|
gt(e.configPath, o);
|
|
241
253
|
}
|
|
242
|
-
},
|
|
243
|
-
const { configPath: r, rootDir: n } = t, s =
|
|
254
|
+
}, ge = async (t, e) => {
|
|
255
|
+
const { configPath: r, rootDir: n } = t, s = f.resolve(n, r);
|
|
244
256
|
if (!v(s)) {
|
|
245
257
|
if (e)
|
|
246
258
|
return a.info("配置文件不存在,使用onNotExists返回值"), e();
|
|
@@ -248,18 +260,18 @@ const ft = async () => {
|
|
|
248
260
|
throw new Error(o);
|
|
249
261
|
}
|
|
250
262
|
return s.endsWith(".json5") ? (a.info(`json5模式解析 ${s}`), F.parse(_(s, "utf8"))) : (a.info(`json模式解析 ${s}`), JSON.parse(_(s, "utf8")));
|
|
251
|
-
},
|
|
252
|
-
const { useDefaultConfig: t } = await
|
|
263
|
+
}, me = async () => {
|
|
264
|
+
const { useDefaultConfig: t } = await I({
|
|
253
265
|
name: "useDefaultConfig",
|
|
254
266
|
type: "confirm",
|
|
255
267
|
message: "使用默认模板配置",
|
|
256
268
|
initial: !0
|
|
257
269
|
});
|
|
258
270
|
return t;
|
|
259
|
-
}, J = "package.json",
|
|
271
|
+
}, J = "package.json", D = ({
|
|
260
272
|
rootDir: t
|
|
261
273
|
}) => {
|
|
262
|
-
const e =
|
|
274
|
+
const e = f.resolve(t, J);
|
|
263
275
|
if (!v(e))
|
|
264
276
|
throw new Error(`${t}未找到package.json文件`);
|
|
265
277
|
const r = _(e, "utf-8");
|
|
@@ -270,7 +282,7 @@ const ft = async () => {
|
|
|
270
282
|
pkgName: r,
|
|
271
283
|
isDevPkg: n
|
|
272
284
|
}) => {
|
|
273
|
-
const s = e ||
|
|
285
|
+
const s = e || D({ rootDir: t }), o = n ? s.devDependencies : s.dependencies;
|
|
274
286
|
let c = o == null ? void 0 : o[r];
|
|
275
287
|
if (!c) {
|
|
276
288
|
const i = n ? s.dependencies : s.devDependencies;
|
|
@@ -280,22 +292,22 @@ const ft = async () => {
|
|
|
280
292
|
return;
|
|
281
293
|
}
|
|
282
294
|
return c || a.info(`依赖包${r}未安装`), c;
|
|
283
|
-
},
|
|
295
|
+
}, pe = ({
|
|
284
296
|
patchConfig: t,
|
|
285
297
|
rootDir: e
|
|
286
298
|
}) => {
|
|
287
299
|
if (!t)
|
|
288
300
|
return;
|
|
289
|
-
const r =
|
|
290
|
-
|
|
291
|
-
},
|
|
301
|
+
const r = D({ rootDir: e }), n = et(r, t), s = f.resolve(e, J);
|
|
302
|
+
b(s, JSON.stringify(n, null, 2), "utf-8");
|
|
303
|
+
}, $ = (t) => {
|
|
292
304
|
const r = g("git rev-parse --show-toplevel", {
|
|
293
305
|
cwd: t
|
|
294
306
|
}).toString();
|
|
295
307
|
if (!r)
|
|
296
308
|
throw new Error("获取git根目录失败");
|
|
297
309
|
return r.trim();
|
|
298
|
-
},
|
|
310
|
+
}, he = () => {
|
|
299
311
|
var t;
|
|
300
312
|
try {
|
|
301
313
|
const e = g("git symbolic-ref --short HEAD", {
|
|
@@ -326,23 +338,23 @@ const ft = async () => {
|
|
|
326
338
|
a.stage(`${t} 没有执行权限 添加... `);
|
|
327
339
|
const n = r | A;
|
|
328
340
|
m.chmodSync(t, n), a.success(`${t} 添加执行权限成功`);
|
|
329
|
-
}, V = (t) => m.existsSync(t),
|
|
341
|
+
}, V = (t) => m.existsSync(t), N = async (t) => {
|
|
330
342
|
try {
|
|
331
343
|
return await m.promises.lstat(t), !0;
|
|
332
344
|
} catch (e) {
|
|
333
345
|
return e.code !== "ENOENT";
|
|
334
346
|
}
|
|
335
|
-
},
|
|
347
|
+
}, yt = (t, e = !1) => {
|
|
336
348
|
V(t) && m.rmSync(t, { recursive: !0, force: e });
|
|
337
|
-
},
|
|
338
|
-
await
|
|
339
|
-
},
|
|
349
|
+
}, Et = async (t, e = !1) => {
|
|
350
|
+
await N(t) && await m.promises.rm(t, { recursive: !0, force: e });
|
|
351
|
+
}, _t = (t) => m.readFileSync(t, "utf-8"), Rt = (t) => m.promises.readFile(t, "utf-8"), de = (t, e) => JSON.parse(_t(t)) || e, K = async (t, e) => JSON.parse(await Rt(t)) || e;
|
|
340
352
|
var d = /* @__PURE__ */ ((t) => (t.PRE_COMMIT = "pre-commit", t.PRE_MERGE_COMMIT = "pre-merge-commit", t.PREPARE_COMMIT_MSG = "prepare-commit-msg", t.COMMIT_MSG = "commit-msg", t.PRE_REBASE = "pre-rebase", t.POST_COMMIT = "post-commit", t.POST_MERGE = "post-merge", t.PRE_PUSH = "pre-push", t))(d || {});
|
|
341
|
-
const
|
|
342
|
-
const e =
|
|
353
|
+
const Ct = "husky", Ot = ".husky", vt = ({ rootDir: t }) => {
|
|
354
|
+
const e = $(t), r = ht({
|
|
343
355
|
rootDir: e,
|
|
344
|
-
pkgJson:
|
|
345
|
-
pkgName:
|
|
356
|
+
pkgJson: D({ rootDir: e }),
|
|
357
|
+
pkgName: Ct,
|
|
346
358
|
isDevPkg: !0
|
|
347
359
|
});
|
|
348
360
|
if (!r)
|
|
@@ -350,17 +362,17 @@ const Rt = "husky", Ct = ".husky", Ot = ({ rootDir: t }) => {
|
|
|
350
362
|
const n = r.replace(/^(\^|~)/, ""), s = "<9.0.0";
|
|
351
363
|
return rt.satisfies(n, s) ? (a.info(`${n}符合${s}`), `#!/usr/bin/env sh
|
|
352
364
|
. "$(dirname -- "$0")/_/husky.sh"`) : (a.info(`${n}不符合${s}`), "");
|
|
353
|
-
},
|
|
354
|
-
const e =
|
|
355
|
-
return
|
|
356
|
-
},
|
|
365
|
+
}, It = ({ rootDir: t }) => {
|
|
366
|
+
const e = $(t);
|
|
367
|
+
return f.resolve(e, Ot);
|
|
368
|
+
}, Se = ({
|
|
357
369
|
hookNames: t,
|
|
358
370
|
rootDir: e,
|
|
359
371
|
getCode: r
|
|
360
372
|
}) => {
|
|
361
|
-
const n =
|
|
373
|
+
const n = It({ rootDir: e });
|
|
362
374
|
m.existsSync(n) || m.mkdirSync(n, { recursive: !0 }), t.forEach((s) => {
|
|
363
|
-
const o =
|
|
375
|
+
const o = f.resolve(n, s), c = m.existsSync(o);
|
|
364
376
|
let i = r(s);
|
|
365
377
|
if (c)
|
|
366
378
|
m.readFileSync(o, "utf-8").includes(i) ? a.skip(`${o} ${s}相关调用 ${i} 已存在 跳过`) : (m.appendFileSync(
|
|
@@ -370,7 +382,7 @@ ${i}
|
|
|
370
382
|
`
|
|
371
383
|
), a.success(`${o} 添加 ${s}相关调用成功`));
|
|
372
384
|
else {
|
|
373
|
-
const u =
|
|
385
|
+
const u = vt({
|
|
374
386
|
rootDir: e
|
|
375
387
|
});
|
|
376
388
|
m.writeFileSync(
|
|
@@ -384,25 +396,25 @@ ${i}
|
|
|
384
396
|
}
|
|
385
397
|
St(o);
|
|
386
398
|
});
|
|
387
|
-
},
|
|
399
|
+
}, ye = [
|
|
388
400
|
// HooksNameEnum.PRE_MERGE_COMMIT,
|
|
389
401
|
d.PREPARE_COMMIT_MSG,
|
|
390
402
|
d.COMMIT_MSG
|
|
391
|
-
],
|
|
403
|
+
], Ee = ({
|
|
392
404
|
hookName: t,
|
|
393
405
|
rootDir: e
|
|
394
406
|
}) => {
|
|
395
|
-
const r =
|
|
407
|
+
const r = $(e), n = f.resolve(r, ".git");
|
|
396
408
|
switch (t) {
|
|
397
409
|
case d.PREPARE_COMMIT_MSG:
|
|
398
410
|
case d.COMMIT_MSG: {
|
|
399
|
-
const s =
|
|
411
|
+
const s = f.resolve(n, "MERGE_MSG");
|
|
400
412
|
if (v(s))
|
|
401
413
|
return _(s, "utf-8");
|
|
402
414
|
}
|
|
403
415
|
}
|
|
404
416
|
return "";
|
|
405
|
-
},
|
|
417
|
+
}, _e = ({
|
|
406
418
|
remoteAlias: t = "origin"
|
|
407
419
|
} = {}) => {
|
|
408
420
|
try {
|
|
@@ -416,15 +428,15 @@ ${i}
|
|
|
416
428
|
return {
|
|
417
429
|
lastHash: e,
|
|
418
430
|
lastCommitter: r,
|
|
419
|
-
lastCommitterPinYin:
|
|
420
|
-
style:
|
|
431
|
+
lastCommitterPinYin: E(r, {
|
|
432
|
+
style: E.STYLE_NORMAL,
|
|
421
433
|
heteronym: !1
|
|
422
434
|
}).join(""),
|
|
423
435
|
lastCommitEmail: n,
|
|
424
436
|
lastCommitMsg: s,
|
|
425
437
|
userName: o,
|
|
426
|
-
userNamePinYin:
|
|
427
|
-
style:
|
|
438
|
+
userNamePinYin: E(o, {
|
|
439
|
+
style: E.STYLE_NORMAL,
|
|
428
440
|
heteronym: !1
|
|
429
441
|
}).join(""),
|
|
430
442
|
userEmail: c,
|
|
@@ -461,12 +473,12 @@ ${i}
|
|
|
461
473
|
fromBranch: i
|
|
462
474
|
};
|
|
463
475
|
}
|
|
464
|
-
},
|
|
465
|
-
if (t.startsWith(
|
|
476
|
+
}, $t = (t) => {
|
|
477
|
+
if (t.startsWith(w.MERGE))
|
|
466
478
|
return {
|
|
467
|
-
fromBranch: t.replace(
|
|
479
|
+
fromBranch: t.replace(w.MERGE, "").trim()
|
|
468
480
|
};
|
|
469
|
-
},
|
|
481
|
+
}, Re = () => {
|
|
470
482
|
const t = process.env.GIT_REFLOG_ACTION || "";
|
|
471
483
|
if (!t)
|
|
472
484
|
return;
|
|
@@ -485,7 +497,7 @@ ${i}
|
|
|
485
497
|
};
|
|
486
498
|
}
|
|
487
499
|
};
|
|
488
|
-
var
|
|
500
|
+
var w = /* @__PURE__ */ ((t) => (t.CHECKOUT = "checkout", t.MERGE = "merge", t.COMMIT = "commit", t.COMMIT_MERGE = "commit (merge)", t.PULL = "pull", t.RESET = "reset", t.REBASE_START = "rebase (start)", t.REBASE_FINISH = "rebase (finish)", t.REBASE_ABORT = "rebase (abort)", t.REBASE_CONTINUE = "rebase (continue)", t))(w || {});
|
|
489
501
|
const B = "__GIT_REPLACE_MARK__", O = {
|
|
490
502
|
stringify(t) {
|
|
491
503
|
return JSON.stringify(t).replace(/"/g, B);
|
|
@@ -493,7 +505,7 @@ const B = "__GIT_REPLACE_MARK__", O = {
|
|
|
493
505
|
parse(t) {
|
|
494
506
|
return JSON.parse(t.replace(new RegExp(B, "g"), '"'));
|
|
495
507
|
}
|
|
496
|
-
},
|
|
508
|
+
}, Ce = ({
|
|
497
509
|
count: t = 100
|
|
498
510
|
} = {}) => {
|
|
499
511
|
if (t <= 0)
|
|
@@ -527,7 +539,7 @@ const B = "__GIT_REPLACE_MARK__", O = {
|
|
|
527
539
|
mergeInfo: Y(c.message)
|
|
528
540
|
};
|
|
529
541
|
});
|
|
530
|
-
},
|
|
542
|
+
}, Oe = ({
|
|
531
543
|
count: t = 100,
|
|
532
544
|
filterItem: e = () => !0
|
|
533
545
|
} = {}) => {
|
|
@@ -546,46 +558,46 @@ const B = "__GIT_REPLACE_MARK__", O = {
|
|
|
546
558
|
)}"`
|
|
547
559
|
).toString().split(`
|
|
548
560
|
`).map((i) => O.parse(i)).filter(e).map((i) => {
|
|
549
|
-
const { fullMessage: u, ...
|
|
550
|
-
let
|
|
561
|
+
const { fullMessage: u, ...l } = i, p = ":", [S] = u.split(p, 1), M = u.slice(`${S}${p}`.length), h = S.trim(), y = M.trim();
|
|
562
|
+
let P, G, X;
|
|
551
563
|
if (h.startsWith(
|
|
552
564
|
"checkout"
|
|
553
565
|
/* CHECKOUT */
|
|
554
566
|
))
|
|
555
|
-
|
|
567
|
+
G = dt(y);
|
|
556
568
|
else if (h.startsWith(
|
|
557
569
|
"merge"
|
|
558
570
|
/* MERGE */
|
|
559
571
|
))
|
|
560
|
-
|
|
572
|
+
P = $t(h);
|
|
561
573
|
else if (h.startsWith(
|
|
562
574
|
"commit (merge)"
|
|
563
575
|
/* COMMIT_MERGE */
|
|
564
576
|
)) {
|
|
565
|
-
const L = Y(
|
|
577
|
+
const L = Y(y);
|
|
566
578
|
L || a.warn(
|
|
567
|
-
`${i.hash} 是合并提交 但是未从提交信息(${
|
|
568
|
-
),
|
|
579
|
+
`${i.hash} 是合并提交 但是未从提交信息(${y})中检测到合并分支信息,推测手动更改了提交内容`
|
|
580
|
+
), P = L;
|
|
569
581
|
}
|
|
570
582
|
return {
|
|
571
|
-
...
|
|
583
|
+
...l,
|
|
572
584
|
type: h,
|
|
573
|
-
message:
|
|
574
|
-
mergeInfo:
|
|
575
|
-
checkoutInfo:
|
|
585
|
+
message: y,
|
|
586
|
+
mergeInfo: P,
|
|
587
|
+
checkoutInfo: G,
|
|
576
588
|
rebaseInfo: X
|
|
577
589
|
};
|
|
578
590
|
});
|
|
579
|
-
},
|
|
580
|
-
const e =
|
|
591
|
+
}, ve = (t) => {
|
|
592
|
+
const e = $(t), r = f.resolve(e, ".git"), n = f.resolve(r, "rebase-merge");
|
|
581
593
|
if (m.existsSync(n))
|
|
582
594
|
return !0;
|
|
583
|
-
const s =
|
|
595
|
+
const s = f.resolve(r, "rebase-apply");
|
|
584
596
|
if (m.existsSync(s))
|
|
585
597
|
return !0;
|
|
586
|
-
const o =
|
|
598
|
+
const o = f.resolve(r, "REBASE_HEAD");
|
|
587
599
|
return !!m.existsSync(o);
|
|
588
|
-
},
|
|
600
|
+
}, Ie = ({
|
|
589
601
|
branchName: t,
|
|
590
602
|
version: e,
|
|
591
603
|
remoteInfo: r
|
|
@@ -595,10 +607,10 @@ const B = "__GIT_REPLACE_MARK__", O = {
|
|
|
595
607
|
}), g(`git push ${r.alias} ${t}`, {
|
|
596
608
|
stdio: "inherit"
|
|
597
609
|
}));
|
|
598
|
-
},
|
|
610
|
+
}, Mt = (t) => /^https?:\/\//.test(t), Pt = (t) => /^git@/.test(t), $e = (t) => {
|
|
599
611
|
const { hostname: e, pathname: r } = new URL(t);
|
|
600
612
|
return `git@${e}:${r.replace("/", "")}`;
|
|
601
|
-
}, W = ".done-coding",
|
|
613
|
+
}, At = (t) => f.resolve(t, ".git"), Me = (t) => Et(At(t)), W = ".done-coding", bt = `${W}/cli/assets-config`, Tt = "assets", wt = "index.json", Dt = `${W}/config.json`, Nt = "https://gitee.com/justsosu/done-coding-cli-assets-config.git", Gt = ({
|
|
602
614
|
dir: t,
|
|
603
615
|
fn: e,
|
|
604
616
|
endClear: r = !0,
|
|
@@ -607,7 +619,7 @@ const B = "__GIT_REPLACE_MARK__", O = {
|
|
|
607
619
|
if (V(t))
|
|
608
620
|
return a.error(`${t} 已存在,请手动删除该目录再试`), process.exit(1);
|
|
609
621
|
const s = () => {
|
|
610
|
-
a.stage("正在清理临时目录...", t),
|
|
622
|
+
a.stage("正在清理临时目录...", t), yt(t);
|
|
611
623
|
};
|
|
612
624
|
n && process.once("exit", () => {
|
|
613
625
|
a.stage("发现进程退出,正在清理临时目录...", t), s();
|
|
@@ -620,17 +632,17 @@ const B = "__GIT_REPLACE_MARK__", O = {
|
|
|
620
632
|
}
|
|
621
633
|
return r && (o instanceof Promise ? o.finally(s) : s()), o;
|
|
622
634
|
};
|
|
623
|
-
var
|
|
624
|
-
const
|
|
635
|
+
var Lt = /* @__PURE__ */ ((t) => (t.ASSETS_CONFIG_REPO_URL = "ASSETS_CONFIG_REPO_URL", t))(Lt || {});
|
|
636
|
+
const Bt = (t) => f.resolve(
|
|
625
637
|
st(),
|
|
626
|
-
|
|
638
|
+
bt,
|
|
627
639
|
`${t}-${ot()}`
|
|
628
|
-
),
|
|
629
|
-
const t =
|
|
630
|
-
ASSETS_CONFIG_REPO_URL:
|
|
640
|
+
), Ft = () => f.resolve(nt(), Dt), xt = async () => {
|
|
641
|
+
const t = Ft(), e = {
|
|
642
|
+
ASSETS_CONFIG_REPO_URL: Nt
|
|
631
643
|
};
|
|
632
644
|
try {
|
|
633
|
-
if (await
|
|
645
|
+
if (await N(t)) {
|
|
634
646
|
const r = await K(t, {});
|
|
635
647
|
Object.entries(r).forEach(([n, s]) => {
|
|
636
648
|
e[n] = s;
|
|
@@ -639,32 +651,32 @@ const Lt = (t) => l.resolve(
|
|
|
639
651
|
} catch {
|
|
640
652
|
}
|
|
641
653
|
return e;
|
|
642
|
-
},
|
|
643
|
-
if (await
|
|
654
|
+
}, jt = async (t) => {
|
|
655
|
+
if (await N(t))
|
|
644
656
|
return a.error(`${t} 已存在,请手动删除该目录再试`), process.exit(1);
|
|
645
657
|
const {
|
|
646
658
|
[
|
|
647
659
|
"ASSETS_CONFIG_REPO_URL"
|
|
648
660
|
/* ASSETS_CONFIG_REPO_URL */
|
|
649
661
|
]: e
|
|
650
|
-
} = await
|
|
651
|
-
return
|
|
662
|
+
} = await xt();
|
|
663
|
+
return Pt(e) || Mt(e) ? g(`git clone ${e} ${t} --depth=1`) : (m.mkdirSync(t, { recursive: !0 }), g(`cp -r ${e}/ ${t}/`)), {
|
|
652
664
|
assetConfigRepoUrl: e
|
|
653
665
|
};
|
|
654
|
-
},
|
|
666
|
+
}, Pe = async ({
|
|
655
667
|
moduleName: t,
|
|
656
668
|
onSuccess: e
|
|
657
|
-
}) => (a.stage(`拉取${t}配置,请稍等...`),
|
|
669
|
+
}) => (a.stage(`拉取${t}配置,请稍等...`), Gt({
|
|
658
670
|
// 资源配置仓库临时文件夹
|
|
659
|
-
dir:
|
|
671
|
+
dir: Bt(t),
|
|
660
672
|
fn: async (r) => {
|
|
661
|
-
const { assetConfigRepoUrl: n } = await
|
|
662
|
-
|
|
673
|
+
const { assetConfigRepoUrl: n } = await jt(r), s = f.join(
|
|
674
|
+
Tt,
|
|
663
675
|
t
|
|
664
|
-
), o =
|
|
676
|
+
), o = f.join(
|
|
665
677
|
s,
|
|
666
678
|
wt
|
|
667
|
-
), c =
|
|
679
|
+
), c = f.resolve(r, o), i = await K(c);
|
|
668
680
|
return await e({
|
|
669
681
|
repoUrl: n,
|
|
670
682
|
config: i,
|
|
@@ -675,62 +687,66 @@ const Lt = (t) => l.resolve(
|
|
|
675
687
|
}
|
|
676
688
|
}));
|
|
677
689
|
export {
|
|
678
|
-
|
|
690
|
+
Lt as DoneCodingCliGlobalConfigKeyEnum,
|
|
679
691
|
at as EditorTypeEnum,
|
|
680
|
-
|
|
692
|
+
w as GitRefLogTypeEnum,
|
|
681
693
|
d as HooksNameEnum,
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
694
|
+
ye as SUPPORT_GET_COMMIT_BY_HOOKS_NAMES,
|
|
695
|
+
je as _curry,
|
|
696
|
+
Le as _get,
|
|
697
|
+
Fe as _set,
|
|
698
|
+
Se as addHuskyHooks,
|
|
699
|
+
pe as addPackageConfig,
|
|
700
|
+
Gt as applyUseTempDir,
|
|
689
701
|
V as assetIsExits,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
702
|
+
N as assetIsExitsAsync,
|
|
703
|
+
ve as checkCurrentIsRebasing,
|
|
704
|
+
ae as createMainCommand,
|
|
705
|
+
fe as createSubcommand,
|
|
706
|
+
ne as decryptAES,
|
|
707
|
+
se as encryptAES,
|
|
696
708
|
St as fileAddX,
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
709
|
+
ie as getAnswerSwift,
|
|
710
|
+
oe as getAnswerWithMCP,
|
|
711
|
+
Bt as getCliModuleTempDir,
|
|
712
|
+
Ee as getCommitByHookName,
|
|
713
|
+
le as getConfigFileCommonOptions,
|
|
714
|
+
Ce as getCurrentBranchLastCommitList,
|
|
715
|
+
he as getCurrentBranchName,
|
|
702
716
|
ft as getEditorType,
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
717
|
+
_e as getGitLastCommitInfo,
|
|
718
|
+
At as getGitPath,
|
|
719
|
+
$ as getGitProjectDir,
|
|
720
|
+
Oe as getLastReflogList,
|
|
721
|
+
ee as getLogText,
|
|
722
|
+
D as getPackageJson,
|
|
708
723
|
ht as getRelyPkgVersion,
|
|
709
724
|
mt as getRootDirOptions,
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
725
|
+
ce as getRootScriptName,
|
|
726
|
+
me as getUseDefaultConfig,
|
|
727
|
+
$e as http2sshGitUrl,
|
|
713
728
|
pt as initConfigFile,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
729
|
+
ue as initHandlerCommon,
|
|
730
|
+
Mt as isHttpGitUrl,
|
|
731
|
+
Pt as isSshGitUrl,
|
|
732
|
+
we as json5,
|
|
718
733
|
a as log,
|
|
719
|
-
|
|
734
|
+
re as lookForParentTarget,
|
|
720
735
|
gt as openFileInEditor,
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
736
|
+
Ie as pushGitPublishInfoToRemote,
|
|
737
|
+
Pe as readCliModuleAssetsConfig,
|
|
738
|
+
ge as readConfigFile,
|
|
739
|
+
_t as readFile,
|
|
740
|
+
Rt as readFileAsync,
|
|
741
|
+
de as readJsonFile,
|
|
727
742
|
K as readJsonFileAsync,
|
|
728
|
-
|
|
729
|
-
|
|
743
|
+
yt as removeAsset,
|
|
744
|
+
Et as removeAssetAsync,
|
|
730
745
|
dt as resolveCheckoutInfoByRefInfo,
|
|
731
746
|
Y as resolveMergeInfoByCommitMsg,
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
747
|
+
Re as resolveMergeInfoByGitReflogAction,
|
|
748
|
+
$t as resolveMergeInfoByRefType,
|
|
749
|
+
Me as rmGitCtrlAsync,
|
|
750
|
+
Ne as uuidv4,
|
|
751
|
+
I as xPrompts
|
|
736
752
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-utils",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-alpha.0",
|
|
4
4
|
"description": "cli utils",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@types/uuid": "^10.0.0",
|
|
51
51
|
"@types/yargs": "^17.0.28",
|
|
52
52
|
"rimraf": "^6.0.1",
|
|
53
|
-
"typescript": "^5.
|
|
53
|
+
"typescript": "^5.8.3",
|
|
54
54
|
"vite": "^4.4.11",
|
|
55
55
|
"vite-plugin-dts": "^3.6.0"
|
|
56
56
|
},
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"uuid": "^11.1.0",
|
|
71
71
|
"yargs": "^17.7.2"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b09dd794f69ba2dafe22a3519d712d059c2eb376"
|
|
74
74
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const addHuskyHooks: <H extends string>({ hookNames, rootDir, get
|
|
|
30
30
|
|
|
31
31
|
/** 添加package.json配置 */
|
|
32
32
|
export declare const addPackageConfig: ({ patchConfig, rootDir, }: {
|
|
33
|
-
patchConfig?: Record<string, any
|
|
33
|
+
patchConfig?: Record<string, any>;
|
|
34
34
|
rootDir: string;
|
|
35
35
|
}) => void;
|
|
36
36
|
|
|
@@ -43,15 +43,17 @@ export declare const applyUseTempDir: <T>({ dir, fn, endClear, exitClear, }: {
|
|
|
43
43
|
dir: string;
|
|
44
44
|
fn: (dir: string) => T;
|
|
45
45
|
/** 结束时移除临时目录 */
|
|
46
|
-
endClear?: boolean
|
|
46
|
+
endClear?: boolean;
|
|
47
47
|
/** 退出信号是否移除临时目录 */
|
|
48
|
-
exitClear?: boolean
|
|
48
|
+
exitClear?: boolean;
|
|
49
49
|
}) => T;
|
|
50
50
|
|
|
51
51
|
export { ArgumentsCamelCase }
|
|
52
52
|
|
|
53
53
|
/** 文件或文件夹是否存在(同步) */
|
|
54
|
-
export declare const assetIsExits: (
|
|
54
|
+
export declare const assetIsExits: (
|
|
55
|
+
/** 资源路径 */
|
|
56
|
+
assetPath: string) => boolean;
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* 检查路径是否存在(包括文件、目录、符号链接)
|
|
@@ -158,6 +160,30 @@ export declare const fileAddX: (filePath: string) => void;
|
|
|
158
160
|
|
|
159
161
|
export { _get }
|
|
160
162
|
|
|
163
|
+
/** 快捷获取答案 */
|
|
164
|
+
export declare const getAnswerSwift: <V = unknown, T extends string = string>(key: T,
|
|
165
|
+
/** 表单问询配置 */
|
|
166
|
+
questionConfig: Parameters<typeof prompts<T>>[0]) => Promise<V>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 获取答案 考虑mcp情况
|
|
170
|
+
* ----
|
|
171
|
+
* mcp 只拿预设值,非mcp优先拿默认值
|
|
172
|
+
* 有预设值的场景: MCP
|
|
173
|
+
*/
|
|
174
|
+
export declare const getAnswerWithMCP: <V = unknown, T extends string = string>({ isMCP, key, presetAnswer, defaultValue, questionConfig, }: {
|
|
175
|
+
/** 是否mcp场景 */
|
|
176
|
+
isMCP: boolean;
|
|
177
|
+
/** 表单key */
|
|
178
|
+
key: T;
|
|
179
|
+
/** 预设答案所在的对象 */
|
|
180
|
+
presetAnswer?: object & { [K in T]: any; };
|
|
181
|
+
/** 默认值 */
|
|
182
|
+
defaultValue?: V;
|
|
183
|
+
/** 表单问询配置 */
|
|
184
|
+
questionConfig: Parameters<typeof prompts<T>>[0];
|
|
185
|
+
}) => Promise<V>;
|
|
186
|
+
|
|
161
187
|
/** 获取cli模块【临时】目录[绝对路径] */
|
|
162
188
|
export declare const getCliModuleTempDir: (moduleName: string) => string;
|
|
163
189
|
|
|
@@ -170,14 +196,14 @@ export declare const getCommitByHookName: ({ hookName, rootDir, }: {
|
|
|
170
196
|
/** 获取配置文件通用选项 */
|
|
171
197
|
export declare const getConfigFileCommonOptions: ({ configPathDefault, rootDirDefault, }: {
|
|
172
198
|
configPathDefault: string;
|
|
173
|
-
rootDirDefault?: string
|
|
199
|
+
rootDirDefault?: string;
|
|
174
200
|
}) => Record<keyof ConfigFileCommonOptions, YargsOptions>;
|
|
175
201
|
|
|
176
202
|
/** 获取当前分支最近提交列表 */
|
|
177
203
|
export declare const getCurrentBranchLastCommitList: ({ count, }?: {
|
|
178
|
-
count?: number
|
|
204
|
+
count?: number;
|
|
179
205
|
/** 某个hash之后的提交 */
|
|
180
|
-
afterHash?: string
|
|
206
|
+
afterHash?: string;
|
|
181
207
|
}) => GitLogItemInfo[];
|
|
182
208
|
|
|
183
209
|
/** 获取当前分支名 */
|
|
@@ -199,16 +225,23 @@ export declare interface GetGitLastCommitParams {
|
|
|
199
225
|
remoteAlias?: GitRemoteInfo["alias"];
|
|
200
226
|
}
|
|
201
227
|
|
|
228
|
+
/**
|
|
229
|
+
* 获取git路径
|
|
230
|
+
* ---
|
|
231
|
+
* @param projectPath 项目路径
|
|
232
|
+
*/
|
|
233
|
+
export declare const getGitPath: (projectPath: string) => string;
|
|
234
|
+
|
|
202
235
|
/** 获取git项目目录 */
|
|
203
236
|
export declare const getGitProjectDir: (rootDir: string) => string;
|
|
204
237
|
|
|
205
238
|
/** 获取最后的reflog */
|
|
206
239
|
export declare const getLastReflogList: ({ count, filterItem, }?: {
|
|
207
|
-
count?: number
|
|
240
|
+
count?: number;
|
|
208
241
|
/** 某个hash之后的提交 */
|
|
209
|
-
afterHash?: string
|
|
242
|
+
afterHash?: string;
|
|
210
243
|
/** 过滤函数 */
|
|
211
|
-
filterItem?: (
|
|
244
|
+
filterItem?: (item: GitReflogItemInfoRaw) => boolean;
|
|
212
245
|
}) => GitReflogItemInfo[];
|
|
213
246
|
|
|
214
247
|
/** 获取输出文字 */
|
|
@@ -235,7 +268,7 @@ export declare const getPackageJson: <R extends PackageJson>({ rootDir, }: {
|
|
|
235
268
|
/** 获取依赖包版本 */
|
|
236
269
|
export declare const getRelyPkgVersion: <R extends PackageJson>({ rootDir, pkgJson, pkgName, isDevPkg, }: {
|
|
237
270
|
rootDir: string;
|
|
238
|
-
pkgJson?: R
|
|
271
|
+
pkgJson?: R;
|
|
239
272
|
pkgName: string;
|
|
240
273
|
/** 是开发依赖包 */
|
|
241
274
|
isDevPkg: boolean;
|
|
@@ -248,8 +281,8 @@ export declare const getRootDirOptions: (rootDirDefault?: string) => {
|
|
|
248
281
|
|
|
249
282
|
/** 获取根命令名称 */
|
|
250
283
|
export declare const getRootScriptName: ({ rootScriptName, packageJson, }: {
|
|
251
|
-
rootScriptName?: string
|
|
252
|
-
packageJson?: Pick<PackageJson, "name" | "bin"
|
|
284
|
+
rootScriptName?: string;
|
|
285
|
+
packageJson?: Pick<PackageJson, "name" | "bin">;
|
|
253
286
|
}) => string | undefined;
|
|
254
287
|
|
|
255
288
|
/** 获取是否使用默认配置 */
|
|
@@ -434,8 +467,8 @@ export declare type InitConfigFileOptions = ConfigFileCommonOptions;
|
|
|
434
467
|
/** 初始化配置文件通用处理器 */
|
|
435
468
|
export declare const initHandlerCommon: <T>(content: T, argv: CliHandlerArgv<InitConfigFileOptions>, { onFileGenerated, edit, }?: {
|
|
436
469
|
/** 文件已生成 */
|
|
437
|
-
onFileGenerated?: (
|
|
438
|
-
edit?: boolean
|
|
470
|
+
onFileGenerated?: (path: string) => void;
|
|
471
|
+
edit?: boolean;
|
|
439
472
|
}) => Promise<void>;
|
|
440
473
|
|
|
441
474
|
/** 是http git地址 */
|
|
@@ -483,9 +516,11 @@ declare enum LogTypeEnum {
|
|
|
483
516
|
/**
|
|
484
517
|
* 查找目标文件或目录
|
|
485
518
|
*/
|
|
486
|
-
export declare const lookForParentTarget: (
|
|
487
|
-
|
|
488
|
-
|
|
519
|
+
export declare const lookForParentTarget: (
|
|
520
|
+
/** 目标文件或目录 */
|
|
521
|
+
target: string, { currentDir, isFindFarthest, }?: {
|
|
522
|
+
currentDir?: string;
|
|
523
|
+
isFindFarthest?: boolean;
|
|
489
524
|
}) => string | undefined;
|
|
490
525
|
|
|
491
526
|
/** 用编辑器打开文件 */
|
|
@@ -525,7 +560,7 @@ export { PromptValueOrFunc }
|
|
|
525
560
|
export declare const pushGitPublishInfoToRemote: ({ branchName, version, remoteInfo, }: {
|
|
526
561
|
branchName: string;
|
|
527
562
|
version: string;
|
|
528
|
-
remoteInfo?: GitRemoteInfo
|
|
563
|
+
remoteInfo?: GitRemoteInfo;
|
|
529
564
|
}) => void;
|
|
530
565
|
|
|
531
566
|
/** 读取(某个模块)配置 */
|
|
@@ -550,7 +585,7 @@ export declare const readCliModuleAssetsConfig: <R>({ moduleName, onSuccess, }:
|
|
|
550
585
|
}) => Promise<R>;
|
|
551
586
|
|
|
552
587
|
/** 读取配置文件 */
|
|
553
|
-
export declare const readConfigFile: <T>(options: ReadConfigFileOptions, onNotExists?: (
|
|
588
|
+
export declare const readConfigFile: <T>(options: ReadConfigFileOptions, onNotExists?: () => T) => Promise<T>;
|
|
554
589
|
|
|
555
590
|
/** 读取配置文件选项 */
|
|
556
591
|
export declare type ReadConfigFileOptions = ConfigFileCommonOptions;
|
|
@@ -562,24 +597,32 @@ export declare const readFile: (assetPath: string) => string;
|
|
|
562
597
|
export declare const readFileAsync: (assetPath: string) => Promise<string>;
|
|
563
598
|
|
|
564
599
|
/** 读取json文件[同步] */
|
|
565
|
-
export declare const readJsonFile: <T>(assetPath: string, defaultValue?: T
|
|
600
|
+
export declare const readJsonFile: <T>(assetPath: string, defaultValue?: T) => T;
|
|
566
601
|
|
|
567
602
|
/** 读取json文件[异步] */
|
|
568
|
-
export declare const readJsonFileAsync: <T>(assetPath: string, defaultValue?: T
|
|
603
|
+
export declare const readJsonFileAsync: <T>(assetPath: string, defaultValue?: T) => Promise<T>;
|
|
569
604
|
|
|
570
605
|
/**
|
|
571
606
|
* 删除资源 (同步)
|
|
572
607
|
* ---
|
|
573
608
|
* 无论文件还是文件夹
|
|
574
609
|
*/
|
|
575
|
-
export declare const removeAsset: (
|
|
610
|
+
export declare const removeAsset: (
|
|
611
|
+
/** 资源路径 */
|
|
612
|
+
assetPath: string,
|
|
613
|
+
/** 是否要强删除 */
|
|
614
|
+
force?: boolean) => void;
|
|
576
615
|
|
|
577
616
|
/**
|
|
578
617
|
* 删除资源 (异步)
|
|
579
618
|
* ---
|
|
580
619
|
* 无论文件还是文件夹
|
|
581
620
|
*/
|
|
582
|
-
export declare const removeAssetAsync: (
|
|
621
|
+
export declare const removeAssetAsync: (
|
|
622
|
+
/** 资源路径 */
|
|
623
|
+
assetPath: string,
|
|
624
|
+
/** 是否要强删除 */
|
|
625
|
+
force?: boolean) => Promise<void>;
|
|
583
626
|
|
|
584
627
|
/** 解析checkoutInfo */
|
|
585
628
|
export declare const resolveCheckoutInfoByRefInfo: (message: string) => {
|
|
@@ -596,6 +639,13 @@ export declare const resolveMergeInfoByGitReflogAction: () => GitMergeBranchInfo
|
|
|
596
639
|
/** 从reflog type解析合并信息 */
|
|
597
640
|
export declare const resolveMergeInfoByRefType: (type: string) => GitMergeBranchInfo | undefined;
|
|
598
641
|
|
|
642
|
+
/**
|
|
643
|
+
* 移除git控制 - 异步
|
|
644
|
+
* @param projectPath
|
|
645
|
+
* @returns
|
|
646
|
+
*/
|
|
647
|
+
export declare const rmGitCtrlAsync: (projectPath: string) => Promise<void>;
|
|
648
|
+
|
|
599
649
|
export { _set }
|
|
600
650
|
|
|
601
651
|
/** 子cli信息 */
|
|
@@ -612,7 +662,7 @@ export declare type SupportGetCommitByHookName = (typeof SUPPORT_GET_COMMIT_BY_H
|
|
|
612
662
|
export { uuidv4 }
|
|
613
663
|
|
|
614
664
|
/** prompts 拓展 */
|
|
615
|
-
export declare const xPrompts: <T extends string = string>(
|
|
665
|
+
export declare const xPrompts: <T extends string = string>(...args: Parameters<typeof prompts<T>>) => Promise<prompts.Answers<T>>;
|
|
616
666
|
|
|
617
667
|
export { YargsArgv }
|
|
618
668
|
|