@naturalcycles/nodejs-lib 13.1.0 → 13.1.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.
Files changed (71) hide show
  1. package/dist/bin/del.js +3 -2
  2. package/dist/bin/generate-build-info.js +8 -7
  3. package/dist/bin/json2env.js +3 -2
  4. package/dist/bin/kpy.js +3 -2
  5. package/dist/bin/secrets-decrypt.js +3 -2
  6. package/dist/bin/secrets-encrypt.js +3 -2
  7. package/dist/bin/secrets-gen-key.js +5 -4
  8. package/dist/bin/slack-this.js +3 -2
  9. package/dist/colors/colors.d.ts +1 -1
  10. package/dist/colors/colors.js +31 -30
  11. package/dist/fs/del.js +11 -10
  12. package/dist/fs/fs.util.d.ts +1 -1
  13. package/dist/fs/fs.util.js +42 -41
  14. package/dist/fs/json2env.js +6 -5
  15. package/dist/fs/kpy.js +8 -7
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +5 -5
  18. package/dist/infra/process.util.js +8 -7
  19. package/dist/jwt/jwt.service.d.ts +1 -1
  20. package/dist/jwt/jwt.service.js +6 -5
  21. package/dist/secret/secrets-decrypt.util.js +9 -8
  22. package/dist/secret/secrets-encrypt.util.js +8 -7
  23. package/dist/security/crypto.util.js +9 -8
  24. package/dist/security/hash.util.js +4 -3
  25. package/dist/security/id.util.js +4 -3
  26. package/dist/security/secret.util.js +7 -6
  27. package/dist/stream/ndjson/ndjsonStreamForEach.js +3 -2
  28. package/dist/stream/ndjson/pipelineFromNDJsonFile.js +4 -3
  29. package/dist/stream/ndjson/pipelineToNDJsonFile.js +4 -3
  30. package/dist/util/env.util.js +3 -2
  31. package/dist/util/exec.util.js +4 -3
  32. package/dist/util/git.util.js +9 -8
  33. package/dist/util/zip.util.js +6 -5
  34. package/dist/validation/ajv/getAjv.js +2 -1
  35. package/dist/validation/joi/joi.extensions.d.ts +1 -1
  36. package/dist/validation/joi/joi.extensions.js +3 -2
  37. package/dist/validation/joi/number.extensions.d.ts +1 -1
  38. package/dist/validation/joi/string.extensions.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/src/bin/del.ts +1 -1
  41. package/src/bin/generate-build-info.ts +3 -3
  42. package/src/bin/json2env.ts +1 -1
  43. package/src/bin/kpy.ts +1 -1
  44. package/src/bin/secrets-decrypt.ts +1 -1
  45. package/src/bin/secrets-encrypt.ts +1 -1
  46. package/src/bin/secrets-gen-key.ts +2 -2
  47. package/src/bin/slack-this.ts +1 -1
  48. package/src/colors/colors.ts +2 -2
  49. package/src/fs/del.ts +2 -2
  50. package/src/fs/fs.util.ts +3 -3
  51. package/src/fs/json2env.ts +1 -1
  52. package/src/fs/kpy.ts +1 -1
  53. package/src/index.ts +2 -2
  54. package/src/infra/process.util.ts +1 -1
  55. package/src/jwt/jwt.service.ts +1 -1
  56. package/src/secret/secrets-decrypt.util.ts +2 -2
  57. package/src/secret/secrets-encrypt.util.ts +2 -2
  58. package/src/security/crypto.util.ts +1 -1
  59. package/src/security/hash.util.ts +1 -1
  60. package/src/security/id.util.ts +1 -1
  61. package/src/security/secret.util.ts +1 -1
  62. package/src/stream/ndjson/ndjsonStreamForEach.ts +1 -1
  63. package/src/stream/ndjson/pipelineFromNDJsonFile.ts +1 -1
  64. package/src/stream/ndjson/pipelineToNDJsonFile.ts +1 -1
  65. package/src/util/env.util.ts +1 -1
  66. package/src/util/exec.util.ts +1 -1
  67. package/src/util/git.util.ts +2 -2
  68. package/src/util/zip.util.ts +1 -1
  69. package/src/validation/joi/joi.extensions.ts +1 -1
  70. package/src/validation/joi/number.extensions.ts +1 -1
  71. package/src/validation/joi/string.extensions.ts +1 -1
