@datatruck/cli 0.5.0 → 0.7.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 (56) hide show
  1. package/Action/BackupAction.d.ts +1 -0
  2. package/Action/BackupAction.js +4 -1
  3. package/Action/RestoreAction.d.ts +1 -0
  4. package/CHANGELOG.md +40 -0
  5. package/Command/BackupCommand.d.ts +1 -0
  6. package/Command/BackupCommand.js +8 -2
  7. package/Command/BackupSessionsCommand.js +1 -1
  8. package/Command/ConfigCommand.d.ts +1 -0
  9. package/Command/ConfigCommand.js +7 -1
  10. package/Command/InitCommand.js +1 -1
  11. package/Command/PruneCommand.js +2 -2
  12. package/Command/RestoreCommand.d.ts +1 -0
  13. package/Command/RestoreCommand.js +8 -2
  14. package/Command/RestoreSessionsCommand.js +1 -1
  15. package/Command/SnapshotsCommand.js +1 -1
  16. package/Repository/GitRepository.js +2 -3
  17. package/Repository/LocalRepository.d.ts +4 -0
  18. package/Repository/LocalRepository.js +38 -37
  19. package/Repository/RepositoryAbstract.d.ts +4 -4
  20. package/Repository/ResticRepository.js +30 -9
  21. package/SessionDriver/ConsoleSessionDriver.d.ts +6 -2
  22. package/SessionDriver/ConsoleSessionDriver.js +31 -40
  23. package/SessionDriver/SessionDriverAbstract.d.ts +1 -1
  24. package/SessionDriver/SessionDriverAbstract.js +1 -1
  25. package/SessionManager/BackupSessionManager.d.ts +1 -1
  26. package/SessionManager/BackupSessionManager.js +2 -2
  27. package/Task/GitTask.d.ts +4 -0
  28. package/Task/GitTask.js +28 -29
  29. package/Task/MariadbTask.js +27 -15
  30. package/Task/MssqlTask.js +1 -2
  31. package/Task/MysqlDumpTask.d.ts +1 -1
  32. package/Task/MysqlDumpTask.js +4 -2
  33. package/Task/PostgresqlDumpTask.d.ts +1 -1
  34. package/Task/PostgresqlDumpTask.js +2 -4
  35. package/Task/SqlDumpTaskAbstract.d.ts +1 -2
  36. package/Task/SqlDumpTaskAbstract.js +60 -17
  37. package/Task/TaskAbstract.d.ts +4 -4
  38. package/config.schema.json +8 -0
  39. package/package.json +2 -2
  40. package/util/GitUtil.js +2 -2
  41. package/util/ResticUtil.d.ts +1 -1
  42. package/util/ResticUtil.js +3 -4
  43. package/util/cli-util.d.ts +1 -0
  44. package/util/cli-util.js +13 -1
  45. package/util/datatruck/config-util.d.ts +1 -0
  46. package/util/datatruck/config-util.js +3 -0
  47. package/util/date-util.d.ts +4 -0
  48. package/util/date-util.js +17 -1
  49. package/util/fs-util.d.ts +33 -0
  50. package/util/fs-util.js +73 -4
  51. package/util/process-util.d.ts +2 -2
  52. package/util/process-util.js +6 -6
  53. package/util/string-util.d.ts +1 -0
  54. package/util/string-util.js +21 -1
  55. package/util/zip-util.d.ts +2 -2
  56. package/util/zip-util.js +9 -9
@@ -4,7 +4,6 @@ exports.ResticUtil = void 0;
4
4
  const fs_util_1 = require("./fs-util");
5
5
  const process_util_1 = require("./process-util");
6
6
  const string_util_1 = require("./string-util");
7
- const fs_extra_1 = require("fs-extra");
8
7
  const promises_1 = require("fs/promises");
9
8
  const path_1 = require("path");
