@datatruck/cli 0.40.1 → 0.40.2

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 (59) hide show
  1. package/lib/actions/BackupAction.js +19 -12
  2. package/lib/actions/CopyAction.js +20 -12
  3. package/lib/actions/ExportAction.js +12 -5
  4. package/lib/actions/RestoreAction.js +12 -5
  5. package/lib/cli.js +2 -3
  6. package/lib/repositories/ResticRepository.d.ts +2 -2
  7. package/lib/tasks/MysqlDumpTask.js +12 -5
  8. package/lib/tasks/ScriptTask.js +2 -2
  9. package/lib/utils/async-process.d.ts +0 -5
  10. package/lib/utils/async.d.ts +0 -1
  11. package/lib/utils/async.js +1 -2
  12. package/lib/utils/bytes.js +2 -3
  13. package/lib/utils/cli.d.ts +0 -1
  14. package/lib/utils/cli.js +12 -12
  15. package/lib/utils/cron.js +1 -2
  16. package/lib/utils/crypto.js +2 -3
  17. package/lib/utils/datatruck/client.js +3 -3
  18. package/lib/utils/datatruck/command.js +3 -3
  19. package/lib/utils/datatruck/config.js +15 -15
  20. package/lib/utils/datatruck/cron-server.js +1 -2
  21. package/lib/utils/datatruck/job.js +4 -5
  22. package/lib/utils/datatruck/paths.js +2 -3
  23. package/lib/utils/datatruck/report-list.js +1 -2
  24. package/lib/utils/datatruck/repository-server.d.ts +0 -1
  25. package/lib/utils/datatruck/repository-server.js +2 -2
  26. package/lib/utils/datatruck/repository.js +4 -5
  27. package/lib/utils/datatruck/snapshot.js +1 -2
  28. package/lib/utils/datatruck/task.js +1 -2
  29. package/lib/utils/date.js +4 -5
  30. package/lib/utils/exit.js +4 -5
  31. package/lib/utils/fs.d.ts +0 -3
  32. package/lib/utils/fs.js +40 -40
  33. package/lib/utils/git.d.ts +1 -1
  34. package/lib/utils/http.d.ts +0 -1
  35. package/lib/utils/http.js +11 -11
  36. package/lib/utils/list.d.ts +2 -2
  37. package/lib/utils/list.js +36 -26
  38. package/lib/utils/logs.js +3 -3
  39. package/lib/utils/math.js +2 -2
  40. package/lib/utils/mongodb.js +2 -3
  41. package/lib/utils/mysql.d.ts +0 -1
  42. package/lib/utils/mysql.js +2 -3
  43. package/lib/utils/object.js +6 -6
  44. package/lib/utils/options.js +2 -3
  45. package/lib/utils/process.d.ts +0 -1
  46. package/lib/utils/process.js +3 -4
  47. package/lib/utils/progress.d.ts +0 -2
  48. package/lib/utils/progress.js +3 -3
  49. package/lib/utils/reportSteps.js +2 -3
  50. package/lib/utils/spawnSteps.js +2 -3
  51. package/lib/utils/stream.d.ts +0 -1
  52. package/lib/utils/stream.js +2 -3
  53. package/lib/utils/string.js +11 -12
  54. package/lib/utils/tar.js +6 -7
  55. package/lib/utils/temp.d.ts +0 -1
  56. package/lib/utils/temp.js +10 -10
  57. package/lib/utils/virtual-fs.js +2 -2
  58. package/lib/utils/watcher.js +1 -2
  59. package/package.json +14 -14
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { BasicProgress } from "./progress";
3
2
  import { IncomingMessage, Server, ServerResponse } from "http";
4
3
  import { fetch, type RequestInit } from "undici";
package/lib/utils/http.js CHANGED
@@ -1,6 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadFile = exports.downloadFile = exports.recvFile = exports.sendFile = exports.parseContentLength = exports.post = exports.fetchJson = exports.safeFetch = exports.readRequestData = exports.closeServer = exports.createHref = void 0;
3
+ exports.safeFetch = void 0;
4
+ exports.createHref = createHref;
5
+ exports.closeServer = closeServer;
6
+ exports.readRequestData = readRequestData;
7
+ exports.fetchJson = fetchJson;
8
+ exports.post = post;
9
+ exports.parseContentLength = parseContentLength;
10
+ exports.sendFile = sendFile;
11
+ exports.recvFile = recvFile;
12
+ exports.downloadFile = downloadFile;
13
+ exports.uploadFile = uploadFile;
4
14
  const crypto_1 = require("./crypto");
