@done-coding/cli-template 0.3.0 → 0.4.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/handler.mjs +174 -148
- package/es/index.mjs +7 -4
- package/es/injectInfo.json.mjs +1 -1
- package/es/main.mjs +17 -15
- package/es/utils/config.mjs +14 -0
- package/package.json +5 -5
- package/types/handler.d.ts +3 -1
- package/types/index.d.ts +2 -1
- package/types/injectInfo.json.d.ts +1 -1
- package/types/utils/config.d.ts +2 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/types.d.ts +13 -2
package/es/handler.mjs
CHANGED
|
@@ -1,213 +1,239 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { OutputModeEnum as
|
|
3
|
-
import { completeDefaultOptions as
|
|
2
|
+
import { OutputModeEnum as b } from "./utils/types.mjs";
|
|
3
|
+
import { completeDefaultOptions as k } from "./utils/dealOptions.mjs";
|
|
4
|
+
import { getConfigPath as N } from "./utils/config.mjs";
|
|
4
5
|
import m from "node:path";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
dealMarkdown: i = !1
|
|
6
|
+
import u from "node:fs";
|
|
7
|
+
import t from "chalk";
|
|
8
|
+
import F from "lodash.template";
|
|
9
|
+
import R from "lodash.assign";
|
|
10
|
+
import E from "prompts";
|
|
11
|
+
const h = ({
|
|
12
|
+
filePath: n,
|
|
13
|
+
dataInit: l,
|
|
14
|
+
limitJson: f,
|
|
15
|
+
filePathKey: s,
|
|
16
|
+
dataInitKey: g,
|
|
17
|
+
dealMarkdown: a = !1
|
|
18
18
|
}) => {
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
19
|
+
if (n) {
|
|
20
|
+
if (f && !n.endsWith(".json"))
|
|
21
21
|
return console.log(
|
|
22
|
-
|
|
22
|
+
t.red(`${s}必须是json文件,请检查文件后缀名`)
|
|
23
23
|
), process.exit(1);
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
return
|
|
24
|
+
const o = u.readFileSync(m.resolve(n), "utf-8");
|
|
25
|
+
let c = o;
|
|
26
|
+
return a && n.endsWith(".md") && (c = o.replace(
|
|
27
27
|
/^\s*```[a-zA-Z0-9]+\s*[\r\n]+([\s\S]+?)```\s*$/,
|
|
28
28
|
"$1"
|
|
29
|
-
)),
|
|
29
|
+
)), f ? JSON.parse(c) : c;
|
|
30
30
|
} else
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
),
|
|
34
|
-
},
|
|
35
|
-
if (!
|
|
36
|
-
return console.log(
|
|
37
|
-
}, D = (
|
|
38
|
-
if (
|
|
39
|
-
return console.log(
|
|
40
|
-
},
|
|
41
|
-
if (!
|
|
42
|
-
return console.log(
|
|
43
|
-
},
|
|
44
|
-
rollbackDelFileAgree:
|
|
31
|
+
return l ? (console.log(
|
|
32
|
+
t.green(`${s} 为空,将使用${g}作为数据`)
|
|
33
|
+
), f ? JSON.parse(l) : l) : (console.log(t.red(`${s}与${g}不能同时为空`)), process.exit(1));
|
|
34
|
+
}, S = (n, l) => {
|
|
35
|
+
if (!l)
|
|
36
|
+
return console.log(t.red(`${n}模式下output不能为空`)), process.exit(1);
|
|
37
|
+
}, D = (n, l) => {
|
|
38
|
+
if (l && n === l)
|
|
39
|
+
return console.log(t.red("output与input不能相同")), process.exit(1);
|
|
40
|
+
}, I = (n, l) => {
|
|
41
|
+
if (!l)
|
|
42
|
+
return console.log(t.red(`${n}模式下input不能为空`)), process.exit(1);
|
|
43
|
+
}, x = async (n, {
|
|
44
|
+
rollbackDelFileAgree: l = !1
|
|
45
45
|
} = {}) => {
|
|
46
46
|
const {
|
|
47
|
-
env:
|
|
48
|
-
input:
|
|
49
|
-
inputData:
|
|
50
|
-
output:
|
|
51
|
-
mode:
|
|
52
|
-
rollback:
|
|
53
|
-
dealMarkdown:
|
|
54
|
-
envData:
|
|
55
|
-
} =
|
|
56
|
-
if (
|
|
57
|
-
switch (
|
|
58
|
-
case
|
|
59
|
-
case
|
|
60
|
-
console.log(
|
|
47
|
+
env: f,
|
|
48
|
+
input: s,
|
|
49
|
+
inputData: g,
|
|
50
|
+
output: a,
|
|
51
|
+
mode: o,
|
|
52
|
+
rollback: c,
|
|
53
|
+
dealMarkdown: v,
|
|
54
|
+
envData: d
|
|
55
|
+
} = n;
|
|
56
|
+
if (c)
|
|
57
|
+
switch (o) {
|
|
58
|
+
case b.REPLACE:
|
|
59
|
+
case b.RETURN: {
|
|
60
|
+
console.log(t.red(`${o}模式不支持回滚`));
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
console.log(
|
|
65
|
-
|
|
66
|
-
mode: ${
|
|
67
|
-
rollback: ${
|
|
65
|
+
t.blue(`开始处理模板
|
|
66
|
+
mode: ${o}
|
|
67
|
+
rollback: ${c}
|
|
68
68
|
`)
|
|
69
69
|
);
|
|
70
|
-
const
|
|
71
|
-
filePath:
|
|
72
|
-
dataInit:
|
|
70
|
+
const r = h({
|
|
71
|
+
filePath: s,
|
|
72
|
+
dataInit: g,
|
|
73
73
|
limitJson: !1,
|
|
74
74
|
filePathKey: "input",
|
|
75
75
|
dataInitKey: "inputData",
|
|
76
|
-
dealMarkdown:
|
|
77
|
-
}),
|
|
78
|
-
switch (
|
|
79
|
-
case
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
if (
|
|
84
|
-
if (
|
|
76
|
+
dealMarkdown: v
|
|
77
|
+
}), p = F(r), $ = typeof d == "function" ? d() : d, i = p($);
|
|
78
|
+
switch (o) {
|
|
79
|
+
case b.OVERWRITE: {
|
|
80
|
+
S(o, a), D(a, s);
|
|
81
|
+
const e = m.resolve(a);
|
|
82
|
+
if (u.mkdirSync(m.dirname(e), { recursive: !0 }), u.existsSync(e)) {
|
|
83
|
+
if (c)
|
|
84
|
+
if (l || (await E({
|
|
85
85
|
type: "confirm",
|
|
86
86
|
name: "remove",
|
|
87
|
-
message: `${
|
|
87
|
+
message: `${o}模式下回滚将删除${e},是否继续?`
|
|
88
88
|
})).remove) {
|
|
89
|
-
|
|
89
|
+
u.rmSync(e, { force: !0 }), console.log(t.green(`${o}模式下${e}已删除`));
|
|
90
90
|
return;
|
|
91
91
|
} else {
|
|
92
|
-
console.log(
|
|
92
|
+
console.log(t.yellow(`${o}模式下${e}回滚取消`));
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
console.log(
|
|
95
|
+
console.log(t.blue(`output:${e} 已存在,将覆盖`));
|
|
96
96
|
} else {
|
|
97
|
-
if (
|
|
97
|
+
if (c) {
|
|
98
98
|
console.log(
|
|
99
|
-
|
|
99
|
+
t.yellow(`${o}模式下${e}不存在,无需回滚`)
|
|
100
100
|
);
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
console.log(
|
|
103
|
+
console.log(t.blue(`output:${e} 不存在,将创建`));
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
u.writeFileSync(e, i, "utf-8"), console.log(t.green(`模板处理完成,输出到 ${e}`));
|
|
106
106
|
break;
|
|
107
107
|
}
|
|
108
|
-
case
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
case b.APPEND: {
|
|
109
|
+
S(o, a), D(a, s);
|
|
110
|
+
const e = m.resolve(a);
|
|
111
|
+
if (u.mkdirSync(m.dirname(e), { recursive: !0 }), u.existsSync(e)) {
|
|
112
|
+
const y = u.readFileSync(e, "utf-8");
|
|
113
|
+
if (c) {
|
|
114
|
+
u.writeFileSync(
|
|
115
|
+
e,
|
|
116
|
+
y.replace(i, ""),
|
|
117
117
|
"utf-8"
|
|
118
|
-
), console.log(
|
|
118
|
+
), console.log(t.green(`${o}模式下${e}回滚完成`));
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
121
|
+
const w = y + i;
|
|
122
|
+
u.writeFileSync(e, w, "utf-8"), console.log(t.green(`模板处理完成,追加到 ${e}`));
|
|
123
123
|
} else {
|
|
124
|
-
if (
|
|
124
|
+
if (c) {
|
|
125
125
|
console.log(
|
|
126
|
-
|
|
126
|
+
t.yellow(`${o}模式下${e}不存在,无需回滚`)
|
|
127
127
|
);
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
console.log(
|
|
130
|
+
console.log(t.blue(`output:${e} 不存在,将创建`)), u.writeFileSync(e, i, "utf-8"), console.log(t.green(`模板处理完成,输出到 ${e}`));
|
|
131
131
|
}
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
134
|
-
case
|
|
135
|
-
if (
|
|
136
|
-
return console.log(
|
|
137
|
-
const
|
|
138
|
-
|
|
134
|
+
case b.REPLACE: {
|
|
135
|
+
if (a && console.log(t.yellow(`output ${a} 将被忽略`)), I(o, s), f && f === s)
|
|
136
|
+
return console.log(t.red("env 与 input 不能相同")), process.exit(1);
|
|
137
|
+
const e = m.resolve(s);
|
|
138
|
+
u.mkdirSync(m.dirname(e), { recursive: !0 }), u.writeFileSync(e, i, "utf-8"), console.log(t.green(`模板处理完成,输出到 ${e}`));
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
|
-
case
|
|
141
|
+
case b.RETURN:
|
|
142
142
|
return console.log(
|
|
143
|
-
|
|
144
|
-
),
|
|
143
|
+
t.green("模板处理完成,返回结果(函数调用才会拿到返回值)")
|
|
144
|
+
), i;
|
|
145
145
|
default:
|
|
146
|
-
return console.log(
|
|
146
|
+
return console.log(t.red(`mode ${o} 不支持`)), process.exit(1);
|
|
147
147
|
}
|
|
148
|
-
return
|
|
148
|
+
return i;
|
|
149
149
|
}, C = async ({
|
|
150
|
+
rootDir: n = process.cwd(),
|
|
150
151
|
itemDefaultRollback: l = !1
|
|
151
|
-
} = {},
|
|
152
|
-
let
|
|
153
|
-
if (
|
|
154
|
-
|
|
152
|
+
} = {}, f) => {
|
|
153
|
+
let s;
|
|
154
|
+
if (f)
|
|
155
|
+
s = f;
|
|
155
156
|
else {
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
return console.log(
|
|
159
|
-
const p =
|
|
160
|
-
|
|
157
|
+
const r = N(n);
|
|
158
|
+
if (!r)
|
|
159
|
+
return console.log(t.red(`配置文件${r}不存在`)), process.exit(1);
|
|
160
|
+
const p = u.readFileSync(r, "utf-8");
|
|
161
|
+
s = JSON.parse(p);
|
|
161
162
|
}
|
|
162
|
-
const {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
const {
|
|
164
|
+
list: g,
|
|
165
|
+
globalEnvData: a = {},
|
|
166
|
+
collectEnvDataForm: o = []
|
|
167
|
+
} = s, c = {};
|
|
168
|
+
for (const r of o) {
|
|
169
|
+
let p, $, i;
|
|
170
|
+
typeof r == "string" ? (p = r, $ = r, i = void 0) : (p = r.key, $ = r.label, i = r.initial), c[p] = (await E({
|
|
171
|
+
type: "text",
|
|
172
|
+
name: p,
|
|
173
|
+
message: `请输入${$}`,
|
|
174
|
+
initial: i,
|
|
175
|
+
format: (e) => (e || "").trim(),
|
|
176
|
+
validate: (e) => e ? !0 : `${$}不能为空`
|
|
177
|
+
}))[p];
|
|
178
|
+
}
|
|
179
|
+
const v = g.map((r) => {
|
|
180
|
+
const { rollback: p = l } = r, {
|
|
181
|
+
envData: $,
|
|
182
|
+
env: i,
|
|
183
|
+
input: e,
|
|
184
|
+
output: y,
|
|
185
|
+
...w
|
|
186
|
+
} = k(r);
|
|
187
|
+
return i && console.log(t.yellow(`批量处理中 env:${i} 将被忽略,只读envData`)), {
|
|
188
|
+
...w,
|
|
189
|
+
env: i,
|
|
190
|
+
input: n && e ? m.resolve(n, e) : e,
|
|
191
|
+
output: n && y ? m.resolve(n, y) : y,
|
|
192
|
+
envData: R({}, a, c, $),
|
|
193
|
+
rollback: p
|
|
168
194
|
};
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}, U = async (
|
|
195
|
+
}), d = [];
|
|
196
|
+
for (const r of v) {
|
|
197
|
+
const p = await x(r, {
|
|
198
|
+
rollbackDelFileAgree: !0
|
|
199
|
+
});
|
|
200
|
+
d.push(p);
|
|
201
|
+
}
|
|
202
|
+
return d;
|
|
203
|
+
}, U = async (n) => {
|
|
178
204
|
const {
|
|
179
|
-
envData:
|
|
180
|
-
env:
|
|
181
|
-
input:
|
|
182
|
-
inputData:
|
|
183
|
-
output:
|
|
184
|
-
mode:
|
|
185
|
-
rollback:
|
|
186
|
-
dealMarkdown:
|
|
187
|
-
batch:
|
|
188
|
-
} =
|
|
189
|
-
if (
|
|
190
|
-
return console.log(
|
|
205
|
+
envData: l,
|
|
206
|
+
env: f,
|
|
207
|
+
input: s,
|
|
208
|
+
inputData: g,
|
|
209
|
+
output: a,
|
|
210
|
+
mode: o,
|
|
211
|
+
rollback: c,
|
|
212
|
+
dealMarkdown: v,
|
|
213
|
+
batch: d
|
|
214
|
+
} = k(n);
|
|
215
|
+
if (d)
|
|
216
|
+
return console.log(t.blue("开始批量处理")), C({
|
|
191
217
|
// 回滚默认值 基于全局
|
|
192
|
-
itemDefaultRollback:
|
|
218
|
+
itemDefaultRollback: c
|
|
193
219
|
});
|
|
194
|
-
console.log(
|
|
195
|
-
const
|
|
196
|
-
filePath:
|
|
197
|
-
dataInit:
|
|
220
|
+
console.log(t.blue("开始单个处理"));
|
|
221
|
+
const r = h({
|
|
222
|
+
filePath: f,
|
|
223
|
+
dataInit: l,
|
|
198
224
|
limitJson: !0,
|
|
199
225
|
filePathKey: "env",
|
|
200
226
|
dataInitKey: "envData",
|
|
201
|
-
dealMarkdown:
|
|
227
|
+
dealMarkdown: v
|
|
202
228
|
});
|
|
203
|
-
return
|
|
204
|
-
input:
|
|
205
|
-
inputData:
|
|
206
|
-
output:
|
|
207
|
-
mode:
|
|
208
|
-
rollback:
|
|
209
|
-
dealMarkdown:
|
|
210
|
-
envData:
|
|
229
|
+
return x({
|
|
230
|
+
input: s,
|
|
231
|
+
inputData: g,
|
|
232
|
+
output: a,
|
|
233
|
+
mode: o,
|
|
234
|
+
rollback: c,
|
|
235
|
+
dealMarkdown: v,
|
|
236
|
+
envData: r
|
|
211
237
|
});
|
|
212
238
|
};
|
|
213
239
|
export {
|
package/es/index.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { command as
|
|
2
|
+
import { batchHandler as e, handler as t } from "./handler.mjs";
|
|
3
|
+
import { command as m } from "./main.mjs";
|
|
4
4
|
import { OutputModeEnum as d } from "./utils/types.mjs";
|
|
5
|
+
import { getConfigPath as p } from "./utils/config.mjs";
|
|
5
6
|
export {
|
|
6
7
|
d as OutputModeEnum,
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
e as batchHandler,
|
|
9
|
+
m as command,
|
|
10
|
+
p as getConfigPath,
|
|
11
|
+
t as handler
|
|
9
12
|
};
|
package/es/injectInfo.json.mjs
CHANGED
package/es/main.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import d from "yargs";
|
|
3
3
|
import { hideBin as m } from "yargs/helpers";
|
|
4
|
-
import { OutputModeEnum as
|
|
5
|
-
import { defaultOptions as
|
|
4
|
+
import { OutputModeEnum as t } from "./utils/types.mjs";
|
|
5
|
+
import { defaultOptions as a } from "./utils/dealOptions.mjs";
|
|
6
|
+
import i from "./injectInfo.json.mjs";
|
|
7
|
+
import "node:path";
|
|
8
|
+
import "node:fs";
|
|
6
9
|
import { handler as n } from "./handler.mjs";
|
|
7
10
|
import s from "chalk";
|
|
8
|
-
import i from "./injectInfo.json.mjs";
|
|
9
11
|
const p = () => ({
|
|
10
12
|
env: {
|
|
11
13
|
alias: "e",
|
|
@@ -32,12 +34,12 @@ const p = () => ({
|
|
|
32
34
|
describe: "输出模式",
|
|
33
35
|
type: "string",
|
|
34
36
|
choices: [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
t.OVERWRITE,
|
|
38
|
+
t.APPEND,
|
|
39
|
+
t.REPLACE,
|
|
40
|
+
t.RETURN
|
|
39
41
|
],
|
|
40
|
-
default:
|
|
42
|
+
default: a.mode
|
|
41
43
|
},
|
|
42
44
|
output: {
|
|
43
45
|
alias: "o",
|
|
@@ -48,35 +50,35 @@ const p = () => ({
|
|
|
48
50
|
alias: "r",
|
|
49
51
|
describe: "是否回滚",
|
|
50
52
|
type: "boolean",
|
|
51
|
-
default:
|
|
53
|
+
default: a.rollback
|
|
52
54
|
},
|
|
53
55
|
dealMarkdown: {
|
|
54
56
|
alias: "d",
|
|
55
57
|
describe: "(检测是markdown)是否处理(单个)代码块包裹",
|
|
56
58
|
type: "boolean",
|
|
57
|
-
default:
|
|
59
|
+
default: a.dealMarkdown
|
|
58
60
|
},
|
|
59
61
|
batch: {
|
|
60
62
|
alias: "b",
|
|
61
63
|
describe: "是否批量处理",
|
|
62
64
|
type: "boolean",
|
|
63
|
-
default:
|
|
65
|
+
default: a.batch
|
|
64
66
|
}
|
|
65
67
|
}), r = i.cliConfig.moduleName, u = (e, o) => {
|
|
66
68
|
console.log(e ? s.red(e) : s.red(o.message)), process.exit(1);
|
|
67
69
|
}, b = i.description, g = `Usage: $0 ${r} [options]`, f = "Usage: $0 [options]", c = (e, o) => {
|
|
68
70
|
const l = p();
|
|
69
71
|
return e.strict().usage(o).help("help").version(i.version).alias("v", "version").alias("h", "help").options(l).fail(u).argv;
|
|
70
|
-
}, h = (e) => c(e, g),
|
|
72
|
+
}, h = (e) => c(e, g), U = {
|
|
71
73
|
command: r,
|
|
72
74
|
describe: b,
|
|
73
75
|
builder: h,
|
|
74
76
|
handler: n
|
|
75
|
-
},
|
|
77
|
+
}, w = async () => {
|
|
76
78
|
const e = d(m(process.argv)), o = await c(e, f);
|
|
77
79
|
return n(o);
|
|
78
80
|
};
|
|
79
81
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
U as command,
|
|
83
|
+
w as createCli
|
|
82
84
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import i from "../injectInfo.json.mjs";
|
|
3
|
+
import r from "node:path";
|
|
4
|
+
import f from "node:fs";
|
|
5
|
+
const p = (o) => {
|
|
6
|
+
const { namespaceDir: t, moduleName: s } = i.cliConfig, e = [t, `${s}.json`];
|
|
7
|
+
o && e.unshift(o);
|
|
8
|
+
const n = r.resolve(...e);
|
|
9
|
+
if (f.existsSync(n))
|
|
10
|
+
return n;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
p as getConfigPath
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-template",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "预编译命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@done-coding/cli-inject": "^0.
|
|
44
|
+
"@done-coding/cli-inject": "^0.4.1",
|
|
45
45
|
"@types/lodash.assign": "^4.2.9",
|
|
46
46
|
"@types/lodash.get": "^4.4.9",
|
|
47
47
|
"@types/lodash.set": "^4.3.9",
|
|
48
48
|
"@types/lodash.template": "^4.5.3",
|
|
49
|
-
"@types/node": "^
|
|
49
|
+
"@types/node": "^18.0.0",
|
|
50
50
|
"@types/prompts": "^2.4.6",
|
|
51
51
|
"@types/yargs": "^17.0.28",
|
|
52
52
|
"rimraf": "^6.0.1",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"vite-plugin-dts": "^3.6.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
58
|
+
"node": ">=18.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"chalk": "^5.3.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"prompts": "^2.4.2",
|
|
67
67
|
"yargs": "^17.7.2"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "1778df27cf625b5588b1de38d260cfed75e123f2"
|
|
70
70
|
}
|
package/types/handler.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { CompileTemplateConfig } from './utils';
|
|
2
2
|
import { type Options } from './utils';
|
|
3
3
|
import type { ArgumentsCamelCase } from "yargs";
|
|
4
|
-
export declare const batchHandler: ({ itemDefaultRollback, }?: {
|
|
4
|
+
export declare const batchHandler: ({ rootDir, itemDefaultRollback, }?: {
|
|
5
|
+
/** 根目录 */
|
|
6
|
+
rootDir?: string | undefined;
|
|
5
7
|
/** item默认回滚? */
|
|
6
8
|
itemDefaultRollback?: boolean | undefined;
|
|
7
9
|
}, paramsConfig?: CompileTemplateConfig) => Promise<(string | undefined)[]>;
|
package/types/index.d.ts
CHANGED
package/types/utils/index.d.ts
CHANGED
package/types/utils/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface Options {
|
|
|
19
19
|
/** 模板数据 */
|
|
20
20
|
inputData?: string;
|
|
21
21
|
/** 输出文件相对路径 */
|
|
22
|
-
output
|
|
22
|
+
output?: string;
|
|
23
23
|
/** 输出模式 @default OutputModeEnum.OVERWRITE */
|
|
24
24
|
mode: OutputModeEnum;
|
|
25
25
|
/** 是否回滚 @default false */
|
|
@@ -34,10 +34,21 @@ export type CompileTemplateConfigListItem = Omit<Options, "envData"> & {
|
|
|
34
34
|
/** 已经解析为对象的envData */
|
|
35
35
|
envData: Record<string, any>;
|
|
36
36
|
};
|
|
37
|
+
/** 采集环境变量配置 */
|
|
38
|
+
export interface CollectFormItem {
|
|
39
|
+
/** 采集环境变量的key */
|
|
40
|
+
key: string;
|
|
41
|
+
/** 采集环境变量标签 */
|
|
42
|
+
label: string;
|
|
43
|
+
/** 采集环境变量初始值 */
|
|
44
|
+
initial?: string;
|
|
45
|
+
}
|
|
37
46
|
/** 编译模板配置 */
|
|
38
47
|
export interface CompileTemplateConfig {
|
|
39
48
|
/** 全局环境变量 */
|
|
40
|
-
globalEnvData
|
|
49
|
+
globalEnvData?: Record<string, any>;
|
|
50
|
+
/** 采集环境变量表单配置 */
|
|
51
|
+
collectEnvDataForm?: (CollectFormItem | string)[];
|
|
41
52
|
/** 配置列表 */
|
|
42
53
|
list: CompileTemplateConfigListItem[];
|
|
43
54
|
}
|