easy-cms 0.13.1 → 0.16.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-5K6LB7DV.js → chunk-MXEUQZMV.js} +54 -0
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -6,6 +6,7 @@ import { createInterface } from "readline/promises";
|
|
|
6
6
|
import { parseArgs } from "util";
|
|
7
7
|
import {
|
|
8
8
|
ConfigError,
|
|
9
|
+
copyDatabase,
|
|
9
10
|
createEasyCMS as createEasyCMS2,
|
|
10
11
|
EasyCMSError,
|
|
11
12
|
generateTypes,
|
|
@@ -198,6 +199,7 @@ Commands:
|
|
|
198
199
|
serve Run the CMS as its own server (admin + REST API)
|
|
199
200
|
run-scheduled Run due scheduled publishes and webhook retries
|
|
200
201
|
backup <file> Copy a SQLite database to a file while the CMS runs
|
|
202
|
+
copy --from <config> Copy all content from another config's database into this one
|
|
201
203
|
|
|
202
204
|
Options:
|
|
203
205
|
--config <file> Config file (default: easy-cms.config.ts)
|
|
@@ -237,6 +239,17 @@ as a consistent snapshot. The file must not exist yet. Uploads are not included:
|
|
|
237
239
|
uploads folder or bucket separately.
|
|
238
240
|
|
|
239
241
|
Postgres: use pg_dump, e.g. pg_dump --format=custom --file=cms.dump "$DATABASE_URL".
|
|
242
|
+
`,
|
|
243
|
+
copy: `Usage: easy-cms copy --from <config> [options]
|
|
244
|
+
|
|
245
|
+
Copies every document, version, user and global from the database of the config in --from into
|
|
246
|
+
the database of this project's config (--config), for example from SQLite to Postgres. Ids stay
|
|
247
|
+
the same, so relationships and logins keep working. Both configs must have the same collections
|
|
248
|
+
and fields: import one into the other and change only \`db\`. The target must be empty; in
|
|
249
|
+
development its tables are created, in production run \`easy-cms migrate\` first.
|
|
250
|
+
|
|
251
|
+
Uploaded files are not copied: they stay in the uploads folder or bucket.
|
|
252
|
+
Stop writing to the source while copying, or copy from a backup.
|
|
240
253
|
`,
|
|
241
254
|
"run-scheduled": `Usage: easy-cms run-scheduled [options]
|
|
242
255
|
|
|
@@ -296,6 +309,7 @@ async function run(argv, io = defaultIO) {
|
|
|
296
309
|
io.out(`Wrote ${file}`);
|
|
297
310
|
return 0;
|
|
298
311
|
}
|
|
312
|
+
if (command === "copy") return await copy(values.from, config, cwd, logger, io);
|
|
299
313
|
const schema = command === "create-admin" && process.env.NODE_ENV !== "production" ? "push" : "skip";
|
|
300
314
|
const cms = await createEasyCMS2(config, {
|
|
301
315
|
cwd,
|
|
@@ -418,6 +432,7 @@ function parse(argv) {
|
|
|
418
432
|
config: { type: "string" },
|
|
419
433
|
cwd: { type: "string" },
|
|
420
434
|
out: { type: "string" },
|
|
435
|
+
from: { type: "string" },
|
|
421
436
|
email: { type: "string" },
|
|
422
437
|
name: { type: "string" },
|
|
423
438
|
role: { type: "string" },
|
|
@@ -462,6 +477,45 @@ ${signal} received, shutting down\u2026`);
|
|
|
462
477
|
await server.close();
|
|
463
478
|
return 0;
|
|
464
479
|
}
|
|
480
|
+
async function copy(from, config, cwd, logger, io) {
|
|
481
|
+
if (!from) {
|
|
482
|
+
io.err("Missing --from <config>.\n");
|
|
483
|
+
io.err(COMMAND_HELP.copy);
|
|
484
|
+
return 1;
|
|
485
|
+
}
|
|
486
|
+
const sourceConfig = await loadConfig({ cwd, configFile: from });
|
|
487
|
+
const source = await createEasyCMS2(sourceConfig, {
|
|
488
|
+
cwd,
|
|
489
|
+
schema: "skip",
|
|
490
|
+
logger,
|
|
491
|
+
scheduler: false
|
|
492
|
+
});
|
|
493
|
+
try {
|
|
494
|
+
const target = await createEasyCMS2(config, {
|
|
495
|
+
cwd,
|
|
496
|
+
// Development: create the target's tables. Production: they must be migrated already.
|
|
497
|
+
schema: process.env.NODE_ENV === "production" ? "verify" : "push",
|
|
498
|
+
logger,
|
|
499
|
+
interactive: io.interactive,
|
|
500
|
+
scheduler: false
|
|
501
|
+
});
|
|
502
|
+
try {
|
|
503
|
+
io.out(`Copying from ${sourceConfig.db.name} (${from}) to ${config.db.name}\u2026`);
|
|
504
|
+
const result = await copyDatabase(source.db, target.db, {
|
|
505
|
+
onTable: ({ table, rows }) => {
|
|
506
|
+
if (rows > 0) io.out(` ${table}: ${rows}`);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
io.out(`Copied ${result.rows} row(s) from ${result.tables} table(s).`);
|
|
510
|
+
io.out("Uploaded files were not copied; they stay in the uploads folder or bucket.");
|
|
511
|
+
return 0;
|
|
512
|
+
} finally {
|
|
513
|
+
await target.destroy();
|
|
514
|
+
}
|
|
515
|
+
} finally {
|
|
516
|
+
await source.destroy();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
465
519
|
function loadDotEnv(cwd) {
|
|
466
520
|
const file = join(cwd, ".env");
|
|
467
521
|
if (existsSync(file)) process.loadEnvFile(file);
|
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.16.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.16.0",
|
|
25
|
+
"@easy-cms/admin": "^0.16.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@easy-cms/db-sqlite": "^0.
|
|
28
|
+
"@easy-cms/db-sqlite": "^0.16.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|