@conloca/cli 0.2.3 → 0.2.5

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 +268 -23
  2. package/dist/conloca.js +3321 -898
  3. package/package.json +21 -7
package/README.md CHANGED
@@ -12,6 +12,9 @@ bun add -g @conloca/cli
12
12
 
13
13
  ## Usage
14
14
 
15
+ `conloca --version` prints the CLI's own version. Each `@conloca/*` package has its own version; one CLI release pins
16
+ the set that goes together, and `upgrade` moves each package to the version this CLI pins.
17
+
15
18
  ### Create a Project
16
19
 
17
20
  Create a new Astro site with Conloca CMS wired in, from an empty directory:
@@ -37,7 +40,7 @@ on unless you pass `--no-install` or `--no-git`, and the command never prompts.
37
40
  Set up an existing Astro site's editor page, so your workspace editor at `<slug>.conloca.com` can edit it:
38
41
 
39
42
  ```bash
40
- conloca connect [path] [--project <dir>] [--site-url <url>] [--yes] [--dry-run] [--no-install] [--no-build] [--json]
43
+ conloca connect [path] [--project <dir>] [--site-url <url>] [--yes] [--dry-run] [--no-install] [--no-build] [--update] [--cf-plan <free|paid>] [--negotiate-404] [--json]
41
44
  ```
42
45
 
43
46
  An agent can do it in one line:
@@ -47,7 +50,8 @@ Run it in the site's folder or the repository holding it. In order, it:
47
50
 
48
51
  1. **Finds the project:** the Astro project in `[path]`. A repository with several asks which one in a terminal; without
49
52
  one it lists them and stops, so you pass `--project <dir>`. The editor needs the repository on GitHub; without a
50
- GitHub `origin` it continues and says so.
53
+ GitHub `origin` it continues and says so. A site whose `@conloca/*` packages are older than this CLI pins is handed
54
+ to `upgrade`: `connect` prints the `upgrade` and `connect` commands to run, writes nothing and exits `2`.
51
55
  2. **Adds packages:** `@conloca/astro-cms`, `@conloca/cloud-astro`, `@astrojs/react` and `@vitejs/plugin-react`,
52
56
  whichever `package.json` lacks, with the package manager of the nearest lockfile. `--no-install` prints the command
53
57
  instead.
@@ -64,10 +68,32 @@ Run it in the site's folder or the repository holding it. In order, it:
64
68
  7. **Removes the old build key:** workflow lines that still pass `CONLOCA_BUILD_TOKEN`, which the editor page does not
65
69
  need.
66
70
 
67
- Every change is printed as a diff first. In a terminal `connect` asks once; `--yes` accepts without asking; `--dry-run`,
68
- or no terminal and no `--yes`, writes nothing. A value you set yourself (another domain, your own `conlocaCloud()`
69
- options, your own `/_conloca/editor/` header rule) is kept and reported as `differs`; only an explicit answer in a
70
- terminal replaces it, never `--yes`. A second run on a connected site changes nothing.
71
+ Every change is printed as a diff first. In a terminal `connect` asks before it writes (and, for a static site
72
+ previewing next to itself, once for your Cloudflare plan); `--yes` accepts without asking; `--dry-run`, or no terminal
73
+ and no `--yes`, writes nothing. A value you set yourself (another domain, your own `conlocaCloud()` options, your own
74
+ `/_conloca/editor/` header rule) is kept and reported as `differs`; only an explicit answer in a terminal replaces it,
75
+ never `--yes`. A second run on a connected site changes nothing.
76
+
77
+ When `conlocaCloud(...)` has `previewBuild`, `connect` also writes the draft preview settings into `wrangler.jsonc`
78
+ (comments kept): the dispatcher `main`, `nodejs_compat`, the static assets, `run_worker_first`, and, on the Cloudflare
79
+ Workers Paid plan, a rate-limit binding that allows each visitor 60 preview requests per 10 seconds (Wrangler 4.36 or
80
+ newer). It never overwrites a setting the site chose; a conflicting `main`, `run_worker_first` or
81
+ single-page-application 404 handling is reported instead, and a `wrangler.toml` is asked to become `wrangler.jsonc`.
82
+ When your middleware negotiates responses (it reads `Accept` or answers 404 pages itself) and you want those misses
83
+ rendered, pass `--negotiate-404`: `connect` then sets `not_found_handling: "none"` and asks you to list the pages it
84
+ negotiates. It never sets it on its own, since with `"none"` a failed preview build fails your build; `conloca doctor`
85
+ points out a middleware that negotiates (CC20).
86
+
87
+ For a static site previewing next to itself, `connect` asks once whether your account is on the Cloudflare Workers Paid
88
+ plan and records the answer in `package.json` (`"conloca": { "cfPlan": "paid" }`). Coding agents and CI pass
89
+ `--cf-plan paid` or `--cf-plan free` instead. On the Free plan the site previews next to itself with no rate limit,
90
+ since a blocked request would still count against the day's requests. A site with on-demand routes (API routes, `/mcp`)
91
+ keeps them next to the preview, and `connect` warns that previews and those routes share one daily request quota: a
92
+ flood of preview requests can stop those routes until 00:00 UTC. Cloudflare Workers Paid removes the daily limit. When
93
+ `--update --cf-plan free` changes a Paid answer, `connect` removes the rate limit it wrote.
94
+
95
+ `conloca connect --update --yes` builds the site and refreshes only the preview settings; it installs nothing. Run it
96
+ when a build fails with "run `conloca connect --update --yes`", after you add an API route.
71
97
 
