done-coding-inject 0.5.20 → 0.5.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-inject
13
14
  # 或
@@ -15,6 +16,7 @@ pnpm add @done-coding/cli-inject
15
16
  ```
16
17
 
17
18
  ### 作为 done-coding CLI 的一部分
19
+
18
20
  ```bash
19
21
  npm install -g @done-coding/cli
20
22
  # 然后使用
@@ -46,6 +48,7 @@ dc-inject --help
46
48
  ### 基础命令
47
49
 
48
50
  #### `dc-inject init`
51
+
49
52
  初始化配置文件
50
53
 
51
54
  ```bash
@@ -54,6 +57,7 @@ dc-inject init
54
57
  ```
55
58
 
56
59
  #### `dc-inject` (默认命令)
60
+
57
61
  生成文件
58
62
 
59
63
  ```bash
@@ -68,6 +72,7 @@ dc-inject -C ./custom-config.json
68
72
  ```
69
73
 
70
74
  **选项说明**:
75
+
71
76
  - `-R, --rootDir`: 运行目录
72
77
  - `-C, --configPath`: 配置文件相对路径,默认为 `./.done-coding/inject.json`
73
78
 
@@ -113,6 +118,7 @@ DC inject -R ./src
113
118
  ### 常见问题
114
119
 
115
120
  **Q: 配置文件找不到**
121
+
116
122
  ```bash
117
123
  # 检查配置文件是否存在
118
124
  ls -la .done-coding/inject.json
@@ -122,6 +128,7 @@ dc-inject init
122
128
  ```
123
129
 
124
130
  **Q: 注入失败**
131
+
125
132
  ```bash
126
133
  # 检查运行目录
127
134
  dc-inject -R ./src
@@ -154,7 +161,7 @@ dc-inject --help
154
161
 
155
162
  ```bash
156
163
  # 克隆仓库
157
- git clone https://gitee.com/done-coding/done-coding-cli.git
164
+ git clone https://github.com/done-coding/done-coding-cli.git
158
165
  cd done-coding-cli/packages/inject
159
166
 
160
167
  # 安装依赖
package/es/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-b3f74005.js";
2
+ import { c as m } from "./index-6e0f42c3.js";
3
3
  import "./index-a1ee6691.js";
4
4
  import "@done-coding/cli-utils";
5
5
  import "node:path";
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { I as c, S as E } from "./index-a1ee6691.js";
3
- import { log as o, _get as I, initHandlerCommon as k, getConfigFileCommonOptions as A, _set as w, readConfigFile as T, createSubcommand as N, getRootScriptName as _, createMainCommand as M } from "@done-coding/cli-utils";
3
+ import { outputConsole as o, _get as I, initHandlerCommon as k, getConfigFileCommonOptions as A, _set as w, readConfigFile as T, createSubcommand as N, getRootScriptName as _, createMainCommand as M } from "@done-coding/cli-utils";
4
4
  import D from "node:path";
5
- import u from "node:fs";
5
+ import m from "node:fs";
6
6
  const x = ({
7
7
  sourceJson: e,
8
8
  targetKey: n,
@@ -36,7 +36,7 @@ const x = ({
36
36
  }
37
37
  }, d = {
38
38
  name: "@done-coding/cli-inject",
39
- version: "0.5.20",
39
+ version: "0.5.23",
40
40
  description: "信息(JSON)注入命令行工具",
41
41
  bin: {
42
42
  "dc-inject": "es/cli.mjs"
@@ -96,21 +96,21 @@ const x = ({
96
96
  return o.error("源文件必须是json"), process.exit(1);
97
97
  if (!r.endsWith(".json"))
98
98
  return o.error("注入文件必须是json"), process.exit(1);
99
- const p = D.resolve(e, s), g = u.readFileSync(p, "utf-8"), y = JSON.parse(g), i = Object.entries(f).reduce(
100
- (m, [F, v]) => {
99
+ const p = D.resolve(e, s), g = m.readFileSync(p, "utf-8"), y = JSON.parse(g), i = Object.entries(f).reduce(
100
+ (u, [F, v]) => {
101
101
  const P = x({ sourceJson: y, targetKey: F, keyConfig: v });
102
- return w(m, F, P), m;
102
+ return w(u, F, P), u;
103
103
  },
104
104
  {}
105
105
  ), l = D.resolve(e, r), C = JSON.stringify(i, null, 2);
106
- if (u.existsSync(l)) {
107
- const m = u.readFileSync(l, "utf-8");
108
- if (C === m)
106
+ if (m.existsSync(l)) {
107
+ const u = m.readFileSync(l, "utf-8");
108
+ if (C === u)
109
109
  return o.skip("注入文件已存在且内容相同,无需重复注入"), i;
110
110
  o.stage("文件内容变化,开始覆盖注入文件");
111
111
  } else
112
112
  o.stage("开始注入文件");
113
- u.writeFileSync(l, C), o.success(`文件注入成功: ${l}`), o.info(C);
113
+ m.writeFileSync(l, C), o.success(`文件注入成功: ${l}`), o.info(C);
114
114
  }, j = async (e) => {
115
115
  const n = await T(e, () => (o.info("配置文件为空,使用默认配置"), h));
116
116
  if (!n)
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as r, a as i, e as s, g as t, d, f as l, b as f, h as p, k as C } from "./index-b3f74005.js";
2
+ import { i as r, a as i, e as s, g as t, d, f as l, b as f, h as p, k as C } from "./index-6e0f42c3.js";
3
3
  import { I as g, S as u } from "./index-a1ee6691.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-inject",
3
- "version": "0.5.20",
3
+ "version": "0.5.23",
4
4
  "description": "信息(JSON)注入命令行工具",
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/inject"
36
36
  },
37
37
  "publishConfig": {
@@ -44,17 +44,16 @@
44
44
  "devDependencies": {
45
45
  "@types/node": "^18.0.0",
46
46
  "@types/yargs": "^17.0.28",
47
- "rimraf": "^6.0.1",
48
- "typescript": "^5.2.2",
47
+ "typescript": "^5.8.3",
49
48
  "vite": "^4.4.11",
50
49
  "vite-plugin-dts": "^3.6.0"
51
50
  },
51
+ "dependencies": {
52
+ "@done-coding/cli-utils": "0.8.4"
53
+ },
52
54
  "engines": {
53
55
  "node": ">=18.0.0"
54
56
  },
55
- "dependencies": {
56
- "@done-coding/cli-utils": "0.8.1"
57
- },
58
- "gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6",
57
+ "gitHead": "d90f437c0a716f3e62bd92a221341838710869ad",
59
58
  "scripts": {}
60
59
  }
package/types/index.d.ts CHANGED
@@ -14,9 +14,9 @@ export declare const generateCommandCliInfo: SubCliInfo;
14
14
 
15
15
  /** 生成注入信息文件 */
16
16
  export declare const generateFile: ({ rootDir, config, keyConfigMap: extractKeyConfigMap, }?: {
17
- rootDir?: string | undefined;
18
- config?: InjectConfig | undefined;
19
- keyConfigMap?: Record<string, InjectKeyConfig> | undefined;
17
+ rootDir?: string;
18
+ config?: InjectConfig;
19
+ keyConfigMap?: InjectConfig["keyConfigMap"];
20
20
  }) => Promise<{} | undefined>;
21
21
 
22
22
  /** 提取文件命令处理器 */