@vscode/test-web 0.0.41 → 0.0.42

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.
Files changed (2) hide show
  1. package/out/server/download.js +16 -32
  2. package/package.json +12 -11
@@ -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 download(downloadUrl, destination, message) {
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,26 +45,20 @@ async function download(downloadUrl, destination, message) {
45
45
  }
46
46
  process.stdout.write(`${reset}${message}: complete\n`);
47
47
  });
48
- res.on('error', reject);
49
- res.pipe(outStream);
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);
59
+ if (!info.url.endsWith('.tar.gz')) {
60
+ throw new Error(`Unexpected download URL: ${info.url}. Should end with .tar.gz`);
61
+ }
68
62
  const folderName = `vscode-web-${quality}-${info.version}`;
69
63
  const downloadedPath = path.resolve(vscodeTestDir, folderName);
70
64
  if ((0, fs_1.existsSync)(downloadedPath) && (0, fs_1.existsSync)(path.join(downloadedPath, 'version'))) {
@@ -75,24 +69,14 @@ async function downloadAndUnzipVSCode(quality, vscodeTestDir) {
75
69
  }
76
70
  await fs_1.promises.mkdir(vscodeTestDir, { recursive: true });
77
71
  const productName = `VS Code ${quality === 'stable' ? 'Stable' : 'Insiders'}`;
78
- const tmpArchiveName = path.join(vscodeTestDir, `vscode-web-${quality}-${info.version}-tmp`);
79
72
  try {
80
- await download(info.url, tmpArchiveName, `Downloading ${productName}`);
81
- await unzip(tmpArchiveName, downloadedPath, `Unpacking ${productName}`);
73
+ await downloadAndUntar(info.url, downloadedPath, `Downloading ${productName}`);
82
74
  await fs_1.promises.writeFile(path.join(downloadedPath, 'version'), folderName);
83
75
  }
84
76
  catch (err) {
85
77
  console.error(err);
86
78
  throw Error(`Failed to download and unpack ${productName}`);
87
79
  }
88
- finally {
89
- try {
90
- fs_1.promises.unlink(tmpArchiveName);
91
- }
92
- catch (e) {
93
- // ignore
94
- }
95
- }
96
80
  return { type: 'static', location: downloadedPath, quality, version: info.version };
97
81
  }
98
82
  exports.downloadAndUnzipVSCode = downloadAndUnzipVSCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vscode/test-web",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
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.1",
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.32.2",
33
+ "playwright": "^1.32.3",
34
34
  "vscode-uri": "^3.0.7",
35
35
  "http-proxy-agent": "^5.0.0",
36
36
  "https-proxy-agent": "^5.0.1",
37
- "decompress": "^4.2.1",
38
- "decompress-targz": "^4.1.1",
39
- "get-stream": "6.0.1"
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
- "@typescript-eslint/eslint-plugin": "^5.57.0",
50
- "@typescript-eslint/parser": "^5.57.0",
51
- "@types/decompress": "^4.2.4",
52
- "eslint": "^8.37.0",
49
+ "@types/gunzip-maybe": "^1.4.0",
50
+ "@types/tar-fs": "^2.0.1",
51
+ "@typescript-eslint/eslint-plugin": "^5.58.0",
52
+ "@typescript-eslint/parser": "^5.58.0",
53
+ "eslint": "^8.38.0",
53
54
  "eslint-plugin-header": "^3.1.1",
54
- "typescript": "^5.0.3"
55
+ "typescript": "^5.0.4"
55
56
  },
56
57
  "license": "MIT",
57
58
  "author": "Visual Studio Code Team",