@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.
- package/dist/bin/generate-build-info.js +15 -18
- package/dist/bin/json2env.js +6 -9
- package/dist/bin/kpy.js +6 -9
- package/dist/bin/secrets-decrypt.d.ts +1 -1
- package/dist/bin/secrets-decrypt.js +9 -12
- package/dist/bin/secrets-encrypt.d.ts +1 -1
- package/dist/bin/secrets-encrypt.js +9 -12
- package/dist/bin/secrets-gen-key.js +8 -11
- package/dist/bin/slack-this.js +6 -9
- package/dist/buffer/buffer.util.js +1 -4
- package/dist/colors/colors.d.ts +26 -27
- package/dist/colors/colors.js +29 -33
- package/dist/csv/csvReader.js +4 -8
- package/dist/csv/csvWriter.js +6 -12
- package/dist/csv/transformToCSV.d.ts +2 -2
- package/dist/csv/transformToCSV.js +5 -8
- package/dist/diff/tableDiff.js +4 -7
- package/dist/fs/fs2.d.ts +1 -1
- package/dist/fs/fs2.js +82 -86
- package/dist/fs/json2env.js +18 -28
- package/dist/fs/kpy.js +28 -33
- package/dist/index.d.ts +71 -71
- package/dist/index.js +73 -78
- package/dist/infra/process.util.js +22 -28
- package/dist/jwt/jwt.service.js +16 -21
- package/dist/log/log.util.js +4 -7
- package/dist/script/runScript.js +11 -15
- package/dist/secret/secrets-decrypt.util.js +18 -22
- package/dist/secret/secrets-encrypt.util.js +17 -21
- package/dist/security/crypto.util.js +24 -34
- package/dist/security/hash.util.js +19 -37
- package/dist/security/id.util.js +11 -18
- package/dist/security/nanoid.js +15 -20
- package/dist/security/secret.util.js +20 -30
- package/dist/slack/slack.service.d.ts +1 -1
- package/dist/slack/slack.service.js +11 -16
- package/dist/slack/slack.service.model.d.ts +1 -1
- package/dist/slack/slack.service.model.js +1 -2
- package/dist/stream/ndjson/ndjson.model.js +7 -11
- package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonMap.js +11 -14
- package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonStreamForEach.js +9 -12
- package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
- package/dist/stream/ndjson/transformJsonParse.js +4 -9
- package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
- package/dist/stream/ndjson/transformToNDJson.js +5 -8
- package/dist/stream/pipeline/pipeline.js +11 -17
- package/dist/stream/progressLogger.d.ts +1 -1
- package/dist/stream/progressLogger.js +22 -28
- package/dist/stream/readable/readableCreate.d.ts +1 -1
- package/dist/stream/readable/readableCreate.js +5 -9
- package/dist/stream/readable/readableForEach.d.ts +2 -2
- package/dist/stream/readable/readableForEach.js +7 -11
- package/dist/stream/readable/readableFromArray.d.ts +1 -1
- package/dist/stream/readable/readableFromArray.js +4 -7
- package/dist/stream/readable/readableToArray.d.ts +1 -1
- package/dist/stream/readable/readableToArray.js +1 -4
- package/dist/stream/sizeStack.js +7 -11
- package/dist/stream/stream.model.js +1 -2
- package/dist/stream/stream.util.js +1 -4
- package/dist/stream/transform/transformChunk.d.ts +1 -1
- package/dist/stream/transform/transformChunk.js +3 -6
- package/dist/stream/transform/transformFilter.d.ts +2 -2
- package/dist/stream/transform/transformFilter.js +6 -10
- package/dist/stream/transform/transformLimit.d.ts +2 -2
- package/dist/stream/transform/transformLimit.js +6 -11
- package/dist/stream/transform/transformLogProgress.d.ts +2 -2
- package/dist/stream/transform/transformLogProgress.js +5 -8
- package/dist/stream/transform/transformMap.d.ts +1 -1
- package/dist/stream/transform/transformMap.js +18 -22
- package/dist/stream/transform/transformMapSimple.d.ts +1 -1
- package/dist/stream/transform/transformMapSimple.js +6 -9
- package/dist/stream/transform/transformMapSync.d.ts +3 -3
- package/dist/stream/transform/transformMapSync.js +14 -19
- package/dist/stream/transform/transformNoOp.d.ts +1 -1
- package/dist/stream/transform/transformNoOp.js +3 -6
- package/dist/stream/transform/transformOffset.d.ts +1 -1
- package/dist/stream/transform/transformOffset.js +5 -8
- package/dist/stream/transform/transformSplit.d.ts +1 -1
- package/dist/stream/transform/transformSplit.js +5 -9
- package/dist/stream/transform/transformTap.d.ts +1 -1
- package/dist/stream/transform/transformTap.js +3 -6
- package/dist/stream/transform/transformTee.d.ts +1 -1
- package/dist/stream/transform/transformTee.js +7 -10
- package/dist/stream/transform/transformThrottle.d.ts +1 -1
- package/dist/stream/transform/transformThrottle.js +9 -12
- package/dist/stream/transform/transformToArray.d.ts +1 -1
- package/dist/stream/transform/transformToArray.js +3 -6
- package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
- package/dist/stream/transform/worker/baseWorkerClass.js +1 -5
- package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
- package/dist/stream/transform/worker/transformMultiThreaded.js +12 -11
- package/dist/stream/transform/worker/transformMultiThreaded.model.js +1 -2
- package/dist/stream/transform/worker/workerClassProxy.js +6 -4
- package/dist/stream/writable/writableForEach.d.ts +2 -2
- package/dist/stream/writable/writableForEach.js +6 -10
- package/dist/stream/writable/writableFork.d.ts +1 -1
- package/dist/stream/writable/writableFork.js +6 -9
- package/dist/stream/writable/writableLimit.d.ts +1 -1
- package/dist/stream/writable/writableLimit.js +3 -6
- package/dist/stream/writable/writablePushToArray.d.ts +1 -1
- package/dist/stream/writable/writablePushToArray.js +3 -6
- package/dist/stream/writable/writableVoid.d.ts +1 -1
- package/dist/stream/writable/writableVoid.js +3 -6
- package/dist/string/inspect.js +8 -13
- package/dist/util/buildInfo.util.js +12 -15
- package/dist/util/env.util.js +5 -9
- package/dist/util/exec2.js +17 -21
- package/dist/util/git2.js +17 -20
- package/dist/util/lruMemoCache.js +3 -7
- package/dist/util/zip.util.js +14 -25
- package/dist/validation/ajv/ajv.util.d.ts +3 -3
- package/dist/validation/ajv/ajv.util.js +6 -10
- package/dist/validation/ajv/ajvSchema.d.ts +2 -2
- package/dist/validation/ajv/ajvSchema.js +14 -18
- package/dist/validation/ajv/ajvValidationError.js +2 -6
- package/dist/validation/ajv/getAjv.d.ts +1 -1
- package/dist/validation/ajv/getAjv.js +9 -9
- package/dist/validation/joi/joi.extensions.d.ts +2 -2
- package/dist/validation/joi/joi.extensions.js +6 -10
- package/dist/validation/joi/joi.model.js +1 -2
- package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
- package/dist/validation/joi/joi.shared.schemas.js +61 -74
- package/dist/validation/joi/joi.validation.error.js +2 -6
- package/dist/validation/joi/joi.validation.util.d.ts +1 -1
- package/dist/validation/joi/joi.validation.util.js +10 -17
- package/dist/validation/joi/number.extensions.js +1 -4
- package/dist/validation/joi/string.extensions.js +4 -7
- package/dist/yargs.util.js +5 -8
- package/package.json +5 -4
- package/src/bin/generate-build-info.ts +3 -3
- package/src/bin/json2env.ts +2 -2
- package/src/bin/kpy.ts +2 -2
- package/src/bin/secrets-decrypt.ts +7 -8
- package/src/bin/secrets-encrypt.ts +7 -8
- package/src/bin/secrets-gen-key.ts +2 -2
- package/src/bin/slack-this.ts +2 -2
- package/src/csv/transformToCSV.ts +3 -3
- package/src/fs/fs2.ts +4 -4
- package/src/fs/json2env.ts +2 -2
- package/src/fs/kpy.ts +2 -2
- package/src/index.ts +71 -71
- package/src/jwt/jwt.service.ts +2 -2
- package/src/log/log.util.ts +1 -1
- package/src/script/runScript.ts +4 -3
- package/src/secret/secrets-decrypt.util.ts +3 -3
- package/src/secret/secrets-encrypt.util.ts +3 -3
- package/src/security/crypto.util.ts +1 -1
- package/src/security/id.util.ts +1 -1
- package/src/security/secret.util.ts +2 -2
- package/src/slack/slack.service.model.ts +1 -1
- package/src/slack/slack.service.ts +3 -3
- package/src/stream/ndjson/ndjson.model.ts +1 -1
- package/src/stream/ndjson/ndjsonMap.ts +2 -2
- package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
- package/src/stream/ndjson/transformJsonParse.ts +1 -1
- package/src/stream/ndjson/transformToNDJson.ts +1 -1
- package/src/stream/pipeline/pipeline.ts +1 -1
- package/src/stream/progressLogger.ts +3 -3
- package/src/stream/readable/readableCreate.ts +1 -1
- package/src/stream/readable/readableForEach.ts +4 -4
- package/src/stream/readable/readableFromArray.ts +1 -1
- package/src/stream/readable/readableToArray.ts +1 -1
- package/src/stream/sizeStack.ts +2 -2
- package/src/stream/transform/transformChunk.ts +1 -1
- package/src/stream/transform/transformFilter.ts +3 -3
- package/src/stream/transform/transformLimit.ts +3 -3
- package/src/stream/transform/transformLogProgress.ts +3 -3
- package/src/stream/transform/transformMap.ts +5 -5
- package/src/stream/transform/transformMapSimple.ts +1 -1
- package/src/stream/transform/transformMapSync.ts +5 -5
- package/src/stream/transform/transformNoOp.ts +1 -1
- package/src/stream/transform/transformOffset.ts +2 -2
- package/src/stream/transform/transformSplit.ts +1 -1
- package/src/stream/transform/transformTap.ts +1 -1
- package/src/stream/transform/transformTee.ts +3 -3
- package/src/stream/transform/transformThrottle.ts +1 -1
- package/src/stream/transform/transformToArray.ts +1 -1
- package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
- package/src/stream/transform/worker/transformMultiThreaded.ts +8 -3
- package/src/stream/transform/worker/workerClassProxy.js +6 -4
- package/src/stream/writable/writableForEach.ts +3 -3
- package/src/stream/writable/writableFork.ts +3 -3
- package/src/stream/writable/writableLimit.ts +1 -1
- package/src/stream/writable/writablePushToArray.ts +1 -1
- package/src/stream/writable/writableVoid.ts +1 -1
- package/src/util/buildInfo.util.ts +2 -2
- package/src/util/exec2.ts +1 -1
- package/src/util/git2.ts +2 -2
- package/src/validation/ajv/ajv.util.ts +4 -4
- package/src/validation/ajv/ajvSchema.ts +4 -5
- package/src/validation/ajv/getAjv.ts +7 -3
- package/src/validation/joi/joi.extensions.ts +4 -4
- package/src/validation/joi/joi.shared.schemas.ts +3 -3
- package/src/validation/joi/joi.validation.util.ts +2 -2
- package/src/yargs.util.ts +1 -0
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
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 =
|
|
19
|
+
const buildInfo = generateBuildInfo({
|
|
23
20
|
overrideTimestamp: overrideTimestamp,
|
|
24
21
|
});
|
|
25
22
|
console.log(buildInfo);
|
|
26
23
|
if (dir)
|
|
27
|
-
|
|
28
|
-
const buildInfoPath = dir ?
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
appendToBashEnv(buildInfo, prefix);
|
|
29
|
+
appendToGithubEnv(buildInfo, prefix);
|
|
30
|
+
appendToGithubOutput(buildInfo, prefix);
|
|
34
31
|
});
|
package/dist/bin/json2env.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
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
|
-
|
|
50
|
+
kpySync(kpyOpt);
|
|
54
51
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import 'dotenv/config';
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
9
|
+
secretsDecrypt(dir, file, encKeyBuffer, del, jsonMode);
|
|
12
10
|
});
|
|
13
11
|
function getDecryptCLIOptions() {
|
|
14
|
-
|
|
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.${
|
|
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
|
-
|
|
2
|
+
import 'dotenv/config';
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
9
|
+
secretsEncrypt(pattern, file, encKeyBuffer, del, jsonMode);
|
|
12
10
|
});
|
|
13
11
|
function getEncryptCLIOptions() {
|
|
14
|
-
|
|
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.${
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
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 =
|
|
15
|
-
console.log(
|
|
11
|
+
const key = randomBytes(sizeBytes).toString('base64');
|
|
12
|
+
console.log(dimGrey('\nSECRET_ENCRYPTION_KEY:\n'));
|
|
16
13
|
console.log(key, '\n');
|
|
17
14
|
});
|
package/dist/bin/slack-this.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
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
|
|
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));
|
package/dist/colors/colors.d.ts
CHANGED
|
@@ -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.
|
|
9
|
-
export declare const dimWhite: chalk.
|
|
10
|
-
export declare const boldWhite: chalk.
|
|
11
|
-
export declare const inverseWhite: chalk.
|
|
12
|
-
export declare const grey: chalk.
|
|
13
|
-
export declare const dimGrey: chalk.
|
|
14
|
-
export declare const boldGrey: chalk.
|
|
15
|
-
export declare const yellow: chalk.
|
|
16
|
-
export declare const dimYellow: chalk.
|
|
17
|
-
export declare const boldYellow: chalk.
|
|
18
|
-
export declare const inverseYellow: chalk.
|
|
19
|
-
export declare const green: chalk.
|
|
20
|
-
export declare const dimGreen: chalk.
|
|
21
|
-
export declare const boldGreen: chalk.
|
|
22
|
-
export declare const red: chalk.
|
|
23
|
-
export declare const dimRed: chalk.
|
|
24
|
-
export declare const boldRed: chalk.
|
|
25
|
-
export declare const blue: chalk.
|
|
26
|
-
export declare const dimBlue: chalk.
|
|
27
|
-
export declare const boldBlue: chalk.
|
|
28
|
-
export declare const magenta: chalk.
|
|
29
|
-
export declare const dimMagenta: chalk.
|
|
30
|
-
export declare const boldMagenta: chalk.
|
|
31
|
-
export declare const cyan: chalk.
|
|
32
|
-
export declare const dimCyan: chalk.
|
|
33
|
-
export declare const boldCyan: 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;
|
package/dist/colors/colors.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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;
|
package/dist/csv/csvReader.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Inspired by: https://gist.github.com/Jezternz/c8e9fafc2c114e079829974e3764db75
|
|
3
|
-
|
|
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
|
-
|
|
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 = [[]];
|
package/dist/csv/csvWriter.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Inspired by: https://github.com/ryu1kn/csv-writer/
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
|
8
|
+
const writer = new CSVWriter(opt);
|
|
12
9
|
let firstRow = true;
|
|
13
|
-
return new
|
|
10
|
+
return new Transform({
|
|
14
11
|
writableObjectMode: true,
|
|
15
12
|
readableObjectMode: false,
|
|
16
13
|
readableHighWaterMark: 64 * 1024,
|
package/dist/diff/tableDiff.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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] ?
|
|
20
|
-
[bTitle]: 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:
|