@naturalcycles/dev-lib 13.54.0 → 13.55.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/cfg/tsconfig.json CHANGED
@@ -5,9 +5,9 @@
5
5
  //
6
6
  {
7
7
  "compilerOptions": {
8
- // Disabled because of https://github.com/Microsoft/TypeScript/issues/29172
9
- // "outDir": "dist",
10
- // "rootDir": "./src",
8
+ // ${configDir} is supported since ts 5.5
9
+ "rootDir": "${configDir}/src",
10
+ "outDir": "${configDir}/dist",
11
11
 
12
12
  // Target/module
13
13
  "target": "es2022",
@@ -39,7 +39,6 @@
39
39
  "noFallthroughCasesInSwitch": true,
40
40
  "forceConsistentCasingInFileNames": true,
41
41
  "resolveJsonModule": true,
42
- "suppressImplicitAnyIndexErrors": false,
43
42
  "noImplicitOverride": true,
44
43
  "noUncheckedIndexedAccess": true,
45
44
  "noPropertyAccessFromIndexSignature": true,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildCopyCommand = void 0;
3
+ exports.buildCopyCommand = buildCopyCommand;
4
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
5
  function buildCopyCommand() {
6
6
  const baseDir = 'src';
@@ -8,7 +8,7 @@ function buildCopyCommand() {
8
8
  '**',
9
9
  '!**/*.ts',
10
10
  '!**/__snapshots__',
11
- '**/__exclude',
11
+ '!**/__exclude',
12
12
  '!test',
13
13
  '!**/*.test.js',
14
14
  ];
@@ -20,4 +20,3 @@ function buildCopyCommand() {
20
20
  dotfiles: true,
21
21
  });
22
22
  }
23
- exports.buildCopyCommand = buildCopyCommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProdESMCJSCommand = void 0;
3
+ exports.buildProdESMCJSCommand = buildProdESMCJSCommand;
4
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
5
  // You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
6
6
  const TSCONF_CJS_PATH = `./tsconfig.cjs.prod.json`;
@@ -39,4 +39,3 @@ async function buildProdESMCJSCommand() {
39
39
  ]),
40
40
  ]);
41
41
  }
42
- exports.buildProdESMCJSCommand = buildProdESMCJSCommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProdCommand = void 0;
3
+ exports.buildProdCommand = buildProdCommand;
4
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
5
  const build_copy_command_1 = require("./build-copy.command");
6
6
  const tsc_prod_command_1 = require("./tsc-prod.command");
@@ -10,4 +10,3 @@ function buildProdCommand() {
10
10
  (0, build_copy_command_1.buildCopyCommand)();
11
11
  (0, tsc_prod_command_1.tscProdCommand)();
12
12
  }
13
- exports.buildProdCommand = buildProdCommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.eslintAllCommand = void 0;
3
+ exports.eslintAllCommand = eslintAllCommand;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
6
  const js_lib_1 = require("@naturalcycles/js-lib");
@@ -61,4 +61,3 @@ async function eslintAllCommand() {
61
61
  }
62
62
  console.log(`${(0, nodejs_lib_1.boldGrey)('eslint-all')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
63
63
  }
64
- exports.eslintAllCommand = eslintAllCommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initFromDevLibCommand = void 0;
3
+ exports.initFromDevLibCommand = initFromDevLibCommand;
4
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
5
  const paths_cnst_1 = require("../cnst/paths.cnst");
6
6
  function initFromDevLibCommand() {
@@ -11,4 +11,3 @@ function initFromDevLibCommand() {
11
11
  verbose: true,
12
12
  });
13
13
  }
14
- exports.initFromDevLibCommand = initFromDevLibCommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lintAllCommand = void 0;
3
+ exports.lintAllCommand = lintAllCommand;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_child_process_1 = require("node:child_process");
6
6
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
@@ -58,7 +58,6 @@ async function lintAllCommand() {
58
58
  }
59
59
  }
60
60
  }
61
- exports.lintAllCommand = lintAllCommand;
62
61
  async function runKTLint() {
63
62
  if (node_fs_1.default.existsSync(`node_modules/@naturalcycles/ktlint`)) {
64
63
  const ktlintLib = require('@naturalcycles/ktlint');
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tscProdCommand = void 0;
3
+ exports.tscProdCommand = tscProdCommand;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
6
6
  function tscProdCommand() {
@@ -11,4 +11,3 @@ function tscProdCommand() {
11
11
  (0, nodejs_lib_1.execVoidCommandSync)(`tsc`, args);
12
12
  console.log(`${(0, nodejs_lib_1.boldGrey)('tsc prod')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
13
13
  }
14
- exports.tscProdCommand = tscProdCommand;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jestOnline = exports.jestOffline = void 0;
3
+ exports.jestOffline = jestOffline;
4
+ exports.jestOnline = jestOnline;
4
5
  const testing_1 = require("./testing");
5
6
  const LOCAL_HOSTS = ['localhost', '127.0.0.1'];
6
7
  const detectLeaks = process.argv.some(a => a.includes('detectLeaks'));
@@ -24,11 +25,9 @@ function jestOffline() {
24
25
  socket.bypass();
25
26
  });
