@done-coding/cli-extract 0.1.21-alpha.2 → 0.1.22-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 +1 -1
- package/es/{index-6a87c9d9.js → index-dcd445f9.js} +52 -52
- package/es/index.mjs +1 -1
- package/package.json +8 -12
package/es/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as r, e as V, E as u, S as D, G as S } from "./index-a1ee6691-8c73eb4d.js";
|
|
3
|
-
import {
|
|
3
|
+
import { outputConsole as s, _get as J, createSubcommand as N, getRootScriptName as v, getConfigFileCommonOptions as h, initHandlerCommon as F, readConfigFile as x, _set as U, createMainCommand as W } from "@done-coding/cli-utils";
|
|
4
4
|
import $ from "node:path";
|
|
5
|
-
import
|
|
5
|
+
import g from "node:fs";
|
|
6
6
|
import { OutputModeEnum as H, batchCompileHandler as X } from "@done-coding/cli-template";
|
|
7
7
|
const j = {
|
|
8
8
|
name: "@done-coding/cli-extract",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.22-alpha.0",
|
|
10
10
|
description: "信息提取命令行工具",
|
|
11
11
|
bin: {
|
|
12
12
|
"dc-extract": "es/cli.mjs"
|
|
@@ -50,7 +50,7 @@ const j = {
|
|
|
50
50
|
}
|
|
51
51
|
}, R = {
|
|
52
52
|
name: "@done-coding/cli-inject",
|
|
53
|
-
version: "0.5.
|
|
53
|
+
version: "0.5.22-alpha.0",
|
|
54
54
|
description: "信息(JSON)注入命令行工具",
|
|
55
55
|
bin: {
|
|
56
56
|
"dc-inject": "es/cli.mjs"
|
|
@@ -61,7 +61,7 @@ const j = {
|
|
|
61
61
|
}
|
|
62
62
|
}, {
|
|
63
63
|
cliConfig: { namespaceDir: B, moduleName: Q }
|
|
64
|
-
} = R, Y = `./${B}/${Q}`, T = `${Y}.json`,
|
|
64
|
+
} = R, Y = `./${B}/${Q}`, T = `${Y}.json`, Z = {
|
|
65
65
|
sourceFilePath: "./package.json",
|
|
66
66
|
keyConfigMap: {
|
|
67
67
|
name: {
|
|
@@ -78,22 +78,22 @@ const j = {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
injectFilePath: "./src/injectInfo.json"
|
|
81
|
-
}, Z = () => h({
|
|
81
|
+
}, O = Z, ee = () => h({
|
|
82
82
|
configPathDefault: T
|
|
83
|
-
}),
|
|
83
|
+
}), ne = async (e) => F(O, e, {
|
|
84
84
|
onFileGenerated: () => {
|
|
85
85
|
s.info("文件生成成功");
|
|
86
86
|
}
|
|
87
|
-
}),
|
|
87
|
+
}), te = {
|
|
88
88
|
command: V.INIT,
|
|
89
89
|
describe: "初始化配置文件",
|
|
90
|
-
options:
|
|
91
|
-
handler:
|
|
92
|
-
},
|
|
90
|
+
options: ee(),
|
|
91
|
+
handler: ne
|
|
92
|
+
}, oe = () => ({
|
|
93
93
|
...h({
|
|
94
94
|
configPathDefault: T
|
|
95
95
|
})
|
|
96
|
-
}),
|
|
96
|
+
}), se = async ({
|
|
97
97
|
rootDir: e = process.cwd(),
|
|
98
98
|
config: n = O,
|
|
99
99
|
keyConfigMap: o = {}
|
|
@@ -110,43 +110,43 @@ const j = {
|
|
|
110
110
|
return s.error("源文件必须是json"), process.exit(1);
|
|
111
111
|
if (!c.endsWith(".json"))
|
|
112
112
|
return s.error("注入文件必须是json"), process.exit(1);
|
|
113
|
-
const l = $.resolve(e, t), f =
|
|
113
|
+
const l = $.resolve(e, t), f = g.readFileSync(l, "utf-8"), d = JSON.parse(f), i = Object.entries(m).reduce(
|
|
114
114
|
(E, [b, M]) => {
|
|
115
115
|
const L = C({ sourceJson: d, targetKey: b, keyConfig: M });
|
|
116
116
|
return U(E, b, L), E;
|
|
117
117
|
},
|
|
118
118
|
{}
|
|
119
|
-
), p = $.resolve(e, c),
|
|
120
|
-
if (
|
|
121
|
-
const E =
|
|
122
|
-
if (
|
|
119
|
+
), p = $.resolve(e, c), y = JSON.stringify(i, null, 2);
|
|
120
|
+
if (g.existsSync(p)) {
|
|
121
|
+
const E = g.readFileSync(p, "utf-8");
|
|
122
|
+
if (y === E)
|
|
123
123
|
return s.skip("注入文件已存在且内容相同,无需重复注入"), i;
|
|
124
124
|
s.stage("文件内容变化,开始覆盖注入文件");
|
|
125
125
|
} else
|
|
126
126
|
s.stage("开始注入文件");
|
|
127
|
-
|
|
128
|
-
},
|
|
127
|
+
g.writeFileSync(p, y), s.success(`文件注入成功: ${p}`), s.info(y);
|
|
128
|
+
}, re = async (e) => {
|
|
129
129
|
const n = await x(e, () => (s.info("配置文件为空,使用默认配置"), O));
|
|
130
130
|
if (!n)
|
|
131
131
|
return s.error("配置文件为空"), process.exit(1);
|
|
132
132
|
const { rootDir: o } = e;
|
|
133
|
-
await
|
|
134
|
-
},
|
|
133
|
+
await se({ rootDir: o, config: n });
|
|
134
|
+
}, ce = {
|
|
135
135
|
command: "$0",
|
|
136
136
|
describe: "生成文件",
|
|
137
|
-
options:
|
|
138
|
-
handler:
|
|
139
|
-
}, { version:
|
|
140
|
-
[
|
|
137
|
+
options: oe(),
|
|
138
|
+
handler: re
|
|
139
|
+
}, { version: ie, description: ae } = R;
|
|
140
|
+
[te, ce].map(
|
|
141
141
|
N
|
|
142
142
|
), v({ packageJson: R });
|
|
143
|
-
const
|
|
143
|
+
const ue = ({
|
|
144
144
|
input: e,
|
|
145
145
|
rootDir: n
|
|
146
146
|
}) => {
|
|
147
|
-
const o = $.resolve(n, e), t =
|
|
147
|
+
const o = $.resolve(n, e), t = g.readFileSync(o, "utf-8");
|
|
148
148
|
return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(t) : t;
|
|
149
|
-
},
|
|
149
|
+
}, de = (e) => typeof e == "object" && !!e, pe = ({
|
|
150
150
|
content: e,
|
|
151
151
|
targetKey: n,
|
|
152
152
|
keyConfig: o
|
|
@@ -169,7 +169,7 @@ const ae = ({
|
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
case u.JSON_INJECT: {
|
|
172
|
-
if (!
|
|
172
|
+
if (!de(e))
|
|
173
173
|
throw new Error(`${t} 类型的keyConfig需要content为json`);
|
|
174
174
|
return C({
|
|
175
175
|
sourceJson: e,
|
|
@@ -189,7 +189,7 @@ const ae = ({
|
|
|
189
189
|
default:
|
|
190
190
|
throw new Error(`不支持的类型${t}`);
|
|
191
191
|
}
|
|
192
|
-
},
|
|
192
|
+
}, me = {
|
|
193
193
|
name: "${name}",
|
|
194
194
|
version: "${version}",
|
|
195
195
|
description: "${description}"
|
|
@@ -232,23 +232,23 @@ const ae = ({
|
|
|
232
232
|
list: [
|
|
233
233
|
{
|
|
234
234
|
mode: H.OVERWRITE,
|
|
235
|
-
inputData: JSON.stringify(
|
|
235
|
+
inputData: JSON.stringify(me, null, 2),
|
|
236
236
|
output: "./src/extractInfo.json"
|
|
237
237
|
}
|
|
238
238
|
]
|
|
239
239
|
}
|
|
240
|
-
},
|
|
240
|
+
}, le = () => h({
|
|
241
241
|
configPathDefault: A
|
|
242
242
|
}), G = async (e) => F(k, e, {
|
|
243
243
|
onFileGenerated: () => {
|
|
244
244
|
s.info("文件生成成功");
|
|
245
245
|
}
|
|
246
|
-
}),
|
|
246
|
+
}), fe = {
|
|
247
247
|
command: D.INIT,
|
|
248
248
|
describe: "初始化配置文件",
|
|
249
|
-
options:
|
|
249
|
+
options: le(),
|
|
250
250
|
handler: G
|
|
251
|
-
},
|
|
251
|
+
}, ye = () => ({
|
|
252
252
|
...h({
|
|
253
253
|
configPathDefault: A
|
|
254
254
|
}),
|
|
@@ -265,18 +265,18 @@ const ae = ({
|
|
|
265
265
|
}) => {
|
|
266
266
|
const { extractInput: o, extractOutput: t } = n, a = Object.entries(o).reduce(
|
|
267
267
|
(c, [m, l]) => {
|
|
268
|
-
const f =
|
|
268
|
+
const f = ue({
|
|
269
269
|
rootDir: e,
|
|
270
270
|
input: m
|
|
271
271
|
});
|
|
272
272
|
return Object.entries(l).reduce(
|
|
273
273
|
(d, [i, p]) => {
|
|
274
|
-
const
|
|
274
|
+
const y = pe({
|
|
275
275
|
content: f,
|
|
276
276
|
targetKey: i,
|
|
277
277
|
keyConfig: p
|
|
278
278
|
});
|
|
279
|
-
return d[i] =
|
|
279
|
+
return d[i] = y, d;
|
|
280
280
|
},
|
|
281
281
|
c
|
|
282
282
|
);
|
|
@@ -296,12 +296,12 @@ const ae = ({
|
|
|
296
296
|
return s.error("配置文件为空"), process.exit(1);
|
|
297
297
|
const { rootDir: o } = e;
|
|
298
298
|
await ge({ rootDir: o, config: n });
|
|
299
|
-
},
|
|
299
|
+
}, Ee = {
|
|
300
300
|
command: "$0",
|
|
301
301
|
describe: "生成文件",
|
|
302
|
-
options:
|
|
302
|
+
options: ye(),
|
|
303
303
|
handler: I
|
|
304
|
-
},
|
|
304
|
+
}, Re = async (e, n) => {
|
|
305
305
|
switch (e) {
|
|
306
306
|
case D.INIT:
|
|
307
307
|
return G(n);
|
|
@@ -310,10 +310,10 @@ const ae = ({
|
|
|
310
310
|
default:
|
|
311
311
|
return I(n);
|
|
312
312
|
}
|
|
313
|
-
}, { version:
|
|
314
|
-
describe:
|
|
315
|
-
version:
|
|
316
|
-
subcommands: [
|
|
313
|
+
}, { version: Ce, description: he } = j, _ = {
|
|
314
|
+
describe: he,
|
|
315
|
+
version: Ce,
|
|
316
|
+
subcommands: [fe, Ee].map(
|
|
317
317
|
N
|
|
318
318
|
),
|
|
319
319
|
demandCommandCount: 1,
|
|
@@ -323,20 +323,20 @@ const ae = ({
|
|
|
323
323
|
} = j, P = (e = !1) => {
|
|
324
324
|
const n = e ? w : void 0, o = `$0${e ? ` ${w}` : ""} <command> [options]`;
|
|
325
325
|
return { command: n, usage: o };
|
|
326
|
-
},
|
|
326
|
+
}, Oe = async () => W({
|
|
327
327
|
..._,
|
|
328
328
|
...P()
|
|
329
|
-
}),
|
|
329
|
+
}), be = () => N({
|
|
330
330
|
..._,
|
|
331
331
|
...P(!0)
|
|
332
332
|
});
|
|
333
333
|
export {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
be as a,
|
|
335
|
+
fe as b,
|
|
336
|
+
Oe as c,
|
|
337
337
|
I as d,
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
Ee as e,
|
|
339
|
+
Re as f,
|
|
340
340
|
ge as g,
|
|
341
341
|
G as h,
|
|
342
342
|
_ as i
|
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as t, a as i, e as s, g as d, d as l, f as p, b as f, h as u } from "./index-
|
|
2
|
+
import { i as t, a as i, e as s, g as d, d as l, f as p, b as f, h as u } from "./index-dcd445f9.js";
|
|
3
3
|
import { E as C, G as E, S as b } from "./index-a1ee6691-8c73eb4d.js";
|
|
4
4
|
import "@done-coding/cli-utils";
|
|
5
5
|
import "node:path";
|
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.22-alpha.0",
|
|
4
4
|
"description": "信息提取命令行工具",
|
|
5
5
|
"private": false,
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -32,10 +32,7 @@
|
|
|
32
32
|
"types"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"predev": "pnpm run clean",
|
|
37
|
-
"dev": "vite build --watch",
|
|
38
|
-
"prebuild": "pnpm run clean",
|
|
35
|
+
"dev": "vite build -w -m hotBuild",
|
|
39
36
|
"build": "vite build",
|
|
40
37
|
"prepack": "pnpm build"
|
|
41
38
|
},
|
|
@@ -52,20 +49,19 @@
|
|
|
52
49
|
"license": "MIT",
|
|
53
50
|
"sideEffects": false,
|
|
54
51
|
"devDependencies": {
|
|
55
|
-
"@done-coding/cli-inject": "0.5.
|
|
52
|
+
"@done-coding/cli-inject": "0.5.22-alpha.0",
|
|
56
53
|
"@types/node": "^18.0.0",
|
|
57
54
|
"@types/yargs": "^17.0.28",
|
|
58
|
-
"rimraf": "^6.0.1",
|
|
59
55
|
"typescript": "^5.8.3",
|
|
60
56
|
"vite": "^4.4.11",
|
|
61
57
|
"vite-plugin-dts": "^3.6.0"
|
|
62
58
|
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@done-coding/cli-template": "0.8.9-alpha.0",
|
|
61
|
+
"@done-coding/cli-utils": "0.8.3-alpha.0"
|
|
62
|
+
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=18.0.0"
|
|
65
65
|
},
|
|
66
|
-
"
|
|
67
|
-
"@done-coding/cli-template": "0.8.8-alpha.2",
|
|
68
|
-
"@done-coding/cli-utils": "0.8.2-alpha.2"
|
|
69
|
-
},
|
|
70
|
-
"gitHead": "7683cce31678dfecc6b35014f9658ad8b59f0c97"
|
|
66
|
+
"gitHead": "906b7683d9e4dc75fb07806b12e5507827122a16"
|
|
71
67
|
}
|