@@ -30,10 +30,15 @@ const printSecurityScanSummary = (securityScanResults: SecurityScanResultType) =
3030 logger . log ( `${ errors } \t${ warnings } \t${ notes } \n` ) ;
3131} ;
3232
33- const writeResultsToFile = ( securityScanResults : SecurityScanResultType , appVersionId : number ) : string => {
33+ const writeResultsToFile = (
34+ securityScanResults : SecurityScanResultType ,
35+ appVersionId : number ,
36+ outputDir ?: string ,
37+ ) : string => {
3438 const timestamp = new Date ( ) . toISOString ( ) . split ( '.' ) [ 0 ] . replaceAll ( ':' , '-' ) ;
3539 const fileName = `security-scan-${ appVersionId } -${ timestamp } .json` ;
36- const filePath = path . join ( process . cwd ( ) , fileName ) ;
40+ const directory = outputDir || process . cwd ( ) ;
41+ const filePath = path . join ( directory , fileName ) ;
3742
3843 fs . writeFileSync ( filePath , JSON . stringify ( securityScanResults , null , 2 ) , 'utf8' ) ;
3944
@@ -46,6 +51,7 @@ export default class Report extends AuthenticatedCommand {
4651 static examples = [
4752 '<%= config.bin %> <%= command.id %> -i APP_VERSION_ID' ,
4853 '<%= config.bin %> <%= command.id %> -i APP_VERSION_ID -o' ,
54+ '<%= config.bin %> <%= command.id %> -i APP_VERSION_ID -o -d /path/to/directory' ,
4955 ] ;
5056
5157 static flags = Report . serializeFlags (
@@ -60,12 +66,17 @@ export default class Report extends AuthenticatedCommand {
6066 description : 'Save the full report to a JSON file' ,
6167 default : false ,
6268 } ) ,
69+ outputDir : Flags . string ( {
70+ char : 'd' ,
71+ description : 'Directory to save the report file (requires -o flag)' ,
72+ dependsOn : [ 'output' ] ,
73+ } ) ,
6374 } ) ,
6475 ) ;
6576
6677 public async run ( ) : Promise < void > {
6778 const { flags } = await this . parse ( Report ) ;
68- const { region : strRegion , output } = flags ;
79+ const { region : strRegion , output, outputDir } = flags ;
6980 const region = getRegionFromString ( strRegion ) ;
7081 let appVersionId = flags . appVersionId ;
7182
@@ -92,7 +103,7 @@ export default class Report extends AuthenticatedCommand {
92103 printSecurityScanSummary ( response . securityScanResults ) ;
93104
94105 if ( output ) {
95- const filePath = writeResultsToFile ( response . securityScanResults , appVersionId ) ;
106+ const filePath = writeResultsToFile ( response . securityScanResults , appVersionId , outputDir ) ;
96107 logger . log ( `Full report saved to: ${ filePath } ` ) ;
97108 } else {
98109 logger . log ( 'Use the -o flag to save the full report to a JSON file.' ) ;
0 commit comments