mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3 # {{SQL CARBON EDIT}} update version
|
||||
inputs:
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -11,7 +11,7 @@ pr:
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: AzureKeyVault@1
|
||||
displayName: 'Azure Key Vault: Get Secrets'
|
||||
|
||||
@@ -11,7 +11,7 @@ pr:
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: AzureKeyVault@1
|
||||
displayName: 'Azure Key Vault: Get Secrets'
|
||||
|
||||
@@ -10,7 +10,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3
|
||||
inputs:
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -16,7 +16,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
condition: and(succeeded(), ne(variables['CacheExists-Compilation'], 'true'))
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
|
||||
@@ -9,7 +9,7 @@ pr: none
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -36,6 +36,18 @@ function updateDTSFile(outPath: string, tag: string) {
|
||||
fs.writeFileSync(outPath, newContent);
|
||||
}
|
||||
|
||||
function repeat(str: string, times: number): string {
|
||||
const result = new Array(times);
|
||||
for (let i = 0; i < times; i++) {
|
||||
result[i] = str;
|
||||
}
|
||||
return result.join('');
|
||||
}
|
||||
|
||||
function convertTabsToSpaces(str: string): string {
|
||||
return str.replace(/^\t+/gm, value => repeat(' ', value.length));
|
||||
}
|
||||
|
||||
function getNewFileContent(content: string, tag: string) {
|
||||
const oldheader = [
|
||||
`/*---------------------------------------------------------------------------------------------`,
|
||||
@@ -44,7 +56,7 @@ function getNewFileContent(content: string, tag: string) {
|
||||
` *--------------------------------------------------------------------------------------------*/`
|
||||
].join('\n');
|
||||
|
||||
return getNewFileHeader(tag) + content.slice(oldheader.length);
|
||||
return convertTabsToSpaces(getNewFileHeader(tag) + content.slice(oldheader.length));
|
||||
}
|
||||
|
||||
function getNewFileHeader(tag: string) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3 # {{SQL CARBON EDIT}} update version
|
||||
inputs:
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -21,7 +21,7 @@ steps:
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "12.14.1"
|
||||
versionSpec: "12.13.0"
|
||||
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
|
||||
@@ -171,8 +171,8 @@ gulp.task(compileExtensionsBuildLegacyTask);
|
||||
const cleanExtensionsBuildTask = task.define('clean-extensions-build', util.rimraf('.build/extensions'));
|
||||
const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series(
|
||||
cleanExtensionsBuildTask,
|
||||
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream().pipe(gulp.dest('.build'))),
|
||||
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream().pipe(gulp.dest('.build')))
|
||||
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream(false).pipe(gulp.dest('.build'))),
|
||||
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream(false).pipe(gulp.dest('.build'))),
|
||||
));
|
||||
|
||||
gulp.task(compileExtensionsBuildTask);
|
||||
|
||||
@@ -42,8 +42,8 @@ const indentationFilter = [
|
||||
'**',
|
||||
|
||||
// except specific files
|
||||
'!ThirdPartyNotices.txt',
|
||||
'!LICENSE.{txt,rtf}',
|
||||
'!**/ThirdPartyNotices.txt',
|
||||
'!**/LICENSE.{txt,rtf}',
|
||||
'!LICENSES.chromium.html',
|
||||
'!**/LICENSE',
|
||||
'!src/vs/nls.js',
|
||||
|
||||
@@ -100,7 +100,7 @@ function writeControlFile(control) {
|
||||
fs.writeFileSync(controlFilePath, JSON.stringify(control, null, 2));
|
||||
}
|
||||
|
||||
function main() {
|
||||
exports.getBuiltInExtensions = function getBuiltInExtensions() {
|
||||
log('Syncronizing built-in extensions...');
|
||||
log(`You can manage built-in extensions with the ${ansiColors.cyan('--builtin')} flag`);
|
||||
|
||||
@@ -116,14 +116,16 @@ function main() {
|
||||
|
||||
writeControlFile(control);
|
||||
|
||||
es.merge(streams)
|
||||
.on('error', err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
})
|
||||
.on('end', () => {
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
es.merge(streams)
|
||||
.on('error', reject)
|
||||
.on('end', resolve);
|
||||
});
|
||||
};
|
||||
|
||||
main();
|
||||
if (require.main === module) {
|
||||
exports.getBuiltInExtensions().then(() => process.exit(0)).catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.translatePackageJSON = exports.packageRebuildExtensionsStream = exports.cleanRebuildExtensions = exports.packageExternalExtensionsStream = exports.scanBuiltinExtensions = exports.packageMarketplaceWebExtensionsStream = exports.packageMarketplaceExtensionsStream = exports.packageLocalWebExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = void 0;
|
||||
exports.translatePackageJSON = exports.packageRebuildExtensionsStream = exports.cleanRebuildExtensions = exports.packageExternalExtensionsStream = exports.scanBuiltinExtensions = exports.packageMarketplaceExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = void 0;
|
||||
const es = require("event-stream");
|
||||
const fs = require("fs");
|
||||
const glob = require("glob");
|
||||
@@ -22,22 +22,28 @@ const fancyLog = require("fancy-log");
|
||||
const ansiColors = require("ansi-colors");
|
||||
const buffer = require('gulp-buffer');
|
||||
const json = require("gulp-json-editor");
|
||||
const jsoncParser = require("jsonc-parser");
|
||||
const webpack = require('webpack');
|
||||
const webpackGulp = require('webpack-stream');
|
||||
const util = require('./util');
|
||||
const root = path.dirname(path.dirname(__dirname));
|
||||
const commit = util.getVersion(root);
|
||||
const sourceMappingURLBase = `https://sqlopsbuilds.blob.core.windows.net/sourcemaps/${commit}`;
|
||||
function minimizeLanguageJSON(input) {
|
||||
const tmLanguageJsonFilter = filter('**/*.tmLanguage.json', { restore: true });
|
||||
function minifyExtensionResources(input) {
|
||||
const jsonFilter = filter(['**/*.json', '**/*.code-snippets'], { restore: true });
|
||||
return input
|
||||
.pipe(tmLanguageJsonFilter)
|
||||
.pipe(jsonFilter)
|
||||
.pipe(buffer())
|
||||
.pipe(es.mapSync((f) => {
|
||||
f.contents = Buffer.from(JSON.stringify(JSON.parse(f.contents.toString('utf8'))));
|
||||
const errors = [];
|
||||
const value = jsoncParser.parse(f.contents.toString('utf8'), errors);
|
||||
if (errors.length === 0) {
|
||||
// file parsed OK => just stringify to drop whitespace and comments
|
||||
f.contents = Buffer.from(JSON.stringify(value));
|
||||
}
|
||||
return f;
|
||||
}))
|
||||
.pipe(tmLanguageJsonFilter.restore);
|
||||
.pipe(jsonFilter.restore);
|
||||
}
|
||||
function updateExtensionPackageJSON(input, update) {
|
||||
const packageJsonFilter = filter('extensions/*/package.json', { restore: true });
|
||||
@@ -57,24 +63,18 @@ function fromLocal(extensionPath, forWeb) {
|
||||
let input = isWebPacked
|
||||
? fromLocalWebpack(extensionPath, webpackConfigFileName)
|
||||
: fromLocalNormal(extensionPath);
|
||||
if (forWeb) {
|
||||
input = updateExtensionPackageJSON(input, (data) => {
|
||||
if (data.browser) {
|
||||
data.main = data.browser;
|
||||
}
|
||||
data.extensionKind = ['web'];
|
||||
return data;
|
||||
});
|
||||
}
|
||||
else if (isWebPacked) {
|
||||
if (isWebPacked) {
|
||||
input = updateExtensionPackageJSON(input, (data) => {
|
||||
delete data.scripts;
|
||||
delete data.dependencies;
|
||||
delete data.devDependencies;
|
||||
if (data.main) {
|
||||
data.main = data.main.replace('/out/', /dist/);
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}
|
||||
return minimizeLanguageJSON(input);
|
||||
return input;
|
||||
}
|
||||
function fromLocalWebpack(extensionPath, webpackConfigFileName) {
|
||||
const result = es.through();
|
||||
@@ -194,7 +194,6 @@ function fromMarketplace(extensionName, version, metadata) {
|
||||
exports.fromMarketplace = fromMarketplace;
|
||||
const excludedExtensions = [
|
||||
'vscode-api-tests',
|
||||
'vscode-web-playground',
|
||||
'vscode-colorize-tests',
|
||||
'vscode-test-resolver',
|
||||
'ms-vscode.node-debug',
|
||||
@@ -230,98 +229,105 @@ const rebuildExtensions = [
|
||||
'big-data-cluster',
|
||||
'mssql'
|
||||
];
|
||||
const builtInExtensions = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
|
||||
function packageLocalExtensionsStream() {
|
||||
const localExtensionDescriptions = glob.sync('extensions/*/package.json')
|
||||
const marketplaceWebExtensions = [
|
||||
'ms-vscode.references-view'
|
||||
];
|
||||
const productJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8'));
|
||||
const builtInExtensions = productJson.builtInExtensions || [];
|
||||
const webBuiltInExtensions = productJson.webBuiltInExtensions || [];
|
||||
/**
|
||||
* Loosely based on `getExtensionKind` from `src/vs/workbench/services/extensions/common/extensionsUtil.ts`
|
||||
*/
|
||||
function isWebExtension(manifest) {
|
||||
if (typeof manifest.extensionKind !== 'undefined') {
|
||||
const extensionKind = Array.isArray(manifest.extensionKind) ? manifest.extensionKind : [manifest.extensionKind];
|
||||
return (extensionKind.indexOf('web') >= 0);
|
||||
}
|
||||
return (!Boolean(manifest.main) || Boolean(manifest.browser));
|
||||
}
|
||||
function packageLocalExtensionsStream(forWeb) {
|
||||
const localExtensionsDescriptions = (glob.sync('extensions/*/package.json')
|
||||
.map(manifestPath => {
|
||||
const absoluteManifestPath = path.join(root, manifestPath);
|
||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||
const extensionName = path.basename(extensionPath);
|
||||
return { name: extensionName, path: extensionPath };
|
||||
return { name: extensionName, path: extensionPath, manifestPath: absoluteManifestPath };
|
||||
})
|
||||
.filter(({ name }) => (name === 'vscode-web-playground' ? forWeb : true)) // package vscode-web-playground only for web
|
||||
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
|
||||
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
|
||||
.filter(({ name }) => externalExtensions.indexOf(name) === -1); // {{SQL CARBON EDIT}} Remove external Extensions with separate package
|
||||
const localExtensions = localExtensionDescriptions.map(extension => {
|
||||
return fromLocal(extension.path, false)
|
||||
.filter(({ name }) => externalExtensions.indexOf(name) === -1) // {{SQL CARBON EDIT}} Remove external Extensions with separate package
|
||||
);
|
||||
const localExtensionsStream = minifyExtensionResources(es.merge(...localExtensionsDescriptions.map(extension => {
|
||||
return fromLocal(extension.path, forWeb)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
});
|
||||
const nodeModules = gulp.src('extensions/node_modules/**', { base: '.' });
|
||||
return es.merge(nodeModules, ...localExtensions)
|
||||
.pipe(util2.setExecutableBit(['**/*.sh']));
|
||||
})));
|
||||
let result;
|
||||
if (forWeb) {
|
||||
result = localExtensionsStream;
|
||||
}
|
||||
else {
|
||||
// also include shared node modules
|
||||
result = es.merge(localExtensionsStream, gulp.src('extensions/node_modules/**', { base: '.' }));
|
||||
}
|
||||
return (result
|
||||
.pipe(util2.setExecutableBit(['**/*.sh'])));
|
||||
}
|
||||
exports.packageLocalExtensionsStream = packageLocalExtensionsStream;
|
||||
function packageLocalWebExtensionsStream() {
|
||||
const localExtensionDescriptions = glob.sync('extensions/*/package.json')
|
||||
.filter(manifestPath => {
|
||||
const packageJsonConfig = require(path.join(root, manifestPath));
|
||||
return !packageJsonConfig.main || packageJsonConfig.browser;
|
||||
})
|
||||
.map(manifestPath => {
|
||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||
const extensionName = path.basename(extensionPath);
|
||||
return { name: extensionName, path: extensionPath };
|
||||
});
|
||||
return es.merge(...localExtensionDescriptions.map(extension => {
|
||||
return fromLocal(extension.path, true)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
}));
|
||||
}
|
||||
exports.packageLocalWebExtensionsStream = packageLocalWebExtensionsStream;
|
||||
function packageMarketplaceExtensionsStream() {
|
||||
const extensions = builtInExtensions.map(extension => {
|
||||
return fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
});
|
||||
return es.merge(extensions)
|
||||
.pipe(util2.setExecutableBit(['**/*.sh']));
|
||||
}
|
||||
exports.packageMarketplaceExtensionsStream = packageMarketplaceExtensionsStream;
|
||||
function packageMarketplaceWebExtensionsStream(builtInExtensions) {
|
||||
const extensions = builtInExtensions
|
||||
function packageMarketplaceExtensionsStream(forWeb) {
|
||||
const marketplaceExtensionsDescriptions = [
|
||||
...builtInExtensions.filter(({ name }) => (forWeb ? marketplaceWebExtensions.indexOf(name) >= 0 : true)),
|
||||
...(forWeb ? webBuiltInExtensions : [])
|
||||
];
|
||||
const marketplaceExtensionsStream = minifyExtensionResources(es.merge(...marketplaceExtensionsDescriptions
|
||||
.map(extension => {
|
||||
const input = fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
return updateExtensionPackageJSON(input, (data) => {
|
||||
if (data.main) {
|
||||
data.browser = data.main;
|
||||
}
|
||||
data.extensionKind = ['web'];
|
||||
delete data.scripts;
|
||||
delete data.dependencies;
|
||||
delete data.devDependencies;
|
||||
return data;
|
||||
});
|
||||
});
|
||||
return es.merge(extensions);
|
||||
})));
|
||||
return (marketplaceExtensionsStream
|
||||
.pipe(util2.setExecutableBit(['**/*.sh'])));
|
||||
}
|
||||
exports.packageMarketplaceWebExtensionsStream = packageMarketplaceWebExtensionsStream;
|
||||
function scanBuiltinExtensions(extensionsRoot, forWeb) {
|
||||
exports.packageMarketplaceExtensionsStream = packageMarketplaceExtensionsStream;
|
||||
function scanBuiltinExtensions(extensionsRoot, exclude = []) {
|
||||
const scannedExtensions = [];
|
||||
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
||||
for (const extensionFolder of extensionsFolders) {
|
||||
const packageJSONPath = path.join(extensionsRoot, extensionFolder, 'package.json');
|
||||
if (!fs.existsSync(packageJSONPath)) {
|
||||
continue;
|
||||
try {
|
||||
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
||||
for (const extensionFolder of extensionsFolders) {
|
||||
if (exclude.indexOf(extensionFolder) >= 0) {
|
||||
continue;
|
||||
}
|
||||
const packageJSONPath = path.join(extensionsRoot, extensionFolder, 'package.json');
|
||||
if (!fs.existsSync(packageJSONPath)) {
|
||||
continue;
|
||||
}
|
||||
let packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8'));
|
||||
if (!isWebExtension(packageJSON)) {
|
||||
continue;
|
||||
}
|
||||
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||
const packageNLSPath = children.filter(child => child === 'package.nls.json')[0];
|
||||
const packageNLS = packageNLSPath ? JSON.parse(fs.readFileSync(path.join(extensionsRoot, extensionFolder, packageNLSPath)).toString()) : undefined;
|
||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
|
||||
scannedExtensions.push({
|
||||
extensionPath: extensionFolder,
|
||||
packageJSON,
|
||||
packageNLS,
|
||||
readmePath: readme ? path.join(extensionFolder, readme) : undefined,
|
||||
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined,
|
||||
});
|
||||
}
|
||||
let packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8'));
|
||||
const extensionKind = packageJSON['extensionKind'] || [];
|
||||
if (forWeb && extensionKind.indexOf('web') === -1) {
|
||||
continue;
|
||||
}
|
||||
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
|
||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
|
||||
if (packageNLS) {
|
||||
// temporary
|
||||
packageJSON = translatePackageJSON(packageJSON, path.join(extensionsRoot, extensionFolder, packageNLS));
|
||||
}
|
||||
scannedExtensions.push({
|
||||
extensionPath: extensionFolder,
|
||||
packageJSON,
|
||||
packageNLSPath: packageNLS ? path.join(extensionFolder, packageNLS) : undefined,
|
||||
readmePath: readme ? path.join(extensionFolder, readme) : undefined,
|
||||
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined,
|
||||
});
|
||||
return scannedExtensions;
|
||||
}
|
||||
catch (ex) {
|
||||
return scannedExtensions;
|
||||
}
|
||||
return scannedExtensions;
|
||||
}
|
||||
exports.scanBuiltinExtensions = scanBuiltinExtensions;
|
||||
function packageExternalExtensionsStream() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import * as fancyLog from 'fancy-log';
|
||||
import * as ansiColors from 'ansi-colors';
|
||||
const buffer = require('gulp-buffer');
|
||||
import json = require('gulp-json-editor');
|
||||
import * as jsoncParser from 'jsonc-parser';
|
||||
const webpack = require('webpack');
|
||||
const webpackGulp = require('webpack-stream');
|
||||
const util = require('./util');
|
||||
@@ -28,16 +29,21 @@ const root = path.dirname(path.dirname(__dirname));
|
||||
const commit = util.getVersion(root);
|
||||
const sourceMappingURLBase = `https://sqlopsbuilds.blob.core.windows.net/sourcemaps/${commit}`;
|
||||
|
||||
function minimizeLanguageJSON(input: Stream): Stream {
|
||||
const tmLanguageJsonFilter = filter('**/*.tmLanguage.json', { restore: true });
|
||||
function minifyExtensionResources(input: Stream): Stream {
|
||||
const jsonFilter = filter(['**/*.json', '**/*.code-snippets'], { restore: true });
|
||||
return input
|
||||
.pipe(tmLanguageJsonFilter)
|
||||
.pipe(jsonFilter)
|
||||
.pipe(buffer())
|
||||
.pipe(es.mapSync((f: File) => {
|
||||
f.contents = Buffer.from(JSON.stringify(JSON.parse(f.contents.toString('utf8'))));
|
||||
const errors: jsoncParser.ParseError[] = [];
|
||||
const value = jsoncParser.parse(f.contents.toString('utf8'), errors);
|
||||
if (errors.length === 0) {
|
||||
// file parsed OK => just stringify to drop whitespace and comments
|
||||
f.contents = Buffer.from(JSON.stringify(value));
|
||||
}
|
||||
return f;
|
||||
}))
|
||||
.pipe(tmLanguageJsonFilter.restore);
|
||||
.pipe(jsonFilter.restore);
|
||||
}
|
||||
|
||||
function updateExtensionPackageJSON(input: Stream, update: (data: any) => any): Stream {
|
||||
@@ -61,16 +67,11 @@ function fromLocal(extensionPath: string, forWeb: boolean): Stream {
|
||||
? fromLocalWebpack(extensionPath, webpackConfigFileName)
|
||||
: fromLocalNormal(extensionPath);
|
||||
|
||||
if (forWeb) {
|
||||
input = updateExtensionPackageJSON(input, (data: any) => {
|
||||
if (data.browser) {
|
||||
data.main = data.browser;
|
||||
}
|
||||
data.extensionKind = ['web'];
|
||||
return data;
|
||||
});
|
||||
} else if (isWebPacked) {
|
||||
if (isWebPacked) {
|
||||
input = updateExtensionPackageJSON(input, (data: any) => {
|
||||
delete data.scripts;
|
||||
delete data.dependencies;
|
||||
delete data.devDependencies;
|
||||
if (data.main) {
|
||||
data.main = data.main.replace('/out/', /dist/);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ function fromLocal(extensionPath: string, forWeb: boolean): Stream {
|
||||
});
|
||||
}
|
||||
|
||||
return minimizeLanguageJSON(input);
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
@@ -224,10 +225,8 @@ export function fromMarketplace(extensionName: string, version: string, metadata
|
||||
.pipe(json({ __metadata: metadata }))
|
||||
.pipe(packageJsonFilter.restore);
|
||||
}
|
||||
|
||||
const excludedExtensions = [
|
||||
'vscode-api-tests',
|
||||
'vscode-web-playground',
|
||||
'vscode-colorize-tests',
|
||||
'vscode-test-resolver',
|
||||
'ms-vscode.node-debug',
|
||||
@@ -266,6 +265,10 @@ const rebuildExtensions = [
|
||||
'mssql'
|
||||
];
|
||||
|
||||
const marketplaceWebExtensions = [
|
||||
'ms-vscode.references-view'
|
||||
];
|
||||
|
||||
interface IBuiltInExtension {
|
||||
name: string;
|
||||
version: string;
|
||||
@@ -273,113 +276,134 @@ interface IBuiltInExtension {
|
||||
metadata: any;
|
||||
}
|
||||
|
||||
const builtInExtensions: IBuiltInExtension[] = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
|
||||
const productJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8'));
|
||||
const builtInExtensions: IBuiltInExtension[] = productJson.builtInExtensions || [];
|
||||
const webBuiltInExtensions: IBuiltInExtension[] = productJson.webBuiltInExtensions || [];
|
||||
|
||||
export function packageLocalExtensionsStream(): NodeJS.ReadWriteStream {
|
||||
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))
|
||||
.map(manifestPath => {
|
||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||
const extensionName = path.basename(extensionPath);
|
||||
return { name: extensionName, path: extensionPath };
|
||||
})
|
||||
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
|
||||
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
|
||||
.filter(({ name }) => externalExtensions.indexOf(name) === -1); // {{SQL CARBON EDIT}} Remove external Extensions with separate package
|
||||
|
||||
|
||||
const localExtensions = localExtensionDescriptions.map(extension => {
|
||||
return fromLocal(extension.path, false)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
});
|
||||
|
||||
const nodeModules = gulp.src('extensions/node_modules/**', { base: '.' });
|
||||
return es.merge(nodeModules, ...localExtensions)
|
||||
.pipe(util2.setExecutableBit(['**/*.sh']));
|
||||
type ExtensionKind = 'ui' | 'workspace' | 'web';
|
||||
interface IExtensionManifest {
|
||||
main: string;
|
||||
browser: string;
|
||||
extensionKind?: ExtensionKind | ExtensionKind[];
|
||||
}
|
||||
/**
|
||||
* Loosely based on `getExtensionKind` from `src/vs/workbench/services/extensions/common/extensionsUtil.ts`
|
||||
*/
|
||||
function isWebExtension(manifest: IExtensionManifest): boolean {
|
||||
if (typeof manifest.extensionKind !== 'undefined') {
|
||||
const extensionKind = Array.isArray(manifest.extensionKind) ? manifest.extensionKind : [manifest.extensionKind];
|
||||
return (extensionKind.indexOf('web') >= 0);
|
||||
}
|
||||
return (!Boolean(manifest.main) || Boolean(manifest.browser));
|
||||
}
|
||||
|
||||
export function packageLocalWebExtensionsStream(): NodeJS.ReadWriteStream {
|
||||
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))
|
||||
.filter(manifestPath => {
|
||||
const packageJsonConfig = require(path.join(root, manifestPath));
|
||||
return !packageJsonConfig.main || packageJsonConfig.browser;
|
||||
})
|
||||
.map(manifestPath => {
|
||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||
const extensionName = path.basename(extensionPath);
|
||||
return { name: extensionName, path: extensionPath };
|
||||
});
|
||||
export function packageLocalExtensionsStream(forWeb: boolean): Stream {
|
||||
const localExtensionsDescriptions = (
|
||||
(<string[]>glob.sync('extensions/*/package.json'))
|
||||
.map(manifestPath => {
|
||||
const absoluteManifestPath = path.join(root, manifestPath);
|
||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||
const extensionName = path.basename(extensionPath);
|
||||
return { name: extensionName, path: extensionPath, manifestPath: absoluteManifestPath };
|
||||
})
|
||||
.filter(({ name }) => (name === 'vscode-web-playground' ? forWeb : true)) // package vscode-web-playground only for web
|
||||
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
|
||||
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
|
||||
.filter(({ name }) => externalExtensions.indexOf(name) === -1) // {{SQL CARBON EDIT}} Remove external Extensions with separate package
|
||||
);
|
||||
const localExtensionsStream = minifyExtensionResources(
|
||||
es.merge(
|
||||
...localExtensionsDescriptions.map(extension => {
|
||||
return fromLocal(extension.path, forWeb)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return es.merge(...localExtensionDescriptions.map(extension => {
|
||||
return fromLocal(extension.path, true)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
}));
|
||||
let result: Stream;
|
||||
if (forWeb) {
|
||||
result = localExtensionsStream;
|
||||
} else {
|
||||
// also include shared node modules
|
||||
result = es.merge(localExtensionsStream, gulp.src('extensions/node_modules/**', { base: '.' }));
|
||||
}
|
||||
|
||||
return (
|
||||
result
|
||||
.pipe(util2.setExecutableBit(['**/*.sh']))
|
||||
);
|
||||
}
|
||||
|
||||
export function packageMarketplaceExtensionsStream(): NodeJS.ReadWriteStream {
|
||||
const extensions = builtInExtensions.map(extension => {
|
||||
return fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
});
|
||||
export function packageMarketplaceExtensionsStream(forWeb: boolean): Stream {
|
||||
const marketplaceExtensionsDescriptions = [
|
||||
...builtInExtensions.filter(({ name }) => (forWeb ? marketplaceWebExtensions.indexOf(name) >= 0 : true)),
|
||||
...(forWeb ? webBuiltInExtensions : [])
|
||||
];
|
||||
const marketplaceExtensionsStream = minifyExtensionResources(
|
||||
es.merge(
|
||||
...marketplaceExtensionsDescriptions
|
||||
.map(extension => {
|
||||
const input = fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
return updateExtensionPackageJSON(input, (data: any) => {
|
||||
delete data.scripts;
|
||||
delete data.dependencies;
|
||||
delete data.devDependencies;
|
||||
return data;
|
||||
});
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return es.merge(extensions)
|
||||
.pipe(util2.setExecutableBit(['**/*.sh']));
|
||||
}
|
||||
|
||||
export function packageMarketplaceWebExtensionsStream(builtInExtensions: IBuiltInExtension[]): NodeJS.ReadWriteStream {
|
||||
const extensions = builtInExtensions
|
||||
.map(extension => {
|
||||
const input = fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||
return updateExtensionPackageJSON(input, (data: any) => {
|
||||
if (data.main) {
|
||||
data.browser = data.main;
|
||||
}
|
||||
data.extensionKind = ['web'];
|
||||
return data;
|
||||
});
|
||||
});
|
||||
return es.merge(extensions);
|
||||
return (
|
||||
marketplaceExtensionsStream
|
||||
.pipe(util2.setExecutableBit(['**/*.sh']))
|
||||
);
|
||||
}
|
||||
|
||||
export interface IScannedBuiltinExtension {
|
||||
extensionPath: string,
|
||||
packageJSON: any,
|
||||
packageNLSPath?: string,
|
||||
readmePath?: string,
|
||||
changelogPath?: string,
|
||||
extensionPath: string;
|
||||
packageJSON: any;
|
||||
packageNLS?: any;
|
||||
readmePath?: string;
|
||||
changelogPath?: string;
|
||||
}
|
||||
|
||||
export function scanBuiltinExtensions(extensionsRoot: string, forWeb: boolean): IScannedBuiltinExtension[] {
|
||||
export function scanBuiltinExtensions(extensionsRoot: string, exclude: string[] = []): IScannedBuiltinExtension[] {
|
||||
const scannedExtensions: IScannedBuiltinExtension[] = [];
|
||||
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
||||
for (const extensionFolder of extensionsFolders) {
|
||||
const packageJSONPath = path.join(extensionsRoot, extensionFolder, 'package.json');
|
||||
if (!fs.existsSync(packageJSONPath)) {
|
||||
continue;
|
||||
}
|
||||
let packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8'));
|
||||
const extensionKind: string[] = packageJSON['extensionKind'] || [];
|
||||
if (forWeb && extensionKind.indexOf('web') === -1) {
|
||||
continue;
|
||||
}
|
||||
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
|
||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
|
||||
|
||||
if (packageNLS) {
|
||||
// temporary
|
||||
packageJSON = translatePackageJSON(packageJSON, path.join(extensionsRoot, extensionFolder, packageNLS));
|
||||
try {
|
||||
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
||||
for (const extensionFolder of extensionsFolders) {
|
||||
if (exclude.indexOf(extensionFolder) >= 0) {
|
||||
continue;
|
||||
}
|
||||
const packageJSONPath = path.join(extensionsRoot, extensionFolder, 'package.json');
|
||||
if (!fs.existsSync(packageJSONPath)) {
|
||||
continue;
|
||||
}
|
||||
let packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8'));
|
||||
if (!isWebExtension(packageJSON)) {
|
||||
continue;
|
||||
}
|
||||
const children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||
const packageNLSPath = children.filter(child => child === 'package.nls.json')[0];
|
||||
const packageNLS = packageNLSPath ? JSON.parse(fs.readFileSync(path.join(extensionsRoot, extensionFolder, packageNLSPath)).toString()) : undefined;
|
||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||
const changelog = children.filter(child => /^changelog(\.txt|\.md|)$/i.test(child))[0];
|
||||
|
||||
scannedExtensions.push({
|
||||
extensionPath: extensionFolder,
|
||||
packageJSON,
|
||||
packageNLS,
|
||||
readmePath: readme ? path.join(extensionFolder, readme) : undefined,
|
||||
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined,
|
||||
});
|
||||
}
|
||||
scannedExtensions.push({
|
||||
extensionPath: extensionFolder,
|
||||
packageJSON,
|
||||
packageNLSPath: packageNLS ? path.join(extensionFolder, packageNLS) : undefined,
|
||||
readmePath: readme ? path.join(extensionFolder, readme) : undefined,
|
||||
changelogPath: changelog ? path.join(extensionFolder, changelog) : undefined,
|
||||
});
|
||||
return scannedExtensions;
|
||||
} catch (ex) {
|
||||
return scannedExtensions;
|
||||
}
|
||||
return scannedExtensions;
|
||||
}
|
||||
|
||||
export function packageExternalExtensionsStream(): NodeJS.ReadWriteStream {
|
||||
|
||||
@@ -246,6 +246,10 @@
|
||||
"name": "vs/workbench/services/configurationResolver",
|
||||
"project": "vscode-workbench"
|
||||
},
|
||||
{
|
||||
"name": "vs/workbench/services/crashReporter",
|
||||
"project": "vscode-workbench"
|
||||
},
|
||||
{
|
||||
"name": "vs/workbench/services/dialogs",
|
||||
"project": "vscode-workbench"
|
||||
|
||||
@@ -72,7 +72,7 @@ function loader(src, bundledFileHeader, bundleLoader) {
|
||||
}))
|
||||
.pipe(concat('vs/loader.js')));
|
||||
}
|
||||
function toConcatStream(src, bundledFileHeader, sources, dest) {
|
||||
function toConcatStream(src, bundledFileHeader, sources, dest, fileContentMapper) {
|
||||
const useSourcemaps = /\.js$/.test(dest) && !/\.nls\.js$/.test(dest);
|
||||
// If a bundle ends up including in any of the sources our copyright, then
|
||||
// insert a fake source at the beginning of each bundle with our copyright
|
||||
@@ -93,10 +93,12 @@ function toConcatStream(src, bundledFileHeader, sources, dest) {
|
||||
const treatedSources = sources.map(function (source) {
|
||||
const root = source.path ? REPO_ROOT_PATH.replace(/\\/g, '/') : '';
|
||||
const base = source.path ? root + `/${src}` : '';
|
||||
const path = source.path ? root + '/' + source.path.replace(/\\/g, '/') : 'fake';
|
||||
const contents = source.path ? fileContentMapper(source.contents, path) : source.contents;
|
||||
return new VinylFile({
|
||||
path: source.path ? root + '/' + source.path.replace(/\\/g, '/') : 'fake',
|
||||
path: path,
|
||||
base: base,
|
||||
contents: Buffer.from(source.contents)
|
||||
contents: Buffer.from(contents)
|
||||
});
|
||||
});
|
||||
return es.readArray(treatedSources)
|
||||
@@ -104,9 +106,9 @@ function toConcatStream(src, bundledFileHeader, sources, dest) {
|
||||
.pipe(concat(dest))
|
||||
.pipe(stats_1.createStatsStream(dest));
|
||||
}
|
||||
function toBundleStream(src, bundledFileHeader, bundles) {
|
||||
function toBundleStream(src, bundledFileHeader, bundles, fileContentMapper) {
|
||||
return es.merge(bundles.map(function (bundle) {
|
||||
return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest);
|
||||
return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest, fileContentMapper);
|
||||
}));
|
||||
}
|
||||
const DEFAULT_FILE_HEADER = [
|
||||
@@ -122,6 +124,7 @@ function optimizeTask(opts) {
|
||||
const bundledFileHeader = opts.header || DEFAULT_FILE_HEADER;
|
||||
const bundleLoader = (typeof opts.bundleLoader === 'undefined' ? true : opts.bundleLoader);
|
||||
const out = opts.out;
|
||||
const fileContentMapper = opts.fileContentMapper || ((contents, _path) => contents);
|
||||
return function () {
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
const resourcesStream = es.through(); // this stream will contain the resources
|
||||
@@ -130,7 +133,7 @@ function optimizeTask(opts) {
|
||||
if (err || !result) {
|
||||
return bundlesStream.emit('error', JSON.stringify(err));
|
||||
}
|
||||
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
|
||||
toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream);
|
||||
// Remove css inlined resources
|
||||
const filteredResources = resources.slice();
|
||||
result.cssInlinedResources.forEach(function (resource) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import * as fancyLog from 'fancy-log';
|
||||
import * as ansiColors from 'ansi-colors';
|
||||
import * as path from 'path';
|
||||
import * as pump from 'pump';
|
||||
import * as sm from 'source-map';
|
||||
import * as terser from 'terser';
|
||||
import * as VinylFile from 'vinyl';
|
||||
import * as bundle from './bundle';
|
||||
@@ -50,10 +49,6 @@ export function loaderConfig() {
|
||||
|
||||
const IS_OUR_COPYRIGHT_REGEXP = /Copyright \(C\) Microsoft Corporation/i;
|
||||
|
||||
declare class FileSourceMap extends VinylFile {
|
||||
public sourceMap: sm.RawSourceMap;
|
||||
}
|
||||
|
||||
function loader(src: string, bundledFileHeader: string, bundleLoader: boolean): NodeJS.ReadWriteStream {
|
||||
let sources = [
|
||||
`${src}/vs/loader.js`
|
||||
@@ -86,7 +81,7 @@ function loader(src: string, bundledFileHeader: string, bundleLoader: boolean):
|
||||
);
|
||||
}
|
||||
|
||||
function toConcatStream(src: string, bundledFileHeader: string, sources: bundle.IFile[], dest: string): NodeJS.ReadWriteStream {
|
||||
function toConcatStream(src: string, bundledFileHeader: string, sources: bundle.IFile[], dest: string, fileContentMapper: (contents: string, path: string) => string): NodeJS.ReadWriteStream {
|
||||
const useSourcemaps = /\.js$/.test(dest) && !/\.nls\.js$/.test(dest);
|
||||
|
||||
// If a bundle ends up including in any of the sources our copyright, then
|
||||
@@ -110,11 +105,13 @@ function toConcatStream(src: string, bundledFileHeader: string, sources: bundle.
|
||||
const treatedSources = sources.map(function (source) {
|
||||
const root = source.path ? REPO_ROOT_PATH.replace(/\\/g, '/') : '';
|
||||
const base = source.path ? root + `/${src}` : '';
|
||||
const path = source.path ? root + '/' + source.path.replace(/\\/g, '/') : 'fake';
|
||||
const contents = source.path ? fileContentMapper(source.contents, path) : source.contents;
|
||||
|
||||
return new VinylFile({
|
||||
path: source.path ? root + '/' + source.path.replace(/\\/g, '/') : 'fake',
|
||||
path: path,
|
||||
base: base,
|
||||
contents: Buffer.from(source.contents)
|
||||
contents: Buffer.from(contents)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -124,9 +121,9 @@ function toConcatStream(src: string, bundledFileHeader: string, sources: bundle.
|
||||
.pipe(createStatsStream(dest));
|
||||
}
|
||||
|
||||
function toBundleStream(src: string, bundledFileHeader: string, bundles: bundle.IConcatFile[]): NodeJS.ReadWriteStream {
|
||||
function toBundleStream(src: string, bundledFileHeader: string, bundles: bundle.IConcatFile[], fileContentMapper: (contents: string, path: string) => string): NodeJS.ReadWriteStream {
|
||||
return es.merge(bundles.map(function (bundle) {
|
||||
return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest);
|
||||
return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest, fileContentMapper);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -164,6 +161,12 @@ export interface IOptimizeTaskOpts {
|
||||
* (out folder name)
|
||||
*/
|
||||
languages?: Language[];
|
||||
/**
|
||||
* File contents interceptor
|
||||
* @param contents The contens of the file
|
||||
* @param path The absolute file path, always using `/`, even on Windows
|
||||
*/
|
||||
fileContentMapper?: (contents: string, path: string) => string;
|
||||
}
|
||||
|
||||
const DEFAULT_FILE_HEADER = [
|
||||
@@ -180,6 +183,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
|
||||
const bundledFileHeader = opts.header || DEFAULT_FILE_HEADER;
|
||||
const bundleLoader = (typeof opts.bundleLoader === 'undefined' ? true : opts.bundleLoader);
|
||||
const out = opts.out;
|
||||
const fileContentMapper = opts.fileContentMapper || ((contents: string, _path: string) => contents);
|
||||
|
||||
return function () {
|
||||
const bundlesStream = es.through(); // this stream will contain the bundled files
|
||||
@@ -189,7 +193,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
|
||||
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
|
||||
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
|
||||
|
||||
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
|
||||
toBundleStream(src, bundledFileHeader, result.files, fileContentMapper).pipe(bundlesStream);
|
||||
|
||||
// Remove css inlined resources
|
||||
const filteredResources = resources.slice();
|
||||
|
||||
55
build/lib/preLaunch.js
Normal file
55
build/lib/preLaunch.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// @ts-check
|
||||
const path = require("path");
|
||||
const child_process_1 = require("child_process");
|
||||
const fs_1 = require("fs");
|
||||
const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn';
|
||||
const rootDir = path.resolve(__dirname, '..', '..');
|
||||
function runProcess(command, args = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = child_process_1.spawn(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env });
|
||||
child.on('exit', err => !err ? resolve() : process.exit(err !== null && err !== void 0 ? err : 1));
|
||||
child.on('error', reject);
|
||||
});
|
||||
}
|
||||
async function exists(subdir) {
|
||||
try {
|
||||
await fs_1.promises.stat(path.join(rootDir, subdir));
|
||||
return true;
|
||||
}
|
||||
catch (_a) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async function ensureNodeModules() {
|
||||
if (!(await exists('node_modules'))) {
|
||||
await runProcess(yarn);
|
||||
}
|
||||
}
|
||||
async function getElectron() {
|
||||
await runProcess(yarn, ['electron']);
|
||||
}
|
||||
async function ensureCompiled() {
|
||||
if (!(await exists('out'))) {
|
||||
await runProcess(yarn, ['compile']);
|
||||
}
|
||||
}
|
||||
async function main() {
|
||||
await ensureNodeModules();
|
||||
await getElectron();
|
||||
await ensureCompiled();
|
||||
// Can't require this until after dependencies are installed
|
||||
const { getBuiltInExtensions } = require('./builtInExtensions');
|
||||
await getBuiltInExtensions();
|
||||
}
|
||||
if (require.main === module) {
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
65
build/lib/preLaunch.ts
Normal file
65
build/lib/preLaunch.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// @ts-check
|
||||
|
||||
import * as path from 'path';
|
||||
import { spawn } from 'child_process';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn';
|
||||
const rootDir = path.resolve(__dirname, '..', '..');
|
||||
|
||||
function runProcess(command: string, args: ReadonlyArray<string> = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(command, args, { cwd: rootDir, stdio: 'inherit', env: process.env });
|
||||
child.on('exit', err => !err ? resolve() : process.exit(err ?? 1));
|
||||
child.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
async function exists(subdir: string) {
|
||||
try {
|
||||
await fs.stat(path.join(rootDir, subdir));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureNodeModules() {
|
||||
if (!(await exists('node_modules'))) {
|
||||
await runProcess(yarn);
|
||||
}
|
||||
}
|
||||
|
||||
async function getElectron() {
|
||||
await runProcess(yarn, ['electron']);
|
||||
}
|
||||
|
||||
async function ensureCompiled() {
|
||||
if (!(await exists('out'))) {
|
||||
await runProcess(yarn, ['compile']);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await ensureNodeModules();
|
||||
await getElectron();
|
||||
await ensureCompiled();
|
||||
|
||||
// Can't require this until after dependencies are installed
|
||||
const { getBuiltInExtensions } = require('./builtInExtensions');
|
||||
await getBuiltInExtensions();
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
@@ -41,6 +41,7 @@
|
||||
"gulp-sourcemaps": "^1.11.0",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"iconv-lite-umd": "0.6.8",
|
||||
"jsonc-parser": "^2.3.0",
|
||||
"mime": "^1.3.4",
|
||||
"minimatch": "3.0.4",
|
||||
"minimist": "^1.2.3",
|
||||
@@ -49,7 +50,7 @@
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"terser": "4.3.8",
|
||||
"typescript": "^4.0.0-dev.20200722",
|
||||
"typescript": "^4.0.0-dev.20200803",
|
||||
"vsce": "1.48.0",
|
||||
"vscode-telemetry-extractor": "^1.6.0",
|
||||
"xml2js": "^0.4.17"
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"checkJs": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
"noUnusedParameters": true,
|
||||
"newLine": "lf"
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
|
||||
@@ -2123,6 +2123,11 @@ json-stringify-safe@~5.0.1:
|
||||
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
|
||||
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=
|
||||
|
||||
jsonc-parser@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.3.0.tgz#7c7fc988ee1486d35734faaaa866fadb00fa91ee"
|
||||
integrity sha512-b0EBt8SWFNnixVdvoR2ZtEGa9ZqLhbJnOjezn+WP+8kspFm+PFYDN8Z4Bc7pRlDjvuVcADSUkroIuTWWn/YiIA==
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
@@ -3539,10 +3544,10 @@ typescript@^3.0.1:
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
|
||||
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
|
||||
|
||||
typescript@^4.0.0-dev.20200722:
|
||||
version "4.0.0-dev.20200722"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.0-dev.20200722.tgz#b59dd5a3cd84a98d5aae0e4f3a3c58f0c81a3b9b"
|
||||
integrity sha512-MmJ1YyPNK3JYeKLiTg5sQXdeZaMgt99Fg4BMRZhJmhoq1/x2V1cpXMYvE1rtIYl9K7NvmTDdU3WDW7ZOD6ybaw==
|
||||
typescript@^4.0.0-dev.20200803:
|
||||
version "4.0.0-dev.20200803"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.0-dev.20200803.tgz#ea8b0e9fb2ee3085598ff200c8568f04f4cbb2ba"
|
||||
integrity sha512-f/jDkFqCs0gbUd5MCUijO9u3AOMx1x1HdRDDHSidlc6uPVEkRduxjeTFhIXbGutO7ivzv+aC2sxH+1FQwsyBcg==
|
||||
|
||||
typical@^4.0.0:
|
||||
version "4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user