ai-yuca 1.2.0 → 1.2.2
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 -4
- package/dist/package.json +1 -1
- package/dist/src/cache.js +2 -2
- package/dist/src/deploy.js +2 -1
- package/dist/src/types/upload.d.ts +4 -0
- package/dist/src/upload.js +6 -4
- package/dist/src/uploadWithConfig.js +4 -1
- package/out/ss/dd/index.js +2 -0
- package/out/ss/dd.js +1 -0
- package/package.json +1 -1
- package/src/cache.ts +2 -2
- package/src/deploy.ts +3 -1
- package/src/types/upload.ts +4 -0
- package/src/upload.ts +6 -4
- package/src/uploadWithConfig.ts +4 -2
package/.cdn.cache.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"lastUploadVersion": "mfhlsh6u",
|
|
3
|
-
"lastDeployTime": "2025-09-15T06:15:45.798Z",
|
|
4
|
-
"lastDeployVersion": "mfkqd0es",
|
|
5
|
-
"66ed0b08d69ac10597199f757081f73f": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/package.json",
|
|
6
2
|
"8d687e843e19199df437e245ee166123": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/about.html",
|
|
7
3
|
"f7c4edbaf98ece51425d5a7bc7d92d8f": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/index.html",
|
|
4
|
+
"55e8513f7e9e0a36434a1d5fa2613537": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/ss/dd/index.js",
|
|
5
|
+
"dc89e4b5e72eed0053323bbd39852234": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/ss/dd.js",
|
|
8
6
|
"d41d8cd98f00b204e9800998ecf8427e": "https://storage.googleapis.com/decom-cdn-test/fed/static/china2u/test.json"
|
|
9
7
|
}
|
package/dist/package.json
CHANGED
package/dist/src/cache.js
CHANGED
package/dist/src/deploy.js
CHANGED
|
@@ -196,7 +196,6 @@ async function updateEnvironmentConfig(env, projectName, versionInfo, config, ke
|
|
|
196
196
|
const { data: envConfig } = await getConfigFiles(env, config, keyFile);
|
|
197
197
|
// 查找或创建项目配置
|
|
198
198
|
let projectConfig = envConfig.projects.find((p) => p.name === projectName);
|
|
199
|
-
envConfig.lastVersion = versionInfo.cdnKey;
|
|
200
199
|
const newProjectConfig = {
|
|
201
200
|
baseUrl: versionInfo.baseUrl,
|
|
202
201
|
s3Static: config.upload.s3Static,
|
|
@@ -217,6 +216,8 @@ async function updateEnvironmentConfig(env, projectName, versionInfo, config, ke
|
|
|
217
216
|
return p;
|
|
218
217
|
});
|
|
219
218
|
}
|
|
219
|
+
envConfig.lastVersion = versionInfo.cdnKey;
|
|
220
|
+
envConfig.cdnVersion = versionInfo.cdnKey;
|
|
220
221
|
// 上传更新后的环境配置
|
|
221
222
|
const configPath = `${config.aws.prefix}/static/config/${env}.config.json`;
|
|
222
223
|
const tempFile = path.join(process.cwd(), `temp-${env}-config.json`);
|
package/dist/src/upload.js
CHANGED
|
@@ -207,7 +207,7 @@ async function uploadFile(options) {
|
|
|
207
207
|
*/
|
|
208
208
|
async function uploadFiles(options) {
|
|
209
209
|
// console.log(options);
|
|
210
|
-
const { bucketName, sourcePath, destination, storageClient, recursive = false, enableCompression = true } = options;
|
|
210
|
+
const { bucketName, sourcePath, destination, storageClient, recursive = false, enableCompression = true, uploadDir } = options;
|
|
211
211
|
if (!bucketName || !sourcePath || !storageClient) {
|
|
212
212
|
throw new Error('缺少必要的上传参数');
|
|
213
213
|
}
|
|
@@ -223,14 +223,15 @@ async function uploadFiles(options) {
|
|
|
223
223
|
const stats = await stat(filePath);
|
|
224
224
|
if (stats.isDirectory()) {
|
|
225
225
|
// 如果是目录,收集其中的文件
|
|
226
|
-
const
|
|
226
|
+
const basePath = uploadDir || filePath;
|
|
227
|
+
const dirFiles = await collectFiles(filePath, basePath, recursive);
|
|
227
228
|
results.files = results.files.concat(dirFiles);
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
const uploadPromises = sourcePath.map(filePath => uploadFile({
|
|
231
232
|
bucketName,
|
|
232
233
|
filePath,
|
|
233
|
-
destination: destination ? `${destination}
|
|
234
|
+
destination: destination ? `${destination}${filePath.replace(uploadDir || '', '')}` : undefined,
|
|
234
235
|
storageClient,
|
|
235
236
|
enableCompression
|
|
236
237
|
}));
|
|
@@ -265,7 +266,8 @@ async function uploadFiles(options) {
|
|
|
265
266
|
}
|
|
266
267
|
else if (stats.isDirectory()) {
|
|
267
268
|
// 收集目录下所有文件的相对路径
|
|
268
|
-
const
|
|
269
|
+
const basePath = uploadDir || sourcePath;
|
|
270
|
+
const allFiles = await collectFiles(sourcePath, basePath, recursive);
|
|
269
271
|
results.files = allFiles;
|
|
270
272
|
// 上传目录中的文件
|
|
271
273
|
const files = await readdir(sourcePath);
|
|
@@ -147,6 +147,7 @@ async function uploadFilesWithConfig(options = {}) {
|
|
|
147
147
|
if (enableCache && cacheManager) {
|
|
148
148
|
// 获取所有需要处理的文件
|
|
149
149
|
const allFiles = await getFilesToProcess(sourcePath, recursive);
|
|
150
|
+
console.log('allFiles', allFiles);
|
|
150
151
|
for (const filePath of allFiles) {
|
|
151
152
|
if (cacheManager.isFileUploaded(filePath)) {
|
|
152
153
|
const cachedUrl = cacheManager.getUploadedUrl(filePath);
|
|
@@ -190,13 +191,15 @@ async function uploadFilesWithConfig(options = {}) {
|
|
|
190
191
|
}
|
|
191
192
|
// 执行批量上传
|
|
192
193
|
const uploadSource = enableCache && filesToUpload.length > 0 ? filesToUpload : sourcePath;
|
|
194
|
+
console.log('uploadSource', uploadSource);
|
|
193
195
|
const result = await (0, upload_1.uploadFiles)({
|
|
194
196
|
bucketName,
|
|
195
197
|
sourcePath: uploadSource,
|
|
196
198
|
destination,
|
|
197
199
|
storageClient,
|
|
198
200
|
recursive,
|
|
199
|
-
enableCompression
|
|
201
|
+
enableCompression,
|
|
202
|
+
uploadDir: sourcePath
|
|
200
203
|
});
|
|
201
204
|
// 如果启用了缓存,记录上传成功的文件
|
|
202
205
|
if (enableCache && cacheManager) {
|
package/out/ss/dd/index.js
CHANGED
package/out/ss/dd.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a = 0;
|
package/package.json
CHANGED
package/src/cache.ts
CHANGED
|
@@ -34,8 +34,8 @@ export class CacheManager {
|
|
|
34
34
|
const content = fs.readFileSync(this.cacheFilePath, 'utf-8');
|
|
35
35
|
return JSON.parse(content);
|
|
36
36
|
}
|
|
37
|
-
} catch
|
|
38
|
-
console.warn(`警告: 无法读取缓存文件 ${this.cacheFilePath}
|
|
37
|
+
} catch {
|
|
38
|
+
console.warn(`警告: 无法读取缓存文件 ${this.cacheFilePath}:`);
|
|
39
39
|
}
|
|
40
40
|
return {};
|
|
41
41
|
}
|
package/src/deploy.ts
CHANGED
|
@@ -202,7 +202,7 @@ async function updateEnvironmentConfig(
|
|
|
202
202
|
|
|
203
203
|
// 查找或创建项目配置
|
|
204
204
|
let projectConfig = envConfig.projects.find((p: any) => p.name === projectName);
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
const newProjectConfig = {
|
|
207
207
|
baseUrl: versionInfo.baseUrl,
|
|
208
208
|
s3Static:config.upload.s3Static,
|
|
@@ -223,6 +223,8 @@ async function updateEnvironmentConfig(
|
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
envConfig.lastVersion = versionInfo.cdnKey;
|
|
227
|
+
envConfig.cdnVersion = versionInfo.cdnKey;
|
|
226
228
|
// 上传更新后的环境配置
|
|
227
229
|
const configPath = `${config.aws.prefix}/static/config/${env}.config.json`;
|
|
228
230
|
const tempFile = path.join(process.cwd(), `temp-${env}-config.json`);
|
package/src/types/upload.ts
CHANGED
package/src/upload.ts
CHANGED
|
@@ -198,7 +198,7 @@ async function uploadFiles(options: UploadFilesOptions): Promise<UploadFilesResu
|
|
|
198
198
|
|
|
199
199
|
// console.log(options);
|
|
200
200
|
|
|
201
|
-
const { bucketName, sourcePath, destination, storageClient, recursive = false, enableCompression = true } = options;
|
|
201
|
+
const { bucketName, sourcePath, destination, storageClient, recursive = false, enableCompression = true, uploadDir } = options;
|
|
202
202
|
|
|
203
203
|
if (!bucketName || !sourcePath || !storageClient) {
|
|
204
204
|
throw new Error('缺少必要的上传参数');
|
|
@@ -217,7 +217,8 @@ async function uploadFiles(options: UploadFilesOptions): Promise<UploadFilesResu
|
|
|
217
217
|
const stats = await stat(filePath);
|
|
218
218
|
if (stats.isDirectory()) {
|
|
219
219
|
// 如果是目录,收集其中的文件
|
|
220
|
-
const
|
|
220
|
+
const basePath = uploadDir || filePath;
|
|
221
|
+
const dirFiles = await collectFiles(filePath, basePath, recursive);
|
|
221
222
|
results.files = results.files!.concat(dirFiles);
|
|
222
223
|
}
|
|
223
224
|
}
|
|
@@ -226,7 +227,7 @@ async function uploadFiles(options: UploadFilesOptions): Promise<UploadFilesResu
|
|
|
226
227
|
uploadFile({
|
|
227
228
|
bucketName,
|
|
228
229
|
filePath,
|
|
229
|
-
destination: destination ? `${destination}
|
|
230
|
+
destination: destination ? `${destination}${filePath.replace(uploadDir || '', '')}` : undefined,
|
|
230
231
|
storageClient,
|
|
231
232
|
enableCompression
|
|
232
233
|
})
|
|
@@ -264,7 +265,8 @@ async function uploadFiles(options: UploadFilesOptions): Promise<UploadFilesResu
|
|
|
264
265
|
}
|
|
265
266
|
} else if (stats.isDirectory()) {
|
|
266
267
|
// 收集目录下所有文件的相对路径
|
|
267
|
-
const
|
|
268
|
+
const basePath = uploadDir || sourcePath;
|
|
269
|
+
const allFiles = await collectFiles(sourcePath, basePath, recursive);
|
|
268
270
|
results.files = allFiles;
|
|
269
271
|
|
|
270
272
|
// 上传目录中的文件
|
package/src/uploadWithConfig.ts
CHANGED
|
@@ -155,7 +155,7 @@ export async function uploadFilesWithConfig(options: UploadWithConfigOptions = {
|
|
|
155
155
|
if (enableCache && cacheManager) {
|
|
156
156
|
// 获取所有需要处理的文件
|
|
157
157
|
const allFiles = await getFilesToProcess(sourcePath, recursive);
|
|
158
|
-
|
|
158
|
+
console.log('allFiles', allFiles);
|
|
159
159
|
for (const filePath of allFiles) {
|
|
160
160
|
if (cacheManager.isFileUploaded(filePath)) {
|
|
161
161
|
const cachedUrl = cacheManager.getUploadedUrl(filePath);
|
|
@@ -202,13 +202,15 @@ export async function uploadFilesWithConfig(options: UploadWithConfigOptions = {
|
|
|
202
202
|
|
|
203
203
|
// 执行批量上传
|
|
204
204
|
const uploadSource = enableCache && filesToUpload.length > 0 ? filesToUpload : sourcePath;
|
|
205
|
+
console.log('uploadSource', uploadSource);
|
|
205
206
|
const result = await uploadFiles({
|
|
206
207
|
bucketName,
|
|
207
208
|
sourcePath: uploadSource,
|
|
208
209
|
destination,
|
|
209
210
|
storageClient,
|
|
210
211
|
recursive,
|
|
211
|
-
enableCompression
|
|
212
|
+
enableCompression,
|
|
213
|
+
uploadDir: sourcePath
|
|
212
214
|
});
|
|
213
215
|
|
|
214
216
|
// 如果启用了缓存,记录上传成功的文件
|