@naturalcycles/dev-lib 19.15.0 → 19.17.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,26 @@
1
+ import { _ms } from '@naturalcycles/js-lib/datetime'
2
+
3
+ export class SummaryReporter {
4
+ constructor(cfg = {}) {
5
+ this.cfg = cfg
6
+ }
7
+
8
+ onTestRunEnd(testModules) {
9
+ const { count = 5 } = this.cfg
10
+
11
+ let stats = []
12
+
13
+ for (const mod of testModules) {
14
+ const name = mod.moduleId.split('/').at(-1)
15
+ const diag = mod.diagnostic()
16
+ stats.push({ name, ms: diag.duration })
17
+ }
18
+
19
+ stats = stats.sort((a, b) => b.ms - a.ms).slice(0, count)
20
+
21
+ console.log(' Slowest:')
22
+ stats.forEach(({ name, ms }) => {
23
+ console.log(String(_ms(ms)).padStart(10), name)
24
+ })
25
+ }
26
+ }
@@ -16,3 +16,4 @@ export function defineVitestConfig(config?: Partial<ViteUserConfig>): ViteUserCo
16
16
  export const sharedConfig: InlineConfig
17
17
 
18
18
  export const CollectReporter: any
19
+ export const SummaryReporter: any
@@ -1,6 +1,8 @@
1
1
  import fs from 'node:fs'
2
2
  import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.js'
3
3
  import { defineConfig } from 'vitest/config'
4
+ import { SummaryReporter } from './summaryReporter.js'
5
+ export { SummaryReporter } from './summaryReporter.js'
4
6
  export { CollectReporter } from './collectReporter.js'
5
7
 
6
8
  const runsInIDE = doesItRunInIDE()
@@ -90,6 +92,7 @@ export const sharedConfig = {
90
92
  exclude,
91
93
  reporters: [
92
94
  'default',
95
+ new SummaryReporter(),
93
96
  junitReporterEnabled && [
94
97
  'junit',
95
98
  {
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ try {
4
+ spawnSync('pnpm', ['outdated'], {
5
+ encoding: 'utf8',
6
+ stdio: 'inherit',
7
+ shell: false,
8
+ });
9
+ }
10
+ catch {
11
+ // suppress the error, since `pnpm outdated`
12
+ // returns non-zero exit code if any outdated deps are found,
13
+ // but in fact it's perfectly fine and not an error exit
14
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "19.15.0",
4
+ "version": "19.17.0",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@commitlint/cli": "^19",
@@ -72,6 +72,7 @@
72
72
  "main": "dist/index.js",
73
73
  "types": "dist/index.d.ts",
74
74
  "bin": {
75
+ "out": "dist/bin/out.js",
75
76
  "dev-lib": "dist/bin/dev-lib.js"
76
77
  },
77
78
  "engines": {
@@ -97,6 +98,7 @@
97
98
  "typecheck": "tsx ./src/bin/dev-lib.ts typecheck",
98
99
  "clean": "tsx ./src/bin/dev-lib.ts clean",
99
100
  "build": "tsx ./src/bin/dev-lib.ts build",
101
+ "out": "tsx ./src/bin/out.ts",
100
102
  "test": "tsx ./src/bin/dev-lib.ts test",
101
103
  "test-leaks": "tsx ./src/bin/dev-lib.ts test-leaks",
102
104
  "test-integration": "tsx ./src/bin/dev-lib.ts test-integration",