@conloca/cli 0.2.1 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +52 -7
  2. package/dist/conloca.js +3019 -1815
  3. package/package.json +23 -6
package/README.md CHANGED
@@ -22,10 +22,9 @@ conloca create <directory> [--site <site>] [--pm <manager>] [--no-install] [--no
22
22
 
23
23
  This writes a complete project — `package.json`, `astro.config.mjs` with `conlocaCMS()` wired, `tsconfig.json`,
24
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`.
25
+ Actions workflow that runs the doctor and the build and builds a pull request's own commit. Then it installs
26
+ dependencies, runs `git init`, and runs `conloca doctor` on the result. It refuses a non-empty directory; for an
27
+ existing site use `conloca connect`.
29
28
 
30
29
  `--site` defaults to `default`. `--pm` takes `bun`, `npm`, `pnpm` or `yarn` and defaults to the package manager that
31
30
  launched the CLI — `bunx` selects bun, `npx` npm, `pnpm dlx` pnpm — falling back to `npm`. Installing and `git init` are
@@ -33,6 +32,50 @@ on unless you pass `--no-install` or `--no-git`, and the command never prompts.
33
32
 
34
33
  `--json` prints one object: `{ok, directory, packageManager, created, install, git, doctor: {ok, problems}}`.
35
34
 
35
+ ### Connect a site
36
+
37
+ Set up an existing Astro site's editor page, so your workspace editor at `<slug>.conloca.com` can edit it:
38
+
39
+ ```bash
40
+ conloca connect [path] [--project <dir>] [--site-url <url>] [--yes] [--dry-run] [--no-install] [--no-build] [--json]
41
+ ```
42
+
43
+ An agent can do it in one line:
44
+ `In my Astro site's folder, run npx @conloca/cli@<version> connect, then commit, push and deploy.`
45
+
46
+ Run it in the site's folder or the repository holding it. In order, it:
47
+
48
+ 1. **Finds the project:** the Astro project in `[path]`. A repository with several asks which one in a terminal; without
49
+ 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.
51
+ 2. **Adds packages:** `@conloca/astro-cms`, `@conloca/cloud-astro`, `@astrojs/react` and `@vitejs/plugin-react`,
52
+ whichever `package.json` lacks, with the package manager of the nearest lockfile. `--no-install` prints the command
53
+ instead.
54
+ 3. **Wires `astro.config`:** `react()`, then `conlocaCMS()`, then `conlocaCloud({ repoUri })`, with their imports. A
55
+ site without `conlocaCMS()` also gets the `conloca astro setup` starter files and a `src/content.config.ts`. A config
56
+ that is not a plain `defineConfig({ integrations: [...] })` is left alone: `connect` prints the lines to add. It
57
+ never adds an adapter or `output`.
58
+ 4. **Writes the address:** the host of Astro's `site` (or `--site-url`) into `sites.json` under the site's default
59
+ locale, and Astro's `base` when it is not `/`. It never writes Astro's `site` itself.
60
+ 5. **Allows framing:** only where a committed header file (`public/_headers`, `netlify.toml`, `vercel.json`) forbids
61
+ framing today, it adds a rule for `/_conloca/editor/`. A site-wide `frame-ancestors` policy is left to you.
62
+ 6. **Builds once:** runs the project's `build` script and checks that the output holds `_conloca/editor/index.html` and
63
+ a `conloca.json` with the site's id. `--no-build` skips it.
64
+ 7. **Removes the old build key:** workflow lines that still pass `CONLOCA_BUILD_TOKEN`, which the editor page does not
65
+ need.
66
+
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
+
72
+ `connect` never commits, pushes or deploys, and the package install is its only network use. Next steps: commit, push to
73
+ the default branch, deploy as usual, then open your workspace editor at `<slug>.conloca.com`.
74
+
75
+ Exit codes: `0` every step is done, changed, skipped or kept; `1` a step failed; `2` a step needs you. `--json` prints
76
+ one object: `{ok, project, siteId, packageManager, steps: [{id, state, files?, message}], next}`, where `state` is
77
+ `done`, `changed`, `needs-you`, `differs`, `failed` or `skipped`.
78
+
36
79
  ### Initialize Content Structure
37
80
 
38
81
  `conloca create` and `conloca astro setup` already do this for the first site — use `init` to add another one.
@@ -74,7 +117,8 @@ This command will generate:
74
117
  - `src/components/puck/Flex.tsx` - Flex layout component
75
118
  - `src/components/puck/Grid.tsx` - Grid layout component
76
119
  - `src/layouts/Layout.astro` - Bare page layout, meant to be replaced
77
- - `src/schemas/data.ts` - Example Zod schemas for data collections
120
+ - `src/schemas/data.ts` - Example Typia data-collection schemas (types plus generated validators and form metadata)
121
+ - `typia-vite.mjs` / `tsconfig.typia.json` - The native Typia transform `astro.config.mjs` runs over `src/schemas/`
78
122
  - `content/sites.json` - Site list, holding the site `default`
79
123
  - `.claude/skills/conloca/SKILL.md` - One-page Conloca guide for coding agents
80
124
 
@@ -123,7 +167,7 @@ Astro checks, when an `astro.config.mjs`/`.ts`/`.js` is present (the config is r
123
167
  - `conlocaCMS` is imported from `@conloca/astro-cms/node` and its options carry `contentRoot`, `puckConfigPath`, and a
124
168
  `routing` block or `layout`
125
169
  - `react()` is in `integrations` and comes before `conlocaCMS()`
126
- - the `zod` and `@vitejs/plugin-react` peers are declared in `package.json`
170
+ - the `@vitejs/plugin-react` peer is declared in `package.json`
127
171
  - `tsconfig.json` sets `compilerOptions.jsx` to `react-jsx` (advisory — a warning only)
128
172
  - with `output: 'server'`, every file under `src/pages` declares `prerender`
129
173
  - no static `src/pages/index.astro` shadows the CMS home page
@@ -223,7 +267,8 @@ Adding Conloca to an existing Astro site instead? Install the packages, run `con
223
267
  prints to `astro.config.mjs`, create `src/content.config.ts` as printed, then run `conloca doctor`:
224
268
 
225
269
  ```bash
226
- npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react zod
270
+ npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react typia
271
+ npm install -D ttsc @ttsc/unplugin
227
272
  conloca astro setup
228
273
  conloca doctor
229
274
  ```