Fix gen-workflow-mermaid to be compatible with Node 22.18+ (#31250)
* Fix gen-workflow-mermaid to be compatible with Node 22.18+ Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import path from "node:path";
|
|||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
import parseArgs from "minimist";
|
import parseArgs from "minimist";
|
||||||
import cronstrue from "cronstrue";
|
import cronstrue from "cronstrue";
|
||||||
import { partition } from "lodash";
|
import _ from "lodash";
|
||||||
|
|
||||||
const argv = parseArgs<{
|
const argv = parseArgs<{
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
@@ -81,7 +81,7 @@ class Graph<T extends Node> {
|
|||||||
public removeNode(node: T): Edge<T>[] {
|
public removeNode(node: T): Edge<T>[] {
|
||||||
if (!this.nodes.has(node.id)) return [];
|
if (!this.nodes.has(node.id)) return [];
|
||||||
this.nodes.delete(node.id);
|
this.nodes.delete(node.id);
|
||||||
const [removedEdges, keptEdges] = partition(
|
const [removedEdges, keptEdges] = _.partition(
|
||||||
this.edges,
|
this.edges,
|
||||||
([source, destination]) => source === node || destination === node,
|
([source, destination]) => source === node || destination === node,
|
||||||
);
|
);
|
||||||
@@ -384,6 +384,7 @@ class MermaidFlowchartPrinter {
|
|||||||
private static INDENT = 4;
|
private static INDENT = 4;
|
||||||
private currentIndent = 0;
|
private currentIndent = 0;
|
||||||
private text = "";
|
private text = "";
|
||||||
|
private readonly markdown: boolean;
|
||||||
public readonly idGenerator = new IdGenerator();
|
public readonly idGenerator = new IdGenerator();
|
||||||
|
|
||||||
private print(text: string): void {
|
private print(text: string): void {
|
||||||
@@ -400,11 +401,8 @@ class MermaidFlowchartPrinter {
|
|||||||
this.currentIndent += delta * MermaidFlowchartPrinter.INDENT;
|
this.currentIndent += delta * MermaidFlowchartPrinter.INDENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public constructor(
|
public constructor(direction: "TD" | "TB" | "BT" | "RL" | "LR", title?: string, markdown = false) {
|
||||||
direction: "TD" | "TB" | "BT" | "RL" | "LR",
|
this.markdown = markdown;
|
||||||
title?: string,
|
|
||||||
private readonly markdown = false,
|
|
||||||
) {
|
|
||||||
if (this.markdown) {
|
if (this.markdown) {
|
||||||
this.print("```mermaid");
|
this.print("```mermaid");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user