-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flows in documentations & visual git diff in Pull Requests (#938)
* Flow doc v0 * Generate mermaid svg * Remove mermaid-cli and call it via npx * diff v0 * Flow diff v0.1: TODO: add tooltips for diff * flow2markdown & refacto * Temporary embed FlowVisualiser * starts to be good :) * factorize * gitdiff for PR * x * Improve perfs * rb * all good ! * changelog * fixes * [Mega-Linter] Apply linters fixes * x * Do not run docker image as root * test * Revert "test" This reverts commit 640234f. * Fixes * Fixes to generate only mmd for PRs * One comment by flow diff ^^ * Allow SFDX_DISABLE_FLOW_DIFF * Handle more cases * More visuals to show diffs * Add flow details * More styling * add formulas * Flow index + rebranding of icons * More styling * Filter sections without updates * Display only updated lines in tables * Apply PR summary and git diff to wrapped SF Cli commands * Fix wraputils & doc * lint fixes * doc * Fix constants and tables * changelog * doc * typo * jscpd * [Mega-Linter] Apply linters fixes :) --------- Co-authored-by: nvuillam <[email protected]>
- Loading branch information
Showing
27 changed files
with
1,778 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"args": [ | ||
"--no-sandbox", | ||
"--disable-setuid-sandbox" | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* jscpd:ignore-start */ | ||
import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; | ||
import c from "chalk"; | ||
import * as path from "path"; | ||
import fs from "fs-extra"; | ||
import { Messages } from '@salesforce/core'; | ||
import { AnyJson } from '@salesforce/ts-types'; | ||
import { WebSocketClient } from '../../../common/websocketClient.js'; | ||
import { isCI, uxLog } from '../../../common/utils/index.js'; | ||
import { MetadataUtils } from '../../../common/metadata-utils/index.js'; | ||
import { generateFlowMarkdownFile, generateMarkdownFileWithMermaid } from '../../../common/utils/mermaidUtils.js'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('sfdx-hardis', 'org'); | ||
|
||
export default class Flow2Markdown extends SfCommand<any> { | ||
public static title = 'Flow to Markdown'; | ||
|
||
public static description = `Generates a markdown documentation from a Flow file`; | ||
|
||
public static examples = [ | ||
'$ sf hardis:doc:flow2markdown', | ||
'$ sf hardis:doc:flow2markdown --inputfile force-app/main/default/flows/MyFlow.flow-meta.xml' | ||
]; | ||
|
||
public static flags: any = { | ||
inputfile: Flags.string({ | ||
char: 'x', | ||
description: 'Path to Flow metadata file. If not specified, the command will prompt the user', | ||
}), | ||
outputfile: Flags.string({ | ||
char: 'f', | ||
description: 'Force the path and name of output markdown file. Must end with .md', | ||
}), | ||
debug: Flags.boolean({ | ||
char: 'd', | ||
default: false, | ||
description: messages.getMessage('debugMode'), | ||
}), | ||
websocket: Flags.string({ | ||
description: messages.getMessage('websocket'), | ||
}), | ||
skipauth: Flags.boolean({ | ||
description: 'Skip authentication check when a default username is required', | ||
}), | ||
}; | ||
|
||
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default | ||
public static requiresProject = false; | ||
|
||
protected inputFile; | ||
protected outputFile; | ||
protected debugMode = false; | ||
/* jscpd:ignore-end */ | ||
|
||
public async run(): Promise<AnyJson> { | ||
const { flags } = await this.parse(Flow2Markdown); | ||
this.inputFile = flags.inputfile || null; | ||
this.outputFile = flags.outputfile || null; | ||
this.debugMode = flags.debug || false; | ||
|
||
if (this.inputFile === null && !isCI) { | ||
this.inputFile = await MetadataUtils.promptFlow(); | ||
} | ||
if (!this.outputFile) { | ||
await fs.ensureDir(path.join("docs", "flows")); | ||
this.outputFile = path.join("docs", "flows", path.basename(this.inputFile).replace(".flow-meta.xml", ".md")); | ||
} | ||
|
||
uxLog(this, c.grey(`Generating markdown for Flow ${this.inputFile}...`)); | ||
const flowXml = (await fs.readFile(this.inputFile, "utf8")).toString(); | ||
const genRes = await generateFlowMarkdownFile(this.inputFile, flowXml, this.outputFile); | ||
if (!genRes) { | ||
throw new Error("Error generating markdown file"); | ||
} | ||
if (this.debugMode) { | ||
await fs.copyFile(this.outputFile, this.outputFile + ".mermaid.md"); | ||
} | ||
const gen2res = await generateMarkdownFileWithMermaid(this.outputFile); | ||
if (!gen2res) { | ||
throw new Error("Error generating mermaid markdown file"); | ||
} | ||
// Open file in a new VsCode tab if available | ||
WebSocketClient.requestOpenFile(this.outputFile); | ||
|
||
// Return an object to be displayed with --json | ||
return { outputFile: this.outputFile }; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.