11import { SfCommand , Flags } from "@salesforce/sf-plugins-core" ;
22import { Messages , SfError } from "@salesforce/core" ;
33import chalk from "chalk" ;
4+ import * as fse from "fs-extra" ;
45import { exec } from "child_process" ;
56
67import { loadScannerOptions } from "../../libs/ScannerConfig.js" ;
@@ -27,7 +28,8 @@ export default class Scan extends SfCommand<ScanResult> {
2728 "sf flow scan -c path/to/config.json" ,
2829 "sf flow scan -c path/to/config.json --failon warning" ,
2930 "sf flow scan -d path/to/flows/directory" ,
30- "sf flow scan -p path/to/single/file.flow-meta.xml" ,
31+ "sf flow scan -p path/to/single/file.flow-meta.xml,path/to/another/file.flow-meta.xml" ,
32+ "sf flow scan --files path/to/single/file.flow-meta.xml path/to/another/file.flow-meta.xml" ,
3133 ] ;
3234
3335 protected static requiresUsername = false ;
@@ -63,13 +65,16 @@ export default class Scan extends SfCommand<ScanResult> {
6365 description : "Force retrieve Flows from org at the start of the command" ,
6466 default : false ,
6567 } ) ,
66- sourcepath : Flags . file ( {
68+ sourcepath : Flags . directory ( {
6769 char : "p" ,
6870 description : "Comma-separated list of source flow paths to scan" ,
6971 required : false ,
70- aliases : [ "files" ] ,
72+ multiple : false ,
73+ } ) ,
74+ files : Flags . file ( {
7175 multiple : true ,
7276 exists : true ,
77+ description : "List of source flows paths to scan" ,
7378 } ) ,
7479 targetusername : Flags . string ( {
7580 char : "u" ,
@@ -88,7 +93,10 @@ export default class Scan extends SfCommand<ScanResult> {
8893 if ( flags . targetusername ) {
8994 await this . retrieveFlowsFromOrg ( flags . targetusername ) ;
9095 }
91- const flowFiles = this . findFlows ( flags . directory , flags . sourcepath ) ;
96+
97+ const targets : string | string [ ] = flags . sourcepath ?? flags . files ;
98+
99+ const flowFiles = this . findFlows ( flags . directory , targets ) ;
92100 this . spinner . start ( `Identified ${ flowFiles . length } flows to scan` ) ;
93101 // to
94102 // core.Flow
@@ -186,7 +194,7 @@ export default class Scan extends SfCommand<ScanResult> {
186194 return { summary, status : status , results } ;
187195 }
188196
189- private findFlows ( directory : string , sourcepath : string [ ] ) {
197+ private findFlows ( directory : string , sourcepath : string | string [ ] ) {
190198 // List flows that will be scanned
191199 let flowFiles ;
192200 if ( directory && sourcepath ) {
@@ -197,7 +205,21 @@ export default class Scan extends SfCommand<ScanResult> {
197205 } else if ( directory ) {
198206 flowFiles = FindFlows ( directory ) ;
199207 } else if ( sourcepath ) {
200- flowFiles = sourcepath ;
208+ if ( typeof sourcepath === "string" ) {
209+ this . log ( chalk . cyanBright ( "********" ) ) ;
210+ this . log ( "" ) ;
211+ this . log (
212+ chalk . yellowBright (
213+ "WARN: flag --path or -p will be deprecated, please use --files to scan flow source files" ,
214+ ) ,
215+ ) ;
216+ this . log ( "" ) ;
217+ this . log ( chalk . cyanBright ( "********" ) ) ;
218+ this . log ( "" ) ;
219+ flowFiles = sourcepath . split ( "," ) . filter ( ( f ) => fse . exists ( f ) ) ;
220+ } else {
221+ flowFiles = sourcepath ;
222+ }
201223 } else {
202224 flowFiles = FindFlows ( "." ) ;
203225 }
0 commit comments