@datatruck/cli 0.30.1 → 0.32.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.js +4 -8
- package/Action/ConfigAction.d.ts +1 -0
- package/Action/ConfigAction.js +8 -7
- package/Action/CopyAction.js +1 -1
- package/Action/RestoreAction.js +1 -1
- package/CHANGELOG.md +22 -0
- package/Command/BackupCommand.d.ts +1 -1
- package/Command/CleanCacheCommand.d.ts +1 -1
- package/Command/CommandAbstract.d.ts +2 -1
- package/Command/CommandAbstract.js +3 -1
- package/Command/CopyCommand.d.ts +1 -1
- package/Command/RestoreCommand.d.ts +1 -1
- package/Command/StartServerCommand.js +31 -8
- package/Config/Config.d.ts +7 -1
- package/Config/Config.js +79 -26
- package/Config/RepositoryConfig.d.ts +1 -0
- package/Config/RepositoryConfig.js +6 -1
- package/Factory/CommandFactory.d.ts +1 -1
- package/Factory/CommandFactory.js +2 -2
- package/JsonSchema/backup-def.d.ts +30 -0
- package/JsonSchema/backup-def.js +18 -0
- package/JsonSchema/copy-def.d.ts +24 -0
- package/JsonSchema/copy-def.js +15 -0
- package/Task/ScriptTask.d.ts +2 -11
- package/Task/ScriptTask.js +27 -33
- package/cli.js +1 -1
- package/config.schema.json +227 -40
- package/package.json +5 -4
- package/pkg.d.ts +6 -0
- package/pkg.js +10 -0
- package/utils/cli.d.ts +4 -1
- package/utils/cli.js +23 -3
- package/utils/datatruck/client.js +3 -3
- package/utils/datatruck/cron-server.d.ts +23 -0
- package/utils/datatruck/cron-server.js +59 -0
- package/utils/datatruck/paths.js +4 -6
- package/utils/datatruck/{server.d.ts → repository-server.d.ts} +12 -5
- package/utils/datatruck/{server.js → repository-server.js} +48 -26
- package/utils/fs.js +19 -18
- package/utils/http.d.ts +8 -2
- package/utils/http.js +12 -14
- package/utils/object.d.ts +1 -1
- package/utils/object.js +6 -6
- package/utils/schema.d.ts +34 -0
- package/utils/schema.js +36 -0
- package/utils/steps.d.ts +10 -10
- package/utils/steps.js +22 -8
- package/utils/string.d.ts +0 -3
- package/utils/string.js +22 -42
- package/utils/ObjectVault.d.ts +0 -13
- package/utils/ObjectVault.js +0 -29
package/Action/BackupAction.js
CHANGED
|
@@ -117,7 +117,7 @@ class BackupAction {
|
|
|
117
117
|
backups: result.filter((r) => !r.error && r.key === "backup")
|
|
118
118
|
.length,
|
|
119
119
|
copies: result.filter((r) => !r.error && r.key === "copy").length,
|
|
120
|
-
})
|
|
120
|
+
}, color)
|
|
121
121
|
: item.key === "report"
|
|
122
122
|
? item.data.type
|
|
123
123
|
: "";
|
|
@@ -312,14 +312,10 @@ class BackupAction {
|
|
|
312
312
|
return task.skip(`Report send skipped: ${reportIndex}`);
|
|
313
313
|
const text = this.dataFormat(result).format(report.format ?? "list");
|
|
314
314
|
await (0, steps_1.runSteps)(report.run, {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
telegram: { vars: { TEXT: text } },
|
|
318
|
-
node: {
|
|
319
|
-
vars: {
|
|
320
|
-
dtt: { report: text, result },
|
|
321
|
-
},
|
|
315
|
+
vars: {
|
|
316
|
+
dtt: { title: "DTT Backup", text, result, success },
|
|
322
317
|
},
|
|
318
|
+
verbose: this.options.verbose,
|
|
323
319
|
});
|
|
324
320
|
},
|
|
325
321
|
});
|
package/Action/ConfigAction.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class ConfigAction<TRequired extends boolean = true> {
|
|
|
11
11
|
static validate(config: ConfigType): void;
|
|
12
12
|
static check(config: ConfigType): void;
|
|
13
13
|
static normalize(config: ConfigType): ConfigType;
|
|
14
|
+
static parseFile(path: string): Promise<ConfigType>;
|
|
14
15
|
static fromGlobalOptionsWithPath(globalOptions: GlobalOptions<true>): Promise<{
|
|
15
16
|
path: string;
|
|
16
17
|
data: ConfigType;
|
package/Action/ConfigAction.js
CHANGED
|
@@ -63,6 +63,12 @@ class ConfigAction {
|
|
|
63
63
|
});
|
|
64
64
|
return config;
|
|
65
65
|
}
|
|
66
|
+
static async parseFile(path) {
|
|
67
|
+
const config = await (0, fs_1.parseFile)(path, "config");
|
|
68
|
+
ConfigAction.validate(config);
|
|
69
|
+
ConfigAction.check(config);
|
|
70
|
+
return ConfigAction.normalize(config);
|
|
71
|
+
}
|
|
66
72
|
static async fromGlobalOptionsWithPath(globalOptions) {
|
|
67
73
|
if (typeof globalOptions.config !== "string")
|
|
68
74
|
return {
|
|
@@ -81,13 +87,8 @@ class ConfigAction {
|
|
|
81
87
|
}
|
|
82
88
|
async exec() {
|
|
83
89
|
const path = await (0, fs_1.findFile)(this.options.path, "datatruck.config", fs_1.parseFileExtensions, "Config path not found");
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
ConfigAction.check(config);
|
|
87
|
-
return {
|
|
88
|
-
path,
|
|
89
|
-
data: ConfigAction.normalize(config),
|
|
90
|
-
};
|
|
90
|
+
const data = await ConfigAction.parseFile(path);
|
|
91
|
+
return { path, data };
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
exports.ConfigAction = ConfigAction;
|
package/Action/CopyAction.js
CHANGED
|
@@ -40,7 +40,7 @@ class CopyAction {
|
|
|
40
40
|
errors: item.data.errors,
|
|
41
41
|
copied: items.filter((i) => i.key === "copy" && !i.error && !i.data.skipped).length,
|
|
42
42
|
skipped: items.filter((i) => i.key === "copy" && !i.error && i.data.skipped).length,
|
|
43
|
-
})
|
|
43
|
+
}, color)
|
|
44
44
|
: "";
|
|
45
45
|
};
|
|
46
46
|
return new DataFormat_1.DataFormat({
|
package/Action/RestoreAction.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @datatruck/cli
|
|
2
2
|
|
|
3
|
+
## 0.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`7d755ba`](https://github.com/swordev/datatruck/commit/7d755bac0edf7aea719446f6bfcee5bea0fe9a90) Thanks [@juanrgm](https://github.com/juanrgm)! - Reload repository server config
|
|
8
|
+
|
|
9
|
+
- [`9dba106`](https://github.com/swordev/datatruck/commit/9dba106865da2d4327282d65deecee5a03e49b49) Thanks [@juanrgm](https://github.com/juanrgm)! - Update to Node.js 20
|
|
10
|
+
|
|
11
|
+
- [`113ee82`](https://github.com/swordev/datatruck/commit/113ee8258951028d54b798eaaa813982222c20e8) Thanks [@juanrgm](https://github.com/juanrgm)! - Add `ntfy` step
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`c24eea2`](https://github.com/swordev/datatruck/commit/c24eea21b41d78451d5eabd65923daa26dcad78a) Thanks [@juanrgm](https://github.com/juanrgm)! - Simplify step configs
|
|
16
|
+
|
|
17
|
+
## 0.31.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [`c98324e`](https://github.com/swordev/datatruck/commit/c98324ebbb5b43113f1bb6d9a07bd905b5883729) Thanks [@juanrgm](https://github.com/juanrgm)! - Add cron server
|
|
22
|
+
|
|
23
|
+
- [`9b40aad`](https://github.com/swordev/datatruck/commit/9b40aadc3ba57db15f14ae08c342b7170d61aa5d) Thanks [@juanrgm](https://github.com/juanrgm)! - Add multiple backends to the datatruck repository
|
|
24
|
+
|
|
3
25
|
## 0.30.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -15,5 +15,5 @@ export type BackupCommandOptions<TResolved = false> = {
|
|
|
15
15
|
export type BackupCommandResult = Unwrap<BackupAction["exec"]>;
|
|
16
16
|
export declare class BackupCommand extends CommandAbstract<BackupCommandOptions<false>, BackupCommandOptions<true>> {
|
|
17
17
|
onOptions(): import("../utils/cli").OptionsType<BackupCommandOptions<false>, BackupCommandOptions<true>>;
|
|
18
|
-
onExec(): Promise<
|
|
18
|
+
onExec(): Promise<1 | 0>;
|
|
19
19
|
}
|
|
@@ -2,5 +2,5 @@ import { CommandAbstract } from "./CommandAbstract";
|
|
|
2
2
|
export type CleanCacheCommandOptions<TResolved = false> = {};
|
|
3
3
|
export declare class CleanCacheCommand extends CommandAbstract<CleanCacheCommandOptions<false>, CleanCacheCommandOptions<true>> {
|
|
4
4
|
onOptions(): import("../utils/cli").OptionsType<CleanCacheCommandOptions<false>, CleanCacheCommandOptions<true>>;
|
|
5
|
-
onExec(): Promise<
|
|
5
|
+
onExec(): Promise<1 | 0>;
|
|
6
6
|
}
|
|
@@ -16,9 +16,10 @@ export type CommandConstructor<TUnresolvedOptions, TOptions extends SimilarObjec
|
|
|
16
16
|
};
|
|
17
17
|
export declare abstract class CommandAbstract<TUnresolvedOptions, TOptions extends SimilarObject<TUnresolvedOptions>> {
|
|
18
18
|
readonly globalOptions: GlobalOptions<true>;
|
|
19
|
+
readonly configPath?: string | undefined;
|
|
19
20
|
readonly options: TOptions;
|
|
20
21
|
readonly streams: Streams;
|
|
21
|
-
constructor(globalOptions: GlobalOptions<true>, options: TUnresolvedOptions, streams?: Partial<Streams
|
|
22
|
+
constructor(globalOptions: GlobalOptions<true>, options: TUnresolvedOptions, streams?: Partial<Streams>, configPath?: string | undefined);
|
|
22
23
|
abstract onOptions(): OptionsType<TUnresolvedOptions, TOptions>;
|
|
23
24
|
protected returnsOptions(options: OptionsType<TUnresolvedOptions, TOptions>): OptionsType<TUnresolvedOptions, TOptions>;
|
|
24
25
|
abstract onExec(): Promise<number>;
|
|
@@ -5,10 +5,12 @@ const cli_1 = require("../utils/cli");
|
|
|
5
5
|
const stream_1 = require("../utils/stream");
|
|
6
6
|
class CommandAbstract {
|
|
7
7
|
globalOptions;
|
|
8
|
+
configPath;
|
|
8
9
|
options;
|
|
9
10
|
streams;
|
|
10
|
-
constructor(globalOptions, options, streams = {}) {
|
|
11
|
+
constructor(globalOptions, options, streams = {}, configPath) {
|
|
11
12
|
this.globalOptions = globalOptions;
|
|
13
|
+
this.configPath = configPath;
|
|
12
14
|
this.options = (0, cli_1.parseOptions)(options, this.onOptions());
|
|
13
15
|
this.streams = (0, stream_1.createStreams)(streams);
|
|
14
16
|
}
|
package/Command/CopyCommand.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export type CopyCommandOptionsType<TResolved = false> = {
|
|
|
12
12
|
export type CopyCommandResult = Unwrap<CopyAction["exec"]>;
|
|
13
13
|
export declare class CopyCommand extends CommandAbstract<CopyCommandOptionsType<false>, CopyCommandOptionsType<true>> {
|
|
14
14
|
onOptions(): import("../utils/cli").OptionsType<CopyCommandOptionsType<false>, CopyCommandOptionsType<true>>;
|
|
15
|
-
onExec(): Promise<
|
|
15
|
+
onExec(): Promise<1 | 0>;
|
|
16
16
|
}
|
|
@@ -13,5 +13,5 @@ export type RestoreCommandOptionsType<TResolved = false> = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare class RestoreCommand extends CommandAbstract<RestoreCommandOptionsType<false>, RestoreCommandOptionsType<true>> {
|
|
15
15
|
onOptions(): import("../utils/cli").OptionsType<RestoreCommandOptionsType<false>, RestoreCommandOptionsType<true>>;
|
|
16
|
-
onExec(): Promise<
|
|
16
|
+
onExec(): Promise<1 | 0>;
|
|
17
17
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StartServerCommand = void 0;
|
|
4
4
|
const ConfigAction_1 = require("../Action/ConfigAction");
|
|
5
|
-
const
|
|
5
|
+
const cron_server_1 = require("../utils/datatruck/cron-server");
|
|
6
|
+
const repository_server_1 = require("../utils/datatruck/repository-server");
|
|
6
7
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
7
8
|
class StartServerCommand extends CommandAbstract_1.CommandAbstract {
|
|
8
9
|
onOptions() {
|
|
@@ -10,14 +11,36 @@ class StartServerCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
10
11
|
}
|
|
11
12
|
async onExec() {
|
|
12
13
|
const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const verbose = !!this.globalOptions.verbose;
|
|
15
|
+
const log = config.server?.log ?? true;
|
|
16
|
+
const repositoryOptions = config.server?.repository || {};
|
|
17
|
+
if (repositoryOptions.enabled ?? true) {
|
|
18
|
+
const server = (0, repository_server_1.createDatatruckRepositoryServer)(repositoryOptions, {
|
|
19
|
+
log,
|
|
20
|
+
configPath: this.configPath,
|
|
21
|
+
});
|
|
22
|
+
const port = repositoryOptions.listen?.port ?? 8888;
|
|
23
|
+
const address = repositoryOptions.listen?.address ?? "127.0.0.1";
|
|
24
|
+
console.info(`Listening datatruck repository on http://${address}:${port}`);
|
|
25
|
+
server.on("error", (error) => {
|
|
26
|
+
console.error(`SERVER ERROR`, error);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
});
|
|
18
29
|
server.listen(port, address);
|
|
19
|
-
|
|
20
|
-
}
|
|
30
|
+
}
|
|
31
|
+
const cronOptions = config.server?.cron || {};
|
|
32
|
+
if (cronOptions.enabled ?? true) {
|
|
33
|
+
if (typeof this.configPath !== "string")
|
|
34
|
+
throw new Error(`Config path is required by cron server`);
|
|
35
|
+
const server = (0, cron_server_1.createCronServer)(cronOptions, {
|
|
36
|
+
verbose,
|
|
37
|
+
log,
|
|
38
|
+
configPath: this.configPath,
|
|
39
|
+
});
|
|
40
|
+
server.start();
|
|
41
|
+
console.info(`Cron server started`);
|
|
42
|
+
}
|
|
43
|
+
await new Promise(() => setInterval(() => { }, 60000));
|
|
21
44
|
return 0;
|
|
22
45
|
}
|
|
23
46
|
}
|
package/Config/Config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FormatType } from "../utils/DataFormat";
|
|
2
|
-
import {
|
|
2
|
+
import { DatatruckCronServerOptions } from "../utils/datatruck/cron-server";
|
|
3
|
+
import { DatatruckRepositoryServerOptions } from "../utils/datatruck/repository-server";
|
|
3
4
|
import { Step } from "../utils/steps";
|
|
4
5
|
import { PackageConfigType } from "./PackageConfig";
|
|
5
6
|
import { PrunePolicyConfigType } from "./PrunePolicyConfig";
|
|
@@ -14,6 +15,11 @@ export type ConfigType = {
|
|
|
14
15
|
reports?: ReportConfig[];
|
|
15
16
|
prunePolicy?: PrunePolicyConfigType;
|
|
16
17
|
};
|
|
18
|
+
export type DatatruckServerOptions = {
|
|
19
|
+
log?: boolean;
|
|
20
|
+
repository?: DatatruckRepositoryServerOptions;
|
|
21
|
+
cron?: DatatruckCronServerOptions;
|
|
22
|
+
};
|
|
17
23
|
export type ReportConfig = {
|
|
18
24
|
when?: "success" | "error";
|
|
19
25
|
format?: Exclude<FormatType, "custom" | "tpl">;
|
package/Config/Config.js
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configDefinition = void 0;
|
|
4
4
|
const DefinitionEnum_1 = require("../JsonSchema/DefinitionEnum");
|
|
5
|
+
const backup_def_1 = require("../JsonSchema/backup-def");
|
|
6
|
+
const copy_def_1 = require("../JsonSchema/copy-def");
|
|
5
7
|
const ScriptTask_1 = require("../Task/ScriptTask");
|
|
6
8
|
const DataFormat_1 = require("../utils/DataFormat");
|
|
9
|
+
const schema_1 = require("../utils/schema");
|
|
7
10
|
exports.configDefinition = {
|
|
8
11
|
type: "object",
|
|
9
12
|
required: ["repositories", "packages"],
|
|
@@ -38,46 +41,96 @@ exports.configDefinition = {
|
|
|
38
41
|
type: "object",
|
|
39
42
|
additionalProperties: false,
|
|
40
43
|
properties: {
|
|
41
|
-
path: { type: "string" },
|
|
42
44
|
log: { type: "boolean" },
|
|
43
|
-
|
|
44
|
-
type: "array",
|
|
45
|
-
items: {
|
|
46
|
-
type: "object",
|
|
47
|
-
additionalProperties: false,
|
|
48
|
-
properties: {
|
|
49
|
-
name: { type: "string" },
|
|
50
|
-
password: { type: "string" },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
listen: {
|
|
45
|
+
repository: {
|
|
55
46
|
type: "object",
|
|
56
47
|
additionalProperties: false,
|
|
57
48
|
properties: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
trustProxy: {
|
|
63
|
-
anyOf: [
|
|
64
|
-
{ type: "boolean" },
|
|
65
|
-
{
|
|
49
|
+
enabled: { type: "boolean" },
|
|
50
|
+
listen: {
|
|
66
51
|
type: "object",
|
|
67
52
|
additionalProperties: false,
|
|
68
|
-
required: ["remoteAddressHeader"],
|
|
69
53
|
properties: {
|
|
70
|
-
|
|
54
|
+
port: { type: "integer" },
|
|
55
|
+
address: { type: "string" },
|
|
71
56
|
},
|
|
72
57
|
},
|
|
73
|
-
|
|
58
|
+
trustProxy: {
|
|
59
|
+
anyOf: [
|
|
60
|
+
{ type: "boolean" },
|
|
61
|
+
{
|
|
62
|
+
type: "object",
|
|
63
|
+
additionalProperties: false,
|
|
64
|
+
required: ["remoteAddressHeader"],
|
|
65
|
+
properties: {
|
|
66
|
+
remoteAddressHeader: { type: "string" },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
allowlist: {
|
|
72
|
+
type: "object",
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
properties: {
|
|
75
|
+
enabled: { type: "boolean" },
|
|
76
|
+
remoteAddresses: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.stringListUtil),
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
backends: {
|
|
80
|
+
type: "array",
|
|
81
|
+
items: {
|
|
82
|
+
type: "object",
|
|
83
|
+
additionalProperties: false,
|
|
84
|
+
required: ["name", "path"],
|
|
85
|
+
properties: {
|
|
86
|
+
name: { type: "string" },
|
|
87
|
+
path: { type: "string" },
|
|
88
|
+
users: {
|
|
89
|
+
type: "array",
|
|
90
|
+
items: {
|
|
91
|
+
type: "object",
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
required: ["name", "password"],
|
|
94
|
+
properties: {
|
|
95
|
+
enabled: { type: "boolean" },
|
|
96
|
+
name: { type: "string" },
|
|
97
|
+
password: { type: "string" },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
74
105
|
},
|
|
75
|
-
|
|
106
|
+
cron: {
|
|
76
107
|
type: "object",
|
|
77
108
|
additionalProperties: false,
|
|
78
109
|
properties: {
|
|
79
110
|
enabled: { type: "boolean" },
|
|
80
|
-
|
|
111
|
+
actions: {
|
|
112
|
+
type: "array",
|
|
113
|
+
items: {
|
|
114
|
+
allOf: [
|
|
115
|
+
{
|
|
116
|
+
type: "object",
|
|
117
|
+
required: ["schedule"],
|
|
118
|
+
properties: {
|
|
119
|
+
schedule: { type: "string" },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
anyOf: (0, schema_1.createCaseSchema)({
|
|
124
|
+
type: "type",
|
|
125
|
+
value: "options",
|
|
126
|
+
}, {
|
|
127
|
+
backup: (0, schema_1.omitPropertySchema)(backup_def_1.backupCommandOptionDef, "dryRun"),
|
|
128
|
+
copy: copy_def_1.copyCommandOptionsDef,
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
81
134
|
},
|
|
82
135
|
},
|
|
83
136
|
},
|
|
@@ -2,6 +2,7 @@ import { DatatruckRepositoryConfigType, datatruckRepositoryName } from "../Repos
|
|
|
2
2
|
import { GitRepositoryConfigType, gitRepositoryName } from "../Repository/GitRepository";
|
|
3
3
|
import { ResticRepositoryConfigType, resticRepositoryName } from "../Repository/ResticRepository";
|
|
4
4
|
import type { JSONSchema7 } from "json-schema";
|
|
5
|
+
export declare const repositoryNames: ("git" | "restic" | "datatruck")[];
|
|
5
6
|
export declare const repositoryConfigDefinition: JSONSchema7;
|
|
6
7
|
export type RepositoryConfigTypeType = RepositoryConfigType["type"];
|
|
7
8
|
export type RepositoryConfigEnabledActionType = "backup" | "init" | "prune" | "restore" | "snapshots";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.repositoryConfigDefinition = void 0;
|
|
3
|
+
exports.repositoryConfigDefinition = exports.repositoryNames = void 0;
|
|
4
4
|
const DefinitionEnum_1 = require("../JsonSchema/DefinitionEnum");
|
|
5
5
|
const DatatruckRepository_1 = require("../Repository/DatatruckRepository");
|
|
6
6
|
const GitRepository_1 = require("../Repository/GitRepository");
|
|
@@ -10,6 +10,11 @@ const types = {
|
|
|
10
10
|
[DatatruckRepository_1.datatruckRepositoryName]: DefinitionEnum_1.DefinitionEnum.datatruckRepository,
|
|
11
11
|
[GitRepository_1.gitRepositoryName]: DefinitionEnum_1.DefinitionEnum.gitRepository,
|
|
12
12
|
};
|
|
13
|
+
exports.repositoryNames = [
|
|
14
|
+
ResticRepository_1.resticRepositoryName,
|
|
15
|
+
DatatruckRepository_1.datatruckRepositoryName,
|
|
16
|
+
GitRepository_1.gitRepositoryName,
|
|
17
|
+
];
|
|
13
18
|
exports.repositoryConfigDefinition = {
|
|
14
19
|
type: "object",
|
|
15
20
|
additionalProperties: false,
|
|
@@ -37,7 +37,7 @@ export type LogMapType = {
|
|
|
37
37
|
[CommandEnum.snapshots]: SnapshotsCommandResult;
|
|
38
38
|
[CommandEnum.backup]: BackupCommandResult;
|
|
39
39
|
};
|
|
40
|
-
export declare function CommandFactory<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams
|
|
40
|
+
export declare function CommandFactory<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams>, configPath?: string): StartServerCommand;
|
|
41
41
|
export declare function exec<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams>): Promise<number>;
|
|
42
42
|
export declare function createActionInterface(globalOptions: GlobalOptions<true>): {
|
|
43
43
|
[K in keyof OptionsMapType as `${K}`]: (options: OptionsMapType[K]) => Promise<K extends keyof LogMapType ? LogMapType[K] : never>;
|
|
@@ -24,9 +24,9 @@ var CommandEnum;
|
|
|
24
24
|
CommandEnum["cleanCache"] = "clean-cache";
|
|
25
25
|
CommandEnum["startServer"] = "start-server";
|
|
26
26
|
})(CommandEnum || (exports.CommandEnum = CommandEnum = {}));
|
|
27
|
-
function CommandFactory(type, globalOptions, options, streams) {
|
|
27
|
+
function CommandFactory(type, globalOptions, options, streams, configPath) {
|
|
28
28
|
const constructor = CommandConstructorFactory(type);
|
|
29
|
-
return new constructor(globalOptions, options, streams);
|
|
29
|
+
return new constructor(globalOptions, options, streams, configPath);
|
|
30
30
|
}
|
|
31
31
|
exports.CommandFactory = CommandFactory;
|
|
32
32
|
async function exec(type, globalOptions, options, streams) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const backupCommandOptionDef: {
|
|
2
|
+
type: "object";
|
|
3
|
+
additionalProperties: false;
|
|
4
|
+
properties: {
|
|
5
|
+
package: {
|
|
6
|
+
type: "string";
|
|
7
|
+
};
|
|
8
|
+
packageTask: {
|
|
9
|
+
type: "string";
|
|
10
|
+
};
|
|
11
|
+
repository: {
|
|
12
|
+
type: "string";
|
|
13
|
+
};
|
|
14
|
+
repositoryType: {
|
|
15
|
+
enum: ("git" | "restic" | "datatruck")[];
|
|
16
|
+
};
|
|
17
|
+
tag: {
|
|
18
|
+
type: "string";
|
|
19
|
+
};
|
|
20
|
+
dryRun: {
|
|
21
|
+
type: "boolean";
|
|
22
|
+
};
|
|
23
|
+
date: {
|
|
24
|
+
type: "string";
|
|
25
|
+
};
|
|
26
|
+
prune: {
|
|
27
|
+
type: "boolean";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.backupCommandOptionDef = void 0;
|
|
4
|
+
const RepositoryConfig_1 = require("../Config/RepositoryConfig");
|
|
5
|
+
exports.backupCommandOptionDef = {
|
|
6
|
+
type: "object",
|
|
7
|
+
additionalProperties: false,
|
|
8
|
+
properties: {
|
|
9
|
+
package: { type: "string" },
|
|
10
|
+
packageTask: { type: "string" },
|
|
11
|
+
repository: { type: "string" },
|
|
12
|
+
repositoryType: { enum: RepositoryConfig_1.repositoryNames },
|
|
13
|
+
tag: { type: "string" },
|
|
14
|
+
dryRun: { type: "boolean" },
|
|
15
|
+
date: { type: "string" },
|
|
16
|
+
prune: { type: "boolean" },
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const copyCommandOptionsDef: {
|
|
2
|
+
type: "object";
|
|
3
|
+
additionalProperties: false;
|
|
4
|
+
properties: {
|
|
5
|
+
id: {
|
|
6
|
+
type: "string";
|
|
7
|
+
};
|
|
8
|
+
last: {
|
|
9
|
+
type: "integer";
|
|
10
|
+
};
|
|
11
|
+
package: {
|
|
12
|
+
type: "string";
|
|
13
|
+
};
|
|
14
|
+
packageTask: {
|
|
15
|
+
type: "string";
|
|
16
|
+
};
|
|
17
|
+
repository: {
|
|
18
|
+
type: "string";
|
|
19
|
+
};
|
|
20
|
+
repository2: {
|
|
21
|
+
type: "string";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyCommandOptionsDef = void 0;
|
|
4
|
+
exports.copyCommandOptionsDef = {
|
|
5
|
+
type: "object",
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
id: { type: "string" },
|
|
9
|
+
last: { type: "integer" },
|
|
10
|
+
package: { type: "string" },
|
|
11
|
+
packageTask: { type: "string" },
|
|
12
|
+
repository: { type: "string" },
|
|
13
|
+
repository2: { type: "string" },
|
|
14
|
+
},
|
|
15
|
+
};
|
package/Task/ScriptTask.d.ts
CHANGED
|
@@ -20,22 +20,13 @@ export declare enum ScriptTaskDefinitionEnum {
|
|
|
20
20
|
step = "step",
|
|
21
21
|
processStepConfig = "processStepConfig",
|
|
22
22
|
nodeStepConfig = "nodeStepConfig",
|
|
23
|
-
telegramMessageStepConfig = "telegramMessageStepConfig"
|
|
23
|
+
telegramMessageStepConfig = "telegramMessageStepConfig",
|
|
24
|
+
ntfyStepConfig = "ntfyStepConfig"
|
|
24
25
|
}
|
|
25
26
|
export declare const scriptTaskName = "script";
|
|
26
27
|
export declare const scriptTaskDefinition: JSONSchema7;
|
|
27
28
|
export declare class ScriptTask extends TaskAbstract<ScriptTaskConfigType> {
|
|
28
29
|
protected verbose?: boolean;
|
|
29
|
-
protected getVars(data: TaskBackupData | TaskRestoreData): {
|
|
30
|
-
process: {
|
|
31
|
-
DTT_SNAPSHOT_ID: string;
|
|
32
|
-
DTT_SNAPSHOT_DATE: string;
|
|
33
|
-
DTT_PACKAGE_NAME: string;
|
|
34
|
-
DTT_PACKAGE_PATH: string | undefined;
|
|
35
|
-
DTT_SNAPSHOT_PATH: string | undefined;
|
|
36
|
-
};
|
|
37
|
-
node: NodeVars;
|
|
38
|
-
};
|
|
39
30
|
backup(data: TaskBackupData): Promise<{
|
|
40
31
|
snapshotPath: string;
|
|
41
32
|
}>;
|