Skip to content

Conversation

@aryan-rajoria
Copy link
Collaborator

@aryan-rajoria aryan-rajoria commented Sep 5, 2024

This PR aims to add support to different Node.js versions, through -t nodejs<version>.
Tested on the following github repos:
For node-8:

    "https://github.com/kriasoft/react-app.git",
    "https://github.com/deepraining/blogs.git",

react-appbom.json
blogsbom.json

For node-10:

    "https://github.com/patrickjuchli/basic-ftp.git",
    "https://github.com/donavon/use-thwack.git",

basic-ftpbom.json
use-thwackbom.json

For node-12:

    "https://github.com/postcss/sugarss.git",
    "https://github.com/sindresorhus/pupa.git",

sugarssbom.json
pupabom.json

For node-14:

    "https://github.com/zabirauf/AutoGPT.js.git",
    "https://github.com/plexidev/quick.db.git",

AutoGPT.jsbom.json
quick.dbbom.json

For node-16:

    "https://github.com/Atome-FE/llama-node.git",
    "https://github.com/sindresorhus/react-extras.git",

llama-nodebom.json
react-extrasbom.json

For node-18:

    "https://github.com/glitch-soc/mastodon.git",
    "https://github.com/sindresorhus/element-ready.git"

mastodonbom.json
element-readybom.json

@aryan-rajoria
Copy link
Collaborator Author

For the dvna project:
https://github.com/appsecco/dvna.git
sbom generated using args:

"args": [
                "-t",
                "nodejs8",
                "-o",
                "~/dvnasbom.json",
                "~/dvna"
            ]

dvnasbom.json

@aryan-rajoria aryan-rajoria changed the title Feat: Add support for Different Node versions (NVM support) Feat: Add support for different Node versions (NVM support) Sep 5, 2024
@aryan-rajoria
Copy link
Collaborator Author

For node-20:

    "https://github.com/nowsecure/node-applesign.git",
    "https://github.com/Mojang/minecraft-scripting-libraries.git",

node-applesignbom.json
minecraft-scripting-librariesbom.json

For node-22:

    "https://github.com/DIYgod/RSSHub.git",
    "https://github.com/pex-gl/pex-gl.git",

RSSHubbom.json
pex-glbom.json

Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
@aryan-rajoria aryan-rajoria marked this pull request as ready for review September 5, 2024 17:18
@aryan-rajoria aryan-rajoria force-pushed the nvm-support branch 2 times, most recently from 611ec25 to a130a92 Compare September 5, 2024 17:19
Signed-off-by: Aryan Rajoria <[email protected]>
@aryan-rajoria
Copy link
Collaborator Author

Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Comment on lines +211 to +227
const resultNpmInstall = spawnSync(
process.env.SHELL || "bash",
[
"-i",
"-c",
`export PATH='${nvmNodePath}${delimiter}$PATH' && npm install --package-lock-only`,
],
{
encoding: "utf-8",
shell: process.env.SHELL || true,
cwd: filePath,
env: {
...process.env,
PATH: newPath,
},
},
);

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [file name](1).
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
Signed-off-by: Aryan Rajoria <[email protected]>
export function tryLoadNvmAndInstallTool(nodeVersion) {
const NVM_DIR = process.env.NVM_DIR;

const command = `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok for this PR, but this won't work in Windows powershell. Maybe this could be added in another PR.

@prabhu
Copy link
Collaborator

prabhu commented Sep 6, 2024

Great job on your first sponsored PR! Just a couple of rename suggestions.

@aryan-rajoria aryan-rajoria merged commit f1a60cd into master Sep 6, 2024
@aryan-rajoria aryan-rajoria deleted the nvm-support branch September 6, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants