Skip to content

Commit 7eb637b

Browse files
committed
Merge branch 'main' into deploy
2 parents b48f46e + 677e686 commit 7eb637b

File tree

21 files changed

+578
-53
lines changed

21 files changed

+578
-53
lines changed

CMSIS/postinstall.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装

STM32Tools/postinstall.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装

STM32_SVD/postinstall.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装

avrdude/postinstall.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装
@@ -205,12 +230,12 @@ async function extractArchives() {
205230
}, 3, 2000); // 最多重试3次,每次间隔2秒
206231
console.log(`已解压 ${fileName}${destDir}`);
207232

208-
// 解压成功后重命名文件夹(将@替换为_)
209-
try {
210-
await renameExtractedFolder(fileName, destDir);
211-
} catch (renameErr) {
212-
throw new Error(`重命名文件夹失败: ${renameErr.message}`);
213-
}
233+
// // 解压成功后重命名文件夹(将@替换为_)
234+
// try {
235+
// await renameExtractedFolder(fileName, destDir);
236+
// } catch (renameErr) {
237+
// throw new Error(`重命名文件夹失败: ${renameErr.message}`);
238+
// }
214239

215240
// 解压成功后可以删除压缩文件
216241
// fs.unlinkSync(zipFilePath);

bossac/postinstall.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,41 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833

934
// 确保 __dirname 有值,如果没有则使用当前工作目录
1035
const srcDir = __dirname || "";
1136
// 确保目标目录有值,空字符串会导致解压到当前目录
1237
const destDir = process.env.AILY_TOOLS_PATH || "";
1338
const _7zaPath = process.env.AILY_7ZA_PATH || "";
14-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
39+
const zipDownloadBaseUrl = getZipBaseUrl();
1540

1641

1742
// 重试函数封装
@@ -207,11 +232,11 @@ async function extractArchives() {
207232
console.log(`已解压 ${fileName}${destDir}`);
208233

209234
// 解压成功后重命名文件夹(将@替换为_)
210-
try {
211-
await renameExtractedFolder(fileName, destDir);
212-
} catch (renameErr) {
213-
throw new Error(`重命名文件夹失败: ${renameErr.message}`);
214-
}
235+
// try {
236+
// await renameExtractedFolder(fileName, destDir);
237+
// } catch (renameErr) {
238+
// throw new Error(`重命名文件夹失败: ${renameErr.message}`);
239+
// }
215240

216241
// 解压成功后可以删除压缩文件
217242
// fs.unlinkSync(zipFilePath);

ctags/postinstall.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装

dfu-util/postinstall.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装

esptool/postinstall.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ const fs = require('fs');
22
const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
5+
const os = require('os');
56

6-
// test
7+
// 获取当前操作系统类型
8+
function getOSType() {
9+
const platform = os.platform();
10+
let arch = os.arch();
11+
12+
// 根据arch判断是intel还是arm架构
13+
if (arch.startsWith('arm')) {
14+
arch = 'arm';
15+
} else {
16+
arch = 'intel';
17+
}
18+
19+
return {
20+
platform: platform,
21+
arch: arch,
22+
release: os.release(),
23+
version: os.version ? os.version() : 'N/A'
24+
};
25+
}
26+
27+
function getZipBaseUrl() {
28+
const osInfo = getOSType();
29+
const baseUrl = process.env.AILY_ZIP_URL || '';
30+
return `${baseUrl}/tools/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

833
// 确保 __dirname 有值,如果没有则使用当前工作目录
934
const srcDir = __dirname || "";
1035
// 确保目标目录有值,空字符串会导致解压到当前目录
1136
const destDir = process.env.AILY_TOOLS_PATH || "";
1237
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/tools';
38+
const zipDownloadBaseUrl = getZipBaseUrl();
1439

1540

1641
// 重试函数封装

0 commit comments

Comments
 (0)