mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Align build scripts
This commit is contained in:
parent
bf8b5c9a2e
commit
5ba8591765
|
@ -165,8 +165,8 @@ gulp.task(compileExtensionsBuildLegacyTask);
|
||||||
const cleanExtensionsBuildTask = task.define('clean-extensions-build', util.rimraf('.build/extensions'));
|
const cleanExtensionsBuildTask = task.define('clean-extensions-build', util.rimraf('.build/extensions'));
|
||||||
const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series(
|
const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series(
|
||||||
cleanExtensionsBuildTask,
|
cleanExtensionsBuildTask,
|
||||||
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream().pipe(gulp.dest('.build'))),
|
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream(false).pipe(gulp.dest('.build'))),
|
||||||
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream().pipe(gulp.dest('.build'))),
|
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream(false).pipe(gulp.dest('.build'))),
|
||||||
));
|
));
|
||||||
|
|
||||||
gulp.task(compileExtensionsBuildTask);
|
gulp.task(compileExtensionsBuildTask);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.translatePackageJSON = exports.scanBuiltinExtensions = exports.packageMarketplaceWebExtensionsStream = exports.packageMarketplaceExtensionsStream = exports.packageLocalWebExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = void 0;
|
exports.translatePackageJSON = exports.scanBuiltinExtensions = exports.packageMarketplaceExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = void 0;
|
||||||
const es = require("event-stream");
|
const es = require("event-stream");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const glob = require("glob");
|
const glob = require("glob");
|
||||||
|
@ -200,68 +200,66 @@ const excludedExtensions = [
|
||||||
'ms-vscode.node-debug2',
|
'ms-vscode.node-debug2',
|
||||||
'vscode-notebook-tests'
|
'vscode-notebook-tests'
|
||||||
];
|
];
|
||||||
|
const marketplaceWebExtensions = [
|
||||||
|
'ms-vscode.references-view'
|
||||||
|
];
|
||||||
const builtInExtensions = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
|
const builtInExtensions = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
|
||||||
function packageLocalExtensionsStream() {
|
/**
|
||||||
const localExtensionDescriptions = glob.sync('extensions/*/package.json')
|
* 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 => {
|
.map(manifestPath => {
|
||||||
|
const absoluteManifestPath = path.join(root, manifestPath);
|
||||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
const extensionPath = path.dirname(path.join(root, manifestPath));
|
||||||
const extensionName = path.basename(extensionPath);
|
const extensionName = path.basename(extensionPath);
|
||||||
return { name: extensionName, path: extensionPath };
|
return { name: extensionName, path: extensionPath, manifestPath: absoluteManifestPath };
|
||||||
})
|
})
|
||||||
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
|
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
|
||||||
.filter(({ name }) => builtInExtensions.every(b => b.name !== name));
|
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
|
||||||
const localExtensions = localExtensionDescriptions.map(extension => {
|
.filter(({ manifestPath }) => (forWeb ? isWebExtension(require(manifestPath)) : true)));
|
||||||
return fromLocal(extension.path, false)
|
const localExtensionsStream = minifyExtensionResources(es.merge(...localExtensionsDescriptions.map(extension => {
|
||||||
|
return fromLocal(extension.path, forWeb)
|
||||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||||
});
|
})));
|
||||||
const nodeModules = gulp.src('extensions/node_modules/**', { base: '.' });
|
let result;
|
||||||
return minifyExtensionResources(es.merge(nodeModules, ...localExtensions)
|
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'])));
|
.pipe(util2.setExecutableBit(['**/*.sh'])));
|
||||||
}
|
}
|
||||||
exports.packageLocalExtensionsStream = packageLocalExtensionsStream;
|
exports.packageLocalExtensionsStream = packageLocalExtensionsStream;
|
||||||
function packageLocalWebExtensionsStream() {
|
function packageMarketplaceExtensionsStream(forWeb) {
|
||||||
const localExtensionDescriptions = glob.sync('extensions/*/package.json')
|
const marketplaceExtensionsDescriptions = (builtInExtensions
|
||||||
.filter(manifestPath => {
|
.filter(({ name }) => (forWeb ? marketplaceWebExtensions.indexOf(name) >= 0 : true)));
|
||||||
const packageJsonConfig = require(path.join(root, manifestPath));
|
const marketplaceExtensionsStream = minifyExtensionResources(es.merge(...marketplaceExtensionsDescriptions
|
||||||
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 minifyExtensionResources(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 minifyExtensionResources(es.merge(extensions)
|
|
||||||
.pipe(util2.setExecutableBit(['**/*.sh'])));
|
|
||||||
}
|
|
||||||
exports.packageMarketplaceExtensionsStream = packageMarketplaceExtensionsStream;
|
|
||||||
function packageMarketplaceWebExtensionsStream(builtInExtensions) {
|
|
||||||
const extensions = builtInExtensions
|
|
||||||
.map(extension => {
|
.map(extension => {
|
||||||
const input = fromMarketplace(extension.name, extension.version, extension.metadata)
|
const input = fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||||
return updateExtensionPackageJSON(input, (data) => {
|
return updateExtensionPackageJSON(input, (data) => {
|
||||||
if (data.main) {
|
delete data.scripts;
|
||||||
data.browser = data.main;
|
delete data.dependencies;
|
||||||
}
|
delete data.devDependencies;
|
||||||
data.extensionKind = ['web'];
|
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
});
|
})));
|
||||||
return minifyExtensionResources(es.merge(extensions));
|
return (marketplaceExtensionsStream
|
||||||
|
.pipe(util2.setExecutableBit(['**/*.sh'])));
|
||||||
}
|
}
|
||||||
exports.packageMarketplaceWebExtensionsStream = packageMarketplaceWebExtensionsStream;
|
exports.packageMarketplaceExtensionsStream = packageMarketplaceExtensionsStream;
|
||||||
function scanBuiltinExtensions(extensionsRoot, forWeb) {
|
function scanBuiltinExtensions(extensionsRoot) {
|
||||||
const scannedExtensions = [];
|
const scannedExtensions = [];
|
||||||
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
||||||
for (const extensionFolder of extensionsFolders) {
|
for (const extensionFolder of extensionsFolders) {
|
||||||
|
@ -270,10 +268,6 @@ function scanBuiltinExtensions(extensionsRoot, forWeb) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8'));
|
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 children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||||
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
|
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
|
||||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||||
|
|
|
@ -235,6 +235,10 @@ const excludedExtensions = [
|
||||||
'vscode-notebook-tests'
|
'vscode-notebook-tests'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const marketplaceWebExtensions = [
|
||||||
|
'ms-vscode.references-view'
|
||||||
|
];
|
||||||
|
|
||||||
interface IBuiltInExtension {
|
interface IBuiltInExtension {
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
@ -244,76 +248,83 @@ interface IBuiltInExtension {
|
||||||
|
|
||||||
const builtInExtensions: IBuiltInExtension[] = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
|
const builtInExtensions: IBuiltInExtension[] = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
|
||||||
|
|
||||||
export function packageLocalExtensionsStream(): Stream {
|
type ExtensionKind = 'ui' | 'workspace' | 'web';
|
||||||
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))
|
interface IExtensionManifest {
|
||||||
.map(manifestPath => {
|
main: string;
|
||||||
const extensionPath = path.dirname(path.join(root, manifestPath));
|
browser: string;
|
||||||
const extensionName = path.basename(extensionPath);
|
extensionKind?: ExtensionKind | ExtensionKind[];
|
||||||
return { name: extensionName, path: extensionPath };
|
}
|
||||||
})
|
/**
|
||||||
.filter(({ name }) => excludedExtensions.indexOf(name) === -1)
|
* Loosely based on `getExtensionKind` from `src/vs/workbench/services/extensions/common/extensionsUtil.ts`
|
||||||
.filter(({ name }) => builtInExtensions.every(b => b.name !== name));
|
*/
|
||||||
|
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 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 }) => excludedExtensions.indexOf(name) === -1)
|
||||||
|
.filter(({ name }) => builtInExtensions.every(b => b.name !== name))
|
||||||
|
.filter(({ manifestPath }) => (forWeb ? isWebExtension(require(manifestPath)) : true))
|
||||||
|
);
|
||||||
|
const localExtensionsStream = minifyExtensionResources(
|
||||||
|
es.merge(
|
||||||
|
...localExtensionsDescriptions.map(extension => {
|
||||||
|
return fromLocal(extension.path, forWeb)
|
||||||
|
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const localExtensions = localExtensionDescriptions.map(extension => {
|
let result: Stream;
|
||||||
return fromLocal(extension.path, false)
|
if (forWeb) {
|
||||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
result = localExtensionsStream;
|
||||||
});
|
} else {
|
||||||
|
// also include shared node modules
|
||||||
|
result = es.merge(localExtensionsStream, gulp.src('extensions/node_modules/**', { base: '.' }));
|
||||||
|
}
|
||||||
|
|
||||||
const nodeModules = gulp.src('extensions/node_modules/**', { base: '.' });
|
return (
|
||||||
return minifyExtensionResources(
|
result
|
||||||
es.merge(nodeModules, ...localExtensions)
|
.pipe(util2.setExecutableBit(['**/*.sh']))
|
||||||
.pipe(util2.setExecutableBit(['**/*.sh']))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function packageLocalWebExtensionsStream(): Stream {
|
export function packageMarketplaceExtensionsStream(forWeb: boolean): Stream {
|
||||||
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))
|
const marketplaceExtensionsDescriptions = (
|
||||||
.filter(manifestPath => {
|
builtInExtensions
|
||||||
const packageJsonConfig = require(path.join(root, manifestPath));
|
.filter(({ name }) => (forWeb ? marketplaceWebExtensions.indexOf(name) >= 0 : true))
|
||||||
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 minifyExtensionResources(
|
|
||||||
es.merge(...localExtensionDescriptions.map(extension => {
|
|
||||||
return fromLocal(extension.path, true)
|
|
||||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
|
||||||
}))
|
|
||||||
);
|
);
|
||||||
}
|
const marketplaceExtensionsStream = minifyExtensionResources(
|
||||||
|
es.merge(
|
||||||
export function packageMarketplaceExtensionsStream(): Stream {
|
...marketplaceExtensionsDescriptions
|
||||||
const extensions = builtInExtensions.map(extension => {
|
.map(extension => {
|
||||||
return fromMarketplace(extension.name, extension.version, extension.metadata)
|
const input = fromMarketplace(extension.name, extension.version, extension.metadata)
|
||||||
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
.pipe(rename(p => p.dirname = `extensions/${extension.name}/${p.dirname}`));
|
||||||
});
|
return updateExtensionPackageJSON(input, (data: any) => {
|
||||||
|
delete data.scripts;
|
||||||
return minifyExtensionResources(
|
delete data.dependencies;
|
||||||
es.merge(extensions)
|
delete data.devDependencies;
|
||||||
.pipe(util2.setExecutableBit(['**/*.sh']))
|
return data;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
export function packageMarketplaceWebExtensionsStream(builtInExtensions: IBuiltInExtension[]): Stream {
|
return (
|
||||||
const extensions = builtInExtensions
|
marketplaceExtensionsStream
|
||||||
.map(extension => {
|
.pipe(util2.setExecutableBit(['**/*.sh']))
|
||||||
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 minifyExtensionResources(
|
|
||||||
es.merge(extensions)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +336,7 @@ export interface IScannedBuiltinExtension {
|
||||||
changelogPath?: string,
|
changelogPath?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scanBuiltinExtensions(extensionsRoot: string, forWeb: boolean): IScannedBuiltinExtension[] {
|
export function scanBuiltinExtensions(extensionsRoot: string): IScannedBuiltinExtension[] {
|
||||||
const scannedExtensions: IScannedBuiltinExtension[] = [];
|
const scannedExtensions: IScannedBuiltinExtension[] = [];
|
||||||
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
const extensionsFolders = fs.readdirSync(extensionsRoot);
|
||||||
for (const extensionFolder of extensionsFolders) {
|
for (const extensionFolder of extensionsFolders) {
|
||||||
|
@ -334,10 +345,6 @@ export function scanBuiltinExtensions(extensionsRoot: string, forWeb: boolean):
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString('utf8'));
|
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 children = fs.readdirSync(path.join(extensionsRoot, extensionFolder));
|
||||||
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
|
const packageNLS = children.filter(child => child === 'package.nls.json')[0];
|
||||||
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
const readme = children.filter(child => /^readme(\.txt|\.md|)$/i.test(child))[0];
|
||||||
|
|
Loading…
Reference in a new issue