Skip to content

Commit

Permalink
unzip crx
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jul 5, 2024
1 parent 092f3c7 commit 5469d14
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"gradient-string": "2.0.2",
"progress": "2.0.3",
"tsup": "8.0.2",
"unzip-crx-3": "0.2.0",
"unzipper": "0.10.14",
"zod": "3.22.4"
},
Expand Down
43 changes: 22 additions & 21 deletions packages/cache/src/prepareExtension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// import download from 'download'
import download from 'download'
import unzipCrx from 'unzip-crx-3';
import { downloadFile, ensureCacheDirExists, unzipArchive } from '.'

interface ExtensionConfig {
Expand Down Expand Up @@ -42,24 +43,24 @@ export async function prepareExtension(extensionName: string) {
const cacheDirPath = ensureCacheDirExists()
const extensionConfig = await getExtensionConfig(extensionName) // Get config
let downloadResult
// if (extensionConfig.name === 'Phantom') {
// downloadResult = await download(extensionConfig.downloadUrl, cacheDirPath, {
// headers: {
// Accept: 'application/octet-stream',
// },
// });
// }
// else {
// }
downloadResult = await downloadFile({
url: extensionConfig.downloadUrl,
outputDir: cacheDirPath,
fileName: extensionName === 'Phantom' ? 'latest.crx' : `${extensionConfig.name.toLowerCase()}-chrome-${extensionConfig.version}.zip`
})
const unzipResult = await unzipArchive({
archivePath: downloadResult.filePath
})

return unzipResult.outputPath
if (extensionConfig.name === 'Phantom') {
downloadResult = await download(extensionConfig.downloadUrl, cacheDirPath, {
headers: {
Accept: 'application/octet-stream',
},
});

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The value assigned to downloadResult here is unused.
return unzipCrx('.cache-synpress/latest.zip', cacheDirPath)
}
else {
downloadResult = await downloadFile({
url: extensionConfig.downloadUrl,
outputDir: cacheDirPath,
fileName: `${extensionConfig.name.toLowerCase()}-chrome-${extensionConfig.version}.zip`
})
const unzipResult = await unzipArchive({
archivePath: downloadResult.filePath
})

return unzipResult.outputPath
}
}
1 change: 1 addition & 0 deletions packages/cache/src/unzip.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'unzip-crx-3';
38 changes: 38 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5469d14

Please sign in to comment.