Upgrade xml2js to v0.5.0 + migration to @vscode/vsce + migration to @azure/storage-blob (#22664)

This commit is contained in:
Cheena Malhotra
2023-04-11 15:13:43 -07:00
committed by GitHub
parent 577d99e790
commit 219bdabfb2
23 changed files with 1713 additions and 1376 deletions

View File

@@ -13,7 +13,7 @@ const ext = require('./lib/extensions');
const loc = require('./lib/locFunc');
const task = require('./lib/task');
const glob = require('glob');
const vsce = require('vsce');
const vsce = require('@vscode/vsce');
const mkdirp = require('mkdirp');
const rename = require('gulp-rename');
const fs = require('fs');
@@ -103,17 +103,22 @@ gulp.task('package-external-extensions', task.series(
return { name: extensionName, path: extensionPath };
})
.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);
const packagePath = path.join(vsixDirectory, `${pkgJson.name}-${pkgJson.version}.vsix`);
console.info('Creating vsix for ' + element.path + ' result:' + packagePath);
return vsce.createVSIX({
cwd: element.path,
packagePath: packagePath,
useYarn: true
});
.map(async element => {
try {
const pkgJson = require(path.join(element.path, 'package.json'));
const vsixDirectory = path.join(root, '.build', 'extensions');
mkdirp.sync(vsixDirectory);
const packagePath = path.join(vsixDirectory, `${pkgJson.name}-${pkgJson.version}.vsix`);
console.info(`Creating vsix for ${element.path}, result: ${packagePath}`);
return await vsce.createVSIX({
cwd: element.path,
packagePath: packagePath,
useYarn: false
});
} catch (e) {
console.error(`Failed to create vsix for ${element.path}, error occurred: ${e}`);
throw e;
}
});
// 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.
@@ -124,50 +129,54 @@ gulp.task('package-external-extensions', task.series(
// 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 => {
if (key !== 'contributes') {
data[key] = updateData[key];
try {
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 => {
if (key !== 'contributes') {
data[key] = updateData[key];
}
});
if (data.contributes?.menus) {
// 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];
});
}
});
if (data.contributes?.menus) {
// 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];
});
}
// Add any configuration properties from the package.vscode.json
// Currently only supports bringing over properties in the first config object found and doesn't support modifying the title
if (updateData.contributes?.configuration[0]?.properties) {
Object.keys(updateData.contributes.configuration[0].properties).forEach(key => {
data.contributes.configuration[0].properties[key] = updateData.contributes.configuration[0].properties[key];
});
}
// Add any configuration properties from the package.vscode.json
// Currently only supports bringing over properties in the first config object found and doesn't support modifying the title
if (updateData.contributes?.configuration[0]?.properties) {
Object.keys(updateData.contributes.configuration[0].properties).forEach(key => {
data.contributes.configuration[0].properties[key] = updateData.contributes.configuration[0].properties[key];
});
}
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 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 await vsce.createVSIX({
cwd: packageDir,
packagePath: packagePath,
useYarn: false
});
} catch (e) {
console.error(`Failed to create vsix for ${packageDir}, error occurred: ${e}`);
throw e;
}
});
return Promise.all(vscodeVsixes);
})
));
@@ -179,17 +188,22 @@ gulp.task('package-langpacks', task.series(
const extensionPath = path.dirname(path.join(root, manifestPath));
const extensionName = path.basename(extensionPath);
return { name: extensionName, path: extensionPath };
}).map(element => {
const pkgJson = require(path.join(element.path, 'package.json'));
const vsixDirectory = path.join(root, '.build', 'langpacks');
mkdirp.sync(vsixDirectory);
const packagePath = path.join(vsixDirectory, `${pkgJson.name}-${pkgJson.version}.vsix`);
console.info('Creating vsix for ' + element.path + ' result:' + packagePath);
return vsce.createVSIX({
cwd: element.path,
packagePath: packagePath,
useYarn: true
});
}).map(async element => {
try {
const pkgJson = require(path.join(element.path, 'package.json'));
const vsixDirectory = path.join(root, '.build', 'langpacks');
mkdirp.sync(vsixDirectory);
const packagePath = path.join(vsixDirectory, `${pkgJson.name}-${pkgJson.version}.vsix`);
console.info('Creating vsix for ' + element.path + ' result:' + packagePath);
return await vsce.createVSIX({
cwd: element.path,
packagePath: packagePath,
useYarn: false
});
} catch (e) {
console.error(`Failed to create vsix for ${element.path}, error occurred: ${e}`);
throw e;
}
});
return Promise.all(vsixes);