@done-coding/cli-config 0.1.10 → 0.1.12

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
@@ -1,11 +1,222 @@
1
1
  # @done-coding/cli-config
2
2
 
3
+ 工程化配置命令行工具 - 检测和管理项目工程化配置
4
+
5
+ [![npm version](https://badge.fury.io/js/@done-coding%2Fcli-config.svg)](https://www.npmjs.com/package/@done-coding/cli-config)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## 安装
9
+
10
+ ### 独立安装
11
+ ```bash
12
+ npm install @done-coding/cli-config
13
+ # 或
14
+ pnpm add @done-coding/cli-config
3
15
  ```
4
- 工程化配置命令行工具
16
+
17
+ ### 作为 done-coding CLI 的一部分
18
+ ```bash
19
+ npm install -g @done-coding/cli
20
+ # 然后使用
21
+ DC config [command]
5
22
  ```
6
23
 
7
- ## 使用
24
+ ## 快速开始
8
25
 
9
- ``` bash
10
- npm install @done-coding/cli-config
11
- ```
26
+ ```bash
27
+ # 独立使用
28
+ dc-config [command]
29
+
30
+ # 作为主 CLI 的子命令
31
+ DC config [command]
32
+
33
+ # 查看帮助
34
+ dc-config --help
35
+ ```
36
+
37
+ ## 功能特性
38
+
39
+ - ✅ **配置检测**: 自动检测项目的工程化配置状态
40
+ - 🔧 **配置添加**: 快速添加常用的工程化配置
41
+ - 🔍 **Git 集成**: 集成 git 包的合并检测功能
42
+ - 📋 **规范检查**: 检查代码规范和项目结构
43
+ - 🚀 **一键配置**: 提供常用工程化工具的快速配置
44
+
45
+ ## API 文档
46
+
47
+ ### 基础命令
48
+
49
+ #### `dc-config check`
50
+ 检测工程化配置
51
+
52
+ ```bash
53
+ # 检测当前项目的工程化配置
54
+ dc-config check
55
+ ```
56
+
57
+ #### `dc-config add`
58
+ 添加工程化配置
59
+
60
+ ```bash
61
+ # 添加工程化配置
62
+ dc-config add
63
+ ```
64
+
65
+ ## 使用示例
66
+
67
+ ### 基础使用场景
68
+
69
+ ```bash
70
+ # 1. 检测当前项目配置状态
71
+ dc-config check
72
+
73
+ # 2. 添加工程化配置
74
+ dc-config add
75
+ ```
76
+
77
+ ### 作为主 CLI 的一部分
78
+
79
+ ```bash
80
+ # Windows 系统
81
+ dc config check
82
+ dc config add
83
+
84
+ # macOS/Linux 系统
85
+ DC config check
86
+ DC config add
87
+ ```
88
+
89
+ ## 配置
90
+
91
+ 本包支持配置文件,具体的配置选项需要查看包的实际实现。
92
+
93
+ ## 编程接口
94
+
95
+ 本包提供了编程接口,具体的导出内容请查看包的类型定义文件。
96
+
97
+ ## Git 合并检测集成
98
+
99
+ 本包集成了 `@done-coding/cli-git` 包的合并检测功能:
100
+
101
+ ### merge-lint 模块
102
+
103
+ 当执行 `dc-config check` 时,会自动调用 `dc-git check reverse-merge` 命令:
104
+
105
+ ```bash
106
+ # 自动执行的检测流程
107
+ dc-config check
108
+ ├── 检测 ESLint 配置
109
+ ├── 检测 Prettier 配置
110
+ ├── 检测 TypeScript 配置
111
+ ├── 检测 Git 钩子配置
112
+ └── 调用 dc-git check reverse-merge # 检测反向合并
113
+ ```
114
+
115
+ ### 反向合并检测
116
+
117
+ 防止将高级分支合并到低级分支:
118
+
119
+ - 防止 `main` 分支被合并到 `feature` 分支
120
+ - 防止 `develop` 分支被合并到个人开发分支
121
+ - 确保分支合并方向符合 Git Flow 规范
122
+
123
+ ## 故障排除
124
+
125
+ ### 常见问题
126
+
127
+ **Q: 配置检测失败**
128
+ ```bash
129
+ # 检查项目根目录
130
+ pwd
131
+
132
+ # 检查是否为 Git 仓库
133
+ git status
134
+
135
+ # 使用详细模式查看错误
136
+ dc-config check --verbose
137
+ ```
138
+
139
+ **Q: Git 合并检测报错**
140
+ ```bash
141
+ # 确保 git 包已安装
142
+ dc-git --version
143
+
144
+ # 手动执行 git 检测
145
+ dc-git check reverse-merge
146
+
147
+ # 检查 Git 仓库状态
148
+ git log --oneline -10
149
+ ```
150
+
151
+ **Q: 配置添加失败**
152
+ ```bash
153
+ # 检查写入权限
154
+ ls -la .
155
+
156
+ # 检查 npm/pnpm 可用性
157
+ npm --version
158
+ pnpm --version
159
+
160
+ # 清理缓存重试
161
+ npm cache clean --force
162
+ ```
163
+
164
+ ### 调试模式
165
+
166
+ ```bash
167
+ # 启用详细输出
168
+ dc-config --verbose check
169
+
170
+ # 启用调试模式
171
+ DEBUG=done-coding:config dc-config check
172
+ ```
173
+
174
+ ## 性能建议
175
+
176
+ - 定期运行配置检测确保项目规范性
177
+ - 使用 Git 钩子自动执行配置检测
178
+ - 团队协作时统一工程化配置标准
179
+
180
+ ## 贡献指南
181
+
182
+ 我们欢迎贡献!请遵循以下步骤:
183
+
184
+ 1. Fork 本仓库
185
+ 2. 创建功能分支:`git checkout -b feature/amazing-feature`
186
+ 3. 提交更改:`git commit -m "feat: add amazing feature"`
187
+ 4. 推送分支:`git push origin feature/amazing-feature`
188
+ 5. 创建 Pull Request
189
+
190
+ ### 开发环境设置
191
+
192
+ ```bash
193
+ # 克隆仓库
194
+ git clone https://gitee.com/done-coding/done-coding-cli.git
195
+ cd done-coding-cli/packages/config
196
+
197
+ # 安装依赖
198
+ pnpm install
199
+
200
+ # 开发模式
201
+ pnpm dev
202
+
203
+ # 构建
204
+ pnpm build
205
+
206
+ # 本地开发测试
207
+ node es/cli.mjs --help
208
+
209
+ # 注意:本地使用 node + 入口文件,发布后使用 bin 命令名
210
+ # 功能完全一致,只是调用方式不同
211
+ ```
212
+
213
+ ## 许可证
214
+
215
+ MIT © [JustSoSu](https://gitee.com/done-coding)
216
+
217
+ ## 相关链接
218
+
219
+ - [主 CLI 工具](https://www.npmjs.com/package/@done-coding/cli)
220
+ - [Git 操作工具](https://www.npmjs.com/package/@done-coding/cli-git) - 本包调用的 Git 检测功能
221
+ - [Gitee 仓库](https://gitee.com/done-coding/done-coding-cli)
222
+ - [更新日志](./CHANGELOG.md)
package/es/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-08808fce.js";
2
+ import { c as m } from "./index-6536e597.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:fs";
5
5
  import "node:path";
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { readConfigFile as B, log as i, getPackageJson as Q, getRelyPkgVersion as X, getConfigFileCommonOptions as Y, readCliConfig as Z, xPrompts as w, addPackageConfig as ee, addHuskyHooks as te, createSubcommand as J, getRootScriptName as ne, createMainCommand as oe } from "@done-coding/cli-utils";
2
+ import { readConfigFile as B, log as i, getPackageJson as Q, getRelyPkgVersion as X, getConfigFileCommonOptions as Y, readCliModuleAssetsConfig as Z, xPrompts as w, addPackageConfig as ee, addHuskyHooks as te, createSubcommand as J, getRootScriptName as ne, createMainCommand as oe } from "@done-coding/cli-utils";
3
3
  import k, { existsSync as C } from "node:fs";
4
4
  import g from "node:path";
5
5
  import { execSync as N } from "node:child_process";
6
6
  var y = /* @__PURE__ */ ((e) => (e.CHECK = "check", e.ADD = "add", e))(y || {}), m = /* @__PURE__ */ ((e) => (e.ESLINT = "eslint", e.PRETTIER = "prettier", e.COMMITLINT = "commitlint", e.LSLINT = "ls-lint", e.MERGELINT = "merge-lint", e))(m || {});
7
7
  const L = {
8
8
  name: "@done-coding/cli-config",
9
- version: "0.1.10",
9
+ version: "0.1.12",
10
10
  description: "工程化配置命令行工具",
11
11
  bin: {
12
12
  "dc-config": "es/cli.mjs"
@@ -274,7 +274,6 @@ ${JSON.stringify($, null, 2)}`), await ee({
274
274
  moduleName: o
275
275
  }) => {
276
276
  if (typeof e == "string") {
277
- console.log(e);
278
277
  const s = g.resolve(t, e);
279
278
  if (!C(s))
280
279
  throw new Error(
@@ -306,8 +305,10 @@ ${JSON.stringify($, null, 2)}`), await ee({
306
305
  moduleName: fe,
307
306
  onSuccess: async ({
308
307
  config: c,
309
- configTemporaryDir: u,
310
- cliConfigDirRelativePath: j
308
+ // configTemporaryDir,
309
+ // cliConfigDirRelativePath,
310
+ assetsConfigRepoTempDir: u,
311
+ moduleEntryFileRelativePath: j
311
312
  }) => {
312
313
  if (!(c != null && c.project))
313
314
  throw new Error("项目工程化预设不存在");
@@ -316,8 +317,7 @@ ${JSON.stringify($, null, 2)}`), await ee({
316
317
  for (let d of a) {
317
318
  const v = g.resolve(
318
319
  u,
319
- j,
320
- d
320
+ j
321
321
  ), D = ke({
322
322
  listConfig: S[d],
323
323
  moduleDir: v,
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as i, S as s, a as t, h as u } from "./index-08808fce.js";
2
+ import { C as i, S as s, a as t, h as u } from "./index-6536e597.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:fs";
5
5
  import "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-config",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "工程化配置命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -41,7 +41,7 @@
41
41
  "license": "MIT",
42
42
  "sideEffects": false,
43
43
  "devDependencies": {
44
- "@done-coding/cli-inject": "0.5.18",
44
+ "@done-coding/cli-inject": "0.5.20",
45
45
  "@types/node": "^18.0.0",
46
46
  "@types/yargs": "^17.0.28",
47
47
  "rimraf": "^6.0.1",
@@ -53,7 +53,7 @@
53
53
  "node": ">=18.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@done-coding/cli-utils": "0.7.8"
56
+ "@done-coding/cli-utils": "0.8.1"
57
57
  },
58
- "gitHead": "67d4fc202427c5b2f387b856cfe9507127a5b26c"
58
+ "gitHead": "0930f800167c04a86b56eae9741872dd51bec0c6"
59
59
  }