ai-yuca 1.0.6 → 1.0.7
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/.cdn.cache.json +2 -2
- package/bin/cli.ts +1 -0
- package/dist/bin/cli.js +1 -0
- package/dist/package.json +1 -1
- package/dist/src/deploy.js +35 -91
- package/dist/src/types/deploy.d.ts +1 -0
- package/dist/src/upload.js +1 -1
- package/package.json +1 -1
- package/src/deploy.ts +40 -116
- package/src/types/deploy.ts +1 -0
- package/src/upload.ts +1 -1
package/.cdn.cache.json
CHANGED
package/bin/cli.ts
CHANGED
|
@@ -42,6 +42,7 @@ program
|
|
|
42
42
|
.option('--no-cache', '禁用文件缓存功能')
|
|
43
43
|
.option('--cache-file <path>', '指定缓存文件路径(默认为.cdn.cache.json)')
|
|
44
44
|
.option('--show-config', '仅显示配置信息,不执行部署')
|
|
45
|
+
.option('-f, --force', '强制执行,跳过交互式确认')
|
|
45
46
|
.action(async (options: DeployCommandOptions) => {
|
|
46
47
|
try {
|
|
47
48
|
const result = await deployFiles(options);
|
package/dist/bin/cli.js
CHANGED
|
@@ -71,6 +71,7 @@ program
|
|
|
71
71
|
.option('--no-cache', '禁用文件缓存功能')
|
|
72
72
|
.option('--cache-file <path>', '指定缓存文件路径(默认为.cdn.cache.json)')
|
|
73
73
|
.option('--show-config', '仅显示配置信息,不执行部署')
|
|
74
|
+
.option('-f, --force', '强制执行,跳过交互式确认')
|
|
74
75
|
.action(async (options) => {
|
|
75
76
|
try {
|
|
76
77
|
const result = await (0, deploy_1.deployFiles)(options);
|
package/dist/package.json
CHANGED
package/dist/src/deploy.js
CHANGED
|
@@ -119,22 +119,6 @@ function getBranchName() {
|
|
|
119
119
|
return 'main';
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
123
|
-
* 读取缓存文件中的版本号
|
|
124
|
-
*/
|
|
125
|
-
function getCachedVersion(cacheFile) {
|
|
126
|
-
const cacheFilePath = cacheFile || path.join(process.cwd(), '.cdn.cache.json');
|
|
127
|
-
if (!fs.existsSync(cacheFilePath)) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
try {
|
|
131
|
-
const cache = JSON.parse(fs.readFileSync(cacheFilePath, 'utf8'));
|
|
132
|
-
return cache.lastUploadVersion || null;
|
|
133
|
-
}
|
|
134
|
-
catch (_a) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
122
|
/**
|
|
139
123
|
* 筛选HTML文件
|
|
140
124
|
*/
|
|
@@ -185,46 +169,6 @@ async function uploadToGcp(filePath, bucketName, destination, keyFile) {
|
|
|
185
169
|
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
186
170
|
}
|
|
187
171
|
}
|
|
188
|
-
/**
|
|
189
|
-
* 上传版本配置文件
|
|
190
|
-
*/
|
|
191
|
-
async function uploadVersionConfig(versionInfo, bucketName, prefix, env, projectName, keyFile) {
|
|
192
|
-
try {
|
|
193
|
-
const configPath = `${prefix}/static/config/${env}/${projectName}/${versionInfo.cdnKey}.json`;
|
|
194
|
-
const tempFile = path.join(process.cwd(), `temp-${versionInfo.cdnKey}.json`);
|
|
195
|
-
// 写入临时文件
|
|
196
|
-
fs.writeFileSync(tempFile, JSON.stringify(versionInfo, null, 2));
|
|
197
|
-
// 上传到GCP
|
|
198
|
-
const result = await uploadToGcp(tempFile, bucketName, configPath, keyFile);
|
|
199
|
-
// 删除临时文件
|
|
200
|
-
fs.unlinkSync(tempFile);
|
|
201
|
-
return result.success;
|
|
202
|
-
}
|
|
203
|
-
catch (_a) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* 维护版本列表
|
|
209
|
-
*/
|
|
210
|
-
async function maintainVersionList(versions, bucketName, prefix, env, projectName, keyFile) {
|
|
211
|
-
try {
|
|
212
|
-
// 保留最近50个版本
|
|
213
|
-
const keepVersions = versions.slice(-50);
|
|
214
|
-
const versionKeepPath = `${prefix}/static/config/${env}/${projectName}/version.keep.json`;
|
|
215
|
-
const tempFile = path.join(process.cwd(), 'temp-version-keep.json');
|
|
216
|
-
// 写入临时文件
|
|
217
|
-
fs.writeFileSync(tempFile, JSON.stringify({ versions: keepVersions }, null, 2));
|
|
218
|
-
// 上传到GCP
|
|
219
|
-
const result = await uploadToGcp(tempFile, bucketName, versionKeepPath, keyFile);
|
|
220
|
-
// 删除临时文件
|
|
221
|
-
fs.unlinkSync(tempFile);
|
|
222
|
-
return result.success;
|
|
223
|
-
}
|
|
224
|
-
catch (_a) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
172
|
/**
|
|
229
173
|
* 更新环境配置
|
|
230
174
|
*/
|
|
@@ -261,24 +205,6 @@ async function updateEnvironmentConfig(env, projectName, versionInfo, config, ke
|
|
|
261
205
|
return false;
|
|
262
206
|
}
|
|
263
207
|
}
|
|
264
|
-
/**
|
|
265
|
-
* 写入缓存文件
|
|
266
|
-
*/
|
|
267
|
-
function writeCacheFile(cdnKey, cacheFile) {
|
|
268
|
-
const cacheFilePath = cacheFile || path.join(process.cwd(), '.cdn.cache.json');
|
|
269
|
-
let cache = {};
|
|
270
|
-
if (fs.existsSync(cacheFilePath)) {
|
|
271
|
-
try {
|
|
272
|
-
cache = JSON.parse(fs.readFileSync(cacheFilePath, 'utf8'));
|
|
273
|
-
}
|
|
274
|
-
catch (_a) {
|
|
275
|
-
cache = {};
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
cache.lastUploadVersion = cdnKey;
|
|
279
|
-
cache.lastDeployTime = new Date().toISOString();
|
|
280
|
-
fs.writeFileSync(cacheFilePath, JSON.stringify(cache, null, 2));
|
|
281
|
-
}
|
|
282
208
|
/**
|
|
283
209
|
* 执行deploy命令
|
|
284
210
|
*/
|
|
@@ -288,10 +214,23 @@ async function deployFiles(options) {
|
|
|
288
214
|
// 1. 配置校验阶段
|
|
289
215
|
console.log('📋 验证配置文件...');
|
|
290
216
|
const config = validateConfig(options.config);
|
|
291
|
-
// 2.
|
|
217
|
+
// 2. 执行upload-config阶段
|
|
218
|
+
console.log('📤 执行upload-config上传配置文件...');
|
|
219
|
+
try {
|
|
220
|
+
const uploadResult = await (0, uploadWithConfig_1.uploadFilesWithConfig)({
|
|
221
|
+
configPath: options.config,
|
|
222
|
+
storageClientOptions: options.keyFile ? { keyFilename: options.keyFile } : {},
|
|
223
|
+
enableCache: true
|
|
224
|
+
});
|
|
225
|
+
console.log(`✅ upload-config完成: 成功${uploadResult.success.length}个,失败${uploadResult.failed.length}个`);
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.warn(`⚠️ upload-config执行失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
229
|
+
}
|
|
230
|
+
// 3. 密钥与客户端初始化阶段
|
|
292
231
|
console.log('⚙️ 继承当前项目中GCP上传的配置...');
|
|
293
232
|
const uploadConfig = (0, uploadWithConfig_1.getConfigSummary)(options.config);
|
|
294
|
-
//
|
|
233
|
+
// 4. 版本与文件准备阶段
|
|
295
234
|
console.log('📦 确定发布版本号...');
|
|
296
235
|
const version = generateVersion();
|
|
297
236
|
const cdnKey = options.cdn ? ((0, cache_1.readLastUploadCacheFile)(options.cacheFile) || version) : version;
|
|
@@ -306,7 +245,7 @@ async function deployFiles(options) {
|
|
|
306
245
|
if (files.length === 0) {
|
|
307
246
|
throw new Error('未找到需要上传的HTML文件');
|
|
308
247
|
}
|
|
309
|
-
//
|
|
248
|
+
// 5. 文件处理与上传阶段
|
|
310
249
|
console.log('📤 上传原始HTML文件...');
|
|
311
250
|
const uploadedFiles = [];
|
|
312
251
|
for (const file of files) {
|
|
@@ -327,7 +266,7 @@ async function deployFiles(options) {
|
|
|
327
266
|
console.warn(` 警告: ${relativePath} 上传失败: ${result.error}`);
|
|
328
267
|
}
|
|
329
268
|
}
|
|
330
|
-
//
|
|
269
|
+
// 6. 发布配置文件上传阶段
|
|
331
270
|
console.log('📝 生成发布信息对象...');
|
|
332
271
|
const langCdnHtml = []; // 多语言HTML文件,暂时为空
|
|
333
272
|
const obj = {
|
|
@@ -391,22 +330,27 @@ async function deployFiles(options) {
|
|
|
391
330
|
fs.unlinkSync(tempVersionListFile);
|
|
392
331
|
}
|
|
393
332
|
}
|
|
394
|
-
//
|
|
333
|
+
// 7. 环境配置同步阶段
|
|
395
334
|
console.log('🔄 同步环境配置...');
|
|
396
335
|
// 检查项目是否存在
|
|
397
336
|
const { data: envConfig } = await getConfigFiles(options.env, config);
|
|
398
337
|
const existingProject = envConfig.projects.find((p) => p.name === projectInfo.name);
|
|
399
338
|
if (!existingProject) {
|
|
400
|
-
|
|
401
|
-
{
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
339
|
+
if (options.force) {
|
|
340
|
+
console.log(`🆕 自动创建项目 "${projectInfo.name}" 在环境 "${options.env}" 中...`);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
const { createProject } = await inquirer_1.default.prompt([
|
|
344
|
+
{
|
|
345
|
+
type: 'confirm',
|
|
346
|
+
name: 'createProject',
|
|
347
|
+
message: `项目 "${projectInfo.name}" 在环境 "${options.env}" 中不存在,是否创建新项目?`,
|
|
348
|
+
default: true
|
|
349
|
+
}
|
|
350
|
+
]);
|
|
351
|
+
if (!createProject) {
|
|
352
|
+
throw new Error('用户取消创建新项目,部署终止');
|
|
406
353
|
}
|
|
407
|
-
]);
|
|
408
|
-
if (!createProject) {
|
|
409
|
-
throw new Error('用户取消创建新项目,部署终止');
|
|
410
354
|
}
|
|
411
355
|
}
|
|
412
356
|
// 创建版本信息对象
|
|
@@ -419,7 +363,7 @@ async function deployFiles(options) {
|
|
|
419
363
|
files: obj.links
|
|
420
364
|
};
|
|
421
365
|
await updateEnvironmentConfig(options.env, projectInfo.name, versionInfo, config, options.keyFile);
|
|
422
|
-
//
|
|
366
|
+
// 8. 发布完成阶段
|
|
423
367
|
console.log('💾 记录发布版本...');
|
|
424
368
|
(0, cache_1.writeLastDeployVersion)(cdnKey);
|
|
425
369
|
console.log('📊 输出发布信息...');
|
|
@@ -428,11 +372,11 @@ async function deployFiles(options) {
|
|
|
428
372
|
console.log(`版本号:【${cdnKey}】`);
|
|
429
373
|
// 测试环境验证(非生产环境)
|
|
430
374
|
if (options.env !== 'production') {
|
|
431
|
-
const testHost = config.deploy.testHost || 'https://test.valleysound.xyz
|
|
375
|
+
const testHost = config.deploy.testHost || 'https://test.valleysound.xyz';
|
|
432
376
|
const baseUrls = Array.isArray(config.deploy.baseUrl) ? config.deploy.baseUrl : [config.deploy.baseUrl];
|
|
433
377
|
console.log('🔍 测试环境验证路径:');
|
|
434
378
|
baseUrls.forEach(baseUrl => {
|
|
435
|
-
const verificationUrl = `${testHost}
|
|
379
|
+
const verificationUrl = `${testHost}/${baseUrl}?deployCheck=${cdnKey}`;
|
|
436
380
|
console.log(` ${verificationUrl}`);
|
|
437
381
|
});
|
|
438
382
|
// 触发配置更新
|
package/dist/src/upload.js
CHANGED
|
@@ -164,7 +164,7 @@ async function uploadFile(options) {
|
|
|
164
164
|
* @returns 上传结果
|
|
165
165
|
*/
|
|
166
166
|
async function uploadFiles(options) {
|
|
167
|
-
console.log(options);
|
|
167
|
+
// console.log(options);
|
|
168
168
|
const { bucketName, sourcePath, destination, storageClient, recursive = false, enableCompression = true } = options;
|
|
169
169
|
if (!bucketName || !sourcePath || !storageClient) {
|
|
170
170
|
throw new Error('缺少必要的上传参数');
|
package/package.json
CHANGED
package/src/deploy.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as path from 'path';
|
|
|
7
7
|
import axios from 'axios';
|
|
8
8
|
import inquirer from 'inquirer';
|
|
9
9
|
import { createStorageClient, uploadFile } from './upload';
|
|
10
|
-
import { getConfigSummary } from './uploadWithConfig';
|
|
10
|
+
import { getConfigSummary, uploadFilesWithConfig } from './uploadWithConfig';
|
|
11
11
|
import { readLastUploadCacheFile, writeLastDeployVersion } from './cache';
|
|
12
12
|
import { execSync } from 'child_process';
|
|
13
13
|
import {
|
|
@@ -105,23 +105,7 @@ function getBranchName(): string {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
* 读取缓存文件中的版本号
|
|
110
|
-
*/
|
|
111
|
-
function getCachedVersion(cacheFile?: string): string | null {
|
|
112
|
-
const cacheFilePath = cacheFile || path.join(process.cwd(), '.cdn.cache.json');
|
|
113
|
-
|
|
114
|
-
if (!fs.existsSync(cacheFilePath)) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const cache = JSON.parse(fs.readFileSync(cacheFilePath, 'utf8'));
|
|
120
|
-
return cache.lastUploadVersion || null;
|
|
121
|
-
} catch {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
108
|
+
|
|
125
109
|
|
|
126
110
|
/**
|
|
127
111
|
* 筛选HTML文件
|
|
@@ -182,67 +166,9 @@ async function uploadToGcp(
|
|
|
182
166
|
}
|
|
183
167
|
}
|
|
184
168
|
|
|
185
|
-
/**
|
|
186
|
-
* 上传版本配置文件
|
|
187
|
-
*/
|
|
188
|
-
async function uploadVersionConfig(
|
|
189
|
-
versionInfo: DeployVersionInfo,
|
|
190
|
-
bucketName: string,
|
|
191
|
-
prefix: string,
|
|
192
|
-
env: string,
|
|
193
|
-
projectName: string,
|
|
194
|
-
keyFile?: string
|
|
195
|
-
): Promise<boolean> {
|
|
196
|
-
try {
|
|
197
|
-
const configPath = `${prefix}/static/config/${env}/${projectName}/${versionInfo.cdnKey}.json`;
|
|
198
|
-
const tempFile = path.join(process.cwd(), `temp-${versionInfo.cdnKey}.json`);
|
|
199
|
-
|
|
200
|
-
// 写入临时文件
|
|
201
|
-
fs.writeFileSync(tempFile, JSON.stringify(versionInfo, null, 2));
|
|
202
|
-
|
|
203
|
-
// 上传到GCP
|
|
204
|
-
const result = await uploadToGcp(tempFile, bucketName, configPath, keyFile);
|
|
205
|
-
|
|
206
|
-
// 删除临时文件
|
|
207
|
-
fs.unlinkSync(tempFile);
|
|
208
|
-
|
|
209
|
-
return result.success;
|
|
210
|
-
} catch {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
169
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
*/
|
|
218
|
-
async function maintainVersionList(
|
|
219
|
-
versions: DeployVersionInfo[],
|
|
220
|
-
bucketName: string,
|
|
221
|
-
prefix: string,
|
|
222
|
-
env: string,
|
|
223
|
-
projectName: string,
|
|
224
|
-
keyFile?: string
|
|
225
|
-
): Promise<boolean> {
|
|
226
|
-
try {
|
|
227
|
-
// 保留最近50个版本
|
|
228
|
-
const keepVersions = versions.slice(-50);
|
|
229
|
-
const versionKeepPath = `${prefix}/static/config/${env}/${projectName}/version.keep.json`;
|
|
230
|
-
const tempFile = path.join(process.cwd(), 'temp-version-keep.json');
|
|
231
|
-
|
|
232
|
-
// 写入临时文件
|
|
233
|
-
fs.writeFileSync(tempFile, JSON.stringify({ versions: keepVersions }, null, 2));
|
|
234
|
-
|
|
235
|
-
// 上传到GCP
|
|
236
|
-
const result = await uploadToGcp(tempFile, bucketName, versionKeepPath, keyFile);
|
|
237
|
-
|
|
238
|
-
// 删除临时文件
|
|
239
|
-
fs.unlinkSync(tempFile);
|
|
240
|
-
|
|
241
|
-
return result.success;
|
|
242
|
-
} catch {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
170
|
+
|
|
171
|
+
|
|
246
172
|
|
|
247
173
|
/**
|
|
248
174
|
* 更新环境配置
|
|
@@ -292,26 +218,7 @@ async function updateEnvironmentConfig(
|
|
|
292
218
|
}
|
|
293
219
|
}
|
|
294
220
|
|
|
295
|
-
|
|
296
|
-
* 写入缓存文件
|
|
297
|
-
*/
|
|
298
|
-
function writeCacheFile(cdnKey: string, cacheFile?: string): void {
|
|
299
|
-
const cacheFilePath = cacheFile || path.join(process.cwd(), '.cdn.cache.json');
|
|
300
|
-
|
|
301
|
-
let cache: any = {};
|
|
302
|
-
if (fs.existsSync(cacheFilePath)) {
|
|
303
|
-
try {
|
|
304
|
-
cache = JSON.parse(fs.readFileSync(cacheFilePath, 'utf8'));
|
|
305
|
-
} catch {
|
|
306
|
-
cache = {};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
cache.lastUploadVersion = cdnKey;
|
|
311
|
-
cache.lastDeployTime = new Date().toISOString();
|
|
312
|
-
|
|
313
|
-
fs.writeFileSync(cacheFilePath, JSON.stringify(cache, null, 2));
|
|
314
|
-
}
|
|
221
|
+
|
|
315
222
|
|
|
316
223
|
/**
|
|
317
224
|
* 执行deploy命令
|
|
@@ -324,11 +231,24 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
324
231
|
console.log('📋 验证配置文件...');
|
|
325
232
|
const config = validateConfig(options.config);
|
|
326
233
|
|
|
327
|
-
// 2.
|
|
234
|
+
// 2. 执行upload-config阶段
|
|
235
|
+
console.log('📤 执行upload-config上传配置文件...');
|
|
236
|
+
try {
|
|
237
|
+
const uploadResult = await uploadFilesWithConfig({
|
|
238
|
+
configPath: options.config,
|
|
239
|
+
storageClientOptions: options.keyFile ? { keyFilename: options.keyFile } : {},
|
|
240
|
+
enableCache: true
|
|
241
|
+
});
|
|
242
|
+
console.log(`✅ upload-config完成: 成功${uploadResult.success.length}个,失败${uploadResult.failed.length}个`);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.warn(`⚠️ upload-config执行失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// 3. 密钥与客户端初始化阶段
|
|
328
248
|
console.log('⚙️ 继承当前项目中GCP上传的配置...');
|
|
329
249
|
const uploadConfig = getConfigSummary(options.config);
|
|
330
250
|
|
|
331
|
-
//
|
|
251
|
+
// 4. 版本与文件准备阶段
|
|
332
252
|
console.log('📦 确定发布版本号...');
|
|
333
253
|
const version = generateVersion();
|
|
334
254
|
const cdnKey = options.cdn ? (readLastUploadCacheFile(options.cacheFile) || version) : version;
|
|
@@ -348,7 +268,7 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
348
268
|
throw new Error('未找到需要上传的HTML文件');
|
|
349
269
|
}
|
|
350
270
|
|
|
351
|
-
//
|
|
271
|
+
// 5. 文件处理与上传阶段
|
|
352
272
|
console.log('📤 上传原始HTML文件...');
|
|
353
273
|
const uploadedFiles: string[] = [];
|
|
354
274
|
|
|
@@ -372,7 +292,7 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
372
292
|
}
|
|
373
293
|
}
|
|
374
294
|
|
|
375
|
-
//
|
|
295
|
+
// 6. 发布配置文件上传阶段
|
|
376
296
|
console.log('📝 生成发布信息对象...');
|
|
377
297
|
const langCdnHtml: string[] = []; // 多语言HTML文件,暂时为空
|
|
378
298
|
const obj = {
|
|
@@ -441,7 +361,7 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
441
361
|
}
|
|
442
362
|
}
|
|
443
363
|
|
|
444
|
-
//
|
|
364
|
+
// 7. 环境配置同步阶段
|
|
445
365
|
console.log('🔄 同步环境配置...');
|
|
446
366
|
|
|
447
367
|
// 检查项目是否存在
|
|
@@ -449,17 +369,21 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
449
369
|
const existingProject = envConfig.projects.find((p: any) => p.name === projectInfo.name);
|
|
450
370
|
|
|
451
371
|
if (!existingProject) {
|
|
452
|
-
|
|
453
|
-
{
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
372
|
+
if (options.force) {
|
|
373
|
+
console.log(`🆕 自动创建项目 "${projectInfo.name}" 在环境 "${options.env}" 中...`);
|
|
374
|
+
} else {
|
|
375
|
+
const { createProject } = await inquirer.prompt([
|
|
376
|
+
{
|
|
377
|
+
type: 'confirm',
|
|
378
|
+
name: 'createProject',
|
|
379
|
+
message: `项目 "${projectInfo.name}" 在环境 "${options.env}" 中不存在,是否创建新项目?`,
|
|
380
|
+
default: true
|
|
381
|
+
}
|
|
382
|
+
]);
|
|
383
|
+
|
|
384
|
+
if (!createProject) {
|
|
385
|
+
throw new Error('用户取消创建新项目,部署终止');
|
|
458
386
|
}
|
|
459
|
-
]);
|
|
460
|
-
|
|
461
|
-
if (!createProject) {
|
|
462
|
-
throw new Error('用户取消创建新项目,部署终止');
|
|
463
387
|
}
|
|
464
388
|
}
|
|
465
389
|
|
|
@@ -475,7 +399,7 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
475
399
|
|
|
476
400
|
await updateEnvironmentConfig(options.env, projectInfo.name, versionInfo, config, options.keyFile);
|
|
477
401
|
|
|
478
|
-
//
|
|
402
|
+
// 8. 发布完成阶段
|
|
479
403
|
console.log('💾 记录发布版本...');
|
|
480
404
|
writeLastDeployVersion(cdnKey);
|
|
481
405
|
|
|
@@ -486,12 +410,12 @@ export async function deployFiles(options: DeployCommandOptions): Promise<Deploy
|
|
|
486
410
|
|
|
487
411
|
// 测试环境验证(非生产环境)
|
|
488
412
|
if (options.env !== 'production') {
|
|
489
|
-
const testHost = config.deploy.testHost || 'https://test.valleysound.xyz
|
|
413
|
+
const testHost = config.deploy.testHost || 'https://test.valleysound.xyz';
|
|
490
414
|
const baseUrls = Array.isArray(config.deploy.baseUrl) ? config.deploy.baseUrl : [config.deploy.baseUrl];
|
|
491
415
|
|
|
492
416
|
console.log('🔍 测试环境验证路径:');
|
|
493
417
|
baseUrls.forEach(baseUrl => {
|
|
494
|
-
const verificationUrl = `${testHost}
|
|
418
|
+
const verificationUrl = `${testHost}/${baseUrl}?deployCheck=${cdnKey}`;
|
|
495
419
|
console.log(` ${verificationUrl}`);
|
|
496
420
|
});
|
|
497
421
|
|
package/src/types/deploy.ts
CHANGED
package/src/upload.ts
CHANGED
|
@@ -153,7 +153,7 @@ async function uploadFile(options: UploadFileOptions): Promise<UploadResult> {
|
|
|
153
153
|
*/
|
|
154
154
|
async function uploadFiles(options: UploadFilesOptions): Promise<UploadFilesResult> {
|
|
155
155
|
|
|
156
|
-
console.log(options);
|
|
156
|
+
// console.log(options);
|
|
157
157
|
|
|
158
158
|
const { bucketName, sourcePath, destination, storageClient, recursive = false, enableCompression = true } = options;
|
|
159
159
|
|