@taliesinb/mash 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +275 -2
- package/bin/mash.ts +253 -0
- package/dist/bin/mash.d.ts +39 -0
- package/dist/bin/mash.d.ts.map +1 -0
- package/dist/bin/mash.js +281 -0
- package/dist/bin/mash.js.map +1 -0
- package/dist/src/analysis/analyze.d.ts +97 -0
- package/dist/src/analysis/analyze.d.ts.map +1 -0
- package/dist/src/analysis/analyze.js +1406 -0
- package/dist/src/analysis/analyze.js.map +1 -0
- package/dist/src/analysis/fs.d.ts +39 -0
- package/dist/src/analysis/fs.d.ts.map +1 -0
- package/dist/src/analysis/fs.js +117 -0
- package/dist/src/analysis/fs.js.map +1 -0
- package/dist/src/analysis/outputs.d.ts +16 -0
- package/dist/src/analysis/outputs.d.ts.map +1 -0
- package/dist/src/analysis/outputs.js +277 -0
- package/dist/src/analysis/outputs.js.map +1 -0
- package/dist/src/analysis/value.d.ts +76 -0
- package/dist/src/analysis/value.d.ts.map +1 -0
- package/dist/src/analysis/value.js +248 -0
- package/dist/src/analysis/value.js.map +1 -0
- package/dist/src/behaviors/defs/core.d.ts +15 -0
- package/dist/src/behaviors/defs/core.d.ts.map +1 -0
- package/dist/src/behaviors/defs/core.js +1084 -0
- package/dist/src/behaviors/defs/core.js.map +1 -0
- package/dist/src/behaviors/defs/devtools.d.ts +9 -0
- package/dist/src/behaviors/defs/devtools.d.ts.map +1 -0
- package/dist/src/behaviors/defs/devtools.js +432 -0
- package/dist/src/behaviors/defs/devtools.js.map +1 -0
- package/dist/src/behaviors/defs/macos.d.ts +12 -0
- package/dist/src/behaviors/defs/macos.d.ts.map +1 -0
- package/dist/src/behaviors/defs/macos.js +454 -0
- package/dist/src/behaviors/defs/macos.js.map +1 -0
- package/dist/src/behaviors/defs/tools.d.ts +9 -0
- package/dist/src/behaviors/defs/tools.d.ts.map +1 -0
- package/dist/src/behaviors/defs/tools.js +639 -0
- package/dist/src/behaviors/defs/tools.js.map +1 -0
- package/dist/src/behaviors/dsl.d.ts +95 -0
- package/dist/src/behaviors/dsl.d.ts.map +1 -0
- package/dist/src/behaviors/dsl.js +267 -0
- package/dist/src/behaviors/dsl.js.map +1 -0
- package/dist/src/behaviors/index.d.ts +12 -0
- package/dist/src/behaviors/index.d.ts.map +1 -0
- package/dist/src/behaviors/index.js +18 -0
- package/dist/src/behaviors/index.js.map +1 -0
- package/dist/src/behaviors/registry.d.ts +45 -0
- package/dist/src/behaviors/registry.d.ts.map +1 -0
- package/dist/src/behaviors/registry.js +266 -0
- package/dist/src/behaviors/registry.js.map +1 -0
- package/dist/src/behaviors/roles.d.ts +29 -0
- package/dist/src/behaviors/roles.d.ts.map +1 -0
- package/dist/src/behaviors/roles.js +198 -0
- package/dist/src/behaviors/roles.js.map +1 -0
- package/dist/src/behaviors/types.d.ts +120 -0
- package/dist/src/behaviors/types.d.ts.map +1 -0
- package/dist/src/behaviors/types.js +12 -0
- package/dist/src/behaviors/types.js.map +1 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/integrations/deepsea.d.ts +121 -0
- package/dist/src/integrations/deepsea.d.ts.map +1 -0
- package/dist/src/integrations/deepsea.js +199 -0
- package/dist/src/integrations/deepsea.js.map +1 -0
- package/dist/src/machine.d.ts +139 -0
- package/dist/src/machine.d.ts.map +1 -0
- package/dist/src/machine.js +400 -0
- package/dist/src/machine.js.map +1 -0
- package/dist/src/parser/ast.d.ts +369 -0
- package/dist/src/parser/ast.d.ts.map +1 -0
- package/dist/src/parser/ast.js +17 -0
- package/dist/src/parser/ast.js.map +1 -0
- package/dist/src/parser/parser.d.ts +48 -0
- package/dist/src/parser/parser.d.ts.map +1 -0
- package/dist/src/parser/parser.js +1950 -0
- package/dist/src/parser/parser.js.map +1 -0
- package/dist/src/policy/effects.d.ts +86 -0
- package/dist/src/policy/effects.d.ts.map +1 -0
- package/dist/src/policy/effects.js +53 -0
- package/dist/src/policy/effects.js.map +1 -0
- package/dist/src/policy/policy.d.ts +130 -0
- package/dist/src/policy/policy.d.ts.map +1 -0
- package/dist/src/policy/policy.js +532 -0
- package/dist/src/policy/policy.js.map +1 -0
- package/dist/src/printer/doc.d.ts +151 -0
- package/dist/src/printer/doc.d.ts.map +1 -0
- package/dist/src/printer/doc.js +409 -0
- package/dist/src/printer/doc.js.map +1 -0
- package/dist/src/printer/highlight.d.ts +53 -0
- package/dist/src/printer/highlight.d.ts.map +1 -0
- package/dist/src/printer/highlight.js +339 -0
- package/dist/src/printer/highlight.js.map +1 -0
- package/dist/src/printer/html.d.ts +72 -0
- package/dist/src/printer/html.d.ts.map +1 -0
- package/dist/src/printer/html.js +423 -0
- package/dist/src/printer/html.js.map +1 -0
- package/dist/src/printer/print.d.ts +63 -0
- package/dist/src/printer/print.d.ts.map +1 -0
- package/dist/src/printer/print.js +484 -0
- package/dist/src/printer/print.js.map +1 -0
- package/dist/src/printer/summary.d.ts +50 -0
- package/dist/src/printer/summary.d.ts.map +1 -0
- package/dist/src/printer/summary.js +621 -0
- package/dist/src/printer/summary.js.map +1 -0
- package/dist/src/trace/events.d.ts +183 -0
- package/dist/src/trace/events.d.ts.map +1 -0
- package/dist/src/trace/events.js +9 -0
- package/dist/src/trace/events.js.map +1 -0
- package/dist/src/trace/progress.d.ts +58 -0
- package/dist/src/trace/progress.d.ts.map +1 -0
- package/dist/src/trace/progress.js +83 -0
- package/dist/src/trace/progress.js.map +1 -0
- package/dist/src/vm/arith.d.ts +29 -0
- package/dist/src/vm/arith.d.ts.map +1 -0
- package/dist/src/vm/arith.js +258 -0
- package/dist/src/vm/arith.js.map +1 -0
- package/dist/src/vm/builtins.d.ts +31 -0
- package/dist/src/vm/builtins.d.ts.map +1 -0
- package/dist/src/vm/builtins.js +1773 -0
- package/dist/src/vm/builtins.js.map +1 -0
- package/dist/src/vm/emulate.d.ts +75 -0
- package/dist/src/vm/emulate.d.ts.map +1 -0
- package/dist/src/vm/emulate.js +380 -0
- package/dist/src/vm/emulate.js.map +1 -0
- package/dist/src/vm/expand.d.ts +68 -0
- package/dist/src/vm/expand.d.ts.map +1 -0
- package/dist/src/vm/expand.js +744 -0
- package/dist/src/vm/expand.js.map +1 -0
- package/dist/src/vm/external.d.ts +34 -0
- package/dist/src/vm/external.d.ts.map +1 -0
- package/dist/src/vm/external.js +228 -0
- package/dist/src/vm/external.js.map +1 -0
- package/dist/src/vm/fifo.d.ts +66 -0
- package/dist/src/vm/fifo.d.ts.map +1 -0
- package/dist/src/vm/fifo.js +232 -0
- package/dist/src/vm/fifo.js.map +1 -0
- package/dist/src/vm/interp.d.ts +209 -0
- package/dist/src/vm/interp.d.ts.map +1 -0
- package/dist/src/vm/interp.js +1641 -0
- package/dist/src/vm/interp.js.map +1 -0
- package/dist/src/vm/io.d.ts +180 -0
- package/dist/src/vm/io.d.ts.map +1 -0
- package/dist/src/vm/io.js +502 -0
- package/dist/src/vm/io.js.map +1 -0
- package/dist/src/vm/pattern.d.ts +46 -0
- package/dist/src/vm/pattern.d.ts.map +1 -0
- package/dist/src/vm/pattern.js +498 -0
- package/dist/src/vm/pattern.js.map +1 -0
- package/dist/src/vm/proc.d.ts +94 -0
- package/dist/src/vm/proc.d.ts.map +1 -0
- package/dist/src/vm/proc.js +130 -0
- package/dist/src/vm/proc.js.map +1 -0
- package/dist/src/vm/state.d.ts +104 -0
- package/dist/src/vm/state.d.ts.map +1 -0
- package/dist/src/vm/state.js +233 -0
- package/dist/src/vm/state.js.map +1 -0
- package/dist/src/vm/test.d.ts +11 -0
- package/dist/src/vm/test.d.ts.map +1 -0
- package/dist/src/vm/test.js +277 -0
- package/dist/src/vm/test.js.map +1 -0
- package/package.json +63 -4
- package/src/analysis/analyze.ts +1395 -0
- package/src/analysis/fs.ts +121 -0
- package/src/analysis/outputs.ts +242 -0
- package/src/analysis/value.ts +264 -0
- package/src/behaviors/defs/core.ts +970 -0
- package/src/behaviors/defs/devtools.ts +400 -0
- package/src/behaviors/defs/macos.ts +426 -0
- package/src/behaviors/defs/tools.ts +596 -0
- package/src/behaviors/dsl.ts +293 -0
- package/src/behaviors/index.ts +19 -0
- package/src/behaviors/registry.ts +261 -0
- package/src/behaviors/roles.ts +187 -0
- package/src/behaviors/types.ts +127 -0
- package/src/index.ts +27 -0
- package/src/integrations/deepsea.ts +259 -0
- package/src/machine.ts +483 -0
- package/src/parser/ast.ts +472 -0
- package/src/parser/parser.ts +1826 -0
- package/src/policy/effects.ts +102 -0
- package/src/policy/policy.ts +578 -0
- package/src/printer/doc.ts +454 -0
- package/src/printer/highlight.ts +283 -0
- package/src/printer/html.ts +441 -0
- package/src/printer/print.ts +528 -0
- package/src/printer/summary.ts +601 -0
- package/src/trace/events.ts +102 -0
- package/src/trace/progress.ts +119 -0
- package/src/vm/arith.ts +236 -0
- package/src/vm/builtins.ts +1590 -0
- package/src/vm/emulate.ts +337 -0
- package/src/vm/expand.ts +721 -0
- package/src/vm/external.ts +265 -0
- package/src/vm/fifo.ts +226 -0
- package/src/vm/interp.ts +1623 -0
- package/src/vm/io.ts +570 -0
- package/src/vm/pattern.ts +477 -0
- package/src/vm/proc.ts +147 -0
- package/src/vm/state.ts +267 -0
- package/src/vm/test.ts +253 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pretty-printer: renders a parsed script as readable bash that parses to the
|
|
3
|
+
* same AST (see docs/pretty-printer.md).
|
|
4
|
+
*
|
|
5
|
+
* Words, assignment values, redirections, here-doc bodies, arithmetic and
|
|
6
|
+
* `[[ ]]` expressions are emitted as their exact source text; only the layout
|
|
7
|
+
* (newlines, ` \` continuations, indentation) is regenerated.
|
|
8
|
+
*/
|
|
9
|
+
import { parse, literalOf } from "../parser/parser.js";
|
|
10
|
+
import { simpleCommandRoles } from "./highlight.js";
|
|
11
|
+
import { blankLine, compoundGroup, cont, contForced, fill, group, hard, heredoc, indent, join, mark, nl, render, src, suffix, tok, } from "./doc.js";
|
|
12
|
+
const DEFAULTS = {
|
|
13
|
+
width: 80, indent: 2, operators: 'trailing', assignments: 'auto', compounds: 'auto',
|
|
14
|
+
formatSubstitutions: false, blankLines: 1, functionKeyword: 'normalize', statements: 'continuation',
|
|
15
|
+
};
|
|
16
|
+
/** Parse and pretty-print `source`. Throws ParseError on invalid input. */
|
|
17
|
+
export function format(source, options = {}) {
|
|
18
|
+
return printScript(parse(source), source, options);
|
|
19
|
+
}
|
|
20
|
+
/** Pretty-print an already parsed script; `source` must be the text it was parsed from. */
|
|
21
|
+
export function printScript(script, source, options = {}) {
|
|
22
|
+
const { doc, opts } = buildDoc(script, source, options);
|
|
23
|
+
const r = render(doc, opts.width, { source });
|
|
24
|
+
return { text: r.text, map: r.map };
|
|
25
|
+
}
|
|
26
|
+
/** The layout document for a script (shared by the text and HTML renderers). */
|
|
27
|
+
export function buildDoc(script, source, options = {}) {
|
|
28
|
+
const opts = { ...DEFAULTS, ...options };
|
|
29
|
+
const p = new Printer(source, script.comments ?? [], opts);
|
|
30
|
+
p.lineHazard = usesLineSensitiveBuiltins(script);
|
|
31
|
+
const doc = p.topLevel(script);
|
|
32
|
+
const leftover = p.remainingComments();
|
|
33
|
+
return { doc: leftover.length ? [doc, hard, join(hard, leftover)] : doc, opts };
|
|
34
|
+
}
|
|
35
|
+
/** `alias` and `shopt` change how *later lines* are parsed: never split their lines (docs/pretty-printer.md §5). */
|
|
36
|
+
function usesLineSensitiveBuiltins(script) {
|
|
37
|
+
let found = false;
|
|
38
|
+
const visit = (n) => {
|
|
39
|
+
if (found || n === null || typeof n !== 'object')
|
|
40
|
+
return;
|
|
41
|
+
if (Array.isArray(n)) {
|
|
42
|
+
for (const x of n)
|
|
43
|
+
visit(x);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const node = n;
|
|
47
|
+
if (node.type === 'SimpleCommand') {
|
|
48
|
+
const w = node.words?.[0];
|
|
49
|
+
const name = w && w.type === 'Word' ? literalOf(w) : null;
|
|
50
|
+
if (name === 'alias' || name === 'shopt' || name === 'unalias')
|
|
51
|
+
found = true;
|
|
52
|
+
}
|
|
53
|
+
for (const [k, v] of Object.entries(node))
|
|
54
|
+
if (k !== 'span' && v && typeof v === 'object')
|
|
55
|
+
visit(v);
|
|
56
|
+
};
|
|
57
|
+
visit(script.body);
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
const kw = (text) => tok(text, 'kw');
|
|
61
|
+
const op = (text) => tok(text, 'op');
|
|
62
|
+
/** The plain text of a simple document (src/tok/string), or null. */
|
|
63
|
+
function plain(d, source) {
|
|
64
|
+
if (typeof d === 'string')
|
|
65
|
+
return d;
|
|
66
|
+
if (Array.isArray(d))
|
|
67
|
+
return null;
|
|
68
|
+
if (d.t === 'src')
|
|
69
|
+
return source.slice(d.start, d.end);
|
|
70
|
+
if (d.t === 'tok')
|
|
71
|
+
return d.text;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
class Printer {
|
|
75
|
+
src;
|
|
76
|
+
opts;
|
|
77
|
+
lineHazard = false;
|
|
78
|
+
comments;
|
|
79
|
+
used;
|
|
80
|
+
constructor(source, comments, opts) {
|
|
81
|
+
this.src = source;
|
|
82
|
+
this.comments = comments;
|
|
83
|
+
this.used = comments.map(() => false);
|
|
84
|
+
this.opts = opts;
|
|
85
|
+
}
|
|
86
|
+
/** Verbatim source, consuming the comments inside it. */
|
|
87
|
+
verbatim(span, atom, cls) {
|
|
88
|
+
this.consume(span);
|
|
89
|
+
return src(span.start, span.end, atom, cls);
|
|
90
|
+
}
|
|
91
|
+
commentDoc(c) {
|
|
92
|
+
const i = this.comments.indexOf(c);
|
|
93
|
+
return src(c.span.start, c.span.end, { id: -(i + 1), kind: 'cm', weight: 0.8 }, 'cm');
|
|
94
|
+
}
|
|
95
|
+
// -------------------------------------------------------------------------
|
|
96
|
+
// Comments
|
|
97
|
+
// -------------------------------------------------------------------------
|
|
98
|
+
/** Mark comments inside a verbatim span as printed (they are part of the text). */
|
|
99
|
+
consume(span) {
|
|
100
|
+
this.comments.forEach((c, i) => {
|
|
101
|
+
if (!this.used[i] && c.span.start >= span.start && c.span.end <= span.end)
|
|
102
|
+
this.used[i] = true;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** Unprinted comments that start before `offset`, in order (marked printed). */
|
|
106
|
+
take(offset) {
|
|
107
|
+
const out = [];
|
|
108
|
+
this.comments.forEach((c, i) => {
|
|
109
|
+
if (!this.used[i] && c.span.start < offset) {
|
|
110
|
+
this.used[i] = true;
|
|
111
|
+
out.push(c);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
/** The unprinted comment that follows `end` on the same source line, if any. */
|
|
117
|
+
trailing(end, limit) {
|
|
118
|
+
for (let i = 0; i < this.comments.length; i++) {
|
|
119
|
+
const c = this.comments[i];
|
|
120
|
+
if (this.used[i] || c.span.start < end || c.span.start >= limit)
|
|
121
|
+
continue;
|
|
122
|
+
if (this.src.slice(end, c.span.start).includes('\n'))
|
|
123
|
+
return null;
|
|
124
|
+
this.used[i] = true;
|
|
125
|
+
return c;
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
trailingDoc(c) {
|
|
130
|
+
return suffix([' ', this.commentDoc(c)]);
|
|
131
|
+
}
|
|
132
|
+
remainingComments() {
|
|
133
|
+
return this.take(Infinity).map((c) => this.commentDoc(c));
|
|
134
|
+
}
|
|
135
|
+
// -------------------------------------------------------------------------
|
|
136
|
+
// Statement lists
|
|
137
|
+
// -------------------------------------------------------------------------
|
|
138
|
+
topLevel(script) {
|
|
139
|
+
return this.list(script.body, script.span.end, true, true);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A statement list. `alwaysBreak` for the script top level; otherwise the
|
|
143
|
+
* separators are `nl` breaks that print `; ` when the enclosing group fits.
|
|
144
|
+
*/
|
|
145
|
+
list(stmts, endOffset, alwaysBreak, top = false) {
|
|
146
|
+
const parts = [];
|
|
147
|
+
stmts.forEach((s, i) => {
|
|
148
|
+
const leading = this.take(s.span.start);
|
|
149
|
+
if (i > 0) {
|
|
150
|
+
const prev = stmts[i - 1];
|
|
151
|
+
const between = this.src.slice(prev.span.end, s.span.start);
|
|
152
|
+
// the same *logical* line: backslash-newline continuations do not end it
|
|
153
|
+
const sameLine = !between.replace(/\\\n/g, '').includes('\n');
|
|
154
|
+
if (top && sameLine && leading.length === 0 && this.opts.statements === 'continuation') {
|
|
155
|
+
parts.push(prev.background ? '' : op(';'), contForced);
|
|
156
|
+
}
|
|
157
|
+
else if (sameLine && leading.length === 0 && ((top && this.opts.statements === 'preserve') || (this.lineHazard && this.opts.statements === 'newline'))) {
|
|
158
|
+
parts.push(prev.background ? ' ' : [op(';'), ' ']);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const blank = this.opts.blankLines > 0 && /\n[ \t]*\n/.test(between);
|
|
162
|
+
if (alwaysBreak || leading.length > 0)
|
|
163
|
+
parts.push(blank ? blankLine : hard);
|
|
164
|
+
else
|
|
165
|
+
parts.push(nl(prev.background ? ' ' : '; ', blank));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const c of leading)
|
|
169
|
+
parts.push(this.commentDoc(c), hard);
|
|
170
|
+
parts.push(this.stmt(s));
|
|
171
|
+
const next = stmts[i + 1];
|
|
172
|
+
const t = this.trailing(s.span.end, next ? next.span.start : endOffset);
|
|
173
|
+
if (t)
|
|
174
|
+
parts.push(this.trailingDoc(t));
|
|
175
|
+
});
|
|
176
|
+
return parts;
|
|
177
|
+
}
|
|
178
|
+
/** Does a body qualify to stay on one line (`compounds: 'auto'`)? */
|
|
179
|
+
simpleBody(body) {
|
|
180
|
+
if (this.opts.compounds === 'expanded' || body.length !== 1)
|
|
181
|
+
return false;
|
|
182
|
+
const c = body[0].command;
|
|
183
|
+
return c.type === 'SimpleCommand' || c.type === 'Pipeline' || c.type === 'AndOr';
|
|
184
|
+
}
|
|
185
|
+
stmt(s) {
|
|
186
|
+
return mark(s.id, [this.command(s.command), s.background ? [' ', op('&')] : '']);
|
|
187
|
+
}
|
|
188
|
+
// -------------------------------------------------------------------------
|
|
189
|
+
// Commands
|
|
190
|
+
// -------------------------------------------------------------------------
|
|
191
|
+
command(c) {
|
|
192
|
+
return mark(c.id, this.commandInner(c));
|
|
193
|
+
}
|
|
194
|
+
commandInner(c) {
|
|
195
|
+
switch (c.type) {
|
|
196
|
+
case 'SimpleCommand': return this.simple(c);
|
|
197
|
+
case 'Pipeline': return this.pipeline(c);
|
|
198
|
+
case 'AndOr': return this.andOr(c);
|
|
199
|
+
case 'FunctionDef': return this.functionDef(c);
|
|
200
|
+
default: return [this.compound(c), this.compoundRedirs(c)];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** Truncation preference for an argument word: strings and substitutions first. */
|
|
204
|
+
/**
|
|
205
|
+
* Truncation preference for an argument word: strings and substitutions
|
|
206
|
+
* first, then paths (shortened from the left), then plain words. Command
|
|
207
|
+
* names, flags and subcommands are never shortened.
|
|
208
|
+
*/
|
|
209
|
+
wordAtom(w, role, argRole) {
|
|
210
|
+
if (role === 'cmd' || argRole === 'cmd' || argRole === 'subcommand')
|
|
211
|
+
return undefined;
|
|
212
|
+
const text = this.src.slice(w.span.start, w.span.end);
|
|
213
|
+
if (/^-/.test(text) && !/[=\s]/.test(text))
|
|
214
|
+
return undefined;
|
|
215
|
+
if ((argRole === 'file' || argRole === 'dir') && text.includes('/') && !text.includes('\n'))
|
|
216
|
+
return { id: w.id, kind: 'word', weight: 0.9, tail: true };
|
|
217
|
+
const rich = w.parts.some((p) => p.type !== 'Lit' && p.type !== 'Escaped');
|
|
218
|
+
return { id: w.id, kind: 'word', weight: rich ? 1 : 0.6 };
|
|
219
|
+
}
|
|
220
|
+
wordDoc(w, role = 'arg', argRole) {
|
|
221
|
+
if (this.opts.formatSubstitutions) {
|
|
222
|
+
const d = this.wordWithSubstitutions(w);
|
|
223
|
+
if (d)
|
|
224
|
+
return d;
|
|
225
|
+
}
|
|
226
|
+
return this.verbatim(w.span, this.wordAtom(w, role, argRole));
|
|
227
|
+
}
|
|
228
|
+
/** Words containing multi-line `$(…)` / `<(…)`: format their bodies, keep the rest verbatim. */
|
|
229
|
+
wordWithSubstitutions(w) {
|
|
230
|
+
const substs = [];
|
|
231
|
+
const visit = (parts) => {
|
|
232
|
+
for (const p of parts) {
|
|
233
|
+
if ((p.type === 'CmdSubst' && !p.backquote) || p.type === 'ProcSubst') {
|
|
234
|
+
if (this.src.slice(p.span.start, p.span.end).includes('\n') && p.body.length > 0)
|
|
235
|
+
substs.push(p);
|
|
236
|
+
}
|
|
237
|
+
else if (p.type === 'DblQuoted')
|
|
238
|
+
visit(p.parts);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
visit(w.parts);
|
|
242
|
+
if (substs.length === 0)
|
|
243
|
+
return null;
|
|
244
|
+
const out = [];
|
|
245
|
+
let cursor = w.span.start;
|
|
246
|
+
for (const s of substs) {
|
|
247
|
+
out.push(this.verbatim({ start: cursor, end: s.span.start }));
|
|
248
|
+
const open = s.type === 'CmdSubst' ? '$(' : `${s.direction}(`;
|
|
249
|
+
out.push(tok(open, 'sub'), indent([hard, this.list(s.body, s.span.end, true)], this.opts.indent), hard, tok(')', 'sub'));
|
|
250
|
+
this.take(s.span.end); // comments right before `)`
|
|
251
|
+
cursor = s.span.end;
|
|
252
|
+
}
|
|
253
|
+
out.push(this.verbatim({ start: cursor, end: w.span.end }));
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
/** `name=value`: the `name=` part verbatim, the value as a word (so `$(…)` in it can be formatted). */
|
|
257
|
+
assignDoc(a) {
|
|
258
|
+
if (a.value?.type !== 'Word')
|
|
259
|
+
return this.verbatim(a.span);
|
|
260
|
+
return [this.verbatim({ start: a.span.start, end: a.value.span.start }), this.wordDoc(a.value)];
|
|
261
|
+
}
|
|
262
|
+
/** The separator before a closing keyword (`done`, `fi`, `}`): `; ` flat, or ` ` after a background `&`. */
|
|
263
|
+
closer(body) {
|
|
264
|
+
return nl(body[body.length - 1]?.background ? ' ' : '; ');
|
|
265
|
+
}
|
|
266
|
+
redirDoc(r) {
|
|
267
|
+
if (!r.heredoc) {
|
|
268
|
+
// `> path`: the target is a path atom (an fd duplication like `2>&1` stays whole)
|
|
269
|
+
const op = { start: r.span.start, end: r.target.span.start };
|
|
270
|
+
const target = this.src.slice(r.target.span.start, r.target.span.end);
|
|
271
|
+
if (r.target.span.end > r.target.span.start && !/&\s*$/.test(this.src.slice(op.start, op.end)) && !target.includes('\n')) {
|
|
272
|
+
const tail = target.includes('/');
|
|
273
|
+
return [this.verbatim(op), this.verbatim(r.target.span, { id: r.target.id, kind: 'word', weight: tail ? 0.9 : 0.6, tail })];
|
|
274
|
+
}
|
|
275
|
+
return this.verbatim(r.span);
|
|
276
|
+
}
|
|
277
|
+
const text = this.verbatim(r.span);
|
|
278
|
+
const b = r.heredoc.body.span;
|
|
279
|
+
this.consume(b);
|
|
280
|
+
return [text, heredoc(b.start, b.end, r.heredoc.delimiter, { id: r.id, kind: 'hd', weight: 1 })];
|
|
281
|
+
}
|
|
282
|
+
simple(c) {
|
|
283
|
+
const assigns = c.assigns.map((a) => this.assignDoc(a));
|
|
284
|
+
let first = true;
|
|
285
|
+
let roles = [];
|
|
286
|
+
try {
|
|
287
|
+
roles = simpleCommandRoles(c);
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
// display only
|
|
291
|
+
}
|
|
292
|
+
const words = c.words.map((w, i) => {
|
|
293
|
+
if (w.type === 'Assign')
|
|
294
|
+
return this.assignDoc(w);
|
|
295
|
+
const d = this.wordDoc(w, first ? 'cmd' : 'arg', roles[i]);
|
|
296
|
+
first = false;
|
|
297
|
+
return d;
|
|
298
|
+
});
|
|
299
|
+
const redirs = c.redirs.map((r) => this.redirDoc(r));
|
|
300
|
+
// keep `-o value`, `-qm value` (combined short flags) and `--opt value` together when wrapping
|
|
301
|
+
const units = [];
|
|
302
|
+
for (let i = 0; i < words.length; i++) {
|
|
303
|
+
const w = plain(words[i], this.src);
|
|
304
|
+
const next = i + 1 < words.length ? plain(words[i + 1], this.src) : null;
|
|
305
|
+
if (i > 0 && w !== null && next !== null && /^(-[A-Za-z]+|--[A-Za-z][\w-]*)$/.test(w) && !next.startsWith('-')) {
|
|
306
|
+
units.push([words[i], ' ', words[i + 1]]);
|
|
307
|
+
i++;
|
|
308
|
+
}
|
|
309
|
+
else
|
|
310
|
+
units.push(words[i]);
|
|
311
|
+
}
|
|
312
|
+
units.push(...redirs);
|
|
313
|
+
// the command name, then arguments filled onto lines and indented twice
|
|
314
|
+
const filled = units.length <= 1 ? (units[0] ?? '') : [units[0], indent(fill(fillParts(units.slice(1))), this.opts.indent * 2)];
|
|
315
|
+
if (assigns.length === 0)
|
|
316
|
+
return group(filled);
|
|
317
|
+
if (units.length === 0)
|
|
318
|
+
return group(join(cont, assigns));
|
|
319
|
+
const ownLines = this.opts.assignments === 'always' || (this.opts.assignments === 'auto' && assigns.length >= 2);
|
|
320
|
+
if (ownLines)
|
|
321
|
+
return [join(contForced, assigns), contForced, group(filled)];
|
|
322
|
+
return group([join(cont, assigns), cont, group(filled)]);
|
|
323
|
+
}
|
|
324
|
+
operatorChain(items, ops) {
|
|
325
|
+
const leading = this.opts.operators === 'leading';
|
|
326
|
+
const out = [this.command(items[0])];
|
|
327
|
+
const rest = [];
|
|
328
|
+
for (let i = 1; i < items.length; i++) {
|
|
329
|
+
const o = ops[i - 1];
|
|
330
|
+
const comments = this.take(items[i].span.start);
|
|
331
|
+
if (leading && comments.length === 0) {
|
|
332
|
+
rest.push(cont, op(o), ' ', this.command(items[i]));
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
rest.push(' ', op(o));
|
|
336
|
+
for (const cm of comments)
|
|
337
|
+
rest.push(this.trailingDoc(cm));
|
|
338
|
+
rest.push(nl(' '), this.command(items[i]));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
out.push(indent(rest, this.opts.indent));
|
|
342
|
+
return group(out);
|
|
343
|
+
}
|
|
344
|
+
pipeline(c) {
|
|
345
|
+
const first = c.stages[0];
|
|
346
|
+
const prefix = this.src.slice(c.span.start, first.span.start).trim().replace(/\s+/g, ' ');
|
|
347
|
+
const ops = c.pipeStderr.map((e) => (e ? '|&' : '|'));
|
|
348
|
+
const chain = c.stages.length === 1 ? this.command(first) : this.operatorChain(c.stages, ops);
|
|
349
|
+
return prefix ? [kw(prefix), ' ', chain] : chain;
|
|
350
|
+
}
|
|
351
|
+
andOr(c) {
|
|
352
|
+
return this.operatorChain(c.items, c.ops);
|
|
353
|
+
}
|
|
354
|
+
functionDef(f) {
|
|
355
|
+
const header = this.opts.functionKeyword === 'preserve'
|
|
356
|
+
? tok(this.src.slice(f.span.start, f.body.span.start).trim().replace(/\s+/g, ' '), 'fn')
|
|
357
|
+
: tok(`${f.name}()`, 'fn');
|
|
358
|
+
return [header, ' ', this.command(f.body)];
|
|
359
|
+
}
|
|
360
|
+
compoundRedirs(c) {
|
|
361
|
+
if (c.redirs.length === 0)
|
|
362
|
+
return '';
|
|
363
|
+
return [' ', join(' ', c.redirs.map((r) => this.redirDoc(r)))];
|
|
364
|
+
}
|
|
365
|
+
/** Source of a compound up to its first redirection (verbatim forms: `(( ))`, `[[ ]]`). */
|
|
366
|
+
compoundText(c) {
|
|
367
|
+
let end = c.redirs.length > 0 ? c.redirs[0].span.start : c.span.end;
|
|
368
|
+
while (end > c.span.start && /\s/.test(this.src[end - 1]))
|
|
369
|
+
end--;
|
|
370
|
+
return this.verbatim({ start: c.span.start, end }, { id: c.id, kind: 'word', weight: 0.3 });
|
|
371
|
+
}
|
|
372
|
+
body(body, endOffset) {
|
|
373
|
+
return indent([nl(' '), this.list(body, endOffset, false)], this.opts.indent);
|
|
374
|
+
}
|
|
375
|
+
compound(c) {
|
|
376
|
+
switch (c.type) {
|
|
377
|
+
case 'Group':
|
|
378
|
+
return compoundGroup([kw('{'), this.body(c.body, c.span.end), this.closer(c.body), kw('}')], !this.groupable(c.body));
|
|
379
|
+
case 'Subshell':
|
|
380
|
+
return compoundGroup([kw('('), this.body(c.body, c.span.end), nl(' '), kw(')')], !this.groupable(c.body));
|
|
381
|
+
case 'If': {
|
|
382
|
+
const parts = [];
|
|
383
|
+
const flatOk = c.clauses.every((cl) => this.simpleBody(cl.body) && cl.cond.length === 1) && (c.elseBody === null || this.simpleBody(c.elseBody));
|
|
384
|
+
c.clauses.forEach((cl, i) => {
|
|
385
|
+
if (i > 0)
|
|
386
|
+
parts.push(this.closer(c.clauses[i - 1].body), kw('elif'), ' ');
|
|
387
|
+
else
|
|
388
|
+
parts.push(kw('if'), ' ');
|
|
389
|
+
parts.push(this.condList(cl.cond, cl.body[0]?.span.start ?? c.span.end), op(';'), ' ', kw('then'), this.body(cl.body, c.span.end));
|
|
390
|
+
});
|
|
391
|
+
const lastBody = c.clauses[c.clauses.length - 1].body;
|
|
392
|
+
if (c.elseBody)
|
|
393
|
+
parts.push(this.closer(lastBody), kw('else'), this.body(c.elseBody, c.span.end));
|
|
394
|
+
parts.push(this.closer(c.elseBody ?? lastBody), kw('fi'));
|
|
395
|
+
return compoundGroup(parts, !flatOk);
|
|
396
|
+
}
|
|
397
|
+
case 'Loop':
|
|
398
|
+
return compoundGroup([kw(c.kind), ' ', this.condList(c.cond, c.body[0]?.span.start ?? c.span.end), op(';'), ' ', kw('do'), this.body(c.body, c.span.end), this.closer(c.body), kw('done')], !this.simpleBody(c.body));
|
|
399
|
+
case 'For':
|
|
400
|
+
case 'Select': {
|
|
401
|
+
const head = [kw(c.type === 'For' ? 'for' : 'select'), ' ', tok(c.variable, 'var')];
|
|
402
|
+
if (c.items !== null)
|
|
403
|
+
head.push(' ', kw('in'), ...c.items.flatMap((w) => [' ', this.wordDoc(w)]));
|
|
404
|
+
return compoundGroup([head, op(';'), ' ', kw('do'), this.body(c.body, c.span.end), this.closer(c.body), kw('done')], !this.simpleBody(c.body));
|
|
405
|
+
}
|
|
406
|
+
case 'ArithFor':
|
|
407
|
+
return compoundGroup([this.arithForHead(c), op(';'), ' ', kw('do'), this.body(c.body, c.span.end), this.closer(c.body), kw('done')], !this.simpleBody(c.body));
|
|
408
|
+
case 'Case':
|
|
409
|
+
return this.caseDoc(c);
|
|
410
|
+
case 'ArithCommand':
|
|
411
|
+
case 'CondCommand':
|
|
412
|
+
return this.compoundText(c);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
groupable(body) {
|
|
416
|
+
if (this.opts.compounds === 'expanded')
|
|
417
|
+
return false;
|
|
418
|
+
return body.length > 0 && body.every((s) => {
|
|
419
|
+
const t = s.command.type;
|
|
420
|
+
return t === 'SimpleCommand' || t === 'Pipeline' || t === 'AndOr';
|
|
421
|
+
}) && body.length <= 3;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* `if`/`while` conditions: statements joined by `; ` (a trailing comment
|
|
425
|
+
* breaks the line). `limit` is where the body starts: a comment after it
|
|
426
|
+
* belongs to the body or the whole compound, not to the condition.
|
|
427
|
+
*/
|
|
428
|
+
condList(stmts, limit) {
|
|
429
|
+
const parts = [];
|
|
430
|
+
stmts.forEach((s, i) => {
|
|
431
|
+
const leading = this.take(s.span.start);
|
|
432
|
+
if (i > 0)
|
|
433
|
+
parts.push(leading.length ? hard : [op(';'), ' ']);
|
|
434
|
+
for (const cm of leading)
|
|
435
|
+
parts.push(this.commentDoc(cm), hard);
|
|
436
|
+
parts.push(this.stmt(s));
|
|
437
|
+
const next = stmts[i + 1];
|
|
438
|
+
const t = this.trailing(s.span.end, next ? next.span.start : limit);
|
|
439
|
+
if (t)
|
|
440
|
+
parts.push(this.trailingDoc(t));
|
|
441
|
+
});
|
|
442
|
+
return parts;
|
|
443
|
+
}
|
|
444
|
+
arithForHead(c) {
|
|
445
|
+
const exprs = [c.init, c.cond, c.step].filter((e) => e !== null);
|
|
446
|
+
const from = exprs.length ? exprs[exprs.length - 1].span.end : c.span.start;
|
|
447
|
+
const close = this.src.indexOf('))', from);
|
|
448
|
+
return this.verbatim({ start: c.span.start, end: close + 2 });
|
|
449
|
+
}
|
|
450
|
+
caseDoc(c) {
|
|
451
|
+
const ind = this.opts.indent;
|
|
452
|
+
const word = this.wordDoc(c.word);
|
|
453
|
+
const items = [];
|
|
454
|
+
for (const item of c.items) {
|
|
455
|
+
const leading = this.take(item.span.start);
|
|
456
|
+
for (const cm of leading)
|
|
457
|
+
items.push(hard, this.commentDoc(cm));
|
|
458
|
+
const pats = join(op('|'), item.patterns.map((p) => this.wordDoc(p)));
|
|
459
|
+
const term = op(item.terminator);
|
|
460
|
+
if (item.body.length === 0) {
|
|
461
|
+
items.push(hard, [pats, op(')'), ' ', term]);
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
const body = this.list(item.body, item.span.end, false);
|
|
465
|
+
items.push(hard, compoundGroup([pats, op(')'), indent([nl(' '), body, nl(' '), term], ind)], !this.simpleBody(item.body)));
|
|
466
|
+
}
|
|
467
|
+
const tail = this.take(c.span.end);
|
|
468
|
+
for (const cm of tail)
|
|
469
|
+
items.push(hard, this.commentDoc(cm));
|
|
470
|
+
return group([kw('case'), ' ', word, ' ', kw('in'), indent(items, ind), hard, kw('esac')], true);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Arguments as fill parts: `['', cont, a, cont, b, …]`. Fill alternates
|
|
475
|
+
* content and separator; the empty first content lets the separator between
|
|
476
|
+
* the command name and its first argument break like the others.
|
|
477
|
+
*/
|
|
478
|
+
function fillParts(units) {
|
|
479
|
+
const parts = [''];
|
|
480
|
+
for (const u of units)
|
|
481
|
+
parts.push(cont, u);
|
|
482
|
+
return parts;
|
|
483
|
+
}
|
|
484
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":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CAAC,CAAA;QAC5D,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;IAClG,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAY;IAC7B,MAAM,KAAK,GAAU,CAAC,EAAE,CAAC,CAAA;IACzB,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-line summaries: a snippet squeezed into a target width while keeping its
|
|
3
|
+
* *shape* (which commands run, how they are combined), e.g.
|
|
4
|
+
*
|
|
5
|
+
* cd …/harness-port && pnpm run build … > …/build.log 2>&1 && echo done
|
|
6
|
+
*
|
|
7
|
+
* The summary is a tree of structure tokens (command names, operators,
|
|
8
|
+
* keywords) and reducible parts. Starting from everything shown (with
|
|
9
|
+
* multi-line strings cut to their first line, here-doc bodies and comments
|
|
10
|
+
* omitted), it repeatedly applies the reduction with the lowest cost per
|
|
11
|
+
* column it saves (counting at most the columns still needed) until the line
|
|
12
|
+
* fits. Costs encode the priorities, cheapest first:
|
|
13
|
+
*
|
|
14
|
+
* shorten long strings, substitutions, words (head and closing quote kept) 1
|
|
15
|
+
* paths and redirection targets → their tail (`…/file.txt`) 1.2
|
|
16
|
+
* collapse assignment values (`FOO=…`; short ones cost double) 4
|
|
17
|
+
* hide plain arguments (strings, words) ┐ hidden runs merge into 3
|
|
18
|
+
* hide long flags (`--frozen-lockfile`) │ one `…` whose tooltip 3.5
|
|
19
|
+
* shorten path tails further │ lists them 4
|
|
20
|
+
* hide paths │ 6
|
|
21
|
+
* hide short flags (`-rn`) ┘ 8
|
|
22
|
+
* hide subcommands (`git status`) 80
|
|
23
|
+
* collapse compound bodies (`for …; do …; done`) 60
|
|
24
|
+
* drop trailing statements of a list (`a; b; …`) 100
|
|
25
|
+
* command names that are paths → their tail 150
|
|
26
|
+
* (and finally a hard cut at the width)
|
|
27
|
+
*
|
|
28
|
+
* Hiding an item of 6 columns or fewer costs double. Command names,
|
|
29
|
+
* operators, keywords and `]`/`]]` are never reduced.
|
|
30
|
+
*
|
|
31
|
+
* Every `…` keeps what it hides: truncated atoms carry the full text as a
|
|
32
|
+
* tooltip, hidden arguments and collapsed bodies carry their source.
|
|
33
|
+
*/
|
|
34
|
+
import type * as A from '../parser/ast.ts';
|
|
35
|
+
export interface SummaryOptions {
|
|
36
|
+
/** Target width in columns (default 80). */
|
|
37
|
+
width?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface SummaryResult {
|
|
40
|
+
/** The summary as plain text (`…` marks truncation). At most `width` columns, never a newline. */
|
|
41
|
+
text: string;
|
|
42
|
+
/** `<span class="mash sum">…</span>`: highlighted, with `el` ellipsis spans and `title` tooltips. */
|
|
43
|
+
html: string;
|
|
44
|
+
/** Number of reductions applied. */
|
|
45
|
+
reductions: number;
|
|
46
|
+
}
|
|
47
|
+
/** Parse and summarize. Unparsable input falls back to a whitespace-collapsed, cut source. */
|
|
48
|
+
export declare function summarize(source: string, options?: SummaryOptions): SummaryResult;
|
|
49
|
+
export declare function summarizeScript(script: A.Script, source: string, options?: SummaryOptions): SummaryResult;
|
|
50
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/printer/summary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,KAAK,CAAC,MAAM,kBAAkB,CAAA;AAI1C,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,kGAAkG;IAClG,IAAI,EAAE,MAAM,CAAA;IACZ,qGAAqG;IACrG,IAAI,EAAE,MAAM,CAAA;IACZ,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAA;CACnB;AA2BD,8FAA8F;AAC9F,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa,CAcrF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa,CA6C7G"}
|