Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@
"yaml": "^2.8.1"
},
"devDependencies": {
"@open-cmsis-pack/vsce-helper": "^0.2.0",
"@open-cmsis-pack/vsce-helper": "^0.2.2",
"@types/extract-zip": "^2.0.1",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^30.0.0",
"@types/minimist": "^1.2.5",
Expand Down
30 changes: 28 additions & 2 deletions scripts/download-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import { PackageJson } from 'type-fest';
import fs from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
// Temporary solution until we have fixed vsce-helper
import extract from 'extract-zip';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

type CmsisPackageJson = PackageJson & {
cmsis: {
Expand All @@ -41,6 +48,15 @@ function splitGitReference(reference: string, owner: string, repo: string) {
return { repo, owner, reference };
}

// Temporary solution until we have fixed vsce-helper
class ExtractZipArchiveFileAsset extends ArchiveFileAsset {
protected async extractArchive(archiveFile: string, dest?: string): Promise<string> {
const effDest = dest ?? path.join(__dirname, 'tools', 'pyocd');
await extract(archiveFile, { dir: effDest });
return effDest;
}
}

const pyocd : Downloadable = new Downloadable(
'pyOCD', 'pyocd',
async (target) => {
Expand All @@ -64,11 +80,21 @@ const pyocd : Downloadable = new Downloadable(
owner, repo, reference,
`pyocd-${os}${arch}-${reference}.zip`,
{ token: process.env.GITHUB_TOKEN });
const asset = new ArchiveFileAsset(releaseAsset);
const asset = new ExtractZipArchiveFileAsset(releaseAsset);
return asset;
},
)

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


const pyocdNightly : Downloadable = new Downloadable(
'pyOCD', 'pyocd',
async (target) => {
Expand All @@ -89,7 +115,7 @@ const pyocdNightly : Downloadable = new Downloadable(
// Here, reference is expected to be the name of the workflow yaml file without file ending
const { repo, owner, reference } = splitGitReference(workflow, 'pyocd', 'pyOCD');
const assetPattern = (`pyocd-${os}${arch}-*`);
const asset = new GitHubWorkflowAsset(
const asset = new ExtractZipGitHubWorkflowAsset(
owner, repo, `${reference}.yaml`,
assetPattern,
{ token: process.env.GITHUB_TOKEN });
Expand Down
Loading