Skip to content

Commit

Permalink
Use mermaid format by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Dec 30, 2024
1 parent 544fa8c commit 48724b0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
35 changes: 20 additions & 15 deletions src/commands/hardis/doc/project2markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,21 +431,26 @@ ${Project2Markdown.htmlInstructions}
// Generate manifest from package folder
const packageManifestFile = path.join("manifest", packageDir.name + '-package.xml');
await fs.ensureDir(path.dirname(packageManifestFile));
await execSfdxJson("sf project generate manifest" +
` --source-dir ${packageDir.path}` +
` --name ${packageManifestFile}`, this,
{
fail: true,
output: true,
debug: this.debugMode,
}
);
// Add package in available packages list
this.packageXmlCandidates.push({
path: packageManifestFile,
name: packageDir.name,
description: `Package.xml generated from content of SFDX package ${packageDir.name} (folder ${packageDir.path})`
});
try {
await execSfdxJson("sf project generate manifest" +
` --source-dir ${packageDir.path}` +
` --name ${packageManifestFile}`, this,
{
fail: true,
output: true,
debug: this.debugMode,
}
);
// Add package in available packages list
this.packageXmlCandidates.push({
path: packageManifestFile,
name: packageDir.name,
description: `Package.xml generated from content of SFDX package ${packageDir.name} (folder ${packageDir.path})`
});
}
catch (e: any) {
uxLog(this, c.red(`Unable to generate manifest from ${packageDir.path}: it won't appear in the documentation\n${e.message}`))
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/common/utils/flowVisualiser/flowParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ async function generateMermaidContent(flowMap: FlowMap, flowObj: any, options: a
const mdEnd = "```\n\n";
const currentBranch = await getCurrentGitBranch();
const footer = `\n\n___\n\n_Documentation generated from branch ${currentBranch} by [sfdx-hardis](${CONSTANTS.DOC_URL_ROOT}), featuring [salesforce-flow-visualiser](https://github.com/toddhalfpenny/salesforce-flow-visualiser)_`;
const mdDiagram = "flowchart TB\n" + nodeDefStr + mdBody + mdClasses
const mdDiagram =
"%% If you read this, your Markdown visualizer does not handle MermaidJS syntax. If you are using sfdx-hardis, try to define env variable `MERMAID_MODES=cli,docker` ,then run again the command to regenerate markdown with SVG images.\n" +
"flowchart TB\n" +
nodeDefStr +
mdBody +
mdClasses
if (options.wrapInMarkdown === false) {
return (mdDiagram);
} else {
Expand Down
9 changes: 7 additions & 2 deletions src/common/utils/mermaidUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ export async function generateFlowMarkdownFile(flowName: string, flowXml: string
}
}

export async function generateMarkdownFileWithMermaid(outputFlowMdFile: string): Promise<boolean> {
const mermaidModes = (process.env.MERMAID_MODES || "cli,docker").split(",");
export async function generateMarkdownFileWithMermaid(outputFlowMdFile: string, mermaidModes: string[] | null = null): Promise<boolean> {
if (mermaidModes === null) {
mermaidModes = (process.env.MERMAID_MODES || "mermaid,cli,docker").split(",");
}
if (mermaidModes.includes("mermaid")) {
return true;
}
const isDockerAvlbl = await isDockerAvailable();
if (isDockerAvlbl && (!(globalThis.mermaidUnavailableTools || []).includes("docker")) && mermaidModes.includes("docker")) {
const dockerSuccess = await generateMarkdownFileWithMermaidDocker(outputFlowMdFile);
Expand Down

0 comments on commit 48724b0

Please sign in to comment.