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:
Michael Telatynski
2025-11-17 10:33:45 +00:00
committed by GitHub
parent 81f1841aea
commit 3d683ec5c6

View File

@@ -5,7 +5,7 @@ import path from "node:path";
import YAML from "yaml";
import parseArgs from "minimist";
import cronstrue from "cronstrue";
import { partition } from "lodash";
import _ from "lodash";
const argv = parseArgs<{
debug: boolean;
@@ -81,7 +81,7 @@ class Graph<T extends Node> {
public removeNode(node: T): Edge<T>[] {
if (!this.nodes.has(node.id)) return [];
this.nodes.delete(node.id);
const [removedEdges, keptEdges] = partition(
const [removedEdges, keptEdges] = _.partition(
this.edges,
([source, destination]) => source === node || destination === node,
);
@@ -384,6 +384,7 @@ class MermaidFlowchartPrinter {
private static INDENT = 4;
private currentIndent = 0;
private text = "";
private readonly markdown: boolean;
public readonly idGenerator = new IdGenerator();
private print(text: string): void {
@@ -400,11 +401,8 @@ class MermaidFlowchartPrinter {
this.currentIndent += delta * MermaidFlowchartPrinter.INDENT;
}
public constructor(
direction: "TD" | "TB" | "BT" | "RL" | "LR",
title?: string,
private readonly markdown = false,
) {
public constructor(direction: "TD" | "TB" | "BT" | "RL" | "LR", title?: string, markdown = false) {
this.markdown = markdown;
if (this.markdown) {
this.print("```mermaid");
}