From b42e7966177f006f3d1aab1d27885d8372c8ed01 Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Thu, 2 Nov 2023 19:51:24 +0100 Subject: [PATCH 01/17] docs: remove outdated update engines.node reference in 10.0.0 changelog --- CHANGELOG.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98315add5e..bcd167d9bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ * the `Gyp` class exported is now created using ECMAScript classes and therefore might have small differences to classes that were previously created with `util.inherits`. * All internal functions have been coverted to return promises and no longer accept callbacks. This is not a breaking change for users but may be breaking to consumers of `node-gyp` if you are requiring internal functions directly. * `node-gyp` now supports node `^16.14.0 || >=18.0.0` -* update engines.node to ^14.17.0 || ^16.13.0 || >=18.0.0 ### Features @@ -706,11 +705,11 @@ Republish of v5.0.6 with unnecessary tarball removed from pack file. * [[`94c39c604e`](https://github.com/nodejs/node-gyp/commit/94c39c604e)] - **gyp**: fix ninja build failure (GYP patch) (Daniel Bevenius) [nodejs/node#12484](https://github.com/nodejs/node/pull/12484) * [[`e8ea74e0fa`](https://github.com/nodejs/node-gyp/commit/e8ea74e0fa)] - **tools**: patch gyp to avoid xcrun errors (Ujjwal Sharma) [nodejs/node#21520](https://github.com/nodejs/node/pull/21520) * [[`ea9aff44f2`](https://github.com/nodejs/node-gyp/commit/ea9aff44f2)] - **tools**: fix "the the" typos in comments (Masashi Hirano) [nodejs/node#20716](https://github.com/nodejs/node/pull/20716) -* [[`207e5aa4fd`](https://github.com/nodejs/node-gyp/commit/207e5aa4fd)] - **gyp**: implement LD/LDXX for ninja and FIPS (Sam Roberts) +* [[`207e5aa4fd`](https://github.com/nodejs/node-gyp/commit/207e5aa4fd)] - **gyp**: implement LD/LDXX for ninja and FIPS (Sam Roberts) * [[`b416c5f4b7`](https://github.com/nodejs/node-gyp/commit/b416c5f4b7)] - **gyp**: enable cctest to use objects (gyp part) (Daniel Bevenius) [nodejs/node#12450](https://github.com/nodejs/node/pull/12450) * [[`40692d016b`](https://github.com/nodejs/node-gyp/commit/40692d016b)] - **gyp**: add compile\_commands.json gyp generator (Ben Noordhuis) [nodejs/node#12450](https://github.com/nodejs/node/pull/12450) * [[`fc3c4e2b10`](https://github.com/nodejs/node-gyp/commit/fc3c4e2b10)] - **gyp**: float gyp patch for long filenames (Anna Henningsen) [nodejs/node#7963](https://github.com/nodejs/node/pull/7963) -* [[`8aedbfdef6`](https://github.com/nodejs/node-gyp/commit/8aedbfdef6)] - **gyp**: backport GYP fix to fix AIX shared suffix (Stewart Addison) +* [[`8aedbfdef6`](https://github.com/nodejs/node-gyp/commit/8aedbfdef6)] - **gyp**: backport GYP fix to fix AIX shared suffix (Stewart Addison) * [[`6cd84b84fc`](https://github.com/nodejs/node-gyp/commit/6cd84b84fc)] - **test**: formatting and minor fixes for execFileSync replacement (Rod Vagg) [#1521](https://github.com/nodejs/node-gyp/pull/1521) * [[`60e421363f`](https://github.com/nodejs/node-gyp/commit/60e421363f)] - **test**: added test/processExecSync.js for when execFileSync is not available. (Rohit Hazra) [#1492](https://github.com/nodejs/node-gyp/pull/1492) * [[`969447c5bd`](https://github.com/nodejs/node-gyp/commit/969447c5bd)] - **deps**: bump request to 2.8.7, fixes heok/hawk issues (Rohit Hazra) [#1492](https://github.com/nodejs/node-gyp/pull/1492) @@ -772,7 +771,7 @@ Republish of v5.0.6 with unnecessary tarball removed from pack file. ## v3.5.0 2017-01-10 -* [[`762d19a39e`](https://github.com/nodejs/node-gyp/commit/762d19a39e)] - \[doc\] merge History.md and CHANGELOG.md (Rod Vagg) +* [[`762d19a39e`](https://github.com/nodejs/node-gyp/commit/762d19a39e)] - \[doc\] merge History.md and CHANGELOG.md (Rod Vagg) * [[`80fc5c3d31`](https://github.com/nodejs/node-gyp/commit/80fc5c3d31)] - Fix deprecated dependency warning (Simone Primarosa) [#1069](https://github.com/nodejs/node-gyp/pull/1069) * [[`05c44944fd`](https://github.com/nodejs/node-gyp/commit/05c44944fd)] - Open the build file with universal-newlines mode (Guy Margalit) [#1053](https://github.com/nodejs/node-gyp/pull/1053) * [[`37ae7be114`](https://github.com/nodejs/node-gyp/commit/37ae7be114)] - Try python launcher when stock python is python 3. (Ben Noordhuis) [#992](https://github.com/nodejs/node-gyp/pull/992) @@ -829,7 +828,7 @@ Republish of v5.0.6 with unnecessary tarball removed from pack file. * [[`0e2dfda1f3`](https://github.com/nodejs/node-gyp/commit/0e2dfda1f3)] - Fix test/test-options when run through `npm test`. (Ben Noordhuis) [#755](https://github.com/nodejs/node-gyp/pull/755) * [[`9bfa0876b4`](https://github.com/nodejs/node-gyp/commit/9bfa0876b4)] - Add support for AIX (Michael Dawson) [#753](https://github.com/nodejs/node-gyp/pull/753) * [[`a8d441a0a2`](https://github.com/nodejs/node-gyp/commit/a8d441a0a2)] - Update README for Windows 10 support. (Jason Williams) [#766](https://github.com/nodejs/node-gyp/pull/766) -* [[`d1d6015276`](https://github.com/nodejs/node-gyp/commit/d1d6015276)] - Update broken links and switch to HTTPS. (andrew morton) +* [[`d1d6015276`](https://github.com/nodejs/node-gyp/commit/d1d6015276)] - Update broken links and switch to HTTPS. (andrew morton) ## v3.1.0 2015-11-14 From cff9ac2c3083769a383e00bc60b91562f03116e3 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Mon, 6 Nov 2023 09:35:09 -0700 Subject: [PATCH 02/17] chore: only run release please on push And then run release-please tests on release PRs --- .github/workflows/release-please.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index f942e74122..de4cb087a7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -13,7 +13,7 @@ jobs: permissions: contents: write # to create release commit (google-github-actions/release-please-action) pull-requests: write # to create release PR (google-github-actions/release-please-action) - + if: github.event_name == 'push' runs-on: ubuntu-latest steps: - uses: google-github-actions/release-please-action@v2 @@ -64,5 +64,5 @@ jobs: test: name: Release Test needs: [ release-please ] - if: needs.release-please.outputs.pr + if: needs.release-please.outputs.pr || startsWith(github.head_ref, 'release-v') uses: ./.github/workflows/tests.yml From ae8478ec32d9b2fa71b591ac22cdf867ef2e9a7d Mon Sep 17 00:00:00 2001 From: Artur Yapparov Date: Mon, 25 Dec 2023 16:07:56 +0300 Subject: [PATCH 03/17] docs: remove outdated Node versions from readme (#2955) Refs: https://github.com/nodejs/node-gyp/issues/2953 --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f46ee06308..a4aa6f893a 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,8 @@ addons. Note that `node-gyp` is _not_ used to build Node.js itself. -Multiple target versions of Node.js are supported (i.e. `0.8`, ..., `4`, `5`, `6`, -etc.), regardless of what version of Node.js is actually installed on your system -(`node-gyp` downloads the necessary development files or headers for the target version). +All current and LTS target versions of Node.js are supported. Depending on what version of Node.js is actually installed on your system +`node-gyp` downloads the necessary development files or headers for the target version. List of stable Node.js versions can be found on [Node.js website](https://nodejs.org/en/about/previous-releases). ## Features From 7f58bc8144edf8beb44736d68386044b450e1885 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 17 Jan 2024 07:52:35 +0100 Subject: [PATCH 04/17] Keep GitHub Actions up to date with Dependabot * https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..15e494ec86 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +# Keep GitHub Actions up to date with Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" From 3f0df7e9334e49e8c7f6fdbbb9e1e6c5a8cca53b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 08:15:15 +0100 Subject: [PATCH 05/17] build(deps): bump actions/setup-python from 4 to 5 (#2960) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5017bcd9f8..6835cceed5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -106,7 +106,7 @@ jobs: with: node-version: ${{ matrix.node }} - name: Use Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} env: From b1f1808bfff0d51e6d3eb696ab6a5b89b7b9630c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 Jan 2024 20:11:30 +0100 Subject: [PATCH 06/17] build(deps): bump google-github-actions/release-please-action (#2961) Bumps [google-github-actions/release-please-action](https://github.com/google-github-actions/release-please-action) from 2 to 4. - [Release notes](https://github.com/google-github-actions/release-please-action/releases) - [Changelog](https://github.com/google-github-actions/release-please-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/google-github-actions/release-please-action/compare/v2...v4) --- updated-dependencies: - dependency-name: google-github-actions/release-please-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index de4cb087a7..114666d043 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -16,7 +16,7 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v2 + - uses: google-github-actions/release-please-action@v4 id: release with: package-name: node-gyp From c24cead6e3991a3c5a612f0d333c4b026541b6d9 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 25 Jan 2024 07:32:33 +0100 Subject: [PATCH 07/17] Revert "build(deps): bump google-github-actions/release-please-action from 2 to 4" (#2967) --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 114666d043..de4cb087a7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -16,7 +16,7 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v4 + - uses: google-github-actions/release-please-action@v2 id: release with: package-name: node-gyp From a87d0bf458e57d9a8c8c113250bf6a9da952016d Mon Sep 17 00:00:00 2001 From: Davee Date: Thu, 25 Jan 2024 21:23:49 +0100 Subject: [PATCH 08/17] refine readme Visual C++ Build Environment text for clarity (#2965) * refine readme text for clarity * refine readme Visual C++ build env for clarity --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index a4aa6f893a..d43d617b78 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,7 @@ Install the current [version of Python](https://devguide.python.org/versions/) f [Microsoft Store](https://apps.microsoft.com/store/search?publisher=Python+Software+Foundation). Install tools and configuration manually: - * Install Visual C++ Build Environment: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) - (using "Visual C++ build tools" if using a version older than VS2019, otherwise use "Desktop development with C++" workload) or [Visual Studio Community](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community) - (using the "Desktop development with C++" workload) + * Install Visual C++ Build Environment: For Visual Studio 2019 or later, use the `Desktop development with C++` workload from [Visual Studio Community](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community). For a version older than Visual Studio 2019, install [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) with the `Visual C++ build tools` option. If the above steps didn't work for you, please visit [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules) for additional tips. From 7705a22f31a62076e9f8429780a459f4ad71ea4c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 29 Jan 2024 19:12:57 +0100 Subject: [PATCH 09/17] docs: npm is currently v10 (#2970) --- docs/Updating-npm-bundled-node-gyp.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/Updating-npm-bundled-node-gyp.md b/docs/Updating-npm-bundled-node-gyp.md index 5759add3fe..7f5794ba05 100644 --- a/docs/Updating-npm-bundled-node-gyp.md +++ b/docs/Updating-npm-bundled-node-gyp.md @@ -14,7 +14,7 @@ This means that while `node-gyp` doesn't get installed into your `$PATH` by defa attempt to `npm install` a native add-on. Sometimes, you may need to update npm's internal node-gyp to a newer version than what is installed. A simple `npm install -g node-gyp` -_won't_ do the trick since npm will still continue to use its internal copy over the global one. +_won't_ do the trick since npm will continue to use its internal copy over the global one. So instead: @@ -29,7 +29,7 @@ npm --version Unix is easy. Just run the following command. -If your npm is version ___7 or 8___, do: +If your npm is version ___7 or higher___, do: ```bash $ npm explore npm/node_modules/@npmcli/run-script -g -- npm_config_global=false npm install node-gyp@latest ``` @@ -43,10 +43,9 @@ If the command fails with a permissions error, please try `sudo` and then the co ## Windows -Windows is a bit trickier, since `npm` might be installed to the "Program Files" directory, which needs admin privileges in order to -modify on current Windows. Therefore, run the following commands __inside a `cmd.exe` started with "Run as Administrator"__: +Windows is a bit trickier, since `npm` might be installed in the "Program Files" directory, which needs admin privileges to modify current Windows. Therefore, run the following commands __inside a `cmd.exe` started with "Run as Administrator"__: -First we need to find the location of `node`. If you don't already know the location that `node.exe` got installed to, then run: +First, we need to find the location of `node`. If you don't already know the location that `node.exe` got installed to, then run: ```bash $ where node ``` @@ -56,7 +55,7 @@ Now `cd` to the directory that `node.exe` is contained in e.g.: $ cd "C:\Program Files\nodejs" ``` -If your npm version is ___7 or 8___, do: +If your npm version is ___7 or higher___, do: ```bash cd node_modules\npm\node_modules\@npmcli\run-script ``` From 329873141f0d3e3787d3c006801431da04e4ed0c Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Mon, 29 Jan 2024 14:03:30 -0500 Subject: [PATCH 10/17] src: add support for locally installed headers (#2964) Some linux distros allow headers to be installed through tools like rpm. If the runtime sets process.config.variables.use_prefix_to_find_headers, look for matching headers based on the directory set for the prefix in process.config.variables.prefix Signed-off-by: Michael Dawson Co-authored-by: Luke Karrys --- lib/configure.js | 28 +++++++- test/test-configure-nodedir.js | 123 +++++++++++++++++++++++++++++++++ test/test-configure-python.js | 1 + 3 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 test/test-configure-nodedir.js diff --git a/lib/configure.js b/lib/configure.js index 8da41a849d..e4b8c94e3d 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -1,6 +1,6 @@ 'use strict' -const { promises: fs } = require('graceful-fs') +const { promises: fs, readFileSync } = require('graceful-fs') const path = require('path') const log = require('./log') const os = require('os') @@ -13,6 +13,10 @@ const { findAccessibleSync } = require('./util') const { findPython } = require('./find-python') const { findVisualStudio } = win ? require('./find-visualstudio') : {} +const majorRe = /^#define NODE_MAJOR_VERSION (\d+)/m +const minorRe = /^#define NODE_MINOR_VERSION (\d+)/m +const patchRe = /^#define NODE_PATCH_VERSION (\d+)/m + async function configure (gyp, argv) { const buildDir = path.resolve('build') const configNames = ['config.gypi', 'common.gypi'] @@ -27,6 +31,28 @@ async function configure (gyp, argv) { // 'python' should be set by now process.env.PYTHON = python + if (!gyp.opts.nodedir && + process.config.variables.use_prefix_to_find_headers) { + // check if the headers can be found using the prefix specified + // at build time. Use them if they match the version expected + const prefix = process.config.variables.node_prefix + let availVersion + try { + const nodeVersionH = readFileSync(path.join(prefix, + 'include', 'node', 'node_version.h'), { encoding: 'utf8' }) + const major = nodeVersionH.match(majorRe)[1] + const minor = nodeVersionH.match(minorRe)[1] + const patch = nodeVersionH.match(patchRe)[1] + availVersion = major + '.' + minor + '.' + patch + } catch {} + if (availVersion === release.version) { + // ok version matches, use the headers + gyp.opts.nodedir = prefix + log.verbose('using local node headers based on prefix', + 'setting nodedir to ' + gyp.opts.nodedir) + } + } + if (gyp.opts.nodedir) { // --nodedir was specified. use that for the dev files nodeDir = gyp.opts.nodedir.replace(/^~/, os.homedir()) diff --git a/test/test-configure-nodedir.js b/test/test-configure-nodedir.js new file mode 100644 index 0000000000..a6debded06 --- /dev/null +++ b/test/test-configure-nodedir.js @@ -0,0 +1,123 @@ +'use strict' + +const { describe, it } = require('mocha') +const assert = require('assert') +const path = require('path') +const os = require('os') +const gyp = require('../lib/node-gyp') +const requireInject = require('require-inject') +const semver = require('semver') + +const versionSemver = semver.parse(process.version) + +const configure = requireInject('../lib/configure', { + 'graceful-fs': { + openSync: () => 0, + closeSync: () => {}, + existsSync: () => true, + readFileSync: () => '#define NODE_MAJOR_VERSION ' + versionSemver.major + '\n' + + '#define NODE_MINOR_VERSION ' + versionSemver.minor + '\n' + + '#define NODE_PATCH_VERSION ' + versionSemver.patch + '\n', + promises: { + stat: async () => ({}), + mkdir: async () => {}, + writeFile: async () => {} + } + } +}) + +const configure2 = requireInject('../lib/configure', { + 'graceful-fs': { + openSync: () => 0, + closeSync: () => {}, + existsSync: () => true, + readFileSync: () => '#define NODE_MAJOR_VERSION 8\n' + + '#define NODE_MINOR_VERSION 0\n' + + '#define NODE_PATCH_VERSION 0\n', + promises: { + stat: async () => ({}), + mkdir: async () => {}, + writeFile: async () => {} + } + } +}) + +const SPAWN_RESULT = cb => ({ on: function () { cb() } }) + +const driveLetter = os.platform() === 'win32' ? `${process.cwd().split(path.sep)[0]}` : '' +function checkTargetPath (target, value) { + let targetPath = path.join(path.sep, target, 'include', + 'node', 'common.gypi') + if (process.platform === 'win32') { + targetPath = driveLetter + targetPath + } + + return targetPath.localeCompare(value) === 0 +} + +describe('configure-nodedir', function () { + it('configure nodedir with node-gyp command line', function (done) { + const prog = gyp() + prog.parseArgv(['dummy_prog', 'dummy_script', '--nodedir=' + path.sep + 'usr']) + + prog.spawn = function (program, args) { + for (let i = 0; i < args.length; i++) { + if (checkTargetPath('usr', args[i])) { + return SPAWN_RESULT(done) + } + }; + assert.fail() + } + configure(prog, [], assert.fail) + }) + + if (process.config.variables.use_prefix_to_find_headers) { + it('use-prefix-to-find-headers build time option - match', function (done) { + const prog = gyp() + prog.parseArgv(['dummy_prog', 'dummy_script']) + + prog.spawn = function (program, args) { + for (let i = 0; i < args.length; i++) { + const nodedir = process.config.variables.node_prefix + if (checkTargetPath(nodedir, args[i])) { + return SPAWN_RESULT(done) + } + }; + assert.fail() + } + configure(prog, [], assert.fail) + }) + + it('use-prefix-to-find-headers build time option - no match', function (done) { + const prog = gyp() + prog.parseArgv(['dummy_prog', 'dummy_script']) + + prog.spawn = function (program, args) { + for (let i = 0; i < args.length; i++) { + const nodedir = process.config.variables.node_prefix + if (checkTargetPath(nodedir, args[i])) { + assert.fail() + } + }; + return SPAWN_RESULT(done) + } + configure2(prog, [], assert.fail) + }) + + it('use-prefix-to-find-headers build time option, target specified', function (done) { + const prog = gyp() + prog.parseArgv(['dummy_prog', 'dummy_script', '--target=8.0.0']) + + prog.spawn = function (program, args) { + for (let i = 0; i < args.length; i++) { + const nodedir = process.config.variables.node_prefix + if (checkTargetPath(nodedir, args[i])) { + assert.fail() + } + }; + return SPAWN_RESULT(done) + } + configure(prog, [], assert.fail) + }) + } +}) diff --git a/test/test-configure-python.js b/test/test-configure-python.js index eee230a496..094e79182c 100644 --- a/test/test-configure-python.js +++ b/test/test-configure-python.js @@ -11,6 +11,7 @@ const configure = requireInject('../lib/configure', { 'graceful-fs': { openSync: () => 0, closeSync: () => {}, + existsSync: () => {}, promises: { stat: async () => ({}), mkdir: async () => {}, From 109e3d4245504a7b75c99f578e1203c0ef4b518e Mon Sep 17 00:00:00 2001 From: Jaroslav <375519+jarig@users.noreply.github.com> Date: Fri, 9 Feb 2024 03:33:54 +0200 Subject: [PATCH 11/17] feat: improve visual studio detection (#2957) Detect visual studio installation using the VSSetup module and Get-VSSetupInstance method. It works even in systems with the Constrained language mode of PowerShell. --- README.md | 3 + lib/find-visualstudio.js | 87 +++- .../VSSetup_VS_2019_Professional_workload.txt | 235 +++++++++++ .../VSSetup_VS_2022_VS2019_workload.txt | 371 ++++++++++++++++++ .../VSSetup_VS_2022_multiple_install.txt | 369 +++++++++++++++++ test/fixtures/VSSetup_VS_2022_workload.txt | 136 +++++++ .../VSSetup_VS_2022_workload_missing_sdk.txt | 152 +++++++ test/test-find-visualstudio.js | 215 ++++++++-- 8 files changed, 1517 insertions(+), 51 deletions(-) create mode 100644 test/fixtures/VSSetup_VS_2019_Professional_workload.txt create mode 100644 test/fixtures/VSSetup_VS_2022_VS2019_workload.txt create mode 100644 test/fixtures/VSSetup_VS_2022_multiple_install.txt create mode 100644 test/fixtures/VSSetup_VS_2022_workload.txt create mode 100644 test/fixtures/VSSetup_VS_2022_workload_missing_sdk.txt diff --git a/README.md b/README.md index d43d617b78..9e4c608e20 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ Install tools and configuration manually: To use the native ARM64 C++ compiler on Windows on ARM, ensure that you have Visual Studio 2022 [17.4 or later](https://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/) installed. +It's advised to install following Powershell module: [VSSetup](https://github.com/microsoft/vssetup.powershell) using `Install-Module VSSetup -Scope CurrentUser`. +This will make Visual Studio detection logic to use more flexible and accessible method, avoiding Powershell's `ConstrainedLanguage` mode. + ### Configuring Python Dependency `node-gyp` requires that you have installed a [supported version of Python](https://devguide.python.org/versions/). diff --git a/lib/find-visualstudio.js b/lib/find-visualstudio.js index b57770259a..f0710fbe9b 100644 --- a/lib/find-visualstudio.js +++ b/lib/find-visualstudio.js @@ -54,6 +54,7 @@ class VisualStudioFinder { } const checks = [ + () => this.findVisualStudio2017OrNewerUsingSetupModule(), () => this.findVisualStudio2017OrNewer(), () => this.findVisualStudio2015(), () => this.findVisualStudio2013() @@ -113,6 +114,52 @@ class VisualStudioFinder { throw new Error('Could not find any Visual Studio installation to use') } + async findVisualStudio2017OrNewerUsingSetupModule () { + const ps = path.join(process.env.SystemRoot, 'System32', + 'WindowsPowerShell', 'v1.0', 'powershell.exe') + const vcInstallDir = this.envVcInstallDir + + const checkModuleArgs = [ + '-NoProfile', + '-Command', + '&{@(Get-Module -ListAvailable -Name VSSetup).Version.ToString()}' + ] + this.log.silly('Running', ps, checkModuleArgs) + const [cErr] = await this.execFile(ps, checkModuleArgs) + if (cErr) { + this.addLog('VSSetup module doesn\'t seem to exist. You can install it via: "Install-Module VSSetup -Scope CurrentUser"') + this.log.silly('VSSetup error = %j', cErr && (cErr.stack || cErr)) + return null + } + const filterArg = vcInstallDir !== undefined ? `| where {$_.InstallationPath -eq '${vcInstallDir}' }` : '' + const psArgs = [ + '-NoProfile', + '-Command', + `&{Get-VSSetupInstance ${filterArg} | ConvertTo-Json -Depth 3}` + ] + + this.log.silly('Running', ps, psArgs) + const [err, stdout, stderr] = await this.execFile(ps, psArgs) + let parsedData = this.parseData(err, stdout, stderr) + if (parsedData === null) { + return null + } + this.log.silly('Parsed data', parsedData) + if (!Array.isArray(parsedData)) { + // if there are only 1 result, then Powershell will output non-array + parsedData = [parsedData] + } + // normalize output + parsedData = parsedData.map((info) => { + info.path = info.InstallationPath + info.version = `${info.InstallationVersion.Major}.${info.InstallationVersion.Minor}.${info.InstallationVersion.Build}.${info.InstallationVersion.Revision}` + info.packages = info.Packages.map((p) => p.Id) + return info + }) + // pass for further processing + return this.processData(parsedData) + } + // Invoke the PowerShell script to get information about Visual Studio 2017 // or newer installations async findVisualStudio2017OrNewer () { @@ -128,24 +175,35 @@ class VisualStudioFinder { ] this.log.silly('Running', ps, psArgs) - const [err, stdout, stderr] = await execFile(ps, psArgs, { encoding: 'utf8' }) - return this.parseData(err, stdout, stderr) + const [err, stdout, stderr] = await this.execFile(ps, psArgs) + const parsedData = this.parseData(err, stdout, stderr, { checkIsArray: true }) + if (parsedData === null) { + return null + } + return this.processData(parsedData) } - // Parse the output of the PowerShell script and look for an installation - // of Visual Studio 2017 or newer to use - parseData (err, stdout, stderr) { + // Parse the output of the PowerShell script, make sanity checks + parseData (err, stdout, stderr, sanityCheckOptions) { + const defaultOptions = { + checkIsArray: false + } + + // Merging provided options with the default options + const sanityOptions = { ...defaultOptions, ...sanityCheckOptions } + this.log.silly('PS stderr = %j', stderr) - const failPowershell = () => { + const failPowershell = (failureDetails) => { this.addLog( - 'could not use PowerShell to find Visual Studio 2017 or newer, try re-running with \'--loglevel silly\' for more details') + `could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details. \n + Failure details: ${failureDetails}`) return null } if (err) { this.log.silly('PS err = %j', err && (err.stack || err)) - return failPowershell() + return failPowershell(`${err}`.substring(0, 40)) } let vsInfo @@ -157,11 +215,16 @@ class VisualStudioFinder { return failPowershell() } - if (!Array.isArray(vsInfo)) { + if (sanityOptions.checkIsArray && !Array.isArray(vsInfo)) { this.log.silly('PS stdout = %j', stdout) - return failPowershell() + return failPowershell('Expected array as output of the PS script') } + return vsInfo + } + // Process parsed data containing information about VS installations + // Look for the required parts, extract and output them back + processData (vsInfo) { vsInfo = vsInfo.map((info) => { this.log.silly(`processing installation: "${info.path}"`) info.path = path.resolve(info.path) @@ -438,6 +501,10 @@ class VisualStudioFinder { return true } + + async execFile (exec, args) { + return await execFile(exec, args, { encoding: 'utf8' }) + } } module.exports = VisualStudioFinder diff --git a/test/fixtures/VSSetup_VS_2019_Professional_workload.txt b/test/fixtures/VSSetup_VS_2019_Professional_workload.txt new file mode 100644 index 0000000000..efafa41707 --- /dev/null +++ b/test/fixtures/VSSetup_VS_2019_Professional_workload.txt @@ -0,0 +1,235 @@ +[ + { + "InstanceId": "2619cf21", + "InstallationName": "VisualStudio/16.11.33+34407.143", + "InstallationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional", + "InstallationVersion": { + "Major": 16, + "Minor": 11, + "Build": 34407, + "Revision": 143, + "MajorRevision": 0, + "MinorRevision": 143 + }, + "InstallDate": "\/Date(1706804943503)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Professional 2019", + "Description": "Professional IDE best suited to small teams", + "ProductPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\IDE\\devenv.exe", + "Product": { + "Id": "Microsoft.VisualStudio.Product.Professional", + "Version": { + "Major": 16, + "Minor": 11, + "Build": 34407, + "Revision": 143, + "MajorRevision": 0, + "MinorRevision": 143 + }, + "Chip": null, + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Professional,version=16.11.34407.143" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.Professional", + "Version": "16.11.34407.143", + "Chip": null, + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Professional,version=16.11.34407.143" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.14.29.16.10.ATL", + "Version": "16.11.31314.313", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.14.29.16.10.ATL,version=16.11.31314.313" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.X64.v142", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.X64.v142,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.X64", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.X64,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.x86.v142", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.x86.v142,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.X86", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.X86,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.Base", + "Version": "16.11.31829.152", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.Base,version=16.11.31829.152" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.Base.Resources", + "Version": "16.11.31829.152", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.Base.Resources,version=16.11.31829.152,language=en-US" + }, + { + "Id": "Microsoft.VisualStudio.Branding.Professional", + "Version": "16.11.31605.320", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Branding.Professional,version=16.11.31605.320,language=en-US" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Version": "16.10.31205.252", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows10SDK.19041,version=16.10.31205.252" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Version": "16.11.32406.258", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64,version=16.11.32406.258" + } + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "09" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.16.Release/16.11.33+34407.143" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/16.11.33+34407.143" + }, + { + "Key": "BuildBranch", + "Value": "d16.11" + }, + { + "Key": "BuildVersion", + "Value": "16.11.34407.143" + }, + { + "Key": "LocalBuild", + "Value": "build-lab" + }, + { + "Key": "ManifestName", + "Value": "VisualStudio" + }, + { + "Key": "ManifestType", + "Value": "installer" + }, + { + "Key": "ProductDisplayVersion", + "Value": "16.11.33" + }, + { + "Key": "ProductLine", + "Value": "Dev16" + }, + { + "Key": "ProductLineVersion", + "Value": "2019" + }, + { + "Key": "ProductMilestone", + "Value": "RTW" + }, + { + "Key": "ProductMilestoneIsPreRelease", + "Value": "False" + }, + { + "Key": "ProductName", + "Value": "Visual Studio" + }, + { + "Key": "ProductPatchVersion", + "Value": "33" + }, + { + "Key": "ProductPreReleaseMilestoneSuffix", + "Value": "1.0" + }, + { + "Key": "ProductSemanticVersion", + "Value": "16.11.33+34407.143" + }, + { + "Key": "RequiredEngineVersion", + "Value": "2.11.72.18200" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2024-01-09T19:19:11.0115234Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.4", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" + } +] diff --git a/test/fixtures/VSSetup_VS_2022_VS2019_workload.txt b/test/fixtures/VSSetup_VS_2022_VS2019_workload.txt new file mode 100644 index 0000000000..a6524171ae --- /dev/null +++ b/test/fixtures/VSSetup_VS_2022_VS2019_workload.txt @@ -0,0 +1,371 @@ +[ + { + "InstanceId": "621862c0", + "InstallationName": "VisualStudio/17.8.3+34330.188", + "InstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "InstallationVersion": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "InstallDate": "\/Date(1703254955000)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Enterprise 2022", + "Description": "Scalable, end-to-end solution for teams of any size", + "ProductPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\devenv.exe", + "Product": { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": "17.8.34330.188", + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64,version=17.8.34129.139" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows11SDK.22000", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows11SDK.22000,version=17.8.34129.139" + }, + { + "Id": "Win11SDK_10.0.22000", + "Version": "10.0.22000.4", + "Chip": null, + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Win11SDK_10.0.22000,version=10.0.22000.4" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows10SDK.20348", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows10SDK.20348,version=17.8.34129.139" + }, + { + "Id": "Win10SDK_10.0.20348", + "Version": "10.0.20348.3", + "Chip": null, + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Win10SDK_10.0.20348,version=10.0.20348.3" + } + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.17.Release/17.8.3+34330.188" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/17.8.3+34330.188" + }, + { + "Key": "BuildBranch", + "Value": "d17.8" + }, + { + "Key": "BuildVersion", + "Value": "17.8.34330.188" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2023-12-22T14:22:35.1818213Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.3", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" +}, +{ + "InstanceId": "2619cf21", + "InstallationName": "VisualStudio/16.11.33+34407.143", + "InstallationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional", + "InstallationVersion": { + "Major": 16, + "Minor": 11, + "Build": 34407, + "Revision": 143, + "MajorRevision": 0, + "MinorRevision": 143 + }, + "InstallDate": "\/Date(1706804943503)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Professional 2019", + "Description": "Professional IDE best suited to small teams", + "ProductPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\Common7\\IDE\\devenv.exe", + "Product": { + "Id": "Microsoft.VisualStudio.Product.Professional", + "Version": { + "Major": 16, + "Minor": 11, + "Build": 34407, + "Revision": 143, + "MajorRevision": 0, + "MinorRevision": 143 + }, + "Chip": null, + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Professional,version=16.11.34407.143" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.Professional", + "Version": "16.11.34407.143", + "Chip": null, + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Professional,version=16.11.34407.143" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.14.29.16.10.ATL", + "Version": "16.11.31314.313", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.14.29.16.10.ATL,version=16.11.31314.313" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.X64.v142", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.X64.v142,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.X64", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.X64,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.x86.v142", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.x86.v142,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.X86", + "Version": "16.11.31503.54", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.X86,version=16.11.31503.54" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.Base", + "Version": "16.11.31829.152", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.Base,version=16.11.31829.152" + }, + { + "Id": "Microsoft.VisualStudio.VC.MSBuild.Base.Resources", + "Version": "16.11.31829.152", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.MSBuild.Base.Resources,version=16.11.31829.152,language=en-US" + }, + { + "Id": "Microsoft.VisualStudio.Branding.Professional", + "Version": "16.11.31605.320", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Branding.Professional,version=16.11.31605.320,language=en-US" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Version": "16.10.31205.252", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows10SDK.19041,version=16.10.31205.252" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Version": "16.11.32406.258", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64,version=16.11.32406.258" + } + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "09" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.16.Release/16.11.33+34407.143" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/16.11.33+34407.143" + }, + { + "Key": "BuildBranch", + "Value": "d16.11" + }, + { + "Key": "BuildVersion", + "Value": "16.11.34407.143" + }, + { + "Key": "LocalBuild", + "Value": "build-lab" + }, + { + "Key": "ManifestName", + "Value": "VisualStudio" + }, + { + "Key": "ManifestType", + "Value": "installer" + }, + { + "Key": "ProductDisplayVersion", + "Value": "16.11.33" + }, + { + "Key": "ProductLine", + "Value": "Dev16" + }, + { + "Key": "ProductLineVersion", + "Value": "2019" + }, + { + "Key": "ProductMilestone", + "Value": "RTW" + }, + { + "Key": "ProductMilestoneIsPreRelease", + "Value": "False" + }, + { + "Key": "ProductName", + "Value": "Visual Studio" + }, + { + "Key": "ProductPatchVersion", + "Value": "33" + }, + { + "Key": "ProductPreReleaseMilestoneSuffix", + "Value": "1.0" + }, + { + "Key": "ProductSemanticVersion", + "Value": "16.11.33+34407.143" + }, + { + "Key": "RequiredEngineVersion", + "Value": "2.11.72.18200" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2024-01-09T19:19:11.0115234Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.4", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" + } +] diff --git a/test/fixtures/VSSetup_VS_2022_multiple_install.txt b/test/fixtures/VSSetup_VS_2022_multiple_install.txt new file mode 100644 index 0000000000..2bfd67a190 --- /dev/null +++ b/test/fixtures/VSSetup_VS_2022_multiple_install.txt @@ -0,0 +1,369 @@ +[ + { + "InstanceId": "621862c0", + "InstallationName": "VisualStudio/17.8.3+34330.188", + "InstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "InstallationVersion": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "InstallDate": "\/Date(1703254955000)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Enterprise 2022", + "Description": "Scalable, end-to-end solution for teams of any size", + "ProductPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\devenv.exe", + "Product": { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": "17.8.34330.188", + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64,version=17.8.34129.139" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows11SDK.22000", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows11SDK.22000,version=17.8.34129.139" + }, + { + "Id": "Win11SDK_10.0.22000", + "Version": "10.0.22000.4", + "Chip": null, + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Win11SDK_10.0.22000,version=10.0.22000.4" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows10SDK.20348", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows10SDK.20348,version=17.8.34129.139" + }, + { + "Id": "Win10SDK_10.0.20348", + "Version": "10.0.20348.3", + "Chip": null, + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Win10SDK_10.0.20348,version=10.0.20348.3" + } + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.17.Release/17.8.3+34330.188" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/17.8.3+34330.188" + }, + { + "Key": "BuildBranch", + "Value": "d17.8" + }, + { + "Key": "BuildVersion", + "Value": "17.8.34330.188" + }, + { + "Key": "LocalBuild", + "Value": "build-lab" + }, + { + "Key": "ManifestName", + "Value": "VisualStudio" + }, + { + "Key": "ManifestType", + "Value": "installer" + }, + { + "Key": "ProductDisplayVersion", + "Value": "17.8.3" + }, + { + "Key": "ProductLine", + "Value": "Dev17" + }, + { + "Key": "ProductLineVersion", + "Value": "2022" + }, + { + "Key": "ProductMilestone", + "Value": "RTW" + }, + { + "Key": "ProductMilestoneIsPreRelease", + "Value": "False" + }, + { + "Key": "ProductName", + "Value": "Visual Studio" + }, + { + "Key": "ProductPatchVersion", + "Value": "3" + }, + { + "Key": "ProductPreReleaseMilestoneSuffix", + "Value": "1.0" + }, + { + "Key": "ProductSemanticVersion", + "Value": "17.8.3+34330.188" + }, + { + "Key": "RequiredEngineVersion", + "Value": "3.8.2112.61926" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2023-12-22T14:22:35.1818213Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.3", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" + }, + { + "InstanceId": "dd50c6cc", + "InstallationName": "VisualStudio/17.8.3+34330.188", + "InstallationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools", + "InstallationVersion": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "InstallDate": "\/Date(1703262914503)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Build Tools 2022", + "Description": "The Visual Studio Build Tools allows you to build native and managed MSBuild-based applications without requiring the Visual Studio IDE. There are options to install the Visual C++ compilers and libraries, MFC, ATL, and C++/CLI support.", + "ProductPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\LaunchDevCmd.bat", + "Product": { + "Id": "Microsoft.VisualStudio.Product.BuildTools", + "Version": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "Chip": null, + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.BuildTools,version=17.8.34330.188" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.BuildTools", + "Version": "17.8.34330.188", + "Chip": null, + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.BuildTools,version=17.8.34330.188" + }, + { + "Id": "Microsoft.VisualStudio.Workload.MSBuildTools", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Workload", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Workload.MSBuildTools,version=17.8.34129.139" + }, + { + "Id": "Microsoft.VisualStudio.NuGet.BuildTools", + "Version": "17.0.60800.131", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.NuGet.BuildTools,version=17.0.60800.131" + }, + { + "Id": "Microsoft.Build.UnGAC", + "Version": "17.8.3.2351904", + "Chip": "neutral", + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Microsoft.Build.UnGAC,version=17.8.3.2351904,chip=neutral,language=neutral" + }, + { + "Id": "Microsoft.VisualStudio.VC.Icons", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Vsix", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.VC.Icons,version=17.8.34129.139" + } + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "09" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "2" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.17.Release/17.8.3+34330.188" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/17.8.3+34330.188" + }, + { + "Key": "BuildBranch", + "Value": "d17.8" + }, + { + "Key": "BuildVersion", + "Value": "17.8.34330.188" + }, + { + "Key": "LocalBuild", + "Value": "build-lab" + }, + { + "Key": "ManifestName", + "Value": "VisualStudio" + }, + { + "Key": "ManifestType", + "Value": "installer" + }, + { + "Key": "ProductDisplayVersion", + "Value": "17.8.3" + }, + { + "Key": "ProductLine", + "Value": "Dev17" + }, + { + "Key": "ProductLineVersion", + "Value": "2022" + }, + { + "Key": "ProductMilestone", + "Value": "RTW" + }, + { + "Key": "ProductMilestoneIsPreRelease", + "Value": "False" + }, + { + "Key": "ProductName", + "Value": "Visual Studio" + }, + { + "Key": "ProductPatchVersion", + "Value": "3" + }, + { + "Key": "ProductPreReleaseMilestoneSuffix", + "Value": "1.0" + }, + { + "Key": "ProductSemanticVersion", + "Value": "17.8.3+34330.188" + }, + { + "Key": "RequiredEngineVersion", + "Value": "3.8.2112.61926" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2023-12-22T14:22:35.1818213Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.3", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" + } +] diff --git a/test/fixtures/VSSetup_VS_2022_workload.txt b/test/fixtures/VSSetup_VS_2022_workload.txt new file mode 100644 index 0000000000..3e1abdc30d --- /dev/null +++ b/test/fixtures/VSSetup_VS_2022_workload.txt @@ -0,0 +1,136 @@ +{ + "InstanceId": "621862c0", + "InstallationName": "VisualStudio/17.8.3+34330.188", + "InstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "InstallationVersion": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "InstallDate": "\/Date(1703254955000)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Enterprise 2022", + "Description": "Scalable, end-to-end solution for teams of any size", + "ProductPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\devenv.exe", + "Product": { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": "17.8.34330.188", + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64,version=17.8.34129.139" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows11SDK.22000", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows11SDK.22000,version=17.8.34129.139" + }, + { + "Id": "Win11SDK_10.0.22000", + "Version": "10.0.22000.4", + "Chip": null, + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Win11SDK_10.0.22000,version=10.0.22000.4" + }, + { + "Id": "Microsoft.VisualStudio.Component.Windows10SDK.20348", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.Windows10SDK.20348,version=17.8.34129.139" + }, + { + "Id": "Win10SDK_10.0.20348", + "Version": "10.0.20348.3", + "Chip": null, + "Branch": null, + "Type": "Exe", + "IsExtension": false, + "UniqueId": "Win10SDK_10.0.20348,version=10.0.20348.3" + } + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.17.Release/17.8.3+34330.188" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/17.8.3+34330.188" + }, + { + "Key": "BuildBranch", + "Value": "d17.8" + }, + { + "Key": "BuildVersion", + "Value": "17.8.34330.188" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2023-12-22T14:22:35.1818213Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.3", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" +} diff --git a/test/fixtures/VSSetup_VS_2022_workload_missing_sdk.txt b/test/fixtures/VSSetup_VS_2022_workload_missing_sdk.txt new file mode 100644 index 0000000000..8edee24607 --- /dev/null +++ b/test/fixtures/VSSetup_VS_2022_workload_missing_sdk.txt @@ -0,0 +1,152 @@ +{ + "InstanceId": "621862c0", + "InstallationName": "VisualStudio/17.8.3+34330.188", + "InstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "InstallationVersion": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "InstallDate": "\/Date(1703254955000)\/", + "State": 4294967295, + "DisplayName": "Visual Studio Enterprise 2022", + "Description": "Scalable, end-to-end solution for teams of any size", + "ProductPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\devenv.exe", + "Product": { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": { + "Major": 17, + "Minor": 8, + "Build": 34330, + "Revision": 188, + "MajorRevision": 0, + "MinorRevision": 188 + }, + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + "Packages": [ + { + "Id": "Microsoft.VisualStudio.Product.Enterprise", + "Version": "17.8.34330.188", + "Chip": "x64", + "Branch": null, + "Type": "Product", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Product.Enterprise,version=17.8.34330.188,chip=x64" + }, + { + "Id": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "Version": "17.8.34129.139", + "Chip": null, + "Branch": null, + "Type": "Component", + "IsExtension": false, + "UniqueId": "Microsoft.VisualStudio.Component.VC.Tools.x86.x64,version=17.8.34129.139" + }, + ], + "Properties": [ + { + "Key": "CampaignId", + "Value": "" + }, + { + "Key": "SetupEngineFilePath", + "Value": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" + }, + { + "Key": "Nickname", + "Value": "" + }, + { + "Key": "ChannelManifestId", + "Value": "VisualStudio.17.Release/17.8.3+34330.188" + } + ], + "Errors": null, + "EnginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", + "IsComplete": true, + "IsLaunchable": true, + "CatalogInfo": [ + { + "Key": "Id", + "Value": "VisualStudio/17.8.3+34330.188" + }, + { + "Key": "BuildBranch", + "Value": "d17.8" + }, + { + "Key": "BuildVersion", + "Value": "17.8.34330.188" + }, + { + "Key": "LocalBuild", + "Value": "build-lab" + }, + { + "Key": "ManifestName", + "Value": "VisualStudio" + }, + { + "Key": "ManifestType", + "Value": "installer" + }, + { + "Key": "ProductDisplayVersion", + "Value": "17.8.3" + }, + { + "Key": "ProductLine", + "Value": "Dev17" + }, + { + "Key": "ProductLineVersion", + "Value": "2022" + }, + { + "Key": "ProductMilestone", + "Value": "RTW" + }, + { + "Key": "ProductMilestoneIsPreRelease", + "Value": "False" + }, + { + "Key": "ProductName", + "Value": "Visual Studio" + }, + { + "Key": "ProductPatchVersion", + "Value": "3" + }, + { + "Key": "ProductPreReleaseMilestoneSuffix", + "Value": "1.0" + }, + { + "Key": "ProductSemanticVersion", + "Value": "17.8.3+34330.188" + }, + { + "Key": "RequiredEngineVersion", + "Value": "3.8.2112.61926" + } + ], + "IsPrerelease": false, + "PSPath": "Microsoft.PowerShell.Core\\FileSystem::C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "UpdateDate": "2023-12-22T14:22:35.1818213Z", + "ResolvedInstallationPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", + "ChannelId": "VisualStudio.17.Release", + "InstalledChannelId": "VisualStudio.17.Release", + "ChannelUri": "https://aka.ms/vs/17/release/channel", + "InstalledChannelUri": "https://aka.ms/vs/17/release/channel", + "ReleaseNotes": "https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.3", + "ThirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288" +} diff --git a/test/test-find-visualstudio.js b/test/test-find-visualstudio.js index 08e9438c45..ca40165a74 100644 --- a/test/test-find-visualstudio.js +++ b/test/test-find-visualstudio.js @@ -22,9 +22,18 @@ class TestVisualStudioFinder extends VisualStudioFinder { } describe('find-visualstudio', function () { + this.beforeAll(function () { + // Condition to skip the test suite + if (process.env.SystemRoot === undefined) { + process.env.SystemRoot = '/' + } + }) + it('VS2013', async function () { const finder = new TestVisualStudioFinder(semverV1, null) - + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { return finder.parseData(new Error(), '', '') } @@ -69,10 +78,15 @@ describe('find-visualstudio', function () { patch: 0 }, null) + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } + finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } finder.regSearchKeys = async (keys, value, addOpts) => { for (let i = 0; i < keys.length; ++i) { @@ -96,6 +110,10 @@ describe('find-visualstudio', function () { it('VS2015', async function () { const finder = new TestVisualStudioFinder(semverV1, null) + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } + finder.findVisualStudio2017OrNewer = async () => { return finder.parseData(new Error(), '', '') } @@ -132,52 +150,49 @@ describe('find-visualstudio', function () { it('error from PowerShell', async function () { const finder = new TestVisualStudioFinder(semverV1, null, null) - finder.parseData(new Error(), '', '', (info) => { - assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error') - assert.ok(!info, 'no data') - }) + const vsInfo = finder.parseData(new Error('Error msg'), '', '') + assert.ok(/use PowerShell/i.test(finder.errorLog[0]), `expect error, output: ${finder.errorLog[0]}`) + assert.ok(/error msg/i.test(finder.errorLog[0]), `expect error, output: ${finder.errorLog[0]}`) + assert.equal(vsInfo, null) }) it('empty output from PowerShell', async function () { const finder = new TestVisualStudioFinder(semverV1, null, null) - finder.parseData(null, '', '', (info) => { - assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error') - assert.ok(!info, 'no data') - }) + const vsInfo = finder.parseData(null, '', '', { checkIsArray: true }) + assert.ok(/use PowerShell/i.test(finder.errorLog[0]), `expect error, output: ${finder.errorLog[0]}`) + assert.equal(vsInfo, null) }) it('output from PowerShell not JSON', async function () { const finder = new TestVisualStudioFinder(semverV1, null, null) - finder.parseData(null, 'AAAABBBB', '', (info) => { - assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error') - assert.ok(!info, 'no data') - }) + const vsInfo = finder.parseData(null, 'AAAABBBB', '', { checkIsArray: true }) + assert.ok(/use PowerShell/i.test(finder.errorLog[0]), `expect error, output: ${finder.errorLog[0]}`) + assert.equal(vsInfo, null) }) it('wrong JSON from PowerShell', async function () { const finder = new TestVisualStudioFinder(semverV1, null, null) - finder.parseData(null, '{}', '', (info) => { - assert.ok(/use PowerShell/i.test(finder.errorLog[0]), 'expect error') - assert.ok(!info, 'no data') - }) + const vsInfo = finder.parseData(null, '{}', '', { checkIsArray: true }) + assert.ok(/use PowerShell/i.test(finder.errorLog[0]), `expect error, output: ${finder.errorLog[0]}`) + assert.ok(/expected array/i.test(finder.errorLog[0]), `expect error, output: ${finder.errorLog[0]}`) + assert.equal(vsInfo, null) }) it('empty JSON from PowerShell', async function () { const finder = new TestVisualStudioFinder(semverV1, null, null) - finder.parseData(null, '[]', '', (info) => { - assert.ok(/find .* Visual Studio/i.test(finder.errorLog[0]), 'expect error') - assert.ok(!info, 'no data') - }) + const vsInfo = finder.parseData(null, '[]', '', { checkIsArray: true }) + assert.equal(finder.errorLog.length, 0) + assert.equal(vsInfo.length, 0) }) it('future version', async function () { const finder = new TestVisualStudioFinder(semverV1, null, null) - finder.parseData(null, JSON.stringify([{ + const vsInfo = finder.parseData(null, JSON.stringify([{ packages: [ 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', 'Microsoft.VisualStudio.Component.Windows10SDK.17763', @@ -185,11 +200,9 @@ describe('find-visualstudio', function () { ], path: 'C:\\VS', version: '9999.9999.9999.9999' - }]), '', (info) => { - assert.ok(/unknown version/i.test(finder.errorLog[0]), 'expect error') - assert.ok(/find .* Visual Studio/i.test(finder.errorLog[1]), 'expect error') - assert.ok(!info, 'no data') - }) + }]), '', { checkIsArray: true }) + assert.equal(finder.errorLog.length, 0) + assert.equal(vsInfo[0].packages.length, 3) }) it('single unusable VS2017', async function () { @@ -197,22 +210,27 @@ describe('find-visualstudio', function () { const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt') const data = fs.readFileSync(file) - finder.parseData(null, data, '', (info) => { - assert.ok(/checking/i.test(finder.errorLog[0]), 'expect error') - assert.ok(/find .* Visual Studio/i.test(finder.errorLog[2]), 'expect error') - assert.ok(!info, 'no data') - }) + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + assert.equal(finder.errorLog.length, 0) + assert.equal(vsInfo.length, 1) + assert.equal(vsInfo[0].InstallationPath, undefined) + assert.notEqual(vsInfo[0].path, undefined) + assert.ok(vsInfo[0].packages.length > 1) }) it('minimal VS2017 Build Tools', async function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_BuildTools_minimal.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -234,11 +252,15 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_Community_workload.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -260,10 +282,14 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -285,11 +311,15 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2019_Preview.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -311,11 +341,15 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2019_BuildTools_minimal.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -337,11 +371,15 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2019_Community_workload.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -372,11 +410,15 @@ describe('find-visualstudio', function () { finder.msBuildPathExists = (path) => { return true } + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } finder.findVisualStudio2017OrNewer = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2022_Community_workload.txt') const data = fs.readFileSync(file) - return finder.parseData(null, data, '') + const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(vsInfo) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -393,7 +435,97 @@ describe('find-visualstudio', function () { }) }) + it('VSSetup: VS2022 with C++ workload without SDK', async function () { + const finder = new TestVisualStudioFinder(semverV1, null) + finder.msBuildPathExists = (path) => { + return true + } + finder.findVisualStudio2017OrNewer = async () => { + return null + } + finder.findOldVS = async (info) => { + return null + } + setupExecFixture(finder, 'VSSetup_VS_2022_workload_missing_sdk.txt') + const { err, info } = await finder.findVisualStudio() + assert.match(err.message, /could not find/i) + assert.strictEqual(info, null) + }) + + it('VSSetup: VS2019 with C++ workload', async function () { + await verifyVSSetupData('VSSetup_VS_2019_Professional_workload.txt', 'Professional', 2019, + '10.0.19041.0', 'v142', '16.11.34407.143', 'Program Files (x86)') + }) + + it('VSSetup: VS2022 with C++ workload', async function () { + await verifyVSSetupData('VSSetup_VS_2022_workload.txt', 'Enterprise', 2022, + '10.0.22000.0', 'v143', '17.8.34330.188', 'Program Files') + }) + + it('VSSetup: VS2022 and VS2019 with C++ workload', async function () { + await verifyVSSetupData('VSSetup_VS_2022_VS2019_workload.txt', 'Enterprise', 2022, + '10.0.22000.0', 'v143', '17.8.34330.188', 'Program Files') + }) + + it('VSSetup: VS2022 with multiple installations', async function () { + await verifyVSSetupData('VSSetup_VS_2022_multiple_install.txt', 'Enterprise', 2022, + '10.0.22000.0', 'v143', '17.8.34330.188', 'Program Files') + }) + + async function verifyVSSetupData (fixtureName, vsType, vsYear, sdkVersion, toolsetVersion, vsVersion, expectedProgramFilesPath) { + const msBuildPath = process.arch === 'arm64' + ? `C:\\${expectedProgramFilesPath}\\Microsoft Visual Studio\\${vsYear}\\` + + `${vsType}\\MSBuild\\Current\\Bin\\arm64\\MSBuild.exe` + : `C:\\${expectedProgramFilesPath}\\Microsoft Visual Studio\\${vsYear}\\` + + `${vsType}\\MSBuild\\Current\\Bin\\MSBuild.exe` + + const finder = new TestVisualStudioFinder(semverV1, null) + + poison(finder, 'regSearchKeys') + const expectedVSPath = `C:\\${expectedProgramFilesPath}\\Microsoft Visual Studio\\${vsYear}\\${vsType}` + finder.msBuildPathExists = (path) => { + if (path.startsWith(expectedVSPath) && path.endsWith('MSBuild.exe')) { + return true + } + return false + } + finder.findVisualStudio2017OrNewer = async () => { + throw new Error("findVisualStudio2017OrNewer shouldn't be called") + } + setupExecFixture(finder, fixtureName) + const { err, info } = await finder.findVisualStudio() + assert.strictEqual(err, null) + const vsVersionTokens = vsVersion.split('.') + assert.deepStrictEqual(info, { + msBuild: msBuildPath, + path: + `C:\\${expectedProgramFilesPath}\\Microsoft Visual Studio\\${vsYear}\\${vsType}`, + sdk: sdkVersion, + toolset: toolsetVersion, + version: vsVersion, + versionMajor: parseInt(vsVersionTokens[0]), + versionMinor: parseInt(vsVersionTokens[1]), + versionYear: vsYear + }) + } + + function setupExecFixture (finder, fixtureName) { + finder.execFile = async (exec, args) => { + if (args.length > 2 && args[2].includes('Get-Module')) { + return [null, '1.0.0', ''] + } else if (args.length > 2 && args.at(-1).includes('Get-VSSetupInstance')) { + const file = path.join(__dirname, 'fixtures', fixtureName) + return [null, fs.readFileSync(file), ''] + } + return [new Error(), '', ''] + } + } + function allVsVersions (finder) { + finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { + return null + } + finder.findVisualStudio2017OrNewer = async () => { const data0 = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt'))) @@ -413,7 +545,8 @@ describe('find-visualstudio', function () { 'VS_2022_Community_workload.txt'))) const data = JSON.stringify(data0.concat(data1, data2, data3, data4, data5, data6, data7)) - return finder.parseData(null, data, '') + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData) } finder.regSearchKeys = async (keys, value, addOpts) => { for (let i = 0; i < keys.length; ++i) { From 391cc5b9b25cffe0cb2edcba3583414a771b4a15 Mon Sep 17 00:00:00 2001 From: Stefan Stojanovic Date: Wed, 6 Mar 2024 17:32:44 +0100 Subject: [PATCH 12/17] win: update supported vs versions (#2959) Drop VS2017 support for Node.js v22 and above. Refs: https://github.com/nodejs/build/pull/3603 Refs: https://github.com/nodejs/node/pull/45427 --- lib/find-visualstudio.js | 50 ++++++++-- test/test-find-visualstudio.js | 173 +++++++++++++++++++-------------- 2 files changed, 142 insertions(+), 81 deletions(-) diff --git a/lib/find-visualstudio.js b/lib/find-visualstudio.js index f0710fbe9b..8c5ae96127 100644 --- a/lib/find-visualstudio.js +++ b/lib/find-visualstudio.js @@ -54,8 +54,10 @@ class VisualStudioFinder { } const checks = [ - () => this.findVisualStudio2017OrNewerUsingSetupModule(), - () => this.findVisualStudio2017OrNewer(), + () => this.findVisualStudio2019OrNewerUsingSetupModule(), + () => this.findVisualStudio2019OrNewer(), + () => this.findVisualStudio2017UsingSetupModule(), + () => this.findVisualStudio2017(), () => this.findVisualStudio2015(), () => this.findVisualStudio2013() ] @@ -114,7 +116,20 @@ class VisualStudioFinder { throw new Error('Could not find any Visual Studio installation to use') } - async findVisualStudio2017OrNewerUsingSetupModule () { + async findVisualStudio2019OrNewerUsingSetupModule () { + return this.findNewVSUsingSetupModule([2019, 2022]) + } + + async findVisualStudio2017UsingSetupModule () { + 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.findNewVSUsingSetupModule([2017]) + } + + async findNewVSUsingSetupModule (supportedYears) { const ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe') const vcInstallDir = this.envVcInstallDir @@ -157,12 +172,28 @@ class VisualStudioFinder { return info }) // pass for further processing - return this.processData(parsedData) + return this.processData(parsedData, supportedYears) + } + + // Invoke the PowerShell script to get information about Visual Studio 2019 + // or newer installations + async findVisualStudio2019OrNewer () { + return this.findNewVS([2019, 2022]) + } + + // 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([2017]) } // Invoke the PowerShell script to get information about Visual Studio 2017 // or newer installations - async findVisualStudio2017OrNewer () { + async findNewVS (supportedYears) { const ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe') const csFile = path.join(__dirname, 'Find-VisualStudio.cs') @@ -180,7 +211,7 @@ class VisualStudioFinder { if (parsedData === null) { return null } - return this.processData(parsedData) + return this.processData(parsedData, supportedYears) } // Parse the output of the PowerShell script, make sanity checks @@ -224,7 +255,7 @@ class VisualStudioFinder { // Process parsed data containing information about VS installations // Look for the required parts, extract and output them back - processData (vsInfo) { + processData (vsInfo, supportedYears) { vsInfo = vsInfo.map((info) => { this.log.silly(`processing installation: "${info.path}"`) info.path = path.resolve(info.path) @@ -238,11 +269,12 @@ class VisualStudioFinder { this.log.silly('vsInfo:', vsInfo) // Remove future versions or errors parsing version number + // Also remove any unsupported versions vsInfo = vsInfo.filter((info) => { - if (info.versionYear) { + if (info.versionYear && supportedYears.indexOf(info.versionYear) !== -1) { return true } - this.addLog(`unknown version "${info.version}" found at "${info.path}"`) + this.addLog(`${info.versionYear ? 'unsupported' : 'unknown'} version "${info.version}" found at "${info.path}"`) return false }) diff --git a/test/test-find-visualstudio.js b/test/test-find-visualstudio.js index ca40165a74..2c3f4e1981 100644 --- a/test/test-find-visualstudio.js +++ b/test/test-find-visualstudio.js @@ -31,12 +31,8 @@ describe('find-visualstudio', function () { it('VS2013', async function () { const finder = new TestVisualStudioFinder(semverV1, null) - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null - } - finder.findVisualStudio2017OrNewer = async () => { - return finder.parseData(new Error(), '', '') - } + finder.findNewVSUsingSetupModule = async () => null + finder.findNewVS = async () => null finder.regSearchKeys = async (keys, value, addOpts) => { for (let i = 0; i < keys.length; ++i) { const fullName = `${keys[i]}\\${value}` @@ -78,15 +74,18 @@ describe('find-visualstudio', function () { patch: 0 }, null) - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_Unusable.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } finder.regSearchKeys = async (keys, value, addOpts) => { for (let i = 0; i < keys.length; ++i) { @@ -109,14 +108,8 @@ describe('find-visualstudio', function () { it('VS2015', async function () { const finder = new TestVisualStudioFinder(semverV1, null) - - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null - } - - finder.findVisualStudio2017OrNewer = async () => { - return finder.parseData(new Error(), '', '') - } + finder.findNewVSUsingSetupModule = async () => null + finder.findNewVS = async () => null finder.regSearchKeys = async (keys, value, addOpts) => { for (let i = 0; i < keys.length; ++i) { const fullName = `${keys[i]}\\${value}` @@ -222,15 +215,20 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', + 'VS_2017_BuildTools_minimal.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_BuildTools_minimal.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -252,15 +250,20 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', + 'VS_2017_Community_workload.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_Community_workload.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -282,14 +285,18 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2017_Express.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -311,15 +318,20 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', + 'VS_2019_Preview.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2019_Preview.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -341,15 +353,20 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', + 'VS_2019_BuildTools_minimal.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2019_BuildTools_minimal.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -371,15 +388,20 @@ describe('find-visualstudio', function () { const finder = new TestVisualStudioFinder(semverV1, null) poison(finder, 'regSearchKeys') - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', + 'VS_2019_Community_workload.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2019_Community_workload.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -410,15 +432,20 @@ describe('find-visualstudio', function () { finder.msBuildPathExists = (path) => { return true } - finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { - return null + finder.findNewVSUsingSetupModule = async () => null + finder.findVisualStudio2019OrNewer = async () => { + const file = path.join(__dirname, 'fixtures', + 'VS_2022_Community_workload.txt') + const data = fs.readFileSync(file) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2019, 2022]) } - finder.findVisualStudio2017OrNewer = async () => { + finder.findVisualStudio2017 = async () => { const file = path.join(__dirname, 'fixtures', 'VS_2022_Community_workload.txt') const data = fs.readFileSync(file) - const vsInfo = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(vsInfo) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) } const { err, info } = await finder.findVisualStudio() assert.strictEqual(err, null) @@ -440,12 +467,8 @@ describe('find-visualstudio', function () { finder.msBuildPathExists = (path) => { return true } - finder.findVisualStudio2017OrNewer = async () => { - return null - } - finder.findOldVS = async (info) => { - return null - } + finder.findNewVS = async () => null + finder.findOldVS = async () => null setupExecFixture(finder, 'VSSetup_VS_2022_workload_missing_sdk.txt') const { err, info } = await finder.findVisualStudio() assert.match(err.message, /could not find/i) @@ -489,8 +512,11 @@ describe('find-visualstudio', function () { } return false } - finder.findVisualStudio2017OrNewer = async () => { - throw new Error("findVisualStudio2017OrNewer shouldn't be called") + finder.findVisualStudio2019OrNewer = async () => { + throw new Error("findVisualStudio2019OrNewer shouldn't be called") + } + finder.findVisualStudio2017 = async () => { + throw new Error("findVisualStudio2017 shouldn't be called") } setupExecFixture(finder, fixtureName) const { err, info } = await finder.findVisualStudio() @@ -525,8 +551,7 @@ describe('find-visualstudio', function () { finder.findVisualStudio2017OrNewerUsingSetupModule = async () => { return null } - - 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', @@ -535,18 +560,22 @@ 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)) + const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) + return finder.processData(parsedData, [2017]) + } + 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)) const parsedData = finder.parseData(null, data, '', { checkIsArray: true }) - return finder.processData(parsedData) + return finder.processData(parsedData, [2019, 2022]) } finder.regSearchKeys = async (keys, value, addOpts) => { for (let i = 0; i < keys.length; ++i) { From 0035d8e9dc98b94f0bc8cd9023a6fa635003703e Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Thu, 7 Mar 2024 02:33:52 +0530 Subject: [PATCH 13/17] chore: upgrade release please action from v2 to v4 (#2982) * chore(release-please-action): upgrade from v2 to v4 * chore(ci): remove target branch * chore(release-please): disable `include-component-in-tag` Co-authored-by: DeeDeeG * chore(release-please): format JSON properties per line Co-authored-by: DeeDeeG * Remove last release sha --------- Co-authored-by: DeeDeeG Co-authored-by: Luke Karrys --- .github/workflows/release-please.yml | 36 +------------------------ .release-please-manifest.json | 3 +++ release-please-config.json | 40 ++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index de4cb087a7..8985302558 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -16,42 +16,8 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v2 + - uses: google-github-actions/release-please-action@v4 id: release - with: - package-name: node-gyp - release-type: node - changelog-types: > - [{"type":"feat","section":"Features","hidden":false}, - {"type":"fix","section":"Bug Fixes","hidden":false}, - {"type":"bin","section":"Core","hidden":false}, - {"type":"gyp","section":"Core","hidden":false}, - {"type":"lib","section":"Core","hidden":false}, - {"type":"src","section":"Core","hidden":false}, - {"type":"test","section":"Tests","hidden":false}, - {"type":"build","section":"Core","hidden":false}, - {"type":"clean","section":"Core","hidden":false}, - {"type":"configure","section":"Core","hidden":false}, - {"type":"install","section":"Core","hidden":false}, - {"type":"list","section":"Core","hidden":false}, - {"type":"rebuild","section":"Core","hidden":false}, - {"type":"remove","section":"Core","hidden":false}, - {"type":"deps","section":"Core","hidden":false}, - {"type":"python","section":"Core","hidden":false}, - {"type":"lin","section":"Core","hidden":false}, - {"type":"linux","section":"Core","hidden":false}, - {"type":"mac","section":"Core","hidden":false}, - {"type":"macos","section":"Core","hidden":false}, - {"type":"win","section":"Core","hidden":false}, - {"type":"windows","section":"Core","hidden":false}, - {"type":"zos","section":"Core","hidden":false}, - {"type":"doc","section":"Doc","hidden":false}, - {"type":"docs","section":"Doc","hidden":false}, - {"type":"readme","section":"Doc","hidden":false}, - {"type":"chore","section":"Miscellaneous","hidden":false}, - {"type":"refactor","section":"Miscellaneous","hidden":false}, - {"type":"ci","section":"Miscellaneous","hidden":false}, - {"type":"meta","section":"Miscellaneous","hidden":false}] # Standard Conventional Commits: `feat` and `fix` # node-gyp subdirectories: `bin`, `gyp`, `lib`, `src`, `test` # node-gyp subcommands: `build`, `clean`, `configure`, `install`, `list`, `rebuild`, `remove` diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000000..31da23be6f --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "10.0.1" +} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000000..94b8f8110e --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,40 @@ +{ + "packages": { + ".": { + "include-component-in-tag": false, + "release-type": "node", + "changelog-sections": [ + { "type": "feat", "section": "Features", "hidden": false }, + { "type": "fix", "section": "Bug Fixes", "hidden": false }, + { "type": "bin", "section": "Core", "hidden": false }, + { "type": "gyp", "section": "Core", "hidden": false }, + { "type": "lib", "section": "Core", "hidden": false }, + { "type": "src", "section": "Core", "hidden": false }, + { "type": "test", "section": "Tests", "hidden": false }, + { "type": "build", "section": "Core", "hidden": false }, + { "type": "clean", "section": "Core", "hidden": false }, + { "type": "configure", "section": "Core", "hidden": false }, + { "type": "install", "section": "Core", "hidden": false }, + { "type": "list", "section": "Core", "hidden": false }, + { "type": "rebuild", "section": "Core", "hidden": false }, + { "type": "remove", "section": "Core", "hidden": false }, + { "type": "deps", "section": "Core", "hidden": false }, + { "type": "python", "section": "Core", "hidden": false }, + { "type": "lin", "section": "Core", "hidden": false }, + { "type": "linux", "section": "Core", "hidden": false }, + { "type": "mac", "section": "Core", "hidden": false }, + { "type": "macos", "section": "Core", "hidden": false }, + { "type": "win", "section": "Core", "hidden": false }, + { "type": "windows", "section": "Core", "hidden": false }, + { "type": "zos", "section": "Core", "hidden": false }, + { "type": "doc", "section": "Doc", "hidden": false }, + { "type": "docs", "section": "Doc", "hidden": false }, + { "type": "readme", "section": "Doc", "hidden": false }, + { "type": "chore", "section": "Miscellaneous", "hidden": false }, + { "type": "refactor", "section": "Miscellaneous", "hidden": false }, + { "type": "ci", "section": "Miscellaneous", "hidden": false }, + { "type": "meta", "section": "Miscellaneous", "hidden": false } + ] + } + } +} From fbf3fda875e1ef8b298ce306d59ce9d36aec0dbe Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 8 Mar 2024 15:59:51 -0700 Subject: [PATCH 14/17] Use new branch name format for release please CI tests --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 8985302558..6b44256ea9 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -30,5 +30,5 @@ jobs: test: name: Release Test needs: [ release-please ] - if: needs.release-please.outputs.pr || startsWith(github.head_ref, 'release-v') + if: needs.release-please.outputs.pr || startsWith(github.head_ref, 'release-please--') uses: ./.github/workflows/tests.yml From 1205fb084c0ed571429cf2ab12e885788be68e5f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 13 Mar 2024 05:54:17 +0100 Subject: [PATCH 15/17] Fix lint: ruff check --select=UP032 --fix (#2994) --- gyp/pylib/gyp/generator/android.py | 6 +++--- gyp/pylib/gyp/generator/gypsh.py | 7 +++---- gyp/pylib/gyp/generator/msvs.py | 20 ++++++++------------ gyp/pylib/gyp/input.py | 10 ++++------ gyp/pylib/gyp/msvs_emulation.py | 9 +++------ gyp/pyproject.toml | 8 ++++---- 6 files changed, 25 insertions(+), 35 deletions(-) diff --git a/gyp/pylib/gyp/generator/android.py b/gyp/pylib/gyp/generator/android.py index d3c97c666d..9a79670214 100644 --- a/gyp/pylib/gyp/generator/android.py +++ b/gyp/pylib/gyp/generator/android.py @@ -739,9 +739,9 @@ def ComputeOutput(self, spec): % (self.android_class, self.android_module) ) else: - path = "$(call intermediates-dir-for,{},{},,,$(GYP_VAR_PREFIX))".format( - self.android_class, - self.android_module, + path = ( + "$(call intermediates-dir-for," + f"{self.android_class},{self.android_module},,,$(GYP_VAR_PREFIX))" ) assert spec.get("product_dir") is None # TODO: not supported? diff --git a/gyp/pylib/gyp/generator/gypsh.py b/gyp/pylib/gyp/generator/gypsh.py index 82a07ddc65..625b6d65ca 100644 --- a/gyp/pylib/gyp/generator/gypsh.py +++ b/gyp/pylib/gyp/generator/gypsh.py @@ -49,10 +49,9 @@ def GenerateOutput(target_list, target_dicts, data, params): # Use a banner that looks like the stock Python one and like what # code.interact uses by default, but tack on something to indicate what # locals are available, and identify gypsh. - banner = "Python {} on {}\nlocals.keys() = {}\ngypsh".format( - sys.version, - sys.platform, - repr(sorted(locals.keys())), + banner = ( + f"Python {sys.version} on {sys.platform}\nlocals.keys() = " + f"{repr(sorted(locals.keys()))}\ngypsh" ) code.interact(banner, local=locals) diff --git a/gyp/pylib/gyp/generator/msvs.py b/gyp/pylib/gyp/generator/msvs.py index 13b0794b4d..6f0f8c1ab6 100644 --- a/gyp/pylib/gyp/generator/msvs.py +++ b/gyp/pylib/gyp/generator/msvs.py @@ -1778,11 +1778,9 @@ def _GetCopies(spec): outer_dir = posixpath.split(src_bare)[1] fixed_dst = _FixPath(dst) full_dst = f'"{fixed_dst}\\{outer_dir}\\"' - cmd = 'mkdir {} 2>nul & cd "{}" && xcopy /e /f /y "{}" {}'.format( - full_dst, - _FixPath(base_dir), - outer_dir, - full_dst, + cmd = ( + f'mkdir {full_dst} 2>nul & cd "{_FixPath(base_dir)}" && ' + f'xcopy /e /f /y "{outer_dir}" {full_dst}' ) copies.append( ( @@ -1794,10 +1792,9 @@ def _GetCopies(spec): ) else: fix_dst = _FixPath(cpy["destination"]) - cmd = 'mkdir "{}" 2>nul & set ERRORLEVEL=0 & copy /Y "{}" "{}"'.format( - fix_dst, - _FixPath(src), - _FixPath(dst), + cmd = ( + f'mkdir "{fix_dst}" 2>nul & set ERRORLEVEL=0 & ' + f'copy /Y "{_FixPath(src)}" "{_FixPath(dst)}"' ) copies.append(([src], [dst], cmd, f"Copying {src} to {fix_dst}")) return copies @@ -1899,9 +1896,8 @@ def _GetPlatformOverridesOfProject(spec): for config_name, c in spec["configurations"].items(): config_fullname = _ConfigFullName(config_name, c) platform = c.get("msvs_target_platform", _ConfigPlatform(c)) - fixed_config_fullname = "{}|{}".format( - _ConfigBaseName(config_name, _ConfigPlatform(c)), - platform, + fixed_config_fullname = ( + f"{_ConfigBaseName(config_name, _ConfigPlatform(c))}|{platform}" ) if spec["toolset"] == "host" and generator_supports_multiple_toolsets: fixed_config_fullname = f"{config_name}|x64" diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py index 8f39519dee..0b56c72750 100644 --- a/gyp/pylib/gyp/input.py +++ b/gyp/pylib/gyp/input.py @@ -1135,18 +1135,16 @@ def EvalCondition(condition, conditions_key, phase, variables, build_file): true_dict = condition[i + 1] if type(true_dict) is not dict: raise GypError( - "{} {} must be followed by a dictionary, not {}".format( - conditions_key, cond_expr, type(true_dict) - ) + f"{conditions_key} {cond_expr} must be followed by a dictionary, not " + f"{type(true_dict)}" ) if len(condition) > i + 2 and type(condition[i + 2]) is dict: false_dict = condition[i + 2] i = i + 3 if i != len(condition): raise GypError( - "{} {} has {} unexpected trailing items".format( - conditions_key, cond_expr, len(condition) - i - ) + f"{conditions_key} {cond_expr} has {len(condition) - i} " + "unexpected trailing items" ) else: false_dict = None diff --git a/gyp/pylib/gyp/msvs_emulation.py b/gyp/pylib/gyp/msvs_emulation.py index 38fa21dd66..847d1b8dc1 100644 --- a/gyp/pylib/gyp/msvs_emulation.py +++ b/gyp/pylib/gyp/msvs_emulation.py @@ -830,17 +830,14 @@ def _GetLdManifestFlags( ("VCLinkerTool", "UACUIAccess"), config, default="false" ) - inner = """ + inner = f""" - + -""".format( - execution_level_map[execution_level], - ui_access, - ) +""" # noqa: E501 else: inner = "" diff --git a/gyp/pyproject.toml b/gyp/pyproject.toml index 0c25d0b3c1..7183e07d3c 100644 --- a/gyp/pyproject.toml +++ b/gyp/pyproject.toml @@ -38,7 +38,7 @@ gyp = "gyp:script_main" "Homepage" = "https://github.com/nodejs/gyp-next" [tool.ruff] -select = [ +lint.select = [ "C4", # flake8-comprehensions "C90", # McCabe cyclomatic complexity "DTZ", # flake8-datetimez @@ -87,7 +87,7 @@ select = [ # "T20", # flake8-print # "TRY", # tryceratops ] -ignore = [ +lint.ignore = [ "E721", "PLC1901", "PLR0402", @@ -105,10 +105,10 @@ extend-exclude = ["pylib/packaging"] line-length = 88 target-version = "py37" -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] max-complexity = 101 -[tool.ruff.pylint] +[tool.ruff.lint.pylint] max-args = 11 max-branches = 108 max-returns = 10 From c4729129daa9bb5204246b857826fb391ac961e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20A=C3=A7acak?= <110401522+huseyinacacak-janea@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:20:35 +0300 Subject: [PATCH 16/17] lib: print Python executable path using UTF-8 (#2995) * lib: print Python executable path using UTF-8 The Python executable path may have non-ASCII characters, which can make the print function fail if the environment encoding is different. This fixes this issue by using stdout.buffer, which can be used with UTF-8 encoding for the output, regardless of the environment encoding. Fixes: https://github.com/nodejs/node-gyp/issues/2829 * fixup! lib: print Python executable path using UTF-8 --- lib/find-python.js | 2 +- test/test-find-python.js | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/find-python.js b/lib/find-python.js index 615da57bb8..a71c00c2b6 100644 --- a/lib/find-python.js +++ b/lib/find-python.js @@ -41,7 +41,7 @@ class PythonFinder { static findPython = (...args) => new PythonFinder(...args).findPython() log = log.withPrefix('find Python') - argsExecutable = ['-c', 'import sys; print(sys.executable);'] + argsExecutable = ['-c', 'import sys; sys.stdout.buffer.write(sys.executable.encode(\'utf-8\'));'] argsVersion = ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);'] semverRange = '>=3.6.0' diff --git a/test/test-find-python.js b/test/test-find-python.js index c5fa35d4bc..dc7192809a 100644 --- a/test/test-find-python.js +++ b/test/test-find-python.js @@ -2,11 +2,14 @@ delete process.env.PYTHON -const { describe, it } = require('mocha') +const { describe, it, after } = require('mocha') const assert = require('assert') const PythonFinder = require('../lib/find-python') const { execFile } = require('../lib/util') const { poison } = require('./common') +const fs = require('fs') +const path = require('path') +const os = require('os') class TestPythonFinder extends PythonFinder { constructor (...args) { @@ -32,6 +35,32 @@ describe('find-python', function () { assert.strictEqual(stderr, '') }) + it('find python - encoding', async function () { + const found = await PythonFinder.findPython(null) + const testFolderPath = fs.mkdtempSync(path.join(os.tmpdir(), 'test-ΓΌ-')) + const testFilePath = path.join(testFolderPath, 'python.exe') + after(function () { + try { + fs.unlinkSync(testFilePath) + fs.rmdirSync(testFolderPath) + } catch {} + }) + + try { + fs.symlinkSync(found, testFilePath) + } catch (err) { + switch (err.code) { + case 'EPERM': + return assert.fail(err, null, 'Please try to run console as an administrator') + default: + return assert.fail(err) + } + } + + const finder = new PythonFinder(testFilePath) + await assert.doesNotReject(finder.checkCommand(testFilePath)) + }) + it('find python - python', async function () { const f = new TestPythonFinder('python') f.execFile = async function (program, args, opts) { From f90ce122fe564be68368d0c0dec5dacd9e770233 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:04:31 -0700 Subject: [PATCH 17/17] chore(main): release 10.1.0 (#2989) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 31da23be6f..1842506cfa 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "10.0.1" + ".": "10.1.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index bcd167d9bc..9db4f9f952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## [10.1.0](https://github.com/nodejs/node-gyp/compare/v10.0.1...v10.1.0) (2024-03-13) + + +### Features + +* improve visual studio detection ([#2957](https://github.com/nodejs/node-gyp/issues/2957)) ([109e3d4](https://github.com/nodejs/node-gyp/commit/109e3d4245504a7b75c99f578e1203c0ef4b518e)) + + +### Core + +* add support for locally installed headers ([#2964](https://github.com/nodejs/node-gyp/issues/2964)) ([3298731](https://github.com/nodejs/node-gyp/commit/329873141f0d3e3787d3c006801431da04e4ed0c)) +* **deps:** bump actions/setup-python from 4 to 5 ([#2960](https://github.com/nodejs/node-gyp/issues/2960)) ([3f0df7e](https://github.com/nodejs/node-gyp/commit/3f0df7e9334e49e8c7f6fdbbb9e1e6c5a8cca53b)) +* **deps:** bump google-github-actions/release-please-action ([#2961](https://github.com/nodejs/node-gyp/issues/2961)) ([b1f1808](https://github.com/nodejs/node-gyp/commit/b1f1808bfff0d51e6d3eb696ab6a5b89b7b9630c)) +* print Python executable path using UTF-8 ([#2995](https://github.com/nodejs/node-gyp/issues/2995)) ([c472912](https://github.com/nodejs/node-gyp/commit/c4729129daa9bb5204246b857826fb391ac961e1)) +* update supported vs versions ([#2959](https://github.com/nodejs/node-gyp/issues/2959)) ([391cc5b](https://github.com/nodejs/node-gyp/commit/391cc5b9b25cffe0cb2edcba3583414a771b4a15)) + + +### Doc + +* npm is currently v10 ([#2970](https://github.com/nodejs/node-gyp/issues/2970)) ([7705a22](https://github.com/nodejs/node-gyp/commit/7705a22f31a62076e9f8429780a459f4ad71ea4c)) +* remove outdated Node versions from readme ([#2955](https://github.com/nodejs/node-gyp/issues/2955)) ([ae8478e](https://github.com/nodejs/node-gyp/commit/ae8478ec32d9b2fa71b591ac22cdf867ef2e9a7d)) +* remove outdated update engines.node reference in 10.0.0 changelog ([b42e796](https://github.com/nodejs/node-gyp/commit/b42e7966177f006f3d1aab1d27885d8372c8ed01)) + + +### Miscellaneous + +* only run release please on push ([cff9ac2](https://github.com/nodejs/node-gyp/commit/cff9ac2c3083769a383e00bc60b91562f03116e3)) +* upgrade release please action from v2 to v4 ([#2982](https://github.com/nodejs/node-gyp/issues/2982)) ([0035d8e](https://github.com/nodejs/node-gyp/commit/0035d8e9dc98b94f0bc8cd9023a6fa635003703e)) + ### [10.0.1](https://www.github.com/nodejs/node-gyp/compare/v10.0.0...v10.0.1) (2023-11-02) diff --git a/package.json b/package.json index 80c63f2e72..95f012fa5d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "bindings", "gyp" ], - "version": "10.0.1", + "version": "10.1.0", "installVersion": 11, "author": "Nathan Rajlich (http://tootallnate.net)", "repository": {