@datatruck/cli 0.40.1 → 0.40.3
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/lib/actions/BackupAction.js +20 -13
- package/lib/actions/CopyAction.js +20 -12
- package/lib/actions/ExportAction.js +13 -6
- package/lib/actions/RestoreAction.js +13 -6
- package/lib/cli.js +2 -3
- package/lib/repositories/ResticRepository.d.ts +2 -2
- package/lib/tasks/MysqlDumpTask.js +12 -5
- package/lib/tasks/ScriptTask.js +2 -2
- package/lib/utils/async-process.d.ts +0 -5
- package/lib/utils/async.d.ts +0 -1
- package/lib/utils/async.js +1 -2
- package/lib/utils/bytes.js +2 -3
- package/lib/utils/cli.d.ts +0 -1
- package/lib/utils/cli.js +13 -13
- package/lib/utils/cron.js +1 -2
- package/lib/utils/crypto.js +2 -3
- package/lib/utils/datatruck/client.js +3 -3
- package/lib/utils/datatruck/command.js +3 -3
- package/lib/utils/datatruck/config.js +15 -15
- package/lib/utils/datatruck/cron-server.js +1 -2
- package/lib/utils/datatruck/job.js +4 -5
- package/lib/utils/datatruck/paths.js +2 -3
- package/lib/utils/datatruck/report-list.js +1 -2
- package/lib/utils/datatruck/repository-server.d.ts +0 -1
- package/lib/utils/datatruck/repository-server.js +2 -2
- package/lib/utils/datatruck/repository.js +4 -5
- package/lib/utils/datatruck/snapshot.js +1 -2
- package/lib/utils/datatruck/task.js +1 -2
- package/lib/utils/date.js +4 -5
- package/lib/utils/exit.js +4 -5
- package/lib/utils/fs.d.ts +0 -3
- package/lib/utils/fs.js +40 -40
- package/lib/utils/git.d.ts +1 -1
- package/lib/utils/http.d.ts +0 -1
- package/lib/utils/http.js +11 -11
- package/lib/utils/list.d.ts +2 -2
- package/lib/utils/list.js +36 -26
- package/lib/utils/logs.js +3 -3
- package/lib/utils/math.js +2 -2
- package/lib/utils/mongodb.js +2 -3
- package/lib/utils/mysql.d.ts +0 -1
- package/lib/utils/mysql.js +30 -21
- package/lib/utils/object.js +6 -6
- package/lib/utils/options.js +2 -3
- package/lib/utils/process.d.ts +0 -1
- package/lib/utils/process.js +3 -4
- package/lib/utils/progress.d.ts +0 -2
- package/lib/utils/progress.js +3 -3
- package/lib/utils/reportSteps.js +2 -3
- package/lib/utils/spawnSteps.js +2 -3
- package/lib/utils/stream.d.ts +0 -1
- package/lib/utils/stream.js +2 -3
- package/lib/utils/string.js +11 -12
- package/lib/utils/tar.js +6 -7
- package/lib/utils/temp.d.ts +2 -3
- package/lib/utils/temp.js +16 -15
- package/lib/utils/virtual-fs.js +2 -2
- package/lib/utils/watcher.js +1 -2
- package/package.json +14 -14
package/lib/utils/string.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.snakeCase = snakeCase;
|
|
4
|
+
exports.camelize = camelize;
|
|
5
|
+
exports.render = render;
|
|
6
|
+
exports.parseStringList = parseStringList;
|
|
7
|
+
exports.formatUri = formatUri;
|
|
8
|
+
exports.splitPatterns = splitPatterns;
|
|
9
|
+
exports.match = match;
|
|
10
|
+
exports.createPatternFilter = createPatternFilter;
|
|
11
|
+
exports.endsWith = endsWith;
|
|
12
|
+
exports.undefIfEmpty = undefIfEmpty;
|
|
13
|
+
exports.compareJsons = compareJsons;
|
|
4
14
|
const error_1 = require("./error");
|
|
5
15
|
const micromatch_1 = require("micromatch");
|
|
6
16
|
function snakeCase(value, char = "_") {
|
|
7
17
|
return value.replace(/[A-Z]/g, (letter) => `${char}${letter.toLowerCase()}`);
|
|
8
18
|
}
|
|
9
|
-
exports.snakeCase = snakeCase;
|
|
10
19
|
function camelize(input) {
|
|
11
20
|
return input.replace(/-./g, (x) => x[1].toUpperCase());
|
|
12
21
|
}
|
|
13
|
-
exports.camelize = camelize;
|
|
14
22
|
function render(subject, data) {
|
|
15
23
|
return subject.replace(/{([\w\./]*)}/g, function (match, name) {
|
|
16
24
|
if (!name.length) {
|
|
@@ -41,7 +49,6 @@ function render(subject, data) {
|
|
|
41
49
|
return ref.toString();
|
|
42
50
|
});
|
|
43
51
|
}
|
|
44
|
-
exports.render = render;
|
|
45
52
|
function parseStringList(value, validValues, defaultsValues) {
|
|
46
53
|
const resultFallback = (defaultsValues === true ? validValues : defaultsValues) ?? [];
|
|
47
54
|
const result = value
|
|
@@ -54,7 +61,6 @@ function parseStringList(value, validValues, defaultsValues) {
|
|
|
54
61
|
throw new error_1.AppError(`Invalid value: ${v}`);
|
|
55
62
|
return result;
|
|
56
63
|
}
|
|
57
|
-
exports.parseStringList = parseStringList;
|
|
58
64
|
function formatUri(input, hidePassword) {
|
|
59
65
|
let uri = "";
|
|
60
66
|
if (input.protocol) {
|
|
@@ -74,7 +80,6 @@ function formatUri(input, hidePassword) {
|
|
|
74
80
|
uri += input.path;
|
|
75
81
|
return uri;
|
|
76
82
|
}
|
|
77
|
-
exports.formatUri = formatUri;
|
|
78
83
|
function splitPatterns(patterns, map) {
|
|
79
84
|
const include = [];
|
|
80
85
|
const exclude = [];
|
|
@@ -92,12 +97,10 @@ function splitPatterns(patterns, map) {
|
|
|
92
97
|
exclude: exclude.length ? exclude : undefined,
|
|
93
98
|
};
|
|
94
99
|
}
|
|
95
|
-
exports.splitPatterns = splitPatterns;
|
|
96
100
|
function match(path, include, exclude) {
|
|
97
101
|
return ((!include || (0, micromatch_1.isMatch)(path, include, { dot: true })) &&
|
|
98
102
|
(!exclude || !(0, micromatch_1.isMatch)(path, exclude, { dot: true })));
|
|
99
103
|
}
|
|
100
|
-
exports.match = match;
|
|
101
104
|
function createPatternFilter(patterns) {
|
|
102
105
|
if (patterns === undefined) {
|
|
103
106
|
return () => true;
|
|
@@ -108,16 +111,12 @@ function createPatternFilter(patterns) {
|
|
|
108
111
|
const { include, exclude } = patterns;
|
|
109
112
|
return (input) => match(input, include, exclude);
|
|
110
113
|
}
|
|
111
|
-
exports.createPatternFilter = createPatternFilter;
|
|
112
114
|
function endsWith(input, patterns) {
|
|
113
115
|
return patterns.some((pattern) => input.endsWith(pattern));
|
|
114
116
|
}
|
|
115
|
-
exports.endsWith = endsWith;
|
|
116
117
|
function undefIfEmpty(input) {
|
|
117
118
|
return input.length ? input : undefined;
|
|
118
119
|
}
|
|
119
|
-
exports.undefIfEmpty = undefIfEmpty;
|
|
120
120
|
function compareJsons(a, b) {
|
|
121
121
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
122
122
|
}
|
|
123
|
-
exports.compareJsons = compareJsons;
|
package/lib/utils/tar.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTarVendor = getTarVendor;
|
|
4
|
+
exports.listTar = listTar;
|
|
5
|
+
exports.checkPigzLib = checkPigzLib;
|
|
6
|
+
exports.createTar = createTar;
|
|
7
|
+
exports.normalizeTarPath = normalizeTarPath;
|
|
8
|
+
exports.extractTar = extractTar;
|
|
4
9
|
const async_process_1 = require("./async-process");
|
|
5
10
|
const cli_1 = require("./cli");
|
|
6
11
|
const fs_1 = require("./fs");
|
|
@@ -28,7 +33,6 @@ async function getTarVendor(cache = true, log = false) {
|
|
|
28
33
|
};
|
|
29
34
|
return (tarVendor = find());
|
|
30
35
|
}
|
|
31
|
-
exports.getTarVendor = getTarVendor;
|
|
32
36
|
async function listTar(options) {
|
|
33
37
|
const vendor = await getTarVendor(true, options.verbose);
|
|
34
38
|
const p = new async_process_1.AsyncProcess("tar", [
|
|
@@ -40,7 +44,6 @@ async function listTar(options) {
|
|
|
40
44
|
options.onEntry?.({ path: normalizeTarPath(path) });
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
|
-
exports.listTar = listTar;
|
|
44
47
|
let pigzLib;
|
|
45
48
|
async function checkPigzLib(cache = true) {
|
|
46
49
|
if (cache && pigzLib !== undefined)
|
|
@@ -55,7 +58,6 @@ async function checkPigzLib(cache = true) {
|
|
|
55
58
|
return false;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
|
-
exports.checkPigzLib = checkPigzLib;
|
|
59
61
|
async function resolveCores(input) {
|
|
60
62
|
if (!(await checkPigzLib()))
|
|
61
63
|
return 1;
|
|
@@ -140,7 +142,6 @@ async function createTar(options) {
|
|
|
140
142
|
await p.waitForClose();
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
exports.createTar = createTar;
|
|
144
145
|
/**
|
|
145
146
|
* Fix `tar.exe: Option --force-local is not supported`
|
|
146
147
|
*/
|
|
@@ -153,7 +154,6 @@ function toLocalPath(path) {
|
|
|
153
154
|
function normalizeTarPath(path) {
|
|
154
155
|
return path.endsWith("/") ? path.slice(0, -1) : path;
|
|
155
156
|
}
|
|
156
|
-
exports.normalizeTarPath = normalizeTarPath;
|
|
157
157
|
async function extractTar(options) {
|
|
158
158
|
let total = options.onEntry
|
|
159
159
|
? options.total ??
|
|
@@ -205,4 +205,3 @@ async function extractTar(options) {
|
|
|
205
205
|
await p.waitForClose();
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
exports.extractTar = extractTar;
|
package/lib/utils/temp.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
export declare function parentTmpDir(): string;
|
|
3
2
|
export declare function sessionTmpDir(): string;
|
|
4
3
|
export declare function ensureFreeDiskTempSpace(size: number | string): Promise<void>;
|
|
@@ -14,10 +13,10 @@ export declare function useTempFile(path: string): AsyncDisposable & {
|
|
|
14
13
|
path: string;
|
|
15
14
|
};
|
|
16
15
|
export declare class GargabeCollector {
|
|
17
|
-
protected
|
|
16
|
+
protected verbose?: boolean | undefined;
|
|
18
17
|
readonly paths: Set<string>;
|
|
19
18
|
readonly children: Set<GargabeCollector>;
|
|
20
|
-
constructor(
|
|
19
|
+
constructor(verbose?: boolean | undefined);
|
|
21
20
|
pending(): boolean;
|
|
22
21
|
cleanup(): Promise<void>;
|
|
23
22
|
dispose(): Promise<void>;
|
package/lib/utils/temp.js
CHANGED
|
@@ -3,7 +3,16 @@ 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.GargabeCollector = exports.
|
|
6
|
+
exports.GargabeCollector = exports.collectors = void 0;
|
|
7
|
+
exports.parentTmpDir = parentTmpDir;
|
|
8
|
+
exports.sessionTmpDir = sessionTmpDir;
|
|
9
|
+
exports.ensureFreeDiskTempSpace = ensureFreeDiskTempSpace;
|
|
10
|
+
exports.isTmpDir = isTmpDir;
|
|
11
|
+
exports.rmTmpDir = rmTmpDir;
|
|
12
|
+
exports.tmpDir = tmpDir;
|
|
13
|
+
exports.mkTmpDir = mkTmpDir;
|
|
14
|
+
exports.useTempDir = useTempDir;
|
|
15
|
+
exports.useTempFile = useTempFile;
|
|
7
16
|
const globalData_1 = __importDefault(require("../globalData"));
|
|
8
17
|
const fs_1 = require("./fs");
|
|
9
18
|
const crypto_1 = require("crypto");
|
|
@@ -14,21 +23,17 @@ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
|
14
23
|
function parentTmpDir() {
|
|
15
24
|
return (0, path_1.join)(globalData_1.default.tempDir, "datatruck-temp");
|
|
16
25
|
}
|
|
17
|
-
exports.parentTmpDir = parentTmpDir;
|
|
18
26
|
function sessionTmpDir() {
|
|
19
27
|
return (0, path_1.join)(parentTmpDir(), process.pid.toString());
|
|
20
28
|
}
|
|
21
|
-
exports.sessionTmpDir = sessionTmpDir;
|
|
22
29
|
async function ensureFreeDiskTempSpace(size) {
|
|
23
30
|
const path = sessionTmpDir();
|
|
24
31
|
await (0, fs_1.mkdirIfNotExists)(sessionTmpDir());
|
|
25
32
|
await (0, fs_1.ensureFreeDiskSpace)([path], size);
|
|
26
33
|
}
|
|
27
|
-
exports.ensureFreeDiskTempSpace = ensureFreeDiskTempSpace;
|
|
28
34
|
function isTmpDir(path) {
|
|
29
35
|
return path.startsWith(sessionTmpDir()) && path.includes("datatruck-temp");
|
|
30
36
|
}
|
|
31
|
-
exports.isTmpDir = isTmpDir;
|
|
32
37
|
async function rmTmpDir(input) {
|
|
33
38
|
if (typeof input === "string") {
|
|
34
39
|
if (!isTmpDir(input))
|
|
@@ -40,7 +45,6 @@ async function rmTmpDir(input) {
|
|
|
40
45
|
await rmTmpDir(path);
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
|
-
exports.rmTmpDir = rmTmpDir;
|
|
44
48
|
function tmpDir(...keys) {
|
|
45
49
|
const id = (0, crypto_1.randomUUID)().slice(0, 8);
|
|
46
50
|
const path = (0, path_1.join)(sessionTmpDir(), [...keys, id].map(encodeURIComponent).join("-"));
|
|
@@ -51,14 +55,12 @@ function tmpDir(...keys) {
|
|
|
51
55
|
}
|
|
52
56
|
return path;
|
|
53
57
|
}
|
|
54
|
-
exports.tmpDir = tmpDir;
|
|
55
58
|
exports.collectors = new Set();
|
|
56
59
|
async function mkTmpDir(...keys) {
|
|
57
60
|
const path = tmpDir(...keys);
|
|
58
61
|
await (0, promises_1.mkdir)(path, { recursive: true });
|
|
59
62
|
return path;
|
|
60
63
|
}
|
|
61
|
-
exports.mkTmpDir = mkTmpDir;
|
|
62
64
|
async function useTempDir(...keys) {
|
|
63
65
|
const path = await mkTmpDir(...keys);
|
|
64
66
|
return {
|
|
@@ -71,7 +73,6 @@ async function useTempDir(...keys) {
|
|
|
71
73
|
},
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
exports.useTempDir = useTempDir;
|
|
75
76
|
function useTempFile(path) {
|
|
76
77
|
return {
|
|
77
78
|
path,
|
|
@@ -83,13 +84,12 @@ function useTempFile(path) {
|
|
|
83
84
|
},
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
|
-
exports.useTempFile = useTempFile;
|
|
87
87
|
class GargabeCollector {
|
|
88
|
-
|
|
88
|
+
verbose;
|
|
89
89
|
paths = new Set();
|
|
90
90
|
children = new Set();
|
|
91
|
-
constructor(
|
|
92
|
-
this.
|
|
91
|
+
constructor(verbose) {
|
|
92
|
+
this.verbose = verbose;
|
|
93
93
|
exports.collectors.add(this);
|
|
94
94
|
}
|
|
95
95
|
pending() {
|
|
@@ -103,7 +103,8 @@ class GargabeCollector {
|
|
|
103
103
|
async cleanup() {
|
|
104
104
|
for (const path of this.paths) {
|
|
105
105
|
try {
|
|
106
|
-
|
|
106
|
+
if (!this.verbose)
|
|
107
|
+
await rmTmpDir(path);
|
|
107
108
|
this.paths.delete(path);
|
|
108
109
|
}
|
|
109
110
|
catch (_) { }
|
|
@@ -132,7 +133,7 @@ class GargabeCollector {
|
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
135
|
create() {
|
|
135
|
-
const gc = new GargabeCollector();
|
|
136
|
+
const gc = new GargabeCollector(this.verbose);
|
|
136
137
|
this.children.add(gc);
|
|
137
138
|
return gc;
|
|
138
139
|
}
|
package/lib/utils/virtual-fs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LocalFs = exports.AbstractFs =
|
|
3
|
+
exports.LocalFs = exports.AbstractFs = void 0;
|
|
4
|
+
exports.resolvePath = resolvePath;
|
|
4
5
|
const fs_1 = require("./fs");
|
|
5
6
|
const promises_1 = require("fs/promises");
|
|
6
7
|
const path_1 = require("path");
|
|
@@ -8,7 +9,6 @@ function resolvePath(path) {
|
|
|
8
9
|
const { pathname } = new URL(`file:///${path}`);
|
|
9
10
|
return pathname;
|
|
10
11
|
}
|
|
11
|
-
exports.resolvePath = resolvePath;
|
|
12
12
|
class AbstractFs {
|
|
13
13
|
options;
|
|
14
14
|
constructor(options) {
|
package/lib/utils/watcher.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWatcher =
|
|
3
|
+
exports.createWatcher = createWatcher;
|
|
4
4
|
function createWatcher(options) {
|
|
5
5
|
let prev;
|
|
6
6
|
let interval;
|
|
@@ -31,4 +31,3 @@ function createWatcher(options) {
|
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
exports.createWatcher = createWatcher;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datatruck/cli",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.3",
|
|
4
4
|
"description": "Tool for creating and managing backups",
|
|
5
5
|
"homepage": "https://github.com/swordev/datatruck#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -27,26 +27,26 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@supercharge/promise-pool": "^3.2.0",
|
|
30
|
-
"ajv": "^8.
|
|
31
|
-
"async": "^3.2.
|
|
30
|
+
"ajv": "^8.17.1",
|
|
31
|
+
"async": "^3.2.6",
|
|
32
32
|
"chalk": "^4.1.2",
|
|
33
|
-
"commander": "^12.
|
|
34
|
-
"croner": "^8.
|
|
35
|
-
"dayjs": "^1.11.
|
|
33
|
+
"commander": "^12.1.0",
|
|
34
|
+
"croner": "^8.1.2",
|
|
35
|
+
"dayjs": "^1.11.13",
|
|
36
36
|
"fast-folder-size": "^2.2.0",
|
|
37
37
|
"fast-glob": "^3.3.2",
|
|
38
|
-
"listr2": "^8.2.
|
|
39
|
-
"micromatch": "^4.0.
|
|
40
|
-
"mongodb": "^6.
|
|
41
|
-
"mysql2": "^3.
|
|
38
|
+
"listr2": "^8.2.5",
|
|
39
|
+
"micromatch": "^4.0.8",
|
|
40
|
+
"mongodb": "^6.9.0",
|
|
41
|
+
"mysql2": "^3.11.3",
|
|
42
42
|
"tty-table": "^4.2.3",
|
|
43
|
-
"undici": "^6.
|
|
44
|
-
"yaml": "^2.
|
|
43
|
+
"undici": "^6.19.8",
|
|
44
|
+
"yaml": "^2.5.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/async": "^3.2.24",
|
|
48
|
-
"@types/micromatch": "^4.0.
|
|
49
|
-
"mongodb-memory-server": "^
|
|
48
|
+
"@types/micromatch": "^4.0.9",
|
|
49
|
+
"mongodb-memory-server": "^10.0.1"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
52
|
"ts-node": "^10.9.2"
|