You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create CycloneDX Software Bill of Materials (SBOM) from Node.js NPM projects.
76
76
77
77
Arguments:
78
-
<package-manifest> Path to project's manifest file.
79
-
(default: "package.json" file in current working directory)
78
+
<package-manifest> Path to project's manifest file.
79
+
(default: "package.json" file in current working directory)
80
80
81
81
Options:
82
-
--ignore-npm-errors Whether to ignore errors of NPM.
83
-
This might be used, if "npm install" was run with "--force" or "--legacy-peer-deps".
84
-
(default: false)
85
-
--package-lock-only Whether to only use the lock file, ignoring "node_modules".
86
-
This means the output will be based only on the few details in and the tree described by the "npm-shrinkwrap.json" or "package-lock.json", rather than the contents of "node_modules" directory.
87
-
(default: false)
88
-
--omit <type...> Dependency types to omit from the installation tree.
89
-
(can be set multiple times)
90
-
(choices: "dev", "optional", "peer", default: "dev" if the NODE_ENV environment variable is set to "production", otherwise empty)
91
-
--gather-license-texts Search for license files in components and include them as license evidence.
92
-
This feature is experimental. (default: false)
93
-
--flatten-components Whether to flatten the components.
94
-
This means the actual nesting of node packages is not represented in the SBOM result.
95
-
(default: false)
96
-
--short-PURLs Omit all qualifiers from PackageURLs.
97
-
This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings.
98
-
(default: false)
99
-
--spec-version <version> Which version of CycloneDX spec to use.
Use multiple times to increase the verbosity even more.
116
-
-V, --version output the version number
117
-
-h, --help display help for command
82
+
--ignore-npm-errors Whether to ignore errors of NPM.
83
+
This might be used, if "npm install" was run with "--force" or "--legacy-peer-deps".
84
+
(default: false)
85
+
--package-lock-only Whether to only use the lock file, ignoring "node_modules".
86
+
This means the output will be based only on the few details in and the tree described by the "npm-shrinkwrap.json" or "package-lock.json", rather than the contents of "node_modules" directory.
87
+
(default: false)
88
+
--omit <type...> Dependency types to omit from the installation tree.
89
+
(can be set multiple times)
90
+
(choices: "dev", "optional", "peer", default: "dev" if the NODE_ENV environment variable is set to "production", otherwise empty)
91
+
--gather-license-texts Search for license files in components and include them as license evidence.
92
+
This feature is experimental. (default: false)
93
+
--flatten-components Whether to flatten the components.
94
+
This means the actual nesting of node packages is not represented in the SBOM result.
95
+
(default: false)
96
+
--short-PURLs Omit all qualifiers from PackageURLs.
97
+
This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings.
98
+
(default: false)
99
+
--spec-version <version> Which version of CycloneDX spec to use.
-w --workspace <workspace...> Only include dependencies for a specific workspace.
115
+
This feature is experimental. (default: empty)
116
+
(can be set multiple times)
117
+
--no-workspaces Do not include dependencies for workspaces.
118
+
Default behaviour is to include dependencies for all configured workspaces.
119
+
This can not be used if workspaces have been explicitly defined using "-w" or "--workspace"
120
+
This feature is experimental.
121
+
--include-workspace-root Include workspace root dependencies along with explicitly defined workspaces' dependencies.
122
+
This can only be used if you have explicitly defined workspaces using "-w" or "--workspace".
123
+
Default behaviour is to not include the workspace root when workspaces are excplicitly defined using "-w" or "--workspace".
124
+
This feature is experimental.
125
+
--no-include-workspace-root Do not include workspace root dependencies. This only has an effect if you have one or more workspaces configured in your project.
126
+
This is useful if you want to include all dependencies for all workspaces without explicitly defining them with "-w" or "--workspace" (default behaviour) but you do not
127
+
want workspace root dependencies included.
128
+
This feature is experimental.
129
+
-v, --verbose Increase the verbosity of messages.
130
+
Use multiple times to increase the verbosity even more.
Copy file name to clipboardExpand all lines: src/cli.ts
+51-1Lines changed: 51 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,9 @@ interface CommandOptions {
43
43
ignoreNpmErrors: boolean
44
44
packageLockOnly: boolean
45
45
omit: Omittable[]
46
+
workspace: string[]
47
+
includeWorkspaceRoot: boolean|undefined
48
+
workspaces: boolean|undefined
46
49
gatherLicenseTexts: boolean
47
50
flattenComponents: boolean
48
51
shortPURLs: boolean
@@ -87,6 +90,37 @@ function makeCommand (process: NodeJS.Process): Command {
87
90
: [],
88
91
`"${Omittable.Dev}" if the NODE_ENV environment variable is set to "production", otherwise empty`
89
92
)
93
+
).addOption(
94
+
newOption(
95
+
'-w, --workspace <workspace...>',
96
+
'Only include dependencies for a specific workspace. '+
97
+
'(can be set multiple times)\n'+
98
+
'This feature is experimental.'
99
+
).default([],'empty')
100
+
).addOption(
101
+
newOption(
102
+
'--no-workspaces',
103
+
'Do not include dependencies for workspaces.\n'+
104
+
'Default behaviour is to include dependencies for all configured workspaces.\n'+
105
+
'This can not be used if workspaces have been explicitly defined using `-w` or `--workspace`\n'+
106
+
'This feature is experimental.'
107
+
).default(undefined).conflicts('workspace')
108
+
).addOption(
109
+
newOption(
110
+
'--include-workspace-root',
111
+
'Include workspace root dependencies along with explicitly defined workspaces\' dependencies. '+
112
+
'This can only be used if you have explicitly defined workspaces using `-w` or `--workspace`.\n'+
113
+
'Default behaviour is to not include the workspace root when workspaces are excplicitly defined using `-w` or `--workspace`.\n'+
114
+
'This feature is experimental.'
115
+
).default(undefined)
116
+
).addOption(
117
+
newOption(
118
+
'--no-include-workspace-root',
119
+
'Do not include workspace root dependencies. This only has an effect if you have one or more workspaces configured in your project.\n'+
120
+
'This is useful if you want to include all dependencies for all workspaces without explicitly defining them with `-w` or `--workspace` (default behaviour) but '+
121
+
'you do not want the workspace root dependencies included.\n'+
122
+
'This feature is experimental.'
123
+
).default(undefined)
90
124
).addOption(
91
125
newOption(
92
126
'--gather-license-texts',
@@ -238,6 +272,19 @@ export async function run (process: NodeJS.Process): Promise<number> {
238
272
thrownewError('missing evidence')
239
273
}
240
274
275
+
// Commander will default this option to true as there
276
+
// is no positive boolean parameter (we define --no-workspaces but
277
+
// no --workspaces).
278
+
if(options.workspaces===true){
279
+
options.workspaces=undefined
280
+
}
281
+
282
+
if(options.includeWorkspaceRoot===true){
283
+
if(options.workspace.length===0){
284
+
thrownewError('Can only use --include-workspace-root when --workspace is also configured')
285
+
}
286
+
}
287
+
241
288
myConsole.log('LOG | gathering BOM data ...')
242
289
constbom=newBomBuilder(
243
290
newBuilders.FromNodePackageJson.ComponentBuilder(
@@ -254,7 +301,10 @@ export async function run (process: NodeJS.Process): Promise<number> {
0 commit comments