@naturalcycles/nodejs-lib 13.45.4 → 14.0.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 (197) hide show
  1. package/dist/bin/generate-build-info.js +15 -18
  2. package/dist/bin/json2env.js +6 -9
  3. package/dist/bin/kpy.js +6 -9
  4. package/dist/bin/secrets-decrypt.d.ts +1 -1
  5. package/dist/bin/secrets-decrypt.js +9 -12
  6. package/dist/bin/secrets-encrypt.d.ts +1 -1
  7. package/dist/bin/secrets-encrypt.js +9 -12
  8. package/dist/bin/secrets-gen-key.js +8 -11
  9. package/dist/bin/slack-this.js +6 -9
  10. package/dist/buffer/buffer.util.js +1 -4
  11. package/dist/colors/colors.d.ts +26 -27
  12. package/dist/colors/colors.js +29 -33
  13. package/dist/csv/csvReader.js +4 -8
  14. package/dist/csv/csvWriter.js +6 -12
  15. package/dist/csv/transformToCSV.d.ts +2 -2
  16. package/dist/csv/transformToCSV.js +5 -8
  17. package/dist/diff/tableDiff.js +4 -7
  18. package/dist/fs/fs2.d.ts +1 -1
  19. package/dist/fs/fs2.js +82 -86
  20. package/dist/fs/json2env.js +18 -28
  21. package/dist/fs/kpy.js +28 -33
  22. package/dist/index.d.ts +71 -71
  23. package/dist/index.js +73 -78
  24. package/dist/infra/process.util.js +22 -28
  25. package/dist/jwt/jwt.service.js +16 -21
  26. package/dist/log/log.util.js +4 -7
  27. package/dist/script/runScript.js +11 -15
  28. package/dist/secret/secrets-decrypt.util.js +18 -22
  29. package/dist/secret/secrets-encrypt.util.js +17 -21
  30. package/dist/security/crypto.util.js +24 -34
  31. package/dist/security/hash.util.js +19 -37
  32. package/dist/security/id.util.js +11 -18
  33. package/dist/security/nanoid.js +15 -20
  34. package/dist/security/secret.util.js +20 -30
  35. package/dist/slack/slack.service.d.ts +1 -1
  36. package/dist/slack/slack.service.js +11 -16
  37. package/dist/slack/slack.service.model.d.ts +1 -1
  38. package/dist/slack/slack.service.model.js +1 -2
  39. package/dist/stream/ndjson/ndjson.model.js +7 -11
  40. package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
  41. package/dist/stream/ndjson/ndjsonMap.js +11 -14
  42. package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +1 -1
  43. package/dist/stream/ndjson/ndjsonStreamForEach.js +9 -12
  44. package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
  45. package/dist/stream/ndjson/transformJsonParse.js +4 -9
  46. package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
  47. package/dist/stream/ndjson/transformToNDJson.js +5 -8
  48. package/dist/stream/pipeline/pipeline.js +11 -17
  49. package/dist/stream/progressLogger.d.ts +1 -1
  50. package/dist/stream/progressLogger.js +22 -28
  51. package/dist/stream/readable/readableCreate.d.ts +1 -1
  52. package/dist/stream/readable/readableCreate.js +5 -9
  53. package/dist/stream/readable/readableForEach.d.ts +2 -2
  54. package/dist/stream/readable/readableForEach.js +7 -11
  55. package/dist/stream/readable/readableFromArray.d.ts +1 -1
  56. package/dist/stream/readable/readableFromArray.js +4 -7
  57. package/dist/stream/readable/readableToArray.d.ts +1 -1
  58. package/dist/stream/readable/readableToArray.js +1 -4
  59. package/dist/stream/sizeStack.js +7 -11
  60. package/dist/stream/stream.model.js +1 -2
  61. package/dist/stream/stream.util.js +1 -4
  62. package/dist/stream/transform/transformChunk.d.ts +1 -1
  63. package/dist/stream/transform/transformChunk.js +3 -6
  64. package/dist/stream/transform/transformFilter.d.ts +2 -2
  65. package/dist/stream/transform/transformFilter.js +6 -10
  66. package/dist/stream/transform/transformLimit.d.ts +2 -2
  67. package/dist/stream/transform/transformLimit.js +6 -11
  68. package/dist/stream/transform/transformLogProgress.d.ts +2 -2
  69. package/dist/stream/transform/transformLogProgress.js +5 -8
  70. package/dist/stream/transform/transformMap.d.ts +1 -1
  71. package/dist/stream/transform/transformMap.js +18 -22
  72. package/dist/stream/transform/transformMapSimple.d.ts +1 -1
  73. package/dist/stream/transform/transformMapSimple.js +6 -9
  74. package/dist/stream/transform/transformMapSync.d.ts +3 -3
  75. package/dist/stream/transform/transformMapSync.js +14 -19
  76. package/dist/stream/transform/transformNoOp.d.ts +1 -1
  77. package/dist/stream/transform/transformNoOp.js +3 -6
  78. package/dist/stream/transform/transformOffset.d.ts +1 -1
  79. package/dist/stream/transform/transformOffset.js +5 -8
  80. package/dist/stream/transform/transformSplit.d.ts +1 -1
  81. package/dist/stream/transform/transformSplit.js +5 -9
  82. package/dist/stream/transform/transformTap.d.ts +1 -1
  83. package/dist/stream/transform/transformTap.js +3 -6
  84. package/dist/stream/transform/transformTee.d.ts +1 -1
  85. package/dist/stream/transform/transformTee.js +7 -10
  86. package/dist/stream/transform/transformThrottle.d.ts +1 -1
  87. package/dist/stream/transform/transformThrottle.js +9 -12
  88. package/dist/stream/transform/transformToArray.d.ts +1 -1
  89. package/dist/stream/transform/transformToArray.js +3 -6
  90. package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
  91. package/dist/stream/transform/worker/baseWorkerClass.js +1 -5
  92. package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
  93. package/dist/stream/transform/worker/transformMultiThreaded.js +12 -11
  94. package/dist/stream/transform/worker/transformMultiThreaded.model.js +1 -2
  95. package/dist/stream/transform/worker/workerClassProxy.js +6 -4
  96. package/dist/stream/writable/writableForEach.d.ts +2 -2
  97. package/dist/stream/writable/writableForEach.js +6 -10
  98. package/dist/stream/writable/writableFork.d.ts +1 -1
  99. package/dist/stream/writable/writableFork.js +6 -9
  100. package/dist/stream/writable/writableLimit.d.ts +1 -1
  101. package/dist/stream/writable/writableLimit.js +3 -6
  102. package/dist/stream/writable/writablePushToArray.d.ts +1 -1
  103. package/dist/stream/writable/writablePushToArray.js +3 -6
  104. package/dist/stream/writable/writableVoid.d.ts +1 -1
  105. package/dist/stream/writable/writableVoid.js +3 -6
  106. package/dist/string/inspect.js +8 -13
  107. package/dist/util/buildInfo.util.js +12 -15
  108. package/dist/util/env.util.js +5 -9
  109. package/dist/util/exec2.js +17 -21
  110. package/dist/util/git2.js +17 -20
  111. package/dist/util/lruMemoCache.js +3 -7
  112. package/dist/util/zip.util.js +14 -25
  113. package/dist/validation/ajv/ajv.util.d.ts +3 -3
  114. package/dist/validation/ajv/ajv.util.js +6 -10
  115. package/dist/validation/ajv/ajvSchema.d.ts +2 -2
  116. package/dist/validation/ajv/ajvSchema.js +14 -18
  117. package/dist/validation/ajv/ajvValidationError.js +2 -6
  118. package/dist/validation/ajv/getAjv.d.ts +1 -1
  119. package/dist/validation/ajv/getAjv.js +9 -9
  120. package/dist/validation/joi/joi.extensions.d.ts +2 -2
  121. package/dist/validation/joi/joi.extensions.js +6 -10
  122. package/dist/validation/joi/joi.model.js +1 -2
  123. package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
  124. package/dist/validation/joi/joi.shared.schemas.js +61 -74
  125. package/dist/validation/joi/joi.validation.error.js +2 -6
  126. package/dist/validation/joi/joi.validation.util.d.ts +1 -1
  127. package/dist/validation/joi/joi.validation.util.js +10 -17
  128. package/dist/validation/joi/number.extensions.js +1 -4
  129. package/dist/validation/joi/string.extensions.js +4 -7
  130. package/dist/yargs.util.js +5 -8
  131. package/package.json +5 -4
  132. package/src/bin/generate-build-info.ts +3 -3
  133. package/src/bin/json2env.ts +2 -2
  134. package/src/bin/kpy.ts +2 -2
  135. package/src/bin/secrets-decrypt.ts +7 -8
  136. package/src/bin/secrets-encrypt.ts +7 -8
  137. package/src/bin/secrets-gen-key.ts +2 -2
  138. package/src/bin/slack-this.ts +2 -2
  139. package/src/csv/transformToCSV.ts +3 -3
  140. package/src/fs/fs2.ts +4 -4
  141. package/src/fs/json2env.ts +2 -2
  142. package/src/fs/kpy.ts +2 -2
  143. package/src/index.ts +71 -71
  144. package/src/jwt/jwt.service.ts +2 -2
  145. package/src/log/log.util.ts +1 -1
  146. package/src/script/runScript.ts +4 -3
  147. package/src/secret/secrets-decrypt.util.ts +3 -3
  148. package/src/secret/secrets-encrypt.util.ts +3 -3
  149. package/src/security/crypto.util.ts +1 -1
  150. package/src/security/id.util.ts +1 -1
  151. package/src/security/secret.util.ts +2 -2
  152. package/src/slack/slack.service.model.ts +1 -1
  153. package/src/slack/slack.service.ts +3 -3
  154. package/src/stream/ndjson/ndjson.model.ts +1 -1
  155. package/src/stream/ndjson/ndjsonMap.ts +2 -2
  156. package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
  157. package/src/stream/ndjson/transformJsonParse.ts +1 -1
  158. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  159. package/src/stream/pipeline/pipeline.ts +1 -1
  160. package/src/stream/progressLogger.ts +3 -3
  161. package/src/stream/readable/readableCreate.ts +1 -1
  162. package/src/stream/readable/readableForEach.ts +4 -4
  163. package/src/stream/readable/readableFromArray.ts +1 -1
  164. package/src/stream/readable/readableToArray.ts +1 -1
  165. package/src/stream/sizeStack.ts +2 -2
  166. package/src/stream/transform/transformChunk.ts +1 -1
  167. package/src/stream/transform/transformFilter.ts +3 -3
  168. package/src/stream/transform/transformLimit.ts +3 -3
  169. package/src/stream/transform/transformLogProgress.ts +3 -3
  170. package/src/stream/transform/transformMap.ts +5 -5
  171. package/src/stream/transform/transformMapSimple.ts +1 -1
  172. package/src/stream/transform/transformMapSync.ts +5 -5
  173. package/src/stream/transform/transformNoOp.ts +1 -1
  174. package/src/stream/transform/transformOffset.ts +2 -2
  175. package/src/stream/transform/transformSplit.ts +1 -1
  176. package/src/stream/transform/transformTap.ts +1 -1
  177. package/src/stream/transform/transformTee.ts +3 -3
  178. package/src/stream/transform/transformThrottle.ts +1 -1
  179. package/src/stream/transform/transformToArray.ts +1 -1
  180. package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
  181. package/src/stream/transform/worker/transformMultiThreaded.ts +8 -3
  182. package/src/stream/transform/worker/workerClassProxy.js +6 -4
  183. package/src/stream/writable/writableForEach.ts +3 -3
  184. package/src/stream/writable/writableFork.ts +3 -3
  185. package/src/stream/writable/writableLimit.ts +1 -1
  186. package/src/stream/writable/writablePushToArray.ts +1 -1
  187. package/src/stream/writable/writableVoid.ts +1 -1
  188. package/src/util/buildInfo.util.ts +2 -2
  189. package/src/util/exec2.ts +1 -1
  190. package/src/util/git2.ts +2 -2
  191. package/src/validation/ajv/ajv.util.ts +4 -4
  192. package/src/validation/ajv/ajvSchema.ts +4 -5
  193. package/src/validation/ajv/getAjv.ts +7 -3
  194. package/src/validation/joi/joi.extensions.ts +4 -4
  195. package/src/validation/joi/joi.shared.schemas.ts +3 -3
  196. package/src/validation/joi/joi.validation.util.ts +2 -2
  197. package/src/yargs.util.ts +1 -0
