@herodevs/cli 2.0.0-beta.7 → 2.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,9 +26,16 @@ Use of this CLI is governed by the [HeroDevs End of Life Dataset Terms of Servic
26
26
 
27
27
  The CLI is designed to be non-invasive:
28
28
 
29
- * It does not install dependencies or modify package manager files (package-lock.json, yarn.lock, etc.)
29
+ * It does **not** install dependencies or modify package manager files (package-lock.json, yarn.lock, etc.)
30
30
  * It analyzes the project in its current state
31
- * If you need dependencies installed for accurate scanning, please install them manually before running the scan
31
+
32
+ ## Installing Dependencies Before Use
33
+
34
+ Some projects and ecosystems require projects to have dependencies installed already, to achieve an accurate scan result. It is **highly** recommended that you install all dependencies of your project to your working directory, before running a scan on your project, to ensure scan accuracy.
35
+
36
+ ### Java Users
37
+
38
+ Maven and Gradle projects should run an install and build before scanning
32
39
 
33
40
  ## Usage
34
41
  <!-- usage -->
@@ -37,7 +44,7 @@ $ npm install -g @herodevs/cli@beta
37
44
  $ hd COMMAND
38
45
  running command...
39
46
  $ hd (--version)
40
- @herodevs/cli/2.0.0-beta.7 darwin-arm64 node-v22.18.0
47
+ @herodevs/cli/2.0.0-beta.8 darwin-arm64 node-v22.18.0
41
48
  $ hd --help [COMMAND]
42
49
  USAGE
43
50
  $ hd COMMAND
@@ -49,6 +56,7 @@ USAGE
49
56
  * [`hd help [COMMAND]`](#hd-help-command)
50
57
  * [`hd scan eol`](#hd-scan-eol)
51
58
  * [`hd update [CHANNEL]`](#hd-update-channel)
59
+ * Only applies to tarball installation. For NPM users, please update using `npm install`
52
60
 
53
61
  ## `hd help [COMMAND]`
54
62
 
@@ -76,13 +84,14 @@ Scan a given SBOM for EOL data
76
84
 
77
85
  ```
78
86
  USAGE
79
- $ hd scan eol [--json] [-f <value> | -d <value>] [-s] [--saveSbom]
87
+ $ hd scan eol [--json] [-f <value> | -d <value>] [-s] [--saveSbom] [--version]
80
88
 
81
89
  FLAGS
82
90
  -d, --dir=<value> [default: <current directory>] The directory to scan in order to create a cyclonedx SBOM
83
91
  -f, --file=<value> The file path of an existing cyclonedx SBOM to scan for EOL
84
92
  -s, --save Save the generated report as herodevs.report.json in the scanned directory
85
93
  --saveSbom Save the generated SBOM as herodevs.sbom.json in the scanned directory
94
+ --version Show CLI version.
86
95
 
87
96
  GLOBAL FLAGS
88
97
  --json Format output as json.
@@ -112,11 +121,12 @@ EXAMPLES
112
121
  $ hd scan eol --json
113
122
  ```
114
123
 
115
- _See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.7/src/commands/scan/eol.ts)_
124
+ _See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v2.0.0-beta.8/src/commands/scan/eol.ts)_
116
125
 
117
126
  ## `hd update [CHANNEL]`
118
127
 
119
128
  update the hd CLI
129
+ **NOTE:** Only applies to binary installation method. NPM users should use `npm install` to update to the latest version.
120
130
 
121
131
  ```
122
132
  USAGE
@@ -157,7 +167,7 @@ _See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v4
157
167
 
158
168
  You can use `@herodevs/cli` in your CI/CD pipelines to automate EOL scanning.
159
169
 
160
- ### Using the Docker Image (recommended)
170
+ ### Using the Docker Image (Recommended)
161
171
 
162
172
  We provide a Docker image that's pre-configured to run EOL scans. Based on [`cdxgen`](https://github.com/CycloneDX/cdxgen),
163
173
  it contains build tools for most project types and will provide best results when generating an SBOM. Use these templates to generate a report and save it to your CI job artifact for analysis and processing after your scan runs.
@@ -207,9 +217,9 @@ eol-scan:
207
217
  - herodevs.report.json
208
218
  ```
209
219
 
210
- ### Using `npx`
220
+ ### Using `npx` in CI
211
221
 
212
- You can use `npx` to run the CLI just like you'd run it locally.
222
+ You can use `npx` to run the CLI in your CI pipeline, just like you would run it locally.
213
223
 
214
224
  > [!NOTE]
215
225
  > The development environment is expected to be ready to run the app. For best results,
package/bin/dev.js CHANGED
@@ -4,6 +4,6 @@ import main from './main.js';
4
4
 
5
5
  try {
6
6
  await main(false);
7
- } catch (error) {
7
+ } catch {
8
8
  process.exit(1);
9
9
  }
package/bin/main.js CHANGED
@@ -21,7 +21,7 @@ async function main(isProduction = false) {
21
21
  development: !isProduction,
22
22
  dir: new URL('./dev.js', import.meta.url),
23
23
  });
24
- } catch (error) {
24
+ } catch {
25
25
  process.exit(1);
26
26
  }
