@done-coding/cli-extract 0.1.8-alpha.1 → 0.1.8

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-b107db2d.js";
2
+ import { c as m } from "./index-2f3f403a.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "./types-a1ee6691-9629699d.js";
5
5
  import "node:path";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
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";
2
+ import { log as r, _get as O, _curry as D, createSubcommand as h, getConfigFileCommonOptions as j, initHandlerCommon as F, readConfigFile as v, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
3
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";
4
+ import R 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
7
  const N = ({
@@ -17,8 +17,8 @@ const N = ({
17
17
  const { type: a = s.READ } = t;
18
18
  switch (a) {
19
19
  case s.REG: {
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(
20
+ const { sourceKey: c, pattern: f, replaceValue: E, flags: g } = t, d = new RegExp(f, g ?? void 0), i = O(e, c);
21
+ return typeof i == "string" ? i.replace(d, E) : (r.warn(
22
22
  `${i}不是字符串类型,无法使用正则表达式进行替换,此处将直接返回原值`
23
23
  ), i);
24
24
  }
@@ -51,7 +51,7 @@ const N = ({
51
51
  injectFilePath: "./src/injectInfo.json"
52
52
  }, w = {
53
53
  name: "@done-coding/cli-inject",
54
- version: "0.5.8-alpha.1",
54
+ version: "0.5.8",
55
55
  description: "信息(JSON)注入命令行工具",
56
56
  cliConfig: {
57
57
  namespaceDir: ".done-coding",
@@ -86,21 +86,21 @@ const N = ({
86
86
  return r.error("源文件必须是json"), process.exit(1);
87
87
  if (!c.endsWith(".json"))
88
88
  return r.error("注入文件必须是json"), process.exit(1);
89
- const E = h.resolve(e, t), g = C.readFileSync(E, "utf-8"), p = JSON.parse(g), i = Object.entries(f).reduce(
89
+ const E = R.resolve(e, t), g = C.readFileSync(E, "utf-8"), d = JSON.parse(g), i = Object.entries(f).reduce(
90
90
  (I, [T, P]) => {
91
- const M = N({ sourceJson: p, targetKey: T, keyConfig: P });
91
+ const M = N({ sourceJson: d, targetKey: T, keyConfig: P });
92
92
  return H(I, T, M), I;
93
93
  },
94
94
  {}
95
- ), d = h.resolve(e, c), y = JSON.stringify(i, null, 2);
96
- if (C.existsSync(d)) {
97
- const I = C.readFileSync(d, "utf-8");
95
+ ), p = R.resolve(e, c), y = JSON.stringify(i, null, 2);
96
+ if (C.existsSync(p)) {
97
+ const I = C.readFileSync(p, "utf-8");
98
98
  if (y === I)
99
99
  return r.skip("注入文件已存在且内容相同,无需重复注入"), i;
100
100
  r.stage("文件内容变化,开始覆盖注入文件");
101
101
  } else
102
102
  r.stage("开始注入文件");
103
- C.writeFileSync(d, y), r.success(`文件注入成功: ${d}`), r.info(y);
103
+ C.writeFileSync(p, y), r.success(`文件注入成功: ${p}`), r.info(y);
104
104
  }, Y = async (e) => {
105
105
  const n = await v(e);
106
106
  if (!n)
@@ -127,7 +127,7 @@ const N = ({
127
127
  )
128
128
  };
129
129
  [ne, te].map(
130
- R
130
+ h
131
131
  );
132
132
  const oe = {
133
133
  name: "${name}",
@@ -179,7 +179,7 @@ const oe = {
179
179
  }
180
180
  }, S = {
181
181
  name: "@done-coding/cli-extract",
182
- version: "0.1.8-alpha.1",
182
+ version: "0.1.8",
183
183
  description: "信息提取命令行工具",
184
184
  cliConfig: {
185
185
  namespaceDir: ".done-coding",
@@ -193,13 +193,13 @@ const oe = {
193
193
  onFileGenerated: () => {
194
194
  r.info("文件生成成功");
195
195
  }
196
- }), pe = ({
196
+ }), de = ({
197
197
  input: e,
198
198
  rootDir: n
199
199
  }) => {
200
- const o = h.resolve(n, e), t = C.readFileSync(o, "utf-8");
200
+ const o = R.resolve(n, e), t = C.readFileSync(o, "utf-8");
201
201
  return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(t) : t;
202
- }, de = (e) => typeof e == "object" && !!e, me = ({
202
+ }, pe = (e) => typeof e == "object" && !!e, me = ({
203
203
  content: e,
204
204
  targetKey: n,
205
205
  keyConfig: o
@@ -222,7 +222,7 @@ const oe = {
222
222
  });
223
223
  }
224
224
  case u.JSON_INJECT: {
225
- if (!de(e))
225
+ if (!pe(e))
226
226
  throw new Error(`${t} 类型的keyConfig需要content为json`);
227
227
  return N({
228
228
  sourceJson: e,
@@ -252,18 +252,18 @@ const oe = {
252
252
  }) => {
253
253
  const { extractInput: o, extractOutput: t } = n, a = Object.entries(o).reduce(
254
254
  (c, [f, E]) => {
255
- const g = pe({
255
+ const g = de({
256
256
  rootDir: e,
257
257
  input: f
258
258
  });
259
259
  return Object.entries(E).reduce(
260
- (p, [i, d]) => {
260
+ (d, [i, p]) => {
261
261
  const y = me({
262
262
  content: g,
263
263
  targetKey: i,
264
- keyConfig: d
264
+ keyConfig: p
265
265
  });
266
- return p[i] = y, p;
266
+ return d[i] = y, d;
267
267
  },
268
268
  c
269
269
  );
@@ -305,7 +305,7 @@ const oe = {
305
305
  describe: ye,
306
306
  version: ge,
307
307
  subcommands: [Ce, Ie].map(
308
- R
308
+ h
309
309
  ),
310
310
  demandCommandCount: 1
311
311
  }, k = (e = !1) => {
@@ -314,7 +314,7 @@ const oe = {
314
314
  }, Oe = async () => V({
315
315
  ..._,
316
316
  ...k()
317
- }), Ae = () => R({
317
+ }), Ae = () => h({
318
318
  ..._,
319
319
  ...k(!0)
320
320
  });
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as n, g as p, h as s } from "./index-b107db2d.js";
2
+ import { a as n, g as p, h as s } from "./index-2f3f403a.js";
3
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-extract",
3
- "version": "0.1.8-alpha.1",
3
+ "version": "0.1.8",
4
4
  "description": "信息提取命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -52,7 +52,7 @@
52
52
  "license": "MIT",
53
53
  "sideEffects": false,
54
54
  "devDependencies": {
55
- "@done-coding/cli-inject": "^0.5.8-alpha.1",
55
+ "@done-coding/cli-inject": "^0.5.8",
56
56
  "@types/node": "^18.0.0",
57
57
  "@types/yargs": "^17.0.28",
58
58
  "rimraf": "^6.0.1",
@@ -64,8 +64,8 @@
64
64
  "node": ">=18.0.0"
65
65
  },
66
66
  "dependencies": {
67
- "@done-coding/cli-template": "0.7.8-alpha.2",
68
- "@done-coding/cli-utils": "^0.7.0-alpha.0"
67
+ "@done-coding/cli-template": "0.7.8",
68
+ "@done-coding/cli-utils": "^0.7.0"
69
69
  },
70
- "gitHead": "ff1616738586a268b50f46dce762774fa5fa6d52"
70
+ "gitHead": "b4fb4f2380a14f72597a1dbfd1bbce22287ef02f"
71
71
  }
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-extract",
3
- "version": "0.1.8-alpha.1",
3
+ "version": "0.1.8",
4
4
  "description": "信息提取命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",