Adding detector settings into the CLI executables
This commit is contained in:
@@ -20,6 +20,10 @@ program.option('-i --run-id <jobName>', 'Optional Run ID number for the activity
|
||||
program.option('--snapshot-exclude-file-name', 'exclude the file name in the dependency snapshot report. If false the name of the artifactor from the POM will be used, but any links in GitHub will not work.');
|
||||
program.option('--snapshot-dependency-file-name <fileName>', 'optional override to specificy the path to the file that the snapshot will be associated with in the repository');
|
||||
|
||||
program.option('--detector-name <detectorName>', 'optional name of the detector that generated the snapshot');
|
||||
program.option('--detector-url <detectorUrl>', 'optional URL of the detector that generated the snapshot, but not optional if you specify an detector-name');
|
||||
program.option('--detector-version <detectorVersion>', 'optional version of the detector that generated the snapshot, but not optional if you specify an detector-name');
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
const opts = program.opts();
|
||||
@@ -44,6 +48,25 @@ async function execute() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// If the detector-name is provided, then the other detector options become mandatory, check these early
|
||||
let detector;
|
||||
if (opts.detectorName) {
|
||||
if (!opts.detectorUrl) {
|
||||
console.error(`Error: detector-url is required when detector-name is provided\n`);
|
||||
program.help({ error: true });
|
||||
}
|
||||
|
||||
if (!opts.detectorVersion) {
|
||||
console.error(`Error: detector-version is required when detector-name is provided\n`);
|
||||
program.help({ error: true });
|
||||
}
|
||||
detector = {
|
||||
name: opts.detectorName,
|
||||
url: opts.detectorUrl,
|
||||
version: opts.detectorVersion,
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Build a fake GitHub Actions context so that values for the submission APIs can be retrieved
|
||||
const context = {
|
||||
@@ -71,8 +94,12 @@ async function execute() {
|
||||
|
||||
manifestFile: opts.snapshotDependencyFileName,
|
||||
includeManifestFile: !opts.snapshotExcludeFileName,
|
||||
detector: detector
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
snapshot = await generateSnapshot(opts.directory, mvnConfig, snapshotConfig);
|
||||
|
||||
} catch (err: any) {
|
||||
|
||||
Reference in New Issue
Block a user