27
27
  }
package/bin/run.js CHANGED
@@ -4,6 +4,6 @@ import main from './main.js';
4
4
 
5
5
  try {
6
6
  await main(true);
7
- } catch (error) {
7
+ } catch {
8
8
  process.exit(1);
9
9
  }
@@ -12,6 +12,7 @@ export default class ScanEol extends Command {
12
12
  dir: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
13
  save: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
14
  saveSbom: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ version: import("@oclif/core/interfaces").BooleanFlag<void>;
15
16
  };
16
17
  run(): Promise<EolReport | undefined>;
17
18
  private loadSbom;
@@ -50,6 +50,7 @@ export default class ScanEol extends Command {
50
50
  default: false,
51
51
  description: `Save the generated SBOM as ${filenamePrefix}.sbom.json in the scanned directory`,
52
52
  }),
53
+ version: Flags.version(),
53
54
  };
54
55
  async run() {
55
56
  const { flags } = await this.parse(ScanEol);
@@ -0,0 +1,18 @@
1
+ import ora, {} from 'ora';
2
+ import { track } from "../../service/analytics.svc.js";
3
+ const hook = async (opts) => {
4
+ const isHelpOrVersionCmd = opts.argv.includes('--help') || opts.argv.includes('--version');
5
+ let spinner;
6
+ if (!isHelpOrVersionCmd) {
7
+ spinner = ora().start('Cleaning up');
8
+ }
9
+ const event = track('CLI Session Ended', (context) => ({
10
+ cli_version: context.cli_version,
11
+ ended_at: new Date(),
12
+ })).promise;
13
+ if (!isHelpOrVersionCmd) {
14
+ await event;
15
+ spinner?.stop();
16
+ }
17
+ };
18
+ export default hook;
@@ -1,7 +1,7 @@
1
1
  import updateNotifier, {} from 'update-notifier';
2
- import pkg from '../../package.json' with { type: 'json' };
3
- import { debugLogger } from "../service/log.svc.js";
4
- const updateNotifierHook = async (options) => {
2
+ import pkg from '../../../package.json' with { type: 'json' };
3
+ import { debugLogger } from "../../service/log.svc.js";
4
+ const updateNotifierHook = async () => {
5
5
  debugLogger('pkg.version', pkg.version);
6
6
  const distTag = getDistTag(pkg.version);
7
7
  debugLogger('distTag', distTag);
@@ -0,0 +1,3 @@
1
+ import type { Hook } from '@oclif/core';
2
+ declare const hook: Hook.Init;
3
+ export default hook;
@@ -1,7 +1,6 @@
1
1
  import { parseArgs } from 'node:util';
2
- import debug from 'debug';
3
- import { initializeAnalytics, track } from "../service/analytics.svc.js";
4
- const hook = async (opts) => {
2
+ import { initializeAnalytics, track } from "../../service/analytics.svc.js";
3
+ const hook = async () => {
5
4
  const args = parseArgs({ allowPositionals: true, strict: false });
6
5
  initializeAnalytics();
7
6
  track('CLI Command Submitted', (context) => ({
@@ -12,9 +11,5 @@ const hook = async (opts) => {
12
11
  cli_version: context.cli_version,
13
12
  started_at: context.started_at,
14
13
  }));
15
- // If JSON flag is enabled, silence debug logging
16
- if (opts.Command.prototype.jsonEnabled()) {
17
- debug.disable();
18
- }
19
14
  };
20
15
  export default hook;
@@ -0,0 +1,8 @@
1
+ import debug from 'debug';
2
+ const hook = async (opts) => {
3
+ // If JSON flag is enabled, silence debug logging
4
+ if (opts.Command.prototype.jsonEnabled()) {
5
+ debug.disable();
6
+ }
7
+ };
8
+ export default hook;
@@ -58,8 +58,8 @@ export function formatScanResults(report) {
58
58
  ux.colorize('bold', `${report.components.length.toLocaleString()} total packages scanned`),
59
59
  getStatusRowText.EOL(`${EOL.toLocaleString().padEnd(5)} End-of-Life (EOL)`),
60
60
  getStatusRowText.EOL_UPCOMING(`${EOL_UPCOMING.toLocaleString().padEnd(5)} EOL Upcoming`),
61
- getStatusRowText.OK(`${OK.toLocaleString().padEnd(5)} Not End-of-Life`),
62
- getStatusRowText.UNKNOWN(`${UNKNOWN.toLocaleString().padEnd(5)} Unknown Status`),
61
+ getStatusRowText.OK(`${OK.toLocaleString().padEnd(5)} Not End-of-Life (EOL)`),
62
+ getStatusRowText.UNKNOWN(`${UNKNOWN.toLocaleString().padEnd(5)} Unknown EOL Status`),
63
63
  getStatusRowText.UNKNOWN(`${NES_AVAILABLE.toLocaleString().padEnd(5)} HeroDevs NES Remediation${NES_AVAILABLE !== 1 ? 's' : ''} Available`),
64
64
  ];
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herodevs/cli",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.8",
4
4
  "author": "HeroDevs, Inc",
5
5
  "bin": {
6
6
  "hd": "./bin/run.js"
@@ -30,7 +30,7 @@
30
30
  "test": "globstar -- node --import tsx --test --experimental-test-module-mocks \"test/**/*.test.ts\"",
31
31
  "test:e2e": "globstar -- node --import tsx --test \"e2e/**/*.test.ts\"",
32
32
  "typecheck": "tsc --noEmit",
33
- "version": "oclif manifest && npm run readme"
33
+ "version": "oclif manifest"
34
34
  },
35
35
  "keywords": [
36
36
  "herodevs",
@@ -87,9 +87,12 @@
87
87
  "@oclif/plugin-update"
88
88
  ],
89
89
  "hooks": {
90
- "init": "./dist/hooks/npm-update-notifier.js",
91
- "prerun": "./dist/hooks/prerun.js",
92
- "finally": "./dist/hooks/finally.js"
90
+ "init": [
91
+ "./dist/hooks/init/00_npm-update-notifier.js",
92
+ "./dist/hooks/init/01_initialize_amplitude.js"
93
+ ],
94
+ "prerun": "./dist/hooks/prerun/prerun.js",
95
+ "finally": "./dist/hooks/finally/finally.js"
93
96
  },
94
97
  "topicSeparator": " ",
95
98
  "macos": {
@@ -1,14 +0,0 @@
1
- import ora from 'ora';
2
- import { track } from "../service/analytics.svc.js";
3
- const hook = async (opts) => {
4
- const spinner = ora().start('Cleaning up');
5
- const event = track('CLI Session Ended', (context) => ({
6
- cli_version: context.cli_version,
7
- ended_at: new Date(),
8
- })).promise;
9
- if (!opts.argv.includes('--help')) {
10
- await event;
11
- }
12
- spinner.stop();
13
- };
14
- export default hook;
File without changes