@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.
- package/config.schema.json +130 -74
- package/lib/actions/BackupAction.d.ts +55 -19
- package/lib/actions/BackupAction.js +31 -7
- 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 +37 -11
- package/lib/actions/CopyAction.js +29 -2
- 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 +55 -21
- package/lib/actions/RestoreAction.js +44 -56
- 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 +14 -93
- package/lib/commands/BackupCommand.d.ts +120 -13
- package/lib/commands/BackupCommand.js +22 -50
- package/lib/commands/CleanCacheCommand.d.ts +10 -3
- package/lib/commands/CleanCacheCommand.js +14 -6
- package/lib/commands/CommandAbstract.d.ts +10 -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 +102 -10
- package/lib/commands/CopyCommand.js +18 -40
- package/lib/commands/ExportCommand.d.ts +143 -0
- package/lib/commands/ExportCommand.js +50 -0
- package/lib/commands/InitCommand.d.ts +42 -7
- package/lib/commands/InitCommand.js +15 -17
- package/lib/commands/PruneCommand.d.ts +237 -17
- package/lib/commands/PruneCommand.js +27 -99
- package/lib/commands/RestoreCommand.d.ts +126 -13
- package/lib/commands/RestoreCommand.js +20 -49
- package/lib/commands/RunCommand.d.ts +23 -4
- package/lib/commands/RunCommand.js +21 -12
- 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 +11 -3
- package/lib/repositories/DatatruckRepository.js +1 -1
- package/lib/repositories/GitRepository.js +5 -2
- 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 +0 -17
- package/lib/utils/cli.js +1 -47
- package/lib/utils/datatruck/command.d.ts +6 -5
- package/lib/utils/datatruck/command.js +9 -5
- package/lib/utils/datatruck/job.js +17 -12
- package/lib/utils/datatruck/repository.d.ts +1 -0
- package/lib/utils/datatruck/repository.js +8 -1
- package/lib/utils/git.d.ts +5 -1
- package/lib/utils/git.js +7 -3
- 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,28 +1,245 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { RepositoryConfig } from "../utils/datatruck/config-type";
|
|
3
|
-
import { If } from "../utils/ts";
|
|
1
|
+
import { InferOptions } from "../utils/options";
|
|
4
2
|
import { CommandAbstract } from "./CommandAbstract";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
export declare const snapshotsCommandOptions: {
|
|
4
|
+
longId: {
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
ids: {
|
|
8
|
+
description: string;
|
|
9
|
+
shortFlag: string;
|
|
10
|
+
value: "array";
|
|
11
|
+
};
|
|
12
|
+
repositoryNames: {
|
|
13
|
+
description: string;
|
|
14
|
+
shortFlag: string;
|
|
15
|
+
value: "array";
|
|
16
|
+
};
|
|
17
|
+
repositoryTypes: {
|
|
18
|
+
description: string;
|
|
19
|
+
shortFlag: string;
|
|
20
|
+
value: "array";
|
|
21
|
+
};
|
|
22
|
+
packageNames: {
|
|
23
|
+
description: string;
|
|
24
|
+
shortFlag: string;
|
|
25
|
+
value: "array";
|
|
26
|
+
};
|
|
27
|
+
packageTaskNames: {
|
|
28
|
+
description: string;
|
|
29
|
+
shortFlag: string;
|
|
30
|
+
value: "array";
|
|
31
|
+
};
|
|
32
|
+
tags: {
|
|
33
|
+
description: string;
|
|
34
|
+
shortFlag: string;
|
|
35
|
+
value: "array";
|
|
36
|
+
};
|
|
37
|
+
packageConfig: {
|
|
38
|
+
description: string;
|
|
39
|
+
shortFlag: string;
|
|
40
|
+
};
|
|
41
|
+
hostnames: {
|
|
42
|
+
description: string;
|
|
43
|
+
shortFlag: string;
|
|
44
|
+
value: "array";
|
|
45
|
+
};
|
|
46
|
+
groupBy: {
|
|
47
|
+
description: string;
|
|
48
|
+
shortFlag: string;
|
|
49
|
+
value: (v: string) => ("packageName" | "repositoryName" | "repositoryType" | "id")[];
|
|
50
|
+
};
|
|
51
|
+
last: {
|
|
52
|
+
description: string;
|
|
53
|
+
shortFlag: string;
|
|
54
|
+
value: "number";
|
|
55
|
+
};
|
|
56
|
+
lastMinutely: {
|
|
57
|
+
description: string;
|
|
58
|
+
value: "number";
|
|
59
|
+
};
|
|
60
|
+
lastDaily: {
|
|
61
|
+
description: string;
|
|
62
|
+
value: "number";
|
|
63
|
+
};
|
|
64
|
+
lastHourly: {
|
|
65
|
+
description: string;
|
|
66
|
+
value: "number";
|
|
67
|
+
};
|
|
68
|
+
lastMonthly: {
|
|
69
|
+
description: string;
|
|
70
|
+
value: "number";
|
|
71
|
+
};
|
|
72
|
+
lastWeekly: {
|
|
73
|
+
description: string;
|
|
74
|
+
value: "number";
|
|
75
|
+
};
|
|
76
|
+
lastYearly: {
|
|
77
|
+
description: string;
|
|
78
|
+
value: "number";
|
|
79
|
+
};
|
|
23
80
|
};
|
|
24
|
-
export
|
|
25
|
-
|
|
81
|
+
export type SnapshotsCommandOptions = InferOptions<typeof snapshotsCommandOptions>;
|
|
82
|
+
export declare class SnapshotsCommand extends CommandAbstract<typeof snapshotsCommandOptions> {
|
|
83
|
+
static config(): {
|
|
84
|
+
name: string;
|
|
85
|
+
alias: string;
|
|
86
|
+
options: {
|
|
87
|
+
longId: {
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
ids: {
|
|
91
|
+
description: string;
|
|
92
|
+
shortFlag: string;
|
|
93
|
+
value: "array";
|
|
94
|
+
};
|
|
95
|
+
repositoryNames: {
|
|
96
|
+
description: string;
|
|
97
|
+
shortFlag: string;
|
|
98
|
+
value: "array";
|
|
99
|
+
};
|
|
100
|
+
repositoryTypes: {
|
|
101
|
+
description: string;
|
|
102
|
+
shortFlag: string;
|
|
103
|
+
value: "array";
|
|
104
|
+
};
|
|
105
|
+
packageNames: {
|
|
106
|
+
description: string;
|
|
107
|
+
shortFlag: string;
|
|
108
|
+
value: "array";
|
|
109
|
+
};
|
|
110
|
+
packageTaskNames: {
|
|
111
|
+
description: string;
|
|
112
|
+
shortFlag: string;
|
|
113
|
+
value: "array";
|
|
114
|
+
};
|
|
115
|
+
tags: {
|
|
116
|
+
description: string;
|
|
117
|
+
shortFlag: string;
|
|
118
|
+
value: "array";
|
|
119
|
+
};
|
|
120
|
+
packageConfig: {
|
|
121
|
+
description: string;
|
|
122
|
+
shortFlag: string;
|
|
123
|
+
};
|
|
124
|
+
hostnames: {
|
|
125
|
+
description: string;
|
|
126
|
+
shortFlag: string;
|
|
127
|
+
value: "array";
|
|
128
|
+
};
|
|
129
|
+
groupBy: {
|
|
130
|
+
description: string;
|
|
131
|
+
shortFlag: string;
|
|
132
|
+
value: (v: string) => ("packageName" | "repositoryName" | "repositoryType" | "id")[];
|
|
133
|
+
};
|
|
134
|
+
last: {
|
|
135
|
+
description: string;
|
|
136
|
+
shortFlag: string;
|
|
137
|
+
value: "number";
|
|
138
|
+
};
|
|
139
|
+
lastMinutely: {
|
|
140
|
+
description: string;
|
|
141
|
+
value: "number";
|
|
142
|
+
};
|
|
143
|
+
lastDaily: {
|
|
144
|
+
description: string;
|
|
145
|
+
value: "number";
|
|
146
|
+
};
|
|
147
|
+
lastHourly: {
|
|
148
|
+
description: string;
|
|
149
|
+
value: "number";
|
|
150
|
+
};
|
|
151
|
+
lastMonthly: {
|
|
152
|
+
description: string;
|
|
153
|
+
value: "number";
|
|
154
|
+
};
|
|
155
|
+
lastWeekly: {
|
|
156
|
+
description: string;
|
|
157
|
+
value: "number";
|
|
158
|
+
};
|
|
159
|
+
lastYearly: {
|
|
160
|
+
description: string;
|
|
161
|
+
value: "number";
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
get optionsConfig(): {
|
|
166
|
+
longId: {
|
|
167
|
+
description: string;
|
|
168
|
+
};
|
|
169
|
+
ids: {
|
|
170
|
+
description: string;
|
|
171
|
+
shortFlag: string;
|
|
172
|
+
value: "array";
|
|
173
|
+
};
|
|
174
|
+
repositoryNames: {
|
|
175
|
+
description: string;
|
|
176
|
+
shortFlag: string;
|
|
177
|
+
value: "array";
|
|
178
|
+
};
|
|
179
|
+
repositoryTypes: {
|
|
180
|
+
description: string;
|
|
181
|
+
shortFlag: string;
|
|
182
|
+
value: "array";
|
|
183
|
+
};
|
|
184
|
+
packageNames: {
|
|
185
|
+
description: string;
|
|
186
|
+
shortFlag: string;
|
|
187
|
+
value: "array";
|
|
188
|
+
};
|
|
189
|
+
packageTaskNames: {
|
|
190
|
+
description: string;
|
|
191
|
+
shortFlag: string;
|
|
192
|
+
value: "array";
|
|
193
|
+
};
|
|
194
|
+
tags: {
|
|
195
|
+
description: string;
|
|
196
|
+
shortFlag: string;
|
|
197
|
+
value: "array";
|
|
198
|
+
};
|
|
199
|
+
packageConfig: {
|
|
200
|
+
description: string;
|
|
201
|
+
shortFlag: string;
|
|
202
|
+
};
|
|
203
|
+
hostnames: {
|
|
204
|
+
description: string;
|
|
205
|
+
shortFlag: string;
|
|
206
|
+
value: "array";
|
|
207
|
+
};
|
|
208
|
+
groupBy: {
|
|
209
|
+
description: string;
|
|
210
|
+
shortFlag: string;
|
|
211
|
+
value: (v: string) => ("packageName" | "repositoryName" | "repositoryType" | "id")[];
|
|
212
|
+
};
|
|
213
|
+
last: {
|
|
214
|
+
description: string;
|
|
215
|
+
shortFlag: string;
|
|
216
|
+
value: "number";
|
|
217
|
+
};
|
|
218
|
+
lastMinutely: {
|
|
219
|
+
description: string;
|
|
220
|
+
value: "number";
|
|
221
|
+
};
|
|
222
|
+
lastDaily: {
|
|
223
|
+
description: string;
|
|
224
|
+
value: "number";
|
|
225
|
+
};
|
|
226
|
+
lastHourly: {
|
|
227
|
+
description: string;
|
|
228
|
+
value: "number";
|
|
229
|
+
};
|
|
230
|
+
lastMonthly: {
|
|
231
|
+
description: string;
|
|
232
|
+
value: "number";
|
|
233
|
+
};
|
|
234
|
+
lastWeekly: {
|
|
235
|
+
description: string;
|
|
236
|
+
value: "number";
|
|
237
|
+
};
|
|
238
|
+
lastYearly: {
|
|
239
|
+
description: string;
|
|
240
|
+
value: "number";
|
|
241
|
+
};
|
|
242
|
+
};
|
|
26
243
|
exec(): Promise<{
|
|
27
244
|
result: import("../actions/SnapshotsAction").ExtendedSnapshot[];
|
|
28
245
|
exitCode: number;
|
|
@@ -1,117 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SnapshotsCommand = void 0;
|
|
3
|
+
exports.SnapshotsCommand = exports.snapshotsCommandOptions = void 0;
|
|
4
4
|
const ConfigAction_1 = require("../actions/ConfigAction");
|
|
5
5
|
const SnapshotsAction_1 = require("../actions/SnapshotsAction");
|
|
6
6
|
const bytes_1 = require("../utils/bytes");
|
|
7
7
|
const data_format_1 = require("../utils/data-format");
|
|
8
|
-
const string_1 = require("../utils/string");
|
|
9
8
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
9
|
+
exports.snapshotsCommandOptions = {
|
|
10
|
+
...SnapshotsAction_1.snapshotsActionOptions,
|
|
11
|
+
longId: {
|
|
12
|
+
description: "Show long id",
|
|
13
|
+
},
|
|
14
|
+
};
|
|
10
15
|
class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
option: "-g,--group-by <values>",
|
|
21
|
-
description: `Group by values (${groupByValues.join(", ")})`,
|
|
22
|
-
parser: (v) => (0, string_1.parseStringList)(v, groupByValues),
|
|
23
|
-
},
|
|
24
|
-
longId: {
|
|
25
|
-
option: "--longId",
|
|
26
|
-
description: "Show long id",
|
|
27
|
-
},
|
|
28
|
-
id: {
|
|
29
|
-
option: "-i,--id <ids>",
|
|
30
|
-
description: "Filter by identifiers",
|
|
31
|
-
parser: string_1.parseStringList,
|
|
32
|
-
},
|
|
33
|
-
host: {
|
|
34
|
-
option: "-h,--host <names>",
|
|
35
|
-
description: "Filter by hostnames",
|
|
36
|
-
parser: string_1.parseStringList,
|
|
37
|
-
},
|
|
38
|
-
last: {
|
|
39
|
-
option: "-l,--last <number>",
|
|
40
|
-
description: "Filter by last snapshots",
|
|
41
|
-
parser: Number,
|
|
42
|
-
},
|
|
43
|
-
lastMinutely: {
|
|
44
|
-
option: "--lastMinutely <number>",
|
|
45
|
-
description: "Filter by last minutely",
|
|
46
|
-
parser: Number,
|
|
47
|
-
},
|
|
48
|
-
lastDaily: {
|
|
49
|
-
option: "--lastDaily <number>",
|
|
50
|
-
description: "Filter by last daily",
|
|
51
|
-
parser: Number,
|
|
52
|
-
},
|
|
53
|
-
lastHourly: {
|
|
54
|
-
option: "--lastHourly <number>",
|
|
55
|
-
description: "Filter by last hourly",
|
|
56
|
-
parser: Number,
|
|
57
|
-
},
|
|
58
|
-
lastMonthly: {
|
|
59
|
-
option: "--lastMonthly <number>",
|
|
60
|
-
description: "Filter by last monthly",
|
|
61
|
-
parser: Number,
|
|
62
|
-
},
|
|
63
|
-
lastWeekly: {
|
|
64
|
-
option: "--lastWeekly <number>",
|
|
65
|
-
description: "Filter by last weekly",
|
|
66
|
-
parser: Number,
|
|
67
|
-
},
|
|
68
|
-
lastYearly: {
|
|
69
|
-
option: "--lastYearly <number>",
|
|
70
|
-
description: "Filter by last yearly",
|
|
71
|
-
parser: Number,
|
|
72
|
-
},
|
|
73
|
-
package: {
|
|
74
|
-
option: "-p,--package <names>",
|
|
75
|
-
description: "Filter by package names",
|
|
76
|
-
parser: string_1.parseStringList,
|
|
77
|
-
},
|
|
78
|
-
packageTask: {
|
|
79
|
-
option: "-pt,--package-task <values>",
|
|
80
|
-
description: "Filter by task names",
|
|
81
|
-
parser: string_1.parseStringList,
|
|
82
|
-
},
|
|
83
|
-
packageConfig: {
|
|
84
|
-
description: "Filter by package config",
|
|
85
|
-
option: "-pc,--package-config",
|
|
86
|
-
},
|
|
87
|
-
repository: {
|
|
88
|
-
option: "-r,--repository <names>",
|
|
89
|
-
description: "Filter by repository names",
|
|
90
|
-
parser: string_1.parseStringList,
|
|
91
|
-
},
|
|
92
|
-
repositoryType: {
|
|
93
|
-
option: "-rt,--repository-type <names>",
|
|
94
|
-
description: "Filter by repository types",
|
|
95
|
-
parser: (v) => (0, string_1.parseStringList)(v),
|
|
96
|
-
},
|
|
97
|
-
tag: {
|
|
98
|
-
description: "Filter by tags",
|
|
99
|
-
option: "-t,--tag <values>",
|
|
100
|
-
parser: string_1.parseStringList,
|
|
101
|
-
},
|
|
102
|
-
});
|
|
16
|
+
static config() {
|
|
17
|
+
return {
|
|
18
|
+
name: "snapshots",
|
|
19
|
+
alias: "s",
|
|
20
|
+
options: exports.snapshotsCommandOptions,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
get optionsConfig() {
|
|
24
|
+
return exports.snapshotsCommandOptions;
|
|
103
25
|
}
|
|
104
26
|
async exec() {
|
|
105
27
|
const verbose = this.globalOptions.verbose ?? 0;
|
|
106
28
|
const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
|
|
107
29
|
const snapshots = new SnapshotsAction_1.SnapshotsAction(config, {
|
|
108
|
-
ids: this.options.
|
|
109
|
-
hostnames: this.options.
|
|
110
|
-
packageNames: this.options.
|
|
111
|
-
packageTaskNames: this.options.
|
|
30
|
+
ids: this.options.ids,
|
|
31
|
+
hostnames: this.options.hostnames,
|
|
32
|
+
packageNames: this.options.packageNames,
|
|
33
|
+
packageTaskNames: this.options.packageTaskNames,
|
|
112
34
|
packageConfig: this.options.packageConfig,
|
|
113
|
-
repositoryNames: this.options.
|
|
114
|
-
repositoryTypes: this.options.
|
|
35
|
+
repositoryNames: this.options.repositoryNames,
|
|
36
|
+
repositoryTypes: this.options.repositoryTypes,
|
|
115
37
|
last: this.options.last,
|
|
116
38
|
lastMinutely: this.options.lastMinutely,
|
|
117
39
|
lastHourly: this.options.lastHourly,
|
|
@@ -121,7 +43,7 @@ class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
|
|
|
121
43
|
lastYearly: this.options.lastYearly,
|
|
122
44
|
groupBy: this.options.groupBy,
|
|
123
45
|
verbose: verbose > 0,
|
|
124
|
-
tags: this.options.
|
|
46
|
+
tags: this.options.tags,
|
|
125
47
|
});
|
|
126
48
|
const result = await snapshots.exec();
|
|
127
49
|
const dataFormat = new data_format_1.DataFormat({
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { InferOptions } from "../utils/options";
|
|
1
2
|
import { CommandAbstract } from "./CommandAbstract";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export declare const startServerOptions: {};
|
|
4
|
+
export type StartServerOptions = InferOptions<typeof startServerOptions>;
|
|
5
|
+
export declare class StartServerCommand extends CommandAbstract<typeof startServerOptions> {
|
|
6
|
+
static config(): {
|
|
7
|
+
name: string;
|
|
8
|
+
alias: string;
|
|
9
|
+
options: {};
|
|
10
|
+
};
|
|
11
|
+
get optionsConfig(): {};
|
|
5
12
|
exec(): Promise<{
|
|
6
13
|
exitCode: number;
|
|
7
14
|
}>;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartServerCommand = void 0;
|
|
3
|
+
exports.StartServerCommand = exports.startServerOptions = void 0;
|
|
4
4
|
const ConfigAction_1 = require("../actions/ConfigAction");
|
|
5
5
|
const cli_1 = require("../utils/cli");
|
|
6
6
|
const cron_server_1 = require("../utils/datatruck/cron-server");
|
|
7
7
|
const repository_server_1 = require("../utils/datatruck/repository-server");
|
|
8
8
|
const error_1 = require("../utils/error");
|
|
9
9
|
const CommandAbstract_1 = require("./CommandAbstract");
|
|
10
|
+
exports.startServerOptions = {};
|
|
10
11
|
class StartServerCommand extends CommandAbstract_1.CommandAbstract {
|
|
11
|
-
|
|
12
|
-
return
|
|
12
|
+
static config() {
|
|
13
|
+
return {
|
|
14
|
+
name: "startServer",
|
|
15
|
+
alias: "start",
|
|
16
|
+
options: exports.startServerOptions,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
get optionsConfig() {
|
|
20
|
+
return exports.startServerOptions;
|
|
13
21
|
}
|
|
14
22
|
async exec() {
|
|
15
23
|
const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
|
|
@@ -308,7 +308,7 @@ class DatatruckRepository extends RepositoryAbstract_1.RepositoryAbstract {
|
|
|
308
308
|
const restorePath = (0, path_1.resolve)(relRestorePath);
|
|
309
309
|
const [snapshot] = await this.fetchSnapshots({
|
|
310
310
|
options: {
|
|
311
|
-
ids: [data.options.
|
|
311
|
+
ids: [data.options.id],
|
|
312
312
|
},
|
|
313
313
|
});
|
|
314
314
|
if (!snapshot)
|
|
@@ -50,7 +50,7 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
|
|
|
50
50
|
log: data.options.verbose,
|
|
51
51
|
});
|
|
52
52
|
if (await git.canBeInit(this.config.repo)) {
|
|
53
|
-
await (0, promises_1.mkdir)(git.options.dir);
|
|
53
|
+
await (0, promises_1.mkdir)(git.options.dir, { recursive: true });
|
|
54
54
|
await git.exec(["init", "--bare", this.config.repo]);
|
|
55
55
|
}
|
|
56
56
|
const branchName = this.config.branch ?? "master";
|
|
@@ -208,7 +208,10 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
|
|
|
208
208
|
version: nodePkg.version,
|
|
209
209
|
size: size.toString(),
|
|
210
210
|
});
|
|
211
|
-
await git.addTag(meta.name, meta.message
|
|
211
|
+
await git.addTag(meta.name, meta.message, {
|
|
212
|
+
userName: "datatruck",
|
|
213
|
+
userEmail: "datatruck@localhost",
|
|
214
|
+
});
|
|
212
215
|
await git.push({ branchName });
|
|
213
216
|
await git.pushTags();
|
|
214
217
|
await (0, promises_1.rm)(tmpPath, { recursive: true });
|
package/lib/tasks/MssqlTask.js
CHANGED
|
@@ -76,7 +76,7 @@ class MssqlTask extends TaskAbstract_1.TaskAbstract {
|
|
|
76
76
|
action: "restore",
|
|
77
77
|
database: databaseName,
|
|
78
78
|
packageName: data.package.name,
|
|
79
|
-
snapshotId: data.options.
|
|
79
|
+
snapshotId: data.options.id,
|
|
80
80
|
snapshotDate: data.snapshot.date,
|
|
81
81
|
});
|
|
82
82
|
const databasePath = (0, path_1.join)(snapshotPath, file);
|
|
@@ -242,7 +242,7 @@ class MysqlDumpTask extends TaskAbstract_1.TaskAbstract {
|
|
|
242
242
|
const snapshotPath = data.snapshotPath;
|
|
243
243
|
const params = {
|
|
244
244
|
packageName: data.package.name,
|
|
245
|
-
snapshotId: data.options.
|
|
245
|
+
snapshotId: data.options.id,
|
|
246
246
|
snapshotDate: data.snapshot.date,
|
|
247
247
|
action: "restore",
|
|
248
248
|
database: undefined,
|
|
@@ -153,7 +153,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
153
153
|
const database = {
|
|
154
154
|
name: (0, config_1.resolveDatabaseName)(this.config.database, {
|
|
155
155
|
packageName: data.package.name,
|
|
156
|
-
snapshotId: data.options.
|
|
156
|
+
snapshotId: data.options.id,
|
|
157
157
|
snapshotDate: data.snapshot.date,
|
|
158
158
|
action: "restore",
|
|
159
159
|
database: undefined,
|
|
@@ -162,7 +162,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
|
|
|
162
162
|
if (this.config.targetDatabase && !data.options.initial) {
|
|
163
163
|
database.name = (0, config_1.resolveDatabaseName)(this.config.targetDatabase.name, {
|
|
164
164
|
packageName: data.package.name,
|
|
165
|
-
snapshotId: data.options.
|
|
165
|
+
snapshotId: data.options.id,
|
|
166
166
|
snapshotDate: data.snapshot.date,
|
|
167
167
|
action: "restore",
|
|
168
168
|
database: database.name,
|
package/lib/utils/cli.d.ts
CHANGED
|
@@ -12,23 +12,6 @@ export declare function renderListTaskItem<T extends Record<string, any>>(item:
|
|
|
12
12
|
}>["data"]) => string | number | string[] | Record<string, string | number>;
|
|
13
13
|
}): string;
|
|
14
14
|
export declare function renderObject(object: Record<string, any>, color?: boolean): string;
|
|
15
|
-
export type OptionsConfig<T1, T2 extends {
|
|
16
|
-
[K in keyof T1]: unknown;
|
|
17
|
-
}> = {
|
|
18
|
-
[K in keyof Required<T1>]: {
|
|
19
|
-
option?: string;
|
|
20
|
-
description: string;
|
|
21
|
-
required?: boolean;
|
|
22
|
-
defaults?: Exclude<T1[K], undefined>;
|
|
23
|
-
parser?: (value: Exclude<T1[K], undefined>) => Exclude<T2[K], undefined>;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export declare function parseOptions<T1, T2 extends {
|
|
27
|
-
[K in keyof T1]: unknown;
|
|
28
|
-
}>(object: T1, options: OptionsConfig<T1, T2>): T2;
|
|
29
|
-
export declare function stringifyOptions<T1, T2 extends {
|
|
30
|
-
[K in keyof T1]: unknown;
|
|
31
|
-
}>(options: OptionsConfig<T1, T2>, object: any): string[];
|
|
32
15
|
export declare function confirm(message: string): Promise<unknown>;
|
|
33
16
|
export declare function waitForStdDrain(ms?: number): Promise<void>;
|
|
34
17
|
export declare function colorizeValue(value: unknown, color?: typeof chalk.ForegroundColor): string;
|
package/lib/utils/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logJson = exports.colorizeObject = exports.colorizeValue = exports.waitForStdDrain = exports.confirm = exports.
|
|
6
|
+
exports.logJson = exports.colorizeObject = exports.colorizeValue = exports.waitForStdDrain = exports.confirm = exports.renderObject = exports.renderListTaskItem = exports.renderError = exports.renderResult = exports.logExec = exports.renderProgressBar = exports.showCursorCommand = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const chalk_2 = require("chalk");
|
|
9
9
|
const readline_1 = require("readline");
|
|
@@ -92,52 +92,6 @@ function renderObject(object, color) {
|
|
|
92
92
|
return values.join(` `);
|
|
93
93
|
}
|
|
94
94
|
exports.renderObject = renderObject;
|
|
95
|
-
function parseOptions(object, options) {
|
|
96
|
-
const result = {};
|
|
97
|
-
for (const key in options) {
|
|
98
|
-
const opt = options[key].option;
|
|
99
|
-
let defaultsValue;
|
|
100
|
-
let parser = options[key].parser;
|
|
101
|
-
if (typeof opt === "string") {
|
|
102
|
-
const isNegative = opt.startsWith("--no");
|
|
103
|
-
defaultsValue = isNegative ? true : options[key].defaults;
|
|
104
|
-
}
|
|
105
|
-
const value = object?.[key] ?? defaultsValue;
|
|
106
|
-
if (typeof value !== "undefined") {
|
|
107
|
-
result[key] = parser ? parser(value) : value;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
exports.parseOptions = parseOptions;
|
|
113
|
-
function stringifyOptions(options, object) {
|
|
114
|
-
const result = [];
|
|
115
|
-
const prepend = [];
|
|
116
|
-
for (const key in options) {
|
|
117
|
-
const fullOpt = options[key].option;
|
|
118
|
-
if (typeof fullOpt === "string") {
|
|
119
|
-
const [opt] = fullOpt.split(",");
|
|
120
|
-
const isNegative = fullOpt.startsWith("--no");
|
|
121
|
-
const isBool = !fullOpt.includes("<") && !fullOpt.includes("[");
|
|
122
|
-
const defaultsValue = isNegative ? true : options[key].defaults;
|
|
123
|
-
const value = object?.[key] ?? defaultsValue;
|
|
124
|
-
if (isBool) {
|
|
125
|
-
if (object[key])
|
|
126
|
-
result.push(opt);
|
|
127
|
-
}
|
|
128
|
-
else if (value !== undefined) {
|
|
129
|
-
result.push(opt, `${value}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const value = object?.[key];
|
|
134
|
-
if (value !== undefined)
|
|
135
|
-
prepend.push(value);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return [...prepend, ...result];
|
|
139
|
-
}
|
|
140
|
-
exports.stringifyOptions = stringifyOptions;
|
|
141
95
|
function confirm(message) {
|
|
142
96
|
const rl = (0, readline_1.createInterface)({
|
|
143
97
|
input: process.stdin,
|
|
@@ -3,6 +3,7 @@ import { CleanCacheCommand } from "../../commands/CleanCacheCommand";
|
|
|
3
3
|
import { GlobalOptions } from "../../commands/CommandAbstract";
|
|
4
4
|
import { ConfigCommand } from "../../commands/ConfigCommand";
|
|
5
5
|
import { CopyCommand } from "../../commands/CopyCommand";
|
|
6
|
+
import { ExportCommand } from "../../commands/ExportCommand";
|
|
6
7
|
import { InitCommand } from "../../commands/InitCommand";
|
|
7
8
|
import { PruneCommand } from "../../commands/PruneCommand";
|
|
8
9
|
import { RestoreCommand } from "../../commands/RestoreCommand";
|
|
@@ -10,7 +11,7 @@ import { RunCommand } from "../../commands/RunCommand";
|
|
|
10
11
|
import { SnapshotsCommand } from "../../commands/SnapshotsCommand";
|
|
11
12
|
import { StartServerCommand } from "../../commands/StartServerCommand";
|
|
12
13
|
import { StdStreams } from "../stream";
|
|
13
|
-
export declare const
|
|
14
|
+
export declare const datatruckCommands: {
|
|
14
15
|
config: typeof ConfigCommand;
|
|
15
16
|
init: typeof InitCommand;
|
|
16
17
|
snapshots: typeof SnapshotsCommand;
|
|
@@ -21,11 +22,11 @@ export declare const datatruckCommandMap: {
|
|
|
21
22
|
copy: typeof CopyCommand;
|
|
22
23
|
cleanCache: typeof CleanCacheCommand;
|
|
23
24
|
startServer: typeof StartServerCommand;
|
|
25
|
+
export: typeof ExportCommand;
|
|
24
26
|
};
|
|
25
|
-
export type DatatruckCommandMap = typeof
|
|
26
|
-
export type InferDatatruckCommandOptions<T extends keyof DatatruckCommandMap> = InstanceType<DatatruckCommandMap[T]>["inputOptions"];
|
|
27
|
+
export type DatatruckCommandMap = typeof datatruckCommands;
|
|
27
28
|
export type InferDatatruckCommandResult<T extends keyof DatatruckCommandMap, R = Awaited<ReturnType<InstanceType<DatatruckCommandMap[T]>["exec"]>>> = "result" extends keyof R ? R["result"] : undefined;
|
|
28
|
-
export declare function createCommand<T extends keyof DatatruckCommandMap>(name: T, globalOptions: GlobalOptions<true>, options:
|
|
29
|
+
export declare function createCommand<T extends keyof DatatruckCommandMap>(name: T, globalOptions: GlobalOptions<true>, options: InstanceType<DatatruckCommandMap[T]>["options"], streams?: Partial<StdStreams>, configPath?: string): BackupCommand | CopyCommand | PruneCommand | CleanCacheCommand | ConfigCommand | ExportCommand | InitCommand | RestoreCommand | RunCommand | SnapshotsCommand | StartServerCommand;
|
|
29
30
|
export declare function createCommands(globalOptions: GlobalOptions<true>): {
|
|
30
|
-
[K in keyof DatatruckCommandMap as `${K}`]: (options:
|
|
31
|
+
[K in keyof DatatruckCommandMap as `${K}`]: (options: InstanceType<DatatruckCommandMap[K]>["options"]) => Promise<InferDatatruckCommandResult<K>>;
|
|
31
32
|
};
|