domma-cms 0.38.2 → 0.38.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 (2) hide show
  1. package/bin/update.js +23 -2
  2. package/package.json +1 -1
package/bin/update.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * preserving all user content, config, and custom plugins.
9
9
  */
10
10
 
11
- import {cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync,} from 'node:fs';
11
+ import {cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync,} from 'node:fs';
12
12
  import {spawnSync} from 'node:child_process';
13
13
  import path from 'node:path';
14
14
  import {createInterface} from 'node:readline';
@@ -199,7 +199,11 @@ export default async function update(_positional, flags) {
199
199
 
200
200
  info('Upstream directories that would be replaced:');
201
201
  for (const dir of UPSTREAM_DIRS) {
202
- info(` → ${dir}/`);
202
+ if (dir === 'public') {
203
+ info(` → ${dir}/ (upstream entries only — site-added files are preserved)`);
204
+ } else {
205
+ info(` → ${dir}/`);
206
+ }
203
207
  }
204
208
  console.log('');
205
209
 
@@ -303,6 +307,23 @@ export default async function update(_positional, flags) {
303
307
  const dest = path.join(cwd, dir);
304
308
  const src = path.join(PACKAGE_ROOT, dir);
305
309
  if (!existsSync(src)) continue;
310
+ if (dir === 'public') {
311
+ // public/ is shared ground: upstream ships css/ and js/, but sites
312
+ // add their own subdirs and files (games, images, downloads). Replace
313
+ // only the entries the package ships; everything else stays put.
314
+ mkdirSync(dest, {recursive: true});
315
+ for (const entry of readdirSync(src)) {
316
+ const destEntry = path.join(dest, entry);
317
+ let st = null;
318
+ try { st = lstatSync(destEntry); } catch { /* missing */ }
319
+ // A symlinked entry (e.g. a manager-shared public/js) is owned by
320
+ // whatever it points at — replacing it would silently fork it.
321
+ if (st && st.isSymbolicLink()) continue;
322
+ if (st) rmSync(destEntry, {recursive: true, force: true});
323
+ cpSync(path.join(src, entry), destEntry, {recursive: true});
324
+ }
325
+ continue;
326
+ }
306
327
  if (existsSync(dest)) rmSync(dest, {recursive: true, force: true});
307
328
  cpSync(src, dest, {recursive: true});
308
329
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "0.38.2",
3
+ "version": "0.38.3",
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",