reslop 0.2.6 → 0.3.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/CHANGELOG.md +27 -1
- package/README.md +16 -14
- package/bin/reslop.js +8 -5
- package/lib/agents/agents.js +504 -0
- package/lib/agents/allow.js +71 -0
- package/lib/agents/allow.json +16 -0
- package/lib/agents/models.js +460 -0
- package/lib/api.js +15 -12
- package/lib/cli.js +61 -66
- package/lib/{files.js → common/files.js} +51 -52
- package/lib/common/find.js +61 -0
- package/lib/common/format.js +101 -0
- package/lib/{utilities.js → common/process.js} +7 -95
- package/lib/common/tasks.json +27 -0
- package/lib/common/utilities.js +112 -0
- package/lib/dashboard/git.js +9 -16
- package/lib/dashboard/model.js +117 -51
- package/lib/dashboard/npm.js +133 -32
- package/lib/dashboard/tree.js +27 -30
- package/lib/{session → dashboard}/watch.js +41 -31
- package/lib/dashboard/workspace.js +151 -0
- package/lib/{deps.js → deps/deps.js} +31 -45
- package/lib/{deps-diff.js → deps/diff.js} +35 -25
- package/lib/{manifest.js → deps/manifest.js} +47 -30
- package/lib/diff/align.js +1 -2
- package/lib/diff/diff.js +2 -2
- package/lib/diff/display.js +29 -5
- package/lib/diff/inline.js +10 -14
- package/lib/diff/items.js +6 -4
- package/lib/diff/patch.js +39 -3
- package/lib/diff/unit.js +45 -16
- package/lib/{git-branches.js → git/branches.js} +53 -48
- package/lib/{git-deps.js → git/deps.js} +123 -95
- package/lib/git/git.js +71 -0
- package/lib/git/worktree.js +475 -0
- package/lib/highlight/bash.js +1 -2
- package/lib/highlight/csv.js +1 -2
- package/lib/highlight/dot.js +1 -2
- package/lib/{highlight.js → highlight/highlight.js} +42 -11
- package/lib/highlight/html.js +20 -18
- package/lib/highlight/json.js +1 -2
- package/lib/highlight/log.js +1 -2
- package/lib/highlight/txt.js +1 -2
- package/lib/{session → input}/actions.js +240 -71
- package/lib/{editor.js → input/editor.js} +7 -8
- package/lib/{keys.js → input/keys.js} +36 -39
- package/lib/input/line-edit.js +77 -0
- package/lib/input/menu-pick.js +70 -0
- package/lib/render/agents.js +640 -0
- package/lib/render/branches.js +4 -5
- package/lib/render/commits.js +54 -64
- package/lib/render/{dash-activity.js → dashboard/activity.js} +25 -40
- package/lib/render/dashboard/blocks.js +490 -0
- package/lib/render/{dashboard.js → dashboard/dashboard.js} +25 -22
- package/lib/render/diff.js +166 -45
- package/lib/render/field.js +131 -0
- package/lib/render/files.js +22 -8
- package/lib/render/footer.js +383 -0
- package/lib/render/frame.js +127 -25
- package/lib/render/header.js +176 -0
- package/lib/render/log.js +319 -0
- package/lib/render/menu.js +60 -0
- package/lib/render/notes.js +29 -13
- package/lib/render/npm.js +322 -196
- package/lib/render/packages.js +89 -0
- package/lib/render/primitives.js +109 -16
- package/lib/render/render.js +7 -11
- package/lib/render/repos.js +214 -0
- package/lib/render/status.js +370 -0
- package/lib/render/status.json +85 -0
- package/lib/render/{dash-table.js → table.js} +19 -61
- package/lib/render/tiles.js +203 -47
- package/lib/render/unit.js +32 -13
- package/lib/{report-model.js → report/model.js} +4 -6
- package/lib/{report-parse.js → report/parse.js} +9 -14
- package/lib/{report-render.js → report/render.js} +46 -14
- package/lib/{report-run.js → report/run.js} +42 -30
- package/lib/{report-test.js → report/test.js} +56 -55
- package/lib/{report-tools.js → report/tools.js} +24 -33
- package/lib/review/agent-instructions.md +9 -0
- package/lib/review/format.js +426 -0
- package/lib/{review-merge.js → review/merge.js} +9 -8
- package/lib/review/review.js +190 -0
- package/lib/review/store.js +281 -0
- package/lib/review/templates.js +83 -0
- package/lib/runs/commands.js +14 -0
- package/lib/runs/logs.js +299 -0
- package/lib/runs/output.js +174 -0
- package/lib/runs/process.js +113 -0
- package/lib/{runs.js → runs/runs.js} +84 -36
- package/lib/runs/scripts.js +150 -0
- package/lib/session/agents/agents.js +958 -0
- package/lib/session/agents/job.js +320 -0
- package/lib/session/agents/jobs.js +355 -0
- package/lib/session/agents/options.js +153 -0
- package/lib/session/agents/plans.js +83 -0
- package/lib/session/branches.js +36 -44
- package/lib/session/change-actions.js +34 -100
- package/lib/session/commit.js +122 -56
- package/lib/session/compose.js +197 -146
- package/lib/session/dashboard.js +183 -37
- package/lib/session/dispatch.js +120 -22
- package/lib/session/files-pane.js +60 -24
- package/lib/session/find.js +81 -0
- package/lib/session/import.js +82 -0
- package/lib/session/items.js +8 -17
- package/lib/session/lifecycle.js +96 -66
- package/lib/session/load.js +2 -4
- package/lib/session/navigation.js +8 -3
- package/lib/session/npm/history.js +249 -0
- package/lib/session/npm/npm.js +815 -0
- package/lib/session/npm/packages.js +150 -0
- package/lib/session/ops.js +125 -34
- package/lib/session/pointer.js +216 -10
- package/lib/session/prefs.js +112 -0
- package/lib/session/reads.js +109 -0
- package/lib/session/review.js +28 -10
- package/lib/session/run-panel.js +40 -0
- package/lib/{session.js → session/session.js} +166 -59
- package/lib/session/tasks.js +321 -66
- package/lib/session/templates.js +1 -1
- package/lib/session/terminal.js +94 -12
- package/lib/session/unit.js +35 -30
- package/lib/session/update.js +194 -6
- package/lib/session/view.js +72 -59
- package/lib/session/workspace.js +416 -0
- package/lib/{capabilities.js → source/capabilities.js} +3 -12
- package/lib/{github.js → source/github.js} +102 -32
- package/lib/{gitlab.js → source/gitlab.js} +87 -10
- package/lib/{remote.js → source/remote.js} +144 -40
- package/lib/source/review-threads.graphql +20 -0
- package/lib/source/source.js +74 -0
- package/lib/term/ansi.js +396 -0
- package/lib/{clipboard.js → term/clipboard.js} +3 -6
- package/lib/{select.js → term/select.js} +2 -2
- package/lib/term/themes/dark.json +122 -0
- package/lib/term/themes/light.json +122 -0
- package/lib/term/wide.txt +21 -0
- package/lib/{wrap.js → term/wrap.js} +4 -4
- package/package.json +2 -2
- package/lib/ansi.js +0 -505
- package/lib/detect.js +0 -34
- package/lib/diff/edit.js +0 -33
- package/lib/git-worktree.js +0 -437
- package/lib/git.js +0 -79
- package/lib/npm-commands.js +0 -522
- package/lib/render/chrome.js +0 -628
- package/lib/render/dash-blocks.js +0 -245
- package/lib/render/present.js +0 -19
- package/lib/render/report.js +0 -43
- package/lib/review.js +0 -744
- package/lib/session/accessors.js +0 -26
- package/lib/session/edit-click.js +0 -57
- package/lib/session/npm.js +0 -452
- package/lib/session/progress.js +0 -41
- package/lib/source.js +0 -36
- package/lib/update.js +0 -192
- /package/lib/{git-reword-todo.js → git/reword-todo.js} +0 -0
package/lib/session/accessors.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const bindAccessors = (target, owner, names) => {
|
|
4
|
-
for (const name of names) {
|
|
5
|
-
Object.defineProperty(target, name, {
|
|
6
|
-
configurable: true,
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: () => owner[name],
|
|
9
|
-
set: (value) => {
|
|
10
|
-
owner[name] = value;
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const bindGetters = (target, owner, names) => {
|
|
17
|
-
for (const name of names) {
|
|
18
|
-
Object.defineProperty(target, name, {
|
|
19
|
-
configurable: true,
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: () => owner[name],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
module.exports = { bindAccessors, bindGetters };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const wrap = require('../wrap.js');
|
|
4
|
-
const diff = require('../render/diff.js');
|
|
5
|
-
|
|
6
|
-
const { indexAtRow } = wrap;
|
|
7
|
-
const { codeInnerWidth } = diff;
|
|
8
|
-
|
|
9
|
-
const hitAt = (hits, cell) => {
|
|
10
|
-
for (const hit of hits) {
|
|
11
|
-
if (hit.y !== cell.y) continue;
|
|
12
|
-
const x0 = hit.x0 ?? hit.textX;
|
|
13
|
-
if (cell.x < x0) continue;
|
|
14
|
-
if (hit.x1 !== undefined && cell.x >= hit.x1) continue;
|
|
15
|
-
return hit;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const offsetOf = (hit, cellX) => {
|
|
21
|
-
const shown = cellX - hit.textX;
|
|
22
|
-
const col = Math.max(0, shown) + (hit.scroll || 0);
|
|
23
|
-
const at = indexAtRow(hit.start || 0, hit.text, col);
|
|
24
|
-
if (hit.limit !== undefined && at > hit.limit) return hit.limit;
|
|
25
|
-
return at;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const revealCode = (ui) => {
|
|
29
|
-
const kind = ui.composeKind;
|
|
30
|
-
if (kind !== 'code' && kind !== 'file') return;
|
|
31
|
-
const size = ui.lastSize ?? ui.getSize();
|
|
32
|
-
ui.editor.reveal(codeInnerWidth(size.width, ui.layout));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const focusField = (ui, hit) => {
|
|
36
|
-
if (!hit.field || !ui.npm) return true;
|
|
37
|
-
if (hit.field === ui.npm.editField) return true;
|
|
38
|
-
return ui.npm.focusField(hit.field);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const placeClick = (ui, cell) => {
|
|
42
|
-
if (ui.mode !== 'compose' || !ui.editor) return false;
|
|
43
|
-
const hits = ui.lastFrame && ui.lastFrame.editHits;
|
|
44
|
-
if (!hits || !hits.length) return false;
|
|
45
|
-
const hit = hitAt(hits, cell);
|
|
46
|
-
if (!hit) return false;
|
|
47
|
-
if (!focusField(ui, hit)) {
|
|
48
|
-
ui.paint();
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
ui.editor.place(offsetOf(hit, cell.x));
|
|
52
|
-
revealCode(ui);
|
|
53
|
-
ui.paint();
|
|
54
|
-
return true;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
module.exports = { placeClick };
|
package/lib/session/npm.js
DELETED
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const metautil = require('metautil');
|
|
4
|
-
const { bytesToSize } = metautil;
|
|
5
|
-
const commands = require('../npm-commands.js');
|
|
6
|
-
const npm = require('../render/npm.js');
|
|
7
|
-
const { logViewRows, expandLogLines } = npm;
|
|
8
|
-
const ansi = require('../ansi.js');
|
|
9
|
-
const { stripAnsi } = ansi;
|
|
10
|
-
const reportParse = require('../report-parse.js');
|
|
11
|
-
const { buildDocument } = reportParse;
|
|
12
|
-
const reportRender = require('../report-render.js');
|
|
13
|
-
const { renderDocument, loggedText } = reportRender;
|
|
14
|
-
const reportView = require('../render/report.js');
|
|
15
|
-
const { renderReport } = reportView;
|
|
16
|
-
|
|
17
|
-
const { listCommands, reduceOutput, nextLogFile, saveLogs } = commands;
|
|
18
|
-
const { staleLogFiles, removeStaleLogs, startNpm } = commands;
|
|
19
|
-
const { saveScript, removeScript, reorderScript } = commands;
|
|
20
|
-
|
|
21
|
-
const NAME_RE = /^[\w:.-]+$/;
|
|
22
|
-
const TESTS_RE = /^(?:TAP version \d+|\s*(?:not )?ok\b|[ℹi]\s+tests\s+\d+)/m;
|
|
23
|
-
|
|
24
|
-
const logRowCount = (text, width, running) => {
|
|
25
|
-
const visual = width > 0 ? expandLogLines(text, width).length : 0;
|
|
26
|
-
const extra = running ? 1 : 0;
|
|
27
|
-
if (visual) return visual + extra;
|
|
28
|
-
const lines = `${text ?? ''}`.split('\n');
|
|
29
|
-
const count = lines.at(-1) === '' ? lines.length - 1 : lines.length;
|
|
30
|
-
return count + extra;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const filteredOutput = (raw, root, status, rawFile) => {
|
|
34
|
-
const text = stripAnsi(`${raw ?? ''}`);
|
|
35
|
-
if (status === '' || !TESTS_RE.test(text)) {
|
|
36
|
-
const output = reduceOutput(raw, root, status);
|
|
37
|
-
return { output, log: output };
|
|
38
|
-
}
|
|
39
|
-
const doc = buildDocument(raw, '', root, status, 'test');
|
|
40
|
-
return { output: renderReport(doc), log: renderDocument(doc, rawFile) };
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const runLabel = (entry) =>
|
|
44
|
-
entry.kind === 'bin' ? `npm exec ${entry.name}` : `npm run ${entry.name}`;
|
|
45
|
-
|
|
46
|
-
const withNotice = (text, notice) => {
|
|
47
|
-
const body = `${text ?? ''}`;
|
|
48
|
-
if (body.endsWith(`${notice}\n`)) return body;
|
|
49
|
-
if (!body) return `${notice}\n`;
|
|
50
|
-
if (body.endsWith('\n')) return `${body}${notice}\n`;
|
|
51
|
-
return `${body}\n${notice}\n`;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const withNewline = (text) => {
|
|
55
|
-
const body = `${text ?? ''}`;
|
|
56
|
-
if (!body || body.endsWith('\n')) return body;
|
|
57
|
-
return `${body}\n`;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
class NpmController {
|
|
61
|
-
constructor(ui) {
|
|
62
|
-
this.ui = ui;
|
|
63
|
-
this.child = null;
|
|
64
|
-
this.running = false;
|
|
65
|
-
this.reset();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
reset() {
|
|
69
|
-
if (this.child) this.child.kill();
|
|
70
|
-
this.stopRun();
|
|
71
|
-
this.commands = [];
|
|
72
|
-
this.viewing = false;
|
|
73
|
-
this.output = '';
|
|
74
|
-
this.followEnd = true;
|
|
75
|
-
this.logScroll = 0;
|
|
76
|
-
this.editName = '';
|
|
77
|
-
this.editField = '';
|
|
78
|
-
this.draftName = '';
|
|
79
|
-
this.draftCommand = '';
|
|
80
|
-
this.verbose = false;
|
|
81
|
-
this.raw = '';
|
|
82
|
-
this.exitStatus = '';
|
|
83
|
-
this.dropName = '';
|
|
84
|
-
this.dropKind = '';
|
|
85
|
-
this.logBytes = 0;
|
|
86
|
-
this.stopping = false;
|
|
87
|
-
this.runLabel = '';
|
|
88
|
-
this.startedAt = 0;
|
|
89
|
-
this.endedAt = 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
get logLabel() {
|
|
93
|
-
if (!this.logBytes) return '';
|
|
94
|
-
return `old logs ${bytesToSize(this.logBytes)}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
get lastRun() {
|
|
98
|
-
if (!this.startedAt) return null;
|
|
99
|
-
return {
|
|
100
|
-
label: this.runLabel,
|
|
101
|
-
running: this.running,
|
|
102
|
-
exit: this.exitStatus,
|
|
103
|
-
startedAt: this.startedAt,
|
|
104
|
-
endedAt: this.endedAt,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
selected() {
|
|
109
|
-
return this.commands[this.ui.nav.npmCursor];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
refresh() {
|
|
113
|
-
this.commands = listCommands(this.ui.top);
|
|
114
|
-
const last = this.commands.length - 1;
|
|
115
|
-
const nav = this.ui.nav;
|
|
116
|
-
nav.npmCursor = Math.max(0, Math.min(nav.npmCursor, last));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
refreshLogs() {
|
|
120
|
-
try {
|
|
121
|
-
this.logBytes = staleLogFiles(this.ui.top).bytes;
|
|
122
|
-
} catch (error) {
|
|
123
|
-
this.logBytes = 0;
|
|
124
|
-
this.ui.status = error.message;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
open() {
|
|
129
|
-
if (this.ui.mode === 'compose') return;
|
|
130
|
-
this.refresh();
|
|
131
|
-
this.refreshLogs();
|
|
132
|
-
this.viewing = false;
|
|
133
|
-
this.output = '';
|
|
134
|
-
const nav = this.ui.nav;
|
|
135
|
-
nav.pane = 'npm';
|
|
136
|
-
nav.resetListScroll('npm');
|
|
137
|
-
this.ui.status = '';
|
|
138
|
-
nav.clearSelection();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
scrollLog(delta) {
|
|
142
|
-
const { lastFrame, lastSize } = this.ui;
|
|
143
|
-
const width = lastSize && lastSize.width ? lastSize.width : 0;
|
|
144
|
-
const count = logRowCount(this.output, width, this.running);
|
|
145
|
-
const bodyH = lastFrame && lastFrame.bodyH ? lastFrame.bodyH : 1;
|
|
146
|
-
const max = Math.max(0, count - logViewRows(bodyH));
|
|
147
|
-
const from = this.followEnd ? max : this.logScroll;
|
|
148
|
-
const start = Math.min(max, Math.max(0, from + delta));
|
|
149
|
-
this.followEnd = start === max;
|
|
150
|
-
this.logScroll = start;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
move(delta) {
|
|
154
|
-
if (this.viewing) return void this.scrollLog(delta);
|
|
155
|
-
if (!this.commands.length) return;
|
|
156
|
-
const nav = this.ui.nav;
|
|
157
|
-
const last = this.commands.length - 1;
|
|
158
|
-
const next = Math.min(last, Math.max(0, nav.npmCursor + delta));
|
|
159
|
-
if (next === nav.npmCursor) return;
|
|
160
|
-
nav.npmCursor = next;
|
|
161
|
-
this.ui.status = '';
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
stopRun() {
|
|
165
|
-
if (this.running) this.endedAt = Date.now();
|
|
166
|
-
this.running = false;
|
|
167
|
-
this.child = null;
|
|
168
|
-
this.ui.progress.stop('npm');
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
shownOutput(raw, status) {
|
|
172
|
-
if (this.verbose) return withNewline(raw);
|
|
173
|
-
return filteredOutput(raw, this.ui.top, status).output;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
showOutput(text) {
|
|
177
|
-
if (!this.viewing || !this.running || this.stopping) return;
|
|
178
|
-
this.raw = text;
|
|
179
|
-
this.output = this.shownOutput(text, '');
|
|
180
|
-
this.ui.paint();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async finishRun(entry, result) {
|
|
184
|
-
const ui = this.ui;
|
|
185
|
-
const stopped = this.stopping === true;
|
|
186
|
-
const raw = stopped ? withNotice(this.raw, 'terminated') : result.text;
|
|
187
|
-
let slot = null;
|
|
188
|
-
try {
|
|
189
|
-
slot = nextLogFile(ui.top, entry.name);
|
|
190
|
-
} catch (error) {
|
|
191
|
-
ui.status = error.message;
|
|
192
|
-
}
|
|
193
|
-
const rawFile = slot ? slot.rawName : '';
|
|
194
|
-
const stoppedOutput = () => {
|
|
195
|
-
const output = withNotice(
|
|
196
|
-
reduceOutput(this.raw, ui.top, ''),
|
|
197
|
-
'terminated',
|
|
198
|
-
);
|
|
199
|
-
return { output, log: output };
|
|
200
|
-
};
|
|
201
|
-
const filtered = stopped
|
|
202
|
-
? stoppedOutput()
|
|
203
|
-
: filteredOutput(result.text, ui.top, result.status, rawFile);
|
|
204
|
-
this.raw = raw;
|
|
205
|
-
this.exitStatus = stopped ? '' : result.status;
|
|
206
|
-
this.output = this.verbose ? this.shownOutput(raw, '') : filtered.output;
|
|
207
|
-
this.stopping = false;
|
|
208
|
-
this.stopRun();
|
|
209
|
-
if (stopped && this.viewing) ui.status = 'terminated';
|
|
210
|
-
ui.paint();
|
|
211
|
-
if (!slot) return;
|
|
212
|
-
try {
|
|
213
|
-
await saveLogs(slot, loggedText(filtered.log, slot.rawName), raw);
|
|
214
|
-
} catch (error) {
|
|
215
|
-
ui.status = error.message;
|
|
216
|
-
ui.paint();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
startRun(entry) {
|
|
221
|
-
const ui = this.ui;
|
|
222
|
-
this.output = '';
|
|
223
|
-
this.raw = '';
|
|
224
|
-
this.exitStatus = '';
|
|
225
|
-
this.viewing = true;
|
|
226
|
-
this.followEnd = true;
|
|
227
|
-
this.logScroll = 0;
|
|
228
|
-
this.running = true;
|
|
229
|
-
this.stopping = false;
|
|
230
|
-
this.runLabel = runLabel(entry);
|
|
231
|
-
this.startedAt = Date.now();
|
|
232
|
-
this.endedAt = 0;
|
|
233
|
-
ui.status = '';
|
|
234
|
-
ui.progress.start('npm');
|
|
235
|
-
const start = (ui.repo && ui.repo.runNpmCommand) || startNpm;
|
|
236
|
-
const child = start(
|
|
237
|
-
ui.top,
|
|
238
|
-
entry,
|
|
239
|
-
(text) => this.showOutput(text),
|
|
240
|
-
(result) => this.finishRun(entry, result),
|
|
241
|
-
);
|
|
242
|
-
if (this.running) this.child = child;
|
|
243
|
-
ui.paint();
|
|
244
|
-
return child;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
run() {
|
|
248
|
-
if (this.viewing || this.child) return null;
|
|
249
|
-
const entry = this.selected();
|
|
250
|
-
if (!entry) return null;
|
|
251
|
-
this.verbose = false;
|
|
252
|
-
return this.startRun(entry);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
rerun() {
|
|
256
|
-
if (!this.viewing || this.running) return;
|
|
257
|
-
const entry = this.selected();
|
|
258
|
-
if (entry) this.startRun(entry);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
closeView() {
|
|
262
|
-
const ui = this.ui;
|
|
263
|
-
if (!this.running) {
|
|
264
|
-
this.viewing = false;
|
|
265
|
-
this.verbose = false;
|
|
266
|
-
ui.status = '';
|
|
267
|
-
return void ui.paint();
|
|
268
|
-
}
|
|
269
|
-
this.stopping = true;
|
|
270
|
-
if (this.child) this.child.kill();
|
|
271
|
-
if (!this.running) return;
|
|
272
|
-
this.raw = withNotice(this.raw, 'terminated');
|
|
273
|
-
this.output = this.verbose
|
|
274
|
-
? this.shownOutput(this.raw, '')
|
|
275
|
-
: withNotice(this.output, 'terminated');
|
|
276
|
-
this.stopRun();
|
|
277
|
-
ui.status = 'terminated';
|
|
278
|
-
ui.paint();
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
toggleVerbose() {
|
|
282
|
-
if (!this.viewing) return;
|
|
283
|
-
this.verbose = !this.verbose;
|
|
284
|
-
const status = this.running ? '' : this.exitStatus;
|
|
285
|
-
this.output = this.shownOutput(this.raw, status);
|
|
286
|
-
this.ui.status = this.verbose ? 'verbose' : 'filtered';
|
|
287
|
-
this.ui.paint();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
editable() {
|
|
291
|
-
if (this.viewing) return false;
|
|
292
|
-
const ui = this.ui;
|
|
293
|
-
const caps = ui.capabilities;
|
|
294
|
-
if (!ui.readOnly && (!caps || caps.changes !== false)) return true;
|
|
295
|
-
ui.status = 'read only';
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
selectedScript() {
|
|
300
|
-
if (!this.editable()) return null;
|
|
301
|
-
const entry = this.selected();
|
|
302
|
-
if (entry && entry.kind === 'script') return entry;
|
|
303
|
-
this.ui.status = 'not a script';
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
focusScript(name) {
|
|
308
|
-
const at = this.commands.findIndex((entry) => entry.name === name);
|
|
309
|
-
if (at >= 0) this.ui.nav.npmCursor = at;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
startEdit(name, command) {
|
|
313
|
-
this.editName = name;
|
|
314
|
-
this.editField = 'name';
|
|
315
|
-
this.draftName = name;
|
|
316
|
-
this.draftCommand = command;
|
|
317
|
-
this.ui.composer.openCompose('npm', name);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
edit() {
|
|
321
|
-
const entry = this.selectedScript();
|
|
322
|
-
if (entry) this.startEdit(entry.name, entry.command ?? '');
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
create() {
|
|
326
|
-
if (this.editable()) this.startEdit('', '');
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
switchField(editor, field, text) {
|
|
330
|
-
this.editField = field;
|
|
331
|
-
editor.replace(text);
|
|
332
|
-
this.ui.status = '';
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
finishName(editor) {
|
|
336
|
-
const name = editor.text.trim();
|
|
337
|
-
if (!name || !NAME_RE.test(name)) {
|
|
338
|
-
this.ui.status = 'name';
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
this.draftName = name;
|
|
342
|
-
this.switchField(editor, 'command', this.draftCommand);
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
focusField(field) {
|
|
347
|
-
const editor = this.ui.editor;
|
|
348
|
-
if (!editor) return false;
|
|
349
|
-
if (field === this.editField) return true;
|
|
350
|
-
if (field === 'command') return this.finishName(editor);
|
|
351
|
-
this.draftCommand = editor.text;
|
|
352
|
-
this.switchField(editor, 'name', this.draftName);
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
writeScripts(write) {
|
|
357
|
-
try {
|
|
358
|
-
this.ui.ignoreWatch();
|
|
359
|
-
write(this.ui.top);
|
|
360
|
-
return true;
|
|
361
|
-
} catch (error) {
|
|
362
|
-
this.ui.status = error.message;
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
finishEdit() {
|
|
368
|
-
const ui = this.ui;
|
|
369
|
-
const editor = ui.composer.editor;
|
|
370
|
-
if (!editor) return;
|
|
371
|
-
if (this.editField !== 'command') return void this.finishName(editor);
|
|
372
|
-
const command = editor.text.trim();
|
|
373
|
-
if (!command) {
|
|
374
|
-
ui.status = 'command';
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
const parsed = { name: this.draftName, command };
|
|
378
|
-
const write = (top) => saveScript(top, this.editName, parsed);
|
|
379
|
-
if (!this.writeScripts(write)) return;
|
|
380
|
-
this.editField = '';
|
|
381
|
-
ui.composer.closeCompose();
|
|
382
|
-
this.refresh();
|
|
383
|
-
this.focusScript(parsed.name);
|
|
384
|
-
ui.status = 'saved';
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
confirm(kind, name) {
|
|
388
|
-
this.dropKind = kind;
|
|
389
|
-
this.dropName = name;
|
|
390
|
-
this.ui.mode = 'confirmDrop';
|
|
391
|
-
this.ui.status = '';
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
askDrop() {
|
|
395
|
-
const entry = this.selectedScript();
|
|
396
|
-
if (entry) this.confirm('script', entry.name);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
askLogs() {
|
|
400
|
-
if (!this.editable()) return;
|
|
401
|
-
this.refreshLogs();
|
|
402
|
-
if (!this.logBytes) return;
|
|
403
|
-
const size = bytesToSize(this.logBytes);
|
|
404
|
-
this.confirm('logs', `logs older than 5 days (${size})`);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
cancelDrop() {
|
|
408
|
-
this.dropName = '';
|
|
409
|
-
this.dropKind = '';
|
|
410
|
-
this.ui.mode = 'review';
|
|
411
|
-
this.ui.status = '';
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
confirmDrop() {
|
|
415
|
-
const ui = this.ui;
|
|
416
|
-
const kind = this.dropKind;
|
|
417
|
-
const name = this.dropName;
|
|
418
|
-
this.dropName = '';
|
|
419
|
-
this.dropKind = '';
|
|
420
|
-
ui.mode = 'review';
|
|
421
|
-
if (kind === 'logs') {
|
|
422
|
-
try {
|
|
423
|
-
removeStaleLogs(ui.top);
|
|
424
|
-
} catch (error) {
|
|
425
|
-
ui.status = error.message;
|
|
426
|
-
return void this.refreshLogs();
|
|
427
|
-
}
|
|
428
|
-
this.refreshLogs();
|
|
429
|
-
ui.status = 'dropped logs';
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
if (!name) return;
|
|
433
|
-
if (!this.writeScripts((top) => removeScript(top, name))) return;
|
|
434
|
-
this.refresh();
|
|
435
|
-
ui.status = `dropped ${name}`;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
reorder(delta) {
|
|
439
|
-
const entry = this.selectedScript();
|
|
440
|
-
if (!entry) return;
|
|
441
|
-
let moved = false;
|
|
442
|
-
const write = (top) => {
|
|
443
|
-
moved = reorderScript(top, entry.name, delta);
|
|
444
|
-
};
|
|
445
|
-
if (!this.writeScripts(write) || !moved) return;
|
|
446
|
-
this.refresh();
|
|
447
|
-
this.focusScript(entry.name);
|
|
448
|
-
this.ui.status = '';
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
module.exports = { NpmController };
|
package/lib/session/progress.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class Progress {
|
|
4
|
-
constructor(term, onTick, intervalMs) {
|
|
5
|
-
this.term = term;
|
|
6
|
-
this.onTick = onTick;
|
|
7
|
-
this.intervalMs = intervalMs;
|
|
8
|
-
this.active = new Set();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
tick() {
|
|
12
|
-
if (!this.active.size) return;
|
|
13
|
-
this.onTick();
|
|
14
|
-
this.schedule();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
schedule() {
|
|
18
|
-
this.term.later('progress', () => this.tick(), this.intervalMs);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
start(id) {
|
|
22
|
-
this.active.add(id);
|
|
23
|
-
this.schedule();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
stop(id) {
|
|
27
|
-
this.active.delete(id);
|
|
28
|
-
if (!this.active.size) this.term.cancel('progress');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
clear() {
|
|
32
|
-
this.active.clear();
|
|
33
|
-
this.term.cancel('progress');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
size() {
|
|
37
|
-
return this.active.size;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = { Progress };
|
package/lib/source.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const github = require('./github.js');
|
|
4
|
-
const { parseGithubPrUrl } = github;
|
|
5
|
-
const gitlab = require('./gitlab.js');
|
|
6
|
-
const { parseGitlabMrUrl } = gitlab;
|
|
7
|
-
const capabilities = require('./capabilities.js');
|
|
8
|
-
const { capabilitiesFor, attachCapabilities } = capabilities;
|
|
9
|
-
|
|
10
|
-
const selectChangeSource = (paths) => {
|
|
11
|
-
if (!paths.length) return { kind: 'local', paths };
|
|
12
|
-
const first = paths[0];
|
|
13
|
-
const pr = parseGithubPrUrl(first);
|
|
14
|
-
if (pr) return { kind: 'pr', pr, paths: paths.slice(1) };
|
|
15
|
-
const mr = parseGitlabMrUrl(first);
|
|
16
|
-
if (mr) return { kind: 'mr', mr, paths: paths.slice(1) };
|
|
17
|
-
return { kind: 'local', paths };
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const createLoadedSource = (loaded, kind = 'pr', extra = {}) => {
|
|
21
|
-
const load = () => {
|
|
22
|
-
const items = loaded.items ?? [];
|
|
23
|
-
return { ...loaded, items: [...items] };
|
|
24
|
-
};
|
|
25
|
-
const impl = {
|
|
26
|
-
load,
|
|
27
|
-
resolveRev: () => null,
|
|
28
|
-
};
|
|
29
|
-
if (extra.loadAsync) impl.loadAsync = extra.loadAsync;
|
|
30
|
-
return attachCapabilities(impl, capabilitiesFor(kind));
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
module.exports = {
|
|
34
|
-
selectChangeSource,
|
|
35
|
-
createLoadedSource,
|
|
36
|
-
};
|