26
27
  }
27
- exports.jestOffline = jestOffline;
28
28
  /**
29
29
  * Undo/reset the jestOffline() function by allowing network calls again.
30
30
  */
31
31
  function jestOnline() {
32
32
  mitm?.disable();
33
33
  }
34
- exports.jestOnline = jestOnline;
@@ -1,4 +1,3 @@
1
- /// <reference types="jest" />
2
1
  /**
3
2
  * expectResults(v => JSON.stringify(v), [
4
3
  * 1,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expectResults = void 0;
3
+ exports.expectResults = expectResults;
4
4
  /**
5
5
  * expectResults(v => JSON.stringify(v), [
6
6
  * 1,
@@ -11,4 +11,3 @@ exports.expectResults = void 0;
11
11
  function expectResults(fn, values) {
12
12
  return expect(new Map(values.map(v => [v, fn(v)])));
13
13
  }
14
- exports.expectResults = expectResults;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jestLog = exports.jestLogger = exports.silentConsole = void 0;
3
+ exports.jestLog = exports.jestLogger = void 0;
4
+ exports.silentConsole = silentConsole;
4
5
  const js_lib_1 = require("@naturalcycles/js-lib");
5
6
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
6
7
  function silentConsole() {
@@ -12,7 +13,6 @@ function silentConsole() {
12
13
  console.time = () => { };
13
14
  console.table = () => { };
14
15
  }
15
- exports.silentConsole = silentConsole;
16
16
  exports.jestLogger = (0, js_lib_1.commonLoggerCreate)((_level, args) => {
17
17
  if (process.env['JEST_SILENT'])
18
18
  return; // no-op
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resetTime = exports.mockTimeMillis = exports.mockTime = exports.MOCK_TS_2018_06_21 = void 0;
3
+ exports.MOCK_TS_2018_06_21 = void 0;
4
+ exports.mockTime = mockTime;
5
+ exports.mockTimeMillis = mockTimeMillis;
6
+ exports.resetTime = resetTime;
4
7
  const tslib_1 = require("tslib");
5
8
  const timekeeper_1 = tslib_1.__importDefault(require("timekeeper"));
6
9
  exports.MOCK_TS_2018_06_21 = 1_529_539_200;
@@ -11,12 +14,9 @@ exports.MOCK_TS_2018_06_21 = 1_529_539_200;
11
14
  function mockTime(ts = exports.MOCK_TS_2018_06_21) {
12
15
  mockTimeMillis(ts * 1000);
13
16
  }
14
- exports.mockTime = mockTime;
15
17
  function mockTimeMillis(millis = exports.MOCK_TS_2018_06_21 * 1000) {
16
18
  timekeeper_1.default.freeze(millis);
17
19
  }
18
- exports.mockTimeMillis = mockTimeMillis;
19
20
  function resetTime() {
20
21
  timekeeper_1.default.reset();
21
22
  }
22
- exports.resetTime = resetTime;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runJest = exports.isRunningAllTests = exports.getJestManualConfigPath = exports.getJestIntegrationConfigPath = exports.getJestConfigPath = void 0;
3
+ exports.getJestConfigPath = getJestConfigPath;
4
+ exports.getJestIntegrationConfigPath = getJestIntegrationConfigPath;
5
+ exports.getJestManualConfigPath = getJestManualConfigPath;
6
+ exports.isRunningAllTests = isRunningAllTests;
7
+ exports.runJest = runJest;
4
8
  const tslib_1 = require("tslib");
5
9
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
10
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
@@ -11,19 +15,16 @@ const test_util_1 = require("./test.util");
11
15
  function getJestConfigPath() {
12
16
  return node_fs_1.default.existsSync(`./jest.config.js`) ? './jest.config.js' : `${paths_cnst_1.cfgDir}/jest.config.js`;
13
17
  }
14
- exports.getJestConfigPath = getJestConfigPath;
15
18
  function getJestIntegrationConfigPath() {
16
19
  return node_fs_1.default.existsSync(`./jest.integration-test.config.js`)
17
20
  ? `./jest.integration-test.config.js`
18
21
  : `${paths_cnst_1.cfgDir}/jest.integration-test.config.js`;
19
22
  }
20
- exports.getJestIntegrationConfigPath = getJestIntegrationConfigPath;
21
23
  function getJestManualConfigPath() {
22
24
  return node_fs_1.default.existsSync(`./jest.manual-test.config.js`)
23
25
  ? `./jest.manual-test.config.js`
24
26
  : `${paths_cnst_1.cfgDir}/jest.manual-test.config.js`;
25
27
  }
26
- exports.getJestManualConfigPath = getJestManualConfigPath;
27
28
  /**
28
29
  * Detects if jest is run with all tests, or with specific tests.
29
30
  */
