@datatruck/cli 0.28.0 → 0.29.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/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 +12 -6
- package/Action/SnapshotsAction.js +1 -1
- package/CHANGELOG.md +18 -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 +1 -7
- 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/list.js +1 -1
- 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/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/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
|