@done-coding/cli-template 0.7.3 → 0.7.4-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/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as m } from "./main-14b08350.js";
2
+ import { d as m } from "./main-83901dc2.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:path";
5
5
  import "node:fs";
package/es/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { M as r } from "./main-14b08350.js";
3
- import { O as E, S as h, T as b, b as T, c as A, a as H, h as O, i as S } from "./main-14b08350.js";
2
+ import { M as r } from "./main-83901dc2.js";
3
+ import { O as E, S as h, T as b, b as T, c as A, a as H, h as O, i as S } from "./main-83901dc2.js";
4
4
  import t from "node:path";
5
5
  import { existsSync as n } from "node:fs";
6
6
  import "@done-coding/cli-utils";
@@ -4,10 +4,10 @@ import k from "node:path";
4
4
  import f from "node:fs";
5
5
  import O from "lodash.template";
6
6
  import B from "lodash.assign";
7
- var I = /* @__PURE__ */ ((e) => (e.INIT = "init", e.COMPILE = "compile", e))(I || {}), J = /* @__PURE__ */ ((e) => (e.REPOSITORY_URL = "REPOSITORY_URL", e))(J || {}), b = /* @__PURE__ */ ((e) => (e.OVERWRITE = "overwrite", e.APPEND = "append", e.REPLACE = "replace", e.RETURN = "return", e))(b || {});
7
+ var h = /* @__PURE__ */ ((e) => (e.INIT = "init", e.COMPILE = "compile", e))(h || {}), J = /* @__PURE__ */ ((e) => (e.REPOSITORY_URL = "REPOSITORY_URL", e))(J || {}), b = /* @__PURE__ */ ((e) => (e.OVERWRITE = "overwrite", e.APPEND = "append", e.REPLACE = "replace", e.RETURN = "return", e))(b || {});
8
8
  const _ = {
9
9
  name: "@done-coding/cli-template",
10
- version: "0.7.3",
10
+ version: "0.7.4-alpha.0",
11
11
  description: "预编译命令行工具",
12
12
  cliConfig: {
13
13
  namespaceDir: ".done-coding",
@@ -15,7 +15,7 @@ const _ = {
15
15
  }
16
16
  }, {
17
17
  cliConfig: { namespaceDir: K, moduleName: q }
18
- } = _, z = `./${K}/${q}`, h = `${z}.json`, v = {
18
+ } = _, z = `./${K}/${q}`, I = `${z}.json`, v = {
19
19
  rollback: !1,
20
20
  dealMarkdown: !1,
21
21
  mode: b.OVERWRITE,
@@ -24,22 +24,22 @@ const _ = {
24
24
  }, S = (e) => {
25
25
  const {
26
26
  rollback: t,
27
- dealMarkdown: l,
27
+ dealMarkdown: s,
28
28
  mode: c,
29
- batch: s,
29
+ batch: l,
30
30
  rootDir: o,
31
31
  configPath: i,
32
32
  rollbackDelNullFile: r,
33
33
  ...u
34
34
  } = e, { rootDir: g, configPath: D } = N({
35
- configPathDefault: h
35
+ configPathDefault: I
36
36
  });
37
37
  return {
38
38
  rollback: t ?? v.rollback,
39
39
  rollbackDelNullFile: r ?? v.rollbackDelNullFile,
40
- dealMarkdown: l ?? v.dealMarkdown,
40
+ dealMarkdown: s ?? v.dealMarkdown,
41
41
  mode: c ?? v.mode,
42
- batch: s ?? v.batch,
42
+ batch: l ?? v.batch,
43
43
  rootDir: o ?? g.default,
44
44
  configPath: i ?? D.default,
45
45
  ...u
@@ -101,7 +101,7 @@ const _ = {
101
101
  default: v.batch
102
102
  },
103
103
  ...N({
104
- configPathDefault: h
104
+ configPathDefault: I
105
105
  })
106
106
  }), Q = {
107
107
  globalEnvData: {},
@@ -139,13 +139,13 @@ const _ = {
139
139
  }
140
140
  ]
141
141
  }, X = () => N({
142
- configPathDefault: h
142
+ configPathDefault: I
143
143
  }), ee = async (e) => {
144
144
  let t = {};
145
145
  if (e)
146
146
  t = Q;
147
147
  else {
148
- const { globalEnvCount: l, collectEnvCount: c, compileFileCount: s } = await R([
148
+ const { globalEnvCount: s, collectEnvCount: c, compileFileCount: l } = await R([
149
149
  {
150
150
  name: "globalEnvCount",
151
151
  type: "number",
@@ -171,16 +171,16 @@ const _ = {
171
171
  validate: (o) => o >= 0
172
172
  }
173
173
  ]);
174
- l && (t.globalEnvData = Array.from({
175
- length: l
174
+ s && (t.globalEnvData = Array.from({
175
+ length: s
176
176
  }).reduce((o, i, r) => (o[`GLOBAL_${r}`] = "", o), {})), c && (t.collectEnvDataForm = Array.from({
177
177
  length: c
178
178
  }).map((o, i) => ({
179
179
  key: `COLLECT_KEY_${i}`,
180
180
  label: `COLLECT_LABEL_${i}`,
181
181
  initial: void 0
182
- }))), s && (t.list = Array.from({
183
- length: s
182
+ }))), l && (t.list = Array.from({
183
+ length: l
184
184
  }).map((o, i) => ({
185
185
  input: `(相对于命令运行目录)需要编译的模板文件路径${i}`,
186
186
  output: `(相对于命令运行目录)编译后输出的文件路径${i}`,
@@ -189,8 +189,9 @@ const _ = {
189
189
  }
190
190
  return t;
191
191
  }, te = async (e) => {
192
- const t = await V(), l = await ee(t);
193
- await W(l, e, {
192
+ const t = await V(), s = await ee(t);
193
+ await W(s, e, {
194
+ edit: !0,
194
195
  onFileGenerated(c) {
195
196
  t || a.success(`配置文件已生成:${c}
196
197
  请具体需要替换
@@ -203,15 +204,15 @@ const _ = {
203
204
  }, x = ({
204
205
  rootDir: e,
205
206
  filePath: t,
206
- dataInit: l,
207
+ dataInit: s,
207
208
  limitJson: c,
208
- filePathKey: s,
209
+ filePathKey: l,
209
210
  dataInitKey: o,
210
211
  dealMarkdown: i = !1
211
212
  }) => {
212
213
  if (t) {
213
214
  if (c && !t.endsWith(".json"))
214
- return a.error(`${s}必须是json文件,请检查文件后缀名`), process.exit(1);
215
+ return a.error(`${l}必须是json文件,请检查文件后缀名`), process.exit(1);
215
216
  const r = f.readFileSync(
216
217
  k.resolve(e, t),
217
218
  "utf-8"
@@ -222,7 +223,7 @@ const _ = {
222
223
  "$1"
223
224
  )), c ? JSON.parse(u) : u;
224
225
  } else
225
- return l ? (a.info(`${s} 为空,将使用${o}作为数据`), c ? JSON.parse(l) : l) : (a.error(`${s}与${o}不能同时为空`), process.exit(1));
226
+ return s ? (a.info(`${l} 为空,将使用${o}作为数据`), c ? JSON.parse(s) : s) : (a.error(`${l}与${o}不能同时为空`), process.exit(1));
226
227
  }, P = (e, t) => {
227
228
  if (!t)
228
229
  return a.error(`${e}模式下output不能为空`), process.exit(1);
@@ -234,11 +235,11 @@ const _ = {
234
235
  return a.error(`${e}模式下input不能为空`), process.exit(1);
235
236
  }, M = async (e, {
236
237
  rootDir: t,
237
- rollbackDelFileAgree: l = !1
238
+ rollbackDelFileAgree: s = !1
238
239
  }) => {
239
240
  const {
240
241
  env: c,
241
- input: s,
242
+ input: l,
242
243
  inputData: o,
243
244
  output: i,
244
245
  mode: r,
@@ -261,7 +262,7 @@ rollback: ${u}
261
262
  `);
262
263
  const m = x({
263
264
  rootDir: t,
264
- filePath: s,
265
+ filePath: l,
265
266
  dataInit: o,
266
267
  limitJson: !1,
267
268
  filePathKey: "input",
@@ -270,11 +271,11 @@ rollback: ${u}
270
271
  }), d = O(m), C = typeof E == "function" ? E() : E, p = d(C);
271
272
  switch (r) {
272
273
  case b.OVERWRITE: {
273
- P(r, i), w(i, s);
274
+ P(r, i), w(i, l);
274
275
  const n = k.resolve(t, i);
275
276
  if (f.mkdirSync(k.dirname(n), { recursive: !0 }), f.existsSync(n)) {
276
277
  if (u)
277
- if (l || (await R({
278
+ if (s || (await R({
278
279
  type: "confirm",
279
280
  name: "remove",
280
281
  message: `${r}模式下回滚将删除${n},是否继续?`
@@ -297,7 +298,7 @@ rollback: ${u}
297
298
  break;
298
299
  }
299
300
  case b.APPEND: {
300
- P(r, i), w(i, s);
301
+ P(r, i), w(i, l);
301
302
  const n = k.resolve(t, i);
302
303
  if (f.mkdirSync(k.dirname(n), { recursive: !0 }), f.existsSync(n)) {
303
304
  const $ = f.readFileSync(n, "utf-8");
@@ -318,9 +319,9 @@ rollback: ${u}
318
319
  break;
319
320
  }
320
321
  case b.REPLACE: {
321
- if (i && a.warn(`output ${i} 将被忽略`), ne(r, s), c && c === s)
322
+ if (i && a.warn(`output ${i} 将被忽略`), ne(r, l), c && c === l)
322
323
  return a.error("env 与 input 不能相同"), process.exit(1);
323
- const n = k.resolve(t, s);
324
+ const n = k.resolve(t, l);
324
325
  let $ = n;
325
326
  const y = O(n)(C);
326
327
  y !== n && (a.success(`检测输入文件名也需要替换
@@ -335,12 +336,12 @@ rollback: ${u}
335
336
  return p;
336
337
  }, ae = async ({
337
338
  rootDir: e,
338
- configPath: t = h,
339
- itemDefaultRollback: l = !1,
339
+ configPath: t = I,
340
+ itemDefaultRollback: s = !1,
340
341
  extraEnvData: c = {}
341
- }, s) => {
342
+ }, l) => {
342
343
  let o;
343
- if (s ? o = s : o = await G({
344
+ if (l ? o = l : o = await G({
344
345
  rootDir: e,
345
346
  configPath: t
346
347
  }), !o)
@@ -362,7 +363,7 @@ rollback: ${u}
362
363
  }))[d];
363
364
  }
364
365
  const D = i.map((m) => {
365
- const { rollback: d = l } = m, {
366
+ const { rollback: d = s } = m, {
366
367
  envData: C,
367
368
  env: p,
368
369
  input: n,
@@ -395,9 +396,9 @@ rollback: ${u}
395
396
  }, oe = async (e) => {
396
397
  const {
397
398
  envData: t,
398
- env: l,
399
+ env: s,
399
400
  input: c,
400
- inputData: s,
401
+ inputData: l,
401
402
  output: o,
402
403
  mode: i,
403
404
  rollback: r,
@@ -417,7 +418,7 @@ rollback: ${u}
417
418
  a.stage("开始单个处理");
418
419
  const d = x({
419
420
  rootDir: E,
420
- filePath: l,
421
+ filePath: s,
421
422
  dataInit: t,
422
423
  limitJson: !0,
423
424
  filePathKey: "env",
@@ -427,7 +428,7 @@ rollback: ${u}
427
428
  return M(
428
429
  {
429
430
  input: c,
430
- inputData: s,
431
+ inputData: l,
431
432
  output: o,
432
433
  mode: i,
433
434
  rollback: r,
@@ -439,34 +440,34 @@ rollback: ${u}
439
440
  rootDir: E
440
441
  }
441
442
  );
442
- }, U = async (e, t) => e === I.INIT ? te(t) : e === I.COMPILE ? oe(t) : (a.error(`无效的命令: ${e}`), process.exit(1)), {
443
+ }, U = async (e, t) => e === h.INIT ? te(t) : e === h.COMPILE ? oe(t) : (a.error(`无效的命令: ${e}`), process.exit(1)), {
443
444
  version: re,
444
445
  description: ie,
445
446
  cliConfig: { moduleName: F }
446
- } = _, se = {
447
- command: I.INIT,
447
+ } = _, le = {
448
+ command: h.INIT,
448
449
  describe: "初始化模板配置文件",
449
450
  options: X(),
450
451
  handler: T(U)(
451
- I.INIT
452
+ h.INIT
452
453
  )
453
- }, le = {
454
- command: I.COMPILE,
454
+ }, se = {
455
+ command: h.COMPILE,
455
456
  describe: "编译模板",
456
457
  options: Z(),
457
458
  handler: T(U)(
458
- I.COMPILE
459
+ h.COMPILE
459
460
  )
460
461
  }, j = {
461
462
  describe: ie,
462
463
  version: re,
463
- subcommands: [se, le].map(
464
+ subcommands: [le, se].map(
464
465
  A
465
466
  ),
466
467
  demandCommandCount: 1
467
468
  }, H = (e = !1) => {
468
- const t = e ? F : void 0, l = `$0${e ? ` ${F}` : ""} <command> [options]`;
469
- return { command: t, usage: l };
469
+ const t = e ? F : void 0, s = `$0${e ? ` ${F}` : ""} <command> [options]`;
470
+ return { command: t, usage: s };
470
471
  }, de = async () => Y({
471
472
  ...j,
472
473
  ...H()
@@ -475,9 +476,9 @@ rollback: ${u}
475
476
  ...H(!0)
476
477
  });
477
478
  export {
478
- h as M,
479
+ I as M,
479
480
  b as O,
480
- I as S,
481
+ h as S,
481
482
  J as T,
482
483
  be as a,
483
484
  ae as b,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-template",
3
- "version": "0.7.3",
3
+ "version": "0.7.4-alpha.0",
4
4
  "description": "预编译命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "license": "MIT",
41
41
  "sideEffects": false,
42
42
  "devDependencies": {
43
- "@done-coding/cli-inject": "^0.5.2",
43
+ "@done-coding/cli-inject": "^0.5.3-alpha.0",
44
44
  "@types/lodash.assign": "^4.2.9",
45
45
  "@types/lodash.template": "^4.5.3",
46
46
  "@types/node": "^18.0.0",
@@ -54,9 +54,9 @@
54
54
  "node": ">=18.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "@done-coding/cli-utils": "^0.3.2",
57
+ "@done-coding/cli-utils": "^0.3.3-alpha.0",
58
58
  "lodash.assign": "^4.2.0",
59
59
  "lodash.template": "^4.5.0"
60
60
  },
61
- "gitHead": "7a8d554748b844c8b7694c587983b21af902d5d1"
61
+ "gitHead": "9b65389752c25c4b7fff7fa8dfd46e5788ef2390"
62
62
  }
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-template",
3
- "version": "0.7.3",
3
+ "version": "0.7.4-alpha.0",
4
4
  "description": "预编译命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",