@herodevs/cli 1.1.0-beta.1 → 1.2.0-beta.1
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 +13 -309
- package/bin/dev.js +6 -5
- package/bin/run.js +3 -2
- package/dist/api/client.d.ts +0 -2
- package/dist/api/client.js +19 -18
- package/dist/api/nes/nes.client.d.ts +4 -0
- package/dist/api/nes/nes.client.js +11 -0
- package/dist/api/queries/nes/sbom.js +5 -0
- package/dist/api/types/nes.types.d.ts +17 -3
- package/dist/api/types/nes.types.js +11 -1
- package/dist/commands/report/committers.js +45 -28
- package/dist/commands/report/purls.js +44 -29
- package/dist/commands/scan/eol.d.ts +13 -4
- package/dist/commands/scan/eol.js +111 -39
- package/dist/commands/scan/sbom.d.ts +1 -0
- package/dist/commands/scan/sbom.js +53 -32
- package/dist/service/committers.svc.js +24 -3
- package/dist/service/eol/cdx.svc.js +1 -0
- package/dist/service/eol/eol.svc.d.ts +0 -21
- package/dist/service/eol/eol.svc.js +0 -60
- package/dist/service/eol/sbom.worker.js +1 -0
- package/dist/service/error.svc.d.ts +8 -0
- package/dist/service/error.svc.js +28 -0
- package/dist/service/nes/nes.svc.js +1 -0
- package/dist/ui/date.ui.d.ts +1 -0
- package/dist/ui/date.ui.js +15 -0
- package/dist/ui/eol.ui.d.ts +4 -3
- package/dist/ui/eol.ui.js +56 -15
- package/dist/ui/shared.us.d.ts +3 -0
- package/dist/ui/shared.us.js +13 -0
- package/package.json +6 -6
- package/dist/service/line.svc.d.ts +0 -24
- package/dist/service/line.svc.js +0 -61
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ $ npm install -g @herodevs/cli
|
|
|
16
16
|
$ hd COMMAND
|
|
17
17
|
running command...
|
|
18
18
|
$ hd (--version)
|
|
19
|
-
@herodevs/cli/1.
|
|
19
|
+
@herodevs/cli/1.2.0-beta.1 linux-x64 node-v22.14.0
|
|
20
20
|
$ hd --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ hd COMMAND
|
|
@@ -26,16 +26,6 @@ USAGE
|
|
|
26
26
|
## Commands
|
|
27
27
|
<!-- commands -->
|
|
28
28
|
* [`hd help [COMMAND]`](#hd-help-command)
|
|
29
|
-
* [`hd plugins`](#hd-plugins)
|
|
30
|
-
* [`hd plugins add PLUGIN`](#hd-plugins-add-plugin)
|
|
31
|
-
* [`hd plugins:inspect PLUGIN...`](#hd-pluginsinspect-plugin)
|
|
32
|
-
* [`hd plugins install PLUGIN`](#hd-plugins-install-plugin)
|
|
33
|
-
* [`hd plugins link PATH`](#hd-plugins-link-path)
|
|
34
|
-
* [`hd plugins remove [PLUGIN]`](#hd-plugins-remove-plugin)
|
|
35
|
-
* [`hd plugins reset`](#hd-plugins-reset)
|
|
36
|
-
* [`hd plugins uninstall [PLUGIN]`](#hd-plugins-uninstall-plugin)
|
|
37
|
-
* [`hd plugins unlink [PLUGIN]`](#hd-plugins-unlink-plugin)
|
|
38
|
-
* [`hd plugins update`](#hd-plugins-update)
|
|
39
29
|
* [`hd report committers`](#hd-report-committers)
|
|
40
30
|
* [`hd report purls`](#hd-report-purls)
|
|
41
31
|
* [`hd scan eol`](#hd-scan-eol)
|
|
@@ -61,296 +51,6 @@ DESCRIPTION
|
|
|
61
51
|
|
|
62
52
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.27/src/commands/help.ts)_
|
|
63
53
|
|
|
64
|
-
## `hd plugins`
|
|
65
|
-
|
|
66
|
-
List installed plugins.
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
USAGE
|
|
70
|
-
$ hd plugins [--json] [--core]
|
|
71
|
-
|
|
72
|
-
FLAGS
|
|
73
|
-
--core Show core plugins.
|
|
74
|
-
|
|
75
|
-
GLOBAL FLAGS
|
|
76
|
-
--json Format output as json.
|
|
77
|
-
|
|
78
|
-
DESCRIPTION
|
|
79
|
-
List installed plugins.
|
|
80
|
-
|
|
81
|
-
EXAMPLES
|
|
82
|
-
$ hd plugins
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/index.ts)_
|
|
86
|
-
|
|
87
|
-
## `hd plugins add PLUGIN`
|
|
88
|
-
|
|
89
|
-
Installs a plugin into hd.
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
USAGE
|
|
93
|
-
$ hd plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
94
|
-
|
|
95
|
-
ARGUMENTS
|
|
96
|
-
PLUGIN... Plugin to install.
|
|
97
|
-
|
|
98
|
-
FLAGS
|
|
99
|
-
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
100
|
-
-h, --help Show CLI help.
|
|
101
|
-
-s, --silent Silences npm output.
|
|
102
|
-
-v, --verbose Show verbose npm output.
|
|
103
|
-
|
|
104
|
-
GLOBAL FLAGS
|
|
105
|
-
--json Format output as json.
|
|
106
|
-
|
|
107
|
-
DESCRIPTION
|
|
108
|
-
Installs a plugin into hd.
|
|
109
|
-
|
|
110
|
-
Uses npm to install plugins.
|
|
111
|
-
|
|
112
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
113
|
-
|
|
114
|
-
Use the HD_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
115
|
-
Use the HD_NPM_REGISTRY environment variable to set the npm registry.
|
|
116
|
-
|
|
117
|
-
ALIASES
|
|
118
|
-
$ hd plugins add
|
|
119
|
-
|
|
120
|
-
EXAMPLES
|
|
121
|
-
Install a plugin from npm registry.
|
|
122
|
-
|
|
123
|
-
$ hd plugins add myplugin
|
|
124
|
-
|
|
125
|
-
Install a plugin from a github url.
|
|
126
|
-
|
|
127
|
-
$ hd plugins add https://github.com/someuser/someplugin
|
|
128
|
-
|
|
129
|
-
Install a plugin from a github slug.
|
|
130
|
-
|
|
131
|
-
$ hd plugins add someuser/someplugin
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## `hd plugins:inspect PLUGIN...`
|
|
135
|
-
|
|
136
|
-
Displays installation properties of a plugin.
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
USAGE
|
|
140
|
-
$ hd plugins inspect PLUGIN...
|
|
141
|
-
|
|
142
|
-
ARGUMENTS
|
|
143
|
-
PLUGIN... [default: .] Plugin to inspect.
|
|
144
|
-
|
|
145
|
-
FLAGS
|
|
146
|
-
-h, --help Show CLI help.
|
|
147
|
-
-v, --verbose
|
|
148
|
-
|
|
149
|
-
GLOBAL FLAGS
|
|
150
|
-
--json Format output as json.
|
|
151
|
-
|
|
152
|
-
DESCRIPTION
|
|
153
|
-
Displays installation properties of a plugin.
|
|
154
|
-
|
|
155
|
-
EXAMPLES
|
|
156
|
-
$ hd plugins inspect myplugin
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/inspect.ts)_
|
|
160
|
-
|
|
161
|
-
## `hd plugins install PLUGIN`
|
|
162
|
-
|
|
163
|
-
Installs a plugin into hd.
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
USAGE
|
|
167
|
-
$ hd plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
168
|
-
|
|
169
|
-
ARGUMENTS
|
|
170
|
-
PLUGIN... Plugin to install.
|
|
171
|
-
|
|
172
|
-
FLAGS
|
|
173
|
-
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
174
|
-
-h, --help Show CLI help.
|
|
175
|
-
-s, --silent Silences npm output.
|
|
176
|
-
-v, --verbose Show verbose npm output.
|
|
177
|
-
|
|
178
|
-
GLOBAL FLAGS
|
|
179
|
-
--json Format output as json.
|
|
180
|
-
|
|
181
|
-
DESCRIPTION
|
|
182
|
-
Installs a plugin into hd.
|
|
183
|
-
|
|
184
|
-
Uses npm to install plugins.
|
|
185
|
-
|
|
186
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
187
|
-
|
|
188
|
-
Use the HD_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
189
|
-
Use the HD_NPM_REGISTRY environment variable to set the npm registry.
|
|
190
|
-
|
|
191
|
-
ALIASES
|
|
192
|
-
$ hd plugins add
|
|
193
|
-
|
|
194
|
-
EXAMPLES
|
|
195
|
-
Install a plugin from npm registry.
|
|
196
|
-
|
|
197
|
-
$ hd plugins install myplugin
|
|
198
|
-
|
|
199
|
-
Install a plugin from a github url.
|
|
200
|
-
|
|
201
|
-
$ hd plugins install https://github.com/someuser/someplugin
|
|
202
|
-
|
|
203
|
-
Install a plugin from a github slug.
|
|
204
|
-
|
|
205
|
-
$ hd plugins install someuser/someplugin
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/install.ts)_
|
|
209
|
-
|
|
210
|
-
## `hd plugins link PATH`
|
|
211
|
-
|
|
212
|
-
Links a plugin into the CLI for development.
|
|
213
|
-
|
|
214
|
-
```
|
|
215
|
-
USAGE
|
|
216
|
-
$ hd plugins link PATH [-h] [--install] [-v]
|
|
217
|
-
|
|
218
|
-
ARGUMENTS
|
|
219
|
-
PATH [default: .] path to plugin
|
|
220
|
-
|
|
221
|
-
FLAGS
|
|
222
|
-
-h, --help Show CLI help.
|
|
223
|
-
-v, --verbose
|
|
224
|
-
--[no-]install Install dependencies after linking the plugin.
|
|
225
|
-
|
|
226
|
-
DESCRIPTION
|
|
227
|
-
Links a plugin into the CLI for development.
|
|
228
|
-
|
|
229
|
-
Installation of a linked plugin will override a user-installed or core plugin.
|
|
230
|
-
|
|
231
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
232
|
-
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
EXAMPLES
|
|
236
|
-
$ hd plugins link myplugin
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/link.ts)_
|
|
240
|
-
|
|
241
|
-
## `hd plugins remove [PLUGIN]`
|
|
242
|
-
|
|
243
|
-
Removes a plugin from the CLI.
|
|
244
|
-
|
|
245
|
-
```
|
|
246
|
-
USAGE
|
|
247
|
-
$ hd plugins remove [PLUGIN...] [-h] [-v]
|
|
248
|
-
|
|
249
|
-
ARGUMENTS
|
|
250
|
-
PLUGIN... plugin to uninstall
|
|
251
|
-
|
|
252
|
-
FLAGS
|
|
253
|
-
-h, --help Show CLI help.
|
|
254
|
-
-v, --verbose
|
|
255
|
-
|
|
256
|
-
DESCRIPTION
|
|
257
|
-
Removes a plugin from the CLI.
|
|
258
|
-
|
|
259
|
-
ALIASES
|
|
260
|
-
$ hd plugins unlink
|
|
261
|
-
$ hd plugins remove
|
|
262
|
-
|
|
263
|
-
EXAMPLES
|
|
264
|
-
$ hd plugins remove myplugin
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
## `hd plugins reset`
|
|
268
|
-
|
|
269
|
-
Remove all user-installed and linked plugins.
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
USAGE
|
|
273
|
-
$ hd plugins reset [--hard] [--reinstall]
|
|
274
|
-
|
|
275
|
-
FLAGS
|
|
276
|
-
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
|
277
|
-
--reinstall Reinstall all plugins after uninstalling.
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/reset.ts)_
|
|
281
|
-
|
|
282
|
-
## `hd plugins uninstall [PLUGIN]`
|
|
283
|
-
|
|
284
|
-
Removes a plugin from the CLI.
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
USAGE
|
|
288
|
-
$ hd plugins uninstall [PLUGIN...] [-h] [-v]
|
|
289
|
-
|
|
290
|
-
ARGUMENTS
|
|
291
|
-
PLUGIN... plugin to uninstall
|
|
292
|
-
|
|
293
|
-
FLAGS
|
|
294
|
-
-h, --help Show CLI help.
|
|
295
|
-
-v, --verbose
|
|
296
|
-
|
|
297
|
-
DESCRIPTION
|
|
298
|
-
Removes a plugin from the CLI.
|
|
299
|
-
|
|
300
|
-
ALIASES
|
|
301
|
-
$ hd plugins unlink
|
|
302
|
-
$ hd plugins remove
|
|
303
|
-
|
|
304
|
-
EXAMPLES
|
|
305
|
-
$ hd plugins uninstall myplugin
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/uninstall.ts)_
|
|
309
|
-
|
|
310
|
-
## `hd plugins unlink [PLUGIN]`
|
|
311
|
-
|
|
312
|
-
Removes a plugin from the CLI.
|
|
313
|
-
|
|
314
|
-
```
|
|
315
|
-
USAGE
|
|
316
|
-
$ hd plugins unlink [PLUGIN...] [-h] [-v]
|
|
317
|
-
|
|
318
|
-
ARGUMENTS
|
|
319
|
-
PLUGIN... plugin to uninstall
|
|
320
|
-
|
|
321
|
-
FLAGS
|
|
322
|
-
-h, --help Show CLI help.
|
|
323
|
-
-v, --verbose
|
|
324
|
-
|
|
325
|
-
DESCRIPTION
|
|
326
|
-
Removes a plugin from the CLI.
|
|
327
|
-
|
|
328
|
-
ALIASES
|
|
329
|
-
$ hd plugins unlink
|
|
330
|
-
$ hd plugins remove
|
|
331
|
-
|
|
332
|
-
EXAMPLES
|
|
333
|
-
$ hd plugins unlink myplugin
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
## `hd plugins update`
|
|
337
|
-
|
|
338
|
-
Update installed plugins.
|
|
339
|
-
|
|
340
|
-
```
|
|
341
|
-
USAGE
|
|
342
|
-
$ hd plugins update [-h] [-v]
|
|
343
|
-
|
|
344
|
-
FLAGS
|
|
345
|
-
-h, --help Show CLI help.
|
|
346
|
-
-v, --verbose
|
|
347
|
-
|
|
348
|
-
DESCRIPTION
|
|
349
|
-
Update installed plugins.
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/update.ts)_
|
|
353
|
-
|
|
354
54
|
## `hd report committers`
|
|
355
55
|
|
|
356
56
|
Generate report of committers to a git repository
|
|
@@ -380,7 +80,7 @@ EXAMPLES
|
|
|
380
80
|
$ hd report committers --csv
|
|
381
81
|
```
|
|
382
82
|
|
|
383
|
-
_See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v1.
|
|
83
|
+
_See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v1.2.0-beta.1/src/commands/report/committers.ts)_
|
|
384
84
|
|
|
385
85
|
## `hd report purls`
|
|
386
86
|
|
|
@@ -414,7 +114,7 @@ EXAMPLES
|
|
|
414
114
|
$ hd report purls --save --csv
|
|
415
115
|
```
|
|
416
116
|
|
|
417
|
-
_See code: [src/commands/report/purls.ts](https://github.com/herodevs/cli/blob/v1.
|
|
117
|
+
_See code: [src/commands/report/purls.ts](https://github.com/herodevs/cli/blob/v1.2.0-beta.1/src/commands/report/purls.ts)_
|
|
418
118
|
|
|
419
119
|
## `hd scan eol`
|
|
420
120
|
|
|
@@ -422,12 +122,14 @@ Scan a given sbom for EOL data
|
|
|
422
122
|
|
|
423
123
|
```
|
|
424
124
|
USAGE
|
|
425
|
-
$ hd scan eol [--json] [-f <value>] [-d <value>] [-s]
|
|
125
|
+
$ hd scan eol [--json] [-f <value>] [-d <value>] [-s] [-a] [-c]
|
|
426
126
|
|
|
427
127
|
FLAGS
|
|
428
|
-
-
|
|
429
|
-
-
|
|
430
|
-
-
|
|
128
|
+
-a, --all Show all components (default is EOL and LTS only)
|
|
129
|
+
-c, --getCustomerSupport Get Never-Ending Support for End-of-Life components
|
|
130
|
+
-d, --dir=<value> The directory to scan in order to create a cyclonedx sbom
|
|
131
|
+
-f, --file=<value> The file path of an existing cyclonedx sbom to scan for EOL
|
|
132
|
+
-s, --save Save the generated SBOM as nes.sbom.json in the scanned directory
|
|
431
133
|
|
|
432
134
|
GLOBAL FLAGS
|
|
433
135
|
--json Format output as json.
|
|
@@ -439,9 +141,11 @@ EXAMPLES
|
|
|
439
141
|
$ hd scan eol --dir=./my-project
|
|
440
142
|
|
|
441
143
|
$ hd scan eol --file=path/to/sbom.json
|
|
144
|
+
|
|
145
|
+
$ hd scan eol -a --dir=./my-project
|
|
442
146
|
```
|
|
443
147
|
|
|
444
|
-
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v1.
|
|
148
|
+
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v1.2.0-beta.1/src/commands/scan/eol.ts)_
|
|
445
149
|
|
|
446
150
|
## `hd scan sbom`
|
|
447
151
|
|
|
@@ -469,5 +173,5 @@ EXAMPLES
|
|
|
469
173
|
$ hd scan sbom --file=path/to/sbom.json
|
|
470
174
|
```
|
|
471
175
|
|
|
472
|
-
_See code: [src/commands/scan/sbom.ts](https://github.com/herodevs/cli/blob/v1.
|
|
176
|
+
_See code: [src/commands/scan/sbom.ts](https://github.com/herodevs/cli/blob/v1.2.0-beta.1/src/commands/scan/sbom.ts)_
|
|
473
177
|
<!-- commandsstop -->
|
package/bin/dev.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { execute } from '@oclif/core';
|
|
4
|
+
|
|
5
|
+
// Localhost
|
|
3
6
|
process.env.GRAPHQL_HOST = 'http://localhost:3000';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
await oclif.execute({ development: true, dir: import.meta.dirname });
|
|
8
|
-
}
|
|
8
|
+
// Dev
|
|
9
|
+
// process.env.GRAPHQL_HOST = 'https://api.dev.nes.herodevs.com';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
await execute({ development: true, dir: import.meta.url });
|
package/bin/run.js
CHANGED
package/dist/api/client.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export interface ApolloHelper {
|
|
|
4
4
|
query<T, V extends apollo.OperationVariables | undefined = undefined>(query: apollo.DocumentNode, variables?: V): Promise<apollo.ApolloQueryResult<T>>;
|
|
5
5
|
}
|
|
6
6
|
export declare const createApollo: (url: string) => apollo.ApolloClient<apollo.NormalizedCacheObject>;
|
|
7
|
-
export declare class ApolloError extends Error {
|
|
8
|
-
}
|
|
9
7
|
export declare class ApolloClient implements ApolloHelper {
|
|
10
8
|
#private;
|
|
11
9
|
constructor(url: string);
|
package/dist/api/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as apollo from '@apollo/client/core/index.js';
|
|
2
|
+
import { ApolloError } from "../service/error.svc.js";
|
|
2
3
|
export const createApollo = (url) => new apollo.ApolloClient({
|
|
3
4
|
cache: new apollo.InMemoryCache({
|
|
4
5
|
addTypename: false,
|
|
@@ -12,31 +13,31 @@ export const createApollo = (url) => new apollo.ApolloClient({
|
|
|
12
13
|
}),
|
|
13
14
|
]),
|
|
14
15
|
});
|
|
15
|
-
export class ApolloError extends Error {
|
|
16
|
-
}
|
|
17
16
|
export class ApolloClient {
|
|
18
17
|
#apollo;
|
|
19
18
|
constructor(url) {
|
|
20
19
|
this.#apollo = createApollo(url);
|
|
21
20
|
}
|
|
22
21
|
async mutate(mutation, variables) {
|
|
23
|
-
|
|
24
|
-
.mutate({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
try {
|
|
23
|
+
return await this.#apollo.mutate({
|
|
24
|
+
mutation,
|
|
25
|
+
variables,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new ApolloError('GraphQL mutation failed', error);
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
async query(query, variables) {
|
|
33
|
-
|
|
34
|
-
.query({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
try {
|
|
34
|
+
return await this.#apollo.query({
|
|
35
|
+
query,
|
|
36
|
+
variables,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new ApolloError('GraphQL query failed', error);
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -14,3 +14,7 @@ export declare class NesApolloClient implements NesClient {
|
|
|
14
14
|
mutate<T, V extends Record<string, unknown>>(mutation: apollo.DocumentNode, variables?: V): Promise<apollo.FetchResult<T>>;
|
|
15
15
|
query<T, V extends Record<string, unknown> | undefined>(query: apollo.DocumentNode, variables?: V): Promise<apollo.ApolloQueryResult<T>>;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Uses the purls from the sbom to run the scan.
|
|
19
|
+
*/
|
|
20
|
+
export declare function submitScan(purls: string[]): Promise<ScanResult>;
|
|
@@ -15,3 +15,14 @@ export class NesApolloClient {
|
|
|
15
15
|
return this.#apollo.query(query, variables);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Uses the purls from the sbom to run the scan.
|
|
20
|
+
*/
|
|
21
|
+
export async function submitScan(purls) {
|
|
22
|
+
// NOTE: GRAPHQL_HOST is set in `./bin/dev.js` or tests
|
|
23
|
+
const host = process.env.GRAPHQL_HOST || 'https://api.nes.herodevs.com';
|
|
24
|
+
const path = process.env.GRAPHQL_PATH || '/graphql';
|
|
25
|
+
const url = host + path;
|
|
26
|
+
const client = new NesApolloClient(url);
|
|
27
|
+
return client.scan.sbom(purls);
|
|
28
|
+
}
|
|
@@ -16,20 +16,34 @@ export interface ScanResponseReport {
|
|
|
16
16
|
diagnostics?: Record<string, unknown>;
|
|
17
17
|
message: string;
|
|
18
18
|
success: boolean;
|
|
19
|
+
warnings?: ScanWarning[];
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
+
export declare const VALID_STATUSES: readonly ["UNKNOWN", "OK", "EOL", "LTS"];
|
|
22
|
+
export type ComponentStatus = (typeof VALID_STATUSES)[number];
|
|
23
|
+
export declare const isValidComponentStatus: (status: string) => status is ComponentStatus;
|
|
24
|
+
export declare const validateComponentStatuses: (statuses: string[]) => ComponentStatus[];
|
|
21
25
|
export interface ScanResultComponent {
|
|
22
26
|
info: {
|
|
23
27
|
eolAt: Date | null;
|
|
24
28
|
isEol: boolean;
|
|
29
|
+
daysEol: number | null;
|
|
25
30
|
isUnsafe: boolean;
|
|
31
|
+
status: ComponentStatus;
|
|
26
32
|
};
|
|
27
33
|
purl: string;
|
|
28
|
-
status?: ComponentStatus;
|
|
29
34
|
}
|
|
35
|
+
export interface ScanWarning {
|
|
36
|
+
purl: string;
|
|
37
|
+
message: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
error?: unknown;
|
|
40
|
+
diagnostics?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export type ScanResultComponentsMap = Map<string, ScanResultComponent>;
|
|
30
43
|
export interface ScanResult {
|
|
31
|
-
components:
|
|
44
|
+
components: ScanResultComponentsMap;
|
|
32
45
|
diagnostics?: Record<string, unknown>;
|
|
33
46
|
message: string;
|
|
34
47
|
success: boolean;
|
|
48
|
+
warnings: ScanWarning[];
|
|
35
49
|
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const VALID_STATUSES = ['UNKNOWN', 'OK', 'EOL', 'LTS'];
|
|
2
|
+
export const isValidComponentStatus = (status) => {
|
|
3
|
+
return VALID_STATUSES.includes(status);
|
|
4
|
+
};
|
|
5
|
+
export const validateComponentStatuses = (statuses) => {
|
|
6
|
+
const validStatuses = statuses.filter(isValidComponentStatus);
|
|
7
|
+
if (validStatuses.length !== statuses.length) {
|
|
8
|
+
throw new Error('Invalid component status provided');
|
|
9
|
+
}
|
|
10
|
+
return validStatuses;
|
|
11
|
+
};
|
|
@@ -3,6 +3,7 @@ import { Command, Flags } from '@oclif/core';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { calculateOverallStats, formatAsCsv, formatAsText, groupCommitsByMonth, parseGitLogOutput, } from "../../service/committers.svc.js";
|
|
6
|
+
import { getErrorMessage, isErrnoException } from "../../service/error.svc.js";
|
|
6
7
|
export default class Committers extends Command {
|
|
7
8
|
static description = 'Generate report of committers to a git repository';
|
|
8
9
|
static enableJsonFlag = true;
|
|
@@ -44,28 +45,42 @@ export default class Committers extends Command {
|
|
|
44
45
|
if (isJson) {
|
|
45
46
|
// JSON mode
|
|
46
47
|
if (save) {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
try {
|
|
49
|
+
fs.writeFileSync(path.resolve('nes.committers.json'), JSON.stringify(reportData, null, 2));
|
|
50
|
+
this.log('Report written to json');
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
this.error(`Failed to save JSON report: ${getErrorMessage(error)}`);
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
return reportData;
|
|
51
57
|
}
|
|
58
|
+
const textOutput = formatAsText(reportData);
|
|
52
59
|
if (csv) {
|
|
53
60
|
// CSV mode
|
|
54
61
|
const csvOutput = formatAsCsv(reportData);
|
|
55
62
|
if (save) {
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
try {
|
|
64
|
+
fs.writeFileSync(path.resolve('nes.committers.csv'), csvOutput);
|
|
65
|
+
this.log('Report written to csv');
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.error(`Failed to save CSV report: ${getErrorMessage(error)}`);
|
|
69
|
+
}
|
|
58
70
|
}
|
|
59
71
|
else {
|
|
60
|
-
this.log(
|
|
72
|
+
this.log(textOutput);
|
|
61
73
|
}
|
|
62
74
|
return csvOutput;
|
|
63
75
|
}
|
|
64
|
-
// Text mode
|
|
65
|
-
const textOutput = formatAsText(reportData);
|
|
66
76
|
if (save) {
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
try {
|
|
78
|
+
fs.writeFileSync(path.resolve('nes.committers.txt'), textOutput);
|
|
79
|
+
this.log('Report written to txt');
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
this.error(`Failed to save txt report: ${getErrorMessage(error)}`);
|
|
83
|
+
}
|
|
69
84
|
}
|
|
70
85
|
else {
|
|
71
86
|
this.log(textOutput);
|
|
@@ -73,8 +88,7 @@ export default class Committers extends Command {
|
|
|
73
88
|
return textOutput;
|
|
74
89
|
}
|
|
75
90
|
catch (error) {
|
|
76
|
-
this.error(`Failed to generate report: ${error
|
|
77
|
-
throw error;
|
|
91
|
+
this.error(`Failed to generate report: ${getErrorMessage(error)}`);
|
|
78
92
|
}
|
|
79
93
|
}
|
|
80
94
|
/**
|
|
@@ -105,25 +119,28 @@ export default class Committers extends Command {
|
|
|
105
119
|
* @param sinceDate - Date range for git log
|
|
106
120
|
*/
|
|
107
121
|
fetchGitCommitData(sinceDate) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (logProcess.error) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
const logProcess = spawnSync('git', [
|
|
123
|
+
'log',
|
|
124
|
+
'--all', // Include committers on all branches in the repo
|
|
125
|
+
'--format="%ad|%an"', // Format: date|author
|
|
126
|
+
'--date=format:%Y-%m', // Format date as YYYY-MM
|
|
127
|
+
`--since="${sinceDate}"`,
|
|
128
|
+
], { encoding: 'utf-8' });
|
|
129
|
+
if (logProcess.error) {
|
|
130
|
+
if (isErrnoException(logProcess.error)) {
|
|
131
|
+
if (logProcess.error.code === 'ENOENT') {
|
|
132
|
+
this.error('Git command not found. Please ensure git is installed and available in your PATH.');
|
|
133
|
+
}
|
|
134
|
+
this.error(`Git command failed: ${getErrorMessage(logProcess.error)}`);
|
|
121
135
|
}
|
|
122
|
-
|
|
136
|
+
this.error(`Git command failed: ${getErrorMessage(logProcess.error)}`);
|
|
123
137
|
}
|
|
124
|
-
|
|
125
|
-
this.error(`
|
|
126
|
-
|
|
138
|
+
if (logProcess.status !== 0) {
|
|
139
|
+
this.error(`Git command failed with status ${logProcess.status}: ${logProcess.stderr}`);
|
|
140
|
+
}
|
|
141
|
+
if (!logProcess.stdout) {
|
|
142
|
+
return [];
|
|
127
143
|
}
|
|
144
|
+
return parseGitLogOutput(logProcess.stdout);
|
|
128
145
|
}
|
|
129
146
|
}
|