Skip to content

Commit 3e0ff01

Browse files
committed
2 parents 3774a74 + 166eb98 commit 3e0ff01

File tree

8 files changed

+197
-38
lines changed

8 files changed

+197
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.7z

avr/postinstall.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +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}/sdk/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

8-
// test
933

1034
// 确保 __dirname 有值,如果没有则使用当前工作目录
1135
const srcDir = __dirname || "";
1236
// 确保目标目录有值,空字符串会导致解压到当前目录
1337
const destDir = process.env.AILY_SDK_PATH || "";
1438
const _7zaPath = process.env.AILY_7ZA_PATH || "";
15-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/sdk';
39+
const zipDownloadBaseUrl = getZipBaseUrl();
1640

1741

1842
// 重试函数封装
@@ -181,9 +205,6 @@ async function extractArchives() {
181205
const zipFilePath = path.join(__dirname, fileName);
182206
try {
183207
const stats = fs.statSync(zipFilePath);
184-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
185-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
186-
}
187208
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
188209
} catch (statErr) {
189210
if (statErr.code === 'ENOENT') {

ch55x/postinstall.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,41 @@ const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
55

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

835
// 确保 __dirname 有值,如果没有则使用当前工作目录
936
const srcDir = __dirname || "";
1037
// 确保目标目录有值,空字符串会导致解压到当前目录
1138
const destDir = process.env.AILY_SDK_PATH || "";
1239
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/sdk';
40+
const zipDownloadBaseUrl = getZipBaseUrl();
1441

1542

1643
// 重试函数封装
@@ -179,9 +206,6 @@ async function extractArchives() {
179206
const zipFilePath = path.join(__dirname, fileName);
180207
try {
181208
const stats = fs.statSync(zipFilePath);
182-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
183-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
184-
}
185209
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
186210
} catch (statErr) {
187211
if (statErr.code === 'ENOENT') {

esp32/postinstall.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,41 @@ const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
55

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

8-
// test
934

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

1742

1843
// 重试函数封装
@@ -181,9 +206,6 @@ async function extractArchives() {
181206
const zipFilePath = path.join(__dirname, fileName);
182207
try {
183208
const stats = fs.statSync(zipFilePath);
184-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
185-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
186-
}
187209
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
188210
} catch (statErr) {
189211
if (statErr.code === 'ENOENT') {

renesas_uno/postinstall.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +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}/sdk/${osInfo.platform}/${osInfo.arch}`;
31+
}
732

8-
// test
933

1034
// 确保 __dirname 有值,如果没有则使用当前工作目录
1135
const srcDir = __dirname || "";
1236
// 确保目标目录有值,空字符串会导致解压到当前目录
1337
const destDir = process.env.AILY_SDK_PATH || "";
1438
const _7zaPath = process.env.AILY_7ZA_PATH || "";
15-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/sdk';
39+
const zipDownloadBaseUrl = getZipBaseUrl();
1640

1741

1842
// 重试函数封装
@@ -181,9 +205,6 @@ async function extractArchives() {
181205
const zipFilePath = path.join(__dirname, fileName);
182206
try {
183207
const stats = fs.statSync(zipFilePath);
184-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
185-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
186-
}
187208
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
188209
} catch (statErr) {
189210
if (statErr.code === 'ENOENT') {

rp2040/postinstall.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +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');
6+
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}/sdk/${osInfo.platform}/${osInfo.arch}`;
31+
}
532

6-
// test
733

834
// 确保 __dirname 有值,如果没有则使用当前工作目录
935
const srcDir = __dirname || "";
1036
// 确保目标目录有值,空字符串会导致解压到当前目录
1137
const destDir = process.env.AILY_SDK_PATH || "";
1238
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/sdk';
39+
const zipDownloadBaseUrl = getZipBaseUrl();
1440

1541

1642
// 重试函数封装
@@ -179,9 +205,6 @@ async function extractArchives() {
179205
const zipFilePath = path.join(__dirname, fileName);
180206
try {
181207
const stats = fs.statSync(zipFilePath);
182-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
183-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
184-
}
185208
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
186209
} catch (statErr) {
187210
if (statErr.code === 'ENOENT') {

sam/postinstall.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,41 @@ const { spawn } = require('child_process');
33
const path = require('path');
44
const https = require('https');
55

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

835
// 确保 __dirname 有值,如果没有则使用当前工作目录
936
const srcDir = __dirname || "";
1037
// 确保目标目录有值,空字符串会导致解压到当前目录
1138
const destDir = process.env.AILY_SDK_PATH || "";
1239
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/sdk';
40+
const zipDownloadBaseUrl = getZipBaseUrl();
1441

1542

1643
// 重试函数封装
@@ -179,9 +206,6 @@ async function extractArchives() {
179206
const zipFilePath = path.join(__dirname, fileName);
180207
try {
181208
const stats = fs.statSync(zipFilePath);
182-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
183-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
184-
}
185209
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
186210
} catch (statErr) {
187211
if (statErr.code === 'ENOENT') {

stm32/postinstall.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +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');
6+
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}/sdk/${osInfo.platform}/${osInfo.arch}`;
31+
}
532

6-
// test
733

834
// 确保 __dirname 有值,如果没有则使用当前工作目录
935
const srcDir = __dirname || "";
1036
// 确保目标目录有值,空字符串会导致解压到当前目录
1137
const destDir = process.env.AILY_SDK_PATH || "";
1238
const _7zaPath = process.env.AILY_7ZA_PATH || "";
13-
const zipDownloadBaseUrl = process.env.AILY_ZIP_URL + '/sdk';
39+
const zipDownloadBaseUrl = getZipBaseUrl();
1440

1541

1642
// 重试函数封装
@@ -179,9 +205,6 @@ async function extractArchives() {
179205
const zipFilePath = path.join(__dirname, fileName);
180206
try {
181207
const stats = fs.statSync(zipFilePath);
182-
if (stats.size < 1048576) { // 1MB = 1024 * 1024 bytes
183-
throw new Error(`下载的文件异常小 (${stats.size} 字节),可能下载不完整或被截断`);
184-
}
185208
console.log(`文件大小: ${(stats.size / (1024 * 1024)).toFixed(2)}MB`);
186209
} catch (statErr) {
187210
if (statErr.code === 'ENOENT') {

0 commit comments

Comments
 (0)