Skip to content

Commit

Permalink
embed [email protected] in sources, for patch tuesday (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno authored Feb 10, 2025
1 parent ebd0778 commit 499d3bd
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 8 deletions.
14 changes: 11 additions & 3 deletions build/lib/builtInExtensions.js

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

15 changes: 12 additions & 3 deletions build/lib/builtInExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface IExtensionDefinition {
sha256: string;
repo: string;
platforms?: string[];
vsix?: string;
metadata: {
id: string;
publisherId: {
Expand Down Expand Up @@ -68,9 +69,17 @@ function isUpToDate(extension: IExtensionDefinition): boolean {
}

function getExtensionDownloadStream(extension: IExtensionDefinition) {
const galleryServiceUrl = productjson.extensionsGallery?.serviceUrl;
return (galleryServiceUrl ? ext.fromMarketplace(galleryServiceUrl, extension) : ext.fromGithub(extension))
.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`));
let input: Stream;

if (extension.vsix) {
input = ext.fromVsix(path.join(root, extension.vsix), extension);
} else if (productjson.extensionsGallery?.serviceUrl) {
input = ext.fromMarketplace(productjson.extensionsGallery.serviceUrl, extension);
} else {
input = ext.fromGithub(extension);
}

return input.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`));
}

export function getExtensionStream(extension: IExtensionDefinition) {
Expand Down
25 changes: 25 additions & 0 deletions build/lib/extensions.js

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

28 changes: 28 additions & 0 deletions build/lib/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import cp from 'child_process';
import glob from 'glob';
import gulp from 'gulp';
import path from 'path';
import crypto from 'crypto';
import { Stream } from 'stream';
import File from 'vinyl';
import { createStatsStream } from './stats';
Expand Down Expand Up @@ -254,6 +255,33 @@ export function fromMarketplace(serviceUrl: string, { name: extensionName, versi
.pipe(packageJsonFilter.restore);
}

export function fromVsix(vsixPath: string, { name: extensionName, version, sha256, metadata }: IExtensionDefinition): Stream {
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');

fancyLog('Using local VSIX for extension:', ansiColors.yellow(`${extensionName}@${version}`), '...');

const packageJsonFilter = filter('package.json', { restore: true });

return gulp.src(vsixPath)
.pipe(buffer())
.pipe(es.mapSync((f: File) => {
const hash = crypto.createHash('sha256');
hash.update(f.contents as Buffer);
const checksum = hash.digest('hex');
if (checksum !== sha256) {
throw new Error(`Checksum mismatch for ${vsixPath} (expected ${sha256}, actual ${checksum}))`);
}
return f;
}))
.pipe(vzip.src())
.pipe(filter('extension/**'))
.pipe(rename(p => p.dirname = p.dirname!.replace(/^extension\/?/, '')))
.pipe(packageJsonFilter)
.pipe(buffer())
.pipe(json({ __metadata: metadata }))
.pipe(packageJsonFilter.restore);
}


export function fromGithub({ name, version, repo, sha256, metadata }: IExtensionDefinition): Stream {
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');
Expand Down
5 changes: 3 additions & 2 deletions product.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@
},
{
"name": "ms-vscode.js-debug",
"version": "1.97.0",
"sha256": "8442c0578c80976ef17031868fd6dcc42206be75b0ca1b0e9b5d6ff965cfdf23",
"version": "1.97.1",
"sha256": "977dd854805547702e312e176f68a1b142fa123f228258f47f0964560ad32496",
"repo": "https://github.com/microsoft/vscode-js-debug",
"vsix": "resources/common/ms-vscode.js-debug.1.97.1.universal.vsix",
"metadata": {
"id": "25629058-ddac-4e17-abba-74678e126c5d",
"publisherId": {
Expand Down
Binary file not shown.

0 comments on commit 499d3bd

Please sign in to comment.