nerdgram1337 1.3.0 → 1.4.0
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.
|
@@ -10,6 +10,11 @@ import puppeteer from "puppeteer";
|
|
|
10
10
|
// server/src/paths.ts
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
|
+
|
|
14
|
+
// server/src/instanceConfig.ts
|
|
15
|
+
var processStartDataDir = process.env.NERDGRAM_DATA_DIR?.trim() || null;
|
|
16
|
+
|
|
17
|
+
// server/src/paths.ts
|
|
13
18
|
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
19
|
var REPO_ROOT = path.resolve(__dirname, "../..");
|
|
15
20
|
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,8 @@ var BOOL_FLAGS = /* @__PURE__ */ new Set([
|
|
|
22
22
|
"copy-data",
|
|
23
23
|
"share-data",
|
|
24
24
|
"with-data",
|
|
25
|
-
"keep-data"
|
|
25
|
+
"keep-data",
|
|
26
|
+
"include-down"
|
|
26
27
|
]);
|
|
27
28
|
var HELP = `nerdgram \u2014 automation client for NerdGram1337
|
|
28
29
|
|
|
@@ -41,6 +42,8 @@ Usage
|
|
|
41
42
|
nerdgram repair-links [--dry-run] [--apply]
|
|
42
43
|
nerdgram generate --path Diagram.mmd --data data.csv
|
|
43
44
|
nerdgram generate --path Diagram.mmd --data neighbors.lldp --format lldp --local-device edge-sw
|
|
45
|
+
nerdgram generate --path Campus-L3.mmd --data campus.network.json --format network --view l3
|
|
46
|
+
nerdgram generate --path Campus-L2.mmd --data campus.network.json --format network --view l2 --group-by site
|
|
44
47
|
nerdgram refresh <path> [--data data.csv]
|
|
45
48
|
nerdgram diff <path> --from <id|name|current> [--to <id|name|current>] [--format md|json|svg]
|
|
46
49
|
nerdgram baseline <path> --name "\u2026" [--note "\u2026"] [--id <revision>]
|
|
@@ -51,9 +54,10 @@ A local .mmd file is rendered and linted in this process. Anything else uses
|
|
|
51
54
|
NERDGRAM_URL (default http://127.0.0.1:8787) and NERDGRAM_TOKEN.
|
|
52
55
|
--url and --token override those. --json prints one JSON object.
|
|
53
56
|
--server forces render to use the API. Exit status is 1 on errors.
|
|
54
|
-
Rename and move also move a CSV, JSON, CDP, or LLDP file that
|
|
55
|
-
diagram and update nerdgram.source. duplicate --copy-data
|
|
56
|
-
own data file. duplicate --share-data keeps both diagrams
|
|
57
|
+
Rename and move also move a CSV, JSON, network JSON, CDP, or LLDP file that
|
|
58
|
+
sits next to the diagram and update nerdgram.source. duplicate --copy-data
|
|
59
|
+
gives the copy its own data file. duplicate --share-data keeps both diagrams
|
|
60
|
+
on the original file.
|
|
57
61
|
delete --with-data moves that file to the trash with the diagram.
|
|
58
62
|
delete --keep-data leaves it in the workspace. When a data file is present and
|
|
59
63
|
the flag is omitted, duplicate and delete stop and list the file.
|
|
@@ -77,7 +81,7 @@ not changed. --undo restores that replace and skips a file edited since.
|
|
|
77
81
|
`;
|
|
78
82
|
var renderModule = null;
|
|
79
83
|
function loadRender() {
|
|
80
|
-
renderModule ??= import("./chunk-
|
|
84
|
+
renderModule ??= import("./chunk-4EOKHSPN.js");
|
|
81
85
|
return renderModule;
|
|
82
86
|
}
|
|
83
87
|
async function loadLint() {
|
|
@@ -429,19 +433,29 @@ async function generateCommand(parsed, io) {
|
|
|
429
433
|
const diagramPath = flagString(parsed.flags, "path") ?? parsed.positionals[0];
|
|
430
434
|
const dataFile = flagString(parsed.flags, "data");
|
|
431
435
|
if (!diagramPath || !dataFile) {
|
|
432
|
-
throw new CliError("generate needs --path Diagram.mmd and --data file.csv, file.json, file.cdp, or file.lldp.");
|
|
436
|
+
throw new CliError("generate needs --path Diagram.mmd and --data file.csv, file.json, file.network.json, file.cdp, or file.lldp.");
|
|
433
437
|
}
|
|
438
|
+
const format = flagString(parsed.flags, "format");
|
|
439
|
+
const view = flagString(parsed.flags, "view");
|
|
440
|
+
if (format === "network" && view !== "l3" && view !== "l2") {
|
|
441
|
+
throw new CliError("generate --format network needs --view l3 or --view l2.");
|
|
442
|
+
}
|
|
443
|
+
const vlanText = flagString(parsed.flags, "vlan");
|
|
444
|
+
if (vlanText != null && !/^\d+$/.test(vlanText)) throw new CliError("vlan must be an integer from 1 to 4094.");
|
|
434
445
|
const text = await fs.readFile(dataFile, "utf8");
|
|
435
446
|
const { base, token } = configOf(parsed.flags, io.env);
|
|
436
447
|
const result = await callApi(base, requireToken(token), "POST", "/api/v1/generate", {
|
|
437
448
|
path: diagramPath,
|
|
438
449
|
text,
|
|
439
|
-
format
|
|
450
|
+
format,
|
|
440
451
|
shape: flagString(parsed.flags, "shape"),
|
|
441
452
|
direction: flagString(parsed.flags, "direction"),
|
|
442
453
|
title: flagString(parsed.flags, "title"),
|
|
443
454
|
localDevice: flagString(parsed.flags, "local-device"),
|
|
444
|
-
groupBy: flagString(parsed.flags, "group-by")
|
|
455
|
+
groupBy: flagString(parsed.flags, "group-by"),
|
|
456
|
+
view,
|
|
457
|
+
...parsed.flags.get("include-down") === true ? { includeDown: true } : {},
|
|
458
|
+
...vlanText != null ? { vlan: Number(vlanText) } : {}
|
|
445
459
|
});
|
|
446
460
|
const body = result.json;
|
|
447
461
|
writeOut(io, isJson(parsed.flags), body, `Created ${body.path}${body.dataPath ? ` from ${body.dataPath}` : ""}`);
|