easy-cms 0.31.0 → 0.32.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 +1 -1
- package/dist/{chunk-ZICOXSUE.js → chunk-IXNAWT6G.js} +18 -8
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { existsSync } from "fs";
|
|
3
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
3
|
+
import { mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
4
4
|
import { dirname, isAbsolute, join, resolve } from "path";
|
|
5
5
|
import { createInterface } from "readline/promises";
|
|
6
6
|
import { parseArgs } from "util";
|
|
7
|
+
import { gzipSync } from "zlib";
|
|
7
8
|
import {
|
|
8
9
|
ConfigError,
|
|
9
10
|
copyDatabase,
|
|
@@ -11,7 +12,8 @@ import {
|
|
|
11
12
|
EasyCMSError,
|
|
12
13
|
generateTypes,
|
|
13
14
|
loadConfig,
|
|
14
|
-
ValidationError
|
|
15
|
+
ValidationError,
|
|
16
|
+
writeBackupFile
|
|
15
17
|
} from "@easy-cms/core";
|
|
16
18
|
|
|
17
19
|
// src/serve.ts
|
|
@@ -204,7 +206,7 @@ Commands:
|
|
|
204
206
|
create-admin Create an admin user
|
|
205
207
|
serve Run the CMS as its own server (admin + REST API)
|
|
206
208
|
run-scheduled Run due scheduled publishes, webhook and email retries
|
|
207
|
-
backup <file> Copy
|
|
209
|
+
backup <file> Copy the database to a SQLite file while the CMS runs
|
|
208
210
|
copy --from <config> Copy all content from another config's database into this one
|
|
209
211
|
<plugin command> Commands from your config's plugins, e.g. nested:rebuild
|
|
210
212
|
|
|
@@ -241,8 +243,9 @@ terminal, or read from EASY_CMS_ADMIN_PASSWORD when there is no terminal.
|
|
|
241
243
|
`,
|
|
242
244
|
backup: `Usage: easy-cms backup <file> [options]
|
|
243
245
|
|
|
244
|
-
Copies the
|
|
245
|
-
as a consistent snapshot
|
|
246
|
+
Copies the database to <file> (relative to the project root) as a SQLite file while the CMS keeps
|
|
247
|
+
running, as a consistent snapshot; a name ending in .gz is compressed. The file must not exist
|
|
248
|
+
yet. Postgres needs backups: { sqlite } in the config. Uploads are not included: back up the
|
|
246
249
|
uploads folder or bucket separately.
|
|
247
250
|
|
|
248
251
|
Postgres: use pg_dump, e.g. pg_dump --format=custom --file=cms.dump "$DATABASE_URL".
|
|
@@ -329,9 +332,9 @@ async function run(argv, io = defaultIO) {
|
|
|
329
332
|
io.err(COMMAND_HELP.backup);
|
|
330
333
|
return 1;
|
|
331
334
|
}
|
|
332
|
-
if (!cms.db.backup) {
|
|
335
|
+
if (!cms.db.backup && !cms.config.backups?.sqlite) {
|
|
333
336
|
io.err(
|
|
334
|
-
'
|
|
337
|
+
'Postgres is copied into a SQLite file: add backups: { sqlite } to the config (sqlite from @easy-cms/db-sqlite).\nOr use pg_dump, e.g.\n pg_dump --format=custom --file=cms.dump "$DATABASE_URL"'
|
|
335
338
|
);
|
|
336
339
|
return 1;
|
|
337
340
|
}
|
|
@@ -341,7 +344,14 @@ async function run(argv, io = defaultIO) {
|
|
|
341
344
|
return 1;
|
|
342
345
|
}
|
|
343
346
|
await mkdir(dirname(file), { recursive: true });
|
|
344
|
-
|
|
347
|
+
if (file.endsWith(".gz")) {
|
|
348
|
+
const plain = file.slice(0, -3);
|
|
349
|
+
await writeBackupFile(cms, plain);
|
|
350
|
+
await writeFile(file, gzipSync(await readFile(plain)));
|
|
351
|
+
await rm(plain, { force: true });
|
|
352
|
+
} else {
|
|
353
|
+
await writeBackupFile(cms, file);
|
|
354
|
+
}
|
|
345
355
|
io.out(`Backed up the database to ${file}`);
|
|
346
356
|
return 0;
|
|
347
357
|
}
|
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.32.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.32.0",
|
|
25
|
+
"@easy-cms/admin": "^0.32.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@easy-cms/db-sqlite": "^0.
|
|
28
|
+
"@easy-cms/db-sqlite": "^0.32.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|