Skip to content

Commit 499d3bd

Browse files
authored
embed [email protected] in sources, for patch tuesday (#20)
1 parent ebd0778 commit 499d3bd

File tree

6 files changed

+79
-8
lines changed

6 files changed

+79
-8
lines changed

build/lib/builtInExtensions.js

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/builtInExtensions.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface IExtensionDefinition {
2121
sha256: string;
2222
repo: string;
2323
platforms?: string[];
24+
vsix?: string;
2425
metadata: {
2526
id: string;
2627
publisherId: {
@@ -68,9 +69,17 @@ function isUpToDate(extension: IExtensionDefinition): boolean {
6869
}
6970

7071
function getExtensionDownloadStream(extension: IExtensionDefinition) {
71-
const galleryServiceUrl = productjson.extensionsGallery?.serviceUrl;
72-
return (galleryServiceUrl ? ext.fromMarketplace(galleryServiceUrl, extension) : ext.fromGithub(extension))
73-
.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`));
72+
let input: Stream;
73+
74+
if (extension.vsix) {
75+
input = ext.fromVsix(path.join(root, extension.vsix), extension);
76+
} else if (productjson.extensionsGallery?.serviceUrl) {
77+
input = ext.fromMarketplace(productjson.extensionsGallery.serviceUrl, extension);
78+
} else {
79+
input = ext.fromGithub(extension);
80+
}
81+
82+
return input.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`));
7483
}
7584

7685
export function getExtensionStream(extension: IExtensionDefinition) {

build/lib/extensions.js

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/extensions.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import cp from 'child_process';
99
import glob from 'glob';
1010
import gulp from 'gulp';
1111
import path from 'path';
12+
import crypto from 'crypto';
1213
import { Stream } from 'stream';
1314
import File from 'vinyl';
1415
import { createStatsStream } from './stats';
@@ -254,6 +255,33 @@ export function fromMarketplace(serviceUrl: string, { name: extensionName, versi
254255
.pipe(packageJsonFilter.restore);
255256
}
256257

258+
export function fromVsix(vsixPath: string, { name: extensionName, version, sha256, metadata }: IExtensionDefinition): Stream {
259+
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');
260+
261+
fancyLog('Using local VSIX for extension:', ansiColors.yellow(`${extensionName}@${version}`), '...');
262+
263+
const packageJsonFilter = filter('package.json', { restore: true });
264+
265+
return gulp.src(vsixPath)
266+
.pipe(buffer())
267+
.pipe(es.mapSync((f: File) => {
268+
const hash = crypto.createHash('sha256');
269+
hash.update(f.contents as Buffer);
270+
const checksum = hash.digest('hex');
271+
if (checksum !== sha256) {
272+
throw new Error(`Checksum mismatch for ${vsixPath} (expected ${sha256}, actual ${checksum}))`);
273+
}
274+
return f;
275+
}))
276+
.pipe(vzip.src())
277+
.pipe(filter('extension/**'))
278+
.pipe(rename(p => p.dirname = p.dirname!.replace(/^extension\/?/, '')))
279+
.pipe(packageJsonFilter)
280+
.pipe(buffer())
281+
.pipe(json({ __metadata: metadata }))
282+
.pipe(packageJsonFilter.restore);
283+
}
284+
257285

258286
export function fromGithub({ name, version, repo, sha256, metadata }: IExtensionDefinition): Stream {
259287
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');

product.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
},
5151
{
5252
"name": "ms-vscode.js-debug",
53-
"version": "1.97.0",
54-
"sha256": "8442c0578c80976ef17031868fd6dcc42206be75b0ca1b0e9b5d6ff965cfdf23",
53+
"version": "1.97.1",
54+
"sha256": "977dd854805547702e312e176f68a1b142fa123f228258f47f0964560ad32496",
5555
"repo": "https://github.com/microsoft/vscode-js-debug",
56+
"vsix": "resources/common/ms-vscode.js-debug.1.97.1.universal.vsix",
5657
"metadata": {
5758
"id": "25629058-ddac-4e17-abba-74678e126c5d",
5859
"publisherId": {
Binary file not shown.

0 commit comments

Comments
 (0)