Skip to content

Commit 0caa1c4

Browse files
Fix: Extract gdb packages in tar.xz format (#699)
* Fix: Extract gdb packages in tar.xz format * use extract-zip to override vsce-helper extract for pyocd
1 parent 58e6b55 commit 0caa1c4

File tree

3 files changed

+231
-329
lines changed

3 files changed

+231
-329
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@
365365
"yaml": "^2.8.1"
366366
},
367367
"devDependencies": {
368-
"@open-cmsis-pack/vsce-helper": "^0.2.0",
368+
"@open-cmsis-pack/vsce-helper": "^0.2.2",
369+
"@types/extract-zip": "^2.0.1",
369370
"@types/fs-extra": "^11.0.4",
370371
"@types/jest": "^30.0.0",
371372
"@types/minimist": "^1.2.5",

scripts/download-tools.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ import { PackageJson } from 'type-fest';
2121
import fs from 'node:fs/promises';
2222
import path from 'node:path';
2323
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';
28+
29+
const __filename = fileURLToPath(import.meta.url);
30+
const __dirname = dirname(__filename);
2431

2532
type CmsisPackageJson = PackageJson & {
2633
cmsis: {
@@ -41,6 +48,15 @@ function splitGitReference(reference: string, owner: string, repo: string) {
4148
return { repo, owner, reference };
4249
}
4350

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+
4460
const pyocd : Downloadable = new Downloadable(
4561
'pyOCD', 'pyocd',
4662
async (target) => {
@@ -64,11 +80,21 @@ const pyocd : Downloadable = new Downloadable(
6480
owner, repo, reference,
6581
`pyocd-${os}${arch}-${reference}.zip`,
6682
{ token: process.env.GITHUB_TOKEN });
67-
const asset = new ArchiveFileAsset(releaseAsset);
83+
const asset = new ExtractZipArchiveFileAsset(releaseAsset);
6884
return asset;
6985
},
7086
)
7187

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+
97+
7298
const pyocdNightly : Downloadable = new Downloadable(
7399
'pyOCD', 'pyocd',
74100
async (target) => {
@@ -89,7 +115,7 @@ const pyocdNightly : Downloadable = new Downloadable(
89115
// Here, reference is expected to be the name of the workflow yaml file without file ending
90116
const { repo, owner, reference } = splitGitReference(workflow, 'pyocd', 'pyOCD');
91117
const assetPattern = (`pyocd-${os}${arch}-*`);
92-
const asset = new GitHubWorkflowAsset(
118+
const asset = new ExtractZipGitHubWorkflowAsset(
93119
owner, repo, `${reference}.yaml`,
94120
assetPattern,
95121
{ token: process.env.GITHUB_TOKEN });

0 commit comments

Comments
 (0)