Skip to content

Commit c55599b

Browse files
committed
feat: add types for the public functions
1 parent 460a772 commit c55599b

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

lib.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Convert the vs version (e.g. 2022) or year (e.g. 17.0) to the version number (e.g. 17.0)
3+
* @param {string} vsversion the year (e.g. 2022) or version number (e.g. 17.0)
4+
* @returns {string} the version number (e.g. 17.0)
5+
*/
6+
export function vsversion_to_versionnumber(version: string): string
7+
8+
/**
9+
* Convert the vs version (e.g. 17.0) or year (e.g. 2022) to the year (e.g. 2022)
10+
* @param {string} vsversion the version number (e.g. 17.0) or year (e.g. 2022)
11+
* @returns {string} the year (e.g. 2022)
12+
*/
13+
export function vsversion_to_year(version: string): string
14+
15+
/**
16+
* Find MSVC tools with vswhere
17+
* @param {string} pattern the pattern to search for
18+
* @param {string} version_pattern the version pattern to search for
19+
* @returns {string | null} the path to the found MSVC tools
20+
*/
21+
export function findWithVswhere(version: string): string | null
22+
23+
/**
24+
* Find the vcvarsall.bat file for the given Visual Studio version
25+
* @param {string} vsversion the version of Visual Studio to find (year or version number)
26+
* @returns {string} the path to the vcvarsall.bat file
27+
*/
28+
export function findVcvarsall(version: string): string
29+
30+
/**
31+
* Setup MSVC Developer Command Prompt
32+
* @param {string} arch - Target architecture
33+
* @param {string} sdk - Windows SDK number to build for
34+
* @param {string} toolset - VC++ compiler toolset version
35+
* @param {'true' | 'false'} uwp - Build for Universal Windows Platform
36+
* @param {'true' | 'false'} spectre - Enable Spectre mitigations
37+
* @param {string} vsversion - The Visual Studio version to use. This can be the version number (e.g. 16.0 for 2019) or the year (e.g. "2019").
38+
*/
39+
export function setupMSVCDevCmd(
40+
arch: string,
41+
sdk?: string,
42+
toolset?: string,
43+
uwp?: 'true' | 'false',
44+
spectre?: 'true' | 'false',
45+
vsversion?: string,
46+
)

lib.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const VsYearVersion = {
1919
'2013': '12.0',
2020
}
2121

22+
/**
23+
* Convert the vs version (e.g. 2022) or year (e.g. 17.0) to the version number (e.g. 17.0)
24+
* @param {string} vsversion the year (e.g. 2022) or version number (e.g. 17.0)
25+
* @returns {string} the version number (e.g. 17.0)
26+
*/
2227
function vsversion_to_versionnumber(vsversion) {
2328
if (Object.values(VsYearVersion).includes(vsversion)) {
2429
return vsversion
@@ -31,6 +36,11 @@ function vsversion_to_versionnumber(vsversion) {
3136
}
3237
exports.vsversion_to_versionnumber = vsversion_to_versionnumber
3338

39+
/**
40+
* Convert the vs version (e.g. 17.0) or year (e.g. 2022) to the year (e.g. 2022)
41+
* @param {string} vsversion the version number (e.g. 17.0) or year (e.g. 2022)
42+
* @returns {string} the year (e.g. 2022)
43+
*/
3444
function vsversion_to_year(vsversion) {
3545
if (Object.keys(VsYearVersion).includes(vsversion)) {
3646
return vsversion
@@ -47,6 +57,12 @@ exports.vsversion_to_year = vsversion_to_year
4757

4858
const VSWHERE_PATH = `${PROGRAM_FILES_X86}\\Microsoft Visual Studio\\Installer`
4959

60+
/**
61+
* Find MSVC tools with vswhere
62+
* @param {string} pattern the pattern to search for
63+
* @param {string} version_pattern the version pattern to search for
64+
* @returns {string | null} the path to the found MSVC tools
65+
*/
5066
function findWithVswhere(pattern, version_pattern) {
5167
try {
5268
let installationPath = child_process.execSync(`vswhere -products * ${version_pattern} -prerelease -property installationPath`).toString().trim()
@@ -58,6 +74,11 @@ function findWithVswhere(pattern, version_pattern) {
5874
}
5975
exports.findWithVswhere = findWithVswhere
6076

77+
/**
78+
* Find the vcvarsall.bat file for the given Visual Studio version
79+
* @param {string} vsversion the version of Visual Studio to find (year or version number)
80+
* @returns {string} the path to the vcvarsall.bat file
81+
*/
6182
function findVcvarsall(vsversion) {
6283
const vsversion_number = vsversion_to_versionnumber(vsversion)
6384
let version_pattern
@@ -120,7 +141,15 @@ function filterPathValue(path) {
120141
return paths.filter(unique).join(';')
121142
}
122143

123-
/** See https://github.com/ilammy/msvc-dev-cmd#inputs */
144+
/**
145+
* Setup MSVC Developer Command Prompt
146+
* @param {string} arch - Target architecture
147+
* @param {string} sdk - Windows SDK number to build for
148+
* @param {string} toolset - VC++ compiler toolset version
149+
* @param {'true' | 'false'} uwp - Build for Universal Windows Platform
150+
* @param {'true' | 'false'} spectre - Enable Spectre mitigations
151+
* @param {string} vsversion - The Visual Studio version to use. This can be the version number (e.g. 16.0 for 2019) or the year (e.g. "2019").
152+
*/
124153
function setupMSVCDevCmd(arch, sdk, toolset, uwp, spectre, vsversion) {
125154
if (process.platform != 'win32') {
126155
core.info('This is not a Windows virtual environment, bye!')

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "1.13.0-dev",
44
"description": "GitHub Action to setup Developer Command Prompt for Microsoft Visual C++",
55
"main": "index.js",
6+
"types": "./lib.d.ts",
7+
"type": "commonjs",
68
"scripts": {
79
"lint": "eslint index.js"
810
},

0 commit comments

Comments
 (0)