@raybase/cli 0.0.2 → 0.3.3
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/dist/admin-assets.d.ts +22 -0
- package/dist/admin-assets.d.ts.map +1 -0
- package/dist/admin-assets.js +285 -0
- package/dist/admin-assets.js.map +1 -0
- package/dist/agent-remote-mcp-cli.d.ts +71 -0
- package/dist/agent-remote-mcp-cli.d.ts.map +1 -0
- package/dist/agent-remote-mcp-cli.js +466 -0
- package/dist/agent-remote-mcp-cli.js.map +1 -0
- package/dist/agent-skills-cli.d.ts +4 -0
- package/dist/agent-skills-cli.d.ts.map +1 -0
- package/dist/agent-skills-cli.js +144 -0
- package/dist/agent-skills-cli.js.map +1 -0
- package/dist/agent.d.ts +169 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +531 -0
- package/dist/agent.js.map +1 -0
- package/dist/app-manifest.d.ts +41 -0
- package/dist/app-manifest.d.ts.map +1 -0
- package/dist/app-manifest.js +294 -0
- package/dist/app-manifest.js.map +1 -0
- package/dist/dev-cron-backstop.d.ts +53 -0
- package/dist/dev-cron-backstop.d.ts.map +1 -0
- package/dist/dev-cron-backstop.js +364 -0
- package/dist/dev-cron-backstop.js.map +1 -0
- package/dist/dev-do-watchdog.d.ts +37 -0
- package/dist/dev-do-watchdog.d.ts.map +1 -0
- package/dist/dev-do-watchdog.js +75 -0
- package/dist/dev-do-watchdog.js.map +1 -0
- package/dist/dev-inference-tape.d.ts +35 -0
- package/dist/dev-inference-tape.d.ts.map +1 -0
- package/dist/dev-inference-tape.js +502 -0
- package/dist/dev-inference-tape.js.map +1 -0
- package/dist/dev-ports.d.ts +25 -0
- package/dist/dev-ports.d.ts.map +1 -0
- package/dist/dev-ports.js +84 -0
- package/dist/dev-ports.js.map +1 -0
- package/dist/dev-project-lock.d.ts +24 -0
- package/dist/dev-project-lock.d.ts.map +1 -0
- package/dist/dev-project-lock.js +307 -0
- package/dist/dev-project-lock.js.map +1 -0
- package/dist/env-files.d.ts +10 -0
- package/dist/env-files.d.ts.map +1 -0
- package/dist/env-files.js +108 -0
- package/dist/env-files.js.map +1 -0
- package/dist/external-json.d.ts +3 -0
- package/dist/external-json.d.ts.map +1 -0
- package/dist/external-json.js +21 -0
- package/dist/external-json.js.map +1 -0
- package/dist/frameworks.d.ts +67 -0
- package/dist/frameworks.d.ts.map +1 -0
- package/dist/frameworks.js +210 -0
- package/dist/frameworks.js.map +1 -0
- package/dist/guide-corpus-doctor.d.ts +24 -0
- package/dist/guide-corpus-doctor.d.ts.map +1 -0
- package/dist/guide-corpus-doctor.js +111 -0
- package/dist/guide-corpus-doctor.js.map +1 -0
- package/dist/hosting.d.ts +85 -0
- package/dist/hosting.d.ts.map +1 -0
- package/dist/hosting.js +136 -0
- package/dist/hosting.js.map +1 -0
- package/dist/index.d.ts +253 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11475 -0
- package/dist/index.js.map +1 -0
- package/dist/kit-doctor.d.ts +19 -0
- package/dist/kit-doctor.d.ts.map +1 -0
- package/dist/kit-doctor.js +255 -0
- package/dist/kit-doctor.js.map +1 -0
- package/dist/kit-install.d.ts +67 -0
- package/dist/kit-install.d.ts.map +1 -0
- package/dist/kit-install.js +409 -0
- package/dist/kit-install.js.map +1 -0
- package/dist/kit-manifest.d.ts +154 -0
- package/dist/kit-manifest.d.ts.map +1 -0
- package/dist/kit-manifest.js +252 -0
- package/dist/kit-manifest.js.map +1 -0
- package/dist/kit-registry.d.ts +42 -0
- package/dist/kit-registry.d.ts.map +1 -0
- package/dist/kit-registry.js +231 -0
- package/dist/kit-registry.js.map +1 -0
- package/dist/kit-spec.d.ts +37 -0
- package/dist/kit-spec.d.ts.map +1 -0
- package/dist/kit-spec.js +48 -0
- package/dist/kit-spec.js.map +1 -0
- package/dist/kit-state.d.ts +57 -0
- package/dist/kit-state.d.ts.map +1 -0
- package/dist/kit-state.js +31 -0
- package/dist/kit-state.js.map +1 -0
- package/dist/kits.d.ts +82 -0
- package/dist/kits.d.ts.map +1 -0
- package/dist/kits.js +255 -0
- package/dist/kits.js.map +1 -0
- package/dist/license-keys.d.ts +3 -0
- package/dist/license-keys.d.ts.map +1 -0
- package/dist/license-keys.js +10 -0
- package/dist/license-keys.js.map +1 -0
- package/dist/licensing.d.ts +269 -0
- package/dist/licensing.d.ts.map +1 -0
- package/dist/licensing.js +474 -0
- package/dist/licensing.js.map +1 -0
- package/dist/local-codex-relay.d.ts +19 -0
- package/dist/local-codex-relay.d.ts.map +1 -0
- package/dist/local-codex-relay.js +203 -0
- package/dist/local-codex-relay.js.map +1 -0
- package/dist/module-doctor.d.ts +35 -0
- package/dist/module-doctor.d.ts.map +1 -0
- package/dist/module-doctor.js +966 -0
- package/dist/module-doctor.js.map +1 -0
- package/dist/module-install.d.ts +71 -0
- package/dist/module-install.d.ts.map +1 -0
- package/dist/module-install.js +1133 -0
- package/dist/module-install.js.map +1 -0
- package/dist/module-manifest.d.ts +33 -0
- package/dist/module-manifest.d.ts.map +1 -0
- package/dist/module-manifest.js +301 -0
- package/dist/module-manifest.js.map +1 -0
- package/dist/module-state.d.ts +76 -0
- package/dist/module-state.d.ts.map +1 -0
- package/dist/module-state.js +162 -0
- package/dist/module-state.js.map +1 -0
- package/dist/modules.d.ts +52 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +110 -0
- package/dist/modules.js.map +1 -0
- package/dist/palette-check.d.ts +42 -0
- package/dist/palette-check.d.ts.map +1 -0
- package/dist/palette-check.js +217 -0
- package/dist/palette-check.js.map +1 -0
- package/dist/palette-compile.d.ts +30 -0
- package/dist/palette-compile.d.ts.map +1 -0
- package/dist/palette-compile.js +149 -0
- package/dist/palette-compile.js.map +1 -0
- package/dist/pm.d.ts +11 -0
- package/dist/pm.d.ts.map +1 -0
- package/dist/pm.js +30 -0
- package/dist/pm.js.map +1 -0
- package/dist/project-local-codex-relay.d.ts +11 -0
- package/dist/project-local-codex-relay.d.ts.map +1 -0
- package/dist/project-local-codex-relay.js +95 -0
- package/dist/project-local-codex-relay.js.map +1 -0
- package/dist/shared.d.ts +4 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +38 -0
- package/dist/shared.js.map +1 -0
- package/dist/shell-match.d.ts +29 -0
- package/dist/shell-match.d.ts.map +1 -0
- package/dist/shell-match.js +160 -0
- package/dist/shell-match.js.map +1 -0
- package/dist/template-doctor.d.ts +40 -0
- package/dist/template-doctor.d.ts.map +1 -0
- package/dist/template-doctor.js +722 -0
- package/dist/template-doctor.js.map +1 -0
- package/dist/template-install.d.ts +135 -0
- package/dist/template-install.d.ts.map +1 -0
- package/dist/template-install.js +1311 -0
- package/dist/template-install.js.map +1 -0
- package/dist/template-manifest.d.ts +328 -0
- package/dist/template-manifest.d.ts.map +1 -0
- package/dist/template-manifest.js +533 -0
- package/dist/template-manifest.js.map +1 -0
- package/dist/template-registry.d.ts +76 -0
- package/dist/template-registry.d.ts.map +1 -0
- package/dist/template-registry.js +365 -0
- package/dist/template-registry.js.map +1 -0
- package/dist/template-spec.d.ts +24 -0
- package/dist/template-spec.d.ts.map +1 -0
- package/dist/template-spec.js +38 -0
- package/dist/template-spec.js.map +1 -0
- package/dist/template-state.d.ts +108 -0
- package/dist/template-state.d.ts.map +1 -0
- package/dist/template-state.js +93 -0
- package/dist/template-state.js.map +1 -0
- package/dist/templates.d.ts +123 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +541 -0
- package/dist/templates.js.map +1 -0
- package/dist/theme-match.d.ts +41 -0
- package/dist/theme-match.d.ts.map +1 -0
- package/dist/theme-match.js +92 -0
- package/dist/theme-match.js.map +1 -0
- package/dist/wrangler-secrets.d.ts +15 -0
- package/dist/wrangler-secrets.d.ts.map +1 -0
- package/dist/wrangler-secrets.js +97 -0
- package/dist/wrangler-secrets.js.map +1 -0
- package/kits/datasheet-grid/file-manifest.json +65 -0
- package/kits/datasheet-grid/files/AGENTS.md +6 -0
- package/kits/datasheet-grid/files/docs/datasheet-grid.md +15 -0
- package/kits/datasheet-grid/files/files/src/kits/datasheet-grid/DatasheetGridRoute.tsx +35 -0
- package/kits/datasheet-grid/files/files/src/kits/datasheet-grid/README.md +10 -0
- package/kits/datasheet-grid/files/files/src/kits/datasheet-grid/grid-adapter.ts +30 -0
- package/kits/datasheet-grid/files/files/src/kits/datasheet-grid/grid-metadata.ts +19 -0
- package/kits/datasheet-grid/files/files/src/kits/datasheet-grid/grid-state.ts +24 -0
- package/kits/datasheet-grid/files/kit.json +119 -0
- package/kits/datasheet-grid/files/skills/datasheet-grid/SKILL.md +16 -0
- package/kits/datasheet-grid/files/tests/datasheet-grid.test.ts +15 -0
- package/kits/datasheet-grid/kit.json +146 -0
- package/kits/index.json +71 -0
- package/kits/resend-email/file-manifest.json +47 -0
- package/kits/resend-email/files/AGENTS.md +7 -0
- package/kits/resend-email/files/docs/resend-email.md +13 -0
- package/kits/resend-email/files/files/src/kits/resend-email/README.md +17 -0
- package/kits/resend-email/files/files/src/kits/resend-email/send-email.ts +44 -0
- package/kits/resend-email/files/kit.json +128 -0
- package/kits/resend-email/files/skills/resend-email/SKILL.md +20 -0
- package/kits/resend-email/files/tests/resend-email.test.ts +54 -0
- package/kits/resend-email/kit.json +159 -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/README.md +0 -3
|
@@ -0,0 +1,722 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { relativePosix, resolveInside, sha256File, walkFiles } from "./template-manifest.js";
|
|
4
|
+
import { resolveTemplateSource } from "./template-registry.js";
|
|
5
|
+
import { readTemplateLock } from "./template-state.js";
|
|
6
|
+
export function doctorTemplatesSync(projectRoot, options = {}) {
|
|
7
|
+
const issues = [];
|
|
8
|
+
let lock;
|
|
9
|
+
try {
|
|
10
|
+
lock = readTemplateLock(projectRoot);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return {
|
|
14
|
+
ok: false,
|
|
15
|
+
templates: [],
|
|
16
|
+
issues: [
|
|
17
|
+
{
|
|
18
|
+
level: "error",
|
|
19
|
+
check: "template-lock",
|
|
20
|
+
message: error instanceof Error ? error.message : String(error),
|
|
21
|
+
fix: "Repair .raybase/templates.json or restore it from app git history."
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (!lock)
|
|
27
|
+
return { ok: true, issues: [], templates: [] };
|
|
28
|
+
for (const installed of Object.values(lock.templates)) {
|
|
29
|
+
try {
|
|
30
|
+
issues.push(...doctorInstalledTemplate(projectRoot, lock, installed, options));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
issues.push({
|
|
34
|
+
level: "error",
|
|
35
|
+
check: "template-lock",
|
|
36
|
+
template: installed.id,
|
|
37
|
+
message: error instanceof Error ? error.message : String(error),
|
|
38
|
+
fix: "Repair .raybase/templates.json or restore it from app git history."
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
issues.push(...doctorActivationIntents(projectRoot));
|
|
43
|
+
issues.push(...doctorStagedPageSeeds(projectRoot));
|
|
44
|
+
issues.push(...doctorInstalledTheme(projectRoot, lock));
|
|
45
|
+
issues.push(...doctorShellMenuCapacity(projectRoot, lock));
|
|
46
|
+
issues.push(...doctorSiteTokenContract(projectRoot, lock));
|
|
47
|
+
issues.push(...doctorDataSourceUrlCoverage(projectRoot, lock));
|
|
48
|
+
return {
|
|
49
|
+
ok: !issues.some((issue) => issue.level === "error"),
|
|
50
|
+
issues,
|
|
51
|
+
templates: Object.keys(lock.templates)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Registry templates style with palette-token utilities (bg-card,
|
|
55
|
+
// text-primary, from-card/70, ...). Tailwind v4 only generates those when the
|
|
56
|
+
// site styles register the tokens in an @theme block; without it every
|
|
57
|
+
// palette-token utility silently compiles to nothing and pages lose their
|
|
58
|
+
// color roles (scrims, CTAs, muted text) while still rendering.
|
|
59
|
+
function doctorSiteTokenContract(projectRoot, lock) {
|
|
60
|
+
if (Object.keys(lock.templates).length === 0)
|
|
61
|
+
return [];
|
|
62
|
+
const stylesPath = resolveInside(projectRoot, "site/src/styles.css");
|
|
63
|
+
if (!existsSync(stylesPath))
|
|
64
|
+
return [];
|
|
65
|
+
let styles;
|
|
66
|
+
try {
|
|
67
|
+
styles = readFileSync(stylesPath, "utf8");
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
if (styles.includes("@theme") && styles.includes("--color-card:"))
|
|
73
|
+
return [];
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
level: "warning",
|
|
77
|
+
check: "template-token-contract",
|
|
78
|
+
message: "site/src/styles.css does not register the shadcn-semantic-v1 palette tokens in an @theme block, so installed Templates' palette-token utilities (bg-card, text-primary, from-card/70, ...) compile to nothing on the public site.",
|
|
79
|
+
fix: "Add the @theme inline token map from a freshly scaffolded astro-emdash site/src/styles.css (it mirrors the spine's src/styles.css block mapping --color-* to the palette variables)."
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
// The registry card idiom links entries with href="{{ item.url | default: '#' }}".
|
|
84
|
+
// Galley only produces item.url when the bound collection declares a urlPattern
|
|
85
|
+
// (forward derivation) or its entries store a url field; against a collection
|
|
86
|
+
// with neither, every card on a collection-driven index renders href="#" with
|
|
87
|
+
// no error anywhere. Warn when an installed template binds such a collection
|
|
88
|
+
// and its Liquid — or a card partial it renders — actually reads item.url.
|
|
89
|
+
function doctorDataSourceUrlCoverage(projectRoot, lock) {
|
|
90
|
+
if (Object.keys(lock.templates).length === 0)
|
|
91
|
+
return [];
|
|
92
|
+
const seed = readSeedJson(projectRoot);
|
|
93
|
+
if (!seed)
|
|
94
|
+
return [];
|
|
95
|
+
const collections = seedCollectionUrlCapability(seed);
|
|
96
|
+
if (collections.size === 0)
|
|
97
|
+
return [];
|
|
98
|
+
const generatedByTemplateId = new Map();
|
|
99
|
+
const installs = [];
|
|
100
|
+
for (const installed of Object.values(lock.templates)) {
|
|
101
|
+
const record = readGeneratedTemplateRecord(projectRoot, installed.stagedArtifacts.template);
|
|
102
|
+
if (!record)
|
|
103
|
+
continue;
|
|
104
|
+
generatedByTemplateId.set(record.id, record);
|
|
105
|
+
installs.push({ packId: installed.id, record });
|
|
106
|
+
}
|
|
107
|
+
const issues = [];
|
|
108
|
+
for (const { packId, record } of installs) {
|
|
109
|
+
for (const [alias, value] of Object.entries(record.dataSources)) {
|
|
110
|
+
const source = asRecord(value);
|
|
111
|
+
if (!source || source.kind !== "collection" || typeof source.collection !== "string")
|
|
112
|
+
continue;
|
|
113
|
+
const capability = collections.get(source.collection);
|
|
114
|
+
// A collection the seed does not declare (live-only or demo content) is
|
|
115
|
+
// not verifiable from here; only a seeded collection that provably lacks
|
|
116
|
+
// both url affordances is a defect.
|
|
117
|
+
if (capability === undefined || capability)
|
|
118
|
+
continue;
|
|
119
|
+
const reference = findDataSourceUrlReference(record, alias, generatedByTemplateId);
|
|
120
|
+
if (!reference)
|
|
121
|
+
continue;
|
|
122
|
+
const where = reference.templateId === record.id ? "its Liquid" : `its rendered partial ${reference.templateId}`;
|
|
123
|
+
issues.push({
|
|
124
|
+
level: "warning",
|
|
125
|
+
check: "template-datasource-url",
|
|
126
|
+
template: packId,
|
|
127
|
+
message: `${packId} binds data source "${alias}" to collection "${source.collection}", and ${where} links {{ ${reference.variable}.url }}, but ${source.collection} declares neither a urlPattern nor a url field in site/seed/seed.json — Galley derives no entry URLs, so every link renders its "#" fallback.`,
|
|
128
|
+
fix: `Add a urlPattern to the ${source.collection} collection in site/seed/seed.json (entry URLs derive from it), store a url field on its entries, or rebind with raybase templates add ${packId} --bind ${alias}=<collection> --overwrite.`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return issues;
|
|
133
|
+
}
|
|
134
|
+
function readGeneratedTemplateRecord(projectRoot, rel) {
|
|
135
|
+
const file = resolveInside(projectRoot, rel);
|
|
136
|
+
if (!existsSync(file))
|
|
137
|
+
return null;
|
|
138
|
+
try {
|
|
139
|
+
const parsed = asRecord(JSON.parse(readFileSync(file, "utf8")));
|
|
140
|
+
if (!parsed || typeof parsed.id !== "string" || !parsed.id)
|
|
141
|
+
return null;
|
|
142
|
+
return {
|
|
143
|
+
id: parsed.id,
|
|
144
|
+
liquid: typeof parsed.liquidSource === "string" ? parsed.liquidSource : "",
|
|
145
|
+
dataSources: asRecord(parsed.dataSources) ?? {}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// slug -> whether the seeded collection can produce per-entry urls (a
|
|
153
|
+
// urlPattern for Galley's forward derivation, or a stored url field).
|
|
154
|
+
function seedCollectionUrlCapability(seed) {
|
|
155
|
+
const map = new Map();
|
|
156
|
+
const collections = Array.isArray(seed.collections) ? seed.collections : [];
|
|
157
|
+
for (const entry of collections) {
|
|
158
|
+
const collection = asRecord(entry);
|
|
159
|
+
const slug = typeof collection?.slug === "string" ? collection.slug : null;
|
|
160
|
+
if (!collection || !slug)
|
|
161
|
+
continue;
|
|
162
|
+
const hasUrlPattern = typeof collection.urlPattern === "string" && collection.urlPattern.trim() !== "";
|
|
163
|
+
const fields = Array.isArray(collection.fields) ? collection.fields : [];
|
|
164
|
+
const hasUrlField = fields.some((field) => asRecord(field)?.slug === "url");
|
|
165
|
+
map.set(slug, hasUrlPattern || hasUrlField);
|
|
166
|
+
}
|
|
167
|
+
return map;
|
|
168
|
+
}
|
|
169
|
+
// Finds a `<var>.url` read on items of the data source alias: direct item
|
|
170
|
+
// access on the alias, loop variables from {% for item in alias %}, and the
|
|
171
|
+
// render-tag idiom where the index hands each item to a card partial that
|
|
172
|
+
// owns the link ({% render "card", article: article %} /
|
|
173
|
+
// {% render "card" for alias as article %}).
|
|
174
|
+
function findDataSourceUrlReference(record, alias, generated) {
|
|
175
|
+
const aliasPattern = escapeRegExp(alias);
|
|
176
|
+
if (new RegExp(`\\b${aliasPattern}(?:\\[[^\\]]+\\]|\\.first|\\.last)\\.url\\b`).test(record.liquid)) {
|
|
177
|
+
return { templateId: record.id, variable: alias };
|
|
178
|
+
}
|
|
179
|
+
for (const match of record.liquid.matchAll(new RegExp(`\\{%-?\\s*render\\s+["']([^"']+)["']\\s+for\\s+${aliasPattern}\\b(?:\\s+as\\s+([A-Za-z_]\\w*))?`, "g"))) {
|
|
180
|
+
const target = generated.get(match[1]);
|
|
181
|
+
const variable = match[2] ?? match[1];
|
|
182
|
+
if (!target || !/^[A-Za-z_]\w*$/.test(variable))
|
|
183
|
+
continue;
|
|
184
|
+
if (new RegExp(`\\b${escapeRegExp(variable)}\\.url\\b`).test(target.liquid)) {
|
|
185
|
+
return { templateId: target.id, variable };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const itemVariables = new Set();
|
|
189
|
+
for (const match of record.liquid.matchAll(new RegExp(`\\{%-?\\s*for\\s+([A-Za-z_]\\w*)\\s+in\\s+${aliasPattern}\\b`, "g"))) {
|
|
190
|
+
itemVariables.add(match[1]);
|
|
191
|
+
}
|
|
192
|
+
if (itemVariables.size === 0)
|
|
193
|
+
return null;
|
|
194
|
+
return findUrlReadOnVariables(record, itemVariables, generated, new Set([record.id]), 3);
|
|
195
|
+
}
|
|
196
|
+
function findUrlReadOnVariables(record, variables, generated, visited, depth) {
|
|
197
|
+
for (const variable of variables) {
|
|
198
|
+
if (new RegExp(`\\b${escapeRegExp(variable)}\\.url\\b`).test(record.liquid)) {
|
|
199
|
+
return { templateId: record.id, variable };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (depth <= 0)
|
|
203
|
+
return null;
|
|
204
|
+
for (const match of record.liquid.matchAll(/\{%-?\s*render\s+["']([^"']+)["']([^%]*?)-?%\}/g)) {
|
|
205
|
+
const target = generated.get(match[1]);
|
|
206
|
+
if (!target || visited.has(target.id))
|
|
207
|
+
continue;
|
|
208
|
+
const mapped = new Set();
|
|
209
|
+
for (const argument of match[2].matchAll(/([A-Za-z_]\w*)\s*:\s*([A-Za-z_][\w.]*)/g)) {
|
|
210
|
+
if (variables.has(argument[2]))
|
|
211
|
+
mapped.add(argument[1]);
|
|
212
|
+
}
|
|
213
|
+
if (mapped.size === 0)
|
|
214
|
+
continue;
|
|
215
|
+
const found = findUrlReadOnVariables(target, mapped, generated, new Set([...visited, target.id]), depth - 1);
|
|
216
|
+
if (found)
|
|
217
|
+
return found;
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
function escapeRegExp(value) {
|
|
222
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
223
|
+
}
|
|
224
|
+
function doctorShellMenuCapacity(projectRoot, lock) {
|
|
225
|
+
const shell = lock.shell;
|
|
226
|
+
if (!shell?.activated)
|
|
227
|
+
return [];
|
|
228
|
+
const installed = lock.templates[shell.id];
|
|
229
|
+
if (!installed?.stagedArtifacts.manifest)
|
|
230
|
+
return [];
|
|
231
|
+
const manifestPath = resolveInside(projectRoot, installed.stagedArtifacts.manifest);
|
|
232
|
+
if (!existsSync(manifestPath))
|
|
233
|
+
return [];
|
|
234
|
+
const seed = readSeedJson(projectRoot);
|
|
235
|
+
if (!seed)
|
|
236
|
+
return [];
|
|
237
|
+
let capacity = null;
|
|
238
|
+
try {
|
|
239
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
240
|
+
capacity = asRecord(manifest.shell?.capacity);
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
if (!capacity)
|
|
246
|
+
return [];
|
|
247
|
+
const issues = [];
|
|
248
|
+
const navRange = asRange(capacity.navItems);
|
|
249
|
+
// A seed without the menu is not a capacity mismatch: pre-menu sites drive
|
|
250
|
+
// their navs from local template fields, and templates:apply seeds a missing
|
|
251
|
+
// menu from the nav template's defaults at install. Only a menu the site
|
|
252
|
+
// actually declares is checked against the shell's capacity.
|
|
253
|
+
const primaryCount = navRange ? seedMenuTopLevelCount(seed, "primary") : null;
|
|
254
|
+
if (navRange && primaryCount !== null) {
|
|
255
|
+
if (primaryCount < navRange.min || primaryCount > navRange.max) {
|
|
256
|
+
issues.push({
|
|
257
|
+
level: "warning",
|
|
258
|
+
check: "template-menu-capacity",
|
|
259
|
+
template: shell.id,
|
|
260
|
+
message: `The active shell ${shell.id} expects ${navRange.min}-${navRange.max} primary nav items, but site/seed/seed.json declares ${primaryCount}.`,
|
|
261
|
+
fix: "Update the primary menu in site/seed/seed.json, or choose a shell whose navItems capacity matches the planned IA."
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const footerRange = asRange(capacity.footerColumns);
|
|
266
|
+
const footerColumns = footerRange ? seedMenuTopLevelCount(seed, "footer") : null;
|
|
267
|
+
if (footerRange && footerColumns !== null) {
|
|
268
|
+
if (footerColumns > footerRange.max) {
|
|
269
|
+
issues.push({
|
|
270
|
+
level: "warning",
|
|
271
|
+
check: "template-menu-capacity",
|
|
272
|
+
template: shell.id,
|
|
273
|
+
message: `The active shell ${shell.id} supports at most ${footerRange.max} footer columns, but site/seed/seed.json declares ${footerColumns}.`,
|
|
274
|
+
fix: "Reduce the top-level footer menu items, or choose a shell with larger footerColumns capacity."
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return issues;
|
|
279
|
+
}
|
|
280
|
+
function readSeedJson(projectRoot) {
|
|
281
|
+
const file = resolveInside(projectRoot, "site/seed/seed.json");
|
|
282
|
+
if (!existsSync(file))
|
|
283
|
+
return null;
|
|
284
|
+
try {
|
|
285
|
+
return asRecord(JSON.parse(readFileSync(file, "utf8")));
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// Returns null when the seed does not declare the menu at all — callers skip
|
|
292
|
+
// the capacity check in that case instead of treating absence as zero items.
|
|
293
|
+
function seedMenuTopLevelCount(seed, name) {
|
|
294
|
+
const defaultLocale = typeof seed.defaultLocale === "string" && seed.defaultLocale ? seed.defaultLocale : "en";
|
|
295
|
+
const menus = Array.isArray(seed.menus) ? seed.menus.map(asRecord).filter((menu) => menu !== null) : [];
|
|
296
|
+
const menu = menus.find((candidate) => candidate.name === name && (candidate.locale === undefined || candidate.locale === defaultLocale)) ??
|
|
297
|
+
menus.find((candidate) => candidate.name === name);
|
|
298
|
+
if (!menu)
|
|
299
|
+
return null;
|
|
300
|
+
return Array.isArray(menu.items) ? menu.items.length : 0;
|
|
301
|
+
}
|
|
302
|
+
function asRange(value) {
|
|
303
|
+
const range = asRecord(value);
|
|
304
|
+
if (!range || !Number.isInteger(range.min) || !Number.isInteger(range.max))
|
|
305
|
+
return null;
|
|
306
|
+
return { min: range.min, max: range.max };
|
|
307
|
+
}
|
|
308
|
+
function asRecord(value) {
|
|
309
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
310
|
+
}
|
|
311
|
+
function doctorInstalledTheme(projectRoot, lock) {
|
|
312
|
+
const issues = [];
|
|
313
|
+
const theme = lock.theme;
|
|
314
|
+
if (!theme)
|
|
315
|
+
return issues;
|
|
316
|
+
const artifacts = theme.generatedArtifacts;
|
|
317
|
+
const required = [
|
|
318
|
+
["palette-css", artifacts.palettes],
|
|
319
|
+
["palette-font-css", artifacts.paletteFonts],
|
|
320
|
+
["palette-module", artifacts.paletteModule],
|
|
321
|
+
["theme-package-json", artifacts.packageJson]
|
|
322
|
+
];
|
|
323
|
+
for (const [check, rel] of required) {
|
|
324
|
+
const target = resolveInside(projectRoot, rel);
|
|
325
|
+
if (!existsSync(target)) {
|
|
326
|
+
issues.push({
|
|
327
|
+
level: "warning",
|
|
328
|
+
check,
|
|
329
|
+
message: `${rel} for installed theme ${theme.id} is missing.`,
|
|
330
|
+
fix: `Re-run raybase templates theme add ${theme.id} --stage-only to regenerate theme artifacts.`
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const colorCss = resolveInside(projectRoot, artifacts.palettes);
|
|
335
|
+
if (existsSync(colorCss)) {
|
|
336
|
+
const css = readFileSync(colorCss, "utf8");
|
|
337
|
+
for (const name of theme.palettes) {
|
|
338
|
+
if (!css.includes(`[data-palette="${name}"]`)) {
|
|
339
|
+
issues.push({
|
|
340
|
+
level: "warning",
|
|
341
|
+
check: "theme-palette-block",
|
|
342
|
+
message: `${artifacts.palettes} is missing an installed palette block for ${name}.`,
|
|
343
|
+
fix: `Restore the [data-palette="${name}"] block or re-run raybase templates theme add ${theme.id} --stage-only.`
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return issues;
|
|
349
|
+
}
|
|
350
|
+
function doctorActivationIntents(projectRoot) {
|
|
351
|
+
const issues = [];
|
|
352
|
+
const templatesDir = resolveInside(projectRoot, "site/seed/templates");
|
|
353
|
+
if (!existsSync(templatesDir))
|
|
354
|
+
return issues;
|
|
355
|
+
for (const file of walkFiles(templatesDir)) {
|
|
356
|
+
if (basename(file) !== "activation.json")
|
|
357
|
+
continue;
|
|
358
|
+
const rel = `site/seed/templates/${relativePosix(templatesDir, file)}`;
|
|
359
|
+
const templateId = relativePosix(templatesDir, dirname(file));
|
|
360
|
+
let parsed = null;
|
|
361
|
+
try {
|
|
362
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
363
|
+
parsed = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
364
|
+
}
|
|
365
|
+
catch {
|
|
366
|
+
parsed = null;
|
|
367
|
+
}
|
|
368
|
+
if (!parsed) {
|
|
369
|
+
issues.push({
|
|
370
|
+
level: "error",
|
|
371
|
+
check: "template-activation-intent",
|
|
372
|
+
template: templateId,
|
|
373
|
+
message: `${rel} is not a valid JSON activation work order.`,
|
|
374
|
+
fix: "Re-run raybase templates shell add <layout-id> --activate to restage the activation intent, or remove the file."
|
|
375
|
+
});
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
if (parsed.activate !== true) {
|
|
379
|
+
issues.push({
|
|
380
|
+
level: "error",
|
|
381
|
+
check: "template-activation-intent",
|
|
382
|
+
template: templateId,
|
|
383
|
+
message: `${rel} must declare activate: true.`,
|
|
384
|
+
fix: "Re-run raybase templates shell add <layout-id> --activate to restage the activation intent, or remove the file."
|
|
385
|
+
});
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (parsed.palette !== undefined && parsed.palette !== null && typeof parsed.palette !== "string") {
|
|
389
|
+
issues.push({
|
|
390
|
+
level: "error",
|
|
391
|
+
check: "template-activation-intent",
|
|
392
|
+
template: templateId,
|
|
393
|
+
message: `${rel} palette must be a string or null.`,
|
|
394
|
+
fix: "Re-run raybase templates shell add <layout-id> --activate to restage the activation intent."
|
|
395
|
+
});
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (stagedTemplateKind(file) !== "layout") {
|
|
399
|
+
issues.push({
|
|
400
|
+
level: "error",
|
|
401
|
+
check: "template-activation-layout",
|
|
402
|
+
template: templateId,
|
|
403
|
+
message: `${rel} must sit beside a staged layout template, but ${templateId} does not stage a layout manifest.`,
|
|
404
|
+
fix: "Re-run raybase templates shell add <layout-id> --activate so the activation intent lands beside the selected layout."
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return issues;
|
|
409
|
+
}
|
|
410
|
+
function stagedTemplateKind(activationFile) {
|
|
411
|
+
const manifestPath = join(dirname(activationFile), "manifest.json");
|
|
412
|
+
if (!existsSync(manifestPath))
|
|
413
|
+
return null;
|
|
414
|
+
try {
|
|
415
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
416
|
+
return typeof manifest.kind === "string" ? manifest.kind : null;
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function doctorStagedPageSeeds(projectRoot) {
|
|
423
|
+
const issues = [];
|
|
424
|
+
const pagesDir = resolveInside(projectRoot, "site/seed/pages");
|
|
425
|
+
if (!existsSync(pagesDir))
|
|
426
|
+
return issues;
|
|
427
|
+
for (const file of walkFiles(pagesDir)) {
|
|
428
|
+
if (!file.endsWith(".json"))
|
|
429
|
+
continue;
|
|
430
|
+
const rel = `site/seed/pages/${relativePosix(pagesDir, file)}`;
|
|
431
|
+
let parsed = null;
|
|
432
|
+
try {
|
|
433
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
434
|
+
parsed = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
parsed = null;
|
|
438
|
+
}
|
|
439
|
+
if (!parsed) {
|
|
440
|
+
issues.push({
|
|
441
|
+
level: "warning",
|
|
442
|
+
check: "template-page-seed",
|
|
443
|
+
message: `${rel} is not a valid staged page seed JSON object.`,
|
|
444
|
+
fix: "Re-install the page starter (raybase templates add <starter> --overwrite) to restage the page seed."
|
|
445
|
+
});
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (parsed.schemaVersion === 1) {
|
|
449
|
+
issues.push({
|
|
450
|
+
level: "warning",
|
|
451
|
+
check: "template-page-seed-version",
|
|
452
|
+
message: `${rel} is a schemaVersion 1 page seed; page.json v1 seeds are no longer supported.`,
|
|
453
|
+
fix: "Re-install the starter (raybase templates add <starter> --overwrite) to stage a v2 page seed with a design pointer."
|
|
454
|
+
});
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
const design = parsed.design;
|
|
458
|
+
if (parsed.schemaVersion !== 2 || !design || typeof design !== "object" || typeof design.templateId !== "string" || !design.templateId) {
|
|
459
|
+
issues.push({
|
|
460
|
+
level: "warning",
|
|
461
|
+
check: "template-page-seed-shape",
|
|
462
|
+
message: `${rel} must be a schemaVersion 2 page seed with design.templateId.`,
|
|
463
|
+
fix: "Re-install the starter (raybase templates add <starter> --overwrite) to stage a v2 page seed."
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return issues;
|
|
468
|
+
}
|
|
469
|
+
export function doctorTemplates(projectRoot, options = {}) {
|
|
470
|
+
const result = doctorTemplatesSync(projectRoot, options);
|
|
471
|
+
if (options.siteUrl && !result.issues.some((issue) => issue.check === "template-live-read")) {
|
|
472
|
+
return {
|
|
473
|
+
...result,
|
|
474
|
+
issues: [
|
|
475
|
+
...result.issues,
|
|
476
|
+
{
|
|
477
|
+
level: "warning",
|
|
478
|
+
check: "template-live-read",
|
|
479
|
+
message: "Live Galley template verification is not enabled because no stable public read endpoint is part of the current contract.",
|
|
480
|
+
fix: "Use staged provenance checks locally; verify draft templates in EmDash admin when reviewing a running site."
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return result;
|
|
486
|
+
}
|
|
487
|
+
export async function updateTemplates(projectRoot, options = {}) {
|
|
488
|
+
const lock = readTemplateLock(projectRoot);
|
|
489
|
+
if (!lock)
|
|
490
|
+
return { ok: true, dryRun: Boolean(options.dryRun), projectDir: projectRoot, updates: [], warnings: ["No Raybase Templates are installed."] };
|
|
491
|
+
const targets = options.templates?.length ? options.templates : Object.keys(lock.templates);
|
|
492
|
+
const updates = [];
|
|
493
|
+
for (const id of targets) {
|
|
494
|
+
const installed = lock.templates[id];
|
|
495
|
+
if (!installed) {
|
|
496
|
+
updates.push({ template: id, currentVersion: "not-installed", status: "blocked", warnings: [`${id} is not installed.`] });
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const drift = installedTemplateDrift(projectRoot, installed);
|
|
500
|
+
if (drift) {
|
|
501
|
+
updates.push({ template: id, currentVersion: installed.version, status: "forked", warnings: [drift] });
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
try {
|
|
505
|
+
const resolved = await resolveTemplateSource(installed.spec, { registry: options.registry ?? installed.source.registry ?? undefined, offline: options.offline, manifestOnly: true });
|
|
506
|
+
try {
|
|
507
|
+
const latest = resolved.manifest.version;
|
|
508
|
+
if (latest === installed.version && sourceFingerprint(resolved.source) === sourceFingerprint(installed.source)) {
|
|
509
|
+
updates.push({ template: id, currentVersion: installed.version, latestVersion: latest, status: "current", warnings: [] });
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
updates.push({
|
|
513
|
+
template: id,
|
|
514
|
+
currentVersion: installed.version,
|
|
515
|
+
latestVersion: latest,
|
|
516
|
+
status: "upgrade-available",
|
|
517
|
+
warnings: options.dryRun ? [] : ["Update apply is review-only in this slice; re-run raybase templates add with --overwrite after review."]
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
finally {
|
|
522
|
+
resolved.cleanup();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
catch (error) {
|
|
526
|
+
updates.push({
|
|
527
|
+
template: id,
|
|
528
|
+
currentVersion: installed.version,
|
|
529
|
+
status: /not found/i.test(error instanceof Error ? error.message : String(error)) ? "missing-from-registry" : "blocked",
|
|
530
|
+
warnings: [error instanceof Error ? error.message : String(error)]
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
ok: updates.every((update) => update.status !== "blocked" && update.status !== "forked"),
|
|
536
|
+
dryRun: Boolean(options.dryRun),
|
|
537
|
+
projectDir: projectRoot,
|
|
538
|
+
updates,
|
|
539
|
+
warnings: options.dryRun ? [] : ["Template update apply is review-only in this slice."]
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function doctorInstalledTemplate(projectRoot, lock, installed, options) {
|
|
543
|
+
const issues = [];
|
|
544
|
+
// A page starter no page points at renders nothing: ordinary starters need
|
|
545
|
+
// a staged page seed (a pages entry whose design selects them), entry-hosted
|
|
546
|
+
// starters need their host.json design-field artifact. An orphaned starter
|
|
547
|
+
// usually means a page seed was deleted or an install was interrupted.
|
|
548
|
+
if (installed.kind === "page-starter" && !installed.stagedArtifacts.hostSeed) {
|
|
549
|
+
const referenced = Object.values(lock.pages ?? {}).some((page) => page.design?.templateId === installed.id);
|
|
550
|
+
if (!referenced) {
|
|
551
|
+
issues.push({
|
|
552
|
+
level: "warning",
|
|
553
|
+
check: "template-starter-unreferenced",
|
|
554
|
+
template: installed.id,
|
|
555
|
+
message: `${installed.id} is an installed page starter, but no staged page seed points its design at it, so no page renders it.`,
|
|
556
|
+
fix: `Re-install it with a page seed (raybase templates add ${installed.id} --overwrite / theme add --page <route=starter>) or remove it if unused.`
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
for (const [label, rel] of Object.entries(installed.stagedArtifacts)) {
|
|
561
|
+
if (typeof rel !== "string" || !rel)
|
|
562
|
+
continue;
|
|
563
|
+
const target = resolveInside(projectRoot, rel);
|
|
564
|
+
if (!existsSync(target)) {
|
|
565
|
+
issues.push({
|
|
566
|
+
level: "warning",
|
|
567
|
+
check: "template-staged-artifact",
|
|
568
|
+
template: installed.id,
|
|
569
|
+
message: `${label} artifact ${rel} for ${installed.id} is missing.`,
|
|
570
|
+
fix: `Restore ${rel} or run raybase templates add ${installed.id} --stage-only --overwrite.`
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
const drift = installedTemplateDrift(projectRoot, installed);
|
|
575
|
+
if (drift) {
|
|
576
|
+
issues.push({
|
|
577
|
+
level: "warning",
|
|
578
|
+
check: "template-forked",
|
|
579
|
+
template: installed.id,
|
|
580
|
+
message: drift,
|
|
581
|
+
fix: `Review local changes before running raybase templates add ${installed.id} --overwrite.`
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
const manifestDrift = installedManifestDrift(projectRoot, installed);
|
|
585
|
+
if (manifestDrift) {
|
|
586
|
+
issues.push({
|
|
587
|
+
level: "warning",
|
|
588
|
+
check: "template-manifest-drift",
|
|
589
|
+
template: installed.id,
|
|
590
|
+
message: manifestDrift,
|
|
591
|
+
fix: `Review local manifest changes before running raybase templates add ${installed.id} --overwrite.`
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
const behaviorDrift = installedBehaviorDrift(projectRoot, installed);
|
|
595
|
+
if (behaviorDrift) {
|
|
596
|
+
issues.push({
|
|
597
|
+
level: "warning",
|
|
598
|
+
check: "template-behavior-drift",
|
|
599
|
+
template: installed.id,
|
|
600
|
+
message: behaviorDrift,
|
|
601
|
+
fix: `Review local behavior changes before running raybase templates add ${installed.id} --overwrite.`
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
for (const dependency of installed.dependencies) {
|
|
605
|
+
const installedDependency = lock.templates[dependency];
|
|
606
|
+
if (!installedDependency) {
|
|
607
|
+
issues.push({
|
|
608
|
+
level: "warning",
|
|
609
|
+
check: "template-dependency",
|
|
610
|
+
template: installed.id,
|
|
611
|
+
message: `${installed.id} depends on ${dependency}, but ${dependency} is not installed.`,
|
|
612
|
+
fix: `Run raybase templates add ${installed.id} again so dependencies are staged.`
|
|
613
|
+
});
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
for (const templateId of installedDependency.templateIds) {
|
|
617
|
+
const rel = installedDependency.stagedArtifacts.template;
|
|
618
|
+
if (!existsSync(resolveInside(projectRoot, rel))) {
|
|
619
|
+
issues.push({
|
|
620
|
+
level: "warning",
|
|
621
|
+
check: "template-dependency-template",
|
|
622
|
+
template: installed.id,
|
|
623
|
+
message: `${installed.id} depends on template ${templateId} from ${dependency}, but ${rel} is missing.`,
|
|
624
|
+
fix: `Restore ${rel} or run raybase templates add ${installed.id} --stage-only --overwrite.`
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (options.framework && installed.compatibility.framework !== options.framework) {
|
|
630
|
+
issues.push({
|
|
631
|
+
level: "warning",
|
|
632
|
+
check: "template-template",
|
|
633
|
+
template: installed.id,
|
|
634
|
+
message: `${installed.id} was installed for ${installed.compatibility.framework}, but this app resolves as ${options.framework}.`,
|
|
635
|
+
fix: "Review staged templates before applying or updating this Template."
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
if (installed.templateIds.length !== 1 || Object.keys(installed.hashes.generatedTemplates).length !== 1) {
|
|
639
|
+
issues.push({
|
|
640
|
+
level: "warning",
|
|
641
|
+
check: "template-template-shape",
|
|
642
|
+
template: installed.id,
|
|
643
|
+
message: `${installed.id} records multiple template ids, but Templates v1 expects one generated template per template.`,
|
|
644
|
+
fix: "Review .raybase/templates.json and reinstall the template with a CLI version that supports this shape."
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
for (const [binding, value] of Object.entries(installed.bindings ?? {})) {
|
|
648
|
+
if (bindingLooksBroken(value)) {
|
|
649
|
+
issues.push({
|
|
650
|
+
level: "warning",
|
|
651
|
+
check: "template-broken-binding",
|
|
652
|
+
template: installed.id,
|
|
653
|
+
message: `${installed.id} has an incomplete binding record for ${binding}.`,
|
|
654
|
+
fix: "Review the template binding provenance and reinstall with an explicit --bind value if needed."
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return issues;
|
|
659
|
+
}
|
|
660
|
+
function installedManifestDrift(projectRoot, installed) {
|
|
661
|
+
const rel = installed.stagedArtifacts.manifest;
|
|
662
|
+
const expected = installed.hashes.manifestSha256;
|
|
663
|
+
if (!rel || !expected)
|
|
664
|
+
return null;
|
|
665
|
+
const target = resolveInside(projectRoot, rel);
|
|
666
|
+
if (!existsSync(target))
|
|
667
|
+
return null;
|
|
668
|
+
const actual = sha256File(target);
|
|
669
|
+
if (actual !== expected)
|
|
670
|
+
return `${rel} has local edits since ${installed.id} was installed.`;
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
function installedBehaviorDrift(projectRoot, installed) {
|
|
674
|
+
const rel = installed.stagedArtifacts.behavior;
|
|
675
|
+
const expected = installed.hashes.behaviorSha256;
|
|
676
|
+
if (!rel || !expected)
|
|
677
|
+
return null;
|
|
678
|
+
const target = resolveInside(projectRoot, rel);
|
|
679
|
+
if (!existsSync(target))
|
|
680
|
+
return null;
|
|
681
|
+
const actual = sha256File(target);
|
|
682
|
+
if (actual !== expected)
|
|
683
|
+
return `${rel} has local edits since ${installed.id} was installed.`;
|
|
684
|
+
return null;
|
|
685
|
+
}
|
|
686
|
+
function installedTemplateDrift(projectRoot, installed) {
|
|
687
|
+
const rel = installed.stagedArtifacts.template;
|
|
688
|
+
const target = resolveInside(projectRoot, rel);
|
|
689
|
+
if (!existsSync(target))
|
|
690
|
+
return null;
|
|
691
|
+
const expected = Object.values(installed.hashes.generatedTemplates)[0];
|
|
692
|
+
if (!expected)
|
|
693
|
+
return null;
|
|
694
|
+
const actual = sha256File(target);
|
|
695
|
+
if (actual !== expected)
|
|
696
|
+
return `${rel} has local edits since ${installed.id} was installed.`;
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
function bindingLooksBroken(value) {
|
|
700
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
701
|
+
return false;
|
|
702
|
+
const record = value;
|
|
703
|
+
if (record.status === "broken" || record.status === "broken-binding")
|
|
704
|
+
return true;
|
|
705
|
+
if ("collection" in record && !record.collection)
|
|
706
|
+
return true;
|
|
707
|
+
if ("menu" in record && !record.menu)
|
|
708
|
+
return true;
|
|
709
|
+
if ("field" in record && !record.field)
|
|
710
|
+
return true;
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
function sourceFingerprint(source) {
|
|
714
|
+
return [
|
|
715
|
+
source.manifestIntegrity ?? "",
|
|
716
|
+
source.templateIntegrity ?? source.sourceIntegrity ?? "",
|
|
717
|
+
source.sampleContentIntegrity ?? "",
|
|
718
|
+
source.pageSeedIntegrity ?? "",
|
|
719
|
+
source.behaviorIntegrity ?? ""
|
|
720
|
+
].join("|");
|
|
721
|
+
}
|
|
722
|
+
//# sourceMappingURL=template-doctor.js.map
|