@forumulate/cli 0.9.0 → 0.11.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/README.md +3 -3
- package/dist/api/args.d.ts.map +1 -1
- package/dist/api/args.js +1 -0
- package/dist/api/args.js.map +1 -1
- package/dist/api/command.d.ts +1 -1
- package/dist/api/command.d.ts.map +1 -1
- package/dist/api/command.js +86 -11
- package/dist/api/command.js.map +1 -1
- package/dist/api/http.d.ts +8 -0
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +3 -2
- package/dist/api/http.js.map +1 -1
- package/dist/api/live-spec.d.ts +48 -0
- package/dist/api/live-spec.d.ts.map +1 -0
- package/dist/api/live-spec.js +72 -0
- package/dist/api/live-spec.js.map +1 -0
- package/dist/api/operations.json +1 -1
- package/dist/api/request.d.ts.map +1 -1
- package/dist/api/request.js +25 -1
- package/dist/api/request.js.map +1 -1
- package/dist/api/send.d.ts +10 -1
- package/dist/api/send.d.ts.map +1 -1
- package/dist/api/send.js +14 -3
- package/dist/api/send.js.map +1 -1
- package/dist/api/slim.d.ts +14 -0
- package/dist/api/slim.d.ts.map +1 -0
- package/dist/api/slim.js +174 -0
- package/dist/api/slim.js.map +1 -0
- package/dist/cache-command.d.ts +12 -0
- package/dist/cache-command.d.ts.map +1 -0
- package/dist/cache-command.js +93 -0
- package/dist/cache-command.js.map +1 -0
- package/dist/check/command.d.ts +48 -0
- package/dist/check/command.d.ts.map +1 -0
- package/dist/check/command.js +256 -0
- package/dist/check/command.js.map +1 -0
- package/dist/check/external.d.ts +66 -0
- package/dist/check/external.d.ts.map +1 -0
- package/dist/check/external.js +177 -0
- package/dist/check/external.js.map +1 -0
- package/dist/check/markdown-links.d.ts +38 -0
- package/dist/check/markdown-links.d.ts.map +1 -0
- package/dist/check/markdown-links.js +166 -0
- package/dist/check/markdown-links.js.map +1 -0
- package/dist/cli.js +42 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +3 -0
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +6 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/groups-api.d.ts.map +1 -1
- package/dist/commands/groups-api.js +20 -2
- package/dist/commands/groups-api.js.map +1 -1
- package/dist/commands/groups-docs.d.ts.map +1 -1
- package/dist/commands/groups-docs.js +8 -2
- package/dist/commands/groups-docs.js.map +1 -1
- package/dist/commands/groups-jobs.d.ts +10 -0
- package/dist/commands/groups-jobs.d.ts.map +1 -0
- package/dist/commands/groups-jobs.js +89 -0
- package/dist/commands/groups-jobs.js.map +1 -0
- package/dist/commands/groups-org.d.ts.map +1 -1
- package/dist/commands/groups-org.js +59 -2
- package/dist/commands/groups-org.js.map +1 -1
- package/dist/commands/groups-site.d.ts.map +1 -1
- package/dist/commands/groups-site.js +33 -3
- package/dist/commands/groups-site.js.map +1 -1
- package/dist/commands/groups-spaces.d.ts.map +1 -1
- package/dist/commands/groups-spaces.js +11 -5
- package/dist/commands/groups-spaces.js.map +1 -1
- package/dist/commands/groups-types.d.ts.map +1 -1
- package/dist/commands/groups-types.js +74 -0
- package/dist/commands/groups-types.js.map +1 -1
- package/dist/commands/groups.d.ts.map +1 -1
- package/dist/commands/groups.js +2 -0
- package/dist/commands/groups.js.map +1 -1
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +18 -3
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/job-wait.d.ts +64 -0
- package/dist/commands/job-wait.d.ts.map +1 -0
- package/dist/commands/job-wait.js +91 -0
- package/dist/commands/job-wait.js.map +1 -0
- package/dist/commands/resource.d.ts +19 -0
- package/dist/commands/resource.d.ts.map +1 -1
- package/dist/commands/resource.js +65 -3
- package/dist/commands/resource.js.map +1 -1
- package/dist/content/library.d.ts +8 -0
- package/dist/content/library.d.ts.map +1 -1
- package/dist/content/library.js +10 -2
- package/dist/content/library.js.map +1 -1
- package/dist/credentials.d.ts +43 -4
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +67 -4
- package/dist/credentials.js.map +1 -1
- package/dist/doctor/address-checks.d.ts +56 -0
- package/dist/doctor/address-checks.d.ts.map +1 -0
- package/dist/doctor/address-checks.js +183 -0
- package/dist/doctor/address-checks.js.map +1 -0
- package/dist/doctor/boilerplate.d.ts +33 -0
- package/dist/doctor/boilerplate.d.ts.map +1 -0
- package/dist/doctor/boilerplate.js +78 -0
- package/dist/doctor/boilerplate.js.map +1 -0
- package/dist/doctor/command.d.ts +18 -0
- package/dist/doctor/command.d.ts.map +1 -0
- package/dist/doctor/command.js +234 -0
- package/dist/doctor/command.js.map +1 -0
- package/dist/doctor/crawl.d.ts +49 -0
- package/dist/doctor/crawl.d.ts.map +1 -0
- package/dist/doctor/crawl.js +210 -0
- package/dist/doctor/crawl.js.map +1 -0
- package/dist/doctor/extended.d.ts +52 -0
- package/dist/doctor/extended.d.ts.map +1 -0
- package/dist/doctor/extended.js +150 -0
- package/dist/doctor/extended.js.map +1 -0
- package/dist/doctor/page-checks.d.ts +42 -0
- package/dist/doctor/page-checks.d.ts.map +1 -0
- package/dist/doctor/page-checks.js +200 -0
- package/dist/doctor/page-checks.js.map +1 -0
- package/dist/doctor/probe.d.ts +63 -0
- package/dist/doctor/probe.d.ts.map +1 -0
- package/dist/doctor/probe.js +170 -0
- package/dist/doctor/probe.js.map +1 -0
- package/dist/doctor/reader-auth-atlas.d.ts +18 -0
- package/dist/doctor/reader-auth-atlas.d.ts.map +1 -0
- package/dist/doctor/reader-auth-atlas.js +50 -0
- package/dist/doctor/reader-auth-atlas.js.map +1 -0
- package/dist/doctor/robots-params.d.ts +36 -0
- package/dist/doctor/robots-params.d.ts.map +1 -0
- package/dist/doctor/robots-params.js +97 -0
- package/dist/doctor/robots-params.js.map +1 -0
- package/dist/doctor/site.d.ts +42 -0
- package/dist/doctor/site.d.ts.map +1 -0
- package/dist/doctor/site.js +82 -0
- package/dist/doctor/site.js.map +1 -0
- package/dist/doctor.d.ts +21 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +94 -3
- package/dist/doctor.js.map +1 -1
- package/dist/exit-codes.d.ts +40 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +66 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/help-commands.d.ts +14 -0
- package/dist/help-commands.d.ts.map +1 -0
- package/dist/help-commands.js +264 -0
- package/dist/help-commands.js.map +1 -0
- package/dist/help.d.ts +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +67 -11
- package/dist/help.js.map +1 -1
- package/dist/io.d.ts +33 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +81 -0
- package/dist/io.js.map +1 -0
- package/dist/plan/command.d.ts +51 -0
- package/dist/plan/command.d.ts.map +1 -0
- package/dist/plan/command.js +182 -0
- package/dist/plan/command.js.map +1 -0
- package/dist/plan/document.d.ts +24 -0
- package/dist/plan/document.d.ts.map +1 -0
- package/dist/plan/document.js +208 -0
- package/dist/plan/document.js.map +1 -0
- package/dist/plan/markdown-dir.d.ts +64 -0
- package/dist/plan/markdown-dir.d.ts.map +1 -0
- package/dist/plan/markdown-dir.js +191 -0
- package/dist/plan/markdown-dir.js.map +1 -0
- package/dist/plan/output.d.ts +59 -0
- package/dist/plan/output.d.ts.map +1 -0
- package/dist/plan/output.js +102 -0
- package/dist/plan/output.js.map +1 -0
- package/dist/preview-comment.d.ts +20 -0
- package/dist/preview-comment.d.ts.map +1 -0
- package/dist/preview-comment.js +88 -0
- package/dist/preview-comment.js.map +1 -0
- package/dist/publish/about.d.ts +23 -0
- package/dist/publish/about.d.ts.map +1 -0
- package/dist/publish/about.js +66 -0
- package/dist/publish/about.js.map +1 -0
- package/dist/publish/command.d.ts +20 -0
- package/dist/publish/command.d.ts.map +1 -1
- package/dist/publish/command.js +97 -4
- package/dist/publish/command.js.map +1 -1
- package/dist/publish/context.d.ts +8 -0
- package/dist/publish/context.d.ts.map +1 -1
- package/dist/publish/context.js.map +1 -1
- package/dist/publish/docs-apply.d.ts.map +1 -1
- package/dist/publish/docs-apply.js +13 -1
- package/dist/publish/docs-apply.js.map +1 -1
- package/dist/publish/extras.d.ts +10 -0
- package/dist/publish/extras.d.ts.map +1 -1
- package/dist/publish/extras.js +54 -2
- package/dist/publish/extras.js.map +1 -1
- package/dist/publish/manifest.d.ts.map +1 -1
- package/dist/publish/manifest.js +27 -2
- package/dist/publish/manifest.js.map +1 -1
- package/dist/publish/preview.d.ts +56 -0
- package/dist/publish/preview.d.ts.map +1 -0
- package/dist/publish/preview.js +133 -0
- package/dist/publish/preview.js.map +1 -0
- package/dist/publish/redirects.d.ts +13 -0
- package/dist/publish/redirects.d.ts.map +1 -0
- package/dist/publish/redirects.js +154 -0
- package/dist/publish/redirects.js.map +1 -0
- package/dist/publish/scan.d.ts +2 -0
- package/dist/publish/scan.d.ts.map +1 -1
- package/dist/publish/scan.js +1 -0
- package/dist/publish/scan.js.map +1 -1
- package/dist/publish/studio-edits.d.ts +25 -0
- package/dist/publish/studio-edits.d.ts.map +1 -0
- package/dist/publish/studio-edits.js +53 -0
- package/dist/publish/studio-edits.js.map +1 -0
- package/dist/publish/types.d.ts +22 -1
- package/dist/publish/types.d.ts.map +1 -1
- package/dist/publish-command.d.ts +55 -0
- package/dist/publish-command.d.ts.map +1 -0
- package/dist/publish-command.js +197 -0
- package/dist/publish-command.js.map +1 -0
- package/dist/run.d.ts +3 -10
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +152 -120
- package/dist/run.js.map +1 -1
- package/dist/translations/target.d.ts.map +1 -1
- package/dist/translations/target.js +2 -2
- package/dist/translations/target.js.map +1 -1
- package/dist/validate.d.ts +39 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +166 -0
- package/dist/validate.js.map +1 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/dist/whoami.d.ts +41 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +161 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What `forumulate plan` and `apply` print (DX-D): the API's manifest answer
|
|
4
|
+
* (`ManifestResultV2`), as lines a person reads in a pull request's CI log.
|
|
5
|
+
*
|
|
6
|
+
* A plan lists only what would MOVE — `+` create, `~` update, `-` delete —
|
|
7
|
+
* with the fields each update touches; `unchanged` steps are counted, not
|
|
8
|
+
* listed (`--verbose` lists them), because a forty-page site re-planned after
|
|
9
|
+
* a one-word fix should print one line, not forty. Drift (a page edited
|
|
10
|
+
* outside the manifest) is an update like any other, and its `content` field
|
|
11
|
+
* says so in words.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.formatPlan = formatPlan;
|
|
15
|
+
exports.formatApply = formatApply;
|
|
16
|
+
const MARK = {
|
|
17
|
+
create: '+',
|
|
18
|
+
update: '~',
|
|
19
|
+
delete: '-',
|
|
20
|
+
unchanged: '=',
|
|
21
|
+
unsupported: '?',
|
|
22
|
+
};
|
|
23
|
+
/** A value short enough for one line of a log. */
|
|
24
|
+
function brief(v) {
|
|
25
|
+
const s = typeof v === 'string' ? v : JSON.stringify(v ?? null);
|
|
26
|
+
return s.length > 80 ? `${s.slice(0, 77)}...` : s;
|
|
27
|
+
}
|
|
28
|
+
function stepLine(s) {
|
|
29
|
+
const fields = Object.keys(s.diff ?? {});
|
|
30
|
+
return `${MARK[s.action]} ${s.action.padEnd(9)} ${s.unit.padEnd(12)} ${s.ref}${fields.length ? ` (${fields.join(', ')})` : ''}`;
|
|
31
|
+
}
|
|
32
|
+
function formatPlan(answer, opts) {
|
|
33
|
+
const out = [];
|
|
34
|
+
for (const s of answer.steps) {
|
|
35
|
+
if (s.action === 'unchanged' && !opts.verbose)
|
|
36
|
+
continue;
|
|
37
|
+
out.push(stepLine(s));
|
|
38
|
+
if (opts.diff)
|
|
39
|
+
for (const [k, d] of Object.entries(s.diff ?? {}))
|
|
40
|
+
out.push(` ${k}: ${brief(d.from)} -> ${brief(d.to)}`);
|
|
41
|
+
}
|
|
42
|
+
out.push(...manualLines(answer));
|
|
43
|
+
const extras = answer.extras ?? [];
|
|
44
|
+
if (extras.length) {
|
|
45
|
+
out.push(`${extras.length} thing(s) here are not in the document and are left alone${opts.verbose ? ':' : ' (--verbose lists them)'}`);
|
|
46
|
+
if (opts.verbose)
|
|
47
|
+
for (const e of extras)
|
|
48
|
+
out.push(` ${e.kind} ${e.space ? `${e.space}/` : ''}${e.key}`);
|
|
49
|
+
}
|
|
50
|
+
const count = (a) => answer.steps.filter((s) => s.action === a).length;
|
|
51
|
+
const moving = count('create') + count('update') + count('delete');
|
|
52
|
+
out.push(moving
|
|
53
|
+
? `Plan: ${count('create')} to create, ${count('update')} to update, ${count('delete')} to delete, ${count('unchanged')} unchanged.`
|
|
54
|
+
: `No changes. ${count('unchanged')} unchanged.`);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
function formatApply(answers, opts) {
|
|
58
|
+
const out = [];
|
|
59
|
+
// A step re-sent in a later batch answers `unchanged` there; its first,
|
|
60
|
+
// real outcome is the one to print.
|
|
61
|
+
const seen = new Map();
|
|
62
|
+
for (const a of answers)
|
|
63
|
+
for (const s of a.steps) {
|
|
64
|
+
const key = `${s.unit}\u0000${s.ref}`;
|
|
65
|
+
if (!seen.has(key) || s.status !== 'unchanged')
|
|
66
|
+
seen.set(key, s);
|
|
67
|
+
}
|
|
68
|
+
let applied = 0;
|
|
69
|
+
let failed = 0;
|
|
70
|
+
let mismatched = 0;
|
|
71
|
+
for (const s of seen.values()) {
|
|
72
|
+
if (s.status === 'unchanged' && !opts.verbose)
|
|
73
|
+
continue;
|
|
74
|
+
if (s.status === 'applied')
|
|
75
|
+
applied++;
|
|
76
|
+
if (s.status === 'failed')
|
|
77
|
+
failed++;
|
|
78
|
+
if (s.readBack === 'mismatch')
|
|
79
|
+
mismatched++;
|
|
80
|
+
const rb = s.readBack === 'mismatch' ? ' READ BACK DIFFERS' : s.readBack === 'ok' ? ' (read back ok)' : '';
|
|
81
|
+
out.push(`${(s.status ?? '').padEnd(9)} ${stepLine(s).slice(2)}${rb}${s.error ? ` ${s.error}` : ''}`);
|
|
82
|
+
for (const [field, value] of Object.entries(s.shownOnce ?? {}))
|
|
83
|
+
if (value)
|
|
84
|
+
out.push(` ${field} (shown once): ${value}`);
|
|
85
|
+
}
|
|
86
|
+
out.push(...manualLines(answers[answers.length - 1] ?? { dryRun: false, ok: true, steps: [] }));
|
|
87
|
+
out.push(`Applied ${applied}${failed ? `, ${failed} failed` : ''}${mismatched ? `, ${mismatched} did not read back as written` : ''}` +
|
|
88
|
+
(answers.length > 1 ? ` (${answers.length} requests).` : '.'));
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
function manualLines(answer) {
|
|
92
|
+
const manual = answer.manual ?? [];
|
|
93
|
+
if (!manual.length)
|
|
94
|
+
return [];
|
|
95
|
+
return [
|
|
96
|
+
'By hand (nothing we can call sets these):',
|
|
97
|
+
...manual.map((m) => m.kind === 'dns'
|
|
98
|
+
? ` DNS ${m.type} ${m.name} = ${m.value} (for ${m.for})`
|
|
99
|
+
: ` proxy ${m.host}${m.path} -> ${m.origin} (for ${m.for})`),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/plan/output.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA0CH,gCAsBC;AAED,kCA6BC;AAxED,MAAM,IAAI,GAA2C;IACnD,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,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AAE,CAAC;IACnC,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO;QACL,2CAA2C;QAC3C,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAClB,CAAC,CAAC,IAAI,KAAK,KAAK;YACd,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,GAAG,GAAG;YAC5D,CAAC,CAAC,aAAa,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,CAAC,GAAG,GAAG,CAClE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type PreviewResult } from './publish/preview';
|
|
2
|
+
type Fetch = typeof fetch;
|
|
3
|
+
/**
|
|
4
|
+
* `publish --preview <name> --comment` (FMU-F01): post the preview's link and
|
|
5
|
+
* diff on the pull request it was built for — and on the next push EDIT that
|
|
6
|
+
* comment rather than add another, found by the hidden
|
|
7
|
+
* `<!-- forumulate-preview:<name> -->` marker the API puts in it.
|
|
8
|
+
*
|
|
9
|
+
* Host-neutral: GitHub, Gitea/Forgejo (the same REST shape), GitLab and
|
|
10
|
+
* Bitbucket, each with the token its CI documents for writing comments
|
|
11
|
+
* (`GITHUB_TOKEN`, `GITEA_TOKEN`, `GITLAB_TOKEN`, `BITBUCKET_TOKEN`). Any other
|
|
12
|
+
* host: print the comment with `--json` (`previews[].comment`) and post it with
|
|
13
|
+
* that host's own tool — the recipes in docs/guides/docs-workflow.md do both.
|
|
14
|
+
*
|
|
15
|
+
* Answers the pull request's address, or null when there is nothing to
|
|
16
|
+
* comment on (not a PR build). Throws with a sentence when the host refuses.
|
|
17
|
+
*/
|
|
18
|
+
export declare function postPreviewComment(preview: PreviewResult, env: NodeJS.ProcessEnv, doFetch?: Fetch): Promise<string | null>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=preview-comment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-comment.d.ts","sourceRoot":"","sources":["../src/preview-comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEjE,KAAK,KAAK,GAAG,OAAO,KAAK,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,OAAO,GAAE,KAAa,GACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+DxB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postPreviewComment = postPreviewComment;
|
|
4
|
+
const preview_1 = require("./publish/preview");
|
|
5
|
+
/**
|
|
6
|
+
* `publish --preview <name> --comment` (FMU-F01): post the preview's link and
|
|
7
|
+
* diff on the pull request it was built for — and on the next push EDIT that
|
|
8
|
+
* comment rather than add another, found by the hidden
|
|
9
|
+
* `<!-- forumulate-preview:<name> -->` marker the API puts in it.
|
|
10
|
+
*
|
|
11
|
+
* Host-neutral: GitHub, Gitea/Forgejo (the same REST shape), GitLab and
|
|
12
|
+
* Bitbucket, each with the token its CI documents for writing comments
|
|
13
|
+
* (`GITHUB_TOKEN`, `GITEA_TOKEN`, `GITLAB_TOKEN`, `BITBUCKET_TOKEN`). Any other
|
|
14
|
+
* host: print the comment with `--json` (`previews[].comment`) and post it with
|
|
15
|
+
* that host's own tool — the recipes in docs/guides/docs-workflow.md do both.
|
|
16
|
+
*
|
|
17
|
+
* Answers the pull request's address, or null when there is nothing to
|
|
18
|
+
* comment on (not a PR build). Throws with a sentence when the host refuses.
|
|
19
|
+
*/
|
|
20
|
+
async function postPreviewComment(preview, env, doFetch = fetch) {
|
|
21
|
+
const src = (0, preview_1.ciSource)(env);
|
|
22
|
+
if (!src.provider || !src.repository || !src.number)
|
|
23
|
+
return null;
|
|
24
|
+
const marker = `<!-- forumulate-preview:${preview.name} -->`;
|
|
25
|
+
const body = preview.comment.includes(marker) ? preview.comment : `${marker}\n${preview.comment}`;
|
|
26
|
+
const call = async (url, init) => {
|
|
27
|
+
const res = await doFetch(url, init);
|
|
28
|
+
if (!res.ok)
|
|
29
|
+
throw new Error(`${src.provider} answered ${res.status} for ${init.method ?? 'GET'} ${url}`);
|
|
30
|
+
return res.status === 204 ? null : res.json();
|
|
31
|
+
};
|
|
32
|
+
switch (src.provider) {
|
|
33
|
+
case 'github':
|
|
34
|
+
case 'gitea': {
|
|
35
|
+
const token = env.GITEA_TOKEN || env.GITHUB_TOKEN || env.GH_TOKEN;
|
|
36
|
+
if (!token)
|
|
37
|
+
throw new Error('no GITHUB_TOKEN (or GITEA_TOKEN) to comment with');
|
|
38
|
+
const api = (env.GITHUB_API_URL || 'https://api.github.com').replace(/\/$/, '');
|
|
39
|
+
const headers = {
|
|
40
|
+
authorization: src.provider === 'gitea' ? `token ${token}` : `Bearer ${token}`,
|
|
41
|
+
accept: 'application/vnd.github+json',
|
|
42
|
+
'content-type': 'application/json',
|
|
43
|
+
'user-agent': 'forumulate-cli',
|
|
44
|
+
};
|
|
45
|
+
const base = `${api}/repos/${src.repository}/issues`;
|
|
46
|
+
const list = (await call(`${base}/${src.number}/comments?per_page=100`, { headers }));
|
|
47
|
+
const mine = list?.find((c) => c.body?.includes(marker));
|
|
48
|
+
if (mine)
|
|
49
|
+
await call(`${base}/comments/${mine.id}`, { method: 'PATCH', headers, body: JSON.stringify({ body }) });
|
|
50
|
+
else
|
|
51
|
+
await call(`${base}/${src.number}/comments`, { method: 'POST', headers, body: JSON.stringify({ body }) });
|
|
52
|
+
return src.url ?? `${src.repository}#${src.number}`;
|
|
53
|
+
}
|
|
54
|
+
case 'gitlab': {
|
|
55
|
+
const token = env.GITLAB_TOKEN;
|
|
56
|
+
if (!token)
|
|
57
|
+
throw new Error('no GITLAB_TOKEN to comment with (CI_JOB_TOKEN cannot write notes)');
|
|
58
|
+
const api = (env.CI_API_V4_URL || 'https://gitlab.com/api/v4').replace(/\/$/, '');
|
|
59
|
+
const headers = { 'private-token': token, 'content-type': 'application/json' };
|
|
60
|
+
const base = `${api}/projects/${encodeURIComponent(src.repository)}/merge_requests/${src.number}/notes`;
|
|
61
|
+
const list = (await call(`${base}?per_page=100`, { headers }));
|
|
62
|
+
const mine = list?.find((n) => n.body?.includes(marker));
|
|
63
|
+
if (mine)
|
|
64
|
+
await call(`${base}/${mine.id}`, { method: 'PUT', headers, body: JSON.stringify({ body }) });
|
|
65
|
+
else
|
|
66
|
+
await call(base, { method: 'POST', headers, body: JSON.stringify({ body }) });
|
|
67
|
+
return src.url ?? `${src.repository}!${src.number}`;
|
|
68
|
+
}
|
|
69
|
+
case 'bitbucket': {
|
|
70
|
+
const token = env.BITBUCKET_TOKEN;
|
|
71
|
+
if (!token)
|
|
72
|
+
throw new Error('no BITBUCKET_TOKEN (a repository access token) to comment with');
|
|
73
|
+
const headers = { authorization: `Bearer ${token}`, 'content-type': 'application/json' };
|
|
74
|
+
const base = `https://api.bitbucket.org/2.0/repositories/${src.repository}/pullrequests/${src.number}/comments`;
|
|
75
|
+
const list = (await call(`${base}?pagelen=100`, { headers }));
|
|
76
|
+
const mine = list?.values?.find((c) => c.content?.raw?.includes(marker));
|
|
77
|
+
const payload = JSON.stringify({ content: { raw: body } });
|
|
78
|
+
if (mine)
|
|
79
|
+
await call(`${base}/${mine.id}`, { method: 'PUT', headers, body: payload });
|
|
80
|
+
else
|
|
81
|
+
await call(base, { method: 'POST', headers, body: payload });
|
|
82
|
+
return src.url ?? `${src.repository}#${src.number}`;
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
throw new Error(`no built-in commenter for ${src.provider}; post previews[].comment from \`--json\` with your host's tool`);
|
|
86
|
+
}
|
|
87
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AAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACtD,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CACb,6BAA6B,GAAG,CAAC,QAAQ,iEAAiE,CAC3G,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SpaceCtx } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* `about:` in forumulate.yaml — an About page's parts, as content-as-code.
|
|
4
|
+
*
|
|
5
|
+
* spaces:
|
|
6
|
+
* - path: about
|
|
7
|
+
* space: about
|
|
8
|
+
* create: { type: ABOUT, name: About }
|
|
9
|
+
* about:
|
|
10
|
+
* mission: Make work lighter.
|
|
11
|
+
* values: [{ title: Ship small }, { title: Write it down }]
|
|
12
|
+
* team: { source: authors, keys: [ada, grace], founders: [ada] }
|
|
13
|
+
* company: { legalName: Acme Software GmbH, vatId: DE123456789 }
|
|
14
|
+
*
|
|
15
|
+
* or `about: about.yaml` (a file beside the manifest holding the same map).
|
|
16
|
+
* The folder's own Markdown is the story page, published like any page. Only
|
|
17
|
+
* the top-level keys that differ from what the space holds are sent, through
|
|
18
|
+
* `PUT …/about` (PATCH semantics), so a re-run that changes nothing writes
|
|
19
|
+
* nothing; `null` in the manifest clears a part. Every reference is checked by
|
|
20
|
+
* the API, and a 422 names the key.
|
|
21
|
+
*/
|
|
22
|
+
export declare function syncAbout(ctx: SpaceCtx, apply: boolean, manifestFile: string | null): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=about.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"about.d.ts","sourceRoot":"","sources":["../../src/publish/about.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncAbout = syncAbout;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const yaml_1 = require("yaml");
|
|
7
|
+
const compare_1 = require("./compare");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
/**
|
|
10
|
+
* `about:` in forumulate.yaml — an About page's parts, as content-as-code.
|
|
11
|
+
*
|
|
12
|
+
* spaces:
|
|
13
|
+
* - path: about
|
|
14
|
+
* space: about
|
|
15
|
+
* create: { type: ABOUT, name: About }
|
|
16
|
+
* about:
|
|
17
|
+
* mission: Make work lighter.
|
|
18
|
+
* values: [{ title: Ship small }, { title: Write it down }]
|
|
19
|
+
* team: { source: authors, keys: [ada, grace], founders: [ada] }
|
|
20
|
+
* company: { legalName: Acme Software GmbH, vatId: DE123456789 }
|
|
21
|
+
*
|
|
22
|
+
* or `about: about.yaml` (a file beside the manifest holding the same map).
|
|
23
|
+
* The folder's own Markdown is the story page, published like any page. Only
|
|
24
|
+
* the top-level keys that differ from what the space holds are sent, through
|
|
25
|
+
* `PUT …/about` (PATCH semantics), so a re-run that changes nothing writes
|
|
26
|
+
* nothing; `null` in the manifest clears a part. Every reference is checked by
|
|
27
|
+
* the API, and a 422 names the key.
|
|
28
|
+
*/
|
|
29
|
+
async function syncAbout(ctx, apply, manifestFile) {
|
|
30
|
+
const raw = ctx.spec.about;
|
|
31
|
+
if (raw === undefined || !ctx.only.part('about', ctx.spec))
|
|
32
|
+
return;
|
|
33
|
+
if (ctx.type !== 'ABOUT') {
|
|
34
|
+
ctx.errors.push(`about: belongs on an ABOUT space; ${ctx.spec.space} is ${ctx.type}`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let want;
|
|
38
|
+
if (typeof raw === 'string') {
|
|
39
|
+
const abs = (0, node_path_1.resolve)(manifestFile ? (0, node_path_1.dirname)(manifestFile) : ctx.root, raw);
|
|
40
|
+
const text = (0, node_fs_1.readFileSync)(abs, 'utf8');
|
|
41
|
+
const parsed = /\.json$/i.test(abs) ? JSON.parse(text) : (0, yaml_1.parse)(text);
|
|
42
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
43
|
+
ctx.errors.push(`about: ${raw} must hold a map of About parts`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
want = parsed;
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
want = raw;
|
|
50
|
+
if (!ctx.api.opts.authed) {
|
|
51
|
+
ctx.line({
|
|
52
|
+
verb: 'patch',
|
|
53
|
+
what: 'about',
|
|
54
|
+
detail: `${Object.keys(want).join(', ')} — cannot compare without a token`,
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const current = await ctx.api.get((0, context_1.spacePath)(ctx, '/about'));
|
|
59
|
+
const keys = (0, compare_1.differingKeys)(current, want);
|
|
60
|
+
if (!keys.length)
|
|
61
|
+
return;
|
|
62
|
+
ctx.line({ verb: 'patch', what: 'about', detail: keys.join(', ') });
|
|
63
|
+
if (apply)
|
|
64
|
+
await ctx.api.put((0, context_1.spacePath)(ctx, '/about'), Object.fromEntries(keys.map((k) => [k, want[k]])));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=about.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"about.js","sourceRoot":"","sources":["../../src/publish/about.ts"],"names":[],"mappings":";;AA0BA,8BAuCC;AAjED,qCAAuC;AACvC,yCAA6C;AAC7C,+BAA0C;AAC1C,uCAA0C;AAC1C,uCAAqD;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,SAAS,CAC7B,GAAa,EACb,KAAc,EACd,YAA2B;IA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C,IAAI,CAAC;YACP,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAmC;SAC3E,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAA0B,IAAA,mBAAS,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IACrF,MAAM,IAAI,GAAG,IAAA,uBAAa,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO;IACzB,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,IAAI,KAAK;QACP,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CACf,IAAA,mBAAS,EAAC,GAAG,EAAE,QAAQ,CAAC,EACxB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;AACN,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ApiClient } from './client';
|
|
2
2
|
import type { PlanLine } from './types';
|
|
3
|
+
import { type StudioConflict } from './studio-edits';
|
|
4
|
+
import { type PreviewResult } from './preview';
|
|
3
5
|
/**
|
|
4
6
|
* `forumulate publish <folder>` — a folder of Markdown, and optionally a
|
|
5
7
|
* manifest, made into a live presence; and the same command run again changes
|
|
@@ -41,6 +43,16 @@ export interface PublishOptions {
|
|
|
41
43
|
defaultSpace?: string;
|
|
42
44
|
/** Which command is speaking, for the words of the summary. */
|
|
43
45
|
command?: 'publish' | 'sync';
|
|
46
|
+
/** `--purge` (FMU-D04). Undefined: the server's background purge, unreported. */
|
|
47
|
+
purge?: 'page' | 'space' | 'none';
|
|
48
|
+
/**
|
|
49
|
+
* `--preview <name>` (FMU-F01): plan as a publish would, then send the pages
|
|
50
|
+
* to a preview of that name instead of publishing them. Implies a plan: no
|
|
51
|
+
* page, setting or theme is written.
|
|
52
|
+
*/
|
|
53
|
+
preview?: string;
|
|
54
|
+
/** `--preview-ttl <days>`: ask for a shorter-lived preview link. */
|
|
55
|
+
previewTtlDays?: number;
|
|
44
56
|
}
|
|
45
57
|
/** Everything a run decided, for a caller that keeps it (the git sync job stores it). */
|
|
46
58
|
export interface PublishReport {
|
|
@@ -57,6 +69,14 @@ export interface PublishReport {
|
|
|
57
69
|
writes: number;
|
|
58
70
|
/** Count per verb that changes something (`create`, `update`, …). */
|
|
59
71
|
counts: Record<string, number>;
|
|
72
|
+
/** Pieces that already matched the folder. */
|
|
73
|
+
unchanged: number;
|
|
74
|
+
/** Every purge the server reported for this run, per space (FMU-D04). */
|
|
75
|
+
purged: Record<string, unknown>[];
|
|
76
|
+
/** Pages the run refused to overwrite: edited in the studio since (FMU-D18). */
|
|
77
|
+
conflicts: StudioConflict[];
|
|
78
|
+
/** `--preview`: each space's preview link and summary (FMU-F01). */
|
|
79
|
+
previews: PreviewResult[];
|
|
60
80
|
}
|
|
61
81
|
export interface PublishDeps {
|
|
62
82
|
client: ApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/publish/command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/publish/command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAW1C,OAAO,KAAK,EAAsB,QAAQ,EAAa,M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qE;IACrE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAClC,gFAAgF;IAChF,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,oEAAoE;IACpE,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,sEAAsE;IACtE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CACrC;AAKD,wBAAsB,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAwMzF"}
|
package/dist/publish/command.js
CHANGED
|
@@ -9,10 +9,14 @@ const docs_plan_1 = require("./docs-plan");
|
|
|
9
9
|
const docs_apply_1 = require("./docs-apply");
|
|
10
10
|
const docs_reconcile_1 = require("./docs-reconcile");
|
|
11
11
|
const extras_1 = require("./extras");
|
|
12
|
+
const about_1 = require("./about");
|
|
12
13
|
const manifest_1 = require("./manifest");
|
|
13
14
|
const posts_1 = require("./posts");
|
|
14
15
|
const scan_1 = require("./scan");
|
|
15
16
|
const tags_1 = require("./tags");
|
|
17
|
+
const studio_edits_1 = require("./studio-edits");
|
|
18
|
+
const redirects_1 = require("./redirects");
|
|
19
|
+
const preview_1 = require("./preview");
|
|
16
20
|
const ACTION = ['create', 'update', 'meta', 'move', 'order', 'prune', 'patch'];
|
|
17
21
|
async function runPublish(opts, deps) {
|
|
18
22
|
const root = (0, node_path_1.resolve)(opts.folder);
|
|
@@ -40,6 +44,18 @@ async function runPublish(opts, deps) {
|
|
|
40
44
|
deps.err(`Which space${missing.path ? ` for ${missing.path}/` : ''}? Pass --space <id|slug> or put \`space:\` in the manifest.`);
|
|
41
45
|
return 1;
|
|
42
46
|
}
|
|
47
|
+
if (opts.preview !== undefined) {
|
|
48
|
+
if (!preview_1.PREVIEW_NAME.test(opts.preview)) {
|
|
49
|
+
deps.err('--preview takes a name: letters, digits, `.`, `_` and `-`, up to 64 (`pr-123`).');
|
|
50
|
+
return 2;
|
|
51
|
+
}
|
|
52
|
+
if (!deps.authed) {
|
|
53
|
+
deps.err('A preview needs a token: `forumulate login`, or FORUMULATE_TOKEN in CI.');
|
|
54
|
+
return 3;
|
|
55
|
+
}
|
|
56
|
+
// A preview publishes nothing: everything else in the run is a plan.
|
|
57
|
+
opts = { ...opts, dryRun: true };
|
|
58
|
+
}
|
|
43
59
|
if (!deps.authed && !opts.dryRun) {
|
|
44
60
|
deps.err('Publishing needs a token: `forumulate login`, or FORUMULATE_TOKEN in CI. `--dry-run` works without one against a public space.');
|
|
45
61
|
return 1;
|
|
@@ -47,6 +63,9 @@ async function runPublish(opts, deps) {
|
|
|
47
63
|
const only = new context_1.Selector(opts.only);
|
|
48
64
|
const lines = [];
|
|
49
65
|
const errors = [];
|
|
66
|
+
const purged = [];
|
|
67
|
+
const conflicts = [];
|
|
68
|
+
const previews = [];
|
|
50
69
|
const print = (space) => (l) => {
|
|
51
70
|
lines.push({ space, line: l });
|
|
52
71
|
if (opts.json || (l.verb === 'same' && !process.env.VERBOSE))
|
|
@@ -85,6 +104,9 @@ async function runPublish(opts, deps) {
|
|
|
85
104
|
only,
|
|
86
105
|
manifest,
|
|
87
106
|
errors,
|
|
107
|
+
purged,
|
|
108
|
+
conflicts,
|
|
109
|
+
previews,
|
|
88
110
|
line: sink(spec.space),
|
|
89
111
|
});
|
|
90
112
|
}
|
|
@@ -112,10 +134,28 @@ async function runPublish(opts, deps) {
|
|
|
112
134
|
}
|
|
113
135
|
const count = (v) => lines.filter((l) => l.line.verb === v).length;
|
|
114
136
|
const counts = Object.fromEntries(ACTION.map((v) => [v, count(v)]).filter(([, n]) => n));
|
|
115
|
-
|
|
137
|
+
const unchanged = count('same');
|
|
138
|
+
const result = {
|
|
139
|
+
dryRun: opts.dryRun,
|
|
140
|
+
lines,
|
|
141
|
+
errors,
|
|
142
|
+
unverified,
|
|
143
|
+
writes: writer.writes,
|
|
144
|
+
counts,
|
|
145
|
+
unchanged,
|
|
146
|
+
purged,
|
|
147
|
+
conflicts,
|
|
148
|
+
previews,
|
|
149
|
+
};
|
|
150
|
+
deps.report?.(result);
|
|
116
151
|
const sync = opts.command === 'sync';
|
|
117
|
-
|
|
118
|
-
|
|
152
|
+
// `--json` is printed by the caller once the run is recorded (it adds the
|
|
153
|
+
// run id and diffUrl); a caller with no `report` gets it here as before.
|
|
154
|
+
if (opts.json && !deps.report) {
|
|
155
|
+
deps.out(JSON.stringify(result, null, 2));
|
|
156
|
+
}
|
|
157
|
+
else if (opts.json) {
|
|
158
|
+
/* the caller prints the summary */
|
|
119
159
|
}
|
|
120
160
|
else {
|
|
121
161
|
deps.out('');
|
|
@@ -130,6 +170,15 @@ async function runPublish(opts, deps) {
|
|
|
130
170
|
deps.out(parts.length
|
|
131
171
|
? `Plan only — nothing was written${anon}. Run again with --apply to make these changes.`
|
|
132
172
|
: `Plan only${anon}.`);
|
|
173
|
+
else if (opts.preview !== undefined) {
|
|
174
|
+
deps.out('Preview only — nothing was published.');
|
|
175
|
+
for (const p of previews) {
|
|
176
|
+
const s = p.summary;
|
|
177
|
+
deps.out(`preview ${p.name} (${p.space}): ${s.added} added, ${s.changed} changed, ${s.removed} removed — expires ${p.expiresAt.slice(0, 10)}`);
|
|
178
|
+
if (p.urls[0])
|
|
179
|
+
deps.out(` ${p.urls[0]}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
133
182
|
else if (opts.dryRun)
|
|
134
183
|
deps.out(`--dry-run: nothing was written${anon}.`);
|
|
135
184
|
else if (!opts.verify)
|
|
@@ -143,7 +192,14 @@ async function runPublish(opts, deps) {
|
|
|
143
192
|
}
|
|
144
193
|
else
|
|
145
194
|
deps.out(`${writer.writes} write(s); read back from the API — everything matches.`);
|
|
195
|
+
for (const c of conflicts)
|
|
196
|
+
deps.err((0, studio_edits_1.conflictText)(c));
|
|
197
|
+
if (conflicts.length)
|
|
198
|
+
deps.err('Nothing in those spaces was written. Pull the studio change into the file, or re-run with --force to overwrite it.');
|
|
146
199
|
}
|
|
200
|
+
// 5 for a conflict, 1 for anything else that went wrong (FMU-D05).
|
|
201
|
+
if (conflicts.length)
|
|
202
|
+
return 5;
|
|
147
203
|
return errors.length || unverified.length ? 1 : 0;
|
|
148
204
|
}
|
|
149
205
|
async function runSpace(api, mode, spec, run) {
|
|
@@ -202,6 +258,8 @@ async function runSpace(api, mode, spec, run) {
|
|
|
202
258
|
line: run.line,
|
|
203
259
|
errors: run.errors,
|
|
204
260
|
slots,
|
|
261
|
+
purge: run.purge,
|
|
262
|
+
purged: run.purged,
|
|
205
263
|
};
|
|
206
264
|
if (mode !== 'verify') {
|
|
207
265
|
for (const s of scan.skipped)
|
|
@@ -219,6 +277,8 @@ async function runSpace(api, mode, spec, run) {
|
|
|
219
277
|
await (0, extras_1.syncSpace)(ctx, apply);
|
|
220
278
|
await (0, extras_1.syncTheme)(ctx, apply);
|
|
221
279
|
}
|
|
280
|
+
if (mode !== 'verify')
|
|
281
|
+
await (0, extras_1.warnMissingDescription)(ctx, isNew);
|
|
222
282
|
const existingAssets = isNew ? new Map() : await api.assets(org, live.id);
|
|
223
283
|
// A plan uploads nothing; it names what a real run would, once per content.
|
|
224
284
|
if (mode === 'plan') {
|
|
@@ -258,9 +318,31 @@ async function runSpace(api, mode, spec, run) {
|
|
|
258
318
|
return bodies.get(p.id) ?? null;
|
|
259
319
|
};
|
|
260
320
|
const plan = await (0, docs_plan_1.planDocs)(ctx, docsLive, bodyOf, openapiCollections, (0, docs_apply_1.knownUrls)(ctx, existingAssets));
|
|
321
|
+
// Studio edits since the last publish, before anything is written (FMU-D18).
|
|
322
|
+
if (api.opts.authed && !isNew && !run.force && mode !== 'verify') {
|
|
323
|
+
const found = await (0, studio_edits_1.studioConflicts)(ctx, plan, docsLive);
|
|
324
|
+
for (const c of found) {
|
|
325
|
+
run.line({ verb: 'conflict', what: `page ${c.slug}`, detail: `edited in studio by ${c.by} at ${c.at}` });
|
|
326
|
+
run.conflicts.push(c);
|
|
327
|
+
}
|
|
328
|
+
if (found.length && apply) {
|
|
329
|
+
run.errors.push(`${spec.space}: ${found.length} page(s) edited in the studio since the last publish — nothing written (--force overwrites)`);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
261
333
|
const metaOf = (id) => api.opts.authed ? api.pageMeta(org, live.id, id) : Promise.resolve(null);
|
|
262
334
|
const bulkOrder = { available: undefined };
|
|
263
|
-
if (!
|
|
335
|
+
if (run.preview !== undefined && mode === 'plan' && !isNew) {
|
|
336
|
+
// FMU-F01: the plan's pages go to a preview instead of the space.
|
|
337
|
+
const sent = await (0, preview_1.sendPreview)(ctx, plan, existingAssets, {
|
|
338
|
+
name: run.preview,
|
|
339
|
+
ttlDays: run.previewTtlDays,
|
|
340
|
+
source: (0, preview_1.ciSource)(process.env),
|
|
341
|
+
});
|
|
342
|
+
if (sent)
|
|
343
|
+
run.previews.push(sent);
|
|
344
|
+
}
|
|
345
|
+
else if (!apply) {
|
|
264
346
|
if (mode === 'plan' && api.opts.authed && !isNew)
|
|
265
347
|
await (0, docs_apply_1.dryRunImports)(ctx, plan);
|
|
266
348
|
await (0, docs_reconcile_1.reconcileDocs)(ctx, {
|
|
@@ -289,5 +371,16 @@ async function runSpace(api, mode, spec, run) {
|
|
|
289
371
|
}
|
|
290
372
|
if (!isNew)
|
|
291
373
|
await (0, extras_1.syncMonitors)(ctx, apply);
|
|
374
|
+
// `redirects:` in the manifest, merged into the space's table (FMU-F09).
|
|
375
|
+
if (!isNew && mode !== 'verify')
|
|
376
|
+
await (0, redirects_1.syncRedirects)(ctx, apply, run.manifest.file);
|
|
377
|
+
// An About page's parts, after its story page has been published.
|
|
378
|
+
if (!isNew)
|
|
379
|
+
await (0, about_1.syncAbout)(ctx, apply, run.manifest.file);
|
|
380
|
+
// `--purge space`: one purge of everything under the space, reported (FMU-D04).
|
|
381
|
+
if (apply && run.purge === 'space' && api.opts.authed) {
|
|
382
|
+
const answer = await api.post((0, context_1.spacePath)(ctx, '/cache/purge'));
|
|
383
|
+
run.purged.push(answer);
|
|
384
|
+
}
|
|
292
385
|
}
|
|
293
386
|
//# sourceMappingURL=command.js.map
|