create-ailk 0.22.0 → 0.24.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 +27 -14
- package/component-catalog.json +149 -5
- package/component-catalog.md +7 -6
- package/dist/add-module.js +17 -10
- package/dist/add-route.d.ts +55 -1
- package/dist/add-route.js +301 -13
- package/dist/cli.js +27 -10
- package/dist/derive-architecture.d.ts +7 -5
- package/dist/derive-architecture.js +26 -32
- package/dist/lib/design-checks.js +4 -2
- package/dist/lib/env-catalog.js +0 -4
- package/dist/lib/npm-auth.d.ts +9 -0
- package/dist/lib/npm-auth.js +48 -0
- package/dist/lib/scaffold-render-sweep.d.ts +36 -2
- package/dist/lib/scaffold-render-sweep.js +50 -8
- package/dist/module-architecture.js +115 -10
- package/dist/paid-sections.d.ts +21 -2
- package/dist/paid-sections.js +69 -7
- package/dist/seed-flows.d.ts +4 -1
- package/dist/seed-flows.js +50 -4
- package/dist/spoke-checkout.d.ts +38 -35
- package/dist/spoke-checkout.js +66 -229
- package/dist/starter-grid.d.ts +0 -3
- package/dist/starter-grid.js +24 -14
- package/dist/surfaces.js +33 -12
- package/dist/sync-routes.d.ts +68 -5
- package/dist/sync-routes.js +455 -29
- package/dist/template-record.d.ts +1 -1
- package/dist/template-record.js +3 -2
- package/dist/update.js +10 -0
- package/package.json +3 -3
- package/site-templates/_base/content/en/NewsletterSignup/newsletter.mdx +4 -49
- package/site-templates/_base/content/en/Pricing/pricing.mdx +3 -21
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +23 -20
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +28 -14
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +15 -39
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +38 -34
- package/site-templates/marketing-site-free/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/local-business-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/organization-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/person-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/templates/.env.example +13 -7
- package/templates/.github/workflows/ci.yml +13 -0
- package/templates/CLAUDE.md +4 -2
- package/templates/README.md +1 -0
- package/templates/_gitignore +4 -0
- package/templates/apps/api/.env.example +34 -0
- package/templates/apps/api/CLAUDE.md +94 -19
- package/templates/apps/api/package.json +1 -0
- package/templates/apps/api/src/__tests__/factories/in-memory-prisma.ts +2 -0
- package/templates/apps/api/src/bin/stripe-connections-rekey.ts +45 -0
- package/templates/apps/api/src/config/__tests__/stripe-connection-key.test.ts +185 -0
- package/templates/apps/api/src/config/index.ts +109 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -1
- package/templates/apps/api/src/lib/__tests__/flow-rename-race.db.test.ts +116 -0
- package/templates/apps/api/src/lib/__tests__/site.test.ts +16 -0
- package/templates/apps/api/src/lib/error-serializer.ts +74 -7
- package/templates/apps/api/src/lib/site.ts +4 -1
- package/templates/apps/api/src/lib/stripe.ts +77 -4
- package/templates/apps/api/src/lib/webhook-idempotency.ts +66 -2
- package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +218 -0
- package/templates/apps/api/src/middleware/__tests__/write-budget.test.ts +174 -0
- package/templates/apps/api/src/middleware/rate-limit.ts +226 -4
- package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +127 -0
- package/templates/apps/api/src/openapi/spec.ts +343 -7
- package/templates/apps/api/src/routes/billing/plan-checkout.ts +332 -0
- package/templates/apps/api/src/routes/checkout/__tests__/live-key.test.ts +11 -0
- package/templates/apps/api/src/routes/checkout/__tests__/offerings-authorization.test.ts +1426 -0
- package/templates/apps/api/src/routes/checkout/__tests__/session.test.ts +11 -0
- package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +49 -0
- package/templates/apps/api/src/routes/checkout/session.ts +57 -25
- package/templates/apps/api/src/routes/checkout/sessions.ts +232 -82
- package/templates/apps/api/src/routes/consent/__tests__/account.test.ts +5 -5
- package/templates/apps/api/src/routes/consent/__tests__/sign-up-rate-limit.test.ts +160 -0
- package/templates/apps/api/src/routes/consent/account.ts +4 -2
- package/templates/apps/api/src/routes/content/__tests__/get-page.test.ts +2 -2
- package/templates/apps/api/src/routes/content/__tests__/offerings.test.ts +731 -0
- package/templates/apps/api/src/routes/content/__tests__/pricing.test.ts +753 -0
- package/templates/apps/api/src/routes/content/__tests__/shown-offerings.test.ts +762 -0
- package/templates/apps/api/src/routes/content/get-page.ts +34 -119
- package/templates/apps/api/src/routes/content/index.ts +16 -2
- package/templates/apps/api/src/routes/content/list-pages.ts +15 -36
- package/templates/apps/api/src/routes/content/offerings.ts +184 -0
- package/templates/apps/api/src/routes/content/pricing.ts +176 -0
- package/templates/apps/api/src/routes/content/search.ts +16 -45
- package/templates/apps/api/src/routes/content/shown-offerings.ts +229 -0
- package/templates/apps/api/src/routes/leads/index.ts +377 -308
- package/templates/apps/api/src/routes/project-listings/__tests__/me.test.ts +20 -9
- package/templates/apps/api/src/routes/project-listings/__tests__/public.test.ts +17 -6
- package/templates/apps/api/src/routes/project-listings/__tests__/site-answers.test.ts +1 -1
- package/templates/apps/api/src/routes/webhooks/README.md +66 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-flow-checkout.test.ts +1 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-offerings.test.ts +814 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-org-billing.test.ts +80 -68
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-site-filter.test.ts +6 -5
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +8 -2
- package/templates/apps/api/src/routes/webhooks/index.ts +23 -0
- package/templates/apps/api/src/routes/webhooks/stripe-offerings.ts +384 -0
- package/templates/apps/api/src/routes/webhooks/stripe.ts +93 -17
- package/templates/apps/api/src/server.ts +165 -51
- package/templates/apps/api/src/services/__tests__/abandon-email.test.ts +121 -4
- package/templates/apps/api/src/services/__tests__/checkout-plan.test.ts +313 -0
- package/templates/apps/api/src/services/__tests__/deliverable-fulfillment.test.ts +61 -2
- package/templates/apps/api/src/services/__tests__/keyless-workspace-predicate.test.ts +234 -0
- package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +374 -44
- package/templates/apps/api/src/services/__tests__/person.test.ts +260 -1
- package/templates/apps/api/src/services/__tests__/plan-offerings.test.ts +450 -0
- package/templates/apps/api/src/services/__tests__/project-listings.counts.test.ts +202 -0
- package/templates/apps/api/src/services/__tests__/project-listings.fence.test.ts +15 -18
- package/templates/apps/api/src/services/abandon-email.ts +28 -5
- package/templates/apps/api/src/services/deliverable-fulfillment.ts +15 -12
- package/templates/apps/api/src/services/entitlements.ts +157 -1
- package/templates/apps/api/src/services/lead-routing.ts +113 -58
- package/templates/apps/api/src/services/offerings/__tests__/catalog.test.ts +348 -0
- package/templates/apps/api/src/services/offerings/__tests__/checkout-session-record.test.ts +268 -0
- package/templates/apps/api/src/services/offerings/__tests__/connection.test.ts +975 -0
- package/templates/apps/api/src/services/offerings/__tests__/fixtures.ts +416 -0
- package/templates/apps/api/src/services/offerings/__tests__/org-products.test.ts +400 -0
- package/templates/apps/api/src/services/offerings/__tests__/readers.test.ts +685 -0
- package/templates/apps/api/src/services/offerings/__tests__/source.test.ts +231 -0
- package/templates/apps/api/src/services/offerings/catalog.ts +318 -0
- package/templates/apps/api/src/services/offerings/checkout-authorization.ts +403 -0
- package/templates/apps/api/src/services/offerings/checkout-session-record.ts +192 -0
- package/templates/apps/api/src/services/offerings/connection.ts +1083 -0
- package/templates/apps/api/src/services/offerings/index.ts +614 -0
- package/templates/apps/api/src/services/offerings/source.ts +140 -0
- package/templates/apps/api/src/services/offerings/store.ts +150 -0
- package/templates/apps/api/src/services/person.ts +147 -9
- package/templates/apps/api/src/services/plan-offerings.ts +96 -30
- package/templates/apps/api/src/services/project-listings.ts +43 -31
- package/templates/apps/api/src/services/public-site-resolver.ts +19 -14
- package/templates/apps/mcp/CLAUDE.md +32 -18
- package/templates/apps/mcp/__tests__/app-entry.test.ts +2 -2
- package/templates/apps/mcp/__tests__/catalog-drift.test.ts +9 -4
- package/templates/apps/mcp/__tests__/get_offerings.test.ts +358 -0
- package/templates/apps/mcp/__tests__/get_pricing.test.ts +364 -0
- package/templates/apps/mcp/__tests__/http-transport.test.ts +95 -14
- package/templates/apps/mcp/__tests__/lib/content-adapter-parity.test.ts +8 -3
- package/templates/apps/mcp/__tests__/lib/content-adapter.test.ts +0 -25
- package/templates/apps/mcp/__tests__/lib/fail-closed-tools.test.ts +22 -7
- package/templates/apps/mcp/__tests__/list_pages.test.ts +84 -44
- package/templates/apps/mcp/__tests__/locale.test.ts +41 -56
- package/templates/apps/mcp/__tests__/module-exclusion.test.ts +2 -2
- package/templates/apps/mcp/__tests__/rate-limit-write.test.ts +189 -0
- package/templates/apps/mcp/__tests__/read_content.test.ts +115 -78
- package/templates/apps/mcp/__tests__/request_callback.test.ts +63 -128
- package/templates/apps/mcp/__tests__/search_content.test.ts +76 -61
- package/templates/apps/mcp/__tests__/server.test.ts +13 -11
- package/templates/apps/mcp/__tests__/start_purchase.test.ts +208 -12
- package/templates/apps/mcp/__tests__/submit_lead.test.ts +82 -167
- package/templates/apps/mcp/__tests__/subscribe_newsletter.test.ts +59 -130
- package/templates/apps/mcp/__tests__/tools/purchase.test.ts +11 -11
- package/templates/apps/mcp/package.json +1 -0
- package/templates/apps/mcp/src/abuse/index.ts +18 -11
- package/templates/apps/mcp/src/http-transport.ts +47 -9
- package/templates/apps/mcp/src/lib/content-adapter.ts +0 -26
- package/templates/apps/mcp/src/lib/empty-content-adapter.ts +5 -4
- package/templates/apps/mcp/src/lib/shown-offerings.ts +105 -0
- package/templates/apps/mcp/src/lib/site-config.ts +53 -0
- package/templates/apps/mcp/src/server.ts +5 -0
- package/templates/apps/mcp/src/tools/capture_lead.ts +30 -28
- package/templates/apps/mcp/src/tools/get_offerings.ts +47 -30
- package/templates/apps/mcp/src/tools/get_pricing.ts +40 -40
- package/templates/apps/mcp/src/tools/index.ts +22 -21
- package/templates/apps/mcp/src/tools/list_pages.ts +27 -33
- package/templates/apps/mcp/src/tools/purchase.ts +30 -2
- package/templates/apps/mcp/src/tools/read_content.ts +46 -40
- package/templates/apps/mcp/src/tools/request_callback.ts +21 -28
- package/templates/apps/mcp/src/tools/search_content.ts +20 -24
- package/templates/apps/mcp/src/tools/subscribe_newsletter.ts +23 -26
- package/templates/apps/mcp/src/workspace-server.ts +15 -0
- package/templates/apps/web/.env.example +10 -31
- package/templates/apps/web/CLAUDE.md +324 -42
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +3 -3
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +189 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +4 -2
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +8 -3
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +22 -144
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +9 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +172 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +149 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +22 -24
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +140 -66
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +57 -22
- package/templates/apps/web/app/[locale]/careers/page.tsx +129 -5
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +119 -11
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +28 -5
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +20 -6
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +1 -1
- package/templates/apps/web/app/[locale]/contact/page.tsx +99 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +237 -5
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +200 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +197 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +430 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +21 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +369 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +12 -73
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +10 -31
- package/templates/apps/web/app/[locale]/layout.tsx +55 -4
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +174 -104
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +95 -58
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +7 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +599 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +216 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +236 -0
- package/templates/apps/web/app/[locale]/pricing/page.tsx +367 -6
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +4 -1
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +17 -0
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +62 -3
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +70 -18
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +30 -9
- package/templates/apps/web/app/api/offerings/checkout/[lookupKey]/route.ts +316 -0
- package/templates/apps/web/app/api/offerings/checkout/__tests__/route.test.ts +810 -0
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +27 -1
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +2 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +265 -0
- package/templates/apps/web/lib/__tests__/magnet-routes.test.ts +64 -0
- package/templates/apps/web/lib/__tests__/newsletter.actions.test.ts +293 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +601 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +67 -8
- package/templates/apps/web/lib/auth-routes.ts +36 -2
- package/templates/apps/web/lib/checkout-config.ts +9 -20
- package/templates/apps/web/lib/deck-page.ts +1 -0
- package/templates/apps/web/lib/deliverable-grant.ts +18 -0
- package/templates/apps/web/lib/in-page-magnet.ts +416 -0
- package/templates/apps/web/lib/magnet-routes.ts +44 -0
- package/templates/apps/web/lib/modules.generated.ts +9 -0
- package/templates/apps/web/lib/newsletter.actions.ts +205 -0
- package/templates/apps/web/lib/offerings-pricing.ts +326 -0
- package/templates/apps/web/lib/posting-title.ts +17 -0
- package/templates/apps/web/lib/sign-up-agreements.ts +4 -2
- package/templates/apps/web/messages/en.json +49 -15
- package/templates/apps/web/middleware.ts +12 -2
- package/templates/apps/web/security-headers.config.ts +17 -0
- package/templates/content/en/BlogList/blog.mdx +4 -71
- package/templates/content/en/BookCall/book-a-call.mdx +1 -41
- package/templates/content/en/BookCall/onsite-estimate.mdx +1 -17
- package/templates/content/en/BookCall/onsite-service.mdx +1 -17
- package/templates/content/en/BookCall/start-project.mdx +1 -17
- package/templates/content/en/ContactPage/contact.mdx +6 -63
- package/templates/content/en/HomePage/home.mdx +3 -21
- package/templates/database/CHANGELOG.md +51 -0
- package/templates/database/__tests__/in-page-magnets-migration.test.ts +161 -0
- package/templates/database/__tests__/offerings-checkout-session.db.test.ts +270 -0
- package/templates/database/__tests__/offerings-migration.test.ts +197 -0
- package/templates/database/__tests__/offerings-shown-price-ids-migration.test.ts +86 -0
- package/templates/database/__tests__/offerings.db.test.ts +303 -0
- package/templates/database/__tests__/seed.test.ts +63 -1
- package/templates/database/__tests__/trial-magnet-migration.test.ts +186 -0
- package/templates/database/auth/schema.prisma +4 -0
- package/templates/database/config/schema.prisma +91 -0
- package/templates/database/migrations/20261020120000_offerings_data_model/migration.sql +146 -0
- package/templates/database/migrations/20261021120000_offerings_checkout_session/migration.sql +77 -0
- package/templates/database/migrations/20261022120000_in_page_magnets/migration.sql +45 -0
- package/templates/database/migrations/20261023120000_offerings_shown_price_ids/migration.sql +47 -0
- package/templates/database/migrations/20261024120000_organization_plan_checkout_session/migration.sql +16 -0
- package/templates/database/migrations/20261025120000_trial_magnet/migration.sql +28 -0
- package/templates/database/migrations/20261026120000_trial_magnet_proof_line/migration.sql +23 -0
- package/templates/database/package.json +1 -1
- package/templates/database/seed.ts +57 -2
- package/templates/tools/lint-architecture.ts +205 -1
- package/versions.json +35 -35
- package/site-templates/marketing-site-free/content/en/Pricing/pricing.mdx +0 -199
- package/templates/apps/api/src/routes/content/slug.ts +0 -9
- package/templates/apps/web/app/[locale]/downloads/__tests__/page-renderer-migration.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/downloads/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/newsletter/__tests__/newsletter.actions.test.ts +0 -139
- package/templates/apps/web/app/[locale]/newsletter/newsletter.actions.ts +0 -93
- package/templates/apps/web/app/api/checkout/[offering]/route.ts +0 -48
- package/templates/apps/web/app/api/checkout/__tests__/route.test.ts +0 -120
- package/templates/apps/web/app/api/checkout/__tests__/success-path.test.ts +0 -86
- package/templates/apps/web/app/api/webhooks/stripe/__tests__/route.test.ts +0 -92
- package/templates/apps/web/app/api/webhooks/stripe/route.ts +0 -31
- package/templates/apps/web/lib/__tests__/checkout.test.ts +0 -243
- package/templates/apps/web/lib/__tests__/meeting-slugs.test.ts +0 -120
- package/templates/apps/web/lib/checkout.ts +0 -93
- package/templates/apps/web/lib/meeting-slugs.ts +0 -63
package/dist/add-route.js
CHANGED
|
@@ -24,11 +24,16 @@
|
|
|
24
24
|
* this. A route the site already declares is a no-op: a second run changes
|
|
25
25
|
* nothing, even where the site has since deleted a seed.
|
|
26
26
|
*
|
|
27
|
+
* `create-ailk add-route magnet --path <path> --flow <slug>` (#8840 D12) is
|
|
28
|
+
* the second mode: it writes a site's own magnet page pair at `<path>` and
|
|
29
|
+
* `<path>/start`, bound to one flow slug, over the standard renderers in
|
|
30
|
+
* `flows/[slug]/magnet-page.tsx` — see `addMagnetToScaffold`.
|
|
31
|
+
*
|
|
27
32
|
* Pure module: no `import.meta.url`, so jest can import it directly — the
|
|
28
33
|
* package-rooted inputs are supplied by the CLI, the `add-module.ts` split.
|
|
29
34
|
*/
|
|
30
35
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, } from "node:fs";
|
|
31
|
-
import { dirname, join, resolve } from "node:path";
|
|
36
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
32
37
|
import { parseArgs } from "node:util";
|
|
33
38
|
import { AddModuleRefusedError, readArchitectureHeader, syncNavConfig, } from "./add-module.js";
|
|
34
39
|
import { isTextFile } from "./copy.js";
|
|
@@ -57,16 +62,7 @@ export class AddRouteRefusedError extends Error {
|
|
|
57
62
|
*/
|
|
58
63
|
export function addRouteToScaffold(opts) {
|
|
59
64
|
const targetAbs = resolve(opts.targetDir);
|
|
60
|
-
|
|
61
|
-
throw new Error(`add-route target does not exist: ${targetAbs}. Point add-route at an already-scaffolded repo.`);
|
|
62
|
-
}
|
|
63
|
-
if (!statSync(targetAbs).isDirectory()) {
|
|
64
|
-
throw new Error(`add-route target is not a directory: ${targetAbs}`);
|
|
65
|
-
}
|
|
66
|
-
const archPath = join(targetAbs, "architecture.yaml");
|
|
67
|
-
if (!existsSync(archPath)) {
|
|
68
|
-
throw new Error(`not a scaffolded repo: no architecture.yaml at ${targetAbs}. Run \`create-ailk <target-dir>\` to scaffold first.`);
|
|
69
|
-
}
|
|
65
|
+
const archPath = scaffoldArchitecturePath(targetAbs);
|
|
70
66
|
// #7426 D13 — a spoke stays a spoke. Read before the first write: an
|
|
71
67
|
// unreadable manifest is a refusal this command names (exit 2).
|
|
72
68
|
let spoke;
|
|
@@ -134,6 +130,20 @@ export function addRouteToScaffold(opts) {
|
|
|
134
130
|
}
|
|
135
131
|
return { targetDir: targetAbs, route, surfaces, report, routes };
|
|
136
132
|
}
|
|
133
|
+
/** The site's `architecture.yaml`, after checking `targetAbs` is a scaffold. */
|
|
134
|
+
function scaffoldArchitecturePath(targetAbs) {
|
|
135
|
+
if (!existsSync(targetAbs)) {
|
|
136
|
+
throw new Error(`add-route target does not exist: ${targetAbs}. Point add-route at an already-scaffolded repo.`);
|
|
137
|
+
}
|
|
138
|
+
if (!statSync(targetAbs).isDirectory()) {
|
|
139
|
+
throw new Error(`add-route target is not a directory: ${targetAbs}`);
|
|
140
|
+
}
|
|
141
|
+
const archPath = join(targetAbs, "architecture.yaml");
|
|
142
|
+
if (!existsSync(archPath)) {
|
|
143
|
+
throw new Error(`not a scaffolded repo: no architecture.yaml at ${targetAbs}. Run \`create-ailk <target-dir>\` to scaffold first.`);
|
|
144
|
+
}
|
|
145
|
+
return archPath;
|
|
146
|
+
}
|
|
137
147
|
/** The canonical id for one route argument, refusing an unknown one. */
|
|
138
148
|
function canonicalRoute(raw) {
|
|
139
149
|
let parsed;
|
|
@@ -216,13 +226,16 @@ export function formatAddRouteReport(result) {
|
|
|
216
226
|
const skipped = result.report.filter((row) => row.action === "skipped");
|
|
217
227
|
const routes = result.routes ?? {
|
|
218
228
|
applied: [],
|
|
229
|
+
refused: [],
|
|
219
230
|
appliedDependencies: [],
|
|
220
231
|
missingMessageNamespaces: [],
|
|
221
232
|
};
|
|
222
233
|
const lines = [
|
|
223
234
|
`[create-ailk] add-route ${result.route} → ${result.targetDir}`,
|
|
224
235
|
];
|
|
225
|
-
if (result.report.length === 0 &&
|
|
236
|
+
if (result.report.length === 0 &&
|
|
237
|
+
routes.applied.length === 0 &&
|
|
238
|
+
routes.refused.length === 0) {
|
|
226
239
|
lines.push(`Nothing to add — the site already carries the ${result.route} route.`);
|
|
227
240
|
}
|
|
228
241
|
if (routes.applied.length > 0) {
|
|
@@ -233,6 +246,9 @@ export function formatAddRouteReport(result) {
|
|
|
233
246
|
lines.push(`Also copied ${routes.appliedDependencies.length} file(s) those routes import:`);
|
|
234
247
|
lines.push(...routes.appliedDependencies.map((dep) => ` ${dep}`));
|
|
235
248
|
}
|
|
249
|
+
if (routes.refused.length > 0) {
|
|
250
|
+
lines.push(`Routes not copied (${routes.refused.length}) — an import does not resolve (run create-ailk sync-routes for the paths): ${routes.refused.join(", ")}`);
|
|
251
|
+
}
|
|
236
252
|
if (written.length > 0) {
|
|
237
253
|
lines.push(`Written (${written.length}):`);
|
|
238
254
|
lines.push(...written.map((row) => ` ${row.path}`));
|
|
@@ -255,10 +271,251 @@ export function formatAddRouteReport(result) {
|
|
|
255
271
|
}
|
|
256
272
|
return lines.join("\n") + "\n";
|
|
257
273
|
}
|
|
274
|
+
// ── add-route magnet (#8840 D12) ───────────────────────────────────────────
|
|
275
|
+
/** The route word that selects the magnet mode. */
|
|
276
|
+
export const MAGNET_ROUTE = "magnet";
|
|
277
|
+
/**
|
|
278
|
+
* The header-comment marker every standard magnet page carries — the same
|
|
279
|
+
* string `flows/[slug]/magnet-page.tsx` exports, which the site's
|
|
280
|
+
* `structured-data.test.tsx` reads to exempt the pair (#8840 D13).
|
|
281
|
+
*/
|
|
282
|
+
export const MAGNET_PAGE_MARKER = "Standard magnet page (#8840)";
|
|
283
|
+
/** The module whose renderers and flow routes a magnet pair mounts. */
|
|
284
|
+
const MAGNET_MODULE = "signal-collectors";
|
|
285
|
+
/**
|
|
286
|
+
* `flowSlugSchema`'s rule (`@working-theory/validation`), restated because
|
|
287
|
+
* create-ailk has no runtime dependency; `add-route-magnet.test.ts` pins the
|
|
288
|
+
* two equal over a fixed table.
|
|
289
|
+
*/
|
|
290
|
+
const FLOW_SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
291
|
+
const FLOW_SLUG_MAX = 59;
|
|
292
|
+
/** One to three kebab-case segments, nothing else (SEC-8840-J). */
|
|
293
|
+
const MAGNET_PATH_RE = /^\/[a-z0-9]+(-[a-z0-9]+)*(\/[a-z0-9]+(-[a-z0-9]+)*){0,2}$/;
|
|
294
|
+
/** A walk's own last segments: `<path>/start` is the pair's, `apply` the careers walks'. */
|
|
295
|
+
const RESERVED_LAST_SEGMENTS = new Set(["start", "apply"]);
|
|
296
|
+
/**
|
|
297
|
+
* First segments a pair may not take: the API and relay prefixes, the flows
|
|
298
|
+
* routes, the account and Admin areas, and `apps/web/lib/auth-routes.ts`'s
|
|
299
|
+
* `AUTH_SEGMENTS` (restated — create-ailk cannot import `apps/web`).
|
|
300
|
+
*/
|
|
301
|
+
const RESERVED_FIRST_SEGMENTS = new Set([
|
|
302
|
+
"api",
|
|
303
|
+
"v1",
|
|
304
|
+
"flows",
|
|
305
|
+
"account",
|
|
306
|
+
"admin",
|
|
307
|
+
"sign-in",
|
|
308
|
+
"sign-up",
|
|
309
|
+
"forgot-password",
|
|
310
|
+
"reset-password",
|
|
311
|
+
"verify-email",
|
|
312
|
+
]);
|
|
313
|
+
/** A first segment next-intl would read as a locale prefix. */
|
|
314
|
+
const LOCALE_SHAPED_RE = /^[a-z]{2}(-[a-z]{2})?$/;
|
|
315
|
+
/** Template-relative root every page directory sits under. */
|
|
316
|
+
const WEB_ROUTE_ROOT = "apps/web/app/[locale]";
|
|
317
|
+
/** Whether `slug` passes `flowSlugSchema`'s rule. */
|
|
318
|
+
export function isMagnetFlowSlug(slug) {
|
|
319
|
+
return slug.length <= FLOW_SLUG_MAX && FLOW_SLUG_RE.test(slug);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Write a magnet page pair — `apps/web/app/[locale]/<path>/page.tsx` (the
|
|
323
|
+
* landing) and `<path>/start/page.tsx` (the walk) — bound to one flow slug.
|
|
324
|
+
* Each page is a few lines over the factories in `flows/[slug]/magnet-page`;
|
|
325
|
+
* the copy, consent and ending come from the flow's record.
|
|
326
|
+
*
|
|
327
|
+
* Every refusal throws `AddRouteRefusedError` before the first write. A page
|
|
328
|
+
* that already exists is never overwritten: a second run reports both
|
|
329
|
+
* `skipped`. No `architecture.yaml`, nav or seed changes — the pair is the
|
|
330
|
+
* site's own, with no `ROUTE_SINCE` key or routes-map row (D13).
|
|
331
|
+
*/
|
|
332
|
+
export function addMagnetToScaffold(opts) {
|
|
333
|
+
const targetAbs = resolve(opts.targetDir);
|
|
334
|
+
const archPath = scaffoldArchitecturePath(targetAbs);
|
|
335
|
+
let modules;
|
|
336
|
+
try {
|
|
337
|
+
modules = readArchitectureHeader(readFileSync(archPath, "utf8")).modules;
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
if (err instanceof AddModuleRefusedError) {
|
|
341
|
+
throw new AddRouteRefusedError(err.message);
|
|
342
|
+
}
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
if (!modules.includes(MAGNET_MODULE)) {
|
|
346
|
+
throw new AddRouteRefusedError(`a magnet page mounts the "${MAGNET_MODULE}" module's flow stepper, which this site does not carry — add it with \`create-ailk add-module ${MAGNET_MODULE}\``);
|
|
347
|
+
}
|
|
348
|
+
if (!isMagnetFlowSlug(opts.flow)) {
|
|
349
|
+
throw new AddRouteRefusedError(`--flow "${opts.flow}" is not a flow slug: kebab-case (lowercase letters, digits and single hyphens), at most ${FLOW_SLUG_MAX} characters`);
|
|
350
|
+
}
|
|
351
|
+
const segments = magnetPathSegments(opts.path);
|
|
352
|
+
if (segments.length === 1) {
|
|
353
|
+
const shadowed = shadowedLandingPage(targetAbs, segments[0]);
|
|
354
|
+
if (shadowed !== undefined) {
|
|
355
|
+
throw new AddRouteRefusedError(`--path ${opts.path} would shadow the site's own page ${shadowed} — pick another path`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const routeDir = segments.join("/");
|
|
359
|
+
const landing = `${WEB_ROUTE_ROOT}/${routeDir}/page.tsx`;
|
|
360
|
+
const walk = `${WEB_ROUTE_ROOT}/${routeDir}/start/page.tsx`;
|
|
361
|
+
const served = staticPageServing(targetAbs, [routeDir, `${routeDir}/start`], {
|
|
362
|
+
ownPages: [landing, walk],
|
|
363
|
+
});
|
|
364
|
+
if (served !== undefined) {
|
|
365
|
+
throw new AddRouteRefusedError(`--path ${opts.path} is already served by ${served} — pick another path`);
|
|
366
|
+
}
|
|
367
|
+
const pages = [
|
|
368
|
+
[
|
|
369
|
+
landing,
|
|
370
|
+
renderMagnetPage("landing", opts.path, opts.flow, segments.length),
|
|
371
|
+
],
|
|
372
|
+
[walk, renderMagnetPage("walk", opts.path, opts.flow, segments.length + 1)],
|
|
373
|
+
];
|
|
374
|
+
const report = [];
|
|
375
|
+
for (const [path, text] of pages) {
|
|
376
|
+
const dest = join(targetAbs, path);
|
|
377
|
+
if (existsSync(dest)) {
|
|
378
|
+
report.push({ path, action: "skipped" });
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
382
|
+
writeFileSync(dest, text);
|
|
383
|
+
report.push({ path, action: "written" });
|
|
384
|
+
}
|
|
385
|
+
return { targetDir: targetAbs, path: opts.path, flow: opts.flow, report };
|
|
386
|
+
}
|
|
387
|
+
/** `--path`'s segments, refusing a path a pair may not take (SEC-8840-J). */
|
|
388
|
+
function magnetPathSegments(path) {
|
|
389
|
+
if (!MAGNET_PATH_RE.test(path)) {
|
|
390
|
+
throw new AddRouteRefusedError(`--path "${path}" is not a magnet path: one to three kebab-case segments after a leading slash, e.g. /diagnostic or /careers/writer`);
|
|
391
|
+
}
|
|
392
|
+
const segments = path.slice(1).split("/");
|
|
393
|
+
const first = segments[0];
|
|
394
|
+
const last = segments[segments.length - 1];
|
|
395
|
+
if (RESERVED_LAST_SEGMENTS.has(last)) {
|
|
396
|
+
throw new AddRouteRefusedError(`--path ${path} ends in "${last}", which a walk route uses — the pair's walk is written at <path>/start`);
|
|
397
|
+
}
|
|
398
|
+
if (RESERVED_FIRST_SEGMENTS.has(first) || LOCALE_SHAPED_RE.test(first)) {
|
|
399
|
+
throw new AddRouteRefusedError(`--path ${path} starts with "${first}", a segment the site reserves (the API, flows, account, Admin and sign-in routes, and locale prefixes)`);
|
|
400
|
+
}
|
|
401
|
+
return segments;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* The site's `content/<locale>/LandingPage/<segment>.mdx`, in any locale,
|
|
405
|
+
* that a one-segment pair would shadow (the generic `[slug]` route serves it).
|
|
406
|
+
*/
|
|
407
|
+
function shadowedLandingPage(targetAbs, segment) {
|
|
408
|
+
const contentRoot = join(targetAbs, "content");
|
|
409
|
+
if (!existsSync(contentRoot))
|
|
410
|
+
return undefined;
|
|
411
|
+
for (const entry of readdirSync(contentRoot, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
412
|
+
if (!entry.isDirectory())
|
|
413
|
+
continue;
|
|
414
|
+
const rel = `content/${entry.name}/LandingPage/${segment}.mdx`;
|
|
415
|
+
if (existsSync(join(targetAbs, rel)))
|
|
416
|
+
return rel;
|
|
417
|
+
}
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The first `page.tsx` under the site's `[locale]` tree whose directory, with
|
|
422
|
+
* route-group segments removed, is one of `dirs` — a path the site already
|
|
423
|
+
* serves statically. A dynamic segment never matches (`careers/[slug]` does
|
|
424
|
+
* not serve `careers/writer` once a static `careers/writer` exists), and the
|
|
425
|
+
* pair's own two files are skipped, so a rerun reaches the no-overwrite rule.
|
|
426
|
+
*/
|
|
427
|
+
function staticPageServing(targetAbs, dirs, { ownPages }) {
|
|
428
|
+
const root = join(targetAbs, WEB_ROUTE_ROOT);
|
|
429
|
+
const wanted = new Set(dirs);
|
|
430
|
+
const own = new Set(ownPages);
|
|
431
|
+
const walk = (abs) => {
|
|
432
|
+
if (!existsSync(abs))
|
|
433
|
+
return undefined;
|
|
434
|
+
const entries = readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
435
|
+
for (const entry of entries) {
|
|
436
|
+
const full = join(abs, entry.name);
|
|
437
|
+
if (entry.isDirectory()) {
|
|
438
|
+
if (entry.name === "__tests__" || entry.name === "node_modules")
|
|
439
|
+
continue;
|
|
440
|
+
const hit = walk(full);
|
|
441
|
+
if (hit !== undefined)
|
|
442
|
+
return hit;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (!entry.isFile() || entry.name !== "page.tsx")
|
|
446
|
+
continue;
|
|
447
|
+
const rel = relative(targetAbs, full).split(sep).join("/");
|
|
448
|
+
if (own.has(rel) &&
|
|
449
|
+
readFileSync(full, "utf8").includes(MAGNET_PAGE_MARKER)) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
const dir = relative(root, abs)
|
|
453
|
+
.split(sep)
|
|
454
|
+
.filter((segment) => segment !== "" && !/^\(.*\)$/.test(segment))
|
|
455
|
+
.join("/");
|
|
456
|
+
if (wanted.has(dir))
|
|
457
|
+
return rel;
|
|
458
|
+
}
|
|
459
|
+
return undefined;
|
|
460
|
+
};
|
|
461
|
+
return walk(root);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* One page of the pair. `depth` is the page directory's segment count under
|
|
465
|
+
* `[locale]`, so the import climbs back to `flows/[slug]/magnet-page`. Every
|
|
466
|
+
* interpolated value has passed `MAGNET_PATH_RE` or `FLOW_SLUG_RE`, so none
|
|
467
|
+
* can leave its string literal (SEC-8840-V5).
|
|
468
|
+
*/
|
|
469
|
+
function renderMagnetPage(kind, path, flow, depth) {
|
|
470
|
+
const [page, metadata, role] = kind === "landing"
|
|
471
|
+
? [
|
|
472
|
+
"magnetLanding",
|
|
473
|
+
"magnetLandingMetadata",
|
|
474
|
+
`the landing of the ${path} magnet pair, its copy from the ${flow} flow's record`,
|
|
475
|
+
]
|
|
476
|
+
: [
|
|
477
|
+
"magnetStart",
|
|
478
|
+
"magnetStartMetadata",
|
|
479
|
+
`the walk of the ${path} magnet pair, its back arrow to ${path}`,
|
|
480
|
+
];
|
|
481
|
+
return [
|
|
482
|
+
`// Generated by \`create-ailk add-route magnet --path ${path} --flow ${flow}\`.`,
|
|
483
|
+
`// ${MAGNET_PAGE_MARKER} — ${role}.`,
|
|
484
|
+
`import { ${page}, ${metadata} } from "${"../".repeat(depth)}flows/[slug]/magnet-page";`,
|
|
485
|
+
"",
|
|
486
|
+
`const MAGNET = { slug: "${flow}", path: "${path}" } as const;`,
|
|
487
|
+
"",
|
|
488
|
+
'export const dynamic = "force-dynamic";',
|
|
489
|
+
`export const generateMetadata = ${metadata}(MAGNET);`,
|
|
490
|
+
`export default ${page}(MAGNET);`,
|
|
491
|
+
"",
|
|
492
|
+
].join("\n");
|
|
493
|
+
}
|
|
494
|
+
/** The report `add-route magnet` prints. */
|
|
495
|
+
export function formatAddMagnetReport(result) {
|
|
496
|
+
const written = result.report.filter((row) => row.action === "written");
|
|
497
|
+
const skipped = result.report.filter((row) => row.action === "skipped");
|
|
498
|
+
const lines = [
|
|
499
|
+
`[create-ailk] add-route magnet ${result.path} (flow ${result.flow}) → ${result.targetDir}`,
|
|
500
|
+
];
|
|
501
|
+
if (written.length > 0) {
|
|
502
|
+
lines.push(`Written (${written.length}):`);
|
|
503
|
+
lines.push(...written.map((row) => ` ${row.path}`));
|
|
504
|
+
}
|
|
505
|
+
if (skipped.length > 0) {
|
|
506
|
+
lines.push(`Skipped (${skipped.length}) — the site already has this page, left untouched:`);
|
|
507
|
+
lines.push(...skipped.map((row) => ` ${row.path}`));
|
|
508
|
+
}
|
|
509
|
+
if (written.length > 0) {
|
|
510
|
+
lines.push(`Next: pnpm build, then open ${result.path}. The page's copy comes from the ${result.flow} flow's record.`);
|
|
511
|
+
}
|
|
512
|
+
return lines.join("\n") + "\n";
|
|
513
|
+
}
|
|
258
514
|
export const ADD_ROUTE_HELP = `create-ailk add-route — add a route family to an existing site.
|
|
259
515
|
|
|
260
516
|
Usage:
|
|
261
517
|
create-ailk add-route <route> [<target-dir>]
|
|
518
|
+
create-ailk add-route magnet --path <path> --flow <slug> [<target-dir>]
|
|
262
519
|
|
|
263
520
|
Arguments:
|
|
264
521
|
<route> One route family, named as --surfaces names it,
|
|
@@ -267,6 +524,9 @@ Arguments:
|
|
|
267
524
|
architecture.yaml). Defaults to the current dir.
|
|
268
525
|
|
|
269
526
|
Options:
|
|
527
|
+
--path <path> magnet only: the site path the landing serves,
|
|
528
|
+
one to three kebab-case segments, e.g. /diagnostic.
|
|
529
|
+
--flow <slug> magnet only: the flow slug the pages are bound to.
|
|
270
530
|
--help, -h Print this message.
|
|
271
531
|
|
|
272
532
|
Copies the route's pages, writes its seed content, declares it in
|
|
@@ -278,11 +538,25 @@ Like add-module, it also restores any other page route the site carries but
|
|
|
278
538
|
lacks. A route a module delivers (blog and docs come with docs-blog) is
|
|
279
539
|
refused; add that module with create-ailk add-module. Running it again changes
|
|
280
540
|
nothing.
|
|
541
|
+
|
|
542
|
+
add-route magnet writes a magnet page pair bound to one flow: a landing at
|
|
543
|
+
apps/web/app/[locale]/<path>/page.tsx and a full-screen walk at
|
|
544
|
+
<path>/start/page.tsx, each a few lines over the standard magnet pages, so the
|
|
545
|
+
copy, consent and ending come from the flow's record. It needs the
|
|
546
|
+
signal-collectors module, and refuses (nothing written) a path the site already
|
|
547
|
+
serves, a one-segment path a LandingPage seed of the same slug owns, a path
|
|
548
|
+
ending in start or apply, a reserved first segment (api, v1, flows, account,
|
|
549
|
+
admin, the sign-in routes, a locale) and a slug the flow API would refuse. A
|
|
550
|
+
page that exists is never overwritten: running it again skips both. It changes
|
|
551
|
+
no architecture.yaml, nav or seed.
|
|
281
552
|
`;
|
|
282
553
|
/**
|
|
283
554
|
* Parse the argv AFTER the `add-route` word. Strict `node:util` parseArgs,
|
|
284
555
|
* like `parseAddModuleArgs`; the route itself is validated by
|
|
285
556
|
* `addRouteToScaffold`, which refuses an unknown one naming the recognized.
|
|
557
|
+
* `--path` and `--flow` belong to the `magnet` route word alone (#8840 D12):
|
|
558
|
+
* with any other route they are refused (`AddRouteRefusedError`, exit 2),
|
|
559
|
+
* and `magnet` needs both. Their values are checked by `addMagnetToScaffold`.
|
|
286
560
|
*/
|
|
287
561
|
export function parseAddRouteArgs(argv) {
|
|
288
562
|
const parsed = parseArgs({
|
|
@@ -291,9 +565,12 @@ export function parseAddRouteArgs(argv) {
|
|
|
291
565
|
allowPositionals: true,
|
|
292
566
|
options: {
|
|
293
567
|
help: { type: "boolean", default: false, short: "h" },
|
|
568
|
+
path: { type: "string" },
|
|
569
|
+
flow: { type: "string" },
|
|
294
570
|
},
|
|
295
571
|
});
|
|
296
572
|
const help = parsed.values.help === true;
|
|
573
|
+
const { path, flow } = parsed.values;
|
|
297
574
|
const [route, target, ...rest] = parsed.positionals;
|
|
298
575
|
if (rest.length > 0) {
|
|
299
576
|
throw new ParseError(`expected a route and at most one target directory, got ${parsed.positionals.length} arguments`);
|
|
@@ -306,5 +583,16 @@ export function parseAddRouteArgs(argv) {
|
|
|
306
583
|
if (route.includes(",")) {
|
|
307
584
|
throw new ParseError(`add-route takes exactly one route, got "${route}" — run it once per route`);
|
|
308
585
|
}
|
|
309
|
-
|
|
586
|
+
if (route !== MAGNET_ROUTE) {
|
|
587
|
+
if (path !== undefined || flow !== undefined) {
|
|
588
|
+
throw new AddRouteRefusedError(`--path and --flow belong to \`create-ailk add-route magnet\`, not to the "${route}" route`);
|
|
589
|
+
}
|
|
590
|
+
return { route, target, help };
|
|
591
|
+
}
|
|
592
|
+
if (help)
|
|
593
|
+
return { route, target, help };
|
|
594
|
+
if (path === undefined || flow === undefined) {
|
|
595
|
+
throw new ParseError("add-route magnet needs --path and --flow, e.g. `create-ailk add-route magnet --path /diagnostic --flow growth`");
|
|
596
|
+
}
|
|
597
|
+
return { route, target, help, path, flow };
|
|
310
598
|
}
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* 0. on an `add-module` / `upgrade` subcommand: parse its own argv, run
|
|
7
7
|
* addModule(), print the report, exit (2 on a refusal it names)
|
|
8
8
|
* on an `add-route` subcommand: add one route surface to an existing
|
|
9
|
-
* site, print the report, exit (2 on a refusal it names) (#6947)
|
|
9
|
+
* site, print the report, exit (2 on a refusal it names) (#6947); with
|
|
10
|
+
* the `magnet` route word, write a magnet page pair instead (#8840)
|
|
10
11
|
* on an `adopt` subcommand: record an existing site's topology and
|
|
11
12
|
* pattern version in its manifest, print the report, exit (2 on a
|
|
12
13
|
* refusal it names) (#7875)
|
|
@@ -45,15 +46,17 @@
|
|
|
45
46
|
*/
|
|
46
47
|
import { spawnSync } from "node:child_process";
|
|
47
48
|
import { existsSync, readFileSync } from "node:fs";
|
|
49
|
+
import { homedir } from "node:os";
|
|
48
50
|
import { basename, dirname, resolve } from "node:path";
|
|
49
51
|
import { fileURLToPath } from "node:url";
|
|
50
52
|
import { ADD_MODULE_HELP, AddModuleRefusedError, formatAddModuleReport, parseAddModuleArgs, } from "./add-module.js";
|
|
51
|
-
import { ADD_ROUTE_HELP, AddRouteRefusedError, addRouteToScaffold, formatAddRouteReport, parseAddRouteArgs, } from "./add-route.js";
|
|
53
|
+
import { ADD_ROUTE_HELP, AddRouteRefusedError, MAGNET_ROUTE, addMagnetToScaffold, addRouteToScaffold, formatAddMagnetReport, formatAddRouteReport, parseAddRouteArgs, } from "./add-route.js";
|
|
52
54
|
import { ADOPT_HELP, AdoptRefusedError, adoptSite, formatAdoptReport, parseAdoptArgs, } from "./adopt.js";
|
|
53
55
|
import { APPLY_DESIGN_HELP, applyDesign, formatApplyDesignReport, parseApplyDesignArgs, } from "./apply-design.js";
|
|
54
56
|
import { CLAUDE_MD_CHECK_PATH } from "./claude-md.js";
|
|
55
57
|
import { buildScaffoldMarkers } from "./copy.js";
|
|
56
58
|
import { assertReleased } from "./lib/module-license-gate.js";
|
|
59
|
+
import { withNpmTokenUserConfig } from "./lib/npm-auth.js";
|
|
57
60
|
import { FREE_PREREQUISITES_NOTE, LICENSED_PREREQUISITES_NOTE, isLicensedInstall, proCallout, } from "./lib/pro-callout.js";
|
|
58
61
|
import { LICENSE_SET_HELP, runLicenseSet } from "./license-set.js";
|
|
59
62
|
import { PLUGIN_INSTALL_LINES, helpText, parseCliArgs, parseModules, resolveCliShape, toScaffoldOptions, } from "./parse-args.js";
|
|
@@ -147,14 +150,26 @@ async function main() {
|
|
|
147
150
|
// scaffolded without — add-module's route, architecture and nav steps with
|
|
148
151
|
// no licence and no bundle. A refusal it names (an unknown route, one a
|
|
149
152
|
// module delivers, an unreadable architecture.yaml) exits 2.
|
|
153
|
+
// `add-route magnet --path <path> --flow <slug> [dir]` (#8840 D12) writes a
|
|
154
|
+
// magnet page pair instead; its refusals (no signal-collectors, a path the
|
|
155
|
+
// site serves or reserves, a bad slug, --path/--flow on another route) exit 2.
|
|
150
156
|
if (argv[0] === "add-route") {
|
|
151
|
-
const args = parseAddRouteArgs(argv.slice(1));
|
|
152
|
-
if (args.help || args.route === undefined) {
|
|
153
|
-
process.stdout.write(ADD_ROUTE_HELP);
|
|
154
|
-
process.exit(0);
|
|
155
|
-
}
|
|
156
|
-
const targetDir = resolve(args.target ?? process.cwd());
|
|
157
157
|
try {
|
|
158
|
+
const args = parseAddRouteArgs(argv.slice(1));
|
|
159
|
+
if (args.help || args.route === undefined) {
|
|
160
|
+
process.stdout.write(ADD_ROUTE_HELP);
|
|
161
|
+
process.exit(0);
|
|
162
|
+
}
|
|
163
|
+
const targetDir = resolve(args.target ?? process.cwd());
|
|
164
|
+
if (args.route === MAGNET_ROUTE) {
|
|
165
|
+
const result = addMagnetToScaffold({
|
|
166
|
+
targetDir,
|
|
167
|
+
path: args.path ?? "",
|
|
168
|
+
flow: args.flow ?? "",
|
|
169
|
+
});
|
|
170
|
+
process.stdout.write(formatAddMagnetReport(result));
|
|
171
|
+
process.exit(0);
|
|
172
|
+
}
|
|
158
173
|
const result = addRouteToScaffold({
|
|
159
174
|
targetDir,
|
|
160
175
|
route: args.route,
|
|
@@ -428,11 +443,13 @@ async function main() {
|
|
|
428
443
|
const templateName = starter?.template ?? opts.template;
|
|
429
444
|
if (opts.install) {
|
|
430
445
|
// Hard-coded argv. User input only flows through `cwd`, never the command.
|
|
431
|
-
|
|
446
|
+
// NPM_TOKEN reaches pnpm at user level, never a project .npmrc (#9092).
|
|
447
|
+
const result = withNpmTokenUserConfig(process.env, homedir(), (env) => spawnSync("pnpm", ["install"], {
|
|
432
448
|
cwd: targetAbs,
|
|
449
|
+
env,
|
|
433
450
|
stdio: "inherit",
|
|
434
451
|
shell: false,
|
|
435
|
-
});
|
|
452
|
+
}));
|
|
436
453
|
if (result.status !== 0) {
|
|
437
454
|
throw new Error(`pnpm install failed in ${targetAbs} (exit ${result.status}). Run it manually after fixing the issue.`);
|
|
438
455
|
}
|
|
@@ -22,20 +22,22 @@ export interface DeriveArchitectureOptions {
|
|
|
22
22
|
/** Spoke only: whether the spoke keeps `apps/mcp` (default true). */
|
|
23
23
|
mcp?: boolean;
|
|
24
24
|
}
|
|
25
|
+
/** The billing action a spoke that signs in through its hub renders (#8217 D6). */
|
|
26
|
+
export declare const SPOKE_BILLING_ACTION_PATH = "apps/web/app/[locale]/(authed)/account/billing/spoke-billing.action.ts";
|
|
25
27
|
/**
|
|
26
28
|
* The only spoke files that may import @working-theory/spoke-checkout (#7873):
|
|
27
|
-
* the
|
|
28
|
-
*
|
|
29
|
+
* the billing action, on a spoke that signs in through its hub (#8217 D9).
|
|
30
|
+
* The buy route and the Stripe webhook route that were also here are retired
|
|
31
|
+
* (#9142): a spoke sells through its hub's Offerings buy route.
|
|
29
32
|
*/
|
|
30
33
|
export declare const SPOKE_CHECKOUT_ROUTE_FILES: readonly string[];
|
|
31
34
|
/**
|
|
32
35
|
* The spoke files that may import @working-theory/spoke-checkout to READ a
|
|
33
36
|
* paid session, and nothing else: the thank-you page's `readPaidCheckoutEmail`
|
|
34
|
-
* (#8757 D13).
|
|
35
|
-
* also admit them to `lib/checkout`, the one file that fulfils an order.
|
|
37
|
+
* (#8757 D13).
|
|
36
38
|
*/
|
|
37
39
|
export declare const SPOKE_CHECKOUT_READER_FILES: readonly string[];
|
|
38
|
-
/** The forbidden patterns a spoke's apps/web carries (#7873, brief Part 2 §2; #8748). */
|
|
40
|
+
/** The forbidden patterns a spoke's apps/web carries (#7873, brief Part 2 §2; #8748). The fulfilment pattern that guarded `lib/checkout.ts` retired with it (#9142). */
|
|
39
41
|
export declare const SPOKE_WEB_FORBIDDEN_PATTERNS: readonly ForbiddenPattern[];
|
|
40
42
|
/** The same three for a spoke's kept apps/mcp — no MCP file may import the package (#7873). */
|
|
41
43
|
export declare const SPOKE_MCP_FORBIDDEN_PATTERNS: readonly ForbiddenPattern[];
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { ARCHITECTURE_BASE, MODULE_SLICES, normalizeModules, } from "./module-architecture.js";
|
|
17
17
|
import { CORE_SURFACE_PATHS, RECOGNIZED_SURFACES, resolveSurfaces, } from "./surfaces.js";
|
|
18
|
+
/** The npm scope a site consumes and never forks (#9191). */
|
|
19
|
+
const PACKAGE_SCOPE = "@working-theory/";
|
|
18
20
|
/** A spoke's composition tiers (#7426 D8): its data and API are the hub's. */
|
|
19
21
|
const SPOKE_TIERS = {
|
|
20
22
|
data: "none — the hub's database",
|
|
@@ -27,21 +29,21 @@ const SPOKE_TIERS = {
|
|
|
27
29
|
// import only to a workspace on disk, so the one way to ban an npm package is
|
|
28
30
|
// a line-level forbidden pattern. These go under the spoke's own `apps.web`
|
|
29
31
|
// and `apps.mcp` only — never top level, and never on a hub derivation.
|
|
32
|
+
/** The billing action a spoke that signs in through its hub renders (#8217 D6). */
|
|
33
|
+
export const SPOKE_BILLING_ACTION_PATH = "apps/web/app/[locale]/(authed)/account/billing/spoke-billing.action.ts";
|
|
30
34
|
/**
|
|
31
35
|
* The only spoke files that may import @working-theory/spoke-checkout (#7873):
|
|
32
|
-
* the
|
|
33
|
-
*
|
|
36
|
+
* the billing action, on a spoke that signs in through its hub (#8217 D9).
|
|
37
|
+
* The buy route and the Stripe webhook route that were also here are retired
|
|
38
|
+
* (#9142): a spoke sells through its hub's Offerings buy route.
|
|
34
39
|
*/
|
|
35
40
|
export const SPOKE_CHECKOUT_ROUTE_FILES = Object.freeze([
|
|
36
|
-
|
|
37
|
-
"apps/web/app/api/webhooks/stripe/route.ts",
|
|
38
|
-
"apps/web/app/[locale]/(authed)/account/billing/spoke-billing.action.ts",
|
|
41
|
+
SPOKE_BILLING_ACTION_PATH,
|
|
39
42
|
]);
|
|
40
43
|
/**
|
|
41
44
|
* The spoke files that may import @working-theory/spoke-checkout to READ a
|
|
42
45
|
* paid session, and nothing else: the thank-you page's `readPaidCheckoutEmail`
|
|
43
|
-
* (#8757 D13).
|
|
44
|
-
* also admit them to `lib/checkout`, the one file that fulfils an order.
|
|
46
|
+
* (#8757 D13).
|
|
45
47
|
*/
|
|
46
48
|
export const SPOKE_CHECKOUT_READER_FILES = Object.freeze([
|
|
47
49
|
"apps/web/app/[locale]/checkout/thank-you/page.tsx",
|
|
@@ -62,7 +64,7 @@ function specifierForm(specifier) {
|
|
|
62
64
|
/** P1 with no exclusions — a kept apps/mcp's form; apps/web adds the route files. */
|
|
63
65
|
const SPOKE_CHECKOUT_PATTERN = Object.freeze({
|
|
64
66
|
pattern: specifierForm("@working-theory/spoke-checkout"),
|
|
65
|
-
reason: "Spoke checkout: only the
|
|
67
|
+
reason: "Spoke checkout: only the billing action and the thank-you page may import @working-theory/spoke-checkout (brief Part 2 §2, #7873, #8217, #8757, #9142)",
|
|
66
68
|
});
|
|
67
69
|
const STRIPE_CLIENT_PATTERN = Object.freeze({
|
|
68
70
|
pattern: specifierForm("@working-theory/stripe-client"),
|
|
@@ -72,29 +74,7 @@ const STRIPE_SDK_PATTERN = Object.freeze({
|
|
|
72
74
|
pattern: specifierForm("stripe"),
|
|
73
75
|
reason: "A spoke never imports the stripe SDK directly — it reaches Stripe only through @working-theory/spoke-checkout (#7873)",
|
|
74
76
|
});
|
|
75
|
-
/**
|
|
76
|
-
* The standard spoke checkout's fulfilment (`lib/checkout.ts`) sends the one
|
|
77
|
-
* `Idempotency-Key` the hub reads as a purchase, so only the files allowed to
|
|
78
|
-
* import the package may reach it (#8748 D3, SEC-8748-A): any relative or
|
|
79
|
-
* `@/`-aliased import (apps/web's tsconfig maps `@/*` to the app root) whose
|
|
80
|
-
* last segment is `checkout` (with or without a `.js`/`.ts`-family
|
|
81
|
-
* extension, which `bundler` resolution maps to the same file), in every form
|
|
82
|
-
* `specifierForm` covers. The
|
|
83
|
-
* closing quote straight after `checkout` keeps `checkout-config` and
|
|
84
|
-
* `checkout.actions` out of it. The checkout tests the writer copies are
|
|
85
|
-
* excluded too: the scaffold's lint reads test files.
|
|
86
|
-
*/
|
|
87
|
-
const SPOKE_FULFILMENT_PATTERN = Object.freeze({
|
|
88
|
-
pattern: "\\b(?:from|import|require)\\s*\\(?\\s*['\"`](?:(?:\\.{1,2}/)+|@/)(?:[^'\"`]*/)?checkout(?:\\.[cm]?[jt]sx?)?['\"`]",
|
|
89
|
-
paths_excluded: [
|
|
90
|
-
...SPOKE_CHECKOUT_ROUTE_FILES,
|
|
91
|
-
"apps/web/app/api/checkout/__tests__/**",
|
|
92
|
-
"apps/web/app/api/webhooks/stripe/__tests__/**",
|
|
93
|
-
"apps/web/lib/__tests__/checkout.test.ts",
|
|
94
|
-
],
|
|
95
|
-
reason: "Spoke checkout: only the buy route, the webhook route and the billing action may import lib/checkout, the one file that sends the hub an Idempotency-Key (#8748)",
|
|
96
|
-
});
|
|
97
|
-
/** The forbidden patterns a spoke's apps/web carries (#7873, brief Part 2 §2; #8748). */
|
|
77
|
+
/** The forbidden patterns a spoke's apps/web carries (#7873, brief Part 2 §2; #8748). The fulfilment pattern that guarded `lib/checkout.ts` retired with it (#9142). */
|
|
98
78
|
export const SPOKE_WEB_FORBIDDEN_PATTERNS = Object.freeze([
|
|
99
79
|
Object.freeze({
|
|
100
80
|
...SPOKE_CHECKOUT_PATTERN,
|
|
@@ -102,7 +82,6 @@ export const SPOKE_WEB_FORBIDDEN_PATTERNS = Object.freeze([
|
|
|
102
82
|
}),
|
|
103
83
|
STRIPE_CLIENT_PATTERN,
|
|
104
84
|
STRIPE_SDK_PATTERN,
|
|
105
|
-
SPOKE_FULFILMENT_PATTERN,
|
|
106
85
|
]);
|
|
107
86
|
/** The same three for a spoke's kept apps/mcp — no MCP file may import the package (#7873). */
|
|
108
87
|
export const SPOKE_MCP_FORBIDDEN_PATTERNS = Object.freeze([
|
|
@@ -337,6 +316,20 @@ export function deriveArchitecture(modules = ["marketing"], surfaces, options =
|
|
|
337
316
|
for (const s of slices)
|
|
338
317
|
extraForbidden.push(...(s.forbiddenPatterns ?? []));
|
|
339
318
|
const forbidden = mergeForbidden([...ARCHITECTURE_BASE.forbiddenPatterns], extraForbidden).map(scoped);
|
|
319
|
+
// The upgradeable-consumer rules (#9191): the workspaces this scaffold
|
|
320
|
+
// creates and the in-scope package names it gives them. The site lint
|
|
321
|
+
// reads this block to refuse a forked, patched or pinned-off package.
|
|
322
|
+
// Every app the scaffold ships is named `@working-theory/<dir>`.
|
|
323
|
+
const upgradeableConsumer = {
|
|
324
|
+
package_scope: PACKAGE_SCOPE,
|
|
325
|
+
workspaces: spoke ? ["apps/*"] : ["apps/*", "database"],
|
|
326
|
+
scaffold_packages: [
|
|
327
|
+
...(spoke ? [] : ["database"]),
|
|
328
|
+
...Object.keys(apps),
|
|
329
|
+
]
|
|
330
|
+
.map((dir) => `${PACKAGE_SCOPE}${dir}`)
|
|
331
|
+
.sort(),
|
|
332
|
+
};
|
|
340
333
|
const doc = {
|
|
341
334
|
version: ARCHITECTURE_BASE.version,
|
|
342
335
|
...(spoke ? { topology: "spoke" } : {}),
|
|
@@ -353,6 +346,7 @@ export function deriveArchitecture(modules = ["marketing"], surfaces, options =
|
|
|
353
346
|
apps,
|
|
354
347
|
...(nsSlice ? { namespaces: namespacesToYaml(nsSlice) } : {}),
|
|
355
348
|
forbidden_patterns: forbidden.map(forbiddenToYaml),
|
|
349
|
+
upgradeable_consumer: upgradeableConsumer,
|
|
356
350
|
};
|
|
357
351
|
const header = [
|
|
358
352
|
"# Architecture Boundaries — AI Launch Kit site",
|
|
@@ -134,11 +134,13 @@ export function admitSeededPeopleSlide(before, after) {
|
|
|
134
134
|
if (!Array.isArray(graph))
|
|
135
135
|
return after;
|
|
136
136
|
const [page, ...people] = graph;
|
|
137
|
+
// A seeded `{placeholder}` name or title never reaches the graph (#8797 D8.4).
|
|
138
|
+
const slot = (value) => /^\{[^{}]+\}$/.test(value.trim());
|
|
137
139
|
const expected = TEAM_SEED_MEMBERS.map((m) => ({
|
|
138
140
|
"@context": "https://schema.org",
|
|
139
141
|
"@type": "Person",
|
|
140
|
-
name: m.name,
|
|
141
|
-
jobTitle: m.role,
|
|
142
|
+
...(!slot(m.name) && { name: m.name }),
|
|
143
|
+
...(!slot(m.role) && { jobTitle: m.role }),
|
|
142
144
|
}));
|
|
143
145
|
const isPeopleSlide = isDeepStrictEqual(page, JSON.parse(standard.jsonld)) && isDeepStrictEqual(people, expected);
|
|
144
146
|
return isPeopleSlide ? { ...after, [HOME_PAGE]: standard } : after;
|
package/dist/lib/env-catalog.js
CHANGED
|
@@ -207,10 +207,6 @@ export const ENV_CATALOG = {
|
|
|
207
207
|
description: "Shared secret the /dev/purchase action sends to the API's checkout route; must equal the API's value. Server-only.",
|
|
208
208
|
secret: true,
|
|
209
209
|
},
|
|
210
|
-
SCHEDULING_CAL_LINK: {
|
|
211
|
-
description: 'Which event /meet books, as "<owner>/<event-slug>"; unset makes /meet 404.',
|
|
212
|
-
secret: false,
|
|
213
|
-
},
|
|
214
210
|
SENTRY_AUTH_TOKEN: {
|
|
215
211
|
description: "Build-time Sentry token that uploads source maps; unset skips the upload.",
|
|
216
212
|
secret: true,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The one user-level line: the registry mapped to the env var, no value. */
|
|
2
|
+
export declare const NPM_TOKEN_AUTH_LINE = "//registry.npmjs.org/:_authToken=${NPM_TOKEN}";
|
|
3
|
+
/**
|
|
4
|
+
* Calls `run` with the env the install should use: `env` itself, or — when
|
|
5
|
+
* `NPM_TOKEN` is set and no user npmrc exists — `env` plus
|
|
6
|
+
* `NPM_CONFIG_USERCONFIG` naming a temporary reference-only npmrc, which is
|
|
7
|
+
* removed once `run` returns or throws.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withNpmTokenUserConfig<T>(env: NodeJS.ProcessEnv, home: string, run: (env: NodeJS.ProcessEnv) => T): T;
|