@@ -1,15 +1,12 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
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"));
8
- const json2env_1 = require("../fs/json2env");
9
- const runScript_1 = require("../script/runScript");
10
- const buildInfo_util_1 = require("../util/buildInfo.util");
11
- (0, runScript_1.runScript)(async () => {
12
- const { dir, overrideTimestamp } = yargs_1.default.options({
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import yargs from 'yargs';
5
+ import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs/json2env.js';
6
+ import { runScript } from '../script/runScript.js';
7
+ import { generateBuildInfo } from '../util/buildInfo.util.js';
8
+ runScript(async () => {
9
+ const { dir, overrideTimestamp } = yargs.options({
13
10
  dir: {
14
11
  type: 'string',
15
12
  desc: 'Output directory',
@@ -19,16 +16,16 @@ const buildInfo_util_1 = require("../util/buildInfo.util");
19
16
  desc: 'This unix timestamp will be used instead of "current time"',
20
17
  },
21
18
  }).argv;
22
- const buildInfo = (0, buildInfo_util_1.generateBuildInfo)({
19
+ const buildInfo = generateBuildInfo({
23
20
  overrideTimestamp: overrideTimestamp,
24
21
  });
25
22
  console.log(buildInfo);
26
23
  if (dir)
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));
24
+ fs.mkdirSync(dir, { recursive: true });
25
+ const buildInfoPath = dir ? path.resolve(dir, 'buildInfo.json') : 'buildInfo.json';
26
+ fs.writeFileSync(buildInfoPath, JSON.stringify(buildInfo, null, 2));
30
27
  const prefix = 'buildInfo_';
31
- (0, json2env_1.appendToBashEnv)(buildInfo, prefix);
32
- (0, json2env_1.appendToGithubEnv)(buildInfo, prefix);
33
- (0, json2env_1.appendToGithubOutput)(buildInfo, prefix);
28
+ appendToBashEnv(buildInfo, prefix);
29
+ appendToGithubEnv(buildInfo, prefix);
30
+ appendToGithubOutput(buildInfo, prefix);
34
31
  });
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
- const json2env_1 = require("../fs/json2env");
7
- const runScript_1 = require("../script/runScript");
8
- (0, runScript_1.runScript)(() => {
9
- const { argv } = yargs_1.default.demandCommand(1).options({
2
+ import yargs from 'yargs';
3
+ import { json2env } from '../fs/json2env.js';
4
+ import { runScript } from '../script/runScript.js';
5
+ runScript(() => {
6
+ const { argv } = yargs.demandCommand(1).options({
10
7
  prefix: {
11
8
  type: 'string',
12
9
  },
@@ -41,7 +38,7 @@ const runScript_1 = require("../script/runScript");
41
38
  if (debug)
42
39
  console.log({ argv });
43
40
  const jsonPath = args[0];
44
- (0, json2env_1.json2env)({
41
+ json2env({
45
42
  jsonPath,
46
43
  prefix,
47
44
  saveEnvFile,
package/dist/bin/kpy.js CHANGED
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
- const kpy_1 = require("../fs/kpy");
7
- const runScript_1 = require("../script/runScript");
8
- (0, runScript_1.runScript)(() => {
9
- const { _: [baseDir, ...inputPatterns], ...opt } = yargs_1.default.demandCommand(2).options({
2
+ import yargs from 'yargs';
3
+ import { kpySync } from '../fs/kpy.js';
4
+ import { runScript } from '../script/runScript.js';
5
+ runScript(() => {
6
+ const { _: [baseDir, ...inputPatterns], ...opt } = yargs.demandCommand(2).options({
10
7
  silent: {
11
8
  type: 'boolean',
12
9
  desc: 'Suppress all text output',
@@ -50,5 +47,5 @@ const runScript_1 = require("../script/runScript");
50
47
  ...opt,
51
48
  noOverwrite: !opt.overwrite,
52
49
  };
53
- (0, kpy_1.kpySync)(kpyOpt);
50
+ kpySync(kpyOpt);
54
51
  });
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import 'dotenv/config';
@@ -1,18 +1,15 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
- const colors_1 = require("../colors/colors");
7
- const runScript_1 = require("../script/runScript");
8
- const secrets_decrypt_util_1 = require("../secret/secrets-decrypt.util");
9
- (0, runScript_1.runScript)(() => {
2
+ import 'dotenv/config';
3
+ import { dimGrey } from '../colors/colors.js';
4
+ import { runScript } from '../script/runScript.js';
5
+ import { secretsDecrypt } from '../secret/secrets-decrypt.util.js';
6
+ import { _yargs } from '../yargs.util.js';
7
+ runScript(() => {
10
8
  const { dir, file, encKeyBuffer, del, jsonMode } = getDecryptCLIOptions();
11
- (0, secrets_decrypt_util_1.secretsDecrypt)(dir, file, encKeyBuffer, del, jsonMode);
9
+ secretsDecrypt(dir, file, encKeyBuffer, del, jsonMode);
12
10
  });
13
11
  function getDecryptCLIOptions() {
14
- require('dotenv').config();
15
- let { dir, file, encKey, encKeyVar, del, jsonMode } = yargs_1.default.options({
12
+ let { dir, file, encKey, encKeyVar, del, jsonMode } = _yargs().options({
16
13
  dir: {
17
14
  type: 'array',
18
15
  desc: 'Directory with secrets. Can be many',
@@ -51,7 +48,7 @@ function getDecryptCLIOptions() {
51
48
  if (!encKey) {
52
49
  encKey = process.env[encKeyVar];
53
50
  if (encKey) {
54
- console.log(`using encKey from env.${(0, colors_1.dimGrey)(encKeyVar)}`);
51
+ console.log(`using encKey from env.${dimGrey(encKeyVar)}`);
55
52
  }
56
53
  else {
57
54
  throw new Error(`encKey is required. Can be provided as --encKey or env.SECRET_ENCRYPTION_KEY (see readme.md)`);
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import 'dotenv/config';
@@ -1,18 +1,15 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
- const colors_1 = require("../colors/colors");
7
- const runScript_1 = require("../script/runScript");
8
- const secrets_encrypt_util_1 = require("../secret/secrets-encrypt.util");
9
- (0, runScript_1.runScript)(() => {
2
+ import 'dotenv/config';
3
+ import { dimGrey } from '../colors/colors.js';
4
+ import { runScript } from '../script/runScript.js';
5
+ import { secretsEncrypt } from '../secret/secrets-encrypt.util.js';
6
+ import { _yargs } from '../yargs.util.js';
7
+ runScript(() => {
10
8
  const { pattern, file, encKeyBuffer, del, jsonMode } = getEncryptCLIOptions();
11
- (0, secrets_encrypt_util_1.secretsEncrypt)(pattern, file, encKeyBuffer, del, jsonMode);
9
+ secretsEncrypt(pattern, file, encKeyBuffer, del, jsonMode);
12
10
  });
13
11
  function getEncryptCLIOptions() {
14
- require('dotenv').config();
15
- let { pattern, file, encKey, encKeyVar, del, jsonMode } = yargs_1.default.options({
12
+ let { pattern, file, encKey, encKeyVar, del, jsonMode } = _yargs().options({
16
13
  pattern: {
17
14
  type: 'string',
18
15
  array: true,
@@ -53,7 +50,7 @@ function getEncryptCLIOptions() {
53
50
  if (!encKey) {
54
51
  encKey = process.env[encKeyVar];
55
52
  if (encKey) {
56
- console.log(`using encKey from process.env.${(0, colors_1.dimGrey)(encKeyVar)}`);
53
+ console.log(`using encKey from process.env.${dimGrey(encKeyVar)}`);
57
54
  }
58
55
  else {
59
56
  throw new Error(`encKey is required. Can be provided as --encKey or env.SECRET_ENCRYPTION_KEY (see readme.md)`);
@@ -1,17 +1,14 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const node_crypto_1 = require("node:crypto");
6
- const yargs_1 = tslib_1.__importDefault(require("yargs"));
7
- const colors_1 = require("../colors/colors");
8
- const runScript_1 = require("../script/runScript");
9
- (0, runScript_1.runScript)(() => {
10
- const { sizeBytes } = yargs_1.default.option('sizeBytes', {
2
+ import { randomBytes } from 'node:crypto';
3
+ import yargs from 'yargs';
4
+ import { dimGrey } from '../colors/colors.js';
5
+ import { runScript } from '../script/runScript.js';
6
+ runScript(() => {
7
+ const { sizeBytes } = yargs.option('sizeBytes', {
11
8
  type: 'number',
12
9
  default: 256,
13
10
  }).argv;
14
- const key = (0, node_crypto_1.randomBytes)(sizeBytes).toString('base64');
15
- console.log((0, colors_1.dimGrey)('\nSECRET_ENCRYPTION_KEY:\n'));
11
+ const key = randomBytes(sizeBytes).toString('base64');
12
+ console.log(dimGrey('\nSECRET_ENCRYPTION_KEY:\n'));
16
13
  console.log(key, '\n');
17
14
  });
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
- const __1 = require("..");
7
- const runScript_1 = require("../script/runScript");
8
- (0, runScript_1.runScript)(async () => {
9
- const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs_1.default.options({
2
+ import yargs from 'yargs';
3
+ import { SlackService } from '../index.js';
4
+ import { runScript } from '../script/runScript.js';
5
+ runScript(async () => {
6
+ const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs.options({
10
7
  channel: {
11
8
  type: 'string',
12
9
  demandOption: true,
@@ -32,7 +29,7 @@ const runScript_1 = require("../script/runScript");
32
29
  console.log(`Slack webhook is required, either via env.SLACK_WEBHOOK_URL or --webhook`);
33
30
  process.exit(1);
34
31
  }
35
- const slack = new __1.SlackService({
32
+ const slack = new SlackService({
36
33
  webhookUrl,
37
34
  });
38
35
  await slack.send({
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._chunkBuffer = _chunkBuffer;
4
1
  /**
5
2
  * Same as _chunk, but for Buffer.
6
3
  */
7
- function _chunkBuffer(buf, size) {
4
+ export function _chunkBuffer(buf, size) {
8
5
  const out = [];
9
6
  for (let i = 0; i < buf.length; i += size) {
10
7
  out.push(buf.subarray(i, i + size));
@@ -1,33 +1,32 @@
1
- import chalk from 'chalk';
2
1
  /**
3
2
  * Based on: https://github.com/sindresorhus/yoctocolors/pull/5
4
3
  *
5
4
  * @experimental
6
5
  */
7
6
  export declare const hasColors: boolean;
8
- export declare const white: chalk.Chalk;
9
- export declare const dimWhite: chalk.Chalk;
10
- export declare const boldWhite: chalk.Chalk;
11
- export declare const inverseWhite: chalk.Chalk;
12
- export declare const grey: chalk.Chalk;
13
- export declare const dimGrey: chalk.Chalk;
14
- export declare const boldGrey: chalk.Chalk;
15
- export declare const yellow: chalk.Chalk;
16
- export declare const dimYellow: chalk.Chalk;
17
- export declare const boldYellow: chalk.Chalk;
18
- export declare const inverseYellow: chalk.Chalk;
19
- export declare const green: chalk.Chalk;
20
- export declare const dimGreen: chalk.Chalk;
21
- export declare const boldGreen: chalk.Chalk;
22
- export declare const red: chalk.Chalk;
23
- export declare const dimRed: chalk.Chalk;
24
- export declare const boldRed: chalk.Chalk;
25
- export declare const blue: chalk.Chalk;
26
- export declare const dimBlue: chalk.Chalk;
27
- export declare const boldBlue: chalk.Chalk;
28
- export declare const magenta: chalk.Chalk;
29
- export declare const dimMagenta: chalk.Chalk;
30
- export declare const boldMagenta: chalk.Chalk;
31
- export declare const cyan: chalk.Chalk;
32
- export declare const dimCyan: chalk.Chalk;
33
- export declare const boldCyan: chalk.Chalk;
7
+ export declare const white: import("chalk").ChalkInstance;
8
+ export declare const dimWhite: import("chalk").ChalkInstance;
9
+ export declare const boldWhite: import("chalk").ChalkInstance;
10
+ export declare const inverseWhite: import("chalk").ChalkInstance;
11
+ export declare const grey: import("chalk").ChalkInstance;
12
+ export declare const dimGrey: import("chalk").ChalkInstance;
13
+ export declare const boldGrey: import("chalk").ChalkInstance;
14
+ export declare const yellow: import("chalk").ChalkInstance;
15
+ export declare const dimYellow: import("chalk").ChalkInstance;
16
+ export declare const boldYellow: import("chalk").ChalkInstance;
17
+ export declare const inverseYellow: import("chalk").ChalkInstance;
18
+ export declare const green: import("chalk").ChalkInstance;
19
+ export declare const dimGreen: import("chalk").ChalkInstance;
20
+ export declare const boldGreen: import("chalk").ChalkInstance;
21
+ export declare const red: import("chalk").ChalkInstance;
22
+ export declare const dimRed: import("chalk").ChalkInstance;
23
+ export declare const boldRed: import("chalk").ChalkInstance;
24
+ export declare const blue: import("chalk").ChalkInstance;
25
+ export declare const dimBlue: import("chalk").ChalkInstance;
26
+ export declare const boldBlue: import("chalk").ChalkInstance;
27
+ export declare const magenta: import("chalk").ChalkInstance;
28
+ export declare const dimMagenta: import("chalk").ChalkInstance;
29
+ export declare const boldMagenta: import("chalk").ChalkInstance;
30
+ export declare const cyan: import("chalk").ChalkInstance;
31
+ export declare const dimCyan: import("chalk").ChalkInstance;
32
+ export declare const boldCyan: import("chalk").ChalkInstance;
@@ -1,42 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 = void 0;
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"));
1
+ import tty from 'node:tty';
2
+ import chalk from 'chalk';
7
3
  /**
8
4
  * Based on: https://github.com/sindresorhus/yoctocolors/pull/5
9
5
  *
10
6
  * @experimental
11
7
  */
12
- exports.hasColors = !process.env['NO_COLOR'] && node_tty_1.default.WriteStream.prototype.hasColors();
8
+ export const hasColors = !process.env['NO_COLOR'] && tty.WriteStream.prototype.hasColors();
13
9
  // The point of re-exporting is:
14
10
  // 1. Fix typings to allow to pass `number` (very common case)
15
11
  // 2. Easier/shorter to import, rather than from 'chalk'
16
12
  // export type ColorFn = (...args: (string | number)[]) => string
17
- exports.white = chalk_1.default.white;
18
- exports.dimWhite = chalk_1.default.dim.white;
19
- exports.boldWhite = chalk_1.default.bold.white;
20
- exports.inverseWhite = chalk_1.default.inverse.white;
21
- exports.grey = chalk_1.default.grey;
22
- exports.dimGrey = chalk_1.default.dim.grey;
23
- exports.boldGrey = chalk_1.default.bold.grey;
24
- exports.yellow = chalk_1.default.yellow;
25
- exports.dimYellow = chalk_1.default.dim.yellow;
26
- exports.boldYellow = chalk_1.default.bold.yellow;
27
- exports.inverseYellow = chalk_1.default.inverse.yellow;
28
- exports.green = chalk_1.default.green;
29
- exports.dimGreen = chalk_1.default.dim.green;
30
- exports.boldGreen = chalk_1.default.bold.green;
31
- exports.red = chalk_1.default.red;
32
- exports.dimRed = chalk_1.default.dim.red;
33
- exports.boldRed = chalk_1.default.bold.red;
34
- exports.blue = chalk_1.default.blue;
35
- exports.dimBlue = chalk_1.default.dim.blue;
36
- exports.boldBlue = chalk_1.default.bold.blue;
37
- exports.magenta = chalk_1.default.magenta;
38
- exports.dimMagenta = chalk_1.default.dim.magenta;
39
- exports.boldMagenta = chalk_1.default.bold.magenta;
40
- exports.cyan = chalk_1.default.cyan;
41
- exports.dimCyan = chalk_1.default.dim.cyan;
42
- exports.boldCyan = chalk_1.default.bold.cyan;
13
+ export const white = chalk.white;
14
+ export const dimWhite = chalk.dim.white;
15
+ export const boldWhite = chalk.bold.white;
16
+ export const inverseWhite = chalk.inverse.white;
17
+ export const grey = chalk.grey;
18
+ export const dimGrey = chalk.dim.grey;
19
+ export const boldGrey = chalk.bold.grey;
20
+ export const yellow = chalk.yellow;
21
+ export const dimYellow = chalk.dim.yellow;
22
+ export const boldYellow = chalk.bold.yellow;
23
+ export const inverseYellow = chalk.inverse.yellow;
24
+ export const green = chalk.green;
25
+ export const dimGreen = chalk.dim.green;
26
+ export const boldGreen = chalk.bold.green;
27
+ export const red = chalk.red;
28
+ export const dimRed = chalk.dim.red;
29
+ export const boldRed = chalk.bold.red;
30
+ export const blue = chalk.blue;
31
+ export const dimBlue = chalk.dim.blue;
32
+ export const boldBlue = chalk.bold.blue;
33
+ export const magenta = chalk.magenta;
34
+ export const dimMagenta = chalk.dim.magenta;
35
+ export const boldMagenta = chalk.bold.magenta;
36
+ export const cyan = chalk.cyan;
37
+ export const dimCyan = chalk.dim.cyan;
38
+ export const boldCyan = chalk.bold.cyan;
@@ -1,9 +1,5 @@
1
- "use strict";
2
1
  // Inspired by: https://gist.github.com/Jezternz/c8e9fafc2c114e079829974e3764db75
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.csvStringParse = csvStringParse;
5
- exports.csvStringToArray = csvStringToArray;
6
- const js_lib_1 = require("@naturalcycles/js-lib");
2
+ import { _assert } from '@naturalcycles/js-lib';
7
3
  // export class CSVReader {
8
4
  // constructor (cfg: CSVReaderConfig) {
9
5
  // this.cfg = {
@@ -15,7 +11,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
15
11
  //
16
12
  // public cfg: Required<CSVReaderConfig>
17
13
  // }
18
- function csvStringParse(str, cfg = {}) {
14
+ export function csvStringParse(str, cfg = {}) {
19
15
  const { firstRowIsHeader = true, columns } = cfg;
20
16
  const arr = csvStringToArray(str);
21
17
  let header = columns;
@@ -23,7 +19,7 @@ function csvStringParse(str, cfg = {}) {
23
19
  const firstRow = arr.shift();
24
20
  header ||= firstRow;
25
21
  }
26
- (0, js_lib_1._assert)(header, `firstRowIsHeader or columns is required`);
22
+ _assert(header, `firstRowIsHeader or columns is required`);
27
23
  return arr.map(row => {
28
24
  // eslint-disable-next-line unicorn/no-array-reduce
29
25
  return header.reduce((obj, col, i) => {
@@ -33,7 +29,7 @@ function csvStringParse(str, cfg = {}) {
33
29
  }, {});
34
30
  });
35
31
  }
36
- function csvStringToArray(str) {
32
+ export function csvStringToArray(str) {
37
33
  const objPattern = /(,|\r?\n|\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^,\r\n]*))/gi;
38
34
  let matches;
39
35
  const arr = [[]];
@@ -1,11 +1,6 @@
1
- "use strict";
2
1
  // Inspired by: https://github.com/ryu1kn/csv-writer/
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CSVWriter = void 0;
5
- exports.arrayToCSVString = arrayToCSVString;
6
- exports.arrayToCSVColumns = arrayToCSVColumns;
7
- const js_lib_1 = require("@naturalcycles/js-lib");
8
- class CSVWriter {
2
+ import { _assert } from '@naturalcycles/js-lib';
3
+ export class CSVWriter {
9
4
  constructor(cfg) {
10
5
  this.cfg = {
11
6
  delimiter: ',',
@@ -24,11 +19,11 @@ class CSVWriter {
24
19
  return s + rows.map(row => this.writeRow(row)).join('\n');
25
20
  }
26
21
  writeHeader() {
27
- (0, js_lib_1._assert)(this.cfg.columns, 'CSVWriter cannot writeHeader, because columns were not provided');
22
+ _assert(this.cfg.columns, 'CSVWriter cannot writeHeader, because columns were not provided');
28
23
  return this.cfg.columns.map(col => this.quoteIfNeeded(col)).join(this.cfg.delimiter);
29
24
  }
30
25
  writeRow(row) {
31
- (0, js_lib_1._assert)(this.cfg.columns, 'CSVWriter cannot writeRow, because columns were not provided');
26
+ _assert(this.cfg.columns, 'CSVWriter cannot writeRow, because columns were not provided');
32
27
  return this.cfg.columns
33
28
  .map(col => this.quoteIfNeeded(String(row[col] ?? '')))
34
29
  .join(this.cfg.delimiter);
@@ -43,15 +38,14 @@ class CSVWriter {
43
38
  return s.includes(this.cfg.delimiter) || s.includes('"') || s.includes('\n') || s.includes('\r');
44
39
  }
45
40
  }
46
- exports.CSVWriter = CSVWriter;
47
- function arrayToCSVString(arr, cfg = {}) {
41
+ export function arrayToCSVString(arr, cfg = {}) {
48
42
  const writer = new CSVWriter(cfg);
49
43
  return writer.writeRows(arr);
50
44
  }
51
45
  /**
52
46
  * Iterates over the whole array and notes all possible columns.
53
47
  */
54
- function arrayToCSVColumns(arr) {
48
+ export function arrayToCSVColumns(arr) {
55
49
  const cols = new Set();
56
50
  arr.forEach(row => Object.keys(row).forEach(col => cols.add(col)));
57
51
  return [...cols];
@@ -1,6 +1,6 @@
1
1
  import type { AnyObject } from '@naturalcycles/js-lib';
2
- import type { TransformTyped } from '../stream/stream.model';
3
- import type { CSVWriterConfig } from './csvWriter';
2
+ import type { TransformTyped } from '../stream/stream.model.js';
3
+ import type { CSVWriterConfig } from './csvWriter.js';
4
4
  export interface TransformToCSVOptions extends CSVWriterConfig {
5
5
  /**
6
6
  * If true - will throw an error on stringify error
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformToCSV = transformToCSV;
4
- const node_stream_1 = require("node:stream");
5
- const csvWriter_1 = require("./csvWriter");
1
+ import { Transform } from 'node:stream';
2
+ import { CSVWriter } from './csvWriter.js';
6
3
  /**
7
4
  * Transforms objects (objectMode=true) into chunks \n-terminated CSV strings (readableObjectMode=false).
8
5
  */
9
- function transformToCSV(opt) {
6
+ export function transformToCSV(opt) {
10
7
  const { strict = true } = opt;
11
- const writer = new csvWriter_1.CSVWriter(opt);
8
+ const writer = new CSVWriter(opt);
12
9
  let firstRow = true;
13
- return new node_stream_1.Transform({
10
+ return new Transform({
14
11
  writableObjectMode: true,
15
12
  readableObjectMode: false,
16
13
  readableHighWaterMark: 64 * 1024,
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tableDiff = tableDiff;
4
- const js_lib_1 = require("@naturalcycles/js-lib");
1
+ import { _truncate } from '@naturalcycles/js-lib';
5
2
  /**
6
3
  * Compares 2 objects, logs their differences via `console.table`.
7
4
  *
@@ -9,15 +6,15 @@ const js_lib_1 = require("@naturalcycles/js-lib");
9
6
  *
10
7
  * Function is located in nodejs-lib (not js-lib), because it's planned to improve in the future and add e.g colors (via chalk).
11
8
  */
12
- function tableDiff(a, b, opt = {}) {
9
+ export function tableDiff(a, b, opt = {}) {
13
10
  const { maxFieldLen, aTitle = 'a', bTitle = 'b' } = opt;
14
11
  const diff = {};
15
12
  if (a && b && a !== b) {
16
13
  new Set([...Object.keys(a), ...Object.keys(b)]).forEach(k => {
17
14
  if (a[k] !== b[k]) {
18
15
  diff[k] = {
19
- [aTitle]: maxFieldLen && a[k] ? (0, js_lib_1._truncate)(String(a[k]), maxFieldLen) : a[k],
20
- [bTitle]: maxFieldLen && b[k] ? (0, js_lib_1._truncate)(String(b[k]), maxFieldLen) : b[k],
16
+ [aTitle]: maxFieldLen && a[k] ? _truncate(String(a[k]), maxFieldLen) : a[k],
17
+ [bTitle]: maxFieldLen && b[k] ? _truncate(String(b[k]), maxFieldLen) : b[k],
21
18
  };
22
19
  }
23
20
  });
package/dist/fs/fs2.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { RmOptions } from 'node:fs';
2
2
  import fs from 'node:fs';
3
3
  import type { DumpOptions } from 'js-yaml';
4
- import type { ReadableTyped, TransformTyped } from '../stream/stream.model';
4
+ import type { ReadableTyped, TransformTyped } from '../stream/stream.model.js';
5
5
  /**
6
6
  * fs2 conveniently groups filesystem functions together.
7
7
  * Supposed to be almost a drop-in replacement for these things together: