mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
eng: cherry-pick 1.97.1 fixes (#240409)
This commit is contained in:
@@ -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';
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user