mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
add generated file api proposal names, add compile script that generates this file
This commit is contained in:
parent
d90dd1355b
commit
da967b591e
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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;
|
Loading…
Reference in a new issue