@datatruck/cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Action/BackupAction.d.ts +32 -0
- package/lib/Action/BackupAction.js +201 -0
- package/lib/Action/BackupSessionsAction.d.ts +13 -0
- package/lib/Action/BackupSessionsAction.js +16 -0
- package/lib/Action/CleanCacheAction.d.ts +9 -0
- package/lib/Action/CleanCacheAction.js +18 -0
- package/lib/Action/ConfigAction.d.ts +14 -0
- package/lib/Action/ConfigAction.js +64 -0
- package/lib/Action/InitAction.d.ts +18 -0
- package/lib/Action/InitAction.js +39 -0
- package/lib/Action/PruneAction.d.ts +37 -0
- package/lib/Action/PruneAction.js +80 -0
- package/lib/Action/RestoreAction.d.ts +36 -0
- package/lib/Action/RestoreAction.js +246 -0
- package/lib/Action/RestoreSessionsAction.d.ts +13 -0
- package/lib/Action/RestoreSessionsAction.js +16 -0
- package/lib/Action/SnapshotsAction.d.ts +30 -0
- package/lib/Action/SnapshotsAction.js +35 -0
- package/lib/Command/BackupCommand.d.ts +15 -0
- package/lib/Command/BackupCommand.js +83 -0
- package/lib/Command/BackupSessionsCommand.d.ts +12 -0
- package/lib/Command/BackupSessionsCommand.js +88 -0
- package/lib/Command/CleanCacheCommand.d.ts +6 -0
- package/lib/Command/CleanCacheCommand.js +20 -0
- package/lib/Command/CommandAbstract.d.ts +19 -0
- package/lib/Command/CommandAbstract.js +14 -0
- package/lib/Command/ConfigCommand.d.ts +17 -0
- package/lib/Command/ConfigCommand.js +61 -0
- package/lib/Command/InitCommand.d.ts +13 -0
- package/lib/Command/InitCommand.js +67 -0
- package/lib/Command/PruneCommand.d.ts +27 -0
- package/lib/Command/PruneCommand.js +160 -0
- package/lib/Command/RestoreCommand.d.ts +14 -0
- package/lib/Command/RestoreCommand.js +71 -0
- package/lib/Command/RestoreSessionsCommand.d.ts +12 -0
- package/lib/Command/RestoreSessionsCommand.js +87 -0
- package/lib/Command/SnapshotsCommand.d.ts +25 -0
- package/lib/Command/SnapshotsCommand.js +128 -0
- package/lib/Config/Config.d.ts +8 -0
- package/lib/Config/Config.js +19 -0
- package/lib/Config/PackageConfig.d.ts +27 -0
- package/lib/Config/PackageConfig.js +69 -0
- package/lib/Config/PackageRepositoryConfig.d.ts +17 -0
- package/lib/Config/PackageRepositoryConfig.js +37 -0
- package/lib/Config/PrunePolicyConfig.d.ts +4 -0
- package/lib/Config/PrunePolicyConfig.js +28 -0
- package/lib/Config/RepositoryConfig.d.ts +18 -0
- package/lib/Config/RepositoryConfig.js +37 -0
- package/lib/Config/TaskConfig.d.ts +23 -0
- package/lib/Config/TaskConfig.js +39 -0
- package/lib/Decorator/EntityDecorator.d.ts +11 -0
- package/lib/Decorator/EntityDecorator.js +17 -0
- package/lib/Entity/BackupSessionEntity.d.ts +6 -0
- package/lib/Entity/BackupSessionEntity.js +22 -0
- package/lib/Entity/BackupSessionRepositoryEntity.d.ts +6 -0
- package/lib/Entity/BackupSessionRepositoryEntity.js +22 -0
- package/lib/Entity/BackupSessionTaskEntity.d.ts +5 -0
- package/lib/Entity/BackupSessionTaskEntity.js +22 -0
- package/lib/Entity/CrudEntityAbstract.d.ts +5 -0
- package/lib/Entity/CrudEntityAbstract.js +6 -0
- package/lib/Entity/RestoreSessionEntity.d.ts +5 -0
- package/lib/Entity/RestoreSessionEntity.js +22 -0
- package/lib/Entity/RestoreSessionRepositoryEntity.d.ts +6 -0
- package/lib/Entity/RestoreSessionRepositoryEntity.js +22 -0
- package/lib/Entity/RestoreSessionTaskEntity.d.ts +5 -0
- package/lib/Entity/RestoreSessionTaskEntity.js +22 -0
- package/lib/Entity/StateEntityAbstract.d.ts +12 -0
- package/lib/Entity/StateEntityAbstract.js +7 -0
- package/lib/Error/AppError.d.ts +2 -0
- package/lib/Error/AppError.js +6 -0
- package/lib/Factory/CommandFactory.d.ts +42 -0
- package/lib/Factory/CommandFactory.js +79 -0
- package/lib/Factory/EntityFactory.d.ts +6 -0
- package/lib/Factory/EntityFactory.js +40 -0
- package/lib/Factory/RepositoryFactory.d.ts +3 -0
- package/lib/Factory/RepositoryFactory.js +23 -0
- package/lib/Factory/TaskFactory.d.ts +3 -0
- package/lib/Factory/TaskFactory.js +30 -0
- package/lib/JsonSchema/DefinitionEnum.d.ts +25 -0
- package/lib/JsonSchema/DefinitionEnum.js +32 -0
- package/lib/JsonSchema/JsonSchema.d.ts +4 -0
- package/lib/JsonSchema/JsonSchema.js +50 -0
- package/lib/Repository/GitRepository.d.ts +29 -0
- package/lib/Repository/GitRepository.js +237 -0
- package/lib/Repository/LocalRepository.d.ts +51 -0
- package/lib/Repository/LocalRepository.js +358 -0
- package/lib/Repository/RepositoryAbstract.d.ts +77 -0
- package/lib/Repository/RepositoryAbstract.js +19 -0
- package/lib/Repository/ResticRepository.d.ts +36 -0
- package/lib/Repository/ResticRepository.js +230 -0
- package/lib/SessionDriver/ConsoleSessionDriver.d.ts +37 -0
- package/lib/SessionDriver/ConsoleSessionDriver.js +178 -0
- package/lib/SessionDriver/SessionDriverAbstract.d.ts +78 -0
- package/lib/SessionDriver/SessionDriverAbstract.js +27 -0
- package/lib/SessionDriver/SqliteSessionDriver.d.ts +20 -0
- package/lib/SessionDriver/SqliteSessionDriver.js +169 -0
- package/lib/SessionManager/BackupSessionManager.d.ts +44 -0
- package/lib/SessionManager/BackupSessionManager.js +206 -0
- package/lib/SessionManager/RestoreSessionManager.d.ts +44 -0
- package/lib/SessionManager/RestoreSessionManager.js +206 -0
- package/lib/Task/GitTask.d.ts +35 -0
- package/lib/Task/GitTask.js +248 -0
- package/lib/Task/MariadbTask.d.ts +25 -0
- package/lib/Task/MariadbTask.js +139 -0
- package/lib/Task/MssqlTask.d.ts +22 -0
- package/lib/Task/MssqlTask.js +109 -0
- package/lib/Task/MysqlDumpTask.d.ts +14 -0
- package/lib/Task/MysqlDumpTask.js +129 -0
- package/lib/Task/PostgresqlDumpTask.d.ts +14 -0
- package/lib/Task/PostgresqlDumpTask.js +101 -0
- package/lib/Task/SqlDumpTaskAbstract.d.ts +36 -0
- package/lib/Task/SqlDumpTaskAbstract.js +146 -0
- package/lib/Task/TaskAbstract.d.ts +37 -0
- package/lib/Task/TaskAbstract.js +17 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +5 -0
- package/lib/cli.d.ts +4 -0
- package/lib/cli.js +110 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.js +1 -0
- package/lib/util/DataFormat.d.ts +24 -0
- package/lib/util/DataFormat.js +50 -0
- package/lib/util/GitUtil.d.ts +38 -0
- package/lib/util/GitUtil.js +105 -0
- package/lib/util/ObjectVault.d.ts +13 -0
- package/lib/util/ObjectVault.js +31 -0
- package/lib/util/ResticUtil.d.ts +92 -0
- package/lib/util/ResticUtil.js +144 -0
- package/lib/util/cli-util.d.ts +27 -0
- package/lib/util/cli-util.js +118 -0
- package/lib/util/datatruck/config-util.d.ts +55 -0
- package/lib/util/datatruck/config-util.js +93 -0
- package/lib/util/datatruck/paths-util.d.ts +5 -0
- package/lib/util/datatruck/paths-util.js +22 -0
- package/lib/util/datatruck/snapshot-util.d.ts +4 -0
- package/lib/util/datatruck/snapshot-util.js +31 -0
- package/lib/util/date-util.d.ts +12 -0
- package/lib/util/date-util.js +74 -0
- package/lib/util/entity-util.d.ts +4 -0
- package/lib/util/entity-util.js +10 -0
- package/lib/util/fs-util.d.ts +43 -0
- package/lib/util/fs-util.js +278 -0
- package/lib/util/math-util.d.ts +1 -0
- package/lib/util/math-util.js +7 -0
- package/lib/util/object-util.d.ts +7 -0
- package/lib/util/object-util.js +58 -0
- package/lib/util/process-util.d.ts +50 -0
- package/lib/util/process-util.js +181 -0
- package/lib/util/string-util.d.ts +17 -0
- package/lib/util/string-util.js +77 -0
- package/lib/util/zip-util.d.ts +52 -0
- package/lib/util/zip-util.js +135 -0
- package/migrations/001-initial.sql +122 -0
- package/package.json +62 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const DataFormat_1 = require("../util/DataFormat");
|
|
6
|
+
const config_util_1 = require("../util/datatruck/config-util");
|
|
7
|
+
const string_util_1 = require("../util/string-util");
|
|
8
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
9
|
+
class ConfigCommand extends CommandAbstract_1.CommandAbstract {
|
|
10
|
+
onOptions() {
|
|
11
|
+
return this.returnsOptions({
|
|
12
|
+
package: {
|
|
13
|
+
description: "Package names",
|
|
14
|
+
option: "-p,--package <values>",
|
|
15
|
+
parser: string_util_1.parseStringList,
|
|
16
|
+
},
|
|
17
|
+
repository: {
|
|
18
|
+
description: "Repository names",
|
|
19
|
+
option: "-r,--repository <values>",
|
|
20
|
+
parser: string_util_1.parseStringList,
|
|
21
|
+
},
|
|
22
|
+
repositoryType: {
|
|
23
|
+
description: "Repository types",
|
|
24
|
+
option: "-t,--repository-type <values>",
|
|
25
|
+
parser: (v) => (0, string_util_1.parseStringList)(v),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async onExec() {
|
|
30
|
+
const configAction = new ConfigAction_1.ConfigAction({
|
|
31
|
+
path: this.globalOptions.config,
|
|
32
|
+
verbose: !!this.globalOptions.verbose,
|
|
33
|
+
});
|
|
34
|
+
const config = await configAction.exec();
|
|
35
|
+
const packages = (0, config_util_1.filterPackages)(config, {
|
|
36
|
+
packageNames: this.options.package,
|
|
37
|
+
repositoryNames: this.options.repository,
|
|
38
|
+
repositoryTypes: this.options.repositoryType,
|
|
39
|
+
});
|
|
40
|
+
const summaryConfig = packages.flatMap((pkg) => ({
|
|
41
|
+
package: pkg.name,
|
|
42
|
+
repositoryNames: pkg.repositoryNames ?? [],
|
|
43
|
+
taskName: pkg.task?.name,
|
|
44
|
+
}));
|
|
45
|
+
const dataFormat = new DataFormat_1.DataFormat({
|
|
46
|
+
items: summaryConfig,
|
|
47
|
+
table: {
|
|
48
|
+
labels: ["Package", "Repository", "Task"],
|
|
49
|
+
handler: (item) => [
|
|
50
|
+
item.package,
|
|
51
|
+
item.repositoryNames.join(", "),
|
|
52
|
+
item.taskName ?? "",
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
if (this.globalOptions.outputFormat)
|
|
57
|
+
console.log(dataFormat.format(this.globalOptions.outputFormat));
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.ConfigCommand = ConfigCommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InitAction } from "../Action/InitAction";
|
|
2
|
+
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
|
+
import { If, Unwrap } from "../util/ts-util";
|
|
4
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
+
export declare type InitCommandOptionsType<TResolved = false> = {
|
|
6
|
+
repository?: If<TResolved, string[]>;
|
|
7
|
+
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
8
|
+
};
|
|
9
|
+
export declare type InitCommandLogType = Unwrap<InitAction["exec"]>;
|
|
10
|
+
export declare class InitCommand extends CommandAbstract<InitCommandOptionsType<false>, InitCommandOptionsType<true>> {
|
|
11
|
+
onOptions(): import("../util/cli-util").OptionsType<InitCommandOptionsType<false>, InitCommandOptionsType<true>>;
|
|
12
|
+
onExec(): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const InitAction_1 = require("../Action/InitAction");
|
|
6
|
+
const DataFormat_1 = require("../util/DataFormat");
|
|
7
|
+
const cli_util_1 = require("../util/cli-util");
|
|
8
|
+
const object_util_1 = require("../util/object-util");
|
|
9
|
+
const string_util_1 = require("../util/string-util");
|
|
10
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
11
|
+
class InitCommand extends CommandAbstract_1.CommandAbstract {
|
|
12
|
+
onOptions() {
|
|
13
|
+
return this.returnsOptions({
|
|
14
|
+
repository: {
|
|
15
|
+
description: "Repository names",
|
|
16
|
+
option: "-r,--repository <values>",
|
|
17
|
+
parser: string_util_1.parseStringList,
|
|
18
|
+
},
|
|
19
|
+
repositoryType: {
|
|
20
|
+
description: "Repository types",
|
|
21
|
+
option: "-t,--repository-type <values>",
|
|
22
|
+
parser: (v) => (0, string_util_1.parseStringList)(v),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async onExec() {
|
|
27
|
+
const verbose = this.globalOptions.verbose ?? 0;
|
|
28
|
+
const configAction = new ConfigAction_1.ConfigAction({
|
|
29
|
+
path: this.globalOptions.config,
|
|
30
|
+
verbose: verbose > 0,
|
|
31
|
+
});
|
|
32
|
+
const config = await configAction.exec();
|
|
33
|
+
const init = new InitAction_1.InitAction(config, {
|
|
34
|
+
repositoryNames: this.options.repository,
|
|
35
|
+
repositoryTypes: this.options.repositoryType,
|
|
36
|
+
verbose: verbose > 0,
|
|
37
|
+
});
|
|
38
|
+
const response = await init.exec();
|
|
39
|
+
const dataFormat = new DataFormat_1.DataFormat({
|
|
40
|
+
items: response,
|
|
41
|
+
json: (item) => ({
|
|
42
|
+
...item,
|
|
43
|
+
error: item.error ? (0, object_util_1.getErrorProperties)(item.error) : null,
|
|
44
|
+
}),
|
|
45
|
+
table: {
|
|
46
|
+
labels: [
|
|
47
|
+
" ",
|
|
48
|
+
"Repository name",
|
|
49
|
+
"Repository type",
|
|
50
|
+
"Repository source",
|
|
51
|
+
"",
|
|
52
|
+
],
|
|
53
|
+
handler: (item) => [
|
|
54
|
+
(0, cli_util_1.resultColumn)(item.error),
|
|
55
|
+
item.repositoryName,
|
|
56
|
+
item.repositoryType,
|
|
57
|
+
item.repositorySource,
|
|
58
|
+
(0, cli_util_1.errorColumn)(item.error, verbose),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (this.globalOptions.outputFormat)
|
|
63
|
+
console.log(dataFormat.format(this.globalOptions.outputFormat));
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.InitCommand = InitCommand;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SnapshotGroupByType } from "../Action/SnapshotsAction";
|
|
2
|
+
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
|
+
import { If } from "../util/ts-util";
|
|
4
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
+
export declare type PruneCommandOptionsType<TResolved = false> = {
|
|
6
|
+
id?: If<TResolved, string[]>;
|
|
7
|
+
longId?: boolean;
|
|
8
|
+
package?: If<TResolved, string[]>;
|
|
9
|
+
repository?: If<TResolved, string[]>;
|
|
10
|
+
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
11
|
+
tag?: If<TResolved, string[]>;
|
|
12
|
+
keepLast?: number;
|
|
13
|
+
keepMinutely?: number;
|
|
14
|
+
keepHourly?: number;
|
|
15
|
+
keepDaily?: number;
|
|
16
|
+
keepWeekly?: number;
|
|
17
|
+
keepMonthly?: number;
|
|
18
|
+
keepYearly?: number;
|
|
19
|
+
groupBy?: If<TResolved, SnapshotGroupByType[]>;
|
|
20
|
+
dryRun?: boolean;
|
|
21
|
+
showAll?: boolean;
|
|
22
|
+
confirm?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare class PruneCommand extends CommandAbstract<PruneCommandOptionsType<false>, PruneCommandOptionsType<true>> {
|
|
25
|
+
onOptions(): import("../util/cli-util").OptionsType<PruneCommandOptionsType<false>, PruneCommandOptionsType<true>>;
|
|
26
|
+
onExec(): Promise<number>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PruneCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const PruneAction_1 = require("../Action/PruneAction");
|
|
6
|
+
const DataFormat_1 = require("../util/DataFormat");
|
|
7
|
+
const cli_util_1 = require("../util/cli-util");
|
|
8
|
+
const string_util_1 = require("../util/string-util");
|
|
9
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
10
|
+
class PruneCommand extends CommandAbstract_1.CommandAbstract {
|
|
11
|
+
onOptions() {
|
|
12
|
+
return this.returnsOptions({
|
|
13
|
+
dryRun: {
|
|
14
|
+
description: "",
|
|
15
|
+
option: "--dry-run",
|
|
16
|
+
parser: undefined,
|
|
17
|
+
},
|
|
18
|
+
groupBy: {
|
|
19
|
+
description: "Group by values (packageName, repositoryName, repositoryType)",
|
|
20
|
+
option: "-g,--group-by <values>",
|
|
21
|
+
defaults: "packageName, repositoryName",
|
|
22
|
+
parser: (v) => (0, string_util_1.parseStringList)(v, [
|
|
23
|
+
"packageName",
|
|
24
|
+
"repositoryName",
|
|
25
|
+
"repositoryType",
|
|
26
|
+
]),
|
|
27
|
+
},
|
|
28
|
+
id: {
|
|
29
|
+
description: "Snapshot id.",
|
|
30
|
+
option: "-i,--id",
|
|
31
|
+
parser: string_util_1.parseStringList,
|
|
32
|
+
},
|
|
33
|
+
keepMinutely: {
|
|
34
|
+
description: "Keep last N minutely snapshots",
|
|
35
|
+
option: "--keepMinutely <number>",
|
|
36
|
+
parser: Number,
|
|
37
|
+
},
|
|
38
|
+
keepDaily: {
|
|
39
|
+
description: "Keep last N daily snapshots",
|
|
40
|
+
option: "--keepDaily <number>",
|
|
41
|
+
parser: Number,
|
|
42
|
+
},
|
|
43
|
+
keepHourly: {
|
|
44
|
+
description: "Keep last N hourly snapshots",
|
|
45
|
+
option: "--keepHourly <number>",
|
|
46
|
+
parser: Number,
|
|
47
|
+
},
|
|
48
|
+
keepLast: {
|
|
49
|
+
description: "Keep last N snapshots",
|
|
50
|
+
option: "--keepLast <number>",
|
|
51
|
+
parser: Number,
|
|
52
|
+
},
|
|
53
|
+
keepMonthly: {
|
|
54
|
+
description: "Keep last N monthly snapshots",
|
|
55
|
+
option: "--keepMonthly <number>",
|
|
56
|
+
parser: Number,
|
|
57
|
+
},
|
|
58
|
+
keepWeekly: {
|
|
59
|
+
description: "Keep last N weekly snapshots",
|
|
60
|
+
option: "--keepWeekly <number>",
|
|
61
|
+
parser: Number,
|
|
62
|
+
},
|
|
63
|
+
keepYearly: {
|
|
64
|
+
description: "Keep last N yearly snapshots",
|
|
65
|
+
option: "--keepYearly <number>",
|
|
66
|
+
parser: Number,
|
|
67
|
+
},
|
|
68
|
+
longId: {
|
|
69
|
+
description: "Show long snapshot id",
|
|
70
|
+
option: "--longId",
|
|
71
|
+
},
|
|
72
|
+
package: {
|
|
73
|
+
description: "Package names",
|
|
74
|
+
option: "-p,--package <values>",
|
|
75
|
+
parser: string_util_1.parseStringList,
|
|
76
|
+
},
|
|
77
|
+
repository: {
|
|
78
|
+
description: "Repository names",
|
|
79
|
+
option: "-r,--repository <values>",
|
|
80
|
+
parser: string_util_1.parseStringList,
|
|
81
|
+
},
|
|
82
|
+
repositoryType: {
|
|
83
|
+
description: "Repository types",
|
|
84
|
+
option: "-t,--repositoryType <values>",
|
|
85
|
+
parser: (v) => (0, string_util_1.parseStringList)(v),
|
|
86
|
+
},
|
|
87
|
+
tag: {
|
|
88
|
+
description: "Tags",
|
|
89
|
+
option: "--tag <values>",
|
|
90
|
+
parser: string_util_1.parseStringList,
|
|
91
|
+
},
|
|
92
|
+
showAll: {
|
|
93
|
+
description: "Show all",
|
|
94
|
+
option: "-a,--showAll",
|
|
95
|
+
},
|
|
96
|
+
confirm: {
|
|
97
|
+
description: "Confirm action",
|
|
98
|
+
option: "--confirm",
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async onExec() {
|
|
103
|
+
const verbose = this.globalOptions.verbose ?? 0;
|
|
104
|
+
const configAction = new ConfigAction_1.ConfigAction({
|
|
105
|
+
path: this.globalOptions.config,
|
|
106
|
+
verbose: verbose > 0,
|
|
107
|
+
});
|
|
108
|
+
const config = await configAction.exec();
|
|
109
|
+
const prune = new PruneAction_1.PruneAction(config, {
|
|
110
|
+
ids: this.options.id,
|
|
111
|
+
packageNames: this.options.package,
|
|
112
|
+
repositoryNames: this.options.repository,
|
|
113
|
+
repositoryTypes: this.options.repositoryType,
|
|
114
|
+
verbose: verbose > 0,
|
|
115
|
+
dryRun: this.options.dryRun || !this.options.confirm,
|
|
116
|
+
groupBy: this.options.groupBy,
|
|
117
|
+
keepLast: this.options.keepLast,
|
|
118
|
+
keepMinutely: this.options.keepMinutely,
|
|
119
|
+
keepHourly: this.options.keepHourly,
|
|
120
|
+
keepDaily: this.options.keepDaily,
|
|
121
|
+
keepMonthly: this.options.keepMonthly,
|
|
122
|
+
keepWeekly: this.options.keepWeekly,
|
|
123
|
+
keepYearly: this.options.keepYearly,
|
|
124
|
+
tags: this.options.tag,
|
|
125
|
+
longId: this.options.longId,
|
|
126
|
+
returnsAll: this.options.showAll,
|
|
127
|
+
});
|
|
128
|
+
const pruneResult = await prune.exec();
|
|
129
|
+
const dataFormat = new DataFormat_1.DataFormat({
|
|
130
|
+
items: pruneResult.snapshots,
|
|
131
|
+
table: {
|
|
132
|
+
labels: [
|
|
133
|
+
"Id.",
|
|
134
|
+
"Date",
|
|
135
|
+
"Package",
|
|
136
|
+
"Repository",
|
|
137
|
+
"Repository type",
|
|
138
|
+
"Exclusion reasons",
|
|
139
|
+
],
|
|
140
|
+
handler: (item) => [
|
|
141
|
+
this.options.longId ? item.id : item.id.slice(0, 8),
|
|
142
|
+
item.date.replace("T", " ").replace("Z", ""),
|
|
143
|
+
item.packageName,
|
|
144
|
+
item.repositoryName,
|
|
145
|
+
item.repositoryType,
|
|
146
|
+
item.exclusionReasons?.join(", ") ?? "",
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
if (this.globalOptions.outputFormat)
|
|
151
|
+
console.log(dataFormat.format(this.globalOptions.outputFormat));
|
|
152
|
+
if (!this.options.confirm && !this.options.dryRun) {
|
|
153
|
+
const answer = await (0, cli_util_1.confirm)(`Delete ${pruneResult.prune}/${pruneResult.total} snapshots?`);
|
|
154
|
+
if (answer)
|
|
155
|
+
await prune.confirm(pruneResult.snapshots);
|
|
156
|
+
}
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.PruneCommand = PruneCommand;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
2
|
+
import { If } from "../util/ts-util";
|
|
3
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
4
|
+
export declare type RestoreCommandOptionsType<TResolved = false> = {
|
|
5
|
+
id: string;
|
|
6
|
+
package?: If<TResolved, string[]>;
|
|
7
|
+
repository?: If<TResolved, string[]>;
|
|
8
|
+
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
9
|
+
tag?: If<TResolved, string[]>;
|
|
10
|
+
};
|
|
11
|
+
export declare class RestoreCommand extends CommandAbstract<RestoreCommandOptionsType<false>, RestoreCommandOptionsType<true>> {
|
|
12
|
+
onOptions(): import("../util/cli-util").OptionsType<RestoreCommandOptionsType<false>, RestoreCommandOptionsType<true>>;
|
|
13
|
+
onExec(): Promise<0 | 1>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestoreCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
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
|
+
const string_util_1 = require("../util/string-util");
|
|
10
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
11
|
+
class RestoreCommand extends CommandAbstract_1.CommandAbstract {
|
|
12
|
+
onOptions() {
|
|
13
|
+
return this.returnsOptions({
|
|
14
|
+
id: {
|
|
15
|
+
description: "Snapshot id",
|
|
16
|
+
option: "-i,--id <id>",
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
package: {
|
|
20
|
+
description: "Package names",
|
|
21
|
+
option: "-p,--package <values>",
|
|
22
|
+
parser: string_util_1.parseStringList,
|
|
23
|
+
},
|
|
24
|
+
repository: {
|
|
25
|
+
description: "Repository names",
|
|
26
|
+
option: "-r,--repository <values>",
|
|
27
|
+
parser: string_util_1.parseStringList,
|
|
28
|
+
},
|
|
29
|
+
repositoryType: {
|
|
30
|
+
description: "Repository types",
|
|
31
|
+
option: "-t,--repository-type <values>",
|
|
32
|
+
parser: (v) => (0, string_util_1.parseStringList)(v),
|
|
33
|
+
},
|
|
34
|
+
tag: {
|
|
35
|
+
description: "Tags",
|
|
36
|
+
option: "--tag <values>",
|
|
37
|
+
parser: string_util_1.parseStringList,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async onExec() {
|
|
42
|
+
const verbose = this.globalOptions.verbose ?? 0;
|
|
43
|
+
const configAction = new ConfigAction_1.ConfigAction({
|
|
44
|
+
path: this.globalOptions.config,
|
|
45
|
+
verbose: verbose > 0,
|
|
46
|
+
});
|
|
47
|
+
const config = await configAction.exec();
|
|
48
|
+
const restore = new RestoreAction_1.RestoreAction(config, {
|
|
49
|
+
snapshotId: this.options.id,
|
|
50
|
+
packageNames: this.options.package,
|
|
51
|
+
repositoryNames: this.options.repository,
|
|
52
|
+
repositoryTypes: this.options.repositoryType,
|
|
53
|
+
tags: this.options.tag,
|
|
54
|
+
verbose: verbose > 0,
|
|
55
|
+
});
|
|
56
|
+
const sessionManager = new RestoreSessionManager_1.RestoreSessionManager({
|
|
57
|
+
driver: new SqliteSessionDriver_1.SqliteSessionDriver({
|
|
58
|
+
verbose: verbose > 1,
|
|
59
|
+
}),
|
|
60
|
+
altDrivers: [
|
|
61
|
+
new ConsoleSessionDriver_1.ConsoleSessionDriver({
|
|
62
|
+
verbose: verbose > 0,
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
verbose: verbose > 1,
|
|
66
|
+
});
|
|
67
|
+
const result = await restore.exec(sessionManager);
|
|
68
|
+
return result ? 0 : 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.RestoreCommand = RestoreCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { If } from "../util/ts-util";
|
|
2
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
3
|
+
export declare type RestoreSessionsCommandOptionsType<TResolved = false> = {
|
|
4
|
+
package?: If<TResolved, string[]>;
|
|
5
|
+
repository?: If<TResolved, string[]>;
|
|
6
|
+
tag?: If<TResolved, string[]>;
|
|
7
|
+
limit?: number | null;
|
|
8
|
+
};
|
|
9
|
+
export declare class RestoreSessionsCommand extends CommandAbstract<RestoreSessionsCommandOptionsType<false>, RestoreSessionsCommandOptionsType<true>> {
|
|
10
|
+
onOptions(): import("../util/cli-util").OptionsType<RestoreSessionsCommandOptionsType<false>, RestoreSessionsCommandOptionsType<true>>;
|
|
11
|
+
onExec(): Promise<number>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestoreSessionsCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const RestoreSessionsAction_1 = require("../Action/RestoreSessionsAction");
|
|
6
|
+
const SqliteSessionDriver_1 = require("../SessionDriver/SqliteSessionDriver");
|
|
7
|
+
const RestoreSessionManager_1 = require("../SessionManager/RestoreSessionManager");
|
|
8
|
+
const DataFormat_1 = require("../util/DataFormat");
|
|
9
|
+
const cli_util_1 = require("../util/cli-util");
|
|
10
|
+
const string_util_1 = require("../util/string-util");
|
|
11
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
12
|
+
class RestoreSessionsCommand extends CommandAbstract_1.CommandAbstract {
|
|
13
|
+
onOptions() {
|
|
14
|
+
return this.returnsOptions({
|
|
15
|
+
package: {
|
|
16
|
+
description: "Package names",
|
|
17
|
+
option: "-p,--package <values>",
|
|
18
|
+
parser: string_util_1.parseStringList,
|
|
19
|
+
},
|
|
20
|
+
repository: {
|
|
21
|
+
description: "Repository names",
|
|
22
|
+
option: "-r,--repository <values>",
|
|
23
|
+
parser: string_util_1.parseStringList,
|
|
24
|
+
},
|
|
25
|
+
tag: {
|
|
26
|
+
description: "Tags",
|
|
27
|
+
option: "--tag <values>",
|
|
28
|
+
parser: string_util_1.parseStringList,
|
|
29
|
+
},
|
|
30
|
+
limit: {
|
|
31
|
+
description: "Limit",
|
|
32
|
+
option: "-l,--limit <value>",
|
|
33
|
+
defaults: 10,
|
|
34
|
+
parser: Number,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async onExec() {
|
|
39
|
+
const verbose = this.globalOptions.verbose ?? 0;
|
|
40
|
+
const configAction = new ConfigAction_1.ConfigAction({
|
|
41
|
+
path: this.globalOptions.config,
|
|
42
|
+
verbose: verbose > 0,
|
|
43
|
+
});
|
|
44
|
+
const config = await configAction.exec();
|
|
45
|
+
const action = new RestoreSessionsAction_1.RestoreSessionsAction(config, {
|
|
46
|
+
packageNames: this.options.package,
|
|
47
|
+
repositoryNames: this.options.repository,
|
|
48
|
+
tags: this.options.tag,
|
|
49
|
+
limit: this.options.limit,
|
|
50
|
+
verbose: verbose > 0,
|
|
51
|
+
});
|
|
52
|
+
const manager = new RestoreSessionManager_1.RestoreSessionManager({
|
|
53
|
+
driver: new SqliteSessionDriver_1.SqliteSessionDriver({
|
|
54
|
+
verbose: verbose > 1,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
const dataFormat = new DataFormat_1.DataFormat({
|
|
58
|
+
items: await action.exec(manager),
|
|
59
|
+
table: {
|
|
60
|
+
labels: [
|
|
61
|
+
" ",
|
|
62
|
+
"Id.",
|
|
63
|
+
"Snapshot id.",
|
|
64
|
+
"Date",
|
|
65
|
+
"Repository",
|
|
66
|
+
"Repository type",
|
|
67
|
+
"Package",
|
|
68
|
+
"",
|
|
69
|
+
],
|
|
70
|
+
handler: (item) => [
|
|
71
|
+
(0, cli_util_1.resultColumn)(item.error, item.state),
|
|
72
|
+
item.id,
|
|
73
|
+
item.snapshotId.slice(0, 8),
|
|
74
|
+
(0, string_util_1.formatDateTime)(item.creationDate),
|
|
75
|
+
item.repositoryName,
|
|
76
|
+
item.repositoryType,
|
|
77
|
+
item.packageName,
|
|
78
|
+
(0, cli_util_1.errorColumn)(item.error, verbose),
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
if (this.globalOptions.outputFormat)
|
|
83
|
+
console.log(dataFormat.format(this.globalOptions.outputFormat));
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.RestoreSessionsCommand = RestoreSessionsCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SnapshotsAction } from "../Action/SnapshotsAction";
|
|
2
|
+
import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
3
|
+
import { If, Unwrap } from "../util/ts-util";
|
|
4
|
+
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
+
export declare type SnapshotsCommandOptionsType<TResolved = false> = {
|
|
6
|
+
id?: If<TResolved, string[]>;
|
|
7
|
+
package?: If<TResolved, string[]>;
|
|
8
|
+
repository?: If<TResolved, string[]>;
|
|
9
|
+
repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
|
|
10
|
+
longId?: boolean;
|
|
11
|
+
last?: If<TResolved, number>;
|
|
12
|
+
lastMinutely?: If<TResolved, number>;
|
|
13
|
+
lastHourly?: If<TResolved, number>;
|
|
14
|
+
lastDaily?: If<TResolved, number>;
|
|
15
|
+
lastWeekly?: If<TResolved, number>;
|
|
16
|
+
lastMonthly?: If<TResolved, number>;
|
|
17
|
+
lastYearly?: If<TResolved, number>;
|
|
18
|
+
groupBy?: If<TResolved, SnapshotsAction["options"]["groupBy"]>;
|
|
19
|
+
tag?: If<TResolved, string[]>;
|
|
20
|
+
};
|
|
21
|
+
export declare type SnapshotsCommandLogType = Unwrap<SnapshotsAction["exec"]>;
|
|
22
|
+
export declare class SnapshotsCommand extends CommandAbstract<SnapshotsCommandOptionsType<false>, SnapshotsCommandOptionsType<true>> {
|
|
23
|
+
onOptions(): import("../util/cli-util").OptionsType<SnapshotsCommandOptionsType<false>, SnapshotsCommandOptionsType<true>>;
|
|
24
|
+
onExec(): Promise<number>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnapshotsCommand = void 0;
|
|
4
|
+
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
+
const SnapshotsAction_1 = require("../Action/SnapshotsAction");
|
|
6
|
+
const DataFormat_1 = require("../util/DataFormat");
|
|
7
|
+
const string_util_1 = require("../util/string-util");
|
|
8
|
+
const CommandAbstract_1 = require("./CommandAbstract");
|
|
9
|
+
class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
|
|
10
|
+
onOptions() {
|
|
11
|
+
return this.returnsOptions({
|
|
12
|
+
groupBy: {
|
|
13
|
+
option: "-g,--group-by <values>",
|
|
14
|
+
description: "Group by values",
|
|
15
|
+
parser: (v) => (0, string_util_1.parseStringList)(v, [
|
|
16
|
+
"packageName",
|
|
17
|
+
"repositoryName",
|
|
18
|
+
"repositoryType",
|
|
19
|
+
]),
|
|
20
|
+
},
|
|
21
|
+
id: {
|
|
22
|
+
option: "-i,--id <ids>",
|
|
23
|
+
description: "Snapshot identifiers",
|
|
24
|
+
parser: string_util_1.parseStringList,
|
|
25
|
+
},
|
|
26
|
+
last: {
|
|
27
|
+
option: "-l,--last <number>",
|
|
28
|
+
description: "Last snapshots",
|
|
29
|
+
parser: Number,
|
|
30
|
+
},
|
|
31
|
+
lastMinutely: {
|
|
32
|
+
option: "--lastMinutely <number>",
|
|
33
|
+
description: "Last minutely snapshots",
|
|
34
|
+
parser: Number,
|
|
35
|
+
},
|
|
36
|
+
lastDaily: {
|
|
37
|
+
option: "--lastDaily <number>",
|
|
38
|
+
description: "Last daily snapshots",
|
|
39
|
+
parser: Number,
|
|
40
|
+
},
|
|
41
|
+
lastHourly: {
|
|
42
|
+
option: "--lastHourly <number>",
|
|
43
|
+
description: "Last hourly snapshots",
|
|
44
|
+
parser: Number,
|
|
45
|
+
},
|
|
46
|
+
lastMonthly: {
|
|
47
|
+
option: "--lastMonthly <number>",
|
|
48
|
+
description: "Last monthly snapshots",
|
|
49
|
+
parser: Number,
|
|
50
|
+
},
|
|
51
|
+
lastWeekly: {
|
|
52
|
+
option: "--lastWeekly <number>",
|
|
53
|
+
description: "Last weekly snapshots",
|
|
54
|
+
parser: Number,
|
|
55
|
+
},
|
|
56
|
+
lastYearly: {
|
|
57
|
+
option: "--lastYearly <number>",
|
|
58
|
+
description: "Last yearly snapshots",
|
|
59
|
+
parser: Number,
|
|
60
|
+
},
|
|
61
|
+
longId: {
|
|
62
|
+
option: "--longId",
|
|
63
|
+
description: "Show long id",
|
|
64
|
+
},
|
|
65
|
+
package: {
|
|
66
|
+
option: "-p,--package <names>",
|
|
67
|
+
description: "Package names",
|
|
68
|
+
parser: string_util_1.parseStringList,
|
|
69
|
+
},
|
|
70
|
+
repository: {
|
|
71
|
+
option: "-r,--repository <names>",
|
|
72
|
+
description: "Repository names",
|
|
73
|
+
parser: string_util_1.parseStringList,
|
|
74
|
+
},
|
|
75
|
+
repositoryType: {
|
|
76
|
+
option: "-t,--repositoryType <names>",
|
|
77
|
+
description: "Repository types",
|
|
78
|
+
parser: (v) => (0, string_util_1.parseStringList)(v),
|
|
79
|
+
},
|
|
80
|
+
tag: {
|
|
81
|
+
description: "Tags",
|
|
82
|
+
option: "--tag <values>",
|
|
83
|
+
parser: string_util_1.parseStringList,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async onExec() {
|
|
88
|
+
const verbose = this.globalOptions.verbose ?? 0;
|
|
89
|
+
const configAction = new ConfigAction_1.ConfigAction({
|
|
90
|
+
path: this.globalOptions.config,
|
|
91
|
+
verbose: verbose > 0,
|
|
92
|
+
});
|
|
93
|
+
const config = await configAction.exec();
|
|
94
|
+
const snapshots = new SnapshotsAction_1.SnapshotsAction(config, {
|
|
95
|
+
ids: this.options.id,
|
|
96
|
+
packageNames: this.options.package,
|
|
97
|
+
repositoryNames: this.options.repository,
|
|
98
|
+
repositoryTypes: this.options.repositoryType,
|
|
99
|
+
last: this.options.last,
|
|
100
|
+
lastMinutely: this.options.lastMinutely,
|
|
101
|
+
lastHourly: this.options.lastHourly,
|
|
102
|
+
lastDaily: this.options.lastDaily,
|
|
103
|
+
lastWeekly: this.options.lastWeekly,
|
|
104
|
+
lastMonthly: this.options.lastMonthly,
|
|
105
|
+
lastYearly: this.options.lastYearly,
|
|
106
|
+
groupBy: this.options.groupBy,
|
|
107
|
+
verbose: verbose > 0,
|
|
108
|
+
tags: this.options.tag,
|
|
109
|
+
});
|
|
110
|
+
const dataFormat = new DataFormat_1.DataFormat({
|
|
111
|
+
items: await snapshots.exec(),
|
|
112
|
+
table: {
|
|
113
|
+
labels: ["Id.", "Date", "Package", "Repository", "Repository type"],
|
|
114
|
+
handler: (item) => [
|
|
115
|
+
this.options.longId ? item.id : item.id.slice(0, 8),
|
|
116
|
+
item.date.replace("T", " ").replace("Z", ""),
|
|
117
|
+
item.packageName,
|
|
118
|
+
item.repositoryName,
|
|
119
|
+
item.repositoryType,
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
if (this.globalOptions.outputFormat)
|
|
124
|
+
console.log(dataFormat.format(this.globalOptions.outputFormat));
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.SnapshotsCommand = SnapshotsCommand;
|