Skip to content

Commit 5b74ab4

Browse files
authored
Merge pull request #137 from Lightning-Flow-Scanner/use-swc-compiled-core
feat: use swc compiled core package
2 parents 26f0f16 + 1be135c commit 5b74ab4

File tree

6 files changed

+28
-30
lines changed

6 files changed

+28
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ coverage/**
1313
.yarn/install-state.gz
1414
oclif.manifest.json
1515
*.log
16+
*.tgz

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"chalk": "^5.4.1",
1010
"cosmiconfig": "^9.0.0",
1111
"glob": "^11.0.1",
12-
"lightning-flow-scanner-core": "4.14.0"
12+
"lightning-flow-scanner-core": "4.15.0"
1313
},
1414
"devDependencies": {
1515
"@oclif/plugin-help": "^6.2.23",

src/commands/flow/fix.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export default class FlowFix extends SfCommand<ScanResult> {
2828
char: "d",
2929
multiple: true,
3030
description: commandMessages.getMessage("flagsDirsDescription"),
31-
exclusive: ["file"],
31+
exclusive: ["files"],
3232
}),
33-
file: Flags.file({
33+
files: Flags.file({
3434
exists: true,
3535
multiple: true,
3636
description: commandMessages.getMessage("flagsFilesDescription"),
@@ -41,8 +41,8 @@ export default class FlowFix extends SfCommand<ScanResult> {
4141

4242
public async run(): Promise<ScanResult> {
4343
const { flags } = await this.parse(FlowFix);
44-
const { dir, file, rules } = flags;
45-
if (!dir && !file) {
44+
const { dir, files, rules } = flags;
45+
if (!dir && !files) {
4646
throw new SfError(
4747
commandMessages.getMessage("errorMutuallyExclusiveRequired"),
4848
);
@@ -52,11 +52,11 @@ export default class FlowFix extends SfCommand<ScanResult> {
5252
stdout: true,
5353
});
5454

55-
const fixService = new CoreFixService(dir, file, rules);
55+
const fixService = new CoreFixService(dir, files, rules);
5656

5757
const outMessage = (await fixService.fix()).join(", ");
5858

59-
console.log(`test`, outMessage);
59+
this.debug(`test`, outMessage);
6060

6161
this.spinner.stop(`Fix Complete.. Fixed ${outMessage}`);
6262

src/commands/flow/scan.ts

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

10-
import {
11-
parse,
12-
scan,
10+
import pkg, {
11+
ScanResult as ScanResults,
1312
RuleResult,
1413
ResultDetails,
15-
ScanResult as scanResults,
1614
} from "lightning-flow-scanner-core";
17-
18-
import { ParsedFlow } from "lightning-flow-scanner-core/main/models/ParsedFlow.js";
15+
const { parse: parseFlows, scan: scanFlows } = pkg;
16+
import type { ParsedFlow } from "lightning-flow-scanner-core/main/models/ParsedFlow.js";
1917

2018
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2119

@@ -94,13 +92,13 @@ export default class Scan extends SfCommand<ScanResult> {
9492
this.spinner.start(`Identified ${flowFiles.length} flows to scan`);
9593
// to
9694
// core.Flow
97-
const parsedFlows: ParsedFlow[] = await parse(flowFiles);
95+
const parsedFlows: ParsedFlow[] = await parseFlows(flowFiles);
9896
this.debug(`parsed flows ${parsedFlows.length}`, ...parsedFlows);
9997

100-
const scanResults: scanResults[] =
98+
const scanResults: ScanResults[] =
10199
this.userConfig && Object.keys(this.userConfig).length > 0
102-
? scan(parsedFlows, this.userConfig)
103-
: scan(parsedFlows);
100+
? scanFlows(parsedFlows, this.userConfig)
101+
: scanFlows(parsedFlows);
104102

105103
this.debug(`scan results: ${scanResults.length}`, ...scanResults);
106104
this.spinner.stop(`Scan complete`);

src/libs/CoreFixService.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import {
2-
fix,
3-
parse,
4-
scan,
5-
ScanResult as ScanResults,
6-
} from "lightning-flow-scanner-core";
71
import { IRulesConfig } from "lightning-flow-scanner-core/main/internals/internals.js";
82
import { writeFileSync } from "node:fs";
93

104
import { FindFlows } from "./FindFlows.js";
115

6+
import pkg from "lightning-flow-scanner-core";
7+
const { fix: fixFlows, parse: parseFlows, scan: scanFlows } = pkg;
8+
9+
import type { ScanResult as FlowScanResults } from "lightning-flow-scanner-core";
10+
1211
export default class CoreFixService {
1312
public constructor(
1413
private readonly dir,
@@ -24,7 +23,7 @@ export default class CoreFixService {
2423
} else {
2524
flowFiles = this.findFlowsByPath(this.file);
2625
}
27-
const parsedFlows = await parse(flowFiles);
26+
const parsedFlows = await parseFlows(flowFiles);
2827

2928
// make on the fly rule
3029
const flatRules = this.rules
@@ -40,10 +39,10 @@ export default class CoreFixService {
4039
) as IRulesConfig;
4140

4241
// scan
43-
const scanResults: ScanResults[] = scan(parsedFlows, flatRules);
42+
const scanResults: FlowScanResults[] = scanFlows(parsedFlows, flatRules);
4443

4544
// fix
46-
const fixFlow: ScanResults[] = fix(scanResults);
45+
const fixFlow: FlowScanResults[] = fixFlows(scanResults);
4746
fixFlow.forEach((fixedObject) => {
4847
writeFileSync(fixedObject.flow.fsPath, fixedObject.flow.toXMLString());
4948
});

0 commit comments

Comments
 (0)