create-ailk 0.37.0 → 0.38.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 +149 -2
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +7 -2
- package/dist/add-route.js +28 -13
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +9 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +67 -0
- package/dist/routes.d.ts +103 -0
- package/dist/routes.js +708 -0
- package/dist/site-manifest.js +1 -1
- package/dist/site-roster.d.ts +2 -1
- package/dist/site-roster.js +30 -8
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +18 -0
- package/dist/surfaces.js +47 -282
- package/dist/sync-routes.d.ts +28 -1
- package/dist/sync-routes.js +144 -11
- package/dist/template-record.d.ts +11 -0
- package/dist/template-record.js +18 -0
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +31 -2
- package/dist/update.js +627 -99
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +62 -20
- package/templates/apps/web/account.config.tsx +101 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
- package/templates/apps/web/app/[locale]/layout.tsx +45 -28
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/i18n/request.ts +44 -1
- package/templates/apps/web/jest.config.cjs +13 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/messages/en.json +8 -684
- package/templates/apps/web/middleware.ts +3 -1
- package/templates/apps/web/next.config.mjs +27 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +48 -47
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
package/dist/update.js
CHANGED
|
@@ -52,6 +52,43 @@
|
|
|
52
52
|
* takes the template's copy on a conflict, and never counts as a site edit
|
|
53
53
|
* for the cascade.
|
|
54
54
|
*
|
|
55
|
+
* An unrecorded file at a template path — one a `sync-routes --apply` or
|
|
56
|
+
* `add-route` copied before #11213 recorded its copies — is adopted when
|
|
57
|
+
* its bytes are that path's template copy in any published version from
|
|
58
|
+
* the record's oldest (the manifest's `patternVersion`) to the running one:
|
|
59
|
+
* recorded, and moved forward as an untouched copy is, named with the
|
|
60
|
+
* version it matched. One matching no published copy is the site's own:
|
|
61
|
+
* held as a site edit, never overwritten, and counted in the report.
|
|
62
|
+
*
|
|
63
|
+
* A skipped file never holds another (#11216): the run has decided not to
|
|
64
|
+
* manage it, so only a file under review, and what is held with it, holds.
|
|
65
|
+
* A relative import a written file names that the site lacks is added when
|
|
66
|
+
* the template supplies it — listed under "Added", its importer moving with
|
|
67
|
+
* it — and, when the template does not, holds the importer only when this
|
|
68
|
+
* write introduces the import; a site copy already naming it moves, and the
|
|
69
|
+
* report names the path under "Not in this site or the template".
|
|
70
|
+
*
|
|
71
|
+
* A test moves with its lib files (#11234): every `apps/web/lib/` or
|
|
72
|
+
* `apps/mcp/src/lib/` file a moving test's import chain reaches — through
|
|
73
|
+
* the route it imports, say — is written from the template when the
|
|
74
|
+
* template supplies it and the site's copy differs or is absent, whether
|
|
75
|
+
* the test itself is written or already current, and its line in the report
|
|
76
|
+
* names the test. One the template does not supply, and the site lacks,
|
|
77
|
+
* holds the test under the missing path.
|
|
78
|
+
*
|
|
79
|
+
* What the written files need from outside the record comes with them
|
|
80
|
+
* (#11392): each `@working-theory/*` package a written `apps/web` file imports
|
|
81
|
+
* that `apps/web/package.json` declares nowhere joins its `dependencies` at
|
|
82
|
+
* the running `versions.json` version, and an edited messages catalog whose
|
|
83
|
+
* three-way merge cannot land, for any reason, takes the template's new keys
|
|
84
|
+
* additively. A written web file that uses, through `t(…)`, a template key a
|
|
85
|
+
* catalog still lacks after that is held with the catalog.
|
|
86
|
+
*
|
|
87
|
+
* A route the site declined in `customizations.yaml` `declined_routes`
|
|
88
|
+
* (#11260) is the site's decision: no file under its directory is written —
|
|
89
|
+
* not updated, not added, not supplied as another file's dependency — and
|
|
90
|
+
* each is listed under "Skipped" naming the declined route.
|
|
91
|
+
*
|
|
55
92
|
* Pure module: no `import.meta.url` — the CLI supplies `templatesDir`, the
|
|
56
93
|
* `adopt.ts` / `add-route.ts` split.
|
|
57
94
|
*/
|
|
@@ -63,6 +100,7 @@ import { parseArgs } from "node:util";
|
|
|
63
100
|
import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
|
|
64
101
|
import { headingViolations, mdxBodyPages, mdxBodyRule, migrateBodyHeadings } from "./body-heading.js";
|
|
65
102
|
import { buildScaffoldMarkers, isExcluded, isTextFile, renderTemplateFile, templateDestination } from "./copy.js";
|
|
103
|
+
import { declinedRouteOfPath, readDeclinedRoutes } from "./declined-routes.js";
|
|
66
104
|
import { deriveArchitecture } from "./derive-architecture.js";
|
|
67
105
|
import { EnvContractError, planEnvRows, readEnvContract, readManifestTopology, } from "./lib/declared-env.js";
|
|
68
106
|
import { ENV_CATALOG } from "./lib/env-catalog.js";
|
|
@@ -73,11 +111,11 @@ import { mergeThreeWay } from "./lib/merge-three-way.js";
|
|
|
73
111
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
74
112
|
import { escapeBareBraces, findBareBraces } from "./mdx-braces.js";
|
|
75
113
|
import { MODULE_SLICES } from "./module-architecture.js";
|
|
76
|
-
import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, writeModuleFlags, writePaidMcpTools, } from "./paid-sections.js";
|
|
114
|
+
import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, renderSitePaidSections, writeModuleFlags, writePaidMcpTools, writePaidSectionsRegistry, } from "./paid-sections.js";
|
|
77
115
|
import { ParseError } from "./parse-args.js";
|
|
116
|
+
import { RoutesRefusedError, writeRoutes } from "./routes.js";
|
|
78
117
|
import { SITE_LISTING_PATH } from "./site-listing-path.js";
|
|
79
118
|
import { SITE_ROSTER_PATH, planServedRoster, readRosterPageRoutes } from "./site-roster.js";
|
|
80
|
-
import { SPOKE_CHECKOUT_TEMPLATE_PATHS } from "./spoke-checkout.js";
|
|
81
119
|
import { GATEABLE_SURFACES, excludedRoutePaths, isRemovedPublicRoutePath, resolveSurfaces, surfacesNamedByRoutes, } from "./surfaces.js";
|
|
82
120
|
import { DATABASE_BOOT_FILES, ROOT_TOOL_FILES, TEMPLATE_RECORD_PATH, isRecordable, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
|
|
83
121
|
import { MCP_SEAM_PATH, MCP_SERVER_HUB, TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
|
|
@@ -111,6 +149,8 @@ function versionOlder(a, b) {
|
|
|
111
149
|
return false;
|
|
112
150
|
}
|
|
113
151
|
/** The reason a boot file is skipped on a site whose `database/` is still the copied package (#9569 DD8). */
|
|
152
|
+
/** The `skipped` reason of an unrecorded in-scope file whose bytes match no published template copy (#11213). */
|
|
153
|
+
const UNRECORDED_SITE_EDIT = "exists, not in the record; a site edit (no template copy matched)";
|
|
114
154
|
const DATABASE_PACKAGE_GUARD = "database/ is still a package here — convert it to the thin consumer first";
|
|
115
155
|
/**
|
|
116
156
|
* Every file under `templatesDir`'s three app trees, plus each of the
|
|
@@ -285,6 +325,8 @@ function containsKnownPath(prefix, knownPaths) {
|
|
|
285
325
|
}
|
|
286
326
|
/** A template test file: a `*.test.*` / `*.spec.*` module, or anything under `__tests__/`. */
|
|
287
327
|
const TEST_FILE = /(^|\/)__tests__\/|\.(test|spec)\.[cm]?[jt]sx?$/;
|
|
328
|
+
/** A lib module a test's import chain reaches (#11234): the web app's `lib/`, the MCP app's `src/lib/`. */
|
|
329
|
+
const LIB_FILE = /^apps\/(?:web\/lib|mcp\/src\/lib)\//;
|
|
288
330
|
/** Module specifiers `import`/`export … from`, `import()`, `require()` and `jest.mock()` name. */
|
|
289
331
|
const IMPORT_SPECIFIER = /\bfrom\s*["']([^"']+)["']|\bimport\s*["']([^"']+)["']|\b(?:import|require|jest\.mock|jest\.requireActual)\s*\(\s*["']([^"']+)["']/g;
|
|
290
332
|
const WEB_ROOT = "apps/web/";
|
|
@@ -341,8 +383,102 @@ function importedHeldFiles(fromPath, text, held) {
|
|
|
341
383
|
}
|
|
342
384
|
return [...out];
|
|
343
385
|
}
|
|
386
|
+
/** The `@working-theory/*` packages `text` imports in its code lines (#11392), by package name. */
|
|
387
|
+
function workingTheoryImportsOf(text) {
|
|
388
|
+
const out = new Set();
|
|
389
|
+
for (const match of codeLines(text.split("\n")).join("\n").matchAll(IMPORT_SPECIFIER)) {
|
|
390
|
+
const specifier = match[1] ?? match[2] ?? match[3];
|
|
391
|
+
const name = /^@working-theory\/[^/]+/.exec(specifier ?? "")?.[0];
|
|
392
|
+
if (name !== undefined)
|
|
393
|
+
out.add(name);
|
|
394
|
+
}
|
|
395
|
+
return [...out];
|
|
396
|
+
}
|
|
344
397
|
/** The `apps/web/messages/` catalogs next-intl loads by locale, never by import. */
|
|
345
398
|
const MESSAGES_JSON = /^apps\/web\/messages\/(?:[^/]+\/)*[^/]+\.json$/;
|
|
399
|
+
/**
|
|
400
|
+
* A next-intl translator call: `[await] useTranslations("ns")`, or
|
|
401
|
+
* `getTranslations({ …, namespace: "ns" })`, or either with no namespace —
|
|
402
|
+
* never one whose namespace is computed. Group 1 or 2 is the namespace.
|
|
403
|
+
*/
|
|
404
|
+
const TRANSLATOR_CALL = /(?:await\s+)?(?:useTranslations|getTranslations)\s*\(\s*(?:["'`]([^"'`$]*)["'`]|\{[^}]*?\bnamespace\s*:\s*["'`]([^"'`$]*)["'`][^}]*\}|\{(?![^}]*\bnamespace\b)[^}]*\})?\s*\)/;
|
|
405
|
+
/** `const t = <translator call>`. */
|
|
406
|
+
const TRANSLATOR = new RegExp(`\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*${TRANSLATOR_CALL.source}`, "g");
|
|
407
|
+
/** `const [a, t, …] = await Promise.all([…])`, up to the array's opening bracket. */
|
|
408
|
+
const PROMISE_ALL = /\b(?:const|let|var)\s*\[([^=]*?)\]\s*=\s*await\s+Promise\.all\(\s*\[/g;
|
|
409
|
+
/** The comma-separated items of `text` at bracket depth 0, trimmed, up to the bracket that closes it. */
|
|
410
|
+
function topLevelItems(text) {
|
|
411
|
+
const items = [];
|
|
412
|
+
let depth = 0;
|
|
413
|
+
let from = 0;
|
|
414
|
+
for (let i = 0; i < text.length; i++) {
|
|
415
|
+
const c = text[i];
|
|
416
|
+
if ("([{".includes(c))
|
|
417
|
+
depth++;
|
|
418
|
+
else if (")]}".includes(c)) {
|
|
419
|
+
if (depth === 0)
|
|
420
|
+
return [...items, text.slice(from, i).trim()];
|
|
421
|
+
depth--;
|
|
422
|
+
}
|
|
423
|
+
else if (c === "," && depth === 0) {
|
|
424
|
+
items.push(text.slice(from, i).trim());
|
|
425
|
+
from = i + 1;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return [...items, text.slice(from).trim()];
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* The full message keys `text` names through a translator it binds
|
|
432
|
+
* (#11392): `t("key")`, `t.rich("key")`, … under the binding's namespace,
|
|
433
|
+
* `nav.backTo` for `tNav("backTo")` — bound alone, or by position out of an
|
|
434
|
+
* `await Promise.all([...])`. A key built at run time, a translator passed
|
|
435
|
+
* in from elsewhere, and a `t.has("key")` probe are not read.
|
|
436
|
+
*/
|
|
437
|
+
function messageKeysOf(text) {
|
|
438
|
+
const code = codeLines(text.split("\n")).join("\n");
|
|
439
|
+
const bindings = [];
|
|
440
|
+
for (const [, name, literal, option] of code.matchAll(TRANSLATOR))
|
|
441
|
+
bindings.push([name, literal ?? option ?? ""]);
|
|
442
|
+
for (const match of code.matchAll(PROMISE_ALL)) {
|
|
443
|
+
const names = topLevelItems(match[1]);
|
|
444
|
+
const calls = topLevelItems(code.slice(match.index + match[0].length));
|
|
445
|
+
names.forEach((name, i) => {
|
|
446
|
+
const call = new RegExp(`^${TRANSLATOR_CALL.source}$`).exec(calls[i] ?? "");
|
|
447
|
+
if (call !== null && /^[A-Za-z_$][\w$]*$/.test(name))
|
|
448
|
+
bindings.push([name, call[1] ?? call[2] ?? ""]);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
const keys = new Set();
|
|
452
|
+
for (const [name, namespace] of bindings) {
|
|
453
|
+
const call = new RegExp(`(?<![\\w$.])${name.replace(/\$/g, "\\$")}(?:\\.(?:rich|markup|raw))?\\(\\s*["'\`]([^"'\`$]+)["'\`]`, "g");
|
|
454
|
+
for (const [, key] of code.matchAll(call))
|
|
455
|
+
keys.add(namespace === "" ? key : `${namespace}.${key}`);
|
|
456
|
+
}
|
|
457
|
+
return [...keys];
|
|
458
|
+
}
|
|
459
|
+
/** Every dotted key path a messages catalog holds, objects' and values', or `undefined` when it is no JSON object. */
|
|
460
|
+
function catalogKeys(text) {
|
|
461
|
+
let doc;
|
|
462
|
+
try {
|
|
463
|
+
doc = JSON.parse(text);
|
|
464
|
+
}
|
|
465
|
+
catch {
|
|
466
|
+
return undefined;
|
|
467
|
+
}
|
|
468
|
+
if (!isPlainObject(doc))
|
|
469
|
+
return undefined;
|
|
470
|
+
const keys = new Set();
|
|
471
|
+
const walk = (node, at) => {
|
|
472
|
+
for (const [key, value] of Object.entries(node)) {
|
|
473
|
+
const path = at === "" ? key : `${at}.${key}`;
|
|
474
|
+
keys.add(path);
|
|
475
|
+
if (isPlainObject(value))
|
|
476
|
+
walk(value, path);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
walk(doc, "");
|
|
480
|
+
return keys;
|
|
481
|
+
}
|
|
346
482
|
const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
347
483
|
function isPlainObject(value) {
|
|
348
484
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -932,17 +1068,21 @@ const WEB_PACKAGE_JSON = "apps/web/package.json";
|
|
|
932
1068
|
* Frozen; a name joins only with a spec.
|
|
933
1069
|
*/
|
|
934
1070
|
const WEB_CARRIED_DEPENDENCIES = Object.freeze(["botid"]);
|
|
1071
|
+
/** Whether the site's `pkg` declares `name`, in `dependencies` or `devDependencies`, at any range. */
|
|
1072
|
+
function declares(pkg, name) {
|
|
1073
|
+
return Object.hasOwn(pkg.dependencies ?? {}, name) || Object.hasOwn(pkg.devDependencies ?? {}, name);
|
|
1074
|
+
}
|
|
935
1075
|
/**
|
|
936
|
-
* The site's `apps/web/package.json`
|
|
937
|
-
* template declares and the site does not
|
|
938
|
-
* `
|
|
939
|
-
*
|
|
940
|
-
*
|
|
1076
|
+
* The site's parsed `apps/web/package.json` and each carried dependency the
|
|
1077
|
+
* running template declares and the site does not, at the template's range
|
|
1078
|
+
* — `undefined` when there is no web app. Throws before any write when the
|
|
1079
|
+
* site's file is not valid JSON. The `@working-theory/*` packages the written
|
|
1080
|
+
* files import join `entries` once the writes are known (#11392).
|
|
941
1081
|
*/
|
|
942
1082
|
function planWebDependencies(targetDir, templatesDir) {
|
|
943
1083
|
const sitePath = join(targetDir, ...WEB_PACKAGE_JSON.split("/"));
|
|
944
1084
|
const templatePath = join(templatesDir, ...WEB_PACKAGE_JSON.split("/"));
|
|
945
|
-
if (!existsSync(sitePath)
|
|
1085
|
+
if (!existsSync(sitePath))
|
|
946
1086
|
return undefined;
|
|
947
1087
|
let pkg;
|
|
948
1088
|
try {
|
|
@@ -951,18 +1091,16 @@ function planWebDependencies(targetDir, templatesDir) {
|
|
|
951
1091
|
catch (err) {
|
|
952
1092
|
throw new UpdateRefusedError(`${WEB_PACKAGE_JSON} is not valid JSON: ${err.message}`);
|
|
953
1093
|
}
|
|
954
|
-
const templateDeps =
|
|
1094
|
+
const templateDeps = existsSync(templatePath)
|
|
1095
|
+
? (JSON.parse(readFileSync(templatePath, "utf8")).dependencies ?? {})
|
|
1096
|
+
: {};
|
|
955
1097
|
const entries = {};
|
|
956
1098
|
for (const name of WEB_CARRIED_DEPENDENCIES) {
|
|
957
1099
|
const range = templateDeps[name];
|
|
958
|
-
if (range
|
|
959
|
-
|
|
960
|
-
if (Object.hasOwn(pkg.dependencies ?? {}, name) || Object.hasOwn(pkg.devDependencies ?? {}, name)) {
|
|
961
|
-
continue;
|
|
962
|
-
}
|
|
963
|
-
entries[name] = range;
|
|
1100
|
+
if (range !== undefined && !declares(pkg, name))
|
|
1101
|
+
entries[name] = range;
|
|
964
1102
|
}
|
|
965
|
-
return
|
|
1103
|
+
return { pkg, entries };
|
|
966
1104
|
}
|
|
967
1105
|
export async function updateSite(opts) {
|
|
968
1106
|
const targetDir = resolve(opts.targetDir);
|
|
@@ -1057,19 +1195,21 @@ export async function updateSite(opts) {
|
|
|
1057
1195
|
}
|
|
1058
1196
|
}
|
|
1059
1197
|
const spokeExclusionList = spoke !== undefined ? spokeExclusions(opts.templatesDir, spoke) : undefined;
|
|
1060
|
-
// #8748 D3 — the standard spoke checkout is a commerce spoke's alone.
|
|
1061
|
-
const sellsAsSpoke = spoke !== undefined && header.modules.includes("commerce");
|
|
1062
1198
|
// #9569 DD8 — a `database/` that is still a package (the pre-thin copy) is
|
|
1063
1199
|
// never touched: its boot paths are out of scope, reported under the guard.
|
|
1064
1200
|
const databaseIsPackage = existsSync(join(targetDir, "database", "package.json"));
|
|
1065
1201
|
const bootFileGuarded = (destRel) => databaseIsPackage && DATABASE_BOOT_FILES.includes(destRel);
|
|
1202
|
+
// #11260 — the routes the site declined: nothing under one is written.
|
|
1203
|
+
const declinedRoutes = readDeclinedRoutes(targetDir);
|
|
1204
|
+
const declinedReason = (destRel) => {
|
|
1205
|
+
const route = declinedRouteOfPath(destRel, declinedRoutes);
|
|
1206
|
+
return route === undefined ? undefined : `under ${route}, declined by this site (customizations.yaml)`;
|
|
1207
|
+
};
|
|
1066
1208
|
const outOfScope = (destRel, excluded = excludedRoutes) => {
|
|
1067
1209
|
if (bootFileGuarded(destRel))
|
|
1068
1210
|
return true;
|
|
1069
1211
|
if (isExcluded(destRel, excluded))
|
|
1070
1212
|
return true;
|
|
1071
|
-
if (!sellsAsSpoke && isExcluded(destRel, SPOKE_CHECKOUT_TEMPLATE_PATHS))
|
|
1072
|
-
return true;
|
|
1073
1213
|
if (spoke !== undefined && spokeExclusionList !== undefined) {
|
|
1074
1214
|
return isSpokeExcluded(destRel, { ...spoke, exclusions: spokeExclusionList });
|
|
1075
1215
|
}
|
|
@@ -1208,7 +1348,7 @@ export async function updateSite(opts) {
|
|
|
1208
1348
|
: undefined;
|
|
1209
1349
|
// ── The web app's carried dependencies (#9889 D9), planned before the
|
|
1210
1350
|
// first write so an unparseable apps/web/package.json refuses the run.
|
|
1211
|
-
const
|
|
1351
|
+
const webDependencies = planWebDependencies(targetDir, opts.templatesDir);
|
|
1212
1352
|
// ── Every recorded row (D4) ────────────────────────────────────────────
|
|
1213
1353
|
const updated = [];
|
|
1214
1354
|
const merged = [];
|
|
@@ -1224,6 +1364,8 @@ export async function updateSite(opts) {
|
|
|
1224
1364
|
// comment-only edit, or a site edit with its hunk summary (the cascade's).
|
|
1225
1365
|
const staleCopies = [];
|
|
1226
1366
|
const commentOnlyEdits = [];
|
|
1367
|
+
// #11213 — the unrecorded files adopted, with the version each matched.
|
|
1368
|
+
const adopted = [];
|
|
1227
1369
|
const siteEdits = new Map();
|
|
1228
1370
|
const nextFiles = { ...record.files };
|
|
1229
1371
|
const writes = [];
|
|
@@ -1237,6 +1379,11 @@ export async function updateSite(opts) {
|
|
|
1237
1379
|
});
|
|
1238
1380
|
continue;
|
|
1239
1381
|
}
|
|
1382
|
+
const declinedRow = declinedReason(path);
|
|
1383
|
+
if (declinedRow !== undefined) {
|
|
1384
|
+
skipped.push({ path, reason: declinedRow });
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1240
1387
|
const abs = join(targetDir, ...path.split("/"));
|
|
1241
1388
|
if (!existsSync(abs)) {
|
|
1242
1389
|
if (newMap.get(path) === undefined) {
|
|
@@ -1294,6 +1441,34 @@ export async function updateSite(opts) {
|
|
|
1294
1441
|
const newHash = sha256Hex(newBytes);
|
|
1295
1442
|
if (newHash === rec.sha256)
|
|
1296
1443
|
continue; // template unchanged for this file
|
|
1444
|
+
/**
|
|
1445
|
+
* #10173 — a messages catalog takes the template's new keys and keeps
|
|
1446
|
+
* every value the site has; only a key-level conflict is reviewed.
|
|
1447
|
+
* #11392 — it needs no base, so a catalog the three-way merge cannot
|
|
1448
|
+
* land, for any reason, takes it too; any other file is reviewed.
|
|
1449
|
+
*/
|
|
1450
|
+
const additiveOrReview = (reason) => {
|
|
1451
|
+
if (!MESSAGES_JSON.test(path)) {
|
|
1452
|
+
review.push({ path, reason });
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
const additive = mergeMessagesAdditively(diskBytes.toString("utf8"), Buffer.from(newBytes).toString("utf8"));
|
|
1456
|
+
if (additive.status === "conflict") {
|
|
1457
|
+
review.push({
|
|
1458
|
+
path,
|
|
1459
|
+
reason: `conflicts with the template change ${rec.version} → ${version} at key ${additive.keys.join(", ")}`,
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
else if (additive.status === "invalid") {
|
|
1463
|
+
review.push({ path, reason: `the additive pass could not run: ${additive.reason}` });
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
if (additive.added > 0)
|
|
1467
|
+
writes.push({ path, bytes: Buffer.from(additive.text, "utf8") });
|
|
1468
|
+
nextFiles[path] = { sha256: newHash, version };
|
|
1469
|
+
merged.push(path);
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1297
1472
|
if (diskHash === newHash) {
|
|
1298
1473
|
nextFiles[path] = { sha256: newHash, version };
|
|
1299
1474
|
current.push(path);
|
|
@@ -1312,25 +1487,16 @@ export async function updateSite(opts) {
|
|
|
1312
1487
|
// Template changed, and the edit does not already match it: three-way merge.
|
|
1313
1488
|
const base = await loadVersionMap(rec.version);
|
|
1314
1489
|
if ("error" in base) {
|
|
1315
|
-
|
|
1316
|
-
path,
|
|
1317
|
-
reason: `edited here, and the ${rec.version} template could not be read: ${base.error}`,
|
|
1318
|
-
});
|
|
1490
|
+
additiveOrReview(`edited here, and the ${rec.version} template could not be read: ${base.error}`);
|
|
1319
1491
|
continue;
|
|
1320
1492
|
}
|
|
1321
1493
|
const baseBytes = base.get(path);
|
|
1322
1494
|
if (baseBytes === undefined) {
|
|
1323
|
-
|
|
1324
|
-
path,
|
|
1325
|
-
reason: `edited here, and the ${rec.version} template could not be read: not present in that version's snapshot`,
|
|
1326
|
-
});
|
|
1495
|
+
additiveOrReview(`edited here, and the ${rec.version} template could not be read: not present in that version's snapshot`);
|
|
1327
1496
|
continue;
|
|
1328
1497
|
}
|
|
1329
1498
|
if (sha256Hex(baseBytes) !== rec.sha256) {
|
|
1330
|
-
|
|
1331
|
-
path,
|
|
1332
|
-
reason: `edited here, and the ${rec.version} template copy does not match the record`,
|
|
1333
|
-
});
|
|
1499
|
+
additiveOrReview(`edited here, and the ${rec.version} template copy does not match the record`);
|
|
1334
1500
|
continue;
|
|
1335
1501
|
}
|
|
1336
1502
|
if (!isTextFile(path)) {
|
|
@@ -1365,26 +1531,6 @@ export async function updateSite(opts) {
|
|
|
1365
1531
|
nextFiles[path] = { sha256: newHash, version };
|
|
1366
1532
|
merged.push(path);
|
|
1367
1533
|
}
|
|
1368
|
-
else if (mergeResult.status === "conflict" && MESSAGES_JSON.test(path)) {
|
|
1369
|
-
// #10173 — a messages catalog takes the template's new keys and keeps
|
|
1370
|
-
// every value the site has; only a key-level conflict is reviewed.
|
|
1371
|
-
const additive = mergeMessagesAdditively(diskBytes.toString("utf8"), Buffer.from(newBytes).toString("utf8"));
|
|
1372
|
-
if (additive.status === "conflict") {
|
|
1373
|
-
review.push({
|
|
1374
|
-
path,
|
|
1375
|
-
reason: `conflicts with the template change ${rec.version} → ${version} at key ${additive.keys.join(", ")}`,
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
else if (additive.status === "invalid") {
|
|
1379
|
-
review.push({ path, reason: `the additive pass could not run: ${additive.reason}` });
|
|
1380
|
-
}
|
|
1381
|
-
else {
|
|
1382
|
-
if (additive.added > 0)
|
|
1383
|
-
writes.push({ path, bytes: Buffer.from(additive.text, "utf8") });
|
|
1384
|
-
nextFiles[path] = { sha256: newHash, version };
|
|
1385
|
-
merged.push(path);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
1534
|
else if (mergeResult.status === "conflict" && edit.commentOnly) {
|
|
1389
1535
|
// #11147 — the site touched only comment lines, on the lines the
|
|
1390
1536
|
// template changed: the template's copy lands, reported as such.
|
|
@@ -1393,13 +1539,10 @@ export async function updateSite(opts) {
|
|
|
1393
1539
|
updated.push(path);
|
|
1394
1540
|
}
|
|
1395
1541
|
else if (mergeResult.status === "conflict") {
|
|
1396
|
-
|
|
1397
|
-
path,
|
|
1398
|
-
reason: `conflicts with the template change ${rec.version} → ${version}`,
|
|
1399
|
-
});
|
|
1542
|
+
additiveOrReview(`conflicts with the template change ${rec.version} → ${version}`);
|
|
1400
1543
|
}
|
|
1401
1544
|
else {
|
|
1402
|
-
|
|
1545
|
+
additiveOrReview(`the three-way merge could not run: ${mergeResult.reason}`);
|
|
1403
1546
|
}
|
|
1404
1547
|
}
|
|
1405
1548
|
// ── Every recordable path the running template has that this record does not (D4) ──
|
|
@@ -1418,6 +1561,11 @@ export async function updateSite(opts) {
|
|
|
1418
1561
|
skipped.push({ path, reason: "marketing removed" });
|
|
1419
1562
|
continue;
|
|
1420
1563
|
}
|
|
1564
|
+
const declinedNew = declinedReason(path);
|
|
1565
|
+
if (declinedNew !== undefined) {
|
|
1566
|
+
skipped.push({ path, reason: declinedNew });
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1421
1569
|
// The guard runs before the disk check, so a full-copy site's boot path
|
|
1422
1570
|
// reads as guarded, never as "exists, not in the record" (#9569 DD8).
|
|
1423
1571
|
if (bootFileGuarded(path)) {
|
|
@@ -1426,26 +1574,39 @@ export async function updateSite(opts) {
|
|
|
1426
1574
|
}
|
|
1427
1575
|
const abs = join(targetDir, ...path.split("/"));
|
|
1428
1576
|
const newBytes = newMap.get(path);
|
|
1429
|
-
|
|
1430
|
-
|
|
1577
|
+
const present = existsSync(abs) && !retired.has(path);
|
|
1578
|
+
if (outOfScope(path, addExcludedRoutes)) {
|
|
1579
|
+
// rule i/ii — never written here, so a copy on disk is left unscanned.
|
|
1580
|
+
if (present)
|
|
1581
|
+
skipped.push({ path, reason: "exists, not in the record; outside this site's scope" });
|
|
1582
|
+
continue;
|
|
1583
|
+
}
|
|
1584
|
+
if (present) {
|
|
1585
|
+
// #11213 — an unrecorded file whose bytes are a published template
|
|
1586
|
+
// copy (the running version's, or any version's in the record's
|
|
1587
|
+
// range) is adopted: recorded, and moved forward as an untouched file
|
|
1588
|
+
// is, named with the version it matched — the boot files (#9569 DD8)
|
|
1589
|
+
// and root tools/ files (#9654) among them. One matching no copy is
|
|
1590
|
+
// the site's own: held, never overwritten.
|
|
1591
|
+
const diskHash = sha256Hex(readFileSync(abs));
|
|
1431
1592
|
const newHash = sha256Hex(newBytes);
|
|
1432
|
-
if (
|
|
1433
|
-
skipped.push({ path, reason: "exists, not in the record" });
|
|
1434
|
-
}
|
|
1435
|
-
else if (DATABASE_BOOT_FILES.includes(path) || ROOT_TOOL_FILES.includes(path)) {
|
|
1436
|
-
// Adoption (#9569 DD8): a thin site converted by hand, or scaffolded
|
|
1437
|
-
// before the boot files were recorded, gains the row for a copy that
|
|
1438
|
-
// already equals the running template's — and so (#9654) does a root
|
|
1439
|
-
// tools/ file a site scaffolded before tools/ was recorded, or copied
|
|
1440
|
-
// by hand. App paths keep today's behaviour: an unrecorded, identical
|
|
1441
|
-
// copy stays unrecorded.
|
|
1593
|
+
if (diskHash === newHash) {
|
|
1442
1594
|
nextFiles[path] = { sha256: newHash, version };
|
|
1443
1595
|
current.push(path);
|
|
1596
|
+
adopted.push({ path, version });
|
|
1597
|
+
continue;
|
|
1444
1598
|
}
|
|
1599
|
+
const stale = await staleCopyOf(path, diskHash);
|
|
1600
|
+
if (stale !== undefined) {
|
|
1601
|
+
writes.push({ path, bytes: Buffer.from(newBytes) });
|
|
1602
|
+
nextFiles[path] = { sha256: newHash, version };
|
|
1603
|
+
updated.push(path);
|
|
1604
|
+
adopted.push({ path, version: stale });
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
skipped.push({ path, reason: UNRECORDED_SITE_EDIT });
|
|
1445
1608
|
continue;
|
|
1446
1609
|
}
|
|
1447
|
-
if (outOfScope(path, addExcludedRoutes))
|
|
1448
|
-
continue; // rule i/ii
|
|
1449
1610
|
// #10774 D3 — a surface this run declares was never copied, so its
|
|
1450
1611
|
// missing directory is no owner's deletion: rule iii does not apply.
|
|
1451
1612
|
const highest = isExcluded(path, declaredRouteDirs) ? undefined : highestMissingAncestor(path, targetDir);
|
|
@@ -1470,9 +1631,15 @@ export async function updateSite(opts) {
|
|
|
1470
1631
|
// new, is not added), so the written tree never imports an export the held
|
|
1471
1632
|
// file lacks. A written file whose relative import names a file the site
|
|
1472
1633
|
// will not have once the run lands is held too, under that missing path.
|
|
1473
|
-
// Only the bytes being written are read for a
|
|
1474
|
-
// own copy already compiles against what it has.
|
|
1475
|
-
|
|
1634
|
+
// Only the bytes being written are read for that check, a test's too: the
|
|
1635
|
+
// site's own copy already compiles against what it has.
|
|
1636
|
+
//
|
|
1637
|
+
// #11216 — a skipped file is inert: the run has decided not to manage it,
|
|
1638
|
+
// so only a file under review, and what is held with it, holds. Its
|
|
1639
|
+
// exports are still read by the named-import checks below, as any file
|
|
1640
|
+
// staying at the site's version. A missing import the template supplies
|
|
1641
|
+
// is no holder either — the file is added with its importer (below).
|
|
1642
|
+
const heldFiles = new Set(review.map((row) => row.path));
|
|
1476
1643
|
// The files left alone outright, before any hold-back joins them.
|
|
1477
1644
|
const leftAlone = new Set(heldFiles);
|
|
1478
1645
|
const writtenBytes = new Map(writes.map((w) => [w.path, w.bytes]));
|
|
@@ -1485,6 +1652,13 @@ export async function updateSite(opts) {
|
|
|
1485
1652
|
// export the held copy lacks (below). Only a test, or a file the site
|
|
1486
1653
|
// itself edited, is held with what it imports.
|
|
1487
1654
|
const heldImportsByFile = new Map();
|
|
1655
|
+
// #11216 — per missing import the template does not supply, the importers
|
|
1656
|
+
// that moved anyway; and the dependencies the template supplied, added.
|
|
1657
|
+
const missingImportsByFile = new Map();
|
|
1658
|
+
const dependenciesAdded = new Set();
|
|
1659
|
+
// #11234 — per lib file written from the template, the moving tests whose
|
|
1660
|
+
// import chain reaches it.
|
|
1661
|
+
const testLibsByFile = new Map();
|
|
1488
1662
|
const heldPaths = new Set();
|
|
1489
1663
|
const moving = [...new Set([...updated, ...merged, ...added, ...removed, ...current])].sort();
|
|
1490
1664
|
const isFileCache = new Map();
|
|
@@ -1501,11 +1675,26 @@ export async function updateSite(opts) {
|
|
|
1501
1675
|
}
|
|
1502
1676
|
return hit;
|
|
1503
1677
|
};
|
|
1678
|
+
// #11394 — the regenerated files (REGENERATED_APP_PATHS) whose bytes this
|
|
1679
|
+
// run writes after the record's writes: a written file's import of one is
|
|
1680
|
+
// read against that render, never the site's stale copy on disk. The
|
|
1681
|
+
// registry written later reads apps/web/package.json as this run leaves it;
|
|
1682
|
+
// its exports are every row's loader whatever is present, so the names
|
|
1683
|
+
// read here are the names it writes.
|
|
1684
|
+
const renders = new Map();
|
|
1685
|
+
const paidSectionsRender = renderSitePaidSections(targetDir);
|
|
1686
|
+
if (paidSectionsRender !== undefined)
|
|
1687
|
+
renders.set(PAID_SECTIONS_PATH, paidSectionsRender);
|
|
1688
|
+
const listingRaw = runningRaw.get(SITE_LISTING_PATH);
|
|
1689
|
+
if (listingRaw !== undefined && !existsSync(join(targetDir, ...SITE_LISTING_PATH.split("/")))) {
|
|
1690
|
+
renders.set(SITE_LISTING_PATH, Buffer.from(renderTemplateFile(listingRaw, SITE_LISTING_PATH, {}, markersForVersion(record.projectName, version))).toString("utf8"));
|
|
1691
|
+
}
|
|
1504
1692
|
// What the run rewrites after the record's writes, never from the template.
|
|
1505
1693
|
const rewrittenLater = new Set([
|
|
1506
1694
|
MODULE_FLAGS_PATH,
|
|
1507
1695
|
PAID_MCP_TOOLS_PATH,
|
|
1508
1696
|
...(mcpMove?.seam !== undefined ? [MCP_SEAM_PATH] : []),
|
|
1697
|
+
...renders.keys(),
|
|
1509
1698
|
]);
|
|
1510
1699
|
/** Whether `path` is a file once this run's writes and deletes, less the held ones, land. */
|
|
1511
1700
|
const presentAfter = (path) => {
|
|
@@ -1585,8 +1774,134 @@ export async function updateSite(opts) {
|
|
|
1585
1774
|
heldFiles.add(path);
|
|
1586
1775
|
grew = true;
|
|
1587
1776
|
};
|
|
1777
|
+
/**
|
|
1778
|
+
* Writes the template's copy of `path` (#11216): recorded, and read for its
|
|
1779
|
+
* own imports on the next pass. Added when the site lacks it; updated when
|
|
1780
|
+
* a test's lib dependency replaces the site's copy (#11234).
|
|
1781
|
+
*/
|
|
1782
|
+
const writeDependency = (path, raw) => {
|
|
1783
|
+
const bytes = Buffer.from(raw);
|
|
1784
|
+
const text = bytes.toString("utf8");
|
|
1785
|
+
writes.push({ path, bytes });
|
|
1786
|
+
writtenBytes.set(path, bytes);
|
|
1787
|
+
nextFiles[path] = { sha256: sha256Hex(bytes), version };
|
|
1788
|
+
if (isFileOnDisk(path))
|
|
1789
|
+
updated.push(path);
|
|
1790
|
+
else {
|
|
1791
|
+
added.push(path);
|
|
1792
|
+
adding.add(path);
|
|
1793
|
+
}
|
|
1794
|
+
dependenciesAdded.add(path);
|
|
1795
|
+
moving.push(path);
|
|
1796
|
+
sourcesOf.set(path, { all: [text], written: text });
|
|
1797
|
+
grew = true;
|
|
1798
|
+
};
|
|
1799
|
+
/**
|
|
1800
|
+
* #11234 — the lib files a moving test's import chain reaches, from the
|
|
1801
|
+
* test's bytes as this run leaves them and through each file on the way
|
|
1802
|
+
* as it leaves that: `write` when the template supplies a copy the site
|
|
1803
|
+
* lacks or differs from, `missing` when neither has one and this run's
|
|
1804
|
+
* write introduces the import, `named` when neither has one but the
|
|
1805
|
+
* importer's own copy already named it (#11216: the test moves, and the
|
|
1806
|
+
* path is reported). A lib under a hold stays as #8704 leaves it; a
|
|
1807
|
+
* regenerated lib (`isRecordable` false) is the run's own to write, never
|
|
1808
|
+
* a dependency; a copy on disk outside this site's scope is left as the
|
|
1809
|
+
* site keeps it; a recorded copy the site edited is the site's (#11238).
|
|
1810
|
+
*/
|
|
1811
|
+
const testLibsOf = (test, source) => {
|
|
1812
|
+
const write = new Set();
|
|
1813
|
+
const missing = new Set();
|
|
1814
|
+
const named = new Set();
|
|
1815
|
+
const seen = new Set([test]);
|
|
1816
|
+
const queue = [[test, source]];
|
|
1817
|
+
for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
|
|
1818
|
+
const [from, text] = next;
|
|
1819
|
+
for (const specifier of localSpecifiers(from, text)) {
|
|
1820
|
+
const candidates = relativeImportCandidates(from, specifier);
|
|
1821
|
+
const lib = LIB_FILE.test(candidates[0]) && candidates.every(isRecordable);
|
|
1822
|
+
const target = candidates.find((c) => (writtenBytes.has(c) && !heldPaths.has(c)) || isFileOnDisk(c));
|
|
1823
|
+
if (target === undefined) {
|
|
1824
|
+
if (!lib)
|
|
1825
|
+
continue;
|
|
1826
|
+
const supplied = candidates.find((c) => newMap.get(c) !== undefined && !heldPaths.has(c));
|
|
1827
|
+
if (supplied !== undefined)
|
|
1828
|
+
write.add(supplied);
|
|
1829
|
+
else if (candidates.some((c) => importCandidatesOf(from).has(c)))
|
|
1830
|
+
named.add(candidates[0]);
|
|
1831
|
+
else
|
|
1832
|
+
missing.add(candidates[0]);
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
if (!SOURCE_FILE.test(target) || rewrittenLater.has(target) || seen.has(target))
|
|
1836
|
+
continue;
|
|
1837
|
+
seen.add(target);
|
|
1838
|
+
const written = !heldPaths.has(target) ? writtenBytes.get(target) : undefined;
|
|
1839
|
+
const onDisk = written === undefined ? diskText(target) : undefined;
|
|
1840
|
+
const through = written?.toString("utf8") ?? onDisk;
|
|
1841
|
+
if (through !== undefined)
|
|
1842
|
+
queue.push([target, through]);
|
|
1843
|
+
if (!lib || written !== undefined || onDisk === undefined)
|
|
1844
|
+
continue;
|
|
1845
|
+
if (heldFiles.has(target) || outOfScope(target, addExcludedRoutes))
|
|
1846
|
+
continue;
|
|
1847
|
+
// #11238 — a recorded lib whose bytes differ from its row is the
|
|
1848
|
+
// site's own edit: never written, never listed; the test moves and
|
|
1849
|
+
// its import resolves to the site's copy.
|
|
1850
|
+
const diskHash = sha256Hex(Buffer.from(onDisk));
|
|
1851
|
+
const recorded = record.files[target];
|
|
1852
|
+
if (recorded !== undefined && recorded.sha256 !== diskHash)
|
|
1853
|
+
continue;
|
|
1854
|
+
const template = newMap.get(target);
|
|
1855
|
+
if (template !== undefined && sha256Hex(template) !== diskHash)
|
|
1856
|
+
write.add(target);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
return { write: [...write], missing: [...missing], named: [...named] };
|
|
1860
|
+
};
|
|
1861
|
+
// #11392 — the messages catalogs the running template has: a written web
|
|
1862
|
+
// file that uses one of a catalog's template keys the site's copy will
|
|
1863
|
+
// lack once this run lands is held with that catalog.
|
|
1864
|
+
const catalogs = [...newMap.keys()].filter((path) => MESSAGES_JSON.test(path)).sort();
|
|
1865
|
+
const templateCatalogKeys = new Map(catalogs.map((path) => [path, catalogKeys(Buffer.from(newMap.get(path)).toString("utf8")) ?? new Set()]));
|
|
1866
|
+
/** Per catalog the site will have, the template's keys it will lack. */
|
|
1867
|
+
const keysLackedByCatalog = () => {
|
|
1868
|
+
const out = new Map();
|
|
1869
|
+
for (const catalog of catalogs) {
|
|
1870
|
+
const writing = heldPaths.has(catalog) ? undefined : writtenBytes.get(catalog)?.toString("utf8");
|
|
1871
|
+
const after = writing ?? diskText(catalog);
|
|
1872
|
+
const siteKeys = after === undefined ? undefined : catalogKeys(after);
|
|
1873
|
+
if (siteKeys === undefined)
|
|
1874
|
+
continue;
|
|
1875
|
+
const lacked = new Set([...templateCatalogKeys.get(catalog)].filter((key) => !siteKeys.has(key)));
|
|
1876
|
+
if (lacked.size > 0)
|
|
1877
|
+
out.set(catalog, lacked);
|
|
1878
|
+
}
|
|
1879
|
+
return out;
|
|
1880
|
+
};
|
|
1588
1881
|
while (grew) {
|
|
1589
1882
|
grew = false;
|
|
1883
|
+
const keysLacked = keysLackedByCatalog();
|
|
1884
|
+
// #11394 — a render names what it imports too: one naming an export the
|
|
1885
|
+
// file it imports will lack once this run lands (a held contracts copy)
|
|
1886
|
+
// is not written, and its importers read the site's copy from then on.
|
|
1887
|
+
for (const [path, render] of renders) {
|
|
1888
|
+
for (const { specifier, names } of namedImportsOf(render)) {
|
|
1889
|
+
if (!isLocal(path, specifier))
|
|
1890
|
+
continue;
|
|
1891
|
+
const target = relativeImportCandidates(path, specifier).find((c) => (writtenBytes.has(c) && !heldPaths.has(c)) || isFileOnDisk(c));
|
|
1892
|
+
if (target === undefined || !SOURCE_FILE.test(target))
|
|
1893
|
+
continue;
|
|
1894
|
+
const text = !heldPaths.has(target) ? writtenBytes.get(target)?.toString("utf8") : undefined;
|
|
1895
|
+
const after = text ?? diskText(target);
|
|
1896
|
+
if (after === undefined || names.every((name) => exportsName(after, name)))
|
|
1897
|
+
continue;
|
|
1898
|
+
renders.delete(path);
|
|
1899
|
+
rewrittenLater.delete(path);
|
|
1900
|
+
hold(path, target, false);
|
|
1901
|
+
grew = true;
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1590
1905
|
// #11147 — a removal a still-present file imports — the site's own
|
|
1591
1906
|
// code, a file left alone, or a file held with one — is held with that
|
|
1592
1907
|
// importer, so the run never removes what the tree still imports. The
|
|
@@ -1618,7 +1933,32 @@ export async function updateSite(opts) {
|
|
|
1618
1933
|
}
|
|
1619
1934
|
const imported = cascades ? importedHeld : new Set();
|
|
1620
1935
|
const missing = new Set();
|
|
1621
|
-
|
|
1936
|
+
// #11234 — a test's lib dependencies move with it, written or current:
|
|
1937
|
+
// the template's copy lands, named with the test; a lib neither the
|
|
1938
|
+
// site nor the template has holds the test when the write introduces
|
|
1939
|
+
// the import, and is reported when the site's copy already named it.
|
|
1940
|
+
// Read from the bytes the run leaves — never a removed test's, nor
|
|
1941
|
+
// the imports an old site copy named and the new one dropped.
|
|
1942
|
+
const leaving = written ?? newMap.get(path);
|
|
1943
|
+
if (TEST_FILE.test(path) && !deleting.has(path) && leaving !== undefined) {
|
|
1944
|
+
const libs = testLibsOf(path, Buffer.from(leaving).toString("utf8"));
|
|
1945
|
+
for (const file of libs.write) {
|
|
1946
|
+
const tests = testLibsByFile.get(file) ?? [];
|
|
1947
|
+
if (!tests.includes(path))
|
|
1948
|
+
tests.push(path);
|
|
1949
|
+
testLibsByFile.set(file, tests);
|
|
1950
|
+
writeDependency(file, newMap.get(file));
|
|
1951
|
+
}
|
|
1952
|
+
for (const file of libs.missing)
|
|
1953
|
+
missing.add(file);
|
|
1954
|
+
for (const file of libs.named) {
|
|
1955
|
+
const importers = missingImportsByFile.get(file) ?? [];
|
|
1956
|
+
if (!importers.includes(path))
|
|
1957
|
+
importers.push(path);
|
|
1958
|
+
missingImportsByFile.set(file, importers);
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
if (written !== undefined) {
|
|
1622
1962
|
for (const specifier of localSpecifiers(path, written)) {
|
|
1623
1963
|
const candidates = relativeImportCandidates(path, specifier);
|
|
1624
1964
|
if (candidates.some((c) => (heldFiles.has(c) ? isFileOnDisk(c) : presentAfter(c))))
|
|
@@ -1627,19 +1967,51 @@ export async function updateSite(opts) {
|
|
|
1627
1967
|
// generates, never a file update could have carried.
|
|
1628
1968
|
if (/(^|\/)\.[^./][^/]*\//.test(candidates[0]))
|
|
1629
1969
|
continue;
|
|
1970
|
+
// #11216 — the template supplies it: added, never a holder. A
|
|
1971
|
+
// dependency is a module the written code imports, never a page or
|
|
1972
|
+
// route file, so the rules that gate what a site SERVES (rule
|
|
1973
|
+
// i/ii, a dropped marketing tree, #10040 D10, an owner-deleted
|
|
1974
|
+
// directory, rule iii) do not hold it back — the hub's
|
|
1975
|
+
// `pricing-page.ts` needs `contact/contact-form-text.ts` whether
|
|
1976
|
+
// or not `/contact` serves. A guarded boot path (#9569 DD8) is a
|
|
1977
|
+
// file on disk the run must not touch, so it stays missing.
|
|
1978
|
+
const supplied = candidates.find((c) => newMap.get(c) !== undefined && !heldPaths.has(c) && !bootFileGuarded(c) && declinedReason(c) === undefined);
|
|
1979
|
+
if (supplied !== undefined) {
|
|
1980
|
+
writeDependency(supplied, newMap.get(supplied));
|
|
1981
|
+
continue;
|
|
1982
|
+
}
|
|
1983
|
+
// #11216 — the site's own copy already names it, and the template
|
|
1984
|
+
// has no copy (one it has was held): this write introduces no
|
|
1985
|
+
// import, so the importer moves and the path is named.
|
|
1986
|
+
if (candidates.every((c) => newMap.get(c) === undefined) &&
|
|
1987
|
+
candidates.some((c) => importCandidatesOf(path).has(c))) {
|
|
1988
|
+
const importers = missingImportsByFile.get(candidates[0]) ?? [];
|
|
1989
|
+
if (!importers.includes(path))
|
|
1990
|
+
importers.push(path);
|
|
1991
|
+
missingImportsByFile.set(candidates[0], importers);
|
|
1992
|
+
continue;
|
|
1993
|
+
}
|
|
1630
1994
|
missing.add(candidates[0]);
|
|
1631
1995
|
}
|
|
1632
1996
|
}
|
|
1633
1997
|
// A named import the file it resolves to — staying at the site's
|
|
1634
1998
|
// version, or held back (#11147) — does not export (a regenerated
|
|
1635
|
-
// nav-config, say).
|
|
1999
|
+
// nav-config, say). One this run renders is read from the render.
|
|
1636
2000
|
const lacking = new Set();
|
|
1637
2001
|
if (written !== undefined) {
|
|
1638
2002
|
for (const { specifier, names } of namedImportsOf(written)) {
|
|
1639
2003
|
if (!isLocal(path, specifier))
|
|
1640
2004
|
continue;
|
|
1641
|
-
const target = relativeImportCandidates(path, specifier).find(isFileOnDisk);
|
|
1642
|
-
if (target === undefined
|
|
2005
|
+
const target = relativeImportCandidates(path, specifier).find((c) => renders.has(c) || isFileOnDisk(c));
|
|
2006
|
+
if (target === undefined)
|
|
2007
|
+
continue;
|
|
2008
|
+
const render = renders.get(target);
|
|
2009
|
+
if (render !== undefined) {
|
|
2010
|
+
if (names.some((name) => !exportsName(render, name)))
|
|
2011
|
+
lacking.add(target);
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
if (rewrittenLater.has(target))
|
|
1643
2015
|
continue;
|
|
1644
2016
|
if (heldFiles.has(target) && cascades)
|
|
1645
2017
|
continue; // held with it above
|
|
@@ -1654,7 +2026,14 @@ export async function updateSite(opts) {
|
|
|
1654
2026
|
lacking.add(target);
|
|
1655
2027
|
}
|
|
1656
2028
|
}
|
|
1657
|
-
|
|
2029
|
+
const keyed = new Set();
|
|
2030
|
+
if (written !== undefined && keysLacked.size > 0 && path.startsWith(WEB_ROOT) && SOURCE_FILE.test(path)) {
|
|
2031
|
+
const keys = messageKeysOf(written);
|
|
2032
|
+
for (const [catalog, lacked] of keysLacked)
|
|
2033
|
+
if (keys.some((key) => lacked.has(key)))
|
|
2034
|
+
keyed.add(catalog);
|
|
2035
|
+
}
|
|
2036
|
+
if (imported.size === 0 && missing.size === 0 && lacking.size === 0 && keyed.size === 0)
|
|
1658
2037
|
continue;
|
|
1659
2038
|
holdPath(path);
|
|
1660
2039
|
for (const file of imported)
|
|
@@ -1663,6 +2042,8 @@ export async function updateSite(opts) {
|
|
|
1663
2042
|
hold(path, file, true);
|
|
1664
2043
|
for (const file of lacking)
|
|
1665
2044
|
hold(path, file, false);
|
|
2045
|
+
for (const file of keyed)
|
|
2046
|
+
hold(path, file, false);
|
|
1666
2047
|
}
|
|
1667
2048
|
// The reverse: a file staying at the site's version imports, by name,
|
|
1668
2049
|
// something the written copy of its target no longer exports.
|
|
@@ -1704,6 +2085,43 @@ export async function updateSite(opts) {
|
|
|
1704
2085
|
delete nextFiles[path];
|
|
1705
2086
|
}
|
|
1706
2087
|
const notHeld = (path) => !heldPaths.has(path);
|
|
2088
|
+
// #11392 — every @working-theory/* package a written web file imports that
|
|
2089
|
+
// the site declares nowhere joins apps/web/package.json at the running
|
|
2090
|
+
// release's version, never workspace:*: package.json is never recorded, so
|
|
2091
|
+
// without it the site updated onto that code would not build.
|
|
2092
|
+
if (webDependencies !== undefined) {
|
|
2093
|
+
for (const write of writes) {
|
|
2094
|
+
if (!notHeld(write.path) || !write.path.startsWith(WEB_ROOT) || !SOURCE_FILE.test(write.path))
|
|
2095
|
+
continue;
|
|
2096
|
+
for (const name of workingTheoryImportsOf(write.bytes.toString("utf8"))) {
|
|
2097
|
+
if (declares(webDependencies.pkg, name) || Object.hasOwn(webDependencies.entries, name))
|
|
2098
|
+
continue;
|
|
2099
|
+
const v = opts.versions?.[name];
|
|
2100
|
+
if (v === undefined) {
|
|
2101
|
+
throw new UpdateRefusedError(`${write.path} imports ${name}, which ${WEB_PACKAGE_JSON} does not declare, and this create-ailk's versions.json has no version for it`);
|
|
2102
|
+
}
|
|
2103
|
+
webDependencies.entries[name] = `^${v}`;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
const webPackageJson = webDependencies !== undefined && Object.keys(webDependencies.entries).length > 0
|
|
2108
|
+
? withDependencies(webDependencies.pkg, webDependencies.entries)
|
|
2109
|
+
: undefined;
|
|
2110
|
+
// #11216 — a dependency written this run is in the site after all.
|
|
2111
|
+
for (let i = skipped.length - 1; i >= 0; i--) {
|
|
2112
|
+
const path = skipped[i].path;
|
|
2113
|
+
if (dependenciesAdded.has(path) && notHeld(path))
|
|
2114
|
+
skipped.splice(i, 1);
|
|
2115
|
+
}
|
|
2116
|
+
const missingImports = [...missingImportsByFile.entries()]
|
|
2117
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
2118
|
+
.map(([file, importers]) => ({ file, importers: importers.filter(notHeld).sort() }))
|
|
2119
|
+
.filter((entry) => entry.importers.length > 0);
|
|
2120
|
+
const testLibs = [...testLibsByFile.entries()]
|
|
2121
|
+
.filter(([file]) => notHeld(file))
|
|
2122
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
2123
|
+
.map(([file, tests]) => ({ file, tests: tests.filter(notHeld).sort() }))
|
|
2124
|
+
.filter((entry) => entry.tests.length > 0);
|
|
1707
2125
|
const heldBack = [...heldBackByFile.entries()]
|
|
1708
2126
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
1709
2127
|
.map(([file, { tests, importers, missing }]) => ({
|
|
@@ -1745,7 +2163,7 @@ export async function updateSite(opts) {
|
|
|
1745
2163
|
const moved = {
|
|
1746
2164
|
updated: updated.filter(notHeld),
|
|
1747
2165
|
merged: merged.filter(notHeld),
|
|
1748
|
-
added: added.filter(notHeld),
|
|
2166
|
+
added: added.filter(notHeld).sort(),
|
|
1749
2167
|
removed: removed.filter(notHeld),
|
|
1750
2168
|
current: current.filter(notHeld),
|
|
1751
2169
|
};
|
|
@@ -1776,11 +2194,11 @@ export async function updateSite(opts) {
|
|
|
1776
2194
|
// #10940 D5 — the site's listing is site-owned (REGENERATED_APP_PATHS):
|
|
1777
2195
|
// written only when absent, so a site updated onto routes that import it
|
|
1778
2196
|
// builds; a present one is never read or written.
|
|
1779
|
-
const
|
|
1780
|
-
|
|
1781
|
-
|
|
2197
|
+
const listing = renders.get(SITE_LISTING_PATH);
|
|
2198
|
+
if (listing !== undefined) {
|
|
2199
|
+
const listingAbs = join(targetDir, ...SITE_LISTING_PATH.split("/"));
|
|
1782
2200
|
mkdirSync(dirname(listingAbs), { recursive: true });
|
|
1783
|
-
writeFileSync(listingAbs,
|
|
2201
|
+
writeFileSync(listingAbs, listing);
|
|
1784
2202
|
moved.added.push(SITE_LISTING_PATH);
|
|
1785
2203
|
}
|
|
1786
2204
|
// #9567 — the MCP move's writes, then the paid MCP tool registry from the
|
|
@@ -1816,6 +2234,15 @@ export async function updateSite(opts) {
|
|
|
1816
2234
|
writeFileSync(join(targetDir, ...WEB_PACKAGE_JSON.split("/")), webPackageJson);
|
|
1817
2235
|
moved.updated.push(WEB_PACKAGE_JSON);
|
|
1818
2236
|
}
|
|
2237
|
+
// #11394 — the paid-sections registry is generated, never copied
|
|
2238
|
+
// (REGENERATED_APP_PATHS): rendered on every run from apps/web/package.json
|
|
2239
|
+
// as this run leaves it, so the loaders a written file imports exist —
|
|
2240
|
+
// unless the contracts it names are held back with the site's copy.
|
|
2241
|
+
const sections = renders.has(PAID_SECTIONS_PATH) ? writePaidSectionsRegistry(targetDir) : undefined;
|
|
2242
|
+
if (sections === "added")
|
|
2243
|
+
moved.added.push(PAID_SECTIONS_PATH);
|
|
2244
|
+
else if (sections === "updated")
|
|
2245
|
+
moved.updated.push(PAID_SECTIONS_PATH);
|
|
1819
2246
|
// #10172 — the env vars the written files read get an env_contract row
|
|
1820
2247
|
// when the site's project.yaml has a block and no row for them, so the
|
|
1821
2248
|
// code update brings never fails `env:declared`. Rows are appended, never
|
|
@@ -1888,6 +2315,24 @@ export async function updateSite(opts) {
|
|
|
1888
2315
|
review.push({ path: sitePath(path), reason: `bare {…} not escaped: ${escape.reason}` });
|
|
1889
2316
|
}
|
|
1890
2317
|
}
|
|
2318
|
+
// #11219 (ADR 0040 rule 3) — the pins have moved, so every page package's
|
|
2319
|
+
// generated route files are rewritten from the installed manifests. Read
|
|
2320
|
+
// from `apps/web/node_modules`: before the install that follows a bump
|
|
2321
|
+
// there is nothing to read, and `routes --check` names what is stale. A refusal (a manifest the install does not carry,
|
|
2322
|
+
// no <package>.config.tsx) is a review row, never a failed run.
|
|
2323
|
+
let routesWritten = [];
|
|
2324
|
+
try {
|
|
2325
|
+
routesWritten = writeRoutes(targetDir).written;
|
|
2326
|
+
}
|
|
2327
|
+
catch (err) {
|
|
2328
|
+
if (!(err instanceof RoutesRefusedError))
|
|
2329
|
+
throw err;
|
|
2330
|
+
review.push({ path: "apps/web/app/[locale]", reason: `route files not regenerated: ${err.message}` });
|
|
2331
|
+
}
|
|
2332
|
+
// The scaffold's `routes:check` preflight step runs the create-ailk its
|
|
2333
|
+
// root devDependencies pin; the files above are this version's rendering,
|
|
2334
|
+
// so the pin follows — an older generator would call them stale.
|
|
2335
|
+
const cliPin = moveCliPin(targetDir, version);
|
|
1891
2336
|
return {
|
|
1892
2337
|
targetDir,
|
|
1893
2338
|
version,
|
|
@@ -1896,12 +2341,19 @@ export async function updateSite(opts) {
|
|
|
1896
2341
|
skipped,
|
|
1897
2342
|
heldBack,
|
|
1898
2343
|
...(heldImports.length > 0 ? { heldImports } : {}),
|
|
2344
|
+
...(missingImports.length > 0 ? { missingImports } : {}),
|
|
2345
|
+
...(testLibs.length > 0 ? { testLibs } : {}),
|
|
1899
2346
|
...(staleCopies.some((row) => notHeld(row.path))
|
|
1900
2347
|
? { staleCopies: staleCopies.filter((row) => notHeld(row.path)) }
|
|
1901
2348
|
: {}),
|
|
1902
2349
|
...(commentOnlyEdits.some(notHeld) ? { commentOnlyEdits: commentOnlyEdits.filter(notHeld) } : {}),
|
|
2350
|
+
...(adopted.some((row) => notHeld(row.path))
|
|
2351
|
+
? { adopted: adopted.filter((row) => notHeld(row.path)) }
|
|
2352
|
+
: {}),
|
|
1903
2353
|
headingsAdded: headings.written.map(sitePath),
|
|
1904
2354
|
bracesEscaped,
|
|
2355
|
+
...(routesWritten.length > 0 ? { routesWritten } : {}),
|
|
2356
|
+
...(cliPin !== undefined ? { cliPin } : {}),
|
|
1905
2357
|
...(backfilled !== undefined ? { backfilled } : {}),
|
|
1906
2358
|
...(envRowsAdded.length > 0 ? { envRowsAdded } : {}),
|
|
1907
2359
|
...(droppedRows.length > 0 ? { droppedRows: droppedRows.sort() } : {}),
|
|
@@ -1911,6 +2363,32 @@ export async function updateSite(opts) {
|
|
|
1911
2363
|
: {}),
|
|
1912
2364
|
};
|
|
1913
2365
|
}
|
|
2366
|
+
/**
|
|
2367
|
+
* The root `package.json` `devDependencies["create-ailk"]` pin (#11219),
|
|
2368
|
+
* rewritten in place to `version` when it names another; the file's other
|
|
2369
|
+
* bytes are left as the site keeps them. `undefined` when there is no pin or
|
|
2370
|
+
* it is already current.
|
|
2371
|
+
*/
|
|
2372
|
+
function moveCliPin(targetDir, version) {
|
|
2373
|
+
const pkgPath = join(targetDir, "package.json");
|
|
2374
|
+
if (!existsSync(pkgPath))
|
|
2375
|
+
return undefined;
|
|
2376
|
+
const text = readFileSync(pkgPath, "utf8");
|
|
2377
|
+
let from;
|
|
2378
|
+
try {
|
|
2379
|
+
from = JSON.parse(text).devDependencies?.["create-ailk"];
|
|
2380
|
+
}
|
|
2381
|
+
catch {
|
|
2382
|
+
return undefined;
|
|
2383
|
+
}
|
|
2384
|
+
if (typeof from !== "string" || from === version)
|
|
2385
|
+
return undefined;
|
|
2386
|
+
const pinned = text.replace(`"create-ailk": ${JSON.stringify(from)}`, `"create-ailk": ${JSON.stringify(version)}`);
|
|
2387
|
+
if (pinned === text)
|
|
2388
|
+
return undefined;
|
|
2389
|
+
writeFileSync(pkgPath, pinned);
|
|
2390
|
+
return { from, to: version };
|
|
2391
|
+
}
|
|
1914
2392
|
/** Whether a `node_modules` at or above `dir` holds `pkg` — so `resolve` never falls back to NODE_PATH. */
|
|
1915
2393
|
function installedAbove(dir, pkg) {
|
|
1916
2394
|
for (let at = dir;; at = dirname(at)) {
|
|
@@ -1957,18 +2435,33 @@ export function formatUpdateReport(result) {
|
|
|
1957
2435
|
["Already current", result.current],
|
|
1958
2436
|
["Page heading added", result.headingsAdded],
|
|
1959
2437
|
["Placeholder brace escaped", result.bracesEscaped],
|
|
2438
|
+
["Route files regenerated", result.routesWritten ?? []],
|
|
1960
2439
|
];
|
|
2440
|
+
if (result.cliPin !== undefined) {
|
|
2441
|
+
lines.push(`create-ailk pin moved: ${result.cliPin.from} → ${result.cliPin.to}`);
|
|
2442
|
+
}
|
|
1961
2443
|
// #11147 — why a moved file's bytes were not the site's.
|
|
1962
2444
|
const notes = new Map();
|
|
1963
2445
|
for (const { path, version } of result.staleCopies ?? [])
|
|
1964
2446
|
notes.set(path, `a stale copy of the ${version} template`);
|
|
1965
2447
|
for (const path of result.commentOnlyEdits ?? [])
|
|
1966
2448
|
notes.set(path, "comment-only edit");
|
|
2449
|
+
// #11234 — a lib written because a test's import chain reaches it.
|
|
2450
|
+
for (const { file, tests } of result.testLibs ?? [])
|
|
2451
|
+
notes.set(file, `moved with ${tests.join(", ")}`);
|
|
2452
|
+
// #11213 — an adopted file is listed once, under its own heading, with
|
|
2453
|
+
// the version it matched.
|
|
2454
|
+
const adoptedPaths = new Set((result.adopted ?? []).map((row) => row.path));
|
|
1967
2455
|
for (const [label, paths] of sections) {
|
|
1968
|
-
|
|
2456
|
+
const listed = paths.filter((path) => !adoptedPaths.has(path));
|
|
2457
|
+
if (listed.length === 0)
|
|
1969
2458
|
continue;
|
|
1970
|
-
lines.push(`${label} (${
|
|
1971
|
-
lines.push(...
|
|
2459
|
+
lines.push(`${label} (${listed.length}):`);
|
|
2460
|
+
lines.push(...listed.map((path) => (notes.has(path) ? ` ${path} — ${notes.get(path)}` : ` ${path}`)));
|
|
2461
|
+
}
|
|
2462
|
+
if (result.adopted !== undefined) {
|
|
2463
|
+
lines.push(`Adopted (${result.adopted.length}):`);
|
|
2464
|
+
lines.push(...result.adopted.map(({ path, version }) => ` ${path} — matched the ${version} template`));
|
|
1972
2465
|
}
|
|
1973
2466
|
if (result.review.length > 0) {
|
|
1974
2467
|
lines.push(`Needs review (${result.review.length}):`);
|
|
@@ -1984,6 +2477,11 @@ export function formatUpdateReport(result) {
|
|
|
1984
2477
|
lines.push(`Held back: ${file} — imported by ${count}; ${edit}`);
|
|
1985
2478
|
lines.push(...importers.map((path) => ` ${path}`));
|
|
1986
2479
|
}
|
|
2480
|
+
for (const { file, importers } of result.missingImports ?? []) {
|
|
2481
|
+
const count = `${importers.length} moved file${importers.length === 1 ? "" : "s"}`;
|
|
2482
|
+
lines.push(`Not in this site or the template: ${file} — imported by ${count}`);
|
|
2483
|
+
lines.push(...importers.map((path) => ` ${path}`));
|
|
2484
|
+
}
|
|
1987
2485
|
if (result.envRowsAdded !== undefined) {
|
|
1988
2486
|
lines.push(`project.yaml env_contract rows added (${result.envRowsAdded.length}):`);
|
|
1989
2487
|
lines.push(...result.envRowsAdded.map((name) => ` ${name}`));
|
|
@@ -2004,6 +2502,12 @@ export function formatUpdateReport(result) {
|
|
|
2004
2502
|
lines.push(`Skipped (${result.skipped.length}):`);
|
|
2005
2503
|
lines.push(...result.skipped.map((row) => ` ${row.path} — ${row.reason}`));
|
|
2006
2504
|
}
|
|
2505
|
+
// #11213 — how many unrecorded files the run left as the site's own,
|
|
2506
|
+
// whenever an unrecorded file was sorted either way.
|
|
2507
|
+
const siteEditsHeld = result.skipped.filter((row) => row.reason === UNRECORDED_SITE_EDIT).length;
|
|
2508
|
+
if (result.adopted !== undefined || siteEditsHeld > 0) {
|
|
2509
|
+
lines.push(`Held as site edits, not in the record: ${siteEditsHeld}`);
|
|
2510
|
+
}
|
|
2007
2511
|
const nothingHappened = result.backfilled === undefined &&
|
|
2008
2512
|
result.updated.length === 0 &&
|
|
2009
2513
|
result.merged.length === 0 &&
|
|
@@ -2012,8 +2516,11 @@ export function formatUpdateReport(result) {
|
|
|
2012
2516
|
result.current.length === 0 &&
|
|
2013
2517
|
result.headingsAdded.length === 0 &&
|
|
2014
2518
|
result.bracesEscaped.length === 0 &&
|
|
2519
|
+
result.routesWritten === undefined &&
|
|
2520
|
+
result.cliPin === undefined &&
|
|
2015
2521
|
result.review.length === 0 &&
|
|
2016
2522
|
result.skipped.length === 0 &&
|
|
2523
|
+
result.heldBack.length === 0 &&
|
|
2017
2524
|
result.envRowsAdded === undefined &&
|
|
2018
2525
|
result.droppedRows === undefined &&
|
|
2019
2526
|
result.surfacesDeclared === undefined &&
|
|
@@ -2049,22 +2556,39 @@ app jest configs require, whose template copy changed is overwritten. An
|
|
|
2049
2556
|
edited file whose template copy also changed is three-way merged with
|
|
2050
2557
|
\`git\` (git must be on PATH); a conflict leaves the file alone and is
|
|
2051
2558
|
listed under "Needs review"; an apps/web/messages catalog instead gains the
|
|
2052
|
-
template's new keys and keeps every value it has
|
|
2053
|
-
|
|
2559
|
+
template's new keys and keeps every value it has — also when its recorded
|
|
2560
|
+
version's copy cannot be read — and is reviewed only when a key is an object
|
|
2561
|
+
on one side and a value on the other; a written apps/web file that uses
|
|
2562
|
+
through t(...) a key the catalog then lacks is held with it, listed under
|
|
2563
|
+
"Held back with <catalog>". Each @working-theory/* package a written apps/web
|
|
2564
|
+
file imports that apps/web/package.json does not declare is added to its
|
|
2565
|
+
dependencies at this release's version. An edited file whose
|
|
2054
2566
|
bytes are another published create-ailk version's copy is a stale copy, not
|
|
2055
2567
|
an edit: it is overwritten or removed as an untouched file is, listed with
|
|
2056
2568
|
the version it matched. An edit that touches only comment lines is listed as
|
|
2057
|
-
"comment-only edit"; on a conflict the template's copy lands.
|
|
2569
|
+
"comment-only edit"; on a conflict the template's copy lands. A file at a
|
|
2570
|
+
template path that is not in the record (one an earlier sync-routes --apply
|
|
2571
|
+
or add-route copied without recording it) whose bytes are a published
|
|
2572
|
+
create-ailk version's copy — from the version the site was scaffolded at to
|
|
2573
|
+
this one — is adopted: recorded and moved forward as an untouched file is,
|
|
2574
|
+
listed under "Adopted" with the version it matched. One whose bytes match no
|
|
2575
|
+
published copy is a site edit: skipped, never overwritten, and counted under
|
|
2576
|
+
"Held as site edits, not in the record". No file under a route the site
|
|
2577
|
+
lists in customizations.yaml declined_routes is written: each is listed under
|
|
2578
|
+
"Skipped" naming the declined route. Every template
|
|
2058
2579
|
test, and every site-edited template file, that imports a file left under
|
|
2059
|
-
"Needs review"
|
|
2580
|
+
"Needs review" (by a relative or @/ import, transitively) is held
|
|
2060
2581
|
at the site's version with it, its record entry is not advanced, and it is
|
|
2061
2582
|
listed under "Held back with <file>" — reconcile the file, then run update
|
|
2062
|
-
again to bring it forward. A file
|
|
2063
|
-
held by what it imports: it moves, unless
|
|
2064
|
-
lacks, and the held file is listed as
|
|
2065
|
-
moved files; the site edit is <hunk
|
|
2066
|
-
|
|
2067
|
-
|
|
2583
|
+
again to bring it forward. A skipped file never holds another. A file whose
|
|
2584
|
+
own bytes are the record's is not held by what it imports: it moves, unless
|
|
2585
|
+
it names an export the held copy lacks, and the held file is listed as
|
|
2586
|
+
"Held back: <file> — imported by N moved files; the site edit is <hunk
|
|
2587
|
+
summary>". A written file whose import names a file the site lacks gets it
|
|
2588
|
+
added when this template supplies it; otherwise it is held the same way,
|
|
2589
|
+
under "Held back with <file> (not in this site)", unless its own copy
|
|
2590
|
+
already named the file — then it moves and the path is listed under "Not in
|
|
2591
|
+
this site or the template: <file>". A file the template removed is kept
|
|
2068
2592
|
while any file still in the site imports it. Every other file in the run
|
|
2069
2593
|
still updates. When project.yaml has an env_contract block, each
|
|
2070
2594
|
env var the written files read that has no row gains one; no row is edited.
|
|
@@ -2092,7 +2616,11 @@ read, is listed under "Needs review". Each bare { on an mdx-body page is
|
|
|
2092
2616
|
escaped as \\{ when the site's own MDX parser then reads the page clean, listed
|
|
2093
2617
|
under "Placeholder brace escaped"; a page it cannot escape safely, or any page
|
|
2094
2618
|
with one while the site's dependencies are not installed, is listed under
|
|
2095
|
-
"Needs review".
|
|
2619
|
+
"Needs review". Last, the generated route files of every installed page
|
|
2620
|
+
package (one whose package.json declares "ailk": { "routes" }) are rewritten
|
|
2621
|
+
from its manifest, listed under "Route files regenerated"; run
|
|
2622
|
+
\`create-ailk routes --write\` after the install when the packages were not
|
|
2623
|
+
installed yet. Commit before running, and review the diff after.
|
|
2096
2624
|
`;
|
|
2097
2625
|
/** Parse the argv AFTER the `update` word. Strict `node:util` parseArgs, like `parseAdoptArgs`. */
|
|
2098
2626
|
export function parseUpdateArgs(argv) {
|