done-coding-extract 0.1.20 → 0.1.23

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/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  ## 安装
9
9
 
10
10
  ### 独立安装
11
+
11
12
  ```bash
12
13
  npm install @done-coding/cli-extract
13
14
  # 或
@@ -15,6 +16,7 @@ pnpm add @done-coding/cli-extract
15
16
  ```
16
17
 
17
18
  ### 作为 done-coding CLI 的一部分
19
+
18
20
  ```bash
19
21
  npm install -g @done-coding/cli
20
22
  # 然后使用
@@ -47,6 +49,7 @@ dc-extract --help
47
49
  ### 基础命令
48
50
 
49
51
  #### `dc-extract init`
52
+
50
53
  初始化配置文件
51
54
 
52
55
  ```bash
@@ -55,11 +58,13 @@ dc-extract init
55
58
  ```
56
59
 
57
60
  **功能说明**:
61
+
58
62
  - 在项目根目录创建 `.done-coding/extract.json5` 配置文件
59
63
  - 提供默认的提取规则和模板配置
60
64
  - 支持自定义提取目标和输出格式
61
65
 
62
66
  #### `dc-extract` (默认命令)
67
+
63
68
  生成文件
64
69
 
65
70
  ```bash
@@ -77,6 +82,7 @@ dc-extract -R ./src
77
82
  ```
78
83
 
79
84
  **选项说明**:
85
+
80
86
  - `-R, --rootDir`: 运行目录,默认为当前目录
81
87
  - `-C, --configPath`: 配置文件相对路径,默认为 `./.done-coding/extract.json5`
82
88
  - `-m, --mode`: 生成模式,可选值:`result`(默认)、`template`
@@ -84,6 +90,7 @@ dc-extract -R ./src
84
90
  ### 生成模式
85
91
 
86
92
  #### result 模式
93
+
87
94
  直接生成最终结果文件
88
95
 
89
96
  ```bash
@@ -92,6 +99,7 @@ dc-extract -m result
92
99
  ```
93
100
 
94
101
  #### template 模式
102
+
95
103
  生成模板文件供进一步处理
96
104
 
97
105
  ```bash
@@ -161,6 +169,7 @@ DC extract -C ./config.json5
161
169
  ### 常见问题
162
170
 
163
171
  **Q: 配置文件找不到**
172
+
164
173
  ```bash
165
174
  # 检查配置文件是否存在
166
175
  ls -la .done-coding/extract.json5
@@ -170,6 +179,7 @@ dc-extract init
170
179
  ```
171
180
 
172
181
  **Q: 生成失败**
182
+
173
183
  ```bash
174
184
  # 检查运行目录
175
185
  dc-extract -R ./src
@@ -208,7 +218,7 @@ dc-extract --help
208
218
 
209
219
  ```bash
210
220
  # 克隆仓库
211
- git clone https://gitee.com/done-coding/done-coding-cli.git
221
+ git clone https://github.com/done-coding/done-coding-cli.git
212
222
  cd done-coding-cli/packages/extract
213
223
 
214
224
  # 安装依赖