package/dist/bin/del.js CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
5
6
  const del_1 = require("../fs/del");
6
7
  const runScript_1 = require("../script/runScript");
7
8
  (0, runScript_1.runScript)(async () => {
8
- const { _: patterns, ...opt } = yargs.demandCommand(1).options({
9
+ const { _: patterns, ...opt } = yargs_1.default.demandCommand(1).options({
9
10
  verbose: {
10
11
  type: 'boolean',
11
12
  },
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const fs = require("node:fs");
5
- const path = require("node:path");
6
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
7
8
  const json2env_1 = require("../fs/json2env");
8
9
  const runScript_1 = require("../script/runScript");
9
10
  const buildInfo_util_1 = require("../util/buildInfo.util");
10
11
  (0, runScript_1.runScript)(async () => {
11
- const { dir, overrideTimestamp } = yargs.options({
12
+ const { dir, overrideTimestamp } = yargs_1.default.options({
12
13
  dir: {
13
14
  type: 'string',
14
15
  desc: 'Output directory',
@@ -23,9 +24,9 @@ const buildInfo_util_1 = require("../util/buildInfo.util");
23
24
  });
24
25
  console.log(buildInfo);
25
26
  if (dir)
26
- fs.mkdirSync(dir, { recursive: true });
27
- const buildInfoPath = dir ? path.resolve(dir, 'buildInfo.json') : 'buildInfo.json';
28
- fs.writeFileSync(buildInfoPath, JSON.stringify(buildInfo, null, 2));
27
+ node_fs_1.default.mkdirSync(dir, { recursive: true });
28
+ const buildInfoPath = dir ? node_path_1.default.resolve(dir, 'buildInfo.json') : 'buildInfo.json';
29
+ node_fs_1.default.writeFileSync(buildInfoPath, JSON.stringify(buildInfo, null, 2));
29
30
  const prefix = 'buildInfo_';
30
31
  (0, json2env_1.appendToBashEnv)(buildInfo, prefix);
31
32
  (0, json2env_1.appendToGithubEnv)(buildInfo, prefix);
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
5
6
  const json2env_1 = require("../fs/json2env");
6
7
  const runScript_1 = require("../script/runScript");
7
8
  (0, runScript_1.runScript)(() => {
8
- const { argv } = yargs.demandCommand(1).options({
9
+ const { argv } = yargs_1.default.demandCommand(1).options({
9
10
  prefix: {
10
11
  type: 'string',
11
12
  },
package/dist/bin/kpy.js CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
5
6
  const kpy_1 = require("../fs/kpy");
6
7
  const runScript_1 = require("../script/runScript");
7
8
  (0, runScript_1.runScript)(() => {
8
- const { _: [baseDir, ...inputPatterns], ...opt } = yargs.demandCommand(2).options({
9
+ const { _: [baseDir, ...inputPatterns], ...opt } = yargs_1.default.demandCommand(2).options({
9
10
  silent: {
10
11
  type: 'boolean',
11
12
  descr: 'Suppress all text output', // todo: desc!
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
5
6
  const colors_1 = require("../colors/colors");
6
7
  const runScript_1 = require("../script/runScript");
7
8
  const secrets_decrypt_util_1 = require("../secret/secrets-decrypt.util");
@@ -11,7 +12,7 @@ const secrets_decrypt_util_1 = require("../secret/secrets-decrypt.util");
11
12
  });
12
13
  function getDecryptCLIOptions() {
13
14
  require('dotenv').config();
14
- let { dir, file, encKey, encKeyVar, del, jsonMode } = yargs.options({
15
+ let { dir, file, encKey, encKeyVar, del, jsonMode } = yargs_1.default.options({
15
16
  dir: {
16
17
  type: 'array',
17
18
  desc: 'Directory with secrets. Can be many',
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
5
6
  const colors_1 = require("../colors/colors");
6
7
  const runScript_1 = require("../script/runScript");
7
8
  const secrets_encrypt_util_1 = require("../secret/secrets-encrypt.util");
@@ -11,7 +12,7 @@ const secrets_encrypt_util_1 = require("../secret/secrets-encrypt.util");
11
12
  });
12
13
  function getEncryptCLIOptions() {
13
14
  require('dotenv').config();
14
- let { pattern, file, encKey, encKeyVar, del, jsonMode } = yargs.options({
15
+ let { pattern, file, encKey, encKeyVar, del, jsonMode } = yargs_1.default.options({
15
16
  pattern: {
16
17
  type: 'string',
17
18
  array: true,
@@ -1,16 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const crypto = require("node:crypto");
5
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
6
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
7
  const colors_1 = require("../colors/colors");
7
8
  const runScript_1 = require("../script/runScript");
8
9
  (0, runScript_1.runScript)(() => {
9
- const { sizeBytes } = yargs.option('sizeBytes', {
10
+ const { sizeBytes } = yargs_1.default.option('sizeBytes', {
10
11
  type: 'number',
11
12
  default: 256,
12
13
  }).argv;
13
- const key = crypto.randomBytes(sizeBytes).toString('base64');
14
+ const key = node_crypto_1.default.randomBytes(sizeBytes).toString('base64');
14
15
  console.log((0, colors_1.dimGrey)('\nSECRET_ENCRYPTION_KEY:\n'));
15
16
  console.log(key, '\n');
16
17
  });
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const yargs = require("yargs");
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
5
6
  const __1 = require("..");
6
7
  const runScript_1 = require("../script/runScript");
7
8
  (0, runScript_1.runScript)(async () => {
8
- const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs.options({
9
+ const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs_1.default.options({
9
10
  channel: {
10
11
  type: 'string',
11
12
  demandOption: true,
@@ -1,4 +1,4 @@
1
- import * as chalk from 'chalk';
1
+ import chalk from 'chalk';
2
2
  export { chalk };
3
3
  /**
4
4
  * Based on: https://github.com/sindresorhus/yoctocolors/pull/5
@@ -1,42 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.boldCyan = exports.dimCyan = exports.cyan = exports.boldMagenta = exports.dimMagenta = exports.magenta = exports.boldBlue = exports.dimBlue = exports.blue = exports.boldRed = exports.dimRed = exports.red = exports.boldGreen = exports.dimGreen = exports.green = exports.inverseYellow = exports.boldYellow = exports.dimYellow = exports.yellow = exports.boldGrey = exports.dimGrey = exports.grey = exports.inverseWhite = exports.boldWhite = exports.dimWhite = exports.white = exports.hasColors = exports.chalk = void 0;
4
- const tty = require("node:tty");
5
- const chalk = require("chalk");
6
- exports.chalk = chalk;
4
+ const tslib_1 = require("tslib");
5
+ const node_tty_1 = tslib_1.__importDefault(require("node:tty"));
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ exports.chalk = chalk_1.default;
7
8
  /**
8
9
  * Based on: https://github.com/sindresorhus/yoctocolors/pull/5
9
10
  *
10
11
  * @experimental
11
12
  */
12
- exports.hasColors = !process.env['NO_COLOR'] && tty.WriteStream.prototype.hasColors();
13
+ exports.hasColors = !process.env['NO_COLOR'] && node_tty_1.default.WriteStream.prototype.hasColors();
13
14
  // The point of re-exporting is:
14
15
  // 1. Fix typings to allow to pass `number` (very common case)
15
16
  // 2. Easier/shorter to import, rather than from 'chalk'
16
17
  // export type ColorFn = (...args: (string | number)[]) => string
17
- exports.white = chalk.white;
18
- exports.dimWhite = chalk.dim.white;
19
- exports.boldWhite = chalk.bold.white;
20
- exports.inverseWhite = chalk.inverse.white;
21
- exports.grey = chalk.grey;
22
- exports.dimGrey = chalk.dim.grey;
23
- exports.boldGrey = chalk.bold.grey;
24
- exports.yellow = chalk.yellow;
25
- exports.dimYellow = chalk.dim.yellow;
26
- exports.boldYellow = chalk.bold.yellow;
27
- exports.inverseYellow = chalk.inverse.yellow;
28
- exports.green = chalk.green;
29
- exports.dimGreen = chalk.dim.green;
30
- exports.boldGreen = chalk.bold.green;
31
- exports.red = chalk.red;
32
- exports.dimRed = chalk.dim.red;
33
- exports.boldRed = chalk.bold.red;
34
- exports.blue = chalk.blue;
35
- exports.dimBlue = chalk.dim.blue;
36
- exports.boldBlue = chalk.bold.blue;
37
- exports.magenta = chalk.magenta;
38
- exports.dimMagenta = chalk.dim.magenta;
39
- exports.boldMagenta = chalk.bold.magenta;
40
- exports.cyan = chalk.cyan;
41
- exports.dimCyan = chalk.dim.cyan;
42
- exports.boldCyan = chalk.bold.cyan;
18
+ exports.white = chalk_1.default.white;
19
+ exports.dimWhite = chalk_1.default.dim.white;
20
+ exports.boldWhite = chalk_1.default.bold.white;
21
+ exports.inverseWhite = chalk_1.default.inverse.white;
22
+ exports.grey = chalk_1.default.grey;
23
+ exports.dimGrey = chalk_1.default.dim.grey;
24
+ exports.boldGrey = chalk_1.default.bold.grey;
25
+ exports.yellow = chalk_1.default.yellow;
26
+ exports.dimYellow = chalk_1.default.dim.yellow;
27
+ exports.boldYellow = chalk_1.default.bold.yellow;
28
+ exports.inverseYellow = chalk_1.default.inverse.yellow;
29
+ exports.green = chalk_1.default.green;
30
+ exports.dimGreen = chalk_1.default.dim.green;
31
+ exports.boldGreen = chalk_1.default.bold.green;
32
+ exports.red = chalk_1.default.red;
33
+ exports.dimRed = chalk_1.default.dim.red;
34
+ exports.boldRed = chalk_1.default.bold.red;
35
+ exports.blue = chalk_1.default.blue;
36
+ exports.dimBlue = chalk_1.default.dim.blue;
37
+ exports.boldBlue = chalk_1.default.bold.blue;
38
+ exports.magenta = chalk_1.default.magenta;
39
+ exports.dimMagenta = chalk_1.default.dim.magenta;
40
+ exports.boldMagenta = chalk_1.default.bold.magenta;
41
+ exports.cyan = chalk_1.default.cyan;
42
+ exports.dimCyan = chalk_1.default.dim.cyan;
43
+ exports.boldCyan = chalk_1.default.bold.cyan;
package/dist/fs/del.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.delSync = exports.del = void 0;
4
- const fs = require("node:fs");
5
- const fsp = require("node:fs/promises");
4
+ const tslib_1 = require("tslib");
5
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
6
7
  const js_lib_1 = require("@naturalcycles/js-lib");
7
8
  const colors_1 = require("../colors/colors");
8
9
  const index_1 = require("../index");
@@ -43,7 +44,7 @@ async function del(_opt) {
43
44
  }
44
45
  if (dry)
45
46
  return;
46
- await (0, js_lib_1.pMap)(filenames, filepath => fsp.rm(filepath, {
47
+ await (0, js_lib_1.pMap)(filenames, filepath => promises_1.default.rm(filepath, {
47
48
  force: true,
48
49
  }), { concurrency });
49
50
  // 2. glob only dirs, expand, delete only empty!
@@ -54,7 +55,7 @@ async function del(_opt) {
54
55
  });
55
56
  // Add original patterns (if any of them are dirs)
56
57
  dirnames = dirnames.concat(await (0, js_lib_1.pFilter)(patterns, async (pattern) => {
57
- return (await (0, index_1._pathExists)(pattern)) && (await fsp.lstat(pattern)).isDirectory();
58
+ return (await (0, index_1._pathExists)(pattern)) && (await promises_1.default.lstat(pattern)).isDirectory();
58
59
  }));
59
60
  const dirnamesSorted = dirnames.sort().reverse();
60
61
  // console.log({ dirnamesSorted })
@@ -62,7 +63,7 @@ async function del(_opt) {
62
63
  for await (const dirpath of dirnamesSorted) {
63
64
  if (await isEmptyDir(dirpath)) {
64
65
  // console.log(`empty dir: ${dirpath}`)
65
- await fsp.rm(dirpath, { force: true, recursive: true });
66
+ await promises_1.default.rm(dirpath, { force: true, recursive: true });
66
67
  deletedDirs.push(dirpath);
67
68
  }
68
69
  }
@@ -100,7 +101,7 @@ function delSync(_opt) {
100
101
  }
101
102
  if (dry)
102
103
  return;
103
- filenames.forEach(filepath => fs.rmSync(filepath, { force: true }));
104
+ filenames.forEach(filepath => node_fs_1.default.rmSync(filepath, { force: true }));
104
105
  // 2. glob only dirs, expand, delete only empty!
105
106
  let dirnames = index_1.globby.sync(patterns, {
106
107
  dot: true,
@@ -108,14 +109,14 @@ function delSync(_opt) {
108
109
  onlyDirectories: true,
109
110
  });
110
111
  // Add original patterns (if any of them are dirs)
111
- dirnames = dirnames.concat(patterns.filter(p => (0, index_1._pathExistsSync)(p) && fs.lstatSync(p).isDirectory()));
112
+ dirnames = dirnames.concat(patterns.filter(p => (0, index_1._pathExistsSync)(p) && node_fs_1.default.lstatSync(p).isDirectory()));
112
113
  const dirnamesSorted = dirnames.sort().reverse();
113
114
  // console.log({ dirnamesSorted })
114
115
  const deletedDirs = [];
115
116
  for (const dirpath of dirnamesSorted) {
116
117
  if (isEmptyDirSync(dirpath)) {
117
118
  // console.log(`empty dir: ${dirpath}`)
118
- fs.rmSync(dirpath, { force: true, recursive: true });
119
+ node_fs_1.default.rmSync(dirpath, { force: true, recursive: true });
119
120
  deletedDirs.push(dirpath);
120
121
  }
121
122
  }
@@ -131,8 +132,8 @@ exports.delSync = delSync;
131
132
  // 2. glob only dirs, expand, delete only empty!
132
133
  // 3. test each original pattern, if it exists and is directory and is empty - delete
133
134
  async function isEmptyDir(dir) {
134
- return (await fsp.readdir(dir)).length === 0;
135
+ return (await promises_1.default.readdir(dir)).length === 0;
135
136
  }
136
137
  function isEmptyDirSync(dir) {
137
- return fs.readdirSync(dir).length === 0;
138
+ return node_fs_1.default.readdirSync(dir).length === 0;
138
139
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- import * as fs from 'node:fs';
4
+ import fs from 'node:fs';
5
5
  /**
6
6
  * fs2 conveniently groups filesystem functions together.
7
7
  * Supposed to be almost a drop-in replacement for these things together:
@@ -16,9 +16,10 @@ Credit to: fs-extra (https://github.com/jprichardson/node-fs-extra)
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports._movePathSync = exports._movePath = exports._copyPathSync = exports._copyPath = exports._emptyDirSync = exports._emptyDir = exports._removePathSync = exports._removePath = exports._ensureFileSync = exports._ensureFile = exports._ensureDirSync = exports._ensureDir = exports._pathExistsSync = exports._pathExists = exports._outputJsonSync = exports._outputJson = exports._writeJsonSync = exports._writeJson = exports._outputFileSync = exports._outputFile = exports._writeFileSync = exports._writeFile = exports._readJsonSync = exports._readJson = exports._readFileAsBufferSync = exports._readFileSync = exports._readFileAsBuffer = exports._readFile = exports.fs2 = void 0;
19
- const fs = require("node:fs");
20
- const fsp = require("node:fs/promises");
21
- const path = require("node:path");
19
+ const tslib_1 = require("tslib");
20
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
21
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
22
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
22
23
  const js_lib_1 = require("@naturalcycles/js-lib");
23
24
  /**
24
25
  * fs2 conveniently groups filesystem functions together.
@@ -31,7 +32,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
31
32
  exports.fs2 = {
32
33
  // "Omit" is here to workaround this TS error:
33
34
  // Exported variable 'fs2' has or is using name 'StreamOptions' from external module "fs" but cannot be named.
34
- ...fs,
35
+ ...node_fs_1.default,
35
36
  readFile: _readFile,
36
37
  readFileSync: _readFileSync,
37
38
  readFileAsBuffer: _readFileAsBuffer,
@@ -65,59 +66,59 @@ exports.fs2 = {
65
66
  * Convenience wrapper that defaults to utf-8 string output.
66
67
  */
67
68
  async function _readFile(filePath) {
68
- return await fsp.readFile(filePath, 'utf8');
69
+ return await promises_1.default.readFile(filePath, 'utf8');
69
70
  }
70
71
  exports._readFile = _readFile;
71
72
  async function _readFileAsBuffer(filePath) {
72
- return await fsp.readFile(filePath);
73
+ return await promises_1.default.readFile(filePath);
73
74
  }
74
75
  exports._readFileAsBuffer = _readFileAsBuffer;
75
76
  /**
76
77
  * Convenience wrapper that defaults to utf-8 string output.
77
78
  */
78
79
  function _readFileSync(filePath) {
79
- return fs.readFileSync(filePath, 'utf8');
80
+ return node_fs_1.default.readFileSync(filePath, 'utf8');
80
81
  }
81
82
  exports._readFileSync = _readFileSync;
82
83
  /**
83
84
  * Convenience wrapper that defaults to utf-8 string output.
84
85
  */
85
86
  function _readFileAsBufferSync(filePath) {
86
- return fs.readFileSync(filePath);
87
+ return node_fs_1.default.readFileSync(filePath);
87
88
  }
88
89
  exports._readFileAsBufferSync = _readFileAsBufferSync;
89
90
  async function _readJson(filePath) {
90
- const str = await fsp.readFile(filePath, 'utf8');
91
+ const str = await promises_1.default.readFile(filePath, 'utf8');
91
92
  return (0, js_lib_1._jsonParse)(str);
92
93
  }
93
94
  exports._readJson = _readJson;
94
95
  function _readJsonSync(filePath) {
95
- const str = fs.readFileSync(filePath, 'utf8');
96
+ const str = node_fs_1.default.readFileSync(filePath, 'utf8');
96
97
  return (0, js_lib_1._jsonParse)(str);
97
98
  }
98
99
  exports._readJsonSync = _readJsonSync;
99
100
  async function _writeFile(filePath, data) {
100
- await fsp.writeFile(filePath, data);
101
+ await promises_1.default.writeFile(filePath, data);
101
102
  }
102
103
  exports._writeFile = _writeFile;
103
104
  function _writeFileSync(filePath, data) {
104
- fs.writeFileSync(filePath, data);
105
+ node_fs_1.default.writeFileSync(filePath, data);
105
106
  }
106
107
  exports._writeFileSync = _writeFileSync;
107
108
  async function _outputFile(filePath, data) {
108
- const dirPath = path.dirname(filePath);
109
+ const dirPath = node_path_1.default.dirname(filePath);
109
110
  if (!(await _pathExists(dirPath))) {
110
111
  await _ensureDir(dirPath);
111
112
  }
112
- await fsp.writeFile(filePath, data);
113
+ await promises_1.default.writeFile(filePath, data);
113
114
  }
114
115
  exports._outputFile = _outputFile;
115
116
  function _outputFileSync(filePath, data) {
116
- const dirPath = path.dirname(filePath);
117
- if (!fs.existsSync(dirPath)) {
117
+ const dirPath = node_path_1.default.dirname(filePath);
118
+ if (!node_fs_1.default.existsSync(dirPath)) {
118
119
  _ensureDirSync(dirPath);
119
120
  }
120
- fs.writeFileSync(filePath, data);
121
+ node_fs_1.default.writeFileSync(filePath, data);
121
122
  }
122
123
  exports._outputFileSync = _outputFileSync;
123
124
  function stringify(data, opt) {
@@ -126,12 +127,12 @@ function stringify(data, opt) {
126
127
  }
127
128
  async function _writeJson(filePath, data, opt) {
128
129
  const str = stringify(data, opt);
129
- await fsp.writeFile(filePath, str);
130
+ await promises_1.default.writeFile(filePath, str);
130
131
  }
131
132
  exports._writeJson = _writeJson;
132
133
  function _writeJsonSync(filePath, data, opt) {
133
134
  const str = stringify(data, opt);
134
- fs.writeFileSync(filePath, str);
135
+ node_fs_1.default.writeFileSync(filePath, str);
135
136
  }
136
137
  exports._writeJsonSync = _writeJsonSync;
137
138
  async function _outputJson(filePath, data, opt) {
@@ -146,7 +147,7 @@ function _outputJsonSync(filePath, data, opt) {
146
147
  exports._outputJsonSync = _outputJsonSync;
147
148
  async function _pathExists(filePath) {
148
149
  try {
149
- await fsp.access(filePath);
150
+ await promises_1.default.access(filePath);
150
151
  return true;
151
152
  }
152
153
  catch {
@@ -155,18 +156,18 @@ async function _pathExists(filePath) {
155
156
  }
156
157
  exports._pathExists = _pathExists;
157
158
  function _pathExistsSync(filePath) {
158
- return fs.existsSync(filePath);
159
+ return node_fs_1.default.existsSync(filePath);
159
160
  }
160
161
  exports._pathExistsSync = _pathExistsSync;
161
162
  async function _ensureDir(dirPath) {
162
- await fsp.mkdir(dirPath, {
163
+ await promises_1.default.mkdir(dirPath, {
163
164
  mode: 0o777,
164
165
  recursive: true,
165
166
  });
166
167
  }
167
168
  exports._ensureDir = _ensureDir;
168
169
  function _ensureDirSync(dirPath) {
169
- fs.mkdirSync(dirPath, {
170
+ node_fs_1.default.mkdirSync(dirPath, {
170
171
  mode: 0o777,
171
172
  recursive: true,
172
173
  });
@@ -175,17 +176,17 @@ exports._ensureDirSync = _ensureDirSync;
175
176
  async function _ensureFile(filePath) {
176
177
  let stats;
177
178
  try {
178
- stats = await fsp.stat(filePath);
179
+ stats = await promises_1.default.stat(filePath);
179
180
  }
180
181
  catch { }
181
182
  if (stats?.isFile())
182
183
  return;
183
- const dir = path.dirname(filePath);
184
+ const dir = node_path_1.default.dirname(filePath);
184
185
  try {
185
- if (!(await fsp.stat(dir)).isDirectory()) {
186
+ if (!(await promises_1.default.stat(dir)).isDirectory()) {
186
187
  // parent is not a directory
187
188
  // This is just to cause an internal ENOTDIR error to be thrown
188
- await fsp.readdir(dir);
189
+ await promises_1.default.readdir(dir);
189
190
  }
190
191
  }
191
192
  catch (err) {
@@ -194,23 +195,23 @@ async function _ensureFile(filePath) {
194
195
  return await _ensureDir(dir);
195
196
  throw err;
196
197
  }
197
- await fsp.writeFile(filePath, '');
198
+ await promises_1.default.writeFile(filePath, '');
198
199
  }
199
200
  exports._ensureFile = _ensureFile;
200
201
  function _ensureFileSync(filePath) {
201
202
  let stats;
202
203
  try {
203
- stats = fs.statSync(filePath);
204
+ stats = node_fs_1.default.statSync(filePath);
204
205
  }
205
206
  catch { }
206
207
  if (stats?.isFile())
207
208
  return;
208
- const dir = path.dirname(filePath);
209
+ const dir = node_path_1.default.dirname(filePath);
209
210
  try {
210
- if (!fs.statSync(dir).isDirectory()) {
211
+ if (!node_fs_1.default.statSync(dir).isDirectory()) {
211
212
  // parent is not a directory
212
213
  // This is just to cause an internal ENOTDIR error to be thrown
213
- fs.readdirSync(dir);
214
+ node_fs_1.default.readdirSync(dir);
214
215
  }
215
216
  }
216
217
  catch (err) {
@@ -219,44 +220,44 @@ function _ensureFileSync(filePath) {
219
220
  return _ensureDirSync(dir);
220
221
  throw err;
221
222
  }
222
- fs.writeFileSync(filePath, '');
223
+ node_fs_1.default.writeFileSync(filePath, '');
223
224
  }
224
225
  exports._ensureFileSync = _ensureFileSync;
225
226
  async function _removePath(fileOrDirPath) {
226
- await fsp.rm(fileOrDirPath, { recursive: true, force: true });
227
+ await promises_1.default.rm(fileOrDirPath, { recursive: true, force: true });
227
228
  }
228
229
  exports._removePath = _removePath;
229
230
  function _removePathSync(fileOrDirPath) {
230
- fs.rmSync(fileOrDirPath, { recursive: true, force: true });
231
+ node_fs_1.default.rmSync(fileOrDirPath, { recursive: true, force: true });
231
232
  }
232
233
  exports._removePathSync = _removePathSync;
233
234
  async function _emptyDir(dirPath) {
234
235
  let items;
235
236
  try {
236
- items = await fsp.readdir(dirPath);
237
+ items = await promises_1.default.readdir(dirPath);
237
238
  }
238
239
  catch {
239
240
  return await _ensureDir(dirPath);
240
241
  }
241
- await Promise.all(items.map(item => _removePath(path.join(dirPath, item))));
242
+ await Promise.all(items.map(item => _removePath(node_path_1.default.join(dirPath, item))));
242
243
  }
243
244
  exports._emptyDir = _emptyDir;
244
245
  function _emptyDirSync(dirPath) {
245
246
  let items;
246
247
  try {
247
- items = fs.readdirSync(dirPath);
248
+ items = node_fs_1.default.readdirSync(dirPath);
248
249
  }
249
250
  catch {
250
251
  return _ensureDirSync(dirPath);
251
252
  }
252
- items.forEach(item => _removePathSync(path.join(dirPath, item)));
253
+ items.forEach(item => _removePathSync(node_path_1.default.join(dirPath, item)));
253
254
  }
254
255
  exports._emptyDirSync = _emptyDirSync;
255
256
  /**
256
257
  * Cautious, underlying Node function is currently Experimental.
257
258
  */
258
259
  async function _copyPath(src, dest, opt) {
259
- await fsp.cp(src, dest, {
260
+ await promises_1.default.cp(src, dest, {
260
261
  recursive: true,
261
262
  ...opt,
262
263
  });
@@ -266,7 +267,7 @@ exports._copyPath = _copyPath;
266
267
  * Cautious, underlying Node function is currently Experimental.
267
268
  */
268
269
  function _copyPathSync(src, dest, opt) {
269
- fs.cpSync(src, dest, {
270
+ node_fs_1.default.cpSync(src, dest, {
270
271
  recursive: true,
271
272
  ...opt,
272
273
  });
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.objectToGithubActionsEnv = exports.objectToShellExport = exports.appendToGithubSummary = exports.appendToGithubOutput = exports.appendToGithubEnv = exports.appendToBashEnv = exports.json2env = void 0;
4
- const fs = require("node:fs");
4
+ const tslib_1 = require("tslib");
5
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
5
6
  const colors_1 = require("../colors/colors");
6
7
  const fs_util_1 = require("./fs.util");
7
8
  const JSON2ENV_OPT_DEF = {
@@ -54,7 +55,7 @@ function appendToBashEnv(obj, prefix = '') {
54
55
  const { BASH_ENV } = process.env;
55
56
  if (BASH_ENV) {
56
57
  const data = objectToShellExport(obj, prefix);
57
- fs.appendFileSync(BASH_ENV, data);
58
+ node_fs_1.default.appendFileSync(BASH_ENV, data);
58
59
  console.log(`BASH_ENV appended:\n${data}`);
59
60
  }
60
61
  }
@@ -63,7 +64,7 @@ function appendToGithubEnv(obj, prefix = '') {
63
64
  const { GITHUB_ENV } = process.env;
64
65
  if (GITHUB_ENV) {
65
66
  const data = objectToGithubActionsEnv(obj, prefix);
66
- fs.appendFileSync(GITHUB_ENV, data);
67
+ node_fs_1.default.appendFileSync(GITHUB_ENV, data);
67
68
  console.log(`GITHUB_ENV appended:\n${data}`);
68
69
  }
69
70
  }
@@ -72,7 +73,7 @@ function appendToGithubOutput(obj, prefix = '') {
72
73
  const { GITHUB_OUTPUT } = process.env;
73
74
  if (GITHUB_OUTPUT) {
74
75
  const data = objectToGithubActionsEnv(obj, prefix);
75
- fs.appendFileSync(GITHUB_OUTPUT, data);
76
+ node_fs_1.default.appendFileSync(GITHUB_OUTPUT, data);
76
77
  console.log(`GITHUB_OUTPUT appended:\n${data}`);
77
78
  }
78
79
  }
@@ -83,7 +84,7 @@ exports.appendToGithubOutput = appendToGithubOutput;
83
84
  function appendToGithubSummary(str) {
84
85
  const { GITHUB_STEP_SUMMARY } = process.env;
85
86
  if (GITHUB_STEP_SUMMARY) {
86
- fs.appendFileSync(GITHUB_STEP_SUMMARY, str + '\n');
87
+ node_fs_1.default.appendFileSync(GITHUB_STEP_SUMMARY, str + '\n');
87
88
  console.log(`GITHUB_STEP_SUMMARY appended:\n${str}`);
88
89
  }
89
90
  }