Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ coverage/**
.yarn/install-state.gz
oclif.manifest.json
*.log
*.tgz
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"chalk": "^5.4.1",
"cosmiconfig": "^9.0.0",
"glob": "^11.0.1",
"lightning-flow-scanner-core": "4.14.0"
"lightning-flow-scanner-core": "4.15.0"
},
"devDependencies": {
"@oclif/plugin-help": "^6.2.23",
Expand Down
12 changes: 6 additions & 6 deletions src/commands/flow/fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export default class FlowFix extends SfCommand<ScanResult> {
char: "d",
multiple: true,
description: commandMessages.getMessage("flagsDirsDescription"),
exclusive: ["file"],
exclusive: ["files"],
}),
file: Flags.file({
files: Flags.file({
exists: true,
multiple: true,
description: commandMessages.getMessage("flagsFilesDescription"),
Expand All @@ -41,8 +41,8 @@ export default class FlowFix extends SfCommand<ScanResult> {

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

const fixService = new CoreFixService(dir, file, rules);
const fixService = new CoreFixService(dir, files, rules);

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

console.log(`test`, outMessage);
this.debug(`test`, outMessage);

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

Expand Down
18 changes: 8 additions & 10 deletions src/commands/flow/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import { loadScannerOptions } from "../../libs/ScannerConfig.js";
import { FindFlows } from "../../libs/FindFlows.js";
import { ScanResult } from "../../models/ScanResult.js";

import {
parse,
scan,
import pkg, {
ScanResult as ScanResults,
RuleResult,
ResultDetails,
ScanResult as scanResults,
} from "lightning-flow-scanner-core";

import { ParsedFlow } from "lightning-flow-scanner-core/main/models/ParsedFlow.js";
const { parse: parseFlows, scan: scanFlows } = pkg;
import type { ParsedFlow } from "lightning-flow-scanner-core/main/models/ParsedFlow.js";

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);

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

const scanResults: scanResults[] =
const scanResults: ScanResults[] =
this.userConfig && Object.keys(this.userConfig).length > 0
? scan(parsedFlows, this.userConfig)
: scan(parsedFlows);
? scanFlows(parsedFlows, this.userConfig)
: scanFlows(parsedFlows);

this.debug(`scan results: ${scanResults.length}`, ...scanResults);
this.spinner.stop(`Scan complete`);
Expand Down
17 changes: 8 additions & 9 deletions src/libs/CoreFixService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {
fix,
parse,
scan,
ScanResult as ScanResults,
} from "lightning-flow-scanner-core";
import { IRulesConfig } from "lightning-flow-scanner-core/main/internals/internals.js";
import { writeFileSync } from "node:fs";

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

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

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

export default class CoreFixService {
public constructor(
private readonly dir,
Expand All @@ -24,7 +23,7 @@ export default class CoreFixService {
} else {
flowFiles = this.findFlowsByPath(this.file);
}
const parsedFlows = await parse(flowFiles);
const parsedFlows = await parseFlows(flowFiles);

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

// scan
const scanResults: ScanResults[] = scan(parsedFlows, flatRules);
const scanResults: FlowScanResults[] = scanFlows(parsedFlows, flatRules);

// fix
const fixFlow: ScanResults[] = fix(scanResults);
const fixFlow: FlowScanResults[] = fixFlows(scanResults);
fixFlow.forEach((fixedObject) => {
writeFileSync(fixedObject.flow.fsPath, fixedObject.flow.toXMLString());
});
Expand Down
Loading