build/lib/extensions.ts/fromGithub
export function fromGithub({ name, version, repo, metadata }: IBuiltInExtension): Stream {
	const remote = require('gulp-remote-retry-src');
	const json = require('gulp-json-editor') as typeof import('gulp-json-editor');

	fancyLog('Downloading extension from GH:', ansiColors.yellow(`${name}@${version}`), '...');

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

	return remote([`/repos${new URL(repo).pathname}/releases/tags/v${version}`], {
		base: 'https://api.github.com',
		requestOptions: { headers: ghApiHeaders }
	}).pipe(through2.obj(function (file, _enc, callback) {
		const asset = JSON.parse(file.contents.toString()).assets.find((a: any) => a.name.endsWith('.vsix'));
		if (!asset) {
			return callback(new Error(`Could not find vsix in release of ${repo} @ ${version}`));
		}

		const res = got.stream(asset.url, { headers: ghDownloadHeaders, followRedirect: true });
		file.contents = res.pipe(through2());
		callback(null, file);
	}))
		.pipe(buffer())
		.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);
}