@@ -33,7 +34,6 @@ function isRunningAllTests() {
33
34
  // console.log(process.argv, positionalArgs)
34
35
  return !positionalArgs.length;
35
36
  }
36
- exports.isRunningAllTests = isRunningAllTests;
37
37
  /**
38
38
  * 1. Adds `--silent` if running all tests at once.
39
39
  */
@@ -129,4 +129,3 @@ function runJest(opt = {}) {
129
129
  });
130
130
  }
131
131
  }
132
- exports.runJest = runJest;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runESLintAsync = exports.runESLint = exports.getTSConfigPathScripts = exports.getTSConfigPath = void 0;
3
+ exports.getTSConfigPath = getTSConfigPath;
4
+ exports.getTSConfigPathScripts = getTSConfigPathScripts;
5
+ exports.runESLint = runESLint;
6
+ exports.runESLintAsync = runESLintAsync;
4
7
  const tslib_1 = require("tslib");
5
8
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
9
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
@@ -11,11 +14,9 @@ function getTSConfigPath() {
11
14
  // return [`./tsconfig.base.json`].find(p => fs.existsSync(p)) || `./tsconfig.json`
12
15
  return './tsconfig.json';
13
16
  }
14
- exports.getTSConfigPath = getTSConfigPath;
15
17
  function getTSConfigPathScripts() {
16
18
  return [`./scripts/tsconfig.json`].find(p => node_fs_1.default.existsSync(p)) || `${paths_cnst_1.scriptsDir}/tsconfig.json`;
17
19
  }
18
- exports.getTSConfigPathScripts = getTSConfigPathScripts;
19
20
  function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
20
21
  if (!node_fs_1.default.existsSync(dir))
21
22
  return; // faster to bail-out like this
@@ -25,7 +26,6 @@ function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx
25
26
  },
26
27
  });
27
28
  }
28
- exports.runESLint = runESLint;
29
29
  async function runESLintAsync(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
30
30
  if (!node_fs_1.default.existsSync(dir))
31
31
  return; // faster to bail-out like this
@@ -35,7 +35,6 @@ async function runESLintAsync(dir, eslintConfigPath, tsconfigPath, extensions =
35
35
  },
36
36
  });
37
37
  }
