@datatruck/cli 0.15.0 → 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/Action/BackupAction.js +7 -7
- package/Action/RestoreAction.js +4 -4
- package/Entity/StateEntityAbstract.d.ts +2 -6
- package/Error/AppError.d.ts +1 -0
- package/Error/AppError.js +4 -0
- package/Repository/DatatruckRepository.js +68 -87
- package/Repository/RepositoryAbstract.d.ts +4 -15
- package/Repository/ResticRepository.js +14 -14
- package/SessionDriver/ConsoleSessionDriver.d.ts +2 -6
- package/SessionDriver/ConsoleSessionDriver.js +52 -26
- package/SessionDriver/SqliteSessionDriver.js +5 -0
- package/SessionManager/BackupSessionManager.d.ts +5 -3
- package/SessionManager/BackupSessionManager.js +14 -18
- package/SessionManager/RestoreSessionManager.d.ts +6 -4
- package/SessionManager/RestoreSessionManager.js +14 -18
- package/SessionManager/SessionManagerAbstract.d.ts +5 -1
- package/SessionManager/SessionManagerAbstract.js +13 -2
- package/Task/GitTask.js +6 -6
- package/Task/MariadbTask.js +3 -3
- package/Task/MysqlDumpTask.d.ts +3 -1
- package/Task/MysqlDumpTask.js +5 -2
- package/Task/PostgresqlDumpTask.d.ts +3 -1
- package/Task/PostgresqlDumpTask.js +2 -2
- package/Task/SqlDumpTaskAbstract.d.ts +3 -1
- package/Task/SqlDumpTaskAbstract.js +33 -11
- package/Task/TaskAbstract.d.ts +3 -14
- package/migrations/001-initial.sql +6 -36
- package/package.json +1 -1
- package/util/cli-util.d.ts +1 -1
- package/util/cli-util.js +17 -2
- package/util/fs-util.js +1 -1
- package/util/process-util.d.ts +3 -0
- package/util/process-util.js +11 -0
- package/util/progress.d.ts +12 -0
- package/util/progress.js +2 -0
- package/util/zip-util.js +6 -2
|
@@ -11,12 +11,7 @@ CREATE TABLE "backup_session" (
|
|
|
11
11
|
"endDate" TEXT,
|
|
12
12
|
"state" TEXT,
|
|
13
13
|
"error" TEXT,
|
|
14
|
-
"
|
|
15
|
-
"progressTotal" INTEGER,
|
|
16
|
-
"progressPercent" INTEGER,
|
|
17
|
-
"progressStepDescription" TEXT,
|
|
18
|
-
"progressStepItem" TEXT,
|
|
19
|
-
"progressStepPercent" INTEGER,
|
|
14
|
+
"progress" TEXT,
|
|
20
15
|
|
|
21
16
|
"snapshotId" TEXT NOT NULL,
|
|
22
17
|
"packageName" TEXT NOT NULL,
|
|
@@ -33,12 +28,7 @@ CREATE TABLE "backup_session_task" (
|
|
|
33
28
|
"endDate" TEXT,
|
|
34
29
|
"state" TEXT,
|
|
35
30
|
"error" TEXT,
|
|
36
|
-
"
|
|
37
|
-
"progressTotal" INTEGER,
|
|
38
|
-
"progressPercent" INTEGER,
|
|
39
|
-
"progressStepDescription" TEXT,
|
|
40
|
-
"progressStepItem" TEXT,
|
|
41
|
-
"progressStepPercent" INTEGER,
|
|
31
|
+
"progress" TEXT,
|
|
42
32
|
|
|
43
33
|
"sessionId" INTEGER NOT NULL,
|
|
44
34
|
"taskName" TEXT NOT NULL
|
|
@@ -53,12 +43,7 @@ CREATE TABLE "backup_session_repository" (
|
|
|
53
43
|
"endDate" TEXT,
|
|
54
44
|
"state" TEXT,
|
|
55
45
|
"error" TEXT,
|
|
56
|
-
"
|
|
57
|
-
"progressTotal" INTEGER,
|
|
58
|
-
"progressPercent" INTEGER,
|
|
59
|
-
"progressStepDescription" TEXT,
|
|
60
|
-
"progressStepItem" TEXT,
|
|
61
|
-
"progressStepPercent" INTEGER,
|
|
46
|
+
"progress" TEXT,
|
|
62
47
|
|
|
63
48
|
"sessionId" INTEGER NOT NULL,
|
|
64
49
|
"repositoryName" TEXT NOT NULL,
|
|
@@ -74,12 +59,7 @@ CREATE TABLE "restore_session" (
|
|
|
74
59
|
"endDate" TEXT,
|
|
75
60
|
"state" TEXT,
|
|
76
61
|
"error" TEXT,
|
|
77
|
-
"
|
|
78
|
-
"progressTotal" INTEGER,
|
|
79
|
-
"progressPercent" INTEGER,
|
|
80
|
-
"progressStepDescription" TEXT,
|
|
81
|
-
"progressStepItem" TEXT,
|
|
82
|
-
"progressStepPercent" INTEGER,
|
|
62
|
+
"progress" TEXT,
|
|
83
63
|
|
|
84
64
|
"snapshotId" TEXT NOT NULL,
|
|
85
65
|
"packageName" TEXT NOT NULL -- ,
|
|
@@ -95,12 +75,7 @@ CREATE TABLE "restore_session_task" (
|
|
|
95
75
|
"endDate" TEXT,
|
|
96
76
|
"state" TEXT,
|
|
97
77
|
"error" TEXT,
|
|
98
|
-
"
|
|
99
|
-
"progressTotal" INTEGER,
|
|
100
|
-
"progressPercent" INTEGER,
|
|
101
|
-
"progressStepDescription" TEXT,
|
|
102
|
-
"progressStepItem" TEXT,
|
|
103
|
-
"progressStepPercent" INTEGER,
|
|
78
|
+
"progress" TEXT,
|
|
104
79
|
|
|
105
80
|
"sessionId" INTEGER NOT NULL,
|
|
106
81
|
"taskName" TEXT NOT NULL
|
|
@@ -115,12 +90,7 @@ CREATE TABLE "restore_session_repository" (
|
|
|
115
90
|
"endDate" TEXT,
|
|
116
91
|
"state" TEXT,
|
|
117
92
|
"error" TEXT,
|
|
118
|
-
"
|
|
119
|
-
"progressTotal" INTEGER,
|
|
120
|
-
"progressPercent" INTEGER,
|
|
121
|
-
"progressStepDescription" TEXT,
|
|
122
|
-
"progressStepItem" TEXT,
|
|
123
|
-
"progressStepPercent" INTEGER,
|
|
93
|
+
"progress" TEXT,
|
|
124
94
|
|
|
125
95
|
"sessionId" INTEGER NOT NULL,
|
|
126
96
|
"repositoryName" TEXT NOT NULL,
|
package/package.json
CHANGED
package/util/cli-util.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const showCursorCommand = "\u001B[?25h";
|
|
|
5
5
|
export declare const clearCommand = "\r\u001B[K";
|
|
6
6
|
export declare const hideCursorCommand = "\u001B[?25l";
|
|
7
7
|
export declare function renderSpinner(counter: number): string;
|
|
8
|
-
export declare function renderProgressBar(progress: number, size?: number): string;
|
|
8
|
+
export declare function renderProgressBar(progress: number, size?: number, subprogress?: number): string;
|
|
9
9
|
export declare function logVars(data: Record<string, any>): void;
|
|
10
10
|
export declare function logExec(command: string, argv?: string[], env?: NodeJS.ProcessEnv, logToStderr?: boolean): void;
|
|
11
11
|
export declare function resultColumn(error: Error | null | string, state?: "started" | "ended"): "❌" | " ? " | "✅";
|
package/util/cli-util.js
CHANGED
|
@@ -20,12 +20,27 @@ function renderSpinner(counter) {
|
|
|
20
20
|
return exports.spinnerChars[counter % (exports.spinnerChars.length - 1)];
|
|
21
21
|
}
|
|
22
22
|
exports.renderSpinner = renderSpinner;
|
|
23
|
-
function renderProgressBar(progress, size = 10) {
|
|
23
|
+
function renderProgressBar(progress, size = 10, subprogress) {
|
|
24
24
|
const completeChar = "\u2588";
|
|
25
25
|
const incompleteChar = "\u2591";
|
|
26
26
|
const completedSize = Math.round((progress * size) / 100);
|
|
27
27
|
const restSize = Math.max(size - completedSize, 0);
|
|
28
|
-
|
|
28
|
+
let result = completeChar.repeat(completedSize) + incompleteChar.repeat(restSize);
|
|
29
|
+
if (typeof subprogress === "number") {
|
|
30
|
+
const subprogressChar = Math.round((subprogress * size) / 100);
|
|
31
|
+
if (subprogressChar === size) {
|
|
32
|
+
result =
|
|
33
|
+
result.slice(0, subprogressChar - 1) +
|
|
34
|
+
chalk_1.default.white(result[Math.max(0, subprogressChar - 1)]);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result =
|
|
38
|
+
result.slice(0, subprogressChar) +
|
|
39
|
+
chalk_1.default.white(result[Math.max(0, subprogressChar - 1)]) +
|
|
40
|
+
result.slice(subprogressChar + 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return (0, chalk_2.cyan)(result);
|
|
29
44
|
}
|
|
30
45
|
exports.renderProgressBar = renderProgressBar;
|
|
31
46
|
function logVars(data) {
|
package/util/fs-util.js
CHANGED
|
@@ -162,7 +162,7 @@ function sessionTmpDir() {
|
|
|
162
162
|
exports.sessionTmpDir = sessionTmpDir;
|
|
163
163
|
function tmpDir(prefix, id) {
|
|
164
164
|
if (!id)
|
|
165
|
-
id = (0, crypto_1.
|
|
165
|
+
id = (0, crypto_1.randomUUID)().slice(0, 8);
|
|
166
166
|
return (0, path_1.join)(sessionTmpDir(), `${prefix}-${id}`);
|
|
167
167
|
}
|
|
168
168
|
exports.tmpDir = tmpDir;
|
package/util/process-util.d.ts
CHANGED
package/util/process-util.js
CHANGED
|
@@ -121,6 +121,17 @@ async function exec(command, argv = [], options = null, settings = {}) {
|
|
|
121
121
|
throw new Error(`stdout is not defined`);
|
|
122
122
|
if (!p.stderr)
|
|
123
123
|
throw new Error(`stderr is not defined`);
|
|
124
|
+
if (pipe.onWriteProgress) {
|
|
125
|
+
let totalBytes = 0;
|
|
126
|
+
p.stdout.on("data", (chunk) => {
|
|
127
|
+
totalBytes += chunk.length;
|
|
128
|
+
pipe.onWriteProgress({ totalBytes });
|
|
129
|
+
});
|
|
130
|
+
p.stderr.on("data", (chunk) => {
|
|
131
|
+
totalBytes += chunk.length;
|
|
132
|
+
pipe.onWriteProgress({ totalBytes });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
124
135
|
p.stdout.pipe(pipe.stream, { end: false });
|
|
125
136
|
p.stderr.pipe(pipe.stream, { end: false });
|
|
126
137
|
p.on("close", tryFinish);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare type ProgressStats = {
|
|
2
|
+
percent?: number;
|
|
3
|
+
total?: number;
|
|
4
|
+
current?: number;
|
|
5
|
+
description?: string;
|
|
6
|
+
payload?: string;
|
|
7
|
+
format?: "amount" | "size";
|
|
8
|
+
};
|
|
9
|
+
export declare type Progress = {
|
|
10
|
+
absolute?: ProgressStats;
|
|
11
|
+
relative?: ProgressStats;
|
|
12
|
+
};
|
package/util/progress.js
ADDED
package/util/zip-util.js
CHANGED
|
@@ -32,7 +32,11 @@ function buildArguments(filters) {
|
|
|
32
32
|
exports.buildArguments = buildArguments;
|
|
33
33
|
let checkSSEOptionResult;
|
|
34
34
|
async function checkSSEOption(command = "7z") {
|
|
35
|
-
const result = await (0, process_util_1.exec)(command
|
|
35
|
+
const result = await (0, process_util_1.exec)(command, [], {}, {
|
|
36
|
+
stdout: {
|
|
37
|
+
save: true,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
36
40
|
if (typeof checkSSEOptionResult === "boolean")
|
|
37
41
|
return checkSSEOptionResult;
|
|
38
42
|
return (checkSSEOptionResult = result.stdout.includes(" -sse"));
|
|
@@ -138,7 +142,7 @@ async function zip(data) {
|
|
|
138
142
|
onExitCodeError: (data, error) => (data.exitCode > 2 ? error : false),
|
|
139
143
|
stdout: {
|
|
140
144
|
onData: async (lines) => {
|
|
141
|
-
for (const line of lines.split(/\r?\n/)) {
|
|
145
|
+
for (const line of lines.replaceAll("\b", "").split(/\r?\n/)) {
|
|
142
146
|
const stream = parseZipLine(line);
|
|
143
147
|
if (stream) {
|
|
144
148
|
if (stream.type === "summary")
|