@@ -236,4 +246,4 @@ MIT © [JustSoSu](https://gitee.com/done-coding)
236
246
  - [主 CLI 工具](https://www.npmjs.com/package/@done-coding/cli)
237
247
  - [模板处理工具](https://www.npmjs.com/package/@done-coding/cli-template) - 本包依赖的模板引擎
238
248
  - [Gitee 仓库](https://gitee.com/done-coding/done-coding-cli)
239
- - [更新日志](./CHANGELOG.md)
249
+ - [更新日志](./CHANGELOG.md)
package/es/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-afbdba02.js";
2
+ import { c as m } from "./index-aebb3f75.js";
3
3
  import "./index-a1ee6691-8c73eb4d.js";
4
4
  import "@done-coding/cli-utils";
5
5
  import "node:path";
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as r, e as V, E as u, S as h, G as S } from "./index-a1ee6691-8c73eb4d.js";
3
- import { log as s, _get as J, createSubcommand as N, getRootScriptName as v, getConfigFileCommonOptions as j, initHandlerCommon as F, readConfigFile as x, _set as U, createMainCommand as W } from "@done-coding/cli-utils";
3
+ import { outputConsole as s, _get as J, createSubcommand as N, getRootScriptName as v, getConfigFileCommonOptions as j, 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 y from "node:fs";
5
+ import g from "node:fs";
6
6
  import { OutputModeEnum as H, batchCompileHandler as X } from "@done-coding/cli-template";
7
7
  const D = {
8
8
  name: "@done-coding/cli-extract",
9
- version: "0.1.20",
9
+ version: "0.1.23",
10
10
  description: "信息提取命令行工具",
11
11
  bin: {
12
12
  "dc-extract": "es/cli.mjs"
@@ -50,7 +50,7 @@ const D = {
50
50
  }
51
51
  }, R = {
52
52
  name: "@done-coding/cli-inject",
53
- version: "0.5.20",
53
+ version: "0.5.23",
54
54
  description: "信息(JSON)注入命令行工具",
55
55
  bin: {
56
56
  "dc-inject": "es/cli.mjs"
@@ -110,21 +110,21 @@ const D = {
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 = y.readFileSync(l, "utf-8"), d = JSON.parse(f), i = Object.entries(m).reduce(
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), g = JSON.stringify(i, null, 2);
120
- if (y.existsSync(p)) {
121
- const E = y.readFileSync(p, "utf-8");
122
- if (g === E)
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
- y.writeFileSync(p, g), s.success(`文件注入成功: ${p}`), s.info(g);
127
+ g.writeFileSync(p, y), s.success(`文件注入成功: ${p}`), s.info(y);
128
128
  }, re = async (e) => {
129
129
  const n = await x(e, () => (s.info("配置文件为空,使用默认配置"), O));
130
130
  if (!n)
@@ -144,7 +144,7 @@ const ue = ({
144
144
  input: e,
145
145
  rootDir: n
146
146
  }) => {
147
- const o = $.resolve(n, e), t = y.readFileSync(o, "utf-8");
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,
@@ -248,7 +248,7 @@ const ue = ({
248
248
  describe: "初始化配置文件",
249
249
  options: le(),
250
250
  handler: G
251
- }, ge = () => ({
251
+ }, ye = () => ({
252
252
  ...j({
253
253
  configPathDefault: A
254
254
  }),
@@ -259,7 +259,7 @@ const ue = ({
259
259
  default: S.RESULT,
260
260
  describe: "生成模式"
261
261
  }
262
- }), ye = async ({
262
+ }), ge = async ({
263
263
  rootDir: e = process.cwd(),
264
264
  config: n
265
265
  }) => {
@@ -271,12 +271,12 @@ const ue = ({
271
271
  });
272
272
  return Object.entries(l).reduce(
273
273
  (d, [i, p]) => {
274
- const g = pe({
274
+ const y = pe({
275
275
  content: f,
276
276
  targetKey: i,
277
277
  keyConfig: p
278
278
  });
279
- return d[i] = g, d;
279
+ return d[i] = y, d;
280
280
  },
281
281
  c
282
282
  );
@@ -295,11 +295,11 @@ const ue = ({
295
295
  if (!n)
296
296
  return s.error("配置文件为空"), process.exit(1);
297
297
  const { rootDir: o } = e;
298
- await ye({ rootDir: o, config: n });
298
+ await ge({ rootDir: o, config: n });
299
299
  }, Ee = {
300
300
  command: "$0",
301
301
  describe: "生成文件",
302
- options: ge(),
302
+ options: ye(),
303
303
  handler: I
304
304
  }, Re = async (e, n) => {
305
305
  switch (e) {
@@ -337,7 +337,7 @@ export {
337
337
  I as d,
338
338
  Ee as e,
339
339
  Re as f,
340
- ye as g,
340
+ ge as g,
341
341
  G as h,
342
342
  _ as i
343
343
  };
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-afbdba02.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-aebb3f75.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.20",
3
+ "version": "0.1.23",
4
4
  "description": "信息提取命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -31,7 +31,7 @@
31
31
  ],
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://gitee.com/done-coding/done-coding-cli.git",
34
+ "url": "https://github.com/done-coding/done-coding-cli.git",
35
35
  "directory": "packages/extract"
36
36
  },
37
37
  "publishConfig": {
@@ -42,21 +42,20 @@
42
42
  "license": "MIT",
43
43
  "sideEffects": false,
44
44
  "devDependencies": {
45
- "@done-coding/cli-inject": "0.5.20",
45
+ "@done-coding/cli-inject": "0.5.23",
46
46
  "@types/node": "^18.0.0",
47
47
  "@types/yargs": "^17.0.28",
48
- "rimraf": "^6.0.1",
49
- "typescript": "^5.2.2",
48
+ "typescript": "^5.8.3",
50
49
  "vite": "^4.4.11",
51
50
  "vite-plugin-dts": "^3.6.0"
52
51
  },
52
+ "dependencies": {
53
+ "@done-coding/cli-template": "0.8.10",
54
+ "@done-coding/cli-utils": "0.8.4"
55
+ },
53
56
  "engines": {
54
57
  "node": ">=18.0.0"
55
58
  },
56
- "dependencies": {
57
- "@done-coding/cli-template": "0.8.7",
58
- "@done-coding/cli-utils": "0.8.1"
59
- },
60
- "gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6",
59
+ "gitHead": "d90f437c0a716f3e62bd92a221341838710869ad",
61
60
  "scripts": {}
62
61
  }
package/types/index.d.ts CHANGED
@@ -76,7 +76,7 @@ export declare const generateCommandCliInfo: SubCliInfo;
76
76
 
77
77
  /** 将提取的信息生成文件 */
78
78
  export declare const generateFile: ({ rootDir, config, }: {
79
- rootDir?: string | undefined;
79
+ rootDir?: string;
80
80
  config: ExtractConfig;
81
81
  }) => Promise<void>;
82
82