@datatruck/cli 0.28.0 → 0.29.1
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/Action/BackupAction.d.ts +7 -1
- package/Action/BackupAction.js +192 -176
- package/Action/CopyAction.d.ts +3 -1
- package/Action/CopyAction.js +67 -46
- package/Action/PruneAction.d.ts +2 -8
- package/Action/PruneAction.js +22 -35
- package/Action/RestoreAction.d.ts +1 -1
- package/Action/RestoreAction.js +20 -14
- package/Action/SnapshotsAction.js +1 -1
- package/CHANGELOG.md +24 -0
- package/Command/BackupCommand.d.ts +1 -0
- package/Command/BackupCommand.js +5 -0
- package/Command/CopyCommand.d.ts +2 -1
- package/Command/CopyCommand.js +6 -1
- package/Command/InitCommand.js +2 -2
- package/Command/PruneCommand.d.ts +2 -8
- package/Command/RestoreCommand.d.ts +1 -1
- package/Command/RestoreCommand.js +4 -4
- package/Config/Config.d.ts +2 -0
- package/Config/Config.js +1 -0
- package/Repository/DatatruckRepository.d.ts +1 -0
- package/Repository/DatatruckRepository.js +5 -0
- package/Task/MysqlDumpTask.js +2 -8
- package/Task/SqlDumpTaskAbstract.js +1 -1
- package/config.schema.json +3 -0
- package/package.json +1 -1
- package/utils/cli.d.ts +3 -2
- package/utils/cli.js +12 -5
- package/utils/crypto.d.ts +1 -0
- package/utils/crypto.js +15 -0
- package/utils/datatruck/snapshot.d.ts +4 -1
- package/utils/datatruck/snapshot.js +12 -22
- package/utils/date.d.ts +14 -1
- package/utils/date.js +25 -11
- package/utils/fs.js +1 -1
- package/utils/list.js +1 -1
- package/utils/progress.js +12 -5
- package/utils/tar.js +3 -1
package/utils/date.js
CHANGED
|
@@ -3,15 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.duration = exports.createTimer = exports.filterByLast = void 0;
|
|
6
|
+
exports.duration = exports.createTimer = exports.filterByLast = exports.createFilterByLastOptions = void 0;
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
|
|
9
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
9
10
|
const duration_1 = __importDefault(require("dayjs/plugin/duration"));
|
|
10
11
|
const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
|
|
11
12
|
dayjs_1.default.extend(isoWeek_1.default);
|
|
12
13
|
dayjs_1.default.extend(advancedFormat_1.default);
|
|
13
14
|
dayjs_1.default.extend(duration_1.default);
|
|
14
|
-
|
|
15
|
+
dayjs_1.default.extend(customParseFormat_1.default);
|
|
16
|
+
function createFilterByLastOptions(keep) {
|
|
17
|
+
return {
|
|
18
|
+
last: keep.keepLast,
|
|
19
|
+
lastMinutely: keep.keepMinutely,
|
|
20
|
+
lastHourly: keep.keepHourly,
|
|
21
|
+
lastDaily: keep.keepDaily,
|
|
22
|
+
lastMonthly: keep.keepMonthly,
|
|
23
|
+
lastWeekly: keep.keepWeekly,
|
|
24
|
+
lastYearly: keep.keepYearly,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.createFilterByLastOptions = createFilterByLastOptions;
|
|
28
|
+
function filterByLast(items, options) {
|
|
15
29
|
const filters = {
|
|
16
30
|
last: { handler: (_, i) => i.toString(), value: options.last },
|
|
17
31
|
lastMinutely: {
|
|
@@ -44,13 +58,13 @@ function filterByLast(items, options, reasons) {
|
|
|
44
58
|
}
|
|
45
59
|
}
|
|
46
60
|
if (!someFilter)
|
|
47
|
-
return items;
|
|
61
|
+
return items.map((item) => ({ item, reasons: ["no-filter"] }));
|
|
62
|
+
const reasons = new Map();
|
|
48
63
|
const validItems = items
|
|
49
64
|
.slice(0)
|
|
50
65
|
.sort((a, b) => b.date.localeCompare(a.date))
|
|
51
66
|
.filter((item, index) => {
|
|
52
67
|
const date = (0, dayjs_1.default)(item.date);
|
|
53
|
-
const itemIndex = items.indexOf(item);
|
|
54
68
|
let success = false;
|
|
55
69
|
for (const key in filters) {
|
|
56
70
|
const object = filters[key];
|
|
@@ -58,12 +72,7 @@ function filterByLast(items, options, reasons) {
|
|
|
58
72
|
const value = object.handler(date, index);
|
|
59
73
|
if (value != object.last) {
|
|
60
74
|
success = true;
|
|
61
|
-
|
|
62
|
-
if (!reasons[itemIndex])
|
|
63
|
-
reasons[itemIndex] = [];
|
|
64
|
-
if (!reasons[itemIndex].includes(key))
|
|
65
|
-
reasons[itemIndex].push(key);
|
|
66
|
-
}
|
|
75
|
+
reasons.set(item, (reasons.get(item) || new Set()).add(key));
|
|
67
76
|
object.last = value;
|
|
68
77
|
object.value--;
|
|
69
78
|
}
|
|
@@ -71,7 +80,12 @@ function filterByLast(items, options, reasons) {
|
|
|
71
80
|
}
|
|
72
81
|
return success;
|
|
73
82
|
});
|
|
74
|
-
return items
|
|
83
|
+
return items
|
|
84
|
+
.filter((item) => validItems.includes(item))
|
|
85
|
+
.map((item) => ({
|
|
86
|
+
item,
|
|
87
|
+
reasons: [...(reasons.get(item) || [])],
|
|
88
|
+
}));
|
|
75
89
|
}
|
|
76
90
|
exports.filterByLast = filterByLast;
|
|
77
91
|
function createTimer() {
|
package/utils/fs.js
CHANGED
|
@@ -384,7 +384,7 @@ function createProgress(options) {
|
|
|
384
384
|
disposed: false,
|
|
385
385
|
total: 0,
|
|
386
386
|
current: 0,
|
|
387
|
-
update:
|
|
387
|
+
update: (description, path, increment = true) => {
|
|
388
388
|
if (progress.disposed)
|
|
389
389
|
return;
|
|
390
390
|
if (path && increment)
|
package/utils/list.js
CHANGED
|
@@ -42,7 +42,7 @@ class Listr3 extends listr2_1.Listr {
|
|
|
42
42
|
this.execTimer = (0, date_1.createTimer)();
|
|
43
43
|
}
|
|
44
44
|
serializeKeyIndex(keyIndex) {
|
|
45
|
-
return keyIndex
|
|
45
|
+
return typeof keyIndex !== "undefined"
|
|
46
46
|
? Array.isArray(keyIndex)
|
|
47
47
|
? keyIndex.map((k) => k.toString())
|
|
48
48
|
: [keyIndex.toString()]
|
package/utils/progress.js
CHANGED
|
@@ -86,19 +86,26 @@ function renderProgressStats(stats, progressBar) {
|
|
|
86
86
|
if (typeof stats.percent === "number") {
|
|
87
87
|
if (progressBar)
|
|
88
88
|
text.push((0, cli_1.renderProgressBar)(stats.percent));
|
|
89
|
-
text.push(`${stats.percent.toFixed(2)}%`);
|
|
89
|
+
text.push(`${stats.percent.toFixed(2).padStart(5, " ")}%`);
|
|
90
90
|
}
|
|
91
91
|
if (typeof stats.current === "number" || typeof stats.total === "number") {
|
|
92
|
-
const format = (value) => stats.format === "size" ? (0, bytes_1.default)(value) : value;
|
|
92
|
+
const format = (value) => stats.format === "size" ? (0, bytes_1.default)(value) : value.toString();
|
|
93
|
+
const pad = 8;
|
|
94
|
+
let values = [];
|
|
93
95
|
if (typeof stats.current === "number" && typeof stats.total === "number") {
|
|
94
|
-
|
|
96
|
+
values = [
|
|
97
|
+
format(stats.current).padStart(pad, " "),
|
|
98
|
+
format(stats.total).padEnd(pad, " "),
|
|
99
|
+
];
|
|
95
100
|
}
|
|
96
101
|
else if (typeof stats.current === "number") {
|
|
97
|
-
|
|
102
|
+
values = [format(stats.current).padStart(pad * 2 + 1)];
|
|
98
103
|
}
|
|
99
104
|
else if (typeof stats.total === "number") {
|
|
100
|
-
|
|
105
|
+
values = ["?".padStart(pad, " "), format(stats.total).padEnd(pad, " ")];
|
|
101
106
|
}
|
|
107
|
+
if (values.length)
|
|
108
|
+
text.push(values.join("/"));
|
|
102
109
|
}
|
|
103
110
|
if (stats.description && stats.payload) {
|
|
104
111
|
text.push(`${stats.description}: ${stats.payload}`);
|
package/utils/tar.js
CHANGED
|
@@ -157,7 +157,9 @@ async function createTar(options) {
|
|
|
157
157
|
...env,
|
|
158
158
|
},
|
|
159
159
|
}, {
|
|
160
|
-
log: options.verbose
|
|
160
|
+
log: options.verbose
|
|
161
|
+
? { envNames: Object.keys(env), exec: true, stderr: true, stdout: true }
|
|
162
|
+
: false,
|
|
161
163
|
...(vendor === "bsdtar"
|
|
162
164
|
? {
|
|
163
165
|
stderr: options.onEntry
|