@cldmv/fix-headers 2.2.7 → 2.4.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/README.md CHANGED
@@ -14,17 +14,18 @@ Headers stay correct without hand-editing: `@Date` follows the file's real creat
14
14
 
15
15
  ## ✨ What's New
16
16
 
17
- ### Latest: v2.2.7 (November 2026)
17
+ ### Latest: v2.4.0 (November 2026)
18
18
 
19
- - **Tests run against `src/` and `dist/`** — no library code changed. The test suite now gets the `fix-headers-dev` condition through `devCondition()` from `@cldmv/configs` (the old `test.nodeOptions` never reached the workers), the tests import the package by name, and `npm run test:dist` builds the package and runs the same suite against `dist/` ([#179](https://github.com/CLDMV/fix-headers/pull/179), [#181](https://github.com/CLDMV/fix-headers/pull/181)). Also a discovery-test fix for checkouts under a `dist` folder, `vitest` 5.1.0 and the `sync-release-notes` workflow ([#182](https://github.com/CLDMV/fix-headers/pull/182), [#183](https://github.com/CLDMV/fix-headers/pull/183), [#187](https://github.com/CLDMV/fix-headers/pull/187)).
20
- - [View full v2.2.7 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.7.md)
19
+ - **`@Filename` without a leading slash** — `@Filename` is the path relative to the project root, now written `src/index.mjs` instead of `/src/index.mjs`. The next run rewrites existing headers (only `@Filename` and `@Last modified time` change), so land it as a header-only commit ([#199](https://github.com/CLDMV/fix-headers/pull/199), fixes [#198](https://github.com/CLDMV/fix-headers/issues/198)).
20
+ - **Generated declarations left alone** — a `.d.ts` / `.d.mts` / `.d.cts` carrying the header `tsc` copied from its own source is skipped, so `tsc` and fix-headers stop flipping `@Filename` in committed `types/` ([#196](https://github.com/CLDMV/fix-headers/pull/196), fixes [#195](https://github.com/CLDMV/fix-headers/issues/195)).
21
+ - [View full v2.4.0 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.4.0.md)
21
22
 
22
23
  ### Recent Releases
23
24
 
25
+ - **v2.3.0** (November 2026) — `.mts`/`.cts` in the `node` detector and a new `c` detector for C/C++; C files carrying another holder's license notice are skipped ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.3.0.md))
26
+ - **v2.2.7** (November 2026) — no library code changed: the tests get the `fix-headers-dev` condition through `devCondition()`, and `npm run test:dist` runs the same suite against `dist/` ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.7.md))
24
27
  - **v2.2.6** (November 2026) — `engines.node` is back to `>=18.0.0`, the runtime floor; the 22.22.0 development toolchain floor moves to `devEngines`, and the `require()` error names ^20.19.0 or >=22.13.0 ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.6.md))
25
28
  - **v2.2.5** (November 2026) — the source-checkout development check is removed (the `fix-headers-dev` condition already picks `src/` or `dist/`), and `engines.node` went to `>=22.22.0` ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.5.md))
26
- - **v2.2.4** (October 2026) — one header per file: stacked headers merge, repeated fields and stale `@Copyright` lines are dropped, only position-critical lines stay above the header, `#` headers are found in CRLF and byte-order-mark files ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.4.md))
27
- - **v2.2.3** (October 2026) — text inside an existing header that is not a header field is kept instead of deleted, moved to its own block below the header by default (`strictHeaderBlock`), plus a dependency refresh ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.3.md))
28
29
 
29
30
  📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder.
30
31
 
@@ -265,25 +266,25 @@ Which project a file belongs to depends on the manifests around it, not on the f
265
266
 
266
267
  Each ecosystem has a manifest driver in `src/drivers/`:
267
268
 
