diff --git a/README.md b/README.md index 66df708b6..08a5ae125 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Sections include: ## Installing ```shell -npm install -g @cyclonedx/cdxgen@10.9.8 +npm install -g @cyclonedx/cdxgen@10.9.9 ``` If you are a [Homebrew][homebrew-homepage] user, you can also install [cdxgen][homebrew-cdxgen] via: @@ -403,7 +403,7 @@ To generate test public/private key pairs, you can run cdxgen by passing the arg Use the bundled `cdx-verify` command, which supports verifying a single signature added at the bom level. ```shell -npm install -g @cyclonedx/cdxgen@10.9.8 +npm install -g @cyclonedx/cdxgen@10.9.9 cdx-verify -i bom.json --public-key public.key ``` diff --git a/deno.json b/deno.json index d31f079dc..79cf50e26 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@cyclonedx/cdxgen", - "version": "10.9.8", + "version": "10.9.9", "exports": "./index.js", "compilerOptions": { "allowJs": true, diff --git a/docs/CLI.md b/docs/CLI.md index 232474a66..e1b7239c8 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -21,7 +21,7 @@ flowchart LR ## Installing ```shell -sudo npm install -g @cyclonedx/cdxgen@10.9.8 +sudo npm install -g @cyclonedx/cdxgen@10.9.9 ``` If you are a [Homebrew](https://brew.sh/) user, you can also install [cdxgen](https://formulae.brew.sh/formula/cdxgen) via: diff --git a/docs/README.md b/docs/README.md index d4b42cb45..da3945897 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,7 +9,7 @@ cdxgen is available as an npm package, container image, and single application e ## Installation ```shell -sudo npm install -g @cyclonedx/cdxgen@10.9.8 +sudo npm install -g @cyclonedx/cdxgen@10.9.9 ``` If you are a [Homebrew](https://brew.sh/) user, you can also install [cdxgen](https://formulae.brew.sh/formula/cdxgen) via: @@ -63,7 +63,7 @@ cdxgen -t c -o bom.json ## Installation ```shell -sudo npm install -g @cyclonedx/cdxgen@10.9.8 +sudo npm install -g @cyclonedx/cdxgen@10.9.9 ``` ## Usage @@ -237,7 +237,7 @@ To generate test public/private key pairs, you can run cdxgen by passing the arg Use the bundled `cdx-verify` command, which supports verifying a single signature added at the bom level. ```shell -npm install -g @cyclonedx/cdxgen@10.9.8 +npm install -g @cyclonedx/cdxgen@10.9.9 cdx-verify -i bom.json --public-key public.key ``` diff --git a/envcontext.test.js b/envcontext.test.js index 57fa8df03..765eb8758 100644 --- a/envcontext.test.js +++ b/envcontext.test.js @@ -1,6 +1,6 @@ +import { spawnSync } from "node:child_process"; import process from "node:process"; import { expect, test } from "@jest/globals"; - import { collectDotnetInfo, collectGccInfo, @@ -10,9 +10,10 @@ import { collectPythonInfo, collectRustInfo, getBranch, + getNvmToolDirectory, + getOrInstallNvmTool, getOriginUrl, isNvmAvailable, - isNvmToolAvailable, isSdkmanAvailable, isSdkmanToolAvailable, listFiles, @@ -43,8 +44,30 @@ test("sdkman tests", () => { }); test("nvm tests", () => { - if (process.env?.SDKMAN_VERSION) { - expect(isNvmAvailable()).toBeTruthy(); - expect(isNvmToolAvailable("22")).toBeTruthy(); + if (process.env?.NVM_DIR) { + if (isNvmAvailable()) { + // try to remove nodejs 14 before testing below + const removeNode14 = spawnSync( + process.env.SHELL || "bash", + ["-i", "-c", `"nvm uninstall 14"`], + { + encoding: "utf-8", + shell: process.env.SHELL || true, + }, + ); + + // expected to be run in CircleCi, where node version is 22.8.0 + // as defined in our Dockerfile + expect(getNvmToolDirectory(22)).toBeTruthy(); + expect(getNvmToolDirectory(14)).toBeFalsy(); + + // now we install nvm tool for a specific verison + expect(getOrInstallNvmTool(14)).toBeTruthy(); + expect(getNvmToolDirectory(14)).toBeTruthy(); + } else { + // if this test is failing it would be due to an error in isNvmAvailable() + expect(getNvmToolDirectory(22)).toBeFalsy(); + expect(getOrInstallNvmTool(14)).toBeFalsy(); + } } }); diff --git a/jsr.json b/jsr.json index 6f6e18bdc..5d0ebec98 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@cyclonedx/cdxgen", - "version": "10.9.8", + "version": "10.9.9", "exports": "./index.js", "include": ["*.js", "bin/**", "data/**", "types/**"], "exclude": ["test/", "docs/", "contrib/", "ci/", "tools_config/"] diff --git a/package.json b/package.json index b844170fa..5cc9d376b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cyclonedx/cdxgen", - "version": "10.9.8", + "version": "10.9.9", "description": "Creates CycloneDX Software Bill of Materials (SBOM) from source or container image", "homepage": "http://github.com/cyclonedx/cdxgen", "author": "Prabhu Subramanian ", diff --git a/pregen.js b/pregen.js index 47fd966e0..b465faab1 100644 --- a/pregen.js +++ b/pregen.js @@ -1,10 +1,9 @@ -import { spawn, spawnSync } from "node:child_process"; +import { spawnSync } from "node:child_process"; import { mkdtempSync, readdirSync } from "node:fs"; import { arch, platform, tmpdir } from "node:os"; import { delimiter, join } from "node:path"; import { SDKMAN_TOOL_ALIASES, - getNvmToolDirectory, getOrInstallNvmTool, installSdkmanTool, isNvmAvailable, @@ -184,7 +183,7 @@ export function tryLoadNvmAndInstallTool(nodeVersion) { fi `; - const spawnedShell = spawnSync(process.env.SHELL || "bash", ["-c", command], { + const result = spawnSync(process.env.SHELL || "bash", ["-c", command], { encoding: "utf-8", shell: process.env.SHELL || true, }); @@ -228,10 +227,10 @@ export function doNpmInstall(filePath, nvmNodePath) { // There was some problem with NpmInstall if (DEBUG_MODE) { if (console.stdout) { - console.log(result.stdout); + console.log(resultNpmInstall.stdout); } if (console.stderr) { - console.log(result.stderr); + console.log(resultNpmInstall.stderr); } } }