@cloudhal/cli 0.9.0 → 0.10.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 +12 -0
- package/dist/assets/starters/blog/package.json +4 -4
- package/dist/assets/starters/blog/src/env.d.ts +2 -1
- package/dist/assets/studio/assets/{AccountPage-nAu_rO1o.js → AccountPage-KnRb0NdZ.js} +2 -2
- package/dist/assets/studio/assets/ActivityPage-97xHggMx.js +2 -0
- package/dist/assets/studio/assets/{AgentModes-_sBUnXcz.js → AgentModes-B0ndZk6-.js} +2 -2
- package/dist/assets/studio/assets/AgentsPage-CaSUxYA6.js +2 -0
- package/dist/assets/studio/assets/{AnalyticsPage-C-ex-HSB.js → AnalyticsPage-BDDle79P.js} +2 -2
- package/dist/assets/studio/assets/{ApprovalsPage-s6dwVD03.js → ApprovalsPage-fQ97gTra.js} +3 -3
- package/dist/assets/studio/assets/{ArticleEditorPage-T1evZ638.js → ArticleEditorPage-BTuLTrRz.js} +2 -2
- package/dist/assets/studio/assets/ArticlesPage-C2W82JpU.js +3 -0
- package/dist/assets/studio/assets/{AssetPage-5LwLx1gR.js → AssetPage-DSFmG_Q5.js} +2 -2
- package/dist/assets/studio/assets/{Audit-DQffLTzE.js → Audit-Cdm2BctF.js} +2 -2
- package/dist/assets/studio/assets/{AuditBadges-CY1uAjI6.js → AuditBadges-CHSvcm9k.js} +2 -2
- package/dist/assets/studio/assets/{AutomationsPage-BDlQj-9A.js → AutomationsPage-2s5bhqNl.js} +2 -2
- package/dist/assets/studio/assets/{BodyChanges-DIjm1bJU.js → BodyChanges-D_RmA99y.js} +2 -2
- package/dist/assets/studio/assets/{BodyEditor-DeqV1Lsh.js → BodyEditor-upQbsOnb.js} +3 -3
- package/dist/assets/studio/assets/BookOpen.es-RObyiWbm.js +2 -0
- package/dist/assets/studio/assets/{BuildPage-CQjvu0rJ.js → BuildPage-2G7MJdni.js} +2 -2
- package/dist/assets/studio/assets/CollectionSettingsPage-DWqVO7uC.js +3 -0
- package/dist/assets/studio/assets/{CollectionsPage-7s3YSr_B.js → CollectionsPage-VEyhuzvN.js} +2 -2
- package/dist/assets/studio/assets/{CommandMenu-N_Ip-LPa.js → CommandMenu-B8e_1Mqk.js} +2 -2
- package/dist/assets/studio/assets/{CommentThreadControls-CQyiHy0N.js → CommentThreadControls-B4KqsWwR.js} +2 -2
- package/dist/assets/studio/assets/{CommentThreadPage-DVSOcxOD.js → CommentThreadPage-Cqf0lMA5.js} +2 -2
- package/dist/assets/studio/assets/{CommenterPage-CPXdSFdV.js → CommenterPage-JE30gYuF.js} +2 -2
- package/dist/assets/studio/assets/{Comments-DJVsgCAa.js → Comments-Z1pe7Eje.js} +2 -2
- package/dist/assets/studio/assets/CommentsPage-Byp1E9GE.js +2 -0
- package/dist/assets/studio/assets/{ConfirmDialog-UY7UuQt8.js → ConfirmDialog-DQTBjdtz.js} +2 -2
- package/dist/assets/studio/assets/{Crumbs-DEIiY7p1.js → Crumbs-Cq31DDaP.js} +2 -2
- package/dist/assets/studio/assets/{DateTimeField-DyVXd_hG.js → DateTimeField-Q1t2hZH5.js} +2 -2
- package/dist/assets/studio/assets/{DeleteReferences-cijJ-S_1.js → DeleteReferences-BZ2-Q7z6.js} +2 -2
- package/dist/assets/studio/assets/{EditorPreview-C3-nmzAO.js → EditorPreview-B-rAr0p-.js} +2 -2
- package/dist/assets/studio/assets/{Elevation-DmmvKhh3.js → Elevation-29GlZjiJ.js} +2 -2
- package/dist/assets/studio/assets/{ElevationRequest-Cayyvqqw.js → ElevationRequest-xDKz9GBv.js} +2 -2
- package/dist/assets/studio/assets/EndedBadge-DtZBIxsu.js +2 -0
- package/dist/assets/studio/assets/{EntryFieldsCard-aHg_PtwX.js → EntryFieldsCard-CfVGl2oF.js} +2 -2
- package/dist/assets/studio/assets/{FieldsSection-Dapb2jAb.js → FieldsSection-Dk0IMgIZ.js} +2 -2
- package/dist/assets/studio/assets/{ForgotPasswordPage-jJLhjZX7.js → ForgotPasswordPage-Dg6lorsR.js} +2 -2
- package/dist/assets/studio/assets/{Gating-HCCmndPb.js → Gating-EbYJlaF7.js} +2 -2
- package/dist/assets/studio/assets/{GovernanceDialog-Cx3r0q-n.js → GovernanceDialog-DkjblwWT.js} +2 -2
- package/dist/assets/studio/assets/{InvitePage-BHGVYDQW.js → InvitePage-CBcoLQGE.js} +2 -2
- package/dist/assets/studio/assets/{ListFieldColumns-BW5Ycf3p.js → ListFieldColumns-Cg7t430N.js} +2 -2
- package/dist/assets/studio/assets/ListToolbar-Dl7JF_yL.js +2 -0
- package/dist/assets/studio/assets/{ListingSections-Cifcu5P5.js → ListingSections-DE8G9HwU.js} +2 -2
- package/dist/assets/studio/assets/{LoginPage-C3-Zu_Ta.js → LoginPage-BZ2zkZBy.js} +2 -2
- package/dist/assets/studio/assets/MediaPage-CibPwRXq.js +2 -0
- package/dist/assets/studio/assets/{MediaPicker-CHinIGGd.js → MediaPicker-xq3mDN8O.js} +2 -2
- package/dist/assets/studio/assets/{MediaUpload-FEtMnYgM.js → MediaUpload-DJp_mOuJ.js} +2 -2
- package/dist/assets/studio/assets/{MembersPage-DRQlIhLy.js → MembersPage-D2QqLRh4.js} +2 -2
- package/dist/assets/studio/assets/{Menus-DpTuIwZQ.js → Menus-v4k8Tqrz.js} +2 -2
- package/dist/assets/studio/assets/{NavigationPage-dmNWCcLa.js → NavigationPage-DUQGXS9h.js} +2 -2
- package/dist/assets/studio/assets/{NewSiteDialog-CXajABEy.js → NewSiteDialog-C486WUcS.js} +2 -2
- package/dist/assets/studio/assets/{NotificationItems-Bql2PkI9.js → NotificationItems-D3ujSgoI.js} +2 -2
- package/dist/assets/studio/assets/{OAuthConsentPage-B-DOabVo.js → OAuthConsentPage-DY6uMxQA.js} +2 -2
- package/dist/assets/studio/assets/{PageEditorPage-CtOD2ZcK.js → PageEditorPage-CTFpnMWJ.js} +2 -2
- package/dist/assets/studio/assets/{PagesPage-DptpPusO.js → PagesPage-Cp2zJvKd.js} +2 -2
- package/dist/assets/studio/assets/{PreviewPanel-DGRZbOUK.js → PreviewPanel-B0Zrx9cb.js} +2 -2
- package/dist/assets/studio/assets/{ProjectPage-B6bKsTrC.js → ProjectPage-D0vxqEn5.js} +2 -2
- package/dist/assets/studio/assets/Readers-lfVDLYVb.js +3 -0
- package/dist/assets/studio/assets/{RedirectDialog-Bi6gecDo.js → RedirectDialog-B3hR7k-E.js} +2 -2
- package/dist/assets/studio/assets/RedirectsPage-VuBze2PX.js +2 -0
- package/dist/assets/studio/assets/{RelativeTime-pU7izbH5.js → RelativeTime-BosTteS_.js} +2 -2
- package/dist/assets/studio/assets/{ReleaseApproval-BJE5qtlq.js → ReleaseApproval-4oFAS20M.js} +2 -2
- package/dist/assets/studio/assets/{ReleasePage-WSfD9gZ3.js → ReleasePage-y62qZka_.js} +2 -2
- package/dist/assets/studio/assets/{ReleaseParts-BtLl_1C4.js → ReleaseParts-D3Wde1-q.js} +2 -2
- package/dist/assets/studio/assets/{ResetPasswordPage-G4u5dPGv.js → ResetPasswordPage-B-n3laYY.js} +2 -2
- package/dist/assets/studio/assets/{RowMenu-BDHWbqzj.js → RowMenu-C_Fth9Tb.js} +2 -2
- package/dist/assets/studio/assets/{ScheduleCard-CU87XC4_.js → ScheduleCard-BtnPrYUf.js} +2 -2
- package/dist/assets/studio/assets/{ScheduleDialog-DZywcZBs.js → ScheduleDialog-DJWak8Wh.js} +2 -2
- package/dist/assets/studio/assets/ScheduleHistoryPage-8U2zrU-1.js +2 -0
- package/dist/assets/studio/assets/{ScheduleStatusBadge-BvBYX3z6.js → ScheduleStatusBadge-CPRnml63.js} +2 -2
- package/dist/assets/studio/assets/{Schedules-WQwT-Vor.js → Schedules-CA_-r-KT.js} +2 -2
- package/dist/assets/studio/assets/SchedulesPage-Bnep_bBB.js +2 -0
- package/dist/assets/studio/assets/{Seo-BFG0drND.js → Seo-CUN9ExWK.js} +2 -2
- package/dist/assets/studio/assets/{SeoPreview-BUgjhYVU.js → SeoPreview-BGYVNywR.js} +2 -2
- package/dist/assets/studio/assets/{Settings-b3xnPmhf.js → Settings-CK5oaZyf.js} +2 -2
- package/dist/assets/studio/assets/{SiteOverviewPage-Ca_9NhG1.js → SiteOverviewPage-DMYnsrCp.js} +2 -2
- package/dist/assets/studio/assets/{SiteSettingsPage-Ci9KyZ3V.js → SiteSettingsPage-C1yPr0YD.js} +2 -2
- package/dist/assets/studio/assets/{SitesPage-DqXhJDMt.js → SitesPage-BDnqFs_w.js} +3 -3
- package/dist/assets/studio/assets/{SkillsPage-IgK0RwyD.js → SkillsPage-DsgOPOHD.js} +3 -3
- package/dist/assets/studio/assets/SnapshotsPage-juzxuJIY.js +2 -0
- package/dist/assets/studio/assets/{StatTile-IFSjHMic.js → StatTile-CdA1sdEg.js} +2 -2
- package/dist/assets/studio/assets/{StatusActions-B1rqPKp6.js → StatusActions-D-UibiFD.js} +3 -3
- package/dist/assets/studio/assets/{TableSkeleton-DqggMdG0.js → TableSkeleton-CuNEabtp.js} +2 -2
- package/dist/assets/studio/assets/{TagsMigration-D6F-LQG_.js → TagsMigration-CY_RNwEY.js} +2 -2
- package/dist/assets/studio/assets/{TaxonomyPage-dXgi9R5w.js → TaxonomyPage-Bnd_ZR0b.js} +2 -2
- package/dist/assets/studio/assets/{TaxonomySettingsDialog-HND1ryKG.js → TaxonomySettingsDialog-BDbLpc0k.js} +2 -2
- package/dist/assets/studio/assets/{TermEditorPage-DXL3ULWI.js → TermEditorPage-C71fUt6l.js} +2 -2
- package/dist/assets/studio/assets/{TermPickers-C8Bo9FgX.js → TermPickers-LA43obMi.js} +2 -2
- package/dist/assets/studio/assets/{TranslationList-BhzYkuAS.js → TranslationList-dYkcEWXh.js} +2 -2
- package/dist/assets/studio/assets/{TranslationsPage-6f2UMDgu.js → TranslationsPage-DMiG7Px3.js} +2 -2
- package/dist/assets/studio/assets/{UsedByCard-0ZXWZYKn.js → UsedByCard-Ci5WhXZr.js} +2 -2
- package/dist/assets/studio/assets/{UsedByList-CqGtfhzh.js → UsedByList-DTTSbfiJ.js} +2 -2
- package/dist/assets/studio/assets/{charts-Bp8JMtwp.js → charts-CyD9XIr2.js} +2 -2
- package/dist/assets/studio/assets/{collapsible-l8g94on4w7qfosmn-D4VL6lMu.js → collapsible-l8g94on4w7qfosmn-DXZ5cSxa.js} +2 -2
- package/dist/assets/studio/assets/collection-icons-DDkx4yxb.js +2 -0
- package/dist/assets/studio/assets/{combobox-hdxtsm2gqcxxgfju-BJ6B99nZ.js → combobox-hdxtsm2gqcxxgfju-BL58YHDj.js} +2 -2
- package/dist/assets/studio/assets/{deleteLabels-CXdCOUFd.js → deleteLabels-C6_mnHMW.js} +2 -2
- package/dist/assets/studio/assets/{editor-BJhMMfuG.js → editor-D-UcfC7J.js} +2 -2
- package/dist/assets/studio/assets/index-B9v-eWBt.js +3 -0
- package/dist/assets/studio/assets/index-D0ZLq-an.css +2 -0
- package/dist/assets/studio/assets/{layer-dialog-j5ywmzs46ccg6oqy-C7BM4aKu.js → layer-dialog-j5ywmzs46ccg6oqy-DdH4sADt.js} +2 -2
- package/dist/assets/studio/assets/{tag-input-ohfybx5dbxy3houy-CsTz-ays.js → tag-input-ohfybx5dbxy3houy-BME_pSFN.js} +2 -2
- package/dist/assets/studio/assets/useCollectionView-YtozZNNc.js +3 -0
- package/dist/assets/studio/index.html +3 -2
- package/dist/src/cli/commands-remote.d.ts +8 -1
- package/dist/src/cli/commands-remote.js +36 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/help.js +10 -1
- package/dist/src/cli.d.ts +9 -0
- package/dist/src/cli.js +3 -0
- package/dist/src/commands/deploy/finish.d.ts +32 -0
- package/dist/src/commands/deploy/finish.js +119 -0
- package/dist/src/commands/deploy/options.d.ts +4 -1
- package/dist/src/commands/deploy/options.js +4 -1
- package/dist/src/commands/deploy/prepare.d.ts +333 -6
- package/dist/src/commands/deploy/prepare.js +32 -26
- package/dist/src/commands/deploy/release/checks.d.ts +10 -0
- package/dist/src/commands/deploy/release/checks.js +93 -0
- package/dist/src/commands/deploy/release/configs.d.ts +37 -0
- package/dist/src/commands/deploy/release/configs.js +106 -0
- package/dist/src/commands/deploy/release/errors.d.ts +33 -0
- package/dist/src/commands/deploy/release/errors.js +44 -0
- package/dist/src/commands/deploy/release/extract.d.ts +19 -0
- package/dist/src/commands/deploy/release/extract.js +95 -0
- package/dist/src/commands/deploy/release/fetch-release.d.ts +27 -0
- package/dist/src/commands/deploy/release/fetch-release.js +179 -0
- package/dist/src/commands/deploy/release/index.d.ts +10 -0
- package/dist/src/commands/deploy/release/index.js +289 -0
- package/dist/src/commands/deploy/release/options.d.ts +37 -0
- package/dist/src/commands/deploy/release/options.js +39 -0
- package/dist/src/commands/deploy/release/theme-check.d.ts +23 -0
- package/dist/src/commands/deploy/release/theme-check.js +181 -0
- package/dist/src/commands/deploy/release/trust.d.ts +25 -0
- package/dist/src/commands/deploy/release/trust.js +195 -0
- package/dist/src/commands/deploy/schedules-guard.d.ts +6 -1
- package/dist/src/commands/deploy/schedules-guard.js +8 -3
- package/dist/src/commands/deploy/ship.d.ts +6 -1
- package/dist/src/commands/deploy/ship.js +6 -2
- package/dist/src/commands/deploy.d.ts +4 -0
- package/dist/src/commands/deploy.js +24 -68
- package/dist/src/commands/fields.js +1 -1
- package/dist/src/commands/import-apply.js +5 -1
- package/dist/src/commands/import-revert.js +7 -1
- package/dist/src/commands/import.js +14 -2
- package/dist/src/commands/sync.js +2 -0
- package/dist/src/config-build-keys.d.ts +54 -0
- package/dist/src/config-build-keys.js +131 -0
- package/dist/src/config.d.ts +2 -0
- package/dist/src/config.js +1 -1
- package/dist/src/render-chrome.d.ts +12 -2
- package/dist/src/render-chrome.js +130 -68
- package/package.json +13 -12
- package/dist/assets/studio/assets/ActivityPage-WMRfMUvK.js +0 -2
- package/dist/assets/studio/assets/AgentsPage-DLLmx-so.js +0 -2
- package/dist/assets/studio/assets/ArticlesPage-DMpZFnlE.js +0 -3
- package/dist/assets/studio/assets/CollectionSettingsPage-DWscLife.js +0 -3
- package/dist/assets/studio/assets/CommentsPage-Cf_CseQi.js +0 -2
- package/dist/assets/studio/assets/EndedBadge-SSv5wA-H.js +0 -2
- package/dist/assets/studio/assets/ListToolbar-AiTPzw9z.js +0 -2
- package/dist/assets/studio/assets/MediaPage-By0qbkgh.js +0 -2
- package/dist/assets/studio/assets/Readers-Bvy9rxlu.js +0 -3
- package/dist/assets/studio/assets/RedirectsPage-XukadT0D.js +0 -2
- package/dist/assets/studio/assets/ScheduleHistoryPage-BA8TT-E9.js +0 -2
- package/dist/assets/studio/assets/SchedulesPage-B-H3TV5a.js +0 -2
- package/dist/assets/studio/assets/SnapshotsPage-8W2qFiqI.js +0 -2
- package/dist/assets/studio/assets/collection-icons-KuQZKlox.js +0 -2
- package/dist/assets/studio/assets/index-IQPO-IzP.css +0 -2
- package/dist/assets/studio/assets/index-jx_2-Qkj.js +0 -3
- package/dist/assets/studio/assets/useCollectionView-DIAOpQTO.js +0 -3
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed key list and yank list for `cloudhal deploy --release` (RFC-0046 §9, §11b).
|
|
3
|
+
*
|
|
4
|
+
* - Online: both lists (each with its `.sig`) from cloudhal.dev on every run. There is no fallback
|
|
5
|
+
* to a release asset or a cached copy: a copy can be older than a revocation.
|
|
6
|
+
* - `--from <dir>`: both lists from that directory, under the same rules.
|
|
7
|
+
* - `keys.json` must verify with the root this CLI pins and be unexpired; `yanked.json` with the
|
|
8
|
+
* yank key it lists, unexpired. Both are checked against the CLI's `YankMemory` (a replayed
|
|
9
|
+
* older key list, a revoked or replaced yank key, a lower serial, a dropped entry), and the new
|
|
10
|
+
* memory is stored only after both pass.
|
|
11
|
+
* - Before the owner's root ceremony no root is pinned, so nothing can be checked: refused.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
15
|
+
import os from "node:os";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import {
|
|
18
|
+
KEYS_FILE,
|
|
19
|
+
PINNED_ROOTS,
|
|
20
|
+
|
|
21
|
+
rememberYanks,
|
|
22
|
+
TRUST_BASE_URL,
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
verifyKeys,
|
|
26
|
+
verifyYanked,
|
|
27
|
+
YANKED_FILE,
|
|
28
|
+
|
|
29
|
+
} from "@cloudhal/release-verify";
|
|
30
|
+
import { refuseDeploy } from "./errors.js";
|
|
31
|
+
|
|
32
|
+
/** Where the CLI keeps its `YankMemory`: one per user, shared by every project. */
|
|
33
|
+
export const defaultTrustStateFile = () =>
|
|
34
|
+
path.join(os.homedir(), ".cloudhal", "release-trust.json");
|
|
35
|
+
|
|
36
|
+
const MAX_LIST_BYTES = 256 * 1024;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const CEREMONY =
|
|
55
|
+
"no root key is pinned in this CLI yet: the owner's root ceremony (docs/security/release-signing-keys.md › First-time setup) has not happened, so the signed key and yank lists cannot be checked and revocations would go unseen";
|
|
56
|
+
|
|
57
|
+
async function readList(input , name ) {
|
|
58
|
+
if (input.from !== undefined) {
|
|
59
|
+
const file = path.join(input.from, name);
|
|
60
|
+
if (!existsSync(file))
|
|
61
|
+
return refuseDeploy(
|
|
62
|
+
"trust-unavailable",
|
|
63
|
+
`--from ${input.from} has no ${name}: an offline install needs keys.json and yanked.json, each with its .sig, next to the release assets`,
|
|
64
|
+
);
|
|
65
|
+
const bytes = new Uint8Array(await readFile(file));
|
|
66
|
+
if (bytes.length > MAX_LIST_BYTES)
|
|
67
|
+
return refuseDeploy("trust-unavailable", `${file} is above ${MAX_LIST_BYTES} bytes`);
|
|
68
|
+
return bytes;
|
|
69
|
+
}
|
|
70
|
+
const url = TRUST_BASE_URL + name;
|
|
71
|
+
let res ;
|
|
72
|
+
try {
|
|
73
|
+
res = await (input.fetch ?? fetch)(url);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
return refuseDeploy(
|
|
76
|
+
"trust-unavailable",
|
|
77
|
+
`could not fetch ${url} (${(e ).message}); --release never falls back to an older copy`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (res.status !== 200)
|
|
81
|
+
return refuseDeploy(
|
|
82
|
+
"trust-unavailable",
|
|
83
|
+
`${url} answered ${res.status}; --release never falls back to an older copy`,
|
|
84
|
+
);
|
|
85
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
86
|
+
if (bytes.length > MAX_LIST_BYTES)
|
|
87
|
+
return refuseDeploy("trust-unavailable", `${url} is above ${MAX_LIST_BYTES} bytes`);
|
|
88
|
+
return bytes;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function readMemory(file ) {
|
|
92
|
+
if (!existsSync(file)) return undefined;
|
|
93
|
+
try {
|
|
94
|
+
const m = JSON.parse(await readFile(file, "utf8")) ;
|
|
95
|
+
const y = m.yankMemory;
|
|
96
|
+
if (
|
|
97
|
+
!y ||
|
|
98
|
+
typeof y.keyId !== "string" ||
|
|
99
|
+
typeof y.serial !== "number" ||
|
|
100
|
+
typeof y.keysIssuedAt !== "string" ||
|
|
101
|
+
!Array.isArray(y.versions) ||
|
|
102
|
+
!Array.isArray(y.revokedKeys) ||
|
|
103
|
+
!Array.isArray(y.retiredYankKeys)
|
|
104
|
+
)
|
|
105
|
+
throw new Error("not a yank memory");
|
|
106
|
+
return y;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
// A damaged memory is never silently dropped: that would undo what it protects.
|
|
109
|
+
return refuseDeploy(
|
|
110
|
+
"trust-unavailable",
|
|
111
|
+
`${file} cannot be read (${(e ).message}); move it aside only if you know why it changed`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const union = (a , b ) => [...new Set([...a, ...b])].sort();
|
|
117
|
+
const later = (a , b ) => (Date.parse(a) >= Date.parse(b) ? a : b);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Two memories combined so neither loses what it saw: for the same yank key the higher serial,
|
|
121
|
+
* the newer key list and the union of every entry; across a rotation the memory of the newer key
|
|
122
|
+
* list, still carrying every retired yank key of both.
|
|
123
|
+
*/
|
|
124
|
+
export function mergeMemory(disk , next ) {
|
|
125
|
+
if (!disk) return next;
|
|
126
|
+
const retiredYankKeys = union(disk.retiredYankKeys, next.retiredYankKeys);
|
|
127
|
+
if (disk.keyId !== next.keyId) {
|
|
128
|
+
const newer = Date.parse(disk.keysIssuedAt) > Date.parse(next.keysIssuedAt) ? disk : next;
|
|
129
|
+
return { ...newer, retiredYankKeys: retiredYankKeys.filter((k) => k !== newer.keyId) };
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
keyId: next.keyId,
|
|
133
|
+
serial: Math.max(disk.serial, next.serial),
|
|
134
|
+
versions: union(disk.versions, next.versions),
|
|
135
|
+
revokedKeys: union(disk.revokedKeys, next.revokedKeys),
|
|
136
|
+
keysIssuedAt: later(disk.keysIssuedAt, next.keysIssuedAt),
|
|
137
|
+
retiredYankKeys,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Stores `memory`, merged with whatever another run stored meanwhile (re-read just before). */
|
|
142
|
+
async function writeMemory(file , memory ) {
|
|
143
|
+
try {
|
|
144
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
145
|
+
const merged = mergeMemory(await readMemory(file), memory);
|
|
146
|
+
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
147
|
+
await writeFile(tmp, `${JSON.stringify({ yankMemory: merged }, null, 2)}\n`, { mode: 0o600 });
|
|
148
|
+
await rename(tmp, file);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
if ((e ).code === "trust-unavailable") throw e;
|
|
151
|
+
refuseDeploy(
|
|
152
|
+
"trust-state",
|
|
153
|
+
`the lists verified, but the yank memory could not be saved to ${file} (${(e ).message}); nothing was deployed`,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Both lists, verified and checked against the memory, which is then updated (see the file comment). */
|
|
159
|
+
export async function loadTrust(input ) {
|
|
160
|
+
const roots = input.roots ?? PINNED_ROOTS;
|
|
161
|
+
if (Object.keys(roots).length === 0) refuseDeploy("trust-unavailable", CEREMONY);
|
|
162
|
+
const stateFile = input.stateFile ?? defaultTrustStateFile();
|
|
163
|
+
const memory = await readMemory(stateFile);
|
|
164
|
+
const now = input.now ?? new Date();
|
|
165
|
+
const [keysDoc, keysSig, yankDoc, yankSig] = await Promise.all(
|
|
166
|
+
[KEYS_FILE, `${KEYS_FILE}.sig`, YANKED_FILE, `${YANKED_FILE}.sig`].map((n) =>
|
|
167
|
+
readList(input, n),
|
|
168
|
+
),
|
|
169
|
+
);
|
|
170
|
+
try {
|
|
171
|
+
const keys = await verifyKeys({
|
|
172
|
+
document: keysDoc ,
|
|
173
|
+
signature: keysSig ,
|
|
174
|
+
roots,
|
|
175
|
+
now,
|
|
176
|
+
...(memory ? { memory } : {}),
|
|
177
|
+
});
|
|
178
|
+
const yanked = await verifyYanked({
|
|
179
|
+
document: yankDoc ,
|
|
180
|
+
signature: yankSig ,
|
|
181
|
+
keys,
|
|
182
|
+
now,
|
|
183
|
+
...(memory ? { memory } : {}),
|
|
184
|
+
});
|
|
185
|
+
await writeMemory(stateFile, rememberYanks(yanked, keys, memory));
|
|
186
|
+
return { keys, yanked };
|
|
187
|
+
} catch (e) {
|
|
188
|
+
const code = (e ).code;
|
|
189
|
+
if (!code || code === "trust-state") throw e;
|
|
190
|
+
return refuseDeploy(
|
|
191
|
+
"trust-unavailable",
|
|
192
|
+
`the signed key and yank lists do not verify (${code}: ${(e ).message}); there is no override`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -21,4 +21,9 @@ export interface SchedulesStatus {
|
|
|
21
21
|
* would release held nodes) and older site Workers ignore gates. A deployment that answers no
|
|
22
22
|
* schedules status predates schedules and has nothing to protect.
|
|
23
23
|
*/
|
|
24
|
-
export declare function downgradeGuard(options: DeployOptions,
|
|
24
|
+
export declare function downgradeGuard(options: DeployOptions, target: {
|
|
25
|
+
readonly adminUrl: string;
|
|
26
|
+
readonly token: string;
|
|
27
|
+
/** The schedules level of the code deployed (`deploy --release`: the manifest's). */
|
|
28
|
+
readonly localLevel?: number;
|
|
29
|
+
}, log: (line: string) => void): Promise<void>;
|
|
@@ -53,10 +53,15 @@ export async function projectSchedulesLevel(projectDir )
|
|
|
53
53
|
*/
|
|
54
54
|
export async function downgradeGuard(
|
|
55
55
|
options ,
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
target
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
,
|
|
58
62
|
log ,
|
|
59
63
|
) {
|
|
64
|
+
const { adminUrl, token } = target;
|
|
60
65
|
let status ;
|
|
61
66
|
try {
|
|
62
67
|
const res = await (options.fetch ?? fetch)(new URL("/api/admin/schedules/status", adminUrl), {
|
|
@@ -77,7 +82,7 @@ export async function downgradeGuard(
|
|
|
77
82
|
return;
|
|
78
83
|
}
|
|
79
84
|
const remote = status.engine?.schedulesLevel ?? 0;
|
|
80
|
-
const local = await projectSchedulesLevel(options.projectDir);
|
|
85
|
+
const local = target.localLevel ?? (await projectSchedulesLevel(options.projectDir));
|
|
81
86
|
if (remote <= local) return;
|
|
82
87
|
const open = (status.sites ?? []).reduce((n, s) => n + (s.openReleases?.length ?? 0), 0);
|
|
83
88
|
const gated = (status.sites ?? []).reduce((n, s) => n + (s.gatedNodes ?? 0), 0);
|
|
@@ -2,7 +2,7 @@ import type { prepareAdminWorker } from "../../cloudflare/admin.js";
|
|
|
2
2
|
import type { AnalyticsDeployment, CommentsDeployment, SchedulerTicker } from "../../cloudflare/config.js";
|
|
3
3
|
import type { DeployContext } from "./context.js";
|
|
4
4
|
import type { DeploySecrets } from "./state.js";
|
|
5
|
-
type PreparedAdmin = Awaited<ReturnType<typeof prepareAdminWorker
|
|
5
|
+
type PreparedAdmin = Pick<Awaited<ReturnType<typeof prepareAdminWorker>>, "dir" | "configPath">;
|
|
6
6
|
/**
|
|
7
7
|
* `wrangler deploy` for the site Worker, then the admin Worker. When Cloudflare refuses the cron
|
|
8
8
|
* trigger (RFC-0008 §8.3: Workers Free allows 5 per account), the same Worker goes without it and
|
|
@@ -15,6 +15,11 @@ export declare function shipWorkers(ctx: DeployContext, input: {
|
|
|
15
15
|
admin: PreparedAdmin;
|
|
16
16
|
prepareAdmin: (ticker: SchedulerTicker) => Promise<PreparedAdmin>;
|
|
17
17
|
scheduler: SchedulerTicker;
|
|
18
|
+
/** `deploy --release`: the site Worker's own config (default: the project's, as built). */
|
|
19
|
+
site?: {
|
|
20
|
+
readonly dir: string;
|
|
21
|
+
readonly configPath: string;
|
|
22
|
+
};
|
|
18
23
|
}): Promise<{
|
|
19
24
|
siteUrl: string | undefined;
|
|
20
25
|
adminUrl: string | undefined;
|
|
@@ -18,7 +18,7 @@ import { purgeSite, waitForHealth, whileTokenPropagates } from "./resources.js";
|
|
|
18
18
|
import { CRON_REFUSED_MESSAGE } from "./schedules-guard.js";
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* `wrangler deploy` for the site Worker, then the admin Worker. When Cloudflare refuses the cron
|
|
@@ -34,6 +34,8 @@ export async function shipWorkers(
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
|
|
38
|
+
|
|
37
39
|
,
|
|
38
40
|
)
|
|
39
41
|
|
|
@@ -59,7 +61,9 @@ export async function shipWorkers(
|
|
|
59
61
|
const siteArgs = await secretsArgs(siteSecretsFile, input.siteSecrets);
|
|
60
62
|
const adminSecrets = await secretsArgs(adminSecretsFile, input.adminSecrets);
|
|
61
63
|
log(`deploying ${names.site}`);
|
|
62
|
-
siteDeploy =
|
|
64
|
+
siteDeploy = input.site
|
|
65
|
+
? await must(run, ["deploy", "-c", input.site.configPath, ...siteArgs], input.site.dir)
|
|
66
|
+
: await must(run, ["deploy", ...siteArgs], options.projectDir);
|
|
63
67
|
log(`deploying ${names.admin}`);
|
|
64
68
|
const adminArgs = ["deploy", "-c", admin.configPath, ...adminSecrets];
|
|
65
69
|
adminDeploy = await run(adminArgs, { cwd: admin.dir });
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
* `wrangler.jsonc`, the starter seeded when the checkout has none, secrets kept on the Workers
|
|
44
44
|
* and no setup link printed (`deploy/workers-builds.ts`, docs/guides/deploy-button.md).
|
|
45
45
|
*
|
|
46
|
+
* 14. `--release` (RFC-0046 §11b, `deploy/release/`): instead of building, installs the signed
|
|
47
|
+
* release of this CLI's version: the signed key and yank lists, the theme and config checks,
|
|
48
|
+
* the verified bundle and its attestation, then the same provisioning, secrets, guard and push.
|
|
49
|
+
*
|
|
46
50
|
* `--dry-run` runs everything up to wrangler's own `--dry-run` (bundles, configs) and skips
|
|
47
51
|
* provisioning, deployment and push — no Cloudflare account needed.
|
|
48
52
|
*/
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
* `wrangler.jsonc`, the starter seeded when the checkout has none, secrets kept on the Workers
|
|
44
44
|
* and no setup link printed (`deploy/workers-builds.ts`, docs/guides/deploy-button.md).
|
|
45
45
|
*
|
|
46
|
+
* 14. `--release` (RFC-0046 §11b, `deploy/release/`): instead of building, installs the signed
|
|
47
|
+
* release of this CLI's version: the signed key and yank lists, the theme and config checks,
|
|
48
|
+
* the verified bundle and its attestation, then the same provisioning, secrets, guard and push.
|
|
49
|
+
*
|
|
46
50
|
* `--dry-run` runs everything up to wrangler's own `--dry-run` (bundles, configs) and skips
|
|
47
51
|
* provisioning, deployment and push — no Cloudflare account needed.
|
|
48
52
|
*/
|
|
@@ -53,6 +57,7 @@ import { prepareAdminWorker } from "../cloudflare/admin.js";
|
|
|
53
57
|
import { must } from "../cloudflare/wrangler.js";
|
|
54
58
|
import { readProjectConfig } from "../config.js";
|
|
55
59
|
import { deployAttached } from "./deploy/attach.js";
|
|
60
|
+
import { deploySecrets, finishDeploy } from "./deploy/finish.js";
|
|
56
61
|
|
|
57
62
|
import {
|
|
58
63
|
analyticsAndComments,
|
|
@@ -63,12 +68,11 @@ import {
|
|
|
63
68
|
provision,
|
|
64
69
|
studioDirFor,
|
|
65
70
|
} from "./deploy/prepare.js";
|
|
71
|
+
import { deployRelease } from "./deploy/release/index.js";
|
|
66
72
|
import { downgradeGuard } from "./deploy/schedules-guard.js";
|
|
67
73
|
import { attachedWorkers } from "./deploy/served-sites.js";
|
|
68
74
|
import { commentsResult } from "./deploy/settings.js";
|
|
69
|
-
import {
|
|
70
|
-
import { loadOrCreateSecrets, SITE_SECRET_KEYS, writeDeployState } from "./deploy/state.js";
|
|
71
|
-
import { buildsSecrets, setupInstructions } from "./deploy/workers-builds.js";
|
|
75
|
+
import { shipWorkers } from "./deploy/ship.js";
|
|
72
76
|
import { resolveSkillsDir } from "./mcp.js";
|
|
73
77
|
|
|
74
78
|
|
|
@@ -94,21 +98,14 @@ export {
|
|
|
94
98
|
SECRET_KEYS,
|
|
95
99
|
} from "./deploy/state.js";
|
|
96
100
|
|
|
97
|
-
/** What this deploy sets on each Worker, and the values it knows (all of them, outside Workers Builds). */
|
|
98
|
-
async function deploySecrets(ctx ) {
|
|
99
|
-
if (ctx.workersBuilds && !ctx.options.dryRun)
|
|
100
|
-
return buildsSecrets(ctx.run, { cwd: ctx.options.projectDir, dir: ctx.dir, names: ctx.names });
|
|
101
|
-
const all = await loadOrCreateSecrets(ctx.dir);
|
|
102
|
-
const site = Object.fromEntries(SITE_SECRET_KEYS.map((k) => [k, all[k]]));
|
|
103
|
-
return { site, admin: all, known: all };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
101
|
export async function deploy(options ) {
|
|
107
102
|
checkOptions(options);
|
|
103
|
+
// RFC-0046 §11b: the signed release of this CLI's version instead of a build.
|
|
104
|
+
if (options.release) return deployRelease(options);
|
|
108
105
|
// RFC-0034 §4: a site Worker that joins another installation deploys only itself.
|
|
109
106
|
if ((await readProjectConfig(options.projectDir)).installation) return deployAttached(options);
|
|
110
107
|
const ctx = await loadDeploy(options);
|
|
111
|
-
const { cfg, log, previous,
|
|
108
|
+
const { cfg, log, previous, names } = ctx;
|
|
112
109
|
const { analytics, comments } = await analyticsAndComments(ctx);
|
|
113
110
|
const studioDir = await studioDirFor(ctx);
|
|
114
111
|
const { withIds, databaseCreated } = await provision(ctx);
|
|
@@ -116,7 +113,11 @@ export async function deploy(options ) {
|
|
|
116
113
|
// ignores holds and gates over open releases
|
|
117
114
|
const secrets = await deploySecrets(ctx);
|
|
118
115
|
if (!options.dryRun && previous?.adminUrl && !ctx.workersBuilds)
|
|
119
|
-
await downgradeGuard(
|
|
116
|
+
await downgradeGuard(
|
|
117
|
+
options,
|
|
118
|
+
{ adminUrl: previous.adminUrl, token: secrets.known.CLOUDHAL_DEPLOY_TOKEN },
|
|
119
|
+
log,
|
|
120
|
+
);
|
|
120
121
|
const settings = await deploySettings(ctx);
|
|
121
122
|
const { plan, schedules, observability } = settings;
|
|
122
123
|
const site = await buildSite(ctx, { withIds, analytics, comments, observability });
|
|
@@ -176,67 +177,22 @@ export async function deploy(options ) {
|
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
const
|
|
180
|
+
const shipped = await shipWorkers(ctx, {
|
|
180
181
|
siteSecrets: secrets.site,
|
|
181
182
|
adminSecrets: secrets.admin,
|
|
182
183
|
admin,
|
|
183
184
|
prepareAdmin,
|
|
184
185
|
scheduler: settings.scheduler,
|
|
185
186
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
...(siteUrl ? { siteUrl } : {}),
|
|
193
|
-
deployedAt: new Date().toISOString(),
|
|
194
|
-
...(cfg.domains?.site ? { siteDomain: cfg.domains.site } : {}),
|
|
195
|
-
analytics: analytics ? "on" : "off",
|
|
196
|
-
comments: comments.available ? "on" : "off",
|
|
197
|
-
...(jurisdiction ? { jurisdiction } : {}),
|
|
198
|
-
scheduler,
|
|
187
|
+
return finishDeploy(ctx, {
|
|
188
|
+
shipped,
|
|
189
|
+
known: secrets.known,
|
|
190
|
+
analytics,
|
|
191
|
+
comments,
|
|
192
|
+
databaseCreated,
|
|
199
193
|
plan,
|
|
200
|
-
|
|
201
|
-
const pushed = await afterDeploy(ctx, { siteUrl, adminUrl });
|
|
202
|
-
// Workers Builds knows no previous deploy, nor (after the first) the purge token: no purge
|
|
203
|
-
const purgeToken = secrets.known.CLOUDHAL_PURGE_TOKEN;
|
|
204
|
-
const { purged, analyticsChanged, commentsChanged } = purgeToken
|
|
205
|
-
? await purgeIfSwitched(ctx, { siteUrl, analytics, comments, purgeToken })
|
|
206
|
-
: { purged: false, analyticsChanged: false, commentsChanged: false };
|
|
207
|
-
|
|
208
|
-
// First deploy: the owner account can only be created through this one-time link.
|
|
209
|
-
const setupToken = secrets.known.CLOUDHAL_SETUP_TOKEN;
|
|
210
|
-
const first = pushed && adminUrl;
|
|
211
|
-
const setupUrl =
|
|
212
|
-
first && setupToken && !ctx.workersBuilds
|
|
213
|
-
? `${adminUrl.replace(/\/$/, "")}/login#setup=${setupToken}`
|
|
214
|
-
: undefined;
|
|
215
|
-
const instructions =
|
|
216
|
-
first && ctx.workersBuilds ? setupInstructions(adminUrl, names.admin) : undefined;
|
|
217
|
-
return {
|
|
218
|
-
dryRun: false,
|
|
219
|
-
names,
|
|
194
|
+
schedules,
|
|
220
195
|
siteConfig: site.siteConfig,
|
|
221
196
|
adminConfig: admin.configPath,
|
|
222
|
-
|
|
223
|
-
adminUrl,
|
|
224
|
-
pushed,
|
|
225
|
-
...(setupUrl ? { setupUrl } : {}),
|
|
226
|
-
...(instructions ? { setupInstructions: instructions } : {}),
|
|
227
|
-
...(cfg.domains?.site ? { customSiteUrl: `https://${cfg.domains.site}` } : {}),
|
|
228
|
-
...(cfg.domains?.studio ? { customStudioUrl: `https://${cfg.domains.studio}` } : {}),
|
|
229
|
-
scheduler,
|
|
230
|
-
schedules,
|
|
231
|
-
analytics: analytics
|
|
232
|
-
? {
|
|
233
|
-
enabled: true,
|
|
234
|
-
dataset: analytics.dataset,
|
|
235
|
-
cron: scheduler === "cron",
|
|
236
|
-
purged: purged && analyticsChanged,
|
|
237
|
-
}
|
|
238
|
-
: { enabled: false, ...(purged && analyticsChanged ? { purged } : {}) },
|
|
239
|
-
comments: commentsResult(comments, scheduler, purged && commentsChanged),
|
|
240
|
-
...(databaseCreated ? { databaseCreated } : {}),
|
|
241
|
-
};
|
|
197
|
+
});
|
|
242
198
|
}
|
|
@@ -135,7 +135,7 @@ export function parseFieldsArgs(
|
|
|
135
135
|
};
|
|
136
136
|
case "retype": {
|
|
137
137
|
need(a, b);
|
|
138
|
-
// The store refuses reference and repeater targets
|
|
138
|
+
// The store refuses reference and repeater targets without its capability (RFC-0045 §1).
|
|
139
139
|
if (!ALL_FIELD_TYPES.includes(b ))
|
|
140
140
|
throw new Error(`the type is one of ${ALL_FIELD_TYPES.join(", ")}`);
|
|
141
141
|
const op = {
|
|
@@ -129,7 +129,11 @@ export async function applyImport(
|
|
|
129
129
|
? await take(local, siteId, options.bracket.before)
|
|
130
130
|
: found.snapshot;
|
|
131
131
|
if (before) options.onBefore?.(before);
|
|
132
|
-
const result = await importSite(local, bundle, {
|
|
132
|
+
const result = await importSite(local, bundle, {
|
|
133
|
+
mode: options.mode,
|
|
134
|
+
// RFC-0045 §1: the local renderer reads reference and repeater fields (`openLocalStore`).
|
|
135
|
+
fieldTypes: local.store.fieldTypes,
|
|
136
|
+
});
|
|
133
137
|
const after =
|
|
134
138
|
before && options.bracket
|
|
135
139
|
? await take(local, siteId, options.bracket.after(before.id))
|
|
@@ -105,7 +105,13 @@ async function planRevert(
|
|
|
105
105
|
bundle ,
|
|
106
106
|
) {
|
|
107
107
|
try {
|
|
108
|
-
return {
|
|
108
|
+
return {
|
|
109
|
+
plan: await planImport(local, bundle, {
|
|
110
|
+
mode: "replace",
|
|
111
|
+
report: true,
|
|
112
|
+
fieldTypes: local.store.fieldTypes,
|
|
113
|
+
}),
|
|
114
|
+
};
|
|
109
115
|
} catch (e) {
|
|
110
116
|
const refusal = hostRefusal(e, "the snapshot's");
|
|
111
117
|
if (refusal === undefined) throw e;
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
planImport,
|
|
58
58
|
|
|
59
59
|
} from "@cloudhal/core-ts";
|
|
60
|
+
import { FIELDS_SUPPORTED } from "@cloudhal/core-ts/fields";
|
|
60
61
|
import { openLocalStore } from "@cloudhal/core-ts/local";
|
|
61
62
|
import { migrate, migrations } from "@cloudhal/storage";
|
|
62
63
|
import { FsBlobStore } from "@cloudhal/storage/fs";
|
|
@@ -200,13 +201,24 @@ async function planLocally(
|
|
|
200
201
|
try {
|
|
201
202
|
if (run.storeExists) {
|
|
202
203
|
run.state.local = await openLocalStore(run.dataDir);
|
|
203
|
-
return {
|
|
204
|
+
return {
|
|
205
|
+
plan: await planImport(run.state.local, bundle, {
|
|
206
|
+
...options,
|
|
207
|
+
fieldTypes: run.state.local.store.fieldTypes,
|
|
208
|
+
}),
|
|
209
|
+
};
|
|
204
210
|
}
|
|
205
211
|
const sql = await BetterSqlite3Driver.open(":memory:");
|
|
206
212
|
try {
|
|
207
213
|
await migrate(sql, migrations);
|
|
208
214
|
const blobs = new FsBlobStore(path.join(run.dataDir, "blobs"));
|
|
209
|
-
|
|
215
|
+
// The store this import would create reads reference and repeater fields (RFC-0045 §1).
|
|
216
|
+
return {
|
|
217
|
+
plan: await planImport({ sql, blobs }, bundle, {
|
|
218
|
+
...options,
|
|
219
|
+
fieldTypes: FIELDS_SUPPORTED,
|
|
220
|
+
}),
|
|
221
|
+
};
|
|
210
222
|
} finally {
|
|
211
223
|
await sql.close();
|
|
212
224
|
}
|
|
@@ -201,6 +201,8 @@ export async function pullSite(options )
|
|
|
201
201
|
const result = await importSite(local, bundle, {
|
|
202
202
|
mode: options.replace ? "replace" : "bootstrap",
|
|
203
203
|
log,
|
|
204
|
+
// RFC-0045 §1: the local renderer reads reference and repeater fields (`openLocalStore`).
|
|
205
|
+
fieldTypes: local.store.fieldTypes,
|
|
204
206
|
});
|
|
205
207
|
const message = JSON.stringify(result);
|
|
206
208
|
log(`pulled: ${message}`);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which `cloudhal.json` keys a build bakes in (RFC-0046 §11b, "Config build keys"). A release
|
|
3
|
+
* bundle was built from this CLI version's starter with `cloudhal init`'s `cloudhal.json`, so
|
|
4
|
+
* `deploy --release` refuses a project whose `build` keys differ from that, and any key this CLI
|
|
5
|
+
* does not know. Every key, and every sub-key of the objects whose sub-keys differ in class, has an
|
|
6
|
+
* explicit class; the types below are mapped over `ProjectConfig` (plus `media`, which only
|
|
7
|
+
* `astro.config.mjs` reads), so a new key without a class fails `tsc`.
|
|
8
|
+
*
|
|
9
|
+
* - `deploy`: the key becomes a binding, a var or a resource; no build reads it.
|
|
10
|
+
* - `runtime`: a build reads it, but the deployed Worker overrides it.
|
|
11
|
+
* - `build`: a build reads it and nothing overrides it: it must equal the starter's value.
|
|
12
|
+
* - `refused`: handled by the other refusals (`installation`, `sites`).
|
|
13
|
+
*
|
|
14
|
+
* Update this table, and its tests, with every key `cloudhal.json` gains.
|
|
15
|
+
*/
|
|
16
|
+
import type { AnalyticsConfig, CommentsConfig, ProjectConfig } from "./config.js";
|
|
17
|
+
export type KeyClass = "deploy" | "runtime" | "build" | "refused";
|
|
18
|
+
/** `media.transform`'s class depends on the bundle: `runtime` when it reads a var, else `build`. */
|
|
19
|
+
export type FeatureClass = {
|
|
20
|
+
readonly build: true;
|
|
21
|
+
readonly runtimeWith: "mediaTransformVar";
|
|
22
|
+
};
|
|
23
|
+
/** `cloudhal.json` `media`, read only by the starter's `astro.config.mjs` (RFC-0004 §7.5). */
|
|
24
|
+
export interface MediaConfig {
|
|
25
|
+
readonly transform?: "cdn-cgi" | "none";
|
|
26
|
+
}
|
|
27
|
+
type Mixed = "analytics" | "comments";
|
|
28
|
+
type Classes<T> = {
|
|
29
|
+
readonly [K in keyof Required<T>]-?: KeyClass | FeatureClass;
|
|
30
|
+
};
|
|
31
|
+
export type ConfigKeyTable = {
|
|
32
|
+
readonly [K in Exclude<keyof Required<ProjectConfig>, Mixed>]-?: KeyClass;
|
|
33
|
+
} & {
|
|
34
|
+
readonly analytics: Classes<AnalyticsConfig>;
|
|
35
|
+
readonly comments: Classes<CommentsConfig>;
|
|
36
|
+
readonly media: Classes<MediaConfig>;
|
|
37
|
+
};
|
|
38
|
+
export declare const CONFIG_KEY_CLASSES: ConfigKeyTable;
|
|
39
|
+
/**
|
|
40
|
+
* The value each `build` key has in the project `cloudhal init` creates, which the bundle was
|
|
41
|
+
* built from, and the value a missing key means. A project may leave it out or set either.
|
|
42
|
+
*/
|
|
43
|
+
export declare const STARTER_BUILD_VALUES: Readonly<Record<string, readonly unknown[]>>;
|
|
44
|
+
export interface BuildKeyProblem {
|
|
45
|
+
readonly key: string;
|
|
46
|
+
readonly problem: "unknown" | "build";
|
|
47
|
+
readonly value?: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The keys of a raw `cloudhal.json` the bundle cannot honour: unknown keys (and unknown sub-keys
|
|
51
|
+
* of `analytics`, `comments` and `media`), and `build` keys set to anything but the starter's.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildKeyProblems(raw: Readonly<Record<string, unknown>>, features: Readonly<Record<string, boolean>>): BuildKeyProblem[];
|
|
54
|
+
export {};
|