@cloudbase/manager-node 4.4.8 → 4.4.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.
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.getCompleteTimeRange = exports.formatTimeByMs = exports.formatTimeValue = exports.guid6 = void 0;
21
21
  exports.compressToZip = compressToZip;
22
+ exports.shouldSkipEntry = shouldSkipEntry;
22
23
  exports.downloadAndExtractRemoteZip = downloadAndExtractRemoteZip;
23
24
  exports.upload = upload;
24
25
  exports.getRuntime = getRuntime;
@@ -69,6 +70,40 @@ async function compressToZip(option) {
69
70
  archive.finalize();
70
71
  });
71
72
  }
73
+ /**
74
+ * 检查是否应该跳过某个文件或文件夹
75
+ * @param {string} entryPath 文件路径
76
+ * @returns {boolean} 如果应该跳过则返回 true
77
+ */
78
+ function shouldSkipEntry(entryPath) {
79
+ const normalizedPath = entryPath.replace(/\\/g, '/'); // 统一路径分隔符
80
+ // 过滤 macOS 系统文件和文件夹
81
+ const macOSPatterns = [
82
+ '__MACOSX', // macOS 资源文件夹
83
+ '.DS_Store', // macOS 文件夹设置文件
84
+ ];
85
+ // 检查是否匹配任何需要跳过的模式
86
+ return macOSPatterns.some(pattern => {
87
+ // 检查路径是否以模式开头(用于文件夹)
88
+ if (normalizedPath.startsWith(pattern + '/') || normalizedPath === pattern) {
89
+ return true;
90
+ }
91
+ // 检查路径中是否包含这些模式(用于嵌套情况)
92
+ if (normalizedPath.includes('/' + pattern + '/') || normalizedPath.includes('/' + pattern)) {
93
+ return true;
94
+ }
95
+ // 检查文件名是否匹配模式
96
+ const fileName = path_1.default.basename(normalizedPath);
97
+ if (fileName === pattern) {
98
+ return true;
99
+ }
100
+ // 检查以 ._ 开头的 macOS 资源文件
101
+ if (fileName.startsWith('._')) {
102
+ return true;
103
+ }
104
+ return false;
105
+ });
106
+ }
72
107
  /**
73
108
  * 下载并解压压缩包到指定目录
74
109
  * @param {string} downloadUrl 压缩包下载地址
@@ -97,6 +132,13 @@ async function downloadAndExtractRemoteZip(downloadUrl, targetPath) {
97
132
  .on('error', reject)
98
133
  .on('entry', async (entry) => {
99
134
  totalEntries++;
135
+ // 检查是否应该跳过这个条目
136
+ if (shouldSkipEntry(entry.path)) {
137
+ entry.autodrain(); // 丢弃数据流
138
+ processedEntries++;
139
+ checkCompletion();
140
+ return;
141
+ }
100
142
  const filePath = path_1.default.join(dirPath, entry.path);
101
143
  try {
102
144
  // 确保父目录存在(处理嵌套目录情况)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.4.8",
3
+ "version": "4.4.9",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -13,6 +13,12 @@ interface IZipOption {
13
13
  pattern?: string;
14
14
  }
15
15
  export declare function compressToZip(option: IZipOption): Promise<unknown>;
16
+ /**
17
+ * 检查是否应该跳过某个文件或文件夹
18
+ * @param {string} entryPath 文件路径
19
+ * @returns {boolean} 如果应该跳过则返回 true
20
+ */
21
+ export declare function shouldSkipEntry(entryPath: string): boolean;
16
22
  /**
17
23
  * 下载并解压压缩包到指定目录
18
24
  * @param {string} downloadUrl 压缩包下载地址