@raybase/create 0.0.2 → 0.3.4
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/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/assets/apple-touch-icons/0.png +0 -0
- package/assets/apple-touch-icons/1.png +0 -0
- package/assets/apple-touch-icons/2.png +0 -0
- package/assets/apple-touch-icons/3.png +0 -0
- package/assets/apple-touch-icons/4.png +0 -0
- package/assets/apple-touch-icons/5.png +0 -0
- package/assets/apple-touch-icons/6.png +0 -0
- package/assets/apple-touch-icons/7.png +0 -0
- package/assets/apple-touch-icons/8.png +0 -0
- package/assets/apple-touch-icons/9.png +0 -0
- package/assets/apple-touch-icons/A.png +0 -0
- package/assets/apple-touch-icons/B.png +0 -0
- package/assets/apple-touch-icons/C.png +0 -0
- package/assets/apple-touch-icons/D.png +0 -0
- package/assets/apple-touch-icons/E.png +0 -0
- package/assets/apple-touch-icons/F.png +0 -0
- package/assets/apple-touch-icons/G.png +0 -0
- package/assets/apple-touch-icons/H.png +0 -0
- package/assets/apple-touch-icons/I.png +0 -0
- package/assets/apple-touch-icons/J.png +0 -0
- package/assets/apple-touch-icons/K.png +0 -0
- package/assets/apple-touch-icons/L.png +0 -0
- package/assets/apple-touch-icons/M.png +0 -0
- package/assets/apple-touch-icons/N.png +0 -0
- package/assets/apple-touch-icons/O.png +0 -0
- package/assets/apple-touch-icons/P.png +0 -0
- package/assets/apple-touch-icons/Q.png +0 -0
- package/assets/apple-touch-icons/R.png +0 -0
- package/assets/apple-touch-icons/S.png +0 -0
- package/assets/apple-touch-icons/T.png +0 -0
- package/assets/apple-touch-icons/U.png +0 -0
- package/assets/apple-touch-icons/V.png +0 -0
- package/assets/apple-touch-icons/W.png +0 -0
- package/assets/apple-touch-icons/X.png +0 -0
- package/assets/apple-touch-icons/Y.png +0 -0
- package/assets/apple-touch-icons/Z.png +0 -0
- package/assets/apple-touch-icons/default.png +0 -0
- package/dist/.source-hash +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2353 -0
- package/dist/index.js.map +1 -0
- package/dist/raybase-package-ranges.d.ts +11 -0
- package/dist/raybase-package-ranges.d.ts.map +1 -0
- package/dist/raybase-package-ranges.js +11 -0
- package/dist/raybase-package-ranges.js.map +1 -0
- package/dist/source-fetch.d.ts +91 -0
- package/dist/source-fetch.d.ts.map +1 -0
- package/dist/source-fetch.js +325 -0
- package/dist/source-fetch.js.map +1 -0
- package/dist/source-hash.d.ts +2 -0
- package/dist/source-hash.d.ts.map +1 -0
- package/dist/source-hash.js +23 -0
- package/dist/source-hash.js.map +1 -0
- package/dist/starter-description.d.ts +44 -0
- package/dist/starter-description.d.ts.map +1 -0
- package/dist/starter-description.js +273 -0
- package/dist/starter-description.js.map +1 -0
- package/dist/starter-source.d.ts +43 -0
- package/dist/starter-source.d.ts.map +1 -0
- package/dist/starter-source.js +156 -0
- package/dist/starter-source.js.map +1 -0
- package/dist/store-app-apply.d.ts +27 -0
- package/dist/store-app-apply.d.ts.map +1 -0
- package/dist/store-app-apply.js +100 -0
- package/dist/store-app-apply.js.map +1 -0
- package/dist/store-app-manifest.d.ts +86 -0
- package/dist/store-app-manifest.d.ts.map +1 -0
- package/dist/store-app-manifest.js +110 -0
- package/dist/store-app-manifest.js.map +1 -0
- package/dist/store-app-registry.d.ts +30 -0
- package/dist/store-app-registry.d.ts.map +1 -0
- package/dist/store-app-registry.js +232 -0
- package/dist/store-app-registry.js.map +1 -0
- package/models/recommended.json +42 -0
- package/modules/api/templates/react-router/app/api/operations.ts +8 -0
- package/modules/api/templates/tanstack-start/src/api/operations.ts +15 -0
- package/modules/docs/templates/astro-emdash/content/docs/getting-started.mdx +13 -0
- package/modules/docs/templates/astro-emdash/content/docs/index.mdx +13 -0
- package/modules/docs/templates/astro-emdash/content/docs/mcp.mdx +11 -0
- package/modules/docs/templates/astro-emdash/content/docs/meta.json +4 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/getting-started.mdx +12 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/index.mdx +12 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/mcp.mdx +10 -0
- package/modules/docs/templates/astro-emdash/site/content/docs/meta.json +4 -0
- package/modules/docs/templates/astro-emdash/site/source.config.ts +10 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-assets.ts +1 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-client.tsx +22 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-data.ts +24 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-handler.tsx +105 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-layout.tsx +56 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-mdx.tsx +79 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-page-actions.tsx +146 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/docs-page.tsx +70 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/llm-text.ts +61 -0
- package/modules/docs/templates/astro-emdash/site/src/docs/source.ts +7 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/docs/[...slug].ts +6 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/docs/api/markdown.ts +4 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/docs/api/search.ts +4 -0
- package/modules/docs/templates/astro-emdash/site/src/pages/llms.txt.ts +8 -0
- package/modules/docs/templates/astro-emdash/site/src/styles-docs.css +3 -0
- package/modules/docs/templates/astro-emdash/source.config.ts +10 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-assets.ts +1 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-client.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-data.ts +24 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-handler.tsx +105 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-layout.tsx +56 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-mdx.tsx +79 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-page-actions.tsx +146 -0
- package/modules/docs/templates/astro-emdash/src/docs/docs-page.tsx +70 -0
- package/modules/docs/templates/astro-emdash/src/docs/llm-text.ts +61 -0
- package/modules/docs/templates/astro-emdash/src/docs/source.ts +7 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs/$.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs/api/markdown.ts +12 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs/api/search.ts +12 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs.index.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/routes/docs.tsx +22 -0
- package/modules/docs/templates/astro-emdash/src/styles-docs.css +3 -0
- package/modules/docs/templates/react-router/app/components/mdx.tsx +79 -0
- package/modules/docs/templates/react-router/app/lib/layout.shared.tsx +54 -0
- package/modules/docs/templates/react-router/app/lib/source.ts +7 -0
- package/modules/docs/templates/react-router/app/routes/docs.$.tsx +49 -0
- package/modules/docs/templates/react-router/app/routes/docs.api.search.ts +10 -0
- package/modules/docs/templates/react-router/app/routes/docs.tsx +13 -0
- package/modules/docs/templates/react-router/content/docs/getting-started.mdx +8 -0
- package/modules/docs/templates/react-router/content/docs/index.mdx +8 -0
- package/modules/docs/templates/react-router/content/docs/mcp.mdx +121 -0
- package/modules/docs/templates/react-router/content/docs/meta.json +4 -0
- package/modules/docs/templates/react-router/source.config.ts +5 -0
- package/modules/docs/templates/tanstack-start/content/docs/getting-started.mdx +10 -0
- package/modules/docs/templates/tanstack-start/content/docs/index.mdx +8 -0
- package/modules/docs/templates/tanstack-start/content/docs/mcp.mdx +121 -0
- package/modules/docs/templates/tanstack-start/content/docs/meta.json +4 -0
- package/modules/docs/templates/tanstack-start/source.config.ts +10 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-assets.ts +1 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-client.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-data.ts +24 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-handler.tsx +105 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-layout.tsx +56 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-mdx.tsx +79 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-page-actions.tsx +146 -0
- package/modules/docs/templates/tanstack-start/src/docs/docs-page.tsx +70 -0
- package/modules/docs/templates/tanstack-start/src/docs/llm-text.ts +61 -0
- package/modules/docs/templates/tanstack-start/src/docs/source.ts +7 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs/$.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs/api/markdown.ts +12 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs/api/search.ts +12 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs.index.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/routes/docs.tsx +22 -0
- package/modules/docs/templates/tanstack-start/src/styles-docs.css +3 -0
- package/modules/guide/templates/astro-emdash/content/guide/capability-map.md +17 -0
- package/modules/guide/templates/astro-emdash/src/components/guide-widget.tsx +41 -0
- package/modules/guide/templates/astro-emdash/src/guide/actions.ts +8 -0
- package/modules/guide/templates/astro-emdash/src/guide/config.ts +21 -0
- package/modules/guide/templates/astro-emdash/src/guide/corpus.gen.ts +4 -0
- package/modules/guide/templates/astro-emdash/src/guide/corpus.manifest.json +72 -0
- package/modules/guide/templates/astro-emdash/src/guide/corpus.ts +4 -0
- package/modules/guide/templates/astro-emdash/src/guide/resources.json +4 -0
- package/modules/guide/templates/react-router/app/components/guide-widget.tsx +29 -0
- package/modules/guide/templates/react-router/app/guide/actions.ts +3 -0
- package/modules/guide/templates/react-router/app/guide/config.ts +21 -0
- package/modules/guide/templates/react-router/app/guide/corpus.gen.ts +4 -0
- package/modules/guide/templates/react-router/app/guide/corpus.manifest.json +22 -0
- package/modules/guide/templates/react-router/app/guide/corpus.ts +4 -0
- package/modules/guide/templates/react-router/app/guide/resources.json +4 -0
- package/modules/guide/templates/react-router/content/guide/capability-map.md +13 -0
- package/modules/guide/templates/tanstack-start/content/guide/capability-map.md +17 -0
- package/modules/guide/templates/tanstack-start/src/components/guide-widget.tsx +41 -0
- package/modules/guide/templates/tanstack-start/src/guide/actions.ts +17 -0
- package/modules/guide/templates/tanstack-start/src/guide/config.ts +21 -0
- package/modules/guide/templates/tanstack-start/src/guide/corpus.gen.ts +4 -0
- package/modules/guide/templates/tanstack-start/src/guide/corpus.manifest.json +22 -0
- package/modules/guide/templates/tanstack-start/src/guide/corpus.ts +4 -0
- package/modules/guide/templates/tanstack-start/src/guide/resources.json +4 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/SKILL.md +57 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/references/compatibility-and-testing.md +129 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/references/module-contract.md +133 -0
- package/modules/openai-subscription/templates/astro-emdash/.agents/skills/raybase-openai-subscription/references/structured-outputs.md +159 -0
- package/modules/openai-subscription/templates/astro-emdash/src/openai-subscription.ts +11 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/SKILL.md +57 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/references/compatibility-and-testing.md +129 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/references/module-contract.md +133 -0
- package/modules/openai-subscription/templates/react-router/.agents/skills/raybase-openai-subscription/references/structured-outputs.md +159 -0
- package/modules/openai-subscription/templates/react-router/app/openai-subscription.ts +11 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/SKILL.md +57 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/references/compatibility-and-testing.md +129 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/references/module-contract.md +133 -0
- package/modules/openai-subscription/templates/tanstack-start/.agents/skills/raybase-openai-subscription/references/structured-outputs.md +159 -0
- package/modules/openai-subscription/templates/tanstack-start/src/openai-subscription.ts +11 -0
- package/package.json +34 -8
- package/skills/README.md +122 -0
- package/skills/raybase-actions/SKILL.md +223 -0
- package/skills/raybase-actions/references/action-patterns.md +190 -0
- package/skills/raybase-actions/references/adapting-actions.md +93 -0
- package/skills/raybase-actions/references/testing-actions.md +48 -0
- package/skills/raybase-agent-debugging/SKILL.md +230 -0
- package/skills/raybase-ai/SKILL.md +1310 -0
- package/skills/raybase-api/SKILL.md +45 -0
- package/skills/raybase-astro-emdash/SKILL.md +143 -0
- package/skills/raybase-astro-emdash-content-model/SKILL.md +217 -0
- package/skills/raybase-astro-emdash-content-model/references/LICENSE-emdash +9 -0
- package/skills/raybase-astro-emdash-content-model/references/emdash-collections.md +265 -0
- package/skills/raybase-astro-emdash-design/LICENSE-impeccable +60 -0
- package/skills/raybase-astro-emdash-design/SKILL.md +170 -0
- package/skills/raybase-astro-emdash-design/reference/color.md +91 -0
- package/skills/raybase-astro-emdash-design/reference/copy.md +73 -0
- package/skills/raybase-astro-emdash-design/reference/direction.md +115 -0
- package/skills/raybase-astro-emdash-design/reference/imagery.md +84 -0
- package/skills/raybase-astro-emdash-design/reference/layout.md +69 -0
- package/skills/raybase-astro-emdash-design/reference/motion.md +75 -0
- package/skills/raybase-astro-emdash-design/reference/polish.md +75 -0
- package/skills/raybase-astro-emdash-design/reference/typography.md +72 -0
- package/skills/raybase-astro-emdash-galley/SKILL.md +265 -0
- package/skills/raybase-astro-emdash-migration/SKILL.md +218 -0
- package/skills/raybase-astro-emdash-migration/references/inventory-and-conversion.md +242 -0
- package/skills/raybase-astro-emdash-security-review/SKILL.md +68 -0
- package/skills/raybase-astro-emdash-theme-selection/SKILL.md +216 -0
- package/skills/raybase-auth/SKILL.md +358 -0
- package/skills/raybase-background-jobs/SKILL.md +774 -0
- package/skills/raybase-building/SKILL.md +409 -0
- package/skills/raybase-building/references/interview-and-spec.md +87 -0
- package/skills/raybase-building/references/planning-docs.md +26 -0
- package/skills/raybase-building/references/schema-and-config.md +70 -0
- package/skills/raybase-changing-a-live-app/SKILL.md +119 -0
- package/skills/raybase-data-and-policies/SKILL.md +377 -0
- package/skills/raybase-deploy/SKILL.md +136 -0
- package/skills/raybase-docs-writing/SKILL.md +119 -0
- package/skills/raybase-guide/SKILL.md +235 -0
- package/skills/raybase-mcp/SKILL.md +309 -0
- package/skills/raybase-mcp/agents/openai.yaml +4 -0
- package/skills/raybase-notifications/SKILL.md +138 -0
- package/skills/raybase-pro-migration/SKILL.md +28 -0
- package/skills/raybase-react-router/SKILL.md +241 -0
- package/skills/raybase-react-router-design/LICENSE-impeccable +60 -0
- package/skills/raybase-react-router-design/SKILL.md +135 -0
- package/skills/raybase-react-router-design/reference/color.md +87 -0
- package/skills/raybase-react-router-design/reference/copy.md +83 -0
- package/skills/raybase-react-router-design/reference/delight.md +48 -0
- package/skills/raybase-react-router-design/reference/interaction.md +91 -0
- package/skills/raybase-react-router-design/reference/layout.md +82 -0
- package/skills/raybase-react-router-design/reference/motion.md +86 -0
- package/skills/raybase-react-router-design/reference/polish.md +79 -0
- package/skills/raybase-react-router-design/reference/typography.md +71 -0
- package/skills/raybase-react-router-security-review/LICENSE +22 -0
- package/skills/raybase-react-router-security-review/SKILL.md +190 -0
- package/skills/raybase-react-router-security-review/agents/openai.yaml +4 -0
- package/skills/raybase-react-router-security-review/references/api-security.md +519 -0
- package/skills/raybase-react-router-security-review/references/authentication.md +353 -0
- package/skills/raybase-react-router-security-review/references/authorization.md +372 -0
- package/skills/raybase-react-router-security-review/references/business-logic.md +443 -0
- package/skills/raybase-react-router-security-review/references/cryptography.md +329 -0
- package/skills/raybase-react-router-security-review/references/csrf.md +398 -0
- package/skills/raybase-react-router-security-review/references/data-protection.md +378 -0
- package/skills/raybase-react-router-security-review/references/deserialization.md +410 -0
- package/skills/raybase-react-router-security-review/references/error-handling.md +436 -0
- package/skills/raybase-react-router-security-review/references/file-security.md +457 -0
- package/skills/raybase-react-router-security-review/references/injection.md +259 -0
- package/skills/raybase-react-router-security-review/references/logging.md +433 -0
- package/skills/raybase-react-router-security-review/references/misconfiguration.md +435 -0
- package/skills/raybase-react-router-security-review/references/modern-threats.md +475 -0
- package/skills/raybase-react-router-security-review/references/raybase-react-router-security.md +235 -0
- package/skills/raybase-react-router-security-review/references/ssrf.md +413 -0
- package/skills/raybase-react-router-security-review/references/supply-chain.md +405 -0
- package/skills/raybase-react-router-security-review/references/xss.md +336 -0
- package/skills/raybase-realtime/SKILL.md +158 -0
- package/skills/raybase-realtime/agents/openai.yaml +4 -0
- package/skills/raybase-schema/SKILL.md +209 -0
- package/skills/raybase-search/SKILL.md +137 -0
- package/skills/raybase-search/agents/openai.yaml +4 -0
- package/skills/raybase-settings/SKILL.md +139 -0
- package/skills/raybase-settings/agents/openai.yaml +4 -0
- package/skills/raybase-tanstack-start/SKILL.md +166 -0
- package/skills/raybase-tanstack-start-design/LICENSE-impeccable +60 -0
- package/skills/raybase-tanstack-start-design/SKILL.md +140 -0
- package/skills/raybase-tanstack-start-design/reference/color.md +80 -0
- package/skills/raybase-tanstack-start-design/reference/copy.md +83 -0
- package/skills/raybase-tanstack-start-design/reference/delight.md +48 -0
- package/skills/raybase-tanstack-start-design/reference/interaction.md +91 -0
- package/skills/raybase-tanstack-start-design/reference/layout.md +82 -0
- package/skills/raybase-tanstack-start-design/reference/motion.md +86 -0
- package/skills/raybase-tanstack-start-design/reference/polish.md +79 -0
- package/skills/raybase-tanstack-start-design/reference/typography.md +71 -0
- package/skills/raybase-tanstack-start-security-review/LICENSE +22 -0
- package/skills/raybase-tanstack-start-security-review/SKILL.md +194 -0
- package/skills/raybase-tanstack-start-security-review/agents/openai.yaml +4 -0
- package/skills/raybase-tanstack-start-security-review/references/api-security.md +519 -0
- package/skills/raybase-tanstack-start-security-review/references/authentication.md +353 -0
- package/skills/raybase-tanstack-start-security-review/references/authorization.md +372 -0
- package/skills/raybase-tanstack-start-security-review/references/business-logic.md +443 -0
- package/skills/raybase-tanstack-start-security-review/references/cryptography.md +329 -0
- package/skills/raybase-tanstack-start-security-review/references/csrf.md +398 -0
- package/skills/raybase-tanstack-start-security-review/references/data-protection.md +378 -0
- package/skills/raybase-tanstack-start-security-review/references/deserialization.md +410 -0
- package/skills/raybase-tanstack-start-security-review/references/error-handling.md +436 -0
- package/skills/raybase-tanstack-start-security-review/references/file-security.md +457 -0
- package/skills/raybase-tanstack-start-security-review/references/injection.md +259 -0
- package/skills/raybase-tanstack-start-security-review/references/logging.md +433 -0
- package/skills/raybase-tanstack-start-security-review/references/misconfiguration.md +435 -0
- package/skills/raybase-tanstack-start-security-review/references/modern-threats.md +475 -0
- package/skills/raybase-tanstack-start-security-review/references/raybase-tanstack-security.md +208 -0
- package/skills/raybase-tanstack-start-security-review/references/ssrf.md +413 -0
- package/skills/raybase-tanstack-start-security-review/references/supply-chain.md +405 -0
- package/skills/raybase-tanstack-start-security-review/references/xss.md +336 -0
- package/skills-manifest.json +41 -0
- package/templates/astro-emdash/.dev.vars.example +7 -0
- package/templates/astro-emdash/AGENTS.md +122 -0
- package/templates/astro-emdash/DESIGN.md +90 -0
- package/templates/astro-emdash/components.json +21 -0
- package/templates/astro-emdash/content/docs/getting-started.mdx +20 -0
- package/templates/astro-emdash/content/docs/index.mdx +13 -0
- package/templates/astro-emdash/content/docs/mcp.mdx +11 -0
- package/templates/astro-emdash/content/docs/meta.json +4 -0
- package/templates/astro-emdash/content/docs/site-templates.mdx +62 -0
- package/templates/astro-emdash/dev/CODEBASE-MAP.md +46 -0
- package/templates/astro-emdash/dev/SPEC-OVERVIEW.md +15 -0
- package/templates/astro-emdash/dev/SPEC.md +84 -0
- package/templates/astro-emdash/dev/features/archive/.gitkeep +1 -0
- package/templates/astro-emdash/docs/theme-previews/base.svg +24 -0
- package/templates/astro-emdash/docs/theme-previews/steel.svg +24 -0
- package/templates/astro-emdash/docs/theme-previews/zen.svg +24 -0
- package/templates/astro-emdash/docs/themes.md +106 -0
- package/templates/astro-emdash/drizzle.config.ts +5 -0
- package/templates/astro-emdash/gitignore +11 -0
- package/templates/astro-emdash/migrations/app/meta/_journal.json +5 -0
- package/templates/astro-emdash/package.json +79 -0
- package/templates/astro-emdash/pnpm-workspace.yaml +71 -0
- package/templates/astro-emdash/public/_headers +4 -0
- package/templates/astro-emdash/site/astro.config.mjs +120 -0
- package/templates/astro-emdash/site/demo/README.md +72 -0
- package/templates/astro-emdash/site/demo/content/collection.json +43 -0
- package/templates/astro-emdash/site/demo/content/entries.json +120 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-card/manifest.json +51 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-card/sample-content.json +5 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-card/template.liquid +48 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/host.json +9 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/manifest.json +38 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/sample-content.json +34 -0
- package/templates/astro-emdash/site/demo/templates/demo-article-page/template.liquid +84 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/manifest.json +64 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/page.json +7 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/sample-content.json +24 -0
- package/templates/astro-emdash/site/demo/templates/demo-articles-index/template.liquid +100 -0
- package/templates/astro-emdash/site/demo/templates/demo-menu-nav/manifest.json +51 -0
- package/templates/astro-emdash/site/demo/templates/demo-menu-nav/sample-content.json +5 -0
- package/templates/astro-emdash/site/demo/templates/demo-menu-nav/template.liquid +70 -0
- package/templates/astro-emdash/site/gitignore +1 -0
- package/templates/astro-emdash/site/package.json +56 -0
- package/templates/astro-emdash/site/scripts/apply-site-templates.mjs +560 -0
- package/templates/astro-emdash/site/scripts/galley-demo.mjs +298 -0
- package/templates/astro-emdash/site/scripts/seed-galley-starter.mjs +360 -0
- package/templates/astro-emdash/site/scripts/site-origin.mjs +45 -0
- package/templates/astro-emdash/site/seed/seed.json +154 -0
- package/templates/astro-emdash/site/seed/templates/.gitkeep +1 -0
- package/templates/astro-emdash/site/src/components/RaybaseSignedInMenu.astro +163 -0
- package/templates/astro-emdash/site/src/components/blocks/RaybaseActionIsland.astro +41 -0
- package/templates/astro-emdash/site/src/content-door/raybase-routes.ts +738 -0
- package/templates/astro-emdash/site/src/content-door/resolve-page.ts +142 -0
- package/templates/astro-emdash/site/src/content-door/seed.ts +85 -0
- package/templates/astro-emdash/site/src/env.d.ts +12 -0
- package/templates/astro-emdash/site/src/layouts/SiteLayout.astro +68 -0
- package/templates/astro-emdash/site/src/lib/palettes.gen.ts +7 -0
- package/templates/astro-emdash/site/src/lib/site-motion.ts +169 -0
- package/templates/astro-emdash/site/src/lib/site-shell.ts +294 -0
- package/templates/astro-emdash/site/src/live.config.ts +8 -0
- package/templates/astro-emdash/site/src/middleware.ts +20 -0
- package/templates/astro-emdash/site/src/pages/[...slug].astro +113 -0
- package/templates/astro-emdash/site/src/pages/_raybase/handoff/consume.ts +6 -0
- package/templates/astro-emdash/site/src/pages/_raybase/islands/action.ts +8 -0
- package/templates/astro-emdash/site/src/pages/_raybase/sign-out/index.ts +6 -0
- package/templates/astro-emdash/site/src/styles/palette-fonts.gen.css +1 -0
- package/templates/astro-emdash/site/src/styles/palettes.gen.css +3 -0
- package/templates/astro-emdash/site/src/styles.css +607 -0
- package/templates/astro-emdash/site/tsconfig.json +12 -0
- package/templates/astro-emdash/site/wrangler.jsonc +34 -0
- package/templates/astro-emdash/source.config.ts +10 -0
- package/templates/astro-emdash/src/actions.ts +58 -0
- package/templates/astro-emdash/src/ai/agents.ts +20 -0
- package/templates/astro-emdash/src/ai/retrieval.ts +36 -0
- package/templates/astro-emdash/src/auth-door.ts +18 -0
- package/templates/astro-emdash/src/client.tsx +25 -0
- package/templates/astro-emdash/src/components/.gitkeep +1 -0
- package/templates/astro-emdash/src/components/account-menu.tsx +91 -0
- package/templates/astro-emdash/src/components/auth-shell.tsx +69 -0
- package/templates/astro-emdash/src/components/mode-toggle.tsx +32 -0
- package/templates/astro-emdash/src/components/search-command-palette.tsx +107 -0
- package/templates/astro-emdash/src/components/setup-token-page.tsx +196 -0
- package/templates/astro-emdash/src/components/ui/avatar.tsx +107 -0
- package/templates/astro-emdash/src/components/ui/badge.tsx +52 -0
- package/templates/astro-emdash/src/components/ui/button.tsx +69 -0
- package/templates/astro-emdash/src/components/ui/checkbox.tsx +29 -0
- package/templates/astro-emdash/src/components/ui/dialog.tsx +158 -0
- package/templates/astro-emdash/src/components/ui/dropdown-menu.tsx +303 -0
- package/templates/astro-emdash/src/components/ui/input.tsx +20 -0
- package/templates/astro-emdash/src/components/ui/label.tsx +20 -0
- package/templates/astro-emdash/src/components/ui/scroll-area.tsx +53 -0
- package/templates/astro-emdash/src/components/ui/select.tsx +215 -0
- package/templates/astro-emdash/src/components/ui/separator.tsx +23 -0
- package/templates/astro-emdash/src/components/ui/sheet.tsx +138 -0
- package/templates/astro-emdash/src/components/ui/sidebar.tsx +728 -0
- package/templates/astro-emdash/src/components/ui/skeleton.tsx +13 -0
- package/templates/astro-emdash/src/components/ui/textarea.tsx +18 -0
- package/templates/astro-emdash/src/components/ui/tooltip.tsx +66 -0
- package/templates/astro-emdash/src/db/migrations.gen.ts +6 -0
- package/templates/astro-emdash/src/db/schema.ts +6 -0
- package/templates/astro-emdash/src/db/seed.ts +16 -0
- package/templates/astro-emdash/src/db/storage.ts +32 -0
- package/templates/astro-emdash/src/docs/docs-assets.ts +1 -0
- package/templates/astro-emdash/src/docs/docs-client.tsx +22 -0
- package/templates/astro-emdash/src/docs/docs-data.ts +24 -0
- package/templates/astro-emdash/src/docs/docs-handler.tsx +105 -0
- package/templates/astro-emdash/src/docs/docs-layout.tsx +56 -0
- package/templates/astro-emdash/src/docs/docs-mdx.tsx +79 -0
- package/templates/astro-emdash/src/docs/docs-page-actions.tsx +146 -0
- package/templates/astro-emdash/src/docs/docs-page.tsx +70 -0
- package/templates/astro-emdash/src/docs/llm-text.ts +61 -0
- package/templates/astro-emdash/src/docs/source.ts +7 -0
- package/templates/astro-emdash/src/guide/corpus.gen.ts +4 -0
- package/templates/astro-emdash/src/guide/corpus.manifest.json +72 -0
- package/templates/astro-emdash/src/hooks/use-mobile.ts +19 -0
- package/templates/astro-emdash/src/jobs.example.ts +48 -0
- package/templates/astro-emdash/src/lib/account.ts +12 -0
- package/templates/astro-emdash/src/lib/auth-client.ts +181 -0
- package/templates/astro-emdash/src/lib/utils.ts +6 -0
- package/templates/astro-emdash/src/mcp-app.ts +57 -0
- package/templates/astro-emdash/src/notifications.example.ts +37 -0
- package/templates/astro-emdash/src/raybase.auth.ts +70 -0
- package/templates/astro-emdash/src/raybase.config.ts +49 -0
- package/templates/astro-emdash/src/raybase.server.ts +56 -0
- package/templates/astro-emdash/src/realtime.example.ts +18 -0
- package/templates/astro-emdash/src/router.tsx +19 -0
- package/templates/astro-emdash/src/routes/__root.tsx +56 -0
- package/templates/astro-emdash/src/routes/_app/admin.tsx +13 -0
- package/templates/astro-emdash/src/routes/_app/forgot-password.tsx +97 -0
- package/templates/astro-emdash/src/routes/_app/index.tsx +169 -0
- package/templates/astro-emdash/src/routes/_app/invite.$token.tsx +11 -0
- package/templates/astro-emdash/src/routes/_app/login.tsx +193 -0
- package/templates/astro-emdash/src/routes/_app/profile.tsx +98 -0
- package/templates/astro-emdash/src/routes/_app/reset-password.$token.tsx +15 -0
- package/templates/astro-emdash/src/routes/_app/reset-password.tsx +115 -0
- package/templates/astro-emdash/src/routes/_app/setup.$token.tsx +11 -0
- package/templates/astro-emdash/src/routes/_app/signup.tsx +141 -0
- package/templates/astro-emdash/src/routes/_app/verify-email.$token.tsx +15 -0
- package/templates/astro-emdash/src/routes/_app/verify-email.tsx +154 -0
- package/templates/astro-emdash/src/routes/_app.tsx +33 -0
- package/templates/astro-emdash/src/routes/admin/$.ts +20 -0
- package/templates/astro-emdash/src/routes/api/$.ts +19 -0
- package/templates/astro-emdash/src/routes/docs/$.tsx +22 -0
- package/templates/astro-emdash/src/routes/docs/api/markdown.ts +12 -0
- package/templates/astro-emdash/src/routes/docs/api/search.ts +12 -0
- package/templates/astro-emdash/src/routes/docs.index.tsx +22 -0
- package/templates/astro-emdash/src/routes/docs.tsx +22 -0
- package/templates/astro-emdash/src/search.ts +6 -0
- package/templates/astro-emdash/src/settings.ts +12 -0
- package/templates/astro-emdash/src/styles-docs.css +3 -0
- package/templates/astro-emdash/src/styles.css +101 -0
- package/templates/astro-emdash/src/themes/base.css +76 -0
- package/templates/astro-emdash/src/themes/carbon.css +76 -0
- package/templates/astro-emdash/src/themes/fonts.css +25 -0
- package/templates/astro-emdash/src/themes/sage.css +76 -0
- package/templates/astro-emdash/src/themes/sand.css +76 -0
- package/templates/astro-emdash/src/themes/slate.css +81 -0
- package/templates/astro-emdash/src/themes/ultra.css +76 -0
- package/templates/astro-emdash/src/themes/zen.css +76 -0
- package/templates/astro-emdash/src/worker-entry.ts +31 -0
- package/templates/astro-emdash/tests/raybase-patterns.test.ts +29 -0
- package/templates/astro-emdash/tsconfig.json +36 -0
- package/templates/astro-emdash/vite.config.ts +130 -0
- package/templates/astro-emdash/vitest.config.ts +8 -0
- package/templates/astro-emdash/wrangler.jsonc +112 -0
- package/templates/react-router/.dev.vars.example +5 -0
- package/templates/react-router/.editorconfig +15 -0
- package/templates/react-router/AGENTS.md +54 -0
- package/templates/react-router/README.md +52 -0
- package/templates/react-router/app/app.css +44 -0
- package/templates/react-router/app/components/mdx.tsx +79 -0
- package/templates/react-router/app/components/ui/button.tsx +45 -0
- package/templates/react-router/app/components/ui/card.tsx +87 -0
- package/templates/react-router/app/components/ui/separator.tsx +22 -0
- package/templates/react-router/app/db/migrations.gen.ts +6 -0
- package/templates/react-router/app/db/schema.ts +56 -0
- package/templates/react-router/app/db/seed.ts +14 -0
- package/templates/react-router/app/entry.server.tsx +41 -0
- package/templates/react-router/app/globals.d.ts +1 -0
- package/templates/react-router/app/lib/layout.shared.tsx +52 -0
- package/templates/react-router/app/lib/source.ts +7 -0
- package/templates/react-router/app/lib/utils.ts +6 -0
- package/templates/react-router/app/raybase.server.ts +65 -0
- package/templates/react-router/app/root.tsx +23 -0
- package/templates/react-router/app/routes/_index.tsx +53 -0
- package/templates/react-router/app/routes/docs.$.tsx +49 -0
- package/templates/react-router/app/routes/docs.api.search.ts +10 -0
- package/templates/react-router/app/routes/docs.tsx +13 -0
- package/templates/react-router/app/routes.ts +3 -0
- package/templates/react-router/components.json +22 -0
- package/templates/react-router/content/docs/getting-started.mdx +15 -0
- package/templates/react-router/content/docs/index.mdx +8 -0
- package/templates/react-router/content/docs/mcp.mdx +121 -0
- package/templates/react-router/content/docs/meta.json +4 -0
- package/templates/react-router/dev/CODEBASE-MAP.md +48 -0
- package/templates/react-router/dev/SPEC-OVERVIEW.md +35 -0
- package/templates/react-router/dev/SPEC.md +93 -0
- package/templates/react-router/dev/features/archive/.gitkeep +1 -0
- package/templates/react-router/drizzle.config.ts +5 -0
- package/templates/react-router/env.d.ts +53 -0
- package/templates/react-router/gitignore +23 -0
- package/templates/react-router/migrations/app/meta/_journal.json +1 -0
- package/templates/react-router/package.json +70 -0
- package/templates/react-router/public/_headers +4 -0
- package/templates/react-router/public/favicon.ico +0 -0
- package/templates/react-router/react-router.config.ts +9 -0
- package/templates/react-router/source.config.ts +5 -0
- package/templates/react-router/tests/raybase-patterns.test.ts +23 -0
- package/templates/react-router/tsconfig.json +27 -0
- package/templates/react-router/vite.config.ts +59 -0
- package/templates/react-router/vitest.config.ts +8 -0
- package/templates/react-router/workers/app.ts +40 -0
- package/templates/react-router/wrangler.jsonc +111 -0
- package/templates/tanstack-start/.dev.vars.example +5 -0
- package/templates/tanstack-start/AGENTS.md +95 -0
- package/templates/tanstack-start/DESIGN.md +65 -0
- package/templates/tanstack-start/components.json +21 -0
- package/templates/tanstack-start/content/docs/getting-started.mdx +65 -0
- package/templates/tanstack-start/content/docs/index.mdx +10 -0
- package/templates/tanstack-start/content/docs/mcp.mdx +122 -0
- package/templates/tanstack-start/content/docs/meta.json +4 -0
- package/templates/tanstack-start/dev/CODEBASE-MAP.md +84 -0
- package/templates/tanstack-start/dev/SPEC-OVERVIEW.md +46 -0
- package/templates/tanstack-start/dev/SPEC.md +213 -0
- package/templates/tanstack-start/dev/features/archive/.gitkeep +1 -0
- package/templates/tanstack-start/docs/theme-previews/base.svg +24 -0
- package/templates/tanstack-start/docs/theme-previews/steel.svg +24 -0
- package/templates/tanstack-start/docs/theme-previews/zen.svg +24 -0
- package/templates/tanstack-start/docs/themes.md +116 -0
- package/templates/tanstack-start/drizzle.config.ts +5 -0
- package/templates/tanstack-start/gitignore +11 -0
- package/templates/tanstack-start/migrations/app/0000_low_karen_page.sql +26 -0
- package/templates/tanstack-start/migrations/app/meta/0000_snapshot.json +196 -0
- package/templates/tanstack-start/migrations/app/meta/_journal.json +13 -0
- package/templates/tanstack-start/package.json +77 -0
- package/templates/tanstack-start/public/_headers +8 -0
- package/templates/tanstack-start/public/icons/app-icon-maskable.svg +1 -0
- package/templates/tanstack-start/public/icons/app-icon.svg +1 -0
- package/templates/tanstack-start/public/icons/apple-touch-icon.png +0 -0
- package/templates/tanstack-start/public/manifest.webmanifest +14 -0
- package/templates/tanstack-start/public/raybase-push-sw.js +32 -0
- package/templates/tanstack-start/source.config.ts +10 -0
- package/templates/tanstack-start/src/actions.ts +560 -0
- package/templates/tanstack-start/src/ai/agents.ts +78 -0
- package/templates/tanstack-start/src/ai/retrieval.ts +36 -0
- package/templates/tanstack-start/src/auth-door.ts +18 -0
- package/templates/tanstack-start/src/client.tsx +25 -0
- package/templates/tanstack-start/src/components/.gitkeep +1 -0
- package/templates/tanstack-start/src/components/account-menu.tsx +127 -0
- package/templates/tanstack-start/src/components/auth-shell.tsx +69 -0
- package/templates/tanstack-start/src/components/install-app.tsx +35 -0
- package/templates/tanstack-start/src/components/mode-toggle.tsx +32 -0
- package/templates/tanstack-start/src/components/search-command-palette.tsx +107 -0
- package/templates/tanstack-start/src/components/setup-token-page.tsx +197 -0
- package/templates/tanstack-start/src/components/ui/avatar.tsx +107 -0
- package/templates/tanstack-start/src/components/ui/badge.tsx +52 -0
- package/templates/tanstack-start/src/components/ui/button.tsx +69 -0
- package/templates/tanstack-start/src/components/ui/checkbox.tsx +29 -0
- package/templates/tanstack-start/src/components/ui/dialog.tsx +158 -0
- package/templates/tanstack-start/src/components/ui/dropdown-menu.tsx +303 -0
- package/templates/tanstack-start/src/components/ui/input.tsx +20 -0
- package/templates/tanstack-start/src/components/ui/label.tsx +20 -0
- package/templates/tanstack-start/src/components/ui/scroll-area.tsx +53 -0
- package/templates/tanstack-start/src/components/ui/select.tsx +215 -0
- package/templates/tanstack-start/src/components/ui/separator.tsx +23 -0
- package/templates/tanstack-start/src/components/ui/sheet.tsx +138 -0
- package/templates/tanstack-start/src/components/ui/sidebar.tsx +728 -0
- package/templates/tanstack-start/src/components/ui/skeleton.tsx +13 -0
- package/templates/tanstack-start/src/components/ui/textarea.tsx +18 -0
- package/templates/tanstack-start/src/components/ui/tooltip.tsx +66 -0
- package/templates/tanstack-start/src/db/migrations.gen.ts +6 -0
- package/templates/tanstack-start/src/db/schema.ts +90 -0
- package/templates/tanstack-start/src/db/seed.ts +106 -0
- package/templates/tanstack-start/src/db/storage.ts +32 -0
- package/templates/tanstack-start/src/docs/docs-assets.ts +1 -0
- package/templates/tanstack-start/src/docs/docs-client.tsx +22 -0
- package/templates/tanstack-start/src/docs/docs-data.ts +24 -0
- package/templates/tanstack-start/src/docs/docs-handler.tsx +105 -0
- package/templates/tanstack-start/src/docs/docs-layout.tsx +56 -0
- package/templates/tanstack-start/src/docs/docs-mdx.tsx +79 -0
- package/templates/tanstack-start/src/docs/docs-page-actions.tsx +146 -0
- package/templates/tanstack-start/src/docs/docs-page.tsx +70 -0
- package/templates/tanstack-start/src/docs/llm-text.ts +61 -0
- package/templates/tanstack-start/src/docs/source.ts +7 -0
- package/templates/tanstack-start/src/hooks/use-mobile.ts +19 -0
- package/templates/tanstack-start/src/hooks/use-pwa-install.ts +77 -0
- package/templates/tanstack-start/src/jobs.example.ts +56 -0
- package/templates/tanstack-start/src/lib/account.ts +13 -0
- package/templates/tanstack-start/src/lib/auth-client.ts +187 -0
- package/templates/tanstack-start/src/lib/push-client.ts +98 -0
- package/templates/tanstack-start/src/lib/utils.ts +6 -0
- package/templates/tanstack-start/src/mcp-app.ts +74 -0
- package/templates/tanstack-start/src/notifications.example.ts +37 -0
- package/templates/tanstack-start/src/raybase.auth.ts +86 -0
- package/templates/tanstack-start/src/raybase.config.ts +86 -0
- package/templates/tanstack-start/src/raybase.server.ts +155 -0
- package/templates/tanstack-start/src/realtime.example.ts +46 -0
- package/templates/tanstack-start/src/router.tsx +19 -0
- package/templates/tanstack-start/src/routes/__root.tsx +73 -0
- package/templates/tanstack-start/src/routes/_app/admin.tsx +13 -0
- package/templates/tanstack-start/src/routes/_app/forgot-password.tsx +97 -0
- package/templates/tanstack-start/src/routes/_app/index.tsx +1316 -0
- package/templates/tanstack-start/src/routes/_app/invite.$token.tsx +11 -0
- package/templates/tanstack-start/src/routes/_app/login.tsx +193 -0
- package/templates/tanstack-start/src/routes/_app/profile.tsx +98 -0
- package/templates/tanstack-start/src/routes/_app/reset-password.$token.tsx +16 -0
- package/templates/tanstack-start/src/routes/_app/reset-password.tsx +115 -0
- package/templates/tanstack-start/src/routes/_app/setup.$token.tsx +11 -0
- package/templates/tanstack-start/src/routes/_app/signup.tsx +141 -0
- package/templates/tanstack-start/src/routes/_app/verify-email.$token.tsx +15 -0
- package/templates/tanstack-start/src/routes/_app/verify-email.tsx +154 -0
- package/templates/tanstack-start/src/routes/_app.tsx +33 -0
- package/templates/tanstack-start/src/routes/admin/$.ts +20 -0
- package/templates/tanstack-start/src/routes/api/$.ts +19 -0
- package/templates/tanstack-start/src/routes/docs/$.tsx +22 -0
- package/templates/tanstack-start/src/routes/docs/api/markdown.ts +12 -0
- package/templates/tanstack-start/src/routes/docs/api/search.ts +12 -0
- package/templates/tanstack-start/src/routes/docs.index.tsx +22 -0
- package/templates/tanstack-start/src/routes/docs.tsx +22 -0
- package/templates/tanstack-start/src/search.ts +26 -0
- package/templates/tanstack-start/src/settings.ts +12 -0
- package/templates/tanstack-start/src/styles-docs.css +3 -0
- package/templates/tanstack-start/src/styles.css +73 -0
- package/templates/tanstack-start/src/themes/base.css +76 -0
- package/templates/tanstack-start/src/themes/carbon.css +76 -0
- package/templates/tanstack-start/src/themes/fonts.css +18 -0
- package/templates/tanstack-start/src/themes/sage.css +76 -0
- package/templates/tanstack-start/src/themes/sand.css +76 -0
- package/templates/tanstack-start/src/themes/slate.css +76 -0
- package/templates/tanstack-start/src/themes/ultra.css +76 -0
- package/templates/tanstack-start/src/themes/zen.css +76 -0
- package/templates/tanstack-start/src/worker-entry.ts +30 -0
- package/templates/tanstack-start/tests/raybase-patterns.test.ts +247 -0
- package/templates/tanstack-start/tsconfig.json +33 -0
- package/templates/tanstack-start/vite.config.ts +132 -0
- package/templates/tanstack-start/vitest.config.ts +8 -0
- package/templates/tanstack-start/wrangler.jsonc +112 -0
- package/README.md +0 -3
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { resolveSiteOrigin } from "./site-origin.mjs";
|
|
5
|
+
|
|
6
|
+
const siteRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
7
|
+
const templatesRoot = join(siteRoot, "seed/templates");
|
|
8
|
+
const pagesRoot = join(siteRoot, "seed/pages");
|
|
9
|
+
const baseUrl = resolveSiteOrigin();
|
|
10
|
+
const contentMarker = "<!--__RAYBASE_GALLEY_CONTENT_SLOT__-->";
|
|
11
|
+
|
|
12
|
+
const pagesCollection = {
|
|
13
|
+
slug: "pages",
|
|
14
|
+
label: "Pages",
|
|
15
|
+
labelSingular: "Page",
|
|
16
|
+
supports: ["drafts", "revisions", "search"],
|
|
17
|
+
hasSeo: true,
|
|
18
|
+
urlPattern: "/{slug}",
|
|
19
|
+
fields: [
|
|
20
|
+
{ slug: "title", label: "Title", type: "string", required: true, searchable: true },
|
|
21
|
+
{ slug: "description", label: "Description", type: "text", searchable: true },
|
|
22
|
+
{ slug: "content", label: "Content", type: "portableText", searchable: true },
|
|
23
|
+
{ slug: "design", label: "Design", type: "json", widget: "galley:block" }
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let cookie = "";
|
|
28
|
+
|
|
29
|
+
export async function applySiteTemplates() {
|
|
30
|
+
const templateFiles = findTemplateFiles(templatesRoot);
|
|
31
|
+
const pageFiles = findPageSeedFiles(pagesRoot);
|
|
32
|
+
if (!templateFiles.length && !pageFiles.length) {
|
|
33
|
+
console.log("No staged registry Templates or page seeds found in site/seed.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
await activateDevBypass();
|
|
38
|
+
const templates = templateFiles.map((file) => withProvenance(JSON.parse(readFileSync(file, "utf8")), file));
|
|
39
|
+
await ensureMenuSeeds(collectMenuSeedsFromTemplates(templates));
|
|
40
|
+
const activation = readActivation(templateFiles, templates);
|
|
41
|
+
if (templates.length) {
|
|
42
|
+
if (activation) {
|
|
43
|
+
const published = await publishTemplates(templates, activation);
|
|
44
|
+
await verifyActiveLayout(activation, published.templates ?? templates);
|
|
45
|
+
rmSync(activation.path);
|
|
46
|
+
console.log(
|
|
47
|
+
`Published ${published.templates?.length ?? templates.length} Templates and activated ${activation.templateId}${activation.palette ? ` (palette ${activation.palette})` : ""}.`
|
|
48
|
+
);
|
|
49
|
+
} else {
|
|
50
|
+
const saved = await saveTemplates(templates);
|
|
51
|
+
for (const template of saved.templates ?? templates) {
|
|
52
|
+
console.log(`Applied Template template draft: ${template.label ?? template.id} (${template.id})`);
|
|
53
|
+
}
|
|
54
|
+
console.log(
|
|
55
|
+
"Saved as drafts only (no activation work order). To publish edited staged defaults to the live site, run `raybase templates shell activate`, then re-run templates:apply."
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (pageFiles.length) {
|
|
61
|
+
await ensurePagesCollectionSchema();
|
|
62
|
+
for (const file of pageFiles) {
|
|
63
|
+
const pageSeed = JSON.parse(readFileSync(file, "utf8"));
|
|
64
|
+
const page = await upsertPageSeed(pageSeed);
|
|
65
|
+
if (pageSeed.publish === true) await postJson(`/_emdash/api/content/pages/${encodeURIComponent(page.id)}/publish`, {});
|
|
66
|
+
console.log(`${pageSeed.publish === true ? "Published" : "Applied draft"} page seed: /${pageSeed.slug} (${page.id})`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Entry-hosted page starters stage host.json beside their template: the
|
|
71
|
+
// bound collection gets a galley:block design field whose options default
|
|
72
|
+
// every entry to the starter (galley's value-less render), making it the
|
|
73
|
+
// shared detail page for the whole collection.
|
|
74
|
+
const hostSeedFiles = findHostSeedFiles(templatesRoot);
|
|
75
|
+
for (const file of hostSeedFiles) {
|
|
76
|
+
const hostSeed = JSON.parse(readFileSync(file, "utf8"));
|
|
77
|
+
await ensureHostCollectionField(hostSeed);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function collectMenuSeedsFromTemplates(templates) {
|
|
82
|
+
const seeds = new Map();
|
|
83
|
+
for (const template of templates) {
|
|
84
|
+
const dataSources = template && typeof template === "object" && template.dataSources && typeof template.dataSources === "object" ? template.dataSources : {};
|
|
85
|
+
const fields = template && typeof template === "object" && template.fields && typeof template.fields === "object" ? template.fields : {};
|
|
86
|
+
for (const [alias, source] of Object.entries(dataSources)) {
|
|
87
|
+
if (!source || typeof source !== "object" || source.kind !== "menu" || typeof source.menu !== "string" || !source.menu.trim()) continue;
|
|
88
|
+
const menu = source.menu.trim();
|
|
89
|
+
if (seeds.has(menu)) continue;
|
|
90
|
+
const field = fields[alias] && typeof fields[alias] === "object" ? fields[alias] : null;
|
|
91
|
+
const items = menuSeedItemsFromDefault(field?.default);
|
|
92
|
+
seeds.set(menu, {
|
|
93
|
+
menu,
|
|
94
|
+
label: menuLabel(menu),
|
|
95
|
+
templateId: typeof template.id === "string" ? template.id : "unknown",
|
|
96
|
+
alias,
|
|
97
|
+
items
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return [...seeds.values()];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function ensureMenuSeeds(seeds, api) {
|
|
105
|
+
api ??= defaultMenuSeedApi;
|
|
106
|
+
for (const seed of seeds) {
|
|
107
|
+
const existing = await api.getMenu(seed.menu);
|
|
108
|
+
if (existing) {
|
|
109
|
+
console.log(`Menu ${seed.menu} already exists; kept existing items.`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
await api.createMenu({ name: seed.menu, label: seed.label });
|
|
113
|
+
await createMenuSeedItems(api, seed.menu, seed.items);
|
|
114
|
+
console.log(`Created menu ${seed.menu} from ${seed.templateId}.${seed.alias} (${countMenuSeedItems(seed.items)} item${countMenuSeedItems(seed.items) === 1 ? "" : "s"}).`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function createMenuSeedItems(api, menu, items, parentId = undefined) {
|
|
119
|
+
for (const [index, item] of items.entries()) {
|
|
120
|
+
const created = await api.createMenuItem(menu, {
|
|
121
|
+
type: "custom",
|
|
122
|
+
label: item.label,
|
|
123
|
+
...(item.url ? { customUrl: item.url } : {}),
|
|
124
|
+
...(item.target ? { target: item.target } : {}),
|
|
125
|
+
...(parentId ? { parentId } : {}),
|
|
126
|
+
sortOrder: index
|
|
127
|
+
});
|
|
128
|
+
const childParent = created?.id;
|
|
129
|
+
if (item.children?.length) {
|
|
130
|
+
if (!childParent) throw new Error(`Could not seed nested items for menu ${menu}: createMenuItem must return the created item id for ${item.label}.`);
|
|
131
|
+
await createMenuSeedItems(api, menu, item.children, childParent);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const defaultMenuSeedApi = {
|
|
137
|
+
async getMenu(name) {
|
|
138
|
+
const response = await request(`/_emdash/api/menus/${encodeURIComponent(name)}`, { method: "GET" });
|
|
139
|
+
if (response.status === 404) return null;
|
|
140
|
+
if (!response.ok) throw await apiError(response, `Could not read menu ${name}`);
|
|
141
|
+
const payload = unwrapApiPayload(await response.json());
|
|
142
|
+
return payload.item ?? payload;
|
|
143
|
+
},
|
|
144
|
+
async createMenu(input) {
|
|
145
|
+
return postJson("/_emdash/api/menus", input, 201);
|
|
146
|
+
},
|
|
147
|
+
async createMenuItem(menu, input) {
|
|
148
|
+
return postJson(`/_emdash/api/menus/${encodeURIComponent(menu)}/items`, input, 201);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
function menuSeedItemsFromDefault(value) {
|
|
153
|
+
if (!Array.isArray(value)) return [];
|
|
154
|
+
return value.map(menuSeedItemFromDefault).filter(Boolean);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function menuSeedItemFromDefault(value) {
|
|
158
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
159
|
+
const label = firstString(value.label, value.title, value.text, value.name);
|
|
160
|
+
if (!label) return null;
|
|
161
|
+
const children = [
|
|
162
|
+
...menuSeedItemsFromDefault(value.children),
|
|
163
|
+
...menuSeedItemsFromLinks(value.links)
|
|
164
|
+
];
|
|
165
|
+
return {
|
|
166
|
+
label,
|
|
167
|
+
...(firstString(value.url, value.href) ? { url: firstString(value.url, value.href) } : {}),
|
|
168
|
+
...(firstString(value.target) ? { target: firstString(value.target) } : {}),
|
|
169
|
+
...(children.length ? { children } : {})
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function menuSeedItemsFromLinks(value) {
|
|
174
|
+
if (Array.isArray(value)) return menuSeedItemsFromDefault(value);
|
|
175
|
+
if (typeof value !== "string") return [];
|
|
176
|
+
return value
|
|
177
|
+
.split(";")
|
|
178
|
+
.map((label) => label.trim())
|
|
179
|
+
.filter(Boolean)
|
|
180
|
+
.map((label) => ({ label, url: "#" }));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function firstString(...values) {
|
|
184
|
+
for (const value of values) {
|
|
185
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
186
|
+
}
|
|
187
|
+
return "";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function countMenuSeedItems(items) {
|
|
191
|
+
return items.reduce((total, item) => total + 1 + countMenuSeedItems(item.children ?? []), 0);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function menuLabel(name) {
|
|
195
|
+
return name
|
|
196
|
+
.split(/[-_]+/)
|
|
197
|
+
.filter(Boolean)
|
|
198
|
+
.map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`)
|
|
199
|
+
.join(" ") || name;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function findTemplateFiles(directory) {
|
|
203
|
+
if (!existsSync(directory)) return [];
|
|
204
|
+
const files = [];
|
|
205
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
206
|
+
const full = join(directory, entry.name);
|
|
207
|
+
if (entry.isDirectory()) files.push(...findTemplateFiles(full));
|
|
208
|
+
else if (entry.isFile() && entry.name === "template.json") files.push(full);
|
|
209
|
+
}
|
|
210
|
+
return files.sort();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function findHostSeedFiles(directory) {
|
|
214
|
+
if (!existsSync(directory)) return [];
|
|
215
|
+
const files = [];
|
|
216
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
217
|
+
const full = join(directory, entry.name);
|
|
218
|
+
if (entry.isDirectory()) files.push(...findHostSeedFiles(full));
|
|
219
|
+
else if (entry.isFile() && entry.name === "host.json") files.push(full);
|
|
220
|
+
}
|
|
221
|
+
return files.sort();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function ensureHostCollectionField(hostSeed) {
|
|
225
|
+
if (!hostSeed || typeof hostSeed !== "object" || hostSeed.schemaVersion !== 1) {
|
|
226
|
+
throw new Error("host.json must be a schemaVersion 1 object. Re-install the article starter to restage it.");
|
|
227
|
+
}
|
|
228
|
+
const collectionSlug = hostSeed.host?.collection;
|
|
229
|
+
const field = hostSeed.field;
|
|
230
|
+
if (typeof collectionSlug !== "string" || !collectionSlug.trim()) throw new Error("host.json is missing host.collection.");
|
|
231
|
+
if (!field || typeof field.slug !== "string" || typeof field.label !== "string" || typeof field.options?.template !== "string") {
|
|
232
|
+
throw new Error(`host.json for collection ${collectionSlug} must declare field.slug, field.label, and field.options.template.`);
|
|
233
|
+
}
|
|
234
|
+
const collection = await getCollectionSchema(collectionSlug);
|
|
235
|
+
if (!collection) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
`Collection "${collectionSlug}" does not exist, so the ${field.options.template} detail page cannot attach its design field. ` +
|
|
238
|
+
`Create the collection first (content-model seed) or re-run \`raybase templates add ${field.options.template} --bind ${hostSeed.host.contextKey ?? "post"}=<collection>\` with the right binding, then re-run templates:apply.`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
const fieldPayload = {
|
|
242
|
+
slug: field.slug,
|
|
243
|
+
label: field.label,
|
|
244
|
+
type: "json",
|
|
245
|
+
widget: "galley:block",
|
|
246
|
+
options: {
|
|
247
|
+
template: field.options.template,
|
|
248
|
+
...(Array.isArray(field.options.allow) ? { allow: field.options.allow } : {})
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const existing = (collection.fields ?? []).find((candidate) => candidate.slug === field.slug);
|
|
252
|
+
if (!existing) {
|
|
253
|
+
await postJson(
|
|
254
|
+
`/_emdash/api/schema/collections/${encodeURIComponent(collectionSlug)}/fields`,
|
|
255
|
+
{ ...fieldPayload, sortOrder: collection.fields?.length ?? 0 },
|
|
256
|
+
201
|
|
257
|
+
);
|
|
258
|
+
console.log(`Added ${collectionSlug}.${field.slug} design field defaulting to ${field.options.template}.`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (existing.type !== "json") {
|
|
262
|
+
throw new Error(
|
|
263
|
+
`Collection ${collectionSlug} field "${field.slug}" exists with type "${existing.type}", but the ${field.options.template} detail page requires a json galley:block field.`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const { slug: _slug, type: _type, ...updates } = fieldPayload;
|
|
267
|
+
await putJson(
|
|
268
|
+
`/_emdash/api/schema/collections/${encodeURIComponent(collectionSlug)}/fields/${encodeURIComponent(field.slug)}`,
|
|
269
|
+
{ ...updates, sortOrder: existing.sortOrder ?? 0 }
|
|
270
|
+
);
|
|
271
|
+
console.log(`Updated ${collectionSlug}.${field.slug} design field to default to ${field.options.template}.`);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function getCollectionSchema(slug) {
|
|
275
|
+
const response = await request(`/_emdash/api/schema/collections/${encodeURIComponent(slug)}?includeFields=true`, {
|
|
276
|
+
method: "GET"
|
|
277
|
+
});
|
|
278
|
+
if (response.status === 404) return null;
|
|
279
|
+
if (!response.ok) throw await apiError(response, `Could not read collection ${slug} schema`);
|
|
280
|
+
const payload = unwrapApiPayload(await response.json());
|
|
281
|
+
return payload.item ?? payload;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function findPageSeedFiles(directory) {
|
|
285
|
+
if (!existsSync(directory)) return [];
|
|
286
|
+
return readdirSync(directory, { withFileTypes: true })
|
|
287
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
288
|
+
.map((entry) => join(directory, entry.name))
|
|
289
|
+
.sort();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// activation.json is an ephemeral work order written by `raybase templates
|
|
293
|
+
// shell add <layout-id> --activate` beside the staged layout. It is consumed
|
|
294
|
+
// here and deleted after a successful publish; nothing may read it afterwards.
|
|
295
|
+
function readActivation(templateFiles, templates) {
|
|
296
|
+
const found = [];
|
|
297
|
+
for (const file of templateFiles) {
|
|
298
|
+
const activationPath = join(dirname(file), "activation.json");
|
|
299
|
+
if (!existsSync(activationPath)) continue;
|
|
300
|
+
const record = JSON.parse(readFileSync(activationPath, "utf8"));
|
|
301
|
+
if (record?.activate !== true) continue;
|
|
302
|
+
const template = JSON.parse(readFileSync(file, "utf8"));
|
|
303
|
+
found.push({
|
|
304
|
+
path: activationPath,
|
|
305
|
+
templateId: template.id,
|
|
306
|
+
templateVersion: template.version,
|
|
307
|
+
palette: typeof record.palette === "string" && record.palette.trim() ? record.palette : undefined,
|
|
308
|
+
slots: Object.keys(template.slots ?? {})
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (found.length > 1) {
|
|
312
|
+
throw new Error(`Multiple activation.json work orders staged (${found.map((entry) => entry.templateId).join(", ")}); keep exactly one.`);
|
|
313
|
+
}
|
|
314
|
+
const activation = found[0] ?? null;
|
|
315
|
+
if (activation && !templates.some((template) => template.id === activation.templateId)) {
|
|
316
|
+
throw new Error(`activation.json points at ${activation.templateId}, which is not staged.`);
|
|
317
|
+
}
|
|
318
|
+
return activation;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function withProvenance(template, file) {
|
|
322
|
+
if (template.provenance && Object.keys(template.provenance).length) return template;
|
|
323
|
+
const provenancePath = join(dirname(file), "provenance.json");
|
|
324
|
+
if (!existsSync(provenancePath)) return template;
|
|
325
|
+
const staged = JSON.parse(readFileSync(provenancePath, "utf8"));
|
|
326
|
+
const compact = {
|
|
327
|
+
...(typeof staged?.template?.id === "string" ? { packId: staged.template.id } : {}),
|
|
328
|
+
...(staged?.template?.version !== undefined ? { packVersion: String(staged.template.version) } : {}),
|
|
329
|
+
...(typeof staged?.source?.registry === "string" ? { registry: staged.source.registry } : {}),
|
|
330
|
+
...(typeof staged?.hashes?.liquidSourceSha256 === "string" ? { liquidSourceSha256: staged.hashes.liquidSourceSha256 } : {})
|
|
331
|
+
};
|
|
332
|
+
return Object.keys(compact).length ? { ...template, provenance: compact } : template;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function saveTemplates(templates) {
|
|
336
|
+
if (templates.length > 1) return postJson("/_emdash/api/plugins/galley/templates/save-batch", { templates });
|
|
337
|
+
const saved = await postJson("/_emdash/api/plugins/galley/templates/save", { template: templates[0] });
|
|
338
|
+
return { templates: [saved.template] };
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async function publishTemplates(templates, activation) {
|
|
342
|
+
return postJson("/_emdash/api/plugins/galley/templates/publish-batch", {
|
|
343
|
+
templates,
|
|
344
|
+
activateLayout: {
|
|
345
|
+
templateId: activation.templateId,
|
|
346
|
+
templateVersion: activation.templateVersion ?? undefined,
|
|
347
|
+
palette: activation.palette,
|
|
348
|
+
provenance: {}
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async function verifyActiveLayout(activation, templates) {
|
|
354
|
+
const layout = templates.find((template) => template.id === activation.templateId);
|
|
355
|
+
const declared = new Set(Object.keys(layout?.slots ?? {}).length ? Object.keys(layout.slots) : activation.slots.length ? activation.slots : ["content"]);
|
|
356
|
+
const slots = Object.fromEntries(
|
|
357
|
+
Object.entries({ content: contentMarker }).filter(([name]) => declared.has(name))
|
|
358
|
+
);
|
|
359
|
+
const rendered = await postJson("/_emdash/api/plugins/galley/render-layout", {
|
|
360
|
+
templateId: activation.templateId,
|
|
361
|
+
includeDrafts: false,
|
|
362
|
+
data: {},
|
|
363
|
+
richText: {},
|
|
364
|
+
slots
|
|
365
|
+
});
|
|
366
|
+
if (rendered.runtime && rendered.runtime !== "liquid") {
|
|
367
|
+
throw new Error(`Active layout ${activation.templateId} rendered with Galley runtime ${rendered.runtime}.`);
|
|
368
|
+
}
|
|
369
|
+
if (typeof rendered.html !== "string" || !rendered.html.includes(contentMarker)) {
|
|
370
|
+
throw new Error(`Active layout ${activation.templateId} did not render the public content slot.`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
async function activateDevBypass() {
|
|
375
|
+
const response = await fetch(`${baseUrl}/_emdash/api/setup/dev-bypass?redirect=/`, {
|
|
376
|
+
redirect: "manual"
|
|
377
|
+
});
|
|
378
|
+
cookie = readCookie(response);
|
|
379
|
+
if (!cookie) {
|
|
380
|
+
throw new Error("Could not activate EmDash dev bypass. Is the Astro site dev server running?");
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
async function ensurePagesCollectionSchema() {
|
|
385
|
+
let collection = await getPagesCollection();
|
|
386
|
+
if (!collection) {
|
|
387
|
+
await postJson(
|
|
388
|
+
"/_emdash/api/schema/collections",
|
|
389
|
+
{
|
|
390
|
+
slug: pagesCollection.slug,
|
|
391
|
+
label: pagesCollection.label,
|
|
392
|
+
labelSingular: pagesCollection.labelSingular,
|
|
393
|
+
supports: pagesCollection.supports,
|
|
394
|
+
hasSeo: pagesCollection.hasSeo,
|
|
395
|
+
urlPattern: pagesCollection.urlPattern
|
|
396
|
+
},
|
|
397
|
+
201
|
|
398
|
+
);
|
|
399
|
+
collection = await getPagesCollection();
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (!collection) throw new Error("Could not create or load the pages collection schema.");
|
|
403
|
+
|
|
404
|
+
await putJson(`/_emdash/api/schema/collections/${encodeURIComponent(pagesCollection.slug)}`, {
|
|
405
|
+
label: pagesCollection.label,
|
|
406
|
+
labelSingular: pagesCollection.labelSingular,
|
|
407
|
+
supports: pagesCollection.supports,
|
|
408
|
+
hasSeo: pagesCollection.hasSeo,
|
|
409
|
+
urlPattern: pagesCollection.urlPattern
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const existingFields = new Map((collection.fields ?? []).map((field) => [field.slug, field]));
|
|
413
|
+
for (const [sortOrder, field] of pagesCollection.fields.entries()) {
|
|
414
|
+
const existing = existingFields.get(field.slug);
|
|
415
|
+
if (!existing) {
|
|
416
|
+
await postJson(
|
|
417
|
+
`/_emdash/api/schema/collections/${encodeURIComponent(pagesCollection.slug)}/fields`,
|
|
418
|
+
{ ...field, sortOrder },
|
|
419
|
+
201
|
|
420
|
+
);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (existing.type !== field.type) {
|
|
425
|
+
throw new Error(
|
|
426
|
+
`Pages field "${field.slug}" exists with type "${existing.type}", but Template page seeds require "${field.type}". Reset the EmDash content database or migrate the field intentionally.`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const { slug: _slug, type: _type, ...updates } = field;
|
|
431
|
+
await putJson(
|
|
432
|
+
`/_emdash/api/schema/collections/${encodeURIComponent(pagesCollection.slug)}/fields/${encodeURIComponent(field.slug)}`,
|
|
433
|
+
{ ...updates, sortOrder }
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
async function getPagesCollection() {
|
|
439
|
+
const response = await request(
|
|
440
|
+
`/_emdash/api/schema/collections/${encodeURIComponent(pagesCollection.slug)}?includeFields=true`,
|
|
441
|
+
{ method: "GET" }
|
|
442
|
+
);
|
|
443
|
+
if (response.status === 404) return null;
|
|
444
|
+
if (!response.ok) throw await apiError(response, "Could not read pages collection schema");
|
|
445
|
+
const payload = unwrapApiPayload(await response.json());
|
|
446
|
+
return payload.item ?? payload;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
async function upsertPageSeed(seed) {
|
|
450
|
+
if (!seed || typeof seed !== "object") throw new Error("Page seed must be an object.");
|
|
451
|
+
if (seed.schemaVersion !== 2) {
|
|
452
|
+
throw new Error(`Page seed ${seed.slug ?? "(unknown)"} must declare schemaVersion 2. Re-install the page starter to restage v2 seeds.`);
|
|
453
|
+
}
|
|
454
|
+
if (typeof seed.slug !== "string" || !seed.slug.trim()) throw new Error("Page seed slug is required.");
|
|
455
|
+
if (typeof seed.title !== "string" || !seed.title.trim()) throw new Error(`Page seed ${seed.slug} title is required.`);
|
|
456
|
+
if (!seed.design || typeof seed.design !== "object" || typeof seed.design.templateId !== "string") {
|
|
457
|
+
throw new Error(`Page seed ${seed.slug} must declare design.templateId.`);
|
|
458
|
+
}
|
|
459
|
+
const design = {
|
|
460
|
+
templateId: seed.design.templateId,
|
|
461
|
+
...(typeof seed.design.templateVersion === "number" ? { templateVersion: seed.design.templateVersion } : {}),
|
|
462
|
+
data: seed.design.data && typeof seed.design.data === "object" ? seed.design.data : {},
|
|
463
|
+
richText: seed.design.richText && typeof seed.design.richText === "object" ? seed.design.richText : {}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const existing = await request(`/_emdash/api/content/pages/${encodeURIComponent(seed.slug)}`, { method: "GET" });
|
|
467
|
+
if (existing.status === 404) {
|
|
468
|
+
const created = await postJson(
|
|
469
|
+
"/_emdash/api/content/pages",
|
|
470
|
+
{
|
|
471
|
+
slug: seed.slug,
|
|
472
|
+
data: {
|
|
473
|
+
title: seed.title,
|
|
474
|
+
description: typeof seed.description === "string" ? seed.description : undefined,
|
|
475
|
+
content: [],
|
|
476
|
+
design
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
201
|
|
480
|
+
);
|
|
481
|
+
return created.item;
|
|
482
|
+
}
|
|
483
|
+
if (!existing.ok) throw await apiError(existing, `Could not read existing page ${seed.slug}`);
|
|
484
|
+
|
|
485
|
+
const rawPayload = await existing.json();
|
|
486
|
+
const payload = unwrapApiPayload(rawPayload);
|
|
487
|
+
const item = payload.item;
|
|
488
|
+
// Existing pages keep their Portable Text content; the seed only refreshes
|
|
489
|
+
// the metadata and the design pointer.
|
|
490
|
+
const updated = await putJson(`/_emdash/api/content/pages/${encodeURIComponent(item.id)}`, {
|
|
491
|
+
slug: seed.slug,
|
|
492
|
+
data: {
|
|
493
|
+
...(item.data ?? {}),
|
|
494
|
+
title: seed.title,
|
|
495
|
+
description: typeof seed.description === "string" ? seed.description : item.data?.description,
|
|
496
|
+
design
|
|
497
|
+
},
|
|
498
|
+
_rev: payload._rev ?? rawPayload._rev ?? rawPayload.data?._rev
|
|
499
|
+
});
|
|
500
|
+
return updated.item;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
async function postJson(path, body, expectedStatus = 200) {
|
|
504
|
+
const response = await request(path, {
|
|
505
|
+
method: "POST",
|
|
506
|
+
headers: { "content-type": "application/json", "x-emdash-request": "1" },
|
|
507
|
+
body: JSON.stringify(body)
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
if (response.status !== expectedStatus) throw await apiError(response, `POST ${path} failed`);
|
|
511
|
+
return unwrapApiPayload(await response.json());
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
async function putJson(path, body, expectedStatus = 200) {
|
|
515
|
+
const response = await request(path, {
|
|
516
|
+
method: "PUT",
|
|
517
|
+
headers: { "content-type": "application/json", "x-emdash-request": "1" },
|
|
518
|
+
body: JSON.stringify(body)
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
if (response.status !== expectedStatus) throw await apiError(response, `PUT ${path} failed`);
|
|
522
|
+
return unwrapApiPayload(await response.json());
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
async function request(path, init) {
|
|
526
|
+
return fetch(`${baseUrl}${path}`, {
|
|
527
|
+
...init,
|
|
528
|
+
headers: {
|
|
529
|
+
...(init.headers ?? {}),
|
|
530
|
+
...(cookie ? { cookie } : {})
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async function apiError(response, prefix) {
|
|
536
|
+
const text = await response.text();
|
|
537
|
+
return new Error(`${prefix}: ${response.status} ${response.statusText}\n${text}`);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function readCookie(response) {
|
|
541
|
+
const setCookies = response.headers.getSetCookie?.() ?? [];
|
|
542
|
+
const parts = setCookies.length ? setCookies : response.headers.get("set-cookie")?.split(",") ?? [];
|
|
543
|
+
return parts
|
|
544
|
+
.map((part) => part.trim().split(";")[0])
|
|
545
|
+
.filter(Boolean)
|
|
546
|
+
.join("; ");
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function unwrapApiPayload(payload) {
|
|
550
|
+
return payload && typeof payload === "object" && "data" in payload ? payload.data : payload;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
554
|
+
try {
|
|
555
|
+
await applySiteTemplates();
|
|
556
|
+
} catch (error) {
|
|
557
|
+
console.error(error instanceof Error ? error.message : error);
|
|
558
|
+
process.exit(1);
|
|
559
|
+
}
|
|
560
|
+
}
|