@datatruck/cli 0.40.1 → 0.40.3

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 +20 -13
  2. package/lib/actions/CopyAction.js +20 -12
  3. package/lib/actions/ExportAction.js +13 -6
  4. package/lib/actions/RestoreAction.js +13 -6
  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 +13 -13
  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 +30 -21
  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 +2 -3
  56. package/lib/utils/temp.js +16 -15
  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,17 +40,24 @@ 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)) ?? "";
46
- const sql = await (0, promise_1.createConnection)({
46
+ const connectionOptions = {
47
47
  host: options.hostname,
48
48
  user: options.username,
49
49
  password,
50
50
  port: options.port,
51
51
  database: options.database,
52
- });
52
+ };
53
+ if (options.verbose)
54
+ (0, cli_1.logExec)("sql.createConnection", [
55
+ JSON.stringify({
56
+ ...connectionOptions,
57
+ password: "********",
58
+ }, null, 2),
59
+ ]);
60
+ const sql = await (0, promise_1.createConnection)(connectionOptions);
53
61
  async function createSqlConfig() {
54
62
  if (sqlConfigPath)
55
63
  return sqlConfigPath;
@@ -70,19 +78,23 @@ async function createMysqlCli(options) {
70
78
  return [`--defaults-file=${await createSqlConfig()}`];
71
79
  }
72
80
  async function fetchAll(query, params) {
81
+ if (options.verbose)
82
+ (0, cli_1.logExec)("> sql.query", [query, JSON.stringify({ params }, null, 2)]);
73
83
  const [rows] = await sql.query(query, params);
84
+ if (options.verbose)
85
+ (0, cli_1.logExec)("< sql.query", [JSON.stringify(rows, null, 2)]);
74
86
  return rows;
75
87
  }
76
88
  async function fetchTableNames(database, include, exclude) {
77
89
  return (await fetchAll(`
78
90
  SELECT
79
- table_name
91
+ TABLE_NAME AS table_name
80
92
  FROM
81
- information_schema.tables
93
+ information_schema.TABLES
82
94
  WHERE
83
- table_schema = ?
95
+ TABLE_SCHEMA = ?
84
96
  ORDER BY
85
- table_name
97
+ TABLE_NAME
86
98
  `, [database]))
87
99
  .map((r) => r.table_name)
88
100
  .filter((0, string_1.createPatternFilter)({ include, exclude }));
@@ -184,14 +196,14 @@ async function createMysqlCli(options) {
184
196
  SELECT
185
197
  COUNT(*) AS total
186
198
  FROM
187
- information_schema.tables
199
+ information_schema.TABLES
188
200
  WHERE
189
- table_schema = ?
201
+ TABLE_SCHEMA = ?
190
202
  `, [database]);
191
203
  return Number(row.total) ? false : true;
192
204
  }
193
205
  async function createDatabase(database) {
194
- await sql.execute(`
206
+ await execute(`
195
207
  CREATE DATABASE IF NOT EXISTS \`${database.name}\`
196
208
  CHARACTER SET ${database.charset ?? "utf8"}
197
209
  COLLATE ${database.charset ?? "utf8_general_ci"}
@@ -221,7 +233,7 @@ async function createMysqlCli(options) {
221
233
  try {
222
234
  await (0, fs_1.mkdirIfNotExists)(dir);
223
235
  await (0, promises_1.chmod)(dir, 0o777);
224
- await sql.execute(`SELECT 1 INTO OUTFILE ${outFileVar}`);
236
+ await execute(`SELECT 1 INTO OUTFILE ${outFileVar}`);
225
237
  const exists = await (0, fs_1.existsFile)(outFile);
226
238
  if (!exists)
227
239
  throw new error_1.AppError(`MySQL shared dir is not reached: ${dir}`);
@@ -234,14 +246,8 @@ async function createMysqlCli(options) {
234
246
  }
235
247
  }
236
248
  async function execute(query, params = []) {
237
- if (options.verbose) {
238
- (0, cli_1.logExec)(`mysql`, [
239
- ...(await args()),
240
- "-e",
241
- `"${flatQuery(query)}"`,
242
- ...(sql.config.database ? [sql.config.database] : []),
243
- ]);
244
- }
249
+ if (options.verbose)
250
+ (0, cli_1.logExec)("> sql.execute", [query, JSON.stringify({ params }, null, 2)]);
245
251
  await sql.execute(query, params);
246
252
  }
247
253
  async function insert(tableName, item) {
@@ -255,10 +261,14 @@ async function createMysqlCli(options) {
255
261
  await execute(`INSERT INTO ${tableName} (${columnsExpr}) VALUES (${paramsExpr})`, params);
256
262
  }
257
263
  async function changeDatabase(name) {
264
+ if (options.verbose)
265
+ (0, cli_1.logExec)("sql.changeUser", [name]);
258
266
  await sql.changeUser({ database: name });
259
267
  }
260
268
  return {
261
269
  async [Symbol.asyncDispose]() {
270
+ if (options.verbose)
271
+ (0, cli_1.logExec)("sql.end");
262
272
  await sql.end();
263
273
  },
264
274
  options,
@@ -279,4 +289,3 @@ async function createMysqlCli(options) {
279
289
  fetchVariable,
280
290
  };
281
291
  }
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;