easy-cms 0.20.1 → 0.22.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/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-Y2RPEQE3.js";
4
+ } from "./chunk-ZICOXSUE.js";
5
5
 
6
6
  // src/bin.ts
7
7
  process.exitCode = await run(process.argv.slice(2));
@@ -206,6 +206,7 @@ Commands:
206
206
  run-scheduled Run due scheduled publishes, webhook and email retries
207
207
  backup <file> Copy a SQLite database to a file while the CMS runs
208
208
  copy --from <config> Copy all content from another config's database into this one
209
+ <plugin command> Commands from your config's plugins, e.g. nested:rebuild
209
210
 
210
211
  Options:
211
212
  --config <file> Config file (default: easy-cms.config.ts)
@@ -291,12 +292,7 @@ async function run(argv, io = defaultIO) {
291
292
  (values.help ? io.out : io.err)(HELP);
292
293
  return values.help ? 0 : 1;
293
294
  }
294
- if (!(command in COMMAND_HELP)) {
295
- io.err(`Unknown command "${command}".
296
- `);
297
- io.err(HELP);
298
- return 1;
299
- }
295
+ if (!(command in COMMAND_HELP)) return await pluginCommand(command, rest, values, io);
300
296
  if (values.help) {
301
297
  io.out(COMMAND_HELP[command]);
302
298
  return 0;
@@ -434,6 +430,62 @@ async function run(argv, io = defaultIO) {
434
430
  return 1;
435
431
  }
436
432
  }
433
+ async function pluginCommand(command, args, values, io) {
434
+ const cwd = values.cwd ?? process.cwd();
435
+ loadDotEnv(cwd);
436
+ const logger = { info: io.out, warn: (m) => io.err(`warning: ${m}`), error: io.err };
437
+ const unknown = (note) => {
438
+ io.err(`Unknown command "${command}".
439
+ `);
440
+ io.err(HELP);
441
+ if (note) io.err(note);
442
+ return 1;
443
+ };
444
+ let config;
445
+ try {
446
+ config = await loadConfig({ cwd, ...values.config ? { configFile: values.config } : {} });
447
+ } catch (error) {
448
+ return unknown(`(Commands from the config were not loaded: ${error.message})`);
449
+ }
450
+ try {
451
+ const found = config.commands.find((c) => c.name === command);
452
+ if (!found) {
453
+ const extra = config.commands.map((c) => ` ${c.name.padEnd(24)}${c.description}`);
454
+ return unknown(extra.length ? `Commands from your config:
455
+ ${extra.join("\n")}
456
+ ` : void 0);
457
+ }
458
+ if (values.help) {
459
+ io.out(found.help ?? `Usage: easy-cms ${found.name}
460
+
461
+ ${found.description}
462
+ `);
463
+ return 0;
464
+ }
465
+ const cms = await createEasyCMS2(config, {
466
+ cwd,
467
+ schema: "skip",
468
+ logger,
469
+ interactive: io.interactive,
470
+ scheduler: false
471
+ });
472
+ try {
473
+ return await found.run({ cms, args, log: io.out }) ?? 0;
474
+ } finally {
475
+ await cms.destroy();
476
+ }
477
+ } catch (error) {
478
+ if (error instanceof ValidationError) {
479
+ for (const e of error.errors) io.err(`${e.field}: ${e.message}`);
480
+ return 1;
481
+ }
482
+ const known = error instanceof ConfigError || error instanceof EasyCMSError;
483
+ if (error instanceof Error)
484
+ io.err(!known && process.env.DEBUG ? error.stack ?? error.message : error.message);
485
+ else io.err(String(error));
486
+ return 1;
487
+ }
488
+ }
437
489
  function parse(argv) {
438
490
  return parseArgs({
439
491
  args: [...argv],
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  createStandaloneHandler,
3
3
  run,
4
4
  startServer
5
- } from "./chunk-Y2RPEQE3.js";
5
+ } from "./chunk-ZICOXSUE.js";
6
6
  export {
7
7
  createStandaloneHandler,
8
8
  run,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-cms",
3
- "version": "0.20.1",
3
+ "version": "0.22.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.20.1",
25
- "@easy-cms/admin": "^0.20.1"
24
+ "@easy-cms/core": "^0.22.0",
25
+ "@easy-cms/admin": "^0.22.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@easy-cms/db-sqlite": "^0.20.1"
28
+ "@easy-cms/db-sqlite": "^0.22.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"