@datatruck/cli 0.23.0 → 0.23.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.
@@ -48,7 +48,7 @@ class MysqlDumpTask extends TaskAbstract_1.TaskAbstract {
48
48
  concurrency,
49
49
  onChange: async ({ processed: proccesed, buffer }) => await data.onProgress({
50
50
  relative: {
51
- description: "Exporting",
51
+ description: buffer.size > 1 ? `Exporting (${buffer.size})` : "Exporting",
52
52
  payload: [...buffer.keys()].join(", "),
53
53
  },
54
54
  absolute: {
@@ -191,18 +191,22 @@ class MysqlDumpTask extends TaskAbstract_1.TaskAbstract {
191
191
  if (data.options.verbose)
192
192
  (0, cli_1.logExec)("readdir", [restorePath]);
193
193
  const concurrency = this.config.concurrency ?? 1;
194
+ let processed = 0;
194
195
  await (0, async_1.runParallel)({
195
196
  items: files.filter((f) => !f.endsWith(suffix.tableData)),
196
197
  concurrency,
197
- onChange: async ({ processed: proccesed, buffer }) => await data.onProgress({
198
+ onFinished: () => {
199
+ processed++;
200
+ },
201
+ onChange: async ({ buffer }) => await data.onProgress({
198
202
  relative: {
199
- description: "Importing",
203
+ description: buffer.size > 1 ? `Importing (${buffer.size})` : "Importing",
200
204
  payload: [...buffer.keys()].join(", "),
201
205
  },
202
206
  absolute: {
203
207
  total: files.length,
204
- current: proccesed,
205
- percent: (0, math_1.progressPercent)(files.length, proccesed),
208
+ current: processed,
209
+ percent: (0, math_1.progressPercent)(files.length, processed),
206
210
  },
207
211
  }),
208
212
  onItem: async ({ item: file, controller }) => {
@@ -216,15 +220,18 @@ class MysqlDumpTask extends TaskAbstract_1.TaskAbstract {
216
220
  await (0, async_1.runParallel)({
217
221
  items: dataFiles,
218
222
  concurrency,
219
- onChange: async ({ processed: proccesed, buffer }) => await data.onProgress({
223
+ onFinished: () => {
224
+ processed++;
225
+ },
226
+ onChange: async ({ buffer }) => await data.onProgress({
220
227
  relative: {
221
- description: "Importing",
228
+ description: buffer.size > 1 ? `Importing (${buffer.size})` : "Importing",
222
229
  payload: [...buffer.keys()].join(", "),
223
230
  },
224
231
  absolute: {
225
232
  total: files.length,
226
- current: proccesed,
227
- percent: (0, math_1.progressPercent)(files.length, proccesed),
233
+ current: processed,
234
+ percent: (0, math_1.progressPercent)(files.length, processed),
228
235
  },
229
236
  }),
230
237
  onItem: async ({ item: file, controller }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datatruck/cli",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "dependencies": {
5
5
  "@supercharge/promise-pool": "^3.1.0",
6
6
  "ajv": "^8.12.0",
package/utils/async.d.ts CHANGED
@@ -9,11 +9,12 @@ export declare function runParallel<T>(options: {
9
9
  buffer: ItemBuffer<T>;
10
10
  processed: number;
11
11
  proccesing: number;
12
- }) => Promise<void>;
12
+ }) => Promise<void> | void;
13
13
  onItem: (data: {
14
14
  item: T;
15
15
  index: number;
16
16
  controller: ControllerItem;
17
- }) => Promise<void>;
17
+ }) => Promise<void> | void;
18
+ onFinished?: () => Promise<void> | void;
18
19
  }): Promise<void>;
19
20
  export {};
package/utils/async.js CHANGED
@@ -36,6 +36,7 @@ async function runParallel(options) {
36
36
  finally {
37
37
  buffer.delete(item);
38
38
  processed++;
39
+ await options.onFinished?.();
39
40
  await options.onChange({
40
41
  processed,
41
42
  proccesing: buffer.size,