@@ -21,6 +21,13 @@ import { PackageJson } from 'type-fest';
2121import fs from 'node:fs/promises' ;
2222import path from 'node:path' ;
2323import 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
2532type 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+
4460const 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+
7298const 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