headlamp 0.1.33 → 0.1.35

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/README.md CHANGED
@@ -1,205 +1,157 @@
1
- # Headlamp CLI
1
+ ### Headlamp
2
2
 
3
- Coverage-first, runner-agnostic test UX for Jest. Delegates execution to your runner, focuses on better selection and coverage insights.
3
+ Headlamp is a **Rust-powered test UX CLI**: smarter test selection, cleaner output, and a unified workflow across **jest**, **cargo test**, and **cargo nextest**.
4
4
 
5
- ## Install
5
+ Headlamp is useful when you want a consistent way to run tests across different projects and keep feedback fast as your repo grows. It can select tests based on what changed, surface failures in a readable format, and keep common defaults (like runner args and coverage settings) in a single config file so your team doesn’t have to remember a long list of flags.
6
6
 
7
- Use via npx (recommended):
7
+ ### Why Headlamp
8
8
 
9
- ```bash
10
- npx headlamp --help
11
- ```
9
+ - **One CLI, many runners**: `--runner=jest|cargo-nextest|cargo-test`
10
+ - **Selection that scales**: run what changed (`--changed`) and what’s related (dependency-graph driven)
11
+ - **Coverage-first UX**: coverage output you can actually read
12
+ - **Fast**: Rust core + caching
12
13
 
13
- Or install locally:
14
+ ### Installation
14
15
 
15
- ```bash
16
- npm i -D headlamp
17
- ```
16
+ #### npm (recommended)
18
17
 
19
- ## Usage
18
+ Requirements:
20
19
 
21
- - Delegates to your local Jest install
22
- - Renders improved coverage tables and hotspots
23
- - Selects tests by import-graph when you pass production paths
20
+ - Node **>= 18**
21
+ - A GitHub Release for your version tag (see “Releases” below)
24
22
 
25
- Quick examples:
23
+ Install:
26
24
 
27
25
  ```bash
28
- # Run tests with coverage
29
- npx headlamp --coverage
30
-
31
- # Run only tests related to selected production files
32
- npx headlamp src/services/user.ts src/components/UserCard.tsx
26
+ npm i -D headlamp
33
27
  ```
34
28
 
35
- ## CLI flags
36
-
37
- Pass your regular Jest flags (e.g. `-t`, `--testNamePattern`, paths). Headlamp forwards them, and strips/adjusts coverage-related flags when listing tests.
38
-
39
- ### General
40
-
41
- - `--bootstrapCommand <cmd>`: run once before tests (npm script name or full shell command)
42
- - `--onlyFailures[=true|false]`: show only failing tests during live output; always shows final summary
43
- - `--showLogs[=true|false]`: include full console output under failing tests/files
29
+ Run:
44
30
 
45
- ### Concurrency
46
-
47
- - `--sequential[=true|false]`: serialize execution
48
- - Effect: adds Jest `--runInBand` and runs Headlamp’s per‑project execution with stride 1 (no parallel projects)
31
+ ```bash
32
+ npx headlamp --help
33
+ ```
49
34
 
50
- ### Selection
35
+ #### Cargo (from source)
51
36
 
52
- - `paths...`: any file/dir paths; production paths trigger related test discovery by import graph
53
- - `-t <pattern>` / `--testNamePattern <pattern>`: filter by test name
54
- - `--changed[=all|staged|unstaged|branch|lastCommit]`: select tests related to changed files
55
- - `--changed.depth=<n>`: cap transitive import scan depth for changed-file discovery (default: 5)
37
+ ```bash
38
+ cargo install --path headlamp
39
+ ```
56
40
 
57
- ### Coverage
41
+ ### Quickstart
58
42
 
59
- - `--coverage`: enable coverage collection and merged reporting
60
- - `--coverage.ui=jest|both` (alias: `--coverage-ui`): output mode for Istanbul text reports (default: `both`)
61
- - `--coverage.abortOnFailure`: exit immediately with test code and skip coverage print on failures
62
- - Display/detail options:
63
- - `--coverage.mode=compact|full|auto` (default: `auto`)
64
- - `--coverage.detail=<n>|all|auto` (default: `auto`)
65
- - `--coverage.showCode=true|false` (default: `true` on TTY)
66
- - `--coverage.maxFiles=<n>`
67
- - `--coverage.maxHotspots=<n>`
68
- - `--coverage.pageFit=true|false` (default: `true` on TTY)
69
- - Globbing filters: `--coverage.include=a,b,c`, `--coverage.exclude=a,b,c`
43
+ #### Jest
70
44
 
