@datatruck/cli 0.26.2 → 0.28.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 +69 -34
- package/Action/BackupAction.js +284 -244
- package/Action/CleanCacheAction.d.ts +8 -4
- package/Action/CleanCacheAction.js +8 -5
- package/Action/ConfigAction.d.ts +12 -5
- package/Action/ConfigAction.js +14 -18
- package/Action/CopyAction.d.ts +49 -0
- package/Action/CopyAction.js +144 -0
- package/Action/InitAction.d.ts +3 -3
- package/Action/InitAction.js +9 -9
- package/Action/PruneAction.d.ts +9 -9
- package/Action/PruneAction.js +39 -23
- package/Action/RestoreAction.d.ts +48 -23
- package/Action/RestoreAction.js +158 -195
- package/Action/SnapshotsAction.d.ts +8 -8
- package/Action/SnapshotsAction.js +8 -8
- package/CHANGELOG.md +495 -0
- package/Command/BackupCommand.d.ts +6 -4
- package/Command/BackupCommand.js +9 -26
- package/Command/CleanCacheCommand.d.ts +4 -4
- package/Command/CleanCacheCommand.js +26 -5
- package/Command/CommandAbstract.d.ts +10 -7
- package/Command/CommandAbstract.js +4 -1
- package/Command/ConfigCommand.d.ts +6 -9
- package/Command/ConfigCommand.js +13 -8
- package/Command/CopyCommand.d.ts +15 -0
- package/Command/CopyCommand.js +61 -0
- package/Command/InitCommand.d.ts +4 -4
- package/Command/InitCommand.js +11 -15
- package/Command/PruneCommand.d.ts +3 -3
- package/Command/PruneCommand.js +13 -12
- package/Command/RestoreCommand.js +9 -17
- package/Command/SnapshotsCommand.d.ts +4 -4
- package/Command/SnapshotsCommand.js +16 -15
- package/Command/StartServerCommand.d.ts +6 -0
- package/Command/StartServerCommand.js +24 -0
- package/Config/Config.d.ts +11 -0
- package/Config/Config.js +43 -0
- package/Config/PrunePolicyConfig.d.ts +2 -2
- package/Factory/CommandFactory.d.ts +29 -33
- package/Factory/CommandFactory.js +32 -53
- package/Factory/RepositoryFactory.d.ts +1 -1
- package/Factory/RepositoryFactory.js +3 -3
- package/Factory/TaskFactory.d.ts +1 -1
- package/Factory/TaskFactory.js +3 -3
- package/Repository/DatatruckRepository.d.ts +17 -16
- package/Repository/DatatruckRepository.js +131 -149
- package/Repository/GitRepository.d.ts +9 -8
- package/Repository/GitRepository.js +22 -25
- package/Repository/RepositoryAbstract.d.ts +39 -37
- package/Repository/RepositoryAbstract.js +4 -5
- package/Repository/ResticRepository.d.ts +9 -8
- package/Repository/ResticRepository.js +30 -28
- package/Task/GitTask.d.ts +6 -7
- package/Task/GitTask.js +24 -30
- package/Task/MariadbTask.d.ts +4 -5
- package/Task/MariadbTask.js +26 -32
- package/Task/MssqlTask.d.ts +5 -3
- package/Task/MssqlTask.js +11 -12
- package/Task/MysqlDumpTask.d.ts +10 -3
- package/Task/MysqlDumpTask.js +107 -31
- package/Task/ScriptTask.d.ts +23 -18
- package/Task/ScriptTask.js +34 -24
- package/Task/SqlDumpTaskAbstract.d.ts +8 -3
- package/Task/SqlDumpTaskAbstract.js +31 -19
- package/Task/TaskAbstract.d.ts +24 -25
- package/Task/TaskAbstract.js +6 -10
- package/cli.js +14 -5
- package/config.schema.json +124 -3
- package/package.json +4 -5
- package/utils/DataFormat.d.ts +23 -12
- package/utils/DataFormat.js +36 -14
- package/utils/cli.d.ts +2 -9
- package/utils/cli.js +9 -52
- package/utils/datatruck/client.d.ts +24 -0
- package/utils/datatruck/client.js +99 -0
- package/utils/datatruck/config.d.ts +8 -6
- package/utils/datatruck/config.js +18 -3
- package/utils/datatruck/paths.d.ts +5 -9
- package/utils/datatruck/paths.js +2 -2
- package/utils/datatruck/server.d.ts +21 -0
- package/utils/datatruck/server.js +96 -0
- package/utils/datatruck/snapshot.d.ts +2 -2
- package/utils/date.d.ts +7 -3
- package/utils/date.js +22 -14
- package/utils/fs.d.ts +27 -15
- package/utils/fs.js +110 -62
- package/utils/http.d.ts +21 -0
- package/utils/http.js +154 -0
- package/utils/list.d.ts +64 -0
- package/utils/list.js +145 -0
- package/utils/mysql.d.ts +2 -0
- package/utils/mysql.js +21 -2
- package/utils/process.d.ts +1 -0
- package/utils/process.js +24 -31
- package/utils/progress.d.ts +33 -0
- package/utils/progress.js +113 -0
- package/utils/steps.d.ts +11 -0
- package/utils/steps.js +22 -10
- package/utils/stream.d.ts +7 -0
- package/utils/stream.js +10 -0
- package/utils/string.d.ts +0 -1
- package/utils/string.js +1 -13
- package/utils/tar.d.ts +10 -3
- package/utils/tar.js +70 -44
- package/utils/temp.d.ts +26 -0
- package/utils/temp.js +133 -0
- package/utils/virtual-fs.d.ts +37 -0
- package/utils/virtual-fs.js +65 -0
- package/Action/BackupSessionsAction.d.ts +0 -13
- package/Action/BackupSessionsAction.js +0 -18
- package/Action/RestoreSessionsAction.d.ts +0 -13
- package/Action/RestoreSessionsAction.js +0 -18
- package/Command/BackupSessionsCommand.d.ts +0 -12
- package/Command/BackupSessionsCommand.js +0 -92
- package/Command/RestoreSessionsCommand.d.ts +0 -12
- package/Command/RestoreSessionsCommand.js +0 -91
- package/Decorator/EntityDecorator.d.ts +0 -11
- package/Decorator/EntityDecorator.js +0 -17
- package/Entity/BackupSessionEntity.d.ts +0 -6
- package/Entity/BackupSessionEntity.js +0 -25
- package/Entity/BackupSessionRepositoryEntity.d.ts +0 -6
- package/Entity/BackupSessionRepositoryEntity.js +0 -25
- package/Entity/BackupSessionTaskEntity.d.ts +0 -5
- package/Entity/BackupSessionTaskEntity.js +0 -24
- package/Entity/CrudEntityAbstract.d.ts +0 -5
- package/Entity/CrudEntityAbstract.js +0 -9
- package/Entity/RestoreSessionEntity.d.ts +0 -5
- package/Entity/RestoreSessionEntity.js +0 -24
- package/Entity/RestoreSessionRepositoryEntity.d.ts +0 -6
- package/Entity/RestoreSessionRepositoryEntity.js +0 -25
- package/Entity/RestoreSessionTaskEntity.d.ts +0 -5
- package/Entity/RestoreSessionTaskEntity.js +0 -24
- package/Entity/StateEntityAbstract.d.ts +0 -9
- package/Entity/StateEntityAbstract.js +0 -12
- package/Factory/EntityFactory.d.ts +0 -6
- package/Factory/EntityFactory.js +0 -40
- package/SessionDriver/ConsoleSessionDriver.d.ts +0 -42
- package/SessionDriver/ConsoleSessionDriver.js +0 -208
- package/SessionDriver/SessionDriverAbstract.d.ts +0 -77
- package/SessionDriver/SessionDriverAbstract.js +0 -28
- package/SessionDriver/SqliteSessionDriver.d.ts +0 -20
- package/SessionDriver/SqliteSessionDriver.js +0 -173
- package/SessionManager/BackupSessionManager.d.ts +0 -45
- package/SessionManager/BackupSessionManager.js +0 -218
- package/SessionManager/RestoreSessionManager.d.ts +0 -47
- package/SessionManager/RestoreSessionManager.js +0 -218
- package/SessionManager/SessionManagerAbstract.d.ts +0 -18
- package/SessionManager/SessionManagerAbstract.js +0 -36
- package/migrations/001-initial.sql +0 -98
- package/utils/entity.d.ts +0 -4
- package/utils/entity.js +0 -10
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandAbstract = void 0;
|
|
4
4
|
const cli_1 = require("../utils/cli");
|
|
5
|
+
const stream_1 = require("../utils/stream");
|
|
5
6
|
class CommandAbstract {
|
|
6
7
|
globalOptions;
|
|
7
8
|
options;
|
|
8
|
-
|
|
9
|
+
streams;
|
|
10
|
+
constructor(globalOptions, options, streams = {}) {
|
|
9
11
|
this.globalOptions = globalOptions;
|
|
10
12
|
this.options = (0, cli_1.parseOptions)(options, this.onOptions());
|
|
13
|
+
this.streams = (0, stream_1.createStreams)(streams);
|
|
11
14
|
}
|
|
12
15
|
returnsOptions(options) {
|
|
13
16
|
return options;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
+
import { ConfigAction } from "../Action/ConfigAction";
|
|
1
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
|
-
import { If } from "../utils/ts";
|
|
3
|
+
import { If, Unwrap } from "../utils/ts";
|
|
3
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
|
-
export type
|
|
5
|
+
export type ConfigCommandOptions<TResolved = false> = {
|
|
5
6
|
package?: If<TResolved, string[]>;
|
|
6
7
|
packageTask?: If<TResolved, string[]>;
|
|
7
8
|
repository?: If<TResolved, string[]>;
|
|
8
9
|
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
9
10
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
taskName: string | undefined;
|
|
14
|
-
}[];
|
|
15
|
-
export declare class ConfigCommand extends CommandAbstract<ConfigCommandOptionsType<false>, ConfigCommandOptionsType<true>> {
|
|
16
|
-
onOptions(): import("../utils/cli").OptionsType<ConfigCommandOptionsType<false>, ConfigCommandOptionsType<true>>;
|
|
11
|
+
export type ConfigCommandResult = Unwrap<ConfigAction["exec"]>;
|
|
12
|
+
export declare class ConfigCommand extends CommandAbstract<ConfigCommandOptions<false>, ConfigCommandOptions<true>> {
|
|
13
|
+
onOptions(): import("../utils/cli").OptionsType<ConfigCommandOptions<false>, ConfigCommandOptions<true>>;
|
|
17
14
|
onExec(): Promise<number>;
|
|
18
15
|
}
|
package/Command/ConfigCommand.js
CHANGED
|
@@ -32,8 +32,8 @@ class ConfigCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
async onExec() {
|
|
35
|
-
const
|
|
36
|
-
const packages = (0, config_1.filterPackages)(
|
|
35
|
+
const result = await ConfigAction_1.ConfigAction.fromGlobalOptionsWithPath(this.globalOptions);
|
|
36
|
+
const packages = (0, config_1.filterPackages)(result.data, {
|
|
37
37
|
packageNames: this.options.package,
|
|
38
38
|
packageTaskNames: this.options.packageTask,
|
|
39
39
|
repositoryNames: this.options.repository,
|
|
@@ -45,22 +45,27 @@ class ConfigCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
45
45
|
taskName: pkg.task?.name,
|
|
46
46
|
}));
|
|
47
47
|
const dataFormat = new DataFormat_1.DataFormat({
|
|
48
|
-
|
|
48
|
+
streams: this.streams,
|
|
49
|
+
json: result,
|
|
49
50
|
table: {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
headers: [
|
|
52
|
+
{ value: "Package" },
|
|
53
|
+
{ value: "Repository" },
|
|
54
|
+
{ value: "Task" },
|
|
55
|
+
],
|
|
56
|
+
rows: () => summaryConfig.map((item) => [
|
|
52
57
|
item.packageName,
|
|
53
58
|
item.repositoryNames.join(", "),
|
|
54
59
|
item.taskName ?? "",
|
|
55
|
-
],
|
|
60
|
+
]),
|
|
56
61
|
},
|
|
57
62
|
});
|
|
58
63
|
if (this.globalOptions.outputFormat)
|
|
59
|
-
|
|
64
|
+
dataFormat.log(this.globalOptions.outputFormat, {
|
|
60
65
|
tpl: {
|
|
61
66
|
pkgNames: () => summaryConfig.map((i) => i.packageName).join(),
|
|
62
67
|
},
|
|
63
|
-
})
|
|
68
|
+
});
|
|
64
69
|
return 0;
|
|
65
70
|
}
|
|
66
71
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CopyAction } from "../Action/CopyAction";
|
|
2
|
+
import { If, Unwrap } from "../utils/ts";
|
|
3
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
4
|
+
export type CopyCommandOptionsType<TResolved = false> = {
|
|
5
|
+
id: If<TResolved, string[]>;
|
|
6
|
+
package?: If<TResolved, string[]>;
|
|
7
|
+
packageTask?: If<TResolved, string[]>;
|
|
8
|
+
repository: string;
|
|
9
|
+
repository2?: If<TResolved, string[]>;
|
|
10
|
+
};
|
|
11
|
+
export type CopyCommandResult = Unwrap<CopyAction["exec"]>;
|
|
12
|
+
export declare class CopyCommand extends CommandAbstract<CopyCommandOptionsType<false>, CopyCommandOptionsType<true>> {
|
|
13
|
+
onOptions(): import("../utils/cli").OptionsType<CopyCommandOptionsType<false>, CopyCommandOptionsType<true>>;
|
|
14
|
+
onExec(): Promise<0 | 1>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CopyCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const CopyAction_1 = require("../Action/CopyAction");
|
|
6
|
+
const string_1 = require("../utils/string");
|
|
7
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
8
|
+
class CopyCommand extends CommandAbstract_1.CommandAbstract {
|
|
9
|
+
onOptions() {
|
|
10
|
+
return this.returnsOptions({
|
|
11
|
+
id: {
|
|
12
|
+
option: "-i,--id <ids>",
|
|
13
|
+
description: "Filter by identifiers",
|
|
14
|
+
required: true,
|
|
15
|
+
parser: string_1.parseStringList,
|
|
16
|
+
},
|
|
17
|
+
package: {
|
|
18
|
+
option: "-p,--package <names>",
|
|
19
|
+
description: "Filter by package names",
|
|
20
|
+
parser: string_1.parseStringList,
|
|
21
|
+
},
|
|
22
|
+
packageTask: {
|
|
23
|
+
option: "-pt,--package-task <values>",
|
|
24
|
+
description: "Filter by task names",
|
|
25
|
+
parser: string_1.parseStringList,
|
|
26
|
+
},
|
|
27
|
+
repository: {
|
|
28
|
+
option: "-r,--repository <name>",
|
|
29
|
+
description: "Filter by repository name",
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
repository2: {
|
|
33
|
+
option: "-r2,--repository2 <names>",
|
|
34
|
+
description: "Filter by repository names",
|
|
35
|
+
parser: string_1.parseStringList,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async onExec() {
|
|
40
|
+
const verbose = this.globalOptions.verbose ?? 0;
|
|
41
|
+
const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
|
|
42
|
+
const copy = new CopyAction_1.CopyAction(config, {
|
|
43
|
+
ids: this.options.id,
|
|
44
|
+
packageNames: this.options.package,
|
|
45
|
+
packageTaskNames: this.options.packageTask,
|
|
46
|
+
repositoryName: this.options.repository,
|
|
47
|
+
repositoryNames2: this.options.repository2,
|
|
48
|
+
verbose: verbose > 0,
|
|
49
|
+
tty: this.globalOptions.tty,
|
|
50
|
+
progress: this.globalOptions.progress,
|
|
51
|
+
progressInterval: this.globalOptions.progressInterval,
|
|
52
|
+
});
|
|
53
|
+
const result = await copy.exec();
|
|
54
|
+
if (this.globalOptions.outputFormat)
|
|
55
|
+
copy
|
|
56
|
+
.dataFormat(result, { streams: this.streams, verbose })
|
|
57
|
+
.log(this.globalOptions.outputFormat);
|
|
58
|
+
return result.some((item) => item.error) ? 1 : 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.CopyCommand = CopyCommand;
|
package/Command/InitCommand.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { InitAction } from "../Action/InitAction";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export type
|
|
5
|
+
export type InitCommandOptions<TResolved = false> = {
|
|
6
6
|
repository?: If<TResolved, string[]>;
|
|
7
7
|
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
10
|
-
export declare class InitCommand extends CommandAbstract<
|
|
11
|
-
onOptions(): import("../utils/cli").OptionsType<
|
|
9
|
+
export type InitCommandResult = Unwrap<InitAction["exec"]>;
|
|
10
|
+
export declare class InitCommand extends CommandAbstract<InitCommandOptions<false>, InitCommandOptions<true>> {
|
|
11
|
+
onOptions(): import("../utils/cli").OptionsType<InitCommandOptions<false>, InitCommandOptions<true>>;
|
|
12
12
|
onExec(): Promise<number>;
|
|
13
13
|
}
|
package/Command/InitCommand.js
CHANGED
|
@@ -5,7 +5,6 @@ const ConfigAction_1 = require("../Action/ConfigAction");
|
|
|
5
5
|
const InitAction_1 = require("../Action/InitAction");
|
|
6
6
|
const DataFormat_1 = require("../utils/DataFormat");
|
|
7
7
|
const cli_1 = require("../utils/cli");
|
|
8
|
-
const object_1 = require("../utils/object");
|
|
9
8
|
const string_1 = require("../utils/string");
|
|
10
9
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
11
10
|
class InitCommand extends CommandAbstract_1.CommandAbstract {
|
|
@@ -33,30 +32,27 @@ class InitCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
33
32
|
});
|
|
34
33
|
const response = await init.exec();
|
|
35
34
|
const dataFormat = new DataFormat_1.DataFormat({
|
|
36
|
-
|
|
37
|
-
json:
|
|
38
|
-
...item,
|
|
39
|
-
error: item.error ? (0, object_1.getErrorProperties)(item.error) : null,
|
|
40
|
-
}),
|
|
35
|
+
streams: this.streams,
|
|
36
|
+
json: response,
|
|
41
37
|
table: {
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"Repository name",
|
|
45
|
-
"Repository type",
|
|
46
|
-
"Repository source",
|
|
47
|
-
"",
|
|
38
|
+
headers: [
|
|
39
|
+
{ value: "", width: 3 },
|
|
40
|
+
{ value: "Repository name" },
|
|
41
|
+
{ value: "Repository type" },
|
|
42
|
+
{ value: "Repository source" },
|
|
43
|
+
{ value: "Error", width: 50 },
|
|
48
44
|
],
|
|
49
|
-
|
|
45
|
+
rows: () => response.map((item) => [
|
|
50
46
|
(0, cli_1.resultColumn)(item.error),
|
|
51
47
|
item.repositoryName,
|
|
52
48
|
item.repositoryType,
|
|
53
49
|
item.repositorySource,
|
|
54
50
|
(0, cli_1.errorColumn)(item.error, verbose),
|
|
55
|
-
],
|
|
51
|
+
]),
|
|
56
52
|
},
|
|
57
53
|
});
|
|
58
54
|
if (this.globalOptions.outputFormat)
|
|
59
|
-
|
|
55
|
+
dataFormat.log(this.globalOptions.outputFormat);
|
|
60
56
|
return 0;
|
|
61
57
|
}
|
|
62
58
|
}
|
|
@@ -2,7 +2,7 @@ import { SnapshotGroupByType } from "../Action/SnapshotsAction";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export type
|
|
5
|
+
export type PruneCommandOptions<TResolved = false> = {
|
|
6
6
|
id?: If<TResolved, string[]>;
|
|
7
7
|
longId?: boolean;
|
|
8
8
|
package?: If<TResolved, string[]>;
|
|
@@ -21,7 +21,7 @@ export type PruneCommandOptionsType<TResolved = false> = {
|
|
|
21
21
|
showAll?: boolean;
|
|
22
22
|
confirm?: boolean;
|
|
23
23
|
};
|
|
24
|
-
export declare class PruneCommand extends CommandAbstract<
|
|
25
|
-
onOptions(): import("../utils/cli").OptionsType<
|
|
24
|
+
export declare class PruneCommand extends CommandAbstract<PruneCommandOptions<false>, PruneCommandOptions<true>> {
|
|
25
|
+
onOptions(): import("../utils/cli").OptionsType<PruneCommandOptions<false>, PruneCommandOptions<true>>;
|
|
26
26
|
onExec(): Promise<number>;
|
|
27
27
|
}
|
package/Command/PruneCommand.js
CHANGED
|
@@ -27,7 +27,7 @@ class PruneCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
27
27
|
},
|
|
28
28
|
id: {
|
|
29
29
|
description: "Filter by snapshot id",
|
|
30
|
-
option: "-i,--id",
|
|
30
|
+
option: "-i,--id <snapshotId>",
|
|
31
31
|
parser: string_1.parseStringList,
|
|
32
32
|
},
|
|
33
33
|
keepMinutely: {
|
|
@@ -123,28 +123,29 @@ class PruneCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
123
123
|
});
|
|
124
124
|
const pruneResult = await prune.exec();
|
|
125
125
|
const dataFormat = new DataFormat_1.DataFormat({
|
|
126
|
-
|
|
126
|
+
streams: this.streams,
|
|
127
|
+
json: pruneResult,
|
|
127
128
|
table: {
|
|
128
|
-
|
|
129
|
-
"Id.",
|
|
130
|
-
"Date",
|
|
131
|
-
"Package",
|
|
132
|
-
"Repository",
|
|
133
|
-
"Repository type",
|
|
134
|
-
"Exclusion reasons",
|
|
129
|
+
headers: [
|
|
130
|
+
{ value: "Id.", width: (this.options.longId ? 32 : 8) + 2 },
|
|
131
|
+
{ value: "Date", width: 23 + 2 },
|
|
132
|
+
{ value: "Package" },
|
|
133
|
+
{ value: "Repository" },
|
|
134
|
+
{ value: "Repository type" },
|
|
135
|
+
{ value: "Exclusion reasons" },
|
|
135
136
|
],
|
|
136
|
-
|
|
137
|
+
rows: () => pruneResult.snapshots.map((item) => [
|
|
137
138
|
this.options.longId ? item.id : item.id.slice(0, 8),
|
|
138
139
|
item.date.replace("T", " ").replace("Z", ""),
|
|
139
140
|
item.packageName,
|
|
140
141
|
item.repositoryName,
|
|
141
142
|
item.repositoryType,
|
|
142
143
|
item.exclusionReasons?.join(", ") ?? "",
|
|
143
|
-
],
|
|
144
|
+
]),
|
|
144
145
|
},
|
|
145
146
|
});
|
|
146
147
|
if (this.globalOptions.outputFormat)
|
|
147
|
-
|
|
148
|
+
dataFormat.log(this.globalOptions.outputFormat);
|
|
148
149
|
if (!this.options.confirm && !this.options.dryRun) {
|
|
149
150
|
const answer = await (0, cli_1.confirm)(`Delete ${pruneResult.prune}/${pruneResult.total} snapshots?`);
|
|
150
151
|
if (answer)
|
|
@@ -3,9 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RestoreCommand = void 0;
|
|
4
4
|
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
5
|
const RestoreAction_1 = require("../Action/RestoreAction");
|
|
6
|
-
const ConsoleSessionDriver_1 = require("../SessionDriver/ConsoleSessionDriver");
|
|
7
|
-
const SqliteSessionDriver_1 = require("../SessionDriver/SqliteSessionDriver");
|
|
8
|
-
const RestoreSessionManager_1 = require("../SessionManager/RestoreSessionManager");
|
|
9
6
|
const string_1 = require("../utils/string");
|
|
10
7
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
11
8
|
class RestoreCommand extends CommandAbstract_1.CommandAbstract {
|
|
@@ -64,22 +61,17 @@ class RestoreCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
64
61
|
tags: this.options.tag,
|
|
65
62
|
verbose: verbose > 0,
|
|
66
63
|
restorePath: this.options.restorePath,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
driver: new SqliteSessionDriver_1.SqliteSessionDriver({
|
|
70
|
-
verbose: verbose > 1,
|
|
71
|
-
}),
|
|
72
|
-
altDrivers: [
|
|
73
|
-
new ConsoleSessionDriver_1.ConsoleSessionDriver({
|
|
74
|
-
verbose: verbose > 0,
|
|
75
|
-
progress: this.globalOptions.progress,
|
|
76
|
-
}),
|
|
77
|
-
],
|
|
78
|
-
verbose: verbose > 1,
|
|
64
|
+
tty: this.globalOptions.tty,
|
|
65
|
+
progress: this.globalOptions.progress,
|
|
79
66
|
progressInterval: this.globalOptions.progressInterval,
|
|
67
|
+
streams: this.streams,
|
|
80
68
|
});
|
|
81
|
-
const result = await restore.exec(
|
|
82
|
-
|
|
69
|
+
const result = await restore.exec();
|
|
70
|
+
if (this.globalOptions.outputFormat)
|
|
71
|
+
restore
|
|
72
|
+
.dataFormat(result, { streams: this.streams, verbose })
|
|
73
|
+
.log(this.globalOptions.outputFormat);
|
|
74
|
+
return result.some((item) => item.error) ? 1 : 0;
|
|
83
75
|
}
|
|
84
76
|
}
|
|
85
77
|
exports.RestoreCommand = RestoreCommand;
|
|
@@ -2,7 +2,7 @@ import { SnapshotsAction } from "../Action/SnapshotsAction";
|
|
|
2
2
|
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export type
|
|
5
|
+
export type SnapshotsCommandOptions<TResolved = false> = {
|
|
6
6
|
id?: If<TResolved, string[]>;
|
|
7
7
|
package?: If<TResolved, string[]>;
|
|
8
8
|
packageTask?: If<TResolved, string[]>;
|
|
@@ -20,8 +20,8 @@ export type SnapshotsCommandOptionsType<TResolved = false> = {
|
|
|
20
20
|
groupBy?: If<TResolved, SnapshotsAction["options"]["groupBy"]>;
|
|
21
21
|
tag?: If<TResolved, string[]>;
|
|
22
22
|
};
|
|
23
|
-
export type
|
|
24
|
-
export declare class SnapshotsCommand extends CommandAbstract<
|
|
25
|
-
onOptions(): import("../utils/cli").OptionsType<
|
|
23
|
+
export type SnapshotsCommandResult = Unwrap<SnapshotsAction["exec"]>;
|
|
24
|
+
export declare class SnapshotsCommand extends CommandAbstract<SnapshotsCommandOptions<false>, SnapshotsCommandOptions<true>> {
|
|
25
|
+
onOptions(): import("../utils/cli").OptionsType<SnapshotsCommandOptions<false>, SnapshotsCommandOptions<true>>;
|
|
26
26
|
onExec(): Promise<number>;
|
|
27
27
|
}
|
|
@@ -9,7 +9,7 @@ const SnapshotsAction_1 = require("../Action/SnapshotsAction");
|
|
|
9
9
|
const DataFormat_1 = require("../utils/DataFormat");
|
|
10
10
|
const string_1 = require("../utils/string");
|
|
11
11
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
12
|
-
const
|
|
12
|
+
const bytes_1 = __importDefault(require("bytes"));
|
|
13
13
|
class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
|
|
14
14
|
onOptions() {
|
|
15
15
|
const groupByValues = [
|
|
@@ -122,36 +122,37 @@ class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
122
122
|
});
|
|
123
123
|
const items = await snapshots.exec();
|
|
124
124
|
const dataFormat = new DataFormat_1.DataFormat({
|
|
125
|
-
|
|
125
|
+
streams: this.streams,
|
|
126
|
+
json: items,
|
|
126
127
|
table: {
|
|
127
|
-
|
|
128
|
-
"Id.",
|
|
129
|
-
"Date",
|
|
130
|
-
"Package",
|
|
131
|
-
"Task",
|
|
132
|
-
"Size",
|
|
133
|
-
"Repository",
|
|
134
|
-
"Repository type",
|
|
128
|
+
headers: [
|
|
129
|
+
{ value: "Id.", width: (this.options.longId ? 32 : 8) + 2 },
|
|
130
|
+
{ value: "Date", width: 23 + 2 },
|
|
131
|
+
{ value: "Package" },
|
|
132
|
+
{ value: "Task" },
|
|
133
|
+
{ value: "Size" },
|
|
134
|
+
{ value: "Repository" },
|
|
135
|
+
{ value: "Repository type" },
|
|
135
136
|
],
|
|
136
|
-
|
|
137
|
+
rows: () => items.map((item) => [
|
|
137
138
|
this.options.longId ? item.id : item.id.slice(0, 8),
|
|
138
139
|
item.date.replace("T", " ").replace("Z", ""),
|
|
139
140
|
item.packageName,
|
|
140
141
|
item.packageTaskName || "",
|
|
141
|
-
(0,
|
|
142
|
+
(0, bytes_1.default)(item.size),
|
|
142
143
|
item.repositoryName,
|
|
143
144
|
item.repositoryType,
|
|
144
|
-
],
|
|
145
|
+
]),
|
|
145
146
|
},
|
|
146
147
|
});
|
|
147
148
|
if (this.globalOptions.outputFormat)
|
|
148
|
-
|
|
149
|
+
dataFormat.log(this.globalOptions.outputFormat, {
|
|
149
150
|
tpl: {
|
|
150
151
|
sids: () => items.map((i) => i.id).join(),
|
|
151
152
|
ssids: () => items.map((i) => i.shortId).join(),
|
|
152
153
|
pkgNames: () => items.map((i) => i.packageName).join(),
|
|
153
154
|
},
|
|
154
|
-
})
|
|
155
|
+
});
|
|
155
156
|
return 0;
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
2
|
+
export type StartServerCommandOptions<TResolved = false> = {};
|
|
3
|
+
export declare class StartServerCommand extends CommandAbstract<StartServerCommandOptions<false>, StartServerCommandOptions<true>> {
|
|
4
|
+
onOptions(): import("../utils/cli").OptionsType<StartServerCommandOptions<false>, StartServerCommandOptions<true>>;
|
|
5
|
+
onExec(): Promise<number>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StartServerCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const server_1 = require("../utils/datatruck/server");
|
|
6
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
7
|
+
class StartServerCommand extends CommandAbstract_1.CommandAbstract {
|
|
8
|
+
onOptions() {
|
|
9
|
+
return this.returnsOptions({});
|
|
10
|
+
}
|
|
11
|
+
async onExec() {
|
|
12
|
+
const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
|
|
13
|
+
const server = (0, server_1.createDatatruckServer)(config.server || {});
|
|
14
|
+
const port = config.server?.listen?.port ?? 8888;
|
|
15
|
+
const address = config.server?.listen?.address ?? "127.0.0.1";
|
|
16
|
+
console.info(`Listening on http://${address}:${port}`);
|
|
17
|
+
await new Promise((resolve, reject) => {
|
|
18
|
+
server.listen(port, address);
|
|
19
|
+
server.on("error", reject);
|
|
20
|
+
});
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.StartServerCommand = StartServerCommand;
|
package/Config/Config.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { FormatType } from "../utils/DataFormat";
|
|
2
|
+
import { DatatruckServerOptions } from "../utils/datatruck/server";
|
|
3
|
+
import { Step } from "../utils/steps";
|
|
1
4
|
import { PackageConfigType } from "./PackageConfig";
|
|
2
5
|
import { RepositoryConfigType } from "./RepositoryConfig";
|
|
3
6
|
import type { JSONSchema7 } from "json-schema";
|
|
4
7
|
export type ConfigType = {
|
|
5
8
|
tempDir?: string;
|
|
9
|
+
minFreeDiskSpace?: string | number;
|
|
6
10
|
repositories: RepositoryConfigType[];
|
|
7
11
|
packages: PackageConfigType[];
|
|
12
|
+
server?: DatatruckServerOptions;
|
|
13
|
+
reports?: ReportConfig[];
|
|
14
|
+
};
|
|
15
|
+
export type ReportConfig = {
|
|
16
|
+
when?: "success" | "error";
|
|
17
|
+
format?: Exclude<FormatType, "custom" | "tpl">;
|
|
18
|
+
run: Step;
|
|
8
19
|
};
|
|
9
20
|
export declare const configDefinition: JSONSchema7;
|
package/Config/Config.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configDefinition = void 0;
|
|
4
4
|
const DefinitionEnum_1 = require("../JsonSchema/DefinitionEnum");
|
|
5
|
+
const ScriptTask_1 = require("../Task/ScriptTask");
|
|
6
|
+
const DataFormat_1 = require("../utils/DataFormat");
|
|
5
7
|
exports.configDefinition = {
|
|
6
8
|
type: "object",
|
|
7
9
|
required: ["repositories", "packages"],
|
|
@@ -9,6 +11,21 @@ exports.configDefinition = {
|
|
|
9
11
|
properties: {
|
|
10
12
|
$schema: { type: "string" },
|
|
11
13
|
tempDir: { type: "string" },
|
|
14
|
+
minFreeDiskSpace: { anyOf: [{ type: "integer" }, { type: "string" }] },
|
|
15
|
+
reports: {
|
|
16
|
+
type: "array",
|
|
17
|
+
items: {
|
|
18
|
+
type: "object",
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
properties: {
|
|
21
|
+
when: { enum: ["success", "error"] },
|
|
22
|
+
format: {
|
|
23
|
+
enum: DataFormat_1.dataFormats.filter((f) => !["custom", "tpl"].includes(f)),
|
|
24
|
+
},
|
|
25
|
+
run: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.scriptTask, ScriptTask_1.ScriptTaskDefinitionEnum.step),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
12
29
|
repositories: {
|
|
13
30
|
type: "array",
|
|
14
31
|
items: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.repository),
|
|
@@ -17,5 +34,31 @@ exports.configDefinition = {
|
|
|
17
34
|
type: "array",
|
|
18
35
|
items: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.package),
|
|
19
36
|
},
|
|
37
|
+
server: {
|
|
38
|
+
type: "object",
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
properties: {
|
|
41
|
+
path: { type: "string" },
|
|
42
|
+
users: {
|
|
43
|
+
type: "array",
|
|
44
|
+
items: {
|
|
45
|
+
type: "object",
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
properties: {
|
|
48
|
+
name: { type: "string" },
|
|
49
|
+
password: { type: "string" },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
listen: {
|
|
54
|
+
type: "object",
|
|
55
|
+
additionalProperties: false,
|
|
56
|
+
properties: {
|
|
57
|
+
port: { type: "integer" },
|
|
58
|
+
address: { type: "string" },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
20
63
|
},
|
|
21
64
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PruneActionsOptions } from "../Action/PruneAction";
|
|
2
2
|
import { JSONSchema7 } from "json-schema";
|
|
3
3
|
export declare const prunePolicyConfigDefinition: JSONSchema7;
|
|
4
|
-
export type PrunePolicyConfigType = Pick<
|
|
4
|
+
export type PrunePolicyConfigType = Pick<PruneActionsOptions, "keepDaily" | "keepHourly" | "keepMinutely" | "keepLast" | "keepMonthly" | "keepWeekly" | "keepYearly" | "groupBy" | "tags">;
|
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { PruneCommandOptionsType } from "../Command/PruneCommand";
|
|
1
|
+
import { CleanCacheActionOptions } from "../Action/CleanCacheAction";
|
|
2
|
+
import { BackupCommandOptions, BackupCommandResult } from "../Command/BackupCommand";
|
|
3
|
+
import { GlobalOptions } from "../Command/CommandAbstract";
|
|
4
|
+
import { ConfigCommandResult, ConfigCommandOptions } from "../Command/ConfigCommand";
|
|
5
|
+
import { CopyCommandOptionsType } from "../Command/CopyCommand";
|
|
6
|
+
import { InitCommandResult, InitCommandOptions } from "../Command/InitCommand";
|
|
7
|
+
import { PruneCommandOptions } from "../Command/PruneCommand";
|
|
9
8
|
import { RestoreCommandOptionsType } from "../Command/RestoreCommand";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { SnapshotsCommandResult, SnapshotsCommandOptions } from "../Command/SnapshotsCommand";
|
|
10
|
+
import { StartServerCommand, StartServerCommandOptions } from "../Command/StartServerCommand";
|
|
11
|
+
import { Streams } from "../utils/stream";
|
|
12
12
|
export declare enum CommandEnum {
|
|
13
13
|
config = "config",
|
|
14
14
|
init = "init",
|
|
15
15
|
snapshots = "snapshots",
|
|
16
16
|
prune = "prune",
|
|
17
17
|
backup = "backup",
|
|
18
|
-
backupSessions = "backup-sessions",
|
|
19
18
|
restore = "restore",
|
|
20
|
-
|
|
21
|
-
cleanCache = "clean-cache"
|
|
19
|
+
copy = "copy",
|
|
20
|
+
cleanCache = "clean-cache",
|
|
21
|
+
startServer = "start-server"
|
|
22
22
|
}
|
|
23
23
|
export type OptionsMapType = {
|
|
24
|
-
[CommandEnum.config]:
|
|
25
|
-
[CommandEnum.init]:
|
|
26
|
-
[CommandEnum.snapshots]:
|
|
27
|
-
[CommandEnum.prune]:
|
|
28
|
-
[CommandEnum.backup]:
|
|
29
|
-
[CommandEnum.backupSessions]: BackupSessionsCommandOptionsType;
|
|
24
|
+
[CommandEnum.config]: ConfigCommandOptions;
|
|
25
|
+
[CommandEnum.init]: InitCommandOptions;
|
|
26
|
+
[CommandEnum.snapshots]: SnapshotsCommandOptions;
|
|
27
|
+
[CommandEnum.prune]: PruneCommandOptions;
|
|
28
|
+
[CommandEnum.backup]: BackupCommandOptions;
|
|
30
29
|
[CommandEnum.restore]: RestoreCommandOptionsType;
|
|
31
|
-
[CommandEnum.
|
|
32
|
-
[CommandEnum.cleanCache]:
|
|
30
|
+
[CommandEnum.copy]: CopyCommandOptionsType;
|
|
31
|
+
[CommandEnum.cleanCache]: CleanCacheActionOptions;
|
|
32
|
+
[CommandEnum.startServer]: StartServerCommandOptions;
|
|
33
33
|
};
|
|
34
34
|
export type LogMapType = {
|
|
35
|
-
[CommandEnum.config]:
|
|
36
|
-
[CommandEnum.init]:
|
|
37
|
-
[CommandEnum.snapshots]:
|
|
35
|
+
[CommandEnum.config]: ConfigCommandResult;
|
|
36
|
+
[CommandEnum.init]: InitCommandResult;
|
|
37
|
+
[CommandEnum.snapshots]: SnapshotsCommandResult;
|
|
38
|
+
[CommandEnum.backup]: BackupCommandResult;
|
|
38
39
|
};
|
|
39
|
-
export declare function CommandFactory<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions:
|
|
40
|
-
export declare function exec<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions:
|
|
41
|
-
export declare function createActionInterface(globalOptions:
|
|
40
|
+
export declare function CommandFactory<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams>): StartServerCommand;
|
|
41
|
+
export declare function exec<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams>): Promise<number>;
|
|
42
|
+
export declare function createActionInterface(globalOptions: GlobalOptions<true>): {
|
|
42
43
|
[K in keyof OptionsMapType as `${K}`]: (options: OptionsMapType[K]) => Promise<K extends keyof LogMapType ? LogMapType[K] : never>;
|
|
43
44
|
};
|
|
44
|
-
export declare function
|
|
45
|
-
exitCode: any;
|
|
46
|
-
log: LogMapType[TCommand];
|
|
47
|
-
}>;
|
|
48
|
-
export declare function makeParseLog<TCommand extends keyof LogMapType>(type: TCommand): () => LogMapType[TCommand];
|
|
49
|
-
export declare function CommandConstructorFactory(type: CommandEnum): typeof CleanCacheCommand;
|
|
45
|
+
export declare function CommandConstructorFactory(type: CommandEnum): typeof StartServerCommand;
|