@done-coding/cli-git 0.6.14 → 0.6.15

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 @@ git 跨平台操作命令行工具 - 提供 git 平台克隆、钩子管理和
8
8
  ## 安装
9
9
 
10
10
  ### 独立安装
11
+
11
12
  ```bash
12
13
  npm install @done-coding/cli-git
13
14
  # 或
@@ -15,6 +16,7 @@ pnpm add @done-coding/cli-git
15
16
  ```
16
17
 
17
18
  ### 作为 done-coding CLI 的一部分
19
+
18
20
  ```bash
19
21
  npm install -g @done-coding/cli
20
22
  # 然后使用
@@ -45,6 +47,7 @@ dc git --help # Windows
45
47
  ### 基础命令
46
48
 
47
49
  #### `dc-git init`
50
+
48
51
  初始化配置文件
49
52
 
50
53
  ```bash
@@ -53,6 +56,7 @@ dc-git init
53
56
  ```
54
57
 
55
58
  #### `dc-git clone <platform> <username>`
59
+
56
60
  从指定的 git 平台克隆用户的代码仓库
57
61
 
58
62
  ```bash
@@ -67,10 +71,12 @@ dc-git clone bitbucket username
67
71
  ```
68
72
 
69
73
  **参数说明**:
74
+
70
75
  - `platform`: git 平台名称 (github, gitlab, bitbucket 等)
71
76
  - `username`: 用户名
72
77
 
73
78
  #### `dc-git hooks <name> [args...]`
79
+
74
80
  执行 git 钩子回调
75
81
 
76
82
  ```bash
@@ -85,10 +91,12 @@ dc-git hooks pre-push origin main
85
91
  ```
86
92
 
87
93
  **参数说明**:
94
+
88
95
  - `name`: 钩子名称
89
96
  - `args`: 传递给钩子的参数
90
97
 
91
98
  #### `dc-git check <type>`
99
+
92
100
  检查 git 操作和状态,主要为工程化配置提供支持
93
101
 
94
102
  ```bash
@@ -97,6 +105,7 @@ dc-git check reverse-merge
97
105
  ```
98
106
 
99
107
  **参数说明**:
108
+
100
109
  - `type`: 检查类型
101
110
  - `reverse-merge`: 检测反向合并,防止高级分支被合并到低级分支
102
111
 
@@ -154,29 +163,29 @@ DC git check reverse-merge
154
163
  ```javascript
155
164
  export default {
156
165
  // 默认平台
157
- defaultPlatform: 'github',
158
-
166
+ defaultPlatform: "github",
167
+
159
168
  // 克隆配置
160
169
  clone: {
161
170
  // 默认克隆协议
162
- protocol: 'https', // 或 'ssh'
171
+ protocol: "https", // 或 'ssh'
163
172
  // 目标目录
164
- targetDir: './repos'
173
+ targetDir: "./repos",
165
174
  },
166
-
175
+
167
176
  // 钩子配置
168
177
  hooks: {
169
178
  // 启用的钩子
170
- enabled: ['pre-commit', 'post-commit', 'pre-push'],
179
+ enabled: ["pre-commit", "post-commit", "pre-push"],
171
180
  // 钩子脚本路径
172
- scriptsPath: './.git/hooks'
181
+ scriptsPath: "./.git/hooks",
173
182
  },
174
-
183
+
175
184
  // 检查配置
176
185
  check: {
177
186
  // 默认检查项
178
- defaultChecks: ['status', 'branch', 'remote']
179
- }
187
+ defaultChecks: ["status", "branch", "remote"],
188
+ },
180
189
  };
181
190
  ```
182
191
 
@@ -185,29 +194,33 @@ export default {
185
194
  ### 作为模块使用
186
195
 
187
196
  ```javascript
188
- import { GitHelper } from '@done-coding/cli-git/helpers';
197
+ import { GitHelper } from "@done-coding/cli-git/helpers";
189
198
 
190
199
  const git = new GitHelper();
191
200
 
192
201
  // 克隆仓库
193
- await git.cloneFromPlatform('github', 'username');
202
+ await git.cloneFromPlatform("github", "username");
194
203
 
195
204
  // 执行钩子
196
- await git.executeHook('pre-commit', []);
205
+ await git.executeHook("pre-commit", []);
197
206
 
198
207
  // 检查状态
199
- const status = await git.checkStatus('status');
208
+ const status = await git.checkStatus("status");
200
209
  console.log(status);
201
210
  ```
202
211
 
203
212
  ### TypeScript 支持
204
213
 
205
214
  ```typescript
206
- import type { PlatformType, HookType, CheckType } from '@done-coding/cli-git/helpers';
207
-
208
- const platform: PlatformType = 'github';
209
- const hook: HookType = 'pre-commit';
210
- const checkType: CheckType = 'status';
215
+ import type {
216
+ PlatformType,
217
+ HookType,
218
+ CheckType,
219
+ } from "@done-coding/cli-git/helpers";
220
+
221
+ const platform: PlatformType = "github";
222
+ const hook: HookType = "pre-commit";
223
+ const checkType: CheckType = "status";
211
224
  ```
212
225
 
213
226
  ## 故障排除
@@ -215,6 +228,7 @@ const checkType: CheckType = 'status';
215
228
  ### 常见问题
216
229
 
217
230
  **Q: 克隆失败**
231
+
218
232
  ```bash
219
233
  # 检查网络连接
220
234
  ping github.com
@@ -227,6 +241,7 @@ dc-git clone github username --verbose
227
241
  ```
228
242
 
229
243
  **Q: 钩子执行失败**
244
+
230
245
  ```bash
