easy-cms 0.48.0 → 0.49.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/README.md +2 -2
- package/dist/bin.js +1 -1
- package/dist/{chunk-EGQ4KNYH.js → chunk-IP3UPED4.js} +59 -43
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -20,9 +20,9 @@ npx easy-cms migrate:create <name> # a migration for config changes
|
|
|
20
20
|
npx easy-cms migrate # apply pending migrations
|
|
21
21
|
npx easy-cms migrate:status
|
|
22
22
|
npx easy-cms generate:types [--out file.ts]
|
|
23
|
-
npx easy-cms create
|
|
23
|
+
npx easy-cms admin:create [--email you@example.com] [--name] [--role]
|
|
24
24
|
npx easy-cms serve [--port 4000] [--watch]
|
|
25
|
-
npx easy-cms run
|
|
25
|
+
npx easy-cms jobs:run # due scheduled jobs, webhook and email retries (cron)
|
|
26
26
|
npx easy-cms backup <file> # SQLite snapshot while the CMS runs
|
|
27
27
|
npx easy-cms copy --from <config> # copy content to another database
|
|
28
28
|
```
|
package/dist/bin.js
CHANGED
|
@@ -7,14 +7,12 @@ import { parseArgs } from "util";
|
|
|
7
7
|
import { gzipSync } from "zlib";
|
|
8
8
|
import {
|
|
9
9
|
ConfigError,
|
|
10
|
-
copyDatabase,
|
|
11
10
|
createEasyCMS as createEasyCMS2,
|
|
12
11
|
EasyCMSError,
|
|
13
|
-
generateTypes,
|
|
14
12
|
loadConfig,
|
|
15
|
-
ValidationError
|
|
16
|
-
writeBackupFile
|
|
13
|
+
ValidationError
|
|
17
14
|
} from "@easy-cms/core";
|
|
15
|
+
import { copyDatabase, generateTypes, writeBackupFile } from "@easy-cms/core/internal";
|
|
18
16
|
|
|
19
17
|
// src/serve.ts
|
|
20
18
|
import { watch } from "fs";
|
|
@@ -24,10 +22,9 @@ import { pipeline } from "stream/promises";
|
|
|
24
22
|
import { adminHandlerFor } from "@easy-cms/admin";
|
|
25
23
|
import {
|
|
26
24
|
createEasyCMS,
|
|
27
|
-
createRestHandler
|
|
28
|
-
createRootEndpointHandler,
|
|
29
|
-
forwardedClientIp
|
|
25
|
+
createRestHandler
|
|
30
26
|
} from "@easy-cms/core";
|
|
27
|
+
import { createRootEndpointHandler, forwardedClientIp } from "@easy-cms/core/internal";
|
|
31
28
|
function createStandaloneHandler(cms) {
|
|
32
29
|
const config = cms.config;
|
|
33
30
|
const adminPath = `/${config.admin.path.replace(/^\/+|\/+$/g, "")}`;
|
|
@@ -198,9 +195,9 @@ Commands:
|
|
|
198
195
|
migrate:create <name> Create a migration from config changes
|
|
199
196
|
migrate:status List migrations and whether they are applied
|
|
200
197
|
generate:types Write TypeScript types for your collections and globals
|
|
201
|
-
create
|
|
198
|
+
admin:create Create an admin user (also: create-admin)
|
|
202
199
|
serve Run the CMS as its own server (admin + REST API)
|
|
203
|
-
run
|
|
200
|
+
jobs:run Run due scheduled publishes, jobs, webhook and email retries (also: run-scheduled)
|
|
204
201
|
backup <file> Copy the database to a SQLite file while the CMS runs
|
|
205
202
|
copy --from <config> Copy all content from another config's database into this one
|
|
206
203
|
<plugin command> Commands from your config's plugins, e.g. nested:rebuild
|
|
@@ -231,7 +228,7 @@ Lists migration files and whether each has been applied.
|
|
|
231
228
|
Writes interfaces for every collection and global (default: easy-cms-types.ts).
|
|
232
229
|
The file has no imports, so a frontend in another repository can copy it.
|
|
233
230
|
`,
|
|
234
|
-
"create
|
|
231
|
+
"admin:create": `Usage: easy-cms admin:create [--email <email>] [--name <name>] [--role <role>] [options]
|
|
235
232
|
|
|
236
233
|
Creates a user (role "admin" unless --role is given). The password is asked for in the
|
|
237
234
|
terminal, or read from EASY_CMS_ADMIN_PASSWORD when there is no terminal.
|
|
@@ -256,7 +253,7 @@ development its tables are created, in production run \`easy-cms migrate\` first
|
|
|
256
253
|
Uploaded files are not copied: they stay in the uploads folder or bucket.
|
|
257
254
|
Stop writing to the source while copying, or copy from a backup.
|
|
258
255
|
`,
|
|
259
|
-
"run
|
|
256
|
+
"jobs:run": `Usage: easy-cms jobs:run [options]
|
|
260
257
|
|
|
261
258
|
Runs due scheduled publishes and unpublishes, and retries failed webhook deliveries, once:
|
|
262
259
|
for a cron job where no server process keeps running. Servers do this every minute on their own.
|
|
@@ -275,22 +272,31 @@ In production (NODE_ENV=production) pending migrations stop the server from star
|
|
|
275
272
|
`
|
|
276
273
|
};
|
|
277
274
|
async function run(argv, io = defaultIO) {
|
|
275
|
+
const loose = parseArgs({
|
|
276
|
+
args: [...argv],
|
|
277
|
+
allowPositionals: true,
|
|
278
|
+
strict: false,
|
|
279
|
+
options: OPTIONS
|
|
280
|
+
});
|
|
281
|
+
const [named, ...looseRest] = loose.positionals;
|
|
282
|
+
const command = named === void 0 ? void 0 : RENAMED_COMMANDS[named] ?? named;
|
|
283
|
+
if (command && !(command in COMMAND_HELP))
|
|
284
|
+
return await pluginCommand(command, looseRest, loose.values, io);
|
|
278
285
|
let parsed;
|
|
279
286
|
try {
|
|
280
287
|
parsed = parse(argv);
|
|
281
288
|
} catch (error) {
|
|
282
289
|
io.err(error.message);
|
|
283
|
-
io.err(HELP);
|
|
290
|
+
io.err(command ? COMMAND_HELP[command] : HELP);
|
|
284
291
|
return 1;
|
|
285
292
|
}
|
|
286
|
-
const { values
|
|
287
|
-
const
|
|
293
|
+
const { values } = parsed;
|
|
294
|
+
const rest = parsed.positionals.slice(1);
|
|
288
295
|
if (!command) {
|
|
289
296
|
;
|
|
290
297
|
(values.help ? io.out : io.err)(HELP);
|
|
291
298
|
return values.help ? 0 : 1;
|
|
292
299
|
}
|
|
293
|
-
if (!(command in COMMAND_HELP)) return await pluginCommand(command, rest, values, io);
|
|
294
300
|
if (values.help) {
|
|
295
301
|
io.out(COMMAND_HELP[command]);
|
|
296
302
|
return 0;
|
|
@@ -310,7 +316,7 @@ async function run(argv, io = defaultIO) {
|
|
|
310
316
|
return 0;
|
|
311
317
|
}
|
|
312
318
|
if (command === "copy") return await copy(values.from, config, cwd, logger, io);
|
|
313
|
-
const schema = command === "create
|
|
319
|
+
const schema = command === "admin:create" && process.env.NODE_ENV !== "production" ? "push" : "skip";
|
|
314
320
|
const cms = await createEasyCMS2(config, {
|
|
315
321
|
cwd,
|
|
316
322
|
schema,
|
|
@@ -350,8 +356,9 @@ async function run(argv, io = defaultIO) {
|
|
|
350
356
|
io.out(`Backed up the database to ${file}`);
|
|
351
357
|
return 0;
|
|
352
358
|
}
|
|
353
|
-
case "run
|
|
354
|
-
const {
|
|
359
|
+
case "jobs:run": {
|
|
360
|
+
const { scheduled, webhooks, emails } = await cms.runJobs();
|
|
361
|
+
const { ran, failed } = scheduled;
|
|
355
362
|
io.out(`Ran ${ran} scheduled job(s)${failed ? `, ${failed} failed` : ""}.`);
|
|
356
363
|
if (webhooks.sent || webhooks.failed)
|
|
357
364
|
io.out(
|
|
@@ -386,11 +393,11 @@ async function run(argv, io = defaultIO) {
|
|
|
386
393
|
}
|
|
387
394
|
return 0;
|
|
388
395
|
}
|
|
389
|
-
case "create
|
|
396
|
+
case "admin:create": {
|
|
390
397
|
const email = values.email ?? (io.interactive && io.prompt ? await io.prompt("Email: ") : "");
|
|
391
398
|
if (!email) {
|
|
392
399
|
io.err("Missing --email.\n");
|
|
393
|
-
io.err(COMMAND_HELP["create
|
|
400
|
+
io.err(COMMAND_HELP["admin:create"]);
|
|
394
401
|
return 1;
|
|
395
402
|
}
|
|
396
403
|
const password = process.env.EASY_CMS_ADMIN_PASSWORD ?? (io.interactive && io.prompt ? await io.prompt("Password (8+ characters): ", { hidden: true }) : "");
|
|
@@ -436,7 +443,9 @@ async function run(argv, io = defaultIO) {
|
|
|
436
443
|
}
|
|
437
444
|
}
|
|
438
445
|
async function pluginCommand(command, args, values, io) {
|
|
439
|
-
const
|
|
446
|
+
const text = (value) => typeof value === "string" ? value : void 0;
|
|
447
|
+
const cwd = text(values.cwd) ?? process.cwd();
|
|
448
|
+
const configFile = text(values.config);
|
|
440
449
|
loadDotEnv(cwd);
|
|
441
450
|
const logger = { info: io.out, warn: (m) => io.err(`warning: ${m}`), error: io.err };
|
|
442
451
|
const unknown = (note) => {
|
|
@@ -448,14 +457,14 @@ async function pluginCommand(command, args, values, io) {
|
|
|
448
457
|
};
|
|
449
458
|
let config;
|
|
450
459
|
try {
|
|
451
|
-
config = await loadConfig({ cwd, ...
|
|
460
|
+
config = await loadConfig({ cwd, ...configFile ? { configFile } : {} });
|
|
452
461
|
} catch (error) {
|
|
453
462
|
return unknown(`(Commands from the config were not loaded: ${error.message})`);
|
|
454
463
|
}
|
|
455
464
|
try {
|
|
456
|
-
const found = config.
|
|
465
|
+
const found = config.cliCommands.find((c) => c.name === command);
|
|
457
466
|
if (!found) {
|
|
458
|
-
const extra = config.
|
|
467
|
+
const extra = config.cliCommands.map((c) => ` ${c.name.padEnd(24)}${c.description}`);
|
|
459
468
|
return unknown(extra.length ? `Commands from your config:
|
|
460
469
|
${extra.join("\n")}
|
|
461
470
|
` : void 0);
|
|
@@ -475,7 +484,13 @@ ${found.description}
|
|
|
475
484
|
scheduler: false
|
|
476
485
|
});
|
|
477
486
|
try {
|
|
478
|
-
|
|
487
|
+
const flags = Object.fromEntries(
|
|
488
|
+
Object.entries(values).filter(([key, value]) => !["config", "cwd", "help"].includes(key) && value !== void 0).map(([key, value]) => [
|
|
489
|
+
key.replace(/-([a-z])/g, (_, c) => c.toUpperCase()),
|
|
490
|
+
value
|
|
491
|
+
])
|
|
492
|
+
);
|
|
493
|
+
return await found.run({ cms, args, flags, log: io.out }) ?? 0;
|
|
479
494
|
} finally {
|
|
480
495
|
await cms.destroy();
|
|
481
496
|
}
|
|
@@ -491,25 +506,26 @@ ${found.description}
|
|
|
491
506
|
return 1;
|
|
492
507
|
}
|
|
493
508
|
}
|
|
509
|
+
var RENAMED_COMMANDS = {
|
|
510
|
+
"create-admin": "admin:create",
|
|
511
|
+
"run-scheduled": "jobs:run"
|
|
512
|
+
};
|
|
513
|
+
var OPTIONS = {
|
|
514
|
+
config: { type: "string" },
|
|
515
|
+
cwd: { type: "string" },
|
|
516
|
+
out: { type: "string" },
|
|
517
|
+
from: { type: "string" },
|
|
518
|
+
email: { type: "string" },
|
|
519
|
+
name: { type: "string" },
|
|
520
|
+
role: { type: "string" },
|
|
521
|
+
port: { type: "string" },
|
|
522
|
+
host: { type: "string" },
|
|
523
|
+
watch: { type: "boolean" },
|
|
524
|
+
"trust-proxy": { type: "boolean" },
|
|
525
|
+
help: { type: "boolean", short: "h" }
|
|
526
|
+
};
|
|
494
527
|
function parse(argv) {
|
|
495
|
-
return parseArgs({
|
|
496
|
-
args: [...argv],
|
|
497
|
-
allowPositionals: true,
|
|
498
|
-
options: {
|
|
499
|
-
config: { type: "string" },
|
|
500
|
-
cwd: { type: "string" },
|
|
501
|
-
out: { type: "string" },
|
|
502
|
-
from: { type: "string" },
|
|
503
|
-
email: { type: "string" },
|
|
504
|
-
name: { type: "string" },
|
|
505
|
-
role: { type: "string" },
|
|
506
|
-
port: { type: "string" },
|
|
507
|
-
host: { type: "string" },
|
|
508
|
-
watch: { type: "boolean" },
|
|
509
|
-
"trust-proxy": { type: "boolean" },
|
|
510
|
-
help: { type: "boolean", short: "h" }
|
|
511
|
-
}
|
|
512
|
-
});
|
|
528
|
+
return parseArgs({ args: [...argv], allowPositionals: true, options: OPTIONS });
|
|
513
529
|
}
|
|
514
530
|
async function serve(values, cwd, logger, load, io) {
|
|
515
531
|
const port = Number(values.port ?? process.env.PORT ?? 4e3);
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-cms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "Command line tool for Easy CMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"node": ">=22.12"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@easy-cms/core": "^0.
|
|
25
|
-
"@easy-cms/admin": "^0.
|
|
24
|
+
"@easy-cms/core": "^0.49.0",
|
|
25
|
+
"@easy-cms/admin": "^0.49.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@easy-cms/db-sqlite": "^0.
|
|
28
|
+
"@easy-cms/db-sqlite": "^0.49.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|