Skip to content

Commit 5ee15b9

Browse files
authored
Merge pull request #277972 from jakebailey/update-types
Update `@types/vscode` package.json too
2 parents 02a7458 + 6668a0e commit 5ee15b9

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

build/azure-pipelines/publish-types/update-types.js

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/azure-pipelines/publish-types/update-types.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@ try {
1414
.toString()
1515
.trim();
1616

17+
const [major, minor] = tag.split('.');
18+
const shorttag = `${major}.${minor}`;
19+
1720
const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vscode-dts/vscode.d.ts`;
18-
const outPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts');
19-
cp.execSync(`curl ${dtsUri} --output ${outPath}`);
21+
const outDtsPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/index.d.ts');
22+
cp.execSync(`curl ${dtsUri} --output ${outDtsPath}`);
23+
24+
updateDTSFile(outDtsPath, shorttag);
2025

21-
updateDTSFile(outPath, tag);
26+
const outPackageJsonPath = path.resolve(process.cwd(), 'DefinitelyTyped/types/vscode/package.json');
27+
const packageJson = JSON.parse(fs.readFileSync(outPackageJsonPath, 'utf-8'));
28+
packageJson.version = shorttag + '.9999';
29+
fs.writeFileSync(outPackageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
2230

23-
console.log(`Done updating vscode.d.ts at ${outPath}`);
31+
console.log(`Done updating vscode.d.ts at ${outDtsPath} and package.json to version ${packageJson.version}`);
2432
} catch (err) {
2533
console.error(err);
2634
console.error('Failed to update types');
2735
process.exit(1);
2836
}
2937

30-
function updateDTSFile(outPath: string, tag: string) {
38+
function updateDTSFile(outPath: string, shorttag: string) {
3139
const oldContent = fs.readFileSync(outPath, 'utf-8');
32-
const newContent = getNewFileContent(oldContent, tag);
40+
const newContent = getNewFileContent(oldContent, shorttag);
3341

3442
fs.writeFileSync(outPath, newContent);
3543
}
@@ -46,21 +54,18 @@ function convertTabsToSpaces(str: string): string {
4654
return str.replace(/\t/gm, value => repeat(' ', value.length));
4755
}
4856

49-
function getNewFileContent(content: string, tag: string) {
57+
function getNewFileContent(content: string, shorttag: string) {
5058
const oldheader = [
5159
`/*---------------------------------------------------------------------------------------------`,
5260
` * Copyright (c) Microsoft Corporation. All rights reserved.`,
5361
` * Licensed under the MIT License. See License.txt in the project root for license information.`,
5462
` *--------------------------------------------------------------------------------------------*/`
5563
].join('\n');
5664

57-
return convertTabsToSpaces(getNewFileHeader(tag) + content.slice(oldheader.length));
65+
return convertTabsToSpaces(getNewFileHeader(shorttag) + content.slice(oldheader.length));
5866
}
5967

60-
function getNewFileHeader(tag: string) {
61-
const [major, minor] = tag.split('.');
62-
const shorttag = `${major}.${minor}`;
63-
68+
function getNewFileHeader(shorttag: string) {
6469
const header = [
6570
`// Type definitions for Visual Studio Code ${shorttag}`,
6671
`// Project: https://github.com/microsoft/vscode`,

0 commit comments

Comments
 (0)