Skip to content

Commit fda15e8

Browse files
authored
Merge pull request microsoft#94526 from microsoft/joao/cleanup-builtin
Cleanup built-in extensions mechanism
2 parents f474fcb + 3d47dd4 commit fda15e8

11 files changed

Lines changed: 99 additions & 144 deletions

File tree

build/builtInExtensions.json

Lines changed: 0 additions & 80 deletions
This file was deleted.

build/builtin/browser-main.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ const os = require('os');
99
const { remote } = require('electron');
1010
const dialog = remote.dialog;
1111

12-
const productJsonPath = path.join(__dirname, '..', '..', 'product.json');
13-
const builtInExtensionsPath = path.join(__dirname, '..', 'builtInExtensions.json');
12+
const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json');
1413
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
1514

1615
function readJson(filePath) {
@@ -51,7 +50,6 @@ function render(el, state) {
5150
}
5251

5352
const ul = document.createElement('ul');
54-
const { quality } = readJson(productJsonPath);
5553
const { builtin, control } = state;
5654

5755
for (const ext of builtin) {
@@ -62,10 +60,6 @@ function render(el, state) {
6260

6361
const name = document.createElement('code');
6462
name.textContent = ext.name;
65-
if (quality && ext.forQualities && !ext.forQualities.includes(quality)) {
66-
name.textContent += ` (only on ${ext.forQualities.join(', ')})`;
67-
}
68-
6963
li.appendChild(name);
7064

7165
const form = document.createElement('form');
@@ -116,7 +110,7 @@ function render(el, state) {
116110

117111
function main() {
118112
const el = document.getElementById('extensions');
119-
const builtin = readJson(builtInExtensionsPath);
113+
const builtin = readJson(builtInExtensionsPath).builtInExtensions;
120114
let control;
121115

122116
try {

build/lib/builtInExtensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const fancyLog = require('fancy-log');
1818
const ansiColors = require('ansi-colors');
1919

2020
const root = path.dirname(path.dirname(__dirname));
21-
const builtInExtensions = require('../builtInExtensions.json');
21+
const builtInExtensions = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
2222
const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json');
2323
const ENABLE_LOGGING = !process.env['VSCODE_BUILD_BUILTIN_EXTENSIONS_SILENCE_PLEASE'];
2424

build/lib/extensions.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const util = require('./util');
2828
const root = path.dirname(path.dirname(__dirname));
2929
const commit = util.getVersion(root);
3030
const sourceMappingURLBase = `https://ticino.blob.core.windows.net/sourcemaps/${commit}`;
31-
const product = require('../../product.json');
3231
function fromLocal(extensionPath) {
3332
const webpackFilename = path.join(extensionPath, 'extension.webpack.config.js');
3433
const input = fs.existsSync(webpackFilename)
@@ -187,10 +186,8 @@ const excludedExtensions = [
187186
'vscode-test-resolver',
188187
'ms-vscode.node-debug',
189188
'ms-vscode.node-debug2',
190-
'ms.vscode.js-debug-nightly'
191189
];
192-
const builtInExtensions = require('../builtInExtensions.json')
193-
.filter(({ forQualities }) => { var _a; return !product.quality || ((_a = forQualities === null || forQualities === void 0 ? void 0 : forQualities.includes) === null || _a === void 0 ? void 0 : _a.call(forQualities, product.quality)) !== false; });
190+
const builtInExtensions = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
194191
function packageLocalExtensionsStream() {
195192
const localExtensionDescriptions = glob.sync('extensions/*/package.json')
196193
.map(manifestPath => {

build/lib/extensions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const util = require('./util');
2727
const root = path.dirname(path.dirname(__dirname));
2828
const commit = util.getVersion(root);
2929
const sourceMappingURLBase = `https://ticino.blob.core.windows.net/sourcemaps/${commit}`;
30-
const product = require('../../product.json');
3130

3231
function fromLocal(extensionPath: string): Stream {
3332
const webpackFilename = path.join(extensionPath, 'extension.webpack.config.js');
@@ -221,19 +220,16 @@ const excludedExtensions = [
221220
'vscode-test-resolver',
222221
'ms-vscode.node-debug',
223222
'ms-vscode.node-debug2',
224-
'ms.vscode.js-debug-nightly'
225223
];
226224

227225
interface IBuiltInExtension {
228226
name: string;
229227
version: string;
230228
repo: string;
231-
forQualities?: ReadonlyArray<string>;
232229
metadata: any;
233230
}
234231

235-
const builtInExtensions = (<IBuiltInExtension[]>require('../builtInExtensions.json'))
236-
.filter(({ forQualities }) => !product.quality || forQualities?.includes?.(product.quality) !== false);
232+
const builtInExtensions: IBuiltInExtension[] = JSON.parse(fs.readFileSync(path.join(__dirname, '../../product.json'), 'utf8')).builtInExtensions;
237233

238234
export function packageLocalExtensionsStream(): NodeJS.ReadWriteStream {
239235
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-oss-dev",
33
"version": "1.45.0",
4-
"distro": "dcdad9bf320e13f9ed6032e4a748fe017d057620",
4+
"distro": "376dbb2c860116cca77316a6bc004b0d150e434a",
55
"author": {
66
"name": "Microsoft Corporation"
77
},
@@ -178,4 +178,4 @@
178178
"windows-mutex": "0.3.0",
179179
"windows-process-tree": "0.2.4"
180180
}
181-
}
181+
}

product.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,82 @@
2222
"urlProtocol": "code-oss",
2323
"extensionAllowedProposedApi": [
2424
"ms-vscode.references-view"
25+
],
26+
"builtInExtensions": [
27+
{
28+
"name": "ms-vscode.node-debug",
29+
"version": "1.44.4",
30+
"repo": "https://github.com/Microsoft/vscode-node-debug",
31+
"metadata": {
32+
"id": "b6ded8fb-a0a0-4c1c-acbd-ab2a3bc995a6",
33+
"publisherId": {
34+
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
35+
"publisherName": "ms-vscode",
36+
"displayName": "Microsoft",
37+
"flags": "verified"
38+
},
39+
"publisherDisplayName": "Microsoft"
40+
}
41+
},
42+
{
43+
"name": "ms-vscode.node-debug2",
44+
"version": "1.42.1",
45+
"repo": "https://github.com/Microsoft/vscode-node-debug2",
46+
"metadata": {
47+
"id": "36d19e17-7569-4841-a001-947eb18602b2",
48+
"publisherId": {
49+
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
50+
"publisherName": "ms-vscode",
51+
"displayName": "Microsoft",
52+
"flags": "verified"
53+
},
54+
"publisherDisplayName": "Microsoft"
55+
}
56+
},
57+
{
58+
"name": "ms-vscode.references-view",
59+
"version": "0.0.50",
60+
"repo": "https://github.com/Microsoft/vscode-reference-view",
61+
"metadata": {
62+
"id": "dc489f46-520d-4556-ae85-1f9eab3c412d",
63+
"publisherId": {
64+
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
65+
"publisherName": "ms-vscode",
66+
"displayName": "Microsoft",
67+
"flags": "verified"
68+
},
69+
"publisherDisplayName": "Microsoft"
70+
}
71+
},
72+
{
73+
"name": "ms-vscode.js-debug-companion",
74+
"version": "0.0.4",
75+
"repo": "https://github.com/microsoft/vscode-js-debug-companion",
76+
"metadata": {
77+
"id": "99cb0b7f-7354-4278-b8da-6cc79972169d",
78+
"publisherId": {
79+
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
80+
"publisherName": "ms-vscode",
81+
"displayName": "Microsoft",
82+
"flags": "verified"
83+
},
84+
"publisherDisplayName": "Microsoft"
85+
}
86+
},
87+
{
88+
"name": "ms-vscode.js-debug-nightly",
89+
"version": "2020.3.3117",
90+
"repo": "https://github.com/Microsoft/vscode-js-debug",
91+
"metadata": {
92+
"id": "7acbb4ce-c85a-49d4-8d95-a8054406ae97",
93+
"publisherId": {
94+
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
95+
"publisherName": "ms-vscode",
96+
"displayName": "Microsoft",
97+
"flags": "verified"
98+
},
99+
"publisherDisplayName": "Microsoft"
100+
}
101+
}
25102
]
26103
}

src/vs/platform/extensionManagement/common/extensionManagementUtil.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,4 @@ export function getMaliciousExtensionsSet(report: IReportedExtension[]): Set<str
116116
}
117117

118118
return result;
119-
}
120-
121-
export interface IBuiltInExtension {
122-
name: string;
123-
version: string;
124-
repo: string;
125-
forQualities?: ReadonlyArray<string>;
126-
metadata: any;
127-
}
128-
129-
/**
130-
* Parses the built-in extension JSON data and filters it down to the
131-
* extensions built into this product quality.
132-
*/
133-
export function parseBuiltInExtensions(rawJson: string, productQuality: string | undefined) {
134-
const parsed: IBuiltInExtension[] = JSON.parse(rawJson);
135-
if (!productQuality) {
136-
return parsed;
137-
}
138-
139-
return parsed.filter(ext => ext.forQualities?.indexOf?.(productQuality) !== -1);
140-
}
119+
}

src/vs/platform/extensionManagement/node/extensionManagementService.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
INSTALL_ERROR_MALICIOUS,
2222
INSTALL_ERROR_INCOMPATIBLE
2323
} from 'vs/platform/extensionManagement/common/extensionManagement';
24-
import { areSameExtensions, getGalleryExtensionId, groupByExtension, getMaliciousExtensionsSet, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, ExtensionIdentifierWithVersion, parseBuiltInExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
24+
import { areSameExtensions, getGalleryExtensionId, groupByExtension, getMaliciousExtensionsSet, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, ExtensionIdentifierWithVersion } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
2525
import { localizeManifest } from '../common/extensionNls';
2626
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
2727
import { INativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
@@ -46,7 +46,6 @@ import { CancellationToken } from 'vs/base/common/cancellation';
4646
import { getPathFromAmdModule } from 'vs/base/common/amd';
4747
import { getManifest } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
4848
import { IExtensionManifest, ExtensionType } from 'vs/platform/extensions/common/extensions';
49-
import { IProductService } from 'vs/platform/product/common/productService';
5049

5150
const ERROR_SCANNING_SYS_EXTENSIONS = 'scanningSystem';
5251
const ERROR_SCANNING_USER_EXTENSIONS = 'scanningUser';
@@ -134,7 +133,6 @@ export class ExtensionManagementService extends Disposable implements IExtension
134133
@ILogService private readonly logService: ILogService,
135134
@optional(IDownloadService) private downloadService: IDownloadService,
136135
@ITelemetryService private readonly telemetryService: ITelemetryService,
137-
@IProductService private readonly productService: IProductService,
138136
) {
139137
super();
140138
this.systemExtensionsPath = environmentService.builtinExtensionsPath;
@@ -756,6 +754,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
756754
// Scan other system extensions during development
757755
const devSystemExtensionsPromise = this.getDevSystemExtensionsList()
758756
.then(devSystemExtensionsList => {
757+
console.log(devSystemExtensionsList);
759758
if (devSystemExtensionsList.length) {
760759
return this.scanExtensions(this.devSystemExtensionsPath, ExtensionType.System)
761760
.then(result => {
@@ -947,17 +946,8 @@ export class ExtensionManagementService extends Disposable implements IExtension
947946
return this._devSystemExtensionsPath;
948947
}
949948

950-
private _devSystemExtensionsFilePath: string | null = null;
951-
private get devSystemExtensionsFilePath(): string {
952-
if (!this._devSystemExtensionsFilePath) {
953-
this._devSystemExtensionsFilePath = path.normalize(path.join(getPathFromAmdModule(require, ''), '..', 'build', 'builtInExtensions.json'));
954-
}
955-
return this._devSystemExtensionsFilePath;
956-
}
957-
958949
private getDevSystemExtensionsList(): Promise<string[]> {
959-
return pfs.readFile(this.devSystemExtensionsFilePath, 'utf8')
960-
.then(data => parseBuiltInExtensions(data, this.productService.quality).map(ext => ext.name));
950+
return Promise.resolve(product.builtInExtensions ? product.builtInExtensions.map(e => e.name) : []);
961951
}
962952

963953
private toNonCancellablePromise<T>(promise: Promise<T>): Promise<T> {

src/vs/platform/product/common/productService.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ export interface IProductService extends Readonly<IProductConfiguration> {
1414

1515
}
1616

17+
export interface IBuiltInExtension {
18+
readonly name: string;
19+
readonly version: string;
20+
readonly repo: string;
21+
readonly metadata: any;
22+
}
23+
1724
export interface IProductConfiguration {
1825
readonly version: string;
1926
readonly date?: string;
@@ -30,6 +37,8 @@ export interface IProductConfiguration {
3037
readonly urlProtocol: string;
3138
readonly dataFolderName: string;
3239

40+
readonly builtInExtensions?: IBuiltInExtension[];
41+
3342
readonly downloadUrl?: string;
3443
readonly updateUrl?: string;
3544
readonly target?: string;

0 commit comments

Comments
 (0)