From 54e93ee5ec553a7c0498f5d3add5c33b8ab5d7ed Mon Sep 17 00:00:00 2001 From: Nicolas Vuillamy Date: Fri, 3 Jan 2025 12:17:54 +0100 Subject: [PATCH] Flow doc & flow diff commands (#188) * Flow doc & flow diff commands * [Mega-Linter] Apply linters fixes * documentation menu * Add commands with history * Doc Gen + changelog * cspell * [Mega-Linter] Apply linters fixes --------- Co-authored-by: nvuillam --- .github/linters/.cspell.json | 1 + CHANGELOG.md | 10 +++++ package.json | 30 +++++++++++++ src/commands.ts | 48 +++++++++++++++++++++ src/hardis-commands-provider.ts | 75 ++++++++++++++++++++++++++++----- src/hardis-websocket-server.ts | 5 +++ src/themeUtils.ts | 13 ++++++ 7 files changed, 172 insertions(+), 10 deletions(-) diff --git a/.github/linters/.cspell.json b/.github/linters/.cspell.json index eae43e9..6bb68bc 100644 --- a/.github/linters/.cspell.json +++ b/.github/linters/.cspell.json @@ -150,6 +150,7 @@ "minimumapiversion", "missingattributes", "mkdir", + "mkdocs", "multiselect", "myfolder", "nogit", diff --git a/CHANGELOG.md b/CHANGELOG.md index e7ecd84..989ed8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ ## [Unreleased] +- Add your updates here :) + +## [5.5.0] 2024-01-03 + +- New Documentation menu section + - [Generate SF project documentation](https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/) (including Visual Flows) + - New command to [**Generate Flow Markdown Documentation**](https://sfdx-hardis.cloudity.com/hardis/doc/flow2markdown/) + - New command to [**Generate Flow Visual Git Diff**](https://sfdx-hardis.cloudity.com/hardis/project/generate/flow-git-diff/) + - New command to run local Web Server with Documentation HTML pages + ## [5.4.0] 2024-12-16 - Add context menu to Generate Package.xml documentation diff --git a/package.json b/package.json index 454f00c..98dea60 100644 --- a/package.json +++ b/package.json @@ -129,6 +129,16 @@ "title": "SFDX Hardis: Generate package.xml Documentation", "icon": "$(book)" }, + { + "command": "vscode-sfdx-hardis.generateFlowDocumentation", + "title": "SFDX Hardis: Generate Flow Documentation", + "icon": "$(book)" + }, + { + "command": "vscode-sfdx-hardis.flowVisualGitDiff", + "title": "SFDX Hardis: Flow Visual Git Diff", + "icon": "$(diff)" + }, { "command": "vscode-sfdx-hardis.openExternal", "title": "SFDX Hardis: Open external url", @@ -266,6 +276,16 @@ "command": "vscode-sfdx-hardis.generatePackageXmlDoc", "when": "resourceExtname == '.xml'", "group": "z_sfdxhardis@10" + }, + { + "command": "vscode-sfdx-hardis.generateFlowDocumentation", + "when": "resourceExtname == '.xml'", + "group": "z_sfdxhardis@15" + }, + { + "command": "vscode-sfdx-hardis.flowVisualGitDiff", + "when": "resourceExtname == '.xml'", + "group": "z_sfdxhardis@20" } ], "view/title": [ @@ -335,6 +355,16 @@ "command": "vscode-sfdx-hardis.generatePackageXmlDoc", "when": "resourceExtname == '.xml'", "group": "z_sfdxhardis@10" + }, + { + "command": "vscode-sfdx-hardis.generateFlowDocumentation", + "when": "resourceExtname == '.xml'", + "group": "z_sfdxhardis@15" + }, + { + "command": "vscode-sfdx-hardis.flowVisualGitDiff", + "when": "resourceExtname == '.xml'", + "group": "z_sfdxhardis@20" } ], "view/item/context": [ diff --git a/src/commands.ts b/src/commands.ts index 41960c8..a292bf9 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -51,6 +51,8 @@ export class Commands { this.registerSelectExtensionTheme(); this.registerSimulateDeployment(); this.registerGeneratePackageXmlDoc(); + this.registerGenerateFlowDocumentation(); + this.registerGenerateFlowVisualGitDiff(); } getLatestTerminal() { @@ -451,6 +453,52 @@ export class Commands { this.disposables.push(disposable); } + registerGenerateFlowDocumentation() { + // Open external command + const disposable = vscode.commands.registerCommand( + "vscode-sfdx-hardis.generateFlowDocumentation", + async (uri: vscode.Uri) => { + const relativePath = vscode.workspace.asRelativePath(uri); + if (!relativePath.endsWith(".flow-meta.xml")) { + vscode.window.showWarningMessage( + "This command only works with Flow files :)", + ); + return; + } + const command = `sf hardis:doc:flow2markdown --inputfile "${relativePath}"`; + vscode.commands.executeCommand( + "vscode-sfdx-hardis.execute-command", + command, + ); + }, + ); + this.disposables.push(disposable); + } + + /* jscpd:ignore-start */ + registerGenerateFlowVisualGitDiff() { + // Open external command + const disposable = vscode.commands.registerCommand( + "vscode-sfdx-hardis.flowVisualGitDiff", + async (uri: vscode.Uri) => { + const relativePath = vscode.workspace.asRelativePath(uri); + if (!relativePath.endsWith(".flow-meta.xml")) { + vscode.window.showWarningMessage( + "This command only works with Flow files :)", + ); + return; + } + const command = `sf hardis:project:generate:flow-git-diff --flow "${relativePath}"`; + vscode.commands.executeCommand( + "vscode-sfdx-hardis.execute-command", + command, + ); + }, + ); + this.disposables.push(disposable); + } + /* jscpd:ignore-end */ + registerOpenKeyFile() { // Open key file command vscode.commands.registerCommand( diff --git a/src/hardis-commands-provider.ts b/src/hardis-commands-provider.ts index cfad3bd..fe2e5ec 100644 --- a/src/hardis-commands-provider.ts +++ b/src/hardis-commands-provider.ts @@ -539,16 +539,6 @@ export class HardisCommandsProvider requiresProject: true, helpUrl: "https://sfdx-hardis.cloudity.com/hardis/org/test/apex/", }, - { - id: "hardis:doc:project2markdown", - label: "Generate Project Documentation", - command: "sf hardis:doc:project2markdown", - tooltip: - "Generates markdown pages with SF Project content: List of metadatas, installed packages...", - requiresProject: true, - helpUrl: - "https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/", - }, { id: "hardis:org:monitor:limits", label: "Check Org Limits", @@ -759,6 +749,71 @@ export class HardisCommandsProvider }, ], }, + { + id: "doc", + label: "Documentation Generation", + commands: [ + { + id: "hardis:doc:project2markdown", + label: "Generate Project Documentation", + command: "sf hardis:doc:project2markdown", + tooltip: + "Generates markdown pages with SF Project content: List of metadatas, installed packages...", + requiresProject: true, + helpUrl: + "https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/", + }, + { + id: "hardis:doc:project2markdown-history", + label: "Generate Project Documentation (with history)", + command: "sf hardis:doc:project2markdown --with-history", + tooltip: + "Generates markdown pages with SF Project content: List of metadatas, installed packages..., with Flow Diff History", + requiresProject: true, + helpUrl: + "https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/", + }, + { + id: "hardis:doc:flow2markdown", + label: "Generate Flow Documentation", + command: "sf hardis:doc:flow2markdown", + tooltip: "Generates Visual Documentation for a Flow", + requiresProject: true, + helpUrl: + "https://sfdx-hardis.cloudity.com/hardis/doc/flow2markdown/", + }, + { + id: "hardis-run-doc", + label: "Run Local HTML Doc Pages", + command: + "pip install mkdocs-material mdx_truly_sane_lists && mkdocs serve", + tooltip: + "Run Documentation local web server, then open http://127.0.0.1:8000/", + requiresProject: true, + helpUrl: + "https://sfdx-hardis.cloudity.com/salesforce-project-documentation/", + }, + { + id: "hardis:doc:flow2markdown-history", + label: "Generate Flow Documentation (with history)", + command: "sf hardis:doc:flow2markdown --with-history", + tooltip: "Generates Visual Documentation for a Flow", + requiresProject: true, + helpUrl: + "https://sfdx-hardis.cloudity.com/hardis/doc/flow2markdown/", + }, + { + id: "hardis:project:generate:flow-git-diff", + label: "Generate Flow Visual Git Diff", + command: "sf hardis:project:generate:flow-git-diff", + tooltip: + "Generates Visual Documentation of the differences between versions of a Flow", + requiresProject: true, + helpUrl: + "https://sfdx-hardis.cloudity.com/hardis/project/generate/flow-git-diff/", + }, + ], + }, { id: "nerdy-stuff", label: "Nerdy stuff", diff --git a/src/hardis-websocket-server.ts b/src/hardis-websocket-server.ts index 3e9b2ac..3ba9e21 100644 --- a/src/hardis-websocket-server.ts +++ b/src/hardis-websocket-server.ts @@ -100,6 +100,11 @@ export class LocalWebSocketServer { ); vscode.workspace.openTextDocument(openPath).then((doc) => { vscode.window.showTextDocument(doc); + if (data.file.endsWith(".md")) { + new Promise((resolve) => setTimeout(resolve, 500)).then(() => { + vscode.commands.executeCommand("markdown.showPreview", doc); + }); + } }); } // Request user input diff --git a/src/themeUtils.ts b/src/themeUtils.ts index f306c72..9df133f 100644 --- a/src/themeUtils.ts +++ b/src/themeUtils.ts @@ -245,6 +245,19 @@ export class ThemeUtils { hardis: "old.svg", }, "hardis:doc:project2markdown": { vscode: "book", hardis: "doc.svg" }, + "hardis:doc:project2markdown-history": { + vscode: "book", + hardis: "doc.svg", + }, + "hardis:doc:flow2markdown": { vscode: "git-branch", hardis: "doc.svg" }, + "hardis:doc:flow2markdown-history": { + vscode: "git-branch", + hardis: "doc.svg", + }, + "hardis:project:generate:flow-git-diff": { + vscode: "diff", + hardis: "doc.svg", + }, "hardis:org:monitor:limits": { vscode: "eye-watch", hardis: "gauge.svg" }, "org:diagnose:legacyapi": { vscode: "watch", hardis: "old.svg" }, "hardis:org:diagnose:unusedusers": {