@done-coding/cli-utils 0.7.5 → 0.7.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/es/index.mjs +25 -25
- package/package.json +2 -2
package/es/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import p from "chalk";
|
|
3
3
|
import { default as se } from "chalk";
|
|
4
4
|
import g from "node:path";
|
|
5
|
-
import m, { existsSync as y, mkdirSync as W, writeFileSync as
|
|
5
|
+
import m, { existsSync as y, mkdirSync as W, writeFileSync as D, readFileSync as v, rmSync as X } from "node:fs";
|
|
6
6
|
import _ from "crypto";
|
|
7
7
|
import q from "prompts";
|
|
8
8
|
import z from "yargs";
|
|
@@ -40,13 +40,13 @@ const l = Object.assign(
|
|
|
40
40
|
/** 优先找最远的父目录 */
|
|
41
41
|
isFindFarthest: e = !0
|
|
42
42
|
} = {}) => {
|
|
43
|
-
const o = g.resolve(r).split(g.sep).map((s, n, c) =>
|
|
43
|
+
const o = g.resolve(r).split(g.sep).map((s, n, c) => c.slice(0, n).concat(s).join(g.sep) || g.sep);
|
|
44
44
|
for (; o.length; ) {
|
|
45
45
|
const s = e ? o.shift() : o.pop(), n = g.join(s, t);
|
|
46
46
|
if (m.existsSync(n))
|
|
47
47
|
return s;
|
|
48
48
|
}
|
|
49
|
-
}, N = "aes-256-cbc", F = 16, M = "hex",
|
|
49
|
+
}, N = "aes-256-cbc", F = 16, M = "hex", w = ":";
|
|
50
50
|
function G(t) {
|
|
51
51
|
return _.pbkdf2Sync(
|
|
52
52
|
t,
|
|
@@ -68,7 +68,7 @@ function kt({
|
|
|
68
68
|
let n = s.update(t);
|
|
69
69
|
n = Buffer.concat([n, s.final()]);
|
|
70
70
|
const c = o.toString(M), i = n.toString(M);
|
|
71
|
-
return `${c}${
|
|
71
|
+
return `${c}${w}${i}`;
|
|
72
72
|
} catch (e) {
|
|
73
73
|
return l.error(
|
|
74
74
|
`加密失败: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -80,9 +80,9 @@ function jt({
|
|
|
80
80
|
secretKey: r
|
|
81
81
|
}) {
|
|
82
82
|
try {
|
|
83
|
-
if (!t.includes(
|
|
83
|
+
if (!t.includes(w))
|
|
84
84
|
return "";
|
|
85
|
-
const e = G(r), [o, s] = t.split(
|
|
85
|
+
const e = G(r), [o, s] = t.split(w);
|
|
86
86
|
if (o.length !== F * 2)
|
|
87
87
|
return "";
|
|
88
88
|
const n = Buffer.from(o, M), c = Buffer.from(s, M), i = _.createDecipheriv(N, e, n);
|
|
@@ -138,8 +138,8 @@ const L = (...t) => {
|
|
|
138
138
|
}, a) => {
|
|
139
139
|
let f = t.strict();
|
|
140
140
|
r && (f = f.usage(`Usage: ${r}`)), o && (f = f.demandCommand(o));
|
|
141
|
-
const
|
|
142
|
-
return f = f.help(
|
|
141
|
+
const h = "help";
|
|
142
|
+
return f = f.help(h), e ? f = f.version(e).alias("h", h).alias("v", "version") : f = f.alias("h", h), s && (f = f.options(s)), n && (f = Object.entries(n).reduce((S, [P, d]) => S.positional(P, d), f)), c && (f = f.command(c)), a && i && (f = f.scriptName(i)), f;
|
|
143
143
|
}, Ht = async ({ handler: t, ...r }) => {
|
|
144
144
|
const e = await J(ot(), r, !0).fail(
|
|
145
145
|
rt
|
|
@@ -228,7 +228,7 @@ const nt = async () => {
|
|
|
228
228
|
const { configPath: e, rootDir: o } = r, s = g.resolve(o, e), n = g.dirname(s);
|
|
229
229
|
return y(n) || W(n, {
|
|
230
230
|
recursive: !0
|
|
231
|
-
}), s.endsWith(".json5") ? (l.info(`json5模式写入 ${s}`),
|
|
231
|
+
}), s.endsWith(".json5") ? (l.info(`json5模式写入 ${s}`), D(s, H.stringify(t, null, 2)), s) : (l.info(`json模式写入 ${s}`), D(s, JSON.stringify(t, null, 2)), s);
|
|
232
232
|
}, Gt = async (t, r, {
|
|
233
233
|
onFileGenerated: e,
|
|
234
234
|
edit: o = !1
|
|
@@ -255,7 +255,7 @@ const nt = async () => {
|
|
|
255
255
|
initial: !0
|
|
256
256
|
});
|
|
257
257
|
return t;
|
|
258
|
-
}, U = "package.json",
|
|
258
|
+
}, U = "package.json", T = ({
|
|
259
259
|
rootDir: t
|
|
260
260
|
}) => {
|
|
261
261
|
const r = g.resolve(t, U);
|
|
@@ -269,7 +269,7 @@ const nt = async () => {
|
|
|
269
269
|
pkgName: e,
|
|
270
270
|
isDevPkg: o
|
|
271
271
|
}) => {
|
|
272
|
-
const s = r ||
|
|
272
|
+
const s = r || T({ rootDir: t }), n = o ? s.devDependencies : s.dependencies;
|
|
273
273
|
let c = n == null ? void 0 : n[e];
|
|
274
274
|
if (!c) {
|
|
275
275
|
const i = o ? s.dependencies : s.devDependencies;
|
|
@@ -287,8 +287,8 @@ const nt = async () => {
|
|
|
287
287
|
}) => {
|
|
288
288
|
if (!t)
|
|
289
289
|
return;
|
|
290
|
-
const e =
|
|
291
|
-
|
|
290
|
+
const e = T({ rootDir: r }), o = Z(e, t), s = g.resolve(r, U);
|
|
291
|
+
D(s, JSON.stringify(o, null, 2), "utf-8");
|
|
292
292
|
}, O = (t) => {
|
|
293
293
|
const e = u("git rev-parse --show-toplevel", {
|
|
294
294
|
cwd: t
|
|
@@ -332,7 +332,7 @@ var R = /* @__PURE__ */ ((t) => (t.PRE_COMMIT = "pre-commit", t.PRE_MERGE_COMMIT
|
|
|
332
332
|
const pt = "husky", ht = ".husky", dt = ({ rootDir: t }) => {
|
|
333
333
|
const r = O(t), e = gt({
|
|
334
334
|
rootDir: r,
|
|
335
|
-
pkgJson:
|
|
335
|
+
pkgJson: T({ rootDir: r }),
|
|
336
336
|
pkgName: pt,
|
|
337
337
|
isDevPkg: !0
|
|
338
338
|
});
|
|
@@ -455,9 +455,9 @@ ${i}
|
|
|
455
455
|
};
|
|
456
456
|
}
|
|
457
457
|
}, Rt = (t) => {
|
|
458
|
-
if (t.startsWith(
|
|
458
|
+
if (t.startsWith(A.MERGE))
|
|
459
459
|
return {
|
|
460
|
-
fromBranch: t.replace(
|
|
460
|
+
fromBranch: t.replace(A.MERGE, "").trim()
|
|
461
461
|
};
|
|
462
462
|
}, qt = () => {
|
|
463
463
|
const t = process.env.GIT_REFLOG_ACTION || "";
|
|
@@ -478,7 +478,7 @@ ${i}
|
|
|
478
478
|
};
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
|
-
var
|
|
481
|
+
var A = /* @__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))(A || {});
|
|
482
482
|
const j = "__GIT_REPLACE_MARK__", $ = {
|
|
483
483
|
stringify(t) {
|
|
484
484
|
return JSON.stringify(t).replace(/"/g, j);
|
|
@@ -539,19 +539,19 @@ const j = "__GIT_REPLACE_MARK__", $ = {
|
|
|
539
539
|
)}"`
|
|
540
540
|
).toString().split(`
|
|
541
541
|
`).map((i) => $.parse(i)).filter(r).map((i) => {
|
|
542
|
-
const { fullMessage: a, ...f } = i,
|
|
542
|
+
const { fullMessage: a, ...f } = i, h = ":", [S] = a.split(h, 1), P = a.slice(`${S}${h}`.length), d = S.trim(), C = P.trim();
|
|
543
543
|
let b, B, V;
|
|
544
|
-
if (
|
|
544
|
+
if (d.startsWith(
|
|
545
545
|
"checkout"
|
|
546
546
|
/* CHECKOUT */
|
|
547
547
|
))
|
|
548
548
|
B = ut(C);
|
|
549
|
-
else if (
|
|
549
|
+
else if (d.startsWith(
|
|
550
550
|
"merge"
|
|
551
551
|
/* MERGE */
|
|
552
552
|
))
|
|
553
|
-
b = Rt(
|
|
554
|
-
else if (
|
|
553
|
+
b = Rt(d);
|
|
554
|
+
else if (d.startsWith(
|
|
555
555
|
"commit (merge)"
|
|
556
556
|
/* COMMIT_MERGE */
|
|
557
557
|
)) {
|
|
@@ -562,7 +562,7 @@ const j = "__GIT_REPLACE_MARK__", $ = {
|
|
|
562
562
|
}
|
|
563
563
|
return {
|
|
564
564
|
...f,
|
|
565
|
-
type:
|
|
565
|
+
type: d,
|
|
566
566
|
message: C,
|
|
567
567
|
mergeInfo: b,
|
|
568
568
|
checkoutInfo: B,
|
|
@@ -627,7 +627,7 @@ const j = "__GIT_REPLACE_MARK__", $ = {
|
|
|
627
627
|
};
|
|
628
628
|
export {
|
|
629
629
|
st as EditorTypeEnum,
|
|
630
|
-
|
|
630
|
+
A as GitRefLogTypeEnum,
|
|
631
631
|
R as HooksNameEnum,
|
|
632
632
|
Vt as SUPPORT_GET_COMMIT_BY_HOOKS_NAMES,
|
|
633
633
|
me as _curry,
|
|
@@ -650,7 +650,7 @@ export {
|
|
|
650
650
|
Xt as getGitLastCommitInfo,
|
|
651
651
|
O as getGitProjectDir,
|
|
652
652
|
Qt as getLastReflogList,
|
|
653
|
-
|
|
653
|
+
T as getPackageJson,
|
|
654
654
|
gt as getRelyPkgVersion,
|
|
655
655
|
ft as getRootDirOptions,
|
|
656
656
|
xt as getRootScriptName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-utils",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "cli utils",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"semver": "^7.5.4",
|
|
69
69
|
"yargs": "^17.7.2"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "30721548bad7e10aaf8bf46762925954f40c5fd3"
|
|
72
72
|
}
|