@herodevs/cli 1.1.0-beta.1 → 1.3.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 +16 -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 +10 -3
- package/dist/api/nes/nes.client.js +89 -2
- package/dist/api/queries/nes/sbom.js +5 -0
- package/dist/api/types/hd-cli.types.d.ts +29 -0
- package/dist/api/types/hd-cli.types.js +10 -0
- package/dist/api/types/nes.types.d.ts +39 -22
- package/dist/api/types/nes.types.js +1 -1
- package/dist/commands/report/committers.js +45 -28
- package/dist/commands/report/purls.js +42 -29
- package/dist/commands/scan/eol.d.ts +16 -4
- package/dist/commands/scan/eol.js +144 -41
- 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.d.ts +2 -8
- package/dist/service/eol/cdx.svc.js +2 -18
- package/dist/service/eol/eol.svc.d.ts +1 -23
- package/dist/service/eol/eol.svc.js +0 -61
- package/dist/service/error.svc.d.ts +8 -0
- package/dist/service/error.svc.js +28 -0
- package/dist/service/nes/nes.svc.d.ts +4 -3
- package/dist/service/nes/nes.svc.js +5 -4
- package/dist/service/purls.svc.d.ts +6 -0
- package/dist/service/purls.svc.js +26 -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 +5 -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 +10 -9
- 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.3.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.3.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.3.0-beta.1/src/commands/report/purls.ts)_
|
|
418
118
|
|
|
419
119
|
## `hd scan eol`
|
|
420
120
|
|
|
@@ -422,12 +122,15 @@ 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>] [-p <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
|
+
-p, --purls=<value> The file path of a list of purls to scan for EOL
|
|
133
|
+
-s, --save Save the generated SBOM as nes.sbom.json in the scanned directory
|
|
431
134
|
|
|
432
135
|
GLOBAL FLAGS
|
|
433
136
|
--json Format output as json.
|
|
@@ -439,9 +142,13 @@ EXAMPLES
|
|
|
439
142
|
$ hd scan eol --dir=./my-project
|
|
440
143
|
|
|
441
144
|
$ hd scan eol --file=path/to/sbom.json
|
|
145
|
+
|
|
146
|
+
$ hd scan eol --purls=path/to/purls.json
|
|
147
|
+
|
|
148
|
+
$ hd scan eol -a --dir=./my-project
|
|
442
149
|
```
|
|
443
150
|
|
|
444
|
-
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v1.
|
|
151
|
+
_See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v1.3.0-beta.1/src/commands/scan/eol.ts)_
|
|
445
152
|
|
|
446
153
|
## `hd scan sbom`
|
|
447
154
|
|
|
@@ -469,5 +176,5 @@ EXAMPLES
|
|
|
469
176
|
$ hd scan sbom --file=path/to/sbom.json
|
|
470
177
|
```
|
|
471
178
|
|
|
472
|
-
_See code: [src/commands/scan/sbom.ts](https://github.com/herodevs/cli/blob/v1.
|
|
179
|
+
_See code: [src/commands/scan/sbom.ts](https://github.com/herodevs/cli/blob/v1.3.0-beta.1/src/commands/scan/sbom.ts)_
|
|
473
180
|
<!-- 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
|
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type * as apollo from '@apollo/client/core/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { InsightsEolScanInput, InsightsEolScanResult } from '../../api/types/nes.types.ts';
|
|
3
|
+
import type { ProcessBatchOptions, ScanInputOptions, ScanResult } from '../types/hd-cli.types.ts';
|
|
3
4
|
export interface NesClient {
|
|
4
5
|
scan: {
|
|
5
|
-
|
|
6
|
+
purls: (purls: string[], options: ScanInputOptions) => Promise<InsightsEolScanResult>;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
8
9
|
export declare class NesApolloClient implements NesClient {
|
|
9
10
|
#private;
|
|
10
11
|
scan: {
|
|
11
|
-
|
|
12
|
+
purls: (purls: string[], options: ScanInputOptions) => Promise<InsightsEolScanResult>;
|
|
12
13
|
};
|
|
13
14
|
constructor(url: string);
|
|
14
15
|
mutate<T, V extends Record<string, unknown>>(mutation: apollo.DocumentNode, variables?: V): Promise<apollo.FetchResult<T>>;
|
|
15
16
|
query<T, V extends Record<string, unknown> | undefined>(query: apollo.DocumentNode, variables?: V): Promise<apollo.ApolloQueryResult<T>>;
|
|
16
17
|
}
|
|
18
|
+
export declare const batchSubmitPurls: (purls: string[], options: ScanInputOptions, batchSize: number) => Promise<ScanResult>;
|
|
19
|
+
export declare const createBatches: (items: string[], batchSize: number) => string[][];
|
|
20
|
+
export declare const processBatch: ({ batch, index, totalPages, scanOptions, previousScanId, }: ProcessBatchOptions) => Promise<InsightsEolScanResult>;
|
|
21
|
+
export declare const processBatches: (batches: string[][], scanOptions: ScanInputOptions) => Promise<InsightsEolScanResult[]>;
|
|
22
|
+
export declare const handleBatchResults: (results: InsightsEolScanResult[]) => ScanResult;
|
|
23
|
+
export declare const buildInsightsEolScanInput: (purls: string[], options: ScanInputOptions) => InsightsEolScanInput;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ApolloClient } from "../../api/client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { debugLogger } from "../../service/log.svc.js";
|
|
3
|
+
import { SbomScanner, buildScanResult } from "../../service/nes/nes.svc.js";
|
|
3
4
|
export class NesApolloClient {
|
|
4
5
|
scan = {
|
|
5
|
-
|
|
6
|
+
purls: SbomScanner(this),
|
|
6
7
|
};
|
|
7
8
|
#apollo;
|
|
8
9
|
constructor(url) {
|
|
@@ -15,3 +16,89 @@ export class NesApolloClient {
|
|
|
15
16
|
return this.#apollo.query(query, variables);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Submit a scan for a list of purls after they've been batched by batchSubmitPurls
|
|
21
|
+
*/
|
|
22
|
+
function submitScan(purls, options) {
|
|
23
|
+
// NOTE: GRAPHQL_HOST is set in `./bin/dev.js` or tests
|
|
24
|
+
const host = process.env.GRAPHQL_HOST || 'https://api.nes.herodevs.com';
|
|
25
|
+
const path = process.env.GRAPHQL_PATH || '/graphql';
|
|
26
|
+
const url = host + path;
|
|
27
|
+
const client = new NesApolloClient(url);
|
|
28
|
+
return client.scan.purls(purls, options);
|
|
29
|
+
}
|
|
30
|
+
export const batchSubmitPurls = async (purls, options, batchSize) => {
|
|
31
|
+
try {
|
|
32
|
+
const batches = createBatches(purls, batchSize);
|
|
33
|
+
debugLogger('Processing %d batches', batches.length);
|
|
34
|
+
if (batches.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
components: new Map(),
|
|
37
|
+
message: 'No batches to process',
|
|
38
|
+
success: true,
|
|
39
|
+
warnings: [],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const results = await processBatches(batches, options);
|
|
43
|
+
return handleBatchResults(results);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
debugLogger('Fatal error in batchSubmitPurls: %s', error);
|
|
47
|
+
throw new Error(`Failed to process purls: ${error instanceof Error ? error.message : String(error)}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const createBatches = (items, batchSize) => {
|
|
51
|
+
const numberOfBatches = Math.ceil(items.length / batchSize);
|
|
52
|
+
return Array.from({ length: numberOfBatches }, (_, index) => {
|
|
53
|
+
const startIndex = index * batchSize;
|
|
54
|
+
const endIndex = startIndex + batchSize;
|
|
55
|
+
return items.slice(startIndex, endIndex);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export const processBatch = async ({ batch, index, totalPages, scanOptions, previousScanId, }) => {
|
|
59
|
+
const page = index + 1;
|
|
60
|
+
if (page > totalPages) {
|
|
61
|
+
throw new Error('Total pages exceeded');
|
|
62
|
+
}
|
|
63
|
+
debugLogger('Processing batch %d of %d', page, totalPages);
|
|
64
|
+
const result = await submitScan(batch, {
|
|
65
|
+
...scanOptions,
|
|
66
|
+
page,
|
|
67
|
+
totalPages,
|
|
68
|
+
scanId: previousScanId,
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
export const processBatches = async (batches, scanOptions) => {
|
|
73
|
+
const totalPages = batches.length;
|
|
74
|
+
const results = [];
|
|
75
|
+
for (const [index, batch] of batches.entries()) {
|
|
76
|
+
const previousScanId = results[index - 1]?.scanId;
|
|
77
|
+
const result = await processBatch({
|
|
78
|
+
batch,
|
|
79
|
+
index,
|
|
80
|
+
totalPages,
|
|
81
|
+
scanOptions,
|
|
82
|
+
previousScanId,
|
|
83
|
+
});
|
|
84
|
+
results.push(result);
|
|
85
|
+
}
|
|
86
|
+
return results;
|
|
87
|
+
};
|
|
88
|
+
export const handleBatchResults = (results) => {
|
|
89
|
+
if (results.length === 0) {
|
|
90
|
+
throw new Error('No results to process');
|
|
91
|
+
}
|
|
92
|
+
// The API returns placeholders for each batch except the last one.
|
|
93
|
+
const finalResult = results[results.length - 1];
|
|
94
|
+
return buildScanResult(finalResult);
|
|
95
|
+
};
|
|
96
|
+
export const buildInsightsEolScanInput = (purls, options) => {
|
|
97
|
+
const { type, page, totalPages } = options;
|
|
98
|
+
return {
|
|
99
|
+
components: purls,
|
|
100
|
+
type,
|
|
101
|
+
page,
|
|
102
|
+
totalPages,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ComponentStatus, type InsightsEolScanComponent, type ScanWarning } from './nes.types.ts';
|
|
2
|
+
export declare const isValidComponentStatus: (status: string) => status is ComponentStatus;
|
|
3
|
+
export interface ScanInputOptions {
|
|
4
|
+
type: 'SBOM' | 'OTHER';
|
|
5
|
+
page: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
scanId?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_SCAN_BATCH_SIZE = 1000;
|
|
10
|
+
export declare const DEFAULT_SCAN_INPUT_OPTIONS: ScanInputOptions;
|
|
11
|
+
export type ScanResultComponentsMap = Map<string, InsightsEolScanComponent>;
|
|
12
|
+
export type ScanInput = {
|
|
13
|
+
components: string[];
|
|
14
|
+
options: ScanInputOptions;
|
|
15
|
+
};
|
|
16
|
+
export interface ScanResult {
|
|
17
|
+
components: ScanResultComponentsMap;
|
|
18
|
+
diagnostics?: Record<string, unknown>;
|
|
19
|
+
message: string;
|
|
20
|
+
success: boolean;
|
|
21
|
+
warnings: ScanWarning[];
|
|
22
|
+
}
|
|
23
|
+
export interface ProcessBatchOptions {
|
|
24
|
+
batch: string[];
|
|
25
|
+
index: number;
|
|
26
|
+
totalPages: number;
|
|
27
|
+
scanOptions: ScanInputOptions;
|
|
28
|
+
previousScanId?: string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VALID_STATUSES } from "./nes.types.js";
|
|
2
|
+
export const isValidComponentStatus = (status) => {
|
|
3
|
+
return VALID_STATUSES.includes(status);
|
|
4
|
+
};
|
|
5
|
+
export const DEFAULT_SCAN_BATCH_SIZE = 1000;
|
|
6
|
+
export const DEFAULT_SCAN_INPUT_OPTIONS = {
|
|
7
|
+
type: 'SBOM',
|
|
8
|
+
page: 1,
|
|
9
|
+
totalPages: 1,
|
|
10
|
+
};
|