domma-cms 1.42.2 → 1.43.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.43.0] - 2026-11-08
4
+
5
+ - **Self-hosted sites hear about new versions.** Once a day the site asks npm for the latest Domma CMS; when it is behind, the Super Admins get a notice (Notifications, "Domma CMS update available") saying which version and the command to run. A newer release replaces it and updating ends it. Hosted sites and managers are updated for them, so they never check. server.json `updateCheck: false` or `DOMMA_UPDATE_CHECK=0` turns it off (and ends a notice already shown). See `server/services/cmsUpdates.js`.
6
+ - New sites' `.gitignore` keeps out `content/.crash.json` and `content/.cms-update.json` (runtime state).
7
+
8
+ ## [1.42.3] - 2026-11-08
9
+
10
+ - Tests: the theme token check reads the Domma stylesheets from the installed domma-js package, as the server serves them, so it passes on a clean checkout (it read a local `public/dist/domma` copy that only old checkouts have).
11
+
3
12
  ## [1.42.2] - 2026-11-08
4
13
 
5
14
  - Shared mail library brought level with Domma Mail core 0.24.1 (provenance headers and lock only; no behaviour change).
@@ -34,6 +34,7 @@ Controls the HTTP server.
34
34
  | `restartOnPluginToggle` | boolean | `true` | Restart the server automatically when an admin enables or disables a plugin. See **Plugin toggles restart the server** below |
35
35
  | `requireSignedPlugins` | boolean | `false` | When `true`, the site runs only plugin code the Marketplace signed: an unsigned `.dcmsplugin` (e.g. one exported from another site) is refused even if the installer confirms it, New plugin is refused, a plugin's files cannot be changed in the code editor (it opens read only), licensed source cannot be read even by a Super Admin, and MongoDB connection options that start a program or read a file (`autoEncryption`, `tls…File`, …) cannot be saved. A bundle with a signature that does not verify is always refused, whatever this is set to. Read fresh on every check, and also as it was at boot, so changing the file on a running site can switch it on but not off. `DOMMA_SIGNED_ONLY=1` in the environment turns it on whatever the file says - Domma CMS Manager sets it on the sites it hosts. Nothing in the admin writes `server.json`. See `server/services/codePolicy.js` |
36
36
  | `storeUrl` | string \| `false` | Domma's store | Where a **self-hosted** site's Marketplace buys and downloads Tools (Browse). A Tool bought there is the site's to keep, with a term of updates that is renewed with a one-off payment; the licence keys and the payment claims are kept in `config/store.json` (out of git). `false` switches the store off, leaving Install from file. Not used on a site a Domma CMS Manager runs (it buys through its manager), nor on the manager itself unless `storeUrl` is set there. `DOMMA_STORE_URL` in the environment wins. See `server/services/storeClient.js` |
37
+ | `updateCheck` | boolean | `true` | A **self-hosted** site asks npm once a day (and at start-up) for the latest Domma CMS and compares it with its `.domma` marker. When it is behind, the Super Admins get one notice, "Domma CMS x.y.z is available", with the command to run (`npx domma-cms@latest update`); a newer release replaces the notice and updating ends it. Listed in Notifications' settings as "Domma CMS update available". `false` stops the check (so does `DOMMA_UPDATE_CHECK=0`). Never runs on a site a Domma CMS Manager runs, on the manager itself, or in a checkout without `.domma`. See `server/services/cmsUpdates.js` |
37
38
  | `outboundAllowPrivate` | boolean \| string[] | `false` | Webhooks (an Action's webhook step, a form's webhook) reach public addresses only: the name is looked up and every address must be public and not the server's own, the request is pinned to that address, redirects into private addresses are refused, and only ports 80 and 443 are used. A self-hosted site that sends webhooks inside its own network sets `true` to lift those rules for every request, or a list of host names, addresses and CIDR ranges (`["n8n.lan", "192.168.10.0/24", "fd00::/8"]`) to lift them for those only - a name passes if it is listed, or if every address it resolves to is. Ignored on a signed-only site (`requireSignedPlugins` / `DOMMA_SIGNED_ONLY=1`), so a hosted site's admin cannot open the host's network. Read fresh on every request. See `server/services/outbound.js` |
38
39
 
39
40
  ### Plugin toggles restart the server
@@ -32,7 +32,7 @@ You do not need to run `npm install` yourself. Options:
32
32
  | `--no-seed` | Skip seeding default pages, forms and collections |
33
33
  | `--help` | Show usage |
34
34
 
35
- To update an existing project later, run `npx domma-cms update` from inside it (`--dry-run` previews the changes).
35
+ To update an existing project later, run `npx domma-cms@latest update` from inside it (`--dry-run` previews the changes). A self-hosted site checks npm once a day and tells its Super Admins when a newer version is out (Notifications; server.json `updateCheck: false` turns that off).
36
36
 
37
37
  ## What the Scaffolder Creates
