@done-coding/cli-utils 0.8.0 → 0.8.1

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/README.md CHANGED
@@ -1,7 +1,109 @@
1
1
  # @done-coding/cli-utils
2
2
 
3
- cli utils
3
+ CLI 通用工具库 - 为 done-coding CLI 生态系统提供基础工具函数
4
4
 
5
- ## 使用
5
+ [![npm version](https://badge.fury.io/js/@done-coding%2Fcli-utils.svg)](https://www.npmjs.com/package/@done-coding/cli-utils)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
 
8
+ ## 安装
9
+
10
+ ```bash
7
11
  npm install @done-coding/cli-utils
12
+ # 或
13
+ pnpm add @done-coding/cli-utils
14
+ ```
15
+
16
+ ## 快速开始
17
+
18
+ ```bash
19
+ # 作为依赖库使用,不提供独立的 CLI 命令
20
+ ```
21
+
22
+ ## 功能特性
23
+
24
+ - ✅ **基础工具**: 提供通用的 CLI 工具函数
25
+ - 🔧 **类型定义**: 统一的 TypeScript 类型定义
26
+ - 📝 **配置处理**: 配置文件读取和处理工具
27
+ - 🎨 **命令行美化**: 基于 chalk 的命令行输出美化
28
+ - 🔄 **数据处理**: 基于 lodash 的数据操作工具
29
+
30
+ ## API 文档
31
+
32
+ 本包是一个工具库,不提供独立的 CLI 命令,主要为其他 done-coding CLI 包提供基础功能。
33
+
34
+ ### 主要依赖
35
+
36
+ - **chalk**: 命令行输出美化
37
+ - **json5**: JSON5 格式支持
38
+ - **lodash**: 数据操作工具函数
39
+ - **prompts**: 交互式命令行提示
40
+ - **semver**: 版本号处理
41
+ - **uuid**: UUID 生成
42
+ - **yargs**: 命令行参数解析
43
+
44
+ ## 使用示例
45
+
46
+ ### 作为依赖使用
47
+
48
+ ```javascript
49
+ import { /* 具体导出内容 */ } from '@done-coding/cli-utils';
50
+
51
+ // 具体使用方法需要查看包的导出内容
52
+ ```
53
+
54
+ ## 编程接口
55
+
56
+ 本包提供了编程接口,具体的导出内容请查看包的类型定义文件。
57
+
58
+ ## 包依赖关系
59
+
60
+ ### 被其他包依赖
61
+
62
+ `@done-coding/cli-utils` 是基础工具库,被以下包依赖:
63
+
64
+ - `@done-coding/cli` - 主 CLI 工具
65
+ - `@done-coding/cli-component` - 组件生成工具
66
+ - `@done-coding/cli-config` - 工程配置工具
67
+ - `@done-coding/cli-extract` - 信息提取工具
68
+ - `@done-coding/cli-git` - Git 操作工具
69
+ - `@done-coding/cli-inject` - 信息注入工具
70
+ - `@done-coding/cli-publish` - 项目发布工具
71
+ - `@done-coding/cli-template` - 模板处理工具
72
+ - `create-done-coding` - 项目创建工具
73
+
74
+ ## 贡献指南
75
+
76
+ 我们欢迎贡献!请遵循以下步骤:
77
+
78
+ 1. Fork 本仓库
79
+ 2. 创建功能分支:`git checkout -b feature/amazing-feature`
80
+ 3. 提交更改:`git commit -m "feat: add amazing feature"`
81
+ 4. 推送分支:`git push origin feature/amazing-feature`
82
+ 5. 创建 Pull Request
83
+
84
+ ### 开发环境设置
85
+
86
+ ```bash
87
+ # 克隆仓库
88
+ git clone https://gitee.com/done-coding/done-coding-cli.git
89
+ cd done-coding-cli/packages/utils
90
+
91
+ # 安装依赖
92
+ pnpm install
93
+
94
+ # 开发模式
95
+ pnpm dev
96
+
97
+ # 构建
98
+ pnpm build
99
+ ```
100
+
101
+ ## 许可证
102
+
103
+ MIT © [JustSoSu](https://gitee.com/done-coding)
104
+
105
+ ## 相关链接
106
+
107
+ - [主 CLI 工具](https://www.npmjs.com/package/@done-coding/cli)
108
+ - [Gitee 仓库](https://gitee.com/done-coding/done-coding-cli)
109
+ - [更新日志](./CHANGELOG.md)
package/es/index.mjs CHANGED
@@ -1,56 +1,55 @@
1
1
  #!/usr/bin/env node
2
- import p from "chalk";
3
- import { default as Ie } from "chalk";
2
+ import q from "chalk";
4
3
  import l from "node:path";
5
- import m, { existsSync as I, mkdirSync as q, writeFileSync as b, readFileSync as R } from "node:fs";
6
- import C from "crypto";
7
- import z from "prompts";
8
- import Q from "yargs";
9
- import { hideBin as Z } from "yargs/helpers";
10
- import { execSync as u } from "node:child_process";
4
+ import m, { existsSync as v, mkdirSync as z, writeFileSync as P, readFileSync as _ } from "node:fs";
5
+ import R from "crypto";
6
+ import Q from "prompts";
7
+ import Z from "yargs";
8
+ import { hideBin as tt } from "yargs/helpers";
9
+ import { execSync as g } from "node:child_process";
11
10
  import F from "json5";
12
11
  export * from "json5";
13
12
  import { default as Ae } from "json5";
14
- import tt from "lodash.merge";
15
- import et from "semver";
16
- import { tmpdir as rt, homedir as st } from "node:os";
13
+ import et from "lodash.merge";
14
+ import rt from "semver";
15
+ import { tmpdir as st, homedir as nt } from "node:os";
17
16
  import { v4 as ot } from "uuid";
18
- import { v4 as be } from "uuid";
17
+ import { v4 as we } from "uuid";
19
18
  import { default as Te } from "lodash.get";
20
19
  import { default as Ne } from "lodash.set";
21
- import { default as Ge } from "lodash.curry";
22
- import _ from "pinyin";
23
- const g = Object.assign(
24
- (t, ...e) => console.log(...e.map((r) => p[t](r))),
25
- {
20
+ import { default as Be } from "lodash.curry";
21
+ import y from "pinyin";
22
+ const G = (t) => {
23
+ const e = (...[r, ...n]) => t(q[r](...n));
24
+ return Object.assign(e, {
26
25
  /** 成功 */
27
- success: (...t) => g("green", ...t),
26
+ success: (...r) => e("green", ...r),
28
27
  /** /步骤 */
29
- stage: (...t) => g("blue", ...t),
28
+ stage: (...r) => e("blue", ...r),
30
29
  /** 提示信息 */
31
- info: (...t) => g("cyan", ...t),
30
+ info: (...r) => e("cyan", ...r),
32
31
  /** 警告 */
33
- warn: (...t) => g("yellow", ...t),
32
+ warn: (...r) => e("yellow", ...r),
34
33
  /** 错误 */
35
- error: (...t) => g("red", ...t),
34
+ error: (...r) => e("red", ...r),
36
35
  /** 跳过 */
37
- skip: (...t) => g("gray", ...t)
38
- }
39
- ), Qt = (t, {
36
+ skip: (...r) => e("gray", ...r)
37
+ });
38
+ }, a = G(console.log), Zt = G((t) => t), te = (t, {
40
39
  /** 当前目录 */
41
40
  currentDir: e = process.cwd(),
42
41
  /** 优先找最远的父目录 */
43
42
  isFindFarthest: r = !0
44
43
  } = {}) => {
45
- const o = l.resolve(e).split(l.sep).map((s, n, c) => c.slice(0, n).concat(s).join(l.sep) || l.sep);
46
- for (; o.length; ) {
47
- const s = r ? o.shift() : o.pop(), n = l.join(s, t);
48
- if (m.existsSync(n))
44
+ const n = l.resolve(e).split(l.sep).map((s, o, c) => c.slice(0, o).concat(s).join(l.sep) || l.sep);
45
+ for (; n.length; ) {
46
+ const s = r ? n.shift() : n.pop(), o = l.join(s, t);
47
+ if (m.existsSync(o))
49
48
  return s;
50
49
  }
51
- }, x = "aes-256-cbc", j = 16, O = "hex", w = ":";
52
- function k(t) {
53
- return C.pbkdf2Sync(
50
+ }, k = "aes-256-cbc", x = 16, C = "hex", w = ":";
51
+ function j(t) {
52
+ return R.pbkdf2Sync(
54
53
  t,
55
54
  "done-coding-cli-salt",
56
55
  // 使用固定的盐值
@@ -61,55 +60,55 @@ function k(t) {
61
60
  "sha256"
62
61
  );
63
62
  }
64
- function Zt({
63
+ function ee({
65
64
  text: t,
66
65
  secretKey: e
67
66
  }) {
68
67
  try {
69
- const r = k(e), o = C.randomBytes(j), s = C.createCipheriv(x, r, o);
70
- let n = s.update(t);
71
- n = Buffer.concat([n, s.final()]);
72
- const c = o.toString(O), i = n.toString(O);
68
+ const r = j(e), n = R.randomBytes(x), s = R.createCipheriv(k, r, n);
69
+ let o = s.update(t);
70
+ o = Buffer.concat([o, s.final()]);
71
+ const c = n.toString(C), i = o.toString(C);
73
72
  return `${c}${w}${i}`;
74
73
  } catch (r) {
75
- return g.error(
74
+ return a.error(
76
75
  `加密失败: ${r instanceof Error ? r.message : String(r)}`
77
76
  ), "";
78
77
  }
79
78
  }
80
- function te({
79
+ function re({
81
80
  encryptedText: t,
82
81
  secretKey: e
83
82
  }) {
84
83
  try {
85
84
  if (!t.includes(w))
86
85
  return "";
87
- const r = k(e), [o, s] = t.split(w);
88
- if (o.length !== j * 2)
86
+ const r = j(e), [n, s] = t.split(w);
87
+ if (n.length !== x * 2)
89
88
  return "";
90
- const n = Buffer.from(o, O), c = Buffer.from(s, O), i = C.createDecipheriv(x, r, n);
91
- let f = i.update(c);
92
- return f = Buffer.concat([f, i.final()]), f.toString();
89
+ const o = Buffer.from(n, C), c = Buffer.from(s, C), i = R.createDecipheriv(k, r, o);
90
+ let u = i.update(c);
91
+ return u = Buffer.concat([u, i.final()]), u.toString();
93
92
  } catch (r) {
94
- return g.error(
93
+ return a.error(
95
94
  `解密失败: ${r instanceof Error ? r.message : String(r)}`
96
95
  ), "";
97
96
  }
98
97
  }
99
- const H = (...t) => {
98
+ const U = (...t) => {
100
99
  const [e, r = {}] = t;
101
- return z(e, {
102
- onCancel(o) {
103
- return g.error(`退出${o == null ? void 0 : o.name}输入`), process.exit(1);
100
+ return Q(e, {
101
+ onCancel(n) {
102
+ return a.error(`退出${n == null ? void 0 : n.name}输入`), process.exit(1);
104
103
  },
105
104
  ...r
106
105
  });
107
- }, nt = (t, e) => {
108
- t ? g.error(t) : g.error(e.message), e != null && e.stack && g.error(e.stack), process.exit(1);
109
- }, it = () => {
110
- const t = Z(process.argv);
111
- return Q(t);
112
- }, ee = ({
106
+ }, it = (t, e) => {
107
+ t ? a.error(t) : a.error(e.message), e != null && e.stack && a.error(e.stack), process.exit(1);
108
+ }, ct = () => {
109
+ const t = tt(process.argv);
110
+ return Z(t);
111
+ }, se = ({
113
112
  rootScriptName: t,
114
113
  packageJson: e
115
114
  }) => {
@@ -117,51 +116,51 @@ const H = (...t) => {
117
116
  return t;
118
117
  if (!e)
119
118
  return;
120
- const { bin: r, name: o } = e;
119
+ const { bin: r, name: n } = e;
121
120
  if (r) {
122
121
  if (typeof r == "string")
123
- return o.includes("/") ? void 0 : o;
122
+ return n.includes("/") ? void 0 : n;
124
123
  if (typeof r == "object") {
125
- const s = Object.entries(r), n = process.argv[1], c = s.filter(([, f]) => n == null ? void 0 : n.endsWith(f));
124
+ const s = Object.entries(r), o = process.argv[1], c = s.filter(([, u]) => o == null ? void 0 : o.endsWith(u));
126
125
  if (c.length !== 1)
127
126
  return;
128
127
  const [i] = c[0];
129
128
  return process.platform === "win32" ? i.toLowerCase() : i;
130
129
  }
131
130
  }
132
- }, U = (t, {
131
+ }, H = (t, {
133
132
  usage: e,
134
133
  version: r,
135
- demandCommandCount: o,
134
+ demandCommandCount: n,
136
135
  options: s,
137
- positionals: n,
136
+ positionals: o,
138
137
  subcommands: c,
139
138
  rootScriptName: i
140
- }, f) => {
141
- let a = t.strict();
142
- e && (a = a.usage(`Usage: ${e}`)), o && (a = a.demandCommand(o));
143
- const h = "help";
144
- return a = a.help(h), r ? a = a.version(r).alias("h", h).alias("v", "version") : a = a.alias("h", h), s && (a = a.options(s)), n && (a = Object.entries(n).reduce((y, [M, d]) => y.positional(M, d), a)), c && (a = a.command(c)), f && i && (a = a.scriptName(i)), a;
145
- }, re = async ({ handler: t, ...e }) => {
146
- const r = await U(it(), e, !0).fail(
147
- nt
139
+ }, u) => {
140
+ let f = t.strict();
141
+ e && (f = f.usage(`Usage: ${e}`)), n && (f = f.demandCommand(n));
142
+ const p = "help";
143
+ return f = f.help(p), r ? f = f.version(r).alias("h", p).alias("v", "version") : f = f.alias("h", p), s && (f = f.options(s)), o && (f = Object.entries(o).reduce((S, [$, h]) => S.positional($, h), f)), c && (f = f.command(c)), u && i && (f = f.scriptName(i)), f;
144
+ }, ne = async ({ handler: t, ...e }) => {
145
+ const r = await H(ct(), e, !0).fail(
146
+ it
148
147
  ).argv;
149
148
  return t ? t(r) : r;
150
- }, se = (t) => {
151
- const { command: e, describe: r, handler: o = () => {
149
+ }, oe = (t) => {
150
+ const { command: e, describe: r, handler: n = () => {
152
151
  }, ...s } = t;
153
152
  return {
154
153
  command: e,
155
154
  describe: r,
156
- builder(n) {
157
- return U(n, s, !1);
155
+ builder(o) {
156
+ return H(o, s, !1);
158
157
  },
159
- handler: o
158
+ handler: n
160
159
  };
161
160
  };
162
- var ct = /* @__PURE__ */ ((t) => (t.VSCODE = "VsCode", t.CURSOR = "Cursor", t.OTHER = "其他", t))(ct || {});
163
- const at = async () => {
164
- const { editorType: t } = await H([
161
+ var at = /* @__PURE__ */ ((t) => (t.VSCODE = "VsCode", t.CURSOR = "Cursor", t.OTHER = "其他", t))(at || {});
162
+ const ft = async () => {
163
+ const { editorType: t } = await U([
165
164
  {
166
165
  name: "editorType",
167
166
  type: "select",
@@ -181,29 +180,29 @@ const at = async () => {
181
180
  }, lt = {
182
181
  Cursor: "cursor",
183
182
  VsCode: "code"
184
- }, ft = (t, e, r) => {
183
+ }, ut = (t, e, r) => {
185
184
  try {
186
- u(`${t} -v`, { stdio: "ignore" }), u(`${t} ${e}`);
185
+ g(`${t} -v`, { stdio: "ignore" }), g(`${t} ${e}`);
187
186
  } catch {
188
187
  r();
189
188
  }
190
189
  }, gt = (t, e) => {
191
- const r = (o) => g.info(`
192
- ${o}, 请用编辑器打开 ${t} 进行编辑
190
+ const r = (n) => a.info(`
191
+ ${n}, 请用编辑器打开 ${t} 进行编辑
193
192
  `);
194
193
  switch (e) {
195
194
  case "Cursor":
196
195
  case "VsCode": {
197
- const o = lt[e];
198
- ft(o, t, () => {
199
- r(`${o}命令未安装`);
196
+ const n = lt[e];
197
+ ut(n, t, () => {
198
+ r(`${n}命令未安装`);
200
199
  });
201
200
  break;
202
201
  }
203
202
  default:
204
203
  r("其他编辑器");
205
204
  }
206
- }, ut = (t = process.cwd()) => ({
205
+ }, mt = (t = process.cwd()) => ({
207
206
  /** 必须保留 */
208
207
  rootDir: {
209
208
  type: "string",
@@ -212,12 +211,12 @@ const at = async () => {
212
211
  /** 必须设置默认值 */
213
212
  default: t
214
213
  }
215
- }), oe = ({
214
+ }), ie = ({
216
215
  configPathDefault: t,
217
216
  rootDirDefault: e
218
217
  }) => ({
219
218
  /** 必须保留 */
220
- ...ut(e),
219
+ ...mt(e),
221
220
  /** 必须保留 */
222
221
  configPath: {
223
222
  type: "string",
@@ -226,279 +225,275 @@ const at = async () => {
226
225
  /** 必须设置默认值 */
227
226
  default: t
228
227
  }
229
- }), mt = async (t, e) => {
230
- const { configPath: r, rootDir: o } = e, s = l.resolve(o, r), n = l.dirname(s);
231
- return I(n) || q(n, {
228
+ }), pt = async (t, e) => {
229
+ const { configPath: r, rootDir: n } = e, s = l.resolve(n, r), o = l.dirname(s);
230
+ return v(o) || z(o, {
232
231
  recursive: !0
233
- }), s.endsWith(".json5") ? (g.info(`json5模式写入 ${s}`), b(s, F.stringify(t, null, 2)), s) : (g.info(`json模式写入 ${s}`), b(s, JSON.stringify(t, null, 2)), s);
234
- }, ne = async (t, e, {
232
+ }), s.endsWith(".json5") ? (a.info(`json5模式写入 ${s}`), P(s, F.stringify(t, null, 2)), s) : (a.info(`json模式写入 ${s}`), P(s, JSON.stringify(t, null, 2)), s);
233
+ }, ce = async (t, e, {
235
234
  onFileGenerated: r,
236
- edit: o = !1
235
+ edit: n = !1
237
236
  } = {}) => {
238
- const s = await mt(t, e);
239
- if (r == null || r(s), o) {
240
- const n = await at();
241
- gt(e.configPath, n);
237
+ const s = await pt(t, e);
238
+ if (r == null || r(s), n) {
239
+ const o = await ft();
240
+ gt(e.configPath, o);
242
241
  }
243
- }, ie = async (t, e) => {
244
- const { configPath: r, rootDir: o } = t, s = l.resolve(o, r);
245
- if (!I(s)) {
242
+ }, ae = async (t, e) => {
243
+ const { configPath: r, rootDir: n } = t, s = l.resolve(n, r);
244
+ if (!v(s)) {
246
245
  if (e)
247
- return g.info("配置文件不存在,使用onNotExists返回值"), e();
248
- const n = `配置文件不存在 ${s}`;
249
- throw new Error(n);
246
+ return a.info("配置文件不存在,使用onNotExists返回值"), e();
247
+ const o = `配置文件不存在 ${s}`;
248
+ throw new Error(o);
250
249
  }
251
- return s.endsWith(".json5") ? (g.info(`json5模式解析 ${s}`), F.parse(R(s, "utf8"))) : (g.info(`json模式解析 ${s}`), JSON.parse(R(s, "utf8")));
252
- }, ce = async () => {
253
- const { useDefaultConfig: t } = await H({
250
+ return s.endsWith(".json5") ? (a.info(`json5模式解析 ${s}`), F.parse(_(s, "utf8"))) : (a.info(`json模式解析 ${s}`), JSON.parse(_(s, "utf8")));
251
+ }, fe = async () => {
252
+ const { useDefaultConfig: t } = await U({
254
253
  name: "useDefaultConfig",
255
254
  type: "confirm",
256
255
  message: "使用默认模板配置",
257
256
  initial: !0
258
257
  });
259
258
  return t;
260
- }, J = "package.json", D = ({
259
+ }, J = "package.json", T = ({
261
260
  rootDir: t
262
261
  }) => {
263
262
  const e = l.resolve(t, J);
264
- if (!I(e))
263
+ if (!v(e))
265
264
  throw new Error(`${t}未找到package.json文件`);
266
- const r = R(e, "utf-8");
265
+ const r = _(e, "utf-8");
267
266
  return JSON.parse(r);
268
- }, pt = ({
267
+ }, ht = ({
269
268
  rootDir: t,
270
269
  pkgJson: e,
271
270
  pkgName: r,
272
- isDevPkg: o
271
+ isDevPkg: n
273
272
  }) => {
274
- const s = e || D({ rootDir: t }), n = o ? s.devDependencies : s.dependencies;
275
- let c = n == null ? void 0 : n[r];
273
+ const s = e || T({ rootDir: t }), o = n ? s.devDependencies : s.dependencies;
274
+ let c = o == null ? void 0 : o[r];
276
275
  if (!c) {
277
- const i = o ? s.dependencies : s.devDependencies;
278
- c = i == null ? void 0 : i[r], c && console.log(
279
- p.yellow(
280
- `${o ? "开发" : "生产"}依赖包${r}可能错误的安装在${o ? "dependencies" : "devDependencies"}`
281
- )
276
+ const i = n ? s.dependencies : s.devDependencies;
277
+ c = i == null ? void 0 : i[r], c && a.warn(
278
+ `${n ? "开发" : "生产"}依赖包${r}可能错误的安装在${n ? "dependencies" : "devDependencies"}`
282
279
  );
283
280
  return;
284
281
  }
285
- return c || console.log(p.cyan(`依赖包${r}未安装`)), c;
286
- }, ae = ({
282
+ return c || a.info(`依赖包${r}未安装`), c;
283
+ }, le = ({
287
284
  patchConfig: t,
288
285
  rootDir: e
289
286
  }) => {
290
287
  if (!t)
291
288
  return;
292
- const r = D({ rootDir: e }), o = tt(r, t), s = l.resolve(e, J);
293
- b(s, JSON.stringify(o, null, 2), "utf-8");
294
- }, $ = (t) => {
295
- const r = u("git rev-parse --show-toplevel", {
289
+ const r = T({ rootDir: e }), n = et(r, t), s = l.resolve(e, J);
290
+ P(s, JSON.stringify(n, null, 2), "utf-8");
291
+ }, I = (t) => {
292
+ const r = g("git rev-parse --show-toplevel", {
296
293
  cwd: t
297
294
  }).toString();
298
295
  if (!r)
299
296
  throw new Error("获取git根目录失败");
300
297
  return r.trim();
301
- }, le = () => {
298
+ }, ue = () => {
302
299
  var t;
303
300
  try {
304
- const e = u("git symbolic-ref --short HEAD", {
301
+ const e = g("git symbolic-ref --short HEAD", {
305
302
  stdio: "ignore"
306
303
  });
307
304
  return (t = e == null ? void 0 : e.toString()) == null ? void 0 : t.trim();
308
305
  } catch {
309
306
  try {
310
- const r = u("git rev-parse --short HEAD").toString().trim();
311
- g.skip(`当前未指向具体某个分支, 当前commit hash: ${r}`);
307
+ const r = g("git rev-parse --short HEAD").toString().trim();
308
+ a.skip(`当前未指向具体某个分支, 当前commit hash: ${r}`);
312
309
  } finally {
313
310
  return;
314
311
  }
315
312
  }
316
- }, ht = (t) => {
313
+ }, dt = (t) => {
317
314
  const e = t.match(/moving\s+from\s+(.*)\s+to\s+(.*)/);
318
315
  if (e) {
319
- const [, r, o] = e;
316
+ const [, r, n] = e;
320
317
  return {
321
318
  fromBranch: r.trim(),
322
- toBranch: o.trim()
319
+ toBranch: n.trim()
323
320
  };
324
321
  }
325
- }, P = 73, dt = (t) => {
322
+ }, A = 73, St = (t) => {
326
323
  const r = m.statSync(t).mode;
327
- if ((r & P) === P)
324
+ if ((r & A) === A)
328
325
  return;
329
- console.log(p.blue(`${t} 没有执行权限 添加... `));
330
- const o = r | P;
331
- m.chmodSync(t, o), console.log(p.green(`${t} 添加执行权限成功`));
332
- }, V = (t) => m.existsSync(t), N = async (t) => {
326
+ a.stage(`${t} 没有执行权限 添加... `);
327
+ const n = r | A;
328
+ m.chmodSync(t, n), a.success(`${t} 添加执行权限成功`);
329
+ }, V = (t) => m.existsSync(t), D = async (t) => {
333
330
  try {
334
331
  return await m.promises.lstat(t), !0;
335
332
  } catch (e) {
336
333
  return e.code !== "ENOENT";
337
334
  }
338
- }, St = (t, e = !1) => {
335
+ }, Et = (t, e = !1) => {
339
336
  V(t) && m.rmSync(t, { recursive: !0, force: e });
340
- }, fe = async (t, e = !1) => {
341
- await N(t) && await m.promises.rm(t, { recursive: !0, force: e });
342
- }, yt = (t) => m.readFileSync(t, "utf-8"), Et = (t) => m.promises.readFile(t, "utf-8"), ge = (t, e) => JSON.parse(yt(t)) || e, K = async (t, e) => JSON.parse(await Et(t)) || e;
343
- var S = /* @__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))(S || {});
344
- const _t = "husky", Rt = ".husky", Ct = ({ rootDir: t }) => {
345
- const e = $(t), r = pt({
337
+ }, ge = async (t, e = !1) => {
338
+ await D(t) && await m.promises.rm(t, { recursive: !0, force: e });
339
+ }, yt = (t) => m.readFileSync(t, "utf-8"), _t = (t) => m.promises.readFile(t, "utf-8"), me = (t, e) => JSON.parse(yt(t)) || e, K = async (t, e) => JSON.parse(await _t(t)) || e;
340
+ 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 Rt = "husky", Ct = ".husky", Ot = ({ rootDir: t }) => {
342
+ const e = I(t), r = ht({
346
343
  rootDir: e,
347
- pkgJson: D({ rootDir: e }),
348
- pkgName: _t,
344
+ pkgJson: T({ rootDir: e }),
345
+ pkgName: Rt,
349
346
  isDevPkg: !0
350
347
  });
351
348
  if (!r)
352
349
  throw new Error("husky版本获取失败, 可能husky未安装");
353
- const o = r.replace(/^(\^|~)/, ""), s = "<9.0.0";
354
- return et.satisfies(o, s) ? (console.log(p.cyan(`${o}符合${s}`)), `#!/usr/bin/env sh
355
- . "$(dirname -- "$0")/_/husky.sh"`) : (console.log(p.cyan(`${o}不符合${s}`)), "");
356
- }, Ot = ({ rootDir: t }) => {
357
- const e = $(t);
358
- return l.resolve(e, Rt);
359
- }, ue = ({
350
+ const n = r.replace(/^(\^|~)/, ""), s = "<9.0.0";
351
+ return rt.satisfies(n, s) ? (a.info(`${n}符合${s}`), `#!/usr/bin/env sh
352
+ . "$(dirname -- "$0")/_/husky.sh"`) : (a.info(`${n}不符合${s}`), "");
353
+ }, vt = ({ rootDir: t }) => {
354
+ const e = I(t);
355
+ return l.resolve(e, Ct);
356
+ }, pe = ({
360
357
  hookNames: t,
361
358
  rootDir: e,
362
359
  getCode: r
363
360
  }) => {
364
- const o = Ot({ rootDir: e });
365
- m.existsSync(o) || m.mkdirSync(o, { recursive: !0 }), t.forEach((s) => {
366
- const n = l.resolve(o, s), c = m.existsSync(n);
361
+ const n = vt({ rootDir: e });
362
+ m.existsSync(n) || m.mkdirSync(n, { recursive: !0 }), t.forEach((s) => {
363
+ const o = l.resolve(n, s), c = m.existsSync(o);
367
364
  let i = r(s);
368
365
  if (c)
369
- m.readFileSync(n, "utf-8").includes(i) ? console.log(
370
- p.gray(`${n} ${s}相关调用 ${i} 已存在 跳过`)
371
- ) : (m.appendFileSync(
372
- n,
366
+ m.readFileSync(o, "utf-8").includes(i) ? a.skip(`${o} ${s}相关调用 ${i} 已存在 跳过`) : (m.appendFileSync(
367
+ o,
373
368
  `
374
369
  ${i}
375
370
  `
376
- ), console.log(p.green(`${n} 添加 ${s}相关调用成功`)));
371
+ ), a.success(`${o} 添加 ${s}相关调用成功`));
377
372
  else {
378
- const f = Ct({
373
+ const u = Ot({
379
374
  rootDir: e
380
375
  });
381
376
  m.writeFileSync(
382
- n,
383
- `${f}
377
+ o,
378
+ `${u}
384
379
 
385
380
  ${i}
386
381
  `,
387
382
  "utf-8"
388
- ), console.log(p.green(`${n} 添加 ${s}相关调用成功`));
383
+ ), a.success(`${o} 添加 ${s}相关调用成功`);
389
384
  }
390
- dt(n);
385
+ St(o);
391
386
  });
392
- }, me = [
387
+ }, he = [
393
388
  // HooksNameEnum.PRE_MERGE_COMMIT,
394
- S.PREPARE_COMMIT_MSG,
395
- S.COMMIT_MSG
396
- ], pe = ({
389
+ d.PREPARE_COMMIT_MSG,
390
+ d.COMMIT_MSG
391
+ ], de = ({
397
392
  hookName: t,
398
393
  rootDir: e
399
394
  }) => {
400
- const r = $(e), o = l.resolve(r, ".git");
395
+ const r = I(e), n = l.resolve(r, ".git");
401
396
  switch (t) {
402
- case S.PREPARE_COMMIT_MSG:
403
- case S.COMMIT_MSG: {
404
- const s = l.resolve(o, "MERGE_MSG");
405
- if (I(s))
406
- return R(s, "utf-8");
397
+ case d.PREPARE_COMMIT_MSG:
398
+ case d.COMMIT_MSG: {
399
+ const s = l.resolve(n, "MERGE_MSG");
400
+ if (v(s))
401
+ return _(s, "utf-8");
407
402
  }
408
403
  }
409
404
  return "";
410
- }, he = ({
405
+ }, Se = ({
411
406
  remoteAlias: t = "origin"
412
407
  } = {}) => {
413
408
  try {
414
- const e = u("git rev-parse HEAD").toString().trim(), r = u('git log -1 --pretty=format:"%an"').toString().trim(), o = u('git log -1 --pretty=format:"%ae"').toString().trim(), s = u('git log -1 --pretty=format:"%s"').toString().trim(), n = u("git config user.name").toString().trim(), c = u("git config user.email").toString().trim(), i = u("git rev-parse --abbrev-ref HEAD").toString().trim();
415
- let f = "";
409
+ const e = g("git rev-parse HEAD").toString().trim(), r = g('git log -1 --pretty=format:"%an"').toString().trim(), n = g('git log -1 --pretty=format:"%ae"').toString().trim(), s = g('git log -1 --pretty=format:"%s"').toString().trim(), o = g("git config user.name").toString().trim(), c = g("git config user.email").toString().trim(), i = g("git rev-parse --abbrev-ref HEAD").toString().trim();
410
+ let u = "";
416
411
  try {
417
- f = u(`git config --get remote.${t}.url`).toString().trim();
412
+ u = g(`git config --get remote.${t}.url`).toString().trim();
418
413
  } catch {
419
- g.warn("git远程仓库地址获取失败或者不存在");
414
+ a.warn("git远程仓库地址获取失败或者不存在");
420
415
  }
421
416
  return {
422
417
  lastHash: e,
423
418
  lastCommitter: r,
424
- lastCommitterPinYin: _(r, {
425
- style: _.STYLE_NORMAL,
419
+ lastCommitterPinYin: y(r, {
420
+ style: y.STYLE_NORMAL,
426
421
  heteronym: !1
427
422
  }).join(""),
428
- lastCommitEmail: o,
423
+ lastCommitEmail: n,
429
424
  lastCommitMsg: s,
430
- userName: n,
431
- userNamePinYin: _(n, {
432
- style: _.STYLE_NORMAL,
425
+ userName: o,
426
+ userNamePinYin: y(o, {
427
+ style: y.STYLE_NORMAL,
433
428
  heteronym: !1
434
429
  }).join(""),
435
430
  userEmail: c,
436
431
  branchName: i,
437
- remoteInfo: f ? {
432
+ remoteInfo: u ? {
438
433
  alias: t,
439
- url: f
434
+ url: u
440
435
  } : void 0
441
436
  };
442
437
  } catch (e) {
443
- throw g.error("获取git最后提交信息失败"), e;
438
+ throw a.error("获取git最后提交信息失败"), e;
444
439
  }
445
440
  }, Y = (t = "") => {
446
441
  const e = /\s*Merge\s+branch\s+['|"](.+)['|"]\s+into\s+['|"](.+)['|"]\s*/i, r = t.match(e);
447
442
  if (r) {
448
- const [, i, f] = r;
443
+ const [, i, u] = r;
449
444
  return {
450
445
  fromBranch: i,
451
- toBranch: f
446
+ toBranch: u
452
447
  };
453
448
  }
454
- const o = /\s*Merge\s+branch\s+['|"](.+)['|"]\s+of\s+.+\s+into\s+['|"](.+)['|"]\s*/i, s = t.match(o);
449
+ const n = /\s*Merge\s+branch\s+['|"](.+)['|"]\s+of\s+.+\s+into\s+['|"](.+)['|"]\s*/i, s = t.match(n);
455
450
  if (s) {
456
- const [, i, f] = s;
451
+ const [, i, u] = s;
457
452
  return {
458
453
  fromBranch: i,
459
- toBranch: f
454
+ toBranch: u
460
455
  };
461
456
  }
462
- const n = /\s*Merge\s+branch\s+['|"](.+)['|"](\s+of)?\s*/i, c = t.match(n);
457
+ const o = /\s*Merge\s+branch\s+['|"](.+)['|"](\s+of)?\s*/i, c = t.match(o);
463
458
  if (c) {
464
459
  const [, i] = c;
465
460
  return {
466
461
  fromBranch: i
467
462
  };
468
463
  }
469
- }, vt = (t) => {
470
- if (t.startsWith(T.MERGE))
464
+ }, It = (t) => {
465
+ if (t.startsWith(b.MERGE))
471
466
  return {
472
- fromBranch: t.replace(T.MERGE, "").trim()
467
+ fromBranch: t.replace(b.MERGE, "").trim()
473
468
  };
474
- }, de = () => {
469
+ }, Ee = () => {
475
470
  const t = process.env.GIT_REFLOG_ACTION || "";
476
471
  if (!t)
477
472
  return;
478
473
  const e = /merge\s+([^\s]+)\s*/i, r = t.match(e);
479
474
  if (r) {
480
- const [, n] = r;
475
+ const [, o] = r;
481
476
  return {
482
- fromBranch: n
477
+ fromBranch: o
483
478
  };
484
479
  }
485
- const o = /pull\s+([^\s]+)\s+([^\s]+)/, s = t.match(o);
480
+ const n = /pull\s+([^\s]+)\s+([^\s]+)/, s = t.match(n);
486
481
  if (s) {
487
- const [, , n] = s;
482
+ const [, , o] = s;
488
483
  return {
489
- fromBranch: n
484
+ fromBranch: o
490
485
  };
491
486
  }
492
487
  };
493
- var T = /* @__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))(T || {});
494
- const L = "__GIT_REPLACE_MARK__", v = {
488
+ 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 || {});
489
+ const B = "__GIT_REPLACE_MARK__", O = {
495
490
  stringify(t) {
496
- return JSON.stringify(t).replace(/"/g, L);
491
+ return JSON.stringify(t).replace(/"/g, B);
497
492
  },
498
493
  parse(t) {
499
- return JSON.parse(t.replace(new RegExp(L, "g"), '"'));
494
+ return JSON.parse(t.replace(new RegExp(B, "g"), '"'));
500
495
  }
501
- }, Se = ({
496
+ }, ye = ({
502
497
  count: t = 100
503
498
  } = {}) => {
504
499
  if (t <= 0)
@@ -520,19 +515,19 @@ const L = "__GIT_REPLACE_MARK__", v = {
520
515
  /** 提交日期 */
521
516
  commitTime: "%ci"
522
517
  };
523
- return u(
524
- `git --no-pager log --oneline -n ${t} --pretty=format:"${v.stringify(
518
+ return g(
519
+ `git --no-pager log --oneline -n ${t} --pretty=format:"${O.stringify(
525
520
  e
526
521
  )}"`
527
522
  ).toString().split(`
528
- `).map((n) => {
529
- const c = v.parse(n);
523
+ `).map((o) => {
524
+ const c = O.parse(o);
530
525
  return {
531
526
  ...c,
532
527
  mergeInfo: Y(c.message)
533
528
  };
534
529
  });
535
- }, ye = ({
530
+ }, _e = ({
536
531
  count: t = 100,
537
532
  filterItem: e = () => !0
538
533
  } = {}) => {
@@ -545,201 +540,197 @@ const L = "__GIT_REPLACE_MARK__", v = {
545
540
  committerEmail: "%ce",
546
541
  commitTime: "%ci"
547
542
  };
548
- return u(
549
- `git --no-pager reflog -n ${t} --pretty=format:"${v.stringify(
543
+ return g(
544
+ `git --no-pager reflog -n ${t} --pretty=format:"${O.stringify(
550
545
  r
551
546
  )}"`
552
547
  ).toString().split(`
553
- `).map((i) => v.parse(i)).filter(e).map((i) => {
554
- const { fullMessage: f, ...a } = i, h = ":", [y] = f.split(h, 1), M = f.slice(`${y}${h}`.length), d = y.trim(), E = M.trim();
555
- let A, B, X;
556
- if (d.startsWith(
548
+ `).map((i) => O.parse(i)).filter(e).map((i) => {
549
+ const { fullMessage: u, ...f } = i, p = ":", [S] = u.split(p, 1), $ = u.slice(`${S}${p}`.length), h = S.trim(), E = $.trim();
550
+ let M, N, X;
551
+ if (h.startsWith(
557
552
  "checkout"
558
553
  /* CHECKOUT */
559
554
  ))
560
- B = ht(E);
561
- else if (d.startsWith(
555
+ N = dt(E);
556
+ else if (h.startsWith(
562
557
  "merge"
563
558
  /* MERGE */
564
559
  ))
565
- A = vt(d);
566
- else if (d.startsWith(
560
+ M = It(h);
561
+ else if (h.startsWith(
567
562
  "commit (merge)"
568
563
  /* COMMIT_MERGE */
569
564
  )) {
570
- const G = Y(E);
571
- G || g.warn(
565
+ const L = Y(E);
566
+ L || a.warn(
572
567
  `${i.hash} 是合并提交 但是未从提交信息(${E})中检测到合并分支信息,推测手动更改了提交内容`
573
- ), A = G;
568
+ ), M = L;
574
569
  }
575
570
  return {
576
- ...a,
577
- type: d,
571
+ ...f,
572
+ type: h,
578
573
  message: E,
579
- mergeInfo: A,
580
- checkoutInfo: B,
574
+ mergeInfo: M,
575
+ checkoutInfo: N,
581
576
  rebaseInfo: X
582
577
  };
583
578
  });
584
- }, Ee = (t) => {
585
- const e = $(t), r = l.resolve(e, ".git"), o = l.resolve(r, "rebase-merge");
586
- if (m.existsSync(o))
579
+ }, Re = (t) => {
580
+ const e = I(t), r = l.resolve(e, ".git"), n = l.resolve(r, "rebase-merge");
581
+ if (m.existsSync(n))
587
582
  return !0;
588
583
  const s = l.resolve(r, "rebase-apply");
589
584
  if (m.existsSync(s))
590
585
  return !0;
591
- const n = l.resolve(r, "REBASE_HEAD");
592
- return !!m.existsSync(n);
593
- }, _e = ({
586
+ const o = l.resolve(r, "REBASE_HEAD");
587
+ return !!m.existsSync(o);
588
+ }, Ce = ({
594
589
  branchName: t,
595
590
  version: e,
596
591
  remoteInfo: r
597
592
  }) => {
598
- r && (u(`git push ${r.alias} v${e}`, {
593
+ r && (g(`git push ${r.alias} v${e}`, {
599
594
  stdio: "inherit"
600
- }), u(`git push ${r.alias} ${t}`, {
595
+ }), g(`git push ${r.alias} ${t}`, {
601
596
  stdio: "inherit"
602
597
  }));
603
- }, It = (t) => /^https?:\/\//.test(t), $t = (t) => /^git@/.test(t), Re = (t) => {
598
+ }, $t = (t) => /^https?:\/\//.test(t), Mt = (t) => /^git@/.test(t), Oe = (t) => {
604
599
  const { hostname: e, pathname: r } = new URL(t);
605
600
  return `git@${e}:${r.replace("/", "")}`;
606
- }, W = ".done-coding", Mt = `${W}/cli/assets-config`, At = "assets", Pt = "index.json", bt = `${W}/config.json`, wt = "https://gitee.com/justsosu/done-coding-cli-assets-config.git", Tt = ({
601
+ }, W = ".done-coding", At = `${W}/cli/assets-config`, Pt = "assets", wt = "index.json", bt = `${W}/config.json`, Tt = "https://gitee.com/justsosu/done-coding-cli-assets-config.git", Dt = ({
607
602
  dir: t,
608
603
  fn: e,
609
604
  endClear: r = !0,
610
- exitClear: o = !0
605
+ exitClear: n = !0
611
606
  }) => {
612
607
  if (V(t))
613
- return console.log(p.red(`${t} 已存在,请手动删除该目录再试`)), process.exit(1);
608
+ return a.error(`${t} 已存在,请手动删除该目录再试`), process.exit(1);
614
609
  const s = () => {
615
- console.log("正在清理临时目录...", t), St(t);
610
+ a.stage("正在清理临时目录...", t), Et(t);
616
611
  };
617
- o && process.once("exit", () => {
618
- console.log("发现进程退出,正在清理临时目录...", t), s();
612
+ n && process.once("exit", () => {
613
+ a.stage("发现进程退出,正在清理临时目录...", t), s();
619
614
  });
620
- let n;
615
+ let o;
621
616
  try {
622
- n = e(t);
617
+ o = e(t);
623
618
  } catch (c) {
624
619
  throw r && s(), c;
625
620
  }
626
- return r && (n instanceof Promise ? n.finally(s) : s()), n;
621
+ return r && (o instanceof Promise ? o.finally(s) : s()), o;
627
622
  };
628
- var Dt = /* @__PURE__ */ ((t) => (t.ASSETS_CONFIG_REPO_URL = "ASSETS_CONFIG_REPO_URL", t))(Dt || {});
629
- const Nt = (t) => l.resolve(
630
- rt(),
631
- Mt,
623
+ var Nt = /* @__PURE__ */ ((t) => (t.ASSETS_CONFIG_REPO_URL = "ASSETS_CONFIG_REPO_URL", t))(Nt || {});
624
+ const Lt = (t) => l.resolve(
625
+ st(),
626
+ At,
632
627
  `${t}-${ot()}`
633
- ), Bt = () => l.resolve(st(), bt), Gt = async () => {
634
- const t = Bt();
635
- console.log("读取全局配置:", t);
636
- const e = {
637
- ASSETS_CONFIG_REPO_URL: wt
628
+ ), Bt = () => l.resolve(nt(), bt), Ft = async () => {
629
+ const t = Bt(), e = {
630
+ ASSETS_CONFIG_REPO_URL: Tt
638
631
  };
639
632
  try {
640
- if (await N(t)) {
633
+ if (await D(t)) {
641
634
  const r = await K(t, {});
642
- Object.entries(r).forEach(([o, s]) => {
643
- e[o] = s;
635
+ Object.entries(r).forEach(([n, s]) => {
636
+ e[n] = s;
644
637
  });
645
638
  }
646
639
  } catch {
647
640
  }
648
- return console.log("done-coding-cli 全局配置:", e), e;
649
- }, Lt = async (t) => {
650
- if (console.log("资产配置仓库临时目录:", t), await N(t))
651
- return console.log(
652
- p.red(`${t} 已存在,请手动删除该目录再试`)
653
- ), process.exit(1);
641
+ return e;
642
+ }, Gt = async (t) => {
643
+ if (await D(t))
644
+ return a.error(`${t} 已存在,请手动删除该目录再试`), process.exit(1);
654
645
  const {
655
646
  [
656
647
  "ASSETS_CONFIG_REPO_URL"
657
648
  /* ASSETS_CONFIG_REPO_URL */
658
649
  ]: e
659
- } = await Gt();
660
- return $t(e) || It(e) ? (console.log("远程仓库拉取配置...", e), u(`git clone ${e} ${t} --depth=1`)) : (m.mkdirSync(t, { recursive: !0 }), u(`cp -r ${e}/ ${t}/`)), {
650
+ } = await Ft();
651
+ return Mt(e) || $t(e) ? g(`git clone ${e} ${t} --depth=1`) : (m.mkdirSync(t, { recursive: !0 }), g(`cp -r ${e}/ ${t}/`)), {
661
652
  assetConfigRepoUrl: e
662
653
  };
663
- }, Ce = async ({
654
+ }, ve = async ({
664
655
  moduleName: t,
665
656
  onSuccess: e
666
- }) => (console.log(p.blue(`拉取${t}配置,请稍等...`)), Tt({
657
+ }) => (a.stage(`拉取${t}配置,请稍等...`), Dt({
667
658
  // 资源配置仓库临时文件夹
668
- dir: Nt(t),
659
+ dir: Lt(t),
669
660
  fn: async (r) => {
670
- const { assetConfigRepoUrl: o } = await Lt(r), s = l.join(
671
- At,
661
+ const { assetConfigRepoUrl: n } = await Gt(r), s = l.join(
662
+ Pt,
672
663
  t
673
- ), n = l.join(
664
+ ), o = l.join(
674
665
  s,
675
- Pt
676
- ), c = l.resolve(r, n), i = await K(c);
666
+ wt
667
+ ), c = l.resolve(r, o), i = await K(c);
677
668
  return await e({
678
- repoUrl: o,
669
+ repoUrl: n,
679
670
  config: i,
680
671
  moduleDirFileRelativePath: s,
681
- moduleEntryFileRelativePath: n,
672
+ moduleEntryFileRelativePath: o,
682
673
  assetsConfigRepoTempDir: r
683
674
  }), i;
684
675
  }
685
676
  }));
686
677
  export {
687
- Dt as DoneCodingCliGlobalConfigKeyEnum,
688
- ct as EditorTypeEnum,
689
- T as GitRefLogTypeEnum,
690
- S as HooksNameEnum,
691
- me as SUPPORT_GET_COMMIT_BY_HOOKS_NAMES,
692
- Ge as _curry,
678
+ Nt as DoneCodingCliGlobalConfigKeyEnum,
679
+ at as EditorTypeEnum,
680
+ b as GitRefLogTypeEnum,
681
+ d as HooksNameEnum,
682
+ he as SUPPORT_GET_COMMIT_BY_HOOKS_NAMES,
683
+ Be as _curry,
693
684
  Te as _get,
694
685
  Ne as _set,
695
- ue as addHuskyHooks,
696
- ae as addPackageConfig,
697
- Tt as applyUseTempDir,
686
+ pe as addHuskyHooks,
687
+ le as addPackageConfig,
688
+ Dt as applyUseTempDir,
698
689
  V as assetIsExits,
699
- N as assetIsExitsAsync,
700
- Ie as chalk,
701
- Ee as checkCurrentIsRebasing,
702
- re as createMainCommand,
703
- se as createSubcommand,
704
- te as decryptAES,
705
- Zt as encryptAES,
706
- dt as fileAddX,
707
- Nt as getCliModuleTempDir,
708
- pe as getCommitByHookName,
709
- oe as getConfigFileCommonOptions,
710
- Se as getCurrentBranchLastCommitList,
711
- le as getCurrentBranchName,
712
- at as getEditorType,
713
- he as getGitLastCommitInfo,
714
- $ as getGitProjectDir,
715
- ye as getLastReflogList,
716
- D as getPackageJson,
717
- pt as getRelyPkgVersion,
718
- ut as getRootDirOptions,
719
- ee as getRootScriptName,
720
- ce as getUseDefaultConfig,
721
- Re as http2sshGitUrl,
722
- mt as initConfigFile,
723
- ne as initHandlerCommon,
724
- It as isHttpGitUrl,
725
- $t as isSshGitUrl,
690
+ D as assetIsExitsAsync,
691
+ Re as checkCurrentIsRebasing,
692
+ ne as createMainCommand,
693
+ oe as createSubcommand,
694
+ re as decryptAES,
695
+ ee as encryptAES,
696
+ St as fileAddX,
697
+ Lt as getCliModuleTempDir,
698
+ de as getCommitByHookName,
699
+ ie as getConfigFileCommonOptions,
700
+ ye as getCurrentBranchLastCommitList,
701
+ ue as getCurrentBranchName,
702
+ ft as getEditorType,
703
+ Se as getGitLastCommitInfo,
704
+ I as getGitProjectDir,
705
+ _e as getLastReflogList,
706
+ Zt as getLogText,
707
+ T as getPackageJson,
708
+ ht as getRelyPkgVersion,
709
+ mt as getRootDirOptions,
710
+ se as getRootScriptName,
711
+ fe as getUseDefaultConfig,
712
+ Oe as http2sshGitUrl,
713
+ pt as initConfigFile,
714
+ ce as initHandlerCommon,
715
+ $t as isHttpGitUrl,
716
+ Mt as isSshGitUrl,
726
717
  Ae as json5,
727
- g as log,
728
- Qt as lookForParentTarget,
718
+ a as log,
719
+ te as lookForParentTarget,
729
720
  gt as openFileInEditor,
730
- _e as pushGitPublishInfoToRemote,
731
- Ce as readCliModuleAssetsConfig,
732
- ie as readConfigFile,
721
+ Ce as pushGitPublishInfoToRemote,
722
+ ve as readCliModuleAssetsConfig,
723
+ ae as readConfigFile,
733
724
  yt as readFile,
734
- Et as readFileAsync,
735
- ge as readJsonFile,
725
+ _t as readFileAsync,
726
+ me as readJsonFile,
736
727
  K as readJsonFileAsync,
737
- St as removeAsset,
738
- fe as removeAssetAsync,
739
- ht as resolveCheckoutInfoByRefInfo,
728
+ Et as removeAsset,
729
+ ge as removeAssetAsync,
730
+ dt as resolveCheckoutInfoByRefInfo,
740
731
  Y as resolveMergeInfoByCommitMsg,
741
- de as resolveMergeInfoByGitReflogAction,
742
- vt as resolveMergeInfoByRefType,
743
- be as uuidv4,
744
- H as xPrompts
732
+ Ee as resolveMergeInfoByGitReflogAction,
733
+ It as resolveMergeInfoByRefType,
734
+ we as uuidv4,
735
+ U as xPrompts
745
736
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-utils",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "cli utils",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -70,5 +70,5 @@
70
70
  "uuid": "^11.1.0",
71
71
  "yargs": "^17.7.2"
72
72
  },
73
- "gitHead": "e68f726aa899f75c4d294b11620f343c953a74c3"
73
+ "gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6"
74
74
  }
package/types/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { ArgumentsCamelCase } from 'yargs';
2
- import chalk from 'chalk';
3
2
  import type { CommandModule } from 'yargs';
4
3
  import _curry from 'lodash.curry';
5
4
  import _get from 'lodash.get';
@@ -60,8 +59,6 @@ export declare const assetIsExits: (assetPath: string) => boolean;
60
59
  */
61
60
  export declare const assetIsExitsAsync: (path: string) => Promise<boolean>;
62
61
 
63
- export { chalk }
64
-
65
62
  /** 检测当前正在变基 */
66
63
  export declare const checkCurrentIsRebasing: (rootDir: string) => boolean;
67
64
 
@@ -214,6 +211,22 @@ export declare const getLastReflogList: ({ count, filterItem, }?: {
214
211
  filterItem?: ((item: GitReflogItemInfoRaw) => boolean) | undefined;
215
212
  }) => GitReflogItemInfo[];
216
213
 
214
+ /** 获取输出文字 */
215
+ export declare const getLogText: ((type: LogTypeEnum, ...messages: unknown[]) => string) & {
216
+ /** 成功 */
217
+ success: (...messages: unknown[]) => string;
218
+ /** /步骤 */
219
+ stage: (...messages: unknown[]) => string;
220
+ /** 提示信息 */
221
+ info: (...messages: unknown[]) => string;
222
+ /** 警告 */
223
+ warn: (...messages: unknown[]) => string;
224
+ /** 错误 */
225
+ error: (...messages: unknown[]) => string;
226
+ /** 跳过 */
227
+ skip: (...messages: unknown[]) => string;
228
+ };
229
+
217
230
  /** 获取package.json文件内容 */
218
231
  export declare const getPackageJson: <R extends PackageJson>({ rootDir, }: {
219
232
  rootDir: string;
@@ -434,21 +447,23 @@ export declare const isSshGitUrl: (url: string) => boolean;
434
447
  export { json5 }
435
448
 
436
449
  /** 日志 */
437
- export declare const log: ((type: LogTypeEnum, ...messages: string[]) => void) & {
450
+ export declare const log: ((type: LogTypeEnum, ...messages: unknown[]) => void) & {
438
451
  /** 成功 */
439
- success: (...messages: string[]) => void;
452
+ success: (...messages: unknown[]) => void;
440
453
  /** /步骤 */
441
- stage: (...messages: string[]) => void;
454
+ stage: (...messages: unknown[]) => void;
442
455
  /** 提示信息 */
443
- info: (...messages: string[]) => void;
456
+ info: (...messages: unknown[]) => void;
444
457
  /** 警告 */
445
- warn: (...messages: string[]) => void;
458
+ warn: (...messages: unknown[]) => void;
446
459
  /** 错误 */
447
- error: (...messages: string[]) => void;
460
+ error: (...messages: unknown[]) => void;
448
461
  /** 跳过 */
449
- skip: (...messages: string[]) => void;
462
+ skip: (...messages: unknown[]) => void;
450
463
  };
451
464
 
465
+ export declare type LogParams = [type: LogTypeEnum, ...messages: unknown[]];
466
+
452
467
  /** 日志类型 */
453
468
  declare enum LogTypeEnum {
454
469
  /** 成功 */