@mason-data/cli 0.7.0 → 0.9.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.
- package/README.md +101 -73
- package/dist/src/api/error.js +3 -0
- package/dist/src/api/postgres/catalog-worker.js +49 -2
- package/dist/src/api/postgres/catalog.js +368 -25
- package/dist/src/api/postgres/encode.js +3 -1
- package/dist/src/api/postgres/explain.js +3 -2
- package/dist/src/api/postgres/listener.js +11 -3
- package/dist/src/api/postgres/protocol.js +39 -23
- package/dist/src/api/postgres/proxy.js +283 -0
- package/dist/src/api/postgres/schema.js +6 -0
- package/dist/src/api/postgres/server.js +1617 -245
- package/dist/src/api/postgres/translate.js +127 -10
- package/dist/src/api/request-log.js +18 -5
- package/dist/src/cdc/poll.js +5 -5
- package/dist/src/cli/background.js +47 -25
- package/dist/src/cli/bridge-stdin.js +101 -0
- package/dist/src/cli/cancel.js +75 -0
- package/dist/src/cli/command.js +170 -11
- package/dist/src/cli/commands.js +804 -209
- package/dist/src/cli/control.js +59 -0
- package/dist/src/cli/credentials.js +182 -0
- package/dist/src/cli/demo.js +20 -11
- package/dist/src/cli/deploy.js +574 -0
- package/dist/src/cli/dev.js +491 -130
- package/dist/src/cli/doctor.js +131 -38
- package/dist/src/cli/generated-files.js +143 -0
- package/dist/src/cli/guides.js +175 -36
- package/dist/src/cli/hosted.js +850 -0
- package/dist/src/cli/init.js +162 -65
- package/dist/src/cli/login.js +289 -0
- package/dist/src/cli/machine.js +13 -12
- package/dist/src/cli/main.js +11 -5
- package/dist/src/cli/mason.cjs +17 -0
- package/dist/src/cli/mcp.js +31 -22
- package/dist/src/cli/metrics.js +79 -0
- package/dist/src/cli/output-gate.js +176 -0
- package/dist/src/cli/page-share.js +96 -0
- package/dist/src/cli/pg-tls.js +14 -4
- package/dist/src/cli/pg-url.js +4 -0
- package/dist/src/cli/pin.js +19 -14
- package/dist/src/cli/pool-size.cjs +85 -0
- package/dist/src/cli/ports.js +2 -0
- package/dist/src/cli/preflight.js +138 -46
- package/dist/src/cli/project.js +142 -4
- package/dist/src/cli/readiness.js +76 -6
- package/dist/src/cli/registry.js +65 -38
- package/dist/src/cli/replica-hosted.js +665 -0
- package/dist/src/cli/replica.js +76 -0
- package/dist/src/cli/replication-checks.js +7 -5
- package/dist/src/cli/replication-mode.js +105 -26
- package/dist/src/cli/request-filter.js +134 -0
- package/dist/src/cli/roles.js +585 -0
- package/dist/src/cli/run-server.js +637 -48
- package/dist/src/cli/runs.js +1 -1
- package/dist/src/cli/security.js +67 -18
- package/dist/src/cli/serve.js +204 -46
- package/dist/src/cli/share-run.js +329 -0
- package/dist/src/cli/share.js +286 -0
- package/dist/src/cli/source-edit.js +75 -17
- package/dist/src/cli/source-role.js +344 -0
- package/dist/src/cli/sources.js +306 -47
- package/dist/src/cli/style.js +2 -1
- package/dist/src/cli/supervise.js +27 -24
- package/dist/src/cli/sync.js +55 -25
- package/dist/src/cli/token-hosted.js +337 -0
- package/dist/src/cli/tunnel.js +200 -0
- package/dist/src/cli/ui-ssh.js +460 -0
- package/dist/src/cli/ui.js +124 -17
- package/dist/src/cli/usage.js +128 -0
- package/dist/src/cli/user-hosted.js +299 -0
- package/dist/src/cli/user.js +573 -65
- package/dist/src/cli/version.js +9 -7
- package/dist/src/demo/seed.js +29 -0
- package/dist/src/duck/analyze.js +36 -20
- package/dist/src/duck/cancel.js +10 -1
- package/dist/src/duck/collation.js +266 -0
- package/dist/src/duck/constant-key.js +94 -0
- package/dist/src/duck/distinct-key.js +283 -26
- package/dist/src/duck/events.js +165 -0
- package/dist/src/duck/executor-worker.js +20 -11
- package/dist/src/duck/executor.js +47 -33
- package/dist/src/duck/explain.js +60 -46
- package/dist/src/duck/extensions.js +160 -0
- package/dist/src/duck/functions.js +461 -63
- package/dist/src/duck/gaps.js +48 -21
- package/dist/src/duck/generated-plan.js +1070 -0
- package/dist/src/duck/generated.js +906 -0
- package/dist/src/duck/grants.js +176 -0
- package/dist/src/duck/held-types.js +64 -0
- package/dist/src/duck/history.js +127 -0
- package/dist/src/duck/jsonb-order.js +9 -12
- package/dist/src/duck/kept-route.js +6 -5
- package/dist/src/duck/kept.js +15 -13
- package/dist/src/duck/late.js +1469 -40
- package/dist/src/duck/libc-bound.js +341 -0
- package/dist/src/duck/libc-order.js +892 -126
- package/dist/src/duck/pg-eval-worker.js +7 -1
- package/dist/src/duck/pg-eval.js +6 -4
- package/dist/src/duck/pgtree.js +774 -23
- package/dist/src/duck/plan.js +369 -47
- package/dist/src/duck/publication.js +20 -6
- package/dist/src/duck/requests.js +269 -93
- package/dist/src/duck/resolved.js +117 -2
- package/dist/src/duck/rewrite.js +4584 -580
- package/dist/src/duck/row-filter.js +655 -0
- package/dist/src/duck/statement.js +19 -0
- package/dist/src/duck/store.js +439 -177
- package/dist/src/duck/stream.js +19 -10
- package/dist/src/duck/sync.js +1411 -368
- package/dist/src/duck/token.js +4 -1
- package/dist/src/duck/types.js +69 -12
- package/dist/src/duck/usage.js +326 -0
- package/dist/src/duck/users.js +69 -15
- package/dist/src/duck/verified.js +161 -1
- package/dist/src/duck/views.js +5 -5
- package/dist/src/lib/database-name.js +62 -0
- package/dist/src/lib/database-url.js +55 -10
- package/dist/src/lib/dotenv.js +17 -4
- package/dist/src/lib/instant.js +50 -0
- package/dist/src/lib/log-buffer.js +77 -0
- package/dist/src/lib/log-read.js +196 -0
- package/dist/src/lib/pg-numeric.js +390 -49
- package/dist/src/lib/project-version.js +23 -23
- package/dist/src/lib/secret-mask.js +142 -0
- package/dist/src/lib/table-sync.js +282 -0
- package/dist/src/web/app.css +706 -66
- package/dist/src/web/app.js +331 -409
- package/dist/src/web/charts.js +229 -0
- package/dist/src/web/index.html +82 -18
- package/dist/src/web/pages/queries.js +192 -0
- package/dist/src/web/pages/status.js +611 -0
- package/dist/src/web/pages/syncs.js +155 -0
- package/dist/src/web/pages/tables.js +439 -0
- package/dist/src/web/pages/usage.js +397 -0
- package/dist/src/web/pages/users.js +219 -0
- package/dist/src/web/shared.js +584 -0
- package/dist/src/web/vendor/README.md +25 -0
- package/dist/src/web/vendor/geist-1.7.2/Geist-Variable.woff2 +0 -0
- package/dist/src/web/vendor/geist-1.7.2/GeistMono-Variable.woff2 +0 -0
- package/dist/src/web/vendor/geist-1.7.2/LICENSE.txt +92 -0
- package/dist/src/web/vendor/lucide-1.56.0/LICENSE.txt +43 -0
- package/dist/src/web/vendor/lucide-1.56.0/chart-column.mjs +29 -0
- package/dist/src/web/vendor/lucide-1.56.0/layout-dashboard.mjs +29 -0
- package/dist/src/web/vendor/lucide-1.56.0/logs.mjs +34 -0
- package/dist/src/web/vendor/lucide-1.56.0/menu.mjs +28 -0
- package/dist/src/web/vendor/lucide-1.56.0/square-terminal.mjs +28 -0
- package/dist/src/web/vendor/lucide-1.56.0/table.mjs +29 -0
- package/dist/src/web/vendor/lucide-1.56.0/users.mjs +29 -0
- package/dist/src/web/vendor/lucide-1.56.0/x.mjs +27 -0
- package/dist/src/web/vendor/uplot-1.6.32/LICENSE.txt +21 -0
- package/dist/src/web/vendor/uplot-1.6.32/uPlot.esm.js +6140 -0
- package/dist/src/web/vendor/uplot-1.6.32/uPlot.min.css +1 -0
- package/dist/src/web/vendor/zilla-slab-5.3.0/LICENSE.txt +93 -0
- package/dist/src/web/vendor/zilla-slab-5.3.0/zilla-slab-latin-700-normal.woff2 +0 -0
- package/package.json +12 -4
package/dist/src/cli/command.js
CHANGED
|
@@ -13,6 +13,159 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { parseArgs } from "node:util";
|
|
15
15
|
import { err as styleErr, out as styleOut, PLAIN, wrap } from "./style.js";
|
|
16
|
+
/**
|
|
17
|
+
* A LINE THAT HOLDS A HOSTED SERVICE'S TEXT IS BROKEN BY THE CLI, NEVER BY THE TERMINAL, AT EVERY WIDTH (PR 481's
|
|
18
|
+
* class rounds: a value sized to the terminal's width made the terminal start a visual line at column 0 with a forged
|
|
19
|
+
* `Next` heading, a step or a row; then the same under 40 columns, where no style wraps). src/cli/hosted.ts makes every
|
|
20
|
+
* value one line with no run of spaces (`serviceText`); the style a command gives its output when that output holds
|
|
21
|
+
* such a value (`serviceStyle`) makes every renderer here break every line it writes, at the terminal's own width
|
|
22
|
+
* (`Style.columns`, read when the output is drawn, whatever it is), so no line ever reaches the terminal's edge:
|
|
23
|
+
*
|
|
24
|
+
* - a line takes at most width - 1 columns (one column at width 1), a character outside ASCII counted as two;
|
|
25
|
+
* - it breaks at a space where one is in reach, else within the word; the headline, a row's label and a step's
|
|
26
|
+
* command are broken as any text is (`strictLines`, the last pass of every renderer: `strict`);
|
|
27
|
+
* - every continuation starts at `continuationAt(width)`: CONTINUATION (4) wherever the width leaves 4 columns after
|
|
28
|
+
* it, else 1 (3 to 8 columns), else 0 (1 or 2 columns, where one character is a line). The CLI's own lines start at
|
|
29
|
+
* 0 (a heading, a failure, a tip) or 2 (a row, a step), never at 1 or 4, so a continuation can never be taken for
|
|
30
|
+
* one; at 1 or 2 columns nothing the CLI starts a line with fits in a line, so none can be forged either;
|
|
31
|
+
* - a value's own column (a row's, a step's description) is kept while it leaves `MIN_ROOM` columns, else its lines
|
|
32
|
+
* continue at continuationAt(width), never one character a line under an indent wider than the terminal.
|
|
33
|
+
*
|
|
34
|
+
* So what a person sees begin a line is always the CLI's own. A pipe, a file and `--json` are unwrapped as ever (no
|
|
35
|
+
* terminal width): what an agent parses never changes.
|
|
36
|
+
*/
|
|
37
|
+
export const CONTINUATION = 4;
|
|
38
|
+
/** The fewest columns a value's own column must leave it before its lines continue there. */
|
|
39
|
+
const MIN_ROOM = 12;
|
|
40
|
+
export const serviceStyle = (s) => ({ ...s, untrusted: true });
|
|
41
|
+
/** The columns a word takes, counted so a line never takes more than the terminal has: a character outside ASCII as two. */
|
|
42
|
+
const columns = (w) => { let n = 0; for (const ch of w)
|
|
43
|
+
n += ch.codePointAt(0) <= 0x7e ? 1 : 2; return n; };
|
|
44
|
+
/** Where a continuation starts on a terminal `width` columns wide (above). */
|
|
45
|
+
export const continuationAt = (width) => lineLimit(width) - CONTINUATION >= 4 ? CONTINUATION : width >= 3 ? 1 : 0;
|
|
46
|
+
/** The most columns one line may take on a terminal `width` wide: one short of its edge, never none. */
|
|
47
|
+
const lineLimit = (width) => Math.max(1, width - 1);
|
|
48
|
+
/** The terminal width a style that holds a service's text breaks at; null when it is no terminal (or holds none). */
|
|
49
|
+
const strictWidth = (s) => s.untrusted ? s.columns ?? s.width : null;
|
|
50
|
+
/** `text` broken at `width` as `serviceStyle` asks (above), its first line after `firstUsed` columns of prefix: every
|
|
51
|
+
* line within the limit, a long word broken within, every line after the first at `indent` while that leaves MIN_ROOM,
|
|
52
|
+
* else at continuationAt(width). */
|
|
53
|
+
export function strictWrap(text, width, indent, firstUsed) {
|
|
54
|
+
const limit = lineLimit(width);
|
|
55
|
+
const cont = Math.max(indent, CONTINUATION) + MIN_ROOM <= limit ? Math.max(indent, CONTINUATION) : continuationAt(width);
|
|
56
|
+
const lines = [];
|
|
57
|
+
let line = "", taken = 0, used = firstUsed;
|
|
58
|
+
const room = () => Math.max(1, limit - used);
|
|
59
|
+
const breakLine = () => { lines.push(line); line = ""; taken = 0; used = cont; };
|
|
60
|
+
// a prefix that leaves no room: the text starts on the next line
|
|
61
|
+
if (limit - used < 1)
|
|
62
|
+
breakLine();
|
|
63
|
+
for (const word of text.split(" ")) {
|
|
64
|
+
if (word === "")
|
|
65
|
+
continue;
|
|
66
|
+
const wc = columns(word);
|
|
67
|
+
if (line && taken + 1 + wc <= room()) {
|
|
68
|
+
line += ` ${word}`;
|
|
69
|
+
taken += 1 + wc;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (line)
|
|
73
|
+
breakLine();
|
|
74
|
+
if (wc <= room()) {
|
|
75
|
+
line = word;
|
|
76
|
+
taken = wc;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
for (const ch of word) {
|
|
80
|
+
const cc = columns(ch);
|
|
81
|
+
if (taken + cc > room() && line)
|
|
82
|
+
breakLine();
|
|
83
|
+
line += ch;
|
|
84
|
+
taken += cc;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
lines.push(line);
|
|
88
|
+
return lines.join(`\n${" ".repeat(cont)}`);
|
|
89
|
+
}
|
|
90
|
+
/** A colour code, which takes no column. */
|
|
91
|
+
const SGR = /^\x1b\[[0-9;]*m/;
|
|
92
|
+
/**
|
|
93
|
+
* THE LAST PASS OF EVERY RENDERER under serviceStyle: each line of `text` that would reach the terminal's edge broken
|
|
94
|
+
* (above) — at its last space in reach, else within a word — its continuations at continuationAt(width), its colour codes
|
|
95
|
+
* taking no column and never split. A line within the limit is left as it is.
|
|
96
|
+
*/
|
|
97
|
+
export function strictLines(text, width) {
|
|
98
|
+
const limit = lineLimit(width), cont = continuationAt(width);
|
|
99
|
+
const out = [];
|
|
100
|
+
for (const whole of text.split("\n")) {
|
|
101
|
+
const tokens = [];
|
|
102
|
+
for (let i = 0; i < whole.length;) {
|
|
103
|
+
const sgr = SGR.exec(whole.slice(i));
|
|
104
|
+
if (sgr) {
|
|
105
|
+
tokens.push({ t: sgr[0], w: 0 });
|
|
106
|
+
i += sgr[0].length;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const ch = String.fromCodePoint(whole.codePointAt(i));
|
|
110
|
+
tokens.push({ t: ch, w: columns(ch) });
|
|
111
|
+
i += ch.length;
|
|
112
|
+
}
|
|
113
|
+
if (tokens.reduce((n, k) => n + k.w, 0) <= limit) {
|
|
114
|
+
out.push(whole);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
// the line's own indent, kept while it leaves room for a word, else the continuation's
|
|
118
|
+
let lead = 0;
|
|
119
|
+
while (tokens[lead]?.t === " ")
|
|
120
|
+
lead++;
|
|
121
|
+
const indent = (n) => Array.from({ length: n }, () => ({ t: " ", w: 1 }));
|
|
122
|
+
let line = indent(lead + MIN_ROOM <= limit ? lead : Math.min(lead, cont));
|
|
123
|
+
let taken = line.length, start = line.length;
|
|
124
|
+
// each token placed in turn; past the limit the line is broken at its last space past the indent, and what followed
|
|
125
|
+
// the space is placed again from there (so it is broken again if it must), else broken here, within the word
|
|
126
|
+
let placed = []; // the source index of each of line's tokens past its indent
|
|
127
|
+
for (let i = lead; i < tokens.length; i++) {
|
|
128
|
+
const k = tokens[i];
|
|
129
|
+
if (taken + k.w > limit && taken > start) {
|
|
130
|
+
let at = -1;
|
|
131
|
+
for (let j = placed.length - 1; j > 0; j--)
|
|
132
|
+
if (tokens[placed[j]].t === " ") {
|
|
133
|
+
at = j;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
const kept = at >= 0 ? line.slice(0, start + at) : line;
|
|
137
|
+
while (kept.length > start && kept[kept.length - 1].t === " ")
|
|
138
|
+
kept.pop();
|
|
139
|
+
out.push(kept.map((x) => x.t).join(""));
|
|
140
|
+
if (at >= 0)
|
|
141
|
+
i = placed[at]; // the loop's i++ places what followed the space
|
|
142
|
+
else
|
|
143
|
+
i--; // this token begins the next line
|
|
144
|
+
line = indent(cont);
|
|
145
|
+
taken = cont;
|
|
146
|
+
start = cont;
|
|
147
|
+
placed = [];
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (k.t === " " && taken === start && start > 0)
|
|
151
|
+
continue; // no space at a continuation's start
|
|
152
|
+
line.push(k);
|
|
153
|
+
placed.push(i);
|
|
154
|
+
taken += k.w;
|
|
155
|
+
}
|
|
156
|
+
// a continuation with nothing after its indent (the line ended in spaces) is no line
|
|
157
|
+
if (taken > start || start === 0)
|
|
158
|
+
out.push(line.map((x) => x.t).join(""));
|
|
159
|
+
}
|
|
160
|
+
return out.join("\n");
|
|
161
|
+
}
|
|
162
|
+
/** A renderer's output, as serviceStyle asks it on a terminal (strictLines), else as it is. */
|
|
163
|
+
export const strict = (text, s) => { const w = strictWidth(s); return w === null ? text : strictLines(text, w); };
|
|
164
|
+
/** A renderer's wrap: the strict one for a style that holds a service's text on a terminal, else style.ts's. */
|
|
165
|
+
const fit = (text, s, indent, firstUsed = indent) => {
|
|
166
|
+
const w = strictWidth(s);
|
|
167
|
+
return w === null ? wrap(text, s.width, indent, firstUsed) : strictWrap(text, w, indent, firstUsed);
|
|
168
|
+
};
|
|
16
169
|
const HELP = { help: { type: "boolean", short: "h" } };
|
|
17
170
|
/**
|
|
18
171
|
* A command line read by its spec: the values and positionals; or the exit code when it answered itself — 0 after
|
|
@@ -46,25 +199,30 @@ export function nextBlock(steps, s = styleOut()) {
|
|
|
46
199
|
if (!what)
|
|
47
200
|
return ` ${s.cyan(command)}`;
|
|
48
201
|
const used = 2 + Math.max(command.length, NEXT_WIDTH) + 2;
|
|
49
|
-
|
|
202
|
+
// a terminal too narrow for the column under serviceStyle: what it does on the next line, at the continuation
|
|
203
|
+
const w = strictWidth(s);
|
|
204
|
+
if (w !== null && 2 + NEXT_WIDTH + 2 + MIN_ROOM > lineLimit(w))
|
|
205
|
+
return ` ${s.cyan(command)}\n${" ".repeat(continuationAt(w))}${s.dim(fit(what, s, continuationAt(w)))}`;
|
|
206
|
+
return ` ${s.cyan(command.padEnd(NEXT_WIDTH))} ${s.dim(fit(what, s, 2 + NEXT_WIDTH + 2, used))}`;
|
|
50
207
|
};
|
|
51
|
-
return ["", s.bold("Next:"), ...steps.map(step)].join("\n");
|
|
208
|
+
return strict(["", s.bold("Next:"), ...steps.map(step)].join("\n"), s);
|
|
52
209
|
}
|
|
53
210
|
export function reportText(r, s = styleOut()) {
|
|
54
|
-
|
|
211
|
+
// a headline is a terminal's to wrap, unless it holds a service's text: then the CLI breaks it (above)
|
|
212
|
+
const lines = [s.bold(strictWidth(s) !== null ? fit(r.headline, s, CONTINUATION, 0) : r.headline)];
|
|
55
213
|
const w = Math.max(0, ...(r.details ?? []).map(([label]) => label.length));
|
|
56
214
|
for (const [label, value] of r.details ?? [])
|
|
57
|
-
lines.push(` ${s.dim(label.padEnd(w))} ${
|
|
58
|
-
return withEnd(lines.join("\n"), r, s);
|
|
215
|
+
lines.push(` ${s.dim(label.padEnd(w))} ${fit(value, s, 2 + w + 3)}`);
|
|
216
|
+
return strict(withEnd(lines.join("\n"), r, s), s);
|
|
59
217
|
}
|
|
60
218
|
/**
|
|
61
219
|
* The end of a command's output, to print on its own (out(endText(…))): its tips, then what to run next, each part after
|
|
62
220
|
* a blank line; "" when it has neither. withEnd puts it after text a command has not printed yet.
|
|
63
221
|
*/
|
|
64
222
|
export function endText(r, s = styleOut()) {
|
|
65
|
-
const tips = r.tips?.length ? `\n${r.tips.map((t) => s.dim(`Tip: ${
|
|
223
|
+
const tips = r.tips?.length ? `\n${r.tips.map((t) => s.dim(`Tip: ${fit(t, s, 5)}`)).join("\n")}` : "";
|
|
66
224
|
const next = r.next?.length ? nextBlock(r.next, s) : "";
|
|
67
|
-
return tips && next ? `${tips}\n${next}` : tips || next;
|
|
225
|
+
return strict(tips && next ? `${tips}\n${next}` : tips || next, s);
|
|
68
226
|
}
|
|
69
227
|
export function withEnd(text, r, s = styleOut()) {
|
|
70
228
|
const end = endText(r, s);
|
|
@@ -105,13 +263,14 @@ export const FAILURE_CODES = {
|
|
|
105
263
|
no_project: "no Mason project here or above (mason init makes one)",
|
|
106
264
|
bad_config: "this folder is a Mason project whose .mason/config.json cannot be read: repair it, or move .mason/ aside and mason init",
|
|
107
265
|
bad_source: "the project's sources file (mason/sources/<name>.yml) is missing or names something wrong: the file, the key and the way out are said",
|
|
266
|
+
bad_roles: "the project's roles file (mason/roles.yml) names something wrong: a table the sources file does not sync, a column the synced table lacks, a role with no table; the file, the key and the way out are said",
|
|
108
267
|
not_running: "Mason is not running for the project (mason start)",
|
|
109
268
|
unreachable: "Mason is running but does not answer (mason logs says why)",
|
|
110
269
|
not_found: "a name nothing has: a table, a column, a user",
|
|
111
270
|
nothing_yet: "nothing to work on yet: no table added (the next steps say what adds one)",
|
|
112
271
|
refused: "Mason refused what was asked, with the reason",
|
|
113
272
|
failed: "the command tried and could not finish: the reason, and what to do",
|
|
114
|
-
timeout: "ran out of time — mason wait; nothing stopped (exit 124)",
|
|
273
|
+
timeout: "ran out of time — mason wait, mason deploy, mason replica create; nothing stopped (exit 124)",
|
|
115
274
|
};
|
|
116
275
|
/** A failure thrown from deep in a command, for main.ts to print: the one way a failure leaves a command without a return code. */
|
|
117
276
|
export class CommandFailed extends Error {
|
|
@@ -126,17 +285,17 @@ export function failureText(cmd, f, s = styleErr()) {
|
|
|
126
285
|
const head = cmd ? `mason ${cmd}:` : "mason:";
|
|
127
286
|
// the checklist's marks: ✘ on a terminal (beside its ✔), ✗ in plain text (beside its ✓); a style that colours is one
|
|
128
287
|
const mark = s.red("x") === "x" ? "✗" : "✘";
|
|
129
|
-
const lines = [`${s.red(mark)} ${s.red(head)} ${s.bold(
|
|
288
|
+
const lines = [`${s.red(mark)} ${s.red(head)} ${s.bold(fit(f.message, s, 2, (strictWidth(s) === null ? mark.length : columns(mark)) + 1 + head.length + 1))}`];
|
|
130
289
|
const rows = [...(f.why ? [["why", f.why]] : []), ...(f.fix ? [["fix", f.fix]] : [])];
|
|
131
290
|
// a value of several lines (a list of failures, an entry to paste) keeps its lines, each under the first
|
|
132
291
|
for (const [label, value] of rows)
|
|
133
|
-
lines.push(` ${s.dim(label)} ${value.split("\n").map((l, i) => i ? `${" ".repeat(8)}${
|
|
292
|
+
lines.push(` ${s.dim(label)} ${value.split("\n").map((l, i) => i ? `${" ".repeat(8)}${fit(l, s, 8)}` : fit(l, s, 8)).join("\n")}`);
|
|
134
293
|
let text = lines.join("\n");
|
|
135
294
|
if (f.next?.length)
|
|
136
295
|
text += `\n${nextBlock(f.next, s)}`;
|
|
137
296
|
if (f.usage)
|
|
138
297
|
text += `\n\n${f.usage.replace(/\n$/, "")}`;
|
|
139
|
-
return text;
|
|
298
|
+
return strict(text, s);
|
|
140
299
|
}
|
|
141
300
|
/** A failure's `error` as --json carries it: on its own (failureJson), or beside a command's own keys when it did part of
|
|
142
301
|
* its work (mason add: the tables added; mason wait: the tables' state). */
|