72
98
  `connect` never commits, pushes or deploys, and the package install is its only network use. Next steps: commit, push to
73
99
  the default branch, deploy as usual, then open your workspace editor at `<slug>.conloca.com`.
@@ -76,6 +102,38 @@ Exit codes: `0` every step is done, changed, skipped or kept; `1` a step failed;
76
102
  one object: `{ok, project, siteId, packageManager, steps: [{id, state, files?, message}], next}`, where `state` is
77
103
  `done`, `changed`, `needs-you`, `differs`, `failed` or `skipped`.
78
104
 
105
+ ### Upgrade a site
106
+
107
+ Bring every `@conloca/*` package of a site to the version the CLI you run pins, with the changes those versions need:
108
+
109
+ ```bash
110
+ npx @conloca/cli@latest upgrade [path] [--project <dir>] [--dry-run] [--json]
111
+ ```
112
+
113
+ Run it in the site's folder or the repository holding it; it picks the Astro project the way `connect` does. In order,
114
+ it:
115
+
116
+ 1. **Refuses what it cannot raise safely:** a `@conloca/*` spec that is no version range (`catalog:`, `workspace:`,
117
+ `link:`, `file:`), `overrides` or `resolutions` pinning a `@conloca/*` package, and any `@conloca/*` package newer
118
+ than this CLI pins, which it never moves back (it tells you to run the latest CLI instead). A site with no
119
+ `@conloca/*` package is sent to `connect`.
120
+ 2. **Dry-runs every migration** a package introduced since the site's version of that package, and stops before touching
121
+ anything when one fails or needs you.
122
+ 3. **Writes:** saves `package.json` and the lockfile, raises every `@conloca/*` package in one package manager install
123
+ (each stays in its own section, `devDependencies` included, also in a workspace root's `package.json`), applies the
124
+ migrations and refreshes the agent skills. A skill page you edited is never overwritten: the new text goes to
125
+ `SKILL.new.md` beside it.
126
+ 4. **Checks:** every installed `@conloca/*` package is at the version upgrade wrote for it, then runs `doctor`.
127
+
128
+ The package and migration changes are printed as a diff first; `--dry-run` stops there. The agent skill refresh is not
129
+ previewed: it reads the `@conloca/cloud-astro` the install brings, and only reports which pages it wrote. On any failure
130
+ the saved files are put back and the report says so, with the install command that puts `node_modules` back. A second
131
+ run on an upgraded site changes nothing. `upgrade` never commits or pushes.
132
+
133
+ Exit codes: `0` every step is done, changed or kept; `1` a step failed and the site was restored; `2` a step needs you
134
+ and nothing was touched. `--json` prints one object:
135
+ `{ok, project, from, to, packageManager, restored, unrestored, steps: [{id, state, files?, message}]}`.
136
+
79
137
  ### Initialize Content Structure
80
138
 
81
139
  `conloca create` and `conloca astro setup` already do this for the first site — use `init` to add another one.
@@ -161,7 +219,8 @@ Content checks, always:
161
219
  flagged too)
