@datatruck/cli 0.32.0 → 0.32.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.
@@ -25,10 +25,6 @@ type Context = {
25
25
  snapshot: {
26
26
  id: string;
27
27
  };
28
- prune: {
29
- total: number;
30
- pruned: number;
31
- };
32
28
  task: {
33
29
  taskName: string;
34
30
  packageName: string;
@@ -43,6 +39,11 @@ type Context = {
43
39
  repositoryName: string;
44
40
  mirrorRepositoryName: string;
45
41
  };
42
+ prune: {
43
+ packageName: string;
44
+ total: number;
45
+ pruned: number;
46
+ };
46
47
  report: {
47
48
  type: string;
48
49
  };
@@ -15,6 +15,7 @@ const list_1 = require("../utils/list");
15
15
  const progress_1 = require("../utils/progress");
16
16
  const steps_1 = require("../utils/steps");
17
17
  const temp_1 = require("../utils/temp");
18
+ const PruneAction_1 = require("./PruneAction");
18
19
  const assert_1 = require("assert");
19
20
  const chalk_1 = __importDefault(require("chalk"));
20
21
  const crypto_1 = require("crypto");
@@ -102,7 +103,7 @@ class BackupAction {
102
103
  const renderData = (item, color, result = []) => {
103
104
  const g = (v) => (color ? `${chalk_1.default.gray(`(${v})`)}` : `(${v})`);
104
105
  return item.key === "prune"
105
- ? `${item.data.pruned}/${item.data.total}`
106
+ ? `${item.data.packageName} ${g(`${item.data.pruned}/${item.data.total}`)}`
106
107
  : item.key === "snapshot"
107
108
  ? item.data.id
108
109
  : item.key === "task"
@@ -117,6 +118,13 @@ class BackupAction {
117
118
  backups: result.filter((r) => !r.error && r.key === "backup")
118
119
  .length,
119
120
  copies: result.filter((r) => !r.error && r.key === "copy").length,
121
+ prunes: result
122
+ .filter((r) => !r.error && r.key === "prune")
123
+ .reduce((result, item) => {
124
+ if (item.key === "prune")
125
+ result += item.data.pruned;
126
+ return result;
127
+ }, 0),
120
128
  }, color)
121
129
  : item.key === "report"
122
130
  ? item.data.type
@@ -285,7 +293,34 @@ class BackupAction {
285
293
  onProgress: (p) => pm.update(p, (t) => (task.output = t)),
286
294
  });
287
295
  },
288
- })));
296
+ })), !!this.options.prune &&
297
+ l.$task({
298
+ title: {
299
+ initial: `Prune: ${pkg.name}`,
300
+ started: `Pruning: ${pkg.name}`,
301
+ completed: `Pruned: ${pkg.name}`,
302
+ failed: `Prune failed: ${pkg.name}`,
303
+ },
304
+ exitOnError: false,
305
+ key: "prune",
306
+ keyIndex: [pkg.name],
307
+ data: {
308
+ pruned: 0,
309
+ total: 0,
310
+ packageName: pkg.name,
311
+ },
312
+ run: async (_, data) => {
313
+ const prune = new PruneAction_1.PruneAction(this.config, {
314
+ repositoryNames: this.options.repositoryNames,
315
+ repositoryTypes: this.options.repositoryTypes,
316
+ packageNames: [pkg.name],
317
+ groupBy: ["packageName", "repositoryName"],
318
+ });
319
+ const result = await prune.exec();
320
+ data.total = result.total;
321
+ data.pruned = result.prune;
322
+ },
323
+ }));
289
324
  }),
290
325
  ...(this.config.reports || []).map((report, index) => {
291
326
  const reportIndex = index + 1;
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @datatruck/cli
2
2
 
3
+ ## 0.32.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a479805`](https://github.com/swordev/datatruck/commit/a479805dd5c206d53eb5610f3f9db8cebe3e697a) Thanks [@juanrgm](https://github.com/juanrgm)! - Fix `prune` option in the `backup` command
8
+
3
9
  ## 0.32.0
4
10
 
5
11
  ### Minor Changes
@@ -40,6 +40,8 @@ class StartServerCommand extends CommandAbstract_1.CommandAbstract {
40
40
  server.start();
41
41
  console.info(`Cron server started`);
42
42
  }
43
+ process.on("SIGINT", () => process.exit(1));
44
+ process.on("SIGTERM", () => process.exit(1));
43
45
  await new Promise(() => setInterval(() => { }, 60000));
44
46
  return 0;
45
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datatruck/cli",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "dependencies": {
5
5
  "@supercharge/promise-pool": "^3.1.0",
6
6
  "ajv": "^8.12.0",