71
- ## Configuration
45
+ ```bash
46
+ npx headlamp --runner=jest
47
+ ```
72
48
 
73
- Project-level file at repo root. CLI always overrides config. No env vars or hidden presets.
49
+ Forward runner args after `--` (unknown args are forwarded):
74
50
 
75
- ### Supported filenames
51
+ ```bash
52
+ npx headlamp --runner=jest -- --runInBand
53
+ ```
76
54
 
77
- - `headlamp.config.ts`
78
- - `headlamp.config.js` / `headlamp.config.mjs` / `headlamp.config.cjs`
79
- - `headlamp.config.json` / `headlamp.config.yaml` / `headlamp.config.yml`
55
+ #### Cargo nextest / cargo test
80
56
 
81
- ### Base defaults (always applied)
57
+ ```bash
58
+ headlamp --runner=cargo-nextest
59
+ headlamp --runner=cargo-test
60
+ ```
82
61
 
83
- - `bootstrapCommand: string`
84
- - `jestArgs: string[]`
85
- - `sequential?: boolean` – serialize tests across Jest and Headlamp
62
+ ### CLI
63
+
64
+ Current `--help` output:
65
+
66
+ ```text
67
+ headlamp
68
+
69
+ Usage:
70
+ headlamp [--runner=<jest|vitest|pytest|cargo-nextest|cargo-test>] [--coverage] [--changed[=<mode>]] [args...]
71
+
72
+ Flags:
73
+ --runner <runner> Select runner (default: jest)
74
+ --coverage Enable coverage collection (runner-specific)
75
+ --coverage-ui=jest|both Coverage output mode
76
+ --coverage.abortOnFailure Exit on test failures without printing coverage
77
+ --watch Re-run on file changes (runner-agnostic polling watch)
78
+ --ci CI mode (disable interactive UI and set CI=1)
79
+ --verbose More Headlamp diagnostics
80
+ --no-cache Disable Headlamp caches (and runner caches when possible)
81
+ --onlyFailures Show only failing tests during live output
82
+ --showLogs Show full logs under failing tests
83
+ --sequential Serialize execution (maps to jest --runInBand)
84
+ --bootstrapCommand <cmd> Run once before tests (npm script name or shell cmd)
85
+ --changed[=all|staged|unstaged|branch|lastCommit]
86
+ --changed.depth=<n>
87
+
88
+ Notes:
89
+ Unknown args are forwarded to the runner.
90
+ ```
86
91
 
87
- ### Coverage-context defaults (applied only when coverage is active)
92
+ ### Configuration
88
93
 
89
- Prefer the nested `coverage` section:
94
+ Headlamp discovers config from your repo root. Supported file names:
90
95
 
91
- ```ts
92
- export default {
93
- coverage: {
94
- abortOnFailure: true, // -> --coverage.abortOnFailure
95
- mode: 'auto', // -> --coverage.mode=auto
96
- pageFit: true, // -> --coverage.pageFit=true
97
- },
98
- };
99
- ```
96
+ - `headlamp.config.ts`
97
+ - `headlamp.config.js`
98
+ - `headlamp.config.mjs`
99
+ - `headlamp.config.cjs`
100
+ - `headlamp.config.json`
101
+ - `headlamp.config.json5`
102
+ - `headlamp.config.jsonc`
103
+ - `headlamp.config.yaml`
104
+ - `headlamp.config.yml`
105
+ - `.headlamprc` plus `.headlamprc.*` variants (`.json`, `.json5`, `.jsonc`, `.yaml`, `.yml`, `.js`, `.cjs`, `.mjs`, `.ts`)
100
106
 
101
- Additional recognized fields when coverage is active:
107
+ #### Example: `headlamp.config.ts`
102
108
 
103
- - `editorCmd` -> `--coverage.editor`
104
- - `include`, `exclude` -> `--coverage.include`, `--coverage.exclude`
105
- - `coverageDetail`, `coverageShowCode`, `coverageMaxFiles`, `coverageMaxHotspots`
109
+ Rules:
106
110
 
