@chaobinchen/mes-cli 1.0.0

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 ADDED
@@ -0,0 +1,225 @@
1
+ # mes-cli
2
+
3
+ MES 数据库查询 CLI — 连接 SQL Server,快速查询 MES 业务数据。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g @chaobinchen/mes-cli
9
+ # 或本地开发
10
+ git clone ...
11
+ cd mes-cli
12
+ npm install
13
+ node bin/mes.js --help
14
+ ```
15
+
16
+ ## 快速开始
17
+
18
+ ### 1. 初始化连接配置
19
+
20
+ ```bash
21
+ mes init # 当前目录(项目级)
22
+ mes init --global # HOME 目录(全局)
23
+ ```
24
+
25
+ 向导会创建 `.mes.json`,并自动将其加入 `.gitignore`。
26
+
27
+ ```json
28
+ {
29
+ "server": "172.29.x.x",
30
+ "port": 1433,
31
+ "user": "sa",
32
+ "password": "YOUR_PASSWORD",
33
+ "database": "mes_master"
34
+ }
35
+ ```
36
+
37
+ ### 2. 也可用环境变量连接
38
+
39
+ ```bash
40
+ MES_DB_SERVER=172.29.x.x MES_DB_USER=sa MES_DB_PASSWORD=xxx mes progress MO6303A035
41
+ ```
42
+
43
+ Windows PowerShell:
44
+ ```powershell
45
+ $env:MES_DB_SERVER='172.29.x.x'; $env:MES_DB_USER='sa'; $env:MES_DB_PASSWORD='xxx'
46
+ mes progress MO6303A035
47
+ ```
48
+
49
+ 优先级:CLI 参数 > 环境变量 > `.mes.json`
50
+
51
+ ---
52
+
53
+ ## 全局连接参数
54
+
55
+ 所有命令均支持以下参数(可覆盖配置文件 / 环境变量):
56
+
57
+ ```
58
+ -S, --server <server> 数据库服务器地址
59
+ -P, --port <port> 端口(默认 1433)
60
+ -u, --user <user> 用户名
61
+ -p, --password <password> 密码
62
+ -d, --database <database> 数据库名
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 命令列表
68
+
69
+ ### 工单类
70
+
71
+ | 命令 | 别名 | 说明 |
72
+ |------|------|------|
73
+ | `mes progress <orderNum>` | `pg` | 工单进度(称量 + 生产状态) |
74
+ | `mes risk-orders` | `ro` | 延期风险工单清单 |
75
+ | `mes order-info <orderNum>` | `oi` | 工单基础信息 |
76
+ | `mes active-orders` | `ao` | 生产中工单清单(需指定日期) |
77
+ | `mes pending-discharge` | `pdc` | 待出锅工单清单 |
78
+ | `mes daily-plan` | `dp` | 某天计划生产工单(需指定日期) |
79
+ | `mes qc-result <orderNum>` | `qcr` | 工单质检结果 |
80
+ | `mes exec-overview <orderNum>` | `eo` | 半成品生产执行概览 |
81
+
82
+ ### 称量类
83
+
84
+ | 命令 | 别名 | 说明 |
85
+ |------|------|------|
86
+ | `mes weighing-overview <orderNum>` | `wov` | 称量工单执行概览 |
87
+ | `mes weighing-tasks <orderNum>` | `wt` | 称量任务清单 |
88
+ | `mes pending-weighing <orderNum>` | `pw` | 未完成称量项 |
89
+ | `mes weighing-detail <orderNum>` | `wdt` | 称量执行明细 |
90
+ | `mes operator-records <operator>` | `orec` | 操作员称量记录 |
91
+ | `mes review-status <orderNum>` | `rvs` | 称量复核状态 |
92
+ | `mes accounting-status <orderNum>` | `acs` | 称量账务状态 |
93
+ | `mes weighing-exceptions <orderNum>` | `wex` | 称量异常 / 作废记录 |
94
+ | `mes weighing-duration <orderNum>` | `wdur` | 称量耗时分析 |
95
+
96
+ ### 物料类
97
+
98
+ | 命令 | 别名 | 说明 |
99
+ |------|------|------|
100
+ | `mes stock-records <materialCode>` | `sr` | 物料出入库记录 |
101
+ | `mes stock-inventory <materialCode>` | `si` | 物料库存查询 |
102
+ | `mes trace-forward` | `tf` | 半成品批次追溯原料 |
103
+ | `mes trace-backward` | `tb` | 原料批次反向追踪半成品 |
104
+ | `mes material-usage <materialCode>` | `mu` | 近期原料使用明细 |
105
+ | `mes stock-coverage <materialCode>` | `sc` | 库存与用量对比(预计可用天数) |
106
+
107
+ ### 报告类
108
+
109
+ | 命令 | 别名 | 说明 |
110
+ |------|------|------|
111
+ | `mes weighing-report <orderNum>` | `wr` | 称量批记录报告(表头 + 明细) |
112
+ | `mes bulk-report <orderNum>` | `br` | 半成品生产报告(表头 + 明细) |
113
+
114
+ ---
115
+
116
+ ## 常用示例
117
+
118
+ ```bash
119
+ # 工单进度
120
+ mes progress MO6303A035
121
+ mes pg MO6303A035
122
+
123
+ # 延期风险工单(可选车间 / 日期过滤)
124
+ mes risk-orders
125
+ mes ro --workshop 车间A
126
+ mes ro -d 2026-04-10
127
+
128
+ # 生产中工单(必填日期)
129
+ mes active-orders --date 2026-04-14
130
+ mes ao -d 2026-04-14 --workshop 车间A
131
+
132
+ # 今日计划工单
133
+ mes daily-plan --date 2026-04-14
134
+ mes dp -d 2026-04-14
135
+
136
+ # 称量任务 / 未完成项
137
+ mes weighing-tasks MO6303A035
138
+ mes pending-weighing MO6303A035
139
+
140
+ # 称量明细(可追加物料编码过滤)
141
+ mes weighing-detail MO6303A035 --material C160
142
+ mes wdt MO6303A035 -m C160
143
+
144
+ # 操作员记录(必填起止日期)
145
+ mes operator-records 陈金波 --start 2026-04-01 --end 2026-04-14
146
+
147
+ # 物料追溯
148
+ mes trace-forward --code 215B654 --batch 2026033101
149
+ mes trace-backward --code C160 --batch P122632
150
+
151
+ # 库存与用量(默认 180 天)
152
+ mes stock-coverage C160
153
+ mes sc C160 --days 30
154
+
155
+ # 生产报告
156
+ mes weighing-report MO6318A001
157
+ mes bulk-report MO6205A045
158
+ ```
159
+
160
+ ---
161
+
162
+ ## 参数说明(常用选项)
163
+
164
+ | 命令 | 必填选项 | 可选选项 |
165
+ |------|---------|---------|
166
+ | `risk-orders` | — | `-w/--workshop`, `-d/--date` |
167
+ | `active-orders` | `-d/--date <YYYY-MM-DD>` | `-w/--workshop` |
168
+ | `daily-plan` | `-d/--date <YYYY-MM-DD>` | — |
169
+ | `weighing-detail` | `<orderNum>` | `-m/--material <code>` |
170
+ | `operator-records` | `<operator>`, `--start`, `--end` | — |
171
+ | `trace-forward` | `--code <半成品编码>`, `-b/--batch <批次>` | — |
172
+ | `trace-backward` | `--code <原料编码>`, `-b/--batch <批次>` | — |
173
+ | `stock-records` | `<materialCode>` | `-b/--batch` |
174
+ | `stock-inventory` | `<materialCode>` | `-b/--batch` |
175
+ | `material-usage` | `<materialCode>` | `-n/--days`(默认 180), `-b/--batch` |
176
+ | `stock-coverage` | `<materialCode>` | `-n/--days`(默认 180), `-b/--batch` |
177
+
178
+ ---
179
+
180
+ ## 项目结构
181
+
182
+ ```
183
+ mes-cli/
184
+ ├── bin/
185
+ │ └── mes.js # CLI 入口,注册所有命令
186
+ ├── src/
187
+ │ ├── config.js # 连接配置解析
188
+ │ ├── db.js # mssql 查询封装
189
+ │ ├── display.js # cli-table3 表格输出
190
+ │ ├── encoding.js # Windows 编码处理
191
+ │ └── commands/
192
+ │ ├── init.js # init 命令
193
+ │ ├── progress.js # progress 命令
194
+ │ ├── work-order.js # 工单类(8 个命令)
195
+ │ ├── weighing.js # 称量类(9 个命令)
196
+ │ ├── material.js # 物料类(6 个命令)
197
+ │ └── reports.js # 报告类(2 个命令)
198
+ ├── skills/
199
+ │ └── mes-cli/
200
+ │ ├── SKILL.md # Codex 技能说明
201
+ │ ├── agents/
202
+ │ │ └── openai.yaml # OpenAI agent 配置
203
+ │ └── scripts/
204
+ │ └── mes-query.ps1 # PowerShell 查询封装脚本
205
+ ├── package.json
206
+ └── README.md
207
+ ```
208
+
209
+ ---
210
+
211
+ ## 依赖
212
+
213
+ - Node.js >= 14
214
+ - [commander](https://www.npmjs.com/package/commander) ^12.1.0
215
+ - [mssql](https://www.npmjs.com/package/mssql) ^11.0.1
216
+ - [cli-table3](https://www.npmjs.com/package/cli-table3)
217
+ - [chalk](https://www.npmjs.com/package/chalk)
218
+ - [iconv-lite](https://www.npmjs.com/package/iconv-lite)
219
+ - [inquirer](https://www.npmjs.com/package/inquirer)
220
+
221
+ ---
222
+
223
+ ## License
224
+
225
+ ISC
package/bin/mes.js ADDED
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // ─── Windows 终端 UTF-8 强制设置 ──────────────────────────────────────────────
5
+ if (process.platform === 'win32') {
6
+ try {
7
+ require('child_process').execSync('chcp 65001', { stdio: 'ignore' });
8
+ } catch (_) {}
9
+ if (process.stdout.isTTY) process.stdout.setDefaultEncoding('utf8');
10
+ if (process.stderr.isTTY) process.stderr.setDefaultEncoding('utf8');
11
+ }
12
+
13
+ const { Command } = require('commander');
14
+ const { progressCommand } = require('../src/commands/progress');
15
+ const { initCommand } = require('../src/commands/init');
16
+ const {
17
+ riskOrdersCommand,
18
+ orderInfoCommand,
19
+ activeOrdersCommand,
20
+ pendingDischargeCommand,
21
+ dailyPlanCommand,
22
+ qcResultCommand,
23
+ execOverviewCommand,
24
+ } = require('../src/commands/work-order');
25
+ const {
26
+ weighingOverviewCommand,
27
+ weighingTasksCommand,
28
+ pendingWeighingCommand,
29
+ weighingDetailCommand,
30
+ operatorRecordsCommand,
31
+ reviewStatusCommand,
32
+ accountingStatusCommand,
33
+ weighingExceptionsCommand,
34
+ weighingDurationCommand,
35
+ } = require('../src/commands/weighing');
36
+ const {
37
+ stockRecordsCommand,
38
+ stockInventoryCommand,
39
+ traceForwardCommand,
40
+ traceBackwardCommand,
41
+ materialUsageCommand,
42
+ stockCoverageCommand,
43
+ } = require('../src/commands/material');
44
+ const { weighingReportCommand, bulkReportCommand } = require('../src/commands/reports');
45
+ const { findConfigFilePath } = require('../src/config');
46
+ const chalk = require('chalk');
47
+ const { version } = require('../package.json');
48
+
49
+ const program = new Command();
50
+
51
+ program
52
+ .name('mes')
53
+ .description(
54
+ chalk.bold('MES 数据库查询 CLI') +
55
+ '\n连接 SQL Server,快速查看 MES 业务数据\n\n' +
56
+ chalk.dim('连接参数优先级:CLI 选项 > 环境变量 > 配置文件 (.mes.json)')
57
+ )
58
+ .version(version, '-v, --version', '显示版本号')
59
+ // ─── 全局数据库连接选项 ────────────────────────────────────────────────────
60
+ .option('--server <host>', '数据库服务器地址 [env: MES_DB_SERVER]')
61
+ .option('--port <port>', '数据库端口(默认 1433) [env: MES_DB_PORT]')
62
+ .option('--user <user>', '数据库用户名 [env: MES_DB_USER]')
63
+ .option('--password <pass>', '数据库密码 [env: MES_DB_PASSWORD]')
64
+ .option('--database <db>', '数据库名称 [env: MES_DB_DATABASE]');
65
+
66
+ // ─── 命令 1:工单进度 ─────────────────────────────────────────────────────────
67
+ program
68
+ .command('progress <orderNum>')
69
+ .alias('pg')
70
+ .description('查询半成品工单的总体进度(称量状态 + 生产状态)')
71
+ .action(progressCommand);
72
+
73
+ // ─── 命令 N:初始化配置 ───────────────────────────────────────────────────────
74
+ program
75
+ .command('init')
76
+ .description('交互式创建 .mes.json 数据库连接配置文件')
77
+ .option('-g, --global', '写入 HOME 目录(对所有项目生效),默认写入当前目录')
78
+ .action(initCommand);
79
+
80
+ // ─── 工单类命令 ───────────────────────────────────────────────────────────────
81
+ program
82
+ .command('risk-orders')
83
+ .alias('ro')
84
+ .description('延期风险工单清单')
85
+ .option('-w, --workshop <name>', '过滤车间名称')
86
+ .option('-d, --date <YYYY-MM-DD>', '截止检查日期(默认今天)')
87
+ .action(riskOrdersCommand);
88
+
89
+ program
90
+ .command('order-info <orderNum>')
91
+ .alias('oi')
92
+ .description('工单基础信息查询')
93
+ .action(orderInfoCommand);
94
+
95
+ program
96
+ .command('active-orders')
97
+ .alias('ao')
98
+ .description('生产中工单清单')
99
+ .requiredOption('-d, --date <YYYY-MM-DD>', '计划日期')
100
+ .option('-w, --workshop <name>', '过滤车间名称')
101
+ .action(activeOrdersCommand);
102
+
103
+ program
104
+ .command('pending-discharge')
105
+ .alias('pdc')
106
+ .description('待出锅工单清单(投料完成状态)')
107
+ .option('-w, --workshop <name>', '过滤车间名称')
108
+ .action(pendingDischargeCommand);
109
+
110
+ program
111
+ .command('daily-plan')
112
+ .alias('dp')
113
+ .description('某天计划生产工单清单')
114
+ .requiredOption('-d, --date <YYYY-MM-DD>', '计划日期')
115
+ .action(dailyPlanCommand);
116
+
117
+ program
118
+ .command('qc-result <orderNum>')
119
+ .alias('qcr')
120
+ .description('工单质检结果查询')
121
+ .action(qcResultCommand);
122
+
123
+ program
124
+ .command('exec-overview <orderNum>')
125
+ .alias('eo')
126
+ .description('半成品生产执行概览(称量+生产+质检+扣账+报工)')
127
+ .action(execOverviewCommand);
128
+
129
+ // ─── 称量类命令 ───────────────────────────────────────────────────────────────
130
+ program
131
+ .command('weighing-overview <orderNum>')
132
+ .alias('wov')
133
+ .description('称量工单执行概览')
134
+ .action(weighingOverviewCommand);
135
+
136
+ program
137
+ .command('weighing-tasks <orderNum>')
138
+ .alias('wt')
139
+ .description('称量任务清单')
140
+ .action(weighingTasksCommand);
141
+
142
+ program
143
+ .command('pending-weighing <orderNum>')
144
+ .alias('pw')
145
+ .description('未完成称量项')
146
+ .action(pendingWeighingCommand);
147
+
148
+ program
149
+ .command('weighing-detail <orderNum>')
150
+ .alias('wdt')
151
+ .description('称量执行明细')
152
+ .option('-m, --material <code>', '过滤物料编码')
153
+ .action(weighingDetailCommand);
154
+
155
+ program
156
+ .command('operator-records <operator>')
157
+ .alias('orec')
158
+ .description('操作员称量记录')
159
+ .requiredOption('--start <YYYY-MM-DD>', '开始日期')
160
+ .requiredOption('--end <YYYY-MM-DD>', '结束日期')
161
+ .action(operatorRecordsCommand);
162
+
163
+ program
164
+ .command('review-status <orderNum>')
165
+ .alias('rvs')
166
+ .description('称量复核状态')
167
+ .action(reviewStatusCommand);
168
+
169
+ program
170
+ .command('accounting-status <orderNum>')
171
+ .alias('acs')
172
+ .description('称量账务状态')
173
+ .action(accountingStatusCommand);
174
+
175
+ program
176
+ .command('weighing-exceptions <orderNum>')
177
+ .alias('wex')
178
+ .description('称量异常或作废记录')
179
+ .action(weighingExceptionsCommand);
180
+
181
+ program
182
+ .command('weighing-duration <orderNum>')
183
+ .alias('wdur')
184
+ .description('称量耗时分析')
185
+ .action(weighingDurationCommand);
186
+
187
+ // ─── 物料类命令 ───────────────────────────────────────────────────────────────
188
+ program
189
+ .command('stock-records <materialCode>')
190
+ .alias('sr')
191
+ .description('物料批次出入库记录')
192
+ .option('-b, --batch <batch>', '过滤批次')
193
+ .action(stockRecordsCommand);
194
+
195
+ program
196
+ .command('stock-inventory <materialCode>')
197
+ .alias('si')
198
+ .description('物料库存查询')
199
+ .option('-b, --batch <batch>', '过滤批次')
200
+ .action(stockInventoryCommand);
201
+
202
+ program
203
+ .command('trace-forward')
204
+ .alias('tf')
205
+ .description('半成品编码+批次追溯原料')
206
+ .requiredOption('--code <code>', '半成品编码')
207
+ .requiredOption('-b, --batch <batch>', '半成品批次')
208
+ .action(traceForwardCommand);
209
+
210
+ program
211
+ .command('trace-backward')
212
+ .alias('tb')
213
+ .description('原料编码+批次反向跟踪半成品')
214
+ .requiredOption('--code <code>', '原料编码')
215
+ .requiredOption('-b, --batch <batch>', '原料批次')
216
+ .action(traceBackwardCommand);
217
+
218
+ program
219
+ .command('material-usage <materialCode>')
220
+ .alias('mu')
221
+ .description('近几天原料使用明细(默认 180 天)')
222
+ .option('-n, --days <days>', '查询天数', '180')
223
+ .option('-b, --batch <batch>', '过滤原料批次')
224
+ .action(materialUsageCommand);
225
+
226
+ program
227
+ .command('stock-coverage <materialCode>')
228
+ .alias('sc')
229
+ .description('原料当前库存与近几天使用量对比(默认 180 天)')
230
+ .option('-n, --days <days>', '查询天数', '180')
231
+ .option('-b, --batch <batch>', '过滤原料批次')
232
+ .action(stockCoverageCommand);
233
+
234
+ // ─── 报告类命令 ───────────────────────────────────────────────────────────────
235
+ program
236
+ .command('weighing-report <orderNum>')
237
+ .alias('wr')
238
+ .description('称量报告(表头 + 明细)')
239
+ .action(weighingReportCommand);
240
+
241
+ program
242
+ .command('bulk-report <orderNum>')
243
+ .alias('br')
244
+ .description('半成品报告(表头 + 明细)')
245
+ .action(bulkReportCommand);
246
+
247
+ // ─── 无子命令时显示帮助 + 提示配置文件 ──────────────────────────────────────
248
+ if (process.argv.length === 2) {
249
+ program.outputHelp();
250
+ const cfgPath = findConfigFilePath();
251
+ if (cfgPath) {
252
+ console.log(chalk.green(`\n✔ 检测到配置文件: ${cfgPath}`));
253
+ } else {
254
+ console.log(chalk.dim('\n提示: 可在当前目录或 HOME 目录新建 .mes.json 保存连接信息'));
255
+ console.log(chalk.dim(' 或运行 mes init 进行交互式初始化'));
256
+ }
257
+ process.exit(0);
258
+ }
259
+
260
+ program.parseAsync(process.argv).catch((err) => {
261
+ console.error(chalk.red('✖ CLI 内部错误:'), err.message);
262
+ process.exit(1);
263
+ });
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@chaobinchen/mes-cli",
3
+ "version": "1.0.0",
4
+ "description": "MES 数据库查询 CLI — 快速查询工单进度等业务数据",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "mes": "bin/mes.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "src/",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "start": "node bin/mes.js",
16
+ "test": "node bin/mes.js --help"
17
+ },
18
+ "keywords": [
19
+ "mes",
20
+ "mssql",
21
+ "cli",
22
+ "database",
23
+ "query"
24
+ ],
25
+ "author": "",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "chalk": "^4.1.2",
29
+ "cli-table3": "^0.6.5",
30
+ "commander": "^12.1.0",
31
+ "iconv-lite": "^0.7.2",
32
+ "mssql": "^11.0.1"
33
+ },
34
+ "engines": {
35
+ "node": ">=14.0.0"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ }
40
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * 命令:init —— 交互式创建 .mes.json 数据库连接配置文件
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const readline = require('readline');
10
+ const chalk = require('chalk');
11
+ const { CONFIG_FILENAME } = require('../config');
12
+
13
+ function ask(rl, prompt, def, secret = false) {
14
+ const hint = def !== undefined ? chalk.dim(` [${def}]`) : '';
15
+ return new Promise((resolve) => {
16
+ if (secret) {
17
+ process.stdout.write(prompt + hint + ': ');
18
+ rl.once('line', line => resolve(line.trim() || def || ''));
19
+ } else {
20
+ rl.question(prompt + hint + ': ', ans => resolve(ans.trim() || def || ''));
21
+ }
22
+ });
23
+ }
24
+
25
+ async function initCommand(options, command) {
26
+ const targetDir = options.global ? require('os').homedir() : process.cwd();
27
+ const targetFile = path.join(targetDir, CONFIG_FILENAME);
28
+
29
+ console.log(chalk.bold('\n🛠️ MES DB CLI —— 数据库连接初始化向导'));
30
+ console.log(chalk.dim(` 配置将写入 ${targetFile}\n`));
31
+
32
+ let existing = {};
33
+ if (fs.existsSync(targetFile)) {
34
+ try {
35
+ existing = JSON.parse(fs.readFileSync(targetFile, 'utf8'));
36
+ console.log(chalk.yellow(`⚠️ 发现已有配置文件,按回车保留原值:\n`));
37
+ } catch (_) {}
38
+ }
39
+
40
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
41
+
42
+ try {
43
+ const server = await ask(rl, ' 服务器地址 (host)', existing.server || '');
44
+ const port = await ask(rl, ' 端口 (port)', String(existing.port || 1433));
45
+ const database = await ask(rl, ' 数据库名 (database)', existing.database || '');
46
+ const user = await ask(rl, ' 用户名 (user)', existing.user || 'sa');
47
+ const password = await ask(rl, ' 密码 (password)', existing.password, true);
48
+
49
+ const config = {
50
+ server,
51
+ port: parseInt(port, 10) || 1433,
52
+ database,
53
+ user,
54
+ password,
55
+ };
56
+
57
+ rl.close();
58
+
59
+ fs.writeFileSync(targetFile, JSON.stringify(config, null, 2) + '\n', 'utf8');
60
+
61
+ console.log(chalk.green(`\n✅ 配置已写入 ${targetFile}`));
62
+ console.log(chalk.dim('\n 现在可以直接运行命令,无需每次传连接参数:'));
63
+ console.log(chalk.cyan(' mes progress MO6303A035'));
64
+ console.log(
65
+ chalk.yellow('\n ⚠️ 提示: ') +
66
+ chalk.dim(`${CONFIG_FILENAME} 包含数据库密码,请勿提交到 Git 仓库。\n`) +
67
+ chalk.dim(' 建议将其加入 .gitignore:') +
68
+ chalk.cyan(` echo "${CONFIG_FILENAME}" >> .gitignore\n`)
69
+ );
70
+ } catch (err) {
71
+ rl.close();
72
+ console.error(chalk.red('❌ 初始化失败'), err.message);
73
+ process.exitCode = 1;
74
+ }
75
+ }
76
+
77
+ module.exports = { initCommand };