done-coding-template 0.7.9-alpha.0 → 0.7.10

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-cc17e60c.js";
2
+ import { d as m } from "./main-0b803373.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-cc17e60c.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-cc17e60c.js";
2
+ import { M as r } from "./main-0b803373.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-0b803373.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.9-alpha.0",
10
+ version: "0.7.10",
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
  edit: !0,
195
195
  onFileGenerated(c) {
196
196
  t || a.success(`配置文件已生成:${c}
@@ -204,15 +204,15 @@ const _ = {
204
204
  }, x = ({
205
205
  rootDir: e,
206
206
  filePath: t,
207
- dataInit: s,
207
+ dataInit: l,
208
208
  limitJson: c,
209
- filePathKey: l,
209
+ filePathKey: s,
210
210
  dataInitKey: o,
211
211
  dealMarkdown: i = !1
212
212
  }) => {
213
213
  if (t) {
214
214
  if (c && !t.endsWith(".json"))
215
- return a.error(`${l}必须是json文件,请检查文件后缀名`), process.exit(1);
215
+ return a.error(`${s}必须是json文件,请检查文件后缀名`), process.exit(1);
216
216
  const r = f.readFileSync(
217
217
  k.resolve(e, t),
218
218
  "utf-8"
@@ -223,7 +223,7 @@ const _ = {
223
223
  "$1"
224
224
  )), c ? JSON.parse(u) : u;
225
225
  } else
226
- return s ? (a.info(`${l} 为空,将使用${o}作为数据`), c ? JSON.parse(s) : s) : (a.error(`${l}与${o}不能同时为空`), process.exit(1));
226
+ return l ? (a.info(`${s} 为空,将使用${o}作为数据`), c ? JSON.parse(l) : l) : (a.error(`${s}与${o}不能同时为空`), process.exit(1));
227
227
  }, P = (e, t) => {
228
228
  if (!t)
229
229
  return a.error(`${e}模式下output不能为空`), process.exit(1);
@@ -235,11 +235,11 @@ const _ = {
235
235
  return a.error(`${e}模式下input不能为空`), process.exit(1);
236
236
  }, M = async (e, {
237
237
  rootDir: t,
238
- rollbackDelFileAgree: s = !1
238
+ rollbackDelFileAgree: l = !1
239
239
  }) => {
240
240
  const {
241
241
  env: c,
242
- input: l,
242
+ input: s,
243
243
  inputData: o,
244
244
  output: i,
245
245
  mode: r,
@@ -262,7 +262,7 @@ rollback: ${u}
262
262
  `);
263
263
  const m = x({
264
264
  rootDir: t,
265
- filePath: l,
265
+ filePath: s,
266
266
  dataInit: o,
267
267
  limitJson: !1,
268
268
  filePathKey: "input",
@@ -271,11 +271,11 @@ rollback: ${u}
271
271
  }), d = O(m), C = typeof E == "function" ? E() : E, p = d(C);
272
272
  switch (r) {
273
273
  case b.OVERWRITE: {
274
- P(r, i), w(i, l);
274
+ P(r, i), w(i, s);
275
275
  const n = k.resolve(t, i);
276
276
  if (f.mkdirSync(k.dirname(n), { recursive: !0 }), f.existsSync(n)) {
277
277
  if (u)
278
- if (s || (await R({
278
+ if (l || (await R({
279
279
  type: "confirm",
280
280
  name: "remove",
281
281
  message: `${r}模式下回滚将删除${n},是否继续?`
@@ -298,7 +298,7 @@ rollback: ${u}
298
298
  break;
299
299
  }
300
300
  case b.APPEND: {
301
- P(r, i), w(i, l);
301
+ P(r, i), w(i, s);
302
302
  const n = k.resolve(t, i);
303
303
  if (f.mkdirSync(k.dirname(n), { recursive: !0 }), f.existsSync(n)) {
304
304
  const $ = f.readFileSync(n, "utf-8");
@@ -319,9 +319,9 @@ rollback: ${u}
319
319
  break;
320
320
  }
321
321
  case b.REPLACE: {
322
- if (i && a.warn(`output ${i} 将被忽略`), ne(r, l), c && c === l)
322
+ if (i && a.warn(`output ${i} 将被忽略`), ne(r, s), c && c === s)
323
323
  return a.error("env 与 input 不能相同"), process.exit(1);
324
- const n = k.resolve(t, l);
324
+ const n = k.resolve(t, s);
325
325
  let $ = n;
326
326
  const y = O(n)(C);
327
327
  y !== n && (a.success(`检测输入文件名也需要替换
@@ -336,12 +336,12 @@ rollback: ${u}
336
336
  return p;
337
337
  }, ae = async ({
338
338
  rootDir: e,
339
- configPath: t = I,
340
- itemDefaultRollback: s = !1,
339
+ configPath: t = h,
340
+ itemDefaultRollback: l = !1,
341
341
  extraEnvData: c = {}
342
- }, l) => {
342
+ }, s) => {
343
343
  let o;
344
- if (l ? o = l : o = await G({
344
+ if (s ? o = s : o = await G({
345
345
  rootDir: e,
346
346
  configPath: t
347
347
  }), !o)
@@ -363,7 +363,7 @@ rollback: ${u}
363
363
  }))[d];
364
364
  }
365
365
  const D = i.map((m) => {
366
- const { rollback: d = s } = m, {
366
+ const { rollback: d = l } = m, {
367
367
  envData: C,
368
368
  env: p,
369
369
  input: n,
@@ -396,9 +396,9 @@ rollback: ${u}
396
396
  }, oe = async (e) => {
397
397
  const {
398
398
  envData: t,
399
- env: s,
399
+ env: l,
400
400
  input: c,
401
- inputData: l,
401
+ inputData: s,
402
402
  output: o,
403
403
  mode: i,
404
404
  rollback: r,
@@ -418,7 +418,7 @@ rollback: ${u}
418
418
  a.stage("开始单个处理");
419
419
  const d = x({
420
420
  rootDir: E,
421
- filePath: s,
421
+ filePath: l,
422
422
  dataInit: t,
423
423
  limitJson: !0,
424
424
  filePathKey: "env",
@@ -428,7 +428,7 @@ rollback: ${u}
428
428
  return M(
429
429
  {
430
430
  input: c,
431
- inputData: l,
431
+ inputData: s,
432
432
  output: o,
433
433
  mode: i,
434
434
  rollback: r,
@@ -440,34 +440,34 @@ rollback: ${u}
440
440
  rootDir: E
441
441
  }
442
442
  );
443
- }, U = async (e, t) => e === h.INIT ? te(t) : e === h.COMPILE ? oe(t) : (a.error(`无效的命令: ${e}`), process.exit(1)), {
443
+ }, U = async (e, t) => e === I.INIT ? te(t) : e === I.COMPILE ? oe(t) : (a.error(`无效的命令: ${e}`), process.exit(1)), {
444
444
  version: re,
445
445
  description: ie,
446
446
  cliConfig: { moduleName: F }
447
- } = _, le = {
448
- command: h.INIT,
447
+ } = _, se = {
448
+ command: I.INIT,
449
449
  describe: "初始化模板配置文件",
450
450
  options: X(),
451
451
  handler: T(U)(
452
- h.INIT
452
+ I.INIT
453
453
  )
454
- }, se = {
455
- command: h.COMPILE,
454
+ }, le = {
455
+ command: I.COMPILE,
456
456
  describe: "编译模板",
457
457
  options: Z(),
458
458
  handler: T(U)(
459
- h.COMPILE
459
+ I.COMPILE
460
460
  )
461
461
  }, j = {
462
462
  describe: ie,
463
463
  version: re,
464
- subcommands: [le, se].map(
464
+ subcommands: [se, le].map(
465
465
  A
466
466
  ),
467
467
  demandCommandCount: 1
468
468
  }, H = (e = !1) => {
469
- const t = e ? F : void 0, s = `$0${e ? ` ${F}` : ""} <command> [options]`;
470
- return { command: t, usage: s };
469
+ const t = e ? F : void 0, l = `$0${e ? ` ${F}` : ""} <command> [options]`;
470
+ return { command: t, usage: l };
471
471
  }, de = async () => Y({
472
472
  ...j,
473
473
  ...H()
@@ -476,9 +476,9 @@ rollback: ${u}
476
476
  ...H(!0)
477
477
  });
478
478
  export {
479
- I as M,
479
+ h as M,
480
480
  b as O,
481
- h as S,
481
+ I as S,
482
482
  J as T,
483
483
  be as a,
484
484
  ae as b,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "done-coding-template",
3
- "version": "0.7.9-alpha.0",
3
+ "version": "0.7.10",
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.9-alpha.0",
33
+ "@done-coding/cli-inject": "^0.5.10",
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.0",
47
+ "@done-coding/cli-utils": "^0.7.1",
48
48
  "lodash.assign": "^4.2.0",
49
49
  "lodash.template": "^4.5.0"
50
50
  },
51
- "gitHead": "62a4c9df2bf8690e52753e0734ebb09010bb2e88",
51
+ "gitHead": "299ab3991d6842c83d65816dfba6efd175aa885a",
52
52
  "scripts": {}
53
53
  }
package/types/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { }
package/types/index.d.ts CHANGED
@@ -1,5 +1,125 @@
1
- export { handler } from './handler';
2
- export { initHandler, compileHandler, batchCompileHandler, MODULE_DEFAULT_CONFIG_RELATIVE_PATH, } from './utils';
3
- export { crateAsSubcommand } from "./main";
4
- export * from './utils/types';
5
- export * from './utils/config';
1
+ import { CliHandlerArgv } from '@done-coding/cli-utils';
2
+ import { CommandModule } from 'yargs';
3
+ import type { InitConfigFileOptions } from '@done-coding/cli-utils';
4
+ import type { ReadConfigFileOptions } from '@done-coding/cli-utils';
5
+
6
+ /** 批量编译模板 */
7
+ export declare const batchCompileHandler: ({ rootDir, configPath, itemDefaultRollback, extraEnvData, }: {
8
+ /** 项目更目录 */
9
+ rootDir: string;
10
+ /** 配置文件路径 */
11
+ configPath?: string | undefined;
12
+ /** item默认回滚? */
13
+ itemDefaultRollback?: boolean | undefined;
14
+ /** 额外环境变量 */
15
+ extraEnvData?: object | undefined;
16
+ }, paramsConfig?: CompileTemplateConfig) => Promise<(string | undefined)[]>;
17
+
18
+ /** 采集环境变量配置 */
19
+ export declare interface CollectFormItem {
20
+ /** 采集环境变量的key */
21
+ key: string;
22
+ /** 采集环境变量标签 */
23
+ label: string;
24
+ /** 采集环境变量初始值 */
25
+ initial?: string;
26
+ /** 绑定的关键变量 */
27
+ bindKey?: TemplateBindKeyEnum;
28
+ }
29
+
30
+ /** 编译模板 */
31
+ export declare const compileHandler: (argv: CliHandlerArgv<CompileOptions>) => Promise<string | (string | undefined)[] | undefined>;
32
+
33
+ export declare interface CompileOptions {
34
+ /** 项目根目录 */
35
+ rootDir: string;
36
+ /** 配置文件路径 */
37
+ configPath?: string;
38
+ /** 环境数据(json)文件(优先级高于 envData ) */
39
+ env?: string;
40
+ /** 环境变量数据(JSON字符串) */
41
+ envData?: string;
42
+ /** 模板文件相对路径(优先级高于 inputData ) */
43
+ input?: string;
44
+ /** 模板数据 */
45
+ inputData?: string;
46
+ /** 输出文件相对路径 */
47
+ output?: string;
48
+ /** 输出模式 @default OutputModeEnum.OVERWRITE */
49
+ mode: OutputModeEnum;
50
+ /** 是否回滚 @default false */
51
+ rollback?: boolean;
52
+ /**
53
+ * 回滚删除空文件
54
+ * ---
55
+ * 只限 OutputModeEnum.APPEND 模式下生效
56
+ */
57
+ rollbackDelNullFile?: boolean;
58
+ /** (检测是markdown)是否处理(单个)代码块包裹 */
59
+ dealMarkdown?: boolean;
60
+ /** 是否批量处理 */
61
+ batch?: boolean;
62
+ }
63
+
64
+ /** 编译模板配置 */
65
+ export declare interface CompileTemplateConfig {
66
+ /** 全局环境变量 */
67
+ globalEnvData?: Record<string, any>;
68
+ /** 采集环境变量表单配置 */
69
+ collectEnvDataForm?: (CollectFormItem | string)[];
70
+ /** 配置列表 */
71
+ list?: Omit<CompileOptions, keyof ReadConfigFileOptions>[];
72
+ }
73
+
74
+ /**
75
+ * 编译模板配置选项
76
+ */
77
+ export declare type CompileTemplateConfigListItem = Omit<CompileOptions, "envData" | keyof ReadConfigFileOptions> & {
78
+ /** 已经解析为对象的envData */
79
+ envData: Record<string, any>;
80
+ };
81
+
82
+ /** 作为子命令创建 */
83
+ export declare const crateAsSubcommand: () => CommandModule<{}, {}>;
84
+
85
+ /** 获取配置文件路径 */
86
+ export declare const getConfigPath: ({ rootDir, configPath, }: ReadConfigFileOptions) => string | undefined;
87
+
88
+ /** 命令处理函数 */
89
+ export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<InitOptions | CompileOptions>) => Promise<string | void | (string | undefined)[]>;
90
+
91
+ /** 初始化模板 */
92
+ export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
93
+
94
+ export declare type InitOptions = InitConfigFileOptions;
95
+
96
+ /** 模块默认配置文件相对路径 */
97
+ export declare const MODULE_DEFAULT_CONFIG_RELATIVE_PATH: string;
98
+
99
+ /** 输出模式 */
100
+ export declare enum OutputModeEnum {
101
+ /** 覆盖模式 */
102
+ OVERWRITE = "overwrite",
103
+ /** 追加模式 */
104
+ APPEND = "append",
105
+ /** 替换模式 */
106
+ REPLACE = "replace",
107
+ /** 返回模式--函数调用方式可用 */
108
+ RETURN = "return"
109
+ }
110
+
111
+ /** 子命令枚举 */
112
+ export declare enum SubcommandEnum {
113
+ /** 初始化模板 */
114
+ INIT = "init",
115
+ /** 编译模板 */
116
+ COMPILE = "compile"
117
+ }
118
+
119
+ /** 绑定的关键变量枚举 */
120
+ export declare enum TemplateBindKeyEnum {
121
+ /** 远程仓库地址 */
122
+ REPOSITORY_URL = "REPOSITORY_URL"
123
+ }
124
+
125
+ export { }
@@ -1,5 +0,0 @@
1
- import type { CompileOptions, InitOptions } from './utils';
2
- import { SubcommandEnum } from './utils';
3
- import type { CliHandlerArgv } from "@done-coding/cli-utils";
4
- /** 命令处理函数 */
5
- export declare const handler: (command: SubcommandEnum, argv: CliHandlerArgv<InitOptions | CompileOptions>) => Promise<string | void | (string | undefined)[]>;
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- "name": "@done-coding/cli-template",
3
- "version": "0.7.9-alpha.0",
4
- "description": "预编译命令行工具",
5
- "cliConfig": {
6
- "namespaceDir": ".done-coding",
7
- "moduleName": "template"
8
- }
9
- };
10
-
11
- export default _default;
@@ -1,38 +0,0 @@
1
- declare const _default: {
2
- "globalEnvData": {},
3
- "collectEnvDataForm": [
4
- {
5
- "key": "name",
6
- "label": "项目名"
7
- },
8
- {
9
- "key": "chineseName",
10
- "label": "项目中文名"
11
- },
12
- {
13
- "key": "description",
14
- "label": "描述",
15
- "initial": "这是一个描述"
16
- },
17
- {
18
- "key": "repositoryUrl",
19
- "label": "仓库地址",
20
- "initial": "",
21
- "bindKey": "REPOSITORY_URL"
22
- }
23
- ],
24
- "list": [
25
- {
26
- "input": "./package.json",
27
- "output": "./package.json",
28
- "mode": "replace"
29
- },
30
- {
31
- "input": "./README.md",
32
- "output": "./README.md",
33
- "mode": "replace"
34
- }
35
- ]
36
- };
37
-
38
- export default _default;
package/types/main.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /// <reference types="yargs" />
2
- /** 作为主命令创建 */
3
- export declare const createCommand: () => Promise<void | {
4
- [x: string]: unknown;
5
- _: (string | number)[];
6
- $0: string;
7
- }>;
8
- /** 作为子命令创建 */
9
- export declare const crateAsSubcommand: () => import("yargs").CommandModule<{}, {}>;
@@ -1,16 +0,0 @@
1
- import type { CompileTemplateConfig } from '.';
2
- import { type CompileOptions } from '.';
3
- import type { CliHandlerArgv } from "@done-coding/cli-utils";
4
- /** 批量编译模板 */
5
- export declare const batchCompileHandler: ({ rootDir, configPath, itemDefaultRollback, extraEnvData, }: {
6
- /** 项目更目录 */
7
- rootDir: string;
8
- /** 配置文件路径 */
9
- configPath?: string | undefined;
10
- /** item默认回滚? */
11
- itemDefaultRollback?: boolean | undefined;
12
- /** 额外环境变量 */
13
- extraEnvData?: object | undefined;
14
- }, paramsConfig?: CompileTemplateConfig) => Promise<(string | undefined)[]>;
15
- /** 编译模板 */
16
- export declare const compileHandler: (argv: CliHandlerArgv<CompileOptions>) => Promise<string | (string | undefined)[] | undefined>;
@@ -1,3 +0,0 @@
1
- import type { ReadConfigFileOptions } from "@done-coding/cli-utils";
2
- /** 获取配置文件路径 */
3
- export declare const getConfigPath: ({ rootDir, configPath, }: ReadConfigFileOptions) => string | undefined;
@@ -1,21 +0,0 @@
1
- import { type CliInfo } from "@done-coding/cli-utils";
2
- import { OutputModeEnum, type CompileOptions } from "./types";
3
- /** 编译默认选项 */
4
- export declare const defaultCompileOptions: Pick<CompileOptions, "rollback" | "dealMarkdown" | "mode" | "batch" | "rollbackDelNullFile">;
5
- /** 设置编译默认选项 */
6
- export declare const completeDefaultCompileOptions: <T extends Pick<CompileOptions, "mode" | "rollback" | "rollbackDelNullFile" | "dealMarkdown" | "batch">>(options: T) => {
7
- env?: string | undefined;
8
- envData?: string | undefined;
9
- input?: string | undefined;
10
- inputData?: string | undefined;
11
- output?: string | undefined;
12
- rollback: boolean | undefined;
13
- rollbackDelNullFile: boolean | undefined;
14
- dealMarkdown: boolean | undefined;
15
- mode: OutputModeEnum;
16
- batch: boolean | undefined;
17
- rootDir: string;
18
- configPath: string;
19
- };
20
- /** 获取编译选项 */
21
- export declare const getCompileOptions: () => CliInfo["options"];
@@ -1,6 +0,0 @@
1
- export * from "./types";
2
- export * from "./dealOptions";
3
- export * from "./config";
4
- export * from "./init";
5
- export * from "./compile";
6
- export * from "./path";
@@ -1,6 +0,0 @@
1
- /// <reference types="yargs" />
2
- import { type InitOptions } from '.';
3
- import { type CliHandlerArgv } from "@done-coding/cli-utils";
4
- export declare const getInitOptions: () => Record<keyof import("@done-coding/cli-utils").ConfigFileCommonOptions, import("yargs").Options>;
5
- /** 初始化模板 */
6
- export declare const initHandler: (argv: CliHandlerArgv<InitOptions>) => Promise<void>;
@@ -1,4 +0,0 @@
1
- /** 模块配置相对路径 */
2
- export declare const MODULE_CONFIG_RELATIVE_PATH: string;
3
- /** 模块默认配置文件相对路径 */
4
- export declare const MODULE_DEFAULT_CONFIG_RELATIVE_PATH: string;
@@ -1,82 +0,0 @@
1
- import type { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
2
- /** 子命令枚举 */
3
- export declare enum SubcommandEnum {
4
- /** 初始化模板 */
5
- INIT = "init",
6
- /** 编译模板 */
7
- COMPILE = "compile"
8
- }
9
- export type InitOptions = InitConfigFileOptions;
10
- /** 绑定的关键变量枚举 */
11
- export declare enum TemplateBindKeyEnum {
12
- /** 远程仓库地址 */
13
- REPOSITORY_URL = "REPOSITORY_URL"
14
- }
15
- /** 输出模式 */
16
- export declare enum OutputModeEnum {
17
- /** 覆盖模式 */
18
- OVERWRITE = "overwrite",
19
- /** 追加模式 */
20
- APPEND = "append",
21
- /** 替换模式 */
22
- REPLACE = "replace",
23
- /** 返回模式--函数调用方式可用 */
24
- RETURN = "return"
25
- }
26
- export interface CompileOptions {
27
- /** 项目根目录 */
28
- rootDir: string;
29
- /** 配置文件路径 */
30
- configPath?: string;
31
- /** 环境数据(json)文件(优先级高于 envData ) */
32
- env?: string;
33
- /** 环境变量数据(JSON字符串) */
34
- envData?: string;
35
- /** 模板文件相对路径(优先级高于 inputData ) */
36
- input?: string;
37
- /** 模板数据 */
38
- inputData?: string;
39
- /** 输出文件相对路径 */
40
- output?: string;
41
- /** 输出模式 @default OutputModeEnum.OVERWRITE */
42
- mode: OutputModeEnum;
43
- /** 是否回滚 @default false */
44
- rollback?: boolean;
45
- /**
46
- * 回滚删除空文件
47
- * ---
48
- * 只限 OutputModeEnum.APPEND 模式下生效
49
- */
50
- rollbackDelNullFile?: boolean;
51
- /** (检测是markdown)是否处理(单个)代码块包裹 */
52
- dealMarkdown?: boolean;
53
- /** 是否批量处理 */
54
- batch?: boolean;
55
- }
56
- /**
57
- * 编译模板配置选项
58
- */
59
- export type CompileTemplateConfigListItem = Omit<CompileOptions, "envData" | keyof ReadConfigFileOptions> & {
60
- /** 已经解析为对象的envData */
61
- envData: Record<string, any>;
62
- };
63
- /** 采集环境变量配置 */
64
- export interface CollectFormItem {
65
- /** 采集环境变量的key */
66
- key: string;
67
- /** 采集环境变量标签 */
68
- label: string;
69
- /** 采集环境变量初始值 */
70
- initial?: string;
71
- /** 绑定的关键变量 */
72
- bindKey?: TemplateBindKeyEnum;
73
- }
74
- /** 编译模板配置 */
75
- export interface CompileTemplateConfig {
76
- /** 全局环境变量 */
77
- globalEnvData?: Record<string, any>;
78
- /** 采集环境变量表单配置 */
79
- collectEnvDataForm?: (CollectFormItem | string)[];
80
- /** 配置列表 */
81
- list?: Omit<CompileOptions, keyof ReadConfigFileOptions>[];
82
- }