@conloca/cli 0.1.16 → 0.2.1
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 +150 -29
- package/dist/conloca.js +3825 -216
- 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
|
|
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/
|
|
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
|
-
|
|
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,137 @@ conloca astro setup
|
|
|
64
95
|
conloca astro setup ./my-astro-project
|
|
65
96
|
```
|
|
66
97
|
|
|
67
|
-
###
|
|
98
|
+
### Check Project Health
|
|
68
99
|
|
|
69
|
-
|
|
100
|
+
Run read-only health checks over a project (replaces the removed `verify` command):
|
|
70
101
|
|
|
71
102
|
```bash
|
|
72
|
-
conloca
|
|
103
|
+
conloca doctor [path] [--json] [--live]
|
|
73
104
|
```
|
|
74
105
|
|
|
75
|
-
|
|
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
|
-
|
|
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
|
-
|
|
114
|
+
- `sites.json` exists, parses, and declares `defaultLocale` plus a non-empty `locales` list for every site, each locale
|
|
115
|
+
one a content file name can carry: a two-letter language code, optionally with a region, like `en` or `en-US`
|
|
116
|
+
- every configured site has its `pages/` directory on disk (site-shaped directories missing from `sites.json` are
|
|
117
|
+
flagged too)
|
|
118
|
+
- every content file indexes cleanly — each file reported is one the CMS would otherwise silently drop
|
|
119
|
+
|
|
120
|
+
Astro checks, when an `astro.config.mjs`/`.ts`/`.js` is present (the config is read as text, never executed):
|
|
121
|
+
|
|
122
|
+
- the content config registers Conloca's collections
|
|
123
|
+
- `conlocaCMS` is imported from `@conloca/astro-cms/node` and its options carry `contentRoot`, `puckConfigPath`, and a
|
|
124
|
+
`routing` block or `layout`
|
|
125
|
+
- `react()` is in `integrations` and comes before `conlocaCMS()`
|
|
126
|
+
- the `zod` and `@vitejs/plugin-react` peers are declared in `package.json`
|
|
127
|
+
- `tsconfig.json` sets `compilerOptions.jsx` to `react-jsx` (advisory — a warning only)
|
|
128
|
+
- with `output: 'server'`, every file under `src/pages` declares `prerender`
|
|
129
|
+
- no static `src/pages/index.astro` shadows the CMS home page
|
|
130
|
+
|
|
131
|
+
Anything doctor cannot determine becomes an explicit warning, never a silent pass, and it never modifies files. The exit
|
|
132
|
+
code is 1 when any error is found; warnings alone exit 0. `--json` prints a single `{ok, problems}` object, each problem
|
|
133
|
+
carrying `check`, `level`, `message`, and usually `path`. Pointing doctor at a directory already named `content` uses
|
|
134
|
+
that directory as the content root, unless it holds a `content/` directory of its own.
|
|
135
|
+
|
|
136
|
+
Example:
|
|
83
137
|
|
|
84
138
|
```bash
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
cd my-site
|
|
139
|
+
conloca doctor ./my-astro-project
|
|
140
|
+
```
|
|
88
141
|
|
|
89
|
-
|
|
90
|
-
|
|
142
|
+
```plain
|
|
143
|
+
Checking /path/to/my-astro-project/content
|
|
144
|
+
✓ C3 sites.json is present and complete
|
|
145
|
+
✓ C4 site directories match sites.json
|
|
146
|
+
✗ C12 content files index cleanly (3 files)
|
|
147
|
+
error: Could not parse VXJSON header for default/pages/broken.en.vxjson (malformed-vxjson)
|
|
148
|
+
✓ C1 content config registers Conloca collections
|
|
149
|
+
…
|
|
150
|
+
✓ C11 no static page shadows the CMS home
|
|
151
|
+
|
|
152
|
+
Found 1 error, 0 warnings
|
|
153
|
+
```
|
|
91
154
|
|
|
92
|
-
|
|
93
|
-
conloca init . default
|
|
155
|
+
### Doctor extensions
|
|
94
156
|
|
|
95
|
-
|
|
96
|
-
conloca
|
|
157
|
+
Doctor also runs checks shipped by the project's own dependencies. Any package in `dependencies` or `devDependencies`
|
|
158
|
+
whose `package.json` carries a `conloca.doctor` field is a doctor extension; the field names a module relative to that
|
|
159
|
+
package, e.g. `"conloca": { "doctor": "./dist/doctor.mjs" }`. Resolution starts at the project, never at the CLI's own
|
|
160
|
+
install, so a globally installed CLI still finds the project's packages.
|
|
97
161
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
162
|
+
The entry is an ES module whose default export is called once with
|
|
163
|
+
`{ contractVersion: 1, projectDir, contentRoot, live }` (a CommonJS module that exports the function as `module.exports`
|
|
164
|
+
works too) and returns `{ contractVersion: 1, checks }`, where every entry of `checks` has the same shape as doctor's
|
|
165
|
+
own: `{ id, label, problems: [{ check, level: 'error' | 'warn', message, path? }], detail?, skipped? }`. The checks are
|
|
166
|
+
appended to the report and to `--json` exactly like built-in ones, so an extension error fails doctor.
|
|
103
167
|
|
|
104
|
-
|
|
105
|
-
|
|
168
|
+
Extensions must stay read-only, and offline unless `live` is true. `live` is true only under `conloca doctor --live`;
|
|
169
|
+
without it an extension should mark its network checks as skipped. A contract-version mismatch, a package that fails to
|
|
170
|
+
load, or a malformed result becomes one warning naming the package — never a crash and never a silent skip. Those
|
|
171
|
+
seam-level warnings carry the check id `EXT`, so `--json` consumers can tell them from an extension's own findings.
|
|
106
172
|
|
|
107
|
-
|
|
173
|
+
### Create a Page
|
|
174
|
+
|
|
175
|
+
Create an empty Puck page in a site's default locale:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
conloca page create --site <site> --collection <collection> --pathname <pathname> --title <title> [path] [--json]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| Argument / Option | Description | Default |
|
|
182
|
+
| --------------------------- | ------------------------------------------------- | ----------------------- |
|
|
183
|
+
| `path` | Project directory holding the content root | `.` (current directory) |
|
|
184
|
+
| `--site <site>` | Site the page belongs to (a key in `sites.json`) | |
|
|
185
|
+
| `--collection <collection>` | Collection directory under the site, e.g. `pages` | |
|
|
186
|
+
| `--pathname <pathname>` | Page route, must start with `/` | |
|
|
187
|
+
| `--title <title>` | Page title (`meta.title`) | |
|
|
188
|
+
| `--json` | Report as a single JSON object on stdout | |
|
|
189
|
+
|
|
190
|
+
Writes a new `.vxjson` file under `<content root>/<site>/<collection>` with the same empty Puck payload the CMS writes
|
|
191
|
+
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
|
|
192
|
+
invalid or already taken, or the write fails; validation failures name the offending option. `--json` prints
|
|
193
|
+
`{ok, id, path, warnings?}` on success and `{ok: false, error, field?}` on failure — stdout carries exactly that one
|
|
194
|
+
object, progress lines and warnings go to stderr.
|
|
195
|
+
|
|
196
|
+
A collection other than `pages` must be declared with `conlocaPages({ collection })` in the content config, or the build
|
|
197
|
+
fails on its pages, and given a route in `conlocaCMS({ routing })` to be served; `page create` warns when the config
|
|
198
|
+
plainly does not declare it.
|
|
199
|
+
|
|
200
|
+
Example:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
conloca page create --site default --collection pages --pathname /about --title 'About us'
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```plain
|
|
207
|
+
Indexing 1 content files...
|
|
208
|
+
✓ Created page /about (vx-0o0swYcO)
|
|
209
|
+
File: content/default/pages/about.en.vxjson
|
|
210
|
+
The page is now editable in the CMS.
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Quick Start
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
bunx @conloca/cli create my-site
|
|
217
|
+
cd my-site
|
|
218
|
+
bun run dev
|
|
219
|
+
# open http://localhost:4321/__cms
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Adding Conloca to an existing Astro site instead? Install the packages, run `conloca astro setup`, add the options it
|
|
223
|
+
prints to `astro.config.mjs`, create `src/content.config.ts` as printed, then run `conloca doctor`:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react zod
|
|
227
|
+
conloca astro setup
|
|
228
|
+
conloca doctor
|
|
108
229
|
```
|
|
109
230
|
|
|
110
231
|
## Development
|