@datatruck/cli 0.36.8 → 0.38.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/config.schema.json +168 -108
- package/lib/actions/BackupAction.d.ts +61 -20
- package/lib/actions/BackupAction.js +43 -17
- package/lib/actions/CleanCacheAction.d.ts +6 -7
- package/lib/actions/CleanCacheAction.js +2 -1
- package/lib/actions/ConfigAction.d.ts +3 -5
- package/lib/actions/ConfigAction.js +0 -1
- package/lib/actions/CopyAction.d.ts +43 -12
- package/lib/actions/CopyAction.js +31 -4
- package/lib/actions/ExportAction.d.ts +94 -0
- package/lib/actions/ExportAction.js +236 -0
- package/lib/actions/InitAction.d.ts +17 -7
- package/lib/actions/InitAction.js +9 -1
- package/lib/actions/PruneAction.d.ts +76 -17
- package/lib/actions/PruneAction.js +62 -2
- package/lib/actions/RestoreAction.d.ts +61 -22
- package/lib/actions/RestoreAction.js +46 -58
- package/lib/actions/SnapshotsAction.d.ts +80 -21
- package/lib/actions/SnapshotsAction.js +82 -1
- package/lib/cli.d.ts +0 -3
- package/lib/cli.js +31 -56
- package/lib/commands/BackupCommand.d.ts +121 -13
- package/lib/commands/BackupCommand.js +29 -54
- package/lib/commands/CleanCacheCommand.d.ts +10 -3
- package/lib/commands/CleanCacheCommand.js +14 -6
- package/lib/commands/CommandAbstract.d.ts +11 -10
- package/lib/commands/CommandAbstract.js +6 -9
- package/lib/commands/ConfigCommand.d.ts +72 -9
- package/lib/commands/ConfigCommand.js +36 -28
- package/lib/commands/CopyCommand.d.ts +103 -10
- package/lib/commands/CopyCommand.js +25 -44
- package/lib/commands/ExportCommand.d.ts +143 -0
- package/lib/commands/ExportCommand.js +50 -0
- package/lib/commands/InitCommand.d.ts +43 -7
- package/lib/commands/InitCommand.js +22 -19
- package/lib/commands/PruneCommand.d.ts +237 -17
- package/lib/commands/PruneCommand.js +27 -99
- package/lib/commands/RestoreCommand.d.ts +127 -13
- package/lib/commands/RestoreCommand.js +27 -53
- package/lib/commands/RunCommand.d.ts +29 -0
- package/lib/commands/RunCommand.js +44 -0
- package/lib/commands/SnapshotsCommand.d.ts +240 -23
- package/lib/commands/SnapshotsCommand.js +23 -101
- package/lib/commands/StartServerCommand.d.ts +10 -3
- package/lib/commands/StartServerCommand.js +23 -15
- package/lib/repositories/DatatruckRepository.js +1 -1
- package/lib/tasks/MssqlTask.js +1 -1
- package/lib/tasks/MysqlDumpTask.js +1 -1
- package/lib/tasks/SqlDumpTaskAbstract.js +2 -2
- package/lib/utils/cli.d.ts +1 -18
- package/lib/utils/cli.js +9 -49
- package/lib/utils/datatruck/command.d.ts +8 -5
- package/lib/utils/datatruck/command.js +8 -4
- package/lib/utils/datatruck/config-type.d.ts +4 -0
- package/lib/utils/datatruck/cron-server.d.ts +8 -39
- package/lib/utils/datatruck/cron-server.js +35 -57
- package/lib/utils/datatruck/job.d.ts +41 -0
- package/lib/utils/datatruck/job.js +82 -0
- package/lib/utils/datatruck/report-list.js +1 -1
- package/lib/utils/datatruck/repository.d.ts +1 -0
- package/lib/utils/datatruck/repository.js +8 -1
- package/lib/utils/list.d.ts +5 -0
- package/lib/utils/list.js +9 -0
- package/lib/utils/math.js +1 -1
- package/lib/utils/object.d.ts +5 -0
- package/lib/utils/object.js +10 -1
- package/lib/utils/options.d.ts +24 -0
- package/lib/utils/options.js +94 -0
- package/lib/utils/progress.js +1 -1
- package/lib/utils/restic.js +1 -1
- package/lib/utils/string.d.ts +2 -1
- package/lib/utils/string.js +5 -1
- package/lib/utils/watcher.js +1 -1
- package/package.json +4 -4
|
@@ -1,12 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PruneAction = void 0;
|
|
3
|
+
exports.PruneAction = exports.pruneActionOptions = void 0;
|
|
4
4
|
const repository_1 = require("../utils/datatruck/repository");
|
|
5
5
|
const snapshot_1 = require("../utils/datatruck/snapshot");
|
|
6
6
|
const date_1 = require("../utils/date");
|
|
7
7
|
const error_1 = require("../utils/error");
|
|
8
8
|
const object_1 = require("../utils/object");
|
|
9
|
+
const string_1 = require("../utils/string");
|
|
9
10
|
const SnapshotsAction_1 = require("./SnapshotsAction");
|
|
11
|
+
exports.pruneActionOptions = {
|
|
12
|
+
ids: {
|
|
13
|
+
description: "Filter by snapshot id",
|
|
14
|
+
shortFlag: "i",
|
|
15
|
+
value: "array",
|
|
16
|
+
},
|
|
17
|
+
...(0, object_1.pickProps)(SnapshotsAction_1.snapshotsActionOptions, {
|
|
18
|
+
packageNames: true,
|
|
19
|
+
repositoryNames: true,
|
|
20
|
+
repositoryTypes: true,
|
|
21
|
+
tags: true,
|
|
22
|
+
}),
|
|
23
|
+
groupBy: {
|
|
24
|
+
description: "Group by values (packageName, repositoryName, repositoryType)",
|
|
25
|
+
shortFlag: "g",
|
|
26
|
+
defaults: "packageName,repositoryName",
|
|
27
|
+
value: (v) => (0, string_1.parseStringList)(v, [
|
|
28
|
+
"packageName",
|
|
29
|
+
"repositoryName",
|
|
30
|
+
"repositoryType",
|
|
31
|
+
]),
|
|
32
|
+
},
|
|
33
|
+
dryRun: {
|
|
34
|
+
description: "",
|
|
35
|
+
value: "boolean",
|
|
36
|
+
},
|
|
37
|
+
showAll: {
|
|
38
|
+
description: "Show all",
|
|
39
|
+
shortFlag: "a",
|
|
40
|
+
},
|
|
41
|
+
keepMinutely: {
|
|
42
|
+
description: "Keep last N minutely snapshots",
|
|
43
|
+
value: "number",
|
|
44
|
+
},
|
|
45
|
+
keepDaily: {
|
|
46
|
+
description: "Keep last N daily snapshots",
|
|
47
|
+
value: "number",
|
|
48
|
+
},
|
|
49
|
+
keepHourly: {
|
|
50
|
+
description: "Keep last N hourly snapshots",
|
|
51
|
+
value: "number",
|
|
52
|
+
},
|
|
53
|
+
keepLast: {
|
|
54
|
+
description: "Keep last N snapshots",
|
|
55
|
+
value: "number",
|
|
56
|
+
},
|
|
57
|
+
keepMonthly: {
|
|
58
|
+
description: "Keep last N monthly snapshots",
|
|
59
|
+
value: "number",
|
|
60
|
+
},
|
|
61
|
+
keepWeekly: {
|
|
62
|
+
description: "Keep last N weekly snapshots",
|
|
63
|
+
value: "number",
|
|
64
|
+
},
|
|
65
|
+
keepYearly: {
|
|
66
|
+
description: "Keep last N yearly snapshots",
|
|
67
|
+
value: "number",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
10
70
|
class PruneAction {
|
|
11
71
|
config;
|
|
12
72
|
options;
|
|
@@ -71,7 +131,7 @@ class PruneAction {
|
|
|
71
131
|
const prune = !keepSnapshot;
|
|
72
132
|
if (prune)
|
|
73
133
|
result.prune++;
|
|
74
|
-
if (prune || this.options.
|
|
134
|
+
if (prune || this.options.showAll)
|
|
75
135
|
snapshotsDeleted.push({
|
|
76
136
|
...snapshot,
|
|
77
137
|
exclusionReasons: keepSnapshot?.reasons || [],
|
|
@@ -3,22 +3,51 @@ import { TaskAbstract } from "../tasks/TaskAbstract";
|
|
|
3
3
|
import { DataFormat } from "../utils/data-format";
|
|
4
4
|
import type { Config, PackageConfig } from "../utils/datatruck/config-type";
|
|
5
5
|
import { Listr3TaskResultEnd } from "../utils/list";
|
|
6
|
+
import { InferOptions } from "../utils/options";
|
|
6
7
|
import { Progress, ProgressMode } from "../utils/progress";
|
|
7
8
|
import { StdStreams } from "../utils/stream";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export declare const restoreActionOptions: {
|
|
10
|
+
initial: {
|
|
11
|
+
description: string;
|
|
12
|
+
value: "boolean";
|
|
13
|
+
};
|
|
14
|
+
repositoryNames: {
|
|
15
|
+
description: string;
|
|
16
|
+
shortFlag: string;
|
|
17
|
+
value: "array";
|
|
18
|
+
};
|
|
19
|
+
repositoryTypes: {
|
|
20
|
+
description: string;
|
|
21
|
+
shortFlag: string;
|
|
22
|
+
value: "array";
|
|
23
|
+
};
|
|
24
|
+
packageNames: {
|
|
25
|
+
description: string;
|
|
26
|
+
shortFlag: string;
|
|
27
|
+
value: "array";
|
|
28
|
+
};
|
|
29
|
+
packageTaskNames: {
|
|
30
|
+
description: string;
|
|
31
|
+
shortFlag: string;
|
|
32
|
+
value: "array";
|
|
33
|
+
};
|
|
34
|
+
tags: {
|
|
35
|
+
description: string;
|
|
36
|
+
shortFlag: string;
|
|
37
|
+
value: "array";
|
|
38
|
+
};
|
|
39
|
+
packageConfig: {
|
|
40
|
+
description: string;
|
|
41
|
+
shortFlag: string;
|
|
42
|
+
};
|
|
43
|
+
id: {
|
|
44
|
+
description: string;
|
|
45
|
+
shortFlag: string;
|
|
46
|
+
required: true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type RestoreActionOptions = InferOptions<typeof restoreActionOptions> & {
|
|
17
50
|
verbose?: boolean;
|
|
18
|
-
initial?: boolean;
|
|
19
|
-
tty?: "auto" | boolean;
|
|
20
|
-
progress?: ProgressMode;
|
|
21
|
-
streams?: StdStreams;
|
|
22
51
|
};
|
|
23
52
|
type RestoreSnapshot = Snapshot & {
|
|
24
53
|
repositoryName: string;
|
|
@@ -34,26 +63,36 @@ type Context = {
|
|
|
34
63
|
};
|
|
35
64
|
restore: RestoreSnapshot;
|
|
36
65
|
};
|
|
37
|
-
export declare class RestoreAction
|
|
66
|
+
export declare class RestoreAction {
|
|
38
67
|
readonly config: Config;
|
|
39
|
-
readonly options:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
readonly options: RestoreActionOptions;
|
|
69
|
+
readonly settings: {
|
|
70
|
+
tty?: "auto" | boolean;
|
|
71
|
+
progress?: ProgressMode;
|
|
72
|
+
streams?: StdStreams;
|
|
73
|
+
};
|
|
74
|
+
constructor(config: Config, options: RestoreActionOptions, settings: {
|
|
75
|
+
tty?: "auto" | boolean;
|
|
76
|
+
progress?: ProgressMode;
|
|
77
|
+
streams?: StdStreams;
|
|
78
|
+
});
|
|
45
79
|
protected restore(data: {
|
|
46
80
|
pkg: PackageConfig;
|
|
47
81
|
task: TaskAbstract | undefined;
|
|
48
82
|
snapshot: RestoreSnapshot;
|
|
49
83
|
onProgress: (progress: Progress) => void;
|
|
50
84
|
}): Promise<{
|
|
51
|
-
snapshotPath: string
|
|
85
|
+
snapshotPath: string;
|
|
52
86
|
}>;
|
|
53
87
|
dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
|
|
54
88
|
streams?: StdStreams;
|
|
55
89
|
verbose?: number;
|
|
90
|
+
errors?: Error[];
|
|
56
91
|
}): DataFormat;
|
|
57
|
-
exec(): Promise<
|
|
92
|
+
exec(): Promise<{
|
|
93
|
+
result: (import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<Context>)[];
|
|
94
|
+
exitCode: number;
|
|
95
|
+
errors: Error[];
|
|
96
|
+
}>;
|
|
58
97
|
}
|
|
59
98
|
export {};
|
|
@@ -48,7 +48,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
49
|
};
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.RestoreAction = void 0;
|
|
51
|
+
exports.RestoreAction = exports.restoreActionOptions = void 0;
|
|
52
52
|
const cli_1 = require("../utils/cli");
|
|
53
53
|
const data_format_1 = require("../utils/data-format");
|
|
54
54
|
const config_1 = require("../utils/datatruck/config");
|
|
@@ -56,61 +56,40 @@ const repository_1 = require("../utils/datatruck/repository");
|
|
|
56
56
|
const task_1 = require("../utils/datatruck/task");
|
|
57
57
|
const date_1 = require("../utils/date");
|
|
58
58
|
const error_1 = require("../utils/error");
|
|
59
|
-
const fs_1 = require("../utils/fs");
|
|
60
59
|
const list_1 = require("../utils/list");
|
|
60
|
+
const object_1 = require("../utils/object");
|
|
61
61
|
const progress_1 = require("../utils/progress");
|
|
62
|
-
const string_1 = require("../utils/string");
|
|
63
62
|
const temp_1 = require("../utils/temp");
|
|
64
63
|
const SnapshotsAction_1 = require("./SnapshotsAction");
|
|
65
64
|
const assert_1 = require("assert");
|
|
66
65
|
const chalk_1 = __importDefault(require("chalk"));
|
|
66
|
+
exports.restoreActionOptions = {
|
|
67
|
+
id: {
|
|
68
|
+
description: "Filter by snapshot id",
|
|
69
|
+
shortFlag: "i",
|
|
70
|
+
required: true,
|
|
71
|
+
},
|
|
72
|
+
...(0, object_1.pickProps)(SnapshotsAction_1.snapshotsActionOptions, {
|
|
73
|
+
tags: true,
|
|
74
|
+
packageNames: true,
|
|
75
|
+
packageTaskNames: true,
|
|
76
|
+
packageConfig: true,
|
|
77
|
+
repositoryNames: true,
|
|
78
|
+
repositoryTypes: true,
|
|
79
|
+
}),
|
|
80
|
+
initial: {
|
|
81
|
+
description: "Initial restoring (disables restore path)",
|
|
82
|
+
value: "boolean",
|
|
83
|
+
},
|
|
84
|
+
};
|
|
67
85
|
class RestoreAction {
|
|
68
86
|
config;
|
|
69
87
|
options;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
constructor(config, options) {
|
|
88
|
+
settings;
|
|
89
|
+
constructor(config, options, settings) {
|
|
73
90
|
this.config = config;
|
|
74
91
|
this.options = options;
|
|
75
|
-
|
|
76
|
-
async findSnapshots() {
|
|
77
|
-
const result = [];
|
|
78
|
-
const filterRepo = (0, string_1.createPatternFilter)(this.options.repositoryNames);
|
|
79
|
-
const filterRepoType = (0, string_1.createPatternFilter)(this.options.repositoryTypes);
|
|
80
|
-
for (const repository of this.config.repositories) {
|
|
81
|
-
if (!filterRepo(repository.name))
|
|
82
|
-
continue;
|
|
83
|
-
if (!filterRepoType(repository.type))
|
|
84
|
-
continue;
|
|
85
|
-
const snapshotsAction = new SnapshotsAction_1.SnapshotsAction(this.config, {
|
|
86
|
-
repositoryNames: [repository.name],
|
|
87
|
-
ids: [this.options.snapshotId],
|
|
88
|
-
packageNames: this.options.packageNames,
|
|
89
|
-
packageTaskNames: this.options.packageTaskNames,
|
|
90
|
-
packageConfig: this.options.packageConfig,
|
|
91
|
-
tags: this.options.tags,
|
|
92
|
-
});
|
|
93
|
-
const snapshots = await snapshotsAction.exec("restore");
|
|
94
|
-
result.push(...snapshots.map((ss) => ({
|
|
95
|
-
date: ss.date,
|
|
96
|
-
id: ss.id,
|
|
97
|
-
originalId: ss.originalId,
|
|
98
|
-
packageName: ss.packageName,
|
|
99
|
-
packageTaskName: ss.packageTaskName,
|
|
100
|
-
tags: ss.tags,
|
|
101
|
-
repositoryName: repository.name,
|
|
102
|
-
})));
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
groupSnapshots(snapshots) {
|
|
107
|
-
const names = [];
|
|
108
|
-
return snapshots.filter((snapshot) => {
|
|
109
|
-
if (names.includes(snapshot.packageName))
|
|
110
|
-
return false;
|
|
111
|
-
names.push(snapshot.packageName);
|
|
112
|
-
return true;
|
|
113
|
-
});
|
|
92
|
+
this.settings = settings;
|
|
114
93
|
}
|
|
115
94
|
async restore(data) {
|
|
116
95
|
let { snapshot, pkg, task } = data;
|
|
@@ -125,9 +104,8 @@ class RestoreAction {
|
|
|
125
104
|
});
|
|
126
105
|
snapshotPath = taskResult?.snapshotPath;
|
|
127
106
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
await (0, fs_1.ensureFreeDiskSpace)([snapshotPath], this.config.minFreeDiskSpace);
|
|
107
|
+
(0, assert_1.ok)(snapshotPath);
|
|
108
|
+
await (0, repository_1.initSnapshotPath)(snapshotPath, this.config.minFreeDiskSpace);
|
|
131
109
|
await repo.restore({
|
|
132
110
|
options: this.options,
|
|
133
111
|
snapshot: data.snapshot,
|
|
@@ -176,21 +154,21 @@ class RestoreAction {
|
|
|
176
154
|
renderTitle(item, true),
|
|
177
155
|
renderData(item, true, result),
|
|
178
156
|
(0, date_1.duration)(item.elapsed),
|
|
179
|
-
(0, cli_1.renderError)(item.error, options.
|
|
157
|
+
(0, cli_1.renderError)(item.error, options.errors?.indexOf(item.error)),
|
|
180
158
|
]),
|
|
181
159
|
},
|
|
182
160
|
});
|
|
183
161
|
}
|
|
184
162
|
async exec() {
|
|
185
|
-
const { options } = this;
|
|
163
|
+
const { options, settings } = this;
|
|
186
164
|
const gc = new temp_1.GargabeCollector();
|
|
187
165
|
const pm = new progress_1.ProgressManager({
|
|
188
166
|
verbose: options.verbose,
|
|
189
|
-
tty:
|
|
190
|
-
mode:
|
|
167
|
+
tty: settings.tty,
|
|
168
|
+
mode: settings.progress,
|
|
191
169
|
});
|
|
192
170
|
const l = new list_1.Listr3({
|
|
193
|
-
streams:
|
|
171
|
+
streams: settings.streams,
|
|
194
172
|
progressManager: pm,
|
|
195
173
|
gargabeCollector: gc,
|
|
196
174
|
});
|
|
@@ -211,12 +189,22 @@ class RestoreAction {
|
|
|
211
189
|
const { minFreeDiskSpace } = this.config;
|
|
212
190
|
if (minFreeDiskSpace)
|
|
213
191
|
await (0, temp_1.ensureFreeDiskTempSpace)(minFreeDiskSpace);
|
|
214
|
-
if (!options.
|
|
192
|
+
if (!options.id)
|
|
215
193
|
throw new error_1.AppError("Snapshot id is required");
|
|
216
|
-
const snapshots =
|
|
194
|
+
const snapshots = await new SnapshotsAction_1.SnapshotsAction(this.config, {
|
|
195
|
+
ids: [this.options.id],
|
|
196
|
+
repositoryNames: this.options.repositoryNames,
|
|
197
|
+
repositoryTypes: this.options.repositoryTypes,
|
|
198
|
+
packageNames: this.options.packageNames,
|
|
199
|
+
packageTaskNames: this.options.packageTaskNames,
|
|
200
|
+
packageConfig: this.options.packageConfig,
|
|
201
|
+
tags: this.options.tags,
|
|
202
|
+
groupBy: ["packageName"],
|
|
203
|
+
last: 1,
|
|
204
|
+
}).exec("restore");
|
|
217
205
|
if (!snapshots.length)
|
|
218
206
|
throw new error_1.AppError("None snapshot found");
|
|
219
|
-
data.id = options.
|
|
207
|
+
data.id = options.id;
|
|
220
208
|
data.packages = snapshots.length;
|
|
221
209
|
return snapshots.map((snapshot) => l.$task({
|
|
222
210
|
key: "restore",
|
|
@@ -233,7 +221,7 @@ class RestoreAction {
|
|
|
233
221
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
234
222
|
try {
|
|
235
223
|
let pkg = (0, config_1.resolvePackage)((0, config_1.findPackageOrFail)(this.config, snapshot.packageName), {
|
|
236
|
-
snapshotId: options.
|
|
224
|
+
snapshotId: options.id,
|
|
237
225
|
snapshotDate: snapshot.date,
|
|
238
226
|
action: "restore",
|
|
239
227
|
});
|
|
@@ -299,7 +287,7 @@ class RestoreAction {
|
|
|
299
287
|
}));
|
|
300
288
|
},
|
|
301
289
|
}))
|
|
302
|
-
.
|
|
290
|
+
.execAndParse(this.options.verbose);
|
|
303
291
|
}
|
|
304
292
|
}
|
|
305
293
|
exports.RestoreAction = RestoreAction;
|
|
@@ -1,34 +1,93 @@
|
|
|
1
1
|
import { Snapshot } from "../repositories/RepositoryAbstract";
|
|
2
2
|
import type { Config, RepositoryConfigEnabledAction } from "../utils/datatruck/config-type";
|
|
3
|
-
import {
|
|
3
|
+
import { InferOptions } from "../utils/options";
|
|
4
4
|
export type SnapshotGroupByType = keyof Pick<ExtendedSnapshot, "packageName" | "repositoryName" | "repositoryType">;
|
|
5
|
-
export
|
|
6
|
-
ids
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
export declare const snapshotsActionOptions: {
|
|
6
|
+
ids: {
|
|
7
|
+
description: string;
|
|
8
|
+
shortFlag: string;
|
|
9
|
+
value: "array";
|
|
10
|
+
};
|
|
11
|
+
repositoryNames: {
|
|
12
|
+
description: string;
|
|
13
|
+
shortFlag: string;
|
|
14
|
+
value: "array";
|
|
15
|
+
};
|
|
16
|
+
repositoryTypes: {
|
|
17
|
+
description: string;
|
|
18
|
+
shortFlag: string;
|
|
19
|
+
value: "array";
|
|
20
|
+
};
|
|
21
|
+
packageNames: {
|
|
22
|
+
description: string;
|
|
23
|
+
shortFlag: string;
|
|
24
|
+
value: "array";
|
|
25
|
+
};
|
|
26
|
+
packageTaskNames: {
|
|
27
|
+
description: string;
|
|
28
|
+
shortFlag: string;
|
|
29
|
+
value: "array";
|
|
30
|
+
};
|
|
31
|
+
tags: {
|
|
32
|
+
description: string;
|
|
33
|
+
shortFlag: string;
|
|
34
|
+
value: "array";
|
|
35
|
+
};
|
|
36
|
+
packageConfig: {
|
|
37
|
+
description: string;
|
|
38
|
+
shortFlag: string;
|
|
39
|
+
};
|
|
40
|
+
hostnames: {
|
|
41
|
+
description: string;
|
|
42
|
+
shortFlag: string;
|
|
43
|
+
value: "array";
|
|
44
|
+
};
|
|
45
|
+
groupBy: {
|
|
46
|
+
description: string;
|
|
47
|
+
shortFlag: string;
|
|
48
|
+
value: (v: string) => ("packageName" | "repositoryName" | "repositoryType" | "id")[];
|
|
49
|
+
};
|
|
50
|
+
last: {
|
|
51
|
+
description: string;
|
|
52
|
+
shortFlag: string;
|
|
53
|
+
value: "number";
|
|
54
|
+
};
|
|
55
|
+
lastMinutely: {
|
|
56
|
+
description: string;
|
|
57
|
+
value: "number";
|
|
58
|
+
};
|
|
59
|
+
lastDaily: {
|
|
60
|
+
description: string;
|
|
61
|
+
value: "number";
|
|
62
|
+
};
|
|
63
|
+
lastHourly: {
|
|
64
|
+
description: string;
|
|
65
|
+
value: "number";
|
|
66
|
+
};
|
|
67
|
+
lastMonthly: {
|
|
68
|
+
description: string;
|
|
69
|
+
value: "number";
|
|
70
|
+
};
|
|
71
|
+
lastWeekly: {
|
|
72
|
+
description: string;
|
|
73
|
+
value: "number";
|
|
74
|
+
};
|
|
75
|
+
lastYearly: {
|
|
76
|
+
description: string;
|
|
77
|
+
value: "number";
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export type SnapshotsActionOptions = InferOptions<typeof snapshotsActionOptions> & {
|
|
13
81
|
verbose?: boolean;
|
|
14
|
-
tags?: string[];
|
|
15
|
-
last?: number;
|
|
16
|
-
lastMinutely?: number;
|
|
17
|
-
lastHourly?: number;
|
|
18
|
-
lastDaily?: number;
|
|
19
|
-
lastWeekly?: number;
|
|
20
|
-
lastMonthly?: number;
|
|
21
|
-
lastYearly?: number;
|
|
22
|
-
groupBy?: SnapshotGroupByType[];
|
|
23
82
|
};
|
|
24
83
|
export type ExtendedSnapshot = {
|
|
25
84
|
shortId: string;
|
|
26
85
|
repositoryName: string;
|
|
27
86
|
repositoryType: string;
|
|
28
87
|
} & Snapshot;
|
|
29
|
-
export declare class SnapshotsAction
|
|
88
|
+
export declare class SnapshotsAction {
|
|
30
89
|
readonly config: Config;
|
|
31
|
-
readonly options:
|
|
32
|
-
constructor(config: Config, options:
|
|
90
|
+
readonly options: SnapshotsActionOptions;
|
|
91
|
+
constructor(config: Config, options: SnapshotsActionOptions);
|
|
33
92
|
exec(sourceAction?: RepositoryConfigEnabledAction): Promise<ExtendedSnapshot[]>;
|
|
34
93
|
}
|
|
@@ -1,10 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SnapshotsAction = void 0;
|
|
3
|
+
exports.SnapshotsAction = exports.snapshotsActionOptions = void 0;
|
|
4
4
|
const config_1 = require("../utils/datatruck/config");
|
|
5
5
|
const repository_1 = require("../utils/datatruck/repository");
|
|
6
6
|
const snapshot_1 = require("../utils/datatruck/snapshot");
|
|
7
7
|
const string_1 = require("../utils/string");
|
|
8
|
+
const groupByValues = [
|
|
9
|
+
"id",
|
|
10
|
+
"packageName",
|
|
11
|
+
"repositoryName",
|
|
12
|
+
"repositoryType",
|
|
13
|
+
];
|
|
14
|
+
exports.snapshotsActionOptions = {
|
|
15
|
+
ids: {
|
|
16
|
+
description: "Filter by identifiers",
|
|
17
|
+
shortFlag: "i",
|
|
18
|
+
value: "array",
|
|
19
|
+
},
|
|
20
|
+
repositoryNames: {
|
|
21
|
+
description: "Filter by repository names",
|
|
22
|
+
shortFlag: "r",
|
|
23
|
+
value: "array",
|
|
24
|
+
},
|
|
25
|
+
repositoryTypes: {
|
|
26
|
+
description: "Filter by repository types",
|
|
27
|
+
shortFlag: "rt",
|
|
28
|
+
value: "array",
|
|
29
|
+
},
|
|
30
|
+
packageNames: {
|
|
31
|
+
description: "Filter by package names",
|
|
32
|
+
shortFlag: "p",
|
|
33
|
+
value: "array",
|
|
34
|
+
},
|
|
35
|
+
packageTaskNames: {
|
|
36
|
+
description: "Filter by task names",
|
|
37
|
+
shortFlag: "pt",
|
|
38
|
+
value: "array",
|
|
39
|
+
},
|
|
40
|
+
tags: {
|
|
41
|
+
description: "Filter by tags",
|
|
42
|
+
shortFlag: "t",
|
|
43
|
+
value: "array",
|
|
44
|
+
},
|
|
45
|
+
packageConfig: {
|
|
46
|
+
description: "Filter by package config",
|
|
47
|
+
shortFlag: "pc",
|
|
48
|
+
},
|
|
49
|
+
hostnames: {
|
|
50
|
+
description: "Filter by hostnames",
|
|
51
|
+
shortFlag: "h",
|
|
52
|
+
value: "array",
|
|
53
|
+
},
|
|
54
|
+
groupBy: {
|
|
55
|
+
description: `Group by values (${groupByValues.join(", ")})`,
|
|
56
|
+
shortFlag: "g",
|
|
57
|
+
value: (v) => (0, string_1.parseStringList)(v, groupByValues),
|
|
58
|
+
},
|
|
59
|
+
last: {
|
|
60
|
+
description: "Filter by last snapshots",
|
|
61
|
+
shortFlag: "l",
|
|
62
|
+
value: "number",
|
|
63
|
+
},
|
|
64
|
+
lastMinutely: {
|
|
65
|
+
description: "Filter by last minutely",
|
|
66
|
+
value: "number",
|
|
67
|
+
},
|
|
68
|
+
lastDaily: {
|
|
69
|
+
description: "Filter by last daily",
|
|
70
|
+
value: "number",
|
|
71
|
+
},
|
|
72
|
+
lastHourly: {
|
|
73
|
+
description: "Filter by last hourly",
|
|
74
|
+
value: "number",
|
|
75
|
+
},
|
|
76
|
+
lastMonthly: {
|
|
77
|
+
description: "Filter by last monthly",
|
|
78
|
+
value: "number",
|
|
79
|
+
},
|
|
80
|
+
lastWeekly: {
|
|
81
|
+
description: "Filter by last weekly",
|
|
82
|
+
value: "number",
|
|
83
|
+
},
|
|
84
|
+
lastYearly: {
|
|
85
|
+
description: "Filter by last yearly",
|
|
86
|
+
value: "number",
|
|
87
|
+
},
|
|
88
|
+
};
|
|
8
89
|
class SnapshotsAction {
|
|
9
90
|
config;
|
|
10
91
|
options;
|
package/lib/cli.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import { DatatruckCommandMap, InferDatatruckCommandOptions } from "./utils/datatruck/command";
|
|
2
|
-
export declare function buildArgs<T extends keyof DatatruckCommandMap>(input: T, options: InferDatatruckCommandOptions<T>): any[];
|
|
3
1
|
export declare function parseArgs(args: string[]): void;
|
|
4
|
-
export declare function exec<T extends keyof DatatruckCommandMap>(input: T, options: InferDatatruckCommandOptions<T>): Promise<void>;
|