@datatruck/cli 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Action/BackupAction.d.ts +2 -4
- package/Action/BackupAction.js +2 -10
- package/Action/CopyAction.d.ts +2 -2
- package/Action/CopyAction.js +1 -2
- package/Action/RestoreAction.d.ts +2 -3
- package/Action/RestoreAction.js +1 -2
- package/CHANGELOG.md +16 -0
- package/Command/BackupCommand.d.ts +1 -1
- package/Command/BackupCommand.js +0 -1
- package/Command/CleanCacheCommand.d.ts +1 -1
- package/Command/CommandAbstract.d.ts +4 -3
- package/Command/CommandAbstract.js +3 -1
- package/Command/CopyCommand.d.ts +1 -1
- package/Command/CopyCommand.js +0 -1
- package/Command/RestoreCommand.d.ts +1 -1
- package/Command/RestoreCommand.js +0 -1
- package/Command/StartServerCommand.js +30 -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/Repository/DatatruckRepository.js +2 -0
- package/cli.js +5 -7
- package/config.schema.json +189 -39
- package/package.json +2 -1
- package/utils/cli.d.ts +3 -0
- package/utils/cli.js +21 -1
- 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/{server.d.ts → repository-server.d.ts} +12 -6
- package/utils/datatruck/{server.js → repository-server.js} +45 -28
- package/utils/http.d.ts +8 -2
- package/utils/http.js +16 -15
- package/utils/object.d.ts +1 -1
- package/utils/object.js +6 -6
- package/utils/progress.d.ts +17 -10
- package/utils/progress.js +20 -10
- package/utils/schema.d.ts +34 -0
- package/utils/schema.js +36 -0
- package/utils/string.d.ts +0 -3
- package/utils/string.js +1 -37
- package/utils/ObjectVault.d.ts +0 -13
- package/utils/ObjectVault.js +0 -29
package/Action/BackupAction.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { RepositoryConfigType } from "../Config/RepositoryConfig";
|
|
|
4
4
|
import { PreSnapshot } from "../Repository/RepositoryAbstract";
|
|
5
5
|
import { DataFormat } from "../utils/DataFormat";
|
|
6
6
|
import { Listr3TaskResultEnd } from "../utils/list";
|
|
7
|
-
import { Progress,
|
|
7
|
+
import { Progress, ProgressMode } from "../utils/progress";
|
|
8
8
|
import { Streams } from "../utils/stream";
|
|
9
9
|
import { IfRequireKeys } from "../utils/ts";
|
|
10
10
|
export type BackupActionOptions = {
|
|
@@ -17,8 +17,7 @@ export type BackupActionOptions = {
|
|
|
17
17
|
verbose?: boolean;
|
|
18
18
|
date?: string;
|
|
19
19
|
tty?: "auto" | boolean;
|
|
20
|
-
progress?:
|
|
21
|
-
progressInterval?: number;
|
|
20
|
+
progress?: ProgressMode;
|
|
22
21
|
streams?: Streams;
|
|
23
22
|
prune?: boolean;
|
|
24
23
|
};
|
|
@@ -51,7 +50,6 @@ type Context = {
|
|
|
51
50
|
export declare class BackupAction<TRequired extends boolean = true> {
|
|
52
51
|
readonly config: ConfigType;
|
|
53
52
|
readonly options: IfRequireKeys<TRequired, BackupActionOptions>;
|
|
54
|
-
protected pm: ProgressManager;
|
|
55
53
|
constructor(config: ConfigType, options?: IfRequireKeys<TRequired, BackupActionOptions>);
|
|
56
54
|
protected prepareSnapshot(): PreSnapshot;
|
|
57
55
|
protected getPackages(snapshot: PreSnapshot): PackageConfigType[];
|
package/Action/BackupAction.js
CHANGED
|
@@ -22,16 +22,9 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
22
22
|
class BackupAction {
|
|
23
23
|
config;
|
|
24
24
|
options;
|
|
25
|
-
pm;
|
|
26
25
|
constructor(config, options = {}) {
|
|
27
26
|
this.config = config;
|
|
28
27
|
this.options = options;
|
|
29
|
-
this.pm = new progress_1.ProgressManager({
|
|
30
|
-
verbose: options.verbose,
|
|
31
|
-
tty: options.tty,
|
|
32
|
-
enabled: options.progress,
|
|
33
|
-
interval: options.progressInterval,
|
|
34
|
-
});
|
|
35
28
|
}
|
|
36
29
|
prepareSnapshot() {
|
|
37
30
|
const date = this.options.date ?? new Date().toISOString();
|
|
@@ -165,8 +158,7 @@ class BackupAction {
|
|
|
165
158
|
const pm = new progress_1.ProgressManager({
|
|
166
159
|
verbose: options.verbose,
|
|
167
160
|
tty: options.tty,
|
|
168
|
-
|
|
169
|
-
interval: options.progressInterval,
|
|
161
|
+
mode: options.progress,
|
|
170
162
|
});
|
|
171
163
|
const l = new list_1.Listr3({
|
|
172
164
|
streams: this.options.streams,
|
|
@@ -246,7 +238,7 @@ class BackupAction {
|
|
|
246
238
|
repositoryName,
|
|
247
239
|
snapshot,
|
|
248
240
|
snapshotPath: taskResult?.snapshotPath,
|
|
249
|
-
onProgress: (p) =>
|
|
241
|
+
onProgress: (p) => pm.update(p, (t) => (task.output = t)),
|
|
250
242
|
});
|
|
251
243
|
},
|
|
252
244
|
})), l.$task({
|
package/Action/CopyAction.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ConfigType } 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
|
+
import { ProgressMode } from "../utils/progress";
|
|
5
6
|
import { Streams } from "../utils/stream";
|
|
6
7
|
import { IfRequireKeys } from "../utils/ts";
|
|
7
8
|
export type CopyActionOptionsType = {
|
|
@@ -13,8 +14,7 @@ export type CopyActionOptionsType = {
|
|
|
13
14
|
repositoryNames2?: string[];
|
|
14
15
|
verbose?: boolean;
|
|
15
16
|
tty?: "auto" | boolean;
|
|
16
|
-
progress?:
|
|
17
|
-
progressInterval?: number;
|
|
17
|
+
progress?: ProgressMode;
|
|
18
18
|
};
|
|
19
19
|
export type CopyActionResult = {
|
|
20
20
|
errors: Error[];
|
package/Action/CopyAction.js
CHANGED
|
@@ -69,8 +69,7 @@ class CopyAction {
|
|
|
69
69
|
const pm = new progress_1.ProgressManager({
|
|
70
70
|
verbose: options.verbose,
|
|
71
71
|
tty: options.tty,
|
|
72
|
-
|
|
73
|
-
interval: options.progressInterval,
|
|
72
|
+
mode: options.progress,
|
|
74
73
|
});
|
|
75
74
|
const l = new list_1.Listr3({ progressManager: pm });
|
|
76
75
|
return l
|
|
@@ -4,7 +4,7 @@ import { Snapshot } from "../Repository/RepositoryAbstract";
|
|
|
4
4
|
import { TaskAbstract } from "../Task/TaskAbstract";
|
|
5
5
|
import { DataFormat } from "../utils/DataFormat";
|
|
6
6
|
import { Listr3TaskResultEnd } from "../utils/list";
|
|
7
|
-
import { Progress } from "../utils/progress";
|
|
7
|
+
import { Progress, ProgressMode } from "../utils/progress";
|
|
8
8
|
import { Streams } from "../utils/stream";
|
|
9
9
|
import { GargabeCollector } from "../utils/temp";
|
|
10
10
|
import { IfRequireKeys } from "../utils/ts";
|
|
@@ -19,8 +19,7 @@ export type RestoreActionOptions = {
|
|
|
19
19
|
verbose?: boolean;
|
|
20
20
|
initial?: boolean;
|
|
21
21
|
tty?: "auto" | boolean;
|
|
22
|
-
progress?:
|
|
23
|
-
progressInterval?: number;
|
|
22
|
+
progress?: ProgressMode;
|
|
24
23
|
streams?: Streams;
|
|
25
24
|
};
|
|
26
25
|
type RestoreSnapshot = Snapshot & {
|
package/Action/RestoreAction.js
CHANGED
|
@@ -143,8 +143,7 @@ class RestoreAction {
|
|
|
143
143
|
const pm = new progress_1.ProgressManager({
|
|
144
144
|
verbose: options.verbose,
|
|
145
145
|
tty: options.tty,
|
|
146
|
-
|
|
147
|
-
interval: options.progressInterval,
|
|
146
|
+
mode: options.progress,
|
|
148
147
|
});
|
|
149
148
|
const l = new list_1.Listr3({
|
|
150
149
|
streams: options.streams,
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @datatruck/cli
|
|
2
2
|
|
|
3
|
+
## 0.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c98324e`](https://github.com/swordev/datatruck/commit/c98324ebbb5b43113f1bb6d9a07bd905b5883729) Thanks [@juanrgm](https://github.com/juanrgm)! - Add cron server
|
|
8
|
+
|
|
9
|
+
- [`9b40aad`](https://github.com/swordev/datatruck/commit/9b40aadc3ba57db15f14ae08c342b7170d61aa5d) Thanks [@juanrgm](https://github.com/juanrgm)! - Add multiple backends to the datatruck repository
|
|
10
|
+
|
|
11
|
+
## 0.30.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`68e991b`](https://github.com/swordev/datatruck/commit/68e991b862ee3793e6b31d1fd5d6cebdf59524a4) Thanks [@juanrgm](https://github.com/juanrgm)! - Fix allowlist in datatruck server
|
|
16
|
+
|
|
17
|
+
- [`16f982c`](https://github.com/swordev/datatruck/commit/16f982c7da0d44cbbb691d5552da77fb27366f82) Thanks [@juanrgm](https://github.com/juanrgm)! - Reduce progress interval to 300 ms in auto progress mode
|
|
18
|
+
|
|
3
19
|
## 0.30.0
|
|
4
20
|
|
|
5
21
|
### Minor 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
|
}
|
package/Command/BackupCommand.js
CHANGED
|
@@ -61,7 +61,6 @@ class BackupCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
61
61
|
date: this.options.date,
|
|
62
62
|
tty: this.globalOptions.tty,
|
|
63
63
|
progress: this.globalOptions.progress,
|
|
64
|
-
progressInterval: this.globalOptions.progressInterval,
|
|
65
64
|
streams: this.streams,
|
|
66
65
|
prune: this.options.prune,
|
|
67
66
|
});
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigType } from "../Config/Config";
|
|
2
2
|
import { FormatType } from "../utils/DataFormat";
|
|
3
3
|
import { OptionsType } from "../utils/cli";
|
|
4
|
+
import { ProgressMode } from "../utils/progress";
|
|
4
5
|
import { Streams } from "../utils/stream";
|
|
5
6
|
import { If, SimilarObject } from "../utils/ts";
|
|
6
7
|
export type GlobalOptions<TResolved = false> = {
|
|
@@ -8,17 +9,17 @@ export type GlobalOptions<TResolved = false> = {
|
|
|
8
9
|
outputFormat?: FormatType;
|
|
9
10
|
verbose?: number;
|
|
10
11
|
tty?: If<TResolved, "auto" | boolean, "auto" | "true" | "false">;
|
|
11
|
-
progress?: If<TResolved,
|
|
12
|
-
progressInterval?: number;
|
|
12
|
+
progress?: If<TResolved, ProgressMode, Exclude<ProgressMode, boolean> | "true" | "false">;
|
|
13
13
|
};
|
|
14
14
|
export type CommandConstructor<TUnresolvedOptions, TOptions extends SimilarObject<TUnresolvedOptions>> = {
|
|
15
15
|
new (globalOptions: GlobalOptions<true>, options: TOptions): CommandAbstract<TUnresolvedOptions, TOptions>;
|
|
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
|
}
|
package/Command/CopyCommand.js
CHANGED
|
@@ -53,7 +53,6 @@ class CopyCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
53
53
|
verbose: verbose > 0,
|
|
54
54
|
tty: this.globalOptions.tty,
|
|
55
55
|
progress: this.globalOptions.progress,
|
|
56
|
-
progressInterval: this.globalOptions.progressInterval,
|
|
57
56
|
});
|
|
58
57
|
const result = await copy.exec();
|
|
59
58
|
if (this.globalOptions.outputFormat)
|
|
@@ -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
|
}
|
|
@@ -63,7 +63,6 @@ class RestoreCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
63
63
|
initial: this.options.initial,
|
|
64
64
|
tty: this.globalOptions.tty,
|
|
65
65
|
progress: this.globalOptions.progress,
|
|
66
|
-
progressInterval: this.globalOptions.progressInterval,
|
|
67
66
|
streams: this.streams,
|
|
68
67
|
});
|
|
69
68
|
const result = await restore.exec();
|
|
@@ -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,35 @@ 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
|
+
});
|
|
21
|
+
const port = repositoryOptions.listen?.port ?? 8888;
|
|
22
|
+
const address = repositoryOptions.listen?.address ?? "127.0.0.1";
|
|
23
|
+
console.info(`Listening datatruck repository on http://${address}:${port}`);
|
|
24
|
+
server.on("error", (error) => {
|
|
25
|
+
console.error(`SERVER ERROR`, error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
18
28
|
server.listen(port, address);
|
|
19
|
-
|
|
20
|
-
}
|
|
29
|
+
}
|
|
30
|
+
const cronOptions = config.server?.cron || {};
|
|
31
|
+
if (cronOptions.enabled ?? true) {
|
|
32
|
+
if (typeof this.configPath !== "string")
|
|
33
|
+
throw new Error(`Config path is required by cron server`);
|
|
34
|
+
const server = (0, cron_server_1.createCronServer)(cronOptions, {
|
|
35
|
+
verbose,
|
|
36
|
+
log,
|
|
37
|
+
configPath: this.configPath,
|
|
38
|
+
});
|
|
39
|
+
server.start();
|
|
40
|
+
console.info(`Cron server started`);
|
|
41
|
+
}
|
|
42
|
+
await new Promise(() => setInterval(() => { }, 60000));
|
|
21
43
|
return 0;
|
|
22
44
|
}
|
|
23
45
|
}
|
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
|
+
};
|
|
@@ -292,6 +292,7 @@ class DatatruckRepository extends RepositoryAbstract_1.RepositoryAbstract {
|
|
|
292
292
|
absolute,
|
|
293
293
|
relative: {
|
|
294
294
|
description: "Downloading",
|
|
295
|
+
format: "size",
|
|
295
296
|
...progress,
|
|
296
297
|
},
|
|
297
298
|
}),
|
|
@@ -306,6 +307,7 @@ class DatatruckRepository extends RepositoryAbstract_1.RepositoryAbstract {
|
|
|
306
307
|
absolute,
|
|
307
308
|
relative: {
|
|
308
309
|
description: "Downloading",
|
|
310
|
+
format: "size",
|
|
309
311
|
...progress,
|
|
310
312
|
},
|
|
311
313
|
}),
|