caracms 0.8.1 → 0.8.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 CHANGED
@@ -369,7 +369,7 @@ export default defineSite({
369
369
  (caracms.config.ts), but CARACMS_CLOUD_KEY isn't set. Make a key for it in
370
370
  app.caracms.com." (the build fails; a running server's `/admin` answers 503 with it, and
371
371
  the public site keeps serving). It never falls back to the self-hosted variables.
372
- `astro dev` without a key is local mode, as always.
372
+ `astro dev` is local mode, with or without the key (see [working locally](#working-locally)).
373
373
  - **`'self-hosted'`**: the site's own variables, as [the variables](#the-variables) list
374
374
  them. A `CARACMS_CLOUD_KEY` beside them is ignored the same way.
375
375
  - **Not set** (a site from before caracms 0.8.0): the key decides, and setting it beside
@@ -538,11 +538,13 @@ has been replaced.
538
538
  laptop, a colleague's, a client's developer, a staging deploy. Each gets **its own key**
539
539
  for the site, labelled ("Rich's laptop", "staging") in app.caracms.com, so revoking one
540
540
  never touches the live site. Leave `CARACMS_CLOUD_URL` unset: images render from
541
- `img.caracms.cloud` and the library lists the site's real folder. A cloud key turns
542
- `astro dev` into live mode on the site's real repo, as the App's variables do. Uploads
541
+ `img.caracms.cloud` and the library lists the site's real folder. `astro dev` stays in
542
+ local mode, editing the files on disk: live mode on a laptop never points at the site's
543
+ real repo, so the key alone never turns it on (the App's variables still do). Uploads
543
544
  from a laptop land in the real folder and count towards its storage, which is harmless:
544
545
  nothing is overwritten or deleted, and nothing is live until it's published.
545
- `CARACMS_CLOUD_URL` is only for working on CaraCMS Cloud itself, against its dev deployment.
546
+ `CARACMS_CLOUD_URL` is only for working on CaraCMS Cloud itself, against its dev deployment;
547
+ with it, `astro dev` is live on that deployment's throwaway repos.
546
548
 
547
549
  ### Behind Cloudflare
548
550
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caracms",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "A visual CMS for Astro sites, with content in git.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -115,7 +115,7 @@ is the exception (section 4).
115
115
  **Images need credentials** in the site's `.env` (never committed). On CaraCMS Cloud
116
116
  that's `CARACMS_CLOUD_KEY` alone: a key labelled for this laptop, made in
117
117
  app.caracms.com (`caracms-hosting` → section 1); it shows, imports and uploads images,
118
- and makes `astro dev` live on the site's real repo. Self-hosted, it's the media
118
+ and `astro dev` still edits the files on disk. Self-hosted, it's the media
119
119
  variables: `CARACMS_MEDIA_URL` (imgproxy's origin), `IMGPROXY_KEY`, `IMGPROXY_SALT` and
120
120
  `S3_BUCKET` to show images, plus `S3_ENDPOINT`, `S3_REGION`, `S3_ACCESS_KEY_ID` and
121
121
  `S3_SECRET_ACCESS_KEY` to import and upload them. Without them `astro dev` draws a
@@ -81,8 +81,9 @@ npx caracms init --cloud --write # writes services: 'cloud' and the rest
81
81
  **One key per place the site runs**, each labelled in app.caracms.com: "Railway" for
82
82
  the host, "Rich's laptop" for a laptop's `.env`, "staging" for a staging deploy.
83
83
  Revoking one never touches the others. Leave `CARACMS_CLOUD_URL` unset (it's only for
84
- working on CaraCMS Cloud itself). On a laptop a cloud key makes `astro dev` live on the
85
- site's real repo and folder; without one, `astro dev` edits content on disk as always.
84
+ working on CaraCMS Cloud itself). On a laptop `astro dev` edits content on disk, with or
85
+ without a key; the key shows, imports and uploads images in the site's real folder. Only
86
+ the key with `CARACMS_CLOUD_URL` (the cloud's dev deployment) makes `astro dev` live.
86
87
 
87
88
  **A production build needs the key.** With `services: 'cloud'` and no
88
89
  `CARACMS_CLOUD_KEY`, `astro build` (and `pnpm build` on a laptop, which is a production
package/src/index.ts CHANGED
@@ -324,11 +324,13 @@ export const EDITOR_CLIENT_DEPS = [
324
324
  ];
325
325
 
326
326
  /**
327
- * The variables M5b Decision 5 names: the media pipeline's and Mux's. Only these are
328
- * taken from the site's env files (copyMediaEnv); everything else in `.env` (the
329
- * GitHub App, live mode) is left to the process's own environment, as before.
327
+ * The variables M5b Decision 5 names: the media pipeline's and Mux's, and the cloud key,
328
+ * which is both on a cloud site. Only these are taken from the site's env files
329
+ * (copyMediaEnv); everything else in `.env` (the GitHub App, live mode) is left to the
330
+ * process's own environment, as before.
330
331
  */
331
332
  export const MEDIA_ENV_NAMES = [
333
+ 'CARACMS_CLOUD_KEY',
332
334
  'CARACMS_MEDIA',
333
335
  'CARACMS_MEDIA_URL',
334
336
  'IMGPROXY_KEY',
package/src/live/mode.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Which mode the editor runs in, read from the environment (M4 Decision 1).
3
3
  *
4
- * - **Local mode**: `astro dev` with no GitHub credentials (`CARACMS_CLOUD_KEY`,
5
- * `GITHUB_APP_ID` or `CARACMS_GITHUB_TOKEN`). M3's editor, files on disk.
4
+ * - **Local mode**: `astro dev` with no GitHub credentials (`GITHUB_APP_ID` or
5
+ * `CARACMS_GITHUB_TOKEN`). M3's editor, files on disk. `CARACMS_CLOUD_KEY` alone stays
6
+ * local (caracms-cloud: live mode on a laptop never points at a client's repo); the key
7
+ * is still the images', clips' and forms' credential there. Only the key with
8
+ * `CARACMS_CLOUD_URL` (the cloud's dev deployment, throwaway repos only) is live in dev.
6
9
  * - **Live mode**: whenever a credential is configured, and **always on a production
7
10
  * server**. It needs one GitHub credential (a fine-grained token, or the App's
8
11
  * `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY`; runs-anywhere Decisions 3–4), the repo
@@ -208,7 +211,9 @@ export function readMode(env: Env = process.env, production = env.NODE_ENV === '
208
211
  // Never GITHUB_TOKEN (Decision 4): the gh CLI and GitHub Actions export it.
209
212
  const ghToken = get('CARACMS_GITHUB_TOKEN');
210
213
  const cloudKey = get('CARACMS_CLOUD_KEY');
211
- if (!production && !memory && !get('GITHUB_APP_ID') && !ghToken && !cloudKey) return { kind: 'local' };
214
+ // A laptop's key is the production cloud's, so the site's real repo: dev stays local unless CARACMS_CLOUD_URL names another cloud.
215
+ const devCloud = cloudKey && get('CARACMS_CLOUD_URL');
216
+ if (!production && !memory && !get('GITHUB_APP_ID') && !ghToken && !devCloud) return { kind: 'local' };
212
217
 
213
218
  const missing: string[] = [];
214
219
  const problems: string[] = [];