@done-coding/cli-extract 0.1.4-alpha.0 → 0.1.4

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-8acf7c8a.js";
2
+ import { c as m } from "./index-90686ee2.js";
3
3
  import "./types-a1ee6691-78bcc10f.js";
4
4
  import "@done-coding/cli-utils";
5
5
  import "node:path";
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as s, e as m, E as u, S as l } from "./types-a1ee6691-78bcc10f.js";
3
- import { log as r, _get as O, _curry as I, createSubcommand as R, getConfigFileCommonOptions as j, initHandlerCommon as v, readConfigFile as $, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
3
+ import { log as r, _get as O, _curry as I, createSubcommand as h, getConfigFileCommonOptions as j, initHandlerCommon as v, readConfigFile as $, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
4
4
  import D 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 h = ({
7
+ const R = ({
8
8
  sourceJson: e,
9
9
  targetKey: n,
10
10
  keyConfig: t
@@ -17,8 +17,8 @@ const h = ({
17
17
  const { type: i = s.READ } = o;
18
18
  switch (i) {
19
19
  case s.REG: {
20
- const { sourceKey: a, pattern: f, replaceValue: E, flags: g } = o, p = new RegExp(f, g ?? void 0), c = O(e, a);
21
- return typeof c == "string" ? c.replace(p, E) : (r.warn(
20
+ const { sourceKey: a, pattern: f, replaceValue: E, flags: g } = o, d = new RegExp(f, g ?? void 0), c = O(e, a);
21
+ return typeof c == "string" ? c.replace(d, E) : (r.warn(
22
22
  `${c}不是字符串类型,无法使用正则表达式进行替换,此处将直接返回原值`
23
23
  ), c);
24
24
  }
@@ -49,7 +49,7 @@ const h = ({
49
49
  injectFilePath: "./src/injectInfo.json"
50
50
  }, w = U, x = {
51
51
  name: "@done-coding/cli-inject",
52
- version: "0.5.4-alpha.0",
52
+ version: "0.5.4",
53
53
  description: "信息(JSON)注入命令行工具",
54
54
  cliConfig: {
55
55
  namespaceDir: ".done-coding",
@@ -84,21 +84,21 @@ const h = ({
84
84
  return r.error("源文件必须是json"), process.exit(1);
85
85
  if (!a.endsWith(".json"))
86
86
  return r.error("注入文件必须是json"), process.exit(1);
87
- const E = D.resolve(e, o), g = C.readFileSync(E, "utf-8"), p = JSON.parse(g), c = Object.entries(f).reduce(
87
+ const E = D.resolve(e, o), g = C.readFileSync(E, "utf-8"), d = JSON.parse(g), c = Object.entries(f).reduce(
88
88
  (N, [T, P]) => {
89
- const M = h({ sourceJson: p, targetKey: T, keyConfig: P });
89
+ const M = R({ sourceJson: d, targetKey: T, keyConfig: P });
90
90
  return H(N, T, M), N;
91
91
  },
92
92
  {}
93
- ), d = D.resolve(e, a), y = JSON.stringify(c, null, 2);
94
- if (C.existsSync(d)) {
95
- const N = C.readFileSync(d, "utf-8");
93
+ ), p = D.resolve(e, a), y = JSON.stringify(c, null, 2);
94
+ if (C.existsSync(p)) {
95
+ const N = C.readFileSync(p, "utf-8");
96
96
  if (y === N)
97
97
  return r.skip("注入文件已存在且内容相同,无需重复注入"), c;
98
98
  r.stage("文件内容变化,开始覆盖注入文件");
99
99
  } else
100
100
  r.stage("开始注入文件");
101
- C.writeFileSync(d, y), r.success(`文件注入成功: ${d}`), r.info(y);
101
+ C.writeFileSync(p, y), r.success(`文件注入成功: ${p}`), r.info(y);
102
102
  }, Z = async (e) => {
103
103
  const n = await $(e);
104
104
  if (!n)
@@ -125,7 +125,7 @@ const h = ({
125
125
  )
126
126
  };
127
127
  [te, oe].map(
128
- R
128
+ h
129
129
  );
130
130
  const re = {
131
131
  name: "${name}",
@@ -177,7 +177,7 @@ const re = {
177
177
  }
178
178
  }, S = {
179
179
  name: "@done-coding/cli-extract",
180
- version: "0.1.4-alpha.0",
180
+ version: "0.1.4",
181
181
  description: "信息提取命令行工具",
182
182
  cliConfig: {
183
183
  namespaceDir: ".done-coding",
@@ -187,11 +187,11 @@ const re = {
187
187
  cliConfig: { namespaceDir: ce, moduleName: ie }
188
188
  } = S, ae = `./${ce}/${ie}`, b = `${ae}.json5`, ue = () => j({
189
189
  configPathDefault: b
190
- }), pe = async (e) => v(se, e, {
190
+ }), de = async (e) => v(se, e, {
191
191
  onFileGenerated: () => {
192
192
  r.info("文件生成成功");
193
193
  }
194
- }), de = ({
194
+ }), pe = ({
195
195
  input: e,
196
196
  rootDir: n
197
197
  }) => {
@@ -207,7 +207,7 @@ const re = {
207
207
  case u.REG: {
208
208
  if (typeof e != "string")
209
209
  throw new Error(`${o} 类型的keyConfig需要content为字符串`);
210
- return h({
210
+ return R({
211
211
  sourceJson: {
212
212
  [n]: e
213
213
  },
@@ -222,7 +222,7 @@ const re = {
222
222
  case u.JSON_INJECT: {
223
223
  if (!me(e))
224
224
  throw new Error(`${o} 类型的keyConfig需要content为json`);
225
- return h({
225
+ return R({
226
226
  sourceJson: e,
227
227
  targetKey: n,
228
228
  keyConfig: t.inject
@@ -241,18 +241,18 @@ const re = {
241
241
  }) => {
242
242
  const { extractInput: t, extractOutput: o } = n, i = Object.entries(t).reduce(
243
243
  (a, [f, E]) => {
244
- const g = de({
244
+ const g = pe({
245
245
  rootDir: e,
246
246
  input: f
247
247
  });
248
248
  return Object.entries(E).reduce(
249
- (p, [c, d]) => {
249
+ (d, [c, p]) => {
250
250
  const y = le({
251
251
  content: g,
252
252
  targetKey: c,
253
- keyConfig: d
253
+ keyConfig: p
254
254
  });
255
- return p[c] = y, p;
255
+ return d[c] = y, d;
256
256
  },
257
257
  a
258
258
  );
@@ -272,7 +272,7 @@ const re = {
272
272
  return r.error("配置文件为空"), process.exit(1);
273
273
  const { rootDir: t } = e;
274
274
  await Ee({ rootDir: t, config: n });
275
- }, G = async (e, n) => e === l.INIT ? pe(n) : e === l.GENERATE ? ge(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
275
+ }, G = async (e, n) => e === l.INIT ? de(n) : e === l.GENERATE ? ge(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
276
276
  version: ye,
277
277
  description: Ce,
278
278
  cliConfig: { moduleName: A }
@@ -294,7 +294,7 @@ const re = {
294
294
  describe: Ce,
295
295
  version: ye,
296
296
  subcommands: [Ne, Ie].map(
297
- R
297
+ h
298
298
  ),
299
299
  demandCommandCount: 1
300
300
  }, k = (e = !1) => {
@@ -303,7 +303,7 @@ const re = {
303
303
  }, Ae = async () => V({
304
304
  ..._,
305
305
  ...k()
306
- }), ve = () => R({
306
+ }), ve = () => h({
307
307
  ..._,
308
308
  ...k(!0)
309
309
  });
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as e, h as p } from "./index-8acf7c8a.js";
2
+ import { a as e, h as p } from "./index-90686ee2.js";
3
3
  import { E as i, S as u } from "./types-a1ee6691-78bcc10f.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.4-alpha.0",
3
+ "version": "0.1.4",
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.4-alpha.0",
54
+ "@done-coding/cli-inject": "^0.5.4",
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.5-alpha.0",
67
- "@done-coding/cli-utils": "^0.3.4-alpha.0"
66
+ "@done-coding/cli-template": "0.7.5",
67
+ "@done-coding/cli-utils": "^0.3.4"
68
68
  },
69
- "gitHead": "94d8199a4e69ddec5d7b967fc602781ef25a3369"
69
+ "gitHead": "be4aa1f92952e9c6e2f7a9b2fe8c28e74a3c7d64"
70
70
  }
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-extract",
3
- "version": "0.1.4-alpha.0",
3
+ "version": "0.1.4",
4
4
  "description": "信息提取命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",