38
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.42.2",
3
+ "version": "1.43.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -0,0 +1,163 @@
1
+ /**
2
+ * "A newer Domma CMS is out" - the notice a SELF-HOSTED site gets.
3
+ *
4
+ * A hosted site is updated by its manager and an owner instance (the manager
5
+ * itself) by the fleet roll, so neither is told. A self-hosted site has nobody
6
+ * doing it for it, and until this nothing in the admin said an update existed.
7
+ *
8
+ * Once a day (and at start-up) the site asks the npm registry for the latest
9
+ * domma-cms and compares it with its own `.domma` marker. Behind = one notice
10
+ * to the Super Admins, `core:cms-update`, saying which version and the command
11
+ * to run. A newer release replaces the notice (unread again); updating ends it.
12
+ *
13
+ * Only a scaffolded project checks: one with a `.domma` marker. The engine's
14
+ * own checkout (and every test copy of it) has none, so it never calls out.
15
+ *
16
+ * Off switches: server.json `updateCheck: false`, or `DOMMA_UPDATE_CHECK=0`.
17
+ * `DOMMA_UPDATE_URL` points the check at another registry document (tests).
18
+ *
19
+ * @module services/cmsUpdates
20
+ */
21
+ import fs from 'fs';
22
+ import path from 'path';
23
+ import {config, getConfig} from '../config.js';
24
+ import {compareVersions} from './pluginInstaller.js';
25
+
26
+ export const REGISTRY_URL = 'https://registry.npmjs.org/domma-cms/latest';
27
+ export const PACKAGE_PAGE = 'https://www.npmjs.com/package/domma-cms';
28
+ const VERSION = /^\d+\.\d+\.\d+$/;
29
+ const TIMEOUT = 10_000;
30
+
31
+ // ---------------------------------------------------------------------------
32
+ // Pure decisions
33
+ // ---------------------------------------------------------------------------
34
+
35
+ /**
36
+ * Should this site look for updates at all.
37
+ *
38
+ * @param {object} site
39
+ * @param {boolean} site.scaffolded - it has a `.domma` marker
40
+ * @param {boolean} site.managed - a manager runs it (it updates the site)
41
+ * @param {boolean} site.owner - an owner instance (the fleet roll updates it)
42
+ * @param {*} site.setting - server.json `updateCheck`
43
+ * @param {string|undefined} site.env - DOMMA_UPDATE_CHECK
44
+ */
45
+ export function updateCheckOn({scaffolded, managed, owner, setting, env}) {
46
+ if (!scaffolded || managed || owner) return false;
47
+ if (env === '0' || env === 'false') return false;
48
+ return setting !== false;
49
+ }
50
+
51
+ /**
52
+ * The notice for an installed version against the latest, or null when there
53
+ * is nothing to say (up to date, ahead, or either version unreadable).
54
+ *
55
+ * @param {string|null} installed
56
+ * @param {string|null} latest
57
+ * @returns {{severity: string, title: string, body: string, link: string}|null}
58
+ */
59
+ export function cmsUpdateNotice(installed, latest) {
60
+ if (!VERSION.test(String(installed ?? '')) || !VERSION.test(String(latest ?? ''))) return null;
61
+ if (compareVersions(latest, installed) <= 0) return null;
62
+ return {
63
+ severity: 'info',
64
+ title: `Domma CMS ${latest} is available`,
65
+ body: `This site runs Domma CMS ${installed}. To update, run this in the site's folder:\n\n`
66
+ + `npx domma-cms@latest update\n\n`
67
+ + `Add --dry-run to see what would change first. The update keeps your content, settings and your own `
68
+ + `plugins, updates the plugins that come with Domma CMS, and backs up the files it replaces before it `
69
+ + `starts. What changed is in CHANGELOG.md.`,
70
+ link: PACKAGE_PAGE
71
+ };
72
+ }
73
+
74
+ /** The version in the registry's `latest` document, or null when it is not a plain x.y.z. */
75
+ export function latestFromRegistry(doc) {
76
+ const v = doc && typeof doc === 'object' ? doc.version : null;
77
+ return typeof v === 'string' && VERSION.test(v) ? v : null;
78
+ }
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // I/O
82
+ // ---------------------------------------------------------------------------
83
+
84
+ /** The version this project was last updated to, from its `.domma` marker. */
85
+ export function markerVersion(root = process.cwd()) {
86
+ try {
87
+ const v = JSON.parse(fs.readFileSync(path.join(root, '.domma'), 'utf8'))?.cmsVersion;
88
+ return typeof v === 'string' ? v : null;
89
+ } catch {
90
+ return null;
91
+ }
92
+ }
93
+
94
+ /** The latest domma-cms on npm. Throws when the registry cannot be read. */
95
+ export async function fetchLatestVersion({fetchImpl = fetch, url = process.env.DOMMA_UPDATE_URL || REGISTRY_URL} = {}) {
96
+ const res = await fetchImpl(url, {headers: {Accept: 'application/json'}, signal: AbortSignal.timeout(TIMEOUT)});
97
+ if (!res.ok) throw new Error(`the registry answered ${res.status}`);
98
+ const latest = latestFromRegistry(await res.json());
99
+ if (!latest) throw new Error('the registry did not give a version');
100
+ return latest;
101
+ }
102
+
103
+ /** Which version the live notice is about, kept beside .crash.json so a newer one can end it. */
104
+ function stateFile() {
105
+ return path.join(path.dirname(path.resolve(config.content.collectionsDir)), '.cms-update.json');
106
+ }
107
+
108
+ /** Is a notice still live from an earlier check (its version is on record). */
109
+ export function noticeOnRecord(file = stateFile()) {
110
+ return readNotified(file) !== null;
111
+ }
112
+
113
+ function readNotified(file) {
114
+ try { return JSON.parse(fs.readFileSync(file, 'utf8'))?.version || null; } catch { return null; }
115
+ }
116
+
117
+ function writeNotified(file, version) {
118
+ try {
119
+ if (version) fs.writeFileSync(file, JSON.stringify({version}) + '\n');
120
+ else fs.rmSync(file, {force: true});
121
+ } catch { /* the dedupe key still stops a repeat */ }
122
+ }
123
+
124
+ /** Is the check on for this running site. */
125
+ export async function updateCheckEnabled() {
126
+ const {isManaged} = await import('./managerClient.js');
127
+ const {isOwnerInstance} = await import('./storeClient.js');
128
+ let setting;
129
+ try { setting = getConfig('server')?.updateCheck; } catch { setting = undefined; }
130
+ return updateCheckOn({
131
+ scaffolded: markerVersion() !== null, managed: isManaged(), owner: isOwnerInstance(),
132
+ setting, env: process.env.DOMMA_UPDATE_CHECK
133
+ });
134
+ }
135
+
136
+ /**
137
+ * The scheduled check: raise, replace or end the notice. `raise`/`resolve` are
138
+ * the notifier's (notify.js runSource hands them in). The options are for the
139
+ * tests; a running site passes none.
140
+ */
141
+ export async function checkForCmsUpdate({notify: raise, resolve}, {fetchImpl, enabled, installed, file = stateFile()} = {}) {
142
+ if (!(enabled ?? await updateCheckEnabled())) {
143
+ // Switched off, or a manager took the site over: end a notice an earlier check raised.
144
+ const stale = readNotified(file);
145
+ if (stale) {
146
+ await resolve(`cms-update:${stale}`);
147
+ writeNotified(file, null);
148
+ }
149
+ return;
150
+ }
151
+ const current = installed ?? markerVersion();
152
+ const latest = await fetchLatestVersion(fetchImpl ? {fetchImpl} : {});
153
+ const notice = cmsUpdateNotice(current, latest);
154
+ const notified = readNotified(file);
155
+ // A newer release replaces the notice, and updating ends it.
156
+ if (notified && (!notice || notified !== latest)) await resolve(`cms-update:${notified}`);
157
+ if (notice) {
158
+ await raise({...notice, dedupeKey: `cms-update:${latest}`});
159
+ writeNotified(file, latest);
160
+ } else if (notified) {
161
+ writeNotified(file, null);
162
+ }
163
+ }
@@ -260,6 +260,17 @@ export async function registerCoreSources() {
260
260
  }
