@conloca/cloud-astro 0.2.2 → 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.
- package/README.md +261 -208
- package/dist/.build-inputs.json +60 -0
- package/dist/src/component-manifest.d.ts +5 -3
- package/dist/src/component-manifest.d.ts.map +1 -1
- package/dist/src/component-manifest.js +7 -7
- package/dist/src/component-manifest.js.map +1 -1
- package/dist/src/constants.d.ts +5 -13
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +5 -13
- package/dist/src/constants.js.map +1 -1
- package/dist/src/descriptors.d.ts +2 -2
- package/dist/src/descriptors.d.ts.map +1 -1
- package/dist/src/doctor/checks-address.d.ts +18 -0
- package/dist/src/doctor/checks-address.d.ts.map +1 -0
- package/dist/src/doctor/checks-address.js +163 -0
- package/dist/src/doctor/checks-address.js.map +1 -0
- package/dist/src/doctor/checks-live.d.ts +8 -5
- package/dist/src/doctor/checks-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-live.js +220 -188
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/checks-offline.d.ts +8 -23
- package/dist/src/doctor/checks-offline.d.ts.map +1 -1
- package/dist/src/doctor/checks-offline.js +22 -239
- package/dist/src/doctor/checks-offline.js.map +1 -1
- package/dist/src/doctor/config-scan.d.ts +6 -3
- package/dist/src/doctor/config-scan.d.ts.map +1 -1
- package/dist/src/doctor/config-scan.js +21 -11
- package/dist/src/doctor/config-scan.js.map +1 -1
- package/dist/src/doctor/run.d.ts.map +1 -1
- package/dist/src/doctor/run.js +12 -10
- package/dist/src/doctor/run.js.map +1 -1
- package/dist/src/doctor/types.d.ts +7 -7
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +7 -7
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/bundle.d.ts +88 -0
- package/dist/src/editor-page/bundle.d.ts.map +1 -0
- package/dist/src/editor-page/bundle.js +370 -0
- package/dist/src/editor-page/bundle.js.map +1 -0
- package/dist/src/editor-page/emit.d.ts +33 -0
- package/dist/src/editor-page/emit.d.ts.map +1 -0
- package/dist/src/editor-page/emit.js +183 -0
- package/dist/src/editor-page/emit.js.map +1 -0
- package/dist/src/editor-page/framing.d.ts +23 -0
- package/dist/src/editor-page/framing.d.ts.map +1 -0
- package/dist/src/editor-page/framing.js +39 -0
- package/dist/src/editor-page/framing.js.map +1 -0
- package/dist/src/editor-page/page.d.ts +9 -0
- package/dist/src/editor-page/page.d.ts.map +1 -0
- package/dist/src/editor-page/page.js +31 -0
- package/dist/src/editor-page/page.js.map +1 -0
- package/dist/src/editor-page/site-base.d.ts +4 -0
- package/dist/src/editor-page/site-base.d.ts.map +1 -0
- package/dist/src/editor-page/site-base.js +13 -0
- package/dist/src/editor-page/site-base.js.map +1 -0
- package/dist/src/git.d.ts +11 -8
- package/dist/src/git.d.ts.map +1 -1
- package/dist/src/git.js +25 -8
- package/dist/src/git.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/integration.d.ts +1 -1
- package/dist/src/integration.d.ts.map +1 -1
- package/dist/src/integration.js +245 -408
- package/dist/src/integration.js.map +1 -1
- package/dist/src/node.d.ts +3 -1
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +7 -2
- package/dist/src/node.js.map +1 -1
- package/dist/src/preview/_resolve-opts.d.ts +16 -10
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
- package/dist/src/preview/_resolve-opts.js +21 -10
- package/dist/src/preview/_resolve-opts.js.map +1 -1
- package/dist/src/preview/banner.d.ts.map +1 -1
- package/dist/src/preview/banner.js +2 -4
- package/dist/src/preview/banner.js.map +1 -1
- package/dist/src/preview/cookie.d.ts +5 -2
- package/dist/src/preview/cookie.d.ts.map +1 -1
- package/dist/src/preview/cookie.js +5 -2
- package/dist/src/preview/cookie.js.map +1 -1
- package/dist/src/preview/label.d.ts +8 -0
- package/dist/src/preview/label.d.ts.map +1 -0
- package/dist/src/preview/label.js +14 -0
- package/dist/src/preview/label.js.map +1 -0
- package/dist/src/preview/landing.d.ts +2 -2
- package/dist/src/preview/landing.js +2 -2
- package/dist/src/preview/middleware.d.ts +25 -20
- package/dist/src/preview/middleware.d.ts.map +1 -1
- package/dist/src/preview/middleware.js +56 -51
- package/dist/src/preview/middleware.js.map +1 -1
- package/dist/src/preview/preview-path.d.ts +18 -5
- package/dist/src/preview/preview-path.d.ts.map +1 -1
- package/dist/src/preview/preview-path.js +24 -8
- package/dist/src/preview/preview-path.js.map +1 -1
- package/dist/src/preview/site-middleware.d.ts +5 -5
- package/dist/src/preview/site-middleware.d.ts.map +1 -1
- package/dist/src/preview/site-middleware.js +16 -16
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview-build.d.ts +18 -15
- package/dist/src/preview-build.d.ts.map +1 -1
- package/dist/src/preview-build.js +36 -21
- package/dist/src/preview-build.js.map +1 -1
- package/dist/src/preview.d.ts +1 -1
- package/dist/src/preview.d.ts.map +1 -1
- package/dist/src/preview.js +1 -1
- package/dist/src/preview.js.map +1 -1
- package/dist/src/repository.d.ts +1 -1
- package/dist/src/repository.js +1 -1
- package/dist/src/resolve-options.d.ts +17 -0
- package/dist/src/resolve-options.d.ts.map +1 -0
- package/dist/src/resolve-options.js +21 -0
- package/dist/src/resolve-options.js.map +1 -0
- package/dist/src/site-id.d.ts +0 -2
- package/dist/src/site-id.d.ts.map +1 -1
- package/dist/src/site-id.js +2 -3
- package/dist/src/site-id.js.map +1 -1
- package/dist/src/types.d.ts +21 -69
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +37 -13
- package/src/component-manifest.ts +11 -8
- package/src/constants.ts +5 -14
- package/src/descriptors.ts +2 -2
- package/src/doctor/checks-address.ts +190 -0
- package/src/doctor/checks-live.ts +256 -268
- package/src/doctor/checks-offline.ts +24 -262
- package/src/doctor/config-scan.ts +21 -9
- package/src/doctor/run.ts +14 -16
- package/src/doctor/types.ts +7 -7
- package/src/editor-page/bundle.ts +482 -0
- package/src/editor-page/emit.ts +246 -0
- package/src/editor-page/framing.ts +62 -0
- package/src/editor-page/page.ts +37 -0
- package/src/editor-page/site-base.ts +11 -0
- package/src/git.ts +29 -10
- package/src/index.ts +20 -6
- package/src/integration.ts +255 -461
- package/src/node.ts +18 -2
- package/src/preview/_resolve-opts.ts +29 -11
- package/src/preview/banner.ts +2 -4
- package/src/preview/cookie.ts +5 -2
- package/src/preview/label.ts +12 -0
- package/src/preview/landing.ts +2 -2
- package/src/preview/middleware.ts +77 -66
- package/src/preview/preview-path.ts +26 -8
- package/src/preview/site-middleware.ts +16 -21
- package/src/preview-build.ts +42 -26
- package/src/preview-handler.astro +10 -8
- package/src/preview.ts +0 -1
- package/src/repository.ts +1 -1
- package/src/resolve-options.ts +37 -0
- package/src/site-id.ts +2 -4
- package/src/skill/SKILL.md +51 -55
- package/src/types.ts +21 -70
- package/src/virtual-modules.d.ts +4 -1
- package/dist/src/build-commit.d.ts +0 -19
- package/dist/src/build-commit.d.ts.map +0 -1
- package/dist/src/build-commit.js +0 -6
- package/dist/src/build-commit.js.map +0 -1
- package/dist/src/bundle.d.ts +0 -181
- package/dist/src/bundle.d.ts.map +0 -1
- package/dist/src/bundle.js +0 -413
- package/dist/src/bundle.js.map +0 -1
- package/dist/src/discovery.d.ts +0 -58
- package/dist/src/discovery.d.ts.map +0 -1
- package/dist/src/discovery.js +0 -133
- package/dist/src/discovery.js.map +0 -1
- package/dist/src/register.d.ts +0 -98
- package/dist/src/register.d.ts.map +0 -1
- package/dist/src/register.js +0 -103
- package/dist/src/register.js.map +0 -1
- package/src/build-commit.ts +0 -22
- package/src/bundle.ts +0 -570
- package/src/discovery.ts +0 -183
- package/src/register.ts +0 -180
package/README.md
CHANGED
|
@@ -1,42 +1,52 @@
|
|
|
1
1
|
# `@conloca/cloud-astro`
|
|
2
2
|
|
|
3
|
-
Astro integration that
|
|
4
|
-
to `conlocaCMS` to:
|
|
5
|
-
|
|
6
|
-
1.
|
|
7
|
-
(react/react-dom/jsx-runtime/`@puckeditor/core` stay external — the editor supplies them at runtime)
|
|
8
|
-
|
|
9
|
-
2.
|
|
10
|
-
3. Wire preview SSR middleware that
|
|
11
|
-
and
|
|
3
|
+
Astro integration that adds the editor page for Conloca's workspace editor to a site's build. Add it to the site's
|
|
4
|
+
`astro.config.mjs` next to `conlocaCMS` to:
|
|
5
|
+
|
|
6
|
+
1. Write the editor page to `/_conloca/editor/` in every build: the site's Puck config compiled into one bundle
|
|
7
|
+
(react/react-dom/jsx-runtime/`@puckeditor/core` stay external — the workspace editor supplies them at runtime), its
|
|
8
|
+
styles, the MDX sandbox frame and `conloca.json`. The page carries no credential.
|
|
9
|
+
2. When `previewBuild` is given as an object, run a recursive preview build that emits SSR routes for draft content.
|
|
10
|
+
3. Wire preview SSR middleware that serves `/_conloca/preview/*` under the site's `base` and admits only passes, signed
|
|
11
|
+
by the endpoint's token issuer, for the repository, site and branch the preview build was made from.
|
|
12
12
|
4. Expose `PreviewContentAPI` for `.astro` pages to fetch draft content.
|
|
13
13
|
|
|
14
|
-
Items 2 to 4 serve draft previews, which are not available on your own deployment yet.
|
|
15
|
-
|
|
14
|
+
Items 2 to 4 serve draft previews, which are not available on your own deployment yet. They stay off unless
|
|
15
|
+
`previewBuild` is given as an object (see [Draft previews](#draft-previews)).
|
|
16
16
|
|
|
17
17
|
## Setup
|
|
18
18
|
|
|
19
19
|
Before you start you need:
|
|
20
20
|
|
|
21
|
-
- An Astro site
|
|
22
|
-
- The repository connected to
|
|
23
|
-
GitHub**, and pick the repository on GitHub's installation screen. If a GitHub organization
|
|
24
|
-
you are not one of its owners, an owner has to approve the installation; until then the editor
|
|
25
|
-
approval**.
|
|
26
|
-
-
|
|
27
|
-
|
|
21
|
+
- An Astro site in a GitHub repository.
|
|
22
|
+
- The repository connected to your workspace editor at `<slug>.conloca.com`: sign in there with **Continue with
|
|
23
|
+
GitHub**, choose **Connect GitHub**, and pick the repository on GitHub's installation screen. If a GitHub organization
|
|
24
|
+
owns the repository and you are not one of its owners, an owner has to approve the installation; until then the editor
|
|
25
|
+
shows **Waiting for approval**.
|
|
26
|
+
- A place the site is deployed to, at an address visitors reach without signing in. The workspace editor edits the
|
|
27
|
+
deployed site: it opens the editor page your build adds under `/_conloca/editor/`, so editing starts after the first
|
|
28
|
+
deploy. For editing before that, `astro dev` keeps the local editor at `/__cms`.
|
|
28
29
|
|
|
29
|
-
### 1.
|
|
30
|
+
### 1. Run `conloca connect`
|
|
31
|
+
|
|
32
|
+
In the site's folder, or the repository holding it:
|
|
30
33
|
|
|
31
34
|
```sh
|
|
32
|
-
|
|
35
|
+
npx @conloca/cli connect
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
A coding agent can do the whole setup from one line:
|
|
39
|
+
`In my Astro site's folder, run npx @conloca/cli@<version> connect, then commit, push and deploy.`
|
|
40
|
+
|
|
41
|
+
`connect` adds `@conloca/astro-cms`, `@conloca/cloud-astro`, `@astrojs/react` and `@vitejs/plugin-react` with the
|
|
42
|
+
package manager of the nearest lockfile, wires `astro.config`, writes the site's host into `sites.json` (step 2), adds a
|
|
43
|
+
framing rule only where a committed header file forbids framing (step 3), builds the site once to check that the editor
|
|
44
|
+
page is there, and removes old build key lines from workflows. Every change is shown as a diff first: in a terminal it
|
|
45
|
+
asks once, `--yes` accepts without asking, and `--dry-run` writes nothing. A value you set yourself is kept and reported
|
|
46
|
+
as `differs`. It exits `2` with the lines to add when a step needs you, such as a config that is not a plain
|
|
47
|
+
`defineConfig({ integrations: [...] })`. `npx @conloca/cli connect --help` lists every option.
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
The config it wires:
|
|
40
50
|
|
|
41
51
|
```js
|
|
42
52
|
// astro.config.mjs
|
|
@@ -46,6 +56,7 @@ import { conlocaCloud } from '@conloca/cloud-astro';
|
|
|
46
56
|
import { defineConfig } from 'astro/config';
|
|
47
57
|
|
|
48
58
|
export default defineConfig({
|
|
59
|
+
site: 'https://www.example.com',
|
|
49
60
|
// Keep your existing settings (output, adapter, ...) as they are.
|
|
50
61
|
integrations: [
|
|
51
62
|
react(),
|
|
@@ -54,124 +65,116 @@ export default defineConfig({
|
|
|
54
65
|
puckConfigPath: './src/puck.config.tsx',
|
|
55
66
|
layout: './src/layouts/Layout.astro',
|
|
56
67
|
}),
|
|
57
|
-
conlocaCloud({
|
|
58
|
-
endpoint: 'https://cms.example.com',
|
|
59
|
-
puckConfigPath: './src/puck.config.tsx',
|
|
60
|
-
publicBaseUrl: 'https://www.example.com',
|
|
61
|
-
previewBuild: false,
|
|
62
|
-
}),
|
|
68
|
+
conlocaCloud({ repoUri: 'your-org/your-site' }),
|
|
63
69
|
],
|
|
64
70
|
});
|
|
65
71
|
```
|
|
66
72
|
|
|
73
|
+
- `conlocaCloud()` needs no options. It takes `puckConfigPath` and `siteStyles` from `conlocaCMS`, and builds for the
|
|
74
|
+
workspace editor at `https://app.conloca.com` (`endpoint`'s default).
|
|
75
|
+
- `connect` writes `repoUri` when the checkout's `origin` is on GitHub, so the editor page names its repository even
|
|
76
|
+
where the build has no git remote. Without it, the build reads the repository from GitHub Actions, Vercel or GitLab,
|
|
77
|
+
else from the checkout's `remote.origin.url`.
|
|
67
78
|
- `conlocaCloud` is an add-on to `conlocaCMS`, not a replacement: keep both, with `react()` first. Doctor reports a
|
|
68
79
|
config without `conlocaCMS` as an error.
|
|
69
|
-
- `
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
If you also build pull requests on GitHub Actions, give `actions/checkout` the pull request's own commit
|
|
116
|
-
(`ref: ${{ github.event.pull_request.head.sha || github.sha }}`). By default it checks out a merge commit that GitHub
|
|
117
|
-
makes for the pull request and never pushes, so the endpoint never receives it and the registration fails.
|
|
118
|
-
|
|
119
|
-
A pull-request build deployed somewhere other than `publicBaseUrl`, such as a host's preview deploy, must set
|
|
120
|
-
`publicBaseUrl` to the address that build is served from, for example from your host's deploy-URL variable (a full
|
|
121
|
-
`https://` address). The editor on that branch loads the build's editor files from `publicBaseUrl`, and your production
|
|
122
|
-
site does not serve the files only a pull request's build produced, so the editor would report that the bundle could not
|
|
123
|
-
be loaded or verified.
|
|
124
|
-
|
|
125
|
-
### 5. Deploy, and serve `/_conloca/*` cross-origin
|
|
126
|
-
|
|
127
|
-
The build writes the editor files under `_conloca/` in its output: `dist/_conloca/` for a static site, or the client
|
|
128
|
-
folder such as `dist/client/_conloca/` for a server-rendered one. Deploy the build the way you already do, to the
|
|
129
|
-
`publicBaseUrl` address.
|
|
130
|
-
|
|
131
|
-
The editor runs on another origin and fetches those files from your site, so every `/_conloca/*` response must be public
|
|
132
|
-
and carry `Access-Control-Allow-Origin: *`. Without the header the editor reports that this build's editor bundle could
|
|
133
|
-
not be loaded or verified, and rebuilding does not help.
|
|
134
|
-
|
|
135
|
-
The build writes that rule to a `_headers` file next to `_conloca/` (`dist/_headers`, or `dist/client/_headers` for a
|
|
136
|
-
server-rendered site): one rule for `/_conloca/*`, plus one for each folder of fonts and images your site styles
|
|
137
|
-
reference.
|
|
138
|
-
|
|
139
|
-
- **Cloudflare Pages and Netlify** apply `_headers` themselves. Nothing else to do.
|
|
140
|
-
- **Everywhere else**, `_headers` is ignored — including a Node server built with `@astrojs/node`, which has no setting
|
|
141
|
-
for headers on static files. Set the header for every path the generated `_headers` lists, in whatever serves the
|
|
142
|
-
site. A site made by `conloca create` is such a Node server: add the header in a proxy in front of it, or switch the
|
|
143
|
-
site to static output (remove `output: 'server'` and the adapter from `astro.config.mjs`) and deploy it to Cloudflare
|
|
144
|
-
Pages or Netlify. With Caddy in front of the Node server:
|
|
145
|
-
|
|
146
|
-
```caddyfile
|
|
147
|
-
www.example.com {
|
|
148
|
-
header /_conloca/* Access-Control-Allow-Origin *
|
|
149
|
-
reverse_proxy localhost:4321
|
|
150
|
-
}
|
|
80
|
+
- Nothing changes `output` or adds an adapter: a static site stays static.
|
|
81
|
+
|
|
82
|
+
By hand: on a site without `conlocaCMS`, run `npx @conloca/cli astro setup` first. Then
|
|
83
|
+
`bun add @conloca/astro-cms @conloca/cloud-astro` (plus the React peers), add `conlocaCloud()` right after
|
|
84
|
+
`conlocaCMS(...)`, and follow steps 2 and 3. `@conloca/cloud-astro` needs Astro 7.3.1 or a later 7.x release, and
|
|
85
|
+
`@conloca/astro-cms` at its own version: the `@conloca/*` packages are released together, so keep them on one version
|
|
86
|
+
and update them together.
|
|
87
|
+
|
|
88
|
+
### 2. Your site's host in `sites.json`
|
|
89
|
+
|
|
90
|
+
The workspace editor opens `https://<host><base>_conloca/editor/`. `<host>` is `domains[defaultLocale]` of the site
|
|
91
|
+
named `default` in `sites.json` (or of the only site), and `<base>` is that site's `base`, `/` when unset:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
"default": {
|
|
95
|
+
"locales": ["en"],
|
|
96
|
+
"defaultLocale": "en",
|
|
97
|
+
"domains": { "en": "www.example.com" }
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- `connect` writes `domains` from Astro's `site`, and `base` from Astro's `base` when it is not `/`. When `astro.config`
|
|
102
|
+
sets no plain `site`, pass the address: `npx @conloca/cli connect --site-url https://www.example.com`. `connect` never
|
|
103
|
+
writes Astro's `site` itself, since that changes canonical URLs and sitemaps.
|
|
104
|
+
- The host is a bare host such as `www.example.com`: no scheme, port or path. The editor never opens an IP address,
|
|
105
|
+
`localhost` or a host under `conloca.com`.
|
|
106
|
+
- Use the address visitors reach. A deploy that asks visitors to sign in, such as a Vercel preview behind Deployment
|
|
107
|
+
Protection, cannot be opened by the editor.
|
|
108
|
+
|
|
109
|
+
### 3. Framing headers, only if your site forbids framing
|
|
110
|
+
|
|
111
|
+
The workspace editor shows `/_conloca/editor/` in a frame. A site that sends no `X-Frame-Options` and no
|
|
112
|
+
`frame-ancestors` can already be framed, so there is nothing to do; GitHub Pages sends neither. When a committed
|
|
113
|
+
`public/_headers`, `netlify.toml` or `vercel.json` sets one of them for the whole site, `connect` adds a rule for
|
|
114
|
+
`/_conloca/editor/`, and until one exists the build warns and `conloca doctor` reports CC10. The rules:
|
|
115
|
+
|
|
116
|
+
- **Cloudflare Pages and Cloudflare Workers static assets**, in `public/_headers` after any site-wide `/*` rule:
|
|
117
|
+
|
|
118
|
+
```plain
|
|
119
|
+
/_conloca/editor/*
|
|
120
|
+
! X-Frame-Options
|
|
121
|
+
! Content-Security-Policy
|
|
122
|
+
Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com
|
|
123
|
+
|
|
124
|
+
/_conloca/editor/sandbox-frame.html
|
|
125
|
+
Content-Security-Policy: sandbox allow-scripts
|
|
151
126
|
```
|
|
152
127
|
|
|
153
|
-
|
|
128
|
+
`! Name` removes a header an earlier rule set. The site's own policy has to come off this path: two policies are both
|
|
129
|
+
enforced, and the editor page carries its own.
|
|
130
|
+
|
|
131
|
+
- **Netlify**, in `public/_headers`. Netlify cannot remove a header, so the rule only adds the policy; a site-wide
|
|
132
|
+
`X-Frame-Options` is then ignored by browsers, because `frame-ancestors` wins:
|
|
154
133
|
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
134
|
+
```plain
|
|
135
|
+
/_conloca/editor/*
|
|
136
|
+
Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com
|
|
137
|
+
|
|
138
|
+
/_conloca/editor/sandbox-frame.html
|
|
139
|
+
Content-Security-Policy: sandbox allow-scripts
|
|
160
140
|
```
|
|
161
141
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
- **Vercel**, in the `headers` list of `vercel.json`:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
[
|
|
146
|
+
{
|
|
147
|
+
"source": "/_conloca/editor/:path*",
|
|
148
|
+
"headers": [{ "key": "Content-Security-Policy", "value": "frame-ancestors 'self' https://*.conloca.com" }]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"source": "/_conloca/editor/sandbox-frame.html",
|
|
152
|
+
"headers": [{ "key": "Content-Security-Policy", "value": "sandbox allow-scripts" }]
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
```
|
|
165
156
|
|
|
166
|
-
|
|
167
|
-
|
|
157
|
+
- **A site-wide `Content-Security-Policy` with `frame-ancestors`**, on any host: a second policy cannot loosen it.
|
|
158
|
+
Narrow it yourself so it does not cover `/_conloca/editor/`, then add the rule above. `connect` reports this case
|
|
159
|
+
instead of editing a policy.
|
|
160
|
+
- **Headers set in host settings or by a server**, such as a proxy in front of an `@astrojs/node` server: exempt
|
|
161
|
+
`/_conloca/editor/` there the same way. `connect` cannot see them; `conloca doctor --live` reads the deployed page's
|
|
162
|
+
real headers (CC12).
|
|
168
163
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
### 4. Commit, push and deploy
|
|
165
|
+
|
|
166
|
+
`connect` never commits, pushes or deploys. Commit its changes, push to the default branch, and deploy the way you
|
|
167
|
+
always do. The build writes the editor page under `_conloca/editor/` in its output (`dist/_conloca/editor/` for a static
|
|
168
|
+
site, the client folder such as `dist/client/_conloca/editor/` for a server-rendered one) and logs
|
|
169
|
+
`editor page written: /_conloca/editor/`. It needs no secret and no environment variable.
|
|
172
170
|
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
On the default branch the workspace editor uses the components of the default branch's deploy. On any other branch it
|
|
172
|
+
uses the deploy whose code is closest to the branch's latest commit, among the branch's own deploys, the default
|
|
173
|
+
branch's and a build of the branch it was created from (on a tie, in that order), and the editor says which; see
|
|
174
|
+
[Branch deploys](#branch-deploys).
|
|
175
|
+
|
|
176
|
+
`/_conloca/editor/conloca.json` publishes the repository's name and the build's branch and commit. If the repository is
|
|
177
|
+
not public, its name becomes public with the deploy.
|
|
175
178
|
|
|
176
179
|
### CI example (GitHub Actions)
|
|
177
180
|
|
|
@@ -190,75 +193,140 @@ jobs:
|
|
|
190
193
|
- uses: actions/checkout@v4
|
|
191
194
|
- uses: oven-sh/setup-bun@v2
|
|
192
195
|
- run: bun install --frozen-lockfile
|
|
193
|
-
# The token goes to doctor and the build only, not to install scripts or the deploy.
|
|
194
196
|
- run: bunx @conloca/cli doctor
|
|
195
|
-
env:
|
|
196
|
-
CONLOCA_BUILD_TOKEN: ${{ secrets.CONLOCA_BUILD_TOKEN }}
|
|
197
197
|
- run: bun run build
|
|
198
|
-
env:
|
|
199
|
-
CONLOCA_BUILD_TOKEN: ${{ secrets.CONLOCA_BUILD_TOKEN }}
|
|
200
198
|
# Deploy the build the way you already do.
|
|
201
199
|
```
|
|
202
200
|
|
|
201
|
+
### Branch deploys
|
|
202
|
+
|
|
203
|
+
On a branch other than the default one, the editor looks for that branch's own build: through the host's records on
|
|
204
|
+
GitHub (deployments, commit statuses, Cloudflare check runs) or its branch address. The deploy must be public for the
|
|
205
|
+
editor to frame it. Reading the records needs Conloca's GitHub App to have **Deployments**, **Commit statuses** and
|
|
206
|
+
**Checks** read access; an organization owner accepts that update on GitHub. Until then only the records go unread: a
|
|
207
|
+
Cloudflare Pages branch address still works. When no build of the branch is found, the editor uses an earlier build from
|
|
208
|
+
the branch's history (labelled as such), else the default branch's deploy, and says so.
|
|
209
|
+
|
|
210
|
+
| Host | Works when | By default | Found through |
|
|
211
|
+
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
|
|
212
|
+
| Cloudflare Pages | previews public (Access off) and branch builds not excluded | **works** | check-run summary (needs permissions) or branch address (no permission) |
|
|
213
|
+
| Netlify | an open pull request from the same repository; previews public | PR deploy previews only, through commit statuses (needs permissions). Branch deploys are off; credit-based plans can make previews private | commit statuses (needs permissions) |
|
|
214
|
+
| Vercel | Deployment Protection off for previews | **protected**: the editor uses the default branch's deploy. Protection has been on by default since 2023-11 | Deployment (needs permissions) |
|
|
215
|
+
| Cloudflare Workers Builds | previews enabled, an open pull request from the same repository, preview URL on Cloudflare's own preview domain | PR only | bot PR comment (needs permissions) |
|
|
216
|
+
| Render | PR previews enabled | off (manual trigger by default) | Deployment created by a person (needs permissions) |
|
|
217
|
+
| S3, your own server or other static hosting with a public address per branch | an opt-in Actions job that posts a Deployment **on push**, for the built commit | the default branch's deploy | Deployment by `github-actions` |
|
|
218
|
+
| GitHub Pages (no per-branch deploys), Amplify, Cloudflare Workers Previews on custom domains | — | the default branch's deploy | not supported |
|
|
219
|
+
|
|
220
|
+
**Cloudflare Pages not connected to a Git repository** (`wrangler pages deploy`): set `CONLOCA_PAGES_PROJECT` to the
|
|
221
|
+
first label of the site's `pages.dev` address (`my-site-4k2` for `my-site-4k2.pages.dev`) in the production build's
|
|
222
|
+
environment, so branch addresses are found. Use the address label, not the project name you gave `wrangler`: when that
|
|
223
|
+
name is taken, Cloudflare adds a suffix to the address, and setting the project name then silently finds no branch
|
|
224
|
+
address.
|
|
225
|
+
|
|
226
|
+
When two branch names clean up to the same Cloudflare Pages branch address, Pages gives the second one a random suffix.
|
|
227
|
+
The editor can't predict that address, so that branch shows the default branch's components unless its deploy is also
|
|
228
|
+
reported to GitHub (the Deployment step below).
|
|
229
|
+
|
|
230
|
+
**Vercel:** Deployment Protection has been on for previews by default since 2023-11. Turn it off for previews to let the
|
|
231
|
+
editor frame them, knowing that anyone with a preview URL can then see it.
|
|
232
|
+
|
|
233
|
+
**Any other host:** the editor frames a branch build at its own address with the site's production base, so a preview
|
|
234
|
+
under a subpath of one site can't work. Publish each branch build at its own public address (a second host or bucket
|
|
235
|
+
works), then add a step that posts a GitHub Deployment for the built commit, on `push`, with `GITHUB_TOKEN` and no other
|
|
236
|
+
secret:
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
on: push
|
|
240
|
+
permissions:
|
|
241
|
+
contents: read
|
|
242
|
+
deployments: write
|
|
243
|
+
jobs:
|
|
244
|
+
deploy:
|
|
245
|
+
runs-on: ubuntu-latest
|
|
246
|
+
steps:
|
|
247
|
+
# … your build and deploy steps; the step with id `deploy` outputs `url` (https)
|
|
248
|
+
- uses: actions/github-script@v7
|
|
249
|
+
env:
|
|
250
|
+
PREVIEW_URL: ${{ steps.deploy.outputs.url }}
|
|
251
|
+
with:
|
|
252
|
+
script: |
|
|
253
|
+
const { owner, repo } = context.repo;
|
|
254
|
+
const { data } = await github.rest.repos.createDeployment({
|
|
255
|
+
owner, repo, ref: context.sha, environment: `preview/${context.ref_name}`,
|
|
256
|
+
auto_merge: false, required_contexts: [],
|
|
257
|
+
});
|
|
258
|
+
await github.rest.repos.createDeploymentStatus({
|
|
259
|
+
owner, repo, deployment_id: data.id, state: 'success', environment_url: process.env.PREVIEW_URL,
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
A `pull_request` build checks out a merge commit, which never matches the branch's commit: build on `push`, or check out
|
|
264
|
+
`github.event.pull_request.head.sha` and pass that commit as `ref` instead of `context.sha`.
|
|
265
|
+
|
|
203
266
|
### Check it
|
|
204
267
|
|
|
205
|
-
After the deploy finishes, run this in your repository
|
|
268
|
+
After the deploy finishes, run this in your repository:
|
|
206
269
|
|
|
207
270
|
```sh
|
|
208
|
-
|
|
271
|
+
npx @conloca/cli doctor --live
|
|
209
272
|
```
|
|
210
273
|
|
|
211
|
-
`--live`
|
|
212
|
-
the editor
|
|
213
|
-
|
|
214
|
-
rather than replacing the token (that stops the CI secret working at once); reloading the editor is enough.
|
|
274
|
+
`--live` reads the deployed `<host><base>_conloca/editor/conloca.json` and the page's headers, and the protocol range
|
|
275
|
+
the editor publishes at `https://app.conloca.com/host/protocols.json`, and judges them by the same rules the workspace
|
|
276
|
+
editor applies. It sends no credential, so it runs anywhere, pull requests from forks included.
|
|
215
277
|
|
|
216
|
-
Then
|
|
217
|
-
|
|
278
|
+
Then open your workspace editor at `<slug>.conloca.com`. Until the editor page is live, **Connect this site** lists the
|
|
279
|
+
steps the site still needs: each row says what is done, whom it waits on, or what failed and how to fix it.
|
|
218
280
|
|
|
219
281
|
### Troubleshooting
|
|
220
282
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
- **
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
283
|
+
Doctor names each check; the checklist in the workspace editor reports the same causes.
|
|
284
|
+
|
|
285
|
+
- **`sites.json` has no `domains` for the default locale, or not a bare host** (CC9). Run `connect`, or add your site's
|
|
286
|
+
host there (step 2). A host under `conloca.com`, an IP address or `localhost` is refused.
|
|
287
|
+
- **A committed header file sets `X-Frame-Options` or `frame-ancestors` for the whole site** (CC10). Run `connect`, or
|
|
288
|
+
add the rule from step 3.
|
|
289
|
+
- **The address cannot be reached, or answers 5xx or 429** (CC11). The site is down or limiting requests: check that it
|
|
290
|
+
is deployed and serving, then try again later.
|
|
291
|
+
- **`conloca.json` is not deployed** (CC11). The address answers 404 or an HTML page: deploy the commit that adds
|
|
292
|
+
`conlocaCloud()`, and check that `domains` names the address it is deployed to.
|
|
293
|
+
- **The address asks visitors to sign in** (CC11), for example Vercel Deployment Protection. Put the public production
|
|
294
|
+
address in `sites.json`, or let visitors through.
|
|
295
|
+
- **The page names no repository** (CC11). The build could not read the git remote: set `repoUri` in `conlocaCloud(...)`
|
|
296
|
+
(`connect` writes it from a checkout with a GitHub `origin`).
|
|
297
|
+
- **The address serves another repository's editor page, or another site** (CC11). Check `domains` and `siteId` in
|
|
298
|
+
`sites.json`.
|
|
299
|
+
- **`conloca.json` is not one the editor can read** (CC11). The host changed the built file; serve it unchanged.
|
|
300
|
+
- **The page is serving an older commit than your checkout** (CC11, a warning). Deploy to see your latest components.
|
|
301
|
+
- **The deployed page sends `X-Frame-Options`, or a `frame-ancestors` that leaves out `https://*.conloca.com`** (CC12).
|
|
302
|
+
Run `connect` again, or exempt `/_conloca/editor/` in your host settings (step 3).
|
|
303
|
+
- **The deployed page sends a `script-src` that does not allow `https://app.conloca.com`** (CC12). The page cannot load
|
|
304
|
+
the editor, and the workspace editor stops waiting for it. Detach the site's policy on `/_conloca/editor/` (step 3),
|
|
305
|
+
or add `https://app.conloca.com` to its `script-src` there.
|
|
306
|
+
- **The page's protocol is outside the range the editor speaks** (CC13). Rebuild with a newer `@conloca/cloud-astro` and
|
|
307
|
+
deploy; if the page is newer than the editor, the editor does not speak that version yet.
|
|
308
|
+
- **A workflow or the config still names `CONLOCA_BUILD_TOKEN`, `buildToken`, `publicBaseUrl`, `previewDomain` or
|
|
309
|
+
`requireRegistration`** (CC14). The editor page needs none of them: remove those lines. `connect` removes the workflow
|
|
310
|
+
lines that only pass the key.
|
|
238
311
|
|
|
239
312
|
## Options
|
|
240
313
|
|
|
241
|
-
| Name
|
|
242
|
-
|
|
|
243
|
-
| `endpoint`
|
|
244
|
-
| `puckConfigPath`
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
The `conlocaCMS` options `schemasPath` and `mdxComponentFolders` reach the editor at `endpoint` automatically: the CMS
|
|
258
|
-
publishes what it resolved and this integration compiles the schemas and the discovered MDX components into the editor
|
|
259
|
-
bundle each build registers. The `conlocaCMS` options `editorStyles` and `editorCSS` have no effect on the editor at
|
|
260
|
-
`endpoint` (they configure the local dev editor only); `templates` and the `routing` data bindings reach it through the
|
|
261
|
-
same channel as `schemasPath`.
|
|
314
|
+
| Name | Required | Description |
|
|
315
|
+
| ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
316
|
+
| `endpoint` | no | The workspace editor's address, scheme and host only, no trailing slash; its host must start with `app.`. Defaults to `https://app.conloca.com`. |
|
|
317
|
+
| `puckConfigPath` | no | Puck config entry to compile. Defaults to the value `conlocaCMS` was given. |
|
|
318
|
+
| `repoUri` | no | Advanced `owner/repo` override; normally detected from CI or the Git remote. |
|
|
319
|
+
| `siteId` | no | Advanced site-id override for CMS-less builds; sites.json is authoritative. |
|
|
320
|
+
| `siteStyles` | no | Site CSS compiled into the canvas stylesheet, as in `conlocaCMS`. |
|
|
321
|
+
| `previewBuild` | no | `PreviewBuildOptions` or `false`. Off unless given as an object; refused under `@astrojs/vercel` and `@astrojs/netlify`. |
|
|
322
|
+
| `saasIssuer` | no | Draft previews only. JWT `iss` the preview middleware pins (the endpoint's token issuer). Baked in; else set at runtime. |
|
|
323
|
+
|
|
324
|
+
The `conlocaCMS` options `schemasPath`, `mdxComponentFolders`, `templates`, the `routing` data bindings, `editorStyles`
|
|
325
|
+
and `editorCSS` reach the editor page automatically: the CMS publishes what it resolved, and the editor page renders
|
|
326
|
+
your pages with them as the local editor at `/__cms` does.
|
|
327
|
+
|
|
328
|
+
`buildToken`, `requireRegistration`, `publicBaseUrl`, `previewDomain`, `editorBundlePlugins` and `fragmentPreviewRoute`
|
|
329
|
+
were removed: a config that still names one fails at load. Run `npx @conloca/cli connect` to update it.
|
|
262
330
|
|
|
263
331
|
## Public render path
|
|
264
332
|
|
|
@@ -271,40 +339,25 @@ they did before.
|
|
|
271
339
|
Draft previews on your own deployment are not available yet. Keep `previewBuild: false` in your config: the preview
|
|
272
340
|
build stays off, and a build produces only your normal site.
|
|
273
341
|
|
|
274
|
-
## When registration is skipped
|
|
275
|
-
|
|
276
|
-
A build that lacks a prerequisite — no `CONLOCA_BUILD_TOKEN`, no repository identity, no git sha/branch, or no public
|
|
277
|
-
base URL — completes without registering and ends with one summary block, with a `missing:` line for each prerequisite
|
|
278
|
-
it lacks:
|
|
279
|
-
|
|
280
|
-
```plain
|
|
281
|
-
[@conloca/cloud-astro] editor at https://cms.example.com NOT updated by this build
|
|
282
|
-
missing: build token (set buildToken or CONLOCA_BUILD_TOKEN)
|
|
283
|
-
consequence: registration was skipped, so the editor keeps serving the previous build of this branch (or the default branch's, or nothing, if neither was ever registered)
|
|
284
|
-
check: conloca doctor --live
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
Set `requireRegistration: true` in CI to turn that into a build failure. An attempted registration that the endpoint
|
|
288
|
-
rejects always fails the build; there is no switch for that.
|
|
289
|
-
|
|
290
342
|
## Doctor
|
|
291
343
|
|
|
292
344
|
This package is a `conloca doctor` extension (`conloca.doctor` in package.json): `conloca doctor` in a project that
|
|
293
345
|
depends on it runs this package's checks after the CMS ones, offline by default.
|
|
294
346
|
|
|
295
|
-
| Check | What it verifies
|
|
296
|
-
| ----- |
|
|
297
|
-
| CC1 | `conlocaCloud(...)` is wired next to `conlocaCMS(...)` (an absent `conlocaCMS` is an error)
|
|
298
|
-
|
|
|
299
|
-
|
|
|
300
|
-
|
|
|
301
|
-
|
|
|
302
|
-
|
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
306
|
-
`conloca doctor --live` sends
|
|
307
|
-
example from an environment variable), set
|
|
347
|
+
| Check | What it verifies |
|
|
348
|
+
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
349
|
+
| CC1 | `conlocaCloud(...)` is wired next to `conlocaCMS(...)` (an absent `conlocaCMS` is an error); notes that the deployed `conloca.json` publishes the repository's name |
|
|
350
|
+
| CC8 | `previewBuild` is absent or `false`, or the preview build has an SSR adapter (the project's own or `previewBuild.adapter`); `previewBuild` on a static project with neither is an error: `astro build` fails |
|
|
351
|
+
| CC9 | `sites.json` gives the site named `default` (or the only site) a bare host in `domains[defaultLocale]` and a valid `base`; Astro's `site` and `base`, when the config shows them, agree (warnings) |
|
|
352
|
+
| CC10 | No committed `public/_headers`, `netlify.toml` or `vercel.json` sets `X-Frame-Options` or `frame-ancestors` for the whole site without a `/_conloca/editor/` rule; the error carries the rule to add |
|
|
353
|
+
| CC11 | `--live`: `<host><base>_conloca/editor/conloca.json` is deployed, public, and names this repository and site; warns when it serves another commit than your checkout |
|
|
354
|
+
| CC12 | `--live`: the deployed `/_conloca/editor/` may be framed by `https://*.conloca.com` and its `script-src` allows the editor's origin |
|
|
355
|
+
| CC13 | `--live`: the page's protocol is in the range the editor publishes at `/host/protocols.json` |
|
|
356
|
+
| CC14 | No tracked workflow and not the astro config still names `CONLOCA_BUILD_TOKEN`, `buildToken`, `publicBaseUrl`, `previewDomain` or `requireRegistration` (warnings) |
|
|
357
|
+
|
|
358
|
+
`conloca doctor --live` sends no credential: it contacts only your site's host and the editor's public
|
|
359
|
+
`/host/protocols.json`. When the config computes `endpoint` (for example from an environment variable), set
|
|
360
|
+
`CONLOCA_ENDPOINT` so doctor can read it.
|
|
308
361
|
|
|
309
362
|
The integration also scaffolds a one-page agent skill at `.claude/skills/conloca-cloud/SKILL.md` — in the nearest
|
|
310
363
|
`.claude/` directory between the Astro project and the git root — on any Astro command that loads the config (build,
|