@foliwake/cli 0.0.0-stage → 0.7.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 +56 -0
- package/LICENSE +202 -0
- package/README.md +654 -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 +32 -0
- package/dist/commands/create.js +171 -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 +30 -0
- package/dist/commands/dev.js +144 -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 +61 -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 +22 -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 +99 -0
- package/dist/core-command.js +332 -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 +19 -0
- package/dist/dev/flags.js +54 -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 +6 -0
- package/dist/index.js +8 -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/local-runtime.d.ts +78 -0
- package/dist/local-runtime.js +11 -0
- package/dist/local-target.d.ts +6 -0
- package/dist/local-target.js +23 -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 +112 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The front-matter `id` of a Markdown page, read with the engine's rules (byte offsets of its value).
|
|
2
|
+
const FENCE = /^---[ \t]*$/;
|
|
3
|
+
// `id:` at column 1, then a plain or quoted single-line scalar and an optional comment.
|
|
4
|
+
const ID_KEY = /^id[ \t]*:(?=[ \t]|$)/;
|
|
5
|
+
const ID_LINE = /^id[ \t]*:[ \t]*(?:"([^"\\\r\n]*)"|'([^'\r\n]*)'|([^\s#'"\[\]{}|>&*!%@`,][^\r\n#]*?))?[ \t]*(?:#[^\r\n]*)?$/;
|
|
6
|
+
function findIdToken(view) {
|
|
7
|
+
// Lines with their start offsets; `\n` ends a line, a preceding `\r` is kept out of the content.
|
|
8
|
+
const lines = [];
|
|
9
|
+
let offset = 0;
|
|
10
|
+
while (offset <= view.length) {
|
|
11
|
+
const newline = view.indexOf('\n', offset);
|
|
12
|
+
const end = newline === -1 ? view.length : newline;
|
|
13
|
+
const raw = view.slice(offset, end);
|
|
14
|
+
lines.push({ start: offset, text: raw.endsWith('\r') ? raw.slice(0, -1) : raw });
|
|
15
|
+
if (newline === -1)
|
|
16
|
+
break;
|
|
17
|
+
offset = newline + 1;
|
|
18
|
+
}
|
|
19
|
+
if (lines.length === 0 || !FENCE.test(lines[0].text))
|
|
20
|
+
return { token: null, reason: 'the document has no front matter (it must start with a `---` line)' };
|
|
21
|
+
const close = lines.findIndex((line, i) => i > 0 && FENCE.test(line.text));
|
|
22
|
+
if (close === -1)
|
|
23
|
+
return { token: null, reason: 'the front matter has no closing `---` line' };
|
|
24
|
+
let token = null;
|
|
25
|
+
for (const line of lines.slice(1, close)) {
|
|
26
|
+
if (!ID_KEY.test(line.text))
|
|
27
|
+
continue;
|
|
28
|
+
if (token)
|
|
29
|
+
return { token: null, reason: 'the front matter has more than one `id:` line' };
|
|
30
|
+
const match = ID_LINE.exec(line.text);
|
|
31
|
+
const value = match ? (match[1] ?? match[2] ?? match[3]) : undefined;
|
|
32
|
+
if (!match || value === undefined || value === '')
|
|
33
|
+
return { token: null, reason: 'the front-matter `id:` value is not a single-line scalar' };
|
|
34
|
+
// Index of the value inside the line: after the `:` and spaces, plus one for an opening quote.
|
|
35
|
+
const colon = line.text.indexOf(':');
|
|
36
|
+
let at = colon + 1;
|
|
37
|
+
while (line.text[at] === ' ' || line.text[at] === '\t')
|
|
38
|
+
at += 1;
|
|
39
|
+
if (match[1] !== undefined || match[2] !== undefined)
|
|
40
|
+
at += 1;
|
|
41
|
+
token = { start: line.start + at, end: line.start + at + value.length };
|
|
42
|
+
}
|
|
43
|
+
if (!token)
|
|
44
|
+
return { token: null, reason: 'the front matter has no `id:` line' };
|
|
45
|
+
return { token, reason: null };
|
|
46
|
+
}
|
|
47
|
+
const latin1 = (bytes) => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('latin1');
|
|
48
|
+
/**
|
|
49
|
+
* The front-matter `id` value as written (quotes removed), or null when the
|
|
50
|
+
* document has no single, single-line `id:` value. The caller checks the
|
|
51
|
+
* grammar (isValidPageId).
|
|
52
|
+
*/
|
|
53
|
+
export function frontMatterId(markdown) {
|
|
54
|
+
const view = latin1(markdown);
|
|
55
|
+
const { token } = findIdToken(view);
|
|
56
|
+
if (!token)
|
|
57
|
+
return null;
|
|
58
|
+
return Buffer.from(markdown.subarray(token.start, token.end)).toString('utf8');
|
|
59
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CoreFailure } from '../remote/core-failure.js';
|
|
2
|
+
const isStoredResult = (value) => value !== null && typeof value === 'object' && typeof value.operationId === 'string';
|
|
3
|
+
function withoutResult(operation) {
|
|
4
|
+
const message = `The operation is ${operation.state} without a result.`;
|
|
5
|
+
return new CoreFailure(operation.error ?? { code: 'INTERNAL', category: 'internal', retryable: false, message });
|
|
6
|
+
}
|
|
7
|
+
/** The stored result with the current cache refresh; an operation that stopped before a result throws its error. */
|
|
8
|
+
export function finishedResult(operation) {
|
|
9
|
+
const stored = operation.result;
|
|
10
|
+
if (!isStoredResult(stored))
|
|
11
|
+
throw withoutResult(operation);
|
|
12
|
+
const delivery = operation.delivery;
|
|
13
|
+
const known = delivery && (delivery.state === 'done' || delivery.state === 'pending' || delivery.state === 'not_required');
|
|
14
|
+
const now = known ? { state: delivery.state, reason: delivery.reason ?? null } : stored.delivery;
|
|
15
|
+
return { ...stored, delivery: now };
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The fields of a problem that grouping reads. */
|
|
2
|
+
export interface GroupedProblem {
|
|
3
|
+
severity: 'error' | 'warning' | 'info';
|
|
4
|
+
source: string | null;
|
|
5
|
+
file: string | null;
|
|
6
|
+
line: number | null;
|
|
7
|
+
page: {
|
|
8
|
+
title: string | null;
|
|
9
|
+
lang: string | null;
|
|
10
|
+
} | null;
|
|
11
|
+
url: string | null;
|
|
12
|
+
}
|
|
13
|
+
/** Problems of one page or file, in the order found. */
|
|
14
|
+
export interface ProblemGroup<G extends GroupedProblem = GroupedProblem> {
|
|
15
|
+
/** What the group is about: the page title with its language, else the file, else `General`. */
|
|
16
|
+
label: string;
|
|
17
|
+
file: string | null;
|
|
18
|
+
source: string | null;
|
|
19
|
+
url: string | null;
|
|
20
|
+
problems: G[];
|
|
21
|
+
}
|
|
22
|
+
/** Problems grouped by file (a file is a page), errors first within a group; groups with errors first, then by file. */
|
|
23
|
+
export declare function groupProblems<G extends GroupedProblem>(problems: readonly G[]): ProblemGroup<G>[];
|
|
24
|
+
/** `4 problems` / `2 problems, 1 note`: errors and warnings counted apart only when both exist. */
|
|
25
|
+
export declare function problemCount(problems: readonly GroupedProblem[]): string;
|
|
26
|
+
/** What a problem line shows: `✗ line 12: message` / `⚠ message`. */
|
|
27
|
+
export declare function problemMark(problem: GroupedProblem): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Grouping and counting of problems (problems.ts). Structural types only.
|
|
2
|
+
function groupLabel(problem) {
|
|
3
|
+
const title = problem.page?.title ?? null;
|
|
4
|
+
const lang = problem.page?.lang ?? null;
|
|
5
|
+
if (title)
|
|
6
|
+
return lang ? `${title} · ${lang}` : title;
|
|
7
|
+
if (problem.file)
|
|
8
|
+
return lang ? `${problem.file} · ${lang}` : problem.file;
|
|
9
|
+
return 'General';
|
|
10
|
+
}
|
|
11
|
+
/** Problems grouped by file (a file is a page), errors first within a group; groups with errors first, then by file. */
|
|
12
|
+
export function groupProblems(problems) {
|
|
13
|
+
const groups = new Map();
|
|
14
|
+
for (const problem of problems) {
|
|
15
|
+
const key = `${problem.source ?? ''}\0${problem.file ?? ''}`;
|
|
16
|
+
let group = groups.get(key);
|
|
17
|
+
if (!group) {
|
|
18
|
+
group = {
|
|
19
|
+
label: groupLabel(problem),
|
|
20
|
+
file: problem.file,
|
|
21
|
+
source: problem.source,
|
|
22
|
+
url: problem.url,
|
|
23
|
+
problems: [],
|
|
24
|
+
};
|
|
25
|
+
groups.set(key, group);
|
|
26
|
+
}
|
|
27
|
+
group.url ??= problem.url;
|
|
28
|
+
group.problems.push(problem);
|
|
29
|
+
}
|
|
30
|
+
const rank = { error: 0, warning: 1, info: 2 };
|
|
31
|
+
const worst = (group) => Math.min(...group.problems.map((p) => rank[p.severity]));
|
|
32
|
+
for (const group of groups.values())
|
|
33
|
+
group.problems.sort((a, b) => rank[a.severity] - rank[b.severity] || (a.line ?? 0) - (b.line ?? 0));
|
|
34
|
+
return [...groups.values()].sort((a, b) => worst(a) - worst(b) ||
|
|
35
|
+
(a.file === null ? 1 : b.file === null ? -1 : a.file < b.file ? -1 : a.file > b.file ? 1 : 0));
|
|
36
|
+
}
|
|
37
|
+
const count = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
38
|
+
/** `4 problems` / `2 problems, 1 note`: errors and warnings counted apart only when both exist. */
|
|
39
|
+
export function problemCount(problems) {
|
|
40
|
+
const errors = problems.filter((p) => p.severity === 'error').length;
|
|
41
|
+
const notes = problems.length - errors;
|
|
42
|
+
if (errors && notes)
|
|
43
|
+
return `${count(errors, 'problem')}, ${count(notes, 'note')}`;
|
|
44
|
+
return errors ? count(errors, 'problem') : count(notes, 'note');
|
|
45
|
+
}
|
|
46
|
+
/** What a problem line shows: `✗ line 12: message` / `⚠ message`. */
|
|
47
|
+
export function problemMark(problem) {
|
|
48
|
+
return problem.severity === 'error' ? '✗' : problem.severity === 'warning' ? '⚠' : 'ℹ';
|
|
49
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface Problem {
|
|
2
|
+
severity: 'error' | 'warning' | 'info';
|
|
3
|
+
/** Stable code, for support and for a client's own wording. */
|
|
4
|
+
code: string;
|
|
5
|
+
/** The content source the file belongs to; null when not known or not file-related. */
|
|
6
|
+
source: string | null;
|
|
7
|
+
/** The file as the source shows it (source-relative); null: no file. */
|
|
8
|
+
file: string | null;
|
|
9
|
+
/** 1-based line in the file; null when the whole file is meant or the line is not known. */
|
|
10
|
+
line: number | null;
|
|
11
|
+
/** The page the file is, as far as it is known. */
|
|
12
|
+
page: {
|
|
13
|
+
title: string | null;
|
|
14
|
+
lang: string | null;
|
|
15
|
+
path: string | null;
|
|
16
|
+
} | null;
|
|
17
|
+
/** A web address that opens the file (or its folder) in the source; null when none is known. */
|
|
18
|
+
url: string | null;
|
|
19
|
+
/** What is wrong, in plain words. */
|
|
20
|
+
message: string;
|
|
21
|
+
/** What to do about it; null when nothing is needed. */
|
|
22
|
+
hint: string | null;
|
|
23
|
+
/** The engine's technical text, for support. */
|
|
24
|
+
details: string | null;
|
|
25
|
+
/** Further structured fields of this problem, as the engine gave them. */
|
|
26
|
+
facts: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export type ProblemSeverity = Problem['severity'];
|
|
29
|
+
export interface ProblemInput {
|
|
30
|
+
code: string;
|
|
31
|
+
severity: ProblemSeverity;
|
|
32
|
+
source?: string | null;
|
|
33
|
+
file?: string | null;
|
|
34
|
+
line?: number | null;
|
|
35
|
+
message: string;
|
|
36
|
+
fix?: string | null;
|
|
37
|
+
page?: Problem['page'];
|
|
38
|
+
url?: string | null;
|
|
39
|
+
facts?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** What the author texts can use besides the diagnostic itself. */
|
|
42
|
+
export interface ProblemContext {
|
|
43
|
+
/** File names the source's path mapping rules expect (SOURCE_PATH_UNMAPPED), e.g. `lesson/{lang}.md`. */
|
|
44
|
+
expectedFiles?: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
/** A problem from a diagnostic: plain texts where the engine has them, its own text kept in `details`. */
|
|
47
|
+
export declare function problemOf(input: ProblemInput, context?: ProblemContext): Problem;
|
|
48
|
+
/** The codes that have a plain text for authors (tests, documentation). */
|
|
49
|
+
export declare const AUTHOR_TEXT_CODES: readonly string[];
|
|
50
|
+
export { type ProblemGroup, groupProblems, problemCount, problemMark } from './problem-groups.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Problems for authors: what the engine found in a source's files, as fields rather than one sentence, so each
|
|
2
|
+
// client can show them its own way. The plain texts are English; a client that localises maps `code` (and
|
|
3
|
+
// `facts`) to its own words, and falls back to `message`/`hint` for a code it does not know.
|
|
4
|
+
const IMAGE_NAME = /[^\s"'`()<>]*\.(?:png|jpe?g|gif|webp|avif|svg)\b/i;
|
|
5
|
+
const HTML_TAG = /<\/?([A-Za-z][A-Za-z0-9-]*)/;
|
|
6
|
+
const quote = (text) => `\`${text}\``;
|
|
7
|
+
const baseName = (file) => file.split('/').filter(Boolean).at(-1) ?? file;
|
|
8
|
+
const folderOf = (file) => file.split('/').filter(Boolean).slice(0, -1).join('/');
|
|
9
|
+
// A hint of the engine worth keeping next to the plain one (a near name it found).
|
|
10
|
+
const nearName = (fix) => fix && /^(Did you mean|Match the exact letter case)/.test(fix) ? fix : null;
|
|
11
|
+
/** Plain texts by code; a code without one keeps the engine's message and fix. */
|
|
12
|
+
const AUTHOR_TEXTS = {
|
|
13
|
+
CONTENT_IMAGE_NOT_FOUND: (input) => {
|
|
14
|
+
const found = IMAGE_NAME.exec(input.message)?.[0] ?? null;
|
|
15
|
+
const image = found ? found.replace(/^\.\//, '') : null;
|
|
16
|
+
const name = image ? baseName(image) : null;
|
|
17
|
+
const folder = image ? folderOf(image) : '';
|
|
18
|
+
const near = nearName(input.fix);
|
|
19
|
+
return {
|
|
20
|
+
message: name
|
|
21
|
+
? `The picture ${quote(name)} is missing${folder ? ` from the folder ${quote(folder)}` : ''}.`
|
|
22
|
+
: 'A picture the page shows is missing.',
|
|
23
|
+
hint: `${near ? `${near} ` : ''}If you have just copied the files, wait until the upload has finished and ` +
|
|
24
|
+
`update the preview again. Otherwise check the file name: capital and small letters are different.`,
|
|
25
|
+
...(image ? { facts: { image } } : {}),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
SECTION_EMPTY: () => ({
|
|
29
|
+
message: 'An extra `---` line leaves an empty section; it was skipped.',
|
|
30
|
+
hint: 'Nothing has to be done. Remove the extra `---` line to make this note go away.',
|
|
31
|
+
}),
|
|
32
|
+
CONTENT_H1_COUNT: (input) => /\bno `#` heading/.test(input.message)
|
|
33
|
+
? { message: 'The page has no heading.', hint: 'Add a line `# Title of the page` before the text.' }
|
|
34
|
+
: {
|
|
35
|
+
message: 'The page has more than one main heading (`#`).',
|
|
36
|
+
hint: 'Keep one `# Title` line; change the other `#` headings to `##`.',
|
|
37
|
+
},
|
|
38
|
+
CONTENT_RAW_HTML: (input) => {
|
|
39
|
+
const tag = HTML_TAG.exec(input.message)?.[1]?.toLowerCase() ?? null;
|
|
40
|
+
return {
|
|
41
|
+
message: `HTML tags${tag ? ` (${quote(`<${tag}>`)})` : ''} are not supported.`,
|
|
42
|
+
hint: tag === 'details'
|
|
43
|
+
? 'Write the answer as ordinary text instead, for example `> **Answer:** …`.'
|
|
44
|
+
: 'Write it as ordinary text or Markdown instead. To show a `<` as text, write `<`.',
|
|
45
|
+
...(tag ? { facts: { tag } } : {}),
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
CONTENT_FRONT_MATTER_MISSING: () => ({
|
|
49
|
+
message: 'The settings block between `---` lines at the top of the file is missing, not closed, or not written correctly.',
|
|
50
|
+
hint: 'Start the file with a `---` line, write one `key: value` per line (for example `title: Name of the ' +
|
|
51
|
+
'page`), and close it with another `---` line.',
|
|
52
|
+
}),
|
|
53
|
+
SOURCE_PATH_UNMAPPED: (input, context) => {
|
|
54
|
+
const expected = context.expectedFiles ?? [];
|
|
55
|
+
return {
|
|
56
|
+
message: 'This file is not where Foliwake expects it, so it does not become a page.',
|
|
57
|
+
hint: `${expected.length ? `Expected file names: ${expected.map(quote).join(', ')}. ` : ''}Move or rename the ` +
|
|
58
|
+
`file, or ask your administrator to add a rule for it.`,
|
|
59
|
+
...(expected.length ? { facts: { expectedFiles: [...expected] } } : {}),
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
MAPPINGS_RULE_UNUSED: (input) => ({
|
|
63
|
+
message: `${input.message.replace(/ fits no document of the source\.$/, '')} matches no file of the source.`,
|
|
64
|
+
hint: input.fix ?? null,
|
|
65
|
+
}),
|
|
66
|
+
SOURCE_PUBLISHED_PATH_CONFLICT: (input) => ({
|
|
67
|
+
message: 'Two files want the same web address; neither is published there.',
|
|
68
|
+
hint: input.fix ?? 'Give one of the pages another address (or remove one of the files).',
|
|
69
|
+
}),
|
|
70
|
+
SOURCE_PATH_CONFLICT: (input) => ({
|
|
71
|
+
message: 'Another source already has a page at this web address.',
|
|
72
|
+
hint: input.fix ?? 'Give the page another address, or ask your administrator which source owns it.',
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
75
|
+
/** A problem from a diagnostic: plain texts where the engine has them, its own text kept in `details`. */
|
|
76
|
+
export function problemOf(input, context = {}) {
|
|
77
|
+
const author = AUTHOR_TEXTS[input.code]?.(input, context) ?? null;
|
|
78
|
+
return {
|
|
79
|
+
severity: input.severity,
|
|
80
|
+
code: input.code,
|
|
81
|
+
source: input.source ?? null,
|
|
82
|
+
file: input.file || null,
|
|
83
|
+
line: input.line && input.line > 0 ? input.line : null,
|
|
84
|
+
page: input.page ?? null,
|
|
85
|
+
url: input.url ?? null,
|
|
86
|
+
message: author?.message ?? input.message,
|
|
87
|
+
hint: author ? author.hint : (input.fix ?? null),
|
|
88
|
+
details: author ? `${input.message}${input.fix ? ` ${input.fix}` : ''}` : null,
|
|
89
|
+
facts: { ...(author?.facts ?? {}), ...(input.facts ?? {}) },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** The codes that have a plain text for authors (tests, documentation). */
|
|
93
|
+
export const AUTHOR_TEXT_CODES = Object.keys(AUTHOR_TEXTS);
|
|
94
|
+
export { groupProblems, problemCount, problemMark } from './problem-groups.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
export interface PromptStreams {
|
|
3
|
+
input: Readable;
|
|
4
|
+
output: Writable;
|
|
5
|
+
}
|
|
6
|
+
/** A server to offer: signed in to, signed out of, or Foliwake Cloud. */
|
|
7
|
+
export interface ServerEntry {
|
|
8
|
+
origin: string;
|
|
9
|
+
signedIn: boolean;
|
|
10
|
+
/** The signed-in account's e-mail address, when known. */
|
|
11
|
+
account: string | null;
|
|
12
|
+
lastUsed: boolean;
|
|
13
|
+
/** Shown instead of the origin (Foliwake Cloud: "Foliwake Cloud (cloud)"). */
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Offered as "Another server…" when no server of one's own is known. */
|
|
17
|
+
export declare const DEFAULT_NEW_SERVER = "http://localhost:8080";
|
|
18
|
+
/** A server in a list: its title or origin, then its account and "last used", or "sign in". */
|
|
19
|
+
export declare function serverChoiceLabel(server: ServerEntry): string;
|
|
20
|
+
/**
|
|
21
|
+
* Which server: each server signed in to, those signed out of and Foliwake Cloud ("sign in"), "Another
|
|
22
|
+
* server…" (an address) and "Not now". Null: not now, or cancelled. `origin` checks an address.
|
|
23
|
+
*/
|
|
24
|
+
export declare function askServer(io: PromptStreams, servers: readonly ServerEntry[], origin: (typed: string) => string, { message, allowOther }?: {
|
|
25
|
+
message?: string;
|
|
26
|
+
allowOther?: boolean;
|
|
27
|
+
}): Promise<string | null>;
|
|
28
|
+
/** After the server is chosen and signed in to: a new site (admins only), an existing one, or not now. */
|
|
29
|
+
export declare function askConnect(io: PromptStreams, { server, site, mayCreate, sites }: {
|
|
30
|
+
server: string;
|
|
31
|
+
site: string;
|
|
32
|
+
mayCreate: boolean;
|
|
33
|
+
sites: readonly string[];
|
|
34
|
+
}): Promise<{
|
|
35
|
+
create: string;
|
|
36
|
+
} | {
|
|
37
|
+
link: string;
|
|
38
|
+
} | null>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isCancel, select, text } from '@clack/prompts';
|
|
2
|
+
/** Offered as "Another server…" when no server of one's own is known. */
|
|
3
|
+
export const DEFAULT_NEW_SERVER = 'http://localhost:8080';
|
|
4
|
+
const OTHER = '\0other';
|
|
5
|
+
const NOT_NOW = '\0no';
|
|
6
|
+
/** A server in a list: its title or origin, then its account and "last used", or "sign in". */
|
|
7
|
+
export function serverChoiceLabel(server) {
|
|
8
|
+
const signedNotes = [server.account, server.lastUsed ? 'last used' : null].filter(Boolean).join(' · ');
|
|
9
|
+
const notes = server.signedIn ? signedNotes : 'sign in';
|
|
10
|
+
const name = server.title ?? server.origin;
|
|
11
|
+
return notes ? `${name} — ${notes}` : name;
|
|
12
|
+
}
|
|
13
|
+
function addressCheck(origin, fallback) {
|
|
14
|
+
return (value) => {
|
|
15
|
+
if (!value)
|
|
16
|
+
return fallback ? undefined : 'Give the server address, e.g. https://foliwake.example';
|
|
17
|
+
try {
|
|
18
|
+
origin(value);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return error.message;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function askAddress(io, origin, fallback) {
|
|
27
|
+
const typed = await text({
|
|
28
|
+
...io,
|
|
29
|
+
message: 'Server address',
|
|
30
|
+
placeholder: fallback ?? 'https://foliwake.example',
|
|
31
|
+
...(fallback ? { defaultValue: fallback } : {}),
|
|
32
|
+
validate: addressCheck(origin, fallback),
|
|
33
|
+
});
|
|
34
|
+
if (isCancel(typed))
|
|
35
|
+
return null;
|
|
36
|
+
return origin(typed || fallback);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Which server: each server signed in to, those signed out of and Foliwake Cloud ("sign in"), "Another
|
|
40
|
+
* server…" (an address) and "Not now". Null: not now, or cancelled. `origin` checks an address.
|
|
41
|
+
*/
|
|
42
|
+
export async function askServer(io, servers, origin, { message = 'Connect to a Foliwake server?', allowOther = true } = {}) {
|
|
43
|
+
const own = servers.filter((server) => server.signedIn || !server.title);
|
|
44
|
+
const fallback = own.length ? undefined : DEFAULT_NEW_SERVER;
|
|
45
|
+
const options = servers.map((server) => ({
|
|
46
|
+
value: server.origin,
|
|
47
|
+
label: serverChoiceLabel(server),
|
|
48
|
+
}));
|
|
49
|
+
if (allowOther)
|
|
50
|
+
options.push({ value: OTHER, label: 'Another server…', ...(fallback ? { hint: fallback } : {}) });
|
|
51
|
+
options.push({ value: NOT_NOW, label: 'Not now' });
|
|
52
|
+
const initial = servers.find((s) => s.lastUsed) ?? servers.find((s) => s.signedIn) ?? own[0];
|
|
53
|
+
const initialValue = initial?.origin ?? (allowOther ? OTHER : NOT_NOW);
|
|
54
|
+
const choice = await select({ ...io, message, initialValue, options });
|
|
55
|
+
if (isCancel(choice) || choice === NOT_NOW)
|
|
56
|
+
return null;
|
|
57
|
+
if (choice !== OTHER)
|
|
58
|
+
return choice;
|
|
59
|
+
return askAddress(io, origin, fallback);
|
|
60
|
+
}
|
|
61
|
+
/** After the server is chosen and signed in to: a new site (admins only), an existing one, or not now. */
|
|
62
|
+
export async function askConnect(io, { server, site, mayCreate, sites }) {
|
|
63
|
+
const options = [];
|
|
64
|
+
if (mayCreate)
|
|
65
|
+
options.push({ value: 'create', label: `Create a new site "${site}"` });
|
|
66
|
+
if (sites.length)
|
|
67
|
+
options.push({ value: 'link', label: 'Link an existing site', hint: `${sites.length} you may develop` });
|
|
68
|
+
options.push({ value: 'no', label: 'Not now' });
|
|
69
|
+
const choice = await select({ ...io, message: `Site on ${server}`, initialValue: options[0].value, options });
|
|
70
|
+
if (isCancel(choice) || choice === 'no')
|
|
71
|
+
return null;
|
|
72
|
+
if (choice === 'create')
|
|
73
|
+
return { create: site };
|
|
74
|
+
const sitesList = sites.map((id) => ({ value: id, label: id }));
|
|
75
|
+
const picked = await select({ ...io, message: 'Which site?', options: sitesList });
|
|
76
|
+
return isCancel(picked) ? null : { link: picked };
|
|
77
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export type OperationResult = {
|
|
2
|
+
operationId: string;
|
|
3
|
+
state: string;
|
|
4
|
+
code: string | null;
|
|
5
|
+
message: string | null;
|
|
6
|
+
siteRelease: string | null;
|
|
7
|
+
generation: number | null;
|
|
8
|
+
codeRelease: string | null;
|
|
9
|
+
sourceRevision: string | null;
|
|
10
|
+
previousSiteRelease: string | null;
|
|
11
|
+
diagnostics: Array<{
|
|
12
|
+
code: string;
|
|
13
|
+
severity: 'error' | 'warning';
|
|
14
|
+
file: string;
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
message: string;
|
|
18
|
+
fix: string | null;
|
|
19
|
+
}>;
|
|
20
|
+
warnings: string[];
|
|
21
|
+
delivery: {
|
|
22
|
+
state: 'done' | 'pending' | 'not_required';
|
|
23
|
+
reason: string | null;
|
|
24
|
+
} | null;
|
|
25
|
+
};
|
|
26
|
+
export type ResetStorageResult = {
|
|
27
|
+
site: string;
|
|
28
|
+
archive: string;
|
|
29
|
+
objectsDeleted: number;
|
|
30
|
+
resumed: boolean;
|
|
31
|
+
codePrepare: {
|
|
32
|
+
operation: string | null;
|
|
33
|
+
state: string;
|
|
34
|
+
siteRelease: string | null;
|
|
35
|
+
codeRelease: string | null;
|
|
36
|
+
};
|
|
37
|
+
sync: {
|
|
38
|
+
operation: string | null;
|
|
39
|
+
state: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type SiteCreateResult = {
|
|
43
|
+
site: string;
|
|
44
|
+
org: string;
|
|
45
|
+
addresses: {
|
|
46
|
+
live: string | null;
|
|
47
|
+
preview: string | null;
|
|
48
|
+
branchPattern: string | null;
|
|
49
|
+
};
|
|
50
|
+
releaseOne: {
|
|
51
|
+
state: 'done';
|
|
52
|
+
siteRelease: string;
|
|
53
|
+
codeRelease: string;
|
|
54
|
+
commit: string;
|
|
55
|
+
} | {
|
|
56
|
+
state: 'waiting';
|
|
57
|
+
};
|
|
58
|
+
bucketCreated: boolean;
|
|
59
|
+
};
|
|
60
|
+
export type SyncResultCore = {
|
|
61
|
+
results: Array<{
|
|
62
|
+
site: string;
|
|
63
|
+
source: string;
|
|
64
|
+
plugin: string;
|
|
65
|
+
mode: 'working-folder' | 'snapshot';
|
|
66
|
+
status: string;
|
|
67
|
+
accepted: boolean;
|
|
68
|
+
code: string | null;
|
|
69
|
+
message: string;
|
|
70
|
+
attempt: number | null;
|
|
71
|
+
snapshot: string | null;
|
|
72
|
+
selected: {
|
|
73
|
+
snapshot: string;
|
|
74
|
+
sequence: number;
|
|
75
|
+
selected_at: string;
|
|
76
|
+
} | null;
|
|
77
|
+
config_digest: string;
|
|
78
|
+
consistency: unknown | null;
|
|
79
|
+
revision: string | null;
|
|
80
|
+
binding: string | null;
|
|
81
|
+
items: Array<{
|
|
82
|
+
native_id: string;
|
|
83
|
+
page_id: string;
|
|
84
|
+
path: string;
|
|
85
|
+
document: string;
|
|
86
|
+
revision: string | null;
|
|
87
|
+
digest: string;
|
|
88
|
+
locations: unknown;
|
|
89
|
+
observed?: unknown;
|
|
90
|
+
}>;
|
|
91
|
+
diagnostics: Array<{
|
|
92
|
+
code: string;
|
|
93
|
+
severity: 'error' | 'warning';
|
|
94
|
+
operation: string;
|
|
95
|
+
source: string;
|
|
96
|
+
nativeId: string | null;
|
|
97
|
+
origin: {
|
|
98
|
+
kind: 'file';
|
|
99
|
+
file: string;
|
|
100
|
+
line: number;
|
|
101
|
+
column: number;
|
|
102
|
+
} | {
|
|
103
|
+
kind: 'element';
|
|
104
|
+
document: string;
|
|
105
|
+
tab?: string | null;
|
|
106
|
+
element: string;
|
|
107
|
+
field?: string | null;
|
|
108
|
+
} | null;
|
|
109
|
+
message: string;
|
|
110
|
+
fix: string | null;
|
|
111
|
+
retryable: boolean;
|
|
112
|
+
claimants?: Array<{
|
|
113
|
+
document: string | null;
|
|
114
|
+
nativeId: string;
|
|
115
|
+
modifiedAt: string | null;
|
|
116
|
+
path: string;
|
|
117
|
+
}>;
|
|
118
|
+
}>;
|
|
119
|
+
problems?: Array<{
|
|
120
|
+
severity: 'error' | 'warning' | 'info';
|
|
121
|
+
code: string;
|
|
122
|
+
source: string | null;
|
|
123
|
+
file: string | null;
|
|
124
|
+
line: number | null;
|
|
125
|
+
page: {
|
|
126
|
+
title: string | null;
|
|
127
|
+
lang: string | null;
|
|
128
|
+
path: string | null;
|
|
129
|
+
} | null;
|
|
130
|
+
url: string | null;
|
|
131
|
+
message: string;
|
|
132
|
+
hint: string | null;
|
|
133
|
+
details: string | null;
|
|
134
|
+
facts: {
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
};
|
|
137
|
+
}>;
|
|
138
|
+
retryAfterMs?: number | null;
|
|
139
|
+
acquisition?: {
|
|
140
|
+
provider: string;
|
|
141
|
+
commit: string | null;
|
|
142
|
+
treeOid: string | null;
|
|
143
|
+
method: string | null;
|
|
144
|
+
entries: number;
|
|
145
|
+
readable: number;
|
|
146
|
+
downloaded: number;
|
|
147
|
+
repaired: number;
|
|
148
|
+
requests: number;
|
|
149
|
+
notes: Array<{
|
|
150
|
+
code: string;
|
|
151
|
+
severity: string;
|
|
152
|
+
message: string;
|
|
153
|
+
}>;
|
|
154
|
+
};
|
|
155
|
+
scope?: unknown;
|
|
156
|
+
}>;
|
|
157
|
+
};
|
|
158
|
+
export type BranchResultCore = {
|
|
159
|
+
branch: string;
|
|
160
|
+
label: string | null;
|
|
161
|
+
state: string;
|
|
162
|
+
code: string | null;
|
|
163
|
+
message: string | null;
|
|
164
|
+
generation: number | null;
|
|
165
|
+
selection: string | null;
|
|
166
|
+
codeRelease: string | null;
|
|
167
|
+
sourceRevision: string | null;
|
|
168
|
+
host: string | null;
|
|
169
|
+
hostNote: string | null;
|
|
170
|
+
releasedHost: string | null;
|
|
171
|
+
previewUrl: string | null;
|
|
172
|
+
siteBranchUrl: string | null;
|
|
173
|
+
prepared: {
|
|
174
|
+
operationId: string;
|
|
175
|
+
state: string;
|
|
176
|
+
code: string | null;
|
|
177
|
+
message: string | null;
|
|
178
|
+
siteRelease: string | null;
|
|
179
|
+
generation: number | null;
|
|
180
|
+
codeRelease: string | null;
|
|
181
|
+
sourceRevision: string | null;
|
|
182
|
+
previousSiteRelease: string | null;
|
|
183
|
+
diagnostics: Array<{
|
|
184
|
+
code: string;
|
|
185
|
+
severity: 'error' | 'warning';
|
|
186
|
+
file: string;
|
|
187
|
+
line: number;
|
|
188
|
+
column: number;
|
|
189
|
+
message: string;
|
|
190
|
+
fix: string | null;
|
|
191
|
+
}>;
|
|
192
|
+
warnings: string[];
|
|
193
|
+
delivery: {
|
|
194
|
+
state: 'done' | 'pending' | 'not_required';
|
|
195
|
+
reason: string | null;
|
|
196
|
+
} | null;
|
|
197
|
+
} | null;
|
|
198
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** What a branch host names for `publish --expect`: the preview release and the code it was shown with. */
|
|
2
|
+
export declare function parseExpectedVersion(value: string): {
|
|
3
|
+
preview: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
} | null;
|
|
6
|
+
/** The URLs of a branch for people: its site branch host first, then its readable host, then its label host. */
|
|
7
|
+
export declare function describeBranchUrls({ site, readable, label, }: {
|
|
8
|
+
site: string | null;
|
|
9
|
+
readable: string | null;
|
|
10
|
+
label: string;
|
|
11
|
+
}): string;
|
|
12
|
+
/** The credential name of a site's code token: `<SITE>__CODE_TOKEN` (upper case, `-` as `_`). */
|
|
13
|
+
export declare function codeTokenName(siteId: string): string;
|
|
14
|
+
/** The largest credential value a server keeps, in bytes. */
|
|
15
|
+
export declare const MAX_CREDENTIAL_BYTES: number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Small rules the commands check or name before calling a server: branch review targets, branch URLs, the code
|
|
2
|
+
// token's credential name and the largest credential value.
|
|
3
|
+
const EXPECTED_VERSION_PATTERN = /^(sr_[0-9a-f]{32})(?:@(cd_[0-9a-f]{32,64}))?$/;
|
|
4
|
+
/** What a branch host names for `publish --expect`: the preview release and the code it was shown with. */
|
|
5
|
+
export function parseExpectedVersion(value) {
|
|
6
|
+
const match = EXPECTED_VERSION_PATTERN.exec(value);
|
|
7
|
+
if (!match)
|
|
8
|
+
return null;
|
|
9
|
+
const [, preview, code] = match;
|
|
10
|
+
if (preview === undefined)
|
|
11
|
+
return null;
|
|
12
|
+
if (code === undefined)
|
|
13
|
+
return { preview };
|
|
14
|
+
return { preview, code };
|
|
15
|
+
}
|
|
16
|
+
/** The URLs of a branch for people: its site branch host first, then its readable host, then its label host. */
|
|
17
|
+
export function describeBranchUrls({ site, readable, label, }) {
|
|
18
|
+
const urls = readable ? `${readable} (also ${label})` : label;
|
|
19
|
+
return site ? `${site} (also ${urls})` : urls;
|
|
20
|
+
}
|
|
21
|
+
/** The credential name of a site's code token: `<SITE>__CODE_TOKEN` (upper case, `-` as `_`). */
|
|
22
|
+
export function codeTokenName(siteId) {
|
|
23
|
+
return `${siteId.toUpperCase().replaceAll('-', '_')}__CODE_TOKEN`;
|
|
24
|
+
}
|
|
25
|
+
/** The largest credential value a server keeps, in bytes. */
|
|
26
|
+
export const MAX_CREDENTIAL_BYTES = 64 * 1024;
|