easy-cms 0.9.1 → 0.10.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # easy-cms
2
2
 
3
- Command line tool for [Easy CMS](https://github.com/maritonx/easy-crm). Install it as a dev
3
+ Command line tool for [Easy CMS](https://github.com/maritonx/easy-cms). Install it as a dev
4
4
  dependency; every command loads `.env` from the project root.
5
5
 
6
6
  ```bash
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-ACQWSB2M.js";
4
+ } from "./chunk-KI6KLIR2.js";
5
5
 
6
6
  // src/bin.ts
7
7
  process.exitCode = await run(process.argv.slice(2));
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import { existsSync } from "fs";
3
- import { writeFile } from "fs/promises";
4
- import { isAbsolute, join, resolve } from "path";
3
+ import { mkdir, writeFile } from "fs/promises";
4
+ import { dirname, isAbsolute, join, resolve } from "path";
5
5
  import { createInterface } from "readline/promises";
6
6
  import { parseArgs } from "util";
7
7
  import {
@@ -195,6 +195,7 @@ Commands:
195
195
  create-admin Create an admin user
196
196
  serve Run the CMS as its own server (admin + REST API)
197
197
  run-scheduled Run due scheduled publishes and webhook retries
198
+ backup <file> Copy a SQLite database to a file while the CMS runs
198
199
 
199
200
  Options:
200
201
  --config <file> Config file (default: easy-cms.config.ts)
@@ -226,6 +227,14 @@ The file has no imports, so a frontend in another repository can copy it.
226
227
 
227
228
  Creates a user (role "admin" unless --role is given). The password is asked for in the
228
229
  terminal, or read from EASY_CMS_ADMIN_PASSWORD when there is no terminal.
230
+ `,
231
+ backup: `Usage: easy-cms backup <file> [options]
232
+
233
+ Copies the SQLite database to <file> (relative to the project root) while the CMS keeps running,
234
+ as a consistent snapshot. The file must not exist yet. Uploads are not included: back up the
235
+ uploads folder or bucket separately.
236
+
237
+ Postgres: use pg_dump, e.g. pg_dump --format=custom --file=cms.dump "$DATABASE_URL".
229
238
  `,
230
239
  "run-scheduled": `Usage: easy-cms run-scheduled [options]
231
240
 
@@ -295,6 +304,29 @@ async function run(argv, io = defaultIO) {
295
304
  });
296
305
  try {
297
306
  switch (command) {
307
+ case "backup": {
308
+ const target = rest.join(" ").trim();
309
+ if (!target) {
310
+ io.err("Missing backup file.\n");
311
+ io.err(COMMAND_HELP.backup);
312
+ return 1;
313
+ }
314
+ if (!cms.db.backup) {
315
+ io.err(
316
+ 'This database cannot back itself up. For Postgres use pg_dump, e.g.\n pg_dump --format=custom --file=cms.dump "$DATABASE_URL"'
317
+ );
318
+ return 1;
319
+ }
320
+ const file = isAbsolute(target) ? target : resolve(cwd, target);
321
+ if (existsSync(file)) {
322
+ io.err(`${file} already exists; choose a new file name.`);
323
+ return 1;
324
+ }
325
+ await mkdir(dirname(file), { recursive: true });
326
+ await cms.db.backup(file);
327
+ io.out(`Backed up the database to ${file}`);
328
+ return 0;
329
+ }
298
330
  case "run-scheduled": {
299
331
  const { ran, failed, webhooks } = await cms.runJobs();
300
332
  io.out(`Ran ${ran} scheduled job(s)${failed ? `, ${failed} failed` : ""}.`);
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  createStandaloneHandler,
3
3
  run,
4
4
  startServer
5
- } from "./chunk-ACQWSB2M.js";
5
+ } from "./chunk-KI6KLIR2.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.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "Command line tool for Easy CMS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,18 +21,18 @@
21
21
  "node": ">=22.12"
22
22
  },
23
23
  "dependencies": {
24
- "@easy-cms/core": "^0.9.1",
25
- "@easy-cms/admin": "^0.9.1"
24
+ "@easy-cms/core": "^0.10.0",
25
+ "@easy-cms/admin": "^0.10.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@easy-cms/db-sqlite": "^0.9.1"
28
+ "@easy-cms/db-sqlite": "^0.10.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  },
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "git+https://github.com/maritonx/easy-crm.git",
35
+ "url": "git+https://github.com/maritonx/easy-cms.git",
36
36
  "directory": "packages/cli"
37
37
  },
38
38
  "keywords": [