268
- | Driver | Claims a folder holding | Name | Copyright holder | Native files |
269
- | -------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
270
- | `node` | `package.json` | `name` | `author.company`, else `author.name`, else the name part of a string `author` (`"Name <email> (url)"`) | `.js .mjs .cjs .ts .tsx .jsx` |
271
- | `python` | `pyproject.toml`, `setup.cfg` or `setup.py` | `pyproject.toml` `[project].name`, then `[tool.poetry].name`; `setup.cfg` `[metadata] name`; `setup.py` `setup(name=...)` | `pyproject.toml` `[project].authors[0].name`, then the name part of `[tool.poetry].authors[0]`; `setup.cfg` `[metadata] author`; `setup.py` `setup(author=...)` | `.py` |
272
- | `php` | `composer.json` | `name` | `authors[0].name` | `.php` |
273
- | `rust` | `Cargo.toml` | `[package].name` | the name part of `[package].authors[0]` | `.rs` |
274
- | `go` | `go.mod` | the `module` path | none (`go.mod` has no author) | `.go` |
269
+ | Driver | Claims a folder holding | Name | Copyright holder | Native files |
270
+ | -------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
271
+ | `node` | `package.json` | `name` | `author.company`, else `author.name`, else the name part of a string `author` (`"Name <email> (url)"`) | `.js .mjs .cjs .ts .mts .cts .tsx .jsx` |
272
+ | `python` | `pyproject.toml`, `setup.cfg` or `setup.py` | `pyproject.toml` `[project].name`, then `[tool.poetry].name`; `setup.cfg` `[metadata] name`; `setup.py` `setup(name=...)` | `pyproject.toml` `[project].authors[0].name`, then the name part of `[tool.poetry].authors[0]`; `setup.cfg` `[metadata] author`; `setup.py` `setup(author=...)` | `.py` |
273
+ | `php` | `composer.json` | `name` | `authors[0].name` | `.php` |
274
+ | `rust` | `Cargo.toml` | `[package].name` | the name part of `[package].authors[0]` | `.rs` |
275
+ | `go` | `go.mod` | the `module` path | none (`go.mod` has no author) | `.go` |
275
276
 
276
277
  A manifest claims its folder as soon as it exists and can be read, even when it is malformed or has no name. `requirements.txt` does not claim a folder: it carries no name and often sits in folders that are not projects of their own (`docs/requirements.txt`).
277
278
 
278
279
  For each file:
279
280
 
280
- 1. **Project root.** Walk up from the file's folder. The nearest folder that at least one driver claims is the project root. `@Filename` is the file's path relative to it, and git history (`@Date`, `@Last modified time`) is looked up from it.
281
- 2. **Order.** When several drivers claim that folder, the file's native driver is read first (a `.py` file reads `python` first), then the fixed order `node`, `python`, `php`, `rust`, `go`. Language-neutral files (CSS, HTML, YAML, JSONC, …) use the fixed order.
281
+ 1. **Project root.** Walk up from the file's folder. The nearest folder that at least one driver claims is the project root. `@Filename` is the file's path relative to it, with no leading slash (`src/index.mjs`; a leading `/` written by fix-headers 2.3 and earlier is removed on the next run), and git history (`@Date`, `@Last modified time`) is looked up from it.
282
+ 2. **Order.** When several drivers claim that folder, the file's native driver is read first (a `.py` file reads `python` first), then the fixed order `node`, `python`, `php`, `rust`, `go`. Language-neutral files (CSS, HTML, YAML, JSONC, C, …) use the fixed order.
282
283
  3. **Per-field fallback.** Each value is taken from the first driver in that order whose manifest provides it. In a folder with a nameless `package.json` and a named `pyproject.toml`, every file gets the `pyproject.toml` name.
283
284
  4. **Climbing.** A value no driver at the project root provides is looked up the same way in each ancestor folder a driver claims, up to and including the scan root (`projectRoot`, else `cwd`), never above it. A nameless sub-package therefore takes the name of the repository around it. Only values climb: the project root, and with it `@Filename` and the git lookups, stays the nearest claimed folder.
284
285
  5. **Folder name.** When nothing up to the scan root provides a name, `@Project` is the project root's folder name.
285
286
 