231
246
  # 检查钩子文件权限
232
247
  ls -la .git/hooks/
@@ -239,6 +254,7 @@ dc-git init
239
254
  ```
240
255
 
241
256
  **Q: 检查命令无响应**
257
+
242
258
  ```bash
243
259
  # 确保在 git 仓库中
244
260
  git status
@@ -277,7 +293,7 @@ DEBUG=done-coding:git dc-git clone github username
277
293
 
278
294
  ```bash
279
295
  # 克隆仓库
280
- git clone https://gitee.com/done-coding/done-coding-cli.git
296
+ git clone https://github.com/done-coding/done-coding-cli.git
281
297
  cd done-coding-cli/packages/git
282
298
 
283
299
  # 安装依赖
@@ -313,6 +329,7 @@ MIT © [JustSoSu](https://gitee.com/done-coding)
313
329
  ### 检测功能详解
314
330
 
315
331
  #### `dc-git check reverse-merge`
332
+
316
333
  专为工程化配置提供的 git 合并规范检测:
317
334
 
318
335
  ```bash
@@ -321,12 +338,13 @@ dc-git check reverse-merge
321
338
 
322
339
  # 该命令会检测:
323
340
  # 1. 通过 git reflog 检测合并操作
324
- # 2. 通过提交信息检测合并记录
341
+ # 2. 通过提交信息检测合并记录
325
342
  # 3. 通过提交记录检测历史合并
326
343
  # 4. 检测 rebase 操作的合规性
327
344
  ```
328
345
 
329
346
  **检测场景**:
347
+
330
348
  - 防止 `main` 分支被合并到 `feature` 分支
331
349
  - 防止 `develop` 分支被合并到个人开发分支
332
350
  - 确保分支合并方向符合 Git Flow 规范
@@ -336,4 +354,4 @@ dc-git check reverse-merge
336
354
  - [主 CLI 工具](https://www.npmjs.com/package/@done-coding/cli)
337
355
  - [配置工具包](https://www.npmjs.com/package/@done-coding/cli-config) - 使用本包的检测功能
338
356
  - [Gitee 仓库](https://gitee.com/done-coding/done-coding-cli)
339
- - [更新日志](./CHANGELOG.md)
357
+ - [更新日志](./CHANGELOG.md)
package/es/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-1c9dde81.js";
3
- import "./index-d7ef8756.js";
2
+ import { c as m } from "./index-d0f82826.js";
3
+ import "./index-569e0691.js";
4
4
  import "@done-coding/cli-utils";
5
5
  import "node:fs";
6
6
  import "node:path";
package/es/helpers.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { g as s, G as n, a as i, h as m } from "./index-d7ef8756.js";
2
+ import { g as s, G as n, a as i, h as m } from "./index-569e0691.js";
3
3
  import { outputConsole as o, xPrompts as r } from "@done-coding/cli-utils";
4
4
  import "node:fs";
5
5
  import "node:path";
@@ -60,7 +60,7 @@ const fe = 3e4, y = Math.random(), U = {
60
60
  }
61
61
  }), T = {
62
62
  name: "@done-coding/cli-git",
63
- version: "0.6.14",
63
+ version: "0.6.15",
64
64
  description: "git跨平台操作命令行工具",
65
65
  bin: {
66
66
  "dc-git": "es/cli.mjs"
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as a, i as t } from "./index-d7ef8756.js";
2
+ import { c as a, i as t } from "./index-569e0691.js";
3
3
  import { createMainCommand as s, createSubcommand as r } from "@done-coding/cli-utils";
4
4
  const {
5
5
  cliConfig: { moduleName: o }
package/es/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { o as i, C as l, G as t, I as d, S as c, m as C, l as p, f, h, c as u, b as k, n as I, k as E, j as b, e as H, d as g } from "./index-d7ef8756.js";
3
- import { a as S } from "./index-1c9dde81.js";
2
+ import { o as i, C as l, G as t, I as d, S as c, m as C, l as p, f, h, c as u, b as k, n as I, k as E, j as b, e as H, d as g } from "./index-569e0691.js";
3
+ import { a as S } from "./index-d0f82826.js";
4
4
  import "@done-coding/cli-utils";
5
5
  import "node:fs";
6
6
  import "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-git",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
  "description": "git跨平台操作命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
41
- "url": "https://gitee.com/done-coding/done-coding-cli.git",
41
+ "url": "https://github.com/done-coding/done-coding-cli.git",
42
42
  "directory": "packages/git"
43
43
  },
44
44
  "publishConfig": {
@@ -49,7 +49,7 @@
49
49
  "license": "MIT",
50
50
  "sideEffects": false,
51
51
  "devDependencies": {
52
- "@done-coding/cli-inject": "0.5.22",
52
+ "@done-coding/cli-inject": "0.5.23",
53
53
  "@types/node": "^18.0.0",
54
54
  "@types/yargs": "^17.0.28",
55
55
  "typescript": "^5.8.3",
@@ -57,12 +57,12 @@
57
57
  "vite-plugin-dts": "^3.6.0"
58
58
  },
59
59
  "dependencies": {
60
- "@done-coding/cli-utils": "0.8.3",
60
+ "@done-coding/cli-utils": "0.8.4",
61
61
  "@done-coding/request-axios": "^1.2.2",
62
62
  "axios": "^1.8.4"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=18.0.0"
66
66
  },
67
- "gitHead": "4893b466954ef5925151d8dfc8fc8aa558ce654c"
67
+ "gitHead": "d90f437c0a716f3e62bd92a221341838710869ad"
68
68
  }