@vscode/test-web
Advanced tools
Comparing version 0.0.41 to 0.0.42
@@ -15,4 +15,2 @@ "use strict"; | ||
const url_1 = require("url"); | ||
const decompress = require("decompress"); | ||
const decompressTargz = require("decompress-targz"); | ||
async function getLatestVersion(quality) { | ||
@@ -23,4 +21,9 @@ const update = await fetchJSON(`https://update.code.visualstudio.com/api/update/web-standalone/${quality}/latest`); | ||
const reset = '\x1b[G\x1b[0K'; | ||
async function download(downloadUrl, destination, message) { | ||
async function downloadAndUntar(downloadUrl, destination, message) { | ||
process.stdout.write(message); | ||
if (!(0, fs_1.existsSync)(destination)) { | ||
await fs_1.promises.mkdir(destination, { recursive: true }); | ||
} | ||
const tar = await Promise.resolve().then(() => require('tar-fs')); | ||
const gunzip = await Promise.resolve().then(() => require('gunzip-maybe')); | ||
return new Promise((resolve, reject) => { | ||
@@ -32,5 +35,2 @@ const httpLibrary = downloadUrl.startsWith('https') ? https : http; | ||
let timeout; | ||
const outStream = (0, fs_1.createWriteStream)(destination); | ||
outStream.on('close', () => resolve(destination)); | ||
outStream.on('error', reject); | ||
res.on('data', chunk => { | ||
@@ -51,22 +51,16 @@ if (!timeout) { | ||
}); | ||
res.on('error', reject); | ||
res.pipe(outStream); | ||
const extract = res.pipe(gunzip()).pipe(tar.extract(destination, { strip: 1 })); | ||
extract.on('finish', () => { | ||
process.stdout.write(`Extracted to ${destination}\n`); | ||
resolve(); | ||
}); | ||
extract.on('error', reject); | ||
}); | ||
}); | ||
} | ||
async function unzip(source, destination, message) { | ||
process.stdout.write(message); | ||
if (!(0, fs_1.existsSync)(destination)) { | ||
await fs_1.promises.mkdir(destination, { recursive: true }); | ||
} | ||
await decompress(source, destination, { | ||
plugins: [ | ||
decompressTargz() | ||
], | ||
strip: 1 | ||
}); | ||
process.stdout.write(`${reset}${message}: complete\n`); | ||
} | ||
async function downloadAndUnzipVSCode(quality, vscodeTestDir) { | ||
const info = await getLatestVersion(quality); | ||
if (!info.url.endsWith('.tar.gz')) { | ||
throw new Error(`Unexpected download URL: ${info.url}. Should end with .tar.gz`); | ||
} | ||
const folderName = `vscode-web-${quality}-${info.version}`; | ||
@@ -82,6 +76,4 @@ const downloadedPath = path.resolve(vscodeTestDir, folderName); | ||
const productName = `VS Code ${quality === 'stable' ? 'Stable' : 'Insiders'}`; | ||
const tmpArchiveName = path.join(vscodeTestDir, `vscode-web-${quality}-${info.version}-tmp`); | ||
try { | ||
await download(info.url, tmpArchiveName, `Downloading ${productName}`); | ||
await unzip(tmpArchiveName, downloadedPath, `Unpacking ${productName}`); | ||
await downloadAndUntar(info.url, downloadedPath, `Downloading ${productName}`); | ||
await fs_1.promises.writeFile(path.join(downloadedPath, 'version'), folderName); | ||
@@ -93,10 +85,2 @@ } | ||
} | ||
finally { | ||
try { | ||
fs_1.promises.unlink(tmpArchiveName); | ||
} | ||
catch (e) { | ||
// ignore | ||
} | ||
} | ||
return { type: 'static', location: downloadedPath, quality, version: info.version }; | ||
@@ -103,0 +87,0 @@ } |
{ | ||
"name": "@vscode/test-web", | ||
"version": "0.0.41", | ||
"version": "0.0.42", | ||
"scripts": { | ||
@@ -28,3 +28,3 @@ "install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample", | ||
"@koa/cors": "^4.0.0", | ||
"koa": "^2.14.1", | ||
"koa": "^2.14.2", | ||
"koa-morgan": "^1.0.1", | ||
@@ -34,9 +34,9 @@ "koa-mount": "^4.0.0", | ||
"minimist": "^1.2.8", | ||
"playwright": "^1.32.2", | ||
"playwright": "^1.32.3", | ||
"vscode-uri": "^3.0.7", | ||
"http-proxy-agent": "^5.0.0", | ||
"https-proxy-agent": "^5.0.1", | ||
"decompress": "^4.2.1", | ||
"decompress-targz": "^4.1.1", | ||
"get-stream": "6.0.1" | ||
"get-stream": "6.0.1", | ||
"tar-fs": "^2.1.1", | ||
"gunzip-maybe": "^1.4.2" | ||
}, | ||
@@ -51,8 +51,9 @@ "devDependencies": { | ||
"@types/node": "16.x", | ||
"@typescript-eslint/eslint-plugin": "^5.57.0", | ||
"@typescript-eslint/parser": "^5.57.0", | ||
"@types/decompress": "^4.2.4", | ||
"eslint": "^8.37.0", | ||
"@types/gunzip-maybe": "^1.4.0", | ||
"@types/tar-fs": "^2.0.1", | ||
"@typescript-eslint/eslint-plugin": "^5.58.0", | ||
"@typescript-eslint/parser": "^5.58.0", | ||
"eslint": "^8.38.0", | ||
"eslint-plugin-header": "^3.1.1", | ||
"typescript": "^5.0.3" | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -59,0 +60,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97011
14
1758
+ Addedgunzip-maybe@^1.4.2
+ Addedtar-fs@^2.1.1
+ Addedbl@4.1.0(transitive)
+ Addedbrowserify-zlib@0.1.4(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedduplexify@3.7.1(transitive)
+ Addedgunzip-maybe@1.4.2(transitive)
+ Addedis-deflate@1.0.0(transitive)
+ Addedis-gzip@1.0.0(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addedpako@0.2.9(transitive)
+ Addedpeek-stream@1.1.3(transitive)
+ Addedpump@2.0.13.0.2(transitive)
+ Addedpumpify@1.5.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedstream-shift@1.0.3(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedthrough2@2.0.5(transitive)
- Removeddecompress@^4.2.1
- Removeddecompress-targz@^4.1.1
- Removedbl@1.2.3(transitive)
- Removedbuffer-alloc@1.2.0(transitive)
- Removedbuffer-alloc-unsafe@1.1.0(transitive)
- Removedbuffer-crc32@0.2.13(transitive)
- Removedbuffer-fill@1.0.0(transitive)
- Removedcommander@2.20.3(transitive)
- Removeddecompress@4.2.1(transitive)
- Removeddecompress-tar@4.1.1(transitive)
- Removeddecompress-tarbz2@4.1.1(transitive)
- Removeddecompress-targz@4.1.1(transitive)
- Removeddecompress-unzip@4.0.1(transitive)
- Removedfd-slicer@1.1.0(transitive)
- Removedfile-type@3.9.05.2.06.2.0(transitive)
- Removedget-stream@2.3.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedis-natural-number@4.0.1(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpend@1.2.0(transitive)
- Removedpify@2.3.03.0.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedseek-bzip@1.0.6(transitive)
- Removedstrip-dirs@2.1.0(transitive)
- Removedtar-stream@1.6.2(transitive)
- Removedthrough@2.3.8(transitive)
- Removedto-buffer@1.1.1(transitive)
- Removedunbzip2-stream@1.4.3(transitive)
- Removedyauzl@2.10.0(transitive)
Updatedkoa@^2.14.2
Updatedplaywright@^1.32.3