261
261
  });
262
262
 
263
+ // Self-hosted sites only: hosted ones are updated by their manager, and the
264
+ // manager itself by the fleet roll (services/cmsUpdates.js). Also registered
265
+ // while a notice from before is on record, so a site switched off (or taken
266
+ // over by a manager) has that notice ended by the check.
267
+ const cmsUpdates = await import('./cmsUpdates.js');
268
+ if (await cmsUpdates.updateCheckEnabled() || cmsUpdates.noticeOnRecord()) registerNotificationSource({
269
+ id: 'core:cms-update', label: 'Domma CMS update available', severity: 'info', every: 'daily', atBoot: true,
270
+ description: 'A newer Domma CMS is on npm. Checked once a day; server.json "updateCheck": false stops the check.',
271
+ check: (ctx) => cmsUpdates.checkForCmsUpdate(ctx)
272
+ });
273
+
263
274
  registerNotificationSource({
264
275
  id: 'core:disk', label: 'Disk space low', severity: 'warning', every: 'hourly', atBoot: true,
265
276
  description: 'Under 10% (or 1 GB) free on the disk that holds the site\'s content.',
@@ -324,6 +324,9 @@ export function buildGitignore({sitePlugins = [], pluginContent = {}, sitePublic
324
324
  // When each notification source last ran, and which one-off migrations have run - rewritten by the CMS itself.
325
325
  '/content/.notification-sources.json',
326
326
  '/content/.migrations.json',
327
+ // A crash on the way down (read at the next start), and which CMS release the update notice is about.
328
+ '/content/.crash.json',
329
+ '/content/.cms-update.json',
327
330
  '/content/instances_log.json',
328
331
  '/content/preview-links.json',
329
332
  // Each admin's own Dashboard Pro layout (keyed by user id); the site default beside it is tracked.