@done-coding/cli-utils 0.8.3-alpha.1 → 0.8.3-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.mjs +363 -337
- package/package.json +2 -2
- package/types/index.d.ts +7 -0
package/es/index.mjs
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { homedir as
|
|
2
|
+
import { homedir as K, tmpdir as W } from "node:os";
|
|
3
3
|
import f from "node:path";
|
|
4
|
-
import { createOutputLogFile as
|
|
5
|
-
import g, { existsSync as
|
|
6
|
-
import
|
|
7
|
-
import { default as
|
|
8
|
-
import A, { randomUUID as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { hideBin as
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
4
|
+
import { createOutputLogFile as mt, createOutputConsole as _t, OutputConsoleTypeEnum as x } from "@done-coding/output-node";
|
|
5
|
+
import g, { existsSync as L, mkdirSync as Et, writeFileSync as G, readFileSync as N } from "node:fs";
|
|
6
|
+
import dt from "dayjs";
|
|
7
|
+
import { default as dr } from "dayjs";
|
|
8
|
+
import A, { randomUUID as ht } from "node:crypto";
|
|
9
|
+
import St from "prompts";
|
|
10
|
+
import Ct from "yargs";
|
|
11
|
+
import { hideBin as Ot } from "yargs/helpers";
|
|
12
|
+
import { spawn as yt, execSync as $ } from "node:child_process";
|
|
13
|
+
import X from "json5";
|
|
14
14
|
export * from "json5";
|
|
15
|
-
import { default as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
15
|
+
import { default as Cr } from "json5";
|
|
16
|
+
import Rt from "lodash.merge";
|
|
17
|
+
import It from "semver";
|
|
18
|
+
import { default as yr } from "lodash.get";
|
|
19
|
+
import { default as Ir } from "lodash.set";
|
|
20
|
+
import { default as Nr } from "lodash.curry";
|
|
21
21
|
import P from "pinyin";
|
|
22
|
-
import { default as
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
),
|
|
22
|
+
import { default as vr } from "chalk";
|
|
23
|
+
const z = "__DONE_CODING_ENV_CONFIG__", Z = Symbol.for(
|
|
24
|
+
z
|
|
25
|
+
), J = Symbol.for(
|
|
26
26
|
"DONE_CODING_CURRENT_LOG_FILE_NAME"
|
|
27
|
-
),
|
|
27
|
+
), q = "DONE_CODING_PROCESS_CREATE_BY_HIJACK_PRESET_JSON", w = ".done-coding", Pt = `${w}/cli/assets-config`, Nt = "assets", At = "index.json", vt = `${w}/config.json`, Tt = "output/log", Q = "default", Lt = "https://gitee.com/justsosu/done-coding-cli-assets-config.git", D = 73, Mt = (t) => {
|
|
28
28
|
const r = g.statSync(t).mode;
|
|
29
|
-
if ((r &
|
|
29
|
+
if ((r & D) === D)
|
|
30
30
|
return;
|
|
31
31
|
a.stage(`${t} 没有执行权限 添加... `);
|
|
32
|
-
const s = r |
|
|
32
|
+
const s = r | D;
|
|
33
33
|
g.chmodSync(t, s), a.success(`${t} 添加执行权限成功`);
|
|
34
|
-
},
|
|
34
|
+
}, B = (t) => g.existsSync(t), U = async (t) => {
|
|
35
35
|
try {
|
|
36
36
|
return await g.promises.lstat(t), !0;
|
|
37
37
|
} catch (e) {
|
|
38
38
|
return e.code !== "ENOENT";
|
|
39
39
|
}
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
await
|
|
44
|
-
},
|
|
45
|
-
var
|
|
46
|
-
const
|
|
47
|
-
const r = process.env[
|
|
40
|
+
}, $t = (t, e = !1) => {
|
|
41
|
+
B(t) && g.rmSync(t, { recursive: !0, force: e });
|
|
42
|
+
}, Dt = async (t, e = !1) => {
|
|
43
|
+
await U(t) && await g.promises.rm(t, { recursive: !0, force: e });
|
|
44
|
+
}, Gt = (t) => g.readFileSync(t, "utf-8"), Ft = (t) => g.promises.readFile(t, "utf-8"), Be = (t, e) => JSON.parse(Gt(t)) || e, tt = async (t, e) => JSON.parse(await Ft(t)) || e;
|
|
45
|
+
var bt = /* @__PURE__ */ ((t) => (t.GLOBAL_CONFIG_IMAGE = "GLOBAL_CONFIG_IMAGE", t))(bt || {});
|
|
46
|
+
const et = (t) => `${z}_${t}`, rt = (t, e) => {
|
|
47
|
+
const r = process.env[et(t)];
|
|
48
48
|
if (r !== void 0)
|
|
49
49
|
try {
|
|
50
50
|
return JSON.parse(r).value;
|
|
@@ -53,38 +53,38 @@ const Q = (t) => `${W}_${t}`, tt = (t, e) => {
|
|
|
53
53
|
}
|
|
54
54
|
else
|
|
55
55
|
return e;
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
const r =
|
|
56
|
+
}, wt = (t, e) => {
|
|
57
|
+
rt(t);
|
|
58
|
+
const r = et(t), s = { value: e };
|
|
59
59
|
process.env[r] = JSON.stringify(s);
|
|
60
|
-
},
|
|
61
|
-
const t = globalThis[
|
|
60
|
+
}, st = () => globalThis[Z], nt = () => {
|
|
61
|
+
const t = globalThis[J];
|
|
62
62
|
if (t)
|
|
63
63
|
return t;
|
|
64
64
|
{
|
|
65
|
-
const e = `${
|
|
66
|
-
return globalThis[
|
|
65
|
+
const e = `${dt().format("YYYY-MM-DD_HH-mm-ss")}_${process.pid}.log`;
|
|
66
|
+
return globalThis[J] = e, e;
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, Bt = (t) => {
|
|
69
69
|
const r = {
|
|
70
|
-
...
|
|
70
|
+
...st() || {},
|
|
71
71
|
...t
|
|
72
72
|
};
|
|
73
|
-
return
|
|
74
|
-
},
|
|
73
|
+
return wt("GLOBAL_CONFIG_IMAGE", r), globalThis[Z] = r, r;
|
|
74
|
+
}, Ut = () => rt(
|
|
75
75
|
"GLOBAL_CONFIG_IMAGE"
|
|
76
76
|
/* GLOBAL_CONFIG_IMAGE */
|
|
77
|
-
),
|
|
78
|
-
const t =
|
|
77
|
+
), ot = (t) => `${w}/${t}/${Tt}`, Ht = () => {
|
|
78
|
+
const t = Ut();
|
|
79
79
|
let e;
|
|
80
80
|
if (t)
|
|
81
81
|
e = t;
|
|
82
82
|
else {
|
|
83
|
-
const m =
|
|
83
|
+
const m = Q;
|
|
84
84
|
e = {
|
|
85
85
|
series: m,
|
|
86
86
|
consoleLog: !0,
|
|
87
|
-
logOutputDir:
|
|
87
|
+
logOutputDir: ot(m),
|
|
88
88
|
processLogFileNameList: []
|
|
89
89
|
};
|
|
90
90
|
}
|
|
@@ -93,7 +93,7 @@ const Q = (t) => `${W}_${t}`, tt = (t, e) => {
|
|
|
93
93
|
consoleLog: s,
|
|
94
94
|
logOutputDir: n,
|
|
95
95
|
processLogFileNameList: o
|
|
96
|
-
} = e, c =
|
|
96
|
+
} = e, c = nt(), i = (o[0] === c ? o : [c, ...o]).slice(0, 10), u = process.env[q];
|
|
97
97
|
let l;
|
|
98
98
|
if (u)
|
|
99
99
|
try {
|
|
@@ -112,47 +112,52 @@ const Q = (t) => `${W}_${t}`, tt = (t, e) => {
|
|
|
112
112
|
/** 自身或祖先进程被劫持进程创建 行为预设信息 */
|
|
113
113
|
processCreateByHijackPresetInfo: l
|
|
114
114
|
};
|
|
115
|
-
},
|
|
116
|
-
series: t =
|
|
115
|
+
}, h = () => st() || Ht(), Ue = ({
|
|
116
|
+
series: t = Q,
|
|
117
117
|
consoleLog: e = !0
|
|
118
118
|
}) => {
|
|
119
|
-
const r =
|
|
120
|
-
...
|
|
119
|
+
const r = ot(t), s = {
|
|
120
|
+
...h(),
|
|
121
121
|
series: t,
|
|
122
122
|
consoleLog: e,
|
|
123
123
|
logOutputDir: r
|
|
124
124
|
};
|
|
125
|
-
return
|
|
126
|
-
},
|
|
125
|
+
return Bt(s);
|
|
126
|
+
}, it = () => h().processCreateByHijack, jt = () => h().processCreateByHijackPresetInfo, kt = (t = !1) => {
|
|
127
127
|
const e = f.resolve(
|
|
128
|
-
t ?
|
|
129
|
-
|
|
128
|
+
t ? K() : W(),
|
|
129
|
+
h().logOutputDir
|
|
130
130
|
);
|
|
131
|
-
return
|
|
132
|
-
},
|
|
133
|
-
const t =
|
|
131
|
+
return B(e) || g.mkdirSync(e, { recursive: !0 }), e;
|
|
132
|
+
}, xt = () => h().processLogFileNameList[1], Jt = (() => {
|
|
133
|
+
const t = mt({
|
|
134
134
|
logFilePath: f.resolve(
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
kt(),
|
|
136
|
+
nt()
|
|
137
137
|
)
|
|
138
138
|
});
|
|
139
139
|
let e = !1;
|
|
140
140
|
if (!e) {
|
|
141
|
-
const r =
|
|
141
|
+
const r = xt();
|
|
142
142
|
r && (t.info(`父进程日志文件: ${r}`), e = !0);
|
|
143
143
|
}
|
|
144
144
|
return t;
|
|
145
|
-
})(),
|
|
146
|
-
const
|
|
145
|
+
})(), Yt = () => {
|
|
146
|
+
const t = h();
|
|
147
|
+
return typeof t.consoleLog == "boolean" ? t.consoleLog : !!t.consoleLog.length;
|
|
148
|
+
}, Vt = (t) => {
|
|
149
|
+
if (it())
|
|
150
|
+
return !0;
|
|
151
|
+
const e = h();
|
|
147
152
|
return typeof e.consoleLog == "boolean" ? e.consoleLog : e.consoleLog.includes(t);
|
|
148
|
-
}, a =
|
|
149
|
-
isSwitchLogFile: (t) => !
|
|
153
|
+
}, a = _t({
|
|
154
|
+
isSwitchLogFile: (t) => [x.DEBUG].includes(t) ? !0 : !Vt(t),
|
|
150
155
|
enableColor: !0,
|
|
151
|
-
outputFileFn: (t, ...e) =>
|
|
152
|
-
consoleType:
|
|
156
|
+
outputFileFn: (t, ...e) => Jt.info({
|
|
157
|
+
consoleType: x[t],
|
|
153
158
|
consoleMessages: e
|
|
154
159
|
})
|
|
155
|
-
}),
|
|
160
|
+
}), He = (t, {
|
|
156
161
|
/** 当前目录 */
|
|
157
162
|
currentDir: e = process.cwd(),
|
|
158
163
|
/** 优先找最远的父目录 */
|
|
@@ -164,8 +169,8 @@ const Q = (t) => `${W}_${t}`, tt = (t, e) => {
|
|
|
164
169
|
if (g.existsSync(o))
|
|
165
170
|
return n;
|
|
166
171
|
}
|
|
167
|
-
},
|
|
168
|
-
function
|
|
172
|
+
}, ct = "aes-256-cbc", at = 16, v = "hex", F = ":";
|
|
173
|
+
function lt(t) {
|
|
169
174
|
return A.pbkdf2Sync(
|
|
170
175
|
t,
|
|
171
176
|
"done-coding-cli-salt",
|
|
@@ -177,38 +182,38 @@ function it(t) {
|
|
|
177
182
|
"sha256"
|
|
178
183
|
);
|
|
179
184
|
}
|
|
180
|
-
function
|
|
185
|
+
function je({
|
|
181
186
|
text: t,
|
|
182
187
|
secretKey: e
|
|
183
188
|
}) {
|
|
184
189
|
try {
|
|
185
|
-
const r =
|
|
186
|
-
|
|
190
|
+
const r = lt(e), s = A.randomBytes(at), n = A.createCipheriv(
|
|
191
|
+
ct,
|
|
187
192
|
r,
|
|
188
193
|
s
|
|
189
194
|
);
|
|
190
195
|
let o = n.update(t);
|
|
191
196
|
o = Buffer.concat([o, n.final()]);
|
|
192
197
|
const c = s.toString(v), i = o.toString(v);
|
|
193
|
-
return `${c}${
|
|
198
|
+
return `${c}${F}${i}`;
|
|
194
199
|
} catch (r) {
|
|
195
200
|
return a.error(
|
|
196
201
|
`加密失败: ${r instanceof Error ? r.message : String(r)}`
|
|
197
202
|
), "";
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
|
-
function
|
|
205
|
+
function ke({
|
|
201
206
|
encryptedText: t,
|
|
202
207
|
secretKey: e
|
|
203
208
|
}) {
|
|
204
209
|
try {
|
|
205
|
-
if (!t.includes(
|
|
210
|
+
if (!t.includes(F))
|
|
206
211
|
return "";
|
|
207
|
-
const r =
|
|
208
|
-
if (s.length !==
|
|
212
|
+
const r = lt(e), [s, n] = t.split(F);
|
|
213
|
+
if (s.length !== at * 2)
|
|
209
214
|
return "";
|
|
210
215
|
const o = Buffer.from(s, v), c = Buffer.from(n, v), i = A.createDecipheriv(
|
|
211
|
-
|
|
216
|
+
ct,
|
|
212
217
|
r,
|
|
213
218
|
o
|
|
214
219
|
);
|
|
@@ -222,27 +227,27 @@ function He({
|
|
|
222
227
|
), "";
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
|
-
const
|
|
230
|
+
const ut = {
|
|
226
231
|
/** prompts 开始等待用户输入 */
|
|
227
232
|
PROMPTS_START_WAIT_USER_INPUT: "PROMPTS_START_WAIT_USER_INPUT",
|
|
228
233
|
/** prompts 结束等待用户输入 */
|
|
229
234
|
PROMPTS_END_WAIT_USER_INPUT: "PROMPTS_END_WAIT_USER_INPUT"
|
|
230
|
-
},
|
|
231
|
-
type:
|
|
235
|
+
}, Kt = (t) => ({
|
|
236
|
+
type: ut.PROMPTS_START_WAIT_USER_INPUT,
|
|
232
237
|
data: t
|
|
233
|
-
}),
|
|
234
|
-
type:
|
|
235
|
-
}),
|
|
238
|
+
}), Wt = () => ({
|
|
239
|
+
type: ut.PROMPTS_END_WAIT_USER_INPUT
|
|
240
|
+
}), Y = (t) => (a.debug("发送进程自定义事件", t), new Promise((e, r) => {
|
|
236
241
|
process.send ? process.send(t, (s) => {
|
|
237
242
|
s ? (a.error("发送进程自定义事件失败", s), r(s)) : (a.debug("发送进程自定义事件成功", t), e());
|
|
238
243
|
}) : (a.error(
|
|
239
244
|
"进程自定义事件发送失败,process.send is not defined"
|
|
240
245
|
), r(new Error("process.send is not defined")));
|
|
241
|
-
})),
|
|
242
|
-
const [e, r = {}] = t, s =
|
|
246
|
+
})), H = async (...t) => {
|
|
247
|
+
const [e, r = {}] = t, s = it();
|
|
243
248
|
if (s) {
|
|
244
|
-
await
|
|
245
|
-
const o =
|
|
249
|
+
await Y(Kt(t));
|
|
250
|
+
const o = jt();
|
|
246
251
|
if (o != null && o.beforeInputExit) {
|
|
247
252
|
a.info(
|
|
248
253
|
"劫持进程设置在等待用户输入前退出",
|
|
@@ -256,7 +261,7 @@ const ct = {
|
|
|
256
261
|
), process.exit(1);
|
|
257
262
|
}
|
|
258
263
|
}
|
|
259
|
-
const n =
|
|
264
|
+
const n = St(e, {
|
|
260
265
|
onCancel(o) {
|
|
261
266
|
return a.error(
|
|
262
267
|
`您取消了 “${(o == null ? void 0 : o.message) || (o == null ? void 0 : o.name)}” 相关表单输入`
|
|
@@ -265,26 +270,26 @@ const ct = {
|
|
|
265
270
|
...r
|
|
266
271
|
});
|
|
267
272
|
return s && n.finally(() => {
|
|
268
|
-
|
|
273
|
+
Y(Wt());
|
|
269
274
|
}), n;
|
|
270
|
-
},
|
|
275
|
+
}, Xt = async ({
|
|
271
276
|
key: t,
|
|
272
277
|
presetAnswer: e,
|
|
273
278
|
defaultValue: r,
|
|
274
279
|
questionConfig: s
|
|
275
|
-
}) => (e == null ? void 0 : e[t]) ?? r ?? (s !== void 0 ? (await
|
|
280
|
+
}) => (e == null ? void 0 : e[t]) ?? r ?? (s !== void 0 ? (await H(s))[t] : void 0), xe = ({
|
|
276
281
|
presetAnswer: t
|
|
277
|
-
}) => async (e, r, s) =>
|
|
282
|
+
}) => async (e, r, s) => Xt({
|
|
278
283
|
key: e,
|
|
279
284
|
questionConfig: r,
|
|
280
285
|
defaultValue: s,
|
|
281
286
|
presetAnswer: t
|
|
282
|
-
}),
|
|
287
|
+
}), zt = (t, e) => {
|
|
283
288
|
t ? a.error(t) : a.error(e.message), e != null && e.stack && a.error(e.stack), process.exit(1);
|
|
284
|
-
},
|
|
285
|
-
const t =
|
|
286
|
-
return
|
|
287
|
-
},
|
|
289
|
+
}, Zt = () => {
|
|
290
|
+
const t = Ot(process.argv);
|
|
291
|
+
return Ct(t);
|
|
292
|
+
}, Je = ({
|
|
288
293
|
rootScriptName: t,
|
|
289
294
|
packageJson: e
|
|
290
295
|
}) => {
|
|
@@ -304,7 +309,7 @@ const ct = {
|
|
|
304
309
|
return process.platform === "win32" ? i.toLowerCase() : i;
|
|
305
310
|
}
|
|
306
311
|
}
|
|
307
|
-
},
|
|
312
|
+
}, ft = (t, {
|
|
308
313
|
usage: e,
|
|
309
314
|
version: r,
|
|
310
315
|
demandCommandCount: s,
|
|
@@ -316,27 +321,87 @@ const ct = {
|
|
|
316
321
|
let l = t.strict();
|
|
317
322
|
e && (l = l.usage(`Usage: ${e}`)), s && (l = l.demandCommand(s));
|
|
318
323
|
const m = "help";
|
|
319
|
-
return l = l.help(m), r ? l = l.version(r).alias("h", m).alias("v", "version") : l = l.alias("h", m), n && (l = l.options(n)), o && (l = Object.entries(o).reduce((
|
|
320
|
-
},
|
|
321
|
-
const r = await
|
|
322
|
-
|
|
324
|
+
return l = l.help(m), r ? l = l.version(r).alias("h", m).alias("v", "version") : l = l.alias("h", m), n && (l = l.options(n)), o && (l = Object.entries(o).reduce((S, [O, E]) => S.positional(O, E), l)), c && (l = l.command(c)), u && i && (l = l.scriptName(i)), l;
|
|
325
|
+
}, Ye = async ({ handler: t, ...e }) => {
|
|
326
|
+
const r = await ft(Zt(), e, !0).fail(
|
|
327
|
+
zt
|
|
323
328
|
).argv;
|
|
324
329
|
return t ? t(r) : r;
|
|
325
|
-
},
|
|
330
|
+
}, Ve = (t) => {
|
|
326
331
|
const { command: e, describe: r, handler: s = () => {
|
|
327
332
|
}, ...n } = t;
|
|
328
333
|
return {
|
|
329
334
|
command: e,
|
|
330
335
|
describe: r,
|
|
331
336
|
builder(o) {
|
|
332
|
-
return
|
|
337
|
+
return ft(o, n, !1);
|
|
333
338
|
},
|
|
334
339
|
handler: s
|
|
335
340
|
};
|
|
341
|
+
}, Ke = ({
|
|
342
|
+
command: t,
|
|
343
|
+
args: e,
|
|
344
|
+
env: r,
|
|
345
|
+
cwd: s,
|
|
346
|
+
beforeInputExit: n
|
|
347
|
+
}) => new Promise((o, c) => {
|
|
348
|
+
var C, y;
|
|
349
|
+
let i = !1;
|
|
350
|
+
const u = {
|
|
351
|
+
beforeInputExit: n
|
|
352
|
+
}, l = yt(t, e, {
|
|
353
|
+
cwd: s,
|
|
354
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
355
|
+
env: {
|
|
356
|
+
...r,
|
|
357
|
+
[q]: JSON.stringify(
|
|
358
|
+
u
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
}), m = () => {
|
|
362
|
+
i = !0, l.removeAllListeners();
|
|
363
|
+
}, S = (_) => {
|
|
364
|
+
i || (m(), c(_));
|
|
365
|
+
}, O = (_) => {
|
|
366
|
+
if (a.debug("劫持子进程消息:", _, i), !i)
|
|
367
|
+
switch (_.type) {
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
l.once("error", S), l.on("message", O);
|
|
371
|
+
let E = "", d = "";
|
|
372
|
+
(C = l.stdout) == null || C.on("data", (_) => {
|
|
373
|
+
E += _;
|
|
374
|
+
}), (y = l.stderr) == null || y.on("data", (_) => {
|
|
375
|
+
d += _;
|
|
376
|
+
}), l.once("exit", (_, I) => {
|
|
377
|
+
if (i)
|
|
378
|
+
return;
|
|
379
|
+
m();
|
|
380
|
+
const k = _ === 0;
|
|
381
|
+
k ? o({
|
|
382
|
+
success: k,
|
|
383
|
+
code: _ ?? null,
|
|
384
|
+
signal: I ?? null,
|
|
385
|
+
stdout: E,
|
|
386
|
+
stderr: d
|
|
387
|
+
}) : c(new Error(`进程退出,退出码: ${_}`));
|
|
388
|
+
});
|
|
389
|
+
}), p = (t, e = {}) => {
|
|
390
|
+
if (Yt())
|
|
391
|
+
return $(t, e);
|
|
392
|
+
{
|
|
393
|
+
const { stdio: r = "pipe" } = e;
|
|
394
|
+
return r === "inherit" ? (a.error(
|
|
395
|
+
"execSyncHijack: execSync 选项中 stdio 设置的值为 inherit,请在设置选项时根据 isAllowOutputConsole 判断是否允许输出到控制台"
|
|
396
|
+
), $(t, {
|
|
397
|
+
...e,
|
|
398
|
+
stdio: "ignore"
|
|
399
|
+
})) : $(t, e);
|
|
400
|
+
}
|
|
336
401
|
};
|
|
337
|
-
var
|
|
338
|
-
const
|
|
339
|
-
const { editorType: t } = await
|
|
402
|
+
var qt = /* @__PURE__ */ ((t) => (t.VSCODE = "VsCode", t.CURSOR = "Cursor", t.OTHER = "其他", t))(qt || {});
|
|
403
|
+
const Qt = async () => {
|
|
404
|
+
const { editorType: t } = await H([
|
|
340
405
|
{
|
|
341
406
|
name: "editorType",
|
|
342
407
|
type: "select",
|
|
@@ -353,24 +418,24 @@ const Zt = async () => {
|
|
|
353
418
|
}
|
|
354
419
|
]);
|
|
355
420
|
return t;
|
|
356
|
-
},
|
|
421
|
+
}, te = {
|
|
357
422
|
Cursor: "cursor",
|
|
358
423
|
VsCode: "code"
|
|
359
|
-
},
|
|
424
|
+
}, ee = (t, e, r) => {
|
|
360
425
|
try {
|
|
361
426
|
p(`${t} -v`, { stdio: "ignore" }), p(`${t} ${e}`);
|
|
362
427
|
} catch {
|
|
363
428
|
r();
|
|
364
429
|
}
|
|
365
|
-
},
|
|
430
|
+
}, re = (t, e) => {
|
|
366
431
|
const r = (s) => a.info(`
|
|
367
432
|
${s}, 请用编辑器打开 ${t} 进行编辑
|
|
368
433
|
`);
|
|
369
434
|
switch (e) {
|
|
370
435
|
case "Cursor":
|
|
371
436
|
case "VsCode": {
|
|
372
|
-
const s =
|
|
373
|
-
|
|
437
|
+
const s = te[e];
|
|
438
|
+
ee(s, t, () => {
|
|
374
439
|
r(`${s}命令未安装`);
|
|
375
440
|
});
|
|
376
441
|
break;
|
|
@@ -378,7 +443,7 @@ const Zt = async () => {
|
|
|
378
443
|
default:
|
|
379
444
|
r("其他编辑器");
|
|
380
445
|
}
|
|
381
|
-
},
|
|
446
|
+
}, se = (t = process.cwd()) => ({
|
|
382
447
|
/** 必须保留 */
|
|
383
448
|
rootDir: {
|
|
384
449
|
type: "string",
|
|
@@ -387,12 +452,12 @@ const Zt = async () => {
|
|
|
387
452
|
/** 必须设置默认值 */
|
|
388
453
|
default: t
|
|
389
454
|
}
|
|
390
|
-
}),
|
|
455
|
+
}), We = ({
|
|
391
456
|
configPathDefault: t,
|
|
392
457
|
rootDirDefault: e
|
|
393
458
|
}) => ({
|
|
394
459
|
/** 必须保留 */
|
|
395
|
-
...
|
|
460
|
+
...se(e),
|
|
396
461
|
/** 必须保留 */
|
|
397
462
|
configPath: {
|
|
398
463
|
type: "string",
|
|
@@ -401,52 +466,52 @@ const Zt = async () => {
|
|
|
401
466
|
/** 必须设置默认值 */
|
|
402
467
|
default: t
|
|
403
468
|
}
|
|
404
|
-
}),
|
|
469
|
+
}), ne = async (t, e) => {
|
|
405
470
|
const { configPath: r, rootDir: s } = e, n = f.resolve(s, r), o = f.dirname(n);
|
|
406
|
-
return
|
|
471
|
+
return L(o) || Et(o, {
|
|
407
472
|
recursive: !0
|
|
408
|
-
}), n.endsWith(".json5") ? (a.info(`json5模式写入 ${n}`),
|
|
409
|
-
},
|
|
473
|
+
}), n.endsWith(".json5") ? (a.info(`json5模式写入 ${n}`), G(n, X.stringify(t, null, 2)), n) : (a.info(`json模式写入 ${n}`), G(n, JSON.stringify(t, null, 2)), n);
|
|
474
|
+
}, Xe = async (t, e, {
|
|
410
475
|
onFileGenerated: r,
|
|
411
476
|
edit: s = !1
|
|
412
477
|
} = {}) => {
|
|
413
|
-
const n = await
|
|
478
|
+
const n = await ne(t, e);
|
|
414
479
|
if (r == null || r(n), s) {
|
|
415
|
-
const o = await
|
|
416
|
-
|
|
480
|
+
const o = await Qt();
|
|
481
|
+
re(e.configPath, o);
|
|
417
482
|
}
|
|
418
|
-
},
|
|
483
|
+
}, ze = async (t, e) => {
|
|
419
484
|
const { configPath: r, rootDir: s } = t, n = f.resolve(s, r);
|
|
420
|
-
if (!
|
|
485
|
+
if (!L(n)) {
|
|
421
486
|
if (e)
|
|
422
487
|
return a.info("配置文件不存在,使用onNotExists返回值"), e();
|
|
423
488
|
const o = `配置文件不存在 ${n}`;
|
|
424
489
|
throw new Error(o);
|
|
425
490
|
}
|
|
426
|
-
return n.endsWith(".json5") ? (a.info(`json5模式解析 ${n}`),
|
|
427
|
-
},
|
|
428
|
-
const { useDefaultConfig: t } = await
|
|
491
|
+
return n.endsWith(".json5") ? (a.info(`json5模式解析 ${n}`), X.parse(N(n, "utf8"))) : (a.info(`json模式解析 ${n}`), JSON.parse(N(n, "utf8")));
|
|
492
|
+
}, Ze = async () => {
|
|
493
|
+
const { useDefaultConfig: t } = await H({
|
|
429
494
|
name: "useDefaultConfig",
|
|
430
495
|
type: "confirm",
|
|
431
496
|
message: "使用默认模板配置",
|
|
432
497
|
initial: !0
|
|
433
498
|
});
|
|
434
499
|
return t;
|
|
435
|
-
},
|
|
500
|
+
}, gt = "package.json", j = ({
|
|
436
501
|
rootDir: t
|
|
437
502
|
}) => {
|
|
438
|
-
const e = f.resolve(t,
|
|
439
|
-
if (!
|
|
503
|
+
const e = f.resolve(t, gt);
|
|
504
|
+
if (!L(e))
|
|
440
505
|
throw new Error(`${t}未找到package.json文件`);
|
|
441
506
|
const r = N(e, "utf-8");
|
|
442
507
|
return JSON.parse(r);
|
|
443
|
-
},
|
|
508
|
+
}, oe = ({
|
|
444
509
|
rootDir: t,
|
|
445
510
|
pkgJson: e,
|
|
446
511
|
pkgName: r,
|
|
447
512
|
isDevPkg: s
|
|
448
513
|
}) => {
|
|
449
|
-
const n = e ||
|
|
514
|
+
const n = e || j({ rootDir: t }), o = s ? n.devDependencies : n.dependencies;
|
|
450
515
|
let c = o == null ? void 0 : o[r];
|
|
451
516
|
if (!c) {
|
|
452
517
|
const i = s ? n.dependencies : n.devDependencies;
|
|
@@ -456,22 +521,22 @@ const Zt = async () => {
|
|
|
456
521
|
return;
|
|
457
522
|
}
|
|
458
523
|
return c || a.info(`依赖包${r}未安装`), c;
|
|
459
|
-
},
|
|
524
|
+
}, qe = ({
|
|
460
525
|
patchConfig: t,
|
|
461
526
|
rootDir: e
|
|
462
527
|
}) => {
|
|
463
528
|
if (!t)
|
|
464
529
|
return;
|
|
465
|
-
const r =
|
|
466
|
-
|
|
467
|
-
},
|
|
530
|
+
const r = j({ rootDir: e }), s = Rt(r, t), n = f.resolve(e, gt);
|
|
531
|
+
G(n, JSON.stringify(s, null, 2), "utf-8");
|
|
532
|
+
}, M = (t) => {
|
|
468
533
|
const r = p("git rev-parse --show-toplevel", {
|
|
469
534
|
cwd: t
|
|
470
535
|
}).toString();
|
|
471
536
|
if (!r)
|
|
472
537
|
throw new Error("获取git根目录失败");
|
|
473
538
|
return r.trim();
|
|
474
|
-
},
|
|
539
|
+
}, Qe = () => {
|
|
475
540
|
var t;
|
|
476
541
|
try {
|
|
477
542
|
const e = p("git symbolic-ref --short HEAD", {
|
|
@@ -488,7 +553,7 @@ const Zt = async () => {
|
|
|
488
553
|
return;
|
|
489
554
|
}
|
|
490
555
|
}
|
|
491
|
-
},
|
|
556
|
+
}, ie = (t) => {
|
|
492
557
|
const e = t.match(/moving\s+from\s+(.*)\s+to\s+(.*)/);
|
|
493
558
|
if (e) {
|
|
494
559
|
const [, r, s] = e;
|
|
@@ -498,28 +563,28 @@ const Zt = async () => {
|
|
|
498
563
|
};
|
|
499
564
|
}
|
|
500
565
|
};
|
|
501
|
-
var
|
|
502
|
-
const
|
|
503
|
-
const e =
|
|
566
|
+
var R = /* @__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))(R || {});
|
|
567
|
+
const ce = "husky", ae = ".husky", le = ({ rootDir: t }) => {
|
|
568
|
+
const e = M(t), r = oe({
|
|
504
569
|
rootDir: e,
|
|
505
|
-
pkgJson:
|
|
506
|
-
pkgName:
|
|
570
|
+
pkgJson: j({ rootDir: e }),
|
|
571
|
+
pkgName: ce,
|
|
507
572
|
isDevPkg: !0
|
|
508
573
|
});
|
|
509
574
|
if (!r)
|
|
510
575
|
throw new Error("husky版本获取失败, 可能husky未安装");
|
|
511
576
|
const s = r.replace(/^(\^|~)/, ""), n = "<9.0.0";
|
|
512
|
-
return
|
|
577
|
+
return It.satisfies(s, n) ? (a.info(`${s}符合${n}`), `#!/usr/bin/env sh
|
|
513
578
|
. "$(dirname -- "$0")/_/husky.sh"`) : (a.info(`${s}不符合${n}`), "");
|
|
514
|
-
},
|
|
515
|
-
const e =
|
|
516
|
-
return f.resolve(e,
|
|
517
|
-
},
|
|
579
|
+
}, ue = ({ rootDir: t }) => {
|
|
580
|
+
const e = M(t);
|
|
581
|
+
return f.resolve(e, ae);
|
|
582
|
+
}, tr = ({
|
|
518
583
|
hookNames: t,
|
|
519
584
|
rootDir: e,
|
|
520
585
|
getCode: r
|
|
521
586
|
}) => {
|
|
522
|
-
const s =
|
|
587
|
+
const s = ue({ rootDir: e });
|
|
523
588
|
g.existsSync(s) || g.mkdirSync(s, { recursive: !0 }), t.forEach((n) => {
|
|
524
589
|
const o = f.resolve(s, n), c = g.existsSync(o);
|
|
525
590
|
let i = r(n);
|
|
@@ -533,7 +598,7 @@ ${i}
|
|
|
533
598
|
`
|
|
534
599
|
), a.success(`${o} 添加 ${n}相关调用成功`));
|
|
535
600
|
else {
|
|
536
|
-
const u =
|
|
601
|
+
const u = le({
|
|
537
602
|
rootDir: e
|
|
538
603
|
});
|
|
539
604
|
g.writeFileSync(
|
|
@@ -545,27 +610,27 @@ ${i}
|
|
|
545
610
|
"utf-8"
|
|
546
611
|
), a.success(`${o} 添加 ${n}相关调用成功`);
|
|
547
612
|
}
|
|
548
|
-
|
|
613
|
+
Mt(o);
|
|
549
614
|
});
|
|
550
|
-
},
|
|
615
|
+
}, er = [
|
|
551
616
|
// HooksNameEnum.PRE_MERGE_COMMIT,
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
],
|
|
617
|
+
R.PREPARE_COMMIT_MSG,
|
|
618
|
+
R.COMMIT_MSG
|
|
619
|
+
], rr = ({
|
|
555
620
|
hookName: t,
|
|
556
621
|
rootDir: e
|
|
557
622
|
}) => {
|
|
558
|
-
const r =
|
|
623
|
+
const r = M(e), s = f.resolve(r, ".git");
|
|
559
624
|
switch (t) {
|
|
560
|
-
case
|
|
561
|
-
case
|
|
625
|
+
case R.PREPARE_COMMIT_MSG:
|
|
626
|
+
case R.COMMIT_MSG: {
|
|
562
627
|
const n = f.resolve(s, "MERGE_MSG");
|
|
563
|
-
if (
|
|
628
|
+
if (L(n))
|
|
564
629
|
return N(n, "utf-8");
|
|
565
630
|
}
|
|
566
631
|
}
|
|
567
632
|
return "";
|
|
568
|
-
},
|
|
633
|
+
}, sr = ({
|
|
569
634
|
remoteAlias: t = "origin"
|
|
570
635
|
} = {}) => {
|
|
571
636
|
try {
|
|
@@ -600,7 +665,7 @@ ${i}
|
|
|
600
665
|
} catch (e) {
|
|
601
666
|
throw a.error("获取git最后提交信息失败"), e;
|
|
602
667
|
}
|
|
603
|
-
},
|
|
668
|
+
}, pt = (t = "") => {
|
|
604
669
|
const e = /\s*Merge\s+branch\s+['|"](.+)['|"]\s+into\s+['|"](.+)['|"]\s*/i, r = t.match(e);
|
|
605
670
|
if (r) {
|
|
606
671
|
const [, i, u] = r;
|
|
@@ -624,12 +689,12 @@ ${i}
|
|
|
624
689
|
fromBranch: i
|
|
625
690
|
};
|
|
626
691
|
}
|
|
627
|
-
},
|
|
628
|
-
if (t.startsWith(
|
|
692
|
+
}, fe = (t) => {
|
|
693
|
+
if (t.startsWith(b.MERGE))
|
|
629
694
|
return {
|
|
630
|
-
fromBranch: t.replace(
|
|
695
|
+
fromBranch: t.replace(b.MERGE, "").trim()
|
|
631
696
|
};
|
|
632
|
-
},
|
|
697
|
+
}, nr = () => {
|
|
633
698
|
const t = process.env.GIT_REFLOG_ACTION || "";
|
|
634
699
|
if (!t)
|
|
635
700
|
return;
|
|
@@ -648,15 +713,15 @@ ${i}
|
|
|
648
713
|
};
|
|
649
714
|
}
|
|
650
715
|
};
|
|
651
|
-
var
|
|
652
|
-
const
|
|
716
|
+
var b = /* @__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))(b || {});
|
|
717
|
+
const V = "__GIT_REPLACE_MARK__", T = {
|
|
653
718
|
stringify(t) {
|
|
654
|
-
return JSON.stringify(t).replace(/"/g,
|
|
719
|
+
return JSON.stringify(t).replace(/"/g, V);
|
|
655
720
|
},
|
|
656
721
|
parse(t) {
|
|
657
|
-
return JSON.parse(t.replace(new RegExp(
|
|
722
|
+
return JSON.parse(t.replace(new RegExp(V, "g"), '"'));
|
|
658
723
|
}
|
|
659
|
-
},
|
|
724
|
+
}, or = ({
|
|
660
725
|
count: t = 100
|
|
661
726
|
} = {}) => {
|
|
662
727
|
if (t <= 0)
|
|
@@ -687,10 +752,10 @@ const J = "__GIT_REPLACE_MARK__", T = {
|
|
|
687
752
|
const c = T.parse(o);
|
|
688
753
|
return {
|
|
689
754
|
...c,
|
|
690
|
-
mergeInfo:
|
|
755
|
+
mergeInfo: pt(c.message)
|
|
691
756
|
};
|
|
692
757
|
});
|
|
693
|
-
},
|
|
758
|
+
}, ir = ({
|
|
694
759
|
count: t = 100,
|
|
695
760
|
filterItem: e = () => !0
|
|
696
761
|
} = {}) => {
|
|
@@ -709,38 +774,38 @@ const J = "__GIT_REPLACE_MARK__", T = {
|
|
|
709
774
|
)}"`
|
|
710
775
|
).toString().split(`
|
|
711
776
|
`).map((i) => T.parse(i)).filter(e).map((i) => {
|
|
712
|
-
const { fullMessage: u, ...l } = i, m = ":", [
|
|
713
|
-
let
|
|
777
|
+
const { fullMessage: u, ...l } = i, m = ":", [S] = u.split(m, 1), O = u.slice(`${S}${m}`.length), E = S.trim(), d = O.trim();
|
|
778
|
+
let C, y, _;
|
|
714
779
|
if (E.startsWith(
|
|
715
780
|
"checkout"
|
|
716
781
|
/* CHECKOUT */
|
|
717
782
|
))
|
|
718
|
-
|
|
783
|
+
y = ie(d);
|
|
719
784
|
else if (E.startsWith(
|
|
720
785
|
"merge"
|
|
721
786
|
/* MERGE */
|
|
722
787
|
))
|
|
723
|
-
|
|
788
|
+
C = fe(E);
|
|
724
789
|
else if (E.startsWith(
|
|
725
790
|
"commit (merge)"
|
|
726
791
|
/* COMMIT_MERGE */
|
|
727
792
|
)) {
|
|
728
|
-
const I =
|
|
793
|
+
const I = pt(d);
|
|
729
794
|
I || a.warn(
|
|
730
795
|
`${i.hash} 是合并提交 但是未从提交信息(${d})中检测到合并分支信息,推测手动更改了提交内容`
|
|
731
|
-
),
|
|
796
|
+
), C = I;
|
|
732
797
|
}
|
|
733
798
|
return {
|
|
734
799
|
...l,
|
|
735
800
|
type: E,
|
|
736
801
|
message: d,
|
|
737
|
-
mergeInfo:
|
|
738
|
-
checkoutInfo:
|
|
802
|
+
mergeInfo: C,
|
|
803
|
+
checkoutInfo: y,
|
|
739
804
|
rebaseInfo: _
|
|
740
805
|
};
|
|
741
806
|
});
|
|
742
|
-
},
|
|
743
|
-
const e =
|
|
807
|
+
}, cr = (t) => {
|
|
808
|
+
const e = M(t), r = f.resolve(e, ".git"), s = f.resolve(r, "rebase-merge");
|
|
744
809
|
if (g.existsSync(s))
|
|
745
810
|
return !0;
|
|
746
811
|
const n = f.resolve(r, "rebase-apply");
|
|
@@ -748,7 +813,7 @@ const J = "__GIT_REPLACE_MARK__", T = {
|
|
|
748
813
|
return !0;
|
|
749
814
|
const o = f.resolve(r, "REBASE_HEAD");
|
|
750
815
|
return !!g.existsSync(o);
|
|
751
|
-
},
|
|
816
|
+
}, ar = ({
|
|
752
817
|
branchName: t,
|
|
753
818
|
version: e,
|
|
754
819
|
remoteInfo: r
|
|
@@ -758,19 +823,19 @@ const J = "__GIT_REPLACE_MARK__", T = {
|
|
|
758
823
|
}), p(`git push ${r.alias} ${t}`, {
|
|
759
824
|
stdio: "inherit"
|
|
760
825
|
}));
|
|
761
|
-
},
|
|
826
|
+
}, ge = (t) => /^https?:\/\//.test(t), pe = (t) => /^git@/.test(t), lr = (t) => {
|
|
762
827
|
const { hostname: e, pathname: r } = new URL(t);
|
|
763
828
|
return `git@${e}:${r.replace("/", "")}`;
|
|
764
|
-
},
|
|
829
|
+
}, me = (t) => f.resolve(t, ".git"), ur = (t) => Dt(me(t)), _e = ({
|
|
765
830
|
dir: t,
|
|
766
831
|
fn: e,
|
|
767
832
|
endClear: r = !0,
|
|
768
833
|
exitClear: s = !0
|
|
769
834
|
}) => {
|
|
770
|
-
if (
|
|
835
|
+
if (B(t))
|
|
771
836
|
return a.error(`${t} 已存在,请手动删除该目录再试`), process.exit(1);
|
|
772
837
|
const n = () => {
|
|
773
|
-
|
|
838
|
+
$t(t);
|
|
774
839
|
};
|
|
775
840
|
s && process.once("exit", () => {
|
|
776
841
|
n();
|
|
@@ -782,19 +847,19 @@ const J = "__GIT_REPLACE_MARK__", T = {
|
|
|
782
847
|
throw r && n(), c;
|
|
783
848
|
}
|
|
784
849
|
return r && (o instanceof Promise ? o.finally(n) : n()), o;
|
|
785
|
-
},
|
|
786
|
-
var
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
`${t}-${
|
|
791
|
-
),
|
|
792
|
-
const t =
|
|
793
|
-
ASSETS_CONFIG_REPO_URL:
|
|
850
|
+
}, Ee = () => ht();
|
|
851
|
+
var de = /* @__PURE__ */ ((t) => (t.ASSETS_CONFIG_REPO_URL = "ASSETS_CONFIG_REPO_URL", t))(de || {});
|
|
852
|
+
const he = (t) => f.resolve(
|
|
853
|
+
W(),
|
|
854
|
+
Pt,
|
|
855
|
+
`${t}-${Ee()}`
|
|
856
|
+
), Se = () => f.resolve(K(), vt), Ce = async () => {
|
|
857
|
+
const t = Se(), e = {
|
|
858
|
+
ASSETS_CONFIG_REPO_URL: Lt
|
|
794
859
|
};
|
|
795
860
|
try {
|
|
796
|
-
if (await
|
|
797
|
-
const r = await
|
|
861
|
+
if (await U(t)) {
|
|
862
|
+
const r = await tt(t, {});
|
|
798
863
|
Object.entries(r).forEach(([s, n]) => {
|
|
799
864
|
e[s] = n;
|
|
800
865
|
});
|
|
@@ -802,32 +867,39 @@ const Ee = (t) => f.resolve(
|
|
|
802
867
|
} catch {
|
|
803
868
|
}
|
|
804
869
|
return e;
|
|
805
|
-
},
|
|
806
|
-
if (
|
|
870
|
+
}, Oe = async (t) => {
|
|
871
|
+
if (a.debug(
|
|
872
|
+
`创建本地资产配置临时仓库,临时目录: ${t}`
|
|
873
|
+
), await U(t))
|
|
807
874
|
return a.error(`${t} 已存在,请手动删除该目录再试`), process.exit(1);
|
|
808
875
|
const {
|
|
809
876
|
[
|
|
810
877
|
"ASSETS_CONFIG_REPO_URL"
|
|
811
878
|
/* ASSETS_CONFIG_REPO_URL */
|
|
812
879
|
]: e
|
|
813
|
-
} = await
|
|
814
|
-
return
|
|
880
|
+
} = await Ce();
|
|
881
|
+
return pe(e) || ge(e) ? p(
|
|
882
|
+
`git clone ${e} ${t} --depth=1`,
|
|
883
|
+
{
|
|
884
|
+
stdio: "ignore"
|
|
885
|
+
}
|
|
886
|
+
) : (g.mkdirSync(t, { recursive: !0 }), p(`cp -r ${e}/ ${t}/`)), {
|
|
815
887
|
assetConfigRepoUrl: e
|
|
816
888
|
};
|
|
817
|
-
},
|
|
889
|
+
}, fr = async ({
|
|
818
890
|
moduleName: t,
|
|
819
891
|
onSuccess: e
|
|
820
|
-
}) => (a.stage(`拉取${t}配置,请稍等...`),
|
|
892
|
+
}) => (a.stage(`拉取${t}配置,请稍等...`), _e({
|
|
821
893
|
// 资源配置仓库临时文件夹
|
|
822
|
-
dir:
|
|
894
|
+
dir: he(t),
|
|
823
895
|
fn: async (r) => {
|
|
824
|
-
const { assetConfigRepoUrl: s } = await
|
|
825
|
-
|
|
896
|
+
const { assetConfigRepoUrl: s } = await Oe(r), n = f.join(
|
|
897
|
+
Nt,
|
|
826
898
|
t
|
|
827
899
|
), o = f.join(
|
|
828
900
|
n,
|
|
829
|
-
|
|
830
|
-
), c = f.resolve(r, o), i = await
|
|
901
|
+
At
|
|
902
|
+
), c = f.resolve(r, o), i = await tt(c);
|
|
831
903
|
return await e({
|
|
832
904
|
repoUrl: s,
|
|
833
905
|
config: i,
|
|
@@ -836,130 +908,84 @@ const Ee = (t) => f.resolve(
|
|
|
836
908
|
assetsConfigRepoTempDir: r
|
|
837
909
|
}), i;
|
|
838
910
|
}
|
|
839
|
-
})),
|
|
840
|
-
command: t,
|
|
841
|
-
args: e,
|
|
842
|
-
env: r,
|
|
843
|
-
cwd: s,
|
|
844
|
-
beforeInputExit: n
|
|
845
|
-
}) => new Promise((o, c) => {
|
|
846
|
-
var S, R;
|
|
847
|
-
let i = !1;
|
|
848
|
-
const u = {
|
|
849
|
-
beforeInputExit: n
|
|
850
|
-
}, l = Ct(t, e, {
|
|
851
|
-
cwd: s,
|
|
852
|
-
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
853
|
-
env: {
|
|
854
|
-
...r,
|
|
855
|
-
[z]: JSON.stringify(
|
|
856
|
-
u
|
|
857
|
-
)
|
|
858
|
-
}
|
|
859
|
-
}), m = () => {
|
|
860
|
-
i = !0, l.removeAllListeners();
|
|
861
|
-
}, h = (_) => {
|
|
862
|
-
i || (m(), c(_));
|
|
863
|
-
}, O = (_) => {
|
|
864
|
-
if (a.debug("劫持子进程消息:", _, i), !i)
|
|
865
|
-
switch (_.type) {
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
l.once("error", h), l.on("message", O);
|
|
869
|
-
let E = "", d = "";
|
|
870
|
-
(S = l.stdout) == null || S.on("data", (_) => {
|
|
871
|
-
E += _;
|
|
872
|
-
}), (R = l.stderr) == null || R.on("data", (_) => {
|
|
873
|
-
d += _;
|
|
874
|
-
}), l.once("exit", (_, I) => {
|
|
875
|
-
if (i)
|
|
876
|
-
return;
|
|
877
|
-
m();
|
|
878
|
-
const j = _ === 0;
|
|
879
|
-
j ? o({
|
|
880
|
-
success: j,
|
|
881
|
-
code: _ ?? null,
|
|
882
|
-
signal: I ?? null,
|
|
883
|
-
stdout: E,
|
|
884
|
-
stderr: d
|
|
885
|
-
}) : c(new Error(`进程退出,退出码: ${_}`));
|
|
886
|
-
});
|
|
887
|
-
});
|
|
911
|
+
})), ye = /[^a-zA-Z0-9._\-]/, Re = /[^a-zA-Z0-9._\-]/g, gr = (t) => t ? !ye.test(t) : !1, pr = (t) => (t || "_").replace(Re, "_"), mr = (t) => Object.entries(t).map(([e, r]) => `--${e}=${r}`);
|
|
888
912
|
export {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
913
|
+
de as DoneCodingCliGlobalConfigKeyEnum,
|
|
914
|
+
qt as EditorTypeEnum,
|
|
915
|
+
bt as EnvConfigProcessKeyEnum,
|
|
916
|
+
b as GitRefLogTypeEnum,
|
|
917
|
+
R as HooksNameEnum,
|
|
918
|
+
er as SUPPORT_GET_COMMIT_BY_HOOKS_NAMES,
|
|
919
|
+
Nr as _curry,
|
|
920
|
+
yr as _get,
|
|
921
|
+
Ir as _set,
|
|
922
|
+
tr as addHuskyHooks,
|
|
923
|
+
qe as addPackageConfig,
|
|
924
|
+
_e as applyUseTempDir,
|
|
925
|
+
B as assetIsExits,
|
|
926
|
+
U as assetIsExitsAsync,
|
|
927
|
+
vr as chalk,
|
|
928
|
+
cr as checkCurrentIsRebasing,
|
|
929
|
+
Ye as createMainCommand,
|
|
930
|
+
Ve as createSubcommand,
|
|
931
|
+
dr as dayjs,
|
|
932
|
+
ke as decryptAES,
|
|
933
|
+
je as encryptAES,
|
|
934
|
+
p as execSyncHijack,
|
|
935
|
+
Mt as fileAddX,
|
|
936
|
+
xe as generateGetAnswerSwiftFn,
|
|
937
|
+
Xt as getAnswer,
|
|
938
|
+
he as getCliModuleTempDir,
|
|
939
|
+
rr as getCommitByHookName,
|
|
940
|
+
We as getConfigFileCommonOptions,
|
|
941
|
+
or as getCurrentBranchLastCommitList,
|
|
942
|
+
Qe as getCurrentBranchName,
|
|
943
|
+
nt as getCurrentProcessLogFileName,
|
|
944
|
+
Qt as getEditorType,
|
|
945
|
+
sr as getGitLastCommitInfo,
|
|
946
|
+
me as getGitPath,
|
|
947
|
+
M as getGitProjectDir,
|
|
948
|
+
ir as getLastReflogList,
|
|
949
|
+
kt as getLogOutputDir,
|
|
950
|
+
j as getPackageJson,
|
|
951
|
+
xt as getParentProcessLogFileName,
|
|
952
|
+
jt as getProcessCreateByHijackPresetInfo,
|
|
953
|
+
rt as getProcessEnv,
|
|
954
|
+
oe as getRelyPkgVersion,
|
|
955
|
+
se as getRootDirOptions,
|
|
956
|
+
Je as getRootScriptName,
|
|
957
|
+
pr as getSafePath,
|
|
958
|
+
Ze as getUseDefaultConfig,
|
|
959
|
+
Ke as hijackChildProcess,
|
|
960
|
+
lr as http2sshGitUrl,
|
|
961
|
+
ne as initConfigFile,
|
|
962
|
+
Xe as initHandlerCommon,
|
|
963
|
+
Yt as isAllowOutputConsole,
|
|
964
|
+
ge as isHttpGitUrl,
|
|
965
|
+
pe as isSshGitUrl,
|
|
966
|
+
Cr as json5,
|
|
967
|
+
Jt as logger,
|
|
968
|
+
He as lookForParentTarget,
|
|
969
|
+
re as openFileInEditor,
|
|
944
970
|
a as outputConsole,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
971
|
+
mr as params2cliParams,
|
|
972
|
+
gr as pathIsSafe,
|
|
973
|
+
it as processIsHijacked,
|
|
974
|
+
ar as pushGitPublishInfoToRemote,
|
|
975
|
+
fr as readCliModuleAssetsConfig,
|
|
976
|
+
ze as readConfigFile,
|
|
977
|
+
Gt as readFile,
|
|
978
|
+
Ft as readFileAsync,
|
|
979
|
+
Be as readJsonFile,
|
|
980
|
+
tt as readJsonFileAsync,
|
|
981
|
+
$t as removeAsset,
|
|
982
|
+
Dt as removeAssetAsync,
|
|
983
|
+
ie as resolveCheckoutInfoByRefInfo,
|
|
984
|
+
pt as resolveMergeInfoByCommitMsg,
|
|
985
|
+
nr as resolveMergeInfoByGitReflogAction,
|
|
986
|
+
fe as resolveMergeInfoByRefType,
|
|
987
|
+
ur as rmGitCtrlAsync,
|
|
988
|
+
Ue as updateEnvConfig,
|
|
989
|
+
Ee as uuidv4,
|
|
990
|
+
H as xPrompts
|
|
965
991
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-utils",
|
|
3
|
-
"version": "0.8.3-alpha.
|
|
3
|
+
"version": "0.8.3-alpha.2",
|
|
4
4
|
"description": "cli utils",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=18.0.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "57548a940adaa810d2d0c870df54d5013a86bfed"
|
|
73
73
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import type { CommandModule } from 'yargs';
|
|
4
4
|
import _curry from 'lodash.curry';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
|
+
import type { ExecSyncOptions } from 'node:child_process';
|
|
6
7
|
import _get from 'lodash.get';
|
|
7
8
|
import json5 from 'json5';
|
|
8
9
|
import { OutputConsole } from '@done-coding/output-node';
|
|
@@ -220,6 +221,9 @@ export declare enum EnvConfigProcessKeyEnum {
|
|
|
220
221
|
GLOBAL_CONFIG_IMAGE = "GLOBAL_CONFIG_IMAGE"
|
|
221
222
|
}
|
|
222
223
|
|
|
224
|
+
/** 劫持 execSync */
|
|
225
|
+
export declare const execSyncHijack: (command: string, options?: ExecSyncOptions) => string | Buffer;
|
|
226
|
+
|
|
223
227
|
/** 文件添加执行权限 */
|
|
224
228
|
export declare const fileAddX: (filePath: string) => void;
|
|
225
229
|
|
|
@@ -578,6 +582,9 @@ export declare const initHandlerCommon: <T>(content: T, argv: CliHandlerArgv<Ini
|
|
|
578
582
|
edit?: boolean;
|
|
579
583
|
}) => Promise<void>;
|
|
580
584
|
|
|
585
|
+
/** 是否允许控制台输出 */
|
|
586
|
+
export declare const isAllowOutputConsole: () => boolean;
|
|
587
|
+
|
|
581
588
|
/** 是http git地址 */
|
|
582
589
|
export declare const isHttpGitUrl: (url: string) => boolean;
|
|
583
590
|
|