@cloudbase/manager-node 4.4.9-beta.0 → 4.5.0
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/utils/index.js +42 -0
- package/package.json +1 -1
- package/types/utils/index.d.ts +6 -0
package/lib/utils/index.js
CHANGED
|
@@ -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;
|
|
@@ -71,6 +72,40 @@ async function compressToZip(option) {
|
|
|
71
72
|
archive.finalize();
|
|
72
73
|
});
|
|
73
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* 检查是否应该跳过某个文件或文件夹
|
|
77
|
+
* @param {string} entryPath 文件路径
|
|
78
|
+
* @returns {boolean} 如果应该跳过则返回 true
|
|
79
|
+
*/
|
|
80
|
+
function shouldSkipEntry(entryPath) {
|
|
81
|
+
const normalizedPath = entryPath.replace(/\\/g, '/'); // 统一路径分隔符
|
|
82
|
+
// 过滤 macOS 系统文件和文件夹
|
|
83
|
+
const macOSPatterns = [
|
|
84
|
+
'__MACOSX', // macOS 资源文件夹
|
|
85
|
+
'.DS_Store', // macOS 文件夹设置文件
|
|
86
|
+
];
|
|
87
|
+
// 检查是否匹配任何需要跳过的模式
|
|
88
|
+
return macOSPatterns.some(pattern => {
|
|
89
|
+
// 检查路径是否以模式开头(用于文件夹)
|
|
90
|
+
if (normalizedPath.startsWith(pattern + '/') || normalizedPath === pattern) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
// 检查路径中是否包含这些模式(用于嵌套情况)
|
|
94
|
+
if (normalizedPath.includes('/' + pattern + '/') || normalizedPath.includes('/' + pattern)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
// 检查文件名是否匹配模式
|
|
98
|
+
const fileName = path_1.default.basename(normalizedPath);
|
|
99
|
+
if (fileName === pattern) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
// 检查以 ._ 开头的 macOS 资源文件
|
|
103
|
+
if (fileName.startsWith('._')) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
74
109
|
/**
|
|
75
110
|
* 下载并解压压缩包到指定目录
|
|
76
111
|
* @param {string} downloadUrl 压缩包下载地址
|
|
@@ -99,6 +134,13 @@ async function downloadAndExtractRemoteZip(downloadUrl, targetPath) {
|
|
|
99
134
|
.on('error', reject)
|
|
100
135
|
.on('entry', async (entry) => {
|
|
101
136
|
totalEntries++;
|
|
137
|
+
// 检查是否应该跳过这个条目
|
|
138
|
+
if (shouldSkipEntry(entry.path)) {
|
|
139
|
+
entry.autodrain(); // 丢弃数据流
|
|
140
|
+
processedEntries++;
|
|
141
|
+
checkCompletion();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
102
144
|
const filePath = path_1.default.join(dirPath, entry.path);
|
|
103
145
|
try {
|
|
104
146
|
// 确保父目录存在(处理嵌套目录情况)
|
package/package.json
CHANGED
package/types/utils/index.d.ts
CHANGED
|
@@ -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 压缩包下载地址
|