Skip to content

Commit

Permalink
win!: update supported vs versions
Browse files Browse the repository at this point in the history
Drop VS2017 support for Node.js v22 and above.

Refs: nodejs/build#3603
Refs: nodejs/node#45427
  • Loading branch information
StefanStojanovic committed Jan 16, 2024
1 parent ae8478e commit 5f6d390
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 19 deletions.
21 changes: 19 additions & 2 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class VisualStudioFinder {
}

const checks = [
() => this.findVisualStudio2017OrNewer(),
() => this.findVisualStudio2019OrNewer(),
() => this.findVisualStudio2017(),
() => this.findVisualStudio2015(),
() => this.findVisualStudio2013()
]
Expand Down Expand Up @@ -113,9 +114,25 @@ class VisualStudioFinder {
throw new Error('Could not find any Visual Studio installation to use')
}

// Invoke the PowerShell script to get information about Visual Studio 2019
// or newer installations
async findVisualStudio2019OrNewer () {
return this.findNewVS()
}

// Invoke the PowerShell script to get information about Visual Studio 2017
async findVisualStudio2017 () {
if (this.nodeSemver.major >= 22) {
this.addLog(
'not looking for VS2017 as it is only supported up to Node.js 21')
return null
}
return this.findNewVS()
}

// Invoke the PowerShell script to get information about Visual Studio 2017
// or newer installations
async findVisualStudio2017OrNewer () {
async findNewVS () {
const ps = path.join(process.env.SystemRoot, 'System32',
'WindowsPowerShell', 'v1.0', 'powershell.exe')
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
Expand Down
89 changes: 72 additions & 17 deletions test/test-find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('find-visualstudio', function () {
it('VS2013', async function () {
const finder = new TestVisualStudioFinder(semverV1, null)

finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
return finder.parseData(new Error(), '', '')
}
finder.findVisualStudio2019OrNewer = async () => {
return finder.parseData(new Error(), '', '')
}
finder.regSearchKeys = async (keys, value, addOpts) => {
Expand Down Expand Up @@ -69,7 +72,12 @@ describe('find-visualstudio', function () {
patch: 0
}, null)

finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
Expand All @@ -96,7 +104,10 @@ describe('find-visualstudio', function () {
it('VS2015', async function () {
const finder = new TestVisualStudioFinder(semverV1, null)

finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
return finder.parseData(new Error(), '', '')
}
finder.findVisualStudio2019OrNewer = async () => {
return finder.parseData(new Error(), '', '')
}
finder.regSearchKeys = async (keys, value, addOpts) => {
Expand Down Expand Up @@ -208,7 +219,13 @@ describe('find-visualstudio', function () {
const finder = new TestVisualStudioFinder(semverV1, null)

poison(finder, 'regSearchKeys')
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2017_BuildTools_minimal.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2017_BuildTools_minimal.txt')
const data = fs.readFileSync(file)
Expand All @@ -234,7 +251,13 @@ describe('find-visualstudio', function () {
const finder = new TestVisualStudioFinder(semverV1, null)

poison(finder, 'regSearchKeys')
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2017_Community_workload.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2017_Community_workload.txt')
const data = fs.readFileSync(file)
Expand All @@ -260,7 +283,12 @@ describe('find-visualstudio', function () {
const finder = new TestVisualStudioFinder(semverV1, null)

poison(finder, 'regSearchKeys')
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
Expand All @@ -285,7 +313,13 @@ describe('find-visualstudio', function () {
const finder = new TestVisualStudioFinder(semverV1, null)

poison(finder, 'regSearchKeys')
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2019_Preview.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2019_Preview.txt')
const data = fs.readFileSync(file)
Expand All @@ -311,7 +345,13 @@ describe('find-visualstudio', function () {
const finder = new TestVisualStudioFinder(semverV1, null)

poison(finder, 'regSearchKeys')
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2019_BuildTools_minimal.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2019_BuildTools_minimal.txt')
const data = fs.readFileSync(file)
Expand All @@ -337,7 +377,13 @@ describe('find-visualstudio', function () {
const finder = new TestVisualStudioFinder(semverV1, null)

poison(finder, 'regSearchKeys')
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2019_Community_workload.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2019_Community_workload.txt')
const data = fs.readFileSync(file)
Expand Down Expand Up @@ -372,7 +418,13 @@ describe('find-visualstudio', function () {
finder.msBuildPathExists = (path) => {
return true
}
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2022_Community_workload.txt')
const data = fs.readFileSync(file)
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const file = path.join(__dirname, 'fixtures',
'VS_2022_Community_workload.txt')
const data = fs.readFileSync(file)
Expand All @@ -394,7 +446,7 @@ describe('find-visualstudio', function () {
})

function allVsVersions (finder) {
finder.findVisualStudio2017OrNewer = async () => {
finder.findVisualStudio2017 = async () => {
const data0 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2017_Unusable.txt')))
const data1 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
Expand All @@ -403,16 +455,19 @@ describe('find-visualstudio', function () {
'VS_2017_Community_workload.txt')))
const data3 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2017_Express.txt')))
const data4 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
const data = JSON.stringify(data0.concat(data1, data2, data3))
return finder.parseData(null, data, '')
}
finder.findVisualStudio2019OrNewer = async () => {
const data0 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2019_Preview.txt')))
const data5 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
const data1 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2019_BuildTools_minimal.txt')))
const data6 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
const data2 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2019_Community_workload.txt')))
const data7 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
const data3 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures',
'VS_2022_Community_workload.txt')))
const data = JSON.stringify(data0.concat(data1, data2, data3, data4,
data5, data6, data7))
const data = JSON.stringify(data0.concat(data1, data2, data3))
return finder.parseData(null, data, '')
}
finder.regSearchKeys = async (keys, value, addOpts) => {
Expand Down

0 comments on commit 5f6d390

Please sign in to comment.