@herodevs/cli 0.3.1 → 1.0.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.
Files changed (273) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +146 -6
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +11 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.js +4 -0
  7. package/dist/api/client.d.ts +14 -0
  8. package/dist/api/client.js +42 -0
  9. package/dist/api/nes/nes.client.d.ts +16 -0
  10. package/dist/api/nes/nes.client.js +17 -0
  11. package/dist/api/queries/nes/sbom.d.ts +3 -0
  12. package/dist/api/queries/nes/sbom.js +29 -0
  13. package/{report-ingestion/src/lib/queries.d.ts → dist/api/queries/nes/telemetry.d.ts} +2 -2
  14. package/{report-ingestion/src/lib/queries.js → dist/api/queries/nes/telemetry.js} +3 -7
  15. package/dist/api/types/nes.types.d.ts +35 -0
  16. package/dist/api/types/nes.types.js +1 -0
  17. package/dist/commands/report/committers.d.ts +22 -0
  18. package/dist/commands/report/committers.js +104 -0
  19. package/dist/commands/report/purls.d.ts +13 -0
  20. package/dist/commands/report/purls.js +66 -0
  21. package/dist/commands/scan/eol.d.ts +16 -0
  22. package/dist/commands/scan/eol.js +71 -0
  23. package/dist/commands/scan/sbom.d.ts +18 -0
  24. package/dist/commands/scan/sbom.js +106 -0
  25. package/dist/config/update.d.ts +3 -0
  26. package/dist/config/update.js +7 -0
  27. package/dist/hooks/init/update.d.ts +2 -0
  28. package/dist/hooks/init/update.js +5 -0
  29. package/dist/hooks/prerun/CommandContextHook.d.ts +3 -0
  30. package/dist/hooks/prerun/CommandContextHook.js +8 -0
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/service/committers.svc.d.ts +70 -0
  34. package/dist/service/committers.svc.js +175 -0
  35. package/dist/service/eol/cdx.svc.d.ts +22 -0
  36. package/dist/service/eol/cdx.svc.js +86 -0
  37. package/dist/service/eol/eol.svc.d.ts +34 -0
  38. package/dist/service/eol/eol.svc.js +86 -0
  39. package/dist/service/line.svc.d.ts +24 -0
  40. package/dist/service/line.svc.js +61 -0
  41. package/dist/service/log.svc.d.ts +10 -0
  42. package/dist/service/log.svc.js +20 -0
  43. package/dist/service/nes/nes.svc.d.ts +4 -0
  44. package/dist/service/nes/nes.svc.js +25 -0
  45. package/dist/service/purls.svc.d.ts +17 -0
  46. package/dist/service/purls.svc.js +29 -0
  47. package/dist/ui/eol.ui.d.ts +3 -0
  48. package/dist/ui/eol.ui.js +17 -0
  49. package/package.json +73 -16
  50. package/core-types/README.md +0 -11
  51. package/core-types/package.json +0 -12
  52. package/core-types/src/index.d.ts +0 -1
  53. package/core-types/src/index.js +0 -5
  54. package/core-types/src/index.js.map +0 -1
  55. package/core-types/src/lib/project-type.d.ts +0 -1
  56. package/core-types/src/lib/project-type.js +0 -3
  57. package/core-types/src/lib/project-type.js.map +0 -1
  58. package/init/README.md +0 -11
  59. package/init/package.json +0 -18
  60. package/init/src/index.d.ts +0 -1
  61. package/init/src/index.js +0 -5
  62. package/init/src/index.js.map +0 -1
  63. package/init/src/lib/configure-project.d.ts +0 -3
  64. package/init/src/lib/configure-project.js +0 -10
  65. package/init/src/lib/configure-project.js.map +0 -1
  66. package/init/src/lib/get-package-choices.d.ts +0 -2
  67. package/init/src/lib/get-package-choices.js +0 -16
  68. package/init/src/lib/get-package-choices.js.map +0 -1
  69. package/init/src/lib/get-product-choices.d.ts +0 -2
  70. package/init/src/lib/get-product-choices.js +0 -29
  71. package/init/src/lib/get-product-choices.js.map +0 -1
  72. package/init/src/lib/get-release-trains.d.ts +0 -2
  73. package/init/src/lib/get-release-trains.js +0 -57
  74. package/init/src/lib/get-release-trains.js.map +0 -1
  75. package/init/src/lib/init.d.ts +0 -5
  76. package/init/src/lib/init.js +0 -72
  77. package/init/src/lib/init.js.map +0 -1
  78. package/init/src/lib/mock-trains.d.ts +0 -2
  79. package/init/src/lib/mock-trains.js +0 -190
  80. package/init/src/lib/mock-trains.js.map +0 -1
  81. package/init/src/lib/models/choice.d.ts +0 -4
  82. package/init/src/lib/models/choice.js +0 -3
  83. package/init/src/lib/models/choice.js.map +0 -1
  84. package/init/src/lib/models/entry.d.ts +0 -6
  85. package/init/src/lib/models/entry.js +0 -3
  86. package/init/src/lib/models/entry.js.map +0 -1
  87. package/init/src/lib/models/index.d.ts +0 -5
  88. package/init/src/lib/models/index.js +0 -9
  89. package/init/src/lib/models/index.js.map +0 -1
  90. package/init/src/lib/models/package-version.d.ts +0 -14
  91. package/init/src/lib/models/package-version.js +0 -3
  92. package/init/src/lib/models/package-version.js.map +0 -1
  93. package/init/src/lib/models/product.d.ts +0 -5
  94. package/init/src/lib/models/product.js +0 -3
  95. package/init/src/lib/models/product.js.map +0 -1
  96. package/init/src/lib/models/release-train.d.ts +0 -9
  97. package/init/src/lib/models/release-train.js +0 -3
  98. package/init/src/lib/models/release-train.js.map +0 -1
  99. package/init/src/lib/npm/configure-npm-project.d.ts +0 -2
  100. package/init/src/lib/npm/configure-npm-project.js +0 -59
  101. package/init/src/lib/npm/configure-npm-project.js.map +0 -1
  102. package/init/src/lib/verify-project-type.d.ts +0 -6
  103. package/init/src/lib/verify-project-type.js +0 -19
  104. package/init/src/lib/verify-project-type.js.map +0 -1
  105. package/report-committers/README.md +0 -11
  106. package/report-committers/package.json +0 -15
  107. package/report-committers/src/index.d.ts +0 -1
  108. package/report-committers/src/index.js +0 -5
  109. package/report-committers/src/index.js.map +0 -1
  110. package/report-committers/src/lib/committers.d.ts +0 -11
  111. package/report-committers/src/lib/committers.js +0 -106
  112. package/report-committers/src/lib/committers.js.map +0 -1
  113. package/report-committers/src/lib/constants.d.ts +0 -4
  114. package/report-committers/src/lib/constants.js +0 -8
  115. package/report-committers/src/lib/constants.js.map +0 -1
  116. package/report-committers/src/lib/get-committer-counts.d.ts +0 -3
  117. package/report-committers/src/lib/get-committer-counts.js +0 -33
  118. package/report-committers/src/lib/get-committer-counts.js.map +0 -1
  119. package/report-committers/src/lib/parse-date-flags.d.ts +0 -4
  120. package/report-committers/src/lib/parse-date-flags.js +0 -11
  121. package/report-committers/src/lib/parse-date-flags.js.map +0 -1
  122. package/report-committers/src/lib/parse-git-log-entries.d.ts +0 -2
  123. package/report-committers/src/lib/parse-git-log-entries.js +0 -11
  124. package/report-committers/src/lib/parse-git-log-entries.js.map +0 -1
  125. package/report-committers/src/lib/parse-monthly.d.ts +0 -4
  126. package/report-committers/src/lib/parse-monthly.js +0 -56
  127. package/report-committers/src/lib/parse-monthly.js.map +0 -1
  128. package/report-committers/src/lib/types.d.ts +0 -27
  129. package/report-committers/src/lib/types.js +0 -3
  130. package/report-committers/src/lib/types.js.map +0 -1
  131. package/report-diagnostics/README.md +0 -11
  132. package/report-diagnostics/package.json +0 -15
  133. package/report-diagnostics/src/index.d.ts +0 -1
  134. package/report-diagnostics/src/index.js +0 -5
  135. package/report-diagnostics/src/index.js.map +0 -1
  136. package/report-diagnostics/src/lib/diagnostics.d.ts +0 -7
  137. package/report-diagnostics/src/lib/diagnostics.js +0 -94
  138. package/report-diagnostics/src/lib/diagnostics.js.map +0 -1
  139. package/report-diagnostics/src/lib/get-diagnostic-types.d.ts +0 -4
  140. package/report-diagnostics/src/lib/get-diagnostic-types.js +0 -15
  141. package/report-diagnostics/src/lib/get-diagnostic-types.js.map +0 -1
  142. package/report-diagnostics/src/lib/get-file-contents.d.ts +0 -1
  143. package/report-diagnostics/src/lib/get-file-contents.js +0 -12
  144. package/report-diagnostics/src/lib/get-file-contents.js.map +0 -1
  145. package/report-diagnostics/src/lib/get-package-json-section.d.ts +0 -1
  146. package/report-diagnostics/src/lib/get-package-json-section.js +0 -15
  147. package/report-diagnostics/src/lib/get-package-json-section.js.map +0 -1
  148. package/report-ingestion/README.md +0 -11
  149. package/report-ingestion/package.json +0 -13
  150. package/report-ingestion/src/index.d.ts +0 -1
  151. package/report-ingestion/src/index.js +0 -5
  152. package/report-ingestion/src/index.js.map +0 -1
  153. package/report-ingestion/src/lib/ingestion.d.ts +0 -3
  154. package/report-ingestion/src/lib/ingestion.js +0 -40
  155. package/report-ingestion/src/lib/ingestion.js.map +0 -1
  156. package/report-ingestion/src/lib/prompts.d.ts +0 -5
  157. package/report-ingestion/src/lib/prompts.js +0 -46
  158. package/report-ingestion/src/lib/prompts.js.map +0 -1
  159. package/report-ingestion/src/lib/queries.js.map +0 -1
  160. package/report-ingestion/src/lib/send-manifest.d.ts +0 -10
  161. package/report-ingestion/src/lib/send-manifest.js +0 -129
  162. package/report-ingestion/src/lib/send-manifest.js.map +0 -1
  163. package/report-ingestion/src/lib/types.d.ts +0 -6
  164. package/report-ingestion/src/lib/types.js +0 -3
  165. package/report-ingestion/src/lib/types.js.map +0 -1
  166. package/sea-config.json +0 -5
  167. package/src/lib/cli.d.ts +0 -1
  168. package/src/lib/cli.js +0 -22
  169. package/src/lib/cli.js.map +0 -1
  170. package/src/lib/create-group-command.d.ts +0 -2
  171. package/src/lib/create-group-command.js +0 -28
  172. package/src/lib/create-group-command.js.map +0 -1
  173. package/src/lib/ensure-version.d.ts +0 -2
  174. package/src/lib/ensure-version.js +0 -71
  175. package/src/lib/ensure-version.js.map +0 -1
  176. package/src/lib/get-commands.d.ts +0 -2
  177. package/src/lib/get-commands.js +0 -27
  178. package/src/lib/get-commands.js.map +0 -1
  179. package/src/lib/log-colors.d.ts +0 -28
  180. package/src/lib/log-colors.js +0 -9
  181. package/src/lib/log-colors.js.map +0 -1
  182. package/src/main.d.ts +0 -2
  183. package/src/main.js +0 -6
  184. package/src/main.js.map +0 -1
  185. package/tracker-init/README.md +0 -11
  186. package/tracker-init/package.json +0 -15
  187. package/tracker-init/src/index.d.ts +0 -1
  188. package/tracker-init/src/index.js +0 -5
  189. package/tracker-init/src/index.js.map +0 -1
  190. package/tracker-init/src/lib/default-config.d.ts +0 -2
  191. package/tracker-init/src/lib/default-config.js +0 -20
  192. package/tracker-init/src/lib/default-config.js.map +0 -1
  193. package/tracker-init/src/lib/init.d.ts +0 -5
  194. package/tracker-init/src/lib/init.js +0 -25
  195. package/tracker-init/src/lib/init.js.map +0 -1
  196. package/tracker-run/README.md +0 -11
  197. package/tracker-run/package.json +0 -18
  198. package/tracker-run/src/index.d.ts +0 -1
  199. package/tracker-run/src/index.js +0 -5
  200. package/tracker-run/src/index.js.map +0 -1
  201. package/tracker-run/src/lib/get-data-filepath.d.ts +0 -1
  202. package/tracker-run/src/lib/get-data-filepath.js +0 -8
  203. package/tracker-run/src/lib/get-data-filepath.js.map +0 -1
  204. package/tracker-run/src/lib/get-data.d.ts +0 -1
  205. package/tracker-run/src/lib/get-data.js +0 -14
  206. package/tracker-run/src/lib/get-data.js.map +0 -1
  207. package/tracker-run/src/lib/get-git-commit.d.ts +0 -4
  208. package/tracker-run/src/lib/get-git-commit.js +0 -32
  209. package/tracker-run/src/lib/get-git-commit.js.map +0 -1
  210. package/tracker-run/src/lib/process-category.d.ts +0 -2
  211. package/tracker-run/src/lib/process-category.js +0 -151
  212. package/tracker-run/src/lib/process-category.js.map +0 -1
  213. package/tracker-run/src/lib/process-config.d.ts +0 -2
  214. package/tracker-run/src/lib/process-config.js +0 -19
  215. package/tracker-run/src/lib/process-config.js.map +0 -1
  216. package/tracker-run/src/lib/run.d.ts +0 -7
  217. package/tracker-run/src/lib/run.js +0 -29
  218. package/tracker-run/src/lib/run.js.map +0 -1
  219. package/tracker-run/src/lib/save-results.d.ts +0 -2
  220. package/tracker-run/src/lib/save-results.js +0 -19
  221. package/tracker-run/src/lib/save-results.js.map +0 -1
  222. package/tracker-shared/README.md +0 -11
  223. package/tracker-shared/package.json +0 -12
  224. package/tracker-shared/src/index.d.ts +0 -2
  225. package/tracker-shared/src/index.js +0 -14
  226. package/tracker-shared/src/index.js.map +0 -1
  227. package/tracker-shared/src/lib/models/aggregate-result.d.ts +0 -4
  228. package/tracker-shared/src/lib/models/aggregate-result.js +0 -3
  229. package/tracker-shared/src/lib/models/aggregate-result.js.map +0 -1
  230. package/tracker-shared/src/lib/models/category-result.d.ts +0 -7
  231. package/tracker-shared/src/lib/models/category-result.js +0 -3
  232. package/tracker-shared/src/lib/models/category-result.js.map +0 -1
  233. package/tracker-shared/src/lib/models/category.d.ts +0 -9
  234. package/tracker-shared/src/lib/models/category.js +0 -3
  235. package/tracker-shared/src/lib/models/category.js.map +0 -1
  236. package/tracker-shared/src/lib/models/config.d.ts +0 -8
  237. package/tracker-shared/src/lib/models/config.js +0 -3
  238. package/tracker-shared/src/lib/models/config.js.map +0 -1
  239. package/tracker-shared/src/lib/models/file-result.d.ts +0 -5
  240. package/tracker-shared/src/lib/models/file-result.js +0 -3
  241. package/tracker-shared/src/lib/models/file-result.js.map +0 -1
  242. package/tracker-shared/src/lib/models/index.d.ts +0 -8
  243. package/tracker-shared/src/lib/models/index.js +0 -12
  244. package/tracker-shared/src/lib/models/index.js.map +0 -1
  245. package/tracker-shared/src/lib/models/process-result.d.ts +0 -6
  246. package/tracker-shared/src/lib/models/process-result.js +0 -3
  247. package/tracker-shared/src/lib/models/process-result.js.map +0 -1
  248. package/tracker-shared/src/lib/models/result.d.ts +0 -11
  249. package/tracker-shared/src/lib/models/result.js +0 -3
  250. package/tracker-shared/src/lib/models/result.js.map +0 -1
  251. package/tracker-shared/src/lib/models/total-result.d.ts +0 -4
  252. package/tracker-shared/src/lib/models/total-result.js +0 -3
  253. package/tracker-shared/src/lib/models/total-result.js.map +0 -1
  254. package/tracker-shared/src/lib/read-config.d.ts +0 -2
  255. package/tracker-shared/src/lib/read-config.js +0 -13
  256. package/tracker-shared/src/lib/read-config.js.map +0 -1
  257. package/utility/README.md +0 -11
  258. package/utility/package.json +0 -13
  259. package/utility/src/index.d.ts +0 -4
  260. package/utility/src/index.js +0 -8
  261. package/utility/src/index.js.map +0 -1
  262. package/utility/src/lib/get-project-types.d.ts +0 -2
  263. package/utility/src/lib/get-project-types.js +0 -13
  264. package/utility/src/lib/get-project-types.js.map +0 -1
  265. package/utility/src/lib/get-root-dir.d.ts +0 -1
  266. package/utility/src/lib/get-root-dir.js +0 -12
  267. package/utility/src/lib/get-root-dir.js.map +0 -1
  268. package/utility/src/lib/run-command.d.ts +0 -1
  269. package/utility/src/lib/run-command.js +0 -31
  270. package/utility/src/lib/run-command.js.map +0 -1
  271. package/utility/src/lib/sort-by-name.d.ts +0 -3
  272. package/utility/src/lib/sort-by-name.js +0 -7
  273. package/utility/src/lib/sort-by-name.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ # Copyright (c) 2025 HeroDevs, Inc
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,151 @@
1
- # cli
1
+ # @herodevs/cli
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ The HeroDevs CLI
4
4
 
