@naturalcycles/dev-lib 20.19.0 → 20.20.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/summaryOnlyReporter.js +26 -0
- package/cfg/vitest.config.d.ts +4 -1
- package/cfg/vitest.config.js +27 -11
- package/dist/bin/dev-lib.js +9 -0
- package/dist/lint.util.d.ts +3 -1
- package/dist/lint.util.js +14 -10
- package/package.json +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { _ms } from '@naturalcycles/js-lib/datetime'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A minimal reporter that only shows failures and the final summary.
|
|
5
|
+
* No per-test, no per-file output - just failures and final summary.
|
|
6
|
+
*
|
|
7
|
+
* Use via: VITEST_REPORTER=summary vitest run
|
|
8
|
+
*/
|
|
9
|
+
export class SummaryOnlyReporter {
|
|
10
|
+
onTestRunEnd(testModules) {
|
|
11
|
+
let files = 0
|
|
12
|
+
let duration = 0
|
|
13
|
+
|
|
14
|
+
for (const mod of testModules) {
|
|
15
|
+
files++
|
|
16
|
+
duration += mod.diagnostic().duration
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log()
|
|
20
|
+
console.log(` Files: ${files}`)
|
|
21
|
+
console.log(` Duration: ${_ms(duration)}`)
|
|
22
|
+
console.log()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default SummaryOnlyReporter
|
package/cfg/vitest.config.d.ts
CHANGED
|
@@ -21,4 +21,7 @@ export function defineVitestConfig(config?: Partial<ViteUserConfig>, cwd?: strin
|
|
|
21
21
|
export function getSharedConfig(cwd?: string): InlineConfig
|
|
22
22
|
|
|
23
23
|
export const CollectReporter: any
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
export class SummaryReporter {}
|
|
26
|
+
|
|
27
|
+
export class SummaryOnlyReporter {}
|
package/cfg/vitest.config.js
CHANGED
|
@@ -2,8 +2,10 @@ import fs from 'node:fs'
|
|
|
2
2
|
import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.js'
|
|
3
3
|
import { defineConfig } from 'vitest/config'
|
|
4
4
|
import { SummaryReporter } from './summaryReporter.js'
|
|
5
|
+
import { SummaryOnlyReporter } from './summaryOnlyReporter.js'
|
|
5
6
|
export { SummaryReporter } from './summaryReporter.js'
|
|
6
7
|
export { CollectReporter } from './collectReporter.js'
|
|
8
|
+
export { SummaryOnlyReporter } from './summaryOnlyReporter.js'
|
|
7
9
|
|
|
8
10
|
const runsInIDE = doesItRunInIDE()
|
|
9
11
|
const testType = getTestType(runsInIDE)
|
|
@@ -90,17 +92,7 @@ export function getSharedConfig(cwd) {
|
|
|
90
92
|
},
|
|
91
93
|
include,
|
|
92
94
|
exclude,
|
|
93
|
-
reporters:
|
|
94
|
-
'default',
|
|
95
|
-
new SummaryReporter(),
|
|
96
|
-
junitReporterEnabled && [
|
|
97
|
-
'junit',
|
|
98
|
-
{
|
|
99
|
-
suiteName: `${testType} tests`,
|
|
100
|
-
// classNameTemplate: '{filename} - {classname}',
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
].filter(Boolean),
|
|
95
|
+
reporters: getReporters(junitReporterEnabled, testType),
|
|
104
96
|
// outputFile location is specified for compatibility with the previous jest config
|
|
105
97
|
outputFile: junitReporterEnabled ? `./tmp/jest/${testType}.xml` : undefined,
|
|
106
98
|
coverage: {
|
|
@@ -130,6 +122,30 @@ export function getSharedConfig(cwd) {
|
|
|
130
122
|
}
|
|
131
123
|
}
|
|
132
124
|
|
|
125
|
+
function getReporters(junitReporterEnabled, testType) {
|
|
126
|
+
// VITEST_REPORTER env var allows overriding the default reporter
|
|
127
|
+
// e.g., VITEST_REPORTER=summary for minimal output
|
|
128
|
+
const { VITEST_REPORTER, CLAUDE_CODE } = process.env
|
|
129
|
+
|
|
130
|
+
if (VITEST_REPORTER === 'summary' || CLAUDE_CODE) {
|
|
131
|
+
return [new SummaryOnlyReporter()]
|
|
132
|
+
}
|
|
133
|
+
if (VITEST_REPORTER === 'dot') {
|
|
134
|
+
return ['dot']
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return [
|
|
138
|
+
'default',
|
|
139
|
+
new SummaryReporter(),
|
|
140
|
+
junitReporterEnabled && [
|
|
141
|
+
'junit',
|
|
142
|
+
{
|
|
143
|
+
suiteName: `${testType} tests`,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
].filter(Boolean)
|
|
147
|
+
}
|
|
148
|
+
|
|
133
149
|
function doesItRunInIDE() {
|
|
134
150
|
// example command line below:
|
|
135
151
|
// /usr/local/bin/node /Users/some/Idea/some/node_modules/vitest/vitest.mjs --run --reporter /Users/some/Library/Application Support/JetBrains/IntelliJIdea2025.2/plugins/javascript-plugin/helpers/vitest-intellij/node_modules/vitest-intellij-reporter-safe.js --testNamePattern=^ ?case 001: empty data$ /Users/some/Idea/some/src/some/some.integration.test.ts
|
package/dist/bin/dev-lib.js
CHANGED
|
@@ -9,6 +9,11 @@ import { eslintAll, lintAllCommand, lintStagedCommand, requireOxlintConfig, runB
|
|
|
9
9
|
import { runTest } from '../test.util.js';
|
|
10
10
|
const commands = [
|
|
11
11
|
{ name: 'check', fn: check, desc: '"Run all possible checks": lint, typecheck, then test.' },
|
|
12
|
+
{
|
|
13
|
+
name: 'quick-check',
|
|
14
|
+
fn: quickCheck,
|
|
15
|
+
desc: 'Like check, but without slow parts, to perform preliminary checks',
|
|
16
|
+
},
|
|
12
17
|
{ name: 'bt', fn: bt, desc: 'Build & Test: run "typecheck" (via oxlint) and then "test".' },
|
|
13
18
|
{
|
|
14
19
|
name: 'typecheck',
|
|
@@ -154,6 +159,10 @@ async function check() {
|
|
|
154
159
|
await lintAllCommand();
|
|
155
160
|
runTest();
|
|
156
161
|
}
|
|
162
|
+
async function quickCheck() {
|
|
163
|
+
await lintAllCommand(false);
|
|
164
|
+
runTest();
|
|
165
|
+
}
|
|
157
166
|
async function bt() {
|
|
158
167
|
await typecheckWithOxlint();
|
|
159
168
|
runTest();
|
package/dist/lint.util.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SemVerString } from '@naturalcycles/js-lib/types';
|
|
2
2
|
/**
|
|
3
3
|
* Run all linters.
|
|
4
|
+
*
|
|
5
|
+
* If full=false - the "slow" linters are skipped.
|
|
4
6
|
*/
|
|
5
|
-
export declare function lintAllCommand(): Promise<void>;
|
|
7
|
+
export declare function lintAllCommand(full?: boolean): Promise<void>;
|
|
6
8
|
interface EslintAllOptions {
|
|
7
9
|
ext?: string;
|
|
8
10
|
fix?: boolean;
|
package/dist/lint.util.js
CHANGED
|
@@ -16,8 +16,10 @@ import { cfgDir } from './paths.js';
|
|
|
16
16
|
const { CI, ESLINT_CONCURRENCY } = process.env;
|
|
17
17
|
/**
|
|
18
18
|
* Run all linters.
|
|
19
|
+
*
|
|
20
|
+
* If full=false - the "slow" linters are skipped.
|
|
19
21
|
*/
|
|
20
|
-
export async function lintAllCommand() {
|
|
22
|
+
export async function lintAllCommand(full = true) {
|
|
21
23
|
const started = Date.now();
|
|
22
24
|
// const { commitOnChanges, failOnChanges } = _yargs().options({
|
|
23
25
|
// commitOnChanges: {
|
|
@@ -44,16 +46,18 @@ export async function lintAllCommand() {
|
|
|
44
46
|
runBiome(fix);
|
|
45
47
|
runOxlint(fix);
|
|
46
48
|
// From this point we start the "slow" linters, with ESLint leading the way
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
existsSync(`node_modules/stylelint
|
|
53
|
-
|
|
49
|
+
if (full) {
|
|
50
|
+
// We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
|
|
51
|
+
eslintAll({
|
|
52
|
+
fix,
|
|
53
|
+
});
|
|
54
|
+
if (existsSync(`node_modules/stylelint`) &&
|
|
55
|
+
existsSync(`node_modules/stylelint-config-standard-scss`)) {
|
|
56
|
+
stylelintAll(fix);
|
|
57
|
+
}
|
|
58
|
+
runPrettier({ fix });
|
|
59
|
+
await runKTLint(fix);
|
|
54
60
|
}
|
|
55
|
-
runPrettier({ fix });
|
|
56
|
-
await runKTLint(fix);
|
|
57
61
|
console.log(`${check(true)}${white(`lint-all`)} ${dimGrey(`took ` + _since(started))}`);
|
|
58
62
|
// if (needToTrackChanges) {
|
|
59
63
|
// const gitStatusAfter = gitStatus()
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/dev-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.20.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@biomejs/biome": "^2",
|
|
7
7
|
"@eslint/js": "^9",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"eslint-plugin-simple-import-sort": "^12",
|
|
17
17
|
"eslint-plugin-unicorn": "^62",
|
|
18
18
|
"eslint-plugin-vue": "^10",
|
|
19
|
-
"globals": "^
|
|
19
|
+
"globals": "^17",
|
|
20
20
|
"lint-staged": "^16",
|
|
21
21
|
"micromatch": "^4",
|
|
22
22
|
"mitm": "^1",
|