@naturalcycles/nodejs-lib 14.3.2 → 14.3.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.
|
@@ -6,10 +6,10 @@ import { dimGrey, yellow } from '../colors/colors.js';
|
|
|
6
6
|
import { fs2 } from '../fs/fs2.js';
|
|
7
7
|
import { decryptObject, decryptRandomIVBuffer } from '../security/crypto.util.js';
|
|
8
8
|
// Debug it like this:
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
9
|
+
// pn tsx scripts/./src/bin/secrets-encrypt.ts --file ./src/test/secrets2.plain.json --jsonMode --encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
10
|
+
// pn tsx scripts/./src/bin/secrets-decrypt.ts --file ./src/test/secrets2.json --jsonMode --encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
11
|
+
// pn tsx scripts/./src/bin/secrets-encrypt.ts --file ./src/test/secrets.json -encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
12
|
+
// pn tsx scripts/./src/bin/secrets-decrypt.ts --file ./src/test/secrets.json.enc -encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
13
13
|
/**
|
|
14
14
|
* Decrypts all files in given directory (*.enc), saves decrypted versions without ending `.enc`.
|
|
15
15
|
* Using provided encKey.
|
package/dist/util/exec2.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyObject, type NumberOfMilliseconds } from '@naturalcycles/js-lib';
|
|
2
2
|
import { AppError } from '@naturalcycles/js-lib';
|
|
3
3
|
/**
|
|
4
4
|
* Set of utility functions to work with Spawn / Exec.
|
package/dist/util/exec2.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execSync, spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { _substringAfterLast, } from '@naturalcycles/js-lib';
|
|
2
3
|
import { _since, AppError } from '@naturalcycles/js-lib';
|
|
3
4
|
import { dimGrey, dimRed, hasColors, white } from '../colors/colors.js';
|
|
4
5
|
/**
|
|
@@ -152,6 +153,11 @@ class Exec2 {
|
|
|
152
153
|
}
|
|
153
154
|
resolve();
|
|
154
155
|
});
|
|
156
|
+
// Important to have this error listener.
|
|
157
|
+
// Without it - the process hangs, and `close` is never emitted
|
|
158
|
+
p.on('error', err => {
|
|
159
|
+
console.error(err);
|
|
160
|
+
});
|
|
155
161
|
});
|
|
156
162
|
}
|
|
157
163
|
/**
|
|
@@ -224,6 +230,11 @@ class Exec2 {
|
|
|
224
230
|
}
|
|
225
231
|
resolve(o);
|
|
226
232
|
});
|
|
233
|
+
// Important to have this error listener.
|
|
234
|
+
// Without it - the process hangs, and `close` is never emitted
|
|
235
|
+
p.on('error', err => {
|
|
236
|
+
console.error(err);
|
|
237
|
+
});
|
|
227
238
|
});
|
|
228
239
|
}
|
|
229
240
|
logStart(cmd, opt) {
|
|
@@ -231,7 +242,7 @@ class Exec2 {
|
|
|
231
242
|
return;
|
|
232
243
|
console.log([
|
|
233
244
|
dimGrey(...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('='))),
|
|
234
|
-
white(opt.name || cmd),
|
|
245
|
+
white(opt.name || _substringAfterLast(cmd, '/')),
|
|
235
246
|
...((!opt.name && opt.args) || []),
|
|
236
247
|
]
|
|
237
248
|
.filter(Boolean)
|
|
@@ -241,7 +252,7 @@ class Exec2 {
|
|
|
241
252
|
if (isSuccessful && !opt.logFinish)
|
|
242
253
|
return;
|
|
243
254
|
console.log([
|
|
244
|
-
white(opt.name || cmd),
|
|
255
|
+
white(opt.name || _substringAfterLast(cmd, '/')),
|
|
245
256
|
...((!opt.name && opt.args) || []),
|
|
246
257
|
dimGrey('took ' + _since(started)),
|
|
247
258
|
!isSuccessful && dimGrey('and ') + dimRed('failed'),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "14.3.
|
|
4
|
+
"version": "14.3.4",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@types/js-yaml": "^4",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"yargs": "^17"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@naturalcycles/dev-lib": "*",
|
|
24
25
|
"@types/through2-concurrent": "^2"
|
|
25
26
|
},
|
|
26
27
|
"bin": {
|
|
@@ -15,11 +15,11 @@ export interface DecryptCLIOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// Debug it like this:
|
|
18
|
-
//
|
|
19
|
-
//
|
|
18
|
+
// pn tsx scripts/./src/bin/secrets-encrypt.ts --file ./src/test/secrets2.plain.json --jsonMode --encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
19
|
+
// pn tsx scripts/./src/bin/secrets-decrypt.ts --file ./src/test/secrets2.json --jsonMode --encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
20
20
|
|
|
21
|
-
//
|
|
22
|
-
//
|
|
21
|
+
// pn tsx scripts/./src/bin/secrets-encrypt.ts --file ./src/test/secrets.json -encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
22
|
+
// pn tsx scripts/./src/bin/secrets-decrypt.ts --file ./src/test/secrets.json.enc -encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Decrypts all files in given directory (*.enc), saves decrypted versions without ending `.enc`.
|
package/src/util/exec2.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { execSync, spawn, spawnSync } from 'node:child_process'
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
_substringAfterLast,
|
|
4
|
+
type AnyObject,
|
|
5
|
+
type NumberOfMilliseconds,
|
|
6
|
+
type UnixTimestampMillis,
|
|
7
|
+
} from '@naturalcycles/js-lib'
|
|
3
8
|
import { _since, AppError } from '@naturalcycles/js-lib'
|
|
4
9
|
import { dimGrey, dimRed, hasColors, white } from '../colors/colors.js'
|
|
5
10
|
|
|
@@ -162,6 +167,12 @@ class Exec2 {
|
|
|
162
167
|
}
|
|
163
168
|
resolve()
|
|
164
169
|
})
|
|
170
|
+
|
|
171
|
+
// Important to have this error listener.
|
|
172
|
+
// Without it - the process hangs, and `close` is never emitted
|
|
173
|
+
p.on('error', err => {
|
|
174
|
+
console.error(err)
|
|
175
|
+
})
|
|
165
176
|
})
|
|
166
177
|
}
|
|
167
178
|
|
|
@@ -247,6 +258,12 @@ class Exec2 {
|
|
|
247
258
|
}
|
|
248
259
|
resolve(o)
|
|
249
260
|
})
|
|
261
|
+
|
|
262
|
+
// Important to have this error listener.
|
|
263
|
+
// Without it - the process hangs, and `close` is never emitted
|
|
264
|
+
p.on('error', err => {
|
|
265
|
+
console.error(err)
|
|
266
|
+
})
|
|
250
267
|
})
|
|
251
268
|
}
|
|
252
269
|
|
|
@@ -256,7 +273,7 @@ class Exec2 {
|
|
|
256
273
|
console.log(
|
|
257
274
|
[
|
|
258
275
|
dimGrey(...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('='))),
|
|
259
|
-
white(opt.name || cmd),
|
|
276
|
+
white(opt.name || _substringAfterLast(cmd, '/')),
|
|
260
277
|
...((!opt.name && (opt as SpawnOptions).args) || []),
|
|
261
278
|
]
|
|
262
279
|
.filter(Boolean)
|
|
@@ -274,7 +291,7 @@ class Exec2 {
|
|
|
274
291
|
|
|
275
292
|
console.log(
|
|
276
293
|
[
|
|
277
|
-
white(opt.name || cmd),
|
|
294
|
+
white(opt.name || _substringAfterLast(cmd, '/')),
|
|
278
295
|
...((!opt.name && (opt as SpawnOptions).args) || []),
|
|
279
296
|
dimGrey('took ' + _since(started)),
|
|
280
297
|
!isSuccessful && dimGrey('and ') + dimRed('failed'),
|