Skip to content

Commit 4c7401f

Browse files
authored
Update node version from 20 to 22 (#899)
* Update node version from 20 to 24 * Updated download-tools script * Update file-type version
1 parent 98206a3 commit 4c7401f

3 files changed

Lines changed: 187 additions & 58 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"theme": "dark"
2020
},
2121
"engines": {
22-
"node": "^20.18.0",
22+
"node": "^22.22.0",
2323
"yarn": "^1.22.0",
2424
"vscode": "^1.108.1"
2525
},
@@ -479,7 +479,7 @@
479479
},
480480
"devDependencies": {
481481
"@eslint/js": "^10.0.1",
482-
"@open-cmsis-pack/vsce-helper": "^0.2.2",
482+
"@open-cmsis-pack/vsce-helper": "^0.3.0",
483483
"@types/extract-zip": "^2.0.3",
484484
"@types/fs-extra": "^11.0.4",
485485
"@types/jest": "^30.0.0",
@@ -499,7 +499,7 @@
499499
"eslint-plugin-security": "^4.0.0",
500500
"extract-zip": "^2.0.1",
501501
"fast-extract": "^1.14.2",
502-
"file-type": "^21.3.1",
502+
"file-type": "^21.3.2",
503503
"fs-extra": "^11.3.3",
504504
"glob": "^13.0.6",
505505
"globby": "^16.1.1",

scripts/download-tools.ts

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@
1818

1919
import { ArchiveFileAsset, Downloadable, Downloader, GitHubReleaseAsset, GitHubWorkflowAsset, WebFileAsset } from '@open-cmsis-pack/vsce-helper';
2020
import { PackageJson } from 'type-fest';
21+
import process from 'node:process';
2122
import fs from 'node:fs/promises';
2223
import path from 'node:path';
23-
import process from 'node:process';
24-
// Temporary solution until we have fixed vsce-helper
25-
import extract from 'extract-zip';
26-
import { fileURLToPath } from 'node:url';
27-
import { dirname } from 'node:path';
24+
import { execFile as execFileCallback } from 'node:child_process';
25+
import { promisify } from 'node:util';
2826

29-
const __filename = fileURLToPath(import.meta.url);
30-
const __dirname = dirname(__filename);
27+
const execFile = promisify(execFileCallback);
3128

3229
type CmsisPackageJson = PackageJson & {
3330
cmsis: {
@@ -48,15 +45,6 @@ function splitGitReference(reference: string, owner: string, repo: string) {
4845
return { repo, owner, reference };
4946
}
5047

51-
// Temporary solution until we have fixed vsce-helper
52-
class ExtractZipArchiveFileAsset extends ArchiveFileAsset {
53-
protected async extractArchive(archiveFile: string, dest?: string): Promise<string> {
54-
const effDest = dest ?? path.join(__dirname, 'tools', 'pyocd');
55-
await extract(archiveFile, { dir: effDest });
56-
return effDest;
57-
}
58-
}
59-
6048
const pyocd : Downloadable = new Downloadable(
6149
'pyOCD', 'pyocd',
6250
async (target) => {
@@ -80,20 +68,11 @@ const pyocd : Downloadable = new Downloadable(
8068
owner, repo, reference,
8169
`pyocd-${os}${arch}-${reference}.zip`,
8270
{ token: process.env.GITHUB_TOKEN });
83-
const asset = new ExtractZipArchiveFileAsset(releaseAsset);
71+
const asset = new ArchiveFileAsset(releaseAsset);
8472
return asset;
8573
},
8674
)
8775

88-
// Temporary solution until we have fixed vsce-helper
89-
class ExtractZipGitHubWorkflowAsset extends GitHubWorkflowAsset {
90-
protected async extractArchive(archiveFile: string, dest?: string): Promise<string> {
91-
const effDest = dest ?? path.join(__dirname, 'tools', 'pyocd');
92-
await extract(archiveFile, { dir: effDest });
93-
return effDest;
94-
}
95-
}
96-
9776

9877
const pyocdNightly : Downloadable = new Downloadable(
9978
'pyOCD', 'pyocd',
@@ -115,7 +94,7 @@ const pyocdNightly : Downloadable = new Downloadable(
11594
// Here, reference is expected to be the name of the workflow yaml file without file ending
11695
const { repo, owner, reference } = splitGitReference(workflow, 'pyocd', 'pyOCD');
11796
const assetPattern = (`pyocd-${os}${arch}-\\d+\\.\\d+\\.\\d+.*`);
118-
const asset = new ExtractZipGitHubWorkflowAsset(
97+
const asset = new GitHubWorkflowAsset(
11998
owner, repo, `${reference}.yaml`,
12099
assetPattern,
121100
{ token: process.env.GITHUB_TOKEN });
@@ -124,10 +103,32 @@ const pyocdNightly : Downloadable = new Downloadable(
124103
)
125104

126105
class GDBArchiveFileAsset extends ArchiveFileAsset {
106+
protected async extractArchive(archiveFile: string, dest?: string, options: { strip?: number; force?: boolean } = {}): Promise<string> {
107+
if (!archiveFile.toLowerCase().endsWith('.tar.xz')) {
108+
return super.extractArchive(archiveFile, dest, options);
109+
}
110+
111+
const effDest = await this.mkDest(dest);
112+
const strip = options.strip ?? this.strip;
113+
const args = ['-xJf', archiveFile, '-C', effDest];
114+
if (strip > 0) {
115+
args.push(`--strip-components=${strip}`);
116+
}
117+
118+
try {
119+
// Some GNU Arm tarballs include large numeric headers the JS tar parser rejects.
120+
await execFile('tar', args);
121+
return effDest;
122+
} catch {
123+
console.warn('System tar extraction failed, falling back to built-in archive extractor.');
124+
return super.extractArchive(archiveFile, effDest, options);
125+
}
126+
}
127+
127128
public async copyTo(dest?: string) {
128129
dest = await super.copyTo(dest);
129130
// Remove doc directory as it contains duplicate files (names differ only in case)
130-
// which are not supported by ZIP (VSIX) archives
131+
// which are not supported by ZIP (VSIX) archives.
131132
await fs.rm(path.join(dest, 'share', 'doc'), { recursive: true, force: true });
132133
return dest;
133134
}

0 commit comments

Comments
 (0)