@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,143 @@
1
+ import { InferOptions } from "../utils/options";
2
+ import { CommandAbstract } from "./CommandAbstract";
3
+ export declare const exportCommandOptions: {
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
+ packageNames: {
15
+ description: string;
16
+ shortFlag: string;
17
+ value: "array";
18
+ };
19
+ packageTaskNames: {
20
+ description: string;
21
+ shortFlag: string;
22
+ value: "array";
23
+ };
24
+ tags: {
25
+ description: string;
26
+ shortFlag: string;
27
+ value: "array";
28
+ };
29
+ packageConfig: {
30
+ description: string;
31
+ shortFlag: string;
32
+ };
33
+ id: {
34
+ description: string;
35
+ shortFlag: string;
36
+ required: true;
37
+ };
38
+ outPath: {
39
+ description: string;
40
+ required: true;
41
+ };
42
+ };
43
+ export type ExportCommandOptions = InferOptions<typeof exportCommandOptions>;
44
+ export declare class ExportCommand extends CommandAbstract<typeof exportCommandOptions> {
45
+ static config(): {
46
+ name: string;
47
+ options: {
48
+ repositoryNames: {
49
+ description: string;
50
+ shortFlag: string;
51
+ value: "array";
52
+ };
53
+ repositoryTypes: {
54
+ description: string;
55
+ shortFlag: string;
56
+ value: "array";
57
+ };
58
+ packageNames: {
59
+ description: string;
60
+ shortFlag: string;
61
+ value: "array";
62
+ };
63
+ packageTaskNames: {
64
+ description: string;
65
+ shortFlag: string;
66
+ value: "array";
67
+ };
68
+ tags: {
69
+ description: string;
70
+ shortFlag: string;
71
+ value: "array";
72
+ };
73
+ packageConfig: {
74
+ description: string;
75
+ shortFlag: string;
76
+ };
77
+ id: {
78
+ description: string;
79
+ shortFlag: string;
80
+ required: true;
81
+ };
82
+ outPath: {
83
+ description: string;
84
+ required: true;
85
+ };
86
+ };
87
+ };
88
+ get optionsConfig(): {
89
+ repositoryNames: {
90
+ description: string;
91
+ shortFlag: string;
92
+ value: "array";
93
+ };
94
+ repositoryTypes: {
95
+ description: string;
96
+ shortFlag: string;
97
+ value: "array";
98
+ };
99
+ packageNames: {
100
+ description: string;
101
+ shortFlag: string;
102
+ value: "array";
103
+ };
104
+ packageTaskNames: {
105
+ description: string;
106
+ shortFlag: string;
107
+ value: "array";
108
+ };
109
+ tags: {
110
+ description: string;
111
+ shortFlag: string;
112
+ value: "array";
113
+ };
114
+ packageConfig: {
115
+ description: string;
116
+ shortFlag: string;
117
+ };
118
+ id: {
119
+ description: string;
120
+ shortFlag: string;
121
+ required: true;
122
+ };
123
+ outPath: {
124
+ description: string;
125
+ required: true;
126
+ };
127
+ };
128
+ exec(): Promise<{
129
+ result: (import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<{
130
+ snapshots: {
131
+ id: string;
132
+ packages: number;
133
+ };
134
+ task: {
135
+ taskName: string;
136
+ packageName: string;
137
+ };
138
+ export: import("../actions/SnapshotsAction").ExtendedSnapshot;
139
+ }>)[];
140
+ exitCode: number;
141
+ errors: Error[];
142
+ }>;
143
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExportCommand = exports.exportCommandOptions = void 0;
4
+ const ConfigAction_1 = require("../actions/ConfigAction");
5
+ const ExportAction_1 = require("../actions/ExportAction");
6
+ const CommandAbstract_1 = require("./CommandAbstract");
7
+ exports.exportCommandOptions = {
8
+ ...ExportAction_1.exportActionOptions,
9
+ };
10
+ class ExportCommand extends CommandAbstract_1.CommandAbstract {
11
+ static config() {
12
+ return {
13
+ name: "export",
14
+ options: exports.exportCommandOptions,
15
+ };
16
+ }
17
+ get optionsConfig() {
18
+ return exports.exportCommandOptions;
19
+ }
20
+ async exec() {
21
+ const verbose = this.globalOptions.verbose ?? 0;
22
+ const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
23
+ const restore = new ExportAction_1.ExportAction(config, {
24
+ id: this.options.id,
25
+ packageNames: this.options.packageNames,
26
+ packageTaskNames: this.options.packageTaskNames,
27
+ packageConfig: this.options.packageConfig,
28
+ repositoryNames: this.options.repositoryNames,
29
+ repositoryTypes: this.options.repositoryTypes,
30
+ tags: this.options.tags,
31
+ outPath: this.options.outPath,
32
+ verbose: verbose > 0,
33
+ }, {
34
+ tty: this.globalOptions.tty,
35
+ progress: this.globalOptions.progress,
36
+ streams: this.streams,
37
+ });
38
+ const data = await restore.exec();
39
+ if (this.globalOptions.outputFormat)
40
+ restore
41
+ .dataFormat(data.result, {
42
+ verbose,
43
+ streams: this.streams,
44
+ errors: data.errors,
45
+ })
46
+ .log(this.globalOptions.outputFormat);
47
+ return data;
48
+ }
49
+ }
50
+ exports.ExportCommand = ExportCommand;
@@ -1,12 +1,47 @@
1
- import type { RepositoryConfig } from "../utils/datatruck/config-type";
2
- import { If } from "../utils/ts";
1
+ import { InferOptions } from "../utils/options";
3
2
  import { CommandAbstract } from "./CommandAbstract";
4
- export type InitCommandOptions<TResolved = false> = {
5
- repository?: If<TResolved, string[]>;
6
- repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
3
+ export declare const initCommandOptions: {
4
+ repositoryNames: {
5
+ description: string;
6
+ shortFlag: string;
7
+ value: "array";
8
+ };
9
+ repositoryTypes: {
10
+ description: string;
11
+ shortFlag: string;
12
+ value: "array";
13
+ };
7
14
  };
8
- export declare class InitCommand extends CommandAbstract<InitCommandOptions<false>, InitCommandOptions<true>> {
9
- optionsConfig(): import("../utils/cli").OptionsConfig<InitCommandOptions<false>, InitCommandOptions<true>>;
15
+ export type InitCommandOptions = InferOptions<typeof initCommandOptions>;
16
+ export declare class InitCommand extends CommandAbstract<typeof initCommandOptions> {
17
+ static config(): {
18
+ name: string;
19
+ alias: string;
20
+ options: {
21
+ repositoryNames: {
22
+ description: string;
23
+ shortFlag: string;
24
+ value: "array";
25
+ };
26
+ repositoryTypes: {
27
+ description: string;
28
+ shortFlag: string;
29
+ value: "array";
30
+ };
31
+ };
32
+ };
33
+ get optionsConfig(): {
34
+ repositoryNames: {
35
+ description: string;
36
+ shortFlag: string;
37
+ value: "array";
38
+ };
39
+ repositoryTypes: {
40
+ description: string;
41
+ shortFlag: string;
42
+ value: "array";
43
+ };
44
+ };
10
45
  exec(): Promise<{
11
46
  result: {
12
47
  repositoryName: string;
@@ -1,34 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InitCommand = void 0;
3
+ exports.InitCommand = exports.initCommandOptions = void 0;
4
4
  const ConfigAction_1 = require("../actions/ConfigAction");
5
5
  const InitAction_1 = require("../actions/InitAction");
6
6
  const cli_1 = require("../utils/cli");
7
7
  const data_format_1 = require("../utils/data-format");
8
8
  const error_1 = require("../utils/error");
9
- const string_1 = require("../utils/string");
10
9
  const CommandAbstract_1 = require("./CommandAbstract");
10
+ exports.initCommandOptions = {
11
+ ...InitAction_1.initActionOptions,
12
+ };
11
13
  class InitCommand extends CommandAbstract_1.CommandAbstract {
12
- optionsConfig() {
13
- return this.castOptionsConfig({
14
- repository: {
15
- description: "Filter by repository names",
16
- option: "-r,--repository <values>",
17
- parser: string_1.parseStringList,
18
- },
19
- repositoryType: {
20
- description: "Filter by repository types",
21
- option: "-rt,--repository-type <values>",
22
- parser: (v) => (0, string_1.parseStringList)(v),
23
- },
24
- });
14
+ static config() {
15
+ return {
16
+ name: "init",
17
+ alias: "i",
18
+ options: exports.initCommandOptions,
19
+ };
20
+ }
21
+ get optionsConfig() {
22
+ return exports.initCommandOptions;
25
23
  }
26
24
  async exec() {
27
25
  const verbose = this.globalOptions.verbose ?? 0;
28
26
  const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
29
27
  const init = new InitAction_1.InitAction(config, {
30
- repositoryNames: this.options.repository,
31
- repositoryTypes: this.options.repositoryType,
28
+ repositoryNames: this.options.repositoryNames,
29
+ repositoryTypes: this.options.repositoryTypes,
32
30
  verbose: verbose > 0,
33
31
  });
34
32
  const result = await init.exec();
@@ -1,22 +1,242 @@
1
- import { SnapshotGroupByType } from "../actions/SnapshotsAction";
2
- import type { RepositoryConfig } from "../utils/datatruck/config-type";
3
- import { KeepObject } from "../utils/date";
4
- import { If } from "../utils/ts";
1
+ import { InferOptions } from "../utils/options";
5
2
  import { CommandAbstract } from "./CommandAbstract";
6
- export type PruneCommandOptions<TResolved = false> = KeepObject & {
7
- id?: If<TResolved, string[]>;
8
- longId?: boolean;
9
- package?: If<TResolved, string[]>;
10
- repository?: If<TResolved, string[]>;
11
- repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
12
- tag?: If<TResolved, string[]>;
13
- groupBy?: If<TResolved, SnapshotGroupByType[]>;
14
- dryRun?: boolean;
15
- showAll?: boolean;
16
- confirm?: boolean;
3
+ export declare const pruneCommandOptions: {
4
+ longId: {
5
+ description: string;
6
+ value: "boolean";
7
+ };
8
+ confirm: {
9
+ description: string;
10
+ value: "boolean";
11
+ };
12
+ groupBy: {
13
+ description: string;
14
+ shortFlag: string;
15
+ defaults: string;
16
+ value: (v: string) => ("packageName" | "repositoryName" | "repositoryType")[];
17
+ };
18
+ dryRun: {
19
+ description: string;
20
+ value: "boolean";
21
+ };
22
+ showAll: {
23
+ description: string;
24
+ shortFlag: string;
25
+ };
26
+ keepMinutely: {
27
+ description: string;
28
+ value: "number";
29
+ };
30
+ keepDaily: {
31
+ description: string;
32
+ value: "number";
33
+ };
34
+ keepHourly: {
35
+ description: string;
36
+ value: "number";
37
+ };
38
+ keepLast: {
39
+ description: string;
40
+ value: "number";
41
+ };
42
+ keepMonthly: {
43
+ description: string;
44
+ value: "number";
45
+ };
46
+ keepWeekly: {
47
+ description: string;
48
+ value: "number";
49
+ };
50
+ keepYearly: {
51
+ description: string;
52
+ value: "number";
53
+ };
54
+ repositoryNames: {
55
+ description: string;
56
+ shortFlag: string;
57
+ value: "array";
58
+ };
59
+ repositoryTypes: {
60
+ description: string;
61
+ shortFlag: string;
62
+ value: "array";
63
+ };
64
+ packageNames: {
65
+ description: string;
66
+ shortFlag: string;
67
+ value: "array";
68
+ };
69
+ tags: {
70
+ description: string;
71
+ shortFlag: string;
72
+ value: "array";
73
+ };
74
+ ids: {
75
+ description: string;
76
+ shortFlag: string;
77
+ value: "array";
78
+ };
17
79
  };
18
- export declare class PruneCommand extends CommandAbstract<PruneCommandOptions<false>, PruneCommandOptions<true>> {
19
- optionsConfig(): import("../utils/cli").OptionsConfig<PruneCommandOptions<false>, PruneCommandOptions<true>>;
80
+ export type PruneCommandOptions = InferOptions<typeof pruneCommandOptions>;
81
+ export declare class PruneCommand extends CommandAbstract<typeof pruneCommandOptions> {
82
+ static config(): {
83
+ name: string;
84
+ alias: string;
85
+ options: {
86
+ longId: {
87
+ description: string;
88
+ value: "boolean";
89
+ };
90
+ confirm: {
91
+ description: string;
92
+ value: "boolean";
93
+ };
94
+ groupBy: {
95
+ description: string;
96
+ shortFlag: string;
97
+ defaults: string;
98
+ value: (v: string) => ("packageName" | "repositoryName" | "repositoryType")[];
99
+ };
100
+ dryRun: {
101
+ description: string;
102
+ value: "boolean";
103
+ };
104
+ showAll: {
105
+ description: string;
106
+ shortFlag: string;
107
+ };
108
+ keepMinutely: {
109
+ description: string;
110
+ value: "number";
111
+ };
112
+ keepDaily: {
113
+ description: string;
114
+ value: "number";
115
+ };
116
+ keepHourly: {
117
+ description: string;
118
+ value: "number";
119
+ };
120
+ keepLast: {
121
+ description: string;
122
+ value: "number";
123
+ };
124
+ keepMonthly: {
125
+ description: string;
126
+ value: "number";
127
+ };
128
+ keepWeekly: {
129
+ description: string;
130
+ value: "number";
131
+ };
132
+ keepYearly: {
133
+ description: string;
134
+ value: "number";
135
+ };
136
+ repositoryNames: {
137
+ description: string;
138
+ shortFlag: string;
139
+ value: "array";
140
+ };
141
+ repositoryTypes: {
142
+ description: string;
143
+ shortFlag: string;
144
+ value: "array";
145
+ };
146
+ packageNames: {
147
+ description: string;
148
+ shortFlag: string;
149
+ value: "array";
150
+ };
151
+ tags: {
152
+ description: string;
153
+ shortFlag: string;
154
+ value: "array";
155
+ };
156
+ ids: {
157
+ description: string;
158
+ shortFlag: string;
159
+ value: "array";
160
+ };
161
+ };
162
+ };
163
+ get optionsConfig(): {
164
+ longId: {
165
+ description: string;
166
+ value: "boolean";
167
+ };
168
+ confirm: {
169
+ description: string;
170
+ value: "boolean";
171
+ };
172
+ groupBy: {
173
+ description: string;
174
+ shortFlag: string;
175
+ defaults: string;
176
+ value: (v: string) => ("packageName" | "repositoryName" | "repositoryType")[];
177
+ };
178
+ dryRun: {
179
+ description: string;
180
+ value: "boolean";
181
+ };
182
+ showAll: {
183
+ description: string;
184
+ shortFlag: string;
185
+ };
186
+ keepMinutely: {
187
+ description: string;
188
+ value: "number";
189
+ };
190
+ keepDaily: {
191
+ description: string;
192
+ value: "number";
193
+ };
194
+ keepHourly: {
195
+ description: string;
196
+ value: "number";
197
+ };
198
+ keepLast: {
199
+ description: string;
200
+ value: "number";
201
+ };
202
+ keepMonthly: {
203
+ description: string;
204
+ value: "number";
205
+ };
206
+ keepWeekly: {
207
+ description: string;
208
+ value: "number";
209
+ };
210
+ keepYearly: {
211
+ description: string;
212
+ value: "number";
213
+ };
214
+ repositoryNames: {
215
+ description: string;
216
+ shortFlag: string;
217
+ value: "array";
218
+ };
219
+ repositoryTypes: {
220
+ description: string;
221
+ shortFlag: string;
222
+ value: "array";
223
+ };
224
+ packageNames: {
225
+ description: string;
226
+ shortFlag: string;
227
+ value: "array";
228
+ };
229
+ tags: {
230
+ description: string;
231
+ shortFlag: string;
232
+ value: "array";
233
+ };
234
+ ids: {
235
+ description: string;
236
+ shortFlag: string;
237
+ value: "array";
238
+ };
239
+ };
20
240
  exec(): Promise<{
21
241
  result: import("../actions/PruneAction").PruneResult;
22
242
  exitCode: number;