diff --git a/build/azure-pipelines/publish-types/update-types.js b/build/azure-pipelines/publish-types/update-types.js index 3ceb35bdb5c..e22911b8470 100644 --- a/build/azure-pipelines/publish-types/update-types.js +++ b/build/azure-pipelines/publish-types/update-types.js @@ -13,7 +13,7 @@ try { .execSync('git describe --tags `git rev-list --tags --max-count=1`') .toString() .trim(); - const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vs/vscode.d.ts`; + const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vscode-dts/vscode.d.ts`; const outPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts'); cp.execSync(`curl ${dtsUri} --output ${outPath}`); updateDTSFile(outPath, tag); diff --git a/build/gulpfile.js b/build/gulpfile.js index efb00f69481..dc043d7b5a7 100644 --- a/build/gulpfile.js +++ b/build/gulpfile.js @@ -16,10 +16,10 @@ const { monacoTypecheckTask/* , monacoTypecheckWatchTask */ } = require('./gulpf const { compileExtensionsTask, watchExtensionsTask, compileExtensionMediaTask } = require('./gulpfile.extensions'); // Fast compile for development time -const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compilation.compileTask('src', 'out', false))); +const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compilation.compileApiProposalNames(), compilation.compileTask('src', 'out', false))); gulp.task(compileClientTask); -const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compilation.watchTask('out', false))); +const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(compilation.watchTask('out', false), compilation.watchApiProposalNames()))); gulp.task(watchClientTask); // All diff --git a/build/lib/compilation.js b/build/lib/compilation.js index c6e9196abce..f88da838930 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.watchTask = exports.compileTask = void 0; +exports.watchApiProposalNames = exports.compileApiProposalNames = exports.watchTask = exports.compileTask = void 0; const es = require("event-stream"); const fs = require("fs"); const gulp = require("gulp"); @@ -175,3 +175,65 @@ class MonacoGenerator { } } } +function apiProposalNamesGenerator() { + const stream = es.through(); + const pattern = /vscode\.proposed\.([a-zA-Z]+)\.d\.ts/; + const dtsFolder = path.join(REPO_SRC_FOLDER, 'vscode-dts'); + const generateFile = () => { + try { + const t1 = Date.now(); + const proposalNames = []; + for (let file of fs.readdirSync(dtsFolder)) { + const match = pattern.exec(file); + if (match) { + proposalNames.push(match[1]); + } + } + const source = [ + '/*---------------------------------------------------------------------------------------------', + ' * Copyright (c) Microsoft Corporation. All rights reserved.', + ' * Licensed under the MIT License. See License.txt in the project root for license information.', + ' *--------------------------------------------------------------------------------------------*/', + '', + '// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.', + '', + 'export const apiProposals = {', + `${proposalNames.map(name => `\t${name}: true`).join(',\n')}`, + '};', + 'export type ApiProposalName = keyof typeof apiProposals;', + '', + ].join('\n'); + const outFile = path.join(dtsFolder, '../vs/workbench/services/extensions/common/extensionsApiProposals.ts'); + if (fs.readFileSync(outFile).toString() !== source) { + fs.writeFileSync(outFile, source); + console.log(`Generated 'extensionsApiProposals.ts' in ${Date.now() - t1}ms`); + } + } + catch (err) { + stream.emit('error', err); + } + }; + let handle; + stream.on('data', () => { + clearTimeout(handle); + handle = setTimeout(generateFile, 250); + }); + return stream; +} +function compileApiProposalNames() { + return function () { + const srcPipe = gulp.src('src/vscode-dts/**', { base: 'src' }); + const proposals = apiProposalNamesGenerator(); + return srcPipe.pipe(proposals); + }; +} +exports.compileApiProposalNames = compileApiProposalNames; +function watchApiProposalNames() { + return function () { + const watchSrc = watch('src/vscode-dts/**', { base: 'src', readDelay: 200 }); + const proposals = apiProposalNamesGenerator(); + proposals.write(undefined); // send something to trigger initial generate + return watchSrc.pipe(proposals); + }; +} +exports.watchApiProposalNames = watchApiProposalNames; diff --git a/build/lib/compilation.ts b/build/lib/compilation.ts index 3db8cf0f917..47454c76dd4 100644 --- a/build/lib/compilation.ts +++ b/build/lib/compilation.ts @@ -211,3 +211,75 @@ class MonacoGenerator { } } } + +function apiProposalNamesGenerator() { + const stream = es.through(); + + const pattern = /vscode\.proposed\.([a-zA-Z]+)\.d\.ts/; + const dtsFolder = path.join(REPO_SRC_FOLDER, 'vscode-dts'); + + const generateFile = () => { + + try { + + const t1 = Date.now(); + const proposalNames: string[] = []; + for (let file of fs.readdirSync(dtsFolder)) { + const match = pattern.exec(file); + if (match) { + proposalNames.push(match[1]); + } + } + + const source = [ + '/*---------------------------------------------------------------------------------------------', + ' * Copyright (c) Microsoft Corporation. All rights reserved.', + ' * Licensed under the MIT License. See License.txt in the project root for license information.', + ' *--------------------------------------------------------------------------------------------*/', + '', + '// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.', + '', + 'export const apiProposals = {', + `${proposalNames.map(name => `\t${name}: true`).join(',\n')}`, + '};', + 'export type ApiProposalName = keyof typeof apiProposals;', + '', + ].join('\n'); + + const outFile = path.join(dtsFolder, '../vs/workbench/services/extensions/common/extensionsApiProposals.ts'); + + if (fs.readFileSync(outFile).toString() !== source) { + fs.writeFileSync(outFile, source); + console.log(`Generated 'extensionsApiProposals.ts' in ${Date.now() - t1}ms`); + } + + } catch (err) { + stream.emit('error', err); + } + }; + + let handle: NodeJS.Timeout; + stream.on('data', () => { + clearTimeout(handle); + handle = setTimeout(generateFile, 250); + }); + + return stream; +} + +export function compileApiProposalNames(): () => NodeJS.ReadWriteStream { + return function () { + const srcPipe = gulp.src('src/vscode-dts/**', { base: 'src' }); + const proposals = apiProposalNamesGenerator(); + return srcPipe.pipe(proposals); + }; +} + +export function watchApiProposalNames(): () => NodeJS.ReadWriteStream { + return function () { + const watchSrc = watch('src/vscode-dts/**', { base: 'src', readDelay: 200 }); + const proposals = apiProposalNamesGenerator(); + proposals.write(undefined); // send something to trigger initial generate + return watchSrc.pipe(proposals); + }; +} diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts new file mode 100644 index 00000000000..f1151e353ec --- /dev/null +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -0,0 +1,11 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. + +export const apiProposals = { + +}; +export type ApiProposalName = keyof typeof apiProposals;