Skip to content

Commit 5bdb90d

Browse files
committed
scripts/code.sh picks up marketplace built-in extensions automatically
1 parent 53a2781 commit 5bdb90d

8 files changed

Lines changed: 100 additions & 10 deletions

File tree

build/builtInExtensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{ "name": "ms-vscode.node-debug", "version": "1.20.3" },
3+
{ "name": "ms-vscode.node-debug2", "version": "1.20.1" }
4+
]

build/gulpfile.vscode.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ const nodeModules = ['electron', 'original-fs']
4444

4545
// Build
4646

47-
const builtInExtensions = [
48-
{ name: 'ms-vscode.node-debug', version: '1.20.3' },
49-
{ name: 'ms-vscode.node-debug2', version: '1.20.1' }
50-
];
47+
const builtInExtensions = require('./builtInExtensions');
5148

5249
const excludedExtensions = [
5350
'vscode-api-tests',
54-
'vscode-colorize-tests'
51+
'vscode-colorize-tests',
52+
'ms-vscode.node-debug',
53+
'ms-vscode.node-debug2',
5554
];
5655

5756
const vscodeEntryPoints = _.flatten([
@@ -584,3 +583,20 @@ gulp.task('generate-vscode-configuration', () => {
584583
console.error(e.toString());
585584
});
586585
});
586+
587+
//#region Built-In Extensions
588+
gulp.task('clean-builtInExtensions', util.rimraf('.build/builtInExtensions'));
589+
590+
gulp.task('builtInExtensions', ['clean-builtInExtensions'], function() {
591+
const marketplaceExtensions = es.merge(...builtInExtensions.map(extension => {
592+
return ext.fromMarketplace(extension.name, extension.version)
593+
.pipe(rename(p => p.dirname = `${extension.name}/${p.dirname}`));
594+
}));
595+
596+
return (
597+
marketplaceExtensions
598+
.pipe(util.setExecutableBit(['**/*.sh']))
599+
.pipe(vfs.dest('.build/builtInExtensions'))
600+
);
601+
});
602+
//#endregion

build/lib/builtInExtensions.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
'use strict';
7+
8+
const fs = require('fs');
9+
const path = require('path');
10+
const root = path.dirname(path.dirname(__dirname));
11+
12+
function isUpToDate(extension) {
13+
const packagePath = path.join(root, '.build', 'builtInExtensions', extension.name, 'package.json');
14+
if (!fs.existsSync(packagePath)) {
15+
return false;
16+
}
17+
const packageContents = fs.readFileSync(packagePath);
18+
try {
19+
const diskVersion = JSON.parse(packageContents).version;
20+
return (diskVersion === extension.version);
21+
} catch(err) {
22+
return false;
23+
}
24+
}
25+
26+
const builtInExtensions = require('../builtInExtensions');
27+
builtInExtensions.forEach((extension) => {
28+
if (!isUpToDate(extension)) {
29+
process.exit(1);
30+
}
31+
});
32+
process.exit(0);

extensions/ms-vscode.node-debug/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "node-debug-placeholder",
2+
"name": "node-debug",
33
"version": "1.6.0",
4-
"publisher": "vscode",
4+
"publisher": "ms-vscode",
55
"engines": {
66
"vscode": "1.6.x"
77
}

extensions/ms-vscode.node-debug2/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "node-debug2-placeholder",
2+
"name": "node-debug2",
33
"version": "0.0.3",
4-
"publisher": "vscode",
4+
"publisher": "ms-vscode",
55
"engines": {
66
"vscode": "1.6.x"
77
}

scripts/code.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function code() {
2424
# Get electron
2525
node build/lib/electron.js || ./node_modules/.bin/gulp electron
2626

27+
# Get built-in extensions
28+
node build/lib/builtInExtensions.js || ./node_modules/.bin/gulp builtInExtensions
29+
2730
# Build
2831
test -d out || ./node_modules/.bin/gulp compile
2932

src/vs/workbench/services/extensions/electron-browser/extensionPoints.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ export class ExtensionScanner {
334334
}
335335

336336
const rawFolders = await pfs.readDirsInDir(absoluteFolderPath);
337+
338+
// Ensure the same extension order
339+
rawFolders.sort();
340+
337341
let folders: string[] = null;
338342
if (isBuiltin) {
339343
folders = rawFolders;

src/vs/workbench/services/extensions/electron-browser/extensionService.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import * as strings from 'vs/base/common/strings';
4444
import { RPCProtocol } from 'vs/workbench/services/extensions/node/rpcProtocol';
4545

4646
const SystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', 'extensions'));
47+
const ExtraDevSystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', '.build', 'builtInExtensions'));
4748

4849
// Enable to see detailed message communication between window and extension host
4950
const logExtensionHostCommunication = false;
@@ -624,6 +625,36 @@ export class ExtensionService extends Disposable implements IExtensionService {
624625
log
625626
);
626627

628+
let finalBuiltinExtensions: TPromise<IExtensionDescription[]> = builtinExtensions;
629+
630+
if (devMode) {
631+
const extraBuiltinExtensions = ExtensionScanner.scanExtensions(new ExtensionScannerInput(version, commit, locale, devMode, ExtraDevSystemExtensionsRoot, true), log);
632+
finalBuiltinExtensions = TPromise.join([builtinExtensions, extraBuiltinExtensions]).then(([builtinExtensions, extraBuiltinExtensions]) => {
633+
let resultMap: { [id: string]: IExtensionDescription; } = Object.create(null);
634+
for (let i = 0, len = builtinExtensions.length; i < len; i++) {
635+
resultMap[builtinExtensions[i].id] = builtinExtensions[i];
636+
}
637+
// Overwrite with extensions found in extra
638+
for (let i = 0, len = extraBuiltinExtensions.length; i < len; i++) {
639+
resultMap[extraBuiltinExtensions[i].id] = extraBuiltinExtensions[i];
640+
}
641+
642+
let resultArr = Object.keys(resultMap).map((id) => resultMap[id]);
643+
resultArr.sort((a, b) => {
644+
const aLastSegment = path.basename(a.extensionFolderPath);
645+
const bLastSegment = path.basename(b.extensionFolderPath);
646+
if (aLastSegment < bLastSegment) {
647+
return -1;
648+
}
649+
if (aLastSegment > bLastSegment) {
650+
return 1;
651+
}
652+
return 0;
653+
});
654+
return resultArr;
655+
});
656+
}
657+
627658
const userExtensions = (
628659
environmentService.disableExtensions || !environmentService.extensionsPath
629660
? TPromise.as([])
@@ -646,7 +677,7 @@ export class ExtensionService extends Disposable implements IExtensionService {
646677
: TPromise.as([])
647678
);
648679

649-
return TPromise.join([builtinExtensions, userExtensions, developedExtensions])
680+
return TPromise.join([finalBuiltinExtensions, userExtensions, developedExtensions])
650681
.then((extensionDescriptions: IExtensionDescription[][]) => {
651682
const system = extensionDescriptions[0];
652683
const user = extensionDescriptions[1];

0 commit comments

Comments
 (0)