mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Package VS Code extensions (#16465)
* Package VS Code extensions * fixes * Add back in path * remove extra indents * Remove extra parens * try fix
This commit is contained in:
@@ -15,6 +15,8 @@ const task = require('./lib/task');
|
||||
const glob = require('glob');
|
||||
const vsce = require('vsce');
|
||||
const mkdirp = require('mkdirp');
|
||||
const rename = require('gulp-rename');
|
||||
const fs = require('fs');
|
||||
|
||||
gulp.task('fmt', () => formatStagedFiles());
|
||||
const formatFiles = (some) => {
|
||||
@@ -94,12 +96,14 @@ const root = path.dirname(__dirname);
|
||||
|
||||
gulp.task('package-external-extensions', task.series(
|
||||
task.define('bundle-external-extensions-build', () => ext.packageExternalExtensionsStream().pipe(gulp.dest('.build/external'))),
|
||||
task.define('create-external-extension-vsix-build', () => {
|
||||
task.define('create-external-extension-vsix-build', async () => {
|
||||
const vsixes = glob.sync('.build/external/extensions/*/package.json').map(manifestPath => {
|
||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||
const extensionName = path.basename(extensionPath);
|
||||
return { name: extensionName, path: extensionPath };
|
||||
}).map(element => {
|
||||
})
|
||||
.filter(element => ext.vscodeExternalExtensions.indexOf(element.name) === -1) // VS Code external extensions are bundled into ADS so no need to create a normal VSIX for them
|
||||
.map(element => {
|
||||
const pkgJson = require(path.join(element.path, 'package.json'));
|
||||
const vsixDirectory = path.join(root, '.build', 'extensions');
|
||||
mkdirp.sync(vsixDirectory);
|
||||
@@ -111,8 +115,46 @@ gulp.task('package-external-extensions', task.series(
|
||||
useYarn: true
|
||||
});
|
||||
});
|
||||
// Wait for all the initial VSIXes to be completed before making the VS Code ones since we'll be overwriting
|
||||
// values in the package.json for those.
|
||||
await Promise.all(vsixes);
|
||||
|
||||
return Promise.all(vsixes);
|
||||
// Go through and find the extensions which build separate versions of themselves for VS Code.
|
||||
// This is currently a pretty simplistic process, essentially just replacing certain values in
|
||||
// the package.json. It doesn't handle more complex tasks such as replacing localized strings.
|
||||
const vscodeVsixes = glob.sync('.build/external/extensions/*/package.vscode.json')
|
||||
.map(async vscodeManifestRelativePath => {
|
||||
const vscodeManifestFullPath = path.join(root, vscodeManifestRelativePath);
|
||||
const packageDir = path.dirname(vscodeManifestFullPath);
|
||||
const packageManifestPath = path.join(packageDir, 'package.json');
|
||||
const json = require('gulp-json-editor');
|
||||
const packageJsonStream = gulp.src(packageManifestPath) // Create stream for the original package.json
|
||||
.pipe(json(data => { // And now use gulp-json-editor to modify the contents
|
||||
const updateData = JSON.parse(fs.readFileSync(vscodeManifestFullPath)); // Read in the set of values to replace from package.vscode.json
|
||||
Object.keys(updateData).forEach(key => {
|
||||
data[key] = updateData[key];
|
||||
});
|
||||
// Remove ADS-only menus. This is a subset of the menus listed in https://github.com/microsoft/azuredatastudio/blob/main/src/vs/workbench/api/common/menusExtensionPoint.ts
|
||||
// More can be added to the list as needed.
|
||||
['objectExplorer/item/context', 'dataExplorer/context', 'dashboard/toolbar'].forEach(menu => {
|
||||
delete data.contributes.menus[menu];
|
||||
});
|
||||
return data;
|
||||
}, { beautify: false }))
|
||||
.pipe(gulp.dest(packageDir));
|
||||
await new Promise(resolve => packageJsonStream.on('finish', resolve)); // Wait for the files to finish being updated before packaging
|
||||
const pkgJson = JSON.parse(fs.readFileSync(packageManifestPath));
|
||||
const vsixDirectory = path.join(root, '.build', 'extensions');
|
||||
const packagePath = path.join(vsixDirectory, `${pkgJson.name}-${pkgJson.version}.vsix`);
|
||||
console.info('Creating vsix for ' + packageDir + ' result:' + packagePath);
|
||||
return vsce.createVSIX({
|
||||
cwd: packageDir,
|
||||
packagePath: packagePath,
|
||||
useYarn: true
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(vscodeVsixes);
|
||||
})
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user