107
- ### Changed-context defaults (applied only when changed selection is active)
111
+ - Must have a **default export**
112
+ - Only **relative imports** are supported inside the config file (`./` and `../`)
108
113
 
109
114
  ```ts
110
115
  export default {
111
- changed: {
112
- depth: 20, // default for all modes -> --changed.depth=20
113
- branch: { depth: 10 },
114
- staged: { depth: 8 },
115
- unstaged: { depth: 6 },
116
- all: { depth: 12 },
117
- },
118
- };
119
- ```
116
+ // Runner defaults
117
+ jestArgs: ["--runInBand"],
120
118
 
121
- You may also set a top‑level default mode (e.g., `changed: 'branch'`); CLI still wins.
119
+ // Run once before tests (npm script name or a shell command)
120
+ bootstrapCommand: "test:jest:bootstrap",
122
121
 
123
- ### Full example
122
+ // Global toggles
123
+ ci: false,
124
+ verbose: false,
125
+ noCache: false,
124
126
 
125
- ```ts
126
- // headlamp.config.ts
127
- export default {
128
- // Base
129
- bootstrapCommand: 'test:jest:bootstrap',
130
- sequential: true, // serialize tests (maps to Jest --runInBand and single-project stride)
131
- jestArgs: ['--runInBand'], // optional: redundant when sequential is true
132
-
133
- // Coverage-context
127
+ // Coverage defaults
128
+ coverage: true,
129
+ coverageUi: "both",
134
130
  coverage: {
135
131
  abortOnFailure: true,
136
- mode: 'auto',
132
+ mode: "auto",
137
133
  pageFit: true,
138
134
  },
139
135
 
140
- // Changed-context
141
- changed: {
142
- depth: 20,
143
- branch: { depth: 10 },
144
- },
136
+ // Changed selection defaults
137
+ changed: { depth: 2 },
145
138
  };
146
139
  ```
147
140
 
148
- ## Scripts
149
-
150
- ```json
151
- {
152
- "scripts": {
153
- "test": "headlamp --sequential",
154
- "test:coverage": "headlamp --coverage --sequential",
155
- "test:dev": "npm run test -- --changed=branch --coverage --onlyFailures"
156
- }
157
- }
158
- ```
159
-
160
- ## Bootstrap command
141
+ ### Contributing
161
142
 
162
- Use `--bootstrapCommand` to run setup work before tests (e.g., database migrations/seeding). If omitted, no bootstrap runs.
143
+ Pull requests are welcome. For large changes, open an issue first to align on direction.
163
144
 
164
- - Single token: treated as an npm script name and run as `npm run -s <name>`
165
- - With spaces: treated as a full command and executed via the system shell
166
-
167
- Examples:
145
+ Local dev:
168
146
 
169
147
  ```bash
170
- npx headlamp --bootstrapCommand test:jest:bootstrap
171
- npx headlamp --bootstrapCommand "sequelize db:migrate --env test"
172
- ```
173
-
174
- ## Examples
175
-
176
- ```bash
177
- # Abort on failing tests without printing coverage
178
- npx headlamp --coverage --coverage.abortOnFailure
179
-
180
- # Show compact coverage limited to 50 files and 5 hotspots per file
181
- npx headlamp --coverage --coverage.mode=compact --coverage.maxFiles=50 --coverage.maxHotspots=5
182
-
183
- # Sequential run to avoid DB deadlocks
184
- npx headlamp --sequential
185
- ```
186
-
187
- ## Editor links
188
-
189
- Headlamp prints clickable links (OSC 8) to open files at hotspots. Set `--coverage.editor` to override the default editor URL template if needed.
190
-
191
- ## API
192
-
193
- Programmatic use:
194
-
195
- ```ts
196
- import { printCompactCoverage, resolveImportWithRoot } from 'headlamp';
148
+ cargo test
197
149
  ```
198
150
 
199
- ## Status
151
+ ### Support
200
152
 
201
- Alpha. Expect changes. Feedback welcome.
153
+ - Bug reports and feature requests: GitHub Issues
202
154
 
203
- ## License
155
+ ### License
204
156
 
205
- MIT
157
+ MIT — see `LICENSE`.
package/bin/.gitkeep ADDED
@@ -0,0 +1,4 @@
1
+
2
+
3
+
4
+
Binary file