|
1 | 1 | import { SfCommand, Flags } from "@salesforce/sf-plugins-core"; |
2 | | -import { Messages, SfError } from "@salesforce/core"; |
| 2 | +import { Messages } from "@salesforce/core"; |
3 | 3 | import chalk from "chalk"; |
4 | | -import { exec } from "child_process"; |
5 | 4 |
|
6 | 5 | import { loadScannerOptions } from "../../libs/ScannerConfig.js"; |
7 | 6 | import { FindFlows } from "../../libs/FindFlows.js"; |
@@ -73,31 +72,17 @@ export default class Scan extends SfCommand<Output> { |
73 | 72 | description: "List of source flows paths to scan", |
74 | 73 | charAliases: ["p"], |
75 | 74 | exclusive: ["directory"], |
76 | | - }), |
77 | | - targetusername: Flags.string({ |
78 | | - char: "u", |
79 | | - description: |
80 | | - "Retrieve the latest metadata from the target before the scan.", |
81 | | - required: false, |
82 | | - charAliases: ["o"], |
83 | | - }), |
| 75 | + }) |
84 | 76 | }; |
85 | 77 |
|
86 | 78 | public async run(): Promise<Output> { |
87 | | - // 🚨 Step 0: Block risky APIs before anything else |
88 | 79 | this.enforceSecurityGuards(); |
89 | | - |
90 | | - // Step 1: Parse CLI flags |
91 | 80 | const { flags } = await this.parse(Scan); |
92 | 81 | this.failOn = flags.failon || "error"; |
93 | 82 |
|
94 | 83 | this.spinner.start("Loading Lightning Flow Scanner"); |
95 | 84 | this.userConfig = await loadScannerOptions(flags.config); |
96 | 85 |
|
97 | | - if (flags.targetusername) { |
98 | | - await this.retrieveFlowsFromOrg(flags.targetusername); |
99 | | - } |
100 | | - |
101 | 86 | const targets: string[] = flags.files; |
102 | 87 |
|
103 | 88 | // Step 2: Find flows to scan |
@@ -280,28 +265,4 @@ public async run(): Promise<Output> { |
280 | 265 | return dynamicImport(...args); |
281 | 266 | }; |
282 | 267 | } |
283 | | - |
284 | | - |
285 | | - private async retrieveFlowsFromOrg(targetusername: string) { |
286 | | - let errored = false; |
287 | | - this.spinner.start(chalk.yellowBright("Retrieving Metadata...")); |
288 | | - const retrieveCommand = `sf project retrieve start -m Flow -o "${targetusername}"`; |
289 | | - try { |
290 | | - await exec(retrieveCommand, { maxBuffer: 1000000 * 1024 }); |
291 | | - } catch (exception) { |
292 | | - errored = true; |
293 | | - this.toErrorJson(exception); |
294 | | - this.spinner.stop(chalk.redBright("Retrieve Operation Failed.")); |
295 | | - } |
296 | | - if (errored) { |
297 | | - throw new SfError( |
298 | | - messages.getMessage("errorRetrievingMetadata"), |
299 | | - "", |
300 | | - [], |
301 | | - 1, |
302 | | - ); |
303 | | - } else { |
304 | | - this.spinner.stop(chalk.greenBright("Retrieve Completed ✔.")); |
305 | | - } |
306 | | - } |
307 | 268 | } |
0 commit comments