5
- ## Building
5
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
6
+ [![Version](https://img.shields.io/npm/v/@herodevs/cli.svg)](https://npmjs.org/package/@herodevs/cli)
7
+ [![Downloads/week](https://img.shields.io/npm/dw/@herodevs/cli.svg)](https://npmjs.org/package/@herodevs/cli)
6
8
 
7
- Run `nx build cli` to build the library.
9
+ <!-- toc -->
10
+ * [@herodevs/cli](#herodevscli)
11
+ <!-- tocstop -->
12
+ ## Usage
13
+ <!-- usage -->
14
+ ```sh-session
15
+ $ npm install -g @herodevs/cli
16
+ $ hd COMMAND
17
+ running command...
18
+ $ hd (--version)
19
+ @herodevs/cli/1.0.0-beta.1 linux-x64 node-v22.14.0
20
+ $ hd --help [COMMAND]
21
+ USAGE
22
+ $ hd COMMAND
23
+ ...
24
+ ```
25
+ <!-- usagestop -->
26
+ ## Commands
27
+ <!-- commands -->
28
+ * [`hd report committers`](#hd-report-committers)
29
+ * [`hd report purls`](#hd-report-purls)
30
+ * [`hd scan eol`](#hd-scan-eol)
31
+ * [`hd scan sbom`](#hd-scan-sbom)
8
32
 
9
- ## Running unit tests
33
+ ## `hd report committers`
10
34
 
11
- Run `nx test cli` to execute the unit tests via [Jest](https://jestjs.io).
35
+ Generate report of committers to a git repository
36
+
37
+ ```
38
+ USAGE
39
+ $ hd report committers [--json] [-m <value>] [-o text|json|csv] [-s]
40
+
41
+ FLAGS
42
+ -m, --months=<value> [default: 12] The number of months of git history to review
43
+ -o, --output=<option> [default: text] Output format: text, json, or csv
44
+ <options: text|json|csv>
45
+ -s, --save Save the committers report as nes.committers.<output>
46
+
47
+ GLOBAL FLAGS
48
+ --json Format output as json.
49
+
50
+ DESCRIPTION
51
+ Generate report of committers to a git repository
52
+
53
+ EXAMPLES
54
+ $ hd report committers
55
+
56
+ $ hd report committers -o csv -s
57
+
58
+ $ hd report committers --output=json
59
+
60
+ $ hd report committers --output=csv
61
+ ```
62
+
63
+ _See code: [src/commands/report/committers.ts](https://github.com/herodevs/cli/blob/v1.0.0-beta.1/src/commands/report/committers.ts)_
64
+
65
+ ## `hd report purls`
66
+
67
+ Generate a list of purls from a sbom
68
+
69
+ ```
70
+ USAGE
71
+ $ hd report purls [--json] [-f <value>] [-d <value>] [-s] [-o json|csv]
72
+
73
+ FLAGS
74
+ -d, --dir=<value> The directory to scan in order to create a cyclonedx sbom
75
+ -f, --file=<value> The file path of an existing cyclonedx sbom to scan for EOL
76
+ -o, --output=<option> [default: json] The format of the saved file (when using --save)
77
+ <options: json|csv>
78
+ -s, --save Save the list of purls as nes.purls.<output>
79
+
80
+ GLOBAL FLAGS
81
+ --json Format output as json.
82
+
83
+ DESCRIPTION
84
+ Generate a list of purls from a sbom
85
+
86
+ EXAMPLES
87
+ $ hd report purls --dir=./my-project
88
+
89
+ $ hd report purls --file=path/to/sbom.json
90
+
91
+ $ hd report purls --dir=./my-project --save
92
+
93
+ $ hd report purls --save --output=csv
94
+ ```
95
+
96
+ _See code: [src/commands/report/purls.ts](https://github.com/herodevs/cli/blob/v1.0.0-beta.1/src/commands/report/purls.ts)_
97
+
98
+ ## `hd scan eol`
99
+
100
+ Scan a given sbom for EOL data
101
+
102
+ ```
103
+ USAGE
104
+ $ hd scan eol [--json] [-f <value>] [-d <value>] [-s]
105
+
106
+ FLAGS
107
+ -d, --dir=<value> The directory to scan in order to create a cyclonedx sbom
108
+ -f, --file=<value> The file path of an existing cyclonedx sbom to scan for EOL
109
+ -s, --save Save the generated SBOM as nes.sbom.json in the scanned directory
110
+
111
+ GLOBAL FLAGS
112
+ --json Format output as json.
113
+
114
+ DESCRIPTION
115
+ Scan a given sbom for EOL data
116
+
117
+ EXAMPLES
118
+ $ hd scan eol --dir=./my-project
119
+
120
+ $ hd scan eol --file=path/to/sbom.json
121
+ ```
122
+
123
+ _See code: [src/commands/scan/eol.ts](https://github.com/herodevs/cli/blob/v1.0.0-beta.1/src/commands/scan/eol.ts)_
124
+
125
+ ## `hd scan sbom`
126
+
127
+ Scan a SBOM for purls
128
+
129
+ ```
130
+ USAGE
131
+ $ hd scan sbom [--json] [-f <value>] [-d <value>] [-s]
132
+
133
+ FLAGS
134
+ -d, --dir=<value> The directory to scan in order to create a cyclonedx sbom
135
+ -f, --file=<value> The file path of an existing cyclonedx sbom to scan for EOL
136
+ -s, --save Save the generated SBOM as nes.sbom.json in the scanned directory
137
+
138
+ GLOBAL FLAGS
139
+ --json Format output as json.
140
+
141
+ DESCRIPTION
142
+ Scan a SBOM for purls
143
+
144
+ EXAMPLES
145
+ $ hd scan sbom --dir=./my-project
146
+
147
+ $ hd scan sbom --file=path/to/sbom.json
148
+ ```
149
+
150
+ _See code: [src/commands/scan/sbom.ts](https://github.com/herodevs/cli/blob/v1.0.0-beta.1/src/commands/scan/sbom.ts)_
151
+ <!-- commandsstop -->
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.env.GRAPHQL_HOST = 'http://localhost:3000';
4
+
5
+ async function run() {
6
+ const oclif = await import('@oclif/core');
7
+ await oclif.execute({ development: true, dir: import.meta.dirname });
8
+ console.log('\n\n\n=> OCLIF: Command complete.');
9
+ }
10
+
11
+ run();
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = await import('@oclif/core');
4
+ await oclif.execute({ dir: import.meta.dirname });
@@ -0,0 +1,14 @@
1
+ import * as apollo from '@apollo/client/core/index.js';
2
+ export interface ApolloHelper {
3
+ mutate<T, V extends apollo.OperationVariables>(mutation: apollo.DocumentNode, variables?: V): Promise<apollo.FetchResult<T>>;
4
+ query<T, V extends apollo.OperationVariables | undefined = undefined>(query: apollo.DocumentNode, variables?: V): Promise<apollo.ApolloQueryResult<T>>;
5
+ }
6
+ export declare const createApollo: (url: string) => apollo.ApolloClient<apollo.NormalizedCacheObject>;
7
+ export declare class ApolloError extends Error {
8
+ }
9
+ export declare class ApolloClient implements ApolloHelper {
10
+ #private;
11
+ constructor(url: string);
12
+ mutate<T, V extends apollo.OperationVariables>(mutation: apollo.DocumentNode, variables?: V): Promise<apollo.FetchResult<T>>;
13
+ query<T, V extends apollo.OperationVariables | undefined>(query: apollo.DocumentNode, variables?: V): Promise<apollo.ApolloQueryResult<T>>;
14
+ }
@@ -0,0 +1,42 @@
1
+ import * as apollo from '@apollo/client/core/index.js';
2
+ export const createApollo = (url) => new apollo.ApolloClient({
3
+ cache: new apollo.InMemoryCache({
4
+ addTypename: false,
5
+ }),
6
+ headers: {
7
+ 'User-Agent': `hdcli/${process.env.npm_package_version ?? 'unknown'}`,
8
+ },
9
+ link: apollo.ApolloLink.from([
10
+ new apollo.HttpLink({
11
+ uri: url,
12
+ }),
13
+ ]),
14
+ });
15
+ export class ApolloError extends Error {
16
+ }
17
+ export class ApolloClient {
18
+ #apollo;
19
+ constructor(url) {
20
+ this.#apollo = createApollo(url);
21
+ }
22
+ async mutate(mutation, variables) {
23
+ return this.#apollo
24
+ .mutate({
25
+ mutation,
26
+ variables,
27
+ })
28
+ .catch((error) => {
29
+ throw new ApolloError('Failed GQL Mutation', error);
30
+ });
31
+ }
32
+ async query(query, variables) {
33
+ return this.#apollo
34
+ .query({
35
+ query,
36
+ variables,
37
+ })
38
+ .catch((error) => {
39
+ throw new ApolloError('Failed GQL Query', error);
40
+ });
41
+ }
42
+ }
@@ -0,0 +1,16 @@
1
+ import type * as apollo from '@apollo/client/core/index.js';
2
+ import type { ScanResult } from '../../api/types/nes.types.ts';
3
+ export interface NesClient {
4
+ scan: {
5
+ sbom: (purls: string[]) => Promise<ScanResult>;
6
+ };
7
+ }
8
+ export declare class NesApolloClient implements NesClient {
9
+ #private;
10
+ scan: {
11
+ sbom: (purls: string[]) => Promise<ScanResult>;
12
+ };
13
+ constructor(url: string);
14
+ mutate<T, V extends Record<string, unknown>>(mutation: apollo.DocumentNode, variables?: V): Promise<apollo.FetchResult<T>>;
15
+ query<T, V extends Record<string, unknown> | undefined>(query: apollo.DocumentNode, variables?: V): Promise<apollo.ApolloQueryResult<T>>;
16
+ }
@@ -0,0 +1,17 @@
1
+ import { ApolloClient } from "../../api/client.js";
2
+ import { SbomScanner } from "../../service/nes/nes.svc.js";
3
+ export class NesApolloClient {
4
+ scan = {
5
+ sbom: SbomScanner(this),
6
+ };
7
+ #apollo;
8
+ constructor(url) {
9
+ this.#apollo = new ApolloClient(url);
10
+ }
11
+ mutate(mutation, variables) {
12
+ return this.#apollo.mutate(mutation, variables);
13
+ }
14
+ query(query, variables) {
15
+ return this.#apollo.query(query, variables);
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ export declare const M_SCAN: {
2
+ gql: import("graphql/language/ast.js").DocumentNode;
3
+ };
@@ -0,0 +1,29 @@
1
+ import { gql } from '@apollo/client/core/core.cjs';
2
+ export const M_SCAN = {
3
+ gql: gql `
4
+ mutation EolScan($input: InsightsEolScanInput!) {
5
+ insights {
6
+ scan {
7
+ eol(input: $input) {
8
+ components {
9
+ purl
10
+ info {
11
+ isEol
12
+ isUnsafe
13
+ eolAt
14
+ }
15
+ }
16
+ diagnostics
17
+ message
18
+ scanId
19
+ success
20
+ warnings {
21
+ purl
22
+ type
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ `,
29
+ };
@@ -1,2 +1,2 @@
1
- export declare const TELEMETRY_INITIALIZE_MUTATION: import("graphql/language/ast").DocumentNode;
2
- export declare const TELEMETRY_REPORT_MUTATION: import("graphql/language/ast").DocumentNode;
1
+ export declare const TELEMETRY_INITIALIZE_MUTATION: import("graphql/language/ast.js").DocumentNode;
2
+ export declare const TELEMETRY_REPORT_MUTATION: import("graphql/language/ast.js").DocumentNode;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TELEMETRY_REPORT_MUTATION = exports.TELEMETRY_INITIALIZE_MUTATION = void 0;
4
- const core_1 = require("@apollo/client/core");
5
- exports.TELEMETRY_INITIALIZE_MUTATION = (0, core_1.gql) `
1
+ import { gql } from '@apollo/client/core/core.cjs';
2
+ export const TELEMETRY_INITIALIZE_MUTATION = gql `
6
3
  mutation Telemetry($clientName: String!) {
7
4
  telemetry {
8
5
  initialize(input: { context: { client: { id: $clientName } } }) {
@@ -13,7 +10,7 @@ exports.TELEMETRY_INITIALIZE_MUTATION = (0, core_1.gql) `
13
10
  }
14
11
  }
15
12
  `;
16
- exports.TELEMETRY_REPORT_MUTATION = (0, core_1.gql) `
13
+ export const TELEMETRY_REPORT_MUTATION = gql `
17
14
  mutation Report($key: String!, $report: JSON!, $metadata: JSON) {
18
15
  telemetry {
19
16
  report(input: { key: $key, report: $report, metadata: $metadata }) {
@@ -25,4 +22,3 @@ exports.TELEMETRY_REPORT_MUTATION = (0, core_1.gql) `
25
22
  }
26
23
  }
27
24
  `;
28
- //# sourceMappingURL=queries.js.map
@@ -0,0 +1,35 @@
1
+ export type ScanInput = {
2
+ components: string[];
3
+ type: 'SBOM';
4
+ } | {
5
+ type: 'OTHER';
6
+ };
7
+ export interface ScanResponse {
8
+ insights: {
9
+ scan: {
10
+ eol: ScanResponseReport;
11
+ };
12
+ };
13
+ }
14
+ export interface ScanResponseReport {
15
+ components: ScanResultComponent[];
16
+ diagnostics?: Record<string, unknown>;
17
+ message: string;
18
+ success: boolean;
19
+ }
20
+ export type ComponentStatus = 'EOL' | 'LTS' | 'OK';
21
+ export interface ScanResultComponent {
22
+ info: {
23
+ eolAt: Date | null;
24
+ isEol: boolean;
25
+ isUnsafe: boolean;
26
+ };
27
+ purl: string;
28
+ status?: ComponentStatus;
29
+ }
30
+ export interface ScanResult {
31
+ components: Map<string, ScanResultComponent>;
32
+ diagnostics?: Record<string, unknown>;
33
+ message: string;
34
+ success: boolean;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Committers extends Command {
3
+ static description: string;
4
+ static enableJsonFlag: boolean;
5
+ static examples: string[];
6
+ static flags: {
7
+ months: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
8
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ save: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ /**
13
+ * Generates structured report data
14
+ * @param entries - parsed git log output for commits
15
+ */
16
+ private generateReportData;
17
+ /**
18
+ * Fetches git commit data with month and author information
19
+ * @param sinceDate - Date range for git log
20
+ */
21
+ private fetchGitCommitData;
22
+ }
@@ -0,0 +1,104 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { Command, Flags } from '@oclif/core';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { calculateOverallStats, formatOutputBasedOnFlag, groupCommitsByMonth, parseGitLogOutput, } from "../../service/committers.svc.js";
6
+ export default class Committers extends Command {
7
+ static description = 'Generate report of committers to a git repository';
8
+ static enableJsonFlag = true;
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %>',
11
+ '<%= config.bin %> <%= command.id %> -o csv -s',
12
+ '<%= config.bin %> <%= command.id %> --output=json',
13
+ '<%= config.bin %> <%= command.id %> --output=csv',
14
+ ];
15
+ static flags = {
16
+ months: Flags.integer({
17
+ char: 'm',
18
+ description: 'The number of months of git history to review',
19
+ default: 12,
20
+ }),
21
+ output: Flags.string({
22
+ char: 'o',
23
+ description: 'Output format: text, json, or csv',
24
+ options: ['text', 'json', 'csv'],
25
+ default: 'text',
26
+ }),
27
+ save: Flags.boolean({
28
+ char: 's',
29
+ description: 'Save the committers report as nes.committers.<output>',
30
+ default: false,
31
+ }),
32
+ };
33
+ async run() {
34
+ const { flags } = await this.parse(Committers);
35
+ const { months, output, save } = flags;
36
+ const sinceDate = `${months} months ago`;
37
+ try {
38
+ // Generate structured report data
39
+ const entries = this.fetchGitCommitData(sinceDate);
40
+ const reportData = this.generateReportData(entries);
41
+ const formattedOutput = formatOutputBasedOnFlag(output, reportData);
42
+ // Output to file or stdout
43
+ if (save) {
44
+ fs.writeFileSync(path.resolve(`nes.committers.${output}`), formattedOutput);
45
+ this.log(`Report written to ${output}`);
46
+ }
47
+ else {
48
+ this.log(formattedOutput);
49
+ }
50
+ }
51
+ catch (error) {
52
+ this.error(`Failed to generate report: ${error.message}`);
53
+ }
54
+ }
55
+ /**
56
+ * Generates structured report data
57
+ * @param entries - parsed git log output for commits
58
+ */
59
+ generateReportData(entries) {
60
+ if (entries.length === 0) {
61
+ return { monthly: {}, overall: { total: 0 } };
62
+ }
63
+ const monthlyData = groupCommitsByMonth(entries);
64
+ const overallStats = calculateOverallStats(entries);
65
+ const grandTotal = entries.length;
66
+ // Format into a structured report data object
67
+ const report = {
68
+ monthly: {},
69
+ overall: { ...overallStats, total: grandTotal },
70
+ };
71
+ // Add monthly totals
72
+ for (const [month, authors] of Object.entries(monthlyData)) {
73
+ const monthTotal = Object.values(authors).reduce((sum, count) => sum + count, 0);
74
+ report.monthly[month] = { ...authors, total: monthTotal };
75
+ }
76
+ return report;
77
+ }
78
+ /**
79
+ * Fetches git commit data with month and author information
80
+ * @param sinceDate - Date range for git log
81
+ */
82
+ fetchGitCommitData(sinceDate) {
83
+ try {
84
+ const logProcess = spawnSync('git', [
85
+ 'log',
86
+ '--all', // Include committers on all branches in the repo
87
+ '--format="%ad|%an"', // Format: date|author
88
+ '--date=format:%Y-%m', // Format date as YYYY-MM
89
+ `--since="${sinceDate}"`,
90
+ ], { encoding: 'utf-8' });
91
+ if (logProcess.error) {
92
+ throw new Error(`Git command failed: ${logProcess.error.message}`);
93
+ }
94
+ if (!logProcess.stdout) {
95
+ return [];
96
+ }
97
+ return parseGitLogOutput(logProcess.stdout);
98
+ }
99
+ catch (error) {
100
+ this.error(`Failed to fetch git data: ${error.message}`);
101
+ return []; // This line won't execute due to this.error() above
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,13 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ReportPurls extends Command {
3
+ static description: string;
4
+ static enableJsonFlag: boolean;
5
+ static examples: string[];
6
+ static flags: {
7
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ dir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ save: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<string[]>;
13
+ }
@@ -0,0 +1,66 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { Command, Flags, ux } from '@oclif/core';
4
+ import { extractPurls, getPurlOutput } from "../../service/purls.svc.js";
5
+ import SbomScan from "../scan/sbom.js";
6
+ export default class ReportPurls extends Command {
7
+ static description = 'Generate a list of purls from a sbom';
8
+ static enableJsonFlag = true;
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %> --dir=./my-project',
11
+ '<%= config.bin %> <%= command.id %> --file=path/to/sbom.json',
12
+ '<%= config.bin %> <%= command.id %> --dir=./my-project --save',
13
+ '<%= config.bin %> <%= command.id %> --save --output=csv',
14
+ ];
15
+ static flags = {
16
+ file: Flags.string({
17
+ char: 'f',
18
+ description: 'The file path of an existing cyclonedx sbom to scan for EOL',
19
+ }),
20
+ dir: Flags.string({
21
+ char: 'd',
22
+ description: 'The directory to scan in order to create a cyclonedx sbom',
23
+ }),
24
+ save: Flags.boolean({
25
+ char: 's',
26
+ default: false,
27
+ description: 'Save the list of purls as nes.purls.<output>',
28
+ }),
29
+ output: Flags.string({
30
+ char: 'o',
31
+ options: ['json', 'csv'],
32
+ default: 'json',
33
+ description: 'The format of the saved file (when using --save)',
34
+ }),
35
+ };
36
+ async run() {
37
+ const { flags } = await this.parse(ReportPurls);
38
+ const { dir: _dirFlag, file: _fileFlag, save, output } = flags;
39
+ // Load the SBOM: Only pass the file, dir, and save flags to SbomScan
40
+ const sbomArgs = SbomScan.getSbomArgs(flags);
41
+ const sbomCommand = new SbomScan(sbomArgs, this.config);
42
+ const sbom = await sbomCommand.run();
43
+ // Extract purls from SBOM
44
+ const purls = await extractPurls(sbom);
45
+ ux.action.stop('Scan completed');
46
+ // Print the purls
47
+ this.log('Found purls:');
48
+ for (const purl of purls) {
49
+ this.log(purl);
50
+ }
51
+ // Save if requested
52
+ if (save) {
53
+ try {
54
+ const outputPath = path.join(_dirFlag || process.cwd(), `nes.purls.${output}`);
55
+ const purlOutput = getPurlOutput(purls, output);
56
+ fs.writeFileSync(outputPath, purlOutput);
57
+ this.log(`\nPurls saved to ${outputPath}`);
58
+ }
59
+ catch (error) {
60
+ const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : 'Unknown error';
61
+ this.warn(`Failed to save purls: ${errorMessage}`);
62
+ }
63
+ }
64
+ return purls;
65
+ }
66
+ }
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { ScanResult } from '../../api/types/nes.types.ts';
3
+ export default class ScanEol extends Command {
4
+ static description: string;
5
+ static enableJsonFlag: boolean;
6
+ static examples: string[];
7
+ static flags: {
8
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ dir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ save: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<ScanResult | {
13
+ components: [];
14
+ }>;
15
+ private checkEolScanDisabled;
16
+ }