10
9
  class ResticUtil {
@@ -20,7 +19,7 @@ class ResticUtil {
20
19
  if (input.passwordFile)
21
20
  input = {
22
21
  ...input,
23
- password: (await (0, fs_extra_1.readFile)(input.passwordFile)).toString(),
22
+ password: (await (0, promises_1.readFile)(input.passwordFile)).toString(),
24
23
  };
25
24
  return `${input.backend}:${(0, string_util_1.formatUri)(input, hidePassword)}`;
26
25
  }
@@ -116,7 +115,7 @@ class ResticUtil {
116
115
  },
117
116
  stdout: {
118
117
  ...(options.onStream && {
119
- onData: async (data) => {
118
+ onData: (data) => {
120
119
  for (const rawLine of data.split("\n")) {
121
120
  const line = rawLine.trim();
122
121
  if (line.startsWith("{") && line.endsWith("}")) {
@@ -126,7 +125,7 @@ class ResticUtil {
126
125
  }
127
126
  catch (error) { }
128
127
  if (parsedLine)
129
- await options.onStream?.(parsedLine);
128
+ options.onStream?.(parsedLine);
130
129
  }
131
130
  }
132
131
  },
@@ -6,6 +6,7 @@ export declare const clearCommand = "\r\u001B[K";
6
6
  export declare const hideCursorCommand = "\u001B[?25l";
7
7
  export declare function renderSpinner(counter: number): string;
8
8
  export declare function renderProgressBar(progress: number, size?: number): string;
9
+ export declare function logVars(data: Record<string, any>): void;
9
10
  export declare function logExec(command: string, argv?: string[], env?: NodeJS.ProcessEnv, logToStderr?: boolean): void;
10
11
  export declare function resultColumn(error: Error | null | string, state?: "started" | "ended"): "❌" | " ? " | "✅";
11
12
  export declare function errorColumn(error: Error | null | string, verbose: number): string;
package/util/cli-util.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.confirm = exports.truncate = exports.parseOptions = exports.errorColumn = exports.resultColumn = exports.logExec = exports.renderProgressBar = exports.renderSpinner = exports.hideCursorCommand = exports.clearCommand = exports.showCursorCommand = exports.spinnerChars = exports.clearLastLine = void 0;
6
+ exports.confirm = exports.truncate = exports.parseOptions = exports.errorColumn = exports.resultColumn = exports.logExec = exports.logVars = exports.renderProgressBar = exports.renderSpinner = exports.hideCursorCommand = exports.clearCommand = exports.showCursorCommand = exports.spinnerChars = exports.clearLastLine = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const chalk_2 = require("chalk");
9
9
  const readline_1 = require("readline");
@@ -28,6 +28,18 @@ function renderProgressBar(progress, size = 10) {
28
28
  return completeChar.repeat(completedSize) + incompleteChar.repeat(restSize);
29
29
  }
30
30
  exports.renderProgressBar = renderProgressBar;
31
+ function logVars(data) {
32
+ let first = true;
33
+ for (const key in data) {
34
+ if (first) {
35
+ console.log();
36
+ first = false;
37
+ }
38
+ const value = data[key];
39
+ console.log(`${chalk_1.default.cyan(key)}${chalk_1.default.grey(":")} ${chalk_1.default.white(value ?? "")}`);
40
+ }
41
+ }
42
+ exports.logVars = logVars;
31
43
  function logExec(command, argv = [], env, logToStderr) {
32
44
  const envText = env
33
45
  ? Object.keys(env)
@@ -5,6 +5,7 @@ export declare function findRepositoryOrFail(config: ConfigType, repositoryName:
5
5
  export declare function filterRepository(repository: RepositoryConfigType, action?: RepositoryConfigEnabledActionType): boolean;
6
6
  export declare function filterPackages(config: ConfigType, options: {
7
7
  packageNames?: string[];
8
+ packageTaskNames?: string[];
8
9
  repositoryNames?: string[];
9
10
  repositoryTypes?: string[];
10
11
  sourceAction?: RepositoryConfigEnabledActionType;
@@ -22,6 +22,7 @@ function filterRepository(repository, action) {
22
22
  exports.filterRepository = filterRepository;
23
23
  function filterPackages(config, options) {
24
24
  const packagePatterns = (0, string_util_1.makePathPatterns)(options.packageNames);
25
+ const taskNamePatterns = (0, string_util_1.makePathPatterns)(options.packageTaskNames);
25
26
  return config.packages
26
27
  .map((pkg) => {
27
28
  pkg = Object.assign({}, pkg);
@@ -37,6 +38,8 @@ function filterPackages(config, options) {
37
38
  return pkg;
38
39
  })
39
40
  .filter((pkg) => {
41
+ if (taskNamePatterns && !(0, micromatch_1.isMatch)(pkg.task?.name ?? "", taskNamePatterns))
42
+ return false;
40
43
  return ((typeof pkg.enabled !== "boolean" || pkg.enabled) &&
41
44
  !!pkg.repositoryNames?.length &&
42
45
  (!packagePatterns || (0, micromatch_1.isMatch)(pkg.name, packagePatterns)));
@@ -10,3 +10,7 @@ export declare type FilterByLastOptionsType = {
10
10
  export declare function filterByLast<TItem extends {
11
11
  date: string;
12
12
  }>(items: TItem[], options: FilterByLastOptionsType, reasons?: Record<number, string[]>): TItem[];
13
+ export declare function createChron(): {
14
+ start: () => number;
15
+ elapsed: (formatted?: boolean | undefined) => string | number;
16
+ };
package/util/date-util.js CHANGED
@@ -3,7 +3,8 @@ 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.filterByLast = void 0;
6
+ exports.createChron = exports.filterByLast = void 0;
7
+ const string_util_1 = require("./string-util");
7
8
  const dayjs_1 = __importDefault(require("dayjs"));
8
9
  const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
9
10
  const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
@@ -72,3 +73,18 @@ function filterByLast(items, options, reasons) {
72
73
  return items.filter((item) => validItems.includes(item));
73
74
  }
74
75
  exports.filterByLast = filterByLast;
76
+ function createChron() {
77
+ let startTime;
78
+ return {
79
+ start: () => (startTime = Date.now()),
80
+ elapsed: (formatted) => {
81
+ if (!startTime)
82
+ throw new Error(`Chron was not started`);
83
+ const seconds = (Date.now() - startTime) / 1000;
84
+ if (formatted)
85
+ return (0, string_util_1.formatSeconds)(seconds);
86
+ return seconds;
87
+ },
88
+ };
89
+ }
90
+ exports.createChron = createChron;
package/util/fs-util.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import { Interface } from "readline";
2
3
  export declare function isLocalDir(path: string): boolean;
3
4
  export declare function isDirEmpty(path: string): Promise<boolean>;
4
5
  export declare function mkdirIfNotExists(path: string): Promise<string>;
@@ -44,3 +45,35 @@ export declare function writePathLists(options: {
44
45
  multipleStats: Record<string, number>;
45
46
  };
46
47
  }>;
48
+ export declare function cpy(options: {
49
+ input: {
50
+ type: "glob";
51
+ sourcePath: string;
52
+ include?: string[];
53
+ exclude?: string[];
54
+ } | {
55
+ type: "stream";
56
+ basePath: string;
57
+ value: Interface;
58
+ } | {
59
+ type: "pathList";
60
+ path: string;
61
+ basePath: string;
62
+ };
63
+ targetPath: string;
64
+ /**
65
+ * @default 1
66
+ */
67
+ concurrency?: number;
68
+ onPath?: (data: {
69
+ isDir: boolean;
70
+ entryPath: string;
71
+ entrySourcePath: string;
72
+ entryTargetPath: string;
73
+ stats: {
74
+ paths: number;
75
+ files: number;
76
+ dirs: number;
77
+ };
78
+ }) => Promise<boolean | void>;
79
+ }): Promise<void>;
package/util/fs-util.js CHANGED
@@ -3,17 +3,19 @@ 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.writePathLists = exports.writeGitIgnoreList = exports.forEachFile = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = exports.tmpDir = exports.sessionTmpDir = exports.parentTmpDir = exports.existsFile = exports.findFile = exports.parsePackageFile = exports.parseFile = exports.parseFileExtensions = exports.readdirIfExists = exports.writeJSONFile = exports.existsDir = exports.ensureEmptyDir = exports.mkdirIfNotExists = exports.isDirEmpty = exports.isLocalDir = void 0;
6
+ exports.cpy = exports.writePathLists = exports.writeGitIgnoreList = exports.forEachFile = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = exports.tmpDir = exports.sessionTmpDir = exports.parentTmpDir = exports.existsFile = exports.findFile = exports.parsePackageFile = exports.parseFile = exports.parseFileExtensions = exports.readdirIfExists = exports.writeJSONFile = exports.existsDir = exports.ensureEmptyDir = exports.mkdirIfNotExists = exports.isDirEmpty = exports.isLocalDir = void 0;
7
7
  const globalData_1 = __importDefault(require("../globalData"));
8
8
  const path_util_1 = require("./path-util");
9
+ const async_1 = require("async");
9
10
  const crypto_1 = require("crypto");
11
+ const fast_glob_1 = __importDefault(require("fast-glob"));
10
12
  const fs_1 = require("fs");
11
13
  const fs_2 = require("fs");
12
- const fs_extra_1 = require("fs-extra");
13
14
  const promises_1 = require("fs/promises");
14
15
  const micromatch_1 = require("micromatch");
15
16
  const path_1 = require("path");
16
17
  const path_2 = require("path");
18
+ const readline_1 = require("readline");
17
19
  function isLocalDir(path) {
18
20
  return /^[\/\.]|([A-Z]:)/i.test(path);
19
21
  }
@@ -25,7 +27,7 @@ async function isDirEmpty(path) {
25
27
  exports.isDirEmpty = isDirEmpty;
26
28
  async function mkdirIfNotExists(path) {
27
29
  try {
28
- await (0, fs_extra_1.mkdir)(path, {
30
+ await (0, promises_1.mkdir)(path, {
29
31
  recursive: true,
30
32
  });
31
33
  }
@@ -128,7 +130,7 @@ function tmpDir(prefix, id) {
128
130
  exports.tmpDir = tmpDir;
129
131
  async function mkTmpDir(prefix, id) {
130
132
  const path = tmpDir(prefix, id);
131
- await (0, fs_extra_1.mkdir)(path, { recursive: true });
133
+ await (0, promises_1.mkdir)(path, { recursive: true });
132
134
  return path;
133
135
  }
134
136
  exports.mkTmpDir = mkTmpDir;
@@ -313,3 +315,70 @@ async function writePathLists(options) {
313
315
  };
314
316
  }
315
317
  exports.writePathLists = writePathLists;
318
+ async function cpy(options) {
319
+ const stats = { paths: 0, files: 0, dirs: 0 };
320
+ const dirs = new Set();
321
+ const makeRecursiveDir = async (path) => {
322
+ if (!dirs.has(path)) {
323
+ stats.paths++;
324
+ stats.dirs++;
325
+ await (0, promises_1.mkdir)(path, {
326
+ recursive: true,
327
+ });
328
+ dirs.add(path);
329
+ }
330
+ };
331
+ const task = async (rawEntryPath, basePath) => {
332
+ const isDir = rawEntryPath.endsWith("/");
333
+ const entryPath = (0, path_1.normalize)(rawEntryPath);
334
+ const entrySourcePath = (0, path_1.resolve)((0, path_1.join)(basePath, rawEntryPath));
335
+ const entryTargetPath = (0, path_1.resolve)((0, path_1.join)(options.targetPath, rawEntryPath));
336
+ const onPathResult = await options?.onPath?.({
337
+ isDir,
338
+ entryPath,
339
+ entrySourcePath,
340
+ entryTargetPath,
341
+ stats,
342
+ });
343
+ if (onPathResult === false) {
344
+ return;
345
+ }
346
+ else if (isDir) {
347
+ await makeRecursiveDir(entryTargetPath);
348
+ }
349
+ else {
350
+ const dir = (0, path_1.dirname)(entryTargetPath);
351
+ await makeRecursiveDir(dir);
352
+ stats.files++;
353
+ await (0, promises_1.cp)(entrySourcePath, entryTargetPath);
354
+ }
355
+ };
356
+ const { input } = options;
357
+ if (input.type === "glob") {
358
+ const stream = await (0, fast_glob_1.default)(input.include || ["**"], {
359
+ cwd: input.sourcePath,
360
+ ignore: input.exclude,
361
+ dot: true,
362
+ onlyFiles: false,
363
+ markDirectories: true,
364
+ });
365
+ await (0, async_1.eachLimit)(stream, options.concurrency ?? 1, async (entryPath) => await task(entryPath, input.sourcePath));
366
+ }
367
+ else if (input.type === "stream") {
368
+ await (0, async_1.eachLimit)(input.value, options.concurrency ?? 1, async (entryPath) => await task(entryPath, input.basePath));
369
+ }
370
+ else if (input.type === "pathList") {
371
+ const stream = (0, readline_1.createInterface)({
372
+ input: (0, fs_1.createReadStream)(input.path),
373
+ });
374
+ await cpy({
375
+ ...options,
376
+ input: {
377
+ type: "stream",
378
+ value: stream,
379
+ basePath: input.basePath,
380
+ },
381
+ });
382
+ }
383
+ }
384
+ exports.cpy = cpy;
@@ -23,11 +23,11 @@ export interface ExecSettingsInterface {
23
23
  onSpawn?: (p: ChildProcess) => void;
24
24
  stdout?: {
25
25
  save?: boolean;
26
- onData?: (data: string) => Promise<void>;
26
+ onData?: (data: string) => void;
27
27
  };
28
28
  stderr?: {
29
29
  save?: boolean;
30
- onData?: (data: string) => Promise<void>;
30
+ onData?: (data: string) => void;
31
31
  toExitCode?: boolean;
32
32
  };
33
33
  onExitCodeError?: (data: ExecResultType, error: Error) => Error | false;
@@ -68,10 +68,10 @@ async function exec(command, argv = [], options = null, settings = {}) {
68
68
  stderr: "",
69
69
  exitCode: 0,
70
70
  };
71
- let finishListens = pipe ? 2 : 1;
71
+ let finishListeners = pipe?.stream instanceof fs_1.WriteStream ? 2 : 1;
72
72
  let streamError;
73
73
  const tryFinish = () => {
74
- if (!--finishListens)
74
+ if (!--finishListeners)
75
75
  finish();
76
76
  };
77
77
  const finish = () => {
@@ -127,7 +127,7 @@ async function exec(command, argv = [], options = null, settings = {}) {
127
127
  if (log.stdout || settings.stdout) {
128
128
  if (!p.stdout)
129
129
  throw new Error(`stdout is not defined`);
130
- p.stdout.on("data", async (data) => {
130
+ p.stdout.on("data", (data) => {
131
131
  if (log.stdout)
132
132
  logExecStdout({
133
133
  data: data.toString(),
@@ -137,13 +137,13 @@ async function exec(command, argv = [], options = null, settings = {}) {
137
137
  if (settings.stdout?.save)
138
138
  spawnData.stdout += data.toString();
139
139
  if (settings.stdout?.onData)
140
- await settings.stdout.onData(data.toString());
140
+ settings.stdout.onData(data.toString());
141
141
  });
142
142
  }
143
143
  if (log.stderr || settings.stderr) {
144
144
  if (!p.stderr)
145
145
  throw new Error(`stderr is not defined`);
146
- p.stderr.on("data", async (data) => {
146
+ p.stderr.on("data", (data) => {
147
147
  if (log.stderr)
148
148
  logExecStdout({
149
149
  data: data.toString(),
@@ -153,7 +153,7 @@ async function exec(command, argv = [], options = null, settings = {}) {
153
153
  if (settings.stderr?.save || settings.stderr?.toExitCode)
154
154
  spawnData.stderr += data.toString();
155
155
  if (settings.stderr?.onData)
156
- await settings.stderr.onData(data.toString());
156
+ settings.stderr.onData(data.toString());
157
157
  });
158
158
  }
159
159
  p.on("error", (error) => (spawnError = error)).on("close", (exitCode) => {
@@ -13,5 +13,6 @@ export declare type UriType = {
13
13
  path?: string;
14
14
  };
15
15
  export declare function formatUri(input: UriType, hidePassword?: boolean): string;
16
+ export declare function formatSeconds(seconds: number): string;
16
17
  export declare function makePathPatterns(values: string[] | undefined): string[] | undefined;
17
18
  export declare function formatDateTime(datetime: string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatDateTime = exports.makePathPatterns = exports.formatUri = exports.parseStringList = exports.render = exports.snakeCase = exports.lcfirst = exports.ucfirst = exports.serialize = void 0;
3
+ exports.formatDateTime = exports.makePathPatterns = exports.formatSeconds = exports.formatUri = exports.parseStringList = exports.render = exports.snakeCase = exports.lcfirst = exports.ucfirst = exports.serialize = void 0;
4
4
  const AppError_1 = require("../Error/AppError");
5
5
  function serialize(message, data) {
6
6
  if (data)
@@ -67,6 +67,26 @@ function formatUri(input, hidePassword) {
67
67
  return uri;
68
68
  }
69
69
  exports.formatUri = formatUri;
70
+ function formatSeconds(seconds) {
71
+ let unit;
72
+ let value;
73
+ if (seconds > 60 * 60) {
74
+ value = seconds / 60 / 60;
75
+ unit = `hour`;
76
+ }
77
+ else if (seconds > 60) {
78
+ value = seconds / 60;
79
+ unit = `minute`;
80
+ }
81
+ else {
82
+ value = seconds;
83
+ unit = `second`;
84
+ }
85
+ if (value !== 1)
86
+ unit += `s`;
87
+ return `${value.toFixed(2)} ${unit}`;
88
+ }
89
+ exports.formatSeconds = formatSeconds;
70
90
  function makePathPatterns(values) {
71
91
  return values?.flatMap((v) => [v, `${v}/**`]);
72
92
  }
@@ -26,7 +26,7 @@ export interface ZipDataType {
26
26
  includeList?: string;
27
27
  excludeList?: string;
28
28
  verbose?: boolean;
29
- onStream?: (data: ZipStreamDataType) => Promise<void>;
29
+ onStream?: (data: ZipStreamDataType) => void;
30
30
  }
31
31
  export interface UnzipDataType {
32
32
  command?: string;
@@ -34,7 +34,7 @@ export interface UnzipDataType {
34
34
  files?: (ZipDataFilterType | string)[];
35
35
  output: string;
36
36
  verbose?: boolean;
37
- onStream?: (data: UnzipStreamDataType) => Promise<void>;
37
+ onStream?: (data: UnzipStreamDataType) => void;
38
38
  }
39
39
  export declare type UnzipStreamDataType = {
40
40
  type: "progress";
package/util/zip-util.js CHANGED
@@ -30,7 +30,7 @@ function buildArguments(filters) {
30
30
  return args;
31
31
  }
32
32
  exports.buildArguments = buildArguments;
33
- async function parseZipStream(chunk, buffer, cb) {
33
+ function parseZipStream(chunk, buffer, cb) {
34
34
  const lines = chunk.trim().split(/\r?\n/g);
35
35
  for (const line of lines) {
36
36
  let matches = null;
@@ -42,7 +42,7 @@ async function parseZipStream(chunk, buffer, cb) {
42
42
  if (path !== buffer.lastPath)
43
43
  buffer.currentPaths++;
44
44
  buffer.lastPath = path;
45
- await cb({
45
+ cb({
46
46
  type: "progress",
47
47
  data: { progress, path, files: buffer.currentPaths },
48
48
  });
@@ -50,7 +50,7 @@ async function parseZipStream(chunk, buffer, cb) {
50
50
  else if (line.startsWith("Add new data to archive:")) {
51
51
  const [, folders] = /(\d+) folders?/i.exec(line) || [, 0];
52
52
  const [, files] = /(\d+) files?/i.exec(line) || [, 0];
53
- await cb({
53
+ cb({
54
54
  type: "summary",
55
55
  data: {
56
56
  folders: Number(folders),
@@ -83,9 +83,9 @@ async function zip(data) {
83
83
  toExitCode: true,
84
84
  },
85
85
  stdout: {
86
- onData: async (chunk) => {
87
- parseZipStream(chunk, buffer, async (stream) => {
88
- await data.onStream?.(stream);
86
+ onData: (chunk) => {
87
+ parseZipStream(chunk, buffer, (stream) => {
88
+ data.onStream?.(stream);
89
89
  if (stream.type === "summary")
90
90
  result = stream.data;
91
91
  });
@@ -95,7 +95,7 @@ async function zip(data) {
95
95
  return result;
96
96
  }
97
97
  exports.zip = zip;
98
- async function parseUnzipStream(chunk, cb) {
98
+ function parseUnzipStream(chunk, cb) {
99
99
  const lines = chunk.trim().split(/\r?\n/g);
100
100
  for (const line of lines) {
101
101
  let matches = null;
@@ -103,7 +103,7 @@ async function parseUnzipStream(chunk, cb) {
103
103
  const progress = Number(matches[1]);
104
104
  const files = Number(matches[2]);
105
105
  const path = line.slice(line.indexOf("-") + 1).trim();
106
- await cb({
106
+ cb({
107
107
  type: "progress",
108
108
  data: { progress, path, files },
109
109
  });
@@ -124,7 +124,7 @@ async function unzip(data) {
124
124
  stderr: { toExitCode: true },
125
125
  stdout: {
126
126
  ...(data.onStream && {
127
- onData: async (chunk) => {
127
+ onData: (chunk) => {
128
128
  if (data.onStream)
129
129
  parseUnzipStream(chunk, data.onStream);
130
130
  },