@conloca/cli 0.1.16 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +145 -29
  2. package/dist/conloca.js +3742 -216
  3. package/package.json +65 -8
package/README.md CHANGED
@@ -12,8 +12,31 @@ bun add -g @conloca/cli
12
12
 
13
13
  ## Usage
14
14
 
15
+ ### Create a Project
16
+
17
+ Create a new Astro site with Conloca CMS wired in, from an empty directory:
18
+
19
+ ```bash
20
+ conloca create <directory> [--site <site>] [--pm <manager>] [--no-install] [--no-git] [--json]
21
+ ```
22
+
23
+ This writes a complete project — `package.json`, `astro.config.mjs` with `conlocaCMS()` wired, `tsconfig.json`,
24
+ `src/content.config.ts`, the starter components and Puck config, a first page at `/`, the agent skill, and a GitHub
25
+ Actions workflow that passes a `CONLOCA_BUILD_TOKEN` secret from the repository to the doctor and build steps (never to
26
+ dependency install scripts) and builds a pull request's own commit. Nothing in this scaffold reads that secret; the slot
27
+ is there for an integration that builds with a token. Then it installs dependencies, runs `git init`, and runs
28
+ `conloca doctor` on the result. It refuses a non-empty directory; for an existing site use `conloca astro setup`.
29
+
30
+ `--site` defaults to `default`. `--pm` takes `bun`, `npm`, `pnpm` or `yarn` and defaults to the package manager that
31
+ launched the CLI — `bunx` selects bun, `npx` npm, `pnpm dlx` pnpm — falling back to `npm`. Installing and `git init` are
32
+ on unless you pass `--no-install` or `--no-git`, and the command never prompts.
33
+
34
+ `--json` prints one object: `{ok, directory, packageManager, created, install, git, doctor: {ok, problems}}`.
35
+
15
36
  ### Initialize Content Structure
16
37
 
38
+ `conloca create` and `conloca astro setup` already do this for the first site — use `init` to add another one.
39
+
17
40
  Initialize a new Conloca content structure for a site:
18
41
 
19
42
  ```bash
@@ -25,7 +48,7 @@ This command will:
25
48
  - Create the content directory structure
26
49
  - Create directories for the specified site
27
50
  - Create or update the sites.json configuration file
28
- - Set up the blocks/shared directory for shared components
51
+ - Set up the fragments/shared directory for shared components
29
52
 
30
53
  Example:
31
54
 
@@ -44,15 +67,23 @@ conloca astro setup [path]
44
67
  This command will generate:
45
68
 
46
69
  - `src/puck.config.tsx` - Puck component configuration
47
- - `src/components/Layout.tsx` - Layout HOC with grid/flex support
70
+ - `src/components/ComponentLayout.tsx` - Puck HOC adding grid/flex props to a component
48
71
  - `src/components/Section.tsx` - Section wrapper component
49
72
  - `src/components/puck/Heading.tsx` - Heading component
50
73
  - `src/components/puck/Text.tsx` - Text component
51
74
  - `src/components/puck/Flex.tsx` - Flex layout component
52
75
  - `src/components/puck/Grid.tsx` - Grid layout component
76
+ - `src/layouts/Layout.astro` - Bare page layout, meant to be replaced
53
77
  - `src/schemas/data.ts` - Example Zod schemas for data collections
78
+ - `content/sites.json` - Site list, holding the site `default`
79
+ - `.claude/skills/conloca/SKILL.md` - One-page Conloca guide for coding agents
54
80
 
55
- > **Note:** Routes are now handled automatically by the Astro plugin. Configure routing in your `astro.config.mjs` with `conlocaCMS({ routing: true })`.
81
+ Existing files are left alone, so the command is safe to re-run.
82
+
83
+ > **Note:** Routes are handled by the Astro plugin. Naming the page layout with
84
+ > `conlocaCMS({ layout: './src/layouts/Layout.astro' })` turns on a catch-all `/[...slug]` route over the `pages`
85
+ > collection. Passing `routing` as well replaces that route and the top-level `layout` is then ignored, so multi-route
86
+ > sites name their layout under `routing.routes.<name>.layout` instead.
56
87
 
57
88
  Examples:
58
89
 
@@ -64,47 +95,132 @@ conloca astro setup
64
95
  conloca astro setup ./my-astro-project
65
96
  ```