5
15
  const math_1 = require("./math");
6
16
  const fs_1 = require("fs");
@@ -14,11 +24,9 @@ function createHref(inUrl, query) {
14
24
  url.searchParams.set(key, query[key]);
15
25
  return url.href;
16
26
  }
17
- exports.createHref = createHref;
18
27
  async function closeServer(server) {
19
28
  await new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve())));
20
29
  }
21
- exports.closeServer = closeServer;
22
30
  function readRequestData(req) {
23
31
  let data;
24
32
  return new Promise((resolve, reject) => {
@@ -34,7 +42,6 @@ function readRequestData(req) {
34
42
  });
35
43
  });
36
44
  }
37
- exports.readRequestData = readRequestData;
38
45
  const safeFetch = async (...args) => {
39
46
  const res = await (0, undici_1.fetch)(...args);
40
47
  if (res.status !== 200)
@@ -47,17 +54,14 @@ async function fetchJson(url, options = {}) {
47
54
  const data = await res.text();
48
55
  return data.length ? JSON.parse(data) : undefined;
49
56
  }
50
- exports.fetchJson = fetchJson;
51
57
  async function post(url, data, options = {}) {
52
58
  return await (0, exports.safeFetch)(url, { ...options, method: "POST", body: data });
53
59
  }
54
- exports.post = post;
55
60
  function parseContentLength(value) {
56
61
  if (!value || !/^\d+$/.test(value))
57
62
  throw new Error(`Invalid 'content-length': ${value}`);
58
63
  return Number(value);
59
64
  }
60
- exports.parseContentLength = parseContentLength;
61
65
  async function sendFile(req, res, path, options = {}) {
62
66
  let file;
63
67
  try {
@@ -79,7 +83,6 @@ async function sendFile(req, res, path, options = {}) {
79
83
  res.end();
80
84
  }
81
85
  }
82
- exports.sendFile = sendFile;
83
86
  async function recvFile(req, res, path) {
84
87
  let file;
85
88
  try {
@@ -99,7 +102,6 @@ async function recvFile(req, res, path) {
99
102
  res.end();
100
103
  }
101
104
  }
102
- exports.recvFile = recvFile;
103
105
  async function downloadFile(url, output, options = {}) {
104
106
  const { timeout, onProgress, ...fetchOptions } = options;
105
107
  const file = (0, fs_1.createWriteStream)(output);
@@ -157,7 +159,6 @@ async function downloadFile(url, output, options = {}) {
157
159
  throw requestError;
158
160
  return { bytes: length.total };
159
161
  }
160
- exports.downloadFile = downloadFile;
161
162
  async function uploadFile(url, path, options = {}) {
162
163
  const { size } = await (0, promises_1.stat)(path);
163
164
  const file = (0, fs_1.createReadStream)(path);
@@ -182,4 +183,3 @@ async function uploadFile(url, path, options = {}) {
182
183
  file.close();
183
184
  }
184
185
  }
185
- exports.uploadFile = uploadFile;
@@ -46,7 +46,6 @@ export declare class Listr3<T extends Listr3Context> extends Listr<void, "defaul
46
46
  gargabeCollector?: GargabeCollector;
47
47
  };
48
48
  readonly resultMap: Record<string, Listr3TaskResult<T>>;
49
- readonly resultList: Listr3TaskResult<T>[];
50
49
  readonly logger: List3Logger;
51
50
  protected execTimer: Timer;
52
51
  constructor($options: {
@@ -56,12 +55,13 @@ export declare class Listr3<T extends Listr3Context> extends Listr<void, "defaul
56
55
  });
57
56
  private serializeKeyIndex;
58
57
  private createResultIndex;
58
+ get resultList(): any[];
59
59
  result(key: keyof T, keyIndex?: KeyIndex): Listr3TaskResult<T>;
60
60
  $task<K extends keyof T>(item: Listr3Task<T, K>): ListrTask;
61
61
  $tasks<K extends keyof T>(...items: (Listr3Task<T, K> | ListrTask | false)[]): ListrTask[];
62
62
  add(tasks: ListrTask<void, ListrGetRendererClassFromValue<"default">> | ListrTask<void, ListrGetRendererClassFromValue<"default">>[]): this;
63
63
  getSummaryResult(): List3SummaryResult;
64
- getResult(): (List3SummaryResult | Listr3TaskResult<T>)[];
64
+ getResult(): any[];
65
65
  protected release(): void;
66
66
  execAndParse(verbose: boolean | undefined): Promise<{
67
67
  result: (List3SummaryResult | Listr3TaskResult<T>)[];
package/lib/utils/list.js CHANGED
@@ -18,7 +18,6 @@ exports.List3Logger = List3Logger;
18
18
  class Listr3 extends listr2_1.Listr {
19
19
  $options;
20
20
  resultMap = {};
21
- resultList = [];
22
21
  logger;
23
22
  execTimer;
24
23
  constructor($options) {
@@ -56,6 +55,16 @@ class Listr3 extends listr2_1.Listr {
56
55
  createResultIndex(key, keyIndex) {
57
56
  return [key, ...this.serializeKeyIndex(keyIndex)].join(".");
58
57
  }
58
+ get resultList() {
59
+ return this.tasks
60
+ .flatMap((task) => [task, ...(task.subtasks || [])])
61
+ .map((task) => {
62
+ const result = task.task.task["_result"];
63
+ if (!result)
64
+ throw new Error(`Task result is not defined: ${task.title}`);
65
+ return result;
66
+ });
67
+ }
59
68
  result(key, keyIndex) {
60
69
  const index = this.createResultIndex(key, keyIndex);
61
70
  const result = this.resultMap[index];
@@ -76,37 +85,38 @@ class Listr3 extends listr2_1.Listr {
76
85
  error: undefined,
77
86
  data: item.data,
78
87
  };
79
- this.resultList.push(this.resultMap[index]);
80
88
  const title = typeof item.title === "string" ? { initial: item.title } : item.title;
89
+ const task = async (_, task) => {
90
+ const result = this.result(item.key, item.keyIndex);
91
+ if (title.started)
92
+ task.title = title.started;
93
+ const timer = (0, date_1.createTimer)();
94
+ if (title)
95
+ try {
96
+ const runResult = await item.run(task, result.data);
97
+ if (title.completed)
98
+ task.title = title.completed;
99
+ return Array.isArray(runResult)
100
+ ? task.newListr(runResult)
101
+ : runResult;
102
+ }
103
+ catch (error) {
104
+ result.error = error;
105
+ if (title.failed)
106
+ task.title = title.failed;
107
+ throw error;
108
+ }
109
+ finally {
110
+ result.elapsed = timer.elapsed();
111
+ }
112
+ };
113
+ task["_result"] = this.resultMap[index];
81
114
  return {
82
115
  title: title.initial,
83
116
  exitOnError: item.exitOnError,
84
117
  enabled: item.enabled,
85
118
  skip: item.skip,
86
- task: async (_, task) => {
87
- const result = this.result(item.key, item.keyIndex);
88
- if (title.started)
89
- task.title = title.started;
90
- const timer = (0, date_1.createTimer)();
91
- if (title)
92
- try {
93
- const runResult = await item.run(task, result.data);
94
- if (title.completed)
95
- task.title = title.completed;
96
- return Array.isArray(runResult)
97
- ? task.newListr(runResult)
98
- : runResult;
99
- }
100
- catch (error) {
101
- result.error = error;
102
- if (title.failed)
103
- task.title = title.failed;
104
- throw error;
105
- }
106
- finally {
107
- result.elapsed = timer.elapsed();
108
- }
109
- },
119
+ task,
110
120
  };
111
121
  }
112
122
  $tasks(...items) {
package/lib/utils/logs.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeOldLogs = exports.defaultsLogPath = exports.maxAgeToMS = void 0;
3
+ exports.defaultsLogPath = void 0;
4
+ exports.maxAgeToMS = maxAgeToMS;
5
+ exports.removeOldLogs = removeOldLogs;
4
6
  const fs_1 = require("./fs");
5
7
  const promises_1 = require("fs/promises");
6
8
  const os_1 = require("os");
@@ -21,7 +23,6 @@ function maxAgeToMS(input) {
21
23
  }
22
24
  return ms;
23
25
  }
24
- exports.maxAgeToMS = maxAgeToMS;
25
26
  exports.defaultsLogPath = (0, os_1.platform)() === "win32"
26
27
  ? (0, path_1.join)(process.env.APPDATA ?? `${process.env.HOMEDRIVE ?? "C:"}\\ProgramData`, "datatruck\\logs")
27
28
  : "/var/logs/datatruck";
@@ -44,4 +45,3 @@ async function removeOldLogs(path, inMaxAge) {
44
45
  }
45
46
  return paths;
46
47
  }
47
- exports.removeOldLogs = removeOldLogs;
package/lib/utils/math.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Counter = exports.progressPercent = void 0;
3
+ exports.Counter = void 0;
4
+ exports.progressPercent = progressPercent;
4
5
  function progressPercent(total, current) {
5
6
  if (total === 0 && current === 0)
6
7
  return 0;
7
8
  return Number(((current / total) * 100).toFixed(2));
8
9
  }
9
- exports.progressPercent = progressPercent;
10
10
  class Counter {
11
11
  maxValue;
12
12
  value = 0;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveMongoUri = exports.toMongoUri = void 0;
3
+ exports.toMongoUri = toMongoUri;
4
+ exports.resolveMongoUri = resolveMongoUri;
4
5
  const fs_1 = require("./fs");
5
6
  function toMongoUri(object) {
6
7
  const url = new URL(`mongodb://${object.host}`);
@@ -13,7 +14,6 @@ function toMongoUri(object) {
13
14
  url.pathname = `/${object.database}`;
14
15
  return url.href;
15
16
  }
16
- exports.toMongoUri = toMongoUri;
17
17
  async function resolveMongoUri(input) {
18
18
  let object;
19
19
  if (typeof input === "string") {
@@ -36,4 +36,3 @@ async function resolveMongoUri(input) {
36
36
  : "",
37
37
  };
38
38
  }
39
- exports.resolveMongoUri = resolveMongoUri;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export type MysqlCliOptions = {
3
2
  password: string | {
4
3
  path: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMysqlCli = exports.assertDumpFile = void 0;
3
+ exports.assertDumpFile = assertDumpFile;
4
+ exports.createMysqlCli = createMysqlCli;
4
5
  const async_process_1 = require("./async-process");
5
6
  const cli_1 = require("./cli");
6
7
  const error_1 = require("./error");
@@ -39,7 +40,6 @@ async function assertDumpFile(path) {
39
40
  if (!successFooter)
40
41
  throw new error_1.AppError("No end line found (incomplete backup)");
41
42
  }
42
- exports.assertDumpFile = assertDumpFile;
43
43
  async function createMysqlCli(options) {
44
44
  let sqlConfigPath;
45
45
  const password = (await (0, fs_1.fetchData)(options.password, (p) => p.path)) ?? "";
@@ -279,4 +279,3 @@ async function createMysqlCli(options) {
279
279
  fetchVariable,
280
280
  };
281
281
  }
282
- exports.createMysqlCli = createMysqlCli;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StrictMap = exports.groupBy = exports.getErrorProperties = exports.pickProps = exports.omitProp = exports.merge = void 0;
3
+ exports.StrictMap = void 0;
4
+ exports.merge = merge;
5
+ exports.omitProp = omitProp;
6
+ exports.pickProps = pickProps;
7
+ exports.getErrorProperties = getErrorProperties;
8
+ exports.groupBy = groupBy;
4
9
  function merge(target, ...sources) {
5
10
  const isObject = (o) => typeof o === "object" && o !== null;
6
11
  for (const source of sources)
@@ -12,13 +17,11 @@ function merge(target, ...sources) {
12
17
  }
13
18
  return target;
14
19
  }
15
- exports.merge = merge;
16
20
  function omitProp(object, name) {
17
21
  const result = { ...object };
18
22
  delete result[name];
19
23
  return result;
20
24
  }
21
- exports.omitProp = omitProp;
22
25
  function pickProps(object, input) {
23
26
  const result = {};
24
27
  for (const name in input) {
@@ -27,7 +30,6 @@ function pickProps(object, input) {
27
30
  }
28
31
  return result;
29
32
  }
30
- exports.pickProps = pickProps;
31
33
  function getErrorProperties(error) {
32
34
  const alt = {};
33
35
  for (const key of Object.getOwnPropertyNames(error)) {
@@ -35,7 +37,6 @@ function getErrorProperties(error) {
35
37
  }
36
38
  return alt;
37
39
  }
38
- exports.getErrorProperties = getErrorProperties;
39
40
  function groupBy(items, keyOrCb, single) {
40
41
  const keyCb = typeof keyOrCb === "function"
41
42
  ? keyOrCb
@@ -64,7 +65,6 @@ function groupBy(items, keyOrCb, single) {
64
65
  }, {});
65
66
  }
66
67
  }
67
- exports.groupBy = groupBy;
68
68
  class StrictMap {
69
69
  serializeKey;
70
70
  constructor(serializeKey) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringifyOptions = exports.createCommand = void 0;
3
+ exports.createCommand = createCommand;
4
+ exports.stringifyOptions = stringifyOptions;
4
5
  const string_1 = require("./string");
5
6
  const commander_1 = require("commander");
6
7
  function createCommand(config, action) {
@@ -66,7 +67,6 @@ function createCommand(config, action) {
66
67
  return await action(options);
67
68
  });
68
69
  }
69
- exports.createCommand = createCommand;
70
70
  function stringifyOptions(options, object) {
71
71
  const result = [];
72
72
  const prepend = [];
@@ -94,4 +94,3 @@ function stringifyOptions(options, object) {
94
94
  }
95
95
  return [...prepend, ...result];
96
96
  }
97
- exports.stringifyOptions = stringifyOptions;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable, Writable } from "stream";
3
2
  export type ProcessEnv = {
4
3
  [name: string]: string | undefined;
@@ -3,7 +3,9 @@ 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.logProcess = exports.logStderr = exports.logStdout = void 0;
6
+ exports.logStdout = logStdout;
7
+ exports.logStderr = logStderr;
8
+ exports.logProcess = logProcess;
7
9
  const cli_1 = require("./cli");
8
10
  const chalk_1 = __importDefault(require("chalk"));
9
11
  const stream_1 = require("stream");
@@ -13,11 +15,9 @@ function logStdout(input) {
13
15
  text += "\n";
14
16
  input.stderr ? process.stderr.write(text) : process.stdout.write(text);
15
17
  }
16
- exports.logStdout = logStdout;
17
18
  function logStderr(data, colorize) {
18
19
  process.stdout.write(colorize ? chalk_1.default.red(data) : data);
19
20
  }
20
- exports.logStderr = logStderr;
21
21
  async function logProcess(command, argv, options) {
22
22
  const logEnv = options.envNames?.reduce((env, key) => {
23
23
  const value = options?.env?.[key];
@@ -33,4 +33,3 @@ async function logProcess(command, argv, options) {
33
33
  ]
34
34
  : argv, logEnv, options.toStderr);
35
35
  }
36
- exports.logProcess = logProcess;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { Timer } from "./date";
4
2
  export type BasicProgress = {
5
3
  percent: number;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderProgressStats = exports.renderProgress = exports.ProgressManager = void 0;
3
+ exports.ProgressManager = void 0;
4
+ exports.renderProgress = renderProgress;
5
+ exports.renderProgressStats = renderProgressStats;
4
6
  const bytes_1 = require("./bytes");
5
7
  const cli_1 = require("./cli");
6
8
  const date_1 = require("./date");
@@ -121,7 +123,6 @@ function renderProgress(progress, bar) {
121
123
  progress.relative && renderProgressStats(progress.relative, bar),
122
124
  ].filter((v) => !!v);
123
125
  }
124
- exports.renderProgress = renderProgress;
125
126
  function renderProgressStats(stats, progressBar) {
126
127
  const text = [];
127
128
  if (typeof stats.percent === "number") {
@@ -160,4 +161,3 @@ function renderProgressStats(stats, progressBar) {
160
161
  const sep = (0, chalk_1.grey)(`|`);
161
162
  return text.join(` ${sep} `);
162
163
  }
163
- exports.renderProgressStats = renderProgressStats;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runReportSteps = exports.isReportStep = void 0;
3
+ exports.isReportStep = isReportStep;
4
+ exports.runReportSteps = runReportSteps;
4
5
  const error_1 = require("./error");
5
6
  const http_1 = require("./http");
6
7
  function isReportStep(step) {
7
8
  return step.type === "telegram" || step.type === "ntfy";
8
9
  }
9
- exports.isReportStep = isReportStep;
10
10
  async function runReportSteps(input, options) {
11
11
  const steps = Array.isArray(input) ? input : [input];
12
12
  for (const step of steps) {
@@ -39,4 +39,3 @@ async function runReportSteps(input, options) {
39
39
  }
40
40
  }
41
41
  }
42
- exports.runReportSteps = runReportSteps;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runSpawnSteps = exports.isSpawnStep = void 0;
3
+ exports.isSpawnStep = isSpawnStep;
4
+ exports.runSpawnSteps = runSpawnSteps;
4
5
  const async_process_1 = require("./async-process");
5
6
  const string_1 = require("./string");
6
7
  const temp_1 = require("./temp");
@@ -27,7 +28,6 @@ async function writeNodeScript(options) {
27
28
  function isSpawnStep(step) {
28
29
  return step.type === "process" || step.type === "node";
29
30
  }
30
- exports.isSpawnStep = isSpawnStep;
31
31
  async function runSpawnSteps(input, options) {
32
32
  const steps = Array.isArray(input) ? input : [input];
33
33
  for (const step of steps) {
@@ -70,4 +70,3 @@ async function runSpawnSteps(input, options) {
70
70
  }
71
71
  }
72
72
  }
73
- exports.runSpawnSteps = runSpawnSteps;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Writable } from "stream";
3
2
  export type StdStreams = {
4
3
  stdout: Writable;
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitForClose = exports.createStdStreams = void 0;
3
+ exports.createStdStreams = createStdStreams;
4
+ exports.waitForClose = waitForClose;
4
5
  function createStdStreams(options = {}) {
5
6
  return {
6
7
  stdout: options.stdout ?? process.stdout,
7
8
  stderr: options.stderr ?? process.stderr,
8
9
  };
9
10
  }
10
- exports.createStdStreams = createStdStreams;
11
11
  async function waitForClose(stream) {
12
12
  return new Promise((resolve, reject) => {
13
13
  stream.on("close", resolve);
14
14
  stream.on("error", reject);
15
15
  });
16
16
  }
17
- exports.waitForClose = waitForClose;
@@ -1,16 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareJsons = exports.undefIfEmpty = exports.endsWith = exports.createPatternFilter = exports.match = exports.splitPatterns = exports.formatUri = exports.parseStringList = exports.render = exports.camelize = exports.snakeCase = void 0;
3
+ exports.snakeCase = snakeCase;
4
+ exports.camelize = camelize;
5
+ exports.render = render;
6
+ exports.parseStringList = parseStringList;
7
+ exports.formatUri = formatUri;
8
+ exports.splitPatterns = splitPatterns;
9
+ exports.match = match;
10
+ exports.createPatternFilter = createPatternFilter;
11
+ exports.endsWith = endsWith;
12
+ exports.undefIfEmpty = undefIfEmpty;
13
+ exports.compareJsons = compareJsons;
4
14
  const error_1 = require("./error");
5
15
  const micromatch_1 = require("micromatch");
6
16
  function snakeCase(value, char = "_") {
7
17
  return value.replace(/[A-Z]/g, (letter) => `${char}${letter.toLowerCase()}`);
8
18
  }
9
- exports.snakeCase = snakeCase;
10
19
  function camelize(input) {
11
20
  return input.replace(/-./g, (x) => x[1].toUpperCase());
12
21
  }
13
- exports.camelize = camelize;
14
22
  function render(subject, data) {
15
23
  return subject.replace(/{([\w\./]*)}/g, function (match, name) {
16
24
  if (!name.length) {
@@ -41,7 +49,6 @@ function render(subject, data) {
41
49
  return ref.toString();
42
50
  });
43
51
  }
44
- exports.render = render;
45
52
  function parseStringList(value, validValues, defaultsValues) {
46
53
  const resultFallback = (defaultsValues === true ? validValues : defaultsValues) ?? [];
47
54
  const result = value
@@ -54,7 +61,6 @@ function parseStringList(value, validValues, defaultsValues) {
54
61
  throw new error_1.AppError(`Invalid value: ${v}`);
55
62
  return result;
56
63
  }
57
- exports.parseStringList = parseStringList;
58
64
  function formatUri(input, hidePassword) {
59
65
  let uri = "";
60
66
  if (input.protocol) {
@@ -74,7 +80,6 @@ function formatUri(input, hidePassword) {
74
80
  uri += input.path;
75
81
  return uri;
76
82
  }
77
- exports.formatUri = formatUri;
78
83
  function splitPatterns(patterns, map) {
79
84
  const include = [];
80
85
  const exclude = [];
@@ -92,12 +97,10 @@ function splitPatterns(patterns, map) {
92
97
  exclude: exclude.length ? exclude : undefined,
93
98
  };
94
99
  }
95
- exports.splitPatterns = splitPatterns;
96
100
  function match(path, include, exclude) {
97
101
  return ((!include || (0, micromatch_1.isMatch)(path, include, { dot: true })) &&
98
102
  (!exclude || !(0, micromatch_1.isMatch)(path, exclude, { dot: true })));
99
103
  }
100
- exports.match = match;
101
104
  function createPatternFilter(patterns) {
102
105
  if (patterns === undefined) {
103
106
  return () => true;
@@ -108,16 +111,12 @@ function createPatternFilter(patterns) {
108
111
  const { include, exclude } = patterns;
109
112
  return (input) => match(input, include, exclude);
110
113
  }
111
- exports.createPatternFilter = createPatternFilter;
112
114
  function endsWith(input, patterns) {
113
115
  return patterns.some((pattern) => input.endsWith(pattern));
114
116
  }
115
- exports.endsWith = endsWith;
116
117
  function undefIfEmpty(input) {
117
118
  return input.length ? input : undefined;
118
119
  }
119
- exports.undefIfEmpty = undefIfEmpty;
120
120
  function compareJsons(a, b) {
121
121
  return JSON.stringify(a) === JSON.stringify(b);
122
122
  }
123
- exports.compareJsons = compareJsons;
package/lib/utils/tar.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractTar = exports.normalizeTarPath = exports.createTar = exports.checkPigzLib = exports.listTar = exports.getTarVendor = void 0;
3
+ exports.getTarVendor = getTarVendor;
4
+ exports.listTar = listTar;
5
+ exports.checkPigzLib = checkPigzLib;
6
+ exports.createTar = createTar;
7
+ exports.normalizeTarPath = normalizeTarPath;
8
+ exports.extractTar = extractTar;
4
9
  const async_process_1 = require("./async-process");
5
10
  const cli_1 = require("./cli");
6
11
  const fs_1 = require("./fs");
@@ -28,7 +33,6 @@ async function getTarVendor(cache = true, log = false) {
28
33
  };
29
34
  return (tarVendor = find());
30
35
  }
31
- exports.getTarVendor = getTarVendor;
32
36
  async function listTar(options) {
33
37
  const vendor = await getTarVendor(true, options.verbose);
34
38
  const p = new async_process_1.AsyncProcess("tar", [
@@ -40,7 +44,6 @@ async function listTar(options) {
40
44
  options.onEntry?.({ path: normalizeTarPath(path) });
41
45
  });
42
46
  }
43
- exports.listTar = listTar;
44
47
  let pigzLib;
45
48
  async function checkPigzLib(cache = true) {
46
49
  if (cache && pigzLib !== undefined)
@@ -55,7 +58,6 @@ async function checkPigzLib(cache = true) {
55
58
  return false;
56
59
  }
57
60
  }
58
- exports.checkPigzLib = checkPigzLib;
59
61
  async function resolveCores(input) {
60
62
  if (!(await checkPigzLib()))
61
63
  return 1;
@@ -140,7 +142,6 @@ async function createTar(options) {
140
142
  await p.waitForClose();
141
143
  }
142
144
  }
143
- exports.createTar = createTar;
144
145
  /**
145
146
  * Fix `tar.exe: Option --force-local is not supported`
146
147
  */
@@ -153,7 +154,6 @@ function toLocalPath(path) {
153
154
  function normalizeTarPath(path) {
154
155
  return path.endsWith("/") ? path.slice(0, -1) : path;
155
156
  }
156
- exports.normalizeTarPath = normalizeTarPath;
157
157
  async function extractTar(options) {
158
158
  let total = options.onEntry
159
159
  ? options.total ??
@@ -205,4 +205,3 @@ async function extractTar(options) {
205
205
  await p.waitForClose();
206
206
  }
207
207
  }
208
- exports.extractTar = extractTar;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare function parentTmpDir(): string;
3
2
  export declare function sessionTmpDir(): string;
4
3
  export declare function ensureFreeDiskTempSpace(size: number | string): Promise<void>;