Need a new Mojo to execute arbitrary node command
Some frameworks need to pre-compile some files before making the front app available. See xslt3 for example where we need to pre-compile xslt files with this commande :
node xslt3 -xsl:whatever.xsl -export:whatever.sef.json
Actually, there is no Mojo that directly allows to call node with specific parameters. I need one, with this usage :
<plugin>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>compile-xslt</id>
<phase>compile</phase>
<goals>
<goal>node</goal>
</goals>
<configuration>
<arguments>node_modules/xslt3/xslt3.js -xsl:src/main/xsl/md-to-xhtml.xsl -export:target/classes/xsl/md-to-html.sef.json</arguments>
</configuration>
</execution>
</executions>
</plugin>
I just open the issue to be referenced in the pull request.
There is the npx goal which would probably work almost exactly as you want: <arguments>xslt3 -xsl:...
You might also want to consider https://docs.npmjs.com/cli/v6/using-npm/scripts -- in particular I'm guessing that you want to do this xslt call as part of the preinstall or postinstall of your package or something like that. But even if not, you can add it as its own script and then make the f-e-p goal npm and the arguments run compile-xslt.
FYI npm run of npm 7.x has a strange behaviour
https://docs.npmjs.com/cli/v7/using-npm/scripts#user
When npm is run as root, scripts are always run with the effective uid and gid of the working directory owner.
As a result, it runs as different user from maven... hitting the permission issue 🤦
Right now I'm just using a script to set up PATH with node/npm installed from this plugin.
See https://github.com/npm/cli/issues/3110