@prisma-psm/core 1.0.15 → 1.0.16
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/package.json +1 -1
- package/src/tools/backup.d.ts.map +1 -1
- package/src/tools/backup.js +11 -2
- package/src/tools/backup.js.map +1 -1
- package/src/tools/backup.ts +12 -2
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["backup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["backup.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,aAAa,iBAyD/C"}
|
package/src/tools/backup.js
CHANGED
|
@@ -47,7 +47,7 @@ function backup(opts) {
|
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
48
|
var _a;
|
|
49
49
|
require('dotenv').config();
|
|
50
|
-
const { psm, psm_sql, driver, home } = yield (0, common_1.psmLockup)({ schema: opts.schema });
|
|
50
|
+
const { psm, psm_sql, driver, home, schema } = yield (0, common_1.psmLockup)({ schema: opts.schema });
|
|
51
51
|
const migrator = driver.migrator({
|
|
52
52
|
url: process.env[psm.psm.url],
|
|
53
53
|
migrate: '', // Não necessário para backup
|
|
@@ -59,7 +59,8 @@ function backup(opts) {
|
|
|
59
59
|
if (dump.error)
|
|
60
60
|
throw dump.error;
|
|
61
61
|
const moment = require('moment');
|
|
62
|
-
const
|
|
62
|
+
const now = moment();
|
|
63
|
+
const instant = now.format('YYYYMMDDHHmmss');
|
|
63
64
|
const label = opts.label ? ` - ${(0, fs_1.sanitizeLabel)(opts.label)}` : '';
|
|
64
65
|
const compressionLevel = (_a = opts.level) !== null && _a !== void 0 ? _a : 9; // nível de compressão padrão 9
|
|
65
66
|
// Caminho temporário do arquivo
|
|
@@ -67,6 +68,14 @@ function backup(opts) {
|
|
|
67
68
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
68
69
|
const backupFile = Path.join(tmpDir, 'backup.sql');
|
|
69
70
|
fs.writeFileSync(backupFile, dump.output);
|
|
71
|
+
fs.writeFileSync(Path.join(tmpDir, 'README'), `
|
|
72
|
+
Label : ${opts.label}
|
|
73
|
+
Level : ${opts.level}
|
|
74
|
+
Git Add: ${opts.add}
|
|
75
|
+
Instante: ${now.toISOString()}
|
|
76
|
+
Driver: ${psm.psm.driver}
|
|
77
|
+
Scheme: ${schema}
|
|
78
|
+
`.split("\n").filter(value => !!value).join("\n"));
|
|
70
79
|
// Arquivo final .tar.gz
|
|
71
80
|
const archiveName = Path.join(home, `psm/backup/${instant}${label}.tar.gz`);
|
|
72
81
|
// Compacta **somente o arquivo backup.sql** (sem nível extra)
|
package/src/tools/backup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup.js","sourceRoot":"","sources":["backup.ts"],"names":[],"mappings":";AAAA,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"backup.js","sourceRoot":"","sources":["backup.ts"],"names":[],"mappings":";AAAA,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBhC,wBAyDC;AA1ED,4CAA8B;AAC9B,gDAAkC;AAClC,yCAA2B;AAE3B,kDAA0B;AAE1B,qCAAmC;AACnC,oCAAsD;AAUtD,SAAsB,MAAM,CAAC,IAAmB;;;QAC5C,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;QAE3B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,I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C,CAAC;QAC1C,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;mBAC/B,IAAI,CAAC,KAAK;mBACV,IAAI,CAAC,KAAK;mBACT,IAAI,CAAC,GAAI;oBACP,GAAG,CAAC,WAAW,EAAG;kBACpB,GAAG,CAAC,GAAG,CAAC,MAAO;kBACf,MAAO;KACtB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpD,wBAAwB;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC;QAE5E,8DAA8D;QAC9D,MAAM,GAAG,CAAC,CAAC,CACP;YACI,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;YACjC,IAAI,EAAE,WAAW;YACjB,GAAG,EAAE,MAAM;SACd,EACD,CAAC,YAAY,CAAC,CACjB,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,oBAAoB,WAAW,EAAE,CAAC,CAAC,CAAC;QAE5D,0BAA0B;QAC1B,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpD,4BAA4B;QAC5B,IAAI,IAAI,CAAC,GAAG;YAAE,IAAA,eAAU,EAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;CAAA"}
|
package/src/tools/backup.ts
CHANGED
|
@@ -8,6 +8,7 @@ import chalk from "chalk";
|
|
|
8
8
|
|
|
9
9
|
import {psmLockup} from "./common";
|
|
10
10
|
import {gitAddPath, sanitizeLabel} from "../utils/fs";
|
|
11
|
+
import moment from "moment/moment";
|
|
11
12
|
|
|
12
13
|
export interface BackupOptions {
|
|
13
14
|
schema?: string;
|
|
@@ -19,7 +20,7 @@ export interface BackupOptions {
|
|
|
19
20
|
export async function backup(opts: BackupOptions) {
|
|
20
21
|
require('dotenv').config();
|
|
21
22
|
|
|
22
|
-
const { psm, psm_sql, driver, home } = await psmLockup({ schema: opts.schema });
|
|
23
|
+
const { psm, psm_sql, driver, home, schema } = await psmLockup({ schema: opts.schema });
|
|
23
24
|
|
|
24
25
|
const migrator = driver.migrator({
|
|
25
26
|
url: process.env[psm.psm.url],
|
|
@@ -33,7 +34,8 @@ export async function backup(opts: BackupOptions) {
|
|
|
33
34
|
if (dump.error) throw dump.error;
|
|
34
35
|
|
|
35
36
|
const moment = require('moment');
|
|
36
|
-
const
|
|
37
|
+
const now = moment();
|
|
38
|
+
const instant = now.format('YYYYMMDDHHmmss');
|
|
37
39
|
const label = opts.label ? ` - ${sanitizeLabel(opts.label)}` : '';
|
|
38
40
|
|
|
39
41
|
const compressionLevel = opts.level ?? 9; // nível de compressão padrão 9
|
|
@@ -43,6 +45,14 @@ export async function backup(opts: BackupOptions) {
|
|
|
43
45
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
44
46
|
const backupFile = Path.join(tmpDir, 'backup.sql');
|
|
45
47
|
fs.writeFileSync(backupFile, dump.output);
|
|
48
|
+
fs.writeFileSync(Path.join(tmpDir, 'README'), `
|
|
49
|
+
Label : ${opts.label}
|
|
50
|
+
Level : ${opts.level}
|
|
51
|
+
Git Add: ${ opts.add }
|
|
52
|
+
Instante: ${ now.toISOString() }
|
|
53
|
+
Driver: ${ psm.psm.driver }
|
|
54
|
+
Scheme: ${ schema }
|
|
55
|
+
`.split("\n").filter( value => !!value).join("\n"));
|
|
46
56
|
|
|
47
57
|
// Arquivo final .tar.gz
|
|
48
58
|
const archiveName = Path.join(home, `psm/backup/${instant}${label}.tar.gz`);
|