@datatruck/cli 0.17.1 → 0.18.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 +1 -1
- package/Action/BackupAction.js +14 -14
- package/Action/BackupSessionsAction.d.ts +1 -1
- package/Action/CleanCacheAction.d.ts +1 -1
- package/Action/CleanCacheAction.js +3 -3
- package/Action/ConfigAction.d.ts +1 -1
- package/Action/ConfigAction.js +5 -5
- package/Action/InitAction.d.ts +1 -1
- package/Action/InitAction.js +2 -2
- package/Action/PruneAction.d.ts +1 -1
- package/Action/PruneAction.js +4 -4
- package/Action/RestoreAction.d.ts +1 -1
- package/Action/RestoreAction.js +18 -18
- package/Action/RestoreSessionsAction.d.ts +1 -1
- package/Action/SnapshotsAction.d.ts +1 -1
- package/Action/SnapshotsAction.js +4 -4
- package/Command/BackupCommand.d.ts +2 -2
- package/Command/BackupCommand.js +6 -6
- package/Command/BackupSessionsCommand.d.ts +2 -2
- package/Command/BackupSessionsCommand.js +9 -9
- package/Command/CleanCacheCommand.d.ts +1 -1
- package/Command/CleanCacheCommand.js +2 -2
- package/Command/CommandAbstract.d.ts +3 -3
- package/Command/CommandAbstract.js +2 -2
- package/Command/ConfigCommand.d.ts +2 -2
- package/Command/ConfigCommand.js +8 -8
- package/Command/InitCommand.d.ts +2 -2
- package/Command/InitCommand.js +9 -9
- package/Command/PruneCommand.d.ts +2 -2
- package/Command/PruneCommand.js +10 -10
- package/Command/RestoreCommand.d.ts +2 -2
- package/Command/RestoreCommand.js +6 -6
- package/Command/RestoreSessionsCommand.d.ts +2 -2
- package/Command/RestoreSessionsCommand.js +9 -9
- package/Command/SnapshotsCommand.d.ts +2 -2
- package/Command/SnapshotsCommand.js +9 -9
- package/Entity/StateEntityAbstract.d.ts +1 -1
- package/Repository/DatatruckRepository.d.ts +1 -2
- package/Repository/DatatruckRepository.js +56 -118
- package/Repository/GitRepository.js +23 -23
- package/Repository/RepositoryAbstract.d.ts +1 -1
- package/Repository/RepositoryAbstract.js +2 -2
- package/Repository/ResticRepository.d.ts +1 -1
- package/Repository/ResticRepository.js +27 -27
- package/SessionDriver/ConsoleSessionDriver.d.ts +1 -1
- package/SessionDriver/ConsoleSessionDriver.js +10 -10
- package/SessionDriver/SqliteSessionDriver.js +12 -12
- package/SessionManager/BackupSessionManager.d.ts +2 -2
- package/SessionManager/BackupSessionManager.js +1 -1
- package/SessionManager/RestoreSessionManager.d.ts +2 -2
- package/SessionManager/RestoreSessionManager.js +1 -1
- package/Task/GitTask.js +21 -21
- package/Task/MariadbTask.d.ts +11 -0
- package/Task/MariadbTask.js +240 -58
- package/Task/MssqlTask.js +8 -8
- package/Task/MysqlDumpTask.d.ts +1 -1
- package/Task/MysqlDumpTask.js +13 -13
- package/Task/PostgresqlDumpTask.d.ts +1 -1
- package/Task/PostgresqlDumpTask.js +4 -4
- package/Task/ScriptTask.js +7 -7
- package/Task/SqlDumpTaskAbstract.d.ts +1 -1
- package/Task/SqlDumpTaskAbstract.js +12 -12
- package/Task/TaskAbstract.d.ts +1 -1
- package/Task/TaskAbstract.js +2 -2
- package/cli.js +10 -10
- package/config.schema.json +44 -0
- package/package.json +3 -3
- package/{util → utils}/DataFormat.d.ts +0 -0
- package/{util → utils}/DataFormat.js +0 -0
- package/{util/GitUtil.d.ts → utils/Git.d.ts} +8 -8
- package/{util/GitUtil.js → utils/Git.js} +8 -8
- package/{util → utils}/ObjectVault.d.ts +0 -0
- package/{util → utils}/ObjectVault.js +0 -0
- package/{util/ResticUtil.d.ts → utils/Restic.d.ts} +3 -3
- package/{util/ResticUtil.js → utils/Restic.js} +9 -9
- package/{util/cli-util.d.ts → utils/cli.d.ts} +0 -0
- package/{util/cli-util.js → utils/cli.js} +0 -0
- package/{util/datatruck/config-util.d.ts → utils/datatruck/config.d.ts} +1 -1
- package/{util/datatruck/config-util.js → utils/datatruck/config.js} +10 -10
- package/{util/datatruck/paths-util.d.ts → utils/datatruck/paths.d.ts} +0 -0
- package/{util/datatruck/paths-util.js → utils/datatruck/paths.js} +2 -2
- package/{util/datatruck/snapshot-util.d.ts → utils/datatruck/snapshot.d.ts} +1 -1
- package/{util/datatruck/snapshot-util.js → utils/datatruck/snapshot.js} +4 -4
- package/{util/date-util.d.ts → utils/date.d.ts} +0 -0
- package/{util/date-util.js → utils/date.js} +2 -2
- package/{util/entity-util.d.ts → utils/entity.d.ts} +0 -0
- package/{util/entity-util.js → utils/entity.js} +0 -0
- package/{util/fs-util.d.ts → utils/fs.d.ts} +23 -2
- package/{util/fs-util.js → utils/fs.js} +83 -24
- package/{util/math-util.d.ts → utils/math.d.ts} +0 -0
- package/{util/math-util.js → utils/math.js} +0 -0
- package/{util/object-util.d.ts → utils/object.d.ts} +0 -0
- package/{util/object-util.js → utils/object.js} +0 -0
- package/{util/path-util.d.ts → utils/path.d.ts} +0 -0
- package/{util/path-util.js → utils/path.js} +0 -0
- package/utils/process.d.ts +107 -0
- package/{util/process-util.js → utils/process.js} +168 -28
- package/{util → utils}/progress.d.ts +0 -0
- package/{util → utils}/progress.js +0 -0
- package/{util/string-util.d.ts → utils/string.d.ts} +0 -0
- package/{util/string-util.js → utils/string.js} +0 -0
- package/{util/zip-util.d.ts → utils/zip.d.ts} +0 -0
- package/{util/zip-util.js → utils/zip.js} +5 -5
- package/util/process-util.d.ts +0 -55
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SqlDumpTaskAbstract = exports.sqlDumpTaskDefinition = void 0;
|
|
4
4
|
const AppError_1 = require("../Error/AppError");
|
|
5
5
|
const DefinitionEnum_1 = require("../JsonSchema/DefinitionEnum");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const cli_1 = require("../utils/cli");
|
|
7
|
+
const config_1 = require("../utils/datatruck/config");
|
|
8
|
+
const fs_1 = require("../utils/fs");
|
|
9
|
+
const math_1 = require("../utils/math");
|
|
10
10
|
const TaskAbstract_1 = require("./TaskAbstract");
|
|
11
11
|
const assert_1 = require("assert");
|
|
12
12
|
const promises_1 = require("fs/promises");
|
|
@@ -114,7 +114,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
114
114
|
return true;
|
|
115
115
|
});
|
|
116
116
|
(0, assert_1.ok)(typeof outputPath === "string");
|
|
117
|
-
if (!(await (0,
|
|
117
|
+
if (!(await (0, fs_1.checkDir)(outputPath)))
|
|
118
118
|
await (0, promises_1.mkdir)(outputPath, { recursive: true });
|
|
119
119
|
if (!this.config.oneFileByTable) {
|
|
120
120
|
const outPath = (0, path_1.join)(outputPath, serializeSqlFile({ database: this.config.database }));
|
|
@@ -144,7 +144,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
144
144
|
absolute: {
|
|
145
145
|
total: tableNames.length,
|
|
146
146
|
current: current,
|
|
147
|
-
percent: (0,
|
|
147
|
+
percent: (0, math_1.progressPercent)(tableNames.length, current),
|
|
148
148
|
},
|
|
149
149
|
});
|
|
150
150
|
const outPath = (0, path_1.join)(outputPath, serializeSqlFile({ table: tableName }));
|
|
@@ -159,7 +159,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
159
159
|
absolute: {
|
|
160
160
|
total: tableNames.length,
|
|
161
161
|
current: current,
|
|
162
|
-
percent: (0,
|
|
162
|
+
percent: (0, math_1.progressPercent)(tableNames.length, current),
|
|
163
163
|
},
|
|
164
164
|
});
|
|
165
165
|
});
|
|
@@ -181,7 +181,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
181
181
|
this.verbose = data.options.verbose;
|
|
182
182
|
(0, assert_1.ok)(typeof restorePath === "string");
|
|
183
183
|
const database = {
|
|
184
|
-
name: (0,
|
|
184
|
+
name: (0, config_1.resolveDatabaseName)(this.config.database, {
|
|
185
185
|
packageName: data.package.name,
|
|
186
186
|
snapshotId: data.options.snapshotId,
|
|
187
187
|
snapshotDate: data.snapshot.date,
|
|
@@ -190,7 +190,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
190
190
|
}),
|
|
191
191
|
};
|
|
192
192
|
if (this.config.targetDatabase) {
|
|
193
|
-
database.name = (0,
|
|
193
|
+
database.name = (0, config_1.resolveDatabaseName)(this.config.targetDatabase.name, {
|
|
194
194
|
packageName: data.package.name,
|
|
195
195
|
snapshotId: data.options.snapshotId,
|
|
196
196
|
snapshotDate: data.snapshot.date,
|
|
@@ -198,7 +198,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
198
198
|
database: database.name,
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
const items = (await (0,
|
|
201
|
+
const items = (await (0, fs_1.readDir)(restorePath))
|
|
202
202
|
.map(parseSqlFile)
|
|
203
203
|
.filter((v) => !!v);
|
|
204
204
|
// Database check
|
|
@@ -216,7 +216,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
216
216
|
}
|
|
217
217
|
await this.onCreateDatabase(database);
|
|
218
218
|
if (this.verbose)
|
|
219
|
-
(0,
|
|
219
|
+
(0, cli_1.logExec)("readdir", [restorePath]);
|
|
220
220
|
let current = 0;
|
|
221
221
|
for (const item of items) {
|
|
222
222
|
const path = (0, path_1.join)(restorePath, item.fileName);
|
|
@@ -228,7 +228,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
228
228
|
absolute: {
|
|
229
229
|
total: items.length,
|
|
230
230
|
current: current,
|
|
231
|
-
percent: (0,
|
|
231
|
+
percent: (0, math_1.progressPercent)(items.length, current),
|
|
232
232
|
},
|
|
233
233
|
});
|
|
234
234
|
await this.onImport(path, database.name);
|
package/Task/TaskAbstract.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BackupActionOptionsType } from "../Action/BackupAction";
|
|
|
2
2
|
import { RestoreActionOptionsType } from "../Action/RestoreAction";
|
|
3
3
|
import { PackageConfigType } from "../Config/PackageConfig";
|
|
4
4
|
import { SnapshotType } from "../Repository/RepositoryAbstract";
|
|
5
|
-
import { Progress } from "../
|
|
5
|
+
import { Progress } from "../utils/progress";
|
|
6
6
|
export type BackupDataType = {
|
|
7
7
|
onProgress: (data: Progress) => Promise<void>;
|
|
8
8
|
options: BackupActionOptionsType;
|
package/Task/TaskAbstract.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaskAbstract = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fs_1 = require("../utils/fs");
|
|
5
5
|
class TaskAbstract {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
this.config = config;
|
|
8
8
|
this.tmpDirs = [];
|
|
9
9
|
}
|
|
10
10
|
async mkTmpDir(prefix, id) {
|
|
11
|
-
const dir = await (0,
|
|
11
|
+
const dir = await (0, fs_1.mkTmpDir)(prefix, id);
|
|
12
12
|
this.tmpDirs.push(dir);
|
|
13
13
|
return dir;
|
|
14
14
|
}
|
package/cli.js
CHANGED
|
@@ -8,13 +8,13 @@ const ConfigAction_1 = require("./Action/ConfigAction");
|
|
|
8
8
|
const AppError_1 = require("./Error/AppError");
|
|
9
9
|
const CommandFactory_1 = require("./Factory/CommandFactory");
|
|
10
10
|
const globalData_1 = __importDefault(require("./globalData"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
const cli_1 = require("./utils/cli");
|
|
12
|
+
const fs_1 = require("./utils/fs");
|
|
13
|
+
const process_1 = require("./utils/process");
|
|
14
|
+
const string_1 = require("./utils/string");
|
|
15
15
|
const chalk_1 = require("chalk");
|
|
16
16
|
const commander_1 = require("commander");
|
|
17
|
-
const
|
|
17
|
+
const fs_2 = require("fs");
|
|
18
18
|
const path_1 = require("path");
|
|
19
19
|
function getGlobalOptions() {
|
|
20
20
|
return program.opts();
|
|
@@ -72,7 +72,7 @@ function makeCommandAction(command) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
const program = new commander_1.Command();
|
|
75
|
-
const { version, description } = (0,
|
|
75
|
+
const { version, description } = (0, fs_1.parsePackageFile)();
|
|
76
76
|
const cwd = process.cwd();
|
|
77
77
|
program.name("datatruck");
|
|
78
78
|
program.version(version);
|
|
@@ -94,7 +94,7 @@ makeCommand(CommandFactory_1.CommandEnum.restoreSessions).alias("rs");
|
|
|
94
94
|
makeCommand(CommandFactory_1.CommandEnum.cleanCache).alias("cc");
|
|
95
95
|
function buildArgs(input, options) {
|
|
96
96
|
const optionsArray = Object.keys(options).flatMap((name) => [
|
|
97
|
-
`--${(0,
|
|
97
|
+
`--${(0, string_1.snakeCase)(name, "-")}`,
|
|
98
98
|
options[name],
|
|
99
99
|
]);
|
|
100
100
|
return [input, ...optionsArray];
|
|
@@ -103,16 +103,16 @@ exports.buildArgs = buildArgs;
|
|
|
103
103
|
function parseArgs(args) {
|
|
104
104
|
program.parse(args);
|
|
105
105
|
const verbose = getGlobalOptions().verbose;
|
|
106
|
-
(0,
|
|
106
|
+
(0, process_1.onExit)((eventName, error) => {
|
|
107
107
|
if (eventName !== "exit") {
|
|
108
|
-
process.stdout.write(
|
|
108
|
+
process.stdout.write(cli_1.showCursorCommand);
|
|
109
109
|
console.info(`\nClosing... (reason: ${eventName})`);
|
|
110
110
|
if (error instanceof Error)
|
|
111
111
|
console.error((0, chalk_1.red)(error.stack));
|
|
112
112
|
}
|
|
113
113
|
if (!verbose)
|
|
114
114
|
try {
|
|
115
|
-
(0,
|
|
115
|
+
(0, fs_2.rmSync)((0, fs_1.sessionTmpDir)(), {
|
|
116
116
|
force: true,
|
|
117
117
|
recursive: true,
|
|
118
118
|
maxRetries: 5,
|
package/config.schema.json
CHANGED
|
@@ -798,6 +798,50 @@
|
|
|
798
798
|
},
|
|
799
799
|
"excludeDatabases": {
|
|
800
800
|
"$ref": "#/definitions/stringlist-util"
|
|
801
|
+
},
|
|
802
|
+
"parallel": {
|
|
803
|
+
"anyOf": [
|
|
804
|
+
{
|
|
805
|
+
"type": "integer",
|
|
806
|
+
"minimum": 1
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"enum": [
|
|
810
|
+
"auto"
|
|
811
|
+
]
|
|
812
|
+
}
|
|
813
|
+
]
|
|
814
|
+
},
|
|
815
|
+
"compress": {
|
|
816
|
+
"anyOf": [
|
|
817
|
+
{
|
|
818
|
+
"type": "object",
|
|
819
|
+
"additionalProperties": false,
|
|
820
|
+
"properties": {
|
|
821
|
+
"command": {
|
|
822
|
+
"type": "string"
|
|
823
|
+
},
|
|
824
|
+
"args": {
|
|
825
|
+
"$ref": "#/definitions/stringlist-util"
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"type": "object",
|
|
831
|
+
"additionalProperties": false,
|
|
832
|
+
"properties": {
|
|
833
|
+
"type": {
|
|
834
|
+
"enum": [
|
|
835
|
+
"gzip",
|
|
836
|
+
"pigz"
|
|
837
|
+
]
|
|
838
|
+
},
|
|
839
|
+
"args": {
|
|
840
|
+
"$ref": "#/definitions/stringlist-util"
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
]
|
|
801
845
|
}
|
|
802
846
|
}
|
|
803
847
|
},
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datatruck/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"ajv": "^8.
|
|
5
|
+
"ajv": "^8.12.0",
|
|
6
6
|
"async": "^3.2.4",
|
|
7
7
|
"chalk": "^4.1.2",
|
|
8
8
|
"cli-table3": "^0.6.3",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"optionalDependencies": {
|
|
19
19
|
"ts-node": "^10.9.1",
|
|
20
|
-
"yaml": "^2.2.
|
|
20
|
+
"yaml": "^2.2.1"
|
|
21
21
|
},
|
|
22
22
|
"engine": {
|
|
23
23
|
"node": ">=16.0.0"
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExecSettingsInterface } from "./process
|
|
2
|
-
export declare class
|
|
1
|
+
import { ExecSettingsInterface } from "./process";
|
|
2
|
+
export declare class Git {
|
|
3
3
|
readonly options: {
|
|
4
4
|
dir: string;
|
|
5
5
|
log?: boolean;
|
|
@@ -8,22 +8,22 @@ export declare class GitUtil {
|
|
|
8
8
|
dir: string;
|
|
9
9
|
log?: boolean;
|
|
10
10
|
});
|
|
11
|
-
exec(args: string[], settings?: ExecSettingsInterface, cwd?: boolean): Promise<import("./process
|
|
11
|
+
exec(args: string[], settings?: ExecSettingsInterface, cwd?: boolean): Promise<import("./process").ExecResultType>;
|
|
12
12
|
canBeInit(repo: string): Promise<boolean>;
|
|
13
13
|
clone(options: {
|
|
14
14
|
repo: string;
|
|
15
15
|
branch?: string;
|
|
16
16
|
orphan?: boolean;
|
|
17
|
-
}): Promise<import("./process
|
|
17
|
+
}): Promise<import("./process").ExecResultType>;
|
|
18
18
|
checkout(options: {
|
|
19
19
|
branchName: string;
|
|
20
20
|
orphan?: boolean;
|
|
21
|
-
}): Promise<import("./process
|
|
21
|
+
}): Promise<import("./process").ExecResultType>;
|
|
22
22
|
checkBranch(options: {
|
|
23
23
|
name: string;
|
|
24
24
|
repo?: string;
|
|
25
25
|
}): Promise<boolean>;
|
|
26
|
-
removeAll(): Promise<import("./process
|
|
26
|
+
removeAll(): Promise<import("./process").ExecResultType>;
|
|
27
27
|
haveChanges(): Promise<boolean>;
|
|
28
28
|
fetchCommitId(tag: string): Promise<string>;
|
|
29
29
|
getTags(names?: string[]): Promise<{
|
|
@@ -31,8 +31,8 @@ export declare class GitUtil {
|
|
|
31
31
|
message?: string | undefined;
|
|
32
32
|
}[]>;
|
|
33
33
|
addTag(name: string, message?: string): Promise<void>;
|
|
34
|
-
pushTags(): Promise<import("./process
|
|
34
|
+
pushTags(): Promise<import("./process").ExecResultType>;
|
|
35
35
|
push(options: {
|
|
36
36
|
branchName: string;
|
|
37
|
-
}): Promise<import("./process
|
|
37
|
+
}): Promise<import("./process").ExecResultType>;
|
|
38
38
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
class
|
|
3
|
+
exports.Git = void 0;
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
const process_1 = require("./process");
|
|
6
|
+
class Git {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.options = options;
|
|
9
9
|
}
|
|
10
10
|
async exec(args, settings, cwd) {
|
|
11
|
-
return await (0,
|
|
11
|
+
return await (0, process_1.exec)("git", args, { cwd: cwd === false ? undefined : this.options.dir }, {
|
|
12
12
|
log: this.options.log,
|
|
13
13
|
...(settings ?? {}),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
async canBeInit(repo) {
|
|
17
|
-
return ((0,
|
|
18
|
-
(!(await (0,
|
|
17
|
+
return ((0, fs_1.isLocalDir)(repo) &&
|
|
18
|
+
(!(await (0, fs_1.checkDir)(repo)) || !(await (0, fs_1.readDir)(repo)).length));
|
|
19
19
|
}
|
|
20
20
|
async clone(options) {
|
|
21
21
|
return await this.exec([
|
|
@@ -101,4 +101,4 @@ class GitUtil {
|
|
|
101
101
|
]);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
exports.
|
|
104
|
+
exports.Git = Git;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExecResultType, ExecSettingsInterface } from "./process
|
|
2
|
-
import { UriType } from "./string
|
|
1
|
+
import { ExecResultType, ExecSettingsInterface } from "./process";
|
|
2
|
+
import { UriType } from "./string";
|
|
3
3
|
export type RepositoryType = {
|
|
4
4
|
name?: string;
|
|
5
5
|
env?: Record<string, string>;
|
|
@@ -36,7 +36,7 @@ export type BackupStreamType = {
|
|
|
36
36
|
total_duration: number;
|
|
37
37
|
snapshot_id: string;
|
|
38
38
|
};
|
|
39
|
-
export declare class
|
|
39
|
+
export declare class Restic {
|
|
40
40
|
readonly options: {
|
|
41
41
|
log?: boolean;
|
|
42
42
|
env: Record<string, string>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
exports.Restic = void 0;
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
const process_1 = require("./process");
|
|
6
|
+
const string_1 = require("./string");
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
class
|
|
9
|
+
class Restic {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
@@ -24,10 +24,10 @@ class ResticUtil {
|
|
|
24
24
|
: (await (0, promises_1.readFile)(input.password.path)).toString(),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
return `${input.backend}:${(0,
|
|
27
|
+
return `${input.backend}:${(0, string_1.formatUri)({ ...input, password: input.password }, hidePassword)}`;
|
|
28
28
|
}
|
|
29
29
|
async exec(args, settings, options) {
|
|
30
|
-
return await (0,
|
|
30
|
+
return await (0, process_1.exec)("restic", args, {
|
|
31
31
|
stdio: ["ignore", "pipe", "pipe"],
|
|
32
32
|
env: { ...process.env, ...this.options.env },
|
|
33
33
|
cwd: options?.cwd,
|
|
@@ -185,7 +185,7 @@ class ResticUtil {
|
|
|
185
185
|
const progressInterval = options.progressInterval ?? 30000;
|
|
186
186
|
async function progressRutine() {
|
|
187
187
|
try {
|
|
188
|
-
const total_bytes = await (0,
|
|
188
|
+
const total_bytes = await (0, fs_1.fastFolderSizeAsync)(options.target);
|
|
189
189
|
options.onStream?.({
|
|
190
190
|
message_type: "restore-status",
|
|
191
191
|
total_bytes,
|
|
@@ -219,4 +219,4 @@ class ResticUtil {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
exports.
|
|
222
|
+
exports.Restic = Restic;
|
|
File without changes
|
|
File without changes
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.params = exports.dbNameParams = exports.pkgRestorePathParams = exports.pkgExcludeParams = exports.pkgIncludeParams = exports.pkgPathParams = exports.resolvePackages = exports.resolvePackage = exports.resolveDatabaseName = exports.resolvePackagePath = exports.filterPackages = exports.filterRepository = exports.findRepositoryOrFail = void 0;
|
|
4
4
|
const AppError_1 = require("../../Error/AppError");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const fs_1 = require("../fs");
|
|
6
|
+
const string_1 = require("../string");
|
|
7
7
|
const micromatch_1 = require("micromatch");
|
|
8
8
|
function findRepositoryOrFail(config, repositoryName) {
|
|
9
9
|
const repo = config.repositories.find((v) => v.name === repositoryName);
|
|
@@ -21,8 +21,8 @@ function filterRepository(repository, action) {
|
|
|
21
21
|
}
|
|
22
22
|
exports.filterRepository = filterRepository;
|
|
23
23
|
function filterPackages(config, options) {
|
|
24
|
-
const packagePatterns = (0,
|
|
25
|
-
const taskNamePatterns = (0,
|
|
24
|
+
const packagePatterns = (0, string_1.makePathPatterns)(options.packageNames);
|
|
25
|
+
const taskNamePatterns = (0, string_1.makePathPatterns)(options.packageTaskNames);
|
|
26
26
|
return config.packages
|
|
27
27
|
.map((pkg) => {
|
|
28
28
|
pkg = Object.assign({}, pkg);
|
|
@@ -38,7 +38,7 @@ function filterPackages(config, options) {
|
|
|
38
38
|
return pkg;
|
|
39
39
|
})
|
|
40
40
|
.filter((pkg) => {
|
|
41
|
-
if (taskNamePatterns && !(0,
|
|
41
|
+
if (taskNamePatterns && !(0, string_1.checkMatch)(pkg.task?.name, taskNamePatterns))
|
|
42
42
|
return false;
|
|
43
43
|
return ((typeof pkg.enabled !== "boolean" || pkg.enabled) &&
|
|
44
44
|
!!pkg.repositoryNames?.length &&
|
|
@@ -47,16 +47,16 @@ function filterPackages(config, options) {
|
|
|
47
47
|
}
|
|
48
48
|
exports.filterPackages = filterPackages;
|
|
49
49
|
function resolvePackagePath(value, params) {
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, string_1.render)(value, {
|
|
51
51
|
...params,
|
|
52
52
|
...{
|
|
53
|
-
temp: (0,
|
|
53
|
+
temp: (0, fs_1.tmpDir)("pkg"),
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
exports.resolvePackagePath = resolvePackagePath;
|
|
58
58
|
function resolveDatabaseName(value, params) {
|
|
59
|
-
return (0,
|
|
59
|
+
return (0, string_1.render)(value, params);
|
|
60
60
|
}
|
|
61
61
|
exports.resolveDatabaseName = resolveDatabaseName;
|
|
62
62
|
function resolvePackage(pkg, params) {
|
|
@@ -67,9 +67,9 @@ function resolvePackage(pkg, params) {
|
|
|
67
67
|
path: undefined,
|
|
68
68
|
};
|
|
69
69
|
if (pkg.include)
|
|
70
|
-
pkg.include = pkg.include.map((v) => typeof v === "string" ? (0,
|
|
70
|
+
pkg.include = pkg.include.map((v) => typeof v === "string" ? (0, string_1.render)(v, pkgParams) : v);
|
|
71
71
|
if (pkg.exclude)
|
|
72
|
-
pkg.exclude = pkg.exclude.map((v) => typeof v === "string" ? (0,
|
|
72
|
+
pkg.exclude = pkg.exclude.map((v) => typeof v === "string" ? (0, string_1.render)(v, pkgParams) : v);
|
|
73
73
|
if (pkg.path)
|
|
74
74
|
pkg.path = resolvePackagePath(pkg.path, pkgParams);
|
|
75
75
|
if (pkg.restorePath)
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parsePaths = void 0;
|
|
4
|
-
const
|
|
4
|
+
const process_1 = require("../process");
|
|
5
5
|
async function parsePaths(values, options) {
|
|
6
6
|
let paths = [];
|
|
7
7
|
for (const value of values) {
|
|
@@ -9,7 +9,7 @@ async function parsePaths(values, options) {
|
|
|
9
9
|
paths.push(value);
|
|
10
10
|
}
|
|
11
11
|
else if (value.type === "spawn") {
|
|
12
|
-
const spawnResult = await (0,
|
|
12
|
+
const spawnResult = await (0, process_1.exec)(value.command, value.args, { cwd: options.cwd }, { log: options.verbose, stderr: { save: true }, stdout: { save: true } });
|
|
13
13
|
const spawnFiles = [spawnResult.stderr, spawnResult.stdout].flatMap((text) => text
|
|
14
14
|
.split(/\r?\n/)
|
|
15
15
|
.map((v) => v.trim())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SnapshotGroupByType } from "../../Action/SnapshotsAction";
|
|
2
2
|
import { SnapshotResultType } from "../../Repository/RepositoryAbstract";
|
|
3
|
-
import { FilterByLastOptionsType } from "../date
|
|
3
|
+
import { FilterByLastOptionsType } from "../date";
|
|
4
4
|
export declare function groupAndFilter<TSnapshot extends SnapshotResultType>(snapshots: TSnapshot[], groupByKey?: SnapshotGroupByType[], filter?: FilterByLastOptionsType | ((groupedSnapshots: TSnapshot[]) => FilterByLastOptionsType), reasons?: Record<number, string[]>): TSnapshot[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.groupAndFilter = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const date_1 = require("../date");
|
|
5
|
+
const object_1 = require("../object");
|
|
6
6
|
function groupAndFilter(snapshots, groupByKey, filter, reasons) {
|
|
7
7
|
const grouped = groupByKey?.length
|
|
8
|
-
? (0,
|
|
8
|
+
? (0, object_1.groupBy)(snapshots, groupByKey)
|
|
9
9
|
: { "": snapshots };
|
|
10
10
|
const result = [];
|
|
11
11
|
for (const key in grouped) {
|
|
@@ -13,7 +13,7 @@ function groupAndFilter(snapshots, groupByKey, filter, reasons) {
|
|
|
13
13
|
const groupReasons = reasons
|
|
14
14
|
? {}
|
|
15
15
|
: undefined;
|
|
16
|
-
result.push(...(0,
|
|
16
|
+
result.push(...(0, date_1.filterByLast)(grouped[key], typeof filter === "function" ? filter(grouped[key]) : filter, groupReasons));
|
|
17
17
|
if (groupReasons && reasons) {
|
|
18
18
|
for (const groupItemIndex in groupReasons) {
|
|
19
19
|
const snapshot = grouped[key][groupItemIndex];
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createChron = exports.filterByLast = void 0;
|
|
7
|
-
const
|
|
7
|
+
const string_1 = require("./string");
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
|
|
10
10
|
const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
|
|
@@ -82,7 +82,7 @@ function createChron() {
|
|
|
82
82
|
throw new Error(`Chron was not started`);
|
|
83
83
|
const seconds = (Date.now() - startTime) / 1000;
|
|
84
84
|
if (formatted)
|
|
85
|
-
return (0,
|
|
85
|
+
return (0, string_1.formatSeconds)(seconds);
|
|
86
86
|
return seconds;
|
|
87
87
|
},
|
|
88
88
|
};
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
|
-
import {
|
|
5
|
+
import { Progress } from "./progress";
|
|
6
|
+
import { Entry, Options } from "fast-glob";
|
|
7
|
+
import { Dirent, ReadStream, Stats } from "fs";
|
|
6
8
|
import { WriteStream } from "fs";
|
|
7
9
|
import { Interface } from "readline";
|
|
8
10
|
export declare const isWSLSystem: boolean;
|
|
@@ -51,7 +53,7 @@ export declare function writeGitIgnoreList(options: {
|
|
|
51
53
|
paths: NodeJS.ReadableStream | string[];
|
|
52
54
|
outDir: string;
|
|
53
55
|
}): Promise<string>;
|
|
54
|
-
export declare function waitForClose(stream: WriteStream): Promise<
|
|
56
|
+
export declare function waitForClose(stream: WriteStream | ReadStream): Promise<void>;
|
|
55
57
|
export declare function copyFileWithStreams(source: string, target: string): Promise<unknown>;
|
|
56
58
|
export declare function updateFileStats(path: string, fileInfo: Stats): Promise<void>;
|
|
57
59
|
export declare function isNotFoundError(error: unknown): boolean;
|
|
@@ -97,4 +99,23 @@ export declare function cpy(options: {
|
|
|
97
99
|
files: number;
|
|
98
100
|
dirs: number;
|
|
99
101
|
}>;
|
|
102
|
+
export declare function createFileScanner(options: {
|
|
103
|
+
glob: Options & {
|
|
104
|
+
include: string[];
|
|
105
|
+
};
|
|
106
|
+
onProgress: (data: Progress) => Promise<void>;
|
|
107
|
+
disableCounting?: boolean;
|
|
108
|
+
disableEndProgress?: boolean;
|
|
109
|
+
}): Promise<{
|
|
110
|
+
total: number;
|
|
111
|
+
current: number;
|
|
112
|
+
progress: (description: string, data: {
|
|
113
|
+
path?: string;
|
|
114
|
+
current: number;
|
|
115
|
+
type?: "start" | "end";
|
|
116
|
+
percent?: number;
|
|
117
|
+
}) => Promise<void>;
|
|
118
|
+
updateProgress: (end?: boolean) => Promise<void>;
|
|
119
|
+
start: (cb?: ((entry: Required<Entry>) => any) | undefined) => Promise<void>;
|
|
120
|
+
}>;
|
|
100
121
|
export {};
|