@cloudhal/cli 0.9.0 → 0.10.1
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 +32 -9
- 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 +14 -13
- 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,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cloudhal deploy --release` (RFC-0046 §11b): installs this CLI version's signed release into
|
|
3
|
+
* the project's Cloudflare account instead of building the project. The site and admin code come
|
|
4
|
+
* from the bundle; the project contributes its content (the first push), config and secrets.
|
|
5
|
+
*
|
|
6
|
+
* 0. refusals: another installation, several sites, Workers Builds, a version with no bundle;
|
|
7
|
+
* 1. the signed key and yank lists (online every run, or `--from`), checked against the memory;
|
|
8
|
+
* 2. the release's statement, signature and manifest (published, not a draft, with a bundle);
|
|
9
|
+
* 3. the theme check, the config build keys and the wrangler version, on that manifest;
|
|
10
|
+
* 4. the tarball, then `verifyRelease` (§2 steps 1–5, keys reduced by both lists, yanks);
|
|
11
|
+
* 5. the build-provenance attestation (`--allow-single-factor` when `gh` is unavailable);
|
|
12
|
+
* 6. extraction into a fresh directory, and the wrangler configs for exactly those bytes;
|
|
13
|
+
* 7. as every deploy: resources, secrets, the downgrade guard (the manifest's schedules level),
|
|
14
|
+
* both Workers, state, the first push and the cache purge.
|
|
15
|
+
*
|
|
16
|
+
* Nothing is written outside `.cloudhal/deploy/`, and nothing is uploaded, before step 5 passes.
|
|
17
|
+
* `--dry-run` stops after step 6.
|
|
18
|
+
*/
|
|
19
|
+
import { mkdir } from "node:fs/promises";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import {
|
|
22
|
+
mergeTrust,
|
|
23
|
+
PINNED_KEYS,
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
verifyRelease,
|
|
27
|
+
} from "@cloudhal/release-verify";
|
|
28
|
+
import { cliVersion } from "../../../assets.js";
|
|
29
|
+
import {
|
|
30
|
+
adminWorkerConfig,
|
|
31
|
+
readExistingIds,
|
|
32
|
+
|
|
33
|
+
} from "../../../cloudflare/config.js";
|
|
34
|
+
import { readProjectConfig } from "../../../config.js";
|
|
35
|
+
import { deploySecrets, finishDeploy } from "../finish.js";
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
analyticsAndComments,
|
|
39
|
+
deploySettings,
|
|
40
|
+
loadDeploy,
|
|
41
|
+
provision,
|
|
42
|
+
siteConfigFor,
|
|
43
|
+
} from "../prepare.js";
|
|
44
|
+
import { downgradeGuard } from "../schedules-guard.js";
|
|
45
|
+
import { attachedWorkers } from "../served-sites.js";
|
|
46
|
+
import { commentsResult } from "../settings.js";
|
|
47
|
+
import { shipWorkers } from "../ship.js";
|
|
48
|
+
import { deployDir } from "../state.js";
|
|
49
|
+
import { checkBuildKeys, checkProjectShape, checkTheme, checkWrangler } from "./checks.js";
|
|
50
|
+
import { writeReleaseConfigs } from "./configs.js";
|
|
51
|
+
import { refuseDeploy } from "./errors.js";
|
|
52
|
+
import { extractRelease } from "./extract.js";
|
|
53
|
+
import {
|
|
54
|
+
checkBundledVersion,
|
|
55
|
+
fetchRelease,
|
|
56
|
+
fetchTarball,
|
|
57
|
+
|
|
58
|
+
} from "./fetch-release.js";
|
|
59
|
+
|
|
60
|
+
import { loadTrust } from "./trust.js";
|
|
61
|
+
|
|
62
|
+
/** The manifest's facts the checks need, before it is verified (verification follows before any use). */
|
|
63
|
+
function unverifiedFacts(bytes )
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
{
|
|
67
|
+
try {
|
|
68
|
+
const m = JSON.parse(new TextDecoder().decode(bytes)) ;
|
|
69
|
+
const wrangler = m.toolchain?.wrangler;
|
|
70
|
+
return {
|
|
71
|
+
features: Object.fromEntries(
|
|
72
|
+
Object.entries(m.features ?? {}).filter(
|
|
73
|
+
(e) => typeof e[1] === "boolean",
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
wrangler: typeof wrangler === "string" ? wrangler : undefined,
|
|
77
|
+
};
|
|
78
|
+
} catch {
|
|
79
|
+
return { features: {}, wrangler: undefined }; // verifyRelease refuses it next
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Why the attestation of `file` failed, in words: a check that could not finish (a timeout, a
|
|
85
|
+
* signal, GitHub's rate limit, the network) is not evidence about the files, but still a refusal.
|
|
86
|
+
* Only literal alternatives are matched, so the scan is linear in `reason`.
|
|
87
|
+
*/
|
|
88
|
+
export function attestationFailure(file , reason ) {
|
|
89
|
+
const incomplete =
|
|
90
|
+
/no answer within|stopped by|rate limit|HTTP 403|HTTP 429|ECONN|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|getaddrinfo|dial tcp|TLS handshake|connection reset|network/i;
|
|
91
|
+
if (reason.length <= 2000 && incomplete.test(reason))
|
|
92
|
+
return `the build-provenance attestation of ${file} could not be checked (${reason}). This is still a refusal: nothing was deployed. Try again later.`;
|
|
93
|
+
return `the build-provenance attestation of ${file} failed (${reason}): these files were not built by this repository's bundle-build.yml. Nothing was deployed.`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function attestation(
|
|
97
|
+
options ,
|
|
98
|
+
input ,
|
|
99
|
+
log ,
|
|
100
|
+
) {
|
|
101
|
+
const attest =
|
|
102
|
+
options.attest ??
|
|
103
|
+
(async (o ) =>
|
|
104
|
+
(await import("@cloudhal/release-verify/attestation")).verifyAttestation(o));
|
|
105
|
+
const r = await attest(input);
|
|
106
|
+
if (r.status === "verified") return "verified";
|
|
107
|
+
if (r.status === "failed")
|
|
108
|
+
return refuseDeploy(
|
|
109
|
+
"attestation-failed" ,
|
|
110
|
+
attestationFailure(r.file, r.reason),
|
|
111
|
+
);
|
|
112
|
+
if (!options.allowSingleFactor)
|
|
113
|
+
return refuseDeploy(
|
|
114
|
+
"attestation-unavailable",
|
|
115
|
+
`the build-provenance attestation cannot be checked: ${r.reason}. Install the GitHub CLI 2.68 or newer (https://cli.github.com) and run \`gh auth login\`, or add --allow-single-factor to rely on the release key alone.`,
|
|
116
|
+
);
|
|
117
|
+
log(
|
|
118
|
+
`--allow-single-factor: the attestation is not checked (${r.reason}); this install relies on the release key alone`,
|
|
119
|
+
);
|
|
120
|
+
return "single-factor";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Steps 1–6 (see the file comment): the verified, extracted release. */
|
|
124
|
+
async function verifiedRelease(
|
|
125
|
+
options ,
|
|
126
|
+
where ,
|
|
127
|
+
) {
|
|
128
|
+
const { dir, version, log } = where;
|
|
129
|
+
const trust = await loadTrust({
|
|
130
|
+
from: options.from,
|
|
131
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
132
|
+
...(options.trustRoots ? { roots: options.trustRoots } : {}),
|
|
133
|
+
...(options.trustStateFile ? { stateFile: options.trustStateFile } : {}),
|
|
134
|
+
});
|
|
135
|
+
log(
|
|
136
|
+
`trust: keys.json ${trust.keys.sha256.slice(0, 12)}, yanked.json serial ${trust.yanked.document.serial}`,
|
|
137
|
+
);
|
|
138
|
+
const source = {
|
|
139
|
+
version,
|
|
140
|
+
from: options.from,
|
|
141
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
142
|
+
dir: path.join(dir, "release-download", version),
|
|
143
|
+
log,
|
|
144
|
+
};
|
|
145
|
+
const files = await fetchRelease(source);
|
|
146
|
+
const facts = unverifiedFacts(files.manifest);
|
|
147
|
+
const notDeployed = await checkTheme(options.projectDir, options.discardLocalTheme, log);
|
|
148
|
+
await checkBuildKeys(options.projectDir, facts.features);
|
|
149
|
+
await checkWrangler(options.projectDir, facts.wrangler, options.wranglerVersion);
|
|
150
|
+
const tarball = await fetchTarball(source);
|
|
151
|
+
const release = await verifyRelease({
|
|
152
|
+
request: { version },
|
|
153
|
+
statement: files.statement,
|
|
154
|
+
signature: files.signature,
|
|
155
|
+
manifest: files.manifest,
|
|
156
|
+
tarball,
|
|
157
|
+
planVersion: 1,
|
|
158
|
+
keys: mergeTrust(options.pinnedKeys ?? PINNED_KEYS, trust),
|
|
159
|
+
yanked: trust.yanked,
|
|
160
|
+
});
|
|
161
|
+
log(
|
|
162
|
+
`verified v${version} (commit ${release.statement.commit.slice(0, 12)}, key ${release.statement.signing.keyId})`,
|
|
163
|
+
);
|
|
164
|
+
const attested = await attestation(
|
|
165
|
+
options,
|
|
166
|
+
{ dir: files.dir, version, commit: release.statement.commit },
|
|
167
|
+
log,
|
|
168
|
+
);
|
|
169
|
+
const extracted = await extractRelease(release, path.join(dir, "release", version));
|
|
170
|
+
log(
|
|
171
|
+
`extracted ${extracted.files} verified files into ${path.relative(options.projectDir, extracted.dir)}`,
|
|
172
|
+
);
|
|
173
|
+
return { release, extracted, attested, notDeployed };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export async function deployRelease(options ) {
|
|
177
|
+
const cfg = await readProjectConfig(options.projectDir);
|
|
178
|
+
checkProjectShape(cfg, options.workersBuilds);
|
|
179
|
+
const version = options.cliVersion ?? (await cliVersion());
|
|
180
|
+
checkBundledVersion(version);
|
|
181
|
+
// Steps 1–6 first: until the attestation passes nothing is written outside .cloudhal/deploy/
|
|
182
|
+
// (loadDeploy may ask about analytics and rewrite cloudhal.json) and nothing is uploaded.
|
|
183
|
+
const dir = deployDir(options.projectDir, cfg.dataDir);
|
|
184
|
+
await mkdir(dir, { recursive: true });
|
|
185
|
+
const log = options.log ?? (() => {});
|
|
186
|
+
const { release, extracted, attested, notDeployed } = await verifiedRelease(options, {
|
|
187
|
+
dir,
|
|
188
|
+
version,
|
|
189
|
+
log,
|
|
190
|
+
});
|
|
191
|
+
const ctx = await loadDeploy(options);
|
|
192
|
+
const manifest = release.manifest;
|
|
193
|
+
|
|
194
|
+
const { analytics, comments } = await analyticsAndComments(ctx);
|
|
195
|
+
const { withIds, databaseCreated } = await provision(ctx);
|
|
196
|
+
const secrets = await deploySecrets(ctx);
|
|
197
|
+
const previous = ctx.previous;
|
|
198
|
+
if (!options.dryRun && previous?.adminUrl)
|
|
199
|
+
await downgradeGuard(
|
|
200
|
+
options,
|
|
201
|
+
{
|
|
202
|
+
adminUrl: previous.adminUrl,
|
|
203
|
+
token: secrets.known.CLOUDHAL_DEPLOY_TOKEN ,
|
|
204
|
+
localLevel: manifest.levels.schedules,
|
|
205
|
+
},
|
|
206
|
+
ctx.log,
|
|
207
|
+
);
|
|
208
|
+
const settings = await deploySettings(ctx);
|
|
209
|
+
const { plan, schedules, observability } = settings;
|
|
210
|
+
const siteConfig = await siteConfigFor(ctx, { withIds, analytics, comments, observability });
|
|
211
|
+
const siteWorkers = await attachedWorkers(ctx);
|
|
212
|
+
const existing = await readExistingIds(
|
|
213
|
+
path.join(ctx.dir, "release-config", "admin", "wrangler.jsonc"),
|
|
214
|
+
);
|
|
215
|
+
const adminConfig = (scheduler ) =>
|
|
216
|
+
adminWorkerConfig({
|
|
217
|
+
...existing,
|
|
218
|
+
...withIds,
|
|
219
|
+
siteId: cfg.siteId,
|
|
220
|
+
...(siteWorkers.length ? { siteWorkers } : {}),
|
|
221
|
+
main: "(release)",
|
|
222
|
+
studioDir: extracted.admin.assetsDir,
|
|
223
|
+
...(cfg.domains?.studio ? { domain: cfg.domains.studio } : {}),
|
|
224
|
+
...(analytics ? { analytics } : {}),
|
|
225
|
+
comments,
|
|
226
|
+
scheduler,
|
|
227
|
+
schedules,
|
|
228
|
+
...(cfg.mail ? { mail: cfg.mail } : {}),
|
|
229
|
+
...(cfg.ai ? { ai: true } : {}),
|
|
230
|
+
...(cfg.render !== false ? { browser: true } : {}),
|
|
231
|
+
observability,
|
|
232
|
+
...(cfg.placement ? { placement: cfg.placement } : {}),
|
|
233
|
+
});
|
|
234
|
+
const write = (scheduler ) =>
|
|
235
|
+
writeReleaseConfigs({
|
|
236
|
+
deployDir: ctx.dir,
|
|
237
|
+
manifest,
|
|
238
|
+
site: { config: siteConfig, worker: extracted.site },
|
|
239
|
+
admin: { config: adminConfig(scheduler), worker: extracted.admin },
|
|
240
|
+
});
|
|
241
|
+
const configs = await write(settings.scheduler);
|
|
242
|
+
const result = {
|
|
243
|
+
version,
|
|
244
|
+
commit: release.statement.commit,
|
|
245
|
+
attestation: attested,
|
|
246
|
+
files: extracted.files,
|
|
247
|
+
...(notDeployed.length > 0 ? { notDeployed: notDeployed.map((d) => d.path) } : {}),
|
|
248
|
+
};
|
|
249
|
+
if (options.dryRun) {
|
|
250
|
+
ctx.log(
|
|
251
|
+
"dry run complete: the verified release and its configs are in .cloudhal/deploy (nothing was deployed)",
|
|
252
|
+
);
|
|
253
|
+
return {
|
|
254
|
+
dryRun: true,
|
|
255
|
+
names: ctx.names,
|
|
256
|
+
siteConfig: configs.site.configPath,
|
|
257
|
+
adminConfig: configs.admin.configPath,
|
|
258
|
+
scheduler: settings.scheduler,
|
|
259
|
+
schedules,
|
|
260
|
+
analytics: analytics
|
|
261
|
+
? { enabled: true, dataset: analytics.dataset, cron: settings.scheduler === "cron" }
|
|
262
|
+
: { enabled: false },
|
|
263
|
+
comments: commentsResult(comments, settings.scheduler),
|
|
264
|
+
release: result,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const shipped = await shipWorkers(ctx, {
|
|
268
|
+
siteSecrets: secrets.site,
|
|
269
|
+
adminSecrets: secrets.admin,
|
|
270
|
+
site: configs.site,
|
|
271
|
+
admin: configs.admin,
|
|
272
|
+
prepareAdmin: async (ticker) => (await write(ticker)).admin,
|
|
273
|
+
scheduler: settings.scheduler,
|
|
274
|
+
});
|
|
275
|
+
const done = await finishDeploy(ctx, {
|
|
276
|
+
shipped,
|
|
277
|
+
known: secrets.known,
|
|
278
|
+
analytics,
|
|
279
|
+
comments,
|
|
280
|
+
databaseCreated,
|
|
281
|
+
plan,
|
|
282
|
+
schedules,
|
|
283
|
+
siteConfig: configs.site.configPath,
|
|
284
|
+
adminConfig: configs.admin.configPath,
|
|
285
|
+
});
|
|
286
|
+
return { ...done, release: result };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The options `cloudhal deploy --release` adds (RFC-0046 §11b), and what it reports. */
|
|
2
|
+
import type { ReleaseKeys, RootKeys } from "@cloudhal/release-verify";
|
|
3
|
+
import type { AttestationResult } from "@cloudhal/release-verify/attestation";
|
|
4
|
+
export interface ReleaseDeployOptions {
|
|
5
|
+
/** Install this CLI version's signed release instead of building the project. */
|
|
6
|
+
readonly release?: boolean;
|
|
7
|
+
/** `--from <dir>`: the five release assets, `keys.json` and `yanked.json` (with `.sig`) offline. */
|
|
8
|
+
readonly from?: string;
|
|
9
|
+
/** Continue on the release key alone when `gh` is unavailable (never implied). */
|
|
10
|
+
readonly allowSingleFactor?: boolean;
|
|
11
|
+
/** Deploy the official theme although the project's theme files differ (never implied). */
|
|
12
|
+
readonly discardLocalTheme?: boolean;
|
|
13
|
+
/** Tests only: the version to install (default: this CLI's). */
|
|
14
|
+
readonly cliVersion?: string;
|
|
15
|
+
/** Tests only: the release keys to start from (default: `PINNED_KEYS`). */
|
|
16
|
+
readonly pinnedKeys?: ReleaseKeys;
|
|
17
|
+
/** Tests only: the roots `keys.json` must verify with (default: `PINNED_ROOTS`). */
|
|
18
|
+
readonly trustRoots?: RootKeys;
|
|
19
|
+
/** Tests only: where the yank memory lives (default: `~/.cloudhal/release-trust.json`). */
|
|
20
|
+
readonly trustStateFile?: string;
|
|
21
|
+
/** Tests only: the attestation check (default: `gh attestation verify`). */
|
|
22
|
+
readonly attest?: (o: {
|
|
23
|
+
dir: string;
|
|
24
|
+
version: string;
|
|
25
|
+
commit: string;
|
|
26
|
+
}) => Promise<AttestationResult>;
|
|
27
|
+
}
|
|
28
|
+
export interface ReleaseResult {
|
|
29
|
+
readonly version: string;
|
|
30
|
+
readonly commit: string;
|
|
31
|
+
/** `verified`, or `single-factor` with `--allow-single-factor` and no `gh`. */
|
|
32
|
+
readonly attestation: "verified" | "single-factor";
|
|
33
|
+
/** With `--discard-local-theme`: the project's files the official theme replaced. */
|
|
34
|
+
readonly notDeployed?: readonly string[];
|
|
35
|
+
/** Files extracted into `.cloudhal/deploy/release/<version>/`. */
|
|
36
|
+
readonly files: number;
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** `postcss-load-config` 6.0.1's search places (the `package.json` key aside). */
|
|
2
|
+
export declare const POSTCSS_FILES: string[];
|
|
3
|
+
export interface ThemeDifference {
|
|
4
|
+
/** Relative to the project (`../postcss.config.cjs` above it). */
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly change: "changed" | "added" | "missing";
|
|
7
|
+
}
|
|
8
|
+
type Keep = (abs: string) => boolean;
|
|
9
|
+
/** The directories Vite searches for a PostCSS config: the project up to its workspace root. */
|
|
10
|
+
export declare function postcssSearchDirs(projectDir: string): Promise<string[]>;
|
|
11
|
+
/** This CLI version's starter (the one `cloudhal init` copies): its directory and file filter. */
|
|
12
|
+
export declare function cliStarter(name?: string): Promise<{
|
|
13
|
+
dir: string;
|
|
14
|
+
keep: Keep;
|
|
15
|
+
}>;
|
|
16
|
+
/** Every difference between the project's build inputs and the starter's (see the file comment). */
|
|
17
|
+
export declare function themeDifferences(projectDir: string, starter: {
|
|
18
|
+
dir: string;
|
|
19
|
+
keep: Keep;
|
|
20
|
+
}): Promise<ThemeDifference[]>;
|
|
21
|
+
/** The differences as lines: the first 20 and a count, or with `all` every one. */
|
|
22
|
+
export declare function listDifferences(diffs: readonly ThemeDifference[], all?: boolean): string;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The theme check of `deploy --release` (RFC-0046 §11b): the bundle's site and admin code were
|
|
3
|
+
* built from this CLI version's own starter, so a project whose build inputs differ from that
|
|
4
|
+
* starter would silently lose its changes. Compared, as normalised relative paths, byte for byte
|
|
5
|
+
* after CRLF → LF:
|
|
6
|
+
*
|
|
7
|
+
* - every file under `src/` and `public/` (and `skills/`, which `resolveSkillsDir` prefers and the
|
|
8
|
+
* admin build bakes in; the starter has none);
|
|
9
|
+
* - the root build inputs `astro.config.mjs`, `tsconfig.json` and `jsconfig.json`;
|
|
10
|
+
* - every PostCSS config Vite would load, in every directory from the project up to Vite's
|
|
11
|
+
* workspace root (`searchForWorkspaceRoot`: the nearest directory with `pnpm-workspace.yaml`,
|
|
12
|
+
* `lerna.json`, a `package.json` with `workspaces`, or a `deno.json(c)` with `workspace`; without
|
|
13
|
+
* one, the project alone), including a `postcss` key in `package.json`.
|
|
14
|
+
*
|
|
15
|
+
* Checked against Astro 7.4.7 and Vite 8.3.5 (`resolvePostcssConfig`, the `postcss-load-config`
|
|
16
|
+
* 6.0.1 search places). Astro passes `configFile: false` to Vite, so `vite.config.*` is never read;
|
|
17
|
+
* `.env*` files are not compared (the starter's code reads no `import.meta.env`). Recheck this list
|
|
18
|
+
* on every Astro or Vite major upgrade.
|
|
19
|
+
*
|
|
20
|
+
* `.DS_Store`, `Thumbs.db` and `desktop.ini` are skipped wherever they appear (exact basenames).
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync } from "node:fs";
|
|
23
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import { assetDir } from "../../../assets.js";
|
|
26
|
+
import { starterFilter } from "../../../starter-files.js";
|
|
27
|
+
|
|
28
|
+
const TREES = ["src", "public", "skills"];
|
|
29
|
+
const ROOT_FILES = ["astro.config.mjs", "tsconfig.json", "jsconfig.json"];
|
|
30
|
+
const JS_EXT = ["js", "cjs", "mjs", "ts", "cts", "mts"];
|
|
31
|
+
/** `postcss-load-config` 6.0.1's search places (the `package.json` key aside). */
|
|
32
|
+
export const POSTCSS_FILES = [
|
|
33
|
+
...JS_EXT.map((e) => `postcss.config.${e}`),
|
|
34
|
+
".postcssrc",
|
|
35
|
+
...["json", "yaml", "yml", ...JS_EXT].map((e) => `.postcssrc.${e}`),
|
|
36
|
+
];
|
|
37
|
+
const OS_METADATA = new Set([".DS_Store", "Thumbs.db", "desktop.ini"]);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
async function filesUnder(root , rel , keep ) {
|
|
48
|
+
const dir = path.join(root, rel);
|
|
49
|
+
if (!existsSync(dir)) return [];
|
|
50
|
+
if (!(await stat(dir)).isDirectory()) return [rel]; // e.g. a file named `skills`
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
53
|
+
const r = `${rel}/${entry.name}`;
|
|
54
|
+
if (OS_METADATA.has(entry.name) || !keep(path.join(root, r))) continue;
|
|
55
|
+
if (entry.isDirectory()) out.push(...(await filesUnder(root, r, keep)));
|
|
56
|
+
else out.push(r);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The compared files of `root`: the trees and the root build inputs. */
|
|
62
|
+
async function comparedFiles(root , keep ) {
|
|
63
|
+
const files = new Set ();
|
|
64
|
+
for (const tree of TREES) for (const f of await filesUnder(root, tree, keep)) files.add(f);
|
|
65
|
+
for (const f of [...ROOT_FILES, ...POSTCSS_FILES])
|
|
66
|
+
if (existsSync(path.join(root, f)) && keep(path.join(root, f))) files.add(f);
|
|
67
|
+
return files;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The file's bytes with every CRLF as LF, so a Windows checkout of the starter compares equal. */
|
|
71
|
+
async function normalised(file ) {
|
|
72
|
+
const bytes = new Uint8Array(await readFile(file));
|
|
73
|
+
const out = new Uint8Array(bytes.length);
|
|
74
|
+
let n = 0;
|
|
75
|
+
for (let i = 0; i < bytes.length; i++)
|
|
76
|
+
if (!(bytes[i] === 0x0d && bytes[i + 1] === 0x0a)) out[n++] = bytes[i] ;
|
|
77
|
+
return out.subarray(0, n);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const sameBytes = (a , b ) =>
|
|
81
|
+
a.length === b.length && a.every((x, i) => x === b[i]);
|
|
82
|
+
|
|
83
|
+
const postcssKey = async (dir ) => {
|
|
84
|
+
const file = path.join(dir, "package.json");
|
|
85
|
+
if (!existsSync(file)) return undefined;
|
|
86
|
+
try {
|
|
87
|
+
const pkg = JSON.parse(await readFile(file, "utf8")) ;
|
|
88
|
+
return Object.hasOwn(pkg, "postcss") ? JSON.stringify(pkg.postcss) : undefined;
|
|
89
|
+
} catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
async function isWorkspaceRoot(dir ) {
|
|
95
|
+
if (existsSync(path.join(dir, "pnpm-workspace.yaml")) || existsSync(path.join(dir, "lerna.json")))
|
|
96
|
+
return true;
|
|
97
|
+
const has = async (name , key ) => {
|
|
98
|
+
const file = path.join(dir, name);
|
|
99
|
+
if (!existsSync(file)) return false;
|
|
100
|
+
try {
|
|
101
|
+
return Object.hasOwn(JSON.parse(await readFile(file, "utf8")) , key);
|
|
102
|
+
} catch {
|
|
103
|
+
return false; // deno.jsonc with comments: Vite strips them; a parse failure is no workspace
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return (
|
|
107
|
+
(await has("package.json", "workspaces")) ||
|
|
108
|
+
(await has("deno.json", "workspace")) ||
|
|
109
|
+
(await has("deno.jsonc", "workspace"))
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The directories Vite searches for a PostCSS config: the project up to its workspace root. */
|
|
114
|
+
export async function postcssSearchDirs(projectDir ) {
|
|
115
|
+
const dirs = [];
|
|
116
|
+
let cur = path.resolve(projectDir);
|
|
117
|
+
for (;;) {
|
|
118
|
+
dirs.push(cur);
|
|
119
|
+
if (await isWorkspaceRoot(cur)) return dirs;
|
|
120
|
+
const parent = path.dirname(cur);
|
|
121
|
+
if (parent === cur) return [path.resolve(projectDir)]; // no workspace: the project alone
|
|
122
|
+
cur = parent;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** This CLI version's starter (the one `cloudhal init` copies): its directory and file filter. */
|
|
127
|
+
export async function cliStarter(name = "blog") {
|
|
128
|
+
const starters = await assetDir("starters");
|
|
129
|
+
const dir = starters ? path.join(starters, name) : undefined;
|
|
130
|
+
if (!dir || !existsSync(dir)) throw new Error(`this CLI ships no starter "${name}"`);
|
|
131
|
+
return { dir, keep: await starterFilter(dir) };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Every difference between the project's build inputs and the starter's (see the file comment). */
|
|
135
|
+
export async function themeDifferences(
|
|
136
|
+
projectDir ,
|
|
137
|
+
starter ,
|
|
138
|
+
) {
|
|
139
|
+
const mine = await comparedFiles(projectDir, () => true);
|
|
140
|
+
const theirs = await comparedFiles(starter.dir, starter.keep);
|
|
141
|
+
const out = [];
|
|
142
|
+
for (const f of [...new Set([...mine, ...theirs])].sort()) {
|
|
143
|
+
if (!theirs.has(f)) out.push({ path: f, change: "added" });
|
|
144
|
+
else if (!mine.has(f)) out.push({ path: f, change: "missing" });
|
|
145
|
+
else if (
|
|
146
|
+
!sameBytes(
|
|
147
|
+
await normalised(path.join(projectDir, f)),
|
|
148
|
+
await normalised(path.join(starter.dir, f)),
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
out.push({ path: f, change: "changed" });
|
|
152
|
+
}
|
|
153
|
+
// `resolveSkillsDir` takes `skills/` whenever it exists, even empty: that alone is a difference.
|
|
154
|
+
const skills = (root ) => existsSync(path.join(root, "skills"));
|
|
155
|
+
if (skills(projectDir) && !skills(starter.dir) && !out.some((d) => d.path.startsWith("skills")))
|
|
156
|
+
out.push({ path: "skills/", change: "added" });
|
|
157
|
+
// `postcss` in the project's package.json, compared with the starter's.
|
|
158
|
+
const [own, starters] = [await postcssKey(projectDir), await postcssKey(starter.dir)];
|
|
159
|
+
if (own !== starters)
|
|
160
|
+
out.push({
|
|
161
|
+
path: "package.json#postcss",
|
|
162
|
+
change: starters === undefined ? "added" : own === undefined ? "missing" : "changed",
|
|
163
|
+
});
|
|
164
|
+
// Above the project, up to Vite's workspace root: any PostCSS config at all.
|
|
165
|
+
for (const dir of (await postcssSearchDirs(projectDir)).slice(1)) {
|
|
166
|
+
const rel = path.relative(projectDir, dir).split(path.sep).join("/");
|
|
167
|
+
for (const f of POSTCSS_FILES)
|
|
168
|
+
if (existsSync(path.join(dir, f))) out.push({ path: `${rel}/${f}`, change: "added" });
|
|
169
|
+
if ((await postcssKey(dir)) !== undefined)
|
|
170
|
+
out.push({ path: `${rel}/package.json#postcss`, change: "added" });
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The differences as lines: the first 20 and a count, or with `all` every one. */
|
|
176
|
+
export function listDifferences(diffs , all = false) {
|
|
177
|
+
const shown = all ? diffs : diffs.slice(0, 20);
|
|
178
|
+
const lines = shown.map((d) => ` ${d.change}: ${d.path}`);
|
|
179
|
+
if (diffs.length > shown.length) lines.push(` … and ${diffs.length - shown.length} more`);
|
|
180
|
+
return lines.join("\n");
|
|
181
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type RootKeys, type VerifiedKeyList, type VerifiedYankList, type YankMemory } from "@cloudhal/release-verify";
|
|
2
|
+
/** Where the CLI keeps its `YankMemory`: one per user, shared by every project. */
|
|
3
|
+
export declare const defaultTrustStateFile: () => string;
|
|
4
|
+
export interface TrustInput {
|
|
5
|
+
/** `--from <dir>`, else the canonical URLs. */
|
|
6
|
+
readonly from?: string | undefined;
|
|
7
|
+
readonly fetch?: typeof fetch;
|
|
8
|
+
/** Tests only: roots other than the pinned ones. */
|
|
9
|
+
readonly roots?: RootKeys;
|
|
10
|
+
/** Default: `defaultTrustStateFile()`. */
|
|
11
|
+
readonly stateFile?: string;
|
|
12
|
+
readonly now?: Date;
|
|
13
|
+
}
|
|
14
|
+
export interface Trust {
|
|
15
|
+
readonly keys: VerifiedKeyList;
|
|
16
|
+
readonly yanked: VerifiedYankList;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Two memories combined so neither loses what it saw: for the same yank key the higher serial,
|
|
20
|
+
* the newer key list and the union of every entry; across a rotation the memory of the newer key
|
|
21
|
+
* list, still carrying every retired yank key of both.
|
|
22
|
+
*/
|
|
23
|
+
export declare function mergeMemory(disk: YankMemory | undefined, next: YankMemory): YankMemory;
|
|
24
|
+
/** Both lists, verified and checked against the memory, which is then updated (see the file comment). */
|
|
25
|
+
export declare function loadTrust(input: TrustInput): Promise<Trust>;
|