162
220
  - every content file indexes cleanly — each file reported is one the CMS would otherwise silently drop
163
221
 
164
- Astro checks, when an `astro.config.mjs`/`.ts`/`.js` is present (the config is read as text, never executed):
222
+ Astro checks, when an `astro.config` (`.mjs`, `.js`, `.ts`, `.mts` or `.cjs`) is present (the config is read as text,
223
+ never executed):
165
224
 
166
225
  - the content config registers Conloca's collections
167
226
  - `conlocaCMS` is imported from `@conloca/astro-cms/node` and its options carry `contentRoot`, `puckConfigPath`, and a
@@ -170,7 +229,17 @@ Astro checks, when an `astro.config.mjs`/`.ts`/`.js` is present (the config is r
170
229
  - the `@vitejs/plugin-react` peer is declared in `package.json`
171
230
  - `tsconfig.json` sets `compilerOptions.jsx` to `react-jsx` (advisory — a warning only)
172
231
  - with `output: 'server'`, every file under `src/pages` declares `prerender`
173
- - no static `src/pages/index.astro` shadows the CMS home page
232
+ - no Conloca page is hidden behind a `src/pages` file at the same path — the file always wins (a warning)
233
+ - a site with static `src/pages` routes has at least one Conloca page for the editor (a warning)
234
+ - every component and prop a Puck page stores is one the Puck config declares — an undeclared one renders as nothing (a
235
+ warning)
236
+ - when Conloca pages exist and `src/` holds a stylesheet, `siteStyles` brings it into the editor (a warning)
237
+
238
+ Repository check, when the project is in a Git repository (it reads the local index only):
239
+
240
+ - Git tracks no dependency or build folder at the project root — `node_modules`, `dist`, `build`, `.astro`, `.next`,
241
+ `.nuxt`, `.output`, `.vercel`, `.netlify`, `.turbo`, `.cache`, `coverage` or `vendor` (a warning naming the
242
+ `git rm -r --cached` command that stops tracking it; some sites commit `dist` on purpose)
174
243
 
175
244
  Anything doctor cannot determine becomes an explicit warning, never a silent pass, and it never modifies files. The exit
176
245
  code is 1 when any error is found; warnings alone exit 0. `--json` prints a single `{ok, problems}` object, each problem
@@ -191,7 +260,11 @@ Checking /path/to/my-astro-project/content
191
260
  error: Could not parse VXJSON header for default/pages/broken.en.vxjson (malformed-vxjson)
192
261
  ✓ C1 content config registers Conloca collections
193
262
  …
194
- ✓ C11 no static page shadows the CMS home
263
+ ✓ C11 no Conloca page is hidden behind a src/pages file
264
+ ✓ C13 the site has Conloca pages to edit
265
+ ✓ C14 pages use only components and fields the Puck config declares
266
+ ✓ C15 siteStyles styles Conloca pages in the editor
267
+ ✓ C16 dependency and build folders are not committed
195
268
 
196
269
  Found 1 error, 0 warnings
197
270
  ```
@@ -214,26 +287,117 @@ without it an extension should mark its network checks as skipped. A contract-ve
214
287
  load, or a malformed result becomes one warning naming the package — never a crash and never a silent skip. Those
215
288
  seam-level warnings carry the check id `EXT`, so `--json` consumers can tell them from an extension's own findings.
216
289
 
290
+ ### List routes
291
+
292
+ List a site's static routes and which of them are Conloca pages:
293
+
294
+ ```bash
295
+ conloca routes [path] [--site <site>] [--json]
296
+ ```
297
+
298
+ | Argument / Option | Description | Default |
299
+ | ----------------- | ----------------------------------------- | ----------------------- |
300
+ | `path` | Project directory, holding `astro.config` | `.` (current directory) |
301
+ | `--site` | Site in `sites.json` to list | the first site |
302
+ | `--json` | Report as a single JSON object on stdout | |
303
+
304
+ It lists every static page route of `src/pages` and every default-locale Conloca page of the site, one line per route.
305
+ When a `src/pages` file and a Conloca page serve the same path, the file wins and the page is marked hidden. Dynamic
306
+ routes (`[slug].astro`, content collection pages) and non-default-locale routes are never listed. Read-only: it never
307
+ modifies a file. `--json` prints `{ok, site, routes}`; each route carries `route`, plus `file` and `prerendered` for a
308
+ `src/pages` file, `pageId` for a Conloca page, and `hidden: true` when both serve it.
309
+
310
+ ```plain
311
+ / src/pages/index.astro
312
+ /about Conloca page about
313
+ /pricing src/pages/pricing.astro
314
+ src/pages/pricing.astro hides Conloca page pricing
315
+ ```
316
+
317
+ ### Compare builds
318
+
319
+ Build the site and compare its output before and after converting pages:
320
+
321
+ ```bash
322
+ conloca compare [path] [--routes <routes>] [--reset] [--json]
323
+ ```
324
+
325
+ | Argument / Option | Description | Default |
326
+ | ----------------- | ------------------------------------------------------------ | ----------------------- |
327
+ | `path` | Project directory, holding `astro.config` | `.` (current directory) |
328
+ | `--routes` | Comma-separated routes the user chose to convert (first run) | none |
329
+ | `--reset` | Remove the saved baseline first, so this run saves a new one | |
330
+ | `--json` | Report as a single JSON object on stdout | |
331
+
332
+ The first run builds the site with its package manager's `run build` and saves the output as a baseline in
333
+ `node_modules/.cache/conloca-compare`, with the routes the user chose to convert (`--routes /pricing,/about`). Later
334
+ runs build again and compare every route with the baseline:
335
+
336
+ - A route nobody touched must be identical, linked `/_astro/*.css` content included. Hashed asset names, timestamps and
337
+ island ids never count; island props that changed because shared values moved into data entries are reported as
338
+ allowed. Sitemaps compare as a set of locations.
339
+ - A chosen route that became a Conloca page must keep its text (with image alt texts), links, head tags and status (page
340
+ or redirect); its markup may change.
341
+ - A route that became a Conloca page without being chosen fails, and so does a Conloca page still hidden behind its
342
+ `src/pages` file, unless it was already hidden at baseline and not chosen.
343
+
344
+ It reads the build from `dist/client` when `dist/server` exists too (a server adapter), else `dist`, and fails when the
345
+ build wrote no fresh HTML there. The site is the first one in `sites.json`. The baseline stays until `--reset`;
346
+ `--routes` is accepted only on the run that saves it. Never commits. Exits 1 when anything differs. `--json` prints
347
+ `{ok, baseline, chosenRoutes, routes, missing, added, unchosen, hidden}`; each route carries `route`, `kind`
348
+ (`untouched` or `converted`), `differences` and `allowed`.
349
+
350
+ ### List components
351
+
352
+ List the site's Puck components and the fields each accepts:
353
+
354
+ ```bash
355
+ conloca components [path] [--json]
356
+ ```
357
+
358
+ | Argument / Option | Description | Default |
359
+ | ----------------- | ---------------------------------------------- | ----------------------- |
360
+ | `path` | Project directory, holding `astro.config` | `.` (current directory) |
361
+ | `--json` | Print the component manifest as JSON on stdout | |
362
+
363
+ It reads the Puck config that `conlocaCMS`'s `puckConfigPath` names from source, without running it, and prints one line
364
+ per component with its fields, then each component it could not read with the reason. `--json` prints the manifest the
365
+ editor and agents use: `components`, `unresolved` and, when the config cannot be fully read, `unreadable: true` with
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. Read-only: it never modifies a file.
368
+
369
+ ```plain
370
+ Hero: title (text), image (image)
371
+ Card: heading (text), body (textarea)
372
+ ```
373
+
217
374
  ### Create a Page
218
375
 
219
- Create an empty Puck page in a site's default locale:
376
+ Create a Puck page in a site's default locale:
220
377
 
221
378
  ```bash
222
- conloca page create --site <site> --collection <collection> --pathname <pathname> --title <title> [path] [--json]
379
+ conloca page create --site <site> --collection <collection> --pathname <pathname> --title <title> [path] [--content <file|->] [--description <text>] [--image <ref>] [--canonical <url>] [--robots <value>] [--json]
223
380
  ```
224
381
 
225
- | Argument / Option | Description | Default |
226
- | --------------------------- | ------------------------------------------------- | ----------------------- |
227
- | `path` | Project directory holding the content root | `.` (current directory) |
228
- | `--site <site>` | Site the page belongs to (a key in `sites.json`) | |
229
- | `--collection <collection>` | Collection directory under the site, e.g. `pages` | |
230
- | `--pathname <pathname>` | Page route, must start with `/` | |
231
- | `--title <title>` | Page title (`meta.title`) | |
232
- | `--json` | Report as a single JSON object on stdout | |
233
-
234
- Writes a new `.vxjson` file under `<content root>/<site>/<collection>` with the same empty Puck payload the CMS writes
235
- 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
236
- invalid or already taken, or the write fails; validation failures name the offending option. `--json` prints
382
+ | Argument / Option | Description | Default |
383
+ | --------------------------- | --------------------------------------------------------------------------- | ----------------------- |
384
+ | `path` | Project directory holding the content root | `.` (current directory) |
385
+ | `--site <site>` | Site the page belongs to (a key in `sites.json`) | |
386
+ | `--collection <collection>` | Collection directory under the site, e.g. `pages` | |
387
+ | `--pathname <pathname>` | Page route, must start with `/` | |
388
+ | `--title <title>` | Page title (`meta.title`) | |
389
+ | `--content <file\|->` | Puck data `{ root, content, zones }` from a JSON file, or `-` to read stdin | the empty page |
390
+ | `--description <text>` | Page description (`meta.description`) | |
391
+ | `--image <ref>` | Social sharing image (`meta.ogImage`) | |
392
+ | `--canonical <url>` | Canonical URL (`meta.canonical`) | |
393
+ | `--robots <value>` | Robots directive, e.g. `noindex` (`meta.robots`) | |
394
+ | `--json` | Report as a single JSON object on stdout | |
395
+
396
+ Writes a new `.vxjson` file under `<content root>/<site>/<collection>` holding the Puck data `--content` points at, or
397
+ the same empty Puck payload the CMS writes for a new page, then prints the page id and the created file path. The
398
+ metadata flags are the fields of the editor's page settings. Inline JSON is not accepted: pass a file, or pipe the JSON
399
+ into `--content -`. It exits 1 when the site is unknown, the pathname is invalid or already taken, `--content` is not
400
+ Puck data, or the write fails; validation failures name the offending option. `--json` prints
237
401
  `{ok, id, path, warnings?}` on success and `{ok: false, error, field?}` on failure — stdout carries exactly that one
238
402
  object, progress lines and warnings go to stderr.
239
403
 
@@ -254,6 +418,84 @@ Indexing 1 content files...
254
418
  The page is now editable in the CMS.
255
419
  ```
256
420
 
421
+ ### Update a Page
422
+
423
+ Change the content or metadata of an existing page in a site's default locale:
424
+
425
+ ```bash
426
+ conloca page update <id|pathname> [path] [--site <site>] [--title <title>] [--content <file|->] [--description <text>] [--image <ref>] [--canonical <url>] [--robots <value>] [--json]
427
+ ```
428
+
429
+ The page is found by its id, or by its route when the reference starts with `/` (`/about/` finds `/about`). `--site`
430
+ defaults to `default`; the other options mean what they mean for `page create`. Only what is given is written:
431
+ `--content` replaces the Puck data and keeps the metadata, a metadata flag sets its field and keeps the content, and an
432
+ empty value (`--robots ''`) clears the field. `--content` writes Puck pages only, so an MDX page takes metadata flags
433
+ alone. It exits 1 when no page has that id or route, the id belongs to a data entry or fragment, nothing is given to
434
+ update, or the write fails. `--json` prints `{ok, id, path}` on success and `{ok: false, error, field?}` on failure.
435
+
436
+ Example:
437
+
438
+ ```bash
439
+ conloca page update /about --content about.json --description 'Who we are'
440
+ ```
441
+
442
+ ### Data entries
443
+
444
+ Create a data entry, such as site settings or an author, in a site's default locale:
445
+
446
+ ```bash
447
+ conloca data create <collection> [path] --name <name> --data <file|-> [--title <title>] [--site <site>] [--no-install] [--json]
448
+ ```
449
+
450
+ `--data` is a JSON object, read from a file or from stdin with `-`; anything else is refused before a file is written.
451
+ The entry lands in `<content root>/data/<collection>/<name>.<locale>.json`, titled `--title` or its name. A name another
452
+ entry of the collection has, in any letter case, is refused. A site without data schemas yet is wired first:
453
+ `schemasPath`, `assetsPath` and the Typia vite plugin in `astro.config`, `conlocaData()` in the content config, the
454
+ starter `src/schemas/data.ts`, `typia-vite.mjs` and `tsconfig.typia.json`, and the Typia packages, added with the site's
455
+ package manager (`--no-install` prints that command instead). A config it cannot edit stops the command, with the lines
456
+ to add by hand. When the schemas module declares no such collection, it warns that the build fails on the entry.
457
+ `--json` prints `{ok, id, path, wired?, command?, warnings?}`.
458
+
459
+ Replace the data of an existing entry, found by its id or by its name in the collection:
460
+
461
+ ```bash
462
+ conloca data update <collection> <id|name> [path] --data <file|-> [--title <title>] [--site <site>] [--json]
463
+ ```
464
+
465
+ It keeps the title unless `--title` is given, and exits 1 when no entry of the collection has that id or name. `--json`
466
+ prints `{ok, id, path}`.
467
+
468
+ Example:
469
+
470
+ ```bash
471
+ echo '{"siteName":"Corner Bakery"}' | conloca data create settings --name site --data -
472
+ ```
473
+
474
+ ### Add an image
475
+
476
+ Copy an image into the image folder of the site and print the reference an image field stores:
477
+
478
+ ```bash
479
+ conloca asset add <file> [path] [--folder <folder>] [--alt <text>] [--no-install] [--json]
480
+ ```
481
+
482
+ The image lands in the `assetsPath` of `conlocaCMS()`, stored the way an editor upload stores it: the name lowercased
483
+ and made URL-safe, keeping underscores and inner dots (`Hero Shot.JPG` becomes `hero-shot.jpg`, `My_Photo.JPG` becomes
484
+ `my_photo.jpg`), a name already taken in any letter case stored as `hero-1.jpg`, and only web image formats up to 25 MB
485
+ taken. A photo whose long edge is over 2560 pixels is stored as a 2560 pixel WebP named `.webp` (a PNG stays PNG),
486
+ upright and without its location data; without the optional `sharp` package it is stored unshrunk with a warning.
487
+ `--folder` puts it in a folder inside the media folder (a new folder must be a name Git and an image link can hold: no
488
+ spaces, no leading dot, none of `# ? % & * : |`); `--alt` records its alt text. A site without data schemas is wired
489
+ first, as `data create` wires it: the schemas, the assets folder and the Typia packages. It prints the reference, such
490
+ as `/media/hero.jpg` (with the site's `base` in front), and the file path; `--json` prints
491
+ `{ok, ref, path, wired?, command?}`. A config that computes `assetsPath`, `publicDir` or `base` stops the command.
492
+
493
+ Example:
494
+
495
+ ```bash
496
+ conloca asset add ~/Pictures/hero.jpg --alt 'Fresh bread on the counter'
497
+ ```
498
+
257
499
  ## Quick Start
258
500
 
259
501
  ```bash
@@ -273,6 +515,9 @@ conloca astro setup
273
515
  conloca doctor
274
516
  ```
275
517
 
518
+ ttsc compiles with native TypeScript 7. A site that keeps TypeScript 5 or 6, as `@astrojs/check` requires, adds it under
519
+ an alias: `npm install -D typescript@^6.0.3 '@typescript/native@npm:typescript@^7.0.2'`.
520
+
276
521
  ## Development
277
522
 
278
523
  ### Building