@naturalcycles/dev-lib 19.6.1 → 19.8.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.
@@ -0,0 +1,30 @@
1
+ export class CollectReporter {
2
+ onTestModuleEnd(testModule) {
3
+ const shortModuleId = testModule.moduleId.split('/').at(-1)
4
+
5
+ console.log(shortModuleId, Math.round(testModule.diagnostic().collectDuration))
6
+
7
+ const selfTimeMap = {}
8
+ const totalTimeMap = {}
9
+
10
+ Object.entries(testModule.diagnostic().importDurations).forEach(([k, v]) => {
11
+ const short = k.split('/').at(-3) + '/' + k.split('/').at(-2) + '/' + k.split('/').at(-1)
12
+ // if (Math.round(v.totalTime) < 5) return // skip <0.5ms imports
13
+ selfTimeMap[short] = Math.round(v.selfTime)
14
+ totalTimeMap[short] = Math.round(v.totalTime)
15
+ })
16
+
17
+ const sortedSelfTimeMap = Object.fromEntries(
18
+ Object.entries(selfTimeMap).sort((a, b) => b[1] - a[1]),
19
+ )
20
+ const sortedTotalTimeMap = Object.fromEntries(
21
+ Object.entries(totalTimeMap).sort((a, b) => b[1] - a[1]),
22
+ )
23
+
24
+ console.log({ sortedSelfTimeMap })
25
+ console.log({ sortedTotalTimeMap })
26
+ }
27
+ // onTestRunEnd() {
28
+ // console.log('Test run ended')
29
+ // }
30
+ }
@@ -14,3 +14,5 @@ import type { InlineConfig } from 'vitest/node'
14
14
  export function defineVitestConfig(config?: Partial<ViteUserConfig>): ViteUserConfig
15
15
 
16
16
  export const sharedConfig: InlineConfig
17
+
18
+ export const CollectReporter: any
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs'
2
2
  import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.js'
3
3
  import { defineConfig } from 'vitest/config'
4
+ export { CollectReporter } from './collectReporter.js'
4
5
 
5
6
  const runsInIDE = doesItRunInIDE()
6
7
  const testType = getTestType(runsInIDE)
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { select, Separator } from '@inquirer/prompts';
3
- import { _assert, _by } from '@naturalcycles/js-lib';
3
+ import { _by } from '@naturalcycles/js-lib';
4
+ import { _assert } from '@naturalcycles/js-lib/error';
4
5
  import { runScript } from '@naturalcycles/nodejs-lib';
5
6
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
6
7
  import { buildCopy, buildProd, runTSCInFolders } from '../build.util.js';
@@ -1,4 +1,4 @@
1
- import type { SemVerString } from '@naturalcycles/js-lib';
1
+ import type { SemVerString } from '@naturalcycles/js-lib/types';
2
2
  /**
3
3
  * Run all linters.
4
4
  */
package/dist/lint.util.js CHANGED
@@ -2,7 +2,11 @@ import { execSync } from 'node:child_process';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
4
  import path from 'node:path';
5
- import { _assert, _isTruthy, _since, _truncate, semver2 } from '@naturalcycles/js-lib';
5
+ import { _isTruthy } from '@naturalcycles/js-lib';
6
+ import { _since } from '@naturalcycles/js-lib/datetime';
7
+ import { _assert } from '@naturalcycles/js-lib/error';
8
+ import { semver2 } from '@naturalcycles/js-lib/semver';
9
+ import { _truncate } from '@naturalcycles/js-lib/string';
6
10
  import { git2 } from '@naturalcycles/nodejs-lib';
7
11
  import { boldGrey, dimGrey } from '@naturalcycles/nodejs-lib/colors';
8
12
  import { exec2 } from '@naturalcycles/nodejs-lib/exec2';
@@ -1,4 +1,4 @@
1
- import { AppError } from '@naturalcycles/js-lib';
1
+ import { AppError } from '@naturalcycles/js-lib/error';
2
2
  export const mockAllKindsOfThings = () => {
3
3
  const errorWithCode = new Error('Error with code');
4
4
  Object.assign(errorWithCode, {
@@ -1,3 +1,3 @@
1
1
  export declare function silentConsole(): void;
2
- export declare const testLogger: import("@naturalcycles/js-lib").CommonLogger;
3
- export declare const testLog: import("@naturalcycles/js-lib").CommonLogFunction;
2
+ export declare const testLogger: import("@naturalcycles/js-lib/log").CommonLogger;
3
+ export declare const testLog: import("@naturalcycles/js-lib/log").CommonLogFunction;
@@ -1,4 +1,4 @@
1
- import { commonLoggerCreate } from '@naturalcycles/js-lib';
1
+ import { commonLoggerCreate } from '@naturalcycles/js-lib/log';
2
2
  import { _inspect } from '@naturalcycles/nodejs-lib';
3
3
  export function silentConsole() {
4
4
  console.log = () => { };
@@ -1,4 +1,4 @@
1
- import type { UnixTimestamp } from '@naturalcycles/js-lib';
1
+ import type { UnixTimestamp } from '@naturalcycles/js-lib/types';
2
2
  export declare const MOCK_TS_2018_06_21: UnixTimestamp;
3
3
  /**
4
4
  * Locks time-related functions to return always same time.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "19.6.1",
4
+ "version": "19.8.0",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@commitlint/cli": "^19",
@@ -9,7 +9,7 @@
9
9
  "@eslint/js": "^9",
10
10
  "@inquirer/prompts": "^7",
11
11
  "@naturalcycles/js-lib": "^15",
12
- "@naturalcycles/nodejs-lib": "^15.2.0",
12
+ "@naturalcycles/nodejs-lib": "^15",
13
13
  "@stylistic/eslint-plugin": "^5",
14
14
  "@vitest/coverage-v8": "^3",
15
15
  "@vitest/eslint-plugin": "^1",