@datatruck/cli 0.32.3 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/config.schema.json +377 -31
  2. package/lib/{Action → actions}/BackupAction.d.ts +13 -19
  3. package/lib/{Action → actions}/BackupAction.js +52 -91
  4. package/lib/{Action → actions}/ConfigAction.d.ts +4 -2
  5. package/lib/{Action → actions}/ConfigAction.js +16 -8
  6. package/lib/{Action → actions}/CopyAction.d.ts +20 -13
  7. package/lib/actions/CopyAction.js +296 -0
  8. package/lib/{Action → actions}/InitAction.d.ts +1 -1
  9. package/lib/{Action → actions}/InitAction.js +3 -3
  10. package/lib/{Action → actions}/PruneAction.d.ts +1 -2
  11. package/lib/{Action → actions}/PruneAction.js +2 -2
  12. package/lib/{Action → actions}/RestoreAction.d.ts +4 -13
  13. package/lib/{Action → actions}/RestoreAction.js +17 -17
  14. package/lib/{Action → actions}/SnapshotsAction.d.ts +2 -3
  15. package/lib/{Action → actions}/SnapshotsAction.js +3 -3
  16. package/lib/cli.d.ts +3 -3
  17. package/lib/cli.js +18 -17
  18. package/lib/commands/BackupCommand.d.ts +45 -0
  19. package/lib/{Command → commands}/BackupCommand.js +7 -6
  20. package/lib/{Command → commands}/CleanCacheCommand.d.ts +4 -2
  21. package/lib/{Command → commands}/CleanCacheCommand.js +6 -5
  22. package/lib/{Command → commands}/CommandAbstract.d.ts +10 -6
  23. package/lib/{Command → commands}/CommandAbstract.js +5 -3
  24. package/lib/commands/ConfigCommand.d.ts +22 -0
  25. package/lib/{Command → commands}/ConfigCommand.js +5 -5
  26. package/lib/commands/CopyCommand.d.ts +17 -0
  27. package/lib/{Command → commands}/CopyCommand.js +7 -6
  28. package/lib/commands/InitCommand.d.ts +19 -0
  29. package/lib/{Command → commands}/InitCommand.js +9 -9
  30. package/lib/{Command → commands}/PruneCommand.d.ts +7 -4
  31. package/lib/{Command → commands}/PruneCommand.js +11 -11
  32. package/lib/commands/RestoreCommand.d.ts +38 -0
  33. package/lib/{Command → commands}/RestoreCommand.js +7 -6
  34. package/lib/{Command → commands}/SnapshotsCommand.d.ts +8 -6
  35. package/lib/{Command → commands}/SnapshotsCommand.js +12 -12
  36. package/lib/{Command → commands}/StartServerCommand.d.ts +4 -2
  37. package/lib/{Command → commands}/StartServerCommand.js +5 -5
  38. package/lib/index.d.ts +20 -23
  39. package/lib/index.js +8 -8
  40. package/lib/{Repository → repositories}/DatatruckRepository.d.ts +6 -2
  41. package/lib/{Repository → repositories}/DatatruckRepository.js +13 -5
  42. package/lib/{Repository → repositories}/GitRepository.d.ts +6 -2
  43. package/lib/{Repository → repositories}/GitRepository.js +8 -3
  44. package/lib/{Repository → repositories}/RepositoryAbstract.d.ts +13 -9
  45. package/lib/{Repository → repositories}/ResticRepository.d.ts +6 -2
  46. package/lib/{Repository → repositories}/ResticRepository.js +17 -10
  47. package/lib/{Task → tasks}/MssqlTask.js +2 -2
  48. package/lib/{Task → tasks}/MysqlDumpTask.js +4 -4
  49. package/lib/{Task → tasks}/ScriptTask.d.ts +2 -2
  50. package/lib/{Task → tasks}/SqlDumpTaskAbstract.js +4 -4
  51. package/lib/{Task → tasks}/TaskAbstract.d.ts +4 -4
  52. package/lib/utils/DataFormat.js +3 -3
  53. package/lib/utils/Restic.d.ts +2 -2
  54. package/lib/utils/Restic.js +12 -10
  55. package/lib/utils/cli.d.ts +9 -3
  56. package/lib/utils/cli.js +17 -1
  57. package/lib/utils/cron.d.ts +11 -0
  58. package/lib/utils/cron.js +27 -0
  59. package/lib/utils/datatruck/client.d.ts +3 -1
  60. package/lib/utils/datatruck/client.js +1 -1
  61. package/lib/utils/datatruck/command.d.ts +29 -0
  62. package/lib/utils/datatruck/command.js +61 -0
  63. package/lib/{Config/RepositoryConfig.d.ts → utils/datatruck/config-repository-type.d.ts} +19 -8
  64. package/lib/{Config/TaskConfig.d.ts → utils/datatruck/config-task-type.d.ts} +6 -6
  65. package/lib/utils/datatruck/config-type.d.ts +51 -0
  66. package/lib/utils/datatruck/config.d.ts +19 -10
  67. package/lib/utils/datatruck/config.js +43 -7
  68. package/lib/utils/datatruck/cron-server.d.ts +27 -6
  69. package/lib/utils/datatruck/cron-server.js +38 -20
  70. package/lib/utils/datatruck/paths.d.ts +2 -2
  71. package/lib/utils/datatruck/report-list.d.ts +14 -0
  72. package/lib/utils/datatruck/report-list.js +57 -0
  73. package/lib/utils/datatruck/repository-server.js +3 -2
  74. package/lib/utils/datatruck/repository.d.ts +16 -0
  75. package/lib/utils/datatruck/repository.js +30 -0
  76. package/lib/utils/datatruck/snapshot.d.ts +2 -2
  77. package/lib/utils/datatruck/task.d.ts +3 -0
  78. package/lib/{Factory/TaskFactory.js → utils/datatruck/task.js} +8 -8
  79. package/lib/utils/date.js +6 -2
  80. package/lib/utils/fs.d.ts +3 -0
  81. package/lib/utils/fs.js +24 -4
  82. package/lib/utils/http.d.ts +3 -1
  83. package/lib/utils/http.js +6 -1
  84. package/lib/utils/list.d.ts +5 -5
  85. package/lib/utils/mysql.js +5 -5
  86. package/lib/utils/object.d.ts +13 -0
  87. package/lib/utils/object.js +32 -1
  88. package/lib/utils/process.js +4 -1
  89. package/lib/utils/string.d.ts +1 -0
  90. package/lib/utils/string.js +7 -3
  91. package/lib/utils/ts.d.ts +16 -0
  92. package/lib/utils/virtual-fs.d.ts +6 -2
  93. package/lib/utils/virtual-fs.js +4 -1
  94. package/lib/utils/watcher.d.ts +10 -0
  95. package/lib/utils/watcher.js +34 -0
  96. package/package.json +4 -4
  97. package/lib/Action/CopyAction.js +0 -164
  98. package/lib/Command/BackupCommand.d.ts +0 -19
  99. package/lib/Command/ConfigCommand.d.ts +0 -15
  100. package/lib/Command/CopyCommand.d.ts +0 -16
  101. package/lib/Command/InitCommand.d.ts +0 -13
  102. package/lib/Command/RestoreCommand.d.ts +0 -17
  103. package/lib/Config/Config.d.ts +0 -28
  104. package/lib/Config/PackageConfig.d.ts +0 -24
  105. package/lib/Config/PackageRepositoryConfig.d.ts +0 -15
  106. package/lib/Config/PrunePolicyConfig.d.ts +0 -2
  107. package/lib/Config/RepositoryConfig.js +0 -2
  108. package/lib/Config/TaskConfig.js +0 -2
  109. package/lib/Factory/CommandFactory.d.ts +0 -45
  110. package/lib/Factory/CommandFactory.js +0 -96
  111. package/lib/Factory/RepositoryFactory.d.ts +0 -3
  112. package/lib/Factory/RepositoryFactory.js +0 -23
  113. package/lib/Factory/TaskFactory.d.ts +0 -3
  114. /package/lib/{Action → actions}/CleanCacheAction.d.ts +0 -0
  115. /package/lib/{Action → actions}/CleanCacheAction.js +0 -0
  116. /package/lib/{Repository → repositories}/RepositoryAbstract.js +0 -0
  117. /package/lib/{Task → tasks}/GitTask.d.ts +0 -0
  118. /package/lib/{Task → tasks}/GitTask.js +0 -0
  119. /package/lib/{Task → tasks}/MariadbTask.d.ts +0 -0
  120. /package/lib/{Task → tasks}/MariadbTask.js +0 -0
  121. /package/lib/{Task → tasks}/MssqlTask.d.ts +0 -0
  122. /package/lib/{Task → tasks}/MysqlDumpTask.d.ts +0 -0
  123. /package/lib/{Task → tasks}/PostgresqlDumpTask.d.ts +0 -0
  124. /package/lib/{Task → tasks}/PostgresqlDumpTask.js +0 -0
  125. /package/lib/{Task → tasks}/ScriptTask.js +0 -0
  126. /package/lib/{Task → tasks}/SqlDumpTaskAbstract.d.ts +0 -0
  127. /package/lib/{Task → tasks}/TaskAbstract.js +0 -0
  128. /package/lib/{Config/Config.js → utils/datatruck/config-repository-type.js} +0 -0
  129. /package/lib/{Config/PackageConfig.js → utils/datatruck/config-task-type.js} +0 -0
  130. /package/lib/{Config/PackageRepositoryConfig.js → utils/datatruck/config-type.js} +0 -0
  131. /package/lib/{Error/AppError.d.ts → utils/datatruck/error.d.ts} +0 -0
  132. /package/lib/{Error/AppError.js → utils/datatruck/error.js} +0 -0
  133. /package/lib/{Config/PrunePolicyConfig.js → utils/ts.js} +0 -0
