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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
package/dist/src/cache.js CHANGED
@@ -62,8 +62,8 @@ class CacheManager {
62
62
  return JSON.parse(content);
63
63
  }
64
64
  }
65
- catch (error) {
66
- console.warn(`警告: 无法读取缓存文件 ${this.cacheFilePath}:`, error);
65
+ catch (_a) {
66
+ console.warn(`警告: 无法读取缓存文件 ${this.cacheFilePath}:`);
67
67
  }
68
68
  return {};
69
69
  }
@@ -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`);
@@ -41,6 +41,10 @@ export interface UploadFilesOptions {
41
41
  * @default true
42
42
  */
43
43
  enableCompression?: boolean;
44
+ /**
45
+ * 源路径目录(用于收集文件列表时的基础路径)
46
+ */
47
+ uploadDir?: string;
44
48
  }
45
49
  /**
46
50
  * 上传成功结果接口
@@ -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 dirFiles = await collectFiles(filePath, filePath, recursive);
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}/${path.basename(filePath)}` : undefined,
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 allFiles = await collectFiles(sourcePath, sourcePath, recursive);
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) {
@@ -0,0 +1,2 @@
1
+ const a = 0;
2
+ const b = 1;
package/out/ss/dd.js CHANGED
@@ -0,0 +1 @@
1
+ const a = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-yuca",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "一个用AI生成的开发辅助工具",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
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 (error) {
38
- console.warn(`警告: 无法读取缓存文件 ${this.cacheFilePath}:`, error);
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
- envConfig.lastVersion = versionInfo.cdnKey;
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`);
@@ -44,6 +44,10 @@ export interface UploadFilesOptions {
44
44
  * @default true
45
45
  */
46
46
  enableCompression?: boolean;
47
+ /**
48
+ * 源路径目录(用于收集文件列表时的基础路径)
49
+ */
50
+ uploadDir?: string;
47
51
  }
48
52
 
49
53
  /**
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 dirFiles = await collectFiles(filePath, filePath, recursive);
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}/${path.basename(filePath)}` : undefined,
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 allFiles = await collectFiles(sourcePath, sourcePath, recursive);
268
+ const basePath = uploadDir || sourcePath;
269
+ const allFiles = await collectFiles(sourcePath, basePath, recursive);
268
270
  results.files = allFiles;
269
271
 
270
272
  // 上传目录中的文件
@@ -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
  // 如果启用了缓存,记录上传成功的文件