@done-coding/cli-template 0.7.2-alpha.0 → 0.7.3

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