create-ailk 0.37.1 → 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 +129 -0
- 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 +2 -2
- package/dist/add-route.js +18 -11
- 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 +14 -1
- package/dist/sync-routes.js +86 -5
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- 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
|
@@ -68,6 +68,27 @@
|
|
|
68
68
|
* write introduces the import; a site copy already naming it moves, and the
|
|
69
69
|
* report names the path under "Not in this site or the template".
|
|
70
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
|
+
*
|
|
71
92
|
* Pure module: no `import.meta.url` — the CLI supplies `templatesDir`, the
|
|
72
93
|
* `adopt.ts` / `add-route.ts` split.
|
|
73
94
|
*/
|
|
@@ -79,6 +100,7 @@ import { parseArgs } from "node:util";
|
|
|
79
100
|
import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
|
|
80
101
|
import { headingViolations, mdxBodyPages, mdxBodyRule, migrateBodyHeadings } from "./body-heading.js";
|
|
81
102
|
import { buildScaffoldMarkers, isExcluded, isTextFile, renderTemplateFile, templateDestination } from "./copy.js";
|
|
103
|
+
import { declinedRouteOfPath, readDeclinedRoutes } from "./declined-routes.js";
|
|
82
104
|
import { deriveArchitecture } from "./derive-architecture.js";
|
|
83
105
|
import { EnvContractError, planEnvRows, readEnvContract, readManifestTopology, } from "./lib/declared-env.js";
|
|
84
106
|
import { ENV_CATALOG } from "./lib/env-catalog.js";
|
|
@@ -89,11 +111,11 @@ import { mergeThreeWay } from "./lib/merge-three-way.js";
|
|
|
89
111
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
90
112
|
import { escapeBareBraces, findBareBraces } from "./mdx-braces.js";
|
|
91
113
|
import { MODULE_SLICES } from "./module-architecture.js";
|
|
92
|
-
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";
|
|
93
115
|
import { ParseError } from "./parse-args.js";
|
|
116
|
+
import { RoutesRefusedError, writeRoutes } from "./routes.js";
|
|
94
117
|
import { SITE_LISTING_PATH } from "./site-listing-path.js";
|
|
95
118
|
import { SITE_ROSTER_PATH, planServedRoster, readRosterPageRoutes } from "./site-roster.js";
|
|
96
|
-
import { SPOKE_CHECKOUT_TEMPLATE_PATHS } from "./spoke-checkout.js";
|
|
97
119
|
import { GATEABLE_SURFACES, excludedRoutePaths, isRemovedPublicRoutePath, resolveSurfaces, surfacesNamedByRoutes, } from "./surfaces.js";
|
|
98
120
|
import { DATABASE_BOOT_FILES, ROOT_TOOL_FILES, TEMPLATE_RECORD_PATH, isRecordable, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
|
|
99
121
|
import { MCP_SEAM_PATH, MCP_SERVER_HUB, TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
|
|
@@ -303,6 +325,8 @@ function containsKnownPath(prefix, knownPaths) {
|
|
|
303
325
|
}
|
|
304
326
|
/** A template test file: a `*.test.*` / `*.spec.*` module, or anything under `__tests__/`. */
|
|
305
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)\//;
|
|
306
330
|
/** Module specifiers `import`/`export … from`, `import()`, `require()` and `jest.mock()` name. */
|
|
307
331
|
const IMPORT_SPECIFIER = /\bfrom\s*["']([^"']+)["']|\bimport\s*["']([^"']+)["']|\b(?:import|require|jest\.mock|jest\.requireActual)\s*\(\s*["']([^"']+)["']/g;
|
|
308
332
|
const WEB_ROOT = "apps/web/";
|
|
@@ -359,8 +383,102 @@ function importedHeldFiles(fromPath, text, held) {
|
|
|
359
383
|
}
|
|
360
384
|
return [...out];
|
|
361
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
|
+
}
|
|
362
397
|
/** The `apps/web/messages/` catalogs next-intl loads by locale, never by import. */
|
|
363
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
|
+
}
|
|
364
482
|
const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
365
483
|
function isPlainObject(value) {
|
|
366
484
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -950,17 +1068,21 @@ const WEB_PACKAGE_JSON = "apps/web/package.json";
|
|
|
950
1068
|
* Frozen; a name joins only with a spec.
|
|
951
1069
|
*/
|
|
952
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
|
+
}
|
|
953
1075
|
/**
|
|
954
|
-
* The site's `apps/web/package.json`
|
|
955
|
-
* template declares and the site does not
|
|
956
|
-
* `
|
|
957
|
-
*
|
|
958
|
-
*
|
|
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).
|
|
959
1081
|
*/
|
|
960
1082
|
function planWebDependencies(targetDir, templatesDir) {
|
|
961
1083
|
const sitePath = join(targetDir, ...WEB_PACKAGE_JSON.split("/"));
|
|
962
1084
|
const templatePath = join(templatesDir, ...WEB_PACKAGE_JSON.split("/"));
|
|
963
|
-
if (!existsSync(sitePath)
|
|
1085
|
+
if (!existsSync(sitePath))
|
|
964
1086
|
return undefined;
|
|
965
1087
|
let pkg;
|
|
966
1088
|
try {
|
|
@@ -969,18 +1091,16 @@ function planWebDependencies(targetDir, templatesDir) {
|
|
|
969
1091
|
catch (err) {
|
|
970
1092
|
throw new UpdateRefusedError(`${WEB_PACKAGE_JSON} is not valid JSON: ${err.message}`);
|
|
971
1093
|
}
|
|
972
|
-
const templateDeps =
|
|
1094
|
+
const templateDeps = existsSync(templatePath)
|
|
1095
|
+
? (JSON.parse(readFileSync(templatePath, "utf8")).dependencies ?? {})
|
|
1096
|
+
: {};
|
|
973
1097
|
const entries = {};
|
|
974
1098
|
for (const name of WEB_CARRIED_DEPENDENCIES) {
|
|
975
1099
|
const range = templateDeps[name];
|
|
976
|
-
if (range
|
|
977
|
-
|
|
978
|
-
if (Object.hasOwn(pkg.dependencies ?? {}, name) || Object.hasOwn(pkg.devDependencies ?? {}, name)) {
|
|
979
|
-
continue;
|
|
980
|
-
}
|
|
981
|
-
entries[name] = range;
|
|
1100
|
+
if (range !== undefined && !declares(pkg, name))
|
|
1101
|
+
entries[name] = range;
|
|
982
1102
|
}
|
|
983
|
-
return
|
|
1103
|
+
return { pkg, entries };
|
|
984
1104
|
}
|
|
985
1105
|
export async function updateSite(opts) {
|
|
986
1106
|
const targetDir = resolve(opts.targetDir);
|
|
@@ -1075,19 +1195,21 @@ export async function updateSite(opts) {
|
|
|
1075
1195
|
}
|
|
1076
1196
|
}
|
|
1077
1197
|
const spokeExclusionList = spoke !== undefined ? spokeExclusions(opts.templatesDir, spoke) : undefined;
|
|
1078
|
-
// #8748 D3 — the standard spoke checkout is a commerce spoke's alone.
|
|
1079
|
-
const sellsAsSpoke = spoke !== undefined && header.modules.includes("commerce");
|
|
1080
1198
|
// #9569 DD8 — a `database/` that is still a package (the pre-thin copy) is
|
|
1081
1199
|
// never touched: its boot paths are out of scope, reported under the guard.
|
|
1082
1200
|
const databaseIsPackage = existsSync(join(targetDir, "database", "package.json"));
|
|
1083
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
|
+
};
|
|
1084
1208
|
const outOfScope = (destRel, excluded = excludedRoutes) => {
|
|
1085
1209
|
if (bootFileGuarded(destRel))
|
|
1086
1210
|
return true;
|
|
1087
1211
|
if (isExcluded(destRel, excluded))
|
|
1088
1212
|
return true;
|
|
1089
|
-
if (!sellsAsSpoke && isExcluded(destRel, SPOKE_CHECKOUT_TEMPLATE_PATHS))
|
|
1090
|
-
return true;
|
|
1091
1213
|
if (spoke !== undefined && spokeExclusionList !== undefined) {
|
|
1092
1214
|
return isSpokeExcluded(destRel, { ...spoke, exclusions: spokeExclusionList });
|
|
1093
1215
|
}
|
|
@@ -1226,7 +1348,7 @@ export async function updateSite(opts) {
|
|
|
1226
1348
|
: undefined;
|
|
1227
1349
|
// ── The web app's carried dependencies (#9889 D9), planned before the
|
|
1228
1350
|
// first write so an unparseable apps/web/package.json refuses the run.
|
|
1229
|
-
const
|
|
1351
|
+
const webDependencies = planWebDependencies(targetDir, opts.templatesDir);
|
|
1230
1352
|
// ── Every recorded row (D4) ────────────────────────────────────────────
|
|
1231
1353
|
const updated = [];
|
|
1232
1354
|
const merged = [];
|
|
@@ -1257,6 +1379,11 @@ export async function updateSite(opts) {
|
|
|
1257
1379
|
});
|
|
1258
1380
|
continue;
|
|
1259
1381
|
}
|
|
1382
|
+
const declinedRow = declinedReason(path);
|
|
1383
|
+
if (declinedRow !== undefined) {
|
|
1384
|
+
skipped.push({ path, reason: declinedRow });
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1260
1387
|
const abs = join(targetDir, ...path.split("/"));
|
|
1261
1388
|
if (!existsSync(abs)) {
|
|
1262
1389
|
if (newMap.get(path) === undefined) {
|
|
@@ -1314,6 +1441,34 @@ export async function updateSite(opts) {
|
|
|
1314
1441
|
const newHash = sha256Hex(newBytes);
|
|
1315
1442
|
if (newHash === rec.sha256)
|
|
1316
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
|
+
};
|
|
1317
1472
|
if (diskHash === newHash) {
|
|
1318
1473
|
nextFiles[path] = { sha256: newHash, version };
|
|
1319
1474
|
current.push(path);
|
|
@@ -1332,25 +1487,16 @@ export async function updateSite(opts) {
|
|
|
1332
1487
|
// Template changed, and the edit does not already match it: three-way merge.
|
|
1333
1488
|
const base = await loadVersionMap(rec.version);
|
|
1334
1489
|
if ("error" in base) {
|
|
1335
|
-
|
|
1336
|
-
path,
|
|
1337
|
-
reason: `edited here, and the ${rec.version} template could not be read: ${base.error}`,
|
|
1338
|
-
});
|
|
1490
|
+
additiveOrReview(`edited here, and the ${rec.version} template could not be read: ${base.error}`);
|
|
1339
1491
|
continue;
|
|
1340
1492
|
}
|
|
1341
1493
|
const baseBytes = base.get(path);
|
|
1342
1494
|
if (baseBytes === undefined) {
|
|
1343
|
-
|
|
1344
|
-
path,
|
|
1345
|
-
reason: `edited here, and the ${rec.version} template could not be read: not present in that version's snapshot`,
|
|
1346
|
-
});
|
|
1495
|
+
additiveOrReview(`edited here, and the ${rec.version} template could not be read: not present in that version's snapshot`);
|
|
1347
1496
|
continue;
|
|
1348
1497
|
}
|
|
1349
1498
|
if (sha256Hex(baseBytes) !== rec.sha256) {
|
|
1350
|
-
|
|
1351
|
-
path,
|
|
1352
|
-
reason: `edited here, and the ${rec.version} template copy does not match the record`,
|
|
1353
|
-
});
|
|
1499
|
+
additiveOrReview(`edited here, and the ${rec.version} template copy does not match the record`);
|
|
1354
1500
|
continue;
|
|
1355
1501
|
}
|
|
1356
1502
|
if (!isTextFile(path)) {
|
|
@@ -1385,26 +1531,6 @@ export async function updateSite(opts) {
|
|
|
1385
1531
|
nextFiles[path] = { sha256: newHash, version };
|
|
1386
1532
|
merged.push(path);
|
|
1387
1533
|
}
|
|
1388
|
-
else if (mergeResult.status === "conflict" && MESSAGES_JSON.test(path)) {
|
|
1389
|
-
// #10173 — a messages catalog takes the template's new keys and keeps
|
|
1390
|
-
// every value the site has; only a key-level conflict is reviewed.
|
|
1391
|
-
const additive = mergeMessagesAdditively(diskBytes.toString("utf8"), Buffer.from(newBytes).toString("utf8"));
|
|
1392
|
-
if (additive.status === "conflict") {
|
|
1393
|
-
review.push({
|
|
1394
|
-
path,
|
|
1395
|
-
reason: `conflicts with the template change ${rec.version} → ${version} at key ${additive.keys.join(", ")}`,
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
else if (additive.status === "invalid") {
|
|
1399
|
-
review.push({ path, reason: `the additive pass could not run: ${additive.reason}` });
|
|
1400
|
-
}
|
|
1401
|
-
else {
|
|
1402
|
-
if (additive.added > 0)
|
|
1403
|
-
writes.push({ path, bytes: Buffer.from(additive.text, "utf8") });
|
|
1404
|
-
nextFiles[path] = { sha256: newHash, version };
|
|
1405
|
-
merged.push(path);
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
1534
|
else if (mergeResult.status === "conflict" && edit.commentOnly) {
|
|
1409
1535
|
// #11147 — the site touched only comment lines, on the lines the
|
|
1410
1536
|
// template changed: the template's copy lands, reported as such.
|
|
@@ -1413,13 +1539,10 @@ export async function updateSite(opts) {
|
|
|
1413
1539
|
updated.push(path);
|
|
1414
1540
|
}
|
|
1415
1541
|
else if (mergeResult.status === "conflict") {
|
|
1416
|
-
|
|
1417
|
-
path,
|
|
1418
|
-
reason: `conflicts with the template change ${rec.version} → ${version}`,
|
|
1419
|
-
});
|
|
1542
|
+
additiveOrReview(`conflicts with the template change ${rec.version} → ${version}`);
|
|
1420
1543
|
}
|
|
1421
1544
|
else {
|
|
1422
|
-
|
|
1545
|
+
additiveOrReview(`the three-way merge could not run: ${mergeResult.reason}`);
|
|
1423
1546
|
}
|
|
1424
1547
|
}
|
|
1425
1548
|
// ── Every recordable path the running template has that this record does not (D4) ──
|
|
@@ -1438,6 +1561,11 @@ export async function updateSite(opts) {
|
|
|
1438
1561
|
skipped.push({ path, reason: "marketing removed" });
|
|
1439
1562
|
continue;
|
|
1440
1563
|
}
|
|
1564
|
+
const declinedNew = declinedReason(path);
|
|
1565
|
+
if (declinedNew !== undefined) {
|
|
1566
|
+
skipped.push({ path, reason: declinedNew });
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1441
1569
|
// The guard runs before the disk check, so a full-copy site's boot path
|
|
1442
1570
|
// reads as guarded, never as "exists, not in the record" (#9569 DD8).
|
|
1443
1571
|
if (bootFileGuarded(path)) {
|
|
@@ -1528,6 +1656,9 @@ export async function updateSite(opts) {
|
|
|
1528
1656
|
// that moved anyway; and the dependencies the template supplied, added.
|
|
1529
1657
|
const missingImportsByFile = new Map();
|
|
1530
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();
|
|
1531
1662
|
const heldPaths = new Set();
|
|
1532
1663
|
const moving = [...new Set([...updated, ...merged, ...added, ...removed, ...current])].sort();
|
|
1533
1664
|
const isFileCache = new Map();
|
|
@@ -1544,11 +1675,26 @@ export async function updateSite(opts) {
|
|
|
1544
1675
|
}
|
|
1545
1676
|
return hit;
|
|
1546
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
|
+
}
|
|
1547
1692
|
// What the run rewrites after the record's writes, never from the template.
|
|
1548
1693
|
const rewrittenLater = new Set([
|
|
1549
1694
|
MODULE_FLAGS_PATH,
|
|
1550
1695
|
PAID_MCP_TOOLS_PATH,
|
|
1551
1696
|
...(mcpMove?.seam !== undefined ? [MCP_SEAM_PATH] : []),
|
|
1697
|
+
...renders.keys(),
|
|
1552
1698
|
]);
|
|
1553
1699
|
/** Whether `path` is a file once this run's writes and deletes, less the held ones, land. */
|
|
1554
1700
|
const presentAfter = (path) => {
|
|
@@ -1628,22 +1774,134 @@ export async function updateSite(opts) {
|
|
|
1628
1774
|
heldFiles.add(path);
|
|
1629
1775
|
grew = true;
|
|
1630
1776
|
};
|
|
1631
|
-
/**
|
|
1632
|
-
|
|
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) => {
|
|
1633
1783
|
const bytes = Buffer.from(raw);
|
|
1634
1784
|
const text = bytes.toString("utf8");
|
|
1635
1785
|
writes.push({ path, bytes });
|
|
1636
1786
|
writtenBytes.set(path, bytes);
|
|
1637
1787
|
nextFiles[path] = { sha256: sha256Hex(bytes), version };
|
|
1638
|
-
|
|
1639
|
-
|
|
1788
|
+
if (isFileOnDisk(path))
|
|
1789
|
+
updated.push(path);
|
|
1790
|
+
else {
|
|
1791
|
+
added.push(path);
|
|
1792
|
+
adding.add(path);
|
|
1793
|
+
}
|
|
1640
1794
|
dependenciesAdded.add(path);
|
|
1641
1795
|
moving.push(path);
|
|
1642
1796
|
sourcesOf.set(path, { all: [text], written: text });
|
|
1643
1797
|
grew = true;
|
|
1644
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
|
+
};
|
|
1645
1881
|
while (grew) {
|
|
1646
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
|
+
}
|
|
1647
1905
|
// #11147 — a removal a still-present file imports — the site's own
|
|
1648
1906
|
// code, a file left alone, or a file held with one — is held with that
|
|
1649
1907
|
// importer, so the run never removes what the tree still imports. The
|
|
@@ -1675,6 +1933,31 @@ export async function updateSite(opts) {
|
|
|
1675
1933
|
}
|
|
1676
1934
|
const imported = cascades ? importedHeld : new Set();
|
|
1677
1935
|
const missing = new Set();
|
|
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
|
+
}
|
|
1678
1961
|
if (written !== undefined) {
|
|
1679
1962
|
for (const specifier of localSpecifiers(path, written)) {
|
|
1680
1963
|
const candidates = relativeImportCandidates(path, specifier);
|
|
@@ -1692,9 +1975,9 @@ export async function updateSite(opts) {
|
|
|
1692
1975
|
// `pricing-page.ts` needs `contact/contact-form-text.ts` whether
|
|
1693
1976
|
// or not `/contact` serves. A guarded boot path (#9569 DD8) is a
|
|
1694
1977
|
// file on disk the run must not touch, so it stays missing.
|
|
1695
|
-
const supplied = candidates.find((c) => newMap.get(c) !== undefined && !heldPaths.has(c) && !bootFileGuarded(c));
|
|
1978
|
+
const supplied = candidates.find((c) => newMap.get(c) !== undefined && !heldPaths.has(c) && !bootFileGuarded(c) && declinedReason(c) === undefined);
|
|
1696
1979
|
if (supplied !== undefined) {
|
|
1697
|
-
|
|
1980
|
+
writeDependency(supplied, newMap.get(supplied));
|
|
1698
1981
|
continue;
|
|
1699
1982
|
}
|
|
1700
1983
|
// #11216 — the site's own copy already names it, and the template
|
|
@@ -1713,14 +1996,22 @@ export async function updateSite(opts) {
|
|
|
1713
1996
|
}
|
|
1714
1997
|
// A named import the file it resolves to — staying at the site's
|
|
1715
1998
|
// version, or held back (#11147) — does not export (a regenerated
|
|
1716
|
-
// nav-config, say).
|
|
1999
|
+
// nav-config, say). One this run renders is read from the render.
|
|
1717
2000
|
const lacking = new Set();
|
|
1718
2001
|
if (written !== undefined) {
|
|
1719
2002
|
for (const { specifier, names } of namedImportsOf(written)) {
|
|
1720
2003
|
if (!isLocal(path, specifier))
|
|
1721
2004
|
continue;
|
|
1722
|
-
const target = relativeImportCandidates(path, specifier).find(isFileOnDisk);
|
|
1723
|
-
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))
|
|
1724
2015
|
continue;
|
|
1725
2016
|
if (heldFiles.has(target) && cascades)
|
|
1726
2017
|
continue; // held with it above
|
|
@@ -1735,7 +2026,14 @@ export async function updateSite(opts) {
|
|
|
1735
2026
|
lacking.add(target);
|
|
1736
2027
|
}
|
|
1737
2028
|
}
|
|
1738
|
-
|
|
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)
|
|
1739
2037
|
continue;
|
|
1740
2038
|
holdPath(path);
|
|
1741
2039
|
for (const file of imported)
|
|
@@ -1744,6 +2042,8 @@ export async function updateSite(opts) {
|
|
|
1744
2042
|
hold(path, file, true);
|
|
1745
2043
|
for (const file of lacking)
|
|
1746
2044
|
hold(path, file, false);
|
|
2045
|
+
for (const file of keyed)
|
|
2046
|
+
hold(path, file, false);
|
|
1747
2047
|
}
|
|
1748
2048
|
// The reverse: a file staying at the site's version imports, by name,
|
|
1749
2049
|
// something the written copy of its target no longer exports.
|
|
@@ -1785,7 +2085,29 @@ export async function updateSite(opts) {
|
|
|
1785
2085
|
delete nextFiles[path];
|
|
1786
2086
|
}
|
|
1787
2087
|
const notHeld = (path) => !heldPaths.has(path);
|
|
1788
|
-
// #
|
|
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.
|
|
1789
2111
|
for (let i = skipped.length - 1; i >= 0; i--) {
|
|
1790
2112
|
const path = skipped[i].path;
|
|
1791
2113
|
if (dependenciesAdded.has(path) && notHeld(path))
|
|
@@ -1795,6 +2117,11 @@ export async function updateSite(opts) {
|
|
|
1795
2117
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
1796
2118
|
.map(([file, importers]) => ({ file, importers: importers.filter(notHeld).sort() }))
|
|
1797
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);
|
|
1798
2125
|
const heldBack = [...heldBackByFile.entries()]
|
|
1799
2126
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
1800
2127
|
.map(([file, { tests, importers, missing }]) => ({
|
|
@@ -1867,11 +2194,11 @@ export async function updateSite(opts) {
|
|
|
1867
2194
|
// #10940 D5 — the site's listing is site-owned (REGENERATED_APP_PATHS):
|
|
1868
2195
|
// written only when absent, so a site updated onto routes that import it
|
|
1869
2196
|
// builds; a present one is never read or written.
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
|
|
2197
|
+
const listing = renders.get(SITE_LISTING_PATH);
|
|
2198
|
+
if (listing !== undefined) {
|
|
2199
|
+
const listingAbs = join(targetDir, ...SITE_LISTING_PATH.split("/"));
|
|
1873
2200
|
mkdirSync(dirname(listingAbs), { recursive: true });
|
|
1874
|
-
writeFileSync(listingAbs,
|
|
2201
|
+
writeFileSync(listingAbs, listing);
|
|
1875
2202
|
moved.added.push(SITE_LISTING_PATH);
|
|
1876
2203
|
}
|
|
1877
2204
|
// #9567 — the MCP move's writes, then the paid MCP tool registry from the
|
|
@@ -1907,6 +2234,15 @@ export async function updateSite(opts) {
|
|
|
1907
2234
|
writeFileSync(join(targetDir, ...WEB_PACKAGE_JSON.split("/")), webPackageJson);
|
|
1908
2235
|
moved.updated.push(WEB_PACKAGE_JSON);
|
|
1909
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);
|
|
1910
2246
|
// #10172 — the env vars the written files read get an env_contract row
|
|
1911
2247
|
// when the site's project.yaml has a block and no row for them, so the
|
|
1912
2248
|
// code update brings never fails `env:declared`. Rows are appended, never
|
|
@@ -1979,6 +2315,24 @@ export async function updateSite(opts) {
|
|
|
1979
2315
|
review.push({ path: sitePath(path), reason: `bare {…} not escaped: ${escape.reason}` });
|
|
1980
2316
|
}
|
|
1981
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);
|
|
1982
2336
|
return {
|
|
1983
2337
|
targetDir,
|
|
1984
2338
|
version,
|
|
@@ -1988,6 +2342,7 @@ export async function updateSite(opts) {
|
|
|
1988
2342
|
heldBack,
|
|
1989
2343
|
...(heldImports.length > 0 ? { heldImports } : {}),
|
|
1990
2344
|
...(missingImports.length > 0 ? { missingImports } : {}),
|
|
2345
|
+
...(testLibs.length > 0 ? { testLibs } : {}),
|
|
1991
2346
|
...(staleCopies.some((row) => notHeld(row.path))
|
|
1992
2347
|
? { staleCopies: staleCopies.filter((row) => notHeld(row.path)) }
|
|
1993
2348
|
: {}),
|
|
@@ -1997,6 +2352,8 @@ export async function updateSite(opts) {
|
|
|
1997
2352
|
: {}),
|
|
1998
2353
|
headingsAdded: headings.written.map(sitePath),
|
|
1999
2354
|
bracesEscaped,
|
|
2355
|
+
...(routesWritten.length > 0 ? { routesWritten } : {}),
|
|
2356
|
+
...(cliPin !== undefined ? { cliPin } : {}),
|
|
2000
2357
|
...(backfilled !== undefined ? { backfilled } : {}),
|
|
2001
2358
|
...(envRowsAdded.length > 0 ? { envRowsAdded } : {}),
|
|
2002
2359
|
...(droppedRows.length > 0 ? { droppedRows: droppedRows.sort() } : {}),
|
|
@@ -2006,6 +2363,32 @@ export async function updateSite(opts) {
|
|
|
2006
2363
|
: {}),
|
|
2007
2364
|
};
|
|
2008
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
|
+
}
|
|
2009
2392
|
/** Whether a `node_modules` at or above `dir` holds `pkg` — so `resolve` never falls back to NODE_PATH. */
|
|
2010
2393
|
function installedAbove(dir, pkg) {
|
|
2011
2394
|
for (let at = dir;; at = dirname(at)) {
|
|
@@ -2052,13 +2435,20 @@ export function formatUpdateReport(result) {
|
|
|
2052
2435
|
["Already current", result.current],
|
|
2053
2436
|
["Page heading added", result.headingsAdded],
|
|
2054
2437
|
["Placeholder brace escaped", result.bracesEscaped],
|
|
2438
|
+
["Route files regenerated", result.routesWritten ?? []],
|
|
2055
2439
|
];
|
|
2440
|
+
if (result.cliPin !== undefined) {
|
|
2441
|
+
lines.push(`create-ailk pin moved: ${result.cliPin.from} → ${result.cliPin.to}`);
|
|
2442
|
+
}
|
|
2056
2443
|
// #11147 — why a moved file's bytes were not the site's.
|
|
2057
2444
|
const notes = new Map();
|
|
2058
2445
|
for (const { path, version } of result.staleCopies ?? [])
|
|
2059
2446
|
notes.set(path, `a stale copy of the ${version} template`);
|
|
2060
2447
|
for (const path of result.commentOnlyEdits ?? [])
|
|
2061
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(", ")}`);
|
|
2062
2452
|
// #11213 — an adopted file is listed once, under its own heading, with
|
|
2063
2453
|
// the version it matched.
|
|
2064
2454
|
const adoptedPaths = new Set((result.adopted ?? []).map((row) => row.path));
|
|
@@ -2126,6 +2516,8 @@ export function formatUpdateReport(result) {
|
|
|
2126
2516
|
result.current.length === 0 &&
|
|
2127
2517
|
result.headingsAdded.length === 0 &&
|
|
2128
2518
|
result.bracesEscaped.length === 0 &&
|
|
2519
|
+
result.routesWritten === undefined &&
|
|
2520
|
+
result.cliPin === undefined &&
|
|
2129
2521
|
result.review.length === 0 &&
|
|
2130
2522
|
result.skipped.length === 0 &&
|
|
2131
2523
|
result.heldBack.length === 0 &&
|
|
@@ -2164,8 +2556,13 @@ app jest configs require, whose template copy changed is overwritten. An
|
|
|
2164
2556
|
edited file whose template copy also changed is three-way merged with
|
|
2165
2557
|
\`git\` (git must be on PATH); a conflict leaves the file alone and is
|
|
2166
2558
|
listed under "Needs review"; an apps/web/messages catalog instead gains the
|
|
2167
|
-
template's new keys and keeps every value it has
|
|
2168
|
-
|
|
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
|
|
2169
2566
|
bytes are another published create-ailk version's copy is a stale copy, not
|
|
2170
2567
|
an edit: it is overwritten or removed as an untouched file is, listed with
|
|
2171
2568
|
the version it matched. An edit that touches only comment lines is listed as
|
|
@@ -2176,7 +2573,9 @@ create-ailk version's copy — from the version the site was scaffolded at to
|
|
|
2176
2573
|
this one — is adopted: recorded and moved forward as an untouched file is,
|
|
2177
2574
|
listed under "Adopted" with the version it matched. One whose bytes match no
|
|
2178
2575
|
published copy is a site edit: skipped, never overwritten, and counted under
|
|
2179
|
-
"Held as site edits, not in the record".
|
|
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
|
|
2180
2579
|
test, and every site-edited template file, that imports a file left under
|
|
2181
2580
|
"Needs review" (by a relative or @/ import, transitively) is held
|
|
2182
2581
|
at the site's version with it, its record entry is not advanced, and it is
|
|
@@ -2217,7 +2616,11 @@ read, is listed under "Needs review". Each bare { on an mdx-body page is
|
|
|
2217
2616
|
escaped as \\{ when the site's own MDX parser then reads the page clean, listed
|
|
2218
2617
|
under "Placeholder brace escaped"; a page it cannot escape safely, or any page
|
|
2219
2618
|
with one while the site's dependencies are not installed, is listed under
|
|
2220
|
-
"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.
|
|
2221
2624
|
`;
|
|
2222
2625
|
/** Parse the argv AFTER the `update` word. Strict `node:util` parseArgs, like `parseAdoptArgs`. */
|
|
2223
2626
|
export function parseUpdateArgs(argv) {
|