66
97
 
67
- ### Verify Content
98
+ ### Check Project Health
68
99
 
69
- Verify content files in a directory, automatically repairing any files missing required fields:
100
+ Run read-only health checks over a project (replaces the removed `verify` command):
70
101
 
71
102
  ```bash
72
- conloca verify <directory>
103
+ conloca doctor [path] [--json] [--live]
73
104
  ```
74
105
 
75
- This command will:
106
+ | Argument / Option | Description | Default |
107
+ | ----------------- | ----------------------------------------------------------------- | ----------------------- |
108
+ | `path` | Project directory to check | `.` (current directory) |
109
+ | `--json` | Report as a single JSON object on stdout | |
110
+ | `--live` | Let doctor extensions contact the services the project configures | |
76
111
 
77
- - Check all content files in the specified directory
78
- - Automatically repair files missing required fields (id, created, modified)
79
- - Report any errors found
80
- - Display a summary of verified content items
112
+ Content checks, always:
81
113
 
82
- ## Quick Start
114
+ - `sites.json` exists, parses, and declares `defaultLocale` plus a non-empty `locales` list for every site
115
+ - every configured site has its `pages/` directory on disk (site-shaped directories missing from `sites.json` are
116
+ flagged too)
117
+ - every content file indexes cleanly — each file reported is one the CMS would otherwise silently drop
118
+
119
+ Astro checks, when an `astro.config.mjs`/`.ts`/`.js` is present (the config is read as text, never executed):
120
+
121
+ - the content config registers Conloca's collections
122
+ - `conlocaCMS` is imported from `@conloca/astro-cms/node` and its options carry `contentRoot`, `puckConfigPath`, and a
123
+ `routing` block or `layout`
124
+ - `react()` is in `integrations` and comes before `conlocaCMS()`
125
+ - the `zod` and `@vitejs/plugin-react` peers are declared in `package.json`
126
+ - `tsconfig.json` sets `compilerOptions.jsx` to `react-jsx` (advisory — a warning only)
127
+ - with `output: 'server'`, every file under `src/pages` declares `prerender`
128
+ - no static `src/pages/index.astro` shadows the CMS home page
129
+
130
+ Anything doctor cannot determine becomes an explicit warning, never a silent pass, and it never modifies files. The exit
131
+ code is 1 when any error is found; warnings alone exit 0. `--json` prints a single `{ok, problems}` object, each problem
132
+ carrying `check`, `level`, `message`, and usually `path`. Pointing doctor at a directory already named `content` uses
133
+ that directory as the content root, unless it holds a `content/` directory of its own.
134
+
135
+ Example:
83
136
 
84
137
  ```bash
85
- # 1. Create a new Astro project (if you don't have one)
86
- npm create astro@latest my-site
87
- cd my-site
138
+ conloca doctor ./my-astro-project
139
+ ```
88
140
 
89
- # 2. Install Conloca packages
90
- npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @measured/puck
141
+ ```plain
142
+ Checking /path/to/my-astro-project/content
143
+ ✓ C3 sites.json is present and complete
144
+ ✓ C4 site directories match sites.json
145
+ ✗ C12 content files index cleanly (3 files)
146
+ error: Could not parse VXJSON header for default/pages/broken.en.vxjson (malformed-vxjson)
147
+ ✓ C1 content config registers Conloca collections
148
+ …
149
+ ✓ C11 no static page shadows the CMS home
150
+
151
+ Found 1 error, 0 warnings
152
+ ```
91
153
 
92
- # 3. Initialize content structure
93
- conloca init . default
154
+ ### Doctor extensions
94
155
 
