@conloca/cli 0.2.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/conloca.js +13 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -364,7 +364,8 @@ It reads the Puck config that `conlocaCMS`'s `puckConfigPath` names from source,
|
|
|
364
364
|
per component with its fields, then each component it could not read with the reason. `--json` prints the manifest the
|
|
365
365
|
editor and agents use: `components`, `unresolved` and, when the config cannot be fully read, `unreadable: true` with
|
|
366
366
|
`unreadableReason`. An unreadable config is still an answer; the command fails only without an `astro.config` or when
|
|
367
|
-
`puckConfigPath` is not a plain string.
|
|
367
|
+
`puckConfigPath` is not a plain string. It lists only the Puck part of the manifest; a site build adds `fragments`, the
|
|
368
|
+
fragment components. Read-only: it never modifies a file.
|
|
368
369
|
|
|
369
370
|
```plain
|
|
370
371
|
Hero: title (text), image (image)
|
package/dist/conloca.js
CHANGED
|
@@ -3498,8 +3498,16 @@ async function updatePage(input) {
|
|
|
3498
3498
|
}
|
|
3499
3499
|
const ext = manifest.type === "mdx" ? "mdx" : "vxjson";
|
|
3500
3500
|
const filePath = pageFilePath(contentRoot, site, manifest.collection, localized.pathname, locale, ext);
|
|
3501
|
+
await input.afterWrite?.();
|
|
3502
|
+
await assertWriteSurvived(api, { id: manifest.id, locale, etag: result.etag, filePath });
|
|
3501
3503
|
return { id: manifest.id, pathname: localized.pathname, filePath };
|
|
3502
3504
|
}
|
|
3505
|
+
async function assertWriteSurvived(api, write) {
|
|
3506
|
+
const { survived } = await api.verifyOwnWrite(write.id, write.locale, write.etag ?? "");
|
|
3507
|
+
if (!survived) {
|
|
3508
|
+
throw new PageWriteError("write_failed", `your write to ${write.filePath} was overwritten by another writer; re-run the command`);
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3503
3511
|
|
|
3504
3512
|
// src/lib/data-write.ts
|
|
3505
3513
|
function dataFilePath(contentRoot, collection, name, locale) {
|
|
@@ -3540,7 +3548,10 @@ async function updateDataEntry(input) {
|
|
|
3540
3548
|
if (!result.success) {
|
|
3541
3549
|
throw new PageWriteError("write_failed", result.error?.message ?? `Update failed (${result.reason ?? "unknown reason"})`);
|
|
3542
3550
|
}
|
|
3543
|
-
|
|
3551
|
+
const filePath = dataFilePath(contentRoot, collection, localized.name, locale);
|
|
3552
|
+
await input.afterWrite?.();
|
|
3553
|
+
await assertWriteSurvived(api, { id: manifest.id, locale, etag: result.etag, filePath });
|
|
3554
|
+
return { id: manifest.id, filePath };
|
|
3544
3555
|
}
|
|
3545
3556
|
|
|
3546
3557
|
// src/lib/json-input.ts
|
|
@@ -4634,7 +4645,7 @@ import { join as join14, resolve as resolve5 } from "node:path";
|
|
|
4634
4645
|
import { stampSkill } from "@conloca/content-api/skill-stamp";
|
|
4635
4646
|
|
|
4636
4647
|
// src/templates/conloca-skill.md
|
|
4637
|
-
var conloca_skill_default = "---\nname: conloca\ndescription: Load when working on an Astro site using Conloca CMS — @conloca/* packages, .vxjson content, sites.json.\n---\n\n# Conloca CMS\n\nConloca stores pages as `.vxjson` files (visual pages built from Puck components) and `.mdx` files under `content/`, and\nrenders them through the `@conloca/astro-cms` Astro integration. The visual editor lives at `/__cms` on the dev server\nonly.\n\n## First move: `conloca doctor`\n\nFor any Conloca problem — blank page, 404 on a content page, editor not loading, build failure — run this before reading\nsource:\n\n```bash\nconloca doctor # human-readable report\nconloca doctor --json # single {ok, problems} object on stdout\n```\n\n`conloca <command>` in this skill means `npx @conloca/cli@<version> <command>`: use the exact version a Conloca prompt\ngave you, `@latest` when none did. Never run a different version than the prompt names.\n\nIt checks the content directory (sites.json complete, site directories present, every content file indexes cleanly) and,\nwhen an astro.config is present, the Astro wiring: content config, conlocaCMS import and options, react() order, peer\ndependencies, tsconfig jsx, prerender under server output, Conloca pages hidden behind a `src/pages` file, static pages\nwith no Conloca pages, and siteStyles. Each problem names the broken file and the fix. It is read-only and exits 1 on\nerrors; warnings alone exit 0.\n\nNew project from an empty directory? `conloca create <dir>` writes and installs the whole wired site. An existing Astro\nsite: `conloca connect` installs the packages, wires `astro.config` and writes the site's domain for the workspace\neditor; `conloca astro setup` only scaffolds the starter files.\n\n## Upgrading Conloca\n\nTo move a site to a newer Conloca release:\n\n1. In the site's folder run `npx @conloca/cli@latest upgrade` (or the exact version a Conloca prompt gave you). It\n raises each `@conloca/*` package to the version that CLI release pins in one install, applies the changes between\n versions, refreshes this skill and runs `conloca doctor`. `--dry-run` shows the diffs and changes nothing, `--json`\n prints one object on stdout, `--project <dir>` picks the site folder.\n2. Exit `2`: it lists what a person must change first; nothing was touched. Make those changes, then run it again.\n3. Exit `1`: it failed and put `package.json`, the lockfile and every changed file back. Fix what it names, run the\n install command its message gives when `node_modules` needs it, and run it again.\n4. A `SKILL.new.md` beside a skill means that skill had local edits, so the new text was written next to it: merge it\n into the skill by hand, then delete `SKILL.new.md`.\n5. Review `git diff`, run the build, then commit and push yourself — the command never commits or pushes.\n\nNever edit `@conloca/*` versions by hand: each package has its own version, and `upgrade` moves them to the versions one\nCLI release pins.\n\nDraft previews: updating `@conloca/cloud-astro` moves a site that previewed from its own server (D2), or an\n`@astrojs/cloudflare` server-rendered site, to drafts rendered in the site's own build (d8) on its next build. `upgrade`\nmakes the edits explicit: the start command becomes `node dist/server/entry.mjs` and the `previewBuild` options d8\nignores go. Preview tabs opened before the update stop working; editors reopen Preview.\n\n## The files a working site needs\n\n- `astro.config.mjs` — registers `react()` and `conlocaCMS(...)`\n- `src/content.config.ts` — declares the content collections (without it every content page 404s)\n- `content/sites.json` — sites with their `locales` and `defaultLocale`, plus `globalLocales`\n- `src/puck.config.tsx` — registers the Puck components pages are built from\n- `src/layouts/Layout.astro` — the page layout content pages render into\n- `src/components/puck/*` and `src/schemas/data.ts` — starter components and data-collection schemas\n\nRun `conloca astro setup` inside an existing Astro project. It scaffolds the content config, components, schemas, page\nlayout, and content directories, preserving existing generated files. It adds the default site to `sites.json` when\nmissing. It prints the `astro.config` wiring rather than writing that file: merge the printed options into the existing\nconfig, then run `conloca doctor` to verify the result — or run `conloca connect`, which writes the wiring itself.\n`conloca init . <site-name>` adds another site to sites.json.\n\n## Install: the exact package set\n\n```bash\nnpm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react typia\nnpm install -D ttsc @ttsc/unplugin\n```\n\n`@puckeditor/core` is what the generated components import — there is no other Puck package to install.\n\nttsc compiles with native TypeScript 7, and only one the site declares: a TypeScript 5 or 6 already installed (a\nworkspace root's) keeps the package manager from adding 7 as ttsc's peer. Add `typescript@^7.0.2`, or, keeping\nTypeScript 5 or 6 as `@astrojs/check` requires, an alias:\n`npm install -D typescript@^6.0.3 '@typescript/native@npm:typescript@^7.0.2'`.\n\n## Canonical astro.config.mjs\n\nThe minimal working config, matching what `conloca astro setup` prints:\n\n```js\nimport react from '@astrojs/react';\nimport { conlocaCMS } from '@conloca/astro-cms/node';\nimport { defineConfig } from 'astro/config';\nimport { schemaTypia } from './typia-vite.mjs';\n\nexport default defineConfig({\n integrations: [\n react(),\n conlocaCMS({\n contentRoot: './content',\n puckConfigPath: './src/puck.config.tsx',\n schemasPath: './src/schemas/data.ts',\n layout: './src/layouts/Layout.astro',\n }),\n ],\n vite: { plugins: [...schemaTypia()] },\n});\n```\n\n`react()` must come before `conlocaCMS()` — doctor checks the order. `src/schemas/data.ts` declares each data collection\nas a TypeScript type plus its generated Typia validator (`typia.plain.createValidatePrune<T>()`) and form metadata\n(`typia.json.schema<T>()`); `typia-vite.mjs` is the native transform that generates them, so it must stay in\n`vite.plugins`. And `src/content.config.ts`:\n\n```ts\nimport { conlocaData, conlocaFragments, conlocaPages } from '@conloca/astro-cms/node/content';\nimport { dataSchemas } from './schemas/data';\n\nexport const collections = {\n pages: conlocaPages(),\n ...conlocaData({ dataSchemas }),\n ...conlocaFragments(),\n};\n```\n\nEvery collection is declared here by name — content the config does not name fails the build instead of silently not\nbuilding.\n\n## Where errors appear\n\n- `astro dev` runs in the foreground: config and integration errors print to the terminal running it, and page errors\n also show in the browser error overlay. There is no separate log command — read that terminal.\n- A page referencing a Puck component type missing from puck.config.tsx serves HTTP 200 with a blank region and a clean\n browser console. The signal is `[Conloca] Page references N component type(s) missing from your Puck config: ...` in\n the dev-server or build terminal.\n- `conloca doctor` finds them before a build: C14 warns about every component type or prop a page stores that the Puck\n config does not declare.\n- The editor at `/__cms` exists only on the dev server. A production build without it is not a bug.\n\n## Writing content from the command line\n\nNever hand-write files under `content/`, and do not reach for HTTP endpoints: these commands write what the editor\nwrites, so the result is editable at `/__cms` right away. Each takes `--json` for a machine-readable result.\n\n```bash\nconloca page create --site default --collection pages --pathname /about --title 'About us' --content about.json\nconloca page update /about --description 'Who we are' --image /media/hero.jpg\nconloca data create site --name contact --data contact.json\nconloca data update site contact --data - < contact.json\nconloca asset add ~/Pictures/hero.jpg --alt 'Fresh bread on the counter'\n```\n\n- `page create` — a new page. `--content` takes Puck data `{ root, content, zones }` from a file or `-` (stdin), never\n inline JSON; `--description`, `--image`, `--canonical` and `--robots` fill its page settings.\n- `page update` — change an existing page, found by id or pathname; only the flags given change, and an empty value\n (`--robots ''`) clears a field.\n- `data create` / `data update` — a shared entry (contact details, a header menu): a JSON object from a file or\n `--data -`. `data update` replaces the entry's whole object: send every field, not just the changed one. Declare the\n collection's type in `src/schemas/data.ts`; the first `data create` wires the data schemas.\n- `asset add` — an image into the media folder; it prints the reference an image field stores, e.g. `/media/hero.jpg`.\n\nA layout reads a shared entry by name:\n\n```ts\nimport { getCollection } from 'astro:content';\nimport { conlocaDataEntry } from '@conloca/astro-cms/collections';\nimport { dataSchemas } from '../schemas/data';\n\nconst contact = conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'contact', 'en');\ncontact.phone; // typed by the `site` schema\n```\n\nA missing name, or one saved in several locales with none given, throws and fails the build instead of rendering empty.\n\nEntries a page's blocks list (team, testimonials) bind to the route with\n`routing.routes.<name>.dataBindings.collections`; a block's Puck `resolveData` then reads them from\n`metadata.collections.<name>`.\n\nAfter writing content, run the build: it validates every entry against its schema.\n\n## Routing\n\n- `layout: './src/layouts/Layout.astro'` alone injects a catch-all `/[...slug]` route over the `pages` collection, with\n `prerender: true` and `fallback: '404'`.\n- Passing `routing` replaces that default route entirely and the top-level `layout` is then ignored — name it per route\n instead: `routing: { routes: { pages: { pattern: '/[...slug]', layout: './src/layouts/Layout.astro' } } }`.\n- `routing: true` is the same default catch-all with no layout.\n- `fallback: '404'` returns a bare 404 when no content matches the pattern; `'passthrough'` hands the miss back to Astro\n so the site's own `/404` page renders, with a real 404 status.\n- Trap: a `src/pages` file always wins over a Conloca page at the same path, and Astro says nothing. Doctor warns when\n one hides a page; delete the file in the same change that makes the Conloca page live.\n\n## Adding Conloca to an existing Astro site\n\n- Switching to `output: 'server'`: first add `export const prerender = true` to every existing file under `src/pages/`,\n then flip the output — otherwise those pages silently stop being static. Doctor errors on files that miss it.\n- Existing `.mdx` content: set the site's `mdxPages` path in `content/sites.json` (relative to the project root, e.g.\n `./src/content/docs`). `.mdx` files under it surface in the CMS as pages of that site; the default locale lives at\n `<mdxPages>/<slug>.mdx`, other locales at `<mdxPages>/<locale>/<slug>.mdx`.\n- Plain `.md` files are never adopted — only `.mdx` and `.vxjson` are recognized as pages. Rename `.md` to `.mdx` to\n bring a file under management.\n\n## Converting an existing Astro page\n\nUse this when the user names existing `src/pages` routes to make editable. Convert only those routes.\n\n1. Run `conloca upgrade` (with the version your prompt gave, as defined above). Stop and report if it or\n `conloca doctor` fails: the commands below ship in that release.\n2. Run `conloca routes` and check each named route is listed. Dynamic routes (`[slug].astro`, content collection pages)\n and non-default-locale routes are out of scope and never listed.\n3. Before changing anything, run `conloca compare --reset --routes /a,/b` with exactly the routes the user named; it\n builds the site and saves a fresh baseline.\n4. Run `conloca components --json` to see the components the site already has.\n5. Port each section of the page to a React component in `src/components/puck/` whose editable text and images are\n fields. `.astro` components cannot be Puck components: port, do not reuse. Scoped `<style>` moves into a stylesheet\n listed in `siteStyles`; `<script>` and `client:` islands keep working through `withHydration()`; links stay links;\n images that become fields go into the assets folder with `conloca asset add`.\n6. Render the page through the layout the original used: point `conlocaCMS` (or a per-route layout) at it and adapt it\n to the props Conloca passes (`title`, `description`, `page`).\n7. Text from data files (like `src/data/*.ts`): per-page text goes into the page; values shared across pages go into\n data entries, moved once, on the first conversion that needs them. Every importer of those values (pages, layout,\n endpoints, browser components through props) then reads the same data entries, so there is one copy. Pages the user\n did not name may change only there, and their output must stay identical.\n8. The shared header and footer stay code in the layout. Their texts and links (menu items, footer links, contact\n details) move into a data entry the layout reads. Fragments are for prose blocks placed inside pages.\n9. Read a shared entry by a fixed name and fail the build when it is missing or duplicated:\n `conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'header', 'en').menu` throws in both cases.\n10. Write all content through the CLI: `conloca page create` / `conloca page update` (with `--content` and the metadata\n flags), `conloca data create` / `conloca data update`, `conloca asset add`. Never hand-write content files.\n11. Delete the old `.astro` file in the same change that makes the Conloca page live. A `src/pages` file always wins\n over a Conloca page at the same path, so the page cannot be seen before that; `conloca compare` is the check, not\n the browser.\n12. Run `conloca compare` again. Every route you did not convert must be identical (its linked stylesheets too); every\n converted route must keep its text, links, `<head>` tags and status; a route that became a Conloca page without\n being named fails. Fix and rerun until it passes, then run `conloca doctor`.\n13. Report every changed file, every page you were not asked to convert whose code changed, every allowed change\n `conloca compare` listed (for example island props that now carry shared values), and anything that could not be\n converted faithfully.\n\nThe workspace also has an MCP server for editing content remotely: pages, fragments and data entries on pushed branches.\nIt cannot change code, upload media or publish. Use the address the editor's prompt gives you; never guess or hardcode\none. Setup and limits: https://conloca.com/workspace-mcp/.\n\n## Custom Puck components\n\nFollow the generated examples in `src/components/puck/` — that is the one proven path:\n\n1. Write a render component plus a `ComponentConfig` wrapped in `withLayout` from `src/components/ComponentLayout.tsx`,\n mirroring the generated `HeadingComponent.tsx` / `Heading.tsx` pair.\n2. Register the component and its Props type in `src/puck.config.tsx`: add it to the `Components` type and the\n `components` map (and optionally a `categories` entry).\n3. Types come from `@puckeditor/core`. If `.tsx` components misrender or fail typecheck, set tsconfig\n `\"jsx\": \"react-jsx\"` — doctor's advisory warning covers this.\n\nA component referenced by stored content but not registered renders blank — see \"Where errors appear\".\n\n## Known limits — by design, do not fight them\n\n- MDX fragments render prose only.\n `Unknown component <X>: fragments render as plain content and cannot use React components.` is intentional: fragment\n content is treated as untrusted, so `{...}` expressions and `import`/`export` statements are rejected too. Do not try\n to sneak components in.\n- Unknown Puck component types render as nothing; the dev-server or build console names them. The fix is registering the\n type in `puck.config.tsx`, not editing the stored content.\n";
|
|
4648
|
+
var conloca_skill_default = "---\nname: conloca\ndescription: Load when working on an Astro site using Conloca CMS — @conloca/* packages, .vxjson content, sites.json.\n---\n\n# Conloca CMS\n\nConloca stores pages as `.vxjson` files (visual pages built from Puck components) and `.mdx` files under `content/`, and\nrenders them through the `@conloca/astro-cms` Astro integration. The visual editor lives at `/__cms` on the dev server\nonly.\n\n## First move: `conloca doctor`\n\nFor any Conloca problem — blank page, 404 on a content page, editor not loading, build failure — run this before reading\nsource:\n\n```bash\nconloca doctor # human-readable report\nconloca doctor --json # single {ok, problems} object on stdout\n```\n\n`conloca <command>` in this skill means `npx @conloca/cli@<version> <command>`: use the exact version a Conloca prompt\ngave you, `@latest` when none did. Never run a different version than the prompt names.\n\nIt checks the content directory (sites.json complete, site directories present, every content file indexes cleanly) and,\nwhen an astro.config is present, the Astro wiring: content config, conlocaCMS import and options, react() order, peer\ndependencies, tsconfig jsx, prerender under server output, Conloca pages hidden behind a `src/pages` file, static pages\nwith no Conloca pages, and siteStyles. Each problem names the broken file and the fix. It is read-only and exits 1 on\nerrors; warnings alone exit 0.\n\nNew project from an empty directory? `conloca create <dir>` writes and installs the whole wired site. An existing Astro\nsite: `conloca connect` installs the packages, wires `astro.config` and writes the site's domain for the workspace\neditor; `conloca astro setup` only scaffolds the starter files.\n\n## Upgrading Conloca\n\nTo move a site to a newer Conloca release:\n\n1. In the site's folder run `npx @conloca/cli@latest upgrade` (or the exact version a Conloca prompt gave you). It\n raises each `@conloca/*` package to the version that CLI release pins in one install, applies the changes between\n versions, refreshes this skill and runs `conloca doctor`. `--dry-run` shows the diffs and changes nothing, `--json`\n prints one object on stdout, `--project <dir>` picks the site folder.\n2. Exit `2`: it lists what a person must change first; nothing was touched. Make those changes, then run it again.\n3. Exit `1`: it failed and put `package.json`, the lockfile and every changed file back. Fix what it names, run the\n install command its message gives when `node_modules` needs it, and run it again.\n4. A `SKILL.new.md` beside a skill means that skill had local edits, so the new text was written next to it: merge it\n into the skill by hand, then delete `SKILL.new.md`.\n5. Review `git diff`, run the build, then commit and push yourself — the command never commits or pushes.\n\nNever edit `@conloca/*` versions by hand: each package has its own version, and `upgrade` moves them to the versions one\nCLI release pins.\n\nDraft previews: updating `@conloca/cloud-astro` moves a site that previewed from its own server (D2), or an\n`@astrojs/cloudflare` server-rendered site, to drafts rendered in the site's own build (d8) on its next build. `upgrade`\nmakes the edits explicit: the start command becomes `node dist/server/entry.mjs` and the `previewBuild` options d8\nignores go. Preview tabs opened before the update stop working; editors reopen Preview.\n\n## The files a working site needs\n\n- `astro.config.mjs` — registers `react()` and `conlocaCMS(...)`\n- `src/content.config.ts` — declares the content collections (without it every content page 404s)\n- `content/sites.json` — sites with their `locales` and `defaultLocale`, plus `globalLocales`\n- `src/puck.config.tsx` — registers the Puck components pages are built from\n- `src/layouts/Layout.astro` — the page layout content pages render into\n- `src/components/puck/*` and `src/schemas/data.ts` — starter components and data-collection schemas\n\nRun `conloca astro setup` inside an existing Astro project. It scaffolds the content config, components, schemas, page\nlayout, and content directories, preserving existing generated files. It adds the default site to `sites.json` when\nmissing. It prints the `astro.config` wiring rather than writing that file: merge the printed options into the existing\nconfig, then run `conloca doctor` to verify the result — or run `conloca connect`, which writes the wiring itself.\n`conloca init . <site-name>` adds another site to sites.json.\n\n## Install: the exact package set\n\n```bash\nnpm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react typia\nnpm install -D ttsc @ttsc/unplugin\n```\n\n`@puckeditor/core` is what the generated components import — there is no other Puck package to install.\n\nttsc compiles with native TypeScript 7, and only one the site declares: a TypeScript 5 or 6 already installed (a\nworkspace root's) keeps the package manager from adding 7 as ttsc's peer. Add `typescript@^7.0.2`, or, keeping\nTypeScript 5 or 6 as `@astrojs/check` requires, an alias:\n`npm install -D typescript@^6.0.3 '@typescript/native@npm:typescript@^7.0.2'`.\n\n## Canonical astro.config.mjs\n\nThe minimal working config, matching what `conloca astro setup` prints:\n\n```js\nimport react from '@astrojs/react';\nimport { conlocaCMS } from '@conloca/astro-cms/node';\nimport { defineConfig } from 'astro/config';\nimport { schemaTypia } from './typia-vite.mjs';\n\nexport default defineConfig({\n integrations: [\n react(),\n conlocaCMS({\n contentRoot: './content',\n puckConfigPath: './src/puck.config.tsx',\n schemasPath: './src/schemas/data.ts',\n layout: './src/layouts/Layout.astro',\n }),\n ],\n vite: { plugins: [...schemaTypia()] },\n});\n```\n\n`react()` must come before `conlocaCMS()` — doctor checks the order. `src/schemas/data.ts` declares each data collection\nas a TypeScript type plus its generated Typia validator (`typia.plain.createValidatePrune<T>()`) and form metadata\n(`typia.json.schema<T>()`); `typia-vite.mjs` is the native transform that generates them, so it must stay in\n`vite.plugins`. And `src/content.config.ts`:\n\n```ts\nimport { conlocaData, conlocaFragments, conlocaPages } from '@conloca/astro-cms/node/content';\nimport { dataSchemas } from './schemas/data';\n\nexport const collections = {\n pages: conlocaPages(),\n ...conlocaData({ dataSchemas }),\n ...conlocaFragments(),\n};\n```\n\nEvery collection is declared here by name — content the config does not name fails the build instead of silently not\nbuilding.\n\n## Where errors appear\n\n- `astro dev` runs in the foreground: config and integration errors print to the terminal running it, and page errors\n also show in the browser error overlay. There is no separate log command — read that terminal.\n- A page referencing a Puck component type missing from puck.config.tsx serves HTTP 200 with a blank region and a clean\n browser console. The signal is `[Conloca] Page references N component type(s) missing from your Puck config: ...` in\n the dev-server or build terminal.\n- `conloca doctor` finds them before a build: C14 warns about every component type or prop a page stores that the Puck\n config does not declare.\n- The editor at `/__cms` exists only on the dev server. A production build without it is not a bug.\n\n## Writing content from the command line\n\nNever hand-write files under `content/`, and do not reach for HTTP endpoints: these commands write what the editor\nwrites, so the result is editable at `/__cms` right away. Each takes `--json` for a machine-readable result.\n\n```bash\nconloca page create --site default --collection pages --pathname /about --title 'About us' --content about.json\nconloca page update /about --description 'Who we are' --image /media/hero.jpg\nconloca data create site --name contact --data contact.json\nconloca data update site contact --data - < contact.json\nconloca asset add ~/Pictures/hero.jpg --alt 'Fresh bread on the counter'\n```\n\n- `page create` — a new page. `--content` takes Puck data `{ root, content, zones }` from a file or `-` (stdin), never\n inline JSON; `--description`, `--image`, `--canonical` and `--robots` fill its page settings.\n- `page update` — change an existing page, found by id or pathname; only the flags given change, and an empty value\n (`--robots ''`) clears a field.\n- `data create` / `data update` — a shared entry (contact details, a header menu): a JSON object from a file or\n `--data -`. `data update` replaces the entry's whole object: send every field, not just the changed one. Declare the\n collection's type in `src/schemas/data.ts`; the first `data create` wires the data schemas.\n- `asset add` — an image into the media folder; it prints the reference an image field stores, e.g. `/media/hero.jpg`.\n\nA layout reads a shared entry by name:\n\n```ts\nimport { getCollection } from 'astro:content';\nimport { conlocaDataEntry } from '@conloca/astro-cms/collections';\nimport { dataSchemas } from '../schemas/data';\n\nconst contact = conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'contact', 'en');\ncontact.phone; // typed by the `site` schema\n```\n\nA missing name, or one saved in several locales with none given, throws and fails the build instead of rendering empty.\n\nEntries a page's blocks list (team, testimonials) bind to the route with\n`routing.routes.<name>.dataBindings.collections`; a block's Puck `resolveData` then reads them from\n`metadata.collections.<name>`.\n\nAfter writing content, run the build: it validates every entry against its schema.\n\n## Editing while the dev server runs\n\nThe CLI and the editor at `/__cms` write the same files, so both can run at once:\n\n- Every write names the version of the page it read. A write against a version someone changed since is merged with that\n change: edits to different fields, blocks or list items with ids both land.\n- A write is refused, with nothing written, only when both changed the same field to different values, when it renames\n the page, or when the version it names is unknown to the writer (e.g. the editor after a dev-server restart). A\n refused command exits with the error: re-run it, and it reads the page again. The editor shows the clash instead of\n overwriting.\n- Writes to one file take a short lock, so a command and an editor save never interleave. A command whose write another\n writer replaced before it exited fails with \"overwritten by another writer\": re-run it.\n\n## Routing\n\n- `layout: './src/layouts/Layout.astro'` alone injects a catch-all `/[...slug]` route over the `pages` collection, with\n `prerender: true` and `fallback: '404'`.\n- Passing `routing` replaces that default route entirely and the top-level `layout` is then ignored — name it per route\n instead: `routing: { routes: { pages: { pattern: '/[...slug]', layout: './src/layouts/Layout.astro' } } }`.\n- `routing: true` is the same default catch-all with no layout.\n- `fallback: '404'` returns a bare 404 when no content matches the pattern; `'passthrough'` hands the miss back to Astro\n so the site's own `/404` page renders, with a real 404 status.\n- Trap: a `src/pages` file always wins over a Conloca page at the same path, and Astro says nothing. Doctor warns when\n one hides a page; delete the file in the same change that makes the Conloca page live.\n\n## Adding Conloca to an existing Astro site\n\n- Switching to `output: 'server'`: first add `export const prerender = true` to every existing file under `src/pages/`,\n then flip the output — otherwise those pages silently stop being static. Doctor errors on files that miss it.\n- Existing `.mdx` content: set the site's `mdxPages` path in `content/sites.json` (relative to the project root, e.g.\n `./src/content/docs`). `.mdx` files under it surface in the CMS as pages of that site; the default locale lives at\n `<mdxPages>/<slug>.mdx`, other locales at `<mdxPages>/<locale>/<slug>.mdx`.\n- Plain `.md` files are never adopted — only `.mdx` and `.vxjson` are recognized as pages. Rename `.md` to `.mdx` to\n bring a file under management.\n\n## Converting an existing Astro page\n\nUse this when the user names existing `src/pages` routes to make editable. Convert only those routes.\n\n1. Run `conloca upgrade` (with the version your prompt gave, as defined above). Stop and report if it or\n `conloca doctor` fails: the commands below ship in that release.\n2. Run `conloca routes` and check each named route is listed. Dynamic routes (`[slug].astro`, content collection pages)\n and non-default-locale routes are out of scope and never listed.\n3. Before changing anything, run `conloca compare --reset --routes /a,/b` with exactly the routes the user named; it\n builds the site and saves a fresh baseline.\n4. Run `conloca components --json` to see the components the site already has.\n5. Port each section of the page to a React component in `src/components/puck/` whose editable text and images are\n fields. `.astro` components cannot be Puck components: port, do not reuse. Scoped `<style>` moves into a stylesheet\n listed in `siteStyles`; `<script>` and `client:` islands keep working through `withHydration()`; links stay links;\n images that become fields go into the assets folder with `conloca asset add`.\n6. Render the page through the layout the original used: point `conlocaCMS` (or a per-route layout) at it and adapt it\n to the props Conloca passes (`title`, `description`, `page`).\n7. Text from data files (like `src/data/*.ts`): per-page text goes into the page; values shared across pages go into\n data entries, moved once, on the first conversion that needs them. Every importer of those values (pages, layout,\n endpoints, browser components through props) then reads the same data entries, so there is one copy. Pages the user\n did not name may change only there, and their output must stay identical.\n8. The shared header and footer stay code in the layout. Their texts and links (menu items, footer links, contact\n details) move into a data entry the layout reads. Fragments are for content blocks placed inside pages: markdown plus\n the site's fragment components (see \"Fragment components\").\n9. Read a shared entry by a fixed name and fail the build when it is missing or duplicated:\n `conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'header', 'en').menu` throws in both cases.\n10. Write all content through the CLI: `conloca page create` / `conloca page update` (with `--content` and the metadata\n flags), `conloca data create` / `conloca data update`, `conloca asset add`. Never hand-write content files.\n11. Delete the old `.astro` file in the same change that makes the Conloca page live. A `src/pages` file always wins\n over a Conloca page at the same path, so the page cannot be seen before that; `conloca compare` is the check, not\n the browser.\n12. Run `conloca compare` again. Every route you did not convert must be identical (its linked stylesheets too); every\n converted route must keep its text, links, `<head>` tags and status; a route that became a Conloca page without\n being named fails. Fix and rerun until it passes, then run `conloca doctor`.\n13. Report every changed file, every page you were not asked to convert whose code changed, every allowed change\n `conloca compare` listed (for example island props that now carry shared values), and anything that could not be\n converted faithfully.\n\nThe workspace also has an MCP server for editing content remotely: pages, fragments and data entries on pushed branches.\nIt cannot change code, upload media or publish. Use the address the editor's prompt gives you; never guess or hardcode\none. Setup and limits: https://conloca.com/workspace-mcp/. Its `get_component_vocabulary` lists the components a\nfragment may use. Every change it makes to a fragment is checked like a save in the editor. On the default branch the\ncomponents are those of the deployed production build, so one added since is refused until that build is deployed. On\nanother branch they are checked only against a deploy of that branch's exact head; otherwise, as when the deployed build\npredates fragment components, the change is stored and the answer gives `vocabularyNotChecked` with the reason.\n\n## Custom Puck components\n\nFollow the generated examples in `src/components/puck/` — that is the one proven path:\n\n1. Write a render component plus a `ComponentConfig` wrapped in `withLayout` from `src/components/ComponentLayout.tsx`,\n mirroring the generated `HeadingComponent.tsx` / `Heading.tsx` pair.\n2. Register the component and its Props type in `src/puck.config.tsx`: add it to the `Components` type and the\n `components` map (and optionally a `categories` entry).\n3. Types come from `@puckeditor/core`. If `.tsx` components misrender or fail typecheck, set tsconfig\n `\"jsx\": \"react-jsx\"` — doctor's advisory warning covers this.\n\nA component referenced by stored content but not registered renders blank — see \"Where errors appear\".\n\n## Fragment components\n\nA fragment is MDX: markdown plus the components the site declares for fragments. Declare them in one render module and\nname it in `conlocaCMS({ fragmentComponentsPath: './src/fragment-components.tsx' })`:\n\n```tsx\n// src/fragment-components.tsx — loaded by the page render, so import no editor code here.\nimport { defineFragmentComponents } from '@conloca/mdx/render';\nimport type { ReactNode } from 'react';\n\nfunction Callout({ children }: { children?: ReactNode }) {\n return <aside className=\"callout\">{children}</aside>;\n}\n\nexport const fragmentComponents = defineFragmentComponents({ components: { Callout } });\n```\n\n- `elements` restyles the HTML markdown produces (`elements: { h2: SectionHeading }`); `outline` makes a component a\n contents entry.\n- An `mdxComponents` descriptor of the same name (from `schemasPath`) gives the component its label, insert hint and\n settings fields. A component without one is still offered, with no settings.\n- Authors write `<Callout>text</Callout>`, or `<Name prop=\"text\" />` without children. Prop values are JSON (`{3}`,\n `{[\"a\", \"b\"]}`); there are no `import` lines, `{…}` expressions, `style` or `on*` props.\n- Components render static HTML. For an interactive one, wrap it with `withHydration(Component, 'visible')` from\n `@conloca/astro-cms/hydration` in its own file and import it into the render module by name.\n- A published or scheduled (not expired) fragment that uses a component the module does not declare fails `astro build`,\n naming the fragment, its file and line: `<X> is not in ./src/fragment-components.tsx`. The fix is declaring the\n component, not editing the fragment. If the module cannot load outside Astro, the build only warns.\n\nAll rules: https://conloca.com/configuration/ (`fragmentComponentsPath`) and https://conloca.com/packages/mdx/ (\"Server:\nFragment Components\").\n\n## Known limits — by design, do not fight them\n\n- Fragment content never runs code: `{...}` expressions, `import`/`export` lines, `<script>`, `style` and `on*`\n attributes are rejected or dropped. Put behavior in a fragment component, never in the fragment.\n- Unknown Puck component types render as nothing; the dev-server or build console names them. The fix is registering the\n type in `puck.config.tsx`, not editing the stored content.\n";
|
|
4638
4649
|
|
|
4639
4650
|
// src/commands/setup.ts
|
|
4640
4651
|
var DEFAULT_SITE_NAME = "default";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conloca/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
"directory": "packages/cli"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@conloca/astro-cms": "0.
|
|
14
|
-
"@conloca/content-api": "0.
|
|
13
|
+
"@conloca/astro-cms": "0.3.0",
|
|
14
|
+
"@conloca/content-api": "0.3.0",
|
|
15
15
|
"diff": "^9.0.0",
|
|
16
16
|
"jsonc-parser": "^3.3.1",
|
|
17
17
|
"linkedom": "^0.18.13",
|
|
18
18
|
"magicast": "^0.5.5"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@conloca/cloud-astro": "0.
|
|
22
|
-
"@conloca/cms-spa": "0.
|
|
23
|
-
"@conloca/content-api-client": "0.
|
|
24
|
-
"@conloca/mdx": "0.
|
|
21
|
+
"@conloca/cloud-astro": "0.3.0",
|
|
22
|
+
"@conloca/cms-spa": "0.3.0",
|
|
23
|
+
"@conloca/content-api-client": "0.3.0",
|
|
24
|
+
"@conloca/mdx": "0.3.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependenciesMeta": {
|
|
27
27
|
"@conloca/cloud-astro": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"!**/*.tsbuildinfo"
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@conloca/cloud-astro": "0.
|
|
53
|
+
"@conloca/cloud-astro": "0.3.0",
|
|
54
54
|
"@types/bun": "1.4.2",
|
|
55
55
|
"commander": "^15.0.0",
|
|
56
56
|
"sharp": "^0.35.4"
|