@agile-team/robot-cli 1.1.9 → 2.1.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/CHANGELOG.md +77 -0
- package/README.md +240 -323
- package/bin/robot.js +3 -0
- package/dist/index.js +1720 -0
- package/package.json +77 -80
- package/bin/index.js +0 -397
- package/lib/create.js +0 -1146
- package/lib/download.js +0 -205
- package/lib/templates.js +0 -353
- package/lib/utils.js +0 -334
package/package.json
CHANGED
|
@@ -1,80 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@agile-team/robot-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "🤖 现代化项目脚手架工具,支持多技术栈快速创建项目 -
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"robot": "bin/
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"url": "
|
|
71
|
-
},
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"access": "public"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@agile-team/robot-cli",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "🤖 现代化项目脚手架工具,支持多技术栈快速创建项目 - 优先 bun,兼容 npm/pnpm/yarn",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"robot": "bin/robot.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"dev": "tsup --watch",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"lint": "oxlint src/ tests/",
|
|
15
|
+
"lint:fix": "oxlint --fix src/ tests/",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"prepublishOnly": "bun run build && bun run test",
|
|
18
|
+
"release:patch": "bun version patch && bunx npm publish --access public",
|
|
19
|
+
"release:minor": "bun version minor && bunx npm publish --access public",
|
|
20
|
+
"release:major": "bun version major && bunx npm publish --access public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"boxen": "^7.1.0",
|
|
24
|
+
"chalk": "^5.3.0",
|
|
25
|
+
"commander": "^11.0.0",
|
|
26
|
+
"extract-zip": "^2.0.1",
|
|
27
|
+
"fs-extra": "^11.1.0",
|
|
28
|
+
"inquirer": "^9.2.0",
|
|
29
|
+
"ora": "^7.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/fs-extra": "^11.0.4",
|
|
33
|
+
"@types/inquirer": "^9.0.9",
|
|
34
|
+
"@types/node": "^22.0.0",
|
|
35
|
+
"oxlint": "^0.16.0",
|
|
36
|
+
"tsup": "^8.4.0",
|
|
37
|
+
"typescript": "^5.7.0",
|
|
38
|
+
"vitest": "^3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"bin",
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"keywords": [
|
|
47
|
+
"cli",
|
|
48
|
+
"scaffold",
|
|
49
|
+
"template",
|
|
50
|
+
"vue",
|
|
51
|
+
"react",
|
|
52
|
+
"node",
|
|
53
|
+
"uni-app",
|
|
54
|
+
"electron",
|
|
55
|
+
"project-generator",
|
|
56
|
+
"boilerplate",
|
|
57
|
+
"bun-first",
|
|
58
|
+
"package-manager-smart",
|
|
59
|
+
"cheny"
|
|
60
|
+
],
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=20.0.0"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/ChenyCHENYU/robot-cli#readme",
|
|
65
|
+
"repository": {
|
|
66
|
+
"type": "git",
|
|
67
|
+
"url": "git+https://github.com/ChenyCHENYU/robot-cli.git"
|
|
68
|
+
},
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/ChenyCHENYU/robot-cli/issues"
|
|
71
|
+
},
|
|
72
|
+
"author": "CHENY <ycyplus@gmail.com>",
|
|
73
|
+
"license": "MIT",
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/bin/index.js
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
4
|
-
import { dirname, join, resolve } from 'path';
|
|
5
|
-
import { existsSync } from 'fs';
|
|
6
|
-
import { readFileSync } from 'fs';
|
|
7
|
-
|
|
8
|
-
// 获取当前文件的目录
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = dirname(__filename);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 获取包版本号
|
|
14
|
-
*/
|
|
15
|
-
function getPackageVersion() {
|
|
16
|
-
try {
|
|
17
|
-
const possiblePaths = [
|
|
18
|
-
join(__dirname, '..', 'package.json'),
|
|
19
|
-
join(__dirname, 'package.json'),
|
|
20
|
-
join(__dirname, '..', '..', 'package.json')
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
for (const packagePath of possiblePaths) {
|
|
24
|
-
if (existsSync(packagePath)) {
|
|
25
|
-
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
26
|
-
return packageJson.version || '1.0.0';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return '1.0.0';
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return '1.0.0';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const PACKAGE_VERSION = getPackageVersion();
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 智能路径解析
|
|
40
|
-
*/
|
|
41
|
-
function resolveLibPath() {
|
|
42
|
-
const possiblePaths = [
|
|
43
|
-
join(__dirname, '..', 'lib'),
|
|
44
|
-
join(__dirname, 'lib'),
|
|
45
|
-
join(__dirname, '..', '..', 'lib'),
|
|
46
|
-
join(__dirname, '..', 'node_modules', '@agile-team', 'robot-cli', 'lib'),
|
|
47
|
-
resolve(__dirname, '..', 'lib'),
|
|
48
|
-
resolve(__dirname, '../../lib'),
|
|
49
|
-
join(__dirname, '..', '..', '@agile-team', 'robot-cli', 'lib'),
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
for (const libPath of possiblePaths) {
|
|
53
|
-
if (existsSync(libPath)) {
|
|
54
|
-
return libPath;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
throw new Error(`
|
|
59
|
-
无法找到 lib 目录,已尝试以下路径:
|
|
60
|
-
${possiblePaths.map(p => ` - ${p}`).join('\n')}
|
|
61
|
-
|
|
62
|
-
当前执行路径: ${__dirname}
|
|
63
|
-
工作目录: ${process.cwd()}
|
|
64
|
-
|
|
65
|
-
可能的解决方案:
|
|
66
|
-
1. 重新安装: npm uninstall -g @agile-team/robot-cli && npm install -g @agile-team/robot-cli
|
|
67
|
-
2. 使用 npx: npx @agile-team/robot-cli
|
|
68
|
-
3. 检查包完整性: npm list -g @agile-team/robot-cli
|
|
69
|
-
`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 动态导入所需模块 - 移除缓存相关模块
|
|
73
|
-
async function loadModules() {
|
|
74
|
-
try {
|
|
75
|
-
const libPath = resolveLibPath();
|
|
76
|
-
|
|
77
|
-
const createUrl = pathToFileURL(join(libPath, 'create.js')).href;
|
|
78
|
-
const templatesUrl = pathToFileURL(join(libPath, 'templates.js')).href;
|
|
79
|
-
const utilsUrl = pathToFileURL(join(libPath, 'utils.js')).href;
|
|
80
|
-
|
|
81
|
-
const [
|
|
82
|
-
{ Command },
|
|
83
|
-
chalk,
|
|
84
|
-
boxen,
|
|
85
|
-
inquirer,
|
|
86
|
-
{ createProject },
|
|
87
|
-
{ getAllTemplates, searchTemplates, getRecommendedTemplates },
|
|
88
|
-
{ checkNetworkConnection }
|
|
89
|
-
] = await Promise.all([
|
|
90
|
-
import('commander'),
|
|
91
|
-
import('chalk'),
|
|
92
|
-
import('boxen'),
|
|
93
|
-
import('inquirer'),
|
|
94
|
-
import(createUrl),
|
|
95
|
-
import(templatesUrl),
|
|
96
|
-
import(utilsUrl)
|
|
97
|
-
]);
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
Command,
|
|
101
|
-
chalk: chalk.default,
|
|
102
|
-
boxen: boxen.default,
|
|
103
|
-
inquirer: inquirer.default,
|
|
104
|
-
createProject,
|
|
105
|
-
getAllTemplates,
|
|
106
|
-
searchTemplates,
|
|
107
|
-
getRecommendedTemplates,
|
|
108
|
-
checkNetworkConnection
|
|
109
|
-
};
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.error(`
|
|
112
|
-
❌ 模块加载失败: ${error.message}
|
|
113
|
-
|
|
114
|
-
🔧 诊断信息:
|
|
115
|
-
当前文件: ${__filename}
|
|
116
|
-
执行目录: ${__dirname}
|
|
117
|
-
工作目录: ${process.cwd()}
|
|
118
|
-
Node版本: ${process.version}
|
|
119
|
-
|
|
120
|
-
💡 解决方案:
|
|
121
|
-
1. 完全重装: npm uninstall -g @agile-team/robot-cli && npm install -g @agile-team/robot-cli
|
|
122
|
-
2. 使用npx: npx @agile-team/robot-cli
|
|
123
|
-
3. 联系支持: https://github.com/ChenyCHENYU/robot-cli/issues
|
|
124
|
-
`);
|
|
125
|
-
process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// 主程序
|
|
130
|
-
async function main() {
|
|
131
|
-
try {
|
|
132
|
-
const modules = await loadModules();
|
|
133
|
-
const {
|
|
134
|
-
Command,
|
|
135
|
-
chalk,
|
|
136
|
-
boxen,
|
|
137
|
-
inquirer,
|
|
138
|
-
createProject,
|
|
139
|
-
getAllTemplates,
|
|
140
|
-
searchTemplates,
|
|
141
|
-
getRecommendedTemplates,
|
|
142
|
-
checkNetworkConnection
|
|
143
|
-
} = modules;
|
|
144
|
-
|
|
145
|
-
const program = new Command();
|
|
146
|
-
|
|
147
|
-
// 现代化欢迎信息
|
|
148
|
-
function showWelcome() {
|
|
149
|
-
console.clear();
|
|
150
|
-
|
|
151
|
-
const logoLines = [
|
|
152
|
-
' ██████╗ ██████╗ ██████╗ ██████╗ ████████╗',
|
|
153
|
-
' ██╔══██╗██╔═══██╗██╔══██╗██╔═══██╗╚══██╔══╝',
|
|
154
|
-
' ██████╔╝██║ ██║██████╔╝██║ ██║ ██║ ',
|
|
155
|
-
' ██╔══██╗██║ ██║██╔══██╗██║ ██║ ██║ ',
|
|
156
|
-
' ██║ ██║╚██████╔╝██████╔╝╚██████╔╝ ██║ ',
|
|
157
|
-
' ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ '
|
|
158
|
-
];
|
|
159
|
-
|
|
160
|
-
const logo = logoLines.map(line => chalk.cyan(line)).join('\n');
|
|
161
|
-
|
|
162
|
-
const titleBox = boxen(
|
|
163
|
-
logo + '\n\n' +
|
|
164
|
-
` 🤖 Robot 项目脚手架工具 v${PACKAGE_VERSION}\n` +
|
|
165
|
-
' 兼容 npm/yarn/pnpm/bun',
|
|
166
|
-
{
|
|
167
|
-
padding: { top: 1, bottom: 1, left: 2, right: 2 },
|
|
168
|
-
borderStyle: 'round',
|
|
169
|
-
borderColor: 'cyan',
|
|
170
|
-
backgroundColor: 'blackBright'
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
console.log();
|
|
175
|
-
console.log(titleBox);
|
|
176
|
-
console.log();
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// 显示主菜单 - 移除缓存信息
|
|
180
|
-
async function showMainMenu() {
|
|
181
|
-
const title = chalk.white.bold('🚀 快速开始');
|
|
182
|
-
|
|
183
|
-
console.log(' ' + title);
|
|
184
|
-
console.log();
|
|
185
|
-
|
|
186
|
-
const allTemplates = getAllTemplates();
|
|
187
|
-
const templateCount = Object.keys(allTemplates).length;
|
|
188
|
-
|
|
189
|
-
console.log(chalk.dim(` 📦 可用模板: ${templateCount} 个`));
|
|
190
|
-
console.log(chalk.dim(` 🌐 总是下载最新版本`));
|
|
191
|
-
console.log();
|
|
192
|
-
|
|
193
|
-
const commands = [
|
|
194
|
-
{
|
|
195
|
-
cmd: 'robot create',
|
|
196
|
-
desc: '交互式创建项目',
|
|
197
|
-
color: 'cyan'
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
cmd: 'robot create <name>',
|
|
201
|
-
desc: '快速创建项目',
|
|
202
|
-
color: 'green'
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
cmd: 'robot list',
|
|
206
|
-
desc: '查看所有可用模板',
|
|
207
|
-
color: 'blue'
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
cmd: 'robot search <keyword>',
|
|
211
|
-
desc: '搜索模板',
|
|
212
|
-
color: 'magenta'
|
|
213
|
-
}
|
|
214
|
-
];
|
|
215
|
-
|
|
216
|
-
commands.forEach(({ cmd, desc, color }) => {
|
|
217
|
-
console.log(' ' + chalk[color](cmd.padEnd(24)) + chalk.dim(desc));
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
console.log();
|
|
221
|
-
console.log(chalk.dim(' 示例:'));
|
|
222
|
-
console.log(chalk.dim(' robot create my-vue-admin'));
|
|
223
|
-
console.log(chalk.dim(' robot search vue'));
|
|
224
|
-
console.log(chalk.dim(' robot create my-app --template robot-admin'));
|
|
225
|
-
console.log();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
program
|
|
229
|
-
.name('robot')
|
|
230
|
-
.description('🤖 Robot 项目脚手架工具 - @agile-team/robot-cli')
|
|
231
|
-
.version(PACKAGE_VERSION)
|
|
232
|
-
.hook('preAction', () => {
|
|
233
|
-
showWelcome();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
// 创建项目命令 - 移除缓存相关选项
|
|
237
|
-
program
|
|
238
|
-
.command('create [project-name]')
|
|
239
|
-
.description('创建新项目')
|
|
240
|
-
.option('-t, --template <template>', '指定模板类型')
|
|
241
|
-
.option('--skip-install', '跳过依赖安装')
|
|
242
|
-
.action(async (projectName, options) => {
|
|
243
|
-
try {
|
|
244
|
-
// 检查网络连接
|
|
245
|
-
console.log(chalk.blue('🌐 检查网络连接...'));
|
|
246
|
-
const hasNetwork = await checkNetworkConnection();
|
|
247
|
-
if (!hasNetwork) {
|
|
248
|
-
console.log(chalk.red('❌ 网络连接失败,无法下载模板'));
|
|
249
|
-
console.log(chalk.yellow('💡 请检查网络连接后重试'));
|
|
250
|
-
process.exit(1);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
await createProject(projectName, options);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
console.log();
|
|
256
|
-
console.log(chalk.red('✗'), chalk.red.bold('创建失败'));
|
|
257
|
-
|
|
258
|
-
if (error.message.includes('网络')) {
|
|
259
|
-
console.log(' ' + chalk.dim('网络相关问题,请检查网络连接'));
|
|
260
|
-
} else if (error.message.includes('权限')) {
|
|
261
|
-
console.log(' ' + chalk.dim('权限问题,请检查文件夹权限'));
|
|
262
|
-
} else {
|
|
263
|
-
console.log(' ' + chalk.dim(error.message));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
console.log();
|
|
267
|
-
console.log(chalk.blue('💡 获取帮助:'));
|
|
268
|
-
console.log(chalk.dim(' robot --help'));
|
|
269
|
-
console.log(chalk.dim(' https://github.com/ChenyCHENYU/robot-cli/issues'));
|
|
270
|
-
console.log();
|
|
271
|
-
process.exit(1);
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
// 列出所有模板
|
|
276
|
-
program
|
|
277
|
-
.command('list')
|
|
278
|
-
.alias('ls')
|
|
279
|
-
.description('列出所有可用模板')
|
|
280
|
-
.option('-r, --recommended', '只显示推荐模板')
|
|
281
|
-
.option('-c, --category <category>', '按分类筛选')
|
|
282
|
-
.action(async (options) => {
|
|
283
|
-
try {
|
|
284
|
-
let templates;
|
|
285
|
-
let title;
|
|
286
|
-
|
|
287
|
-
if (options.recommended) {
|
|
288
|
-
templates = getRecommendedTemplates();
|
|
289
|
-
title = '🎯 推荐模板';
|
|
290
|
-
} else {
|
|
291
|
-
templates = getAllTemplates();
|
|
292
|
-
title = '📋 所有可用模板';
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
console.log();
|
|
296
|
-
console.log(chalk.blue(title));
|
|
297
|
-
console.log(chalk.dim(`共 ${Object.keys(templates).length} 个模板\n`));
|
|
298
|
-
|
|
299
|
-
// 按分类显示
|
|
300
|
-
const categories = {};
|
|
301
|
-
Object.entries(templates).forEach(([key, template]) => {
|
|
302
|
-
const category = key.split('-')[0];
|
|
303
|
-
if (!categories[category]) {
|
|
304
|
-
categories[category] = [];
|
|
305
|
-
}
|
|
306
|
-
categories[category].push({ key, ...template });
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
Object.entries(categories).forEach(([category, templates]) => {
|
|
310
|
-
console.log(chalk.cyan(`${category.toUpperCase()} 相关:`));
|
|
311
|
-
templates.forEach(template => {
|
|
312
|
-
console.log(` ${chalk.green('●')} ${chalk.bold(template.name)}`);
|
|
313
|
-
console.log(` ${chalk.dim(template.description)}`);
|
|
314
|
-
console.log(` ${chalk.dim('功能: ' + template.features.join(', '))}`);
|
|
315
|
-
console.log(` ${chalk.dim('使用: robot create my-app --template ' + template.key)}`);
|
|
316
|
-
console.log();
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
} catch (error) {
|
|
321
|
-
console.log(chalk.red('❌ 获取模板列表失败:'), error.message);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// 搜索模板
|
|
326
|
-
program
|
|
327
|
-
.command('search <keyword>')
|
|
328
|
-
.description('搜索模板')
|
|
329
|
-
.action(async (keyword) => {
|
|
330
|
-
try {
|
|
331
|
-
const results = searchTemplates(keyword);
|
|
332
|
-
|
|
333
|
-
console.log();
|
|
334
|
-
if (Object.keys(results).length === 0) {
|
|
335
|
-
console.log(chalk.yellow('🔍 没有找到匹配的模板'));
|
|
336
|
-
console.log();
|
|
337
|
-
console.log(chalk.blue('💡 建议:'));
|
|
338
|
-
console.log(chalk.dim(' • 尝试其他关键词'));
|
|
339
|
-
console.log(chalk.dim(' • 使用 robot list 查看所有模板'));
|
|
340
|
-
console.log(chalk.dim(' • 使用 robot list --recommended 查看推荐模板'));
|
|
341
|
-
} else {
|
|
342
|
-
console.log(chalk.green(`🔍 找到 ${Object.keys(results).length} 个匹配的模板:`));
|
|
343
|
-
console.log();
|
|
344
|
-
|
|
345
|
-
Object.entries(results).forEach(([key, template]) => {
|
|
346
|
-
console.log(`${chalk.green('●')} ${chalk.bold(template.name)}`);
|
|
347
|
-
console.log(` ${chalk.dim(template.description)}`);
|
|
348
|
-
console.log(` ${chalk.dim('功能: ' + template.features.join(', '))}`);
|
|
349
|
-
console.log(` ${chalk.cyan('robot create my-app --template ' + key)}`);
|
|
350
|
-
console.log();
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
} catch (error) {
|
|
354
|
-
console.log(chalk.red('❌ 搜索失败:'), error.message);
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// 如果没有参数,显示主菜单
|
|
359
|
-
if (process.argv.length === 2) {
|
|
360
|
-
showWelcome();
|
|
361
|
-
await showMainMenu();
|
|
362
|
-
process.exit(0);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// 全局错误处理
|
|
366
|
-
process.on('uncaughtException', (error) => {
|
|
367
|
-
console.log();
|
|
368
|
-
console.log(chalk.red('💥 程序发生未预期的错误:'));
|
|
369
|
-
console.log(chalk.dim(error.message));
|
|
370
|
-
console.log();
|
|
371
|
-
console.log(chalk.blue('💡 建议:'));
|
|
372
|
-
console.log(chalk.dim(' • 重启终端重试'));
|
|
373
|
-
console.log(chalk.dim(' • 检查网络连接'));
|
|
374
|
-
console.log(chalk.dim(' • 重新安装: npm install -g @agile-team/robot-cli'));
|
|
375
|
-
console.log(chalk.dim(' • 联系技术支持: https://github.com/ChenyCHENYU/robot-cli/issues'));
|
|
376
|
-
console.log();
|
|
377
|
-
process.exit(1);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
process.on('unhandledRejection', (error) => {
|
|
381
|
-
console.log();
|
|
382
|
-
console.log(chalk.red('💥 程序发生未处理的异步错误:'));
|
|
383
|
-
console.log(chalk.dim(error.message));
|
|
384
|
-
console.log();
|
|
385
|
-
process.exit(1);
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
program.parse();
|
|
389
|
-
|
|
390
|
-
} catch (error) {
|
|
391
|
-
console.error('启动失败:', error.message);
|
|
392
|
-
process.exit(1);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// 启动程序
|
|
397
|
-
main();
|