@vscode/test-web 0.0.41 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/server/download.js +13 -32
- package/package.json +12 -11
package/out/server/download.js
CHANGED
|
@@ -12,24 +12,24 @@ const http = require("http");
|
|
|
12
12
|
const createHttpsProxyAgent = require("https-proxy-agent");
|
|
13
13
|
const createHttpProxyAgent = require("http-proxy-agent");
|
|
14
14
|
const url_1 = require("url");
|
|
15
|
-
const decompress = require("decompress");
|
|
16
|
-
const decompressTargz = require("decompress-targz");
|
|
17
15
|
async function getLatestVersion(quality) {
|
|
18
16
|
const update = await fetchJSON(`https://update.code.visualstudio.com/api/update/web-standalone/${quality}/latest`);
|
|
19
17
|
return update;
|
|
20
18
|
}
|
|
21
19
|
const reset = '\x1b[G\x1b[0K';
|
|
22
|
-
async function
|
|
20
|
+
async function downloadAndUntar(downloadUrl, destination, message) {
|
|
23
21
|
process.stdout.write(message);
|
|
22
|
+
if (!(0, fs_1.existsSync)(destination)) {
|
|
23
|
+
await fs_1.promises.mkdir(destination, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
const tar = await Promise.resolve().then(() => require('tar-fs'));
|
|
26
|
+
const gunzip = await Promise.resolve().then(() => require('gunzip-maybe'));
|
|
24
27
|
return new Promise((resolve, reject) => {
|
|
25
28
|
const httpLibrary = downloadUrl.startsWith('https') ? https : http;
|
|
26
29
|
httpLibrary.get(downloadUrl, getAgent(downloadUrl), res => {
|
|
27
30
|
const total = Number(res.headers['content-length']);
|
|
28
31
|
let received = 0;
|
|
29
32
|
let timeout;
|
|
30
|
-
const outStream = (0, fs_1.createWriteStream)(destination);
|
|
31
|
-
outStream.on('close', () => resolve(destination));
|
|
32
|
-
outStream.on('error', reject);
|
|
33
33
|
res.on('data', chunk => {
|
|
34
34
|
if (!timeout) {
|
|
35
35
|
timeout = setTimeout(() => {
|
|
@@ -45,24 +45,15 @@ async function download(downloadUrl, destination, message) {
|
|
|
45
45
|
}
|
|
46
46
|
process.stdout.write(`${reset}${message}: complete\n`);
|
|
47
47
|
});
|
|
48
|
-
res.
|
|
49
|
-
|
|
48
|
+
const extract = res.pipe(gunzip()).pipe(tar.extract(destination, { strip: 1 }));
|
|
49
|
+
extract.on('finish', () => {
|
|
50
|
+
process.stdout.write(`Extracted to ${destination}\n`);
|
|
51
|
+
resolve();
|
|
52
|
+
});
|
|
53
|
+
extract.on('error', reject);
|
|
50
54
|
});
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
|
-
async function unzip(source, destination, message) {
|
|
54
|
-
process.stdout.write(message);
|
|
55
|
-
if (!(0, fs_1.existsSync)(destination)) {
|
|
56
|
-
await fs_1.promises.mkdir(destination, { recursive: true });
|
|
57
|
-
}
|
|
58
|
-
await decompress(source, destination, {
|
|
59
|
-
plugins: [
|
|
60
|
-
decompressTargz()
|
|
61
|
-
],
|
|
62
|
-
strip: 1
|
|
63
|
-
});
|
|
64
|
-
process.stdout.write(`${reset}${message}: complete\n`);
|
|
65
|
-
}
|
|
66
57
|
async function downloadAndUnzipVSCode(quality, vscodeTestDir) {
|
|
67
58
|
const info = await getLatestVersion(quality);
|
|
68
59
|
const folderName = `vscode-web-${quality}-${info.version}`;
|
|
@@ -75,24 +66,14 @@ async function downloadAndUnzipVSCode(quality, vscodeTestDir) {
|
|
|
75
66
|
}
|
|
76
67
|
await fs_1.promises.mkdir(vscodeTestDir, { recursive: true });
|
|
77
68
|
const productName = `VS Code ${quality === 'stable' ? 'Stable' : 'Insiders'}`;
|
|
78
|
-
const tmpArchiveName = path.join(vscodeTestDir, `vscode-web-${quality}-${info.version}-tmp`);
|
|
79
69
|
try {
|
|
80
|
-
await
|
|
81
|
-
await unzip(tmpArchiveName, downloadedPath, `Unpacking ${productName}`);
|
|
70
|
+
await downloadAndUntar(info.url, downloadedPath, `Downloading ${productName}`);
|
|
82
71
|
await fs_1.promises.writeFile(path.join(downloadedPath, 'version'), folderName);
|
|
83
72
|
}
|
|
84
73
|
catch (err) {
|
|
85
74
|
console.error(err);
|
|
86
75
|
throw Error(`Failed to download and unpack ${productName}`);
|
|
87
76
|
}
|
|
88
|
-
finally {
|
|
89
|
-
try {
|
|
90
|
-
fs_1.promises.unlink(tmpArchiveName);
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
// ignore
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
77
|
return { type: 'static', location: downloadedPath, quality, version: info.version };
|
|
97
78
|
}
|
|
98
79
|
exports.downloadAndUnzipVSCode = downloadAndUnzipVSCode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vscode/test-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample",
|
|
6
6
|
"compile": "tsc -p ./ && yarn compile-fs-provider",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@koa/router": "^12.0.0",
|
|
27
27
|
"@koa/cors": "^4.0.0",
|
|
28
|
-
"koa": "^2.14.
|
|
28
|
+
"koa": "^2.14.2",
|
|
29
29
|
"koa-morgan": "^1.0.1",
|
|
30
30
|
"koa-mount": "^4.0.0",
|
|
31
31
|
"koa-static": "^5.0.0",
|
|
32
32
|
"minimist": "^1.2.8",
|
|
33
|
-
"playwright": "^1.
|
|
33
|
+
"playwright": "^1.33.0",
|
|
34
34
|
"vscode-uri": "^3.0.7",
|
|
35
35
|
"http-proxy-agent": "^5.0.0",
|
|
36
36
|
"https-proxy-agent": "^5.0.1",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
37
|
+
"get-stream": "6.0.1",
|
|
38
|
+
"tar-fs": "^2.1.1",
|
|
39
|
+
"gunzip-maybe": "^1.4.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/koa": "^2.13.6",
|
|
@@ -46,12 +46,13 @@
|
|
|
46
46
|
"@types/koa__router": "^12.0.0",
|
|
47
47
|
"@types/minimist": "^1.2.2",
|
|
48
48
|
"@types/node": "16.x",
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"eslint": "^
|
|
49
|
+
"@types/gunzip-maybe": "^1.4.0",
|
|
50
|
+
"@types/tar-fs": "^2.0.1",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
|
52
|
+
"@typescript-eslint/parser": "^5.59.1",
|
|
53
|
+
"eslint": "^8.39.0",
|
|
53
54
|
"eslint-plugin-header": "^3.1.1",
|
|
54
|
-
"typescript": "^5.0.
|
|
55
|
+
"typescript": "^5.0.4"
|
|
55
56
|
},
|
|
56
57
|
"license": "MIT",
|
|
57
58
|
"author": "Visual Studio Code Team",
|