done-coding-template 0.7.11 → 0.7.12-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-3510f696.js";
2
+ import { d as m } from "./main-3e20cca2.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-3510f696.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-3510f696.js";
2
+ import { M as r } from "./main-3e20cca2.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-3e20cca2.js";
4
4
  import t from "node:path";
5
5
  import { existsSync as n } from "node:fs";
6
6
  import "@done-coding/cli-utils";
@@ -1,27 +1,30 @@
1
1
  #!/usr/bin/env node
2
- import { getConfigFileCommonOptions as N, getUseDefaultConfig as V, initHandlerCommon as W, log as a, xPrompts as R, readConfigFile as G, _curry as T, createSubcommand as A, createMainCommand as Y } from "@done-coding/cli-utils";
2
+ import { getConfigFileCommonOptions as I, getUseDefaultConfig as V, initHandlerCommon as W, log as a, xPrompts as R, readConfigFile as G, _curry as A, createSubcommand as S, getRootScriptName as J, createMainCommand as Y } from "@done-coding/cli-utils";
3
3
  import k from "node:path";
4
4
  import f from "node:fs";
5
- import O from "lodash.template";
5
+ import P 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 || {});
8
- const _ = {
7
+ var N = /* @__PURE__ */ ((e) => (e.INIT = "init", e.COMPILE = "compile", e))(N || {}), K = /* @__PURE__ */ ((e) => (e.REPOSITORY_URL = "REPOSITORY_URL", e))(K || {}), b = /* @__PURE__ */ ((e) => (e.OVERWRITE = "overwrite", e.APPEND = "append", e.REPLACE = "replace", e.RETURN = "return", e))(b || {});
8
+ const L = {
9
9
  name: "@done-coding/cli-template",
10
- version: "0.7.11",
10
+ version: "0.7.12-alpha.0",
11
11
  description: "预编译命令行工具",
12
+ bin: {
13
+ "dc-template": "es/cli.mjs"
14
+ },
12
15
  cliConfig: {
13
16
  namespaceDir: ".done-coding",
14
17
  moduleName: "template"
15
18
  }
16
19
  }, {
17
- cliConfig: { namespaceDir: K, moduleName: q }
18
- } = _, z = `./${K}/${q}`, h = `${z}.json`, v = {
20
+ cliConfig: { namespaceDir: q, moduleName: z }
21
+ } = L, Z = `./${q}/${z}`, h = `${Z}.json`, v = {
19
22
  rollback: !1,
20
23
  dealMarkdown: !1,
21
24
  mode: b.OVERWRITE,
22
25
  batch: !1,
23
26
  rollbackDelNullFile: !1
24
- }, S = (e) => {
27
+ }, _ = (e) => {
25
28
  const {
26
29
  rollback: t,
27
30
  dealMarkdown: l,
@@ -31,7 +34,7 @@ const _ = {
31
34
  configPath: i,
32
35
  rollbackDelNullFile: r,
33
36
  ...u
34
- } = e, { rootDir: g, configPath: D } = N({
37
+ } = e, { rootDir: g, configPath: D } = I({
35
38
  configPathDefault: h
36
39
  });
37
40
  return {
@@ -44,7 +47,7 @@ const _ = {
44
47
  configPath: i ?? D.default,
45
48
  ...u
46
49
  };
47
- }, Z = () => ({
50
+ }, Q = () => ({
48
51
  env: {
49
52
  alias: "e",
50
53
  describe: "环境数据文件JSON文件相对路径(优先级高于envData)",
@@ -100,10 +103,10 @@ const _ = {
100
103
  type: "boolean",
101
104
  default: v.batch
102
105
  },
103
- ...N({
106
+ ...I({
104
107
  configPathDefault: h
105
108
  })
106
- }), Q = {
109
+ }), X = {
107
110
  globalEnvData: {},
108
111
  collectEnvDataForm: [
109
112
  {
@@ -138,12 +141,12 @@ const _ = {
138
141
  mode: "replace"
139
142
  }
140
143
  ]
141
- }, X = () => N({
144
+ }, ee = () => I({
142
145
  configPathDefault: h
143
- }), ee = async (e) => {
146
+ }), te = async (e) => {
144
147
  let t = {};
145
148
  if (e)
146
- t = Q;
149
+ t = X;
147
150
  else {
148
151
  const { globalEnvCount: l, collectEnvCount: c, compileFileCount: s } = await R([
149
152
  {
@@ -188,8 +191,8 @@ const _ = {
188
191
  })));
189
192
  }
190
193
  return t;
191
- }, te = async (e) => {
192
- const t = await V(), l = await ee(t);
194
+ }, ne = async (e) => {
195
+ const t = await V(), l = await te(t);
193
196
  await W(l, e, {
194
197
  edit: !0,
195
198
  onFileGenerated(c) {
@@ -224,13 +227,13 @@ const _ = {
224
227
  )), c ? JSON.parse(u) : u;
225
228
  } else
226
229
  return l ? (a.info(`${s} 为空,将使用${o}作为数据`), c ? JSON.parse(l) : l) : (a.error(`${s}与${o}不能同时为空`), process.exit(1));
227
- }, P = (e, t) => {
230
+ }, w = (e, t) => {
228
231
  if (!t)
229
232
  return a.error(`${e}模式下output不能为空`), process.exit(1);
230
- }, w = (e, t) => {
233
+ }, F = (e, t) => {
231
234
  if (t && e === t)
232
235
  return a.error("output与input不能相同"), process.exit(1);
233
- }, ne = (e, t) => {
236
+ }, ae = (e, t) => {
234
237
  if (!t)
235
238
  return a.error(`${e}模式下input不能为空`), process.exit(1);
236
239
  }, M = async (e, {
@@ -268,10 +271,10 @@ rollback: ${u}
268
271
  filePathKey: "input",
269
272
  dataInitKey: "inputData",
270
273
  dealMarkdown: D
271
- }), d = O(m), C = typeof E == "function" ? E() : E, p = d(C);
274
+ }), d = P(m), C = typeof E == "function" ? E() : E, p = d(C);
272
275
  switch (r) {
273
276
  case b.OVERWRITE: {
274
- P(r, i), w(i, s);
277
+ w(r, i), F(i, s);
275
278
  const n = k.resolve(t, i);
276
279
  if (f.mkdirSync(k.dirname(n), { recursive: !0 }), f.existsSync(n)) {
277
280
  if (u)
@@ -298,13 +301,13 @@ rollback: ${u}
298
301
  break;
299
302
  }
300
303
  case b.APPEND: {
301
- P(r, i), w(i, s);
304
+ w(r, i), F(i, s);
302
305
  const n = k.resolve(t, i);
303
306
  if (f.mkdirSync(k.dirname(n), { recursive: !0 }), f.existsSync(n)) {
304
307
  const $ = f.readFileSync(n, "utf-8");
305
308
  if (u) {
306
- const L = $.replace(p, "");
307
- L || !g ? f.writeFileSync(n, L, "utf-8") : (a.stage(`${r}模式下 文件为空 删除`), f.unlinkSync(n)), a.success(`${r}模式下${n}回滚完成`);
309
+ const O = $.replace(p, "");
310
+ O || !g ? f.writeFileSync(n, O, "utf-8") : (a.stage(`${r}模式下 文件为空 删除`), f.unlinkSync(n)), a.success(`${r}模式下${n}回滚完成`);
308
311
  return;
309
312
  }
310
313
  const y = $ + p;
@@ -319,11 +322,11 @@ rollback: ${u}
319
322
  break;
320
323
  }
321
324
  case b.REPLACE: {
322
- if (i && a.warn(`output ${i} 将被忽略`), ne(r, s), c && c === s)
325
+ if (i && a.warn(`output ${i} 将被忽略`), ae(r, s), c && c === s)
323
326
  return a.error("env 与 input 不能相同"), process.exit(1);
324
327
  const n = k.resolve(t, s);
325
328
  let $ = n;
326
- const y = O(n)(C);
329
+ const y = P(n)(C);
327
330
  y !== n && (a.success(`检测输入文件名也需要替换
328
331
  ${n} => ${y}`), f.rmSync(n), $ = y), f.mkdirSync(k.dirname($), { recursive: !0 }), f.writeFileSync($, p, "utf-8"), a.success(`模板处理完成,输出到 ${$}`);
329
332
  break;
@@ -334,7 +337,7 @@ rollback: ${u}
334
337
  return a.error(`mode ${r} 不支持`), process.exit(1);
335
338
  }
336
339
  return p;
337
- }, ae = async ({
340
+ }, oe = async ({
338
341
  rootDir: e,
339
342
  configPath: t = h,
340
343
  itemDefaultRollback: l = !1,
@@ -369,7 +372,7 @@ rollback: ${u}
369
372
  input: n,
370
373
  output: $,
371
374
  ...y
372
- } = S(m);
375
+ } = _(m);
373
376
  return p && a.warn(`批量处理中 env:${p} 将被忽略, 只读envData`), {
374
377
  ...y,
375
378
  env: p,
@@ -393,7 +396,7 @@ rollback: ${u}
393
396
  E.push(d);
394
397
  }
395
398
  return E;
396
- }, oe = async (e) => {
399
+ }, re = async (e) => {
397
400
  const {
398
401
  envData: t,
399
402
  env: l,
@@ -407,9 +410,9 @@ rollback: ${u}
407
410
  batch: D,
408
411
  rootDir: E,
409
412
  configPath: m
410
- } = S(e);
413
+ } = _(e);
411
414
  if (D)
412
- return a.stage("开始批量处理"), ae({
415
+ return a.stage("开始批量处理"), oe({
413
416
  // 回滚默认值 基于全局
414
417
  itemDefaultRollback: r,
415
418
  rootDir: E,
@@ -440,50 +443,51 @@ rollback: ${u}
440
443
  rootDir: E
441
444
  }
442
445
  );
443
- }, U = async (e, t) => e === I.INIT ? te(t) : e === I.COMPILE ? oe(t) : (a.error(`无效的命令: ${e}`), process.exit(1)), {
444
- version: re,
445
- description: ie,
446
- cliConfig: { moduleName: F }
447
- } = _, se = {
448
- command: I.INIT,
446
+ }, U = async (e, t) => e === N.INIT ? ne(t) : e === N.COMPILE ? re(t) : (a.error(`无效的命令: ${e}`), process.exit(1)), {
447
+ version: ie,
448
+ description: se,
449
+ cliConfig: { moduleName: T }
450
+ } = L, le = {
451
+ command: N.INIT,
449
452
  describe: "初始化模板配置文件",
450
- options: X(),
451
- handler: T(U)(
452
- I.INIT
453
+ options: ee(),
454
+ handler: A(U)(
455
+ N.INIT
453
456
  )
454
- }, le = {
455
- command: I.COMPILE,
457
+ }, ce = {
458
+ command: N.COMPILE,
456
459
  describe: "编译模板",
457
- options: Z(),
458
- handler: T(U)(
459
- I.COMPILE
460
+ options: Q(),
461
+ handler: A(U)(
462
+ N.COMPILE
460
463
  )
461
464
  }, j = {
462
- describe: ie,
463
- version: re,
464
- subcommands: [se, le].map(
465
- A
465
+ describe: se,
466
+ version: ie,
467
+ subcommands: [le, ce].map(
468
+ S
466
469
  ),
467
- demandCommandCount: 1
470
+ demandCommandCount: 1,
471
+ rootScriptName: J({ packageJson: L })
468
472
  }, H = (e = !1) => {
469
- const t = e ? F : void 0, l = `$0${e ? ` ${F}` : ""} <command> [options]`;
473
+ const t = e ? T : void 0, l = `$0${e ? ` ${T}` : ""} <command> [options]`;
470
474
  return { command: t, usage: l };
471
- }, de = async () => Y({
475
+ }, be = async () => Y({
472
476
  ...j,
473
477
  ...H()
474
- }), be = () => A({
478
+ }), Ee = () => S({
475
479
  ...j,
476
480
  ...H(!0)
477
481
  });
478
482
  export {
479
483
  h as M,
480
484
  b as O,
481
- I as S,
482
- J as T,
483
- be as a,
484
- ae as b,
485
- oe as c,
486
- de as d,
485
+ N as S,
486
+ K as T,
487
+ Ee as a,
488
+ oe as b,
489
+ re as c,
490
+ be as d,
487
491
  U as h,
488
- te as i
492
+ ne as i
489
493
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "done-coding-template",
3
- "version": "0.7.11",
3
+ "version": "0.7.12-alpha.0",
4
4
  "description": "预编译命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -30,7 +30,7 @@
30
30
  "license": "MIT",
31
31
  "sideEffects": false,
32
32
  "devDependencies": {
33
- "@done-coding/cli-inject": "^0.5.11",
33
+ "@done-coding/cli-inject": "^0.5.12-alpha.0",
34
34
  "@types/lodash.assign": "^4.2.9",
35
35
  "@types/lodash.template": "^4.5.3",
36
36
  "@types/node": "^18.0.0",
@@ -44,10 +44,10 @@
44
44
  "node": ">=18.0.0"
45
45
  },
46
46
  "dependencies": {
47
- "@done-coding/cli-utils": "^0.7.2",
47
+ "@done-coding/cli-utils": "^0.7.3-alpha.0",
48
48
  "lodash.assign": "^4.2.0",
49
49
  "lodash.template": "^4.5.0"
50
50
  },
51
- "gitHead": "ad322da7f5d0897ee91a399aff9a14b111d62825",
51
+ "gitHead": "9d9a2e60f255038a0f065e3a4e6d6d35488408ae",
52
52
  "scripts": {}
53
53
  }