domma-cms 0.5.3 → 0.5.4
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/bin/cli.js +8 -1
- package/package.json +2 -2
- package/scripts/setup.js +24 -0
- package/server/services/renderer.js +0 -18
- package/server/templates/page.html +8 -5
package/bin/cli.js
CHANGED
|
@@ -355,6 +355,13 @@ if (noSeed) {
|
|
|
355
355
|
// Success
|
|
356
356
|
// ---------------------------------------------------------------------------
|
|
357
357
|
|
|
358
|
+
let devPort = 4096;
|
|
359
|
+
try {
|
|
360
|
+
const serverCfg = JSON.parse(readFileSync(path.join(target, 'config/server.json'), 'utf8'));
|
|
361
|
+
if (Number.isInteger(serverCfg.port)) devPort = serverCfg.port;
|
|
362
|
+
} catch { /* fallback to default */
|
|
363
|
+
}
|
|
364
|
+
|
|
358
365
|
console.log('');
|
|
359
366
|
console.log(' ┌──────────────────────────────────────────┐');
|
|
360
367
|
console.log(' │ ✓ Project created successfully! │');
|
|
@@ -366,5 +373,5 @@ if (noInstall) console.log(` npm install`);
|
|
|
366
373
|
if (noSetup && !noInstall) console.log(` npm run setup`);
|
|
367
374
|
console.log(` npm run dev`);
|
|
368
375
|
console.log('');
|
|
369
|
-
console.log(` Then open: http://localhost
|
|
376
|
+
console.log(` Then open: http://localhost:${devPort}/admin`);
|
|
370
377
|
console.log('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "domma-cms",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"delete-users": "node -e \"import('fs').then(({readdirSync,rmSync})=>{const d='content/users';readdirSync(d).filter(f=>f.endsWith('.json')).forEach(f=>{rmSync(d+'/'+f);console.log('deleted',f)})})\"",
|
|
30
30
|
"start": "node server/server.js",
|
|
31
31
|
"start:cluster": "pm2 start server/server.js -i max --name domma-cms",
|
|
32
|
-
"dev": "
|
|
32
|
+
"dev": "node --watch server/server.js",
|
|
33
33
|
"prod": "node server/server.js",
|
|
34
34
|
"setup": "node scripts/setup.js",
|
|
35
35
|
"reset": "node scripts/reset.js",
|
package/scripts/setup.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* 2. Create admin account (skips if users already exist)
|
|
11
11
|
* 3. Set site title and tagline
|
|
12
12
|
* 4. Pick a theme
|
|
13
|
+
* 5. Set server port
|
|
13
14
|
*/
|
|
14
15
|
import {createInterface} from 'node:readline/promises';
|
|
15
16
|
import {randomBytes} from 'node:crypto';
|
|
@@ -43,8 +44,11 @@ const THEMES = [
|
|
|
43
44
|
'christmas-dark', 'christmas-light',
|
|
44
45
|
'unicorn-dark', 'unicorn-light',
|
|
45
46
|
'dreamy-dark', 'dreamy-light',
|
|
47
|
+
'wedding-dark', 'wedding-light',
|
|
46
48
|
];
|
|
47
49
|
|
|
50
|
+
const SERVER_CONFIG = path.join(ROOT, 'config', 'server.json');
|
|
51
|
+
|
|
48
52
|
// ---------------------------------------------------------------------------
|
|
49
53
|
// Utilities
|
|
50
54
|
// ---------------------------------------------------------------------------
|
|
@@ -256,6 +260,26 @@ THEMES.forEach((t, i) => {
|
|
|
256
260
|
console.log(` ✓ Theme set to "${theme}"`);
|
|
257
261
|
}
|
|
258
262
|
|
|
263
|
+
// ---------------------------------------------------------------------------
|
|
264
|
+
// Step 5 — Port
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
section('5. Server Port');
|
|
267
|
+
|
|
268
|
+
{
|
|
269
|
+
const rl = createInterface({input: process.stdin, output: process.stdout});
|
|
270
|
+
const input = (await rl.question(' Port (Enter = 4096): ')).trim();
|
|
271
|
+
rl.close();
|
|
272
|
+
|
|
273
|
+
const parsed = parseInt(input, 10);
|
|
274
|
+
const port = (parsed >= 1024 && parsed <= 65535) ? parsed : 4096;
|
|
275
|
+
|
|
276
|
+
const server = JSON.parse(await readFile(SERVER_CONFIG, 'utf8'));
|
|
277
|
+
server.port = port;
|
|
278
|
+
await writeFile(SERVER_CONFIG, JSON.stringify(server, null, 4) + '\n', 'utf8');
|
|
279
|
+
|
|
280
|
+
console.log(` ✓ Port set to ${port}`);
|
|
281
|
+
}
|
|
282
|
+
|
|
259
283
|
// ---------------------------------------------------------------------------
|
|
260
284
|
// Done
|
|
261
285
|
// ---------------------------------------------------------------------------
|
|
@@ -113,7 +113,6 @@ export async function renderPage(page) {
|
|
|
113
113
|
site.cookieConsent?.enabled ? '<script src="/public/js/cookie-consent.js"></script>' : ''
|
|
114
114
|
].filter(Boolean).join('\n'),
|
|
115
115
|
dconfigScript,
|
|
116
|
-
autoThemeScript: autoTheme ? buildAutoThemeScript(autoTheme) : '',
|
|
117
116
|
};
|
|
118
117
|
|
|
119
118
|
const finalVars = applyTransforms('render:beforeRender', vars, {page});
|
|
@@ -206,23 +205,6 @@ function buildFontVars(fontFamily, fontSize) {
|
|
|
206
205
|
return {fontLink, fontOverride: rules.length ? rules.join(' ') : null};
|
|
207
206
|
}
|
|
208
207
|
|
|
209
|
-
/**
|
|
210
|
-
* Build a self-executing inline script that applies the correct day/night theme
|
|
211
|
-
* before the page uncloak — eliminates any flash of wrong theme.
|
|
212
|
-
*
|
|
213
|
-
* @param {object} at - autoTheme config object
|
|
214
|
-
* @returns {string}
|
|
215
|
-
*/
|
|
216
|
-
function buildAutoThemeScript(at) {
|
|
217
|
-
const json = JSON.stringify(at).replace(/<\/script>/gi, '<\\/script>');
|
|
218
|
-
return `(function(){var c=${json},n=new Date(),m=n.getHours()*60+n.getMinutes(),`
|
|
219
|
-
+ `ds=(c.dayStart||"07:00").split(":"),ns=(c.nightStart||"19:00").split(":"),`
|
|
220
|
-
+ `d=+ds[0]*60+(+ds[1]||0),e=+ns[0]*60+(+ns[1]||0),`
|
|
221
|
-
+ `t=(m>=d&&m<e)?c.dayTheme:c.nightTheme;`
|
|
222
|
-
+ `if(window.Domma&&window.Domma.theme)window.Domma.theme.set(t);`
|
|
223
|
-
+ `}());`;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
208
|
/**
|
|
227
209
|
* Simple template interpolation.
|
|
228
210
|
* Handles {{variable}}, {{#if flag}}...{{/if}}.
|
|
@@ -101,13 +101,16 @@
|
|
|
101
101
|
if (window.Domma && window.Domma.theme) {
|
|
102
102
|
window.Domma.theme.init({ theme: '{{theme}}', persist: false });
|
|
103
103
|
}
|
|
104
|
-
{
|
|
105
|
-
{
|
|
106
|
-
autoThemeScript
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
104
|
window.__CMS_NAV__ = {{navJson}};
|
|
110
105
|
window.__CMS_SITE__ = {{siteJson}};
|
|
106
|
+
(function () {
|
|
107
|
+
var c = window.__CMS_SITE__ && window.__CMS_SITE__.autoTheme;
|
|
108
|
+
if (!c || !c.enabled) return;
|
|
109
|
+
var n = new Date(), m = n.getHours() * 60 + n.getMinutes(), ds = (c.dayStart || "07:00").split(":"),
|
|
110
|
+
ns = (c.nightStart || "19:00").split(":"), d = +ds[0] * 60 + (+ds[1] || 0),
|
|
111
|
+
e = +ns[0] * 60 + (+ns[1] || 0), t = (m >= d && m < e) ? c.dayTheme : c.nightTheme;
|
|
112
|
+
if (window.Domma && window.Domma.theme) window.Domma.theme.set(t);
|
|
113
|
+
}());
|
|
111
114
|
{{dconfigScript}}
|
|
112
115
|
</script>
|
|
113
116
|
|