Skip to content

feat: adds file --output and --sbomOutput flags to specify custom file paths#387

Merged
KLongmuirHD merged 2 commits into
mainfrom
feat/output-flags
Oct 23, 2025
Merged

feat: adds file --output and --sbomOutput flags to specify custom file paths#387
KLongmuirHD merged 2 commits into
mainfrom
feat/output-flags

Conversation

@v3nant
Copy link
Copy Markdown
Contributor

@v3nant v3nant commented Oct 21, 2025

Custom Output Paths

Summary
Enabled hd scan eol to write reports and SBOMs to caller-defined destinations and improved related UX.

What changed

  • Added --output and --sbomOutput flags with validation ensuring they pair with --save / --saveSbom.

  • Updated scan workflow to pass custom paths into the file service, adjust display hints, and emit warnings when outputs are skipped.

  • Refactored file service to resolve absolute targets, enforce directory existence, and standardize JSON write error handling.

  • Expanded E2E and unit coverage around new flags, error cases, and cleanup helpers; documented the workflow in README examples.

  • Prevented the cleanup spinner from running when commands fail, so warning messages remain visible.

@v3nant v3nant force-pushed the feat/output-flags branch from ae7e429 to 5030773 Compare October 21, 2025 22:01
@v3nant v3nant marked this pull request as ready for review October 21, 2025 22:11
@v3nant v3nant requested a review from a team as a code owner October 21, 2025 22:11
@KLongmuirHD
Copy link
Copy Markdown
Contributor

KLongmuirHD commented Oct 22, 2025

➜  cli git:(feat/output-flags) npm run dev -- --dir=/Users/klongmuir/HeroDevs/signals-playground --save --output=/Users/klongmuir/HeroDevs/nes/eol-api --saveSbom --sbomOutput=/Users/klongmuir/HeroDevs/nes/eol-report-card/banana.sbom.json

> @herodevs/cli@2.0.0-beta.10 dev
> npm run build && ./bin/dev.js --dir=/Users/klongmuir/HeroDevs/signals-playground --save --output=/Users/klongmuir/HeroDevs/nes/eol-api --saveSbom --sbomOutput=/Users/klongmuir/HeroDevs/nes/eol-report-card/banana.sbom.json


> @herodevs/cli@2.0.0-beta.10 build
> shx rm -rf dist && tsc -b

✔ Generated SBOM
SBOM saved to /Users/klongmuir/HeroDevs/nes/eol-report-card/banana.sbom.json
✔ SBOM trimmed
✔ Scan completed
Error: Failed to save eol-api: EISDIR: illegal operation on a directory, open '/Users/klongmuir/HeroDevs/nes/eol-api'
    at Object.error (/Users/klongmuir/HeroDevs/nes/cli/node_modules/@oclif/core/lib/errors/error.js:44:15)
    at ScanEol.error (/Users/klongmuir/HeroDevs/nes/cli/node_modules/@oclif/core/lib/command.js:210:23)
    at ScanEol.saveReport (file:///Users/klongmuir/HeroDevs/nes/cli/dist/commands/scan/eol.js:206:18)
    at ScanEol.run (file:///Users/klongmuir/HeroDevs/nes/cli/dist/commands/scan/eol.js:144:37)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async ScanEol._run (/Users/klongmuir/HeroDevs/nes/cli/node_modules/@oclif/core/lib/command.js:181:22)
    at async Config.runCommand (/Users/klongmuir/HeroDevs/nes/cli/node_modules/@oclif/core/lib/config/config.js:456:25)
    at async run (/Users/klongmuir/HeroDevs/nes/cli/node_modules/@oclif/core/lib/main.js:97:16)
    at async main (file:///Users/klongmuir/HeroDevs/nes/cli/bin/main.js:20:5)
    at async file:///Users/klongmuir/HeroDevs/nes/cli/bin/dev.js:6:3

issue: if I don't provide a file name in the output path, the CLI errors. If the path the user provides is just a directory, and doesn't give a custom filename, we should save with the default file name, to that path. So in this example, I would expect herodevs.report.json to be saved to my eol-api directory. Apply to both new flags.

Comment thread e2e/scan/eol.test.ts Outdated
Comment thread e2e/scan/eol.test.ts Outdated
Comment thread e2e/scan/eol.test.ts Outdated
Comment thread e2e/scan/eol.test.ts Outdated
Comment thread e2e/scan/eol.test.ts Outdated
Comment thread e2e/scan/eol.test.ts Outdated
Comment thread src/commands/scan/eol.ts
Comment thread src/hooks/finally/finally.ts Outdated
Comment thread src/service/file.svc.ts Outdated
Comment thread src/service/file.svc.ts
Comment thread src/service/file.svc.ts Outdated
Comment thread src/service/file.svc.ts Outdated
Comment thread test/service/file.svc.test.ts Outdated
Comment thread test/service/file.svc.test.ts Outdated
@v3nant v3nant force-pushed the feat/output-flags branch 2 times, most recently from 530f3e3 to 74ff59b Compare October 23, 2025 01:29
@v3nant v3nant force-pushed the feat/output-flags branch from 74ff59b to f1de0b6 Compare October 23, 2025 19:46
@KLongmuirHD KLongmuirHD merged commit 75c61ca into main Oct 23, 2025
12 checks passed
@KLongmuirHD KLongmuirHD deleted the feat/output-flags branch October 23, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants