@datatruck/cli 0.37.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/config.schema.json +130 -74
  2. package/lib/actions/BackupAction.d.ts +55 -19
  3. package/lib/actions/BackupAction.js +31 -7
  4. package/lib/actions/CleanCacheAction.d.ts +6 -7
  5. package/lib/actions/CleanCacheAction.js +2 -1
  6. package/lib/actions/ConfigAction.d.ts +3 -5
  7. package/lib/actions/ConfigAction.js +0 -1
  8. package/lib/actions/CopyAction.d.ts +37 -11
  9. package/lib/actions/CopyAction.js +29 -2
  10. package/lib/actions/ExportAction.d.ts +94 -0
  11. package/lib/actions/ExportAction.js +236 -0
  12. package/lib/actions/InitAction.d.ts +17 -7
  13. package/lib/actions/InitAction.js +9 -1
  14. package/lib/actions/PruneAction.d.ts +76 -17
  15. package/lib/actions/PruneAction.js +62 -2
  16. package/lib/actions/RestoreAction.d.ts +55 -21
  17. package/lib/actions/RestoreAction.js +44 -56
  18. package/lib/actions/SnapshotsAction.d.ts +80 -21
  19. package/lib/actions/SnapshotsAction.js +82 -1
  20. package/lib/cli.d.ts +0 -3
  21. package/lib/cli.js +14 -93
  22. package/lib/commands/BackupCommand.d.ts +120 -13
  23. package/lib/commands/BackupCommand.js +22 -50
  24. package/lib/commands/CleanCacheCommand.d.ts +10 -3
  25. package/lib/commands/CleanCacheCommand.js +14 -6
  26. package/lib/commands/CommandAbstract.d.ts +10 -10
  27. package/lib/commands/CommandAbstract.js +6 -9
  28. package/lib/commands/ConfigCommand.d.ts +72 -9
  29. package/lib/commands/ConfigCommand.js +36 -28
  30. package/lib/commands/CopyCommand.d.ts +102 -10
  31. package/lib/commands/CopyCommand.js +18 -40
  32. package/lib/commands/ExportCommand.d.ts +143 -0
  33. package/lib/commands/ExportCommand.js +50 -0
  34. package/lib/commands/InitCommand.d.ts +42 -7
  35. package/lib/commands/InitCommand.js +15 -17
  36. package/lib/commands/PruneCommand.d.ts +237 -17
  37. package/lib/commands/PruneCommand.js +27 -99
  38. package/lib/commands/RestoreCommand.d.ts +126 -13
  39. package/lib/commands/RestoreCommand.js +20 -49
  40. package/lib/commands/RunCommand.d.ts +23 -4
  41. package/lib/commands/RunCommand.js +21 -12
  42. package/lib/commands/SnapshotsCommand.d.ts +240 -23
  43. package/lib/commands/SnapshotsCommand.js +23 -101
  44. package/lib/commands/StartServerCommand.d.ts +10 -3
  45. package/lib/commands/StartServerCommand.js +11 -3
  46. package/lib/repositories/DatatruckRepository.js +1 -1
  47. package/lib/repositories/GitRepository.js +5 -2
  48. package/lib/tasks/MssqlTask.js +1 -1
  49. package/lib/tasks/MysqlDumpTask.js +1 -1
  50. package/lib/tasks/SqlDumpTaskAbstract.js +2 -2
  51. package/lib/utils/cli.d.ts +0 -17
  52. package/lib/utils/cli.js +1 -47
  53. package/lib/utils/datatruck/command.d.ts +6 -5
  54. package/lib/utils/datatruck/command.js +9 -5
  55. package/lib/utils/datatruck/job.js +17 -12
  56. package/lib/utils/datatruck/repository.d.ts +1 -0
  57. package/lib/utils/datatruck/repository.js +8 -1
  58. package/lib/utils/git.d.ts +5 -1
  59. package/lib/utils/git.js +7 -3
  60. package/lib/utils/math.js +1 -1
  61. package/lib/utils/object.d.ts +5 -0
  62. package/lib/utils/object.js +10 -1
  63. package/lib/utils/options.d.ts +24 -0
  64. package/lib/utils/options.js +94 -0
  65. package/lib/utils/progress.js +1 -1
  66. package/lib/utils/restic.js +1 -1
  67. package/lib/utils/string.d.ts +2 -1
  68. package/lib/utils/string.js +5 -1
  69. package/lib/utils/watcher.js +1 -1
  70. package/package.json +4 -4
@@ -0,0 +1,94 @@
1
+ import { DataFormat } from "../utils/data-format";
2
+ import type { Config } from "../utils/datatruck/config-type";
3
+ import { Listr3TaskResultEnd } from "../utils/list";
4
+ import { InferOptions } from "../utils/options";
5
+ import { Progress, ProgressMode } from "../utils/progress";
6
+ import { StdStreams } from "../utils/stream";
7
+ import { ExtendedSnapshot } from "./SnapshotsAction";
8
+ export declare const exportActionOptions: {
9
+ repositoryNames: {
10
+ description: string;
11
+ shortFlag: string;
12
+ value: "array";
13
+ };
14
+ repositoryTypes: {
15
+ description: string;
16
+ shortFlag: string;
17
+ value: "array";
18
+ };
19
+ packageNames: {
20
+ description: string;
21
+ shortFlag: string;
22
+ value: "array";
23
+ };
24
+ packageTaskNames: {
25
+ description: string;
26
+ shortFlag: string;
27
+ value: "array";
28
+ };
29
+ tags: {
30
+ description: string;
31
+ shortFlag: string;
32
+ value: "array";
33
+ };
34
+ packageConfig: {
35
+ description: string;
36
+ shortFlag: string;
37
+ };
38
+ id: {
39
+ description: string;
40
+ shortFlag: string;
41
+ required: true;
42
+ };
43
+ outPath: {
44
+ description: string;
45
+ required: true;
46
+ };
47
+ };
48
+ export type ExportActionOptions = InferOptions<typeof exportActionOptions> & {
49
+ verbose?: boolean;
50
+ };
51
+ type Context = {
52
+ snapshots: {
53
+ id: string;
54
+ packages: number;
55
+ };
56
+ task: {
57
+ taskName: string;
58
+ packageName: string;
59
+ };
60
+ export: ExtendedSnapshot;
61
+ };
62
+ export declare class ExportAction {
63
+ readonly config: Config;
64
+ readonly options: ExportActionOptions;
65
+ readonly settings: {
66
+ tty?: "auto" | boolean;
67
+ progress?: ProgressMode;
68
+ streams?: StdStreams;
69
+ };
70
+ constructor(config: Config, options: ExportActionOptions, settings: {
71
+ tty?: "auto" | boolean;
72
+ progress?: ProgressMode;
73
+ streams?: StdStreams;
74
+ });
75
+ protected restore(data: {
76
+ pkg: {
77
+ name: string;
78
+ };
79
+ snapshotPath: string;
80
+ snapshot: ExtendedSnapshot;
81
+ onProgress: (progress: Progress) => void;
82
+ }): Promise<void>;
83
+ dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
84
+ streams?: StdStreams;
85
+ verbose?: number;
86
+ errors?: Error[];
87
+ }): DataFormat;
88
+ exec(): Promise<{
89
+ result: (import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<Context>)[];
90
+ exitCode: number;
91
+ errors: Error[];
92
+ }>;
93
+ }
94
+ export {};
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
3
+ if (value !== null && value !== void 0) {
4
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
5
+ var dispose;
6
+ if (async) {
7
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
8
+ dispose = value[Symbol.asyncDispose];
9
+ }
10
+ if (dispose === void 0) {
11
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
12
+ dispose = value[Symbol.dispose];
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ env.stack.push({ value: value, dispose: dispose, async: async });
16
+ }
17
+ else if (async) {
18
+ env.stack.push({ async: true });
19
+ }
20
+ return value;
21
+ };
22
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
23
+ return function (env) {
24
+ function fail(e) {
25
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
26
+ env.hasError = true;
27
+ }
28
+ function next() {
29
+ while (env.stack.length) {
30
+ var rec = env.stack.pop();
31
+ try {
32
+ var result = rec.dispose && rec.dispose.call(rec.value);
33
+ if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
34
+ }
35
+ catch (e) {
36
+ fail(e);
37
+ }
38
+ }
39
+ if (env.hasError) throw env.error;
40
+ }
41
+ return next();
42
+ };
43
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
44
+ var e = new Error(message);
45
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46
+ });
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.ExportAction = exports.exportActionOptions = void 0;
52
+ const DatatruckRepository_1 = require("../repositories/DatatruckRepository");
53
+ const cli_1 = require("../utils/cli");
54
+ const data_format_1 = require("../utils/data-format");
55
+ const config_1 = require("../utils/datatruck/config");
56
+ const repository_1 = require("../utils/datatruck/repository");
57
+ const date_1 = require("../utils/date");
58
+ const error_1 = require("../utils/error");
59
+ const list_1 = require("../utils/list");
60
+ const object_1 = require("../utils/object");
61
+ const progress_1 = require("../utils/progress");
62
+ const temp_1 = require("../utils/temp");
63
+ const SnapshotsAction_1 = require("./SnapshotsAction");
64
+ const chalk_1 = __importDefault(require("chalk"));
65
+ const path_1 = require("path");
66
+ exports.exportActionOptions = {
67
+ id: {
68
+ description: "Filter by snapshot id",
69
+ shortFlag: "i",
70
+ required: true,
71
+ },
72
+ outPath: {
73
+ description: "Out path",
74
+ required: true,
75
+ },
76
+ ...(0, object_1.pickProps)(SnapshotsAction_1.snapshotsActionOptions, {
77
+ tags: true,
78
+ packageNames: true,
79
+ packageTaskNames: true,
80
+ packageConfig: true,
81
+ repositoryNames: true,
82
+ repositoryTypes: true,
83
+ }),
84
+ };
85
+ class ExportAction {
86
+ config;
87
+ options;
88
+ settings;
89
+ constructor(config, options, settings) {
90
+ this.config = config;
91
+ this.options = options;
92
+ this.settings = settings;
93
+ }
94
+ async restore(data) {
95
+ let { snapshot, snapshotPath, pkg } = data;
96
+ await (0, repository_1.initSnapshotPath)(snapshotPath, this.config.minFreeDiskSpace);
97
+ const repoConfig = (0, config_1.findRepositoryOrFail)(this.config, snapshot.repositoryName);
98
+ const repo = await (0, repository_1.createAndInitRepo)(repoConfig, this.options.verbose);
99
+ await repo.restore({
100
+ options: this.options,
101
+ snapshot: data.snapshot,
102
+ package: pkg,
103
+ snapshotPath: snapshotPath,
104
+ packageConfig: undefined,
105
+ onProgress: data.onProgress,
106
+ });
107
+ }
108
+ dataFormat(result, options = {}) {
109
+ const renderTitle = (item, color) => {
110
+ let title = item.key.slice(0, 1).toUpperCase() + item.key.slice(1);
111
+ return item.key === "export" && color ? chalk_1.default.cyan(title) : title;
112
+ };
113
+ const renderData = (item, color, result = []) => {
114
+ const g = (v) => (color ? `${chalk_1.default.gray(`(${v})`)}` : `(${v})`);
115
+ return (0, cli_1.renderListTaskItem)(item, color, {
116
+ snapshots: (data) => [
117
+ data.id.slice(0, 8),
118
+ g(`${data.packages} packages`),
119
+ ],
120
+ task: (data) => [data.packageName, g(data.taskName)],
121
+ export: (data) => [data.packageName, g(data.repositoryName)],
122
+ summary: (data) => ({
123
+ errors: data.errors,
124
+ exports: result.filter((r) => !r.error && r.key === "export").length,
125
+ }),
126
+ });
127
+ };
128
+ return new data_format_1.DataFormat({
129
+ streams: options.streams,
130
+ json: result,
131
+ table: {
132
+ headers: [
133
+ { value: "", width: 3 },
134
+ { value: "Title", width: 15 },
135
+ { value: "Data" },
136
+ { value: "Duration", width: 10 },
137
+ { value: "Error", width: 50 },
138
+ ],
139
+ rows: () => result.map((item) => [
140
+ (0, cli_1.renderResult)(item.error),
141
+ renderTitle(item, true),
142
+ renderData(item, true, result),
143
+ (0, date_1.duration)(item.elapsed),
144
+ (0, cli_1.renderError)(item.error, options.errors?.indexOf(item.error)),
145
+ ]),
146
+ },
147
+ });
148
+ }
149
+ async exec() {
150
+ const { options, settings } = this;
151
+ const gc = new temp_1.GargabeCollector();
152
+ const pm = new progress_1.ProgressManager({
153
+ verbose: options.verbose,
154
+ tty: settings.tty,
155
+ mode: settings.progress,
156
+ });
157
+ const l = new list_1.Listr3({
158
+ streams: settings.streams,
159
+ progressManager: pm,
160
+ gargabeCollector: gc,
161
+ });
162
+ return l
163
+ .add(l.$task({
164
+ key: "snapshots",
165
+ data: {
166
+ id: "",
167
+ packages: 0,
168
+ },
169
+ title: {
170
+ initial: "Fetch snapshots",
171
+ started: "Fetching snapshots",
172
+ completed: "Snapshots fetched",
173
+ failed: "Snapshot fetch failed",
174
+ },
175
+ run: async (_, data) => {
176
+ const { minFreeDiskSpace } = this.config;
177
+ if (minFreeDiskSpace)
178
+ await (0, temp_1.ensureFreeDiskTempSpace)(minFreeDiskSpace);
179
+ if (!options.id)
180
+ throw new error_1.AppError("Snapshot id is required");
181
+ const snapshots = await new SnapshotsAction_1.SnapshotsAction(this.config, {
182
+ ids: [this.options.id],
183
+ repositoryNames: this.options.repositoryNames,
184
+ repositoryTypes: this.options.repositoryTypes,
185
+ packageNames: this.options.packageNames,
186
+ packageTaskNames: this.options.packageTaskNames,
187
+ packageConfig: this.options.packageConfig,
188
+ tags: this.options.tags,
189
+ groupBy: ["packageName"],
190
+ }).exec("restore");
191
+ if (!snapshots.length)
192
+ throw new error_1.AppError("None snapshot found");
193
+ data.id = options.id;
194
+ data.packages = snapshots.length;
195
+ return snapshots.map((snapshot) => l.$task({
196
+ key: "export",
197
+ keyIndex: snapshot.packageName,
198
+ data: snapshot,
199
+ title: {
200
+ initial: `Export snapshot: ${snapshot.packageName} (${snapshot.repositoryName})`,
201
+ started: `Restoring snapshot: ${snapshot.packageName} (${snapshot.repositoryName})`,
202
+ completed: `Snapshot exported: ${snapshot.packageName} (${snapshot.repositoryName})`,
203
+ failed: `Snapshot export failed: ${snapshot.packageName} (${snapshot.repositoryName})`,
204
+ },
205
+ exitOnError: false,
206
+ run: async (listTask) => {
207
+ const env_1 = { stack: [], error: void 0, hasError: false };
208
+ try {
209
+ const progress = __addDisposableResource(env_1, pm.create(listTask), false);
210
+ const _ = __addDisposableResource(env_1, gc.create().disposeOnFinish(), true);
211
+ await this.restore({
212
+ pkg: { name: snapshot.packageName },
213
+ snapshotPath: (0, path_1.join)(this.options.outPath, snapshot.repositoryName, DatatruckRepository_1.DatatruckRepository.createSnapshotName(snapshot, {
214
+ name: snapshot.packageName,
215
+ })),
216
+ snapshot: snapshot,
217
+ onProgress: progress.update,
218
+ });
219
+ }
220
+ catch (e_1) {
221
+ env_1.error = e_1;
222
+ env_1.hasError = true;
223
+ }
224
+ finally {
225
+ const result_1 = __disposeResources(env_1);
226
+ if (result_1)
227
+ await result_1;
228
+ }
229
+ },
230
+ }));
231
+ },
232
+ }))
233
+ .execAndParse(this.options.verbose);
234
+ }
235
+ }
236
+ exports.ExportAction = ExportAction;
@@ -1,14 +1,24 @@
1
1
  import type { Config } from "../utils/datatruck/config-type";
