@datatruck/cli 0.32.1 → 0.32.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/config.schema.json +1224 -1271
- package/{Action → lib/Action}/BackupAction.d.ts +9 -9
- package/{Action → lib/Action}/BackupAction.js +27 -8
- package/{Action → lib/Action}/ConfigAction.d.ts +9 -9
- package/{Action → lib/Action}/ConfigAction.js +4 -2
- package/{Action → lib/Action}/CopyAction.d.ts +5 -5
- package/{Action → lib/Action}/InitAction.d.ts +3 -3
- package/{Action → lib/Action}/PruneAction.d.ts +5 -5
- package/{Action → lib/Action}/RestoreAction.d.ts +5 -5
- package/{Action → lib/Action}/SnapshotsAction.d.ts +5 -5
- package/{Command → lib/Command}/BackupCommand.d.ts +2 -2
- package/{Command → lib/Command}/CommandAbstract.d.ts +4 -4
- package/{Command → lib/Command}/ConfigCommand.d.ts +2 -2
- package/{Command → lib/Command}/InitCommand.d.ts +2 -2
- package/{Command → lib/Command}/PruneCommand.d.ts +2 -2
- package/{Command → lib/Command}/RestoreCommand.d.ts +2 -2
- package/{Command → lib/Command}/SnapshotsCommand.d.ts +2 -2
- package/lib/Config/Config.d.ts +28 -0
- package/lib/Config/PackageConfig.d.ts +24 -0
- package/lib/Config/PackageConfig.js +2 -0
- package/lib/Config/PackageRepositoryConfig.d.ts +15 -0
- package/lib/Config/PackageRepositoryConfig.js +2 -0
- package/lib/Config/PrunePolicyConfig.d.ts +2 -0
- package/lib/Config/PrunePolicyConfig.js +2 -0
- package/lib/Config/RepositoryConfig.d.ts +27 -0
- package/lib/Config/RepositoryConfig.js +2 -0
- package/lib/Config/TaskConfig.d.ts +31 -0
- package/lib/Config/TaskConfig.js +2 -0
- package/{Factory → lib/Factory}/CommandFactory.d.ts +5 -5
- package/lib/Factory/RepositoryFactory.d.ts +3 -0
- package/lib/Factory/TaskFactory.d.ts +3 -0
- package/{Repository → lib/Repository}/DatatruckRepository.d.ts +9 -12
- package/{Repository → lib/Repository}/DatatruckRepository.js +1 -38
- package/lib/Repository/GitRepository.d.ts +28 -0
- package/{Repository → lib/Repository}/GitRepository.js +1 -15
- package/{Repository → lib/Repository}/RepositoryAbstract.d.ts +8 -8
- package/{Repository → lib/Repository}/ResticRepository.d.ts +11 -14
- package/{Repository → lib/Repository}/ResticRepository.js +1 -63
- package/{Task → lib/Task}/GitTask.d.ts +2 -4
- package/{Task → lib/Task}/GitTask.js +1 -42
- package/{Task → lib/Task}/MariadbTask.d.ts +2 -4
- package/{Task → lib/Task}/MariadbTask.js +1 -54
- package/{Task → lib/Task}/MssqlTask.d.ts +2 -4
- package/{Task → lib/Task}/MssqlTask.js +1 -14
- package/{Task → lib/Task}/MysqlDumpTask.d.ts +4 -5
- package/{Task → lib/Task}/MysqlDumpTask.js +1 -11
- package/{Task → lib/Task}/PostgresqlDumpTask.d.ts +5 -7
- package/{Task → lib/Task}/PostgresqlDumpTask.js +1 -5
- package/lib/Task/ScriptTask.d.ts +30 -0
- package/lib/Task/ScriptTask.js +55 -0
- package/{Task → lib/Task}/SqlDumpTaskAbstract.d.ts +5 -7
- package/{Task → lib/Task}/SqlDumpTaskAbstract.js +1 -43
- package/{Task → lib/Task}/TaskAbstract.d.ts +2 -2
- package/lib/cli.d.ts +4 -0
- package/lib/config.schema.d.ts +2 -0
- package/lib/config.schema.js +10 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +21 -0
- package/{utils → lib/utils}/DataFormat.d.ts +4 -4
- package/{utils → lib/utils}/Git.d.ts +6 -6
- package/{utils → lib/utils}/Restic.d.ts +14 -14
- package/{utils → lib/utils}/datatruck/config.d.ts +20 -20
- package/lib/utils/datatruck/paths.d.ts +17 -0
- package/{utils → lib/utils}/datatruck/paths.js +3 -3
- package/{utils → lib/utils}/datatruck/repository-server.d.ts +1 -1
- package/{utils → lib/utils}/datatruck/snapshot.d.ts +2 -2
- package/{utils → lib/utils}/date.d.ts +3 -3
- package/{utils → lib/utils}/exit.d.ts +3 -3
- package/{utils → lib/utils}/mysql.d.ts +5 -4
- package/{utils → lib/utils}/mysql.js +2 -2
- package/{utils → lib/utils}/process.d.ts +8 -5
- package/lib/utils/reportSteps.d.ts +26 -0
- package/lib/utils/reportSteps.js +41 -0
- package/lib/utils/spawnSteps.d.ts +36 -0
- package/lib/utils/spawnSteps.js +74 -0
- package/{utils → lib/utils}/string.d.ts +3 -3
- package/{utils → lib/utils}/string.js +3 -3
- package/{utils → lib/utils}/tar.d.ts +0 -8
- package/{utils → lib/utils}/tar.js +1 -18
- package/package.json +39 -25
- package/CHANGELOG.md +0 -569
- package/Config/Config.d.ts +0 -28
- package/Config/Config.js +0 -140
- package/Config/PackageConfig.d.ts +0 -23
- package/Config/PackageConfig.js +0 -51
- package/Config/PackageRepositoryConfig.d.ts +0 -17
- package/Config/PackageRepositoryConfig.js +0 -37
- package/Config/PrunePolicyConfig.d.ts +0 -4
- package/Config/PrunePolicyConfig.js +0 -28
- package/Config/RepositoryConfig.d.ts +0 -24
- package/Config/RepositoryConfig.js +0 -62
- package/Config/TaskConfig.d.ts +0 -27
- package/Config/TaskConfig.js +0 -41
- package/Factory/RepositoryFactory.d.ts +0 -3
- package/Factory/TaskFactory.d.ts +0 -3
- package/JsonSchema/DefinitionEnum.d.ts +0 -26
- package/JsonSchema/DefinitionEnum.js +0 -33
- package/JsonSchema/JsonSchema.d.ts +0 -4
- package/JsonSchema/JsonSchema.js +0 -65
- package/JsonSchema/backup-def.d.ts +0 -30
- package/JsonSchema/backup-def.js +0 -18
- package/JsonSchema/copy-def.d.ts +0 -24
- package/JsonSchema/copy-def.js +0 -15
- package/Repository/GitRepository.d.ts +0 -31
- package/Task/ScriptTask.d.ts +0 -38
- package/Task/ScriptTask.js +0 -163
- package/cli.d.ts +0 -4
- package/index.d.ts +0 -1
- package/utils/datatruck/paths.d.ts +0 -17
- package/utils/path.d.ts +0 -1
- package/utils/path.js +0 -8
- package/utils/schema.d.ts +0 -34
- package/utils/schema.js +0 -36
- package/utils/steps.d.ts +0 -43
- package/utils/steps.js +0 -97
- /package/{Action → lib/Action}/CleanCacheAction.d.ts +0 -0
- /package/{Action → lib/Action}/CleanCacheAction.js +0 -0
- /package/{Action → lib/Action}/CopyAction.js +0 -0
- /package/{Action → lib/Action}/InitAction.js +0 -0
- /package/{Action → lib/Action}/PruneAction.js +0 -0
- /package/{Action → lib/Action}/RestoreAction.js +0 -0
- /package/{Action → lib/Action}/SnapshotsAction.js +0 -0
- /package/{Command → lib/Command}/BackupCommand.js +0 -0
- /package/{Command → lib/Command}/CleanCacheCommand.d.ts +0 -0
- /package/{Command → lib/Command}/CleanCacheCommand.js +0 -0
- /package/{Command → lib/Command}/CommandAbstract.js +0 -0
- /package/{Command → lib/Command}/ConfigCommand.js +0 -0
- /package/{Command → lib/Command}/CopyCommand.d.ts +0 -0
- /package/{Command → lib/Command}/CopyCommand.js +0 -0
- /package/{Command → lib/Command}/InitCommand.js +0 -0
- /package/{Command → lib/Command}/PruneCommand.js +0 -0
- /package/{Command → lib/Command}/RestoreCommand.js +0 -0
- /package/{Command → lib/Command}/SnapshotsCommand.js +0 -0
- /package/{Command → lib/Command}/StartServerCommand.d.ts +0 -0
- /package/{Command → lib/Command}/StartServerCommand.js +0 -0
- /package/{index.js → lib/Config/Config.js} +0 -0
- /package/{Error → lib/Error}/AppError.d.ts +0 -0
- /package/{Error → lib/Error}/AppError.js +0 -0
- /package/{Factory → lib/Factory}/CommandFactory.js +0 -0
- /package/{Factory → lib/Factory}/RepositoryFactory.js +0 -0
- /package/{Factory → lib/Factory}/TaskFactory.js +0 -0
- /package/{Repository → lib/Repository}/RepositoryAbstract.js +0 -0
- /package/{Task → lib/Task}/TaskAbstract.js +0 -0
- /package/{bin.d.ts → lib/bin.d.ts} +0 -0
- /package/{bin.js → lib/bin.js} +0 -0
- /package/{cli.js → lib/cli.js} +0 -0
- /package/{globalData.d.ts → lib/globalData.d.ts} +0 -0
- /package/{globalData.js → lib/globalData.js} +0 -0
- /package/{pkg.d.ts → lib/pkg.d.ts} +0 -0
- /package/{pkg.js → lib/pkg.js} +0 -0
- /package/{utils → lib/utils}/DataFormat.js +0 -0
- /package/{utils → lib/utils}/Git.js +0 -0
- /package/{utils → lib/utils}/Restic.js +0 -0
- /package/{utils → lib/utils}/async.d.ts +0 -0
- /package/{utils → lib/utils}/async.js +0 -0
- /package/{utils → lib/utils}/bytes.d.ts +0 -0
- /package/{utils → lib/utils}/bytes.js +0 -0
- /package/{utils → lib/utils}/cli.d.ts +0 -0
- /package/{utils → lib/utils}/cli.js +0 -0
- /package/{utils → lib/utils}/crypto.d.ts +0 -0
- /package/{utils → lib/utils}/crypto.js +0 -0
- /package/{utils → lib/utils}/datatruck/client.d.ts +0 -0
- /package/{utils → lib/utils}/datatruck/client.js +0 -0
- /package/{utils → lib/utils}/datatruck/config.js +0 -0
- /package/{utils → lib/utils}/datatruck/cron-server.d.ts +0 -0
- /package/{utils → lib/utils}/datatruck/cron-server.js +0 -0
- /package/{utils → lib/utils}/datatruck/repository-server.js +0 -0
- /package/{utils → lib/utils}/datatruck/snapshot.js +0 -0
- /package/{utils → lib/utils}/date.js +0 -0
- /package/{utils → lib/utils}/exit.js +0 -0
- /package/{utils → lib/utils}/fs.d.ts +0 -0
- /package/{utils → lib/utils}/fs.js +0 -0
- /package/{utils → lib/utils}/http.d.ts +0 -0
- /package/{utils → lib/utils}/http.js +0 -0
- /package/{utils → lib/utils}/list.d.ts +0 -0
- /package/{utils → lib/utils}/list.js +0 -0
- /package/{utils → lib/utils}/math.d.ts +0 -0
- /package/{utils → lib/utils}/math.js +0 -0
- /package/{utils → lib/utils}/object.d.ts +0 -0
- /package/{utils → lib/utils}/object.js +0 -0
- /package/{utils → lib/utils}/process.js +0 -0
- /package/{utils → lib/utils}/progress.d.ts +0 -0
- /package/{utils → lib/utils}/progress.js +0 -0
- /package/{utils → lib/utils}/stream.d.ts +0 -0
- /package/{utils → lib/utils}/stream.js +0 -0
- /package/{utils → lib/utils}/temp.d.ts +0 -0
- /package/{utils → lib/utils}/temp.js +0 -0
- /package/{utils → lib/utils}/virtual-fs.d.ts +0 -0
- /package/{utils → lib/utils}/virtual-fs.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Config } from "../Config/Config";
|
|
2
|
+
import { PackageConfig } from "../Config/PackageConfig";
|
|
3
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
4
4
|
import { PreSnapshot } from "../Repository/RepositoryAbstract";
|
|
5
5
|
import { DataFormat } from "../utils/DataFormat";
|
|
6
6
|
import { Listr3TaskResultEnd } from "../utils/list";
|
|
@@ -9,7 +9,7 @@ import { Streams } from "../utils/stream";
|
|
|
9
9
|
import { IfRequireKeys } from "../utils/ts";
|
|
10
10
|
export type BackupActionOptions = {
|
|
11
11
|
repositoryNames?: string[];
|
|
12
|
-
repositoryTypes?:
|
|
12
|
+
repositoryTypes?: RepositoryConfig["type"][];
|
|
13
13
|
packageNames?: string[];
|
|
14
14
|
packageTaskNames?: string[];
|
|
15
15
|
tags?: string[];
|
|
@@ -49,11 +49,11 @@ type Context = {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
export declare class BackupAction<TRequired extends boolean = true> {
|
|
52
|
-
readonly config:
|
|
52
|
+
readonly config: Config;
|
|
53
53
|
readonly options: IfRequireKeys<TRequired, BackupActionOptions>;
|
|
54
|
-
constructor(config:
|
|
54
|
+
constructor(config: Config, options?: IfRequireKeys<TRequired, BackupActionOptions>);
|
|
55
55
|
protected prepareSnapshot(): PreSnapshot;
|
|
56
|
-
protected getPackages(snapshot: PreSnapshot):
|
|
56
|
+
protected getPackages(snapshot: PreSnapshot): PackageConfig[];
|
|
57
57
|
protected getRepositoryNames(repositoryNames: string[]): {
|
|
58
58
|
name: string;
|
|
59
59
|
mirrors: string[];
|
|
@@ -62,14 +62,14 @@ export declare class BackupAction<TRequired extends boolean = true> {
|
|
|
62
62
|
repositoryName: string;
|
|
63
63
|
snapshot: PreSnapshot;
|
|
64
64
|
snapshotPath: string | undefined;
|
|
65
|
-
pkg:
|
|
65
|
+
pkg: PackageConfig;
|
|
66
66
|
onProgress: (data: Progress) => void;
|
|
67
67
|
}): Promise<void>;
|
|
68
68
|
protected copy(data: {
|
|
69
69
|
repositoryName: string;
|
|
70
70
|
mirrorRepositoryName: string;
|
|
71
71
|
snapshot: PreSnapshot;
|
|
72
|
-
pkg:
|
|
72
|
+
pkg: PackageConfig;
|
|
73
73
|
onProgress: (data: Progress) => void;
|
|
74
74
|
}): Promise<void>;
|
|
75
75
|
dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
|
|
@@ -13,7 +13,8 @@ const date_1 = require("../utils/date");
|
|
|
13
13
|
const fs_1 = require("../utils/fs");
|
|
14
14
|
const list_1 = require("../utils/list");
|
|
15
15
|
const progress_1 = require("../utils/progress");
|
|
16
|
-
const
|
|
16
|
+
const reportSteps_1 = require("../utils/reportSteps");
|
|
17
|
+
const spawnSteps_1 = require("../utils/spawnSteps");
|
|
17
18
|
const temp_1 = require("../utils/temp");
|
|
18
19
|
const PruneAction_1 = require("./PruneAction");
|
|
19
20
|
const assert_1 = require("assert");
|
|
@@ -345,13 +346,31 @@ class BackupAction {
|
|
|
345
346
|
(report.when === "error" && !success);
|
|
346
347
|
if (!enabled)
|
|
347
348
|
return task.skip(`Report send skipped: ${reportIndex}`);
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
349
|
+
const message = this.dataFormat(result).format(report.format ?? "list");
|
|
350
|
+
if ((0, spawnSteps_1.isSpawnStep)(report.run)) {
|
|
351
|
+
await (0, spawnSteps_1.runSpawnSteps)(report.run, {
|
|
352
|
+
data: {
|
|
353
|
+
dtt: {
|
|
354
|
+
message,
|
|
355
|
+
result,
|
|
356
|
+
success,
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
verbose: this.options.verbose,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
else if ((0, reportSteps_1.isReportStep)(report.run)) {
|
|
363
|
+
await (0, reportSteps_1.runReportSteps)(report.run, {
|
|
364
|
+
data: {
|
|
365
|
+
title: "DTT Backup",
|
|
366
|
+
message,
|
|
367
|
+
success,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
throw new Error(`Invalid step type: ${report.run.type}`);
|
|
373
|
+
}
|
|
355
374
|
},
|
|
356
375
|
});
|
|
357
376
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlobalOptions } from "../Command/CommandAbstract";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Config } from "../Config/Config";
|
|
3
3
|
import { IfRequireKeys } from "../utils/ts";
|
|
4
4
|
export type ConfigActionOptions = {
|
|
5
5
|
path: string;
|
|
@@ -8,20 +8,20 @@ export type ConfigActionOptions = {
|
|
|
8
8
|
export declare class ConfigAction<TRequired extends boolean = true> {
|
|
9
9
|
readonly options: IfRequireKeys<TRequired, ConfigActionOptions>;
|
|
10
10
|
constructor(options: IfRequireKeys<TRequired, ConfigActionOptions>);
|
|
11
|
-
static validate(config:
|
|
12
|
-
static check(config:
|
|
13
|
-
static normalize(config:
|
|
14
|
-
static parseFile(path: string): Promise<
|
|
11
|
+
static validate(config: Config): void;
|
|
12
|
+
static check(config: Config): void;
|
|
13
|
+
static normalize(config: Config): Config;
|
|
14
|
+
static parseFile(path: string): Promise<Config>;
|
|
15
15
|
static fromGlobalOptionsWithPath(globalOptions: GlobalOptions<true>): Promise<{
|
|
16
16
|
path: string;
|
|
17
|
-
data:
|
|
17
|
+
data: Config;
|
|
18
18
|
} | {
|
|
19
19
|
path: null;
|
|
20
|
-
data:
|
|
20
|
+
data: Config;
|
|
21
21
|
}>;
|
|
22
|
-
static fromGlobalOptions(globalOptions: GlobalOptions<true>): Promise<
|
|
22
|
+
static fromGlobalOptions(globalOptions: GlobalOptions<true>): Promise<Config>;
|
|
23
23
|
exec(): Promise<{
|
|
24
24
|
path: string;
|
|
25
|
-
data:
|
|
25
|
+
data: Config;
|
|
26
26
|
}>;
|
|
27
27
|
}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ConfigAction = void 0;
|
|
7
7
|
const AppError_1 = require("../Error/AppError");
|
|
8
|
-
const
|
|
8
|
+
const config_schema_1 = require("../config.schema");
|
|
9
9
|
const config_1 = require("../utils/datatruck/config");
|
|
10
10
|
const fs_1 = require("../utils/fs");
|
|
11
11
|
const ajv_1 = __importDefault(require("ajv"));
|
|
@@ -16,7 +16,9 @@ class ConfigAction {
|
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|
|
18
18
|
static validate(config) {
|
|
19
|
-
const validate = new ajv_1.default(
|
|
19
|
+
const validate = new ajv_1.default({
|
|
20
|
+
allowUnionTypes: true,
|
|
21
|
+
}).compile(config_schema_1.configSchema);
|
|
20
22
|
if (!validate(config))
|
|
21
23
|
throw new AppError_1.AppError("Json schema error: " + JSON.stringify(validate.errors, null, 2));
|
|
22
24
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config } from "../Config/Config";
|
|
2
2
|
import { Snapshot } from "../Repository/RepositoryAbstract";
|
|
3
3
|
import { DataFormat } from "../utils/DataFormat";
|
|
4
4
|
import { Listr3TaskResultEnd } from "../utils/list";
|
|
5
5
|
import { ProgressMode } from "../utils/progress";
|
|
6
6
|
import { Streams } from "../utils/stream";
|
|
7
7
|
import { IfRequireKeys } from "../utils/ts";
|
|
8
|
-
export type
|
|
8
|
+
export type CopyActionOptions = {
|
|
9
9
|
ids?: string[];
|
|
10
10
|
last?: number;
|
|
11
11
|
repositoryName: string;
|
|
@@ -32,9 +32,9 @@ export type Context = {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
export declare class CopyAction<TRequired extends boolean = true> {
|
|
35
|
-
readonly config:
|
|
36
|
-
readonly options: IfRequireKeys<TRequired,
|
|
37
|
-
constructor(config:
|
|
35
|
+
readonly config: Config;
|
|
36
|
+
readonly options: IfRequireKeys<TRequired, CopyActionOptions>;
|
|
37
|
+
constructor(config: Config, options: IfRequireKeys<TRequired, CopyActionOptions>);
|
|
38
38
|
dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
|
|
39
39
|
streams?: Streams;
|
|
40
40
|
verbose?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config } from "../Config/Config";
|
|
2
2
|
import { IfRequireKeys } from "../utils/ts";
|
|
3
3
|
export type InitActionOptions = {
|
|
4
4
|
repositoryNames?: string[];
|
|
@@ -6,9 +6,9 @@ export type InitActionOptions = {
|
|
|
6
6
|
verbose?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare class InitAction<TRequired extends boolean = true> {
|
|
9
|
-
readonly config:
|
|
9
|
+
readonly config: Config;
|
|
10
10
|
readonly options: IfRequireKeys<TRequired, InitActionOptions>;
|
|
11
|
-
constructor(config:
|
|
11
|
+
constructor(config: Config, options: IfRequireKeys<TRequired, InitActionOptions>);
|
|
12
12
|
exec(): Promise<{
|
|
13
13
|
repositoryName: string;
|
|
14
14
|
repositoryType: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { Config } from "../Config/Config";
|
|
2
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
3
3
|
import { KeepObject } from "../utils/date";
|
|
4
4
|
import { IfRequireKeys } from "../utils/ts";
|
|
5
5
|
import { ExtendedSnapshot, SnapshotsActionOptions } from "./SnapshotsAction";
|
|
@@ -7,7 +7,7 @@ export type PruneActionsOptions = KeepObject & {
|
|
|
7
7
|
ids?: string[];
|
|
8
8
|
packageNames?: string[];
|
|
9
9
|
repositoryNames?: string[];
|
|
10
|
-
repositoryTypes?:
|
|
10
|
+
repositoryTypes?: RepositoryConfig["type"][];
|
|
11
11
|
tags?: string[];
|
|
12
12
|
verbose?: boolean;
|
|
13
13
|
groupBy?: SnapshotsActionOptions["groupBy"];
|
|
@@ -23,9 +23,9 @@ export type PruneResult = {
|
|
|
23
23
|
})[];
|
|
24
24
|
};
|
|
25
25
|
export declare class PruneAction<TRequired extends boolean = true> {
|
|
26
|
-
readonly config:
|
|
26
|
+
readonly config: Config;
|
|
27
27
|
readonly options: IfRequireKeys<TRequired, PruneActionsOptions>;
|
|
28
|
-
constructor(config:
|
|
28
|
+
constructor(config: Config, options: IfRequireKeys<TRequired, PruneActionsOptions>);
|
|
29
29
|
confirm(snapshots: PruneResult["snapshots"]): Promise<void>;
|
|
30
30
|
exec(): Promise<PruneResult>;
|
|
31
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { Config } from "../Config/Config";
|
|
2
|
+
import { PackageConfig } from "../Config/PackageConfig";
|
|
3
3
|
import { Snapshot } from "../Repository/RepositoryAbstract";
|
|
4
4
|
import { TaskAbstract } from "../Task/TaskAbstract";
|
|
5
5
|
import { DataFormat } from "../utils/DataFormat";
|
|
@@ -37,15 +37,15 @@ type Context = {
|
|
|
37
37
|
restore: RestoreSnapshot;
|
|
38
38
|
};
|
|
39
39
|
export declare class RestoreAction<TRequired extends boolean = true> {
|
|
40
|
-
readonly config:
|
|
40
|
+
readonly config: Config;
|
|
41
41
|
readonly options: IfRequireKeys<TRequired, RestoreActionOptions>;
|
|
42
42
|
protected taskErrors: Record<string, Error[]>;
|
|
43
43
|
protected repoErrors: Record<string, Error[]>;
|
|
44
|
-
constructor(config:
|
|
44
|
+
constructor(config: Config, options: IfRequireKeys<TRequired, RestoreActionOptions>);
|
|
45
45
|
protected findSnapshots(): Promise<RestoreSnapshot[]>;
|
|
46
46
|
protected groupSnapshots(snapshots: RestoreSnapshot[]): RestoreSnapshot[];
|
|
47
47
|
protected restore(data: {
|
|
48
|
-
pkg:
|
|
48
|
+
pkg: PackageConfig;
|
|
49
49
|
task: TaskAbstract | undefined;
|
|
50
50
|
snapshot: RestoreSnapshot;
|
|
51
51
|
gc: GargabeCollector;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { Config } from "../Config/Config";
|
|
2
|
+
import { RepositoryConfigEnabledAction } from "../Config/RepositoryConfig";
|
|
3
3
|
import { Snapshot } from "../Repository/RepositoryAbstract";
|
|
4
4
|
import { IfRequireKeys } from "../utils/ts";
|
|
5
5
|
export type SnapshotGroupByType = keyof Pick<ExtendedSnapshot, "packageName" | "repositoryName" | "repositoryType">;
|
|
@@ -27,8 +27,8 @@ export type ExtendedSnapshot = {
|
|
|
27
27
|
repositoryType: string;
|
|
28
28
|
} & Snapshot;
|
|
29
29
|
export declare class SnapshotsAction<TRequired extends boolean = true> {
|
|
30
|
-
readonly config:
|
|
30
|
+
readonly config: Config;
|
|
31
31
|
readonly options: IfRequireKeys<TRequired, SnapshotsActionOptions>;
|
|
32
|
-
constructor(config:
|
|
33
|
-
exec(sourceAction?:
|
|
32
|
+
constructor(config: Config, options: IfRequireKeys<TRequired, SnapshotsActionOptions>);
|
|
33
|
+
exec(sourceAction?: RepositoryConfigEnabledAction): Promise<ExtendedSnapshot[]>;
|
|
34
34
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BackupAction } from "../Action/BackupAction";
|
|
2
|
-
import {
|
|
2
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
5
|
export type BackupCommandOptions<TResolved = false> = {
|
|
6
6
|
package?: If<TResolved, string[]>;
|
|
7
7
|
packageTask?: If<TResolved, string[]>;
|
|
8
8
|
repository?: If<TResolved, string[]>;
|
|
9
|
-
repositoryType?: If<TResolved,
|
|
9
|
+
repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
|
|
10
10
|
tag?: If<TResolved, string[]>;
|
|
11
11
|
dryRun?: boolean;
|
|
12
12
|
date?: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Config } from "../Config/Config";
|
|
2
|
+
import { DataFormatType } from "../utils/DataFormat";
|
|
3
3
|
import { OptionsType } from "../utils/cli";
|
|
4
4
|
import { ProgressMode } from "../utils/progress";
|
|
5
5
|
import { Streams } from "../utils/stream";
|
|
6
6
|
import { If, SimilarObject } from "../utils/ts";
|
|
7
7
|
export type GlobalOptions<TResolved = false> = {
|
|
8
|
-
config: string |
|
|
9
|
-
outputFormat?:
|
|
8
|
+
config: string | Config;
|
|
9
|
+
outputFormat?: DataFormatType;
|
|
10
10
|
verbose?: number;
|
|
11
11
|
tty?: If<TResolved, "auto" | boolean, "auto" | "true" | "false">;
|
|
12
12
|
progress?: If<TResolved, ProgressMode, Exclude<ProgressMode, boolean> | "true" | "false">;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ConfigAction } from "../Action/ConfigAction";
|
|
2
|
-
import {
|
|
2
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
5
|
export type ConfigCommandOptions<TResolved = false> = {
|
|
6
6
|
package?: If<TResolved, string[]>;
|
|
7
7
|
packageTask?: If<TResolved, string[]>;
|
|
8
8
|
repository?: If<TResolved, string[]>;
|
|
9
|
-
repositoryType?: If<TResolved,
|
|
9
|
+
repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
|
|
10
10
|
};
|
|
11
11
|
export type ConfigCommandResult = Unwrap<ConfigAction["exec"]>;
|
|
12
12
|
export declare class ConfigCommand extends CommandAbstract<ConfigCommandOptions<false>, ConfigCommandOptions<true>> {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { InitAction } from "../Action/InitAction";
|
|
2
|
-
import {
|
|
2
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
5
|
export type InitCommandOptions<TResolved = false> = {
|
|
6
6
|
repository?: If<TResolved, string[]>;
|
|
7
|
-
repositoryType?: If<TResolved,
|
|
7
|
+
repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
|
|
8
8
|
};
|
|
9
9
|
export type InitCommandResult = Unwrap<InitAction["exec"]>;
|
|
10
10
|
export declare class InitCommand extends CommandAbstract<InitCommandOptions<false>, InitCommandOptions<true>> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SnapshotGroupByType } from "../Action/SnapshotsAction";
|
|
2
|
-
import {
|
|
2
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
3
3
|
import { KeepObject } from "../utils/date";
|
|
4
4
|
import { If } from "../utils/ts";
|
|
5
5
|
import { CommandAbstract } from "./CommandAbstract";
|
|
@@ -8,7 +8,7 @@ export type PruneCommandOptions<TResolved = false> = KeepObject & {
|
|
|
8
8
|
longId?: boolean;
|
|
9
9
|
package?: If<TResolved, string[]>;
|
|
10
10
|
repository?: If<TResolved, string[]>;
|
|
11
|
-
repositoryType?: If<TResolved,
|
|
11
|
+
repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
|
|
12
12
|
tag?: If<TResolved, string[]>;
|
|
13
13
|
groupBy?: If<TResolved, SnapshotGroupByType[]>;
|
|
14
14
|
dryRun?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
2
2
|
import { If } from "../utils/ts";
|
|
3
3
|
import { CommandAbstract } from "./CommandAbstract";
|
|
4
4
|
export type RestoreCommandOptionsType<TResolved = false> = {
|
|
@@ -7,7 +7,7 @@ export type RestoreCommandOptionsType<TResolved = false> = {
|
|
|
7
7
|
packageTask?: If<TResolved, string[]>;
|
|
8
8
|
packageConfig?: boolean;
|
|
9
9
|
repository?: If<TResolved, string[]>;
|
|
10
|
-
repositoryType?: If<TResolved,
|
|
10
|
+
repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
|
|
11
11
|
tag?: If<TResolved, string[]>;
|
|
12
12
|
initial?: boolean;
|
|
13
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SnapshotsAction } from "../Action/SnapshotsAction";
|
|
2
|
-
import {
|
|
2
|
+
import { RepositoryConfig } from "../Config/RepositoryConfig";
|
|
3
3
|
import { If, Unwrap } from "../utils/ts";
|
|
4
4
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
5
|
export type SnapshotsCommandOptions<TResolved = false> = {
|
|
@@ -8,7 +8,7 @@ export type SnapshotsCommandOptions<TResolved = false> = {
|
|
|
8
8
|
packageTask?: If<TResolved, string[]>;
|
|
9
9
|
packageConfig?: boolean;
|
|
10
10
|
repository?: If<TResolved, string[]>;
|
|
11
|
-
repositoryType?: If<TResolved,
|
|
11
|
+
repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
|
|
12
12
|
longId?: boolean;
|
|
13
13
|
last?: If<TResolved, number>;
|
|
14
14
|
lastMinutely?: If<TResolved, number>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DataFormatType } from "../utils/DataFormat";
|
|
2
|
+
import { DatatruckCronServerOptions } from "../utils/datatruck/cron-server";
|
|
3
|
+
import { DatatruckRepositoryServerOptions } from "../utils/datatruck/repository-server";
|
|
4
|
+
import { ReportStep } from "../utils/reportSteps";
|
|
5
|
+
import { SpawnStep } from "../utils/spawnSteps";
|
|
6
|
+
import { PackageConfig } from "./PackageConfig";
|
|
7
|
+
import { PrunePolicyConfig } from "./PrunePolicyConfig";
|
|
8
|
+
import { RepositoryConfig } from "./RepositoryConfig";
|
|
9
|
+
export type Config = {
|
|
10
|
+
$schema?: string;
|
|
11
|
+
tempDir?: string;
|
|
12
|
+
minFreeDiskSpace?: string | number;
|
|
13
|
+
repositories: RepositoryConfig[];
|
|
14
|
+
packages: PackageConfig[];
|
|
15
|
+
server?: DatatruckServerOptions;
|
|
16
|
+
reports?: ReportConfig[];
|
|
17
|
+
prunePolicy?: PrunePolicyConfig;
|
|
18
|
+
};
|
|
19
|
+
export type DatatruckServerOptions = {
|
|
20
|
+
log?: boolean;
|
|
21
|
+
repository?: DatatruckRepositoryServerOptions;
|
|
22
|
+
cron?: DatatruckCronServerOptions;
|
|
23
|
+
};
|
|
24
|
+
export type ReportConfig = {
|
|
25
|
+
when?: "success" | "error";
|
|
26
|
+
format?: Exclude<DataFormatType, "custom" | "tpl">;
|
|
27
|
+
run: SpawnStep | ReportStep;
|
|
28
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SpawnStep } from "../utils/spawnSteps";
|
|
2
|
+
import { PackageRepositoryConfig } from "./PackageRepositoryConfig";
|
|
3
|
+
import { PrunePolicyConfig } from "./PrunePolicyConfig";
|
|
4
|
+
import type { TaskConfig } from "./TaskConfig";
|
|
5
|
+
export type Meta = {
|
|
6
|
+
[name: string]: any;
|
|
7
|
+
};
|
|
8
|
+
export type PackageConfig = {
|
|
9
|
+
name: string;
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
task?: TaskConfig;
|
|
12
|
+
path?: string;
|
|
13
|
+
restorePath?: string;
|
|
14
|
+
meta?: Meta;
|
|
15
|
+
restorePermissions?: {
|
|
16
|
+
uid: string | number;
|
|
17
|
+
gid: string | number;
|
|
18
|
+
};
|
|
19
|
+
include?: (string | SpawnStep)[];
|
|
20
|
+
exclude?: (string | SpawnStep)[];
|
|
21
|
+
repositoryNames?: string[];
|
|
22
|
+
prunePolicy?: PrunePolicyConfig;
|
|
23
|
+
repositoryConfigs?: PackageRepositoryConfig[];
|
|
24
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DatatruckPackageRepositoryConfig, datatruckRepositoryName } from "../Repository/DatatruckRepository";
|
|
2
|
+
import { GitPackageRepositoryConfig, gitRepositoryName } from "../Repository/GitRepository";
|
|
3
|
+
import { ResticPackageRepositoryConfig, resticRepositoryName } from "../Repository/ResticRepository";
|
|
4
|
+
export type PackageRepositoryConfig = {
|
|
5
|
+
names?: string[];
|
|
6
|
+
} & ({
|
|
7
|
+
type: typeof resticRepositoryName;
|
|
8
|
+
config: ResticPackageRepositoryConfig;
|
|
9
|
+
} | {
|
|
10
|
+
type: typeof datatruckRepositoryName;
|
|
11
|
+
config: DatatruckPackageRepositoryConfig;
|
|
12
|
+
} | {
|
|
13
|
+
type: typeof gitRepositoryName;
|
|
14
|
+
config: GitPackageRepositoryConfig;
|
|
15
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DatatruckRepositoryConfig, datatruckRepositoryName } from "../Repository/DatatruckRepository";
|
|
2
|
+
import { GitRepositoryConfig, gitRepositoryName } from "../Repository/GitRepository";
|
|
3
|
+
import { ResticRepositoryConfig, resticRepositoryName } from "../Repository/ResticRepository";
|
|
4
|
+
export type RepositoryConfigType = RepositoryConfig["type"];
|
|
5
|
+
export type RepositoryConfigEnabledAction = "backup" | "init" | "prune" | "restore" | "snapshots";
|
|
6
|
+
export type RepositoryEnabledObject = {
|
|
7
|
+
[K in "defaults" | RepositoryConfigEnabledAction]?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ResticRepositoryConfigItem = {
|
|
10
|
+
type: typeof resticRepositoryName;
|
|
11
|
+
config: ResticRepositoryConfig;
|
|
12
|
+
};
|
|
13
|
+
export type DatatruckRepositoryConfigItem = {
|
|
14
|
+
type: typeof datatruckRepositoryName;
|
|
15
|
+
config: DatatruckRepositoryConfig;
|
|
16
|
+
};
|
|
17
|
+
export type GitRepositoryConfigItem = {
|
|
18
|
+
type: typeof gitRepositoryName;
|
|
19
|
+
config: GitRepositoryConfig;
|
|
20
|
+
};
|
|
21
|
+
type CommonRepositoryConfig = {
|
|
22
|
+
name: string;
|
|
23
|
+
mirrorRepoNames?: string[];
|
|
24
|
+
enabled?: boolean | RepositoryEnabledObject;
|
|
25
|
+
};
|
|
26
|
+
export type RepositoryConfig = CommonRepositoryConfig & (ResticRepositoryConfigItem | DatatruckRepositoryConfigItem | GitRepositoryConfigItem);
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GitTaskConfig, gitTaskName } from "../Task/GitTask";
|
|
2
|
+
import { MariadbTaskConfig, mariadbTaskName } from "../Task/MariadbTask";
|
|
3
|
+
import { MssqlTaskConfig, mssqlTaskName } from "../Task/MssqlTask";
|
|
4
|
+
import { MysqlDumpTaskConfig, mysqlDumpTaskName } from "../Task/MysqlDumpTask";
|
|
5
|
+
import { PostgresqlDumpTaskConfig, postgresqlDumpTaskName } from "../Task/PostgresqlDumpTask";
|
|
6
|
+
import { ScriptTaskConfig, scriptTaskName } from "../Task/ScriptTask";
|
|
7
|
+
export type GitTaskConfigItem = {
|
|
8
|
+
name: typeof gitTaskName;
|
|
9
|
+
config: GitTaskConfig;
|
|
10
|
+
};
|
|
11
|
+
export type MariadbTaskConfigItem = {
|
|
12
|
+
name: typeof mariadbTaskName;
|
|
13
|
+
config: MariadbTaskConfig;
|
|
14
|
+
};
|
|
15
|
+
export type MssqlTaskConfigItem = {
|
|
16
|
+
name: typeof mssqlTaskName;
|
|
17
|
+
config: MssqlTaskConfig;
|
|
18
|
+
};
|
|
19
|
+
export type MysqlDumpTaskConfigItem = {
|
|
20
|
+
name: typeof mysqlDumpTaskName;
|
|
21
|
+
config: MysqlDumpTaskConfig;
|
|
22
|
+
};
|
|
23
|
+
export type PostgresqlDumpTaskConfigItem = {
|
|
24
|
+
name: typeof postgresqlDumpTaskName;
|
|
25
|
+
config: PostgresqlDumpTaskConfig;
|
|
26
|
+
};
|
|
27
|
+
export type ScriptTaskConfigItem = {
|
|
28
|
+
name: typeof scriptTaskName;
|
|
29
|
+
config: ScriptTaskConfig;
|
|
30
|
+
};
|
|
31
|
+
export type TaskConfig = GitTaskConfigItem | MariadbTaskConfigItem | MssqlTaskConfigItem | MysqlDumpTaskConfigItem | PostgresqlDumpTaskConfigItem | ScriptTaskConfigItem;
|
|
@@ -20,7 +20,7 @@ export declare enum CommandEnum {
|
|
|
20
20
|
cleanCache = "clean-cache",
|
|
21
21
|
startServer = "start-server"
|
|
22
22
|
}
|
|
23
|
-
export type
|
|
23
|
+
export type OptionsMap = {
|
|
24
24
|
[CommandEnum.config]: ConfigCommandOptions;
|
|
25
25
|
[CommandEnum.init]: InitCommandOptions;
|
|
26
26
|
[CommandEnum.snapshots]: SnapshotsCommandOptions;
|
|
@@ -31,15 +31,15 @@ export type OptionsMapType = {
|
|
|
31
31
|
[CommandEnum.cleanCache]: CleanCacheActionOptions;
|
|
32
32
|
[CommandEnum.startServer]: StartServerCommandOptions;
|
|
33
33
|
};
|
|
34
|
-
export type
|
|
34
|
+
export type LogMap = {
|
|
35
35
|
[CommandEnum.config]: ConfigCommandResult;
|
|
36
36
|
[CommandEnum.init]: InitCommandResult;
|
|
37
37
|
[CommandEnum.snapshots]: SnapshotsCommandResult;
|
|
38
38
|
[CommandEnum.backup]: BackupCommandResult;
|
|
39
39
|
};
|
|
40
|
-
export declare function CommandFactory<TCommand extends keyof
|
|
41
|
-
export declare function exec<TCommand extends keyof
|
|
40
|
+
export declare function CommandFactory<TCommand extends keyof OptionsMap>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMap[TCommand], streams?: Partial<Streams>, configPath?: string): StartServerCommand;
|
|
41
|
+
export declare function exec<TCommand extends keyof OptionsMap>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMap[TCommand], streams?: Partial<Streams>): Promise<number>;
|
|
42
42
|
export declare function createActionInterface(globalOptions: GlobalOptions<true>): {
|
|
43
|
-
[K in keyof
|
|
43
|
+
[K in keyof OptionsMap as `${K}`]: (options: OptionsMap[K]) => Promise<K extends keyof LogMap ? LogMap[K] : never>;
|
|
44
44
|
};
|
|
45
45
|
export declare function CommandConstructorFactory(type: CommandEnum): typeof StartServerCommand;
|