From dd18e737c6ac0b071f78de879685a7abb1fcff12 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 22 Jul 2025 12:54:58 -0400 Subject: [PATCH 1/6] Start linting --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd4b11d..ccc6332 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,11 +6,10 @@ on: workflow_dispatch: permissions: {} - jobs: test: - uses: nodenv/.github/.github/workflows/test.yml@v5 - with: { npm: false, superlinter: false } + uses: nodenv/.github/.github/workflows/test.yml@v6 + with: { npm: false } permissions: contents: read packages: read From 22491f6742ddffcb4b8d78cdbed8737e300c79c1 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 22 Jul 2025 12:59:36 -0400 Subject: [PATCH 2/6] Add prettier --- package-lock.json | 21 ++++++++++++++++++++- package.json | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 594ec31..cdd6c86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,26 @@ "": { "name": "@nodenv/jetbrains-npm", "version": "1.0.2", - "license": "MIT" + "license": "MIT", + "devDependencies": { + "prettier": "^3.6.2" + } + }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } } } } diff --git a/package.json b/package.json index 25ac8ec..dd36f7f 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,9 @@ "lint": "echo NEEDS LINT", "postversion": "git push --follow-tags" }, + "devDependencies": { + "prettier": "^3.6.2" + }, "keywords": [ "nodenv", "jetbrains", From 5300e400a4c82d2b7b55095745961578f95a3246 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 22 Jul 2025 13:01:11 -0400 Subject: [PATCH 3/6] prettier --write --- .github/workflows/release.yml | 4 +-- .github/workflows/sync-default-branch.yml | 3 +-- README.md | 30 +++++++++++------------ bin/npm-cli.js | 28 ++++++++++----------- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff7ffb0..9c90489 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,10 @@ name: Release on: - push: { tags: 'v[0-9]+.[0-9]+.[0-9]+*' } + push: { tags: "v[0-9]+.[0-9]+.[0-9]+*" } permissions: {} jobs: release: - permissions: {contents: write, id-token: write} + permissions: { contents: write, id-token: write } uses: nodenv/.github/.github/workflows/release.yml@v5 secrets: inherit diff --git a/.github/workflows/sync-default-branch.yml b/.github/workflows/sync-default-branch.yml index 9d122c7..0d3b55e 100644 --- a/.github/workflows/sync-default-branch.yml +++ b/.github/workflows/sync-default-branch.yml @@ -6,9 +6,8 @@ permissions: {} jobs: sync: - permissions: {contents: write} + permissions: { contents: write } uses: nodenv/.github/.github/workflows/sync-default-branch.yml@v5 - # One-time commands for users to switch-over: # # ```console diff --git a/README.md b/README.md index 6922f3c..bdbc79c 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ Fix IntelliJ/WebStorm's npm integration under nodenv - [Pre-requisites](#pre-requisites) - [Installation](#installation) - * [nodenv plugin](#nodenv-plugin) - * [jetbrains-aware git clone](#jetbrains-aware-git-clone) - * [standalone clone](#standalone-clone) - * [homebrew](#homebrew) - * [global npm or yarn package](#global-npm-or-yarn-package) + - [nodenv plugin](#nodenv-plugin) + - [jetbrains-aware git clone](#jetbrains-aware-git-clone) + - [standalone clone](#standalone-clone) + - [homebrew](#homebrew) + - [global npm or yarn package](#global-npm-or-yarn-package) - [Configuration](#configuration) - * [Package Manager](#package-manager) - * [Nodenv Root](#nodenv-root) + - [Package Manager](#package-manager) + - [Nodenv Root](#nodenv-root) - [Why is this necessary?](#why-is-this-necessary) - [How it works](#how-it-works) @@ -28,7 +28,8 @@ This proxy assumes you have already selected nodenv's shim as your node runtime ## Installation ### nodenv plugin -__(recommended if you have a custom nodenv root)__ + +**(recommended if you have a custom nodenv root)** This installation method allows the proxy to find nodenv root automatically; the tradeoff being that IntelliJ/WebStorm must be explicitly configured with the proxy's location. @@ -44,7 +45,8 @@ echo "$(nodenv root)"/plugins/jetbrains-npm ``` ### jetbrains-aware git clone -__(recommended if your nodenv root is the default ~/.nodenv)__ + +**(recommended if your nodenv root is the default ~/.nodenv)** This installation method enables JetBrains to find the npm proxy automatically, as it is relative to the node executable: `../lib/node_modules/npm/bin/npm-cli.js`; (relative to `shims/node`) the tradeoff requires ensuring the proxy can find your nodenv-root. @@ -66,10 +68,10 @@ git clone https://github.com/nodenv/jetbrains-npm ``` After installation: + 1. set your [Package Manager path](#Package-Manager) as the path to your clone 2. ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment - ### homebrew ```sh @@ -111,7 +113,7 @@ echo $(yarn global dir)/node_modules/@nodenv/jetbrains-npm And finally, ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment. -*__NOTE:__* +_**NOTE:**_ Be aware which node is active when you install this package. Remember that global npm installs are still contained within the node version itself. (`$(nodenv prefix)/lib/node_modules/`) This means the package will be removed if you `nodenv uninstall` the particular node version. @@ -136,11 +138,7 @@ It should be set to the path where this proxy was installed. (ie, the directory If you use the default path of `~/.nodenv` as your nodenv root, you're all set; the proxy should be able to derive your nodenv root location automatically. -If you use a custom location for nodenv root, you must ensure `NODENV_ROOT` is set accordingly and exported in IntelliJ/WebStorm's environment in one of the following ways: - - set and export it in `~/.profile` or `~/.bash_profile` - - or source `~/.bashrc` from `~/.profile` or `~/.bash_profile` - - or always launch IntelliJ/WebStorm from a terminal - - or modify the IDE desktop launcher to launch bash interactively +If you use a custom location for nodenv root, you must ensure `NODENV_ROOT` is set accordingly and exported in IntelliJ/WebStorm's environment in one of the following ways: - set and export it in `~/.profile` or `~/.bash_profile` - or source `~/.bashrc` from `~/.profile` or `~/.bash_profile` - or always launch IntelliJ/WebStorm from a terminal - or modify the IDE desktop launcher to launch bash interactively (see https://youtrack.jetbrains.com/issue/IDEABKL-7589 for more details about JetBrains and environment variables) diff --git a/bin/npm-cli.js b/bin/npm-cli.js index 1b2f8e3..d109be3 100755 --- a/bin/npm-cli.js +++ b/bin/npm-cli.js @@ -1,29 +1,29 @@ #!/usr/bin/env node -var child_process = require('child_process') -var fs = require('fs') -var path = require('path') +var child_process = require("child_process"); +var fs = require("fs"); +var path = require("path"); -child_process.exec('nodenv root', function(err, stdout, stderr) { - var npm +child_process.exec("nodenv root", function (err, stdout, stderr) { + var npm; // get shim path from `nodenv root` (respects $NODENV_ROOT) - if(!err && stdout) { - npm = npmShim(stdout.replace(/\n/g, '')) + if (!err && stdout) { + npm = npmShim(stdout.replace(/\n/g, "")); } // infer shim path if installed as nodenv plugin - if (!npm && path.basename(path.resolve(__dirname + '/../..')) === 'plugins') { - npm = npmShim(path.resolve(__dirname + '/../../..')) + if (!npm && path.basename(path.resolve(__dirname + "/../..")) === "plugins") { + npm = npmShim(path.resolve(__dirname + "/../../..")); } // fallback to npm from PATH if not found thus far child_process - .spawn(npm || 'npm', process.argv.slice(2), { stdio: 'inherit' }) - .on('close', process.exit) -}) + .spawn(npm || "npm", process.argv.slice(2), { stdio: "inherit" }) + .on("close", process.exit); +}); function npmShim(nodenvRoot) { - var npmShim = nodenvRoot + '/shims/npm' - if (fs.existsSync(npmShim)) return npmShim + var npmShim = nodenvRoot + "/shims/npm"; + if (fs.existsSync(npmShim)) return npmShim; } From 2fc1c6924f81feb94ea67e83aef8cdd328f0de1b Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 22 Jul 2025 13:07:34 -0400 Subject: [PATCH 4/6] Natural language lintfixes --- README.md | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bdbc79c..505b1ce 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ Fix IntelliJ/WebStorm's npm integration under nodenv - [Pre-requisites](#pre-requisites) - [Installation](#installation) - [nodenv plugin](#nodenv-plugin) - - [jetbrains-aware git clone](#jetbrains-aware-git-clone) + - [JetBrains-aware Git clone](#jetbrains-aware-git-clone) - [standalone clone](#standalone-clone) - - [homebrew](#homebrew) - - [global npm or yarn package](#global-npm-or-yarn-package) + - [Homebrew](#homebrew) + - [global npm or Yarn package](#global-npm-or-yarn-package) - [Configuration](#configuration) - [Package Manager](#package-manager) - [Nodenv Root](#nodenv-root) @@ -32,7 +32,7 @@ This proxy assumes you have already selected nodenv's shim as your node runtime **(recommended if you have a custom nodenv root)** This installation method allows the proxy to find nodenv root automatically; -the tradeoff being that IntelliJ/WebStorm must be explicitly configured with the proxy's location. +the trade-off being that IntelliJ/WebStorm must be explicitly configured with the proxy's location. ```sh git clone https://github.com/nodenv/jetbrains-npm "$(nodenv root)"/plugins/jetbrains-npm @@ -44,12 +44,12 @@ After installation, set the [Package Manager path](#Package-Manager) to the outp echo "$(nodenv root)"/plugins/jetbrains-npm ``` -### jetbrains-aware git clone +### JetBrains-aware Git clone **(recommended if your nodenv root is the default ~/.nodenv)** This installation method enables JetBrains to find the npm proxy automatically, as it is relative to the node executable: `../lib/node_modules/npm/bin/npm-cli.js`; (relative to `shims/node`) -the tradeoff requires ensuring the proxy can find your nodenv-root. +the trade-off requires ensuring the proxy can find your nodenv-root. ```sh mkdir -p "$(nodenv root)/lib/node_modules" @@ -72,7 +72,7 @@ After installation: 1. set your [Package Manager path](#Package-Manager) as the path to your clone 2. ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment -### homebrew +### Homebrew ```sh brew tap nodenv/nodenv @@ -87,7 +87,7 @@ brew --prefix jetbrains-npm And finally, ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment. -### global npm or yarn package +### global npm or Yarn package ```sh npm -g install @nodenv/jetbrains-npm @@ -138,17 +138,22 @@ It should be set to the path where this proxy was installed. (ie, the directory If you use the default path of `~/.nodenv` as your nodenv root, you're all set; the proxy should be able to derive your nodenv root location automatically. -If you use a custom location for nodenv root, you must ensure `NODENV_ROOT` is set accordingly and exported in IntelliJ/WebStorm's environment in one of the following ways: - set and export it in `~/.profile` or `~/.bash_profile` - or source `~/.bashrc` from `~/.profile` or `~/.bash_profile` - or always launch IntelliJ/WebStorm from a terminal - or modify the IDE desktop launcher to launch bash interactively +If you use a custom location for nodenv root, you must ensure `NODENV_ROOT` is set accordingly and exported in IntelliJ/WebStorm's environment in one of the following ways: + +- set and export it in `~/.profile` or `~/.bash_profile` +- or source `~/.bashrc` from `~/.profile` or `~/.bash_profile` +- or always launch IntelliJ/WebStorm from a terminal +- or modify the IDE desktop launcher to launch Bash interactively (see https://youtrack.jetbrains.com/issue/IDEABKL-7589 for more details about JetBrains and environment variables) ## Why is this necessary? -IntelliJ/WebStorm, for its own reasons, does not directly execute the npm or yarn executable found in `PATH`. -Instead, it attempts to find the npm/yarn _package directory_, and invoke node with the `bin/npm-cli.js` or `bin/yarn.js` script. +IntelliJ/WebStorm, for its own reasons, does not directly execute the npm or Yarn executable found in `PATH`. +Instead, it attempts to find the npm/Yarn _package directory_, and invoke node with the `bin/npm-cli.js` or `bin/yarn.js` script. ([resolution logic](https://github.com/nodenv/nodenv/pull/129#discussion_r246391978)) -Of course, nodenv only resolves the true location of the node (or npm/yarn) executable at invocation time. -This means JetBrains will never find the npm-cli.js or yarn.js scripts, since they do not exist relative to nodenv's node shim. (nor can they be found relative to nodenv's npm/yarn shims) +Of course, nodenv only resolves the true location of the node (or npm/Yarn) executable at invocation time. +This means JetBrains will never find the npm-cli.js or yarn.js scripts, since they do not exist relative to nodenv's node shim. (nor can they be found relative to nodenv's npm/Yarn shims) ## How it works From 675ff8d72a4be5c98acdf4312a83e1469a586b07 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 22 Jul 2025 13:11:06 -0400 Subject: [PATCH 5/6] Markdown lintfixes --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 505b1ce..a20ea83 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ the trade-off being that IntelliJ/WebStorm must be explicitly configured with th git clone https://github.com/nodenv/jetbrains-npm "$(nodenv root)"/plugins/jetbrains-npm ``` -After installation, set the [Package Manager path](#Package-Manager) to the output of: +After installation, set the [Package Manager path](#package-manager) to the output of: ```sh echo "$(nodenv root)"/plugins/jetbrains-npm @@ -56,7 +56,7 @@ mkdir -p "$(nodenv root)/lib/node_modules" git clone https://github.com/nodenv/jetbrains-npm "$(nodenv root)"/lib/node_modules/npm ``` -After installation, the IDE should automatically find the proxy and include it in the list of available [package managers](#Package-Manager); just select it! (In fact, if the package manager field is empty before cloning, then a restart of WebStorm should select it automatically.) +After installation, the IDE should automatically find the proxy and include it in the list of available [package managers](#package-manager); just select it! (In fact, if the package manager field is empty before cloning, then a restart of WebStorm should select it automatically.) ### standalone clone @@ -69,8 +69,8 @@ git clone https://github.com/nodenv/jetbrains-npm After installation: -1. set your [Package Manager path](#Package-Manager) as the path to your clone -2. ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment +1. set your [Package Manager path](#package-manager) as the path to your clone +2. ensure [`NODENV_ROOT`](#nodenv-root) is set in your IDE environment ### Homebrew @@ -79,13 +79,13 @@ brew tap nodenv/nodenv brew install jetbrains-npm ``` -After installation, set the [Package Manager path](#Package-Manager) to the output of: +After installation, set the [Package Manager path](#package-manager) to the output of: ```sh brew --prefix jetbrains-npm ``` -And finally, ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment. +And finally, ensure [`NODENV_ROOT`](#nodenv-root) is set in your IDE environment. ### global npm or Yarn package @@ -99,7 +99,7 @@ or yarn global add @nodenv/jetbrains-npm ``` -After installation, set the [Package Manager path](#Package-Manager) to the output of: +After installation, set the [Package Manager path](#package-manager) to the output of: ```sh echo $(npm -g prefix)/lib/node_modules/@nodenv/jetbrains-npm @@ -111,7 +111,7 @@ or echo $(yarn global dir)/node_modules/@nodenv/jetbrains-npm ``` -And finally, ensure [`NODENV_ROOT`](#Nodenv-Root) is set in your IDE environment. +And finally, ensure [`NODENV_ROOT`](#nodenv-root) is set in your IDE environment. _**NOTE:**_ Be aware which node is active when you install this package. @@ -145,7 +145,8 @@ If you use a custom location for nodenv root, you must ensure `NODENV_ROOT` is s - or always launch IntelliJ/WebStorm from a terminal - or modify the IDE desktop launcher to launch Bash interactively -(see https://youtrack.jetbrains.com/issue/IDEABKL-7589 for more details about JetBrains and environment variables) +(see [JetBrains issue](https://youtrack.jetbrains.com/issue/IDEABKL-7589) for +more details about JetBrains and environment variables) ## Why is this necessary? From 628605bc3501f7f5ce4e052fa33d2407f29fd9b4 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 22 Jul 2025 13:13:54 -0400 Subject: [PATCH 6/6] JS lintfixes --- bin/npm-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/npm-cli.js b/bin/npm-cli.js index d109be3..2c713e6 100755 --- a/bin/npm-cli.js +++ b/bin/npm-cli.js @@ -4,7 +4,7 @@ var child_process = require("child_process"); var fs = require("fs"); var path = require("path"); -child_process.exec("nodenv root", function (err, stdout, stderr) { +child_process.exec("nodenv root", function (err, stdout) { var npm; // get shim path from `nodenv root` (respects $NODENV_ROOT)