@@ -4,23 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BackupAction = void 0;
7
- const RepositoryFactory_1 = require("../Factory/RepositoryFactory");
8
- const TaskFactory_1 = require("../Factory/TaskFactory");
9
7
  const DataFormat_1 = require("../utils/DataFormat");
8
+ const bytes_1 = require("../utils/bytes");
10
9
  const cli_1 = require("../utils/cli");
11
10
  const config_1 = require("../utils/datatruck/config");
11
+ const report_list_1 = require("../utils/datatruck/report-list");
12
+ const repository_1 = require("../utils/datatruck/repository");
13
+ const task_1 = require("../utils/datatruck/task");
12
14
  const date_1 = require("../utils/date");
13
15
  const fs_1 = require("../utils/fs");
14
16
  const list_1 = require("../utils/list");
15
17
  const progress_1 = require("../utils/progress");
16
- const reportSteps_1 = require("../utils/reportSteps");
17
- const spawnSteps_1 = require("../utils/spawnSteps");
18
18
  const temp_1 = require("../utils/temp");
19
19
  const PruneAction_1 = require("./PruneAction");
20
20
  const assert_1 = require("assert");
21
21
  const chalk_1 = __importDefault(require("chalk"));
22
22
  const crypto_1 = require("crypto");
23
23
  const dayjs_1 = __importDefault(require("dayjs"));