286
- A folder holding `.git` is a repository boundary: neither the root search nor the climb goes past it, so a nested repository without a manifest is a project of its own. With no manifest up to the repository root, that repository root is the project root and its folder name is the name. With neither a manifest nor a repository anywhere above the file, the file's own folder is the project root: `@Project` is that folder's name and `@Filename` is `/<file name>`.
287
+ A folder holding `.git` is a repository boundary: neither the root search nor the climb goes past it, so a nested repository without a manifest is a project of its own. With no manifest up to the repository root, that repository root is the project root and its folder name is the name. With neither a manifest nor a repository anywhere above the file, the file's own folder is the project root: `@Project` is that folder's name and `@Filename` is the file name.
287
288
 
288
289
  `projectName`, `projectRoot`, `language` and `marker` override the detected values for every file. The copyright holder is resolved from the same manifests by the same rules, see [Copyright holder](#-copyright-holder).
289
290
 
@@ -293,15 +294,15 @@ For example, scanning `repo/`:
293
294
  repo/
294
295
  ├── package.json { "name": "@scope/repo" }
295
296
  ├── pyproject.toml [project] name = "repo-py"
296
- ├── scripts/build.py → @Project: repo-py @Filename: /scripts/build.py
297
- ├── site/main.css → @Project: @scope/repo @Filename: /site/main.css
297
+ ├── scripts/build.py → @Project: repo-py @Filename: scripts/build.py
298
+ ├── site/main.css → @Project: @scope/repo @Filename: site/main.css
298
299
  └── packages/
299
300
  ├── a/
300
301
  │ ├── package.json { "private": true }
301
- │ └── src/x.mjs → @Project: @scope/repo @Filename: /src/x.mjs
302
+ │ └── src/x.mjs → @Project: @scope/repo @Filename: src/x.mjs
302
303
  └── b/
303
304
  ├── Cargo.toml [package] name = "b-crate"
304
- └── src/lib.rs → @Project: b-crate @Filename: /src/lib.rs
305
+ └── src/lib.rs → @Project: b-crate @Filename: src/lib.rs
305
306
  ```
306
307
 
307
308
  To support another ecosystem, add a module to `src/drivers/` that exports a `driver` with `id`, `languages` (the file-type detector ids native to it), `manifests` (filenames that claim a folder, in reading order), `detect(dirPath)` (returns `detectManifests(dirPath, manifests)` from `src/drivers/shared.mjs`) and `read(detection)` (returns `{ name, company }`, each `undefined` when the manifest has none), then add it to `MANIFEST_DRIVERS` in `src/drivers/index.mjs` at its place in the fixed order.
@@ -400,7 +401,7 @@ With the defaults a JavaScript file and a YAML file look like this:
400
401
  /**
401
402
  *
402
403
  * @Project: @cldmv/example
403
- * @Filename: /src/index.mjs
404
+ * @Filename: src/index.mjs
404
405
  * ...
405
406
  * @Copyright: Copyright (c) 2026-2026 Example Inc. All rights reserved.
406
407
  *
@@ -413,7 +414,7 @@ export const value = 1;
413
414
  ```text
414
415
  #
415
416
  # @Project: @cldmv/example
416
- # @Filename: /.github/workflows/ci.yml
417
+ # @Filename: .github/workflows/ci.yml
417
418
  # ...
418
419
  # @Copyright: Copyright (c) 2026-2026 Example Inc. All rights reserved.
419
420
  #
@@ -558,24 +559,27 @@ The `@Date` instant is unchanged; `@Last modified time` is restamped with the ti
558
559
 
559
560
  Each file type is handled by a detector, which decides the header's comment syntax. A file is given a header only when an enabled detector handles its extension:
560
561
 
561
- | Detector | Extensions | Header comment | Default |
562
- | ---------- | ----------------------------- | -------------- | ------------------------------------------ |
563
- | `node` | `.js .mjs .cjs .ts .tsx .jsx` | `/** … */` | on |
564
- | `json` | `.jsonc .json5 .jsonv` | `/** … */` | on |
565
- | `css` | `.css` | `/* … */` | on |
566
- | `html` | `.html .htm` | `<!-- … -->` | on |
567
- | `yaml` | `.yaml .yml` | `# …` | on |
568
- | `python` | `.py` | `# …` | on |
569
- | `php` | `.php` | `/** … */` | on |
570
- | `rust` | `.rs` | `/** … */` | on |
571
- | `go` | `.go` | `/** … */` | on |
572
- | `markdown` | `.md .markdown` | `<!-- … -->` | off; only with `--force-detector markdown` |
562
+ | Detector | Extensions | Header comment | Default |
563
+ | ---------- | --------------------------------------- | -------------- | ------------------------------------------ |
564
+ | `node` | `.js .mjs .cjs .ts .mts .cts .tsx .jsx` | `/** … */` | on |
565
+ | `json` | `.jsonc .json5 .jsonv` | `/** … */` | on |
566
+ | `css` | `.css` | `/* … */` | on |
567
+ | `html` | `.html .htm` | `<!-- … -->` | on |
568
+ | `yaml` | `.yaml .yml` | `# …` | on |
569
+ | `python` | `.py` | `# …` | on |
570
+ | `php` | `.php` | `/** … */` | on |
571
+ | `rust` | `.rs` | `/** … */` | on |
572
+ | `go` | `.go` | `/** … */` | on |
573
+ | `c` | `.c .h .cc .cpp .cxx .hh .hpp .hxx` | `/* … */` | on |
574
+ | `markdown` | `.md .markdown` | `<!-- … -->` | off; only with `--force-detector markdown` |
573
575
 
574
576
  Every other file is skipped and left byte-for-byte unchanged, including when you name it with `--input` or add its extension with `includeExtensions`:
575
577
 
576
578
  - **Strict JSON (`.json`)** has no comment syntax, so it never gets a header. A comment would make `package.json` and every other JSON file invalid.
577
579
  - **Files with no extension, or an extension no enabled detector handles** (`.txt`, `.toml`, a disabled detector's extensions, …) are skipped instead of being given a guessed comment.
578
580
  - **A PHP file that does not open with `<?php`** (a template starting with HTML) is skipped: a comment at the top would be output as text. A file where only a fix-headers header (and blank lines) comes before `<?php` is not skipped: an earlier version wrote that header there, and it is moved back below `<?php` (see [What stays above the header](#what-stays-above-the-header)).
581
+ - **Third-party C and C++** is skipped: a `c` file whose prologue (the comments, blank lines and preprocessor directives before its first line of code) holds a comment with license or copyright wording (`Copyright`, `License`, `SPDX-License-Identifier`, `public domain`) that is not a fix-headers header is left untouched, so a vendored library such as the SQLite amalgamation (`sqlite3.c`, `sqlite3.h`) keeps its own notice. A file whose first comment is already a fix-headers header is never skipped this way. To keep a whole folder of vendored code out of the run regardless of its comments, use `excludeFolders` / `--exclude-folder`.
582
+ - **A declaration file `tsc` generated from a source with a header** is skipped: `tsc` copies the source's header into the `.d.ts` / `.d.mts` / `.d.cts` it emits, `@Filename` included, and that header is maintained on the source. A declaration whose header names its own source (`types/src/x.d.mts` with `@Filename: src/x.mts`, or `.mjs`; `.d.ts` pairs with `.ts .tsx .js .jsx`, `.d.cts` with `.cts .cjs`) is left as `tsc` wrote it, so the two tools no longer rewrite each other's output. A declaration with no header, or one whose header names any other file, is fixed as usual.
579
583
  - **Markdown** is skipped unless the `markdown` detector is forced with `--force-detector markdown` (`forcedDetectors: ["markdown"]` in the API or a config file). Naming a `.md` file with `--input` does not force it. A forced header is an HTML comment, which Markdown renderers do not display; it goes below any YAML front matter (`---` … `---`), and later runs update it in place. Forcing applies to discovery too, so a repo-wide run with the option also stamps `README.md` and changelogs; to stamp one file, pass the option together with `--input <file>`. `.mdx` is not covered, because MDX does not accept HTML comments.
580
584
 
581
585
  A skipped file is listed in the result's `skipped` array as `{ file, reason }` and counted in `filesSkipped`, not in `filesScanned` or `changes`. The CLI adds `skipped=<n>` to its summary and prints one `skipped: <file> (<reason>)` line per file: