nerdgram1337 1.6.0 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{chunk-AWVTRON2.js → chunk-53YCVNDJ.js} +3 -2
- package/dist/chunk-5IHMGYXV.js +78 -0
- package/dist/{chunk-JL7RYIQE.js → chunk-6ELR2KYA.js} +463 -2
- package/dist/{chunk-LXSDAIF4.js → chunk-7GEA3JEU.js} +4 -2
- package/dist/{chunk-5C6VO4LC.js → chunk-BW6ANOTX.js} +38 -0
- package/dist/chunk-GDPSIPXV.js +3389 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/{chunk-BCO66AYP.js → chunk-P666JXDB.js} +1 -0
- package/dist/{chunk-LYMG57VV.js → chunk-R3RZTEM3.js} +3 -2
- package/dist/{chunk-FIAVRIHI.js → chunk-RB3SBRHP.js} +22 -3
- package/dist/cli.js +55 -5
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildTree,
|
|
3
3
|
readFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6ELR2KYA.js";
|
|
5
5
|
import {
|
|
6
6
|
atomicWriteJson,
|
|
7
7
|
getDataRoot,
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
readJsonFile,
|
|
11
11
|
rewriteMovedPath
|
|
12
12
|
} from "./chunk-KA5X3YY6.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-BW6ANOTX.js";
|
|
14
14
|
import {
|
|
15
15
|
literalLocator,
|
|
16
16
|
matchDiagramSearch,
|
|
17
17
|
parseDiagram,
|
|
18
18
|
searchMatchLabel
|
|
19
19
|
} from "./chunk-6LCHDAAN.js";
|
|
20
|
+
import "./chunk-MLKGABMK.js";
|
|
20
21
|
|
|
21
22
|
// server/src/search.ts
|
|
22
23
|
import path from "node:path";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isDiagramLink,
|
|
8
8
|
parseClickLine,
|
|
9
9
|
resolveDiagramTarget
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BW6ANOTX.js";
|
|
11
11
|
import {
|
|
12
12
|
ELK_NODE_PLACEMENTS,
|
|
13
13
|
FLOWCHART_CURVES,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
matchFrontMatter,
|
|
19
19
|
parseDiagram
|
|
20
20
|
} from "./chunk-6LCHDAAN.js";
|
|
21
|
+
import "./chunk-MLKGABMK.js";
|
|
21
22
|
|
|
22
23
|
// server/src/mermaidSyntax.ts
|
|
23
24
|
import mermaid from "mermaid";
|
|
@@ -1925,6 +1926,24 @@ function escapeRegExp(value) {
|
|
|
1925
1926
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1926
1927
|
}
|
|
1927
1928
|
|
|
1929
|
+
// server/src/warningMute.ts
|
|
1930
|
+
var DIRECTIVE = /^[ \t]*%%[ \t]*nerdgram:[ \t]*warnings[ \t]*=[ \t]*muted[ \t]*$/;
|
|
1931
|
+
function warningsMuted(source) {
|
|
1932
|
+
return splitSource(source).lines.some((line) => DIRECTIVE.test(line));
|
|
1933
|
+
}
|
|
1934
|
+
function omitMutedWarnings(source, diagnostics) {
|
|
1935
|
+
if (!warningsMuted(source)) return [...diagnostics];
|
|
1936
|
+
return diagnostics.filter((item) => item.severity !== "warning");
|
|
1937
|
+
}
|
|
1938
|
+
function splitSource(source) {
|
|
1939
|
+
const ending = source.includes("\r\n") ? "\r\n" : "\n";
|
|
1940
|
+
const trailing = source.endsWith("\n");
|
|
1941
|
+
if (source.length === 0) return { lines: [], ending, trailing: false };
|
|
1942
|
+
const parts = source.split(/\r?\n/);
|
|
1943
|
+
if (trailing) parts.pop();
|
|
1944
|
+
return { lines: parts, ending, trailing };
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1928
1947
|
// server/src/mermaidSyntax.ts
|
|
1929
1948
|
async function mermaidSyntaxDiagnostic(source) {
|
|
1930
1949
|
if (!source.trim()) return null;
|
|
@@ -1953,10 +1972,10 @@ async function mermaidSyntaxDiagnostic(source) {
|
|
|
1953
1972
|
async function lintDiagramSource(source, options = {}) {
|
|
1954
1973
|
const diagnostics = lintDiagram(source, options);
|
|
1955
1974
|
const syntax = await mermaidSyntaxDiagnostic(source);
|
|
1956
|
-
|
|
1957
|
-
return [...diagnostics, syntax].sort(
|
|
1975
|
+
const combined = !syntax ? diagnostics : [...diagnostics, syntax].sort(
|
|
1958
1976
|
(a, b) => a.from - b.from || a.line - b.line || String(a.ruleId).localeCompare(String(b.ruleId))
|
|
1959
1977
|
);
|
|
1978
|
+
return omitMutedWarnings(source, combined);
|
|
1960
1979
|
}
|
|
1961
1980
|
export {
|
|
1962
1981
|
lintDiagramSource,
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import "./chunk-MLKGABMK.js";
|
|
2
3
|
|
|
3
4
|
// server/src/cli.ts
|
|
4
5
|
import { readFileSync } from "node:fs";
|
|
@@ -48,13 +49,15 @@ Usage
|
|
|
48
49
|
nerdgram generate --path Diagram.mmd --data neighbors.lldp --format lldp --local-device edge-sw
|
|
49
50
|
nerdgram generate --path Campus-L3.mmd --data campus.network.json --format network --view l3
|
|
50
51
|
nerdgram generate --path Campus-L2.mmd --data campus.network.json --format network --view l2 --group-by site
|
|
52
|
+
nerdgram convert <source> [file] [-o out.network.json]
|
|
51
53
|
nerdgram refresh <path> [--data data.csv]
|
|
52
54
|
nerdgram diff <path> --from <id|name|current> [--to <id|name|current>] [--format md|json|svg]
|
|
53
55
|
nerdgram baseline <path> --name "\u2026" [--note "\u2026"] [--id <revision>]
|
|
54
56
|
nerdgram replace <find> <replace> [--folder path] [--regex] [--whole-word] [--match-case] [--front-matter] [--no-recursive] [--dry-run] [--yes]
|
|
55
57
|
nerdgram replace --undo <id>
|
|
56
58
|
|
|
57
|
-
A local .mmd file is rendered and linted in this process.
|
|
59
|
+
A local .mmd file is rendered and linted in this process. convert reads a
|
|
60
|
+
saved export and writes canonical network JSON in this process. Anything else uses
|
|
58
61
|
NERDGRAM_URL (default http://127.0.0.1:8787) and NERDGRAM_TOKEN.
|
|
59
62
|
--url and --token override those. --server forces render to use a workspace
|
|
60
63
|
path on the API, not a file on this computer. Exit status is 1 on errors.
|
|
@@ -112,16 +115,16 @@ not changed. --undo restores that replace and skips a file edited since.
|
|
|
112
115
|
`;
|
|
113
116
|
var renderModule = null;
|
|
114
117
|
function loadRender() {
|
|
115
|
-
renderModule ??= import("./chunk-
|
|
118
|
+
renderModule ??= import("./chunk-P666JXDB.js");
|
|
116
119
|
return renderModule;
|
|
117
120
|
}
|
|
118
121
|
async function loadLint() {
|
|
119
|
-
return import("./chunk-
|
|
122
|
+
return import("./chunk-RB3SBRHP.js");
|
|
120
123
|
}
|
|
121
124
|
async function templateCommand(parsed, io) {
|
|
122
125
|
const sub = parsed.positionals[0] ?? "";
|
|
123
126
|
const target = parsed.positionals[1] ?? "";
|
|
124
|
-
const templates = await import("./chunk-
|
|
127
|
+
const templates = await import("./chunk-53YCVNDJ.js");
|
|
125
128
|
try {
|
|
126
129
|
if (sub === "save") {
|
|
127
130
|
if (!target) throw new CliError("Usage: nerdgram template save <diagram> [--name name] [--replace]");
|
|
@@ -771,11 +774,55 @@ async function refreshCommand(parsed, io) {
|
|
|
771
774
|
const body = result.json;
|
|
772
775
|
writeOut(io, isJson(parsed.flags), body, `Refreshed ${body.path}`);
|
|
773
776
|
}
|
|
777
|
+
async function readStdin() {
|
|
778
|
+
const chunks = [];
|
|
779
|
+
for await (const chunk of process.stdin) {
|
|
780
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
781
|
+
}
|
|
782
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
783
|
+
}
|
|
784
|
+
async function convertCommand(parsed, io) {
|
|
785
|
+
const translators = await import("./chunk-GDPSIPXV.js");
|
|
786
|
+
const source = parsed.positionals[0] ?? "";
|
|
787
|
+
if (!source) {
|
|
788
|
+
const installed = await translators.installedTranslators();
|
|
789
|
+
const ids = installed.map((item) => item.id).join(", ") || "(none)";
|
|
790
|
+
throw new CliError(`Usage: nerdgram convert <source> [file] [-o out.network.json]
|
|
791
|
+
Installed translators: ${ids}`);
|
|
792
|
+
}
|
|
793
|
+
const file = parsed.positionals[1];
|
|
794
|
+
let text;
|
|
795
|
+
if (file && file !== "-") text = await fs.readFile(file, "utf8");
|
|
796
|
+
else if (io.stdin != null) text = io.stdin;
|
|
797
|
+
else if (process.stdin.isTTY) throw new CliError("convert needs a file or stdin.");
|
|
798
|
+
else text = await readStdin();
|
|
799
|
+
translators.assertConvertInputSize(Buffer.byteLength(text));
|
|
800
|
+
const converted = await translators.convertExport(source, translators.parseExport(text));
|
|
801
|
+
const pretty = `${JSON.stringify(converted.document, null, 2)}
|
|
802
|
+
`;
|
|
803
|
+
const output = flagString(parsed.flags, "output");
|
|
804
|
+
if (output) await fs.writeFile(output, pretty, "utf8");
|
|
805
|
+
const warningLines = converted.warnings.map((item) => item.path ? `${item.path}: ${item.message}` : item.message);
|
|
806
|
+
if (!isJson(parsed.flags) && warningLines.length > 0) io.stderr(`${warningLines.join("\n")}
|
|
807
|
+
`);
|
|
808
|
+
if (isJson(parsed.flags)) {
|
|
809
|
+
const payload = output ? { source: converted.source, output, warnings: converted.warnings, bytes: Buffer.byteLength(pretty) } : { source: converted.source, document: converted.document, warnings: converted.warnings };
|
|
810
|
+
writeOut(io, true, payload, "");
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
if (output) {
|
|
814
|
+
io.stdout(`Wrote ${output}
|
|
815
|
+
`);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
io.stdout(pretty);
|
|
819
|
+
}
|
|
774
820
|
async function main(argv, io = {}) {
|
|
775
821
|
const streams = {
|
|
776
822
|
stdout: io.stdout ?? ((chunk) => process.stdout.write(chunk)),
|
|
777
823
|
stderr: io.stderr ?? ((chunk) => process.stderr.write(chunk)),
|
|
778
|
-
env: io.env ?? process.env
|
|
824
|
+
env: io.env ?? process.env,
|
|
825
|
+
stdin: io.stdin
|
|
779
826
|
};
|
|
780
827
|
let parsed;
|
|
781
828
|
try {
|
|
@@ -835,6 +882,9 @@ async function main(argv, io = {}) {
|
|
|
835
882
|
case "generate":
|
|
836
883
|
await generateCommand(parsed, streams);
|
|
837
884
|
return 0;
|
|
885
|
+
case "convert":
|
|
886
|
+
await convertCommand(parsed, streams);
|
|
887
|
+
return 0;
|
|
838
888
|
case "refresh":
|
|
839
889
|
await refreshCommand(parsed, streams);
|
|
840
890
|
return 0;
|