FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: improve DX of request-cves by RafaelGSS · Pull Request #1120 · nodejs/node-core-utils · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
76 changes: 46 additions & 30 deletions components/git/security.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ const securityOptions = {

let yargsInstance;

function isPromptInterrupted(error) {
return error?.name === 'ExitPromptError' ||
error?.name === 'AbortPromptError' ||
error?.message?.includes('User force closed');
}

function runSecurityAction(cli, action) {
return Promise.resolve(action).catch((error) => {
if (!isPromptInterrupted(error)) {
throw error;
}

if (cli.spinner.isSpinning) {
cli.spinner.stop();
}
cli.warn('Aborted.');
cli.setExitCode(1);
});
}

export function builder(yargs) {
yargsInstance = yargs;
return yargs.options(securityOptions)
Expand Down Expand Up @@ -117,40 +137,36 @@ export function builder(yargs) {
export function handler(argv) {
const logStream = process.stdout.isTTY ? process.stdout : process.stderr;
const cli = new CLI(logStream);
let action;

if (argv.start) {
return startSecurityRelease(cli, argv);
}
if (argv['apply-patches']) {
return applySecurityPatches(cli, argv);
action = startSecurityRelease(cli, argv);
} else if (argv['apply-patches']) {
action = applySecurityPatches(cli, argv);
} else if (argv.sync) {
action = syncSecurityRelease(cli, argv);
} else if (argv['update-date']) {
action = updateReleaseDate(cli, argv);
} else if (argv['pre-release']) {
action = createPreRelease(cli, argv);
} else if (argv['add-report']) {
action = addReport(cli, argv);
} else if (argv['remove-report']) {
action = removeReport(cli, argv);
} else if (argv['notify-pre-release']) {
action = notifyPreRelease(cli, argv);
} else if (argv['request-cve']) {
action = requestCVEs(cli, argv);
} else if (argv['post-release']) {
action = createPostRelease(cli, argv);
} else if (argv.cleanup) {
action = cleanupSecurityRelease(cli, argv);
}
if (argv.sync) {
return syncSecurityRelease(cli, argv);
}
if (argv['update-date']) {
return updateReleaseDate(cli, argv);
}
if (argv['pre-release']) {
return createPreRelease(cli, argv);
}
if (argv['add-report']) {
return addReport(cli, argv);
}
if (argv['remove-report']) {
return removeReport(cli, argv);
}
if (argv['notify-pre-release']) {
return notifyPreRelease(cli, argv);
}
if (argv['request-cve']) {
return requestCVEs(cli, argv);
}
if (argv['post-release']) {
return createPostRelease(cli, argv);
}
if (argv.cleanup) {
return cleanupSecurityRelease(cli, argv);

if (action) {
return runSecurityAction(cli, action);
}

yargsInstance.showHelp();
}

Expand Down
2 changes: 2 additions & 0 deletions lib/security-release/security-release.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,11 @@ export class SecurityRelease {
'chore: updated vulnerabilities.json',
{ cli: this.cli, repository: this.repository });
this.cli.stopSpinner(`Done updating vulnerabilities.json from ${vulnerabilitiesJSONPath}`);
return true;
} catch (error) {
this.cli.error('Error updating vulnerabilities.json');
this.cli.error(error);
return false;
}
}

Expand Down
Loading
Loading

Back | FazBrowse Home | New Git URL