@agile-team/robot-cli 1.0.8 → 1.0.9
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/lib/create.js +1 -1
- package/lib/download.js +23 -2
- package/package.json +1 -1
package/lib/create.js
CHANGED
|
@@ -652,7 +652,7 @@ async function confirmCreation(projectName, template, projectConfig) {
|
|
|
652
652
|
: chalk.dim("否")
|
|
653
653
|
}`
|
|
654
654
|
);
|
|
655
|
-
console.log(` 源码仓库: ${chalk.dim(template.
|
|
655
|
+
console.log(` 源码仓库: ${chalk.dim(template.repoUrl)}`);
|
|
656
656
|
console.log();
|
|
657
657
|
|
|
658
658
|
const { confirmed } = await inquirer.prompt([
|
package/lib/download.js
CHANGED
|
@@ -69,11 +69,15 @@ async function tryDownload(repoUrl, spinner) {
|
|
|
69
69
|
|
|
70
70
|
try {
|
|
71
71
|
if (spinner) {
|
|
72
|
-
spinner.text =
|
|
72
|
+
spinner.text = `🔍 连接到 ${sourceName}...`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const downloadUrl = buildDownloadUrl(currentUrl);
|
|
76
76
|
|
|
77
|
+
if (spinner) {
|
|
78
|
+
spinner.text = `📦 从 ${sourceName} 下载模板...`;
|
|
79
|
+
}
|
|
80
|
+
|
|
77
81
|
const response = await fetch(downloadUrl, {
|
|
78
82
|
timeout: isOriginal ? 15000 : 10000, // 官方源给更多时间
|
|
79
83
|
headers: {
|
|
@@ -169,9 +173,18 @@ export async function downloadTemplate(template, options = {}) {
|
|
|
169
173
|
|
|
170
174
|
// 下载远程模板
|
|
171
175
|
try {
|
|
176
|
+
if (spinner) {
|
|
177
|
+
spinner.text = '🌐 开始下载模板...';
|
|
178
|
+
}
|
|
179
|
+
|
|
172
180
|
// 尝试从不同源下载
|
|
173
181
|
const { response, sourceName } = await tryDownload(template.repoUrl, spinner);
|
|
174
182
|
|
|
183
|
+
// 显示下载完成,开始保存
|
|
184
|
+
if (spinner) {
|
|
185
|
+
spinner.text = '💾 保存下载文件...';
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
// 保存到临时文件
|
|
176
189
|
const tempZipPath = path.join(os.tmpdir(), cacheKey + '-' + Date.now() + '.zip');
|
|
177
190
|
const tempExtractPath = path.join(os.tmpdir(), cacheKey + '-extract-' + Date.now());
|
|
@@ -186,6 +199,10 @@ export async function downloadTemplate(template, options = {}) {
|
|
|
186
199
|
// 解压文件
|
|
187
200
|
await extract(tempZipPath, { dir: tempExtractPath });
|
|
188
201
|
|
|
202
|
+
if (spinner) {
|
|
203
|
+
spinner.text = '🔍 查找项目结构...';
|
|
204
|
+
}
|
|
205
|
+
|
|
189
206
|
// 查找项目目录
|
|
190
207
|
const extractedItems = await fs.readdir(tempExtractPath);
|
|
191
208
|
const projectDir = extractedItems.find(item =>
|
|
@@ -212,7 +229,7 @@ export async function downloadTemplate(template, options = {}) {
|
|
|
212
229
|
|
|
213
230
|
// 保存到缓存
|
|
214
231
|
if (spinner) {
|
|
215
|
-
spinner.text = '💾
|
|
232
|
+
spinner.text = '💾 保存到缓存目录...';
|
|
216
233
|
}
|
|
217
234
|
|
|
218
235
|
await fs.ensureDir(CACHE_DIR);
|
|
@@ -222,6 +239,10 @@ export async function downloadTemplate(template, options = {}) {
|
|
|
222
239
|
await fs.move(sourcePath, cachePath);
|
|
223
240
|
|
|
224
241
|
// 清理临时文件
|
|
242
|
+
if (spinner) {
|
|
243
|
+
spinner.text = '🧹 清理临时文件...';
|
|
244
|
+
}
|
|
245
|
+
|
|
225
246
|
await fs.remove(tempZipPath).catch(() => {});
|
|
226
247
|
await fs.remove(tempExtractPath).catch(() => {});
|
|
227
248
|
|