Skip to content

Commit 313c9de

Browse files
authored
Merge pull request #142 from Lightning-Flow-Scanner/standardize-core-esm
feat: standardize core es module
2 parents 39d9fb7 + 5d51793 commit 313c9de

File tree

4 files changed

+83
-88
lines changed

4 files changed

+83
-88
lines changed

package-lock.json

Lines changed: 60 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"version": "2.43.0",
44
"bugs": "https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-sfdx/issues",
55
"dependencies": {
6-
"@oclif/core": "^4.2.4",
6+
"@oclif/core": "^4.2.5",
77
"@salesforce/core": "^8.8.2",
88
"@salesforce/sf-plugins-core": "^12.1.3",
99
"chalk": "^5.4.1",
1010
"cosmiconfig": "^9.0.0",
1111
"fs-extra": "^11.3.0",
1212
"glob": "^11.0.1",
13-
"lightning-flow-scanner-core": "4.15.0"
13+
"lightning-flow-scanner-core": "4.16.0"
1414
},
1515
"devDependencies": {
1616
"@oclif/plugin-help": "^6.2.23",
@@ -21,18 +21,18 @@
2121
"@types/chai": "^5",
2222
"@types/jsforce": "^1.11.5",
2323
"@types/mocha": "^10.0.10",
24-
"@types/node": "^22.10.10",
24+
"@types/node": "^22.13.0",
2525
"@types/sinon": "^17.0.3",
2626
"@types/sinonjs__fake-timers": "^8.1.5",
27-
"@typescript-eslint/eslint-plugin": "^8.21.0",
28-
"@typescript-eslint/parser": "^8.21.0",
27+
"@typescript-eslint/eslint-plugin": "^8.22.0",
28+
"@typescript-eslint/parser": "^8.22.0",
2929
"chai": "^5",
3030
"eslint": "^9.19.0",
3131
"eslint-config-prettier": "^10.0.1",
3232
"globby": "^14.0.2",
3333
"mocha": "^11.1.0",
3434
"nyc": "^17",
35-
"oclif": "^4.17.19",
35+
"oclif": "^4.17.21",
3636
"prettier": "^3.4.2",
3737
"sinon": "^19.0.2",
3838
"ts-node": "^10.9.2",

src/commands/flow/scan.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import { loadScannerOptions } from "../../libs/ScannerConfig.js";
88
import { FindFlows } from "../../libs/FindFlows.js";
99
import { ScanResult } from "../../models/ScanResult.js";
1010

11-
import pkg, {
11+
import {
1212
ScanResult as ScanResults,
1313
RuleResult,
1414
ResultDetails,
15+
parse as parseFlows,
16+
scan as scanFlows,
17+
ParsedFlow,
1518
} from "lightning-flow-scanner-core";
16-
const { parse: parseFlows, scan: scanFlows } = pkg;
17-
import type { ParsedFlow } from "lightning-flow-scanner-core/main/models/ParsedFlow.js";
1819

1920
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2021

@@ -28,7 +29,7 @@ export default class Scan extends SfCommand<ScanResult> {
2829
"sf flow scan -c path/to/config.json",
2930
"sf flow scan -c path/to/config.json --failon warning",
3031
"sf flow scan -d path/to/flows/directory",
31-
"sf flow scan -p path/to/single/file.flow-meta.xml,path/to/another/file.flow-meta.xml",
32+
"[DEPRECATION WARNING USE --files] sf flow scan -p path/to/single/file.flow-meta.xml,path/to/another/file.flow-meta.xml",
3233
"sf flow scan --files path/to/single/file.flow-meta.xml path/to/another/file.flow-meta.xml",
3334
];
3435

@@ -37,7 +38,7 @@ export default class Scan extends SfCommand<ScanResult> {
3738
public static requiresProject = false;
3839
protected static supportsUsername = true;
3940

40-
protected userConfig;
41+
protected userConfig: object;
4142
protected failOn = "error";
4243
protected errorCounters: Map<string, number> = new Map<string, number>();
4344

src/libs/CoreFixService.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { writeFileSync } from "node:fs";
33

44
import { FindFlows } from "./FindFlows.js";
55

6-
import pkg from "lightning-flow-scanner-core";
7-
const { fix: fixFlows, parse: parseFlows, scan: scanFlows } = pkg;
6+
import { scan, parse, fix as fixFlows } from "lightning-flow-scanner-core";
87

98
import type { ScanResult as FlowScanResults } from "lightning-flow-scanner-core";
109

@@ -17,13 +16,8 @@ export default class CoreFixService {
1716

1817
public async fix(): Promise<string[]> {
1918
//find flow file(s)
20-
let flowFiles;
21-
if (this.dir) {
22-
flowFiles = this.findFlowsByDir(this.dir);
23-
} else {
24-
flowFiles = this.findFlowsByPath(this.file);
25-
}
26-
const parsedFlows = await parseFlows(flowFiles);
19+
const flowFiles = this.findFlows();
20+
const parsedFlows = await parse(flowFiles);
2721

2822
// make on the fly rule
2923
const flatRules = this.rules
@@ -39,7 +33,7 @@ export default class CoreFixService {
3933
) as IRulesConfig;
4034

4135
// scan
42-
const scanResults: FlowScanResults[] = scanFlows(parsedFlows, flatRules);
36+
const scanResults: FlowScanResults[] = scan(parsedFlows, flatRules);
4337

4438
// fix
4539
const fixFlow: FlowScanResults[] = fixFlows(scanResults);
@@ -50,6 +44,13 @@ export default class CoreFixService {
5044
return fixFlow.map((fixedOut) => fixedOut.flow.fsPath);
5145
}
5246

47+
private findFlows(): string[] {
48+
if (this.dir) {
49+
return this.findFlowsByDir(this.dir);
50+
}
51+
return this.findFlowsByPath(this.file);
52+
}
53+
5354
private findFlowsByDir(dir: string[]): string[] {
5455
return dir
5556
.map((dirName) => {

0 commit comments

Comments
 (0)