2
- import { IfRequireKeys } from "../utils/ts";
3
- export type InitActionOptions = {
4
- repositoryNames?: string[];
5
- repositoryTypes?: string[];
2
+ import { InferOptions } from "../utils/options";
3
+ export declare const initActionOptions: {
4
+ repositoryNames: {
5
+ description: string;
6
+ shortFlag: string;
7
+ value: "array";
8
+ };
9
+ repositoryTypes: {
10
+ description: string;
11
+ shortFlag: string;
12
+ value: "array";
13
+ };
14
+ };
15
+ export type InitActionOptions = InferOptions<typeof initActionOptions> & {
6
16
  verbose?: boolean;
7
17
  };
8
- export declare class InitAction<TRequired extends boolean = true> {
18
+ export declare class InitAction {
9
19
  readonly config: Config;
10
- readonly options: IfRequireKeys<TRequired, InitActionOptions>;
11
- constructor(config: Config, options: IfRequireKeys<TRequired, InitActionOptions>);
20
+ readonly options: InitActionOptions;
21
+ constructor(config: Config, options: InitActionOptions);
12
22
  exec(): Promise<{
13
23
  repositoryName: string;
14
24
  repositoryType: string;
@@ -1,9 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InitAction = void 0;
3
+ exports.InitAction = exports.initActionOptions = void 0;
4
4
  const config_1 = require("../utils/datatruck/config");
5
5
  const repository_1 = require("../utils/datatruck/repository");
6
+ const object_1 = require("../utils/object");
6
7
  const string_1 = require("../utils/string");
8
+ const SnapshotsAction_1 = require("./SnapshotsAction");
9
+ exports.initActionOptions = {
10
+ ...(0, object_1.pickProps)(SnapshotsAction_1.snapshotsActionOptions, {
11
+ repositoryNames: true,
12
+ repositoryTypes: true,
13
+ }),
14
+ };
7
15
  class InitAction {
8
16
  config;
9
17
  options;
@@ -1,18 +1,77 @@
1
- import type { Config, RepositoryConfig } from "../utils/datatruck/config-type";
2
- import { KeepObject } from "../utils/date";
3
- import { IfRequireKeys } from "../utils/ts";
4
- import { ExtendedSnapshot, SnapshotsActionOptions } from "./SnapshotsAction";
5
- export type PruneActionsOptions = KeepObject & {
6
- ids?: string[];
7
- packageNames?: string[];
8
- repositoryNames?: string[];
9
- repositoryTypes?: RepositoryConfig["type"][];
10
- tags?: string[];
1
+ import type { Config } from "../utils/datatruck/config-type";
2
+ import { InferOptions } from "../utils/options";
3
+ import { ExtendedSnapshot } from "./SnapshotsAction";
4
+ export declare const pruneActionOptions: {
5
+ groupBy: {
6
+ description: string;
7
+ shortFlag: string;
8
+ defaults: string;
9
+ value: (v: string) => ("packageName" | "repositoryName" | "repositoryType")[];
10
+ };
11
+ dryRun: {
12
+ description: string;
13
+ value: "boolean";
14
+ };
15
+ showAll: {
16
+ description: string;
17
+ shortFlag: string;
18
+ };
19
+ keepMinutely: {
20
+ description: string;
21
+ value: "number";
22
+ };
23
+ keepDaily: {
24
+ description: string;
25
+ value: "number";
26
+ };
27
+ keepHourly: {
28
+ description: string;
29
+ value: "number";
30
+ };
31
+ keepLast: {
32
+ description: string;
33
+ value: "number";
34
+ };
35
+ keepMonthly: {
36
+ description: string;
37
+ value: "number";
38
+ };
39
+ keepWeekly: {
40
+ description: string;
41
+ value: "number";
42
+ };
43
+ keepYearly: {
44
+ description: string;
45
+ value: "number";
46
+ };
47
+ repositoryNames: {
48
+ description: string;
49
+ shortFlag: string;
50
+ value: "array";
51
+ };
52
+ repositoryTypes: {
53
+ description: string;
54
+ shortFlag: string;
55
+ value: "array";
56
+ };
57
+ packageNames: {
58
+ description: string;
59
+ shortFlag: string;
60
+ value: "array";
61
+ };
62
+ tags: {
63
+ description: string;
64
+ shortFlag: string;
65
+ value: "array";
66
+ };
67
+ ids: {
68
+ description: string;
69
+ shortFlag: string;
70
+ value: "array";
71
+ };
72
+ };
73
+ export type PruneActionsOptions = InferOptions<typeof pruneActionOptions> & {
11
74
  verbose?: boolean;
12
- groupBy?: SnapshotsActionOptions["groupBy"];
13
- dryRun?: boolean;
14
- longId?: boolean;
15
- returnsAll?: boolean;
16
75
  };
17
76
  export type PruneResult = {
18
77
  total: number;
@@ -21,10 +80,10 @@ export type PruneResult = {
21
80
  exclusionReasons: string[];
22
81
  })[];
23
82
  };
24
- export declare class PruneAction<TRequired extends boolean = true> {
83
+ export declare class PruneAction {
25
84
  readonly config: Config;
26
- readonly options: IfRequireKeys<TRequired, PruneActionsOptions>;
27
- constructor(config: Config, options: IfRequireKeys<TRequired, PruneActionsOptions>);
85
+ readonly options: PruneActionsOptions;
86
+ constructor(config: Config, options: PruneActionsOptions);
28
87
  confirm(snapshots: PruneResult["snapshots"]): Promise<void>;
29
88
  exec(): Promise<PruneResult>;
30
89
  }
@@ -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.returnsAll)
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
- import { IfRequireKeys } from "../utils/ts";
9
- export type RestoreActionOptions = {
10
- snapshotId: string;
11
- tags?: string[];
12
- packageNames?: string[];
13
- packageTaskNames?: string[];
14
- packageConfig?: boolean;
15
- repositoryNames?: string[];
16
- repositoryTypes?: string[];
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,21 +63,26 @@ type Context = {
34
63
  };
35
64
  restore: RestoreSnapshot;
36
65
  };
37
- export declare class RestoreAction<TRequired extends boolean = true> {
66
+ export declare class RestoreAction {
38
67
  readonly config: Config;
39
- readonly options: IfRequireKeys<TRequired, RestoreActionOptions>;
40
- protected taskErrors: Record<string, Error[]>;
41
- protected repoErrors: Record<string, Error[]>;
42
- constructor(config: Config, options: IfRequireKeys<TRequired, RestoreActionOptions>);
43
- protected findSnapshots(): Promise<RestoreSnapshot[]>;
44
- protected groupSnapshots(snapshots: RestoreSnapshot[]): RestoreSnapshot[];
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 | undefined;
85
+ snapshotPath: string;
52
86
  }>;
53
87
  dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
54
88
  streams?: StdStreams;