@foliwake/cli 0.0.0-stage → 0.6.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 +35 -0
- package/LICENSE +202 -0
- package/README.md +643 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +9 -0
- package/dist/command-words.d.ts +13 -0
- package/dist/command-words.js +53 -0
- package/dist/commands/account/keys/create.d.ts +12 -0
- package/dist/commands/account/keys/create.js +36 -0
- package/dist/commands/account/keys/list.d.ts +9 -0
- package/dist/commands/account/keys/list.js +23 -0
- package/dist/commands/account/keys/revoke.d.ts +12 -0
- package/dist/commands/account/keys/revoke.js +15 -0
- package/dist/commands/branch/bootstrap.d.ts +11 -0
- package/dist/commands/branch/bootstrap.js +23 -0
- package/dist/commands/branch/delete.d.ts +17 -0
- package/dist/commands/branch/delete.js +38 -0
- package/dist/commands/branch/history.d.ts +14 -0
- package/dist/commands/branch/history.js +24 -0
- package/dist/commands/branch/list.d.ts +11 -0
- package/dist/commands/branch/list.js +15 -0
- package/dist/commands/branch/update.d.ts +19 -0
- package/dist/commands/branch/update.js +49 -0
- package/dist/commands/code/deploy.d.ts +15 -0
- package/dist/commands/code/deploy.js +78 -0
- package/dist/commands/code/prepare.d.ts +13 -0
- package/dist/commands/code/prepare.js +54 -0
- package/dist/commands/code/release.d.ts +19 -0
- package/dist/commands/code/release.js +51 -0
- package/dist/commands/code/rollback.d.ts +17 -0
- package/dist/commands/code/rollback.js +38 -0
- package/dist/commands/connect.d.ts +19 -0
- package/dist/commands/connect.js +100 -0
- package/dist/commands/create.d.ts +30 -0
- package/dist/commands/create.js +163 -0
- package/dist/commands/credential/list.d.ts +10 -0
- package/dist/commands/credential/list.js +21 -0
- package/dist/commands/credential/rm.d.ts +12 -0
- package/dist/commands/credential/rm.js +18 -0
- package/dist/commands/credential/set.d.ts +15 -0
- package/dist/commands/credential/set.js +58 -0
- package/dist/commands/dev.d.ts +25 -0
- package/dist/commands/dev.js +89 -0
- package/dist/commands/login.d.ts +20 -0
- package/dist/commands/login.js +94 -0
- package/dist/commands/logout.d.ts +14 -0
- package/dist/commands/logout.js +61 -0
- package/dist/commands/migration/commit.d.ts +13 -0
- package/dist/commands/migration/commit.js +42 -0
- package/dist/commands/migration/prepare.d.ts +18 -0
- package/dist/commands/migration/prepare.js +53 -0
- package/dist/commands/operation/cancel.d.ts +14 -0
- package/dist/commands/operation/cancel.js +21 -0
- package/dist/commands/operation/get.d.ts +14 -0
- package/dist/commands/operation/get.js +26 -0
- package/dist/commands/operation/list.d.ts +12 -0
- package/dist/commands/operation/list.js +25 -0
- package/dist/commands/operation/recover.d.ts +20 -0
- package/dist/commands/operation/recover.js +49 -0
- package/dist/commands/page/changes.d.ts +13 -0
- package/dist/commands/page/changes.js +26 -0
- package/dist/commands/page/check.d.ts +12 -0
- package/dist/commands/page/check.js +25 -0
- package/dist/commands/page/replace.d.ts +13 -0
- package/dist/commands/page/replace.js +59 -0
- package/dist/commands/page/unpreview.d.ts +17 -0
- package/dist/commands/page/unpreview.js +54 -0
- package/dist/commands/page/unpublish.d.ts +18 -0
- package/dist/commands/page/unpublish.js +36 -0
- package/dist/commands/project/preview.d.ts +8 -0
- package/dist/commands/project/preview.js +20 -0
- package/dist/commands/project/publish.d.ts +16 -0
- package/dist/commands/project/publish.js +40 -0
- package/dist/commands/project/unpublish.d.ts +16 -0
- package/dist/commands/project/unpublish.js +33 -0
- package/dist/commands/release/rollback.d.ts +17 -0
- package/dist/commands/release/rollback.js +38 -0
- package/dist/commands/servers/index.d.ts +20 -0
- package/dist/commands/servers/index.js +36 -0
- package/dist/commands/servers/use.d.ts +11 -0
- package/dist/commands/servers/use.js +30 -0
- package/dist/commands/site/adopt.d.ts +11 -0
- package/dist/commands/site/adopt.js +21 -0
- package/dist/commands/site/create.d.ts +18 -0
- package/dist/commands/site/create.js +61 -0
- package/dist/commands/site/edit.d.ts +11 -0
- package/dist/commands/site/edit.js +56 -0
- package/dist/commands/site/history.d.ts +11 -0
- package/dist/commands/site/history.js +25 -0
- package/dist/commands/site/link.d.ts +15 -0
- package/dist/commands/site/link.js +35 -0
- package/dist/commands/site/list.d.ts +9 -0
- package/dist/commands/site/list.js +29 -0
- package/dist/commands/site/reset-storage.d.ts +15 -0
- package/dist/commands/site/reset-storage.js +61 -0
- package/dist/commands/site/set.d.ts +16 -0
- package/dist/commands/site/set.js +45 -0
- package/dist/commands/site/show.d.ts +10 -0
- package/dist/commands/site/show.js +19 -0
- package/dist/commands/site/status.d.ts +11 -0
- package/dist/commands/site/status.js +15 -0
- package/dist/commands/site/unlink.d.ts +11 -0
- package/dist/commands/site/unlink.js +28 -0
- package/dist/commands/source/add.d.ts +32 -0
- package/dist/commands/source/add.js +103 -0
- package/dist/commands/source/adopt-pages.d.ts +14 -0
- package/dist/commands/source/adopt-pages.js +30 -0
- package/dist/commands/source/check.d.ts +17 -0
- package/dist/commands/source/check.js +52 -0
- package/dist/commands/source/list.d.ts +11 -0
- package/dist/commands/source/list.js +15 -0
- package/dist/commands/source/mappings/check.d.ts +13 -0
- package/dist/commands/source/mappings/check.js +69 -0
- package/dist/commands/source/pending.d.ts +12 -0
- package/dist/commands/source/pending.js +25 -0
- package/dist/commands/source/plugins.d.ts +6 -0
- package/dist/commands/source/plugins.js +17 -0
- package/dist/commands/source/sync.d.ts +16 -0
- package/dist/commands/source/sync.js +58 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.js +21 -0
- package/dist/connect-prompts.d.ts +16 -0
- package/dist/connect-prompts.js +24 -0
- package/dist/connect.d.ts +133 -0
- package/dist/connect.js +416 -0
- package/dist/core-command.d.ts +91 -0
- package/dist/core-command.js +262 -0
- package/dist/core-types.d.ts +21 -0
- package/dist/core-types.js +1 -0
- package/dist/create-connect.d.ts +26 -0
- package/dist/create-connect.js +93 -0
- package/dist/dev/code-watcher.d.ts +66 -0
- package/dist/dev/code-watcher.js +254 -0
- package/dist/dev/dev-checks.d.ts +14 -0
- package/dist/dev/dev-checks.js +138 -0
- package/dist/dev/dev-reload.d.ts +51 -0
- package/dist/dev/dev-reload.js +345 -0
- package/dist/dev/flags.d.ts +15 -0
- package/dist/dev/flags.js +43 -0
- package/dist/dev/html.d.ts +30 -0
- package/dist/dev/html.js +106 -0
- package/dist/dev/kit-files.d.ts +7 -0
- package/dist/dev/kit-files.js +33 -0
- package/dist/dev/local-code.d.ts +22 -0
- package/dist/dev/local-code.js +101 -0
- package/dist/dev/remote-config.d.ts +57 -0
- package/dist/dev/remote-config.js +100 -0
- package/dist/dev/remote-dev.d.ts +41 -0
- package/dist/dev/remote-dev.js +527 -0
- package/dist/dev/remote-fetch.d.ts +5 -0
- package/dist/dev/remote-fetch.js +36 -0
- package/dist/dev/remote-html.d.ts +10 -0
- package/dist/dev/remote-html.js +60 -0
- package/dist/dev/remote-page.d.ts +34 -0
- package/dist/dev/remote-page.js +183 -0
- package/dist/dev/remote-routes.d.ts +63 -0
- package/dist/dev/remote-routes.js +114 -0
- package/dist/dev/signal-stop.d.ts +17 -0
- package/dist/dev/signal-stop.js +46 -0
- package/dist/dev/start.d.ts +18 -0
- package/dist/dev/start.js +80 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/lib/diagnostics.d.ts +15 -0
- package/dist/lib/diagnostics.js +12 -0
- package/dist/lib/front-matter.d.ts +6 -0
- package/dist/lib/front-matter.js +59 -0
- package/dist/lib/operation-result.d.ts +3 -0
- package/dist/lib/operation-result.js +16 -0
- package/dist/lib/problem-groups.d.ts +27 -0
- package/dist/lib/problem-groups.js +49 -0
- package/dist/lib/problems.d.ts +50 -0
- package/dist/lib/problems.js +94 -0
- package/dist/lib/prompts.d.ts +38 -0
- package/dist/lib/prompts.js +77 -0
- package/dist/lib/result-types.d.ts +198 -0
- package/dist/lib/result-types.js +3 -0
- package/dist/lib/rules.d.ts +15 -0
- package/dist/lib/rules.js +26 -0
- package/dist/lib/summaries.d.ts +19 -0
- package/dist/lib/summaries.js +22 -0
- package/dist/lib/sync-problems.d.ts +21 -0
- package/dist/lib/sync-problems.js +19 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +40 -0
- package/dist/project-preview.d.ts +35 -0
- package/dist/project-preview.js +156 -0
- package/dist/project-publish.d.ts +28 -0
- package/dist/project-publish.js +173 -0
- package/dist/remote/connection.d.ts +8 -0
- package/dist/remote/connection.js +19 -0
- package/dist/remote/core-failure.d.ts +8 -0
- package/dist/remote/core-failure.js +15 -0
- package/dist/remote/credentials.d.ts +15 -0
- package/dist/remote/credentials.js +112 -0
- package/dist/remote/device-login.d.ts +33 -0
- package/dist/remote/device-login.js +161 -0
- package/dist/remote/remote-caller.d.ts +14 -0
- package/dist/remote/remote-caller.js +52 -0
- package/dist/remote/rpc-wire.d.ts +18 -0
- package/dist/remote/rpc-wire.js +57 -0
- package/dist/remote/servers.d.ts +80 -0
- package/dist/remote/servers.js +162 -0
- package/dist/remote/session.d.ts +53 -0
- package/dist/remote/session.js +132 -0
- package/dist/remote/sign-in-here.d.ts +5 -0
- package/dist/remote/sign-in-here.js +33 -0
- package/dist/remote/sign-in.d.ts +25 -0
- package/dist/remote/sign-in.js +55 -0
- package/dist/remote/wait-slices.d.ts +16 -0
- package/dist/remote/wait-slices.js +21 -0
- package/dist/render/add.d.ts +3 -0
- package/dist/render/add.js +9 -0
- package/dist/render/branch-write.d.ts +9 -0
- package/dist/render/branch-write.js +28 -0
- package/dist/render/branches.d.ts +5 -0
- package/dist/render/branches.js +28 -0
- package/dist/render/credentials.d.ts +5 -0
- package/dist/render/credentials.js +39 -0
- package/dist/render/operation-result.d.ts +16 -0
- package/dist/render/operation-result.js +65 -0
- package/dist/render/operation.d.ts +7 -0
- package/dist/render/operation.js +15 -0
- package/dist/render/page-changes.d.ts +3 -0
- package/dist/render/page-changes.js +36 -0
- package/dist/render/pending.d.ts +3 -0
- package/dist/render/pending.js +46 -0
- package/dist/render/plugin-list.d.ts +3 -0
- package/dist/render/plugin-list.js +30 -0
- package/dist/render/probe.d.ts +3 -0
- package/dist/render/probe.js +61 -0
- package/dist/render/problems.d.ts +35 -0
- package/dist/render/problems.js +64 -0
- package/dist/render/recovery.d.ts +2 -0
- package/dist/render/recovery.js +36 -0
- package/dist/render/reset-storage.d.ts +4 -0
- package/dist/render/reset-storage.js +70 -0
- package/dist/render/site-status.d.ts +2 -0
- package/dist/render/site-status.js +81 -0
- package/dist/render/source-list.d.ts +2 -0
- package/dist/render/source-list.js +37 -0
- package/dist/render/sync.d.ts +5 -0
- package/dist/render/sync.js +66 -0
- package/dist/settings.d.ts +10 -0
- package/dist/settings.js +45 -0
- package/dist/site-entry-edit.d.ts +5 -0
- package/dist/site-entry-edit.js +44 -0
- package/dist/source-entry.d.ts +32 -0
- package/dist/source-entry.js +89 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +10 -0
- package/package.json +108 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Operation } from '../core-types.js';
|
|
2
|
+
import type { OperationResult } from '../core-types.js';
|
|
3
|
+
/** Whether a finished operation did what was asked (a no-op re-run included). */
|
|
4
|
+
export declare const succeeded: (result: OperationResult) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Exit status of a live commit: 1 not done, 3 committed with its cache refresh still pending (as `operation recover
|
|
7
|
+
* --wait`), else 0.
|
|
8
|
+
*/
|
|
9
|
+
export declare function exitCodeOf(result: OperationResult): number;
|
|
10
|
+
/** The lines every long operation prints: what happened, its problems, and its cache refresh. */
|
|
11
|
+
export declare function operationResultLines(result: OperationResult, verb: string): string[];
|
|
12
|
+
/** The lines of a long write, and its exit status as for any live commit (exitCodeOf). */
|
|
13
|
+
export declare function longWriteReport(operation: Operation, verb: string): {
|
|
14
|
+
lines: string[];
|
|
15
|
+
exitCode: number;
|
|
16
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { COMMAND } from '../settings.js';
|
|
2
|
+
import { finishedResult } from '../lib/operation-result.js';
|
|
3
|
+
const C = COMMAND;
|
|
4
|
+
const SUCCEEDED = new Set(['done', 'committed', 'invalidation_pending', 'noop']);
|
|
5
|
+
/** Whether a finished operation did what was asked (a no-op re-run included). */
|
|
6
|
+
export const succeeded = (result) => SUCCEEDED.has(result.state);
|
|
7
|
+
/** ` (sr_…, generation 7)` after a verb, or nothing without a release. */
|
|
8
|
+
function releaseNote({ siteRelease, generation }) {
|
|
9
|
+
if (!siteRelease)
|
|
10
|
+
return '';
|
|
11
|
+
return ` (${siteRelease}${generation === null ? '' : `, generation ${generation}`})`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Exit status of a live commit: 1 not done, 3 committed with its cache refresh still pending (as `operation recover
|
|
15
|
+
* --wait`), else 0.
|
|
16
|
+
*/
|
|
17
|
+
export function exitCodeOf(result) {
|
|
18
|
+
if (!succeeded(result))
|
|
19
|
+
return 1;
|
|
20
|
+
return result.delivery?.state === 'pending' ? 3 : 0;
|
|
21
|
+
}
|
|
22
|
+
/** The lines every long operation prints: what happened, its problems, and its cache refresh. */
|
|
23
|
+
export function operationResultLines(result, verb) {
|
|
24
|
+
const lines = [];
|
|
25
|
+
if (!succeeded(result))
|
|
26
|
+
lines.push(`${result.state}${result.code ? ` (${result.code})` : ''}: ${result.message ?? 'no message'}`);
|
|
27
|
+
else
|
|
28
|
+
lines.push(`${verb}${releaseNote(result)}.${result.message ? ` ${result.message}` : ''}`);
|
|
29
|
+
for (const item of result.diagnostics)
|
|
30
|
+
lines.push(` ${item.severity} ${item.code} ${item.file}:${item.line}:${item.column} ${item.message}`);
|
|
31
|
+
for (const warning of result.warnings)
|
|
32
|
+
lines.push(`Warning: ${warning}`);
|
|
33
|
+
if (result.delivery?.state === 'pending')
|
|
34
|
+
lines.push(`Cache refresh still pending${result.delivery.reason ? ` (${result.delivery.reason})` : ''}; \`${C} operation ` +
|
|
35
|
+
`recover --wait\` finishes it. Visitors may see the previous version until then.`);
|
|
36
|
+
return lines;
|
|
37
|
+
}
|
|
38
|
+
/** A long write followed to its end: the result it stored, or null when it stopped before the engine answered. */
|
|
39
|
+
function resultOrNull(operation) {
|
|
40
|
+
try {
|
|
41
|
+
return finishedResult(operation);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The lines of a long write, and its exit status as for any live commit (exitCodeOf). */
|
|
48
|
+
export function longWriteReport(operation, verb) {
|
|
49
|
+
const result = resultOrNull(operation);
|
|
50
|
+
if (result)
|
|
51
|
+
return { lines: operationResultLines(result, verb), exitCode: exitCodeOf(result) };
|
|
52
|
+
const error = operation.error;
|
|
53
|
+
if (operation.state === 'unknown')
|
|
54
|
+
return {
|
|
55
|
+
lines: [
|
|
56
|
+
`${operation.kind}: whether it committed is not known yet (${error?.code ?? 'COMMIT_UNKNOWN'}); \`${C} ` +
|
|
57
|
+
`operation recover\` finds out and never runs it again.`,
|
|
58
|
+
],
|
|
59
|
+
exitCode: 1,
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
lines: [`${operation.kind} ${operation.state}${error ? ` (${error.code}): ${error.message}` : ''}`],
|
|
63
|
+
exitCode: 1,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Operation } from '../core-types.js';
|
|
2
|
+
/** One operation as a row: id, kind, state, start, and its error code or stage. */
|
|
3
|
+
export declare function operationRow(operation: Operation): string;
|
|
4
|
+
/**
|
|
5
|
+
* The trace of an operation (recorded while traces were exported): its ID, and its address when the template is set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function traceLines(trace: Operation['trace']): string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** One operation as a row: id, kind, state, start, and its error code or stage. */
|
|
2
|
+
export function operationRow(operation) {
|
|
3
|
+
const detail = operation.error?.code ?? operation.stage ?? '';
|
|
4
|
+
return [operation.id, operation.kind.padEnd(9), operation.state.padEnd(9), operation.startedAt, detail]
|
|
5
|
+
.join(' ')
|
|
6
|
+
.trimEnd();
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The trace of an operation (recorded while traces were exported): its ID, and its address when the template is set.
|
|
10
|
+
*/
|
|
11
|
+
export function traceLines(trace) {
|
|
12
|
+
if (!trace)
|
|
13
|
+
return [];
|
|
14
|
+
return trace.url ? [` trace: ${trace.id}`, ` trace URL: ${trace.url}`] : [` trace: ${trace.id}`];
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { COMMAND } from '../settings.js';
|
|
2
|
+
const C = COMMAND;
|
|
3
|
+
function summary({ changed, new: added, invalid, liveOnly }) {
|
|
4
|
+
const parts = [
|
|
5
|
+
[changed, 'changed'],
|
|
6
|
+
[added, 'new'],
|
|
7
|
+
[invalid, 'invalid'],
|
|
8
|
+
[liveOnly, 'live only'],
|
|
9
|
+
].filter(([n]) => n > 0);
|
|
10
|
+
return parts.length ? parts.map(([n, label]) => `${n} ${label}`).join(', ') : 'none (working directory matches live)';
|
|
11
|
+
}
|
|
12
|
+
/** The lines `foliwake page changes` prints. */
|
|
13
|
+
export function pageChangesLines({ live, pages, counts }) {
|
|
14
|
+
const lines = [];
|
|
15
|
+
if (!live)
|
|
16
|
+
lines.push(`No live site yet; every page is new. \`${C} code prepare\` makes release 1 of the site.`);
|
|
17
|
+
if (pages.length) {
|
|
18
|
+
const header = ['page', 'path', 'file', 'state'];
|
|
19
|
+
const cells = pages.map((r) => [
|
|
20
|
+
r.id ?? '-',
|
|
21
|
+
r.path ?? '-',
|
|
22
|
+
r.file ?? '-',
|
|
23
|
+
r.detail ? `${r.state}: ${r.detail}` : r.state,
|
|
24
|
+
]);
|
|
25
|
+
const widths = header.map((h, i) => Math.max(h.length, ...cells.map((row) => row[i].length)));
|
|
26
|
+
const line = (row) => row
|
|
27
|
+
.map((cell, i) => cell.padEnd(widths[i]))
|
|
28
|
+
.join(' ')
|
|
29
|
+
.trimEnd();
|
|
30
|
+
lines.push(line(header), ...cells.map(line));
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
lines.push('No differences from the live site.');
|
|
34
|
+
lines.push(`Drafts: ${summary(counts)}.`);
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { COMMAND } from '../settings.js';
|
|
2
|
+
const C = COMMAND;
|
|
3
|
+
const SHOWN = 20;
|
|
4
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
5
|
+
/** The lines `foliwake source pending` prints. Editor names are plain text, shown and never stored. */
|
|
6
|
+
export function pendingLines({ site, sources }) {
|
|
7
|
+
const lines = [
|
|
8
|
+
`Site ${site}: edits waiting in ${plural(sources.length, 'source')} (checked now; nothing was fetched or changed)`,
|
|
9
|
+
];
|
|
10
|
+
for (const source of sources) {
|
|
11
|
+
lines.push('');
|
|
12
|
+
if (source.status === 'busy') {
|
|
13
|
+
lines.push(`${source.source}: a sync is running now; check again when it ends.`);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (source.status === 'unsupported') {
|
|
17
|
+
lines.push(`${source.source}: pending edits cannot be checked (${source.code}): ${source.reason}.`);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (source.status === 'unavailable') {
|
|
21
|
+
lines.push(`${source.source}: the check failed (${source.code}): ` +
|
|
22
|
+
`${source.reason}${source.retryAfterMs ? ` — retry in ${Math.ceil(source.retryAfterMs / 1000)} s` : ''}.`);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const { changed, new: added, removed, unknown } = source.counts;
|
|
26
|
+
const parts = [
|
|
27
|
+
changed && `${changed} changed`,
|
|
28
|
+
added && `${added} new`,
|
|
29
|
+
removed && `${removed} removed`,
|
|
30
|
+
unknown && `${unknown} unknown until fetched`,
|
|
31
|
+
].filter(Boolean);
|
|
32
|
+
lines.push(parts.length
|
|
33
|
+
? `${source.source}: ${parts.join(' · ')} since the selected snapshot`
|
|
34
|
+
: `${source.source}: no new edits`);
|
|
35
|
+
for (const change of source.changes.slice(0, SHOWN)) {
|
|
36
|
+
const who = [change.modifiedAt, change.modifiedBy?.name].filter(Boolean).join(' · ');
|
|
37
|
+
lines.push(` ${change.kind.padEnd(8)} ` +
|
|
38
|
+
`${change.path}${change.pageId ? ` (page ${change.pageId})` : ''}${who ? ` ${who}` : ''}`);
|
|
39
|
+
}
|
|
40
|
+
if (source.changes.length > SHOWN)
|
|
41
|
+
lines.push(` … and ${source.changes.length - SHOWN} more (--json lists every one)`);
|
|
42
|
+
if (parts.length)
|
|
43
|
+
lines.push(` Take them into the preview: ${C} source sync --source ${source.source}, then ${C} preview`);
|
|
44
|
+
}
|
|
45
|
+
return lines;
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The lines `foliwake source plugins` prints. */
|
|
2
|
+
export function pluginListLines({ registryFile, apiVersion, plugins, unavailable, disabled, planned, problems, }) {
|
|
3
|
+
const lines = [
|
|
4
|
+
`Content-source plugins (API ${apiVersion}; ` +
|
|
5
|
+
`${registryFile ? 'from the registry file' : 'no registry file, bundled plugins only'})`,
|
|
6
|
+
];
|
|
7
|
+
for (const p of plugins)
|
|
8
|
+
lines.push(` ${p.id.padEnd(16)}${p.displayName} · ` +
|
|
9
|
+
`${p.bundled ? 'bundled' : `${p.package}@${p.packageVersion}${p.origin === 'shipped' ? ' (shipped)' : ''}`} ` +
|
|
10
|
+
`· API ${p.apiVersion} · normalization ${p.normalizationVersion}`);
|
|
11
|
+
if (unavailable.length) {
|
|
12
|
+
lines.push('\nUnavailable (cannot be configured until fixed):');
|
|
13
|
+
for (const p of unavailable)
|
|
14
|
+
lines.push(` ${p.id.padEnd(16)}${p.displayName}${p.origin === 'shipped' ? ' (shipped)' : ''} · ${p.reason}`);
|
|
15
|
+
}
|
|
16
|
+
if (disabled.length) {
|
|
17
|
+
lines.push('\nDisabled by configuration (shipped with the engine, not selected by the registry):');
|
|
18
|
+
for (const p of disabled)
|
|
19
|
+
lines.push(` ${p.id.padEnd(16)}${p.displayName} · to enable, add {"shipped": "${p.id}"}`);
|
|
20
|
+
}
|
|
21
|
+
lines.push('\nPlanned (not installed; cannot be configured):');
|
|
22
|
+
for (const p of planned)
|
|
23
|
+
lines.push(` ${p.id.padEnd(16)}${p.displayName}`);
|
|
24
|
+
if (problems.length) {
|
|
25
|
+
lines.push('\nProblems (these plugins are unavailable; nothing else is affected; --debug says why):');
|
|
26
|
+
for (const p of problems)
|
|
27
|
+
lines.push(` ${p.code}: ${p.message}`);
|
|
28
|
+
}
|
|
29
|
+
return lines;
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const SHOWN_ROWS = 50;
|
|
2
|
+
function fieldLines(fields) {
|
|
3
|
+
return Object.entries(fields).map(([field, message]) => ` ${field}: ${message}`);
|
|
4
|
+
}
|
|
5
|
+
function credentialLines(credentials) {
|
|
6
|
+
return credentials.map((c) => {
|
|
7
|
+
const state = c.set
|
|
8
|
+
? 'set'
|
|
9
|
+
: 'not set: `foliwake credential set` (the installation owner) or the server environment';
|
|
10
|
+
const account = c.serviceAccount ? ` · share the folder with ${c.serviceAccount.clientEmail} (Viewer)` : '';
|
|
11
|
+
return ` ${c.field} → ${c.name}: ${state}${account}`;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function connectionLines(connection) {
|
|
15
|
+
const head = connection.ok ? `Connected: ${connection.target}` : `Not connected: ${connection.target}`;
|
|
16
|
+
const problems = connection.problems.map((p) => ` ${p.severity} ${p.code}: ${p.message}${p.fix ? ` ${p.fix}` : ''}`);
|
|
17
|
+
return [head, ...problems];
|
|
18
|
+
}
|
|
19
|
+
function addressOf(row) {
|
|
20
|
+
if (row.outcome === 'page')
|
|
21
|
+
return row.pagePath ?? '';
|
|
22
|
+
if (row.outcome === 'file')
|
|
23
|
+
return '(decided by the file)';
|
|
24
|
+
if (row.outcome === 'ignored')
|
|
25
|
+
return 'ignored';
|
|
26
|
+
return `no rule fits: ${row.problem ?? ''}`;
|
|
27
|
+
}
|
|
28
|
+
function layoutLines(answer) {
|
|
29
|
+
const { listing, layout } = answer;
|
|
30
|
+
if (listing === null)
|
|
31
|
+
return [];
|
|
32
|
+
if (!listing.ok)
|
|
33
|
+
return [`Listing failed: ${listing.problem?.code}: ${listing.problem?.message}`];
|
|
34
|
+
const lines = [`${listing.total} file(s)${listing.truncated ? `; the first ${listing.items.length} are shown` : ''}`];
|
|
35
|
+
for (const row of (layout?.rows ?? []).slice(0, SHOWN_ROWS))
|
|
36
|
+
lines.push(` ${row.document} → ${addressOf(row)}`);
|
|
37
|
+
if ((layout?.rows.length ?? 0) > SHOWN_ROWS)
|
|
38
|
+
lines.push(` … ${layout.rows.length - SHOWN_ROWS} more (--json shows all)`);
|
|
39
|
+
if (layout && layout.unmatched > 0)
|
|
40
|
+
lines.push(`${layout.unmatched} file(s) fit no rule: the first sync refuses until they are mapped or ignored.`);
|
|
41
|
+
for (const d of layout?.duplicates ?? [])
|
|
42
|
+
lines.push(`Two or more files for ${d.pagePath}: ${d.documents.join(', ')}`);
|
|
43
|
+
return lines;
|
|
44
|
+
}
|
|
45
|
+
function suggestionLines(suggestions) {
|
|
46
|
+
if (suggestions.owns.length === 0)
|
|
47
|
+
return [];
|
|
48
|
+
const overlaps = suggestions.overlaps.map((o) => `${o.path} (owned by "${o.source}")`);
|
|
49
|
+
const tail = overlaps.length ? ` · overlaps ${overlaps.join(', ')}` : ' · no overlap with other sources';
|
|
50
|
+
return [`Owned paths that cover these addresses: ${suggestions.owns.join(' ')}${tail}`];
|
|
51
|
+
}
|
|
52
|
+
/** The lines `foliwake source check` prints for one probed source. Nothing was saved or fetched into a snapshot. */
|
|
53
|
+
export function probeLines(answer) {
|
|
54
|
+
const head = `Source ${answer.source} (${answer.plugin}) of site ${answer.site}: checked ${answer.checkedAt}`;
|
|
55
|
+
if (Object.keys(answer.fields).length > 0)
|
|
56
|
+
return [head, 'The entry has problems; nothing was contacted:', ...fieldLines(answer.fields)];
|
|
57
|
+
const lines = [head, ...credentialLines(answer.credentials)];
|
|
58
|
+
if (answer.connection)
|
|
59
|
+
lines.push(...connectionLines(answer.connection));
|
|
60
|
+
return [...lines, ...layoutLines(answer), ...suggestionLines(answer.suggestions)];
|
|
61
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Diagnostic } from '../lib/diagnostics.js';
|
|
2
|
+
import { type Problem } from '../lib/problems.js';
|
|
3
|
+
/** A page a preview left out, with its diagnostics. */
|
|
4
|
+
export interface SkippedPage {
|
|
5
|
+
/** The page ID, or null when the file has none. */
|
|
6
|
+
page: string | null;
|
|
7
|
+
/** Content-root-relative file. */
|
|
8
|
+
file: string;
|
|
9
|
+
title: string | null;
|
|
10
|
+
lang: string | null;
|
|
11
|
+
path: string | null;
|
|
12
|
+
diagnostics: Array<{
|
|
13
|
+
code: string;
|
|
14
|
+
severity: 'error' | 'warning';
|
|
15
|
+
line: number;
|
|
16
|
+
message: string;
|
|
17
|
+
fix: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/** `Preview not updated · published pages unchanged · 4 problems`; parts that are empty are left out. */
|
|
21
|
+
export declare function headerLine(parts: ReadonlyArray<string | null | false | undefined>, problems: readonly Problem[]): string;
|
|
22
|
+
/** Whether codes may be dimmed: an interactive terminal, and colour not turned off (NO_COLOR, TERM=dumb). */
|
|
23
|
+
export declare function canDim(stream?: {
|
|
24
|
+
isTTY?: boolean;
|
|
25
|
+
}, env?: NodeJS.ProcessEnv): boolean;
|
|
26
|
+
/** The grouped problem lines, indented by `indent`; `dim`: the codes dimmed (ANSI), see canDim. */
|
|
27
|
+
export declare function problemLines(problems: readonly Problem[], { verbose, indent, dim }?: {
|
|
28
|
+
verbose?: boolean;
|
|
29
|
+
indent?: string;
|
|
30
|
+
dim?: boolean;
|
|
31
|
+
}): string[];
|
|
32
|
+
/** Problems from content diagnostics (preview, publish, page check): the file as the content root names it. */
|
|
33
|
+
export declare function contentProblems(diagnostics: readonly Diagnostic[], page?: Problem['page']): Problem[];
|
|
34
|
+
/** Problems of the pages a preview left out: each page's errors, or one line saying it was left out. */
|
|
35
|
+
export declare function leftOutProblems(pages: readonly SkippedPage[]): Problem[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { groupProblems, problemCount, problemMark, problemOf } from '../lib/problems.js';
|
|
2
|
+
/** `Preview not updated · published pages unchanged · 4 problems`; parts that are empty are left out. */
|
|
3
|
+
export function headerLine(parts, problems) {
|
|
4
|
+
return [...parts.filter((part) => Boolean(part)), problems.length ? problemCount(problems) : null]
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.join(' · ');
|
|
7
|
+
}
|
|
8
|
+
/** Whether codes may be dimmed: an interactive terminal, and colour not turned off (NO_COLOR, TERM=dumb). */
|
|
9
|
+
export function canDim(stream = process.stdout, env = process.env) {
|
|
10
|
+
return Boolean(stream.isTTY) && env.NO_COLOR === undefined && env.TERM !== 'dumb';
|
|
11
|
+
}
|
|
12
|
+
const codeTag = (code, dim) => (dim ? `\x1b[2m[${code}]\x1b[22m` : `[${code}]`);
|
|
13
|
+
/** ` (file)` after a group's label when the label does not already name the file. */
|
|
14
|
+
function fileNote(group) {
|
|
15
|
+
const named = group.label === group.file || group.label.startsWith(`${group.file} `);
|
|
16
|
+
return group.file && !named ? ` (${group.file})` : '';
|
|
17
|
+
}
|
|
18
|
+
/** The grouped problem lines, indented by `indent`; `dim`: the codes dimmed (ANSI), see canDim. */
|
|
19
|
+
export function problemLines(problems, { verbose = false, indent = '', dim = false } = {}) {
|
|
20
|
+
const lines = [];
|
|
21
|
+
for (const group of groupProblems(problems)) {
|
|
22
|
+
lines.push(`${indent}${group.label}${fileNote(group)}`);
|
|
23
|
+
for (const problem of group.problems) {
|
|
24
|
+
lines.push(`${indent} ${problemMark(problem)} ` +
|
|
25
|
+
`${problem.line !== null ? `line ${problem.line}: ` : ''}${problem.message} ${codeTag(problem.code, dim)}`);
|
|
26
|
+
if (problem.hint)
|
|
27
|
+
lines.push(`${indent} → ${problem.hint}`);
|
|
28
|
+
if (verbose && problem.details)
|
|
29
|
+
lines.push(`${indent} engine: ${problem.details}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return lines;
|
|
33
|
+
}
|
|
34
|
+
/** Problems from content diagnostics (preview, publish, page check): the file as the content root names it. */
|
|
35
|
+
export function contentProblems(diagnostics, page = null) {
|
|
36
|
+
return diagnostics.map((d) => problemOf({ code: d.code, severity: d.severity, file: d.file, line: d.line, message: d.message, fix: d.fix, page }));
|
|
37
|
+
}
|
|
38
|
+
/** Problems of the pages a preview left out: each page's errors, or one line saying it was left out. */
|
|
39
|
+
export function leftOutProblems(pages) {
|
|
40
|
+
return pages.flatMap((page) => {
|
|
41
|
+
const facts = { title: page.title, lang: page.lang, path: page.path };
|
|
42
|
+
if (page.diagnostics.length === 0) {
|
|
43
|
+
return [
|
|
44
|
+
problemOf({
|
|
45
|
+
code: 'PAGE_LEFT_OUT',
|
|
46
|
+
severity: 'error',
|
|
47
|
+
file: page.file,
|
|
48
|
+
message: 'This page was left out of the preview.',
|
|
49
|
+
fix: page.page === null ? 'Give the file an `id` in its front matter.' : null,
|
|
50
|
+
page: facts,
|
|
51
|
+
}),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return page.diagnostics.map((d) => problemOf({
|
|
55
|
+
code: d.code,
|
|
56
|
+
severity: d.severity,
|
|
57
|
+
file: page.file,
|
|
58
|
+
line: d.line,
|
|
59
|
+
message: d.message,
|
|
60
|
+
fix: d.fix,
|
|
61
|
+
page: facts,
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// `operation recover` for people: what it settled and what is left of the cache refreshes.
|
|
2
|
+
import { COMMAND } from '../settings.js';
|
|
3
|
+
import { operationRow } from './operation.js';
|
|
4
|
+
const C = COMMAND;
|
|
5
|
+
function refreshLine({ cacheRefresh: refresh }) {
|
|
6
|
+
const notRequired = refresh.notRequired
|
|
7
|
+
? `, ${refresh.notRequired} not required (recorded while no cache was configured; nothing sent)`
|
|
8
|
+
: '';
|
|
9
|
+
const counted = `${refresh.processed} refresh(es) done${notRequired}`;
|
|
10
|
+
const waited = refresh.timeoutMs > 0;
|
|
11
|
+
if (refresh.state === 'pending' && refresh.held && refresh.held === refresh.pending)
|
|
12
|
+
return (`Cache refresh: ${counted}, ${refresh.pending} kept pending: ` +
|
|
13
|
+
`${refresh.reason ?? 'no cache is configured now'}.`);
|
|
14
|
+
if (refresh.state === 'pending' && waited) {
|
|
15
|
+
return (`Cache refresh not finished after ${Math.round(refresh.timeoutMs / 1000)} s: ${counted}, ` +
|
|
16
|
+
`${refresh.pending < 0 ? 'an unknown number' : refresh.pending} still pending ` +
|
|
17
|
+
`(${refresh.reason ?? 'not finished'}). They stay recorded; run \`${C} operation recover --wait\` again. ` +
|
|
18
|
+
`Visitors may still see previous versions until then.`);
|
|
19
|
+
}
|
|
20
|
+
if (waited)
|
|
21
|
+
return `Cache refresh done (${counted}).`;
|
|
22
|
+
return refresh.processed || refresh.notRequired ? `Cache refresh: ${counted}.` : null;
|
|
23
|
+
}
|
|
24
|
+
export function recoveryLines(answer) {
|
|
25
|
+
const { engine } = answer;
|
|
26
|
+
const lines = [
|
|
27
|
+
`Recovered. ${engine.interrupted} interrupted operation(s) handled. Live release ` +
|
|
28
|
+
`${engine.live?.generation ?? 'none'}; pending cache refreshes: ${engine.pendingInvalidations}.`,
|
|
29
|
+
];
|
|
30
|
+
for (const operation of answer.operations)
|
|
31
|
+
lines.push(` ${operationRow(operation)}`);
|
|
32
|
+
for (const warning of engine.blockWarnings)
|
|
33
|
+
lines.push(`Warning: ${warning.message}`, ' Check these pages with the new code in preview; republish them to compile them with the new definition.');
|
|
34
|
+
const refresh = refreshLine(engine);
|
|
35
|
+
return refresh ? [...lines, refresh] : lines;
|
|
36
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// What `site reset-storage` prints: the plan (what a reset loses and does) and the reset's end.
|
|
2
|
+
import { COMMAND } from '../settings.js';
|
|
3
|
+
const C = COMMAND;
|
|
4
|
+
const size = (bytes) => bytes < 1024 * 1024 ? `${Math.ceil(bytes / 1024)} KiB` : `${(bytes / 1024 / 1024).toFixed(1)} MiB`;
|
|
5
|
+
function head(name, value) {
|
|
6
|
+
if (!value)
|
|
7
|
+
return ` ${name}: none`;
|
|
8
|
+
const generation = value.generation === null ? '' : ` (generation ${value.generation})`;
|
|
9
|
+
const code = value.codeRelease ? `, code ${value.codeRelease}` : '';
|
|
10
|
+
return ` ${name}: ${value.siteRelease}${generation}${code}`;
|
|
11
|
+
}
|
|
12
|
+
export function resetPlanLines(plan) {
|
|
13
|
+
const lines = [
|
|
14
|
+
`Reset storage of site ${plan.site}: what is lost`,
|
|
15
|
+
' !! Live will be EMPTY (no pages) until you publish again: the reset makes release 1 with code only.',
|
|
16
|
+
head('Live', plan.live),
|
|
17
|
+
head('Preview', plan.preview),
|
|
18
|
+
];
|
|
19
|
+
lines.push(plan.history
|
|
20
|
+
? ` Release history: ${plan.history.committedReleases} committed release(s) of ` +
|
|
21
|
+
`${plan.history.publisherOperations} publisher operation(s), ${plan.history.branchOperations} branch ` +
|
|
22
|
+
`operation(s); page journal: ${plan.history.pageJournal} page(s). Archived in the state folder, not deleted.`
|
|
23
|
+
: ' State: no state database yet.');
|
|
24
|
+
if (plan.storage)
|
|
25
|
+
lines.push(` Storage (${plan.storage.kind}): ${plan.storage.truncated ? 'at least ' : ''}${plan.storage.objects} ` +
|
|
26
|
+
`object(s), ${size(plan.storage.bytes)}, ` +
|
|
27
|
+
`${plan.storage.prefix ? `under ${plan.storage.prefix}` : 'the whole bucket of this site'}: DELETED.`);
|
|
28
|
+
else
|
|
29
|
+
lines.push(` Storage: could not be counted (${plan.storageProblem?.code ?? 'unknown'}: ` +
|
|
30
|
+
`${plan.storageProblem?.message ?? ''}).`);
|
|
31
|
+
if (plan.storage?.kind !== 'local')
|
|
32
|
+
lines.push(" The site's storage key (R2/S3) needs permission to delete objects; without it the reset stops at " +
|
|
33
|
+
'clear-storage.');
|
|
34
|
+
lines.push('What the reset does:', ` ${plan.steps.join(' → ')}`);
|
|
35
|
+
lines.push(` Code prepared again: ${plan.code.rev ?? 'HEAD of the checkout'} (${plan.code.from}); it becomes release 1, ` +
|
|
36
|
+
`code and no pages.`);
|
|
37
|
+
lines.push(` Sources synced again: ${plan.sources.length ? plan.sources.join(', ') : 'none'}. Preview and publication ` +
|
|
38
|
+
`stay with you.`);
|
|
39
|
+
lines.push(' Kept: the operations journal, pushed content, the site configuration and its credentials.');
|
|
40
|
+
if (plan.unfinishedOperations > 0)
|
|
41
|
+
lines.push(` ${plan.unfinishedOperations} operation(s) of this site are still queued or running: the reset is refused ` +
|
|
42
|
+
`until they end.`);
|
|
43
|
+
if (plan.resume)
|
|
44
|
+
lines.push(` An earlier reset (${plan.resume.startedAt}) stopped after: ${plan.resume.done.join(', ') || 'nothing'}. ` +
|
|
45
|
+
`This one goes on from there (archive ${plan.resume.archive}).`);
|
|
46
|
+
lines.push(' Stop the integration worker of this site first, and restart origin, admin and integration afterwards: a ' +
|
|
47
|
+
'process that keeps the old state open writes into the archive.');
|
|
48
|
+
return lines;
|
|
49
|
+
}
|
|
50
|
+
export function resetResultLines(operation) {
|
|
51
|
+
if (operation.state !== 'succeeded') {
|
|
52
|
+
return [
|
|
53
|
+
`The reset did not finish ` +
|
|
54
|
+
`(${operation.state}${operation.error ? `: ${operation.error.code}: ${operation.error.message}` : ''}).`,
|
|
55
|
+
`\`${C} operation get ${operation.id} --site ${operation.site}\` shows its steps.`,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
const result = operation.result;
|
|
59
|
+
return [
|
|
60
|
+
`Storage of site ${result.site} reset${result.resumed ? ' (went on from an earlier run)' : ''}: ` +
|
|
61
|
+
`${result.objectsDeleted} object(s) deleted, old state archived as ${result.archive}.`,
|
|
62
|
+
` Release 1: ${releaseOneText(result)}. Sources synced (${result.sync.state}).`,
|
|
63
|
+
`Nothing was published. Next: \`${C} preview --site ${result.site}\`, check it, then \`${C} publish --site ` +
|
|
64
|
+
`${result.site}\`.`,
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
function releaseOneText({ codePrepare }) {
|
|
68
|
+
const code = codePrepare.codeRelease ? ` with code ${codePrepare.codeRelease}` : '';
|
|
69
|
+
return `${codePrepare.siteRelease ?? 'made earlier'}${code}`;
|
|
70
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// `site status` for people.
|
|
2
|
+
import { COMMAND } from '../settings.js';
|
|
3
|
+
import { describeInputs } from '../lib/summaries.js';
|
|
4
|
+
const C = COMMAND;
|
|
5
|
+
const FINISHED_STATES = ['done', 'noop', 'conflict', 'superseded', 'failed'];
|
|
6
|
+
function committedAt(iso) {
|
|
7
|
+
return `${iso.replace('T', ' ').slice(0, 16)} UTC`;
|
|
8
|
+
}
|
|
9
|
+
function channelLine(channel) {
|
|
10
|
+
return `release ${channel.generation} · ${committedAt(channel.committed_at)}`;
|
|
11
|
+
}
|
|
12
|
+
function versionLines(version) {
|
|
13
|
+
const built = version.inputs
|
|
14
|
+
? ` · built from ${describeInputs(version.inputs)}`
|
|
15
|
+
: ' · source snapshots not recorded here';
|
|
16
|
+
const lines = [
|
|
17
|
+
`Version ${version.site_release}${built} · code ${version.code_release} (publish it with --expect ` +
|
|
18
|
+
`${version.site_release})`,
|
|
19
|
+
];
|
|
20
|
+
if (version.prepared_for_code) {
|
|
21
|
+
lines.push(` prepared for code ${version.prepared_for_code} (preview --code): this preview cannot be published ` +
|
|
22
|
+
`(PUBLISH_PREVIEW_CHANGED); make that code live, run \`${C} preview\` again and review it.`);
|
|
23
|
+
}
|
|
24
|
+
if (version.preview_update === 'migration' &&
|
|
25
|
+
version.live_code_release &&
|
|
26
|
+
version.live_code_release !== version.code_release) {
|
|
27
|
+
lines.push(` new code ${version.code_release} waits here for its release (\`${C} migration commit --expect ` +
|
|
28
|
+
`${version.site_release}@${version.code_release}\`); pages published meanwhile go live on the current live ` +
|
|
29
|
+
`code ${version.live_code_release}.`);
|
|
30
|
+
}
|
|
31
|
+
else if (version.live_code_release && version.live_code_release !== version.code_release) {
|
|
32
|
+
lines.push(` live code is now ${version.live_code_release}: this preview cannot be published ` +
|
|
33
|
+
`(PUBLISH_CODE_CHANGED); run \`${C} preview\` again and review it.`);
|
|
34
|
+
}
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
37
|
+
function pendingLine(status) {
|
|
38
|
+
const pending = [];
|
|
39
|
+
const open = status.operations.filter((operation) => !FINISHED_STATES.includes(operation.state));
|
|
40
|
+
if (status.pendingInvalidations)
|
|
41
|
+
pending.push(`${status.pendingInvalidations} cache refresh(es)` +
|
|
42
|
+
(status.cache.configured ? '' : ' recorded for a cache that is not configured now (kept until it is)'));
|
|
43
|
+
if (open.length)
|
|
44
|
+
pending.push(`${open.length} unfinished operation(s)`);
|
|
45
|
+
return `Pending ${pending.length ? `${pending.join(', ')} — run \`${C} operation recover --wait\`` : 'nothing'}`;
|
|
46
|
+
}
|
|
47
|
+
function lastOperationLines(status) {
|
|
48
|
+
const last = status.operations.at(-1);
|
|
49
|
+
if (last == null)
|
|
50
|
+
return [];
|
|
51
|
+
const pages = last.pages.length ? ` ${last.pages.join(', ')}` : '';
|
|
52
|
+
return [`Last ${last.kind}${pages} → ${last.state}${last.message ? ` (${last.message})` : ''}`];
|
|
53
|
+
}
|
|
54
|
+
function codeReleaseLines(status) {
|
|
55
|
+
const { mode, lastDeploy } = status.codeRollout;
|
|
56
|
+
const lines = [
|
|
57
|
+
`Code new frontend code is released ` +
|
|
58
|
+
(mode === 'auto'
|
|
59
|
+
? 'automatically when its checks pass (codeRelease: auto)'
|
|
60
|
+
: 'by hand after review (codeRelease: manual)'),
|
|
61
|
+
];
|
|
62
|
+
if (lastDeploy)
|
|
63
|
+
lines.push(` last deploy ${lastDeploy.revision.slice(0, 12)} → ${lastDeploy.result} · ` +
|
|
64
|
+
`${committedAt(lastDeploy.at)}${lastDeploy.reason ? ` (${lastDeploy.reason})` : ''}`);
|
|
65
|
+
return lines;
|
|
66
|
+
}
|
|
67
|
+
export function siteStatusLines(status) {
|
|
68
|
+
return [
|
|
69
|
+
`Site ${status.site}`,
|
|
70
|
+
`Live ${status.live ? channelLine(status.live) : `none (\`${C} code prepare\` makes release 1)`}`,
|
|
71
|
+
`Preview ${status.preview ? channelLine(status.preview) : 'none'}`,
|
|
72
|
+
...(status.previewVersion ? versionLines(status.previewVersion) : []),
|
|
73
|
+
...codeReleaseLines(status),
|
|
74
|
+
`Cache ` +
|
|
75
|
+
`${status.cache.configured ? status.cache.target : 'none configured (publications need no cache refresh)'}`,
|
|
76
|
+
pendingLine(status),
|
|
77
|
+
...status.pendingByCache.map((owed) => ` ${owed.target ?? 'a cache'}: ${owed.pending} refresh(es), ${owed.attempts} ` +
|
|
78
|
+
`attempt(s)${owed.lastError ? `, last error: ${owed.lastError}` : ''}`),
|
|
79
|
+
...lastOperationLines(status),
|
|
80
|
+
];
|
|
81
|
+
}
|