From 8d42747c7365b13e39e1bda95ae0587ed6bce665 Mon Sep 17 00:00:00 2001 From: Kal Cramer Date: Thu, 5 Dec 2024 13:08:31 -0700 Subject: [PATCH 1/5] resolves #46 Add libexec/lib/node_modules to RESOLVE_NODE_HOME_SCRIPT --- src/main/java/org/antora/maven/SystemNodeLinker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/antora/maven/SystemNodeLinker.java b/src/main/java/org/antora/maven/SystemNodeLinker.java index 3507b41..6eddaf0 100644 --- a/src/main/java/org/antora/maven/SystemNodeLinker.java +++ b/src/main/java/org/antora/maven/SystemNodeLinker.java @@ -22,7 +22,7 @@ public class SystemNodeLinker { private static final String RESOLVE_NODE_HOME_SCRIPT = "const p=require('path');" + "function hasNpm(dir){try{require.resolve(p.join(dir,'npm/bin/npm-cli.js'));return dir}catch{}};" + "const exe=process.execPath,root=p.join(exe,p.basename(p.dirname(exe))==='bin'?'../..':'..');" + - "const pkgs=hasNpm(p.join(root,'lib/node_modules'))||hasNpm(p.join(root,'node_modules'))||'';" + + "const pkgs=hasNpm(p.join(root,'lib/node_modules'))||hasNpm(p.join(root,'node_modules'))||hasNpm(p.join(root,'libexec/lib/node_modules'))||'';" + "pkgs&&exe+'\\n'+pkgs+'\\n'+process.version"; private final Log log; -- GitLab From e3a90fff88a1f6b6d50b5d0e29b13dcc1d1dcfb6 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 11 Dec 2024 12:51:30 -0700 Subject: [PATCH 2/5] reformat resolve Node.js home script --- src/main/java/org/antora/maven/SystemNodeLinker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/antora/maven/SystemNodeLinker.java b/src/main/java/org/antora/maven/SystemNodeLinker.java index 6eddaf0..575e2a3 100644 --- a/src/main/java/org/antora/maven/SystemNodeLinker.java +++ b/src/main/java/org/antora/maven/SystemNodeLinker.java @@ -20,9 +20,9 @@ import static java.nio.file.Files.readSymbolicLink; public class SystemNodeLinker { private static final String RESOLVE_NODE_HOME_SCRIPT = "const p=require('path');" + - "function hasNpm(dir){try{require.resolve(p.join(dir,'npm/bin/npm-cli.js'));return dir}catch{}};" + "const exe=process.execPath,root=p.join(exe,p.basename(p.dirname(exe))==='bin'?'../..':'..');" + - "const pkgs=hasNpm(p.join(root,'lib/node_modules'))||hasNpm(p.join(root,'node_modules'))||hasNpm(p.join(root,'libexec/lib/node_modules'))||'';" + + "function hasNpm(dir){try{require.resolve(p.join(root, dir,'npm/bin/npm-cli.js'));return dir}catch{}};" + + "const pkgs=hasNpm('lib/node_modules')||hasNpm('node_modules')||hasNpm('libexec/lib/node_modules')||'';" + "pkgs&&exe+'\\n'+pkgs+'\\n'+process.version"; private final Log log; -- GitLab From 1b7d600afe86a1c147ab72209cbcf31015b3f4f6 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 11 Dec 2024 12:58:44 -0700 Subject: [PATCH 3/5] document how the plugin validates the system Node.js installation --- docs/modules/ROOT/pages/antora-goal.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/modules/ROOT/pages/antora-goal.adoc b/docs/modules/ROOT/pages/antora-goal.adoc index 8865a55..92fd2f3 100644 --- a/docs/modules/ROOT/pages/antora-goal.adoc +++ b/docs/modules/ROOT/pages/antora-goal.adoc @@ -127,6 +127,7 @@ The name or path of the Node.js executable to use. When this parameter is specified, a Node.js installation structure will be created under the location specified by the <> parameter that links (using symlinks) to the Node.js installation for the specified executable. In this scenario, Node.js will not be downloaded and installed locally and the <> parameter will be ignored. The location of the Node.js installation is determined by passing a script to the specified executable that reports the location where Node.js is installed. +The plugin validates the Node.js installation by looking for the npm binscript under [.path]_lib/node_modules_, [.path]_node_modules_, or [.path]_libexec/lib/node_modules_ relative to the node executable (aka binary). In order for the plugin to set up this link on Windows, developer mode must be enabled (so `mklink` can be used). If it isn't, the plugin will copy the Node.js installation instead of creating symlinks to it. -- GitLab From bb0ab6c37a5c3b50cbde195aedb5a1cc538923e0 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 11 Dec 2024 13:10:20 -0700 Subject: [PATCH 4/5] fix logic error introduced while reformatting Node.js home detection script --- src/main/java/org/antora/maven/SystemNodeLinker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/antora/maven/SystemNodeLinker.java b/src/main/java/org/antora/maven/SystemNodeLinker.java index 575e2a3..10078ee 100644 --- a/src/main/java/org/antora/maven/SystemNodeLinker.java +++ b/src/main/java/org/antora/maven/SystemNodeLinker.java @@ -21,7 +21,7 @@ import static java.nio.file.Files.readSymbolicLink; public class SystemNodeLinker { private static final String RESOLVE_NODE_HOME_SCRIPT = "const p=require('path');" + "const exe=process.execPath,root=p.join(exe,p.basename(p.dirname(exe))==='bin'?'../..':'..');" + - "function hasNpm(dir){try{require.resolve(p.join(root, dir,'npm/bin/npm-cli.js'));return dir}catch{}};" + + "function hasNpm(v){try{require.resolve(p.join((v=p.join(root,v)),'npm/bin/npm-cli.js'));return v}catch{}};" + "const pkgs=hasNpm('lib/node_modules')||hasNpm('node_modules')||hasNpm('libexec/lib/node_modules')||'';" + "pkgs&&exe+'\\n'+pkgs+'\\n'+process.version"; -- GitLab From bf0a65e1927820d1fe70ce073d37c9de6c4517e2 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 11 Dec 2024 18:11:09 -0700 Subject: [PATCH 5/5] add entry to CHANGELOG [skip ci] --- CHANGELOG.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index d603903..bf2e104 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -5,6 +5,12 @@ For a detailed view of what's changed, refer to the repository https://gitlab.co This project utilizes semantic versioning. +== Unreleased + +=== Changed + +* Look for npm in libexec/lib/node_modules when verifying the system Node.js installation (#46) (*@KalCramer*) + == 1.0.0-alpha.4 (2024-04-30) === Added -- GitLab