nerdgram1337 1.4.0 → 1.4.1
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 +1 -1
- package/dist/cli.js +41 -8
- package/package.json +2 -2
- /package/dist/{chunk-4EOKHSPN.js → chunk-YNM3RGIQ.js} +0 -0
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ nerdgram render Welcome.mmd -o Welcome.svg
|
|
|
45
45
|
|
|
46
46
|
The app still has to be reachable for every other command. NerdGram is a single-user app. The API is a tool port for programs you trust, not an always-on multi-user server. The browser routes have no token, so anyone who can reach the port can use them. The default URL is loopback. Point `NERDGRAM_URL` at another machine only when that machine has opened its Host setting to you.
|
|
47
47
|
|
|
48
|
-
The full command list
|
|
48
|
+
The full command list is in the [command-line tool](https://github.com/NetworkNerd1337/NerdGram1337/blob/main/docs/cli.md) page. Release notes are in the [changelog](https://github.com/NetworkNerd1337/NerdGram1337/blob/main/CHANGELOG.md).
|
|
49
49
|
|
|
50
50
|
## License
|
|
51
51
|
|
package/dist/cli.js
CHANGED
|
@@ -81,7 +81,7 @@ not changed. --undo restores that replace and skips a file edited since.
|
|
|
81
81
|
`;
|
|
82
82
|
var renderModule = null;
|
|
83
83
|
function loadRender() {
|
|
84
|
-
renderModule ??= import("./chunk-
|
|
84
|
+
renderModule ??= import("./chunk-YNM3RGIQ.js");
|
|
85
85
|
return renderModule;
|
|
86
86
|
}
|
|
87
87
|
async function loadLint() {
|
|
@@ -94,11 +94,35 @@ async function shutdownCli() {
|
|
|
94
94
|
}
|
|
95
95
|
var CliError = class extends Error {
|
|
96
96
|
status;
|
|
97
|
-
|
|
97
|
+
details;
|
|
98
|
+
constructor(message, status, details) {
|
|
98
99
|
super(message);
|
|
99
100
|
this.status = status;
|
|
101
|
+
this.details = details;
|
|
100
102
|
}
|
|
101
103
|
};
|
|
104
|
+
function formatRowIssues(errors) {
|
|
105
|
+
if (!Array.isArray(errors)) return [];
|
|
106
|
+
const lines = [];
|
|
107
|
+
for (const item of errors) {
|
|
108
|
+
if (!item || typeof item !== "object") continue;
|
|
109
|
+
const issue = item;
|
|
110
|
+
if (typeof issue.message !== "string" || !issue.message.trim()) continue;
|
|
111
|
+
const message = issue.message.trim();
|
|
112
|
+
const field = typeof issue.path === "string" ? issue.path.trim() : "";
|
|
113
|
+
if (field && !message.includes(field)) {
|
|
114
|
+
lines.push(`${field}: ${message}`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const row = typeof issue.row === "number" ? issue.row : 0;
|
|
118
|
+
if (row > 0 && !message.toLowerCase().includes(`row ${row}`)) {
|
|
119
|
+
lines.push(`row ${row}: ${message}`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
lines.push(message);
|
|
123
|
+
}
|
|
124
|
+
return lines;
|
|
125
|
+
}
|
|
102
126
|
function parseArgs(argv) {
|
|
103
127
|
const flags = /* @__PURE__ */ new Map();
|
|
104
128
|
const positionals = [];
|
|
@@ -188,8 +212,11 @@ async function callApi(base, token, method, apiPath, body) {
|
|
|
188
212
|
}
|
|
189
213
|
if (!response.ok) {
|
|
190
214
|
const record = json && typeof json === "object" ? json : {};
|
|
191
|
-
const
|
|
192
|
-
|
|
215
|
+
const summary = typeof record.error === "string" ? record.error : `Request failed (${response.status})`;
|
|
216
|
+
const rows = formatRowIssues(record.errors);
|
|
217
|
+
const message = rows.length > 0 ? `${summary}
|
|
218
|
+
${rows.join("\n")}` : summary;
|
|
219
|
+
throw new CliError(message, response.status, record);
|
|
193
220
|
}
|
|
194
221
|
return { status: response.status, json, bytes, contentType };
|
|
195
222
|
}
|
|
@@ -427,7 +454,8 @@ async function deleteCommand(parsed, io) {
|
|
|
427
454
|
...keepData ? { deleteData: false } : {}
|
|
428
455
|
});
|
|
429
456
|
const body = result.json;
|
|
430
|
-
|
|
457
|
+
const kept = body.message ? ` ${body.message}` : "";
|
|
458
|
+
writeOut(io, isJson(parsed.flags), body, `Moved ${body.path ?? itemPath} to the trash.${kept}`);
|
|
431
459
|
}
|
|
432
460
|
async function generateCommand(parsed, io) {
|
|
433
461
|
const diagramPath = flagString(parsed.flags, "path") ?? parsed.positionals[0];
|
|
@@ -707,9 +735,13 @@ async function main(argv, io = {}) {
|
|
|
707
735
|
} catch (err) {
|
|
708
736
|
const message = err instanceof Error ? err.message : String(err);
|
|
709
737
|
const status = err instanceof CliError ? err.status : void 0;
|
|
710
|
-
if (isJson(parsed.flags))
|
|
711
|
-
|
|
712
|
-
|
|
738
|
+
if (isJson(parsed.flags)) {
|
|
739
|
+
const errors = err instanceof CliError && Array.isArray(err.details?.errors) ? err.details.errors : void 0;
|
|
740
|
+
streams.stdout(
|
|
741
|
+
`${JSON.stringify({ ok: false, error: message, status: status ?? null, ...errors ? { errors } : {} })}
|
|
742
|
+
`
|
|
743
|
+
);
|
|
744
|
+
} else streams.stderr(`${message}
|
|
713
745
|
`);
|
|
714
746
|
return 1;
|
|
715
747
|
}
|
|
@@ -732,6 +764,7 @@ if (isDirectRun()) {
|
|
|
732
764
|
});
|
|
733
765
|
}
|
|
734
766
|
export {
|
|
767
|
+
formatRowIssues,
|
|
735
768
|
main,
|
|
736
769
|
shutdownCli
|
|
737
770
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nerdgram1337",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Command-line client for a local NerdGram1337 server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"url": "git+https://github.com/NetworkNerd1337/NerdGram1337.git",
|
|
24
24
|
"directory": "cli"
|
|
25
25
|
},
|
|
26
|
-
"homepage": "https://github.com/NetworkNerd1337/NerdGram1337
|
|
26
|
+
"homepage": "https://github.com/NetworkNerd1337/NerdGram1337/blob/main/docs/cli.md",
|
|
27
27
|
"bugs": {
|
|
28
28
|
"url": "https://github.com/NetworkNerd1337/NerdGram1337/issues"
|
|
29
29
|
},
|
|
File without changes
|