diff --git a/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/install-fnm.ps1 b/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/install-fnm.ps1 index 27ae766c..8b87069b 100755 --- a/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/install-fnm.ps1 +++ b/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/install-fnm.ps1 @@ -1,8 +1,10 @@ # Set the HOME directory to the directory of the script -$HOME = Split-Path -Parent $MyInvocation.MyCommand.Definition +$WORKING_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition + +Write-Output $WORKING_DIR # Set the FNM_DIR variable -$FNM_DIR = Join-Path -Path $HOME -ChildPath ".fnm" +$FNM_DIR = Join-Path -Path $WORKING_DIR -ChildPath ".fnm" # Create the directory if it does not exist if (-Not (Test-Path -Path $FNM_DIR)) { @@ -11,12 +13,13 @@ if (-Not (Test-Path -Path $FNM_DIR)) { # Download and execute the FNM install script $zipUrl = "https://github.com/Schniz/fnm/releases/download/v1.38.1/fnm-windows.zip" -$zipFilePath = "$FNM_DIR\installer" +$zipFilePath = "$FNM_DIR\installer.zip" Invoke-WebRequest -Uri $zipUrl -OutFile $zipFilePath $destinationPath = $FNM_DIR Expand-Archive -Path $zipFilePath -DestinationPath $destinationPath -Force # Load the FNM environment and install Node.js version 20.15.1 -"$FNM_DIR\fnm.exe" env --use-on-cd --shell powershell | Out-String | Invoke-Expression -"$FNM_DIR\fnm.exe" install 20.15.1 \ No newline at end of file +Invoke-Expression "$FNM_DIR\fnm.exe install 20.15.1 --fnm-dir $FNM_DIR" + +Write-Output "Finished FNM installation" \ No newline at end of file diff --git a/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/invoker.properties b/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/invoker.properties index 00f8dfeb..56f6851d 100644 --- a/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/invoker.properties +++ b/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/invoker.properties @@ -1,3 +1,3 @@ -invoker.environmentVariables.HOME=${basedir}/target/it/node-version-manager/fnm/with-npm -invoker.environmentVariables.FNM_DIR=${basedir}/target/it/node-version-manager/fnm/with-npm/.fnm -invoker.environmentVariables.XDG_DATA_HOME=${basedir}/target/it/node-version-manager/fnm/with-npm \ No newline at end of file +invoker.environmentVariables.HOME=${basedir}/target/it/node-version-manager/windows/fnm +invoker.environmentVariables.FNM_DIR=${basedir}/target/it/node-version-manager/windows/fnm/.fnm +invoker.environmentVariables.XDG_DATA_HOME=${basedir}/target/it/node-version-manager/windows/fnm \ No newline at end of file diff --git a/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/prebuild.groovy b/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/prebuild.groovy index 8c33081b..a0316adc 100644 --- a/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/prebuild.groovy +++ b/frontend-maven-plugin/src/it/node-version-manager/windows/fnm/prebuild.groovy @@ -1,2 +1,2 @@ -def p = "powershell $basedir/install-fnm.ps1".execute() +def p = "powershell $basedir\\install-fnm.ps1".execute() p.waitForProcessOutput(System.out, System.err) \ No newline at end of file diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/client/FnmClient.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/client/FnmClient.java index f530e32b..0d84278f 100644 --- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/client/FnmClient.java +++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/client/FnmClient.java @@ -35,22 +35,33 @@ public File getNodeExecutable(String nodeVersion) { String architecture = platform.getArchitectureName(); String osCodename = platform.getCodename(); String nodeOnPlatform = String.format("node-%s-%s-%s", nodeVersionWithV, osCodename, architecture); - Path path = Paths.get(fnmDir, "node-versions", nodeVersionWithV, nodeOnPlatform, "bin", "node"); + if (installConfig.getPlatform().isWindows()) { + return Paths.get(fnmDir, "node-versions", nodeVersionWithV, "installation", "node.exe").toFile(); + } + + Path path = Paths.get(fnmDir, "node-versions", nodeVersionWithV, nodeOnPlatform, "bin", "node"); if (Files.exists(path)) { return path.toFile(); } + return Paths.get(fnmDir, "node-versions", nodeVersionWithV, "installation", "bin", "node").toFile(); } @Override public File getNpmExecutable(String nodeVersion) { File nodeExec = getNodeExecutable(nodeVersion); + + if (installConfig.getPlatform().isWindows()) { + return Paths.get(nodeExec.getParent(), "node_modules", "npm", "bin", "npm-cli.js").toFile(); + } + return new File(nodeExec.getParent(), "npm"); } private String getFnmDir() { String fnmDir = System.getenv("FNM_DIR"); + System.out.println("XXX " + fnmDir); if (fnmDir != null) { Path path = Paths.get(fnmDir); if (Files.exists(path)) { @@ -60,19 +71,26 @@ private String getFnmDir() { String home = System.getenv("HOME"); if (home != null) { - Path path = Paths.get(home, ".fnm"); - if (Files.exists(path)) { - return path.toString(); - } - - path = Paths.get(home, "Library", "Application Support", "fnm"); - if (Files.exists(path)) { - return path.toString(); - } - - path = Paths.get(home, ".local", "share", "fnm"); - if (Files.exists(path)) { - return path.toString(); + if (installConfig.getPlatform().isWindows()) { + Path path = Paths.get(home, "AppData", "Roaming", "fnm"); + if (Files.exists(path)) { + return path.toString(); + } + } else { + Path path = Paths.get(home, ".fnm"); + if (Files.exists(path)) { + return path.toString(); + } + + path = Paths.get(home, "Library", "Application Support", "fnm"); + if (Files.exists(path)) { + return path.toString(); + } + + path = Paths.get(home, ".local", "share", "fnm"); + if (Files.exists(path)) { + return path.toString(); + } } }