@basaltkit/deploy-ui 0.1.0 → 0.1.2
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 +11 -1
- package/dist/client/app.js +30 -13
- package/dist/client/dialog.js +3 -2
- package/dist/client/dom.js +33 -1
- package/dist/client/icons.js +47 -0
- package/dist/client/reply.js +4 -3
- package/dist/client/view-history.js +9 -4
- package/dist/client/view-plan.js +25 -8
- package/dist/client/view-run.js +47 -20
- package/dist/client/view-status.js +42 -20
- package/dist/client/view-targets.js +12 -8
- package/dist/page.d.ts +2 -2
- package/dist/page.js +435 -66
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -10,6 +10,13 @@ Design and threat model: [RFC 0009](https://github.com/basaltkit/basalt/blob/mai
|
|
|
10
10
|
(it builds on the machine protocol of [RFC 0008](https://github.com/basaltkit/basalt/blob/main/docs/rfcs/0008-deploy-machine-protocol.md)
|
|
11
11
|
and the pipeline of [RFC 0006](https://github.com/basaltkit/basalt/blob/main/docs/rfcs/0006-basalt-deploy.md)).
|
|
12
12
|
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
**Illustrated guide:** [Deploying from the local UI](https://basaltkit-docs.pages.dev/guide/deploy#ui)
|
|
16
|
+
covers adding a target, SSH keys and `known_hosts`, `node` under nvm, plan and
|
|
17
|
+
deploy, the live run, cancel, rollback and protected targets, with a
|
|
18
|
+
troubleshooting table ([Português](https://basaltkit-docs.pages.dev/pt/guide/deploy#ui)).
|
|
19
|
+
|
|
13
20
|
## Start it
|
|
14
21
|
|
|
15
22
|
```sh
|
|
@@ -69,7 +76,7 @@ repository must not be able to repoint it. The file holds no secret.
|
|
|
69
76
|
| `ssh` | `[user@]host` or a `Host` alias of your `~/.ssh/config` — jump hosts, identity files and proxies go there |
|
|
70
77
|
| `port` | optional, 1–65535 |
|
|
71
78
|
| `dir` | the checkout on the server, absolute |
|
|
72
|
-
| `node` | optional absolute path, when a non-interactive shell has no `node` on `PATH` (nvm) |
|
|
79
|
+
| `node` | optional absolute path, when a non-interactive shell has no `node` on `PATH` (nvm); from `@basaltkit/deploy` 0.5.1 the deploy puts its directory on `PATH` for `pnpm` and the app's scripts too |
|
|
73
80
|
| `config` | optional `--config` path, relative to the checkout |
|
|
74
81
|
| `protected` | deploy and rollback need the target's name typed |
|
|
75
82
|
| `actor` | recorded with each release (`--actor`); default: your OS user name |
|
|
@@ -159,6 +166,9 @@ the tab (RFC 0009 §15).
|
|
|
159
166
|
|
|
160
167
|
## Troubleshooting
|
|
161
168
|
|
|
169
|
+
Every message, with its fix, is in the guide's
|
|
170
|
+
[troubleshooting section](https://basaltkit-docs.pages.dev/guide/deploy#troubleshooting).
|
|
171
|
+
|
|
162
172
|
| The UI says | Do |
|
|
163
173
|
|---|---|
|
|
164
174
|
| the server refused your SSH key | `ssh-add`, then check `ssh deploy@host` works from a terminal |
|
package/dist/client/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiError } from './api.js';
|
|
2
2
|
import { confirmDialog } from './dialog.js';
|
|
3
|
-
import { button, el, replace } from './dom.js';
|
|
3
|
+
import { button, el, emptyState, quiet, replace } from './dom.js';
|
|
4
|
+
import { icon } from './icons.js';
|
|
4
5
|
import { describe } from './reply.js';
|
|
5
6
|
import { renderHistory } from './view-history.js';
|
|
6
7
|
import { renderPlan } from './view-plan.js';
|
|
@@ -20,7 +21,7 @@ export function forgetSession(storage) {
|
|
|
20
21
|
// No storage: nothing kept.
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
const SCREENS = [['status', 'Status'], ['plan', 'Plan & deploy'], ['history', 'History'], ['run', 'Run'], ['targets', 'Targets']];
|
|
24
|
+
const SCREENS = [['status', 'Status', 'status'], ['plan', 'Plan & deploy', 'plan'], ['history', 'History', 'history'], ['run', 'Run', 'run'], ['targets', 'Targets', 'targets']];
|
|
24
25
|
/** Per-target state the screens render; every server string in it is shown as text only. */
|
|
25
26
|
export class App {
|
|
26
27
|
api;
|
|
@@ -53,9 +54,9 @@ export class App {
|
|
|
53
54
|
this.stopped = true;
|
|
54
55
|
this.run?.stop();
|
|
55
56
|
forgetSession(this.storage);
|
|
56
|
-
replace(this.shell.main, el('div', { class: 'banner err', role: 'alert' }, el('strong', {}, error.why === 'unverified' ? 'This page no longer talks to your deploy UI.' : 'The deploy UI has stopped.'), el('p', {}, error.message), el('p', {}, 'Nothing was sent. Detached runs go on on the server. Start basalt-deploy-ui again and open the URL it prints.')));
|
|
57
|
+
replace(this.shell.main, el('div', { class: 'stopped' }, emptyState('power', 'Disconnected', 'This page sends nothing from here on.'), el('div', { class: 'banner err', role: 'alert' }, icon('error', 'icon banner-icon'), el('div', { class: 'banner-body' }, el('strong', { class: 'banner-title' }, error.why === 'unverified' ? 'This page no longer talks to your deploy UI.' : 'The deploy UI has stopped.'), el('p', {}, error.message), el('p', {}, 'Nothing was sent. Detached runs go on on the server. Start basalt-deploy-ui again and open the URL it prints.')))));
|
|
57
58
|
replace(this.shell.nav);
|
|
58
|
-
|
|
59
|
+
this.clearBar();
|
|
59
60
|
replace(this.shell.session);
|
|
60
61
|
}
|
|
61
62
|
get status() {
|
|
@@ -65,7 +66,7 @@ export class App {
|
|
|
65
66
|
return this.planReply?.result;
|
|
66
67
|
}
|
|
67
68
|
async start() {
|
|
68
|
-
replace(this.shell.session,
|
|
69
|
+
replace(this.shell.session, el('button', { type: 'button', class: 'ghost danger', on: { click: () => { void this.quit(); } } }, icon('power'), 'Quit'));
|
|
69
70
|
await this.loadTargets();
|
|
70
71
|
const first = this.targets.targets[0];
|
|
71
72
|
if (first) {
|
|
@@ -113,35 +114,50 @@ export class App {
|
|
|
113
114
|
if (screen === 'targets')
|
|
114
115
|
return replace(main, renderTargets(this));
|
|
115
116
|
if (!this.current)
|
|
116
|
-
return replace(main,
|
|
117
|
+
return replace(main, emptyState('targets', 'No target selected', 'Add a target first.', el('span', { class: 'row' }, button('Targets', () => this.show('targets'), { class: 'primary' }))));
|
|
117
118
|
if (screen === 'status')
|
|
118
119
|
return replace(main, renderStatus(this));
|
|
119
120
|
if (screen === 'plan')
|
|
120
121
|
return replace(main, renderPlan(this));
|
|
121
122
|
if (screen === 'history')
|
|
122
123
|
return replace(main, renderHistory(this));
|
|
123
|
-
replace(main, this.run ? this.run.element : el('
|
|
124
|
+
replace(main, this.run ? this.run.element : el('section', { aria: { label: 'Run' } }, emptyState('run', 'Nothing running here', 'No run in this tab yet: start one from Plan & deploy, or attach from Status.')));
|
|
124
125
|
}
|
|
125
126
|
/** Re-renders the current screen (after a state change). */
|
|
126
127
|
refresh() {
|
|
127
128
|
this.show(this.screen);
|
|
128
129
|
}
|
|
129
130
|
renderNav() {
|
|
130
|
-
const select = el('select', { aria: { label: 'Target' }, on: { change: (event) => { this.select(event.target.value); this.refresh(); if (this.current)
|
|
131
|
+
const select = el('select', { id: 'target-select', aria: { label: 'Target' }, on: { change: (event) => { this.select(event.target.value); this.refresh(); if (this.current)
|
|
131
132
|
void this.refreshStatus(); } } }, ...this.targets.targets.map((t) => {
|
|
132
133
|
const option = el('option', { value: t.name }, t.name);
|
|
133
134
|
option.selected = t.name === this.current?.name;
|
|
134
135
|
return option;
|
|
135
136
|
}));
|
|
136
|
-
replace(this.shell.nav, this.targets.targets.length > 0 ?
|
|
137
|
+
replace(this.shell.nav, this.targets.targets.length > 0 ? el('div', { class: 'nav-target' }, el('label', { class: 'section-label', for: 'target-select' }, 'Target'), select) : null, el('div', { class: 'nav-list' }, ...SCREENS.map(([screen, label, name]) => el('button', {
|
|
138
|
+
type: 'button', class: 'nav-item', ...(screen === this.screen ? { aria: { current: 'page' } } : {}),
|
|
139
|
+
on: { click: () => this.show(screen) },
|
|
140
|
+
}, icon(name), label))));
|
|
137
141
|
}
|
|
138
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* "Am I about to deploy production?": name, destination, the server's host
|
|
144
|
+
* name and the app — on every screen. The dividers are text (" · ") for
|
|
145
|
+
* screen readers and copy, drawn as rules.
|
|
146
|
+
*/
|
|
139
147
|
renderBar() {
|
|
140
148
|
const t = this.current;
|
|
141
149
|
if (!t)
|
|
142
|
-
return
|
|
150
|
+
return this.clearBar();
|
|
143
151
|
const status = this.status;
|
|
144
|
-
|
|
152
|
+
const sep = () => el('span', { class: 'ctx-sep', aria: { hidden: 'true' } }, ' · ');
|
|
153
|
+
const item = (name, value, label) => [sep(),
|
|
154
|
+
el('span', { class: 'ctx-item' }, icon(name), label ? el('span', { class: 'ctx-label' }, label) : null, label ? ' ' : null, el('span', { class: 'ctx-val' }, value))];
|
|
155
|
+
this.shell.bar.classList.toggle('is-protected', t.protected === true);
|
|
156
|
+
replace(this.shell.bar, el('span', { class: 'ctx-target' }, el('strong', { class: 'ctx-name' }, t.name), t.protected ? el('span', { class: 'badge badge-protected', title: 'Deploy and rollback ask for the name to be typed' }, icon('shield'), quiet(' '), 'PROTECTED') : null), ...item('terminal', `${t.ssh}${t.port ? `:${t.port}` : ''}`), ...item('folder', t.dir), ...(this.hello ? [...item('server', this.hello.host, 'host'), ...item('tag', this.hello.version, 'deploy')] : []), ...(status ? item('app', status.app, 'app') : []));
|
|
157
|
+
}
|
|
158
|
+
clearBar() {
|
|
159
|
+
this.shell.bar.classList.remove('is-protected');
|
|
160
|
+
replace(this.shell.bar);
|
|
145
161
|
}
|
|
146
162
|
async refreshStatus() {
|
|
147
163
|
const t = this.current;
|
|
@@ -228,8 +244,9 @@ export class App {
|
|
|
228
244
|
}
|
|
229
245
|
this.stopped = true;
|
|
230
246
|
forgetSession(this.storage);
|
|
231
|
-
replace(this.shell.main, el('
|
|
247
|
+
replace(this.shell.main, el('div', { class: 'stopped' }, emptyState('power', 'Stopped', 'The deploy UI has stopped. You can close this tab.', 'Detached runs go on on the server; start basalt-deploy-ui again to re-attach.')));
|
|
232
248
|
replace(this.shell.nav);
|
|
249
|
+
this.clearBar();
|
|
233
250
|
replace(this.shell.session);
|
|
234
251
|
}
|
|
235
252
|
}
|
package/dist/client/dialog.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { append, button, el } from './dom.js';
|
|
2
|
+
import { icon } from './icons.js';
|
|
2
3
|
/**
|
|
3
4
|
* A native modal `<dialog>` (focus stays inside, Escape cancels). Resolves
|
|
4
5
|
* true only on the confirm button.
|
|
5
6
|
*/
|
|
6
7
|
export function confirmDialog(options, host = document.body) {
|
|
7
8
|
return new Promise((resolve) => {
|
|
8
|
-
const dialog = el('dialog', { aria: { labelledby: 'confirm-title' } });
|
|
9
|
+
const dialog = el('dialog', { class: options.danger ? 'is-danger' : '', aria: { labelledby: 'confirm-title' } });
|
|
9
10
|
let settled = false;
|
|
10
11
|
const finish = (answer) => {
|
|
11
12
|
if (settled)
|
|
@@ -27,7 +28,7 @@ export function confirmDialog(options, host = document.body) {
|
|
|
27
28
|
on: { input: () => { confirm.disabled = typed.value !== expected; } },
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
append(dialog, el('h2', { id: 'confirm-title' }, options.title), ...options.lines.map((line) => el('p', {}, line)), typed ? el('div', { class: 'field' }, el('label', { for: 'confirm-name' },
|
|
31
|
+
append(dialog, el('div', { class: 'dialog-head' }, el('span', { class: 'dialog-icon' }, icon(options.danger ? 'alert' : 'info')), el('h2', { id: 'confirm-title' }, options.title)), el('div', { class: 'dialog-body' }, options.context ? el('p', { class: 'dialog-context' }, options.context) : null, options.typeToConfirm !== undefined ? el('p', { class: 'dialog-protected' }, el('span', { class: 'badge badge-protected' }, icon('shield'), 'PROTECTED'), ' This target is protected.') : null, ...options.lines.filter((line) => line !== null && line !== undefined && line !== false && line !== '').map((line) => el('p', {}, line)), typed ? el('div', { class: 'field' }, el('label', { for: 'confirm-name' }, 'Type ', el('code', {}, options.typeToConfirm), ' to confirm'), typed) : null), el('div', { class: 'dialog-actions' }, dismiss, confirm));
|
|
31
32
|
dialog.addEventListener('cancel', (event) => { event.preventDefault(); finish(false); });
|
|
32
33
|
dialog.addEventListener('keydown', (event) => { if (event.key === 'Escape')
|
|
33
34
|
finish(false); });
|
package/dist/client/dom.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { icon } from './icons.js';
|
|
1
2
|
import { clean } from './sanitize.js';
|
|
2
3
|
export function text(value) {
|
|
3
4
|
return document.createTextNode(clean(value));
|
|
@@ -8,7 +9,7 @@ export function el(tag, props = {}, ...children) {
|
|
|
8
9
|
node.className = props.class;
|
|
9
10
|
if (props.id)
|
|
10
11
|
node.id = props.id;
|
|
11
|
-
for (const key of ['type', 'name', 'placeholder', 'title', 'role', 'autocomplete', 'min', 'max', 'for']) {
|
|
12
|
+
for (const key of ['type', 'name', 'placeholder', 'title', 'role', 'autocomplete', 'min', 'max', 'for', 'scope']) {
|
|
12
13
|
const value = props[key];
|
|
13
14
|
if (value !== undefined)
|
|
14
15
|
node.setAttribute(key, value);
|
|
@@ -49,3 +50,34 @@ export function button(label, onClick, props = {}) {
|
|
|
49
50
|
}
|
|
50
51
|
/** A short when: the ISO time as the server wrote it, without milliseconds. */
|
|
51
52
|
export const when = (iso) => clean(iso).replace('T', ' ').replace(/\.\d+Z$/, 'Z');
|
|
53
|
+
/** A status pill: a dot and a label (the label carries the meaning, never the colour alone). */
|
|
54
|
+
export function pill(tone, label) {
|
|
55
|
+
return el('span', { class: `pill pill-${tone}` }, el('span', { class: 'dot', aria: { hidden: 'true' } }), label);
|
|
56
|
+
}
|
|
57
|
+
/** Text that screen readers and `textContent` keep, but the layout replaces with spacing or a divider. */
|
|
58
|
+
export function quiet(value) {
|
|
59
|
+
return el('span', { class: 'sr-only' }, value);
|
|
60
|
+
}
|
|
61
|
+
/** The screen's header: its title (the id a section is labelled by), an optional line under it, and its actions. */
|
|
62
|
+
export function pageHead(id, title, sub, ...actions) {
|
|
63
|
+
const subs = Array.isArray(sub) ? sub : [sub];
|
|
64
|
+
return el('header', { class: 'page-head' }, el('div', { class: 'page-title' }, el('h2', { id }, title), subs.some((s) => s !== null && s !== undefined && s !== false && s !== '') ? el('p', { class: 'page-sub' }, ...subs) : null), actions.some(Boolean) ? el('div', { class: 'page-actions' }, ...actions) : null);
|
|
65
|
+
}
|
|
66
|
+
/** A card: a header row (title, then actions) and a body. */
|
|
67
|
+
export function card(title, body, options = {}) {
|
|
68
|
+
return el('div', { class: `card${options.class ? ` ${options.class}` : ''}` }, el('div', { class: 'card-head' }, el('h3', {}, title), options.actions && options.actions.some(Boolean) ? el('div', { class: 'card-actions' }, ...options.actions) : null), el('div', { class: `card-body${options.bodyClass ? ` ${options.bodyClass}` : ''}` }, ...body), options.foot && options.foot.some(Boolean) ? el('div', { class: 'card-foot' }, ...options.foot) : null);
|
|
69
|
+
}
|
|
70
|
+
/** A key/value grid. */
|
|
71
|
+
export function kv(rows) {
|
|
72
|
+
const list = el('dl', { class: 'kv' });
|
|
73
|
+
for (const row of rows) {
|
|
74
|
+
if (!row)
|
|
75
|
+
continue;
|
|
76
|
+
append(list, el('div', { class: 'kv-row' }, el('dt', {}, row[0]), el('dd', {}, row[1])));
|
|
77
|
+
}
|
|
78
|
+
return list;
|
|
79
|
+
}
|
|
80
|
+
/** An empty or final state: an icon, a title and a line. */
|
|
81
|
+
export function emptyState(name, title, ...lines) {
|
|
82
|
+
return el('div', { class: 'empty' }, el('div', { class: 'empty-icon' }, icon(name)), el('p', { class: 'empty-title' }, title), ...lines.map((line) => el('p', { class: 'empty-text' }, line)));
|
|
83
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page's icons: fixed path data drawn with `createElementNS`, stroked in
|
|
3
|
+
* `currentColor`. No markup is parsed and nothing is loaded from elsewhere;
|
|
4
|
+
* every icon is decorative (`aria-hidden`), the text next to it carries the meaning.
|
|
5
|
+
*/
|
|
6
|
+
const PATHS = {
|
|
7
|
+
status: 'M3 12h4l3-8 4 16 3-8h4',
|
|
8
|
+
plan: 'M12 15V3M7 8l5-5 5 5M5 21h14',
|
|
9
|
+
history: 'M3 12a9 9 0 1 0 2.6-6.4L3 8M3 3v5h5M12 7v5l3 2',
|
|
10
|
+
run: 'M4 17l6-5-6-5M12 19h8',
|
|
11
|
+
targets: 'M4 4h16v6H4zM4 14h16v6H4zM8 7h.01M8 17h.01',
|
|
12
|
+
lock: 'M6 11h12v10H6zM8 11V7a4 4 0 0 1 8 0v4',
|
|
13
|
+
terminal: 'M4 17l6-5-6-5M12 19h8',
|
|
14
|
+
folder: 'M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z',
|
|
15
|
+
server: 'M5 4h14v6H5zM5 14h14v6H5zM8 7h.01M8 17h.01',
|
|
16
|
+
app: 'M12 3l8 4.5v9L12 21l-8-4.5v-9zM4 7.5l8 4.5 8-4.5M12 12v9',
|
|
17
|
+
check: 'M5 12l5 5L20 7',
|
|
18
|
+
cross: 'M6 6l12 12M18 6L6 18',
|
|
19
|
+
alert: 'M12 3.5l9.5 16.5h-19zM12 10v4.5M12 17.5h.01',
|
|
20
|
+
info: 'M12 3a9 9 0 1 1 0 18 9 9 0 1 1 0-18zM12 11v6M12 7.5h.01',
|
|
21
|
+
ok: 'M12 3a9 9 0 1 1 0 18 9 9 0 1 1 0-18zM8 12.5l3 3 5-6',
|
|
22
|
+
error: 'M12 3a9 9 0 1 1 0 18 9 9 0 1 1 0-18zM12 7.5v5.5M12 16.5h.01',
|
|
23
|
+
shield: 'M12 3l8 3v6c0 4.5-3.4 7.8-8 9-4.6-1.2-8-4.5-8-9V6z',
|
|
24
|
+
power: 'M12 3v8M6.3 6.6a8 8 0 1 0 11.4 0',
|
|
25
|
+
refresh: 'M20 11a8 8 0 0 0-14.6-4.5M4 3v4h4M4 13a8 8 0 0 0 14.6 4.5M20 21v-4h-4',
|
|
26
|
+
inbox: 'M3 13l3-8h12l3 8v6H3zM3 13h5l1.5 2h5L16 13h5',
|
|
27
|
+
tag: 'M3 12V4h8l10 10-8 8zM7.5 8h.01',
|
|
28
|
+
};
|
|
29
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
30
|
+
export function icon(name, className = 'icon') {
|
|
31
|
+
const svg = document.createElementNS(SVG, 'svg');
|
|
32
|
+
svg.setAttribute('class', className);
|
|
33
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
34
|
+
svg.setAttribute('width', '16');
|
|
35
|
+
svg.setAttribute('height', '16');
|
|
36
|
+
svg.setAttribute('fill', 'none');
|
|
37
|
+
svg.setAttribute('stroke', 'currentColor');
|
|
38
|
+
svg.setAttribute('stroke-width', '1.75');
|
|
39
|
+
svg.setAttribute('stroke-linecap', 'round');
|
|
40
|
+
svg.setAttribute('stroke-linejoin', 'round');
|
|
41
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
42
|
+
svg.setAttribute('focusable', 'false');
|
|
43
|
+
const path = document.createElementNS(SVG, 'path');
|
|
44
|
+
path.setAttribute('d', PATHS[name]);
|
|
45
|
+
svg.appendChild(path);
|
|
46
|
+
return svg;
|
|
47
|
+
}
|
package/dist/client/reply.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { el } from './dom.js';
|
|
1
|
+
import { el, quiet } from './dom.js';
|
|
2
|
+
import { icon } from './icons.js';
|
|
2
3
|
import { ApiError } from './api.js';
|
|
3
4
|
/** What went wrong, as a banner: a protocol error (code, message, hint), a failure of the connection, or the local server's refusal. */
|
|
4
5
|
export function problem(reply, error) {
|
|
@@ -33,8 +34,8 @@ export function errorBanner(error, diagnostics = []) {
|
|
|
33
34
|
return banner('err', error.message, lines, diagnostics, error.code);
|
|
34
35
|
}
|
|
35
36
|
export function banner(level, title, lines = [], diagnostics = [], code) {
|
|
36
|
-
return el('div', { class: `banner ${level}`, role: level === 'err' ? 'alert' : 'status' }, el('strong', {}, level === 'ok' ? 'OK: ' : level === 'warn' ? 'Warning: ' : 'Error: ', title), code ? el('span', { class: '
|
|
37
|
+
return el('div', { class: `banner ${level}`, role: level === 'err' ? 'alert' : 'status' }, icon(level === 'ok' ? 'ok' : level === 'warn' ? 'alert' : 'error', 'icon banner-icon'), el('div', { class: 'banner-body' }, el('strong', { class: 'banner-title' }, quiet(level === 'ok' ? 'OK: ' : level === 'warn' ? 'Warning: ' : 'Error: '), title), code ? el('span', { class: 'banner-code' }, ` [${code}]`) : null, ...lines.filter((line) => line !== '' && line !== null && line !== undefined && line !== false).map((line) => el('p', {}, line)), diagnostics.length > 0 ? diagnosticsBlock(diagnostics) : null));
|
|
37
38
|
}
|
|
38
39
|
export function diagnosticsBlock(lines) {
|
|
39
|
-
return el('details', {}, el('summary', {}, `Diagnostics (${lines.length})`), el('pre', { class: 'diagnostics' }, lines.join('\n')));
|
|
40
|
+
return el('details', { class: 'disclosure' }, el('summary', {}, `Diagnostics (${lines.length})`), el('pre', { class: 'diagnostics' }, lines.join('\n')));
|
|
40
41
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { confirmDialog } from './dialog.js';
|
|
2
|
-
import { button, el, replace, when } from './dom.js';
|
|
2
|
+
import { button, card, el, emptyState, pageHead, pill, replace, when } from './dom.js';
|
|
3
|
+
import { icon } from './icons.js';
|
|
3
4
|
import { problem } from './reply.js';
|
|
4
5
|
import { short } from './sanitize.js';
|
|
5
6
|
/** History: the last 10 releases, and rollback (to the last healthy release, or one picked here). */
|
|
@@ -10,10 +11,14 @@ export function renderHistory(app) {
|
|
|
10
11
|
const current = releases.find((r) => r.status === 'ok');
|
|
11
12
|
const choices = releases.filter((r) => r.status === 'ok' && r !== current);
|
|
12
13
|
const select = el('select', { id: 'rollback-to' }, el('option', { value: '' }, 'the last healthy release (the deploy decides)'), ...choices.map((r) => el('option', { value: r.sha }, `${short(r.sha)} — ${when(r.at)}`)));
|
|
13
|
-
return el('section', { aria: { labelledby: 'history-title' } },
|
|
14
|
+
return el('section', { aria: { labelledby: 'history-title' } }, pageHead('history-title', 'History', 'The last 10 releases the server recorded, newest first.', el('button', { type: 'button', on: { click: () => { void app.refreshStatus(); } } }, icon('refresh'), 'Refresh')), !status ? emptyState('history', 'Load the status first.', 'The releases come with the status of the target.') : null, releases.length > 0 ? card('Releases', [table(releases)], { bodyClass: 'flush', actions: [el('span', { class: 'muted num' }, `${releases.length} recorded`)] }) : status ? emptyState('inbox', 'No release recorded yet.', 'The first deploy of this target will show here.') : null, status ? card('Roll back', [
|
|
15
|
+
el('div', { class: 'field' }, el('label', { for: 'rollback-to' }, 'Back to'), select),
|
|
16
|
+
el('p', { class: 'form-note' }, icon('alert'), 'Code only: the database is not rolled back. The commit it leaves is held: a scheduled run will not redeploy it until the branch moves on.'),
|
|
17
|
+
message,
|
|
18
|
+
], { foot: [button('Roll back…', () => { void rollback(app, select.value, message); }, { class: 'danger' })] }) : null);
|
|
14
19
|
}
|
|
15
20
|
function table(releases) {
|
|
16
|
-
return el('div', { class: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ...['Commit', 'When', 'Status', 'Actor', 'Via', 'Client', 'Migrations', 'Backup', 'Note'].map((h) => el('th', {}, h)))), el('tbody', {}, ...releases.map((r) => el('tr', {}, el('td', {}, el('code', {}, short(r.sha))), el('td', {}, when(r.at)), el('td', {},
|
|
21
|
+
return el('div', { class: 'table-wrap' }, el('table', {}, el('thead', {}, el('tr', {}, ...['Commit', 'When', 'Status', 'Actor', 'Via', 'Client', 'Migrations', 'Backup', 'Note'].map((h) => el('th', { scope: 'col' }, h)))), el('tbody', {}, ...releases.map((r) => el('tr', {}, el('td', { class: 'nowrap' }, el('code', {}, short(r.sha))), el('td', { class: 'nowrap num' }, when(r.at)), el('td', {}, pill(r.status === 'ok' ? 'ok' : 'err', r.status)), el('td', {}, r.actor ?? r.user), el('td', { class: 'muted' }, r.via ?? ''), el('td', { class: 'mono' }, r.client ?? ''), el('td', { class: 'mono wrap' }, r.migrations.join(', ')), el('td', { class: 'mono wrap' }, r.backup ?? ''), el('td', { class: 'wrap' }, r.note ?? ''))))));
|
|
17
22
|
}
|
|
18
23
|
async function rollback(app, to, message) {
|
|
19
24
|
const t = app.current;
|
|
@@ -21,8 +26,8 @@ async function rollback(app, to, message) {
|
|
|
21
26
|
return;
|
|
22
27
|
const ok = await confirmDialog({
|
|
23
28
|
title: `Roll back ${t.name}?`,
|
|
29
|
+
context: `${t.ssh} · ${t.dir}${app.hello ? ` · host ${app.hello.host}` : ''}`,
|
|
24
30
|
lines: [
|
|
25
|
-
`${t.ssh} · ${t.dir}${app.hello ? ` · host ${app.hello.host}` : ''}`,
|
|
26
31
|
to ? `Back to ${short(to)}.` : 'Back to the last healthy release.',
|
|
27
32
|
'The commit it leaves is held until the branch moves on.',
|
|
28
33
|
],
|
package/dist/client/view-plan.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { confirmDialog } from './dialog.js';
|
|
2
|
-
import { append, button, el, replace } from './dom.js';
|
|
2
|
+
import { append, button, card, el, emptyState, pageHead, replace } from './dom.js';
|
|
3
|
+
import { icon } from './icons.js';
|
|
3
4
|
import { banner, describe, diagnosticsBlock, problem } from './reply.js';
|
|
4
5
|
import { ApiError } from './api.js';
|
|
5
6
|
/** Plan & deploy: what a run would do, the questions it would ask, and the `.env` form. */
|
|
6
7
|
export function renderPlan(app) {
|
|
7
8
|
const reply = app.planReply;
|
|
8
9
|
const plan = app.plan;
|
|
9
|
-
const root = el('section', { aria: { labelledby: 'plan-title' } },
|
|
10
|
-
if (!reply)
|
|
10
|
+
const root = el('section', { aria: { labelledby: 'plan-title' } }, pageHead('plan-title', 'Plan & deploy', 'plan changes nothing on the server. Its preflight may reach the git remote, so it can take a while.', button(app.planBusy ? 'Planning…' : plan ? 'Plan again' : 'Run plan', () => { void app.runPlan(); }, { disabled: app.planBusy, class: plan ? '' : 'primary' })));
|
|
11
|
+
if (!reply) {
|
|
12
|
+
append(root, app.planBusy
|
|
13
|
+
? emptyState('refresh', 'Planning…', 'Preflight checks and the plan run on the server; nothing changes there.')
|
|
14
|
+
: emptyState('plan', 'No plan yet', 'Run a plan to see what a deploy would do, the questions it would ask, and anything that would stop it.'));
|
|
11
15
|
return root;
|
|
16
|
+
}
|
|
12
17
|
if (!plan) {
|
|
13
18
|
append(root, problem(reply) ?? el('p', {}, 'No plan came back.'));
|
|
14
19
|
return root;
|
|
15
20
|
}
|
|
16
21
|
append(root, ...findings(plan.findings));
|
|
17
22
|
if (plan.lines.length > 0) {
|
|
18
|
-
append(root,
|
|
23
|
+
append(root, card('What a run would do', [el('div', { class: 'table-wrap' }, el('table', { class: 'plan-lines' }, el('tbody', {}, ...plan.lines.map((line) => el('tr', {}, el('th', { scope: 'row' }, el('span', { class: 'step-chip' }, line.step)), el('td', {}, line.text))))))], { bodyClass: 'flush' }));
|
|
19
24
|
}
|
|
20
25
|
if (reply.diagnostics.length > 0)
|
|
21
26
|
append(root, diagnosticsBlock(reply.diagnostics));
|
|
@@ -26,11 +31,22 @@ function findings(list) {
|
|
|
26
31
|
if (list.length === 0)
|
|
27
32
|
return [banner('ok', 'No problem found.')];
|
|
28
33
|
const sorted = [...list].sort((a, b) => (a.level === b.level ? 0 : a.level === 'error' ? -1 : 1));
|
|
29
|
-
|
|
34
|
+
const errors = list.filter((f) => f.level === 'error').length;
|
|
35
|
+
return [card('Findings', [findingList(sorted)], {
|
|
36
|
+
bodyClass: 'flush',
|
|
37
|
+
actions: [el('span', { class: 'muted' }, `${errors} error${errors === 1 ? '' : 's'}, ${list.length - errors} warning${list.length - errors === 1 ? '' : 's'}`)],
|
|
38
|
+
})];
|
|
39
|
+
}
|
|
40
|
+
/** Findings with a severity badge; the fix is copyable text, never run by the page. */
|
|
41
|
+
export function findingList(list, label) {
|
|
42
|
+
return el('ul', { class: 'findings', ...(label ? { aria: { label } } : {}) }, ...list.map((f) => findingItem(f)));
|
|
43
|
+
}
|
|
44
|
+
export function findingItem(f) {
|
|
45
|
+
return el('li', { class: 'finding' }, el('span', { class: `sev sev-${f.level === 'error' ? 'error' : 'warning'}` }, f.level === 'error' ? 'Error ' : 'Warning '), el('span', { class: 'finding-msg' }, f.id ? el('span', { class: 'finding-id' }, `[${f.id}] `) : null, f.message), f.fix ? el('div', { class: 'fix' }, el('span', { class: 'fix-label' }, 'Fix: '), el('code', {}, f.fix)) : null);
|
|
30
46
|
}
|
|
31
47
|
function questionField(question, index) {
|
|
32
48
|
const id = `q-${index}`;
|
|
33
|
-
const label = el('label', { for: id }, question.message, question.
|
|
49
|
+
const label = el('label', { for: id }, question.message, question.optional ? '' : el('span', { class: 'required', title: 'required' }, ' *'), question.key ? el('span', { class: 'field-key' }, ` (${question.key})`) : null);
|
|
34
50
|
let input;
|
|
35
51
|
if (question.kind === 'secret') {
|
|
36
52
|
// No default, no autocomplete, no spellcheck: a secret is typed, sent once, and the field is emptied.
|
|
@@ -43,6 +59,7 @@ function questionField(question, index) {
|
|
|
43
59
|
}
|
|
44
60
|
else if (question.kind === 'confirm') {
|
|
45
61
|
input = el('input', { type: 'checkbox', id, checked: question.default === 'yes' || question.default === 'true', aria: { describedby: `${id}-error` } });
|
|
62
|
+
return { node: el('div', { class: 'field check' }, el('label', { for: id }, input, el('span', {}, question.message, question.optional ? '' : el('span', { class: 'required', title: 'required' }, ' *'), question.key ? el('span', { class: 'field-key' }, ` (${question.key})`) : null)), el('span', { id: `${id}-error`, class: 'field-error' })), field: { question, input } };
|
|
46
63
|
}
|
|
47
64
|
else {
|
|
48
65
|
input = el('input', { type: 'text', id, value: question.default ?? '', autocomplete: 'off', spellcheck: false, required: !question.optional, aria: { describedby: `${id}-error` } });
|
|
@@ -99,8 +116,8 @@ function deployForm(app, questions, blocking) {
|
|
|
99
116
|
const deploy = route === 'run';
|
|
100
117
|
const ok = await confirmDialog({
|
|
101
118
|
title: deploy ? `Deploy to ${t.name}?` : `Write the .env on ${t.name}?`,
|
|
119
|
+
context: `${t.ssh} · ${t.dir}${app.hello ? ` · host ${app.hello.host}` : ''}${app.status ? ` · app ${app.status.app}` : ''}`,
|
|
102
120
|
lines: [
|
|
103
|
-
`${t.ssh} · ${t.dir}${app.hello ? ` · host ${app.hello.host}` : ''}${app.status ? ` · app ${app.status.app}` : ''}`,
|
|
104
121
|
deploy ? 'Fetch, .env, build, migrate, restart, health check — the run goes on on the server if this page closes (unless attended).' : 'The .env and the dedicated infra only; nothing is built or restarted.',
|
|
105
122
|
deploy && app.plan?.lines.some((l) => /migrat/i.test(l.step) || /migrat/i.test(l.text)) ? el('strong', {}, 'This will migrate the database.') : null,
|
|
106
123
|
],
|
|
@@ -150,5 +167,5 @@ function deployForm(app, questions, blocking) {
|
|
|
150
167
|
}
|
|
151
168
|
replace(message, problem(reply));
|
|
152
169
|
};
|
|
153
|
-
return el('form', { class: '
|
|
170
|
+
return el('form', { class: 'card', aria: { label: 'Deploy' }, on: { submit: (event) => { event.preventDefault(); void send('run'); } } }, el('div', { class: 'card-head' }, el('h3', {}, questions.length > 0 ? 'What the run will ask' : 'Deploy'), t?.protected ? el('span', { class: 'badge badge-protected' }, icon('shield'), 'PROTECTED') : null), el('div', { class: 'card-body' }, el('p', { class: 'form-note' }, icon(questions.length > 0 ? 'lock' : 'ok'), questions.length > 0 ? 'Secrets are sent once, over your ssh, to the deploy on the server; they are never stored here and the fields are emptied after sending.' : 'Nothing to answer: the .env is complete.'), nodes.length > 0 ? el('div', { class: 'form-section' }, ...nodes) : null, el('div', { class: 'form-section' }, hold ? el('div', { class: 'field check' }, el('label', { for: 'unhold' }, unhold, el('span', {}, ' Deploy anyway: the held commit ', el('code', {}, hold.sha.slice(0, 12)), ' may be deployed (--unhold)'))) : null, el('details', { class: 'advanced' }, el('summary', {}, 'Advanced'), el('div', { class: 'field check' }, el('label', { for: 'attended' }, attended, el('span', {}, ' Attended: the run stops at its next step if this page closes or the UI quits'))))), blocking ? banner('err', 'The plan found problems that stop a run: fix them first.') : null, message), el('div', { class: 'card-foot' }, button('Write .env only…', () => { void send('env'); }), el('button', { type: 'submit', class: 'primary', disabled: blocking }, 'Deploy…')));
|
|
154
171
|
}
|
package/dist/client/view-run.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ApiError } from './api.js';
|
|
2
2
|
import { confirmDialog } from './dialog.js';
|
|
3
|
-
import { append, button, el, replace } from './dom.js';
|
|
3
|
+
import { append, button, el, quiet, replace } from './dom.js';
|
|
4
|
+
import { icon } from './icons.js';
|
|
5
|
+
import { findingItem } from './view-plan.js';
|
|
4
6
|
import { banner, describe, errorBanner, problem } from './reply.js';
|
|
5
7
|
import { clean } from './sanitize.js';
|
|
6
8
|
/** The log lines kept in the page; the full log stays on the server ("Show from the start" replays it). */
|
|
@@ -28,6 +30,7 @@ export class RunView {
|
|
|
28
30
|
/** The run's own `done` was seen (or attach said it had finished): nothing more will come. */
|
|
29
31
|
runFinished = false;
|
|
30
32
|
findings;
|
|
33
|
+
findingsCard;
|
|
31
34
|
log;
|
|
32
35
|
outcome;
|
|
33
36
|
actions;
|
|
@@ -41,14 +44,15 @@ export class RunView {
|
|
|
41
44
|
this.app = app;
|
|
42
45
|
this.target = target;
|
|
43
46
|
this.runId = runId;
|
|
44
|
-
this.stateLine = el('p', { class: '
|
|
47
|
+
this.stateLine = el('p', { class: 'run-state', role: 'status', aria: { live: 'polite' } });
|
|
45
48
|
this.steps = el('ol', { class: 'steps', aria: { label: 'Steps' } });
|
|
46
|
-
this.findings = el('ul', { aria: { label: 'Findings' } });
|
|
49
|
+
this.findings = el('ul', { class: 'findings', aria: { label: 'Findings' } });
|
|
47
50
|
this.log = el('ol', { class: 'log', aria: { label: 'Log' } });
|
|
48
|
-
this.outcome = el('div');
|
|
49
|
-
this.actions = el('div', { class: '
|
|
51
|
+
this.outcome = el('div', { class: 'run-outcome' });
|
|
52
|
+
this.actions = el('div', { class: 'page-actions' });
|
|
50
53
|
this.diagnostics = el('pre', { class: 'diagnostics', hidden: true });
|
|
51
|
-
this.
|
|
54
|
+
this.findingsCard = el('div', { class: 'card', hidden: true }, el('div', { class: 'card-head' }, el('h3', {}, 'Findings')), el('div', { class: 'card-body flush' }, this.findings));
|
|
55
|
+
this.element = el('section', { aria: { labelledby: 'run-title' } }, el('header', { class: 'page-head' }, el('div', { class: 'page-title' }, el('h2', { id: 'run-title', class: 'mono-title' }, title), el('p', { class: 'page-sub' }, `${target.name} · ${target.ssh} · ${target.dir}`)), this.actions), this.stateLine, this.outcome, el('div', { class: 'run-grid' }, el('div', { class: 'card' }, el('div', { class: 'card-head' }, el('h3', {}, 'Steps')), el('div', { class: 'card-body' }, this.steps)), el('div', { class: 'console' }, el('div', { class: 'console-head' }, el('h3', {}, icon('terminal'), 'Log'), el('span', { class: 'console-meta' }, target.name)), this.log)), this.findingsCard, this.diagnostics);
|
|
52
56
|
this.renderActions();
|
|
53
57
|
}
|
|
54
58
|
/** Where to resume: the seq after the last one this tab saw for this run, kept in sessionStorage (not a secret). */
|
|
@@ -96,8 +100,10 @@ export class RunView {
|
|
|
96
100
|
}
|
|
97
101
|
finally {
|
|
98
102
|
this.following = false;
|
|
99
|
-
if (!this.ended)
|
|
103
|
+
if (!this.ended) {
|
|
104
|
+
this.settleSteps();
|
|
100
105
|
this.setState(this.controller.signal.aborted ? 'Stopped watching (the run goes on on the server).' : 'The stream ended.');
|
|
106
|
+
}
|
|
101
107
|
this.renderActions();
|
|
102
108
|
}
|
|
103
109
|
}
|
|
@@ -119,9 +125,9 @@ export class RunView {
|
|
|
119
125
|
}
|
|
120
126
|
state(message) {
|
|
121
127
|
if (message.state === 'connecting')
|
|
122
|
-
return this.setState(`Connecting to ${this.target.ssh}
|
|
128
|
+
return this.setState(`Connecting to ${this.target.ssh}…`, 'live');
|
|
123
129
|
if (message.state === 'reconnecting') {
|
|
124
|
-
return this.setState(`Connection lost (${clean(message.reason)}); reconnecting in ${Math.round((message.retryInMs ?? 0) / 1000)} s from event ${this.lastSeq === undefined ? 0 : this.lastSeq + 1}
|
|
130
|
+
return this.setState(`Connection lost (${clean(message.reason)}); reconnecting in ${Math.round((message.retryInMs ?? 0) / 1000)} s from event ${this.lastSeq === undefined ? 0 : this.lastSeq + 1}…`, 'live');
|
|
125
131
|
}
|
|
126
132
|
this.ended = true;
|
|
127
133
|
if (message.exitCode !== undefined)
|
|
@@ -152,11 +158,11 @@ export class RunView {
|
|
|
152
158
|
case 'hello':
|
|
153
159
|
return;
|
|
154
160
|
case 'step-start': {
|
|
155
|
-
const node = el('li', {},
|
|
161
|
+
const node = el('li', { class: 'step is-running' }, el('span', { class: 'step-icon', aria: { hidden: 'true' } }, '▸'), ' ', el('span', { class: 'step-title' }, event.title), el('span', { class: 'step-meta' }, quiet(' '), quiet('…'), el('span', { class: 'step-status', aria: { hidden: 'true' } }, 'running')));
|
|
156
162
|
this.stepNodes.set(event.id, node);
|
|
157
163
|
this.stepTitles.set(event.id, event.title);
|
|
158
164
|
this.steps.append(node);
|
|
159
|
-
this.setState(`Step: ${event.title}
|
|
165
|
+
this.setState(`Step: ${event.title}`, 'live');
|
|
160
166
|
return;
|
|
161
167
|
}
|
|
162
168
|
case 'step-end': {
|
|
@@ -164,15 +170,18 @@ export class RunView {
|
|
|
164
170
|
const mark = event.status === 'ok' ? '✓' : event.status === 'skipped' ? '–' : '✗';
|
|
165
171
|
// A step that started before the resume point has no node: its id names it.
|
|
166
172
|
const title = this.stepTitles.get(event.id) ?? event.id;
|
|
167
|
-
|
|
173
|
+
node.className = `step is-${event.status === 'ok' ? 'ok' : event.status === 'skipped' ? 'skipped' : 'failed'}`;
|
|
174
|
+
// The text reads "✓ build — ok, 1.5 s"; the layout draws the mark as an icon and the duration in a column.
|
|
175
|
+
replace(node, el('span', { class: 'step-icon', aria: { hidden: 'true' } }, mark), quiet(' '), el('span', { class: 'step-title' }, title), el('span', { class: 'step-meta' }, quiet(' — '), el('span', { class: 'step-status' }, event.status), quiet(', '), el('span', { class: 'step-dur' }, `${(event.durationMs / 1000).toFixed(1)} s`)));
|
|
168
176
|
if (!node.parentNode)
|
|
169
177
|
this.steps.append(node);
|
|
170
178
|
return;
|
|
171
179
|
}
|
|
172
180
|
case 'log':
|
|
173
|
-
return this.line(event.level, event.text, event.source);
|
|
181
|
+
return this.line(event.level, event.text, event.source, event.ts);
|
|
174
182
|
case 'finding':
|
|
175
|
-
this.
|
|
183
|
+
this.findingsCard.hidden = false;
|
|
184
|
+
this.findings.append(findingItem(event));
|
|
176
185
|
return;
|
|
177
186
|
case 'prompt':
|
|
178
187
|
return this.line('warn', `the deploy asks: ${event.message} (answer it in the form and run again)`);
|
|
@@ -193,38 +202,56 @@ export class RunView {
|
|
|
193
202
|
return this.line('warn', 'an unexpected wrapped event was ignored');
|
|
194
203
|
}
|
|
195
204
|
}
|
|
196
|
-
line(level, textValue, source) {
|
|
205
|
+
line(level, textValue, source, ts) {
|
|
197
206
|
if (this.log.childElementCount >= MAX_LOG_LINES) {
|
|
198
207
|
this.log.firstElementChild?.remove();
|
|
199
208
|
this.dropped++;
|
|
200
209
|
this.setDropped();
|
|
201
210
|
}
|
|
202
211
|
const mark = level === 'error' ? '✗ ' : level === 'warn' ? '! ' : '';
|
|
203
|
-
|
|
212
|
+
const node = el('li', { class: level === 'error' || level === 'warn' || level === 'ok' ? level : '' }, mark, source ? el('span', { class: 'src' }, `[${source}] `) : null, textValue);
|
|
213
|
+
// The time column is drawn from an attribute: the line's text stays exactly what the deploy printed.
|
|
214
|
+
const time = /T(\d\d:\d\d:\d\d)/.exec(clean(ts))?.[1];
|
|
215
|
+
if (time)
|
|
216
|
+
node.dataset['ts'] = time;
|
|
217
|
+
this.log.append(node);
|
|
204
218
|
}
|
|
205
219
|
note(textValue) {
|
|
206
220
|
this.log.append(el('li', { class: 'src' }, textValue));
|
|
207
221
|
}
|
|
222
|
+
/** A step still running when this view stopped following: its end is not known here (it is not drawn as running). */
|
|
223
|
+
settleSteps() {
|
|
224
|
+
for (const node of this.stepNodes.values()) {
|
|
225
|
+
if (!node.classList.contains('is-running'))
|
|
226
|
+
continue;
|
|
227
|
+
node.classList.replace('is-running', 'is-aborted');
|
|
228
|
+
const status = node.querySelector('.step-status');
|
|
229
|
+
if (status)
|
|
230
|
+
replace(status, 'no end seen');
|
|
231
|
+
}
|
|
232
|
+
}
|
|
208
233
|
setDropped() {
|
|
209
234
|
this.stateLine.dataset['dropped'] = String(this.dropped);
|
|
210
235
|
}
|
|
211
|
-
setState(textValue) {
|
|
236
|
+
setState(textValue, tone) {
|
|
237
|
+
this.stateLine.className = `run-state${tone ? ` is-${tone}` : ''}`;
|
|
212
238
|
replace(this.stateLine, textValue, this.dropped > 0 ? ` (${this.dropped} older log lines dropped from the page)` : '');
|
|
213
239
|
}
|
|
214
240
|
finish() {
|
|
215
241
|
// Status is refreshed once after any action (no polling loop).
|
|
216
242
|
void this.app.refreshStatus();
|
|
243
|
+
this.settleSteps();
|
|
217
244
|
if (this.failed && this.exitCode === undefined) {
|
|
218
245
|
const reconnectable = this.runId !== undefined;
|
|
219
|
-
this.setState(`Stopped: ${clean(this.failed.reason ?? this.failed.code)}
|
|
246
|
+
this.setState(`Stopped: ${clean(this.failed.reason ?? this.failed.code)}`, 'err');
|
|
220
247
|
this.outcome.append(banner('err', this.failed.reason ?? 'the stream ended', [this.failed.hint ?? '', reconnectable ? 'The run may still be going on the server: re-attach to see.' : ''], [], this.failed.code));
|
|
221
248
|
}
|
|
222
249
|
else if (this.exitCode === 0) {
|
|
223
|
-
this.setState('Done.');
|
|
250
|
+
this.setState('Done.', 'ok');
|
|
224
251
|
this.outcome.append(banner('ok', 'Finished: exit 0'));
|
|
225
252
|
}
|
|
226
253
|
else {
|
|
227
|
-
this.setState(`Finished with exit ${this.exitCode ?? 'unknown'}
|
|
254
|
+
this.setState(`Finished with exit ${this.exitCode ?? 'unknown'}`, 'err');
|
|
228
255
|
if (!this.lastError)
|
|
229
256
|
this.outcome.append(banner('err', `Finished with exit ${this.exitCode ?? 'unknown'}`));
|
|
230
257
|
}
|