95
- # 4. Set up Astro integration (components + Puck config)
96
- conloca astro setup
156
+ Doctor also runs checks shipped by the project's own dependencies. Any package in `dependencies` or `devDependencies`
157
+ whose `package.json` carries a `conloca.doctor` field is a doctor extension; the field names a module relative to that
158
+ package, e.g. `"conloca": { "doctor": "./dist/doctor.mjs" }`. Resolution starts at the project, never at the CLI's own
159
+ install, so a globally installed CLI still finds the project's packages.
97
160
 
98
- # 5. Configure routing in astro.config.mjs:
99
- # import { conlocaCMS } from '@conloca/astro-cms';
100
- # export default defineConfig({
101
- # integrations: [conlocaCMS({ routing: true })]
102
- # });
161
+ The entry is an ES module whose default export is called once with
162
+ `{ contractVersion: 1, projectDir, contentRoot, live }` (a CommonJS module that exports the function as `module.exports`
163
+ works too) and returns `{ contractVersion: 1, checks }`, where every entry of `checks` has the same shape as doctor's
164
+ own: `{ id, label, problems: [{ check, level: 'error' | 'warn', message, path? }], detail?, skipped? }`. The checks are
165
+ appended to the report and to `--json` exactly like built-in ones, so an extension error fails doctor.
103
166
 
104
- # 6. Start your dev server
105
- npm run dev
167
+ Extensions must stay read-only, and offline unless `live` is true. `live` is true only under `conloca doctor --live`;
168
+ without it an extension should mark its network checks as skipped. A contract-version mismatch, a package that fails to
169
+ load, or a malformed result becomes one warning naming the package — never a crash and never a silent skip. Those
170
+ seam-level warnings carry the check id `EXT`, so `--json` consumers can tell them from an extension's own findings.
106
171
 
107
- # 7. Visit /__cms to edit pages
172
+ ### Create a Page
173
+
174
+ Create an empty Puck page in a site's default locale:
175
+
176
+ ```bash
177
+ conloca page create --site <site> --collection <collection> --pathname <pathname> --title <title> [path] [--json]
178
+ ```
179
+
180
+ | Argument / Option | Description | Default |
181
+ | --------------------------- | ------------------------------------------------- | ----------------------- |
182
+ | `path` | Project directory holding the content root | `.` (current directory) |
183
+ | `--site <site>` | Site the page belongs to (a key in `sites.json`) | |
184
+ | `--collection <collection>` | Collection directory under the site, e.g. `pages` | |
185
+ | `--pathname <pathname>` | Page route, must start with `/` | |
186
+ | `--title <title>` | Page title (`meta.title`) | |
187
+ | `--json` | Report as a single JSON object on stdout | |
188
+
189
+ Writes a new `.vxjson` file under `<content root>/<site>/<collection>` with the same empty Puck payload the CMS writes
190
+ for a new page, then prints the page id and the created file path. It exits 1 when the site is unknown, the pathname is
191
+ invalid or already taken, or the write fails; validation failures name the offending option. `--json` prints
192
+ `{ok, id, path}` on success and `{ok: false, error, field?}` on failure — stdout carries exactly that one object,
193
+ progress lines go to stderr.
194
+
195
+ Example:
196
+
197
+ ```bash
198
+ conloca page create --site default --collection pages --pathname /about --title 'About us'
199
+ ```
200
+
201
+ ```plain
202
+ Indexing 1 content files...
203
+ ✓ Created page /about (vx-0o0swYcO)
204
+ File: content/default/pages/about.en.vxjson
205
+ The page is now editable in the CMS.
206
+ ```
207
+
208
+ ## Quick Start
209
+
210
+ ```bash
211
+ bunx @conloca/cli create my-site
212
+ cd my-site
213
+ bun run dev
214
+ # open http://localhost:4321/__cms
215
+ ```
216
+
217
+ Adding Conloca to an existing Astro site instead? Install the packages, run `conloca astro setup`, add the options it
218
+ prints to `astro.config.mjs`, create `src/content.config.ts` as printed, then run `conloca doctor`:
219
+
220
+ ```bash
221
+ npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react zod
222
+ conloca astro setup
223
+ conloca doctor
108
224
  ```
109
225
 
110
226
  ## Development