Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.

Commit b71711d

Browse files
committed
fallback uri processing
1 parent bd2cf46 commit b71711d

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,33 +368,40 @@ npm install @flow-scanner/lightning-flow-scanner-core
368368
npm run test
369369
```
370370

371-
5. Deploy Demo Flows (Optional):
371+
5. Testing the module locally(Optional):
372372

373-
```bash
374-
cd assets/example-flows && sf project deploy start &&
375-
```
373+
To link the module, run:
376374

377-
Navigate to the [Demo Readme](assets\example-flows\README.md) for full details
375+
```bash
376+
npm run link
377+
```
378378

379-
6. Test as local dependency(Optional):
380-
a. run:
379+
a. Ad-Hoc Testing with node:
381380

382381
```bash
383382
npm run link
384383
```
385384

386-
b. Go to the dependent project (e.g. VSX or CLI) and use:
385+
b. Test in a dependent project (e.g. VSX or CLI):
387386

388387
```bash
389388
npm link @flow-scanner/lightning-flow-scanner-core
390389
```
391390

392391
Your local module will now replace any installed version and update on rebuild.
393392

393+
6. Deploy Demo Flows (Optional):
394+
395+
```bash
396+
cd assets/example-flows && sf project deploy start &&
397+
```
398+
399+
Navigate to the [Demo Readme](assets\example-flows\README.md) for full details
400+
394401
7. Create a standalone UMD Module(Optional):
395402

396-
```bash
397-
npm run vite:dist // creates UMD at`dist/lightning-flow-scanner-core.umd.js`.
398-
```
403+
```bash
404+
npm run vite:dist // creates UMD at`dist/lightning-flow-scanner-core.umd.js`.
405+
```
399406

400407
<p><strong>Want to help improve Lightning Flow Scanner? See our <a href="https://github.com/Flow-Scanner/lightning-flow-scanner-core?tab=contributing-ov-file">Contributing Guidelines</a></strong></p>

src/main/libs/exportAsSarif.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Flow } from "../models/Flow";
22
import { ScanResult } from "../models/ScanResult";
33
import { Violation } from "../models/Violation";
4-
import * as p from "path"; // For relative path fallback
54

65
export function exportSarif(results: ScanResult[]): string {
76
const runs = results.map((result) => {
@@ -53,15 +52,20 @@ export function exportSarif(results: ScanResult[]): string {
5352
}
5453

5554
function getUri(flow: Flow): string {
56-
// Prioritize uri (virtual/relative from input, e.g., for browser)
55+
// Prefer uri (works in both browser and Node)
5756
if (flow.uri) {
5857
return flow.uri.replace(/\\/g, "/");
5958
}
60-
// Fallback to relative fsPath for Node
59+
60+
// Node only: fsPath is only set in Node environments
6161
if (flow.fsPath) {
62-
return p.relative(process.cwd(), flow.fsPath).replace(/\\/g, "/");
62+
const match = flow.fsPath.match(/(?:force-app|src)\/.+$/);
63+
if (match) {
64+
return match[0].replace(/\\/g, "/");
65+
}
66+
return flow.fsPath.replace(/\\/g, "/");
6367
}
64-
// Final generic fallback
68+
6569
return `flows/${flow.name}.flow-meta.xml`;
6670
}
6771

src/main/models/Flow.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ export class Flow {
6969
constructor(path?: string, data?: unknown) {
7070
if (path) {
7171
this.uri = path; // Always set general URI from input (file path or virtual)
72-
this.fsPath = p.resolve(path); // Resolve for Node; test can override to undefined for browser sim
72+
73+
// Only resolve fsPath in Node.js environments
74+
// In browser with polyfills, fsPath stays undefined
75+
if (typeof process !== 'undefined' && process.cwd) {
76+
this.fsPath = p.resolve(path);
77+
}
78+
7379
let flowName = p.basename(p.basename(path), p.extname(path));
7480
if (flowName.includes(".")) {
7581
flowName = flowName.split(".")[0];

0 commit comments

Comments
 (0)