done-coding-extract 0.1.10-alpha.0 → 0.1.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 { c as m } from "./index-ad21e5e4.js";
2
+ import { c as m } from "./index-e4f5918d.js";
3
3
  import "./index-a1ee6691-8c73eb4d.js";
4
4
  import "@done-coding/cli-utils";
5
5
  import "node:path";
@@ -6,7 +6,7 @@ import y from "node:fs";
6
6
  import { OutputModeEnum as U, batchCompileHandler as W } from "@done-coding/cli-template";
7
7
  const O = {
8
8
  name: "@done-coding/cli-extract",
9
- version: "0.1.10-alpha.0",
9
+ version: "0.1.10",
10
10
  description: "信息提取命令行工具",
11
11
  cliConfig: {
12
12
  namespaceDir: ".done-coding",
@@ -27,7 +27,7 @@ const O = {
27
27
  const { type: a = r.READ } = t;
28
28
  switch (a) {
29
29
  case r.REG: {
30
- const { sourceKey: c, pattern: m, replaceValue: l, flags: f } = t, d = new RegExp(m, f ?? void 0), i = b(e, c);
30
+ const { sourceKey: c, pattern: p, replaceValue: l, flags: f } = t, d = new RegExp(p, f ?? void 0), i = b(e, c);
31
31
  return typeof i == "string" ? i.replace(d, l) : (s.warn(
32
32
  `${i}不是字符串类型,无法使用正则表达式进行替换,此处将直接返回原值`
33
33
  ), i);
@@ -47,7 +47,7 @@ const O = {
47
47
  }
48
48
  }, S = {
49
49
  name: "@done-coding/cli-inject",
50
- version: "0.5.10-alpha.0",
50
+ version: "0.5.10",
51
51
  description: "信息(JSON)注入命令行工具",
52
52
  cliConfig: {
53
53
  namespaceDir: ".done-coding",
@@ -55,7 +55,7 @@ const O = {
55
55
  }
56
56
  }, {
57
57
  cliConfig: { namespaceDir: q, moduleName: z }
58
- } = S, B = `./${q}/${z}`, A = `${B}.json`, Q = {
58
+ } = S, B = `./${q}/${z}`, A = `${B}.json`, x = {
59
59
  sourceFilePath: "./package.json",
60
60
  keyConfigMap: {
61
61
  name: {
@@ -69,22 +69,22 @@ const O = {
69
69
  }
70
70
  },
71
71
  injectFilePath: "./src/injectInfo.json"
72
- }, x = Q, Y = () => D({
72
+ }, Q = () => D({
73
73
  configPathDefault: A
74
- }), Z = async (e) => v(x, e, {
74
+ }), Y = async (e) => v(x, e, {
75
75
  onFileGenerated: () => {
76
76
  s.info("文件生成成功");
77
77
  }
78
- }), ee = {
78
+ }), Z = {
79
79
  command: T.INIT,
80
80
  describe: "初始化配置文件",
81
- options: Y(),
82
- handler: Z
83
- }, ne = () => ({
81
+ options: Q(),
82
+ handler: Y
83
+ }, ee = () => ({
84
84
  ...D({
85
85
  configPathDefault: A
86
86
  })
87
- }), te = async ({
87
+ }), ne = async ({
88
88
  rootDir: e = process.cwd(),
89
89
  config: n = x,
90
90
  keyConfigMap: o = {}
@@ -93,7 +93,7 @@ const O = {
93
93
  sourceFilePath: t,
94
94
  keyConfigMap: a,
95
95
  injectFilePath: c
96
- } = n, m = {
96
+ } = n, p = {
97
97
  ...a,
98
98
  ...o
99
99
  };
@@ -101,43 +101,43 @@ const O = {
101
101
  return s.error("源文件必须是json"), process.exit(1);
102
102
  if (!c.endsWith(".json"))
103
103
  return s.error("注入文件必须是json"), process.exit(1);
104
- const l = j.resolve(e, t), f = y.readFileSync(l, "utf-8"), d = JSON.parse(f), i = Object.entries(m).reduce(
104
+ const l = j.resolve(e, t), f = y.readFileSync(l, "utf-8"), d = JSON.parse(f), i = Object.entries(p).reduce(
105
105
  (g, [R, P]) => {
106
106
  const M = C({ sourceJson: d, targetKey: R, keyConfig: P });
107
107
  return L(g, R, M), g;
108
108
  },
109
109
  {}
110
- ), p = j.resolve(e, c), E = JSON.stringify(i, null, 2);
111
- if (y.existsSync(p)) {
112
- const g = y.readFileSync(p, "utf-8");
110
+ ), m = j.resolve(e, c), E = JSON.stringify(i, null, 2);
111
+ if (y.existsSync(m)) {
112
+ const g = y.readFileSync(m, "utf-8");
113
113
  if (E === g)
114
114
  return s.skip("注入文件已存在且内容相同,无需重复注入"), i;
115
115
  s.stage("文件内容变化,开始覆盖注入文件");
116
116
  } else
117
117
  s.stage("开始注入文件");
118
- y.writeFileSync(p, E), s.success(`文件注入成功: ${p}`), s.info(E);
119
- }, oe = async (e) => {
118
+ y.writeFileSync(m, E), s.success(`文件注入成功: ${m}`), s.info(E);
119
+ }, te = async (e) => {
120
120
  const n = await F(e);
121
121
  if (!n)
122
122
  return s.error("配置文件为空"), process.exit(1);
123
123
  const { rootDir: o } = e;
124
- await te({ rootDir: o, config: n });
125
- }, se = {
124
+ await ne({ rootDir: o, config: n });
125
+ }, oe = {
126
126
  command: T.GENERATE,
127
127
  describe: "生成文件",
128
- options: ne(),
129
- handler: oe
130
- }, { version: re, description: ce } = S;
131
- [ee, se].map(
128
+ options: ee(),
129
+ handler: te
130
+ }, { version: se, description: re } = S;
131
+ [Z, oe].map(
132
132
  N
133
133
  );
134
- const ie = ({
134
+ const ce = ({
135
135
  input: e,
136
136
  rootDir: n
137
137
  }) => {
138
138
  const o = j.resolve(n, e), t = y.readFileSync(o, "utf-8");
139
139
  return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(t) : t;
140
- }, ae = (e) => typeof e == "object" && !!e, ue = ({
140
+ }, ie = (e) => typeof e == "object" && !!e, ae = ({
141
141
  content: e,
142
142
  targetKey: n,
143
143
  keyConfig: o
@@ -160,7 +160,7 @@ const ie = ({
160
160
  });
161
161
  }
162
162
  case u.JSON_INJECT: {
163
- if (!ae(e))
163
+ if (!ie(e))
164
164
  throw new Error(`${t} 类型的keyConfig需要content为json`);
165
165
  return C({
166
166
  sourceJson: e,
@@ -180,11 +180,11 @@ const ie = ({
180
180
  default:
181
181
  throw new Error(`不支持的类型${t}`);
182
182
  }
183
- }, de = {
183
+ }, ue = {
184
184
  name: "${name}",
185
185
  version: "${version}",
186
186
  description: "${description}"
187
- }, pe = {
187
+ }, de = {
188
188
  extractInput: {
189
189
  "./package.json": {
190
190
  name: {
@@ -223,23 +223,23 @@ const ie = ({
223
223
  list: [
224
224
  {
225
225
  mode: U.OVERWRITE,
226
- inputData: JSON.stringify(de, null, 2),
226
+ inputData: JSON.stringify(ue, null, 2),
227
227
  output: "./src/extractInfo.json"
228
228
  }
229
229
  ]
230
230
  }
231
231
  }, me = () => D({
232
232
  configPathDefault: J
233
- }), G = async (e) => v(pe, e, {
233
+ }), G = async (e) => v(de, e, {
234
234
  onFileGenerated: () => {
235
235
  s.info("文件生成成功");
236
236
  }
237
- }), le = {
237
+ }), pe = {
238
238
  command: h.INIT,
239
239
  describe: "初始化配置文件",
240
240
  options: me(),
241
241
  handler: G
242
- }, fe = () => ({
242
+ }, le = () => ({
243
243
  ...D({
244
244
  configPathDefault: J
245
245
  }),
@@ -250,22 +250,22 @@ const ie = ({
250
250
  default: $.RESULT,
251
251
  describe: "生成模式"
252
252
  }
253
- }), Ee = async ({
253
+ }), fe = async ({
254
254
  rootDir: e = process.cwd(),
255
255
  config: n
256
256
  }) => {
257
257
  const { extractInput: o, extractOutput: t } = n, a = Object.entries(o).reduce(
258
- (c, [m, l]) => {
259
- const f = ie({
258
+ (c, [p, l]) => {
259
+ const f = ce({
260
260
  rootDir: e,
261
- input: m
261
+ input: p
262
262
  });
263
263
  return Object.entries(l).reduce(
264
- (d, [i, p]) => {
265
- const E = ue({
264
+ (d, [i, m]) => {
265
+ const E = ae({
266
266
  content: f,
267
267
  targetKey: i,
268
- keyConfig: p
268
+ keyConfig: m
269
269
  });
270
270
  return d[i] = E, d;
271
271
  },
@@ -286,13 +286,13 @@ const ie = ({
286
286
  if (!n)
287
287
  return s.error("配置文件为空"), process.exit(1);
288
288
  const { rootDir: o } = e;
289
- await Ee({ rootDir: o, config: n });
290
- }, ye = {
289
+ await fe({ rootDir: o, config: n });
290
+ }, Ee = {
291
291
  command: h.GENERATE,
292
292
  describe: "生成文件",
293
- options: fe(),
293
+ options: le(),
294
294
  handler: I
295
- }, Oe = async (e, n) => {
295
+ }, Ne = async (e, n) => {
296
296
  switch (e) {
297
297
  case h.INIT:
298
298
  return G(n);
@@ -301,10 +301,10 @@ const ie = ({
301
301
  default:
302
302
  return I(n);
303
303
  }
304
- }, { version: ge, description: Ce } = O, k = {
305
- describe: Ce,
306
- version: ge,
307
- subcommands: [le, ye].map(
304
+ }, { version: ye, description: ge } = O, k = {
305
+ describe: ge,
306
+ version: ye,
307
+ subcommands: [pe, Ee].map(
308
308
  N
309
309
  ),
310
310
  demandCommandCount: 1
@@ -313,21 +313,21 @@ const ie = ({
313
313
  } = O, _ = (e = !1) => {
314
314
  const n = e ? w : void 0, o = `$0${e ? ` ${w}` : ""} <command> [options]`;
315
315
  return { command: n, usage: o };
316
- }, Re = async () => V({
316
+ }, Oe = async () => V({
317
317
  ...k,
318
318
  ..._()
319
- }), $e = () => N({
319
+ }), Re = () => N({
320
320
  ...k,
321
321
  ..._(!0)
322
322
  });
323
323
  export {
324
- $e as a,
325
- le as b,
326
- Re as c,
324
+ Re as a,
325
+ pe as b,
326
+ Oe as c,
327
327
  I as d,
328
- ye as e,
329
- Oe as f,
330
- Ee as g,
328
+ Ee as e,
329
+ Ne as f,
330
+ fe as g,
331
331
  G as h,
332
332
  k as i
333
333
  };
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-ad21e5e4.js";
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-e4f5918d.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-extract",
3
- "version": "0.1.10-alpha.0",
3
+ "version": "0.1.10",
4
4
  "description": "信息提取命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -42,7 +42,7 @@
42
42
  "license": "MIT",
43
43
  "sideEffects": false,
44
44
  "devDependencies": {
45
- "@done-coding/cli-inject": "^0.5.10-alpha.0",
45
+ "@done-coding/cli-inject": "^0.5.10",
46
46
  "@types/node": "^18.0.0",
47
47
  "@types/yargs": "^17.0.28",
48
48
  "rimraf": "^6.0.1",
@@ -54,9 +54,9 @@
54
54
  "node": ">=18.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "@done-coding/cli-template": "0.7.10-alpha.0",
58
- "@done-coding/cli-utils": "^0.7.1-alpha.0"
57
+ "@done-coding/cli-template": "0.7.10",
58
+ "@done-coding/cli-utils": "^0.7.1"
59
59
  },
60
- "gitHead": "3376f5fbbf8b87c791316e76df06028afd650e08",
60
+ "gitHead": "299ab3991d6842c83d65816dfba6efd175aa885a",
61
61
  "scripts": {}
62
62
  }