24
+ const os_1 = require("os");
24
25
  class BackupAction {
25
26
  config;
26
27
  options;
@@ -68,12 +69,12 @@ class BackupAction {
68
69
  const pkg = { ...data.pkg, path: data.snapshotPath ?? data.pkg.path };
69
70
  (0, assert_1.ok)(pkg.path);
70
71
  await (0, fs_1.ensureExistsDir)(pkg.path);
71
- const repo = (0, RepositoryFactory_1.createRepo)(repoConfig);
72
+ const repo = await (0, repository_1.createAndInitRepo)(repoConfig, this.options.verbose);
72
73
  if (this.config.minFreeDiskSpace)
73
74
  await repo.ensureFreeDiskSpace(repoConfig.config, this.config.minFreeDiskSpace);
74
75
  const packageConfig = pkg.repositoryConfigs?.find((config) => config.type === repoConfig.type &&
75
76
  (!config.names || config.names.includes(repoConfig.name)))?.config;
76
- await repo.backup({
77
+ return await repo.backup({
77
78
  options: this.options,
78
79
  snapshot: data.snapshot,
79
80
  package: pkg,
@@ -84,11 +85,11 @@ class BackupAction {
84
85
  async copy(data) {
85
86
  const repoConfig = (0, config_1.findRepositoryOrFail)(this.config, data.repositoryName);
86
87
  const mirrorRepoConfig = (0, config_1.findRepositoryOrFail)(this.config, data.mirrorRepositoryName);
87
- const repo = (0, RepositoryFactory_1.createRepo)(repoConfig);
88
- const mirrorRepo = (0, RepositoryFactory_1.createRepo)(mirrorRepoConfig);
88
+ const repo = await (0, repository_1.createAndInitRepo)(repoConfig, this.options.verbose);
89
+ const mirrorRepo = await (0, repository_1.createAndInitRepo)(mirrorRepoConfig, this.options.verbose);
89
90
  if (this.config.minFreeDiskSpace)
90
91
  await mirrorRepo.ensureFreeDiskSpace(mirrorRepoConfig.config, this.config.minFreeDiskSpace);
91
- await repo.copy({
92
+ return await repo.copy({
92
93
  options: this.options,
93
94
  package: data.pkg,
94
95
  snapshot: data.snapshot,
@@ -103,33 +104,33 @@ class BackupAction {
103
104
  };
104
105
  const renderData = (item, color, result = []) => {
105
106
  const g = (v) => (color ? `${chalk_1.default.gray(`(${v})`)}` : `(${v})`);
106
- return item.key === "prune"
107
- ? `${item.data.packageName} ${g(`${item.data.pruned}/${item.data.total}`)}`
108
- : item.key === "snapshot"
109
- ? item.data.id
110
- : item.key === "task"
111
- ? `${item.data.packageName} ${g(item.data.taskName)}`
112
- : item.key === "backup"
113
- ? `${item.data.packageName} ${g(item.data.repositoryName)}`
114
- : item.key === "copy"
115
- ? `${item.data.packageName} ${g(item.data.mirrorRepositoryName)}`
116
- : item.key === "summary"
117
- ? (0, cli_1.renderObject)({
118
- errors: item.data.errors,
119
- backups: result.filter((r) => !r.error && r.key === "backup")
120
- .length,
121
- copies: result.filter((r) => !r.error && r.key === "copy").length,
122
- prunes: result
123
- .filter((r) => !r.error && r.key === "prune")
124
- .reduce((result, item) => {
125
- if (item.key === "prune")
126
- result += item.data.pruned;
127
- return result;
128
- }, 0),
129
- }, color)
130
- : item.key === "report"
131
- ? item.data.type
132
- : "";
107
+ return (0, cli_1.renderListTaskItem)(item, color, {
108
+ snapshot: (data) => data.id,
109
+ task: (data) => [data.packageName, data.taskName],
110
+ backup: (data) => [
111
+ data.packageName,
112
+ g([data.repositoryName, (0, bytes_1.formatBytes)(data.bytes)].join(" ")),
113
+ ],
114
+ copy: (data) => [
115
+ data.packageName,
116
+ g([data.mirrorRepositoryName, (0, bytes_1.formatBytes)(data.bytes)].join(" ")),
117
+ ],
118
+ prune: (data) => [data.packageName, g(`${data.pruned}/${data.total}`)],
119
+ cleanup: () => "",
120
+ report: (data) => data.type,
121
+ summary: (data) => ({
122
+ errors: data.errors,
123
+ backups: result.filter((r) => !r.error && r.key === "backup").length,
124
+ copies: result.filter((r) => !r.error && r.key === "copy").length,
125
+ prunes: result
126
+ .filter((r) => !r.error && r.key === "prune")
127
+ .reduce((result, item) => {
128
+ if (item.key === "prune")
129
+ result += item.data.pruned;
130
+ return result;
131
+ }, 0),
132
+ }),
133
+ });
133
134
  };
134
135
  return new DataFormat_1.DataFormat({
135
136
  streams: options.streams,
@@ -214,7 +215,7 @@ class BackupAction {
214
215
  exitOnError: false,
215
216
  runWrapper: gc.cleanupIfFail.bind(gc),
216
217
  run: async (task) => {
217
- taskResult = await (0, TaskFactory_1.createTask)(pkg.task).backup({
218
+ taskResult = await (0, task_1.createTask)(pkg.task).backup({
218
219
  options,
219
220
  package: pkg,
220
221
  snapshot,
@@ -227,6 +228,7 @@ class BackupAction {
227
228
  data: {
228
229
  packageName: pkg.name,
229
230
  repositoryName: repositoryName,
231
+ bytes: 0,
230
232
  },
231
233
  title: {
232
234
  initial: `Create backup: ${pkg.name} (${repositoryName})`,
@@ -236,19 +238,20 @@ class BackupAction {
236
238
  },
237
239
  exitOnError: false,
238
240
  runWrapper: gc.cleanupOnFinish.bind(gc),
239
- run: async (task) => {
241
+ run: async (task, data) => {
240
242
  const taskSummary = pkg.task
241
243
  ? l.result("task", pkg.name)
242
244
  : undefined;
243
245
  if (taskSummary?.error)
244
246
  throw new Error(`Task failed`);
245
- await this.backup({
247
+ const backup = await this.backup({
246
248
  pkg,
247
249
  repositoryName,
248
250
  snapshot,
249
251
  snapshotPath: taskResult?.snapshotPath,
250
252
  onProgress: (p) => pm.update(p, (t) => (task.output = t)),
251
253
  });
254
+ data.bytes = backup.bytes;
252
255
  },
253
256
  })), l.$task({
254
257
  key: "cleanup",
@@ -270,6 +273,7 @@ class BackupAction {
270
273
  packageName: pkg.name,
271
274
  repositoryName: name,
272
275
  mirrorRepositoryName: mirror,
276
+ bytes: 0,
273
277
  },
274
278
  title: {
275
279
  initial: `Copy snapshot: ${pkg.name} (${mirror})`,
@@ -279,20 +283,21 @@ class BackupAction {
279
283
  },
280
284
  exitOnError: false,
281
285
  runWrapper: gc.cleanup.bind(gc),
282
- run: async (task) => {
286
+ run: async (task, data) => {
283
287
  const backupSummary = l.result("backup", [
284
288
  pkg.name,
285
289
  name,
286
290
  ]);
287
291
  if (backupSummary.error)
288
292
  throw new Error(`Backup failed`);
289
- await this.copy({
293
+ const copy = await this.copy({
290
294
  repositoryName: name,
291
295
  mirrorRepositoryName: mirror,
292
296
  pkg,
293
297
  snapshot,
294
298
  onProgress: (p) => pm.update(p, (t) => (task.output = t)),
295
299
  });
300
+ data.bytes = copy.bytes;
296
301
  },
297
302
  })), !!this.options.prune &&
298
303
  l.$task({
@@ -323,56 +328,12 @@ class BackupAction {
323
328
  },
324
329
  }));
325
330
  }),
326
- ...(this.config.reports || []).map((report, index) => {
327
- const reportIndex = index + 1;
328
- return l.$task({
329
- title: {
330
- initial: `Send report ${reportIndex}`,
331
- started: `Sending report ${reportIndex}`,
332
- completed: `Report sent: ${reportIndex}`,
333
- failed: `Report send failed: ${reportIndex}`,
334
- },
335
- key: "report",
336
- keyIndex: index,
337
- data: { type: report.run.type },
338
- exitOnError: false,
339
- run: async (task) => {
340
- const result = l
341
- .getResult()
342
- .filter((r) => r.key !== "report");
343
- const success = result.every((r) => !r.error);
344
- const enabled = !report.when ||
345
- (report.when === "success" && success) ||
346
- (report.when === "error" && !success);
347
- if (!enabled)
348
- return task.skip(`Report send skipped: ${reportIndex}`);
349
- const message = this.dataFormat(result).format(report.format ?? "list");
350
- if ((0, spawnSteps_1.isSpawnStep)(report.run)) {
351
- await (0, spawnSteps_1.runSpawnSteps)(report.run, {
352
- data: {
353
- dtt: {
354
- message,
355
- result,
356
- success,
357
- },
358
- },
359
- verbose: this.options.verbose,
360
- });
361
- }
362
- else if ((0, reportSteps_1.isReportStep)(report.run)) {
363
- await (0, reportSteps_1.runReportSteps)(report.run, {
364
- data: {
365
- title: "DTT Backup",
366
- message,
367
- success,
368
- },
369
- });
370
- }
371
- else {
372
- throw new Error(`Invalid step type: ${report.run.type}`);
373
- }
374
- },
375
- });
331
+ ...(0, report_list_1.createReportListTasks)(l, {
332
+ hostname: this.config.hostname ?? (0, os_1.hostname)(),
333
+ action: "backup",
334
+ reports: this.config.reports || [],
335
+ verbose: this.options.verbose,
336
+ onMessage: (result, report) => this.dataFormat(result).format(report.format ?? "list"),
376
337
  }),
377
338
  ];
378
339
  },
@@ -1,5 +1,5 @@
1
- import { GlobalOptions } from "../Command/CommandAbstract";
2
- import type { Config } from "../Config/Config";
1
+ import { GlobalOptions } from "../commands/CommandAbstract";
2
+ import type { Config } from "../utils/datatruck/config-type";
3
3
  import { IfRequireKeys } from "../utils/ts";
4
4
  export type ConfigActionOptions = {
5
5
  path: string;
@@ -11,7 +11,9 @@ export declare class ConfigAction<TRequired extends boolean = true> {
11
11
  static validate(config: Config): void;
12
12
  static check(config: Config): void;
13
13
  static normalize(config: Config): Config;
14
+ static findFile(path: string): Promise<string>;
14
15
  static parseFile(path: string): Promise<Config>;
16
+ static findAndParseFile(inputPath: string): Promise<Config>;
15
17
  static fromGlobalOptionsWithPath(globalOptions: GlobalOptions<true>): Promise<{
16
18
  path: string;
17
19
  data: Config;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfigAction = void 0;
7
- const AppError_1 = require("../Error/AppError");
8
7
  const config_schema_1 = require("../config.schema");
9
8
  const config_1 = require("../utils/datatruck/config");
9
+ const error_1 = require("../utils/datatruck/error");
10
10
  const fs_1 = require("../utils/fs");
11
11
  const ajv_1 = __importDefault(require("ajv"));
12
12
  const assert_1 = require("assert");
@@ -20,7 +20,7 @@ class ConfigAction {
20
20
  allowUnionTypes: true,
21
21
  }).compile(config_schema_1.configSchema);
22
22
  if (!validate(config))
23
- throw new AppError_1.AppError("Json schema error: " + JSON.stringify(validate.errors, null, 2));
23
+ throw new error_1.AppError("Json schema error: " + JSON.stringify(validate.errors, null, 2));
24
24
  }
25
25
  static check(config) {
26
26
  const repositoryNames = [];
@@ -29,18 +29,18 @@ class ConfigAction {
29
29
  for (const repo of config.repositories) {
30
30
  repos[repo.name] = repo;
31
31
  if (repositoryNames.includes(repo.name))
32
- throw new AppError_1.AppError(`Duplicated repository name: ${repo.name}`);
32
+ throw new error_1.AppError(`Duplicated repository name: ${repo.name}`);
33
33
  repositoryNames.push(repo.name);
34
34
  }
35
35
  for (const repo of config.repositories) {
36
36
  if (repo.mirrorRepoNames) {
37
37
  for (const mirrorRepoName of repo.mirrorRepoNames) {
38
38
  if (!repos[mirrorRepoName])
39
- throw new AppError_1.AppError(`Mirror repository name not found: ${mirrorRepoName}`);
39
+ throw new error_1.AppError(`Mirror repository name not found: ${mirrorRepoName}`);
40
40
  if (repos[mirrorRepoName].type !== repo.type)
41
- throw new AppError_1.AppError(`Mirror repository type is incompatible: ${mirrorRepoName}`);
41
+ throw new error_1.AppError(`Mirror repository type is incompatible: ${mirrorRepoName}`);
42
42
  if (mirrorRepoNames.includes(mirrorRepoName))
43
- throw new AppError_1.AppError(`Mirror repository is already used`);
43
+ throw new error_1.AppError(`Mirror repository is already used`);
44
44
  mirrorRepoNames.push(mirrorRepoName);
45
45
  }
46
46
  }
@@ -48,7 +48,7 @@ class ConfigAction {
48
48
  const packageNames = [];
49
49
  for (const pkg of config.packages) {
50
50
  if (packageNames.includes(pkg.name))
51
- throw new AppError_1.AppError(`Duplicated package name: ${pkg.name}`);
51
+ throw new error_1.AppError(`Duplicated package name: ${pkg.name}`);
52
52
  repositoryNames.push(pkg.name);
53
53
  }
54
54
  }
@@ -65,12 +65,20 @@ class ConfigAction {
65
65
  });
66
66
  return config;
67
67
  }
68
+ static async findFile(path) {
69
+ return await (0, fs_1.findFile)(path, "datatruck.config", fs_1.parseFileExtensions, "Config path not found");
70
+ }
68
71
  static async parseFile(path) {
69
72
  const config = await (0, fs_1.parseFile)(path, "config");
70
73
  ConfigAction.validate(config);
71
74
  ConfigAction.check(config);
72
75
  return ConfigAction.normalize(config);
73
76
  }
77
+ static async findAndParseFile(inputPath) {
78
+ const path = await ConfigAction.findFile(inputPath);
79
+ const data = await ConfigAction.parseFile(path);
80
+ return data;
81
+ }
74
82
  static async fromGlobalOptionsWithPath(globalOptions) {
75
83
  if (typeof globalOptions.config !== "string")
76
84
  return {
@@ -88,7 +96,7 @@ class ConfigAction {
88
96
  return config.data;
89
97
  }
90
98
  async exec() {
91
- const path = await (0, fs_1.findFile)(this.options.path, "datatruck.config", fs_1.parseFileExtensions, "Config path not found");
99
+ const path = await ConfigAction.findFile(this.options.path);
92
100
  const data = await ConfigAction.parseFile(path);
93
101
  return { path, data };
94
102
  }
@@ -1,8 +1,10 @@
1
- import type { Config } from "../Config/Config";
2
- import { Snapshot } from "../Repository/RepositoryAbstract";
1
+ import { RepositoryAbstract, Snapshot } from "../repositories/RepositoryAbstract";
3
2
  import { DataFormat } from "../utils/DataFormat";
3
+ import type { Config, RepositoryConfig } from "../utils/datatruck/config-type";
4
+ import { ReportListTaskContext } from "../utils/datatruck/report-list";
4
5
  import { Listr3TaskResultEnd } from "../utils/list";
5
- import { ProgressMode } from "../utils/progress";
6
+ import { StrictMap } from "../utils/object";
7
+ import { Progress, ProgressMode } from "../utils/progress";
6
8
  import { Streams } from "../utils/stream";
7
9
  import { IfRequireKeys } from "../utils/ts";
8
10
  export type CopyActionOptions = {
@@ -29,8 +31,9 @@ export type Context = {
29
31
  repositoryName: string;
30
32
  mirrorRepositoryName: string;
31
33
  skipped: boolean;
34
+ bytes: number;
32
35
  };
33
- };
36
+ } & ReportListTaskContext;
34
37
  export declare class CopyAction<TRequired extends boolean = true> {
35
38
  readonly config: Config;
36
39
  readonly options: IfRequireKeys<TRequired, CopyActionOptions>;
@@ -39,13 +42,17 @@ export declare class CopyAction<TRequired extends boolean = true> {
39
42
  streams?: Streams;
40
43
  verbose?: number;
41
44
  }): DataFormat;
42
- exec(): Promise<({
43
- key: "summary";
44
- keyIndex?: string | undefined;
45
- data: {
46
- errors: number;
47
- };
48
- elapsed: number;
49
- error?: Error | undefined;
50
- } | import("../utils/list").Listr3TaskResult<Context>)[]>;
45
+ protected fetchSnapshots(repo: RepositoryAbstract<any>): Promise<Snapshot[]>;
46
+ protected createSourceRepoMap(): StrictMap<[Pick<Snapshot, "packageName" | "id">, Pick<RepositoryConfig, "type">], RepositoryAbstract<any>>;
47
+ protected copyCrossRepository(options: {
48
+ repo: RepositoryAbstract<any>;
49
+ repoConfig: RepositoryConfig;
50
+ mirrorRepo: RepositoryAbstract<any>;
51
+ mirrorConfig: RepositoryConfig;
52
+ snapshot: Snapshot;
53
+ onProgress: (p: Progress) => void;
54
+ }): Promise<{
55
+ bytes: number;
56
+ }>;
57
+ exec(): Promise<(import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<Context>)[]>;
51
58
  }