38
- exports.runESLintAsync = runESLintAsync;
39
38
  function getEslintArgs(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
40
39
  return [
41
40
  `--config`,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runPrettier = void 0;
3
+ exports.runPrettier = runPrettier;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
6
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
@@ -21,4 +21,3 @@ function runPrettier() {
21
21
  const args = [`--write`, `--log-level=warn`, `--config`, prettierConfigPath, ...prettierPaths];
22
22
  (0, nodejs_lib_1.execVoidCommandSync)('prettier', args);
23
23
  }
24
- exports.runPrettier = runPrettier;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stylelintAll = exports.stylelintPaths = void 0;
3
+ exports.stylelintPaths = void 0;
4
+ exports.stylelintAll = stylelintAll;
4
5
  const tslib_1 = require("tslib");
5
6
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
7
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
@@ -30,4 +31,3 @@ function stylelintAll() {
30
31
  ].filter(Boolean);
31
32
  (0, nodejs_lib_1.execVoidCommandSync)('stylelint', args);
32
33
  }
33
- exports.stylelintAll = stylelintAll;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nodeModuleExists = void 0;
3
+ exports.nodeModuleExists = nodeModuleExists;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
6
  /**
@@ -9,4 +9,3 @@ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
9
9
  function nodeModuleExists(moduleName) {
10
10
  return node_fs_1.default.existsSync(`./node_modules/${moduleName}`);
11
11
  }
12
- exports.nodeModuleExists = nodeModuleExists;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureProjectTsconfigScripts = exports.tscScriptsAsync = exports.tscScripts = exports.tscAsync = exports.tsc = exports.tscMainAndScripts = void 0;
3
+ exports.tscMainAndScripts = tscMainAndScripts;
4
+ exports.tsc = tsc;
5
+ exports.tscAsync = tscAsync;
6
+ exports.tscScripts = tscScripts;
7
+ exports.tscScriptsAsync = tscScriptsAsync;
8
+ exports.ensureProjectTsconfigScripts = ensureProjectTsconfigScripts;
4
9
  const tslib_1 = require("tslib");
5
10
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
11
  const js_lib_1 = require("@naturalcycles/js-lib");
@@ -9,21 +14,18 @@ const paths_cnst_1 = require("../cnst/paths.cnst");
9
14
  async function tscMainAndScripts(noEmit = false) {
10
15
  await Promise.all([tscAsync(noEmit), tscScriptsAsync()]);
11
16
  }
12
- exports.tscMainAndScripts = tscMainAndScripts;
13
17
  function tsc(noEmit = false) {
14
18
  const started = Date.now();
15
19
  const args = [noEmit && '--noEmit'].filter(js_lib_1._isTruthy);
16
20
  (0, nodejs_lib_1.execVoidCommandSync)('tsc', args);
17
21
  console.log(`${(0, nodejs_lib_1.boldGrey)('tsc')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
18
22
  }
19
- exports.tsc = tsc;
20
23
  async function tscAsync(noEmit = false) {
21
24
  const started = Date.now();
22
25
  const args = [noEmit && '--noEmit'].filter(js_lib_1._isTruthy);
23
26
  await (0, nodejs_lib_1.execVoidCommand)('tsc', args);
24
27
  console.log(`${(0, nodejs_lib_1.boldGrey)('tsc')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
25
28
  }
26
- exports.tscAsync = tscAsync;
27
29
  function tscScripts() {
28
30
  if (!node_fs_1.default.existsSync('./scripts')) {
29
31
  // ./scripts folder doesn't exist, skipping
@@ -35,7 +37,6 @@ function tscScripts() {
35
37
  (0, nodejs_lib_1.execVoidCommandSync)(`tsc`, args);
36
38
  console.log(`${(0, nodejs_lib_1.boldGrey)('tsc scripts')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
37
39
  }
38
- exports.tscScripts = tscScripts;
39
40
  async function tscScriptsAsync() {
40
41
  if (!node_fs_1.default.existsSync('./scripts')) {
41
42
  // ./scripts folder doesn't exist, skipping
@@ -47,7 +48,6 @@ async function tscScriptsAsync() {
47
48
  await (0, nodejs_lib_1.execVoidCommand)(`tsc`, args);
48
49
  console.log(`${(0, nodejs_lib_1.boldGrey)('tsc scripts')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
49
50
  }
50
- exports.tscScriptsAsync = tscScriptsAsync;
51
51
  /**
52
52
  * Returns path to /scripts/tsconfig.json
53
53
  */
@@ -65,4 +65,3 @@ function ensureProjectTsconfigScripts() {
65
65
  }
66
66
  return projectTsconfigPath;
67
67
  }
68
- exports.ensureProjectTsconfigScripts = ensureProjectTsconfigScripts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "13.54.0",
3
+ "version": "13.55.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "tsn-debug": "tsn testScript.ts",
@@ -4,8 +4,8 @@
4
4
  {
5
5
  "extends": "../cfg/tsconfig.json",
6
6
  "compilerOptions": {
7
- "baseUrl": "./",
8
- "outDir": "../dist",
7
+ "rootDir": "${configDir}/..",
8
+ "outDir": "${configDir}/../dist",
9
9
  },
10
10
  "exclude": ["**/__exclude"],
11
11
  }
@@ -1,2 +0,0 @@
1
-
2
- some invalid css {