@done-coding/cli-extract 0.1.7-alpha.0 → 0.1.8-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 +2 -2
- package/es/helpers.mjs +74 -10
- package/es/{index-05646883.js → index-9abc1104.js} +129 -117
- package/es/index.mjs +7 -6
- package/es/types-a1ee6691-9629699d.js +8 -0
- package/package.json +5 -5
- package/types/helpers-assets/done-coding.d.ts +3 -1
- package/types/index.d.ts +1 -0
- package/types/injectInfo.json.d.ts +1 -1
- package/types/utils/types.d.ts +7 -3
- package/es/types-a1ee6691-78bcc10f.js +0 -8
package/es/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as m } from "./index-
|
|
3
|
-
import "./types-a1ee6691-78bcc10f.js";
|
|
2
|
+
import { c as m } from "./index-9abc1104.js";
|
|
4
3
|
import "@done-coding/cli-utils";
|
|
4
|
+
import "./types-a1ee6691-9629699d.js";
|
|
5
5
|
import "node:path";
|
|
6
6
|
import "node:fs";
|
|
7
7
|
import "@done-coding/cli-template";
|
package/es/helpers.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { E as e, a as
|
|
2
|
+
import { E as e, a as n } from "./types-a1ee6691-9629699d.js";
|
|
3
3
|
import "@done-coding/cli-utils";
|
|
4
4
|
import "node:path";
|
|
5
5
|
import "node:fs";
|
|
6
|
-
import { OutputModeEnum as
|
|
6
|
+
import { OutputModeEnum as t } from "@done-coding/cli-template";
|
|
7
7
|
const i = {
|
|
8
8
|
name: "${name}",
|
|
9
9
|
version: "${version}",
|
|
@@ -12,36 +12,39 @@ const i = {
|
|
|
12
12
|
namespaceDir: "${cliConfig.namespaceDir}",
|
|
13
13
|
moduleName: "${cliConfig.moduleName}"
|
|
14
14
|
}
|
|
15
|
-
},
|
|
15
|
+
}, u = {
|
|
16
16
|
extractInput: {
|
|
17
17
|
"./package.json": {
|
|
18
18
|
name: {
|
|
19
19
|
type: e.JSON_INJECT,
|
|
20
20
|
inject: {
|
|
21
|
-
type:
|
|
21
|
+
type: n.READ
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
description: {
|
|
25
25
|
type: e.JSON_INJECT,
|
|
26
26
|
inject: {
|
|
27
|
-
type:
|
|
27
|
+
type: n.READ
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
version: {
|
|
31
31
|
type: e.JSON_INJECT,
|
|
32
32
|
inject: {
|
|
33
|
-
type:
|
|
33
|
+
type: n.READ
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"cliConfig.namespaceDir": {
|
|
37
37
|
type: e.JSON_INJECT,
|
|
38
|
-
inject:
|
|
38
|
+
inject: {
|
|
39
|
+
type: n.FIXED,
|
|
40
|
+
value: ".done-coding"
|
|
41
|
+
}
|
|
39
42
|
},
|
|
40
43
|
"cliConfig.moduleName": {
|
|
41
44
|
type: e.JSON_INJECT,
|
|
42
45
|
inject: {
|
|
43
46
|
sourceKey: "name",
|
|
44
|
-
type:
|
|
47
|
+
type: n.REG,
|
|
45
48
|
pattern: /@done-coding\/cli-([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)/.source,
|
|
46
49
|
replaceValue: "$1"
|
|
47
50
|
}
|
|
@@ -51,13 +54,74 @@ const i = {
|
|
|
51
54
|
extractOutput: {
|
|
52
55
|
list: [
|
|
53
56
|
{
|
|
54
|
-
mode:
|
|
57
|
+
mode: t.OVERWRITE,
|
|
55
58
|
inputData: JSON.stringify(i, null, 2),
|
|
56
59
|
output: "./src/extractInfo.json"
|
|
57
60
|
}
|
|
58
61
|
]
|
|
59
62
|
}
|
|
63
|
+
}, o = {
|
|
64
|
+
npm: {
|
|
65
|
+
aliasInfo: [
|
|
66
|
+
{
|
|
67
|
+
packageJson: {
|
|
68
|
+
name: "${organizationAbbr}-${moduleName}",
|
|
69
|
+
bin: "${binEntry}",
|
|
70
|
+
scripts: {}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}, l = {
|
|
76
|
+
extractInput: {
|
|
77
|
+
"./package.json": {
|
|
78
|
+
name: {
|
|
79
|
+
type: e.JSON_INJECT,
|
|
80
|
+
inject: {
|
|
81
|
+
type: n.READ
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
bin: {
|
|
85
|
+
type: e.JSON_INJECT,
|
|
86
|
+
inject: {
|
|
87
|
+
type: n.READ
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
organization: {
|
|
91
|
+
type: e.FIXED,
|
|
92
|
+
value: "done-coding"
|
|
93
|
+
},
|
|
94
|
+
/** 组织名缩写 */
|
|
95
|
+
organizationAbbr: {
|
|
96
|
+
type: e.FIXED,
|
|
97
|
+
value: "dc"
|
|
98
|
+
},
|
|
99
|
+
binEntry: {
|
|
100
|
+
type: e.FIXED,
|
|
101
|
+
value: "es/cli.mjs"
|
|
102
|
+
},
|
|
103
|
+
moduleName: {
|
|
104
|
+
type: e.JSON_INJECT,
|
|
105
|
+
inject: {
|
|
106
|
+
sourceKey: "name",
|
|
107
|
+
type: n.REG,
|
|
108
|
+
pattern: /@done-coding\/cli-([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)/.source,
|
|
109
|
+
replaceValue: "$1"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
extractOutput: {
|
|
115
|
+
list: [
|
|
116
|
+
{
|
|
117
|
+
mode: t.OVERWRITE,
|
|
118
|
+
inputData: JSON.stringify(o, null, 2),
|
|
119
|
+
output: "./.done-coding/publish.json"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
60
123
|
};
|
|
61
124
|
export {
|
|
62
|
-
|
|
125
|
+
l as doneCodingPublishAliasInfo,
|
|
126
|
+
u as doneCodingSeriesCliInjectInfo
|
|
63
127
|
};
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { log as r, _get as O, _curry as D, createSubcommand as R, getConfigFileCommonOptions as j, initHandlerCommon as F, readConfigFile as v, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
|
|
3
|
+
import { a as s, e as m, E as u, S as l } from "./types-a1ee6691-9629699d.js";
|
|
4
|
+
import h from "node:path";
|
|
5
5
|
import C from "node:fs";
|
|
6
6
|
import { OutputModeEnum as L, batchCompileHandler as W } from "@done-coding/cli-template";
|
|
7
|
-
const
|
|
7
|
+
const N = ({
|
|
8
8
|
sourceJson: e,
|
|
9
9
|
targetKey: n,
|
|
10
|
-
keyConfig:
|
|
10
|
+
keyConfig: o
|
|
11
11
|
}) => {
|
|
12
|
-
let
|
|
13
|
-
typeof
|
|
12
|
+
let t;
|
|
13
|
+
typeof o == "string" ? t = {
|
|
14
14
|
type: s.FIXED,
|
|
15
|
-
value:
|
|
16
|
-
} :
|
|
17
|
-
const { type:
|
|
18
|
-
switch (
|
|
15
|
+
value: o
|
|
16
|
+
} : t = o;
|
|
17
|
+
const { type: a = s.READ } = t;
|
|
18
|
+
switch (a) {
|
|
19
19
|
case s.REG: {
|
|
20
|
-
const { sourceKey:
|
|
21
|
-
return typeof
|
|
22
|
-
`${
|
|
23
|
-
),
|
|
20
|
+
const { sourceKey: c, pattern: f, replaceValue: E, flags: g } = t, p = new RegExp(f, g ?? void 0), i = O(e, c);
|
|
21
|
+
return typeof i == "string" ? i.replace(p, E) : (r.warn(
|
|
22
|
+
`${i}不是字符串类型,无法使用正则表达式进行替换,此处将直接返回原值`
|
|
23
|
+
), i);
|
|
24
24
|
}
|
|
25
25
|
case s.FIXED: {
|
|
26
|
-
const { value:
|
|
27
|
-
return
|
|
26
|
+
const { value: c } = t;
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
case s.READ: {
|
|
30
|
+
const { sourceKey: c = n } = t;
|
|
31
|
+
return O(e, c);
|
|
28
32
|
}
|
|
29
|
-
case s.READ:
|
|
30
|
-
return O(e, n);
|
|
31
33
|
default: {
|
|
32
|
-
r.warn(`未知的配置类型${
|
|
34
|
+
r.warn(`未知的配置类型${a}`);
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
},
|
|
38
|
+
}, $ = {
|
|
37
39
|
sourceFilePath: "./package.json",
|
|
38
40
|
keyConfigMap: {
|
|
39
41
|
name: {
|
|
@@ -47,91 +49,91 @@ const h = ({
|
|
|
47
49
|
}
|
|
48
50
|
},
|
|
49
51
|
injectFilePath: "./src/injectInfo.json"
|
|
50
|
-
}, w =
|
|
52
|
+
}, w = {
|
|
51
53
|
name: "@done-coding/cli-inject",
|
|
52
|
-
version: "0.5.
|
|
54
|
+
version: "0.5.8-alpha.0",
|
|
53
55
|
description: "信息(JSON)注入命令行工具",
|
|
54
56
|
cliConfig: {
|
|
55
57
|
namespaceDir: ".done-coding",
|
|
56
58
|
moduleName: "inject"
|
|
57
59
|
}
|
|
58
60
|
}, {
|
|
59
|
-
cliConfig: { namespaceDir:
|
|
60
|
-
} =
|
|
61
|
-
configPathDefault:
|
|
62
|
-
}),
|
|
61
|
+
cliConfig: { namespaceDir: U, moduleName: X }
|
|
62
|
+
} = w, K = `./${U}/${X}`, x = `${K}.json`, q = () => j({
|
|
63
|
+
configPathDefault: x
|
|
64
|
+
}), z = async (e) => F($, e, {
|
|
63
65
|
onFileGenerated: () => {
|
|
64
66
|
r.info("文件生成成功");
|
|
65
67
|
}
|
|
66
|
-
}),
|
|
68
|
+
}), B = () => ({
|
|
67
69
|
...j({
|
|
68
|
-
configPathDefault:
|
|
70
|
+
configPathDefault: x
|
|
69
71
|
})
|
|
70
|
-
}),
|
|
72
|
+
}), Q = async ({
|
|
71
73
|
rootDir: e = process.cwd(),
|
|
72
|
-
config: n =
|
|
73
|
-
keyConfigMap:
|
|
74
|
+
config: n = $,
|
|
75
|
+
keyConfigMap: o = {}
|
|
74
76
|
} = {}) => {
|
|
75
77
|
const {
|
|
76
|
-
sourceFilePath:
|
|
77
|
-
keyConfigMap:
|
|
78
|
-
injectFilePath:
|
|
78
|
+
sourceFilePath: t,
|
|
79
|
+
keyConfigMap: a,
|
|
80
|
+
injectFilePath: c
|
|
79
81
|
} = n, f = {
|
|
80
|
-
...
|
|
81
|
-
...
|
|
82
|
+
...a,
|
|
83
|
+
...o
|
|
82
84
|
};
|
|
83
|
-
if (!
|
|
85
|
+
if (!t.endsWith(".json"))
|
|
84
86
|
return r.error("源文件必须是json"), process.exit(1);
|
|
85
|
-
if (!
|
|
87
|
+
if (!c.endsWith(".json"))
|
|
86
88
|
return r.error("注入文件必须是json"), process.exit(1);
|
|
87
|
-
const E =
|
|
88
|
-
(
|
|
89
|
-
const M =
|
|
90
|
-
return H(
|
|
89
|
+
const E = h.resolve(e, t), g = C.readFileSync(E, "utf-8"), p = JSON.parse(g), i = Object.entries(f).reduce(
|
|
90
|
+
(I, [T, P]) => {
|
|
91
|
+
const M = N({ sourceJson: p, targetKey: T, keyConfig: P });
|
|
92
|
+
return H(I, T, M), I;
|
|
91
93
|
},
|
|
92
94
|
{}
|
|
93
|
-
), d =
|
|
95
|
+
), d = h.resolve(e, c), y = JSON.stringify(i, null, 2);
|
|
94
96
|
if (C.existsSync(d)) {
|
|
95
|
-
const
|
|
96
|
-
if (y ===
|
|
97
|
-
return r.skip("注入文件已存在且内容相同,无需重复注入"),
|
|
97
|
+
const I = C.readFileSync(d, "utf-8");
|
|
98
|
+
if (y === I)
|
|
99
|
+
return r.skip("注入文件已存在且内容相同,无需重复注入"), i;
|
|
98
100
|
r.stage("文件内容变化,开始覆盖注入文件");
|
|
99
101
|
} else
|
|
100
102
|
r.stage("开始注入文件");
|
|
101
103
|
C.writeFileSync(d, y), r.success(`文件注入成功: ${d}`), r.info(y);
|
|
102
|
-
},
|
|
103
|
-
const n = await
|
|
104
|
+
}, Y = async (e) => {
|
|
105
|
+
const n = await v(e);
|
|
104
106
|
if (!n)
|
|
105
107
|
return r.error("配置文件为空"), process.exit(1);
|
|
106
|
-
const { rootDir:
|
|
107
|
-
await
|
|
108
|
-
}, J = async (e, n) => e === m.INIT ?
|
|
109
|
-
version:
|
|
110
|
-
description:
|
|
111
|
-
cliConfig: { moduleName:
|
|
112
|
-
} =
|
|
108
|
+
const { rootDir: o } = e;
|
|
109
|
+
await Q({ rootDir: o, config: n });
|
|
110
|
+
}, J = async (e, n) => e === m.INIT ? z(n) : e === m.GENERATE ? Y(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
|
|
111
|
+
version: Z,
|
|
112
|
+
description: ee,
|
|
113
|
+
cliConfig: { moduleName: Te }
|
|
114
|
+
} = w, ne = {
|
|
113
115
|
command: m.INIT,
|
|
114
116
|
describe: "初始化提取配置文件",
|
|
115
|
-
options:
|
|
116
|
-
handler:
|
|
117
|
+
options: q(),
|
|
118
|
+
handler: D(J)(
|
|
117
119
|
m.INIT
|
|
118
120
|
)
|
|
119
|
-
},
|
|
121
|
+
}, te = {
|
|
120
122
|
command: m.GENERATE,
|
|
121
123
|
describe: "提取信息",
|
|
122
|
-
options:
|
|
123
|
-
handler:
|
|
124
|
+
options: B(),
|
|
125
|
+
handler: D(J)(
|
|
124
126
|
m.GENERATE
|
|
125
127
|
)
|
|
126
128
|
};
|
|
127
|
-
[
|
|
129
|
+
[ne, te].map(
|
|
128
130
|
R
|
|
129
131
|
);
|
|
130
|
-
const
|
|
132
|
+
const oe = {
|
|
131
133
|
name: "${name}",
|
|
132
134
|
version: "${version}",
|
|
133
135
|
description: "${description}"
|
|
134
|
-
},
|
|
136
|
+
}, re = {
|
|
135
137
|
extractInput: {
|
|
136
138
|
"./package.json": {
|
|
137
139
|
name: {
|
|
@@ -170,91 +172,100 @@ const re = {
|
|
|
170
172
|
list: [
|
|
171
173
|
{
|
|
172
174
|
mode: L.OVERWRITE,
|
|
173
|
-
inputData: JSON.stringify(
|
|
175
|
+
inputData: JSON.stringify(oe, null, 2),
|
|
174
176
|
output: "./src/extractInfo.json"
|
|
175
177
|
}
|
|
176
178
|
]
|
|
177
179
|
}
|
|
178
180
|
}, S = {
|
|
179
181
|
name: "@done-coding/cli-extract",
|
|
180
|
-
version: "0.1.
|
|
182
|
+
version: "0.1.8-alpha.0",
|
|
181
183
|
description: "信息提取命令行工具",
|
|
182
184
|
cliConfig: {
|
|
183
185
|
namespaceDir: ".done-coding",
|
|
184
186
|
moduleName: "extract"
|
|
185
187
|
}
|
|
186
188
|
}, {
|
|
187
|
-
cliConfig: { namespaceDir:
|
|
188
|
-
} = S,
|
|
189
|
+
cliConfig: { namespaceDir: se, moduleName: ce }
|
|
190
|
+
} = S, ie = `./${se}/${ce}`, b = `${ie}.json5`, ae = () => j({
|
|
189
191
|
configPathDefault: b
|
|
190
|
-
}),
|
|
192
|
+
}), ue = async (e) => F(re, e, {
|
|
191
193
|
onFileGenerated: () => {
|
|
192
194
|
r.info("文件生成成功");
|
|
193
195
|
}
|
|
194
|
-
}),
|
|
196
|
+
}), pe = ({
|
|
195
197
|
input: e,
|
|
196
198
|
rootDir: n
|
|
197
199
|
}) => {
|
|
198
|
-
const
|
|
199
|
-
return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(
|
|
200
|
-
},
|
|
200
|
+
const o = h.resolve(n, e), t = C.readFileSync(o, "utf-8");
|
|
201
|
+
return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(t) : t;
|
|
202
|
+
}, de = (e) => typeof e == "object" && !!e, me = ({
|
|
201
203
|
content: e,
|
|
202
204
|
targetKey: n,
|
|
203
|
-
keyConfig:
|
|
205
|
+
keyConfig: o
|
|
204
206
|
}) => {
|
|
205
|
-
const { type:
|
|
206
|
-
switch (
|
|
207
|
+
const { type: t, ...a } = o;
|
|
208
|
+
switch (t) {
|
|
207
209
|
case u.REG: {
|
|
208
210
|
if (typeof e != "string")
|
|
209
|
-
throw new Error(`${
|
|
210
|
-
return
|
|
211
|
+
throw new Error(`${t} 类型的keyConfig需要content为字符串`);
|
|
212
|
+
return N({
|
|
211
213
|
sourceJson: {
|
|
212
214
|
[n]: e
|
|
213
215
|
},
|
|
214
216
|
targetKey: n,
|
|
215
217
|
keyConfig: {
|
|
216
|
-
...
|
|
218
|
+
...a,
|
|
217
219
|
type: s.REG,
|
|
218
220
|
sourceKey: n
|
|
219
221
|
}
|
|
220
222
|
});
|
|
221
223
|
}
|
|
222
224
|
case u.JSON_INJECT: {
|
|
223
|
-
if (!
|
|
224
|
-
throw new Error(`${
|
|
225
|
-
return
|
|
225
|
+
if (!de(e))
|
|
226
|
+
throw new Error(`${t} 类型的keyConfig需要content为json`);
|
|
227
|
+
return N({
|
|
226
228
|
sourceJson: e,
|
|
227
229
|
targetKey: n,
|
|
228
|
-
keyConfig:
|
|
230
|
+
keyConfig: o.inject
|
|
229
231
|
});
|
|
230
232
|
}
|
|
233
|
+
case u.FIXED:
|
|
234
|
+
return N({
|
|
235
|
+
sourceJson: {},
|
|
236
|
+
targetKey: n,
|
|
237
|
+
keyConfig: {
|
|
238
|
+
...a,
|
|
239
|
+
type: s.FIXED
|
|
240
|
+
}
|
|
241
|
+
});
|
|
231
242
|
default:
|
|
232
|
-
throw new Error(`不支持的类型${
|
|
243
|
+
throw new Error(`不支持的类型${t}`);
|
|
233
244
|
}
|
|
234
|
-
},
|
|
245
|
+
}, le = () => ({
|
|
235
246
|
...j({
|
|
236
247
|
configPathDefault: b
|
|
237
248
|
})
|
|
238
|
-
}),
|
|
249
|
+
}), fe = async ({
|
|
239
250
|
rootDir: e = process.cwd(),
|
|
240
251
|
config: n
|
|
241
252
|
}) => {
|
|
242
|
-
const { extractInput:
|
|
243
|
-
(
|
|
244
|
-
const g =
|
|
253
|
+
const { extractInput: o, extractOutput: t } = n, a = Object.entries(o).reduce(
|
|
254
|
+
(c, [f, E]) => {
|
|
255
|
+
const g = pe({
|
|
245
256
|
rootDir: e,
|
|
246
257
|
input: f
|
|
247
258
|
});
|
|
248
259
|
return Object.entries(E).reduce(
|
|
249
|
-
(p, [
|
|
250
|
-
const y =
|
|
260
|
+
(p, [i, d]) => {
|
|
261
|
+
const y = me({
|
|
251
262
|
content: g,
|
|
252
|
-
targetKey:
|
|
263
|
+
targetKey: i,
|
|
253
264
|
keyConfig: d
|
|
254
265
|
});
|
|
255
|
-
return p[
|
|
266
|
+
return p[i] = y, p;
|
|
256
267
|
},
|
|
257
|
-
|
|
268
|
+
c
|
|
258
269
|
);
|
|
259
270
|
},
|
|
260
271
|
{}
|
|
@@ -262,53 +273,54 @@ const re = {
|
|
|
262
273
|
await W(
|
|
263
274
|
{
|
|
264
275
|
rootDir: e,
|
|
265
|
-
extraEnvData:
|
|
276
|
+
extraEnvData: a
|
|
266
277
|
},
|
|
267
|
-
|
|
278
|
+
t
|
|
268
279
|
);
|
|
269
|
-
},
|
|
270
|
-
const n = await
|
|
280
|
+
}, Ee = async (e) => {
|
|
281
|
+
const n = await v(e);
|
|
271
282
|
if (!n)
|
|
272
283
|
return r.error("配置文件为空"), process.exit(1);
|
|
273
|
-
const { rootDir:
|
|
274
|
-
await
|
|
275
|
-
}, G = async (e, n) => e === l.INIT ?
|
|
276
|
-
version:
|
|
277
|
-
description:
|
|
284
|
+
const { rootDir: o } = e;
|
|
285
|
+
await fe({ rootDir: o, config: n });
|
|
286
|
+
}, G = async (e, n) => e === l.INIT ? ue(n) : e === l.GENERATE ? Ee(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
|
|
287
|
+
version: ge,
|
|
288
|
+
description: ye,
|
|
278
289
|
cliConfig: { moduleName: A }
|
|
279
|
-
} = S,
|
|
290
|
+
} = S, Ce = {
|
|
280
291
|
command: l.INIT,
|
|
281
292
|
describe: "初始化提取配置文件",
|
|
282
|
-
options:
|
|
283
|
-
handler:
|
|
293
|
+
options: ae(),
|
|
294
|
+
handler: D(G)(
|
|
284
295
|
l.INIT
|
|
285
296
|
)
|
|
286
297
|
}, Ie = {
|
|
287
298
|
command: l.GENERATE,
|
|
288
299
|
describe: "提取信息",
|
|
289
|
-
options:
|
|
290
|
-
handler:
|
|
300
|
+
options: le(),
|
|
301
|
+
handler: D(G)(
|
|
291
302
|
l.GENERATE
|
|
292
303
|
)
|
|
293
304
|
}, _ = {
|
|
294
|
-
describe:
|
|
295
|
-
version:
|
|
296
|
-
subcommands: [
|
|
305
|
+
describe: ye,
|
|
306
|
+
version: ge,
|
|
307
|
+
subcommands: [Ce, Ie].map(
|
|
297
308
|
R
|
|
298
309
|
),
|
|
299
310
|
demandCommandCount: 1
|
|
300
311
|
}, k = (e = !1) => {
|
|
301
|
-
const n = e ? A : void 0,
|
|
302
|
-
return { command: n, usage:
|
|
303
|
-
},
|
|
312
|
+
const n = e ? A : void 0, o = `$0${e ? ` ${A}` : ""} <command> [options]`;
|
|
313
|
+
return { command: n, usage: o };
|
|
314
|
+
}, Oe = async () => V({
|
|
304
315
|
..._,
|
|
305
316
|
...k()
|
|
306
|
-
}),
|
|
317
|
+
}), Ae = () => R({
|
|
307
318
|
..._,
|
|
308
319
|
...k(!0)
|
|
309
320
|
});
|
|
310
321
|
export {
|
|
311
|
-
|
|
312
|
-
|
|
322
|
+
Ae as a,
|
|
323
|
+
Oe as c,
|
|
324
|
+
fe as g,
|
|
313
325
|
G as h
|
|
314
326
|
};
|
package/es/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
3
|
-
import { E as
|
|
2
|
+
import { a as n, g as p, h as s } from "./index-9abc1104.js";
|
|
3
|
+
import { E as u, S as c } from "./types-a1ee6691-9629699d.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
5
|
import "node:path";
|
|
6
6
|
import "node:fs";
|
|
7
7
|
import "@done-coding/cli-template";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
p as
|
|
9
|
+
u as ExtractTypeEnum,
|
|
10
|
+
c as SubcommandEnum,
|
|
11
|
+
n as crateAsSubcommand,
|
|
12
|
+
p as generateFile,
|
|
13
|
+
s as handler
|
|
13
14
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var i = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(i || {}), E = /* @__PURE__ */ ((e) => (e.REG = "reg", e.JSON_INJECT = "json-inject", e.FIXED = "fixed", e))(E || {}), n = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(n || {}), r = /* @__PURE__ */ ((e) => (e.REG = "reg", e.FIXED = "fixed", e.READ = "read", e))(r || {});
|
|
3
|
+
export {
|
|
4
|
+
E,
|
|
5
|
+
i as S,
|
|
6
|
+
r as a,
|
|
7
|
+
n as e
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/cli-extract",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-alpha.0",
|
|
4
4
|
"description": "信息提取命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"sideEffects": false,
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@done-coding/cli-inject": "^0.5.
|
|
54
|
+
"@done-coding/cli-inject": "^0.5.8-alpha.0",
|
|
55
55
|
"@types/node": "^18.0.0",
|
|
56
56
|
"@types/yargs": "^17.0.28",
|
|
57
57
|
"rimraf": "^6.0.1",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"node": ">=18.0.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@done-coding/cli-template": "0.7.8-alpha.
|
|
67
|
-
"@done-coding/cli-utils": "^0.
|
|
66
|
+
"@done-coding/cli-template": "0.7.8-alpha.1",
|
|
67
|
+
"@done-coding/cli-utils": "^0.6.0-alpha.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "5879161383e32e7bed351d71d3ef607d81dc021a"
|
|
70
70
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { type ExtractConfig } from
|
|
1
|
+
import { type ExtractConfig } from "../utils";
|
|
2
2
|
/** done-coding 系列cli 注入信息 */
|
|
3
3
|
export declare const doneCodingSeriesCliInjectInfo: ExtractConfig;
|
|
4
|
+
/** done-coding 系列cli 别名发布信息 */
|
|
5
|
+
export declare const doneCodingPublishAliasInfo: ExtractConfig;
|
package/types/index.d.ts
CHANGED
package/types/utils/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InitConfigFileOptions, ReadConfigFileOptions } from "@done-coding/cli-utils";
|
|
2
2
|
import type { CompileTemplateConfig } from "@done-coding/cli-template";
|
|
3
|
-
import type { InjectKeyConfig, InjectKeyConfigReg } from "@done-coding/cli-inject";
|
|
3
|
+
import type { InjectKeyConfig, InjectKeyConfigFixed, InjectKeyConfigReg } from "@done-coding/cli-inject";
|
|
4
4
|
/** 子命令枚举 */
|
|
5
5
|
export declare enum SubcommandEnum {
|
|
6
6
|
/** 初始化提取配置文件 */
|
|
@@ -23,7 +23,9 @@ export declare enum ExtractTypeEnum {
|
|
|
23
23
|
* ---
|
|
24
24
|
* 内部直接调用 @done-coding/cli-inject
|
|
25
25
|
*/
|
|
26
|
-
JSON_INJECT = "json-inject"
|
|
26
|
+
JSON_INJECT = "json-inject",
|
|
27
|
+
/** 固定值 类型 */
|
|
28
|
+
FIXED = "fixed"
|
|
27
29
|
}
|
|
28
30
|
/** 初始化选项 */
|
|
29
31
|
export type InitOptions = InitConfigFileOptions;
|
|
@@ -41,8 +43,10 @@ export interface ExtractInputKeyConfigReg extends ExtractInputKeyConfigBase<Extr
|
|
|
41
43
|
export interface ExtractInputKeyConfigJsonInject extends ExtractInputKeyConfigBase<ExtractTypeEnum.JSON_INJECT> {
|
|
42
44
|
inject: InjectKeyConfig;
|
|
43
45
|
}
|
|
46
|
+
/** 提取配置固定值 */
|
|
47
|
+
export type ExtractInputKeyConfigFixed = ExtractInputKeyConfigBase<ExtractTypeEnum.FIXED> & Omit<InjectKeyConfigFixed, "type">;
|
|
44
48
|
/** 提取配置 */
|
|
45
|
-
export type ExtractInputKeyConfig = ExtractInputKeyConfigReg | ExtractInputKeyConfigJsonInject;
|
|
49
|
+
export type ExtractInputKeyConfig = ExtractInputKeyConfigReg | ExtractInputKeyConfigJsonInject | ExtractInputKeyConfigFixed;
|
|
46
50
|
/** 提取输入配置 */
|
|
47
51
|
export interface ExtractInputConfig {
|
|
48
52
|
[key: string]: ExtractInputKeyConfig;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var E = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(E || {}), n = /* @__PURE__ */ ((e) => (e.REG = "reg", e.JSON_INJECT = "json-inject", e))(n || {}), r = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.REG = "reg", e.FIXED = "fixed", e.READ = "read", e))(a || {});
|
|
3
|
-
export {
|
|
4
|
-
n as E,
|
|
5
|
-
E as S,
|
|
6
|
-
a,
|
|
7
|
-
r as e
|
|
8
|
-
};
|