@datatruck/cli 0.34.3 → 0.34.5
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/lib/actions/BackupAction.js +125 -39
- package/lib/actions/ConfigAction.js +1 -1
- package/lib/actions/CopyAction.js +110 -74
- package/lib/actions/InitAction.js +1 -1
- package/lib/actions/PruneAction.js +3 -2
- package/lib/actions/RestoreAction.d.ts +0 -2
- package/lib/actions/RestoreAction.js +131 -62
- package/lib/cli.js +1 -1
- package/lib/commands/StartServerCommand.js +2 -1
- package/lib/repositories/DatatruckRepository.d.ts +1 -1
- package/lib/repositories/DatatruckRepository.js +31 -18
- package/lib/repositories/GitRepository.js +11 -3
- package/lib/repositories/RepositoryAbstract.d.ts +2 -1
- package/lib/repositories/RepositoryAbstract.js +3 -1
- package/lib/repositories/ResticRepository.js +1 -1
- package/lib/tasks/GitTask.js +2 -1
- package/lib/tasks/MssqlTask.js +2 -2
- package/lib/tasks/MysqlDumpTask.js +1 -1
- package/lib/tasks/SqlDumpTaskAbstract.js +2 -2
- package/lib/utils/async-process.js +3 -2
- package/lib/utils/cli.js +10 -10
- package/lib/utils/data-format.js +3 -3
- package/lib/utils/datatruck/client.d.ts +7 -3
- package/lib/utils/datatruck/client.js +9 -2
- package/lib/utils/datatruck/command.js +1 -1
- package/lib/utils/datatruck/config.js +4 -4
- package/lib/utils/datatruck/report-list.js +2 -1
- package/lib/utils/datatruck/repository.d.ts +3 -3
- package/lib/utils/datatruck/repository.js +4 -4
- package/lib/utils/datatruck/task.js +1 -1
- package/lib/utils/{datatruck/error.d.ts → error.d.ts} +1 -1
- package/lib/utils/{datatruck/error.js → error.js} +2 -2
- package/lib/utils/fs.d.ts +2 -1
- package/lib/utils/fs.js +22 -3
- package/lib/utils/git.d.ts +5 -0
- package/lib/utils/git.js +10 -0
- package/lib/utils/list.d.ts +3 -1
- package/lib/utils/list.js +2 -3
- package/lib/utils/mysql.js +1 -1
- package/lib/utils/object.d.ts +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/progress.d.ts +8 -1
- package/lib/utils/progress.js +38 -5
- package/lib/utils/reportSteps.js +3 -2
- package/lib/utils/string.js +1 -1
- package/lib/utils/temp.d.ts +13 -10
- package/lib/utils/temp.js +47 -40
- package/package.json +1 -1
|
@@ -1,4 +1,49 @@
|
|
|
1
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
|
+
});
|
|
2
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
49
|
};
|
|
@@ -12,6 +57,7 @@ const report_list_1 = require("../utils/datatruck/report-list");
|
|
|
12
57
|
const repository_1 = require("../utils/datatruck/repository");
|
|
13
58
|
const task_1 = require("../utils/datatruck/task");
|
|
14
59
|
const date_1 = require("../utils/date");
|
|
60
|
+
const error_1 = require("../utils/error");
|
|
15
61
|
const fs_1 = require("../utils/fs");
|
|
16
62
|
const list_1 = require("../utils/list");
|
|
17
63
|
const progress_1 = require("../utils/progress");
|
|
@@ -32,7 +78,7 @@ class BackupAction {
|
|
|
32
78
|
prepareSnapshot() {
|
|
33
79
|
const date = this.options.date ?? new Date().toISOString();
|
|
34
80
|
if (!(0, dayjs_1.default)(date, "YYYY-MM-DDTHH:mm:ss.SSS[Z]", true).isValid())
|
|
35
|
-
throw new
|
|
81
|
+
throw new error_1.AppError(`Invalid snapshot date: ${date}`);
|
|
36
82
|
return {
|
|
37
83
|
id: (0, crypto_1.randomUUID)().replaceAll("-", ""),
|
|
38
84
|
date,
|
|
@@ -165,6 +211,7 @@ class BackupAction {
|
|
|
165
211
|
}
|
|
166
212
|
async exec() {
|
|
167
213
|
const { options } = this;
|
|
214
|
+
const gc = new temp_1.GargabeCollector();
|
|
168
215
|
const pm = new progress_1.ProgressManager({
|
|
169
216
|
verbose: options.verbose,
|
|
170
217
|
tty: options.tty,
|
|
@@ -173,6 +220,7 @@ class BackupAction {
|
|
|
173
220
|
const l = new list_1.Listr3({
|
|
174
221
|
streams: this.options.streams,
|
|
175
222
|
progressManager: pm,
|
|
223
|
+
gargabeCollector: gc,
|
|
176
224
|
});
|
|
177
225
|
return l
|
|
178
226
|
.add([
|
|
@@ -196,11 +244,11 @@ class BackupAction {
|
|
|
196
244
|
return [
|
|
197
245
|
...packages.flatMap((pkg) => {
|
|
198
246
|
let taskResult = {};
|
|
199
|
-
const gc = new temp_1.GargabeCollector();
|
|
200
247
|
const repositories = this.getRepositoryNames(pkg.repositoryNames ?? []);
|
|
201
248
|
const mirrorRepositories = repositories
|
|
202
249
|
.filter((r) => r.mirrors.length)
|
|
203
250
|
.flatMap(({ name, mirrors }) => mirrors.map((mirror) => ({ name, mirror })));
|
|
251
|
+
const taskGc = gc.create();
|
|
204
252
|
return l.$tasks(!!pkg.task &&
|
|
205
253
|
l.$task({
|
|
206
254
|
key: "task",
|
|
@@ -213,13 +261,25 @@ class BackupAction {
|
|
|
213
261
|
completed: `Task executed: ${pkg.name} (${pkg.task.name})`,
|
|
214
262
|
},
|
|
215
263
|
exitOnError: false,
|
|
216
|
-
runWrapper: gc.cleanupIfFail.bind(gc),
|
|
217
264
|
run: async (task) => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
265
|
+
await taskGc.disposeIfFail(async () => {
|
|
266
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
267
|
+
try {
|
|
268
|
+
const progress = __addDisposableResource(env_1, pm.create(task), false);
|
|
269
|
+
taskResult = await (0, task_1.createTask)(pkg.task).backup({
|
|
270
|
+
options,
|
|
271
|
+
package: pkg,
|
|
272
|
+
snapshot,
|
|
273
|
+
onProgress: progress.update,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
catch (e_1) {
|
|
277
|
+
env_1.error = e_1;
|
|
278
|
+
env_1.hasError = true;
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
__disposeResources(env_1);
|
|
282
|
+
}
|
|
223
283
|
});
|
|
224
284
|
},
|
|
225
285
|
}), ...repositories.map(({ name: repositoryName }) => l.$task({
|
|
@@ -237,21 +297,34 @@ class BackupAction {
|
|
|
237
297
|
failed: `Backup create failed: ${pkg.name} (${repositoryName})`,
|
|
238
298
|
},
|
|
239
299
|
exitOnError: false,
|
|
240
|
-
runWrapper: gc.cleanupOnFinish.bind(gc),
|
|
241
300
|
run: async (task, data) => {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
301
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
302
|
+
try {
|
|
303
|
+
const _ = __addDisposableResource(env_2, gc.create().disposeOnFinish(), true);
|
|
304
|
+
const taskSummary = pkg.task
|
|
305
|
+
? l.result("task", pkg.name)
|
|
306
|
+
: undefined;
|
|
307
|
+
if (taskSummary?.error)
|
|
308
|
+
throw new error_1.AppError(`Task failed`);
|
|
309
|
+
const progress = __addDisposableResource(env_2, pm.create(task), false);
|
|
310
|
+
const backup = await this.backup({
|
|
311
|
+
pkg,
|
|
312
|
+
repositoryName,
|
|
313
|
+
snapshot,
|
|
314
|
+
snapshotPath: taskResult?.snapshotPath,
|
|
315
|
+
onProgress: progress.update,
|
|
316
|
+
});
|
|
317
|
+
data.bytes = backup.bytes;
|
|
318
|
+
}
|
|
319
|
+
catch (e_2) {
|
|
320
|
+
env_2.error = e_2;
|
|
321
|
+
env_2.hasError = true;
|
|
322
|
+
}
|
|
323
|
+
finally {
|
|
324
|
+
const result_1 = __disposeResources(env_2);
|
|
325
|
+
if (result_1)
|
|
326
|
+
await result_1;
|
|
327
|
+
}
|
|
255
328
|
},
|
|
256
329
|
})), l.$task({
|
|
257
330
|
key: "cleanup",
|
|
@@ -264,8 +337,8 @@ class BackupAction {
|
|
|
264
337
|
failed: "Task files clean failed",
|
|
265
338
|
},
|
|
266
339
|
exitOnError: false,
|
|
267
|
-
enabled:
|
|
268
|
-
run: () =>
|
|
340
|
+
enabled: taskGc.pending(),
|
|
341
|
+
run: () => taskGc.dispose(),
|
|
269
342
|
}), ...mirrorRepositories.map(({ name, mirror }) => l.$task({
|
|
270
343
|
key: "copy",
|
|
271
344
|
keyIndex: [pkg.name, mirror],
|
|
@@ -282,22 +355,35 @@ class BackupAction {
|
|
|
282
355
|
failed: `Snapshot copy failed: ${pkg.name} (${mirror})`,
|
|
283
356
|
},
|
|
284
357
|
exitOnError: false,
|
|
285
|
-
runWrapper: gc.cleanup.bind(gc),
|
|
286
358
|
run: async (task, data) => {
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
359
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
360
|
+
try {
|
|
361
|
+
const _ = __addDisposableResource(env_3, gc.create().disposeOnFinish(), true);
|
|
362
|
+
const backupSummary = l.result("backup", [
|
|
363
|
+
pkg.name,
|
|
364
|
+
name,
|
|
365
|
+
]);
|
|
366
|
+
if (backupSummary.error)
|
|
367
|
+
throw new error_1.AppError(`Backup failed`);
|
|
368
|
+
const progress = __addDisposableResource(env_3, pm.create(task), false);
|
|
369
|
+
const copy = await this.copy({
|
|
370
|
+
repositoryName: name,
|
|
371
|
+
mirrorRepositoryName: mirror,
|
|
372
|
+
pkg,
|
|
373
|
+
snapshot,
|
|
374
|
+
onProgress: progress.update,
|
|
375
|
+
});
|
|
376
|
+
data.bytes = copy.bytes;
|
|
377
|
+
}
|
|
378
|
+
catch (e_3) {
|
|
379
|
+
env_3.error = e_3;
|
|
380
|
+
env_3.hasError = true;
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
const result_2 = __disposeResources(env_3);
|
|
384
|
+
if (result_2)
|
|
385
|
+
await result_2;
|
|
386
|
+
}
|
|
301
387
|
},
|
|
302
388
|
})), !!this.options.prune &&
|
|
303
389
|
l.$task({
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ConfigAction = void 0;
|
|
7
7
|
const config_schema_1 = require("../config.schema");
|
|
8
8
|
const config_1 = require("../utils/datatruck/config");
|
|
9
|
-
const error_1 = require("../utils/
|
|
9
|
+
const error_1 = require("../utils/error");
|
|
10
10
|
const fs_1 = require("../utils/fs");
|
|
11
11
|
const ajv_1 = __importDefault(require("ajv"));
|
|
12
12
|
const assert_1 = require("assert");
|
|
@@ -57,6 +57,7 @@ const report_list_1 = require("../utils/datatruck/report-list");
|
|
|
57
57
|
const repository_1 = require("../utils/datatruck/repository");
|
|
58
58
|
const snapshot_1 = require("../utils/datatruck/snapshot");
|
|
59
59
|
const date_1 = require("../utils/date");
|
|
60
|
+
const error_1 = require("../utils/error");
|
|
60
61
|
const list_1 = require("../utils/list");
|
|
61
62
|
const object_1 = require("../utils/object");
|
|
62
63
|
const progress_1 = require("../utils/progress");
|
|
@@ -98,6 +99,12 @@ class CopyAction {
|
|
|
98
99
|
return new data_format_1.DataFormat({
|
|
99
100
|
streams: options.streams,
|
|
100
101
|
json: result,
|
|
102
|
+
list: () => result.map((item) => {
|
|
103
|
+
const icon = (0, cli_1.renderResult)(item.error, false);
|
|
104
|
+
const title = renderTitle(item);
|
|
105
|
+
const data = renderData(item, false, result);
|
|
106
|
+
return `${icon} ${title}: ${data}`;
|
|
107
|
+
}),
|
|
101
108
|
table: {
|
|
102
109
|
headers: [
|
|
103
110
|
{ value: "", width: 3 },
|
|
@@ -131,7 +138,7 @@ class CopyAction {
|
|
|
131
138
|
}).map(({ item }) => item)
|
|
132
139
|
: snapshots;
|
|
133
140
|
if (!result.length)
|
|
134
|
-
throw new
|
|
141
|
+
throw new error_1.AppError("No snapshots found");
|
|
135
142
|
return result;
|
|
136
143
|
}
|
|
137
144
|
createSourceRepoMap() {
|
|
@@ -212,83 +219,112 @@ class CopyAction {
|
|
|
212
219
|
action: "backup",
|
|
213
220
|
}), [repoConfig.type]);
|
|
214
221
|
if (!repositoryNames2.length)
|
|
215
|
-
throw new
|
|
222
|
+
throw new error_1.AppError("No mirror snapshots found");
|
|
216
223
|
const sourceRepoMap = this.createSourceRepoMap();
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (currentCopies.length) {
|
|
249
|
-
data.skipped = true;
|
|
250
|
-
return task.skip(`Already exists at ${mirrorConfig.name}: ${pkgName} (${id})`);
|
|
251
|
-
}
|
|
252
|
-
if (this.config.minFreeDiskSpace)
|
|
253
|
-
await mirrorRepo.ensureFreeDiskSpace(mirrorConfig.config, this.config.minFreeDiskSpace);
|
|
254
|
-
const sourceRepo = sourceRepoMap.with([
|
|
255
|
-
snapshot,
|
|
256
|
-
mirrorConfig,
|
|
257
|
-
]);
|
|
258
|
-
if (sourceRepo.has()) {
|
|
259
|
-
const copy = await sourceRepo.get().copy({
|
|
260
|
-
mirrorRepositoryConfig: mirrorConfig.config,
|
|
261
|
-
options: { verbose: this.options.verbose },
|
|
262
|
-
package: { name: snapshot.packageName },
|
|
263
|
-
snapshot,
|
|
264
|
-
onProgress: (p) => pm.update(p, (d) => (task.output = d)),
|
|
265
|
-
});
|
|
266
|
-
data.bytes = copy.bytes;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
const copy = await this.copyCrossRepository({
|
|
270
|
-
mirrorConfig,
|
|
271
|
-
mirrorRepo,
|
|
272
|
-
repo,
|
|
273
|
-
repoConfig,
|
|
274
|
-
snapshot,
|
|
275
|
-
onProgress: (p) => pm.update(p, (d) => (task.output = d)),
|
|
224
|
+
return [
|
|
225
|
+
...data.snapshots.flatMap((snapshot) => repositoryNames2.map((repo2) => {
|
|
226
|
+
const id = snapshot.id.slice(0, 8);
|
|
227
|
+
const pkgName = snapshot.packageName;
|
|
228
|
+
return l.$task({
|
|
229
|
+
key: "copy",
|
|
230
|
+
keyIndex: [snapshot.packageName, repo2.name, snapshot.id],
|
|
231
|
+
data: {
|
|
232
|
+
snapshotId: snapshot.id,
|
|
233
|
+
packageName: snapshot.packageName,
|
|
234
|
+
repositoryName: repoConfig.name,
|
|
235
|
+
mirrorRepositoryName: repo2.name,
|
|
236
|
+
bytes: 0,
|
|
237
|
+
skipped: false,
|
|
238
|
+
},
|
|
239
|
+
title: {
|
|
240
|
+
initial: `Copy snapshot: ${pkgName} (${id}) » ${repo2.name}`,
|
|
241
|
+
started: `Copying snapshot: ${pkgName} (${id}) » ${repo2.name}`,
|
|
242
|
+
completed: `Snapshot copied: ${pkgName} (${id}) » ${repo2.name}`,
|
|
243
|
+
failed: `Snapshot copy failed: ${pkgName} (${id}) » ${repo2.name}`,
|
|
244
|
+
},
|
|
245
|
+
exitOnError: false,
|
|
246
|
+
run: async (task, data) => {
|
|
247
|
+
const mirrorConfig = (0, config_1.findRepositoryOrFail)(this.config, repo2.name);
|
|
248
|
+
const mirrorRepo = await (0, repository_1.createAndInitRepo)(mirrorConfig, this.options.verbose);
|
|
249
|
+
const currentCopies = await mirrorRepo.fetchSnapshots({
|
|
250
|
+
options: {
|
|
251
|
+
ids: [snapshot.id],
|
|
252
|
+
packageNames: [snapshot.packageName],
|
|
253
|
+
verbose: this.options.verbose,
|
|
254
|
+
},
|
|
276
255
|
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
256
|
+
if (currentCopies.length) {
|
|
257
|
+
data.skipped = true;
|
|
258
|
+
return task.skip(`Already exists at ${mirrorConfig.name}: ${pkgName} (${id})`);
|
|
259
|
+
}
|
|
260
|
+
if (this.config.minFreeDiskSpace)
|
|
261
|
+
await mirrorRepo.ensureFreeDiskSpace(mirrorConfig.config, this.config.minFreeDiskSpace);
|
|
262
|
+
const sourceRepo = sourceRepoMap.withKey([
|
|
263
|
+
{ id: snapshot.id, packageName: snapshot.packageName },
|
|
264
|
+
{ type: mirrorConfig.type },
|
|
265
|
+
]);
|
|
266
|
+
const $sourceRepo = repoConfig.type === mirrorConfig.type
|
|
267
|
+
? repo
|
|
268
|
+
: sourceRepo.has()
|
|
269
|
+
? sourceRepo.get()
|
|
270
|
+
: undefined;
|
|
271
|
+
if ($sourceRepo) {
|
|
272
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
273
|
+
try {
|
|
274
|
+
const progress = __addDisposableResource(env_2, pm.create(task), false);
|
|
275
|
+
const copy = await $sourceRepo.copy({
|
|
276
|
+
mirrorRepositoryConfig: mirrorConfig.config,
|
|
277
|
+
options: { verbose: this.options.verbose },
|
|
278
|
+
package: { name: snapshot.packageName },
|
|
279
|
+
snapshot,
|
|
280
|
+
onProgress: progress.update,
|
|
281
|
+
});
|
|
282
|
+
data.bytes = copy.bytes;
|
|
283
|
+
}
|
|
284
|
+
catch (e_2) {
|
|
285
|
+
env_2.error = e_2;
|
|
286
|
+
env_2.hasError = true;
|
|
287
|
+
}
|
|
288
|
+
finally {
|
|
289
|
+
__disposeResources(env_2);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
294
|
+
try {
|
|
295
|
+
const progress = __addDisposableResource(env_3, pm.create(task), false);
|
|
296
|
+
const copy = await this.copyCrossRepository({
|
|
297
|
+
mirrorConfig,
|
|
298
|
+
mirrorRepo,
|
|
299
|
+
repo,
|
|
300
|
+
repoConfig,
|
|
301
|
+
snapshot,
|
|
302
|
+
onProgress: progress.update,
|
|
303
|
+
});
|
|
304
|
+
data.bytes = copy.bytes;
|
|
305
|
+
sourceRepo.set(mirrorRepo);
|
|
306
|
+
}
|
|
307
|
+
catch (e_3) {
|
|
308
|
+
env_3.error = e_3;
|
|
309
|
+
env_3.hasError = true;
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
__disposeResources(env_3);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
})),
|
|
318
|
+
...(0, report_list_1.createReportListTasks)(l, {
|
|
319
|
+
hostname: this.config.hostname ?? (0, os_1.hostname)(),
|
|
320
|
+
action: "copy",
|
|
321
|
+
reports: this.config.reports || [],
|
|
322
|
+
verbose: this.options.verbose,
|
|
323
|
+
onMessage: (result, report) => this.dataFormat(result).format(report.format ?? "list"),
|
|
324
|
+
}),
|
|
325
|
+
];
|
|
283
326
|
},
|
|
284
327
|
}),
|
|
285
|
-
...(0, report_list_1.createReportListTasks)(l, {
|
|
286
|
-
hostname: this.config.hostname ?? (0, os_1.hostname)(),
|
|
287
|
-
action: "copy",
|
|
288
|
-
reports: this.config.reports || [],
|
|
289
|
-
verbose: this.options.verbose,
|
|
290
|
-
onMessage: (result, report) => this.dataFormat(result).format(report.format ?? "list"),
|
|
291
|
-
}),
|
|
292
328
|
])
|
|
293
329
|
.exec();
|
|
294
330
|
}
|
|
@@ -21,7 +21,7 @@ class InitAction {
|
|
|
21
21
|
if (this.options.repositoryTypes &&
|
|
22
22
|
!this.options.repositoryTypes.includes(repoConfig.type))
|
|
23
23
|
continue;
|
|
24
|
-
const repo = (0, repository_1.createRepo)(repoConfig);
|
|
24
|
+
const repo = (0, repository_1.createRepo)(repoConfig, this.options.verbose);
|
|
25
25
|
let initError = null;
|
|
26
26
|
try {
|
|
27
27
|
await repo.init({
|
|
@@ -4,6 +4,7 @@ exports.PruneAction = 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
|
+
const error_1 = require("../utils/error");
|
|
7
8
|
const object_1 = require("../utils/object");
|
|
8
9
|
const SnapshotsAction_1 = require("./SnapshotsAction");
|
|
9
10
|
class PruneAction {
|
|
@@ -41,10 +42,10 @@ class PruneAction {
|
|
|
41
42
|
const keepFilter = (0, date_1.createFilterByLastOptions)(this.options);
|
|
42
43
|
const hasKeepFilter = Object.values(keepFilter).some((v) => typeof v === "number");
|
|
43
44
|
if (hasIdFilter && hasKeepFilter)
|
|
44
|
-
throw new
|
|
45
|
+
throw new error_1.AppError(`Snapshot id filter can not be used with 'keep' filters`);
|
|
45
46
|
const prunePolicy = !hasIdFilter && !hasKeepFilter;
|
|
46
47
|
if (prunePolicy && !this.options.groupBy?.includes("packageName"))
|
|
47
|
-
throw new
|
|
48
|
+
throw new error_1.AppError(`Policy config requires groupBy packageName`);
|
|
48
49
|
const keepSnapshots = hasKeepFilter
|
|
49
50
|
? (0, snapshot_1.groupAndFilter)(snapshots, this.options.groupBy, keepFilter)
|
|
50
51
|
: prunePolicy
|
|
@@ -5,7 +5,6 @@ import type { Config, PackageConfig } from "../utils/datatruck/config-type";
|
|
|
5
5
|
import { Listr3TaskResultEnd } from "../utils/list";
|
|
6
6
|
import { Progress, ProgressMode } from "../utils/progress";
|
|
7
7
|
import { StdStreams } from "../utils/stream";
|
|
8
|
-
import { GargabeCollector } from "../utils/temp";
|
|
9
8
|
import { IfRequireKeys } from "../utils/ts";
|
|
10
9
|
export type RestoreActionOptions = {
|
|
11
10
|
snapshotId: string;
|
|
@@ -47,7 +46,6 @@ export declare class RestoreAction<TRequired extends boolean = true> {
|
|
|
47
46
|
pkg: PackageConfig;
|
|
48
47
|
task: TaskAbstract | undefined;
|
|
49
48
|
snapshot: RestoreSnapshot;
|
|
50
|
-
gc: GargabeCollector;
|
|
51
49
|
onProgress: (progress: Progress) => void;
|
|
52
50
|
}): Promise<{
|
|
53
51
|
snapshotPath: string | undefined;
|