mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Update build definition
This commit is contained in:
parent
77fa61bb8a
commit
f5f559de80
43
build/azure-pipelines/publish-types/check-version.ts
Normal file
43
build/azure-pipelines/publish-types/check-version.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as cp from 'child_process';
|
||||
|
||||
let tag = '';
|
||||
try {
|
||||
tag = cp
|
||||
.execSync('git describe --tags `git rev-list --tags --max-count=1`')
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
if (isValidTag(tag)) {
|
||||
throw Error(`Invalid tag ${tag}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
console.error('Failed to update types');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function isValidTag(t: string) {
|
||||
if (t.split('.').length !== 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const [major, minor, bug] = t.split('.');
|
||||
|
||||
// Only release for tags like 1.34.0
|
||||
if (bug !== '0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parseInt(major, 10) === NaN || parseInt(minor, 10) === NaN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -9,33 +9,34 @@ steps:
|
|||
inputs:
|
||||
versionSpec: "10.15.1"
|
||||
|
||||
- bash: git clone https://github.com/octref/vscode-DefinitelyTyped.git
|
||||
displayName: Clone vscode-DefinitelyTyped
|
||||
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
|
||||
inputs:
|
||||
versionSpec: "1.10.1"
|
||||
|
||||
- bash: |
|
||||
# Install build dependencies
|
||||
(cd build && yarn)
|
||||
node build/azure-pipelines/publish-types/check-version.js
|
||||
displayName: vscode-DefinitelyTyped
|
||||
|
||||
- bash: |
|
||||
git config user.email "vscode@microsoft.com"
|
||||
git config user.name "VSCode"
|
||||
|
||||
git clone https://github.com/octref/vscode-DefinitelyTyped.git --depth=1 -b vscode
|
||||
|
||||
cd vscode-DefinitelyTyped
|
||||
|
||||
git remote add dt https://github.com/DefinitelyTyped/DefinitelyTyped.git
|
||||
git fetch dt
|
||||
git checkout vscode
|
||||
git rebase dt/master
|
||||
|
||||
cd ..
|
||||
|
||||
node build/azure-pipelines/publish-types/update-types.js
|
||||
|
||||
TAG_VERSION=git describe --tags `git rev-list --tags --max-count=1`
|
||||
git commit -am 'VS Code $TAG_VERSION Extension API'
|
||||
git push origin vscode
|
||||
git push origin master
|
||||
|
||||
workingDirectory: vscode-DefinitelyTyped
|
||||
displayName: Preapare vscode-DefinitelyTyped
|
||||
|
||||
- bash: |
|
||||
node build/azure-pipelines/publish-types/update-types.js
|
||||
displayName: Update vscode-DefinitelyTyped
|
||||
|
||||
- bash: |
|
||||
TAG_VERSION=git describe --tags `git rev-list --tags --max-count=1`
|
||||
git commit -am 'VS Code $TAG_VERSION Extension API'
|
||||
git push origin vscode
|
||||
displayName: Commit vscode-DefinitelyTyped
|
||||
|
|
|
@ -16,10 +16,6 @@ try {
|
|||
.toString()
|
||||
.trim();
|
||||
|
||||
if (isValidTag(tag)) {
|
||||
throw Error(`Invalid tag ${tag}`);
|
||||
}
|
||||
|
||||
const dtsUri = `https://raw.githubusercontent.com/microsoft/vscode/${tag}/src/vs/vscode.d.ts`;
|
||||
const outPath = path.resolve(process.cwd(), 'vscode-DefinitelyTyped/types/vscode/index.d.ts');
|
||||
cp.execSync(`curl ${dtsUri} -O ${outPath}`);
|
||||
|
@ -33,25 +29,6 @@ try {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
function isValidTag(t: string) {
|
||||
if (t.split('.').length !== 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const [major, minor, bug] = t.split('.');
|
||||
|
||||
// Only release for tags like 1.34.0
|
||||
if (bug !== '0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parseInt(major, 10) === NaN || parseInt(minor, 10) === NaN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateDTSFile(outPath: string, tag: string) {
|
||||
const oldContent = fs.readFileSync(outPath, 'utf-8');
|
||||
const newContent = getNewFileContent(oldContent, tag);
|
||||
|
@ -60,31 +37,34 @@ function updateDTSFile(outPath: string, tag: string) {
|
|||
}
|
||||
|
||||
function getNewFileContent(content: string, tag: string) {
|
||||
const oldheader = `/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
`;
|
||||
const oldheader = [
|
||||
`/*---------------------------------------------------------------------------------------------`,
|
||||
`* Copyright (c) Microsoft Corporation. All rights reserved.`,
|
||||
`* Licensed under the MIT License. See License.txt in the project root for license information.`,
|
||||
`*--------------------------------------------------------------------------------------------*/`
|
||||
].join('\n');
|
||||
|
||||
return getNewFileHeader(tag) + content.slice(oldheader.length + 2);
|
||||
}
|
||||
|
||||
function getNewFileHeader(tag: string) {
|
||||
const header = `// Type definitions for Visual Studio Code ${tag}
|
||||
// Project: https://github.com/microsoft/vscode
|
||||
// Definitions by: Visual Studio Code Team, Microsoft <https://github.com/Microsoft>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
const header = [
|
||||
`// Type definitions for Visual Studio Code ${tag}`,
|
||||
`// Project: https://github.com/microsoft/vscode`,
|
||||
`// Definitions by: Visual Studio Code Team, Microsoft <https://github.com/Microsoft>`,
|
||||
`// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped`,
|
||||
``,
|
||||
`/*---------------------------------------------------------------------------------------------`,
|
||||
` * Copyright (c) Microsoft Corporation. All rights reserved.`,
|
||||
` * Licensed under the MIT License.`,
|
||||
` * See https://github.com/Microsoft/vscode/blob/master/LICENSE.txt for license information.`,
|
||||
` *--------------------------------------------------------------------------------------------*/`,
|
||||
``,
|
||||
`/**`,
|
||||
` * Type Definition for Visual Studio Code ${tag} Extension API`,
|
||||
` * See https://code.visualstudio.com/api for more information`,
|
||||
` */`
|
||||
].join('\n');
|
||||
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
* See https://github.com/Microsoft/vscode/blob/master/LICENSE.txt for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Type Definition for Visual Studio Code ${tag} Extension API
|
||||
* See https://code.visualstudio.com/api for more information
|
||||
*/`;
|
||||
|
||||
return header;
|
||||
return header;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue