@datatruck/cli 0.17.1 → 0.17.2
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 -1
- package/Repository/DatatruckRepository.js +56 -52
- 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.js +11 -11
- 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/package.json +1 -1
- 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} +0 -0
- 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} +0 -0
- package/{util/fs-util.js → utils/fs.js} +17 -17
- 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/{util/process-util.d.ts → utils/process.d.ts} +0 -0
- package/{util/process-util.js → utils/process.js} +13 -13
- 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/Action/BackupAction.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { AppError } from "../Error/AppError";
|
|
|
5
5
|
import { SnapshotType } from "../Repository/RepositoryAbstract";
|
|
6
6
|
import { BackupSessionManager } from "../SessionManager/BackupSessionManager";
|
|
7
7
|
import { TaskAbstract } from "../Task/TaskAbstract";
|
|
8
|
-
import { IfRequireKeys } from "../
|
|
8
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
9
9
|
export type BackupActionOptionsType = {
|
|
10
10
|
repositoryNames?: string[];
|
|
11
11
|
repositoryTypes?: string[];
|
package/Action/BackupAction.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.BackupAction = void 0;
|
|
|
4
4
|
const AppError_1 = require("../Error/AppError");
|
|
5
5
|
const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
|
|
6
6
|
const TaskFactory_1 = require("../Factory/TaskFactory");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const config_1 = require("../utils/datatruck/config");
|
|
8
|
+
const fs_1 = require("../utils/fs");
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
10
10
|
class BackupAction {
|
|
11
11
|
constructor(config, options = {}) {
|
|
@@ -20,14 +20,14 @@ class BackupAction {
|
|
|
20
20
|
date: this.options.date ?? new Date().toISOString(),
|
|
21
21
|
};
|
|
22
22
|
await session.initDrivers();
|
|
23
|
-
let packages = (0,
|
|
23
|
+
let packages = (0, config_1.filterPackages)(this.config, {
|
|
24
24
|
packageNames: this.options.packageNames,
|
|
25
25
|
packageTaskNames: this.options.packageTaskNames,
|
|
26
26
|
repositoryNames: this.options.repositoryNames,
|
|
27
27
|
repositoryTypes: this.options.repositoryTypes,
|
|
28
28
|
sourceAction: "backup",
|
|
29
29
|
});
|
|
30
|
-
packages = (0,
|
|
30
|
+
packages = (0, config_1.resolvePackages)(packages, {
|
|
31
31
|
snapshotId: snapshot.id,
|
|
32
32
|
snapshotDate: snapshot.date,
|
|
33
33
|
action: "backup",
|
|
@@ -44,7 +44,7 @@ class BackupAction {
|
|
|
44
44
|
taskName: pkg.task.name,
|
|
45
45
|
});
|
|
46
46
|
for (const repositoryName of pkg.repositoryNames ?? []) {
|
|
47
|
-
const repo = (0,
|
|
47
|
+
const repo = (0, config_1.findRepositoryOrFail)(this.config, repositoryName);
|
|
48
48
|
await session.initRepository({
|
|
49
49
|
sessionId: sessionId,
|
|
50
50
|
repositoryName: repositoryName,
|
|
@@ -208,7 +208,7 @@ class BackupAction {
|
|
|
208
208
|
const allMirrorRepoNames = [];
|
|
209
209
|
const repoNames = repositoryNames ?? [];
|
|
210
210
|
for (const repoName of repoNames) {
|
|
211
|
-
const repo = (0,
|
|
211
|
+
const repo = (0, config_1.findRepositoryOrFail)(this.config, repoName);
|
|
212
212
|
if (repo.mirrorRepoNames)
|
|
213
213
|
mirrorRepoMap[repoName] = repo.mirrorRepoNames.filter((mirrorRepoName) => {
|
|
214
214
|
allMirrorRepoNames.push(mirrorRepoName);
|
|
@@ -250,23 +250,23 @@ class BackupAction {
|
|
|
250
250
|
}
|
|
251
251
|
const { repoNames, mirrors } = this.splitRepositories(pkg.repositoryNames ?? []);
|
|
252
252
|
for (const repoName of repoNames) {
|
|
253
|
-
const repo = (0,
|
|
253
|
+
const repo = (0, config_1.findRepositoryOrFail)(this.config, repoName);
|
|
254
254
|
const { tmpDirs } = await this.backup(session, pkg, repo, snapshot, targetPath);
|
|
255
255
|
if (!this.options.verbose)
|
|
256
|
-
await (0,
|
|
256
|
+
await (0, fs_1.rmTmpDir)(tmpDirs);
|
|
257
257
|
}
|
|
258
258
|
if (!this.options.verbose) {
|
|
259
|
-
await (0,
|
|
260
|
-
if (pkg.path && (0,
|
|
261
|
-
await (0,
|
|
259
|
+
await (0, fs_1.rmTmpDir)(taskTmpDirs);
|
|
260
|
+
if (pkg.path && (0, fs_1.isTmpDir)(pkg.path)) {
|
|
261
|
+
await (0, fs_1.rmTmpDir)(pkg.path);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
for (const mirror of mirrors) {
|
|
265
|
-
const repo = (0,
|
|
266
|
-
const mirrorRepo = (0,
|
|
265
|
+
const repo = (0, config_1.findRepositoryOrFail)(this.config, mirror.sourceName);
|
|
266
|
+
const mirrorRepo = (0, config_1.findRepositoryOrFail)(this.config, mirror.name);
|
|
267
267
|
const { tmpDirs } = await this.copyBackup(session, pkg, repo, mirrorRepo, snapshot);
|
|
268
268
|
if (!this.options.verbose)
|
|
269
|
-
await (0,
|
|
269
|
+
await (0, fs_1.rmTmpDir)(tmpDirs);
|
|
270
270
|
}
|
|
271
271
|
const error = this.getError(pkg);
|
|
272
272
|
if (error)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { ReadDataType } from "../SessionDriver/SessionDriverAbstract";
|
|
3
3
|
import { BackupSessionManager } from "../SessionManager/BackupSessionManager";
|
|
4
|
-
import { IfRequireKeys } from "../
|
|
4
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
5
5
|
export type BackupSessionsActionOptionsType = ReadDataType & {
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CleanCacheAction = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fs_1 = require("../utils/fs");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
class CleanCacheAction {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.options = options;
|
|
9
9
|
}
|
|
10
10
|
async exec() {
|
|
11
|
-
const path = (0,
|
|
12
|
-
if (await (0,
|
|
11
|
+
const path = (0, fs_1.parentTmpDir)();
|
|
12
|
+
if (await (0, fs_1.existsDir)(path))
|
|
13
13
|
await (0, promises_1.rm)(path, {
|
|
14
14
|
recursive: true,
|
|
15
15
|
});
|
package/Action/ConfigAction.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GlobalOptionsType } from "../Command/CommandAbstract";
|
|
2
2
|
import type { ConfigType } from "../Config/Config";
|
|
3
|
-
import { IfRequireKeys } from "../
|
|
3
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
4
4
|
export type ConfigActionOptionsType = {
|
|
5
5
|
path: string;
|
|
6
6
|
verbose?: boolean;
|
package/Action/ConfigAction.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ConfigAction = void 0;
|
|
7
7
|
const AppError_1 = require("../Error/AppError");
|
|
8
8
|
const JsonSchema_1 = require("../JsonSchema/JsonSchema");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const config_1 = require("../utils/datatruck/config");
|
|
10
|
+
const fs_1 = require("../utils/fs");
|
|
11
11
|
const ajv_1 = __importDefault(require("ajv"));
|
|
12
12
|
const assert_1 = require("assert");
|
|
13
13
|
const path_1 = require("path");
|
|
@@ -64,7 +64,7 @@ class ConfigAction {
|
|
|
64
64
|
pkg.repositoryNames ?? config.repositories.map((repo) => repo.name);
|
|
65
65
|
(0, assert_1.ok)(Array.isArray(pkg.repositoryNames));
|
|
66
66
|
for (const repoName of pkg.repositoryNames)
|
|
67
|
-
(0,
|
|
67
|
+
(0, config_1.findRepositoryOrFail)(config, repoName);
|
|
68
68
|
return pkg;
|
|
69
69
|
});
|
|
70
70
|
return config;
|
|
@@ -83,8 +83,8 @@ class ConfigAction {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
async exec() {
|
|
86
|
-
const path = await (0,
|
|
87
|
-
const config = await (0,
|
|
86
|
+
const path = await (0, fs_1.findFile)(this.options.path, "datatruck.config", fs_1.parseFileExtensions, "Config path not found");
|
|
87
|
+
const config = await (0, fs_1.parseFile)(path, "config");
|
|
88
88
|
ConfigAction.validate(config);
|
|
89
89
|
ConfigAction.check(config);
|
|
90
90
|
return {
|
package/Action/InitAction.d.ts
CHANGED
package/Action/InitAction.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InitAction = void 0;
|
|
4
4
|
const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
|
|
5
|
-
const
|
|
5
|
+
const config_1 = require("../utils/datatruck/config");
|
|
6
6
|
class InitAction {
|
|
7
7
|
constructor(config, options) {
|
|
8
8
|
this.config = config;
|
|
@@ -11,7 +11,7 @@ class InitAction {
|
|
|
11
11
|
async exec() {
|
|
12
12
|
const result = [];
|
|
13
13
|
for (const repo of this.config.repositories) {
|
|
14
|
-
if (!(0,
|
|
14
|
+
if (!(0, config_1.filterRepository)(repo, "init"))
|
|
15
15
|
continue;
|
|
16
16
|
if (this.options.repositoryNames &&
|
|
17
17
|
!this.options.repositoryNames.includes(repo.name))
|
package/Action/PruneAction.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
|
-
import { IfRequireKeys } from "../
|
|
3
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
4
4
|
import { SnapshotExtendedType, SnapshotsActionOptionsType } from "./SnapshotsAction";
|
|
5
5
|
export type PruneActionsOptionsType = {
|
|
6
6
|
ids?: string[];
|
package/Action/PruneAction.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PruneAction = void 0;
|
|
4
4
|
const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const snapshot_1 = require("../utils/datatruck/snapshot");
|
|
6
|
+
const object_1 = require("../utils/object");
|
|
7
7
|
const SnapshotsAction_1 = require("./SnapshotsAction");
|
|
8
8
|
class PruneAction {
|
|
9
9
|
constructor(config, options) {
|
|
@@ -11,7 +11,7 @@ class PruneAction {
|
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
13
|
async confirm(snapshots) {
|
|
14
|
-
const repository = (0,
|
|
14
|
+
const repository = (0, object_1.groupBy)(this.config.repositories, "name", true);
|
|
15
15
|
for (const snapshot of snapshots) {
|
|
16
16
|
if (!snapshot.exclusionReasons?.length) {
|
|
17
17
|
const repoInstance = (0, RepositoryFactory_1.RepositoryFactory)(repository[snapshot.repositoryName]);
|
|
@@ -38,7 +38,7 @@ class PruneAction {
|
|
|
38
38
|
};
|
|
39
39
|
const hasInputFilter = Object.values(inputFilter).some(Number);
|
|
40
40
|
const usePrunePolicyConfig = !hasInputFilter && this.options.groupBy?.includes("packageName");
|
|
41
|
-
const keepSnapshots = (0,
|
|
41
|
+
const keepSnapshots = (0, snapshot_1.groupAndFilter)(snapshots, this.options.groupBy, usePrunePolicyConfig
|
|
42
42
|
? (groupedSnapshots) => {
|
|
43
43
|
const [firstSnapshot] = groupedSnapshots;
|
|
44
44
|
const packageName = firstSnapshot.packageName;
|
|
@@ -5,7 +5,7 @@ import { AppError } from "../Error/AppError";
|
|
|
5
5
|
import { SnapshotResultType } from "../Repository/RepositoryAbstract";
|
|
6
6
|
import { RestoreSessionManager } from "../SessionManager/RestoreSessionManager";
|
|
7
7
|
import { TaskAbstract } from "../Task/TaskAbstract";
|
|
8
|
-
import { IfRequireKeys } from "../
|
|
8
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
9
9
|
export type RestoreActionOptionsType = {
|
|
10
10
|
snapshotId: string;
|
|
11
11
|
tags?: string[];
|
package/Action/RestoreAction.js
CHANGED
|
@@ -4,11 +4,11 @@ exports.RestoreAction = void 0;
|
|
|
4
4
|
const AppError_1 = require("../Error/AppError");
|
|
5
5
|
const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
|
|
6
6
|
const TaskFactory_1 = require("../Factory/TaskFactory");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
7
|
+
const cli_1 = require("../utils/cli");
|
|
8
|
+
const config_1 = require("../utils/datatruck/config");
|
|
9
|
+
const fs_1 = require("../utils/fs");
|
|
10
|
+
const object_1 = require("../utils/object");
|
|
11
|
+
const process_1 = require("../utils/process");
|
|
12
12
|
const SnapshotsAction_1 = require("./SnapshotsAction");
|
|
13
13
|
const assert_1 = require("assert");
|
|
14
14
|
const os_1 = require("os");
|
|
@@ -40,7 +40,7 @@ class RestoreAction {
|
|
|
40
40
|
taskName: pkg.task.name,
|
|
41
41
|
});
|
|
42
42
|
for (const repositoryName of pkg.repositoryNames ?? []) {
|
|
43
|
-
const repo = (0,
|
|
43
|
+
const repo = (0, config_1.findRepositoryOrFail)(this.config, repositoryName);
|
|
44
44
|
await session.initRepository({
|
|
45
45
|
sessionId: sessionId,
|
|
46
46
|
repositoryName: repositoryName,
|
|
@@ -146,11 +146,11 @@ class RestoreAction {
|
|
|
146
146
|
try {
|
|
147
147
|
if (typeof pkg.restorePath !== "string")
|
|
148
148
|
throw new AppError_1.AppError("Restore path is not defined");
|
|
149
|
-
await (0,
|
|
150
|
-
if (!(await (0,
|
|
149
|
+
await (0, fs_1.mkdirIfNotExists)(pkg.restorePath);
|
|
150
|
+
if (!(await (0, fs_1.isDirEmpty)(pkg.restorePath)))
|
|
151
151
|
throw new AppError_1.AppError(`Restore path is not empty: ${pkg.restorePath}`);
|
|
152
152
|
if (this.options.verbose)
|
|
153
|
-
(0,
|
|
153
|
+
(0, cli_1.logExec)(`restorePath=${pkg.restorePath}`);
|
|
154
154
|
repoInstance = (0, RepositoryFactory_1.RepositoryFactory)(repo);
|
|
155
155
|
await repoInstance.onRestore({
|
|
156
156
|
package: pkg,
|
|
@@ -167,7 +167,7 @@ class RestoreAction {
|
|
|
167
167
|
},
|
|
168
168
|
});
|
|
169
169
|
if (pkg.restorePermissions && (0, os_1.platform)() !== "win32")
|
|
170
|
-
await (0,
|
|
170
|
+
await (0, process_1.exec)("chown", [
|
|
171
171
|
"-R",
|
|
172
172
|
`${pkg.restorePermissions.uid}:${pkg.restorePermissions.gid}`,
|
|
173
173
|
pkg.restorePath,
|
|
@@ -176,7 +176,7 @@ class RestoreAction {
|
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
catch (error) {
|
|
179
|
-
(0,
|
|
179
|
+
(0, object_1.push)(this.repoErrors, pkg.name, (repoError = error));
|
|
180
180
|
}
|
|
181
181
|
await session.endRepository({
|
|
182
182
|
id: repositoryId,
|
|
@@ -209,11 +209,11 @@ class RestoreAction {
|
|
|
209
209
|
const snapshots = this.groupSnapshots(await this.findSnapshots());
|
|
210
210
|
if (!snapshots.length)
|
|
211
211
|
throw new AppError_1.AppError("None snapshot found");
|
|
212
|
-
let packages = (0,
|
|
212
|
+
let packages = (0, config_1.filterPackages)(this.config, {
|
|
213
213
|
...this.options,
|
|
214
214
|
sourceAction: "restore",
|
|
215
215
|
});
|
|
216
|
-
packages = (0,
|
|
216
|
+
packages = (0, config_1.resolvePackages)(packages, {
|
|
217
217
|
snapshotId: this.options.snapshotId,
|
|
218
218
|
snapshotDate: snapshots[0].date,
|
|
219
219
|
action: "restore",
|
|
@@ -223,7 +223,7 @@ class RestoreAction {
|
|
|
223
223
|
let sessionErrors = 0;
|
|
224
224
|
for (const [snapshot, pkg] of snapshotAndConfigs) {
|
|
225
225
|
(0, assert_1.ok)(pkg);
|
|
226
|
-
const repo = (0,
|
|
226
|
+
const repo = (0, config_1.findRepositoryOrFail)(this.config, snapshot.repositoryName);
|
|
227
227
|
const id = session.findId({
|
|
228
228
|
packageName: pkg.name,
|
|
229
229
|
});
|
|
@@ -244,10 +244,10 @@ class RestoreAction {
|
|
|
244
244
|
await this.task(session, pkg, taskInstance, snapshot, targetPath);
|
|
245
245
|
}
|
|
246
246
|
if (!this.options.verbose) {
|
|
247
|
-
await (0,
|
|
248
|
-
await (0,
|
|
249
|
-
if (pkg.restorePath && (0,
|
|
250
|
-
await (0,
|
|
247
|
+
await (0, fs_1.rmTmpDir)(taskInstance?.tmpDirs || []);
|
|
248
|
+
await (0, fs_1.rmTmpDir)(tmpDirs);
|
|
249
|
+
if (pkg.restorePath && (0, fs_1.isTmpDir)(pkg.restorePath))
|
|
250
|
+
await (0, fs_1.rmTmpDir)(pkg.restorePath);
|
|
251
251
|
}
|
|
252
252
|
const error = this.getError(pkg);
|
|
253
253
|
await session.end({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { ReadDataType } from "../SessionDriver/SessionDriverAbstract";
|
|
3
3
|
import { RestoreSessionManager } from "../SessionManager/RestoreSessionManager";
|
|
4
|
-
import { IfRequireKeys } from "../
|
|
4
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
5
5
|
export type RestoreSessionsActionOptionsType = ReadDataType & {
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigType } from "../Config/Config";
|
|
2
2
|
import { RepositoryConfigEnabledActionType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { SnapshotResultType } from "../Repository/RepositoryAbstract";
|
|
4
|
-
import { IfRequireKeys } from "../
|
|
4
|
+
import { IfRequireKeys } from "../utils/ts";
|
|
5
5
|
export type SnapshotGroupByType = keyof Pick<SnapshotExtendedType, "packageName" | "repositoryName" | "repositoryType">;
|
|
6
6
|
export type SnapshotsActionOptionsType = {
|
|
7
7
|
ids?: string[];
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SnapshotsAction = void 0;
|
|
4
4
|
const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const config_1 = require("../utils/datatruck/config");
|
|
6
|
+
const snapshot_1 = require("../utils/datatruck/snapshot");
|
|
7
7
|
class SnapshotsAction {
|
|
8
8
|
constructor(config, options) {
|
|
9
9
|
this.config = config;
|
|
@@ -14,7 +14,7 @@ class SnapshotsAction {
|
|
|
14
14
|
sourceAction = "snapshots";
|
|
15
15
|
let result = [];
|
|
16
16
|
for (const repo of this.config.repositories) {
|
|
17
|
-
if (!(0,
|
|
17
|
+
if (!(0, config_1.filterRepository)(repo, sourceAction))
|
|
18
18
|
continue;
|
|
19
19
|
if (this.options.repositoryNames &&
|
|
20
20
|
!this.options.repositoryNames.includes(repo.name))
|
|
@@ -42,7 +42,7 @@ class SnapshotsAction {
|
|
|
42
42
|
result.push(...extentedItems);
|
|
43
43
|
}
|
|
44
44
|
result = result.sort((a, b) => b.date.localeCompare(a.date));
|
|
45
|
-
return (0,
|
|
45
|
+
return (0, snapshot_1.groupAndFilter)(result, this.options.groupBy, this.options);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
exports.SnapshotsAction = SnapshotsAction;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
|
-
import { If } from "../
|
|
2
|
+
import { If } from "../utils/ts";
|
|
3
3
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
4
|
export type BackupCommandOptionsType<TResolved = false> = {
|
|
5
5
|
package?: If<TResolved, string[]>;
|
|
@@ -11,6 +11,6 @@ export type BackupCommandOptionsType<TResolved = false> = {
|
|
|
11
11
|
date?: string;
|
|
12
12
|
};
|
|
13
13
|
export declare class BackupCommand extends CommandAbstract<BackupCommandOptionsType<false>, BackupCommandOptionsType<true>> {
|
|
14
|
-
onOptions(): import("../
|
|
14
|
+
onOptions(): import("../utils/cli").OptionsType<BackupCommandOptionsType<false>, BackupCommandOptionsType<true>>;
|
|
15
15
|
onExec(): Promise<0 | 1>;
|
|
16
16
|
}
|
package/Command/BackupCommand.js
CHANGED
|
@@ -7,7 +7,7 @@ const AppError_1 = require("../Error/AppError");
|
|
|
7
7
|
const ConsoleSessionDriver_1 = require("../SessionDriver/ConsoleSessionDriver");
|
|
8
8
|
const SqliteSessionDriver_1 = require("../SessionDriver/SqliteSessionDriver");
|
|
9
9
|
const BackupSessionManager_1 = require("../SessionManager/BackupSessionManager");
|
|
10
|
-
const
|
|
10
|
+
const string_1 = require("../utils/string");
|
|
11
11
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
12
12
|
class BackupCommand extends CommandAbstract_1.CommandAbstract {
|
|
13
13
|
onOptions() {
|
|
@@ -19,27 +19,27 @@ class BackupCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
19
19
|
package: {
|
|
20
20
|
description: "Filter by package names",
|
|
21
21
|
option: "-p,--package <values>",
|
|
22
|
-
parser:
|
|
22
|
+
parser: string_1.parseStringList,
|
|
23
23
|
},
|
|
24
24
|
packageTask: {
|
|
25
25
|
description: "Filter by package task names",
|
|
26
26
|
option: "-pt,--package-task <values>",
|
|
27
|
-
parser:
|
|
27
|
+
parser: string_1.parseStringList,
|
|
28
28
|
},
|
|
29
29
|
repository: {
|
|
30
30
|
description: "Filter by repository names",
|
|
31
31
|
option: "-r,--repository <values>",
|
|
32
|
-
parser:
|
|
32
|
+
parser: string_1.parseStringList,
|
|
33
33
|
},
|
|
34
34
|
repositoryType: {
|
|
35
35
|
description: "Filter by repository types",
|
|
36
36
|
option: "-rt,--repository-type <values>",
|
|
37
|
-
parser: (v) => (0,
|
|
37
|
+
parser: (v) => (0, string_1.parseStringList)(v),
|
|
38
38
|
},
|
|
39
39
|
tag: {
|
|
40
40
|
description: "Filter by tags",
|
|
41
41
|
option: "-t,--tag <values>",
|
|
42
|
-
parser:
|
|
42
|
+
parser: string_1.parseStringList,
|
|
43
43
|
},
|
|
44
44
|
date: {
|
|
45
45
|
description: "Date time (ISO)",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { If } from "../
|
|
1
|
+
import { If } from "../utils/ts";
|
|
2
2
|
import { CommandAbstract } from "./CommandAbstract";
|
|
3
3
|
export type BackupSessionsCommandOptionsType<TResolved = false> = {
|
|
4
4
|
package?: If<TResolved, string[]>;
|
|
@@ -7,6 +7,6 @@ export type BackupSessionsCommandOptionsType<TResolved = false> = {
|
|
|
7
7
|
limit?: number;
|
|
8
8
|
};
|
|
9
9
|
export declare class BackupSessionsCommand extends CommandAbstract<BackupSessionsCommandOptionsType<false>, BackupSessionsCommandOptionsType<true>> {
|
|
10
|
-
onOptions(): import("../
|
|
10
|
+
onOptions(): import("../utils/cli").OptionsType<BackupSessionsCommandOptionsType<false>, BackupSessionsCommandOptionsType<true>>;
|
|
11
11
|
onExec(): Promise<number>;
|
|
12
12
|
}
|
|
@@ -5,9 +5,9 @@ const BackupSessionsAction_1 = require("../Action/BackupSessionsAction");
|
|
|
5
5
|
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
6
6
|
const SqliteSessionDriver_1 = require("../SessionDriver/SqliteSessionDriver");
|
|
7
7
|
const BackupSessionManager_1 = require("../SessionManager/BackupSessionManager");
|
|
8
|
-
const DataFormat_1 = require("../
|
|
9
|
-
const
|
|
10
|
-
const
|
|
8
|
+
const DataFormat_1 = require("../utils/DataFormat");
|
|
9
|
+
const cli_1 = require("../utils/cli");
|
|
10
|
+
const string_1 = require("../utils/string");
|
|
11
11
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
12
12
|
class BackupSessionsCommand extends CommandAbstract_1.CommandAbstract {
|
|
13
13
|
onOptions() {
|
|
@@ -15,17 +15,17 @@ class BackupSessionsCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
15
15
|
package: {
|
|
16
16
|
description: "Filter by package names",
|
|
17
17
|
option: "-p,--package <values>",
|
|
18
|
-
parser:
|
|
18
|
+
parser: string_1.parseStringList,
|
|
19
19
|
},
|
|
20
20
|
repository: {
|
|
21
21
|
description: "Filter by repository names",
|
|
22
22
|
option: "-r,--repository <values>",
|
|
23
|
-
parser:
|
|
23
|
+
parser: string_1.parseStringList,
|
|
24
24
|
},
|
|
25
25
|
tag: {
|
|
26
26
|
description: "Filter by tags",
|
|
27
27
|
option: "-t,--tag <values>",
|
|
28
|
-
parser:
|
|
28
|
+
parser: string_1.parseStringList,
|
|
29
29
|
},
|
|
30
30
|
limit: {
|
|
31
31
|
description: "Limit",
|
|
@@ -67,14 +67,14 @@ class BackupSessionsCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
67
67
|
"",
|
|
68
68
|
],
|
|
69
69
|
handler: (item) => [
|
|
70
|
-
(0,
|
|
70
|
+
(0, cli_1.resultColumn)(item.error, item.state),
|
|
71
71
|
item.id,
|
|
72
72
|
item.snapshotId.slice(0, 8),
|
|
73
|
-
(0,
|
|
73
|
+
(0, string_1.formatDateTime)(item.creationDate),
|
|
74
74
|
item.repositoryName,
|
|
75
75
|
item.repositoryType,
|
|
76
76
|
item.packageName,
|
|
77
|
-
(0,
|
|
77
|
+
(0, cli_1.errorColumn)(item.error, verbose),
|
|
78
78
|
],
|
|
79
79
|
},
|
|
80
80
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandAbstract } from "./CommandAbstract";
|
|
2
2
|
export type CleanCacheCommandOptionsType<TResolved = false> = {};
|
|
3
3
|
export declare class CleanCacheCommand extends CommandAbstract<CleanCacheCommandOptionsType<false>, CleanCacheCommandOptionsType<true>> {
|
|
4
|
-
onOptions(): import("../
|
|
4
|
+
onOptions(): import("../utils/cli").OptionsType<CleanCacheCommandOptionsType<false>, CleanCacheCommandOptionsType<true>>;
|
|
5
5
|
onExec(): Promise<number>;
|
|
6
6
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CleanCacheCommand = void 0;
|
|
4
4
|
const CleanCacheAction_1 = require("../Action/CleanCacheAction");
|
|
5
|
-
const
|
|
5
|
+
const fs_1 = require("../utils/fs");
|
|
6
6
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
7
7
|
class CleanCacheCommand extends CommandAbstract_1.CommandAbstract {
|
|
8
8
|
onOptions() {
|
|
@@ -12,7 +12,7 @@ class CleanCacheCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
12
12
|
const action = new CleanCacheAction_1.CleanCacheAction({
|
|
13
13
|
verbose: !!this.globalOptions.verbose,
|
|
14
14
|
});
|
|
15
|
-
console.info(`Cleaning ${(0,
|
|
15
|
+
console.info(`Cleaning ${(0, fs_1.parentTmpDir)()}...`);
|
|
16
16
|
await action.exec();
|
|
17
17
|
return 0;
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigType } from "../Config/Config";
|
|
2
|
-
import { FormatType } from "../
|
|
3
|
-
import { OptionsType } from "../
|
|
4
|
-
import { SimilarObject } from "../
|
|
2
|
+
import { FormatType } from "../utils/DataFormat";
|
|
3
|
+
import { OptionsType } from "../utils/cli";
|
|
4
|
+
import { SimilarObject } from "../utils/ts";
|
|
5
5
|
export type GlobalOptionsType<TResolved = false> = {
|
|
6
6
|
config: string | ConfigType;
|
|
7
7
|
outputFormat?: FormatType;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandAbstract = void 0;
|
|
4
|
-
const
|
|
4
|
+
const cli_1 = require("../utils/cli");
|
|
5
5
|
class CommandAbstract {
|
|
6
6
|
constructor(globalOptions, options) {
|
|
7
7
|
this.globalOptions = globalOptions;
|
|
8
|
-
this.options = (0,
|
|
8
|
+
this.options = (0, cli_1.parseOptions)(options, this.onOptions());
|
|
9
9
|
}
|
|
10
10
|
returnsOptions(options) {
|
|
11
11
|
return options;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
|
-
import { If } from "../
|
|
2
|
+
import { If } from "../utils/ts";
|
|
3
3
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
4
|
export type ConfigCommandOptionsType<TResolved = false> = {
|
|
5
5
|
package?: If<TResolved, string[]>;
|
|
@@ -13,6 +13,6 @@ export type ConfigCommandLogType = {
|
|
|
13
13
|
taskName: string | undefined;
|
|
14
14
|
}[];
|
|
15
15
|
export declare class ConfigCommand extends CommandAbstract<ConfigCommandOptionsType<false>, ConfigCommandOptionsType<true>> {
|
|
16
|
-
onOptions(): import("../
|
|
16
|
+
onOptions(): import("../utils/cli").OptionsType<ConfigCommandOptionsType<false>, ConfigCommandOptionsType<true>>;
|
|
17
17
|
onExec(): Promise<number>;
|
|
18
18
|
}
|
package/Command/ConfigCommand.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfigCommand = void 0;
|
|
4
4
|
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
-
const DataFormat_1 = require("../
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const DataFormat_1 = require("../utils/DataFormat");
|
|
6
|
+
const config_1 = require("../utils/datatruck/config");
|
|
7
|
+
const string_1 = require("../utils/string");
|
|
8
8
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
9
9
|
class ConfigCommand extends CommandAbstract_1.CommandAbstract {
|
|
10
10
|
onOptions() {
|
|
@@ -12,28 +12,28 @@ class ConfigCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
12
12
|
package: {
|
|
13
13
|
description: "Filter by package names",
|
|
14
14
|
option: "-p,--package <values>",
|
|
15
|
-
parser:
|
|
15
|
+
parser: string_1.parseStringList,
|
|
16
16
|
},
|
|
17
17
|
packageTask: {
|
|
18
18
|
description: "Filter by package task names",
|
|
19
19
|
option: "-pt,--package-task <values>",
|
|
20
|
-
parser:
|
|
20
|
+
parser: string_1.parseStringList,
|
|
21
21
|
},
|
|
22
22
|
repository: {
|
|
23
23
|
description: "Filter by repository names",
|
|
24
24
|
option: "-r,--repository <values>",
|
|
25
|
-
parser:
|
|
25
|
+
parser: string_1.parseStringList,
|
|
26
26
|
},
|
|
27
27
|
repositoryType: {
|
|
28
28
|
description: "Filter by repository types",
|
|
29
29
|
option: "-rt,--repository-type <values>",
|
|
30
|
-
parser: (v) => (0,
|
|
30
|
+
parser: (v) => (0, string_1.parseStringList)(v),
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
async onExec() {
|
|
35
35
|
const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
|
|
36
|
-
const packages = (0,
|
|
36
|
+
const packages = (0, config_1.filterPackages)(config, {
|
|
37
37
|
packageNames: this.options.package,
|
|
38
38
|
packageTaskNames: this.options.packageTask,
|
|
39
39
|
repositoryNames: this.options.repository,
|