@naturalcycles/nodejs-lib 13.42.0 → 13.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -72,5 +72,6 @@ export * from './validation/joi/joi.shared.schemas';
72
72
  export * from './validation/joi/joi.validation.error';
73
73
  export * from './validation/joi/joi.validation.util';
74
74
  export type { StringSchema } from './validation/joi/string.extensions';
75
+ export * from './yargs.util';
75
76
  export type { AlternativesSchema, AnySchema, ArraySchema, BinarySchema, BooleanSchema, DateSchema, FastGlobOptions, FunctionSchema, ObjectSchema, ValidationErrorItem, };
76
77
  export { Ajv, fastGlob };
package/dist/index.js CHANGED
@@ -75,3 +75,4 @@ tslib_1.__exportStar(require("./validation/joi/joi.model"), exports);
75
75
  tslib_1.__exportStar(require("./validation/joi/joi.shared.schemas"), exports);
76
76
  tslib_1.__exportStar(require("./validation/joi/joi.validation.error"), exports);
77
77
  tslib_1.__exportStar(require("./validation/joi/joi.validation.util"), exports);
78
+ tslib_1.__exportStar(require("./yargs.util"), exports);
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runScript = runScript;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
6
- const node_util_1 = require("node:util");
7
6
  const js_lib_1 = require("@naturalcycles/js-lib");
7
+ const colors_1 = require("../colors/colors");
8
8
  const inspect_1 = require("../string/inspect");
9
9
  const { DEBUG_RUN_SCRIPT } = process.env;
10
10
  /**
@@ -66,13 +66,13 @@ function runScript(fn, opt = {}) {
66
66
  })();
67
67
  }
68
68
  function logEnvironment() {
69
- const { platform, arch, versions: { node }, env: { CPU_LIMIT, NODE_OPTIONS = 'not defined' }, } = process;
69
+ const { platform, arch, versions: { node }, env: { CPU_LIMIT, NODE_OPTIONS }, } = process;
70
70
  const cpuLimit = Number(CPU_LIMIT) || undefined;
71
71
  const availableParallelism = node_os_1.default.availableParallelism?.();
72
72
  const cpus = node_os_1.default.cpus().length;
73
- console.log(dimGrey(Object.entries({
73
+ console.log((0, colors_1.dimGrey)(Object.entries({
74
74
  node: `${node} ${platform} ${arch}`,
75
- NODE_OPTIONS,
75
+ NODE_OPTIONS: NODE_OPTIONS || 'not defined',
76
76
  cpus,
77
77
  availableParallelism,
78
78
  cpuLimit,
@@ -86,6 +86,3 @@ function logEnvironment() {
86
86
  console.warn(`It looks like you're using "max_old_space_size" syntax with underscores instead of dashes - it's WRONG and doesn't work in environment variables. Strongly advised to rename it to "max-old-space-size"`);
87
87
  }
88
88
  }
89
- function dimGrey(s) {
90
- return (0, node_util_1.styleText)(['dim', 'grey'], s);
91
- }
@@ -0,0 +1,6 @@
1
+ import yargs from 'yargs';
2
+ /**
3
+ * Quick yargs helper to make it work in esm.
4
+ * It also allows to not have yargs and `@types/yargs` to be declared as dependencies.
5
+ */
6
+ export declare function _yargs(): yargs.Argv<{}>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._yargs = _yargs;
4
+ const tslib_1 = require("tslib");
5
+ const yargs_1 = tslib_1.__importDefault(require("yargs"));
6
+ const helpers_1 = require("yargs/helpers");
7
+ /**
8
+ * Quick yargs helper to make it work in esm.
9
+ * It also allows to not have yargs and `@types/yargs` to be declared as dependencies.
10
+ */
11
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
12
+ function _yargs() {
13
+ return (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv));
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.42.0",
3
+ "version": "13.43.1",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
@@ -23,6 +23,7 @@
23
23
  "@naturalcycles/js-lib": "^14",
24
24
  "@types/js-yaml": "^4",
25
25
  "@types/jsonwebtoken": "^9",
26
+ "@types/yargs": "^16",
26
27
  "ajv": "^8",
27
28
  "ajv-formats": "^3",
28
29
  "ajv-keywords": "^5",
@@ -41,7 +42,6 @@
41
42
  "@naturalcycles/dev-lib": "^16",
42
43
  "@types/node": "^22",
43
44
  "@types/through2-concurrent": "^2",
44
- "@types/yargs": "^16",
45
45
  "@vitest/coverage-v8": "^3",
46
46
  "tsx": "^4",
47
47
  "vitest": "^3"
package/src/index.ts CHANGED
@@ -82,6 +82,7 @@ export * from './validation/joi/joi.shared.schemas'
82
82
  export * from './validation/joi/joi.validation.error'
83
83
  export * from './validation/joi/joi.validation.util'
84
84
  export type { StringSchema } from './validation/joi/string.extensions'
85
+ export * from './yargs.util'
85
86
 
86
87
  export type {
87
88
  AlternativesSchema,
@@ -1,7 +1,7 @@
1
1
  import os from 'node:os'
2
- import { styleText } from 'node:util'
3
2
  import type { CommonLogger } from '@naturalcycles/js-lib'
4
3
  import { pDelay, setGlobalStringifyFunction } from '@naturalcycles/js-lib'
4
+ import { dimGrey } from '../colors/colors'
5
5
  import { inspectStringifyFn } from '../string/inspect'
6
6
 
7
7
  export interface RunScriptOptions {
@@ -95,7 +95,7 @@ function logEnvironment(): void {
95
95
  platform,
96
96
  arch,
97
97
  versions: { node },
98
- env: { CPU_LIMIT, NODE_OPTIONS = 'not defined' },
98
+ env: { CPU_LIMIT, NODE_OPTIONS },
99
99
  } = process
100
100
 
101
101
  const cpuLimit = Number(CPU_LIMIT) || undefined
@@ -105,7 +105,7 @@ function logEnvironment(): void {
105
105
  dimGrey(
106
106
  Object.entries({
107
107
  node: `${node} ${platform} ${arch}`,
108
- NODE_OPTIONS,
108
+ NODE_OPTIONS: NODE_OPTIONS || 'not defined',
109
109
  cpus,
110
110
  availableParallelism,
111
111
  cpuLimit,
@@ -125,7 +125,3 @@ function logEnvironment(): void {
125
125
  )
126
126
  }
127
127
  }
128
-
129
- function dimGrey(s: string): string {
130
- return styleText(['dim', 'grey'], s)
131
- }
@@ -0,0 +1,11 @@
1
+ import yargs from 'yargs'
2
+ import { hideBin } from 'yargs/helpers'
3
+
4
+ /**
5
+ * Quick yargs helper to make it work in esm.
6
+ * It also allows to not have yargs and `@types/yargs` to be declared as dependencies.
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
9
+ export function _yargs() {
10
+ return yargs(hideBin(process.argv))
11
+ }