@naturalcycles/nodejs-lib 13.45.2 → 13.45.4
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 +7 -7
- package/dist/bin/json2env.js +2 -2
- package/dist/bin/kpy.js +2 -2
- package/dist/bin/secrets-decrypt.js +2 -2
- package/dist/bin/secrets-encrypt.js +2 -2
- package/dist/bin/secrets-gen-key.js +2 -2
- package/dist/bin/slack-this.js +2 -2
- package/dist/colors/colors.d.ts +0 -1
- package/dist/colors/colors.js +3 -4
- package/dist/csv/csvWriter.js +1 -0
- package/dist/fs/fs2.js +32 -34
- package/dist/fs/json2env.js +5 -5
- package/dist/fs/kpy.js +8 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/infra/process.util.js +8 -7
- package/dist/jwt/jwt.service.d.ts +1 -1
- package/dist/jwt/jwt.service.js +6 -5
- package/dist/script/runScript.js +3 -3
- package/dist/secret/secrets-decrypt.util.js +4 -4
- package/dist/secret/secrets-encrypt.util.js +7 -7
- package/dist/security/crypto.util.js +9 -9
- package/dist/slack/slack.service.js +2 -0
- package/dist/stream/ndjson/ndjson.model.js +3 -5
- package/dist/stream/pipeline/pipeline.js +2 -0
- package/dist/stream/progressLogger.js +10 -0
- package/dist/stream/sizeStack.js +2 -1
- package/dist/stream/transform/worker/baseWorkerClass.js +1 -0
- package/dist/util/lruMemoCache.js +1 -0
- package/dist/util/zip.util.js +5 -5
- package/dist/validation/ajv/ajvSchema.js +3 -0
- package/dist/validation/joi/number.extensions.d.ts +1 -1
- package/dist/validation/joi/string.extensions.d.ts +1 -1
- package/package.json +1 -1
- package/src/bin/generate-build-info.ts +3 -3
- package/src/bin/json2env.ts +1 -1
- package/src/bin/kpy.ts +1 -1
- package/src/bin/secrets-decrypt.ts +1 -1
- package/src/bin/secrets-encrypt.ts +1 -1
- package/src/bin/secrets-gen-key.ts +1 -1
- package/src/bin/slack-this.ts +1 -1
- package/src/colors/colors.ts +1 -3
- package/src/fs/fs2.ts +2 -2
- package/src/fs/json2env.ts +1 -1
- package/src/fs/kpy.ts +1 -1
- package/src/index.ts +1 -1
- package/src/infra/process.util.ts +1 -1
- package/src/jwt/jwt.service.ts +1 -1
- package/src/script/runScript.ts +1 -1
- package/src/secret/secrets-decrypt.util.ts +1 -1
- package/src/secret/secrets-encrypt.util.ts +2 -2
- package/src/security/crypto.util.ts +1 -1
- package/src/util/zip.util.ts +1 -1
- package/src/validation/joi/number.extensions.ts +1 -1
- package/src/validation/joi/string.extensions.ts +1 -1
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
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
8
|
const json2env_1 = require("../fs/json2env");
|
|
9
9
|
const runScript_1 = require("../script/runScript");
|
|
10
10
|
const buildInfo_util_1 = require("../util/buildInfo.util");
|
|
11
11
|
(0, runScript_1.runScript)(async () => {
|
|
12
|
-
const { dir, overrideTimestamp } =
|
|
12
|
+
const { dir, overrideTimestamp } = yargs_1.default.options({
|
|
13
13
|
dir: {
|
|
14
14
|
type: 'string',
|
|
15
15
|
desc: 'Output directory',
|
|
@@ -24,9 +24,9 @@ const buildInfo_util_1 = require("../util/buildInfo.util");
|
|
|
24
24
|
});
|
|
25
25
|
console.log(buildInfo);
|
|
26
26
|
if (dir)
|
|
27
|
-
|
|
28
|
-
const buildInfoPath = dir ?
|
|
29
|
-
|
|
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));
|
|
30
30
|
const prefix = 'buildInfo_';
|
|
31
31
|
(0, json2env_1.appendToBashEnv)(buildInfo, prefix);
|
|
32
32
|
(0, json2env_1.appendToGithubEnv)(buildInfo, prefix);
|
package/dist/bin/json2env.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
6
6
|
const json2env_1 = require("../fs/json2env");
|
|
7
7
|
const runScript_1 = require("../script/runScript");
|
|
8
8
|
(0, runScript_1.runScript)(() => {
|
|
9
|
-
const { argv } =
|
|
9
|
+
const { argv } = yargs_1.default.demandCommand(1).options({
|
|
10
10
|
prefix: {
|
|
11
11
|
type: 'string',
|
|
12
12
|
},
|
package/dist/bin/kpy.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
6
6
|
const kpy_1 = require("../fs/kpy");
|
|
7
7
|
const runScript_1 = require("../script/runScript");
|
|
8
8
|
(0, runScript_1.runScript)(() => {
|
|
9
|
-
const { _: [baseDir, ...inputPatterns], ...opt } =
|
|
9
|
+
const { _: [baseDir, ...inputPatterns], ...opt } = yargs_1.default.demandCommand(2).options({
|
|
10
10
|
silent: {
|
|
11
11
|
type: 'boolean',
|
|
12
12
|
desc: 'Suppress all text output',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
6
6
|
const colors_1 = require("../colors/colors");
|
|
7
7
|
const runScript_1 = require("../script/runScript");
|
|
8
8
|
const secrets_decrypt_util_1 = require("../secret/secrets-decrypt.util");
|
|
@@ -12,7 +12,7 @@ const secrets_decrypt_util_1 = require("../secret/secrets-decrypt.util");
|
|
|
12
12
|
});
|
|
13
13
|
function getDecryptCLIOptions() {
|
|
14
14
|
require('dotenv').config();
|
|
15
|
-
let { dir, file, encKey, encKeyVar, del, jsonMode } =
|
|
15
|
+
let { dir, file, encKey, encKeyVar, del, jsonMode } = yargs_1.default.options({
|
|
16
16
|
dir: {
|
|
17
17
|
type: 'array',
|
|
18
18
|
desc: 'Directory with secrets. Can be many',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
6
6
|
const colors_1 = require("../colors/colors");
|
|
7
7
|
const runScript_1 = require("../script/runScript");
|
|
8
8
|
const secrets_encrypt_util_1 = require("../secret/secrets-encrypt.util");
|
|
@@ -12,7 +12,7 @@ const secrets_encrypt_util_1 = require("../secret/secrets-encrypt.util");
|
|
|
12
12
|
});
|
|
13
13
|
function getEncryptCLIOptions() {
|
|
14
14
|
require('dotenv').config();
|
|
15
|
-
let { pattern, file, encKey, encKeyVar, del, jsonMode } =
|
|
15
|
+
let { pattern, file, encKey, encKeyVar, del, jsonMode } = yargs_1.default.options({
|
|
16
16
|
pattern: {
|
|
17
17
|
type: 'string',
|
|
18
18
|
array: true,
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const
|
|
6
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
7
7
|
const colors_1 = require("../colors/colors");
|
|
8
8
|
const runScript_1 = require("../script/runScript");
|
|
9
9
|
(0, runScript_1.runScript)(() => {
|
|
10
|
-
const { sizeBytes } =
|
|
10
|
+
const { sizeBytes } = yargs_1.default.option('sizeBytes', {
|
|
11
11
|
type: 'number',
|
|
12
12
|
default: 256,
|
|
13
13
|
}).argv;
|
package/dist/bin/slack-this.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
6
6
|
const __1 = require("..");
|
|
7
7
|
const runScript_1 = require("../script/runScript");
|
|
8
8
|
(0, runScript_1.runScript)(async () => {
|
|
9
|
-
const { channel, msg, username, emoji, webhook: webhookUrl, } =
|
|
9
|
+
const { channel, msg, username, emoji, webhook: webhookUrl, } = yargs_1.default.options({
|
|
10
10
|
channel: {
|
|
11
11
|
type: 'string',
|
|
12
12
|
demandOption: true,
|
package/dist/colors/colors.d.ts
CHANGED
package/dist/colors/colors.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
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 =
|
|
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
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const node_tty_1 = tslib_1.__importDefault(require("node:tty"));
|
|
6
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
exports.chalk = chalk_1.default;
|
|
8
7
|
/**
|
|
9
8
|
* Based on: https://github.com/sindresorhus/yoctocolors/pull/5
|
|
10
9
|
*
|
|
11
10
|
* @experimental
|
|
12
11
|
*/
|
|
13
|
-
exports.hasColors = !process.env['NO_COLOR'] &&
|
|
12
|
+
exports.hasColors = !process.env['NO_COLOR'] && node_tty_1.default.WriteStream.prototype.hasColors();
|
|
14
13
|
// The point of re-exporting is:
|
|
15
14
|
// 1. Fix typings to allow to pass `number` (very common case)
|
|
16
15
|
// 2. Easier/shorter to import, rather than from 'chalk'
|
package/dist/csv/csvWriter.js
CHANGED
package/dist/fs/fs2.js
CHANGED
|
@@ -19,10 +19,10 @@ exports.fs2 = void 0;
|
|
|
19
19
|
const tslib_1 = require("tslib");
|
|
20
20
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
21
21
|
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
22
|
-
const
|
|
22
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
23
23
|
const node_zlib_1 = require("node:zlib");
|
|
24
24
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
25
|
-
const
|
|
25
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
26
26
|
const transformToNDJson_1 = require("../stream/ndjson/transformToNDJson");
|
|
27
27
|
const transformSplit_1 = require("../stream/transform/transformSplit");
|
|
28
28
|
const env_util_1 = require("../util/env.util");
|
|
@@ -35,26 +35,9 @@ const env_util_1 = require("../util/env.util");
|
|
|
35
35
|
* 3. fs-extra
|
|
36
36
|
*/
|
|
37
37
|
class FS2 {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// - sync function has postfix in the name, e.g readText
|
|
42
|
-
// Re-export the whole fs/fsp, for the edge cases where they are needed
|
|
43
|
-
this.fs = node_fs_1.default;
|
|
44
|
-
this.fsp = promises_1.default;
|
|
45
|
-
// Re-export existing fs/fsp functions
|
|
46
|
-
// rm/rmAsync are replaced with removePath/removePathAsync
|
|
47
|
-
this.lstat = node_fs_1.default.lstatSync;
|
|
48
|
-
this.lstatAsync = promises_1.default.lstat;
|
|
49
|
-
this.stat = node_fs_1.default.statSync;
|
|
50
|
-
this.statAsync = promises_1.default.stat;
|
|
51
|
-
this.mkdir = node_fs_1.default.mkdirSync;
|
|
52
|
-
this.mkdirAsync = promises_1.default.mkdir;
|
|
53
|
-
this.readdir = node_fs_1.default.readdirSync;
|
|
54
|
-
this.readdirAsync = promises_1.default.readdir;
|
|
55
|
-
this.createWriteStream = node_fs_1.default.createWriteStream;
|
|
56
|
-
this.createReadStream = node_fs_1.default.createReadStream;
|
|
57
|
-
}
|
|
38
|
+
// Naming convention is:
|
|
39
|
+
// - async function has Async in the name, e.g readTextAsync
|
|
40
|
+
// - sync function has postfix in the name, e.g readText
|
|
58
41
|
/**
|
|
59
42
|
* Convenience wrapper that defaults to utf-8 string output.
|
|
60
43
|
*/
|
|
@@ -83,10 +66,10 @@ class FS2 {
|
|
|
83
66
|
return (0, js_lib_1._jsonParse)(str);
|
|
84
67
|
}
|
|
85
68
|
readYaml(filePath) {
|
|
86
|
-
return
|
|
69
|
+
return js_yaml_1.default.load(node_fs_1.default.readFileSync(filePath, 'utf8'));
|
|
87
70
|
}
|
|
88
71
|
async readYamlAsync(filePath) {
|
|
89
|
-
return
|
|
72
|
+
return js_yaml_1.default.load(await promises_1.default.readFile(filePath, 'utf8'));
|
|
90
73
|
}
|
|
91
74
|
writeFile(filePath, data) {
|
|
92
75
|
node_fs_1.default.writeFileSync(filePath, data);
|
|
@@ -103,11 +86,11 @@ class FS2 {
|
|
|
103
86
|
await promises_1.default.writeFile(filePath, str);
|
|
104
87
|
}
|
|
105
88
|
writeYaml(filePath, data, opt) {
|
|
106
|
-
const str =
|
|
89
|
+
const str = js_yaml_1.default.dump(data, opt);
|
|
107
90
|
node_fs_1.default.writeFileSync(filePath, str);
|
|
108
91
|
}
|
|
109
92
|
async writeYamlAsync(filePath, data, opt) {
|
|
110
|
-
const str =
|
|
93
|
+
const str = js_yaml_1.default.dump(data, opt);
|
|
111
94
|
await promises_1.default.writeFile(filePath, str);
|
|
112
95
|
}
|
|
113
96
|
appendFile(filePath, data) {
|
|
@@ -125,22 +108,22 @@ class FS2 {
|
|
|
125
108
|
await this.outputFileAsync(filePath, str);
|
|
126
109
|
}
|
|
127
110
|
outputYaml(filePath, data, opt) {
|
|
128
|
-
const str =
|
|
111
|
+
const str = js_yaml_1.default.dump(data, opt);
|
|
129
112
|
this.outputFile(filePath, str);
|
|
130
113
|
}
|
|
131
114
|
async outputYamlAsync(filePath, data, opt) {
|
|
132
|
-
const str =
|
|
115
|
+
const str = js_yaml_1.default.dump(data, opt);
|
|
133
116
|
await this.outputFileAsync(filePath, str);
|
|
134
117
|
}
|
|
135
118
|
outputFile(filePath, data) {
|
|
136
|
-
const dirPath =
|
|
119
|
+
const dirPath = node_path_1.default.dirname(filePath);
|
|
137
120
|
if (!node_fs_1.default.existsSync(dirPath)) {
|
|
138
121
|
this.ensureDir(dirPath);
|
|
139
122
|
}
|
|
140
123
|
node_fs_1.default.writeFileSync(filePath, data);
|
|
141
124
|
}
|
|
142
125
|
async outputFileAsync(filePath, data) {
|
|
143
|
-
const dirPath =
|
|
126
|
+
const dirPath = node_path_1.default.dirname(filePath);
|
|
144
127
|
if (!(await this.pathExistsAsync(dirPath))) {
|
|
145
128
|
await this.ensureDirAsync(dirPath);
|
|
146
129
|
}
|
|
@@ -178,7 +161,7 @@ class FS2 {
|
|
|
178
161
|
catch { }
|
|
179
162
|
if (stats?.isFile())
|
|
180
163
|
return;
|
|
181
|
-
const dir =
|
|
164
|
+
const dir = node_path_1.default.dirname(filePath);
|
|
182
165
|
try {
|
|
183
166
|
if (!node_fs_1.default.statSync(dir).isDirectory()) {
|
|
184
167
|
// parent is not a directory
|
|
@@ -204,7 +187,7 @@ class FS2 {
|
|
|
204
187
|
catch { }
|
|
205
188
|
if (stats?.isFile())
|
|
206
189
|
return;
|
|
207
|
-
const dir =
|
|
190
|
+
const dir = node_path_1.default.dirname(filePath);
|
|
208
191
|
try {
|
|
209
192
|
if (!(await promises_1.default.stat(dir)).isDirectory()) {
|
|
210
193
|
// parent is not a directory
|
|
@@ -235,7 +218,7 @@ class FS2 {
|
|
|
235
218
|
this.ensureDir(dirPath);
|
|
236
219
|
return;
|
|
237
220
|
}
|
|
238
|
-
items.forEach(item => this.removePath(
|
|
221
|
+
items.forEach(item => this.removePath(node_path_1.default.join(dirPath, item)));
|
|
239
222
|
}
|
|
240
223
|
async emptyDirAsync(dirPath) {
|
|
241
224
|
let items;
|
|
@@ -245,7 +228,7 @@ class FS2 {
|
|
|
245
228
|
catch {
|
|
246
229
|
return await this.ensureDirAsync(dirPath);
|
|
247
230
|
}
|
|
248
|
-
await Promise.all(items.map(item => this.removePathAsync(
|
|
231
|
+
await Promise.all(items.map(item => this.removePathAsync(node_path_1.default.join(dirPath, item))));
|
|
249
232
|
}
|
|
250
233
|
/**
|
|
251
234
|
* Cautious, underlying Node function is currently Experimental.
|
|
@@ -291,6 +274,21 @@ class FS2 {
|
|
|
291
274
|
})
|
|
292
275
|
?.isDirectory() || false);
|
|
293
276
|
}
|
|
277
|
+
// Re-export the whole fs/fsp, for the edge cases where they are needed
|
|
278
|
+
fs = node_fs_1.default;
|
|
279
|
+
fsp = promises_1.default;
|
|
280
|
+
// Re-export existing fs/fsp functions
|
|
281
|
+
// rm/rmAsync are replaced with removePath/removePathAsync
|
|
282
|
+
lstat = node_fs_1.default.lstatSync;
|
|
283
|
+
lstatAsync = promises_1.default.lstat;
|
|
284
|
+
stat = node_fs_1.default.statSync;
|
|
285
|
+
statAsync = promises_1.default.stat;
|
|
286
|
+
mkdir = node_fs_1.default.mkdirSync;
|
|
287
|
+
mkdirAsync = promises_1.default.mkdir;
|
|
288
|
+
readdir = node_fs_1.default.readdirSync;
|
|
289
|
+
readdirAsync = promises_1.default.readdir;
|
|
290
|
+
createWriteStream = node_fs_1.default.createWriteStream;
|
|
291
|
+
createReadStream = node_fs_1.default.createReadStream;
|
|
294
292
|
/*
|
|
295
293
|
Returns a Readable of [already parsed] NDJSON objects.
|
|
296
294
|
|
package/dist/fs/json2env.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.appendToGithubSummary = appendToGithubSummary;
|
|
|
8
8
|
exports.objectToShellExport = objectToShellExport;
|
|
9
9
|
exports.objectToGithubActionsEnv = objectToGithubActionsEnv;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
12
12
|
const colors_1 = require("../colors/colors");
|
|
13
13
|
const fs2_1 = require("./fs2");
|
|
14
14
|
const JSON2ENV_OPT_DEF = {
|
|
@@ -60,7 +60,7 @@ function appendToBashEnv(obj, prefix = '') {
|
|
|
60
60
|
const { BASH_ENV } = process.env;
|
|
61
61
|
if (BASH_ENV) {
|
|
62
62
|
const data = objectToShellExport(obj, prefix);
|
|
63
|
-
|
|
63
|
+
node_fs_1.default.appendFileSync(BASH_ENV, data);
|
|
64
64
|
console.log(`BASH_ENV appended:\n${data}`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ function appendToGithubEnv(obj, prefix = '') {
|
|
|
68
68
|
const { GITHUB_ENV } = process.env;
|
|
69
69
|
if (GITHUB_ENV) {
|
|
70
70
|
const data = objectToGithubActionsEnv(obj, prefix);
|
|
71
|
-
|
|
71
|
+
node_fs_1.default.appendFileSync(GITHUB_ENV, data);
|
|
72
72
|
console.log(`GITHUB_ENV appended:\n${data}`);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -76,7 +76,7 @@ function appendToGithubOutput(obj, prefix = '') {
|
|
|
76
76
|
const { GITHUB_OUTPUT } = process.env;
|
|
77
77
|
if (GITHUB_OUTPUT) {
|
|
78
78
|
const data = objectToGithubActionsEnv(obj, prefix);
|
|
79
|
-
|
|
79
|
+
node_fs_1.default.appendFileSync(GITHUB_OUTPUT, data);
|
|
80
80
|
console.log(`GITHUB_OUTPUT appended:\n${data}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -87,7 +87,7 @@ function appendToGithubSummary(...lines) {
|
|
|
87
87
|
const { GITHUB_STEP_SUMMARY } = process.env;
|
|
88
88
|
if (GITHUB_STEP_SUMMARY) {
|
|
89
89
|
const str = lines.join('\n') + '\n';
|
|
90
|
-
|
|
90
|
+
node_fs_1.default.appendFileSync(GITHUB_STEP_SUMMARY, str);
|
|
91
91
|
console.log(`GITHUB_STEP_SUMMARY appended:\n${str}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
package/dist/fs/kpy.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.kpy = kpy;
|
|
4
4
|
exports.kpySync = kpySync;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const colors_1 = require("../colors/colors");
|
|
9
9
|
const index_1 = require("../index");
|
|
@@ -17,9 +17,9 @@ async function kpy(opt) {
|
|
|
17
17
|
kpyLogFilenames(opt, filenames);
|
|
18
18
|
const overwrite = !opt.noOverwrite;
|
|
19
19
|
await Promise.all(filenames.map(async (filename) => {
|
|
20
|
-
const basename =
|
|
21
|
-
const srcFilename =
|
|
22
|
-
const destFilename =
|
|
20
|
+
const basename = node_path_1.default.basename(filename);
|
|
21
|
+
const srcFilename = node_path_1.default.resolve(opt.baseDir, filename);
|
|
22
|
+
const destFilename = node_path_1.default.resolve(opt.outputDir, opt.flat ? basename : filename);
|
|
23
23
|
if (!opt.dry) {
|
|
24
24
|
if (opt.move) {
|
|
25
25
|
await index_1.fs2.movePathAsync(srcFilename, destFilename, {
|
|
@@ -46,9 +46,9 @@ function kpySync(opt) {
|
|
|
46
46
|
kpyLogFilenames(opt, filenames);
|
|
47
47
|
const overwrite = !opt.noOverwrite;
|
|
48
48
|
filenames.forEach(filename => {
|
|
49
|
-
const basename =
|
|
50
|
-
const srcFilename =
|
|
51
|
-
const destFilename =
|
|
49
|
+
const basename = node_path_1.default.basename(filename);
|
|
50
|
+
const srcFilename = node_path_1.default.resolve(opt.baseDir, filename);
|
|
51
|
+
const destFilename = node_path_1.default.resolve(opt.outputDir, opt.flat ? basename : filename);
|
|
52
52
|
if (!opt.dry) {
|
|
53
53
|
if (opt.move) {
|
|
54
54
|
index_1.fs2.movePath(srcFilename, destFilename, { force: overwrite });
|
|
@@ -80,7 +80,7 @@ function kpyPrepare(opt) {
|
|
|
80
80
|
for (const pattern of opt.inputPatterns) {
|
|
81
81
|
if (pattern.includes('*'))
|
|
82
82
|
continue;
|
|
83
|
-
if (index_1.fs2.isDirectory(
|
|
83
|
+
if (index_1.fs2.isDirectory(node_path_1.default.resolve(opt.baseDir, pattern))) {
|
|
84
84
|
extraPatterns.push(`${pattern}/**`);
|
|
85
85
|
}
|
|
86
86
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
2
|
import type { Options as FastGlobOptions } from 'fast-glob';
|
|
3
3
|
import fastGlob from 'fast-glob';
|
|
4
4
|
import type { AlternativesSchema, AnySchema, ArraySchema, BinarySchema, BooleanSchema, DateSchema, FunctionSchema, ObjectSchema, ValidationErrorItem } from 'joi';
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fastGlob = exports.Ajv = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
exports.Ajv =
|
|
5
|
+
const ajv_1 = tslib_1.__importDefault(require("ajv"));
|
|
6
|
+
exports.Ajv = ajv_1.default;
|
|
7
7
|
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
|
|
8
8
|
exports.fastGlob = fast_glob_1.default;
|
|
9
9
|
tslib_1.__exportStar(require("./buffer/buffer.util"), exports);
|
|
@@ -4,7 +4,7 @@ exports.processSharedUtil = void 0;
|
|
|
4
4
|
exports.memoryUsage = memoryUsage;
|
|
5
5
|
exports.memoryUsageFull = memoryUsageFull;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
-
const
|
|
7
|
+
const node_os_1 = tslib_1.__importDefault(require("node:os"));
|
|
8
8
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
9
9
|
function memoryUsage() {
|
|
10
10
|
const { rss, external, heapUsed, heapTotal } = process.memoryUsage();
|
|
@@ -17,8 +17,8 @@ function memoryUsage() {
|
|
|
17
17
|
}
|
|
18
18
|
function memoryUsageFull() {
|
|
19
19
|
const { rss, external, heapUsed, heapTotal } = process.memoryUsage();
|
|
20
|
-
const totalMem =
|
|
21
|
-
const freeMem =
|
|
20
|
+
const totalMem = node_os_1.default.totalmem();
|
|
21
|
+
const freeMem = node_os_1.default.freemem();
|
|
22
22
|
return {
|
|
23
23
|
rss: (0, js_lib_1._mb)(rss),
|
|
24
24
|
heapTotal: (0, js_lib_1._mb)(heapTotal),
|
|
@@ -30,6 +30,7 @@ function memoryUsageFull() {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
class ProcessUtil {
|
|
33
|
+
timer;
|
|
33
34
|
startMemoryTimer(intervalMillis = 1000) {
|
|
34
35
|
console.log(memoryUsage());
|
|
35
36
|
this.timer = setInterval(() => {
|
|
@@ -40,7 +41,7 @@ class ProcessUtil {
|
|
|
40
41
|
setTimeout(() => clearInterval(this.timer), afterMillis);
|
|
41
42
|
}
|
|
42
43
|
cpuAvg() {
|
|
43
|
-
const avg =
|
|
44
|
+
const avg = node_os_1.default.loadavg();
|
|
44
45
|
return {
|
|
45
46
|
avg1: avg[0].toFixed(2),
|
|
46
47
|
avg5: avg[1].toFixed(2),
|
|
@@ -48,9 +49,9 @@ class ProcessUtil {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
cpuInfo() {
|
|
51
|
-
const c =
|
|
52
|
+
const c = node_os_1.default.cpus()[0];
|
|
52
53
|
return {
|
|
53
|
-
count:
|
|
54
|
+
count: node_os_1.default.cpus().length,
|
|
54
55
|
model: c.model,
|
|
55
56
|
speed: c.speed,
|
|
56
57
|
};
|
|
@@ -73,7 +74,7 @@ class ProcessUtil {
|
|
|
73
74
|
}
|
|
74
75
|
getCPUInfo() {
|
|
75
76
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
76
|
-
return
|
|
77
|
+
return node_os_1.default.cpus().reduce((r, cpu) => {
|
|
77
78
|
r['idle'] += cpu.times.idle;
|
|
78
79
|
Object.values(cpu.times).forEach(m => (r['total'] += m));
|
|
79
80
|
return r;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyObject, ErrorData, JWTString } from '@naturalcycles/js-lib';
|
|
2
2
|
import type { AnySchema } from 'joi';
|
|
3
3
|
import type { Algorithm, JwtHeader, SignOptions, VerifyOptions } from 'jsonwebtoken';
|
|
4
|
-
import
|
|
4
|
+
import jsonwebtoken from 'jsonwebtoken';
|
|
5
5
|
export { jsonwebtoken };
|
|
6
6
|
export type { Algorithm, JwtHeader, SignOptions, VerifyOptions };
|
|
7
7
|
export interface JWTServiceCfg {
|
package/dist/jwt/jwt.service.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JWTService = exports.jsonwebtoken = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
|
-
const
|
|
7
|
-
exports.jsonwebtoken =
|
|
6
|
+
const jsonwebtoken_1 = tslib_1.__importDefault(require("jsonwebtoken"));
|
|
7
|
+
exports.jsonwebtoken = jsonwebtoken_1.default;
|
|
8
8
|
const joi_shared_schemas_1 = require("../validation/joi/joi.shared.schemas");
|
|
9
9
|
const joi_validation_util_1 = require("../validation/joi/joi.validation.util");
|
|
10
10
|
// todo: define JWTError and list possible options
|
|
@@ -23,6 +23,7 @@ const joi_validation_util_1 = require("../validation/joi/joi.validation.util");
|
|
|
23
23
|
* openssl ec -in key.pem -pubout > key.pub.pem
|
|
24
24
|
*/
|
|
25
25
|
class JWTService {
|
|
26
|
+
cfg;
|
|
26
27
|
constructor(cfg) {
|
|
27
28
|
this.cfg = cfg;
|
|
28
29
|
}
|
|
@@ -31,7 +32,7 @@ class JWTService {
|
|
|
31
32
|
if (schema) {
|
|
32
33
|
(0, joi_validation_util_1.validate)(payload, schema);
|
|
33
34
|
}
|
|
34
|
-
return
|
|
35
|
+
return jsonwebtoken_1.default.sign(payload, this.cfg.privateKey, {
|
|
35
36
|
algorithm: this.cfg.algorithm,
|
|
36
37
|
noTimestamp: true,
|
|
37
38
|
...this.cfg.signOptions,
|
|
@@ -41,7 +42,7 @@ class JWTService {
|
|
|
41
42
|
verify(token, schema, opt = {}, publicKey) {
|
|
42
43
|
(0, js_lib_1._assert)(this.cfg.publicKey, 'JWTService: publicKey is required to be able to verify, but not provided');
|
|
43
44
|
try {
|
|
44
|
-
const data =
|
|
45
|
+
const data = jsonwebtoken_1.default.verify(token, publicKey || this.cfg.publicKey, {
|
|
45
46
|
algorithms: [this.cfg.algorithm],
|
|
46
47
|
...this.cfg.verifyOptions,
|
|
47
48
|
...opt,
|
|
@@ -61,7 +62,7 @@ class JWTService {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
decode(token, schema) {
|
|
64
|
-
const data =
|
|
65
|
+
const data = jsonwebtoken_1.default.decode(token, {
|
|
65
66
|
complete: true,
|
|
66
67
|
});
|
|
67
68
|
(0, js_lib_1._assert)(data?.payload, 'invalid token, decoded value is empty', {
|
package/dist/script/runScript.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runScript = runScript;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const node_os_1 = tslib_1.__importDefault(require("node:os"));
|
|
6
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
7
|
const colors_1 = require("../colors/colors");
|
|
8
8
|
const inspect_1 = require("../string/inspect");
|
|
@@ -69,8 +69,8 @@ function runScript(fn, opt = {}) {
|
|
|
69
69
|
function logEnvironment() {
|
|
70
70
|
const { platform, arch, versions: { node }, env: { CPU_LIMIT, NODE_OPTIONS }, } = process;
|
|
71
71
|
const cpuLimit = Number(CPU_LIMIT) || undefined;
|
|
72
|
-
const availableParallelism =
|
|
73
|
-
const cpus =
|
|
72
|
+
const availableParallelism = node_os_1.default.availableParallelism?.();
|
|
73
|
+
const cpus = node_os_1.default.cpus().length;
|
|
74
74
|
console.log((0, colors_1.dimGrey)(Object.entries({
|
|
75
75
|
node: `${node} ${platform} ${arch}`,
|
|
76
76
|
NODE_OPTIONS: NODE_OPTIONS || 'not defined',
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.secretsDecrypt = secretsDecrypt;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const colors_1 = require("../colors/colors");
|
|
9
9
|
const index_1 = require("../index");
|
|
@@ -24,8 +24,8 @@ function secretsDecrypt(dir, file, encKeyBuffer, del = false, jsonMode = false)
|
|
|
24
24
|
filenames.forEach(filename => {
|
|
25
25
|
let plainFilename;
|
|
26
26
|
if (jsonMode) {
|
|
27
|
-
(0, js_lib_1._assert)(filename.endsWith('.json'), `${
|
|
28
|
-
(0, js_lib_1._assert)(!filename.endsWith('.plain.json'), `${
|
|
27
|
+
(0, js_lib_1._assert)(filename.endsWith('.json'), `${node_path_1.default.basename(filename)} MUST end with '.json'`);
|
|
28
|
+
(0, js_lib_1._assert)(!filename.endsWith('.plain.json'), `${node_path_1.default.basename(filename)} MUST NOT end with '.plain.json'`);
|
|
29
29
|
plainFilename = filename.replace('.json', '.plain.json');
|
|
30
30
|
const json = (0, crypto_util_1.decryptObject)(index_1.fs2.readJson(filename), encKeyBuffer);
|
|
31
31
|
index_1.fs2.writeJson(plainFilename, json, { spaces: 2 });
|
|
@@ -39,7 +39,7 @@ function secretsDecrypt(dir, file, encKeyBuffer, del = false, jsonMode = false)
|
|
|
39
39
|
if (del) {
|
|
40
40
|
node_fs_1.default.unlinkSync(filename);
|
|
41
41
|
}
|
|
42
|
-
console.log(` ${
|
|
42
|
+
console.log(` ${node_path_1.default.basename(filename)} > ${node_path_1.default.basename(plainFilename)}`);
|
|
43
43
|
});
|
|
44
44
|
console.log(`decrypted ${(0, colors_1.yellow)(filenames.length)} files in ${(0, colors_1.dimGrey)(dir.join(' '))}`);
|
|
45
45
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.secretsEncrypt = secretsEncrypt;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const colors_1 = require("../colors/colors");
|
|
9
9
|
const index_1 = require("../index");
|
|
@@ -23,21 +23,21 @@ function secretsEncrypt(pattern, file, encKeyBuffer, del = false, jsonMode = fal
|
|
|
23
23
|
let encFilename;
|
|
24
24
|
filenames.forEach(filename => {
|
|
25
25
|
if (jsonMode) {
|
|
26
|
-
(0, js_lib_1._assert)(filename.endsWith('.plain.json'), `${
|
|
26
|
+
(0, js_lib_1._assert)(filename.endsWith('.plain.json'), `${node_path_1.default.basename(filename)} MUST end with '.plain.json'`);
|
|
27
27
|
encFilename = filename.replace('.plain', '');
|
|
28
28
|
const json = (0, crypto_util_1.encryptObject)(index_1.fs2.readJson(filename), encKeyBuffer);
|
|
29
29
|
index_1.fs2.writeJson(encFilename, json, { spaces: 2 });
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
const plain =
|
|
32
|
+
const plain = node_fs_1.default.readFileSync(filename);
|
|
33
33
|
const enc = (0, crypto_util_1.encryptRandomIVBuffer)(plain, encKeyBuffer);
|
|
34
34
|
encFilename = `${filename}.enc`;
|
|
35
|
-
|
|
35
|
+
node_fs_1.default.writeFileSync(encFilename, enc);
|
|
36
36
|
}
|
|
37
37
|
if (del) {
|
|
38
|
-
|
|
38
|
+
node_fs_1.default.unlinkSync(filename);
|
|
39
39
|
}
|
|
40
|
-
console.log(` ${
|
|
40
|
+
console.log(` ${node_path_1.default.basename(filename)} > ${node_path_1.default.basename(encFilename)}`);
|
|
41
41
|
});
|
|
42
42
|
console.log(`encrypted ${(0, colors_1.yellow)(filenames.length)} files in (${(0, colors_1.dimGrey)(pattern.join(' '))})`);
|
|
43
43
|
}
|
|
@@ -8,7 +8,7 @@ exports.decryptString = decryptString;
|
|
|
8
8
|
exports.encryptString = encryptString;
|
|
9
9
|
exports.timingSafeStringEqual = timingSafeStringEqual;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
12
12
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
13
13
|
const hash_util_1 = require("./hash.util");
|
|
14
14
|
const algorithm = 'aes-256-cbc';
|
|
@@ -19,8 +19,8 @@ function encryptRandomIVBuffer(input, secretKeyBuffer) {
|
|
|
19
19
|
// sha256 to match aes-256 key length
|
|
20
20
|
const key = (0, hash_util_1.sha256AsBuffer)(secretKeyBuffer);
|
|
21
21
|
// Random iv to achieve non-deterministic encryption (but deterministic decryption)
|
|
22
|
-
const iv =
|
|
23
|
-
const cipher =
|
|
22
|
+
const iv = node_crypto_1.default.randomBytes(16);
|
|
23
|
+
const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
|
|
24
24
|
return Buffer.concat([iv, cipher.update(input), cipher.final()]);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -32,7 +32,7 @@ function decryptRandomIVBuffer(input, secretKeyBuffer) {
|
|
|
32
32
|
// iv is first 16 bytes of encrypted buffer, the rest is payload
|
|
33
33
|
const iv = input.subarray(0, 16);
|
|
34
34
|
const payload = input.subarray(16);
|
|
35
|
-
const decipher =
|
|
35
|
+
const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
|
|
36
36
|
return Buffer.concat([decipher.update(payload), decipher.final()]);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
@@ -43,7 +43,7 @@ function decryptObject(obj, secretKeyBuffer) {
|
|
|
43
43
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
44
44
|
const r = {};
|
|
45
45
|
(0, js_lib_1._stringMapEntries)(obj).forEach(([k, v]) => {
|
|
46
|
-
const decipher =
|
|
46
|
+
const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
|
|
47
47
|
r[k] = decipher.update(v, 'base64', 'utf8') + decipher.final('utf8');
|
|
48
48
|
});
|
|
49
49
|
return r;
|
|
@@ -56,7 +56,7 @@ function encryptObject(obj, secretKeyBuffer) {
|
|
|
56
56
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
57
57
|
const r = {};
|
|
58
58
|
(0, js_lib_1._stringMapEntries)(obj).forEach(([k, v]) => {
|
|
59
|
-
const cipher =
|
|
59
|
+
const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
|
|
60
60
|
r[k] = cipher.update(v, 'utf8', 'base64') + cipher.final('base64');
|
|
61
61
|
});
|
|
62
62
|
return r;
|
|
@@ -69,7 +69,7 @@ function encryptObject(obj, secretKeyBuffer) {
|
|
|
69
69
|
*/
|
|
70
70
|
function decryptString(str, secretKeyBuffer) {
|
|
71
71
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
72
|
-
const decipher =
|
|
72
|
+
const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
|
|
73
73
|
return decipher.update(str, 'base64', 'utf8') + decipher.final('utf8');
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -80,7 +80,7 @@ function decryptString(str, secretKeyBuffer) {
|
|
|
80
80
|
*/
|
|
81
81
|
function encryptString(str, secretKeyBuffer) {
|
|
82
82
|
const { key, iv } = getCryptoParams(secretKeyBuffer);
|
|
83
|
-
const cipher =
|
|
83
|
+
const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
|
|
84
84
|
return cipher.update(str, 'utf8', 'base64') + cipher.final('base64');
|
|
85
85
|
}
|
|
86
86
|
function getCryptoParams(secretKeyBuffer) {
|
|
@@ -103,5 +103,5 @@ function getCryptoParams(secretKeyBuffer) {
|
|
|
103
103
|
function timingSafeStringEqual(s1, s2) {
|
|
104
104
|
if (s1 === undefined || s2 === undefined || s1.length !== s2.length)
|
|
105
105
|
return false;
|
|
106
|
-
return
|
|
106
|
+
return node_crypto_1.default.timingSafeEqual(Buffer.from(s1), Buffer.from(s2));
|
|
107
107
|
}
|
|
@@ -4,11 +4,6 @@ exports.NDJsonStats = void 0;
|
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const colors_1 = require("../../colors/colors");
|
|
6
6
|
class NDJsonStats {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.tookMillis = 0;
|
|
9
|
-
this.rows = 0;
|
|
10
|
-
this.sizeBytes = 0;
|
|
11
|
-
}
|
|
12
7
|
static create(o = {}) {
|
|
13
8
|
return Object.assign(new NDJsonStats(), o);
|
|
14
9
|
}
|
|
@@ -19,6 +14,9 @@ class NDJsonStats {
|
|
|
19
14
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
20
15
|
return stats.reduce((statsTotal, stats) => statsTotal.add(stats), new NDJsonStats());
|
|
21
16
|
}
|
|
17
|
+
tookMillis = 0;
|
|
18
|
+
rows = 0;
|
|
19
|
+
sizeBytes = 0;
|
|
22
20
|
get rpsTotal() {
|
|
23
21
|
return Math.round(this.rows / ((this.tookMillis || 1) / 1000));
|
|
24
22
|
}
|
|
@@ -29,6 +29,16 @@ class ProgressLogger {
|
|
|
29
29
|
this.start();
|
|
30
30
|
this.logStats(); // initial
|
|
31
31
|
}
|
|
32
|
+
cfg;
|
|
33
|
+
started;
|
|
34
|
+
lastSecondStarted;
|
|
35
|
+
sma;
|
|
36
|
+
logEvery10;
|
|
37
|
+
processedLastSecond;
|
|
38
|
+
progress;
|
|
39
|
+
peakRSS;
|
|
40
|
+
sizes;
|
|
41
|
+
sizesZipped;
|
|
32
42
|
start() {
|
|
33
43
|
this.started = Date.now();
|
|
34
44
|
this.lastSecondStarted = Date.now();
|
package/dist/stream/sizeStack.js
CHANGED
|
@@ -5,11 +5,12 @@ const js_lib_1 = require("@naturalcycles/js-lib");
|
|
|
5
5
|
const colors_1 = require("../colors/colors");
|
|
6
6
|
const zip_util_1 = require("../util/zip.util");
|
|
7
7
|
class SizeStack extends js_lib_1.NumberStack {
|
|
8
|
+
name;
|
|
8
9
|
constructor(name, size) {
|
|
9
10
|
super(size);
|
|
10
11
|
this.name = name;
|
|
11
|
-
this.total = 0;
|
|
12
12
|
}
|
|
13
|
+
total = 0;
|
|
13
14
|
push(item) {
|
|
14
15
|
this.total += item;
|
|
15
16
|
return super.push(item);
|
package/dist/util/zip.util.js
CHANGED
|
@@ -10,11 +10,11 @@ exports.gzipString = gzipString;
|
|
|
10
10
|
exports.gunzipToString = gunzipToString;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const node_util_1 = require("node:util");
|
|
13
|
-
const
|
|
14
|
-
const deflate = (0, node_util_1.promisify)(
|
|
15
|
-
const inflate = (0, node_util_1.promisify)(
|
|
16
|
-
const gzip = (0, node_util_1.promisify)(
|
|
17
|
-
const gunzip = (0, node_util_1.promisify)(
|
|
13
|
+
const node_zlib_1 = tslib_1.__importDefault(require("node:zlib"));
|
|
14
|
+
const deflate = (0, node_util_1.promisify)(node_zlib_1.default.deflate.bind(node_zlib_1.default));
|
|
15
|
+
const inflate = (0, node_util_1.promisify)(node_zlib_1.default.inflate.bind(node_zlib_1.default));
|
|
16
|
+
const gzip = (0, node_util_1.promisify)(node_zlib_1.default.gzip.bind(node_zlib_1.default));
|
|
17
|
+
const gunzip = (0, node_util_1.promisify)(node_zlib_1.default.gunzip.bind(node_zlib_1.default));
|
|
18
18
|
// string > compressed buffer
|
|
19
19
|
/**
|
|
20
20
|
* deflateBuffer uses `deflate`.
|
|
@@ -12,6 +12,7 @@ const getAjv_1 = require("./getAjv");
|
|
|
12
12
|
* @experimental
|
|
13
13
|
*/
|
|
14
14
|
class AjvSchema {
|
|
15
|
+
schema;
|
|
15
16
|
constructor(schema, cfg = {}) {
|
|
16
17
|
this.schema = schema;
|
|
17
18
|
this.cfg = {
|
|
@@ -62,6 +63,8 @@ class AjvSchema {
|
|
|
62
63
|
const schema = index_1.fs2.readJson(filePath);
|
|
63
64
|
return new AjvSchema(schema, cfg);
|
|
64
65
|
}
|
|
66
|
+
cfg;
|
|
67
|
+
validateFunction;
|
|
65
68
|
/**
|
|
66
69
|
* It returns the original object just for convenience.
|
|
67
70
|
* Reminder: Ajv will MUTATE your object under 2 circumstances:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IsoDate } from '@naturalcycles/js-lib';
|
|
2
|
-
import type
|
|
2
|
+
import type Joi from 'joi';
|
|
3
3
|
import type { Extension, StringSchema as JoiStringSchema } from 'joi';
|
|
4
4
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
5
5
|
dateString: (min?: IsoDate | 'today', max?: IsoDate | 'today') => StringSchema<IsoDate>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
5
|
import type { UnixTimestamp } from '@naturalcycles/js-lib'
|
|
6
|
-
import
|
|
6
|
+
import yargs from 'yargs'
|
|
7
7
|
import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs/json2env'
|
|
8
8
|
import { runScript } from '../script/runScript'
|
|
9
9
|
import { generateBuildInfo } from '../util/buildInfo.util'
|
package/src/bin/json2env.ts
CHANGED
package/src/bin/kpy.ts
CHANGED
package/src/bin/slack-this.ts
CHANGED
package/src/colors/colors.ts
CHANGED
package/src/fs/fs2.ts
CHANGED
|
@@ -17,11 +17,11 @@ Credit to: fs-extra (https://github.com/jprichardson/node-fs-extra)
|
|
|
17
17
|
import type { RmOptions, Stats } from 'node:fs'
|
|
18
18
|
import fs from 'node:fs'
|
|
19
19
|
import fsp from 'node:fs/promises'
|
|
20
|
-
import
|
|
20
|
+
import path from 'node:path'
|
|
21
21
|
import { createGzip, createUnzip } from 'node:zlib'
|
|
22
22
|
import { _isTruthy, _jsonParse } from '@naturalcycles/js-lib'
|
|
23
23
|
import type { DumpOptions } from 'js-yaml'
|
|
24
|
-
import
|
|
24
|
+
import yaml from 'js-yaml'
|
|
25
25
|
import { transformToNDJson } from '../stream/ndjson/transformToNDJson'
|
|
26
26
|
import type { ReadableTyped, TransformTyped } from '../stream/stream.model'
|
|
27
27
|
import { transformSplitOnNewline } from '../stream/transform/transformSplit'
|
package/src/fs/json2env.ts
CHANGED
package/src/fs/kpy.ts
CHANGED
package/src/index.ts
CHANGED
package/src/jwt/jwt.service.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { AnyObject, ErrorData, JWTString } from '@naturalcycles/js-lib'
|
|
|
2
2
|
import { _assert, _errorDataAppend } from '@naturalcycles/js-lib'
|
|
3
3
|
import type { AnySchema } from 'joi'
|
|
4
4
|
import type { Algorithm, JwtHeader, SignOptions, VerifyOptions } from 'jsonwebtoken'
|
|
5
|
-
import
|
|
5
|
+
import jsonwebtoken from 'jsonwebtoken'
|
|
6
6
|
import { anyObjectSchema } from '../validation/joi/joi.shared.schemas'
|
|
7
7
|
import { validate } from '../validation/joi/joi.validation.util'
|
|
8
8
|
export { jsonwebtoken }
|
package/src/script/runScript.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
3
|
import { _assert } from '@naturalcycles/js-lib'
|
|
4
4
|
import { dimGrey, yellow } from '../colors/colors'
|
|
5
5
|
import { fastGlob, fs2 } from '../index'
|
package/src/util/zip.util.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IsoDate } from '@naturalcycles/js-lib'
|
|
2
2
|
import { localTime } from '@naturalcycles/js-lib'
|
|
3
|
-
import type
|
|
3
|
+
import type Joi from 'joi'
|
|
4
4
|
import type { Extension, StringSchema as JoiStringSchema } from 'joi'
|
|
5
5
|
|
|
6
6
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|