@cldmv/fix-headers 2.2.6 → 2.3.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 +28 -26
- package/bin/fix-headers.mjs +29 -25
- package/dist/index.mjs +32 -28
- package/package.json +5 -4
- package/types/src/detectors/c.d.mts +18 -0
- package/types/src/detectors/index.d.mts +1 -1
package/README.md
CHANGED
|
@@ -14,17 +14,17 @@ 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.
|
|
17
|
+
### Latest: v2.3.0 (November 2026)
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
- [View full v2.
|
|
19
|
+
- **`.mts`/`.cts` and C/C++ support** — the `node` detector now stamps `.mts` and `.cts` like `.ts`, and a new `c` detector (on by default) stamps `.c .h .cc .cpp .cxx .hh .hpp .hxx` with a plain `/* … */` header placed above `#include`, `#pragma once` and include guards. C files that open with someone else's license or copyright notice, such as the SQLite amalgamation, are skipped and left byte-for-byte untouched ([#193](https://github.com/CLDMV/fix-headers/pull/193), fixes [#192](https://github.com/CLDMV/fix-headers/issues/192)).
|
|
20
|
+
- [View full v2.3.0 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.3.0.md)
|
|
21
21
|
|
|
22
22
|
### Recent Releases
|
|
23
23
|
|
|
24
|
+
- **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))
|
|
25
|
+
- **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))
|
|
24
26
|
- **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))
|
|
25
27
|
- **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))
|
|
26
|
-
- **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))
|
|
27
|
-
- **v2.2.2** (October 2026) — dependency refresh with nothing the package ships changed: `ignore` 7.0.12 within its range, plus `@cldmv/vitest-runner` 1.5.3, `vitest` 5.0.3, `eslint` 10.12.0 and `globals` 17.13.0 ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.2.md))
|
|
28
28
|
|
|
29
29
|
📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder.
|
|
30
30
|
|
|
@@ -52,7 +52,7 @@ Headers stay correct without hand-editing: `@Date` follows the file's real creat
|
|
|
52
52
|
|
|
53
53
|
- **Node.js 18.0.0 or later** (`engines.node` is `>=18.0.0`). The package is an ES module and loads with `import` on every supported version. Remote (`https://`) config `extends` uses the global `fetch`, which Node.js 18 has.
|
|
54
54
|
- `require("@cldmv/fix-headers")` loads the ES module build synchronously, which needs Node.js ^20.19.0 or >=22.13.0; on older Node.js, use `import()` instead.
|
|
55
|
-
- Developing this package needs Node.js 22.22.0 or later (`devEngines`).
|
|
55
|
+
- Developing this package needs Node.js 22.22.0 or later (`devEngines`). `npm test` runs the suite against `src/`, and `npm run test:dist` builds the package and runs it against `dist/`.
|
|
56
56
|
|
|
57
57
|
### Install
|
|
58
58
|
|
|
@@ -265,20 +265,20 @@ Which project a file belongs to depends on the manifests around it, not on the f
|
|
|
265
265
|
|
|
266
266
|
Each ecosystem has a manifest driver in `src/drivers/`:
|
|
267
267
|
|
|
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`
|
|
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 .mts .cts .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` |
|
|
275
275
|
|
|
276
276
|
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
277
|
|
|
278
278
|
For each file:
|
|
279
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
|
+
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
282
|
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
283
|
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
284
|
5. **Folder name.** When nothing up to the scan root provides a name, `@Project` is the project root's folder name.
|
|
@@ -558,24 +558,26 @@ The `@Date` instant is unchanged; `@Last modified time` is restamped with the ti
|
|
|
558
558
|
|
|
559
559
|
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
560
|
|
|
561
|
-
| Detector | Extensions
|
|
562
|
-
| ---------- |
|
|
563
|
-
| `node` | `.js .mjs .cjs .ts .tsx .jsx` | `/** … */` | on |
|
|
564
|
-
| `json` | `.jsonc .json5 .jsonv`
|
|
565
|
-
| `css` | `.css`
|
|
566
|
-
| `html` | `.html .htm`
|
|
567
|
-
| `yaml` | `.yaml .yml`
|
|
568
|
-
| `python` | `.py`
|
|
569
|
-
| `php` | `.php`
|
|
570
|
-
| `rust` | `.rs`
|
|
571
|
-
| `go` | `.go`
|
|
572
|
-
| `
|
|
561
|
+
| Detector | Extensions | Header comment | Default |
|
|
562
|
+
| ---------- | --------------------------------------- | -------------- | ------------------------------------------ |
|
|
563
|
+
| `node` | `.js .mjs .cjs .ts .mts .cts .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
|
+
| `c` | `.c .h .cc .cpp .cxx .hh .hpp .hxx` | `/* … */` | on |
|
|
573
|
+
| `markdown` | `.md .markdown` | `<!-- … -->` | off; only with `--force-detector markdown` |
|
|
573
574
|
|
|
574
575
|
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
576
|
|
|
576
577
|
- **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
578
|
- **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
579
|
- **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)).
|
|
580
|
+
- **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`.
|
|
579
581
|
- **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
582
|
|
|
581
583
|
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:
|
package/bin/fix-headers.mjs
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
`)
|
|
5
|
-
`)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`)
|
|
2
|
+
var gr=Object.defineProperty;var s=(e,t)=>gr(e,"name",{value:t,configurable:!0});import{realpathSync as rr}from"node:fs";import{fileURLToPath as Ni,pathToFileURL as Fi}from"node:url";import{readFile as yr}from"node:fs/promises";import{createRequire as xr}from"node:module";import{dirname as wr,isAbsolute as br,resolve as dt}from"node:path";var kr=3e4,Er=new Set(["localhost","127.0.0.1","[::1]"]);function we(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(we,"isPlainObject");function be(e,t){let n={...e};for(let[r,o]of Object.entries(t))r!=="__proto__"&&(n[r]=we(n[r])&&we(o)?be(n[r],o):o);return n}s(be,"mergeConfig");function mt(e){return e.kind==="file"?e.path:e.href}s(mt,"describeSource");async function $r(e){if(e.kind==="file")return{text:await yr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(kr)})}catch(n){let r=n.cause instanceof Error?n.cause.message:n.message;throw new Error(`Failed to fetch config ${e.href}: ${r}`,{cause:n})}if(!t.ok)throw new Error(`Failed to fetch config ${e.href}: HTTP ${t.status} ${t.statusText}`);return{text:await t.text(),source:{kind:"url",href:t.url}}}s($r,"readSource");function ft(e){if(e.protocol==="http:"&&!Er.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}s(ft,"toUrlSource");function Sr(e,t){if(/^https?:\/\//i.test(e))return ft(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${mt(t)}; use https, a file path or a package path`);let n=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(n||e.startsWith("/"))return ft(new URL(e,t.href));throw new Error(`Cannot extend package "${e}" from the remote config ${t.href}; use a URL or a relative path`)}if(n||br(e))return{kind:"file",path:dt(wr(t.path),e)};try{return{kind:"file",path:xr(t.path).resolve(e)}}catch(r){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${r.message}`,{cause:r})}}s(Sr,"resolveReference");function Ar(e,t){if(e===void 0)return[];let n=Array.isArray(e)?e:[e];if(!n.every(r=>typeof r=="string"&&r.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return n.map(r=>r.trim())}s(Ar,"readExtends");async function pt(e,t){let n=mt(e);if(t.includes(n))throw new Error(`Config extends cycle: ${[...t,n].join(" -> ")}`);let{text:r,source:o}=await $r(e),i;try{i=JSON.parse(r)}catch(f){throw new Error(`Config ${n} is not valid JSON: ${f.message}`,{cause:f})}if(!we(i))throw new Error(`Config file must contain a JSON object: ${n}`);let{extends:a,...c}=i,l={};for(let f of Ar(a,n))l=be(l,await pt(Sr(f,o),[...t,n]));return be(l,c)}s(pt,"loadSource");function Dr(e,t=process.cwd()){return pt({kind:"file",path:dt(t,e)},[])}s(Dr,"loadConfigFile");async function re(e,t){let n=typeof e[t]=="string"?e[t].trim():"";if(n.length===0)return e;let r=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Dr(n,r),...e};return delete o[t],o}s(re,"applyConfigOption");import{readFile as xi,stat as wi,writeFile as bi}from"node:fs/promises";import{relative as Ve,resolve as er}from"node:path";import{extname as ke}from"node:path";import{extname as Cr}from"node:path";var gt=[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],vr=400,Nr=/\bcopyright\b|\blicen[cs]e[ds]?\b|SPDX-License-Identifier|\bpublic domain\b/i,ht=/^[\s*/]*@(?:Project|Filename):/m;function Fr(e){let t=Cr(e).toLowerCase();return gt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Fr,"resolveCCommentSyntax");function Lr(e){let t=e.replace(/^\uFEFF/,"").split(`
|
|
3
|
+
`).slice(0,vr),n=[],r=null,o=null,i=!1;for(let a of t){let c=a.replace(/\r$/,"");if(r){r.push(c),c.includes("*/")&&(n.push(r.join(`
|
|
4
|
+
`)),r=null);continue}if(i){i=c.endsWith("\\");continue}let l=c.trim();if(o&&!l.startsWith("//")&&(n.push(o.join(`
|
|
5
|
+
`)),o=null),l.length!==0){if(l.startsWith("//")){(o??=[]).push(l);continue}if(l.startsWith("/*")){let f=l.indexOf("*/",2);if(f===-1){r=[l];continue}if(n.push(l.slice(0,f+2)),l.slice(f+2).trim().length>0)break;continue}if(l.startsWith("#")){i=l.endsWith("\\");continue}break}}return o&&n.push(o.join(`
|
|
6
|
+
`)),n}s(Lr,"prologueComments");var yt={id:"c",extensions:gt,enabledByDefault:!0,resolveContentSkipReason(e){let t=Lr(e);return t.length>0&&ht.test(t[0])?null:t.some(n=>!ht.test(n)&&Nr.test(n))?"the file starts with a license or copyright notice that is not a fix-headers header (third-party code)":null},resolveCommentSyntax(e){return Fr(e)}};import{extname as jr}from"node:path";var xt=[".css"];function Rr(e){let t=jr(e).toLowerCase();return xt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Rr,"resolveCssCommentSyntax");var wt={id:"css",extensions:xt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Rr(e)}};import{extname as Or}from"node:path";var Mr=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,Pr=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,Ir=new Set(["et","expandtab","ai","autoindent","si","smartindent","ro","readonly","bin","binary","noet","noexpandtab","noai","noautoindent","nosi","nosmartindent","noro","noreadonly","nobin","nobinary","nowrap","nolist","nospell","nofen","nofoldenable","noeol","nofixeol","nofixendofline"]);function oe(e){let t=e.match(Mr);if(!t)return!1;let n=t[2].trim();if(n.endsWith("-->"))n=n.slice(0,-3).trimEnd();else if(n.endsWith("*/")){let i=n.length-2;for(;i>0&&n[i-1]==="*";)i-=1;n=n.slice(0,i).trimEnd()}let r=n.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!r&&t[1]==="Vim")return!1;let o=r?r[1].match(/(?:\\.|[^\s\\])+/g):n.match(/(?:\\.|[^\s:\\])+/g);return o!==null&&o.every(i=>Pr.test(i))&&o.some(i=>i.includes("=")||Ir.has(i))}s(oe,"isModeline");function ie(e,t){return t===0&&e.startsWith("#!")}s(ie,"isShebang");function se(e,t,n=0){let r=0,o=n;for(;r<e.length;){let i=e.indexOf(`
|
|
7
|
+
`,r),a=i===-1?e.length:i+1;if(!t(e.slice(r,a).replace(/\r?\n$/,""),o))break;r=a,o+=1}return e.slice(0,r)}s(se,"takeTopLines");var kt=[".go"];function Tr(e){let t=Or(e).toLowerCase();return kt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Tr,"resolveGoCommentSyntax");var bt=/^\/\/(?:go:build|\s*\+build)\s/;function Hr(e,t){let n=se(t,o=>bt.test(o)||oe(o));if(!n.split(/\r?\n/).some(o=>bt.test(o)))return"";let r=t.slice(n.length);return`${n}${r.slice(0,r.length-r.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}s(Hr,"resolveGoPreservedPrefix");var Et={id:"go",extensions:kt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Hr(e,t)},resolveCommentSyntax(e){return Tr(e)}};import{extname as _r}from"node:path";var $t=[".html",".htm"];function Ur(e){let t=_r(e).toLowerCase();return $t.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}s(Ur,"resolveHtmlCommentSyntax");var St={id:"html",extensions:$t,enabledByDefault:!0,resolveCommentSyntax(e){return Ur(e)}};import{extname as Wr}from"node:path";var At=[".jsonv",".jsonc",".json5"];function Br(e){let t=Wr(e).toLowerCase();return At.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Br,"resolveJsonCommentSyntax");var Dt={id:"json",extensions:At,enabledByDefault:!0,resolveCommentSyntax(e){return Br(e)}};import{extname as zr}from"node:path";var Ct=[".md",".markdown"];function Gr(e){let t=zr(e).toLowerCase();return Ct.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}s(Gr,"resolveMarkdownCommentSyntax");function Yr(e,t){let n=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return n?n[0]:""}s(Yr,"resolveMarkdownPreservedPrefix");var vt={id:"markdown",extensions:Ct,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return Yr(e,t)},resolveCommentSyntax(e){return Gr(e)}};import{extname as Vr}from"node:path";var Nt=[".js",".mjs",".cjs",".ts",".mts",".cts",".tsx",".jsx"];function Jr(e){let t=Vr(e).toLowerCase();return Nt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Jr,"resolveNodeCommentSyntax");var Ft={id:"node",extensions:Nt,enabledByDefault:!0,keepsAboveHeader:ie,resolveCommentSyntax(e){return Jr(e)}};import{extname as Kr}from"node:path";var jt=[".php"];function qr(e){let t=Kr(e).toLowerCase();return jt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(qr,"resolvePhpCommentSyntax");var Lt=/^<\?php(?:\s|$)/i,Rt={id:"php",extensions:jt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&Lt.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return Lt.test(e.replace(/^\uFEFF/,""))?null:"the file does not start with <?php, so a comment at the top would be output as text"},resolveCommentSyntax(e){return qr(e)}};import{extname as Xr}from"node:path";var Mt=[".py"],Zr=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function Qr(e,t){return ie(e,t)||t<=1&&Zr.test(e)}s(Qr,"keepsAboveHeader");var Pt={id:"python",extensions:Mt,enabledByDefault:!0,keepsAboveHeader:Qr,resolveCommentSyntax(e){let t=Xr(e).toLowerCase();return Mt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as eo}from"node:path";var It=[".rs"];function to(e){let t=eo(e).toLowerCase();return It.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(to,"resolveRustCommentSyntax");var Ot={id:"rust",extensions:It,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return to(e)}};import{extname as no}from"node:path";var Tt=[".yaml",".yml"];function ro(e){let t=no(e).toLowerCase();return Tt.includes(t)?{kind:"line",linePrefix:"#"}:null}s(ro,"resolveYamlCommentSyntax");var Ht={id:"yaml",extensions:Tt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return ro(e)}};var ae=[yt,wt,Et,St,Dt,vt,Ft,Rt,Pt,Ot,Ht],oo=new Map(ae.map(e=>[e.id,e]));function io(e,t){return!t||typeof t!="object"?e:e.kind==="line"?{...e,linePrefix:typeof t.linePrefix=="string"&&t.linePrefix.length>0?t.linePrefix:e.linePrefix,lineSeparator:typeof t.lineSeparator=="string"?t.lineSeparator:e.lineSeparator}:{...e,blockStart:typeof t.blockStart=="string"&&t.blockStart.length>0?t.blockStart:e.blockStart,blockLinePrefix:typeof t.blockLinePrefix=="string"&&t.blockLinePrefix.length>0?t.blockLinePrefix:e.blockLinePrefix,blockEnd:typeof t.blockEnd=="string"&&t.blockEnd.length>0?t.blockEnd:e.blockEnd}}s(io,"applySyntaxOverride");function _t(e){if(e==null)return[];if(!Array.isArray(e)||e.some(n=>typeof n!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=ae.filter(n=>n.requiresForce===!0).map(n=>n.id);for(let n of e){if(!oo.has(n))throw new Error(`forcedDetectors: unknown detector "${n}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(n))throw new Error(`forcedDetectors: "${n}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}s(_t,"resolveForcedDetectors");function O(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),n=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),r=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return ae.filter(o=>o.requiresForce===!0?r.has(o.id)&&!n.has(o.id):t.size>0?t.has(o.id):n.has(o.id)?!1:o.enabledByDefault)}s(O,"getEnabledDetectors");function Ut(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(n=>n.toLowerCase()));let t=O(e);return new Set(t.flatMap(n=>n.extensions))}s(Ut,"getAllowedExtensions");function Wt(e,t={}){let n=ke(e).toLowerCase();if(O(t).some(a=>a.extensions.includes(n)&&a.resolveCommentSyntax(e)!==null))return null;if(n.length===0)return"the file has no extension, so its comment syntax is unknown";let o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),i=ae.find(a=>a.requiresForce===!0&&a.extensions.includes(n)&&!o.has(a.id));return i?`${n} files get a header only when forced (--force-detector ${i.id} / forcedDetectors: ["${i.id}"])`:`no enabled detector handles ${n} files`}s(Wt,"getHeaderSkipReason");function Bt(e,t={}){let n=ke(e).toLowerCase(),r=Array.isArray(t.detectors)?t.detectors:O(t);for(let o of r){if(!o.extensions.includes(n))continue;let i=o.resolveCommentSyntax(e);if(i){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return io(i,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}s(Bt,"getCommentSyntaxForFile");function zt(e,t){let n=ke(e).toLowerCase();return O(t).find(r=>r.extensions.includes(n))}s(zt,"detectorForFile");function ce(e,t,n={}){let r=zt(e,n);if(!r)return"";let o=typeof r.resolvePreservedPrefix=="function"?r.resolvePreservedPrefix(e,t):"",i=r.keepsAboveHeader,a=se(t.slice(o.length),(c,l)=>oe(c)||typeof i=="function"&&i(c,l),o.split(`
|
|
8
|
+
`).length-1);return`${o}${a}`}s(ce,"getPreservedPrefixForFile");function Gt(e,t,n={}){let r=zt(e,n);return r&&typeof r.resolveContentSkipReason=="function"?r.resolveContentSkipReason(t):null}s(Gt,"getContentSkipReason");var Yt=200,X=1,le=2;function T(e,t,n){if(e==null)return n;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(e)}`);return e}s(T,"resolveLayoutCount");import{existsSync as xo}from"node:fs";import{join as Ne,relative as sn,resolve as Fe,sep as Ce}from"node:path";import{realpath as wo,stat as bo}from"node:fs/promises";import{access as so,readdir as ao,readFile as Xs,stat as co}from"node:fs/promises";import{constants as lo}from"node:fs";import{dirname as ea,join as uo,resolve as ta}from"node:path";async function Ee(e){try{return await so(e,lo.F_OK),!0}catch{return!1}}s(Ee,"pathExists");async function $e(e,t){let n=[],r=await ao(e,{withFileTypes:!0});for(let o of r){let i=uo(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(i,o.name)===!0)continue;if(o.isDirectory()){let l=await $e(i,t);n.push(...l);continue}if(!o.isFile())continue;let a=o.name.lastIndexOf(".");if(a===-1)continue;let c=o.name.slice(a).toLowerCase();t.allowedExtensions.has(c)&&n.push(i)}return n}s($e,"walkFiles");async function Vt(e){let t=await co(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}s(Vt,"readFileDates");function Jt(e){let t=e.indexOf("<");for(;t!==-1;){let n=e.indexOf(">",t+1);if(n===-1)return!1;if(n>t+1)return!0;t=e.indexOf("<",n+1)}return!1}s(Jt,"hasAngleTag");function Kt(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}s(Kt,"trimTrailingSlashes");import{execFile as fo}from"node:child_process";import{lstat as mo,readFile as po}from"node:fs/promises";import{dirname as qt,isAbsolute as ho,join as Qt,relative as en,resolve as Se,sep as tn}from"node:path";import go from"ignore";function Xt(e,t){return new Promise(n=>{fo("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(r,o)=>{if(!r){n({code:0,stdout:o});return}n({code:typeof r.code=="number"?r.code:-1,stdout:""})})})}s(Xt,"runGitCommand");function De(e,t){return en(e,t).split(tn).join("/")}s(De,"toPosixRelative");async function nn(e){try{return go().add(await po(e,"utf8"))}catch{return null}}s(nn,"readIgnoreFile");async function yo(e){return mo(Qt(e,".git")).then(()=>!0,()=>!1)}s(yo,"hasGitEntry");function Zt(e,t,n){for(let r=e.length-1;r>=0;r--){let{base:o,rules:i}=e[r],a=i.test(`${De(o,t)}${n?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}s(Zt,"matchesRules");async function rn(e,t){let n=await nn(Qt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:n?[...t,{base:e,rules:n}]:t}}s(rn,"buildRulesContext");async function Ae(e){let[t,n]=await Promise.all([Xt(e,["check-ignore","-q","."]),Xt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||n.code!==0)return rn(e,[]);let r=new Set,o=new Set;for(let i of n.stdout.split("\0")){let a=i.endsWith("/")?i.slice(0,-1):i;if(a.length!==0){r.add(a);for(let c=a.indexOf("/");c!==-1;c=a.indexOf("/",c+1))o.add(a.slice(0,c))}}return{kind:"git",root:e,entries:r,dirs:o}}s(Ae,"resolveScopeContext");function on(e){let t=Se(e.root),n=e.gitignore;if(n===!1)return{isIgnored:s(async()=>!1,"isIgnored")};let r=new Map,o=s(async()=>{if(typeof n!="string"&&!Array.isArray(n))return Ae(t);let c=typeof n=="string"?[n]:n.filter(f=>typeof f=="string"),l=[];for(let f of c){let u=await nn(Se(t,f));u&&l.push({base:t,rules:u})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),i=s(c=>{let l=r.get(c);return l||(l=c===t?o():a(c),r.set(c,l)),l},"contextFor"),a=s(async c=>{let l=await i(qt(c));return l.kind==="git"?l.entries.has(De(l.root,c))?Ae(c):l:!l.nested||l.excluded?l:Zt(l.matchers,c,!0)?{...l,excluded:!0}:await yo(c)?Ae(c):rn(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let f=Se(c),u=en(t,f);if(u.length===0||u===".."||u.startsWith(`..${tn}`)||ho(u))return!1;let m=await i(qt(f));if(m.kind==="git"){let h=De(m.root,f);return!(m.entries.has(h)||l&&m.dirs.has(h))}return m.excluded||Zt(m.matchers,f,l)}}}s(on,"createIgnoreFilter");function ko(e){return Ut(e)}s(ko,"resolveExtensions");var Eo=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),ln=new Set([".git",...Eo]),$o=Object.freeze(["autoload.php","modules.txt"]);function an(e,t){return ln.has(t)?!0:t==="vendor"&&$o.some(n=>xo(Ne(e,n)))}s(an,"isNeverWalked");function ve(e){return Kt(e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}s(ve,"normalizeFolderPath");function So(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{path:t,recursive:!0};if(t&&typeof t=="object"&&typeof t.path=="string")return{path:t.path,recursive:t.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(t)} (expected a path string or { path, recursive? })`)}):[]}s(So,"resolveIncludeFolders");function cn(e,t){let n=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${n})`)}s(cn,"reportSkippedIncludeFolder");function Ao(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let n=Fe(e),r=[],o=new Set;for(let i of t){if(typeof i!="string")continue;let a=ve(i);if(a.length!==0){if(a.includes("/")){r.push(Fe(n,a));continue}o.add(a)}}return(i,a)=>{if(o.has(a))return!0;for(let l of r)if(i===l||i.startsWith(`${l}/`))return!0;let c=ve(sn(n,i));return r.some(l=>{let f=ve(sn(n,l));return c===f||c.startsWith(`${f}/`)})}}s(Ao,"buildExclusionMatcher");async function Le(e){let t=ko(e),n=So(e.includeFolders),r=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=Ao(e.projectRoot,r),i=on({root:e.projectRoot,gitignore:e.gitignore}),a=s(async(d,p)=>an(d,p)||o(d,p)||await i.isIgnored(d,!0),"shouldSkipDirectory"),c=n.length>0?n.map(d=>({includeFolder:d.path,rootPath:Ne(e.projectRoot,d.path),recursive:d.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let d of c){let p=await bo(d.rootPath).catch(b=>b);if(p instanceof Error){if(p.code==="ENOENT"){cn(d.includeFolder,p);continue}throw p}if(!p.isDirectory()){cn(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let w=await wo(d.rootPath).catch(()=>Fe(d.rootPath));l.push({...d,realRoot:w})}let f=s((d,p)=>{if(d.realRoot===p.realRoot)return d.recursive||!p.recursive;let w=d.realRoot.endsWith(Ce)?d.realRoot:`${d.realRoot}${Ce}`;if(!d.recursive||!p.realRoot.startsWith(w))return!1;let b=d.rootPath;for(let $ of p.realRoot.slice(w.length).split(Ce))if(b=Ne(b,$),an(b,$)||o(b,$))return!1;return!0},"covers"),u=[...l].sort((d,p)=>d.realRoot.length-p.realRoot.length||Number(p.recursive)-Number(d.recursive)),m=[];for(let d of u)m.some(p=>f(p,d))||m.push(d);let h=[];for(let d of l){if(!m.includes(d))continue;let p=await $e(d.rootPath,{allowedExtensions:t,ignoreFolders:ln,shouldSkipDirectory:a,recursive:d.recursive});h.push(...p)}let y=[];for(let d of new Set(h))!o(d,d.split("/").at(-1)||"")&&!await i.isIgnored(d,!1)&&y.push(d);return y}s(Le,"discoverFiles");import{basename as Xo,dirname as Zo,extname as Qo,resolve as Oe}from"node:path";import{dirname as kn,isAbsolute as Io,join as En,relative as Oo,resolve as $n,sep as To}from"node:path";import{readFile as Do}from"node:fs/promises";import{join as Co}from"node:path";async function vo(e){try{return await Do(e,"utf8")}catch{return null}}s(vo,"readManifest");async function j(e,t){let n=[];for(let r of t){let o=await vo(Co(e,r));o!==null&&n.push({file:r,content:o})}return n.length>0?{dir:e,manifest:n[0].file,files:n}:null}s(j,"detectManifests");function H(e,t){return e.files.find(n=>n.file===t)?.content??null}s(H,"manifestContent");function D(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}s(D,"cleanName");function je(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return D(t===-1?e:e.slice(0,t))}s(je,"personName");function ue(e){try{return JSON.parse(e)}catch{return}}s(ue,"parseJsonManifest");function*Re(e,t){let n="";for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.startsWith("[")){let i=o.match(/^\[([^[\]]+)\]/);n=i?i[1].split(".").map(a=>a.trim()).join("."):"";continue}n===t&&(yield o)}}s(Re,"sectionLines");function Z(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of Re(e,t)){let i=o.match(r);if(i)return D(i[1]??i[2])}}s(Z,"readTomlString");function Me(e,t,n){let r=new RegExp(`^${n}\\s*[=:](.*)$`);for(let o of Re(e,t)){let i=o.match(r);if(i)return D(i[1])}}s(Me,"readIniValue");function No(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*\\[`),o=null;for(let i of Re(e,t)){if(o!==null){o.push(i);continue}let a=i.match(r);a&&(o=[i.slice(a[0].length)])}return o===null?null:o.join(`
|
|
9
|
+
`)}s(No,"tomlArrayText");function Fo(e,t){let n=t;for(;n<e.length;)if(e[n]==="#"){let r=e.indexOf(`
|
|
10
|
+
`,n);n=r===-1?e.length:r+1}else if(/\s/.test(e[n]))n+=1;else break;return n}s(Fo,"skipTomlSpace");function Q(e,t){let n=No(e,t,"authors");if(n===null)return;let r=n.slice(Fo(n,0)),o=r.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return je(o[1]??o[2]);let a=r.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return a?D(a[1]??a[2]):void 0}s(Q,"readTomlAuthor");var un=["go.mod"];function Lo(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return D(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}s(Lo,"readModulePath");var fn={id:"go",languages:["go"],manifests:un,detect(e){return j(e,un)},read(e){return{name:Lo(e.files[0].content)}}};var dn=["package.json"];function jo(e){let t=D(e?.name),n=D(e?.publisher),r=typeof e?.engines?.vscode=="string";return t&&n&&r?`${n}.${t}`:t}s(jo,"readPublishedName");function Ro(e){if(e!==null&&typeof e=="object"){let t=e;return D(t.company)??D(t.name)}return je(e)}s(Ro,"readAuthorCompany");var mn={id:"node",languages:["node"],manifests:dn,detect(e){return j(e,dn)},read(e){let t=ue(e.files[0].content);return{name:jo(t),company:Ro(t?.author)}}};var pn=["composer.json"],hn={id:"php",languages:["php"],manifests:pn,detect(e){return j(e,pn)},read(e){let t=ue(e.files[0].content),n=t?.authors;return{name:D(t?.name),company:Array.isArray(n)?D(n[0]?.name):void 0}}};var gn=["pyproject.toml","setup.cfg","setup.py"];function yn(e,t){let n=e.indexOf("setup(");if(n===-1)return;let r=e.slice(n).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return r&&r[2].trim()||void 0}s(yn,"readSetupPyArgument");function Mo(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Z(t,"project","name")??Z(t,"tool.poetry","name"))??(n===null?void 0:Me(n,"metadata","name"))??(r===null?void 0:yn(r,"name"))}s(Mo,"readPythonName");function Po(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Q(t,"project")??Q(t,"tool.poetry"))??(n===null?void 0:Me(n,"metadata","author"))??(r===null?void 0:yn(r,"author"))}s(Po,"readPythonCompany");var xn={id:"python",languages:["python"],manifests:gn,detect(e){return j(e,gn)},read(e){return{name:Mo(e),company:Po(e)}}};var wn=["Cargo.toml"],bn={id:"rust",languages:["rust"],manifests:wn,detect(e){return j(e,wn)},read(e){let t=e.files[0].content;return{name:Z(t,"package","name"),company:Q(t,"package")}}};var Ho=[mn,xn,hn,bn,fn],Sn=["name","company"];async function Pe(e,t,n){let o=(await Promise.all(t.map(async a=>({driver:a,detection:await a.detect(e)})))).filter(a=>a.detection!==null),i=o.filter(a=>typeof n=="string"&&a.driver.languages.includes(n));return[...i,...o.filter(a=>!i.includes(a))]}s(Pe,"claimFolder");function _o(e,t){let n=Oo(t,e);return n!==""&&n!==".."&&!n.startsWith(`..${To}`)&&!Io(n)}s(_o,"isStrictlyInside");async function An(e,t={}){let n=Array.isArray(t.drivers)?t.drivers:Ho,r=typeof t.scanRoot=="string"?$n(t.scanRoot):null,o=$n(e),i=await Pe(o,n,t.language);for(;i.length===0;){if(await Ee(En(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let u=kn(o);if(u===o)return null;o=u,i=await Pe(o,n,t.language)}let a={},c={},l=o,f=i;for(;;){for(let{driver:m,detection:h}of f){let y=m.read(h);for(let d of Sn)a[d]===void 0&&y[d]!==void 0&&(a[d]=y[d],c[d]={driver:m.id,manifest:h.manifest,dir:l})}if(Sn.every(m=>a[m]!==void 0)||r===null||!_o(l,r)||await Ee(En(l,".git")))break;l=kn(l),f=await Pe(l,n,t.language)}return{root:o,marker:i[0].detection.manifest,drivers:i.map(u=>u.driver.id),fields:a,sources:c}}s(An,"resolveManifestProject");import{execFile as Uo}from"node:child_process";import{basename as Wo,dirname as Bo}from"node:path";import{promisify as zo}from"node:util";var Ie=zo(Uo);async function F(e,t){try{let{stdout:n}=await Ie("git",t,{cwd:e}),r=n.trim();return r.length>0?r:null}catch{return null}}s(F,"runGit");function Dn(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}s(Dn,"isEscaped");function Go(e){let t=e.trim();if(!t.endsWith(")")||Dn(t,t.length-1))return t;let n=0;for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(o!=="("&&o!==")"||Dn(t,r))&&(n+=o===")"?1:-1,n===0))return t.slice(0,r).trim()}return t}s(Go,"stripUidComment");function Yo(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let n=t.match(/<([^>\n]+)>\s*$/),r=n?.[1]?.trim()||null,o=(n?t.slice(0,n.index):t).trim();return{authorName:Go(o)||o||null,authorEmail:r}}s(Yo,"parseSignerUid");async function Vo(e,t){try{let{stdout:n}=await Ie(e,t),r=n.trim();return r.length>0?r:null}catch{return null}}s(Vo,"runProgram");function Jo(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16)))}s(Jo,"decodeColonField");async function Ko(e){let t=await F(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let n=await F(e,["config","--get","user.signingkey"]);if(!n)return null;let r=await F(e,["config","--get","gpg.openpgp.program"])||await F(e,["config","--get","gpg.program"])||"gpg",o=await Vo(r,["--batch","--with-colons","--list-keys",n]);if(!o)return null;for(let i of o.split(`
|
|
11
|
+
`)){let a=i.split(":");if(a[0]==="uid"&&a[1]!=="r"&&a[1]!=="e"&&a[9])return Jo(a[9])}return null}s(Ko,"readSigningKeyUid");async function Cn(e,t={}){let n=await F(e,["config","--get","user.name"]),r=await F(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Ko(e)||await F(e,["log","-1","--format=%GS"]),i=Yo(o||"");n=i.authorName||n,r=r||i.authorEmail}if(!n||!r){let o=await F(e,["log","-1","--format=%an|%ae"]);if(o){let[i,a]=o.split("|");n=n||i||null,r=r||a||null}}return{authorName:n,authorEmail:r}}s(Cn,"detectGitAuthor");function vn(e){return e.replace(/z$/i,"+00:00")}s(vn,"canonicalGitDate");async function Nn(e,t){let n=await F(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!n)return null;let r=n.split(`
|
|
12
|
+
`)[0],[o,i]=r.split("|");if(!o||!i)return null;let a=Number.parseInt(i,10);return Number.isNaN(a)?null:{date:vn(o),timestamp:a}}s(Nn,"getGitCreationDate");async function Fn(e,t){let n=await F(e,["log","-1","--format=%aI|%at","--",t]);if(!n)return null;let[r,o]=n.split("|");if(!r||!o)return null;let i=Number.parseInt(o,10);return Number.isNaN(i)?null:{date:vn(r),timestamp:i}}s(Fn,"getGitLastModifiedDate");var qo=256*1024*1024;async function Ln(e){let t=Bo(e);if(await F(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:n}=await Ie("git",["show",`HEAD:./${Wo(e)}`],{cwd:t,encoding:"utf8",maxBuffer:qo});return{state:"tracked",content:n}}catch{return{state:"untracked",content:null}}}s(Ln,"readGitHeadFile");function ei(e){return Xo(e)||"project"}s(ei,"folderName");function ti(e,t){if(typeof t!="string")return e;let n=t.trim();return n.length===0||Jt(e)?e:`${e} <${n}>`}s(ti,"formatAuthorNameWithCompany");async function ni(e,t={}){let n=Array.isArray(t.detectors)?t.detectors:O(t),r=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=r.length>0?n.find(f=>f.extensions.includes(r)):void 0,i=await An(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),a=i?i.root:Oe(e),c=i?.sources.name,l=i?.sources.company;return{language:o?.id??i?.drivers[0]??"unknown",rootDir:a,marker:i?i.marker:null,projectName:i?.fields.name??ei(a),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:a},companyName:i?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:i?i.drivers:[]}}s(ni,"detectProjectFromMarkers");async function Te(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),n=Oe(t),r=O(e),o=e.targetFilePath?Zo(n):n,i=e.targetFilePath?Qo(n).toLowerCase():"",a=Oe(e.projectRoot||e.cwd||process.cwd()),c=await ni(o,{detectors:r,preferredExtension:i,scanRoot:a}),l=await Cn(c.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),f=e.authorName||l.authorName||"Unknown Author",u=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||c.projectName,projectNameSource:e.projectName?{from:"option"}:c.projectNameSource,language:e.language||c.language,projectRoot:e.projectRoot||c.rootDir,marker:e.marker===void 0?c.marker:e.marker,authorName:ti(f,e.company),authorEmail:e.authorEmail||l.authorEmail||"unknown@example.com",companyName:u||c.companyName,companyNameSource:u?{from:"option"}:c.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}s(Te,"resolveProjectMetadata");function ri(e){return He({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}s(ri,"formatDateWithTimezone");function He(e){return`${Pn(e," ")} ${In(e.offsetMinutes)}`}s(He,"formatSpaceDate");function Rn(e){if(typeof e!="string")throw new Error(`timezone must be an IANA time zone name string, such as "America/Los_Angeles" or "UTC" (got ${typeof e})`);try{Mn(e)}catch(t){throw new Error(`Unknown time zone "${e}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:t})}return e}s(Rn,"assertTimeZone");var jn=new Map;function Mn(e){let t=jn.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),jn.set(e,t)),t}s(Mn,"getZoneFormatter");function _e(e,t){let n={};for(let o of Mn(t).formatToParts(new Date(e*1e3)))n[o.type]=Number(o.value);let r=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)/1e3;return{year:n.year,month:n.month,day:n.day,hour:n.hour,minute:n.minute,second:n.second,offsetMinutes:(r-e)/60}}s(_e,"toZonedDateParts");function Pn(e,t){let n=s(r=>String(r).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${n(e.month)}-${n(e.day)}${t}${n(e.hour)}:${n(e.minute)}:${n(e.second)}`}s(Pn,"formatWallClock");function In(e){let t=s(r=>String(r).padStart(2,"0"),"pad"),n=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(n/60))}:${t(n%60)}`}s(In,"formatOffset");function fe(e=new Date){return{date:ri(e),timestamp:Math.floor(e.getTime()/1e3)}}s(fe,"toDatePayload");var oi=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function _(e){let t=oi.exec(e.trim());if(!t)return null;let[n,r,o,i,a,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),f=t[8]==="-"?-l:l,u=new Date(Date.UTC(n,r-1,o,i,a,c));return!(u.getUTCFullYear()===n&&u.getUTCMonth()===r-1&&u.getUTCDate()===o&&u.getUTCHours()===i&&u.getUTCMinutes()===a&&u.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:n,month:r,day:o,hour:i,minute:a,second:c,offsetMinutes:f,timestamp:Math.floor(u.getTime()/1e3)-f*60}}s(_,"parseHeaderDate");function Ue(e){return`${Pn(e,"T")}${In(e.offsetMinutes)}`}s(Ue,"formatIsoDate");var ii={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function On(e,t){let n=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return n?n[1].trim():null}s(On,"readHeaderField");function We(e){let t=null;for(let{source:n,payload:r}of e)r&&(!t||r.timestamp<t.payload.timestamp)&&(t={source:n,payload:r});return t}s(We,"pickOldestDate");function Hn({existing:e,gitCreated:t,filesystemCreated:n,fixCreatedDate:r=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:n}];if(!e)return We(o);if(!r)return{source:"existing-header",payload:e};let i=_(e.date)?e:null;return We([{source:"existing-header",payload:i},...o])}s(Hn,"resolveCreatedDate");function _n(e,t=null){if(t)return _e(e.timestamp,t).year;let n=_(e.date);return n?n.year:new Date(e.timestamp*1e3).getFullYear()}s(_n,"dateYear");function Tn(e,t,n,r){let o=e.match(/^(.+?)\s*\((\d+)\)$/),i=o?_(o[1]):null;if(!o||!i)return r.push({check:`${n}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let a=Number.parseInt(o[2],10);return a!==i.timestamp&&r.push({check:`${n}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${i.timestamp})`,message:`${t} epoch ${a} does not match ${o[1]} (expected ${i.timestamp})`}),{text:o[1],timestamp:i.timestamp}}s(Tn,"checkDateValue");function Un(e,t={},n={}){let r=[],o=On(e,"@Date"),i=o===null?null:Tn(o,"@Date","created",r),a=We([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(i&&a&&i.timestamp>a.payload.timestamp){let u=ii[a.source];r.push({check:"created-newer-than-source",field:"@Date",advisory:n.strictCreatedDate!==!0,value:o,expected:`${a.payload.date} (${a.payload.timestamp})`,source:a.source,message:`@Date ${i.text} is later than the ${u} ${a.payload.date} (${a.payload.timestamp})`})}let c=On(e,"@Last modified time"),l=c===null?null:Tn(c,"@Last modified time","modified",r),f=t.gitLastModified;return l&&f&&l.timestamp!==f.timestamp&&r.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${f.date} (${f.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${f.date} (${f.timestamp})`}),r}s(Un,"checkHeaderDates");function Be(e){if(!e)return null;let t=_(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}s(Be,"repairDateEpoch");function Wn(e){let t=_(e.date);return t?{date:Ue(t),timestamp:t.timestamp}:e}s(Wn,"normalizeDatePayload");function Bn(e,t){let n=_(e.date);if(!n)return e;let r=_e(n.timestamp,t);return r.offsetMinutes===n.offsetMinutes||!Number.isInteger(r.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?Ue(r):He(r),timestamp:n.timestamp}}s(Bn,"convertDatePayload");import{relative as ai}from"node:path";import{extname as si}from"node:path";function U(e,t={}){let n=si(e).toLowerCase(),r=T(t.spacing,"spacing",X);return n.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:r}:{...Bt(e,t),spacing:r}}s(U,"getHeaderSyntaxForFile");function zn(e,t){let n=e.spacing??X;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",f=Array.from({length:n},()=>c);return[...f,...t.map(u=>`${c}${l}${u}`),...f].join(`
|
|
9
13
|
`)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),i=e.blockEnd||(e.kind==="html"?"-->":" */"),a=Array.from({length:n},()=>o.trimEnd());return[r,...a,...t.map(c=>`${o}${c}`),...a,i].join(`
|
|
10
|
-
`)}s(
|
|
14
|
+
`)}s(zn,"renderHeaderLines");function Gn(e){let t=`/${ai(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,n=U(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),r=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,i=e.lastModifiedByName||e.authorName,a=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",f=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${r}`,`@Email: <${o}>`,"-----",`@Last modified by: ${i} (${a})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return zn(n,f)}s(Gn,"buildHeader");var ci=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function I(e,t){let n=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),r=n?n[1].trim():"";return r.length>0?r:null}s(I,"readTag");function li(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),n=t.indexOf("(",t.lastIndexOf(")")+1);return n===-1?{name:e,email:null}:{name:t.slice(0,n).trimEnd()||null,email:t.slice(n+1)||null}}s(li,"splitLastModifiedBy");function ui(e){let t={startYear:null,endYear:null,companyName:null},n=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!n)return t;let r=e.slice(n[0].length),o=r.match(/^\s*-\s*(\d{4})/);o&&(r=r.slice(o[0].length));let i=r.toLowerCase(),a=i.endsWith("all rights reserved.")?20:i.endsWith("all rights reserved")?19:0;return a===0||!/^\s/.test(r)?t:{startYear:n[1],endYear:o?o[1]:null,companyName:r.slice(0,-a).trim()||null}}s(ui,"splitCopyright");function Yn(e){let t=li(I(e,"Last modified by")),n=ui(I(e,"Copyright")),r=I(e,"Email");return{projectName:I(e,"Project"),filename:I(e,"Filename"),createdAt:I(e,"Date"),authorName:I(e,"Author"),authorEmail:r===null?null:r.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:I(e,"Last modified time"),copyrightStartYear:n.startYear,copyrightEndYear:n.endYear,companyName:n.companyName}}s(Yn,"parseHeaderFields");function Vn(e,t){let n=Yn(e??""),r=Yn(t);return ci.filter(o=>n[o]!==r[o]).map(o=>({field:o,previous:n[o],detected:r[o]}))}s(Vn,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(ee,"escapeRegex");function ze(e,t,n={}){let r=t.startsWith("\uFEFF")?"\uFEFF":"",o=t.slice(r.length),i=`${r}${ce(e,o,n)}`;return{prefix:i,body:t.slice(i.length)}}s(ze,"splitPreservedPrefix");function de(e){let t=e.indexOf(`
|
|
11
15
|
`);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
|
|
12
16
|
`:`
|
|
13
|
-
`}s(de,"lineEnding");function
|
|
17
|
+
`}s(de,"lineEnding");function z(e,t){if(t.kind==="html"){let r=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${r}[\\s\\S]*?${o}(?:\\r?\\n)*`))}if(t.kind==="line"){let r=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${r}[^\\n]*\\n)+(?:\\r?\\n)*`))}let n=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${n}(?:\\r?\\n)*`))}s(z,"matchHeaderSegment");var qn=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,fi="Moved out of the file header by fix-headers:";function Xn(e){return e.some(t=>/^@(?:Project|Filename):/.test(t.text))}s(Xn,"isFileHeader");function Ge(e,t){let n=e.replace(/(?:\r?\n)+$/,"");if(t.kind==="line"){let u=new RegExp(`^${ee(t.linePrefix||"#")}[ \\t]*`);return n.split(`
|
|
14
18
|
`).map(m=>{let h=m.replace(/\r$/,"");return{raw:h,text:h.replace(u,"").trim()}})}let r=t.kind==="html",o=r?n.replace(/^<!--/,"").replace(/--!?>\s*$/,""):n.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),i=t.blockLinePrefix||(r?" ":" * "),a=r?/^\s*/:/^\s*\*?[ \t]*/,c=o.split(`
|
|
15
|
-
`).map((u,m)=>({raw:m===0&&u.trim()!==""?`${i}${u.trim()}`:u.trimEnd(),text:(m===0?u:u.replace(a,"")).trim()})),l=c[0].raw===""?1:0,f=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,f)}s(Ge,"segmentLines");function
|
|
19
|
+
`).map((u,m)=>({raw:m===0&&u.trim()!==""?`${i}${u.trim()}`:u.trimEnd(),text:(m===0?u:u.replace(a,"")).trim()})),l=c[0].raw===""?1:0,f=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,f)}s(Ge,"segmentLines");function di(e,t){let n=e.map(o=>{let i=o.text.match(qn);return o.text===""?"blank":i&&i[1]==="Copyright"?t.copyright?"copyright":(t.copyright=!0,"field"):i?"field":/^-{3,}$/.test(o.text)?"dash":"text"}),r=s((o,i)=>{for(let a=o+i;a>=0&&a<n.length;a+=i)if(n[a]!=="blank"&&n[a]!=="dash")return n[a]==="copyright"?"field":n[a]},"neighbour");return n.map((o,i)=>o==="dash"?r(i,-1)==="field"||r(i,1)==="field"?"separator":"text":o)}s(di,"classifyLines");function mi(e,t="",n={}){let r=U(t,n),o=[],i=[],a={copyright:!1},c=e,l=z(c,r),f=!0;for(;l&&l[0].length>0;){let p=Ge(l[0],r),w=di(p,a),b=p.findIndex($=>$.text!=="");!f&&b!==-1&&p[b].text===fi&&(w[b]="separator"),p.forEach(($,C)=>{w[C]==="copyright"&&i.push($.text.replace(qn,"").trim()),o.push({raw:$.raw,kind:w[C]})}),c=c.slice(l[0].length),l=z(c,r),f=!1}let u=o.findIndex(p=>p.kind==="text");if(u===-1)return{foreign:[],copyrights:i};let m=o.map(p=>p.kind).lastIndexOf("text"),h=[],y=[],d=!1;for(let p of o.slice(u,m+1))p.kind==="text"?(h.push(...d?[]:y,p.raw),y=[],d=!1):p.kind==="blank"?y.push(p.raw):d=!0;return{foreign:h,copyrights:i}}s(mi,"splitHeaderText");function pi(e,t,n){let r=t.kind==="html";return t.kind==="line"?e.join(n):[t.blockStart||(r?"<!--":"/**"),...e,t.blockEnd||(r?"-->":" */")].join(n)}s(pi,"renderForeignBlock");function hi(e,t,n){let r=e.split(`
|
|
16
20
|
`),o=n.kind==="html",i=n.kind==="line"?n.linePrefix||"#":(n.blockLinePrefix||(o?" ":" * ")).trimEnd(),a=Math.min(r.length-1,(n.spacing??1)+(n.kind==="line"?0:1)),c=r.length-a;return[...r.slice(0,c),i,...t,...r.slice(c)].join(`
|
|
17
|
-
`)}s(
|
|
18
|
-
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}s(
|
|
21
|
+
`)}s(hi,"appendToHeader");function Jn(e){let t=e.trim(),n=t.match(/^copyright\b/i);t=n?t.slice(n[0].length).trimStart():t;for(let c=t.match(/^(?:\(c\)|©)/i);c;c=t.match(/^(?:\(c\)|©)/i))t=t.slice(c[0].length).trimStart();let r=t.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);t=r?t.slice(r[0].length):t,t=t.trimEnd();let o=t.toLowerCase(),i=o.endsWith("all rights reserved.")?20:o.endsWith("all rights reserved")?19:0;t=t.slice(0,t.length-i);let a=t.length;for(;a>0&&`.,; \r
|
|
22
|
+
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}s(Jn,"copyrightHolder");function gi(e,t){let n=e.split(`
|
|
19
23
|
`),r=n.findIndex(c=>c.includes("@Copyright:")),o=n.map(c=>/@[A-Za-z][A-Za-z ]*:/.test(c)).lastIndexOf(!0),i=r!==-1?r:o;if(t.length===0||i===-1)return e;let a=n[i].slice(0,n[i].indexOf("@"));return[...n.slice(0,i+1),...t.map(c=>`${a}@Copyright: ${c}`),...n.slice(i+1)].join(`
|
|
20
|
-
`)}s(
|
|
24
|
+
`)}s(gi,"insertCopyrights");function Kn(e,t){let n=0,r=z(e,t);for(;r&&r[0].length>0&&Xn(Ge(r[0],t));)n+=r[0].length,r=z(e.slice(n),t);return n}s(Kn,"leadingHeadersLength");function me(e,t="",n={}){let r=e.startsWith("\uFEFF")?"\uFEFF":"",o=e.slice(r.length),i=ce(t,o,n),a=U(t,n),c=i.length,l=Kn(o.slice(c),a);if(l===0)return e;let f=r===""&&c===0&&o.startsWith("\uFEFF",l);f&&(r="\uFEFF",o=`${o.slice(0,l)}${o.slice(l+1)}`,l+=Kn(o.slice(l),a));let u=o.slice(c,c+l),m=o.slice(c+l),h=ce(t,`${i}${m}`,n),y=h.length>i.length?h.slice(i.length):"";if(y===""&&!f)return e;let d=y===""||y.endsWith(`
|
|
21
25
|
`)?y:`${y}${de(e)??`
|
|
22
|
-
`}`;return`${r}${i}${d}${u}${m.slice(y.length)}`}s(me,"restoreTopLines");function pe(e,t="",n={}){let{prefix:r,body:o}=
|
|
23
|
-
`).slice(0,
|
|
24
|
-
`),a=U(t,n);if(!
|
|
25
|
-
`?E:E.replace(/\r?\n/g,S),"withEol");if(!i){let{prefix:E,body:S}=
|
|
26
|
-
`,
|
|
27
|
-
`)?A:"",P=`${E}${g}${V.trim()===""?`${
|
|
28
|
-
`).find(E=>E.includes("@Copyright:")),d=new Set(y===void 0?[]:[
|
|
29
|
-
`,b=w.repeat(l+1),$=r.strictHeaderBlock!==!1,C=
|
|
26
|
+
`}`;return`${r}${i}${d}${u}${m.slice(y.length)}`}s(me,"restoreTopLines");function pe(e,t="",n={}){let{prefix:r,body:o}=ze(t,e,n),i=o.split(`
|
|
27
|
+
`).slice(0,Yt).join(`
|
|
28
|
+
`),a=U(t,n);if(!z(i,a))return null;let l=0,f=0;for(;;){let u=i.slice(l),m=z(u,a);if(!m||!Xn(Ge(m[0],a)))break;l+=m[0].length,f=l}return f===0?null:{start:r.length,end:r.length+f}}s(pe,"findProjectHeader");function he(e,t,n="",r={}){let o=me(e,n,r),i=pe(o,n,r),a=U(n,r),c=T(r.margin,"margin",le),l=a.kind==="line"?Math.max(1,c):c,f=s((E,S)=>S===`
|
|
29
|
+
`?E:E.replace(/\r?\n/g,S),"withEol");if(!i){let{prefix:E,body:S}=ze(n,o,r),A=de(o)??`
|
|
30
|
+
`,M=f(t,A),V=S.replace(/^(?:\r?\n)+/,""),g=E.replace(/^\uFEFF/,"")!==""&&!E.endsWith(`
|
|
31
|
+
`)?A:"",P=`${E}${g}${V.trim()===""?`${M}${A}`:`${M}${A.repeat(l+1)}${V}`}`;return{nextContent:P,changed:P!==e,header:M,written:M,extraCopyrights:[]}}let u=o.slice(i.start,i.end),{foreign:m,copyrights:h}=mi(u,n,r),y=t.split(`
|
|
32
|
+
`).find(E=>E.includes("@Copyright:")),d=new Set(y===void 0?[]:[Jn(y.slice(y.indexOf("@Copyright:")+11))]),p=[];for(let E of h){let S=Jn(E);d.has(S)||(d.add(S),p.push(E))}let w=de(o.slice(i.end))??de(u)??`
|
|
33
|
+
`,b=w.repeat(l+1),$=r.strictHeaderBlock!==!1,C=gi(t,p),R=f(m.length>0&&!$?hi(C,m,a):C,w),k=m.length>0&&$?pi(m,a,w):"",W=o.slice(i.end).replace(/^(?:\r?\n)+/,""),G=k===""?W:`${k}${W.trim()===""?w:`${b}${W}`}`,Y=`${o.slice(0,i.start)}${G.trim()===""?`${R}${w}`:`${R}${b}${G}`}`,x=`${R}${k===""?"":`${b}${k}`}`;return{nextContent:Y,changed:Y!==e,header:R,written:x,extraCopyrights:p}}s(he,"replaceOrInsertHeader");function Ye(e,t="",n={}){let r=me(e,t,n),o=pe(r,t,n);if(o){let l=r.slice(0,o.start),u=he(r,"",t,{...n,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${u.trim()===""?"":u}`}let{prefix:i,body:a}=ze(t,r,n),c=a.replace(/^(?:\r?\n)+/,"");return`${i}${c.trim()===""?"":c}`}s(Ye,"extractHeaderlessBody");function yi(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let l=n-1;l>=0;l-=1)for(let f=r-1;f>=0;f-=1)o[l][f]=e[l]===t[f]?o[l+1][f+1]+1:Math.max(o[l+1][f],o[l][f+1]);let i=[],a=0,c=0;for(;a<n&&c<r;)e[a]===t[c]?(i.push({type:" ",line:e[a]}),a+=1,c+=1):o[a+1][c]>=o[a][c+1]?(i.push({type:"-",line:e[a]}),a+=1):(i.push({type:"+",line:t[c]}),c+=1);for(;a<n;a+=1)i.push({type:"-",line:e[a]});for(;c<r;c+=1)i.push({type:"+",line:t[c]});return i}s(yi,"diffLines");function Zn(e,t){return`${t===0?e:e+1},${t}`}s(Zn,"formatRange");function Qn(e,t,n={}){let r=e===null?[]:e.split(`
|
|
30
34
|
`),o=t.split(`
|
|
31
|
-
`),i=
|
|
32
|
-
`)}s(
|
|
33
|
-
`).length-1;ne.sample={previousValue:N,newValue:
|
|
35
|
+
`),i=yi(r,o),a=Math.max(0,n.context??3),c=n.lineOffset??0,l=[];if(i.forEach((h,y)=>{if(h.type===" ")return;let d=l[l.length-1];d&&y-d.last<=a*2+1?d.last=y:l.push({first:y,last:y})}),l.length===0)return"";let f=n.fromFile??"a",u=n.toFile??"b",m=[`--- ${e===null?"/dev/null":f}`,`+++ ${u}`];for(let h of l){let y=Math.max(0,h.first-a),d=Math.min(i.length,h.last+a+1),p=i.slice(0,y),w=i.slice(y,d),b=p.filter(k=>k.type!=="+").length+c,$=p.filter(k=>k.type!=="-").length+c,C=w.filter(k=>k.type!=="+").length,R=w.filter(k=>k.type!=="-").length;m.push(`@@ -${Zn(b,C)} +${Zn($,R)} @@`);for(let k of w)m.push(`${k.type}${k.line}`)}return m.join(`
|
|
36
|
+
`)}s(Qn,"createUnifiedDiff");function ki(e){return re(e,"configFile")}s(ki,"resolveRuntimeOptions");function Ei(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(n=>typeof n!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(n=>n.trim().length>0)}s(Ei,"resolveInputs");function $i(e){let t=e.match(/@Author:\s*(.+)$/m),n=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:n?.[1]?.trim()}}s($i,"extractHeaderAuthorIdentity");function Si(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}s(Si,"extractHeaderLastModifiedIdentity");function Ai(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}s(Ai,"extractHeaderCreatedAt");function Di(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}s(Di,"extractHeaderLastModifiedAt");async function Ci(e,t,n){let r=await Ln(t);return r.state!=="tracked"?{edited:r.state==="untracked",state:r.state}:{edited:Ye(r.content,t,n)!==Ye(e,t,n),state:"tracked"}}s(Ci,"detectContentEdit");async function tr(e={}){let t=await ki(e),n=t.timezone===void 0||t.timezone===null?null:Rn(t.timezone),r=t.convertTimezone===!0;if(r&&!n)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=_t(t.forcedDetectors),i=er(t.projectRoot||t.cwd||process.cwd()),a=await Te({...t,cwd:i});T(t.spacing,"spacing",X),T(t.margin,"margin",le);let c=t.check===!0,l=c||t.dryRun===!0,f=t.fixCreatedDate===!0,u=s(x=>x,"keepDate"),m=t.normalizeDateFormat===!0?Wn:u,h=n?x=>Bn(x,n):u,y=r?h:u,d={language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore},p=Ei(t.input),w;if(p.length>0){let x=new Set;for(let E of p){let S=er(i,E),A=await wi(S).catch(()=>null);if(!A)throw new Error(`Input path does not exist: ${E}`);if(A.isFile())x.add(S);else if(A.isDirectory())for(let M of await Le({...d,projectRoot:S}))x.add(M);else throw new Error(`Input path must be a file or directory: ${E}`)}w=Array.from(x)}else w=await Le({...d,projectRoot:i});let b=new Date().getFullYear(),$=[],C=[],R=new Set,k=0,W=0,G=0,Y=[];for(let x of w){let E=Wt(x,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(E!==null){C.push({file:Ve(i,x),reason:E});continue}let S=Ve(i,x),A=await xi(x,"utf8"),M={enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides},V=Gt(x,me(A,x,M),M);if(V!==null){C.push({file:S,reason:V});continue}let g=await Te({...t,cwd:i,targetFilePath:x});R.add(`${g.language}:${g.projectRoot}`);let P={language:g.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin,strictHeaderBlock:t.strictHeaderBlock!==!1},ge=pe(A,x,P),v=ge?A.slice(ge.start,ge.end):"",Ke=v.length>0?$i(v):{},qe=v.length>0?Si(v):{},ar=v.length>0?Ai(v):null,cr=v.length>0?Di(v):null,Xe=await Vt(x),Ze=Ve(g.projectRoot,x),Qe=await Nn(g.projectRoot,Ze),J=await Fn(g.projectRoot,Ze),et=fe(Xe.createdAt),ye=Hn({existing:Be(ar),gitCreated:Qe,filesystemCreated:et,fixCreatedDate:f}),K=Be(cr),tt=ye.source,lr=K?"existing-header":J?"git-last-modified":"filesystem-updated",xe=m(tt==="existing-header"?y(ye.payload):h(ye.payload)),ur=g.copyrightStartYear===null?"created-date":"option",nt=g.copyrightStartYear??_n(xe,n),rt=m(K?y(K):h(J||fe(Xe.updatedAt))),ot=t.forceAuthorUpdate===!0,fr=t.forceLastModifiedAuthorUpdate===!0,it=await Ci(A,x,P),st=fr||it.edited,at=s(N=>Gn({absoluteFilePath:x,language:g.language,syntaxOptions:P,projectRoot:g.projectRoot,projectName:g.projectName,createdByName:ot?g.authorName:Ke.authorName||g.authorName,createdByEmail:ot?g.authorEmail:Ke.authorEmail||g.authorEmail,lastModifiedByName:st?g.authorName:qe.authorName||g.authorName,lastModifiedByEmail:st?g.authorEmail:qe.authorEmail||g.authorEmail,authorName:g.authorName,authorEmail:g.authorEmail,createdAt:xe,lastModifiedAt:N,copyrightStartYear:nt,companyName:g.companyName,currentYear:b}),"renderHeader"),ct=at(rt),lt=he(A,ct,x,P),dr=it.edited&&K!==null&&J!==null&&K.timestamp<J.timestamp,te=lt.changed||dr,ut=te?m(h(fe(new Date))):rt,mr=te?"current-time-on-change":lr,pr=te?at(ut):ct,L=te?he(A,pr,x,P):lt,ne={file:S,changed:L.changed};if(c){let N=Un(v,{gitCreated:Qe,gitLastModified:J,filesystemCreated:et},{strictCreatedDate:t.strictCreatedDate===!0}),q=N.filter(B=>B.advisory).length;ne.dateIssues=N,G+=q,W+=N.length>q?1:0}if(t.sampleOutput===!0&&L.changed){let N=v.length>0?v.trimEnd():null,q=S.replace(/\\/g,"/"),B=L.written,hr=L.nextContent.slice(0,L.nextContent.indexOf(B)).split(`
|
|
37
|
+
`).length-1;ne.sample={previousValue:N,newValue:B,diff:Qn(N,B,{fromFile:`a/${q}`,toFile:`b/${q}`,lineOffset:hr}),issues:Vn(N,B),detectedValues:{projectName:g.projectName,projectNameSource:g.projectNameSource,language:g.language,projectRoot:g.projectRoot,marker:g.marker,authorName:g.authorName,authorEmail:g.authorEmail,companyName:g.companyName,companyNameSource:g.companyNameSource,copyrightStartYear:nt,copyrightStartYearSource:ur,createdAtSource:tt,lastModifiedAtSource:mr,createdAt:xe,lastModifiedAt:ut}}}if(L.extraCopyrights.length>0){ne.extraCopyrights=L.extraCopyrights;for(let N of L.extraCopyrights)Y.push({file:S,copyright:N})}$.push(ne),L.changed&&(k+=1,l||await bi(x,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(R),filesScanned:w.length-C.length,filesUpdated:k,filesSkipped:C.length,dryRun:l,check:c,...c?{filesWithDateDrift:W,dateAdvisories:G}:{},copyrightWarnings:Y,changes:$,skipped:C}}s(tr,"fixHeaders");function vi(e){return tr(e)}s(vi,"fixHeaders");var nr=vi;var Li=`fix-headers CLI
|
|
34
38
|
|
|
35
39
|
Usage:
|
|
36
40
|
fix-headers [options]
|
|
@@ -81,5 +85,5 @@ Examples:
|
|
|
81
85
|
fix-headers --check --verbose
|
|
82
86
|
fix-headers --timezone America/Los_Angeles --convert-timezone
|
|
83
87
|
fix-headers --project-name @scope/pkg --company-name "Catalyzed Motivation Inc."
|
|
84
|
-
`;function
|
|
88
|
+
`;function ji(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}s(ji,"toCamelCase");function Ri(e){let t={},n={help:!1,json:!1,diff:!1},r={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors","force-detector":"forcedDetectors",input:"input"},o={cwd:"cwd","project-name":"projectName",language:"language","project-root":"projectRoot",marker:"marker","author-name":"authorName","author-email":"authorEmail",company:"company","company-name":"companyName","copyright-start-year":"copyrightStartYear",spacing:"spacing",margin:"margin",timezone:"timezone",config:"config"};for(let i=0;i<e.length;i+=1){let a=e[i];if(a==="-h"||a==="--help"){n.help=!0;continue}if(a==="--json"){n.json=!0;continue}if(a==="--diff"){n.diff=!0;continue}if(a==="--verbose"){t.verbose=!0;continue}if(a==="--dry-run"){t.dryRun=!0;continue}if(a==="--check"){t.check=!0;continue}if(a==="--fix-created-date"){t.fixCreatedDate=!0;continue}if(a==="--strict-created-date"){t.strictCreatedDate=!0;continue}if(a==="--strict-header-block"){let u=e[i+1];(u==="true"||u==="false")&&(i+=1),t.strictHeaderBlock=u!=="false";continue}if(a==="--no-strict-header-block"){t.strictHeaderBlock=!1;continue}if(a==="--normalize-date-format"){t.normalizeDateFormat=!0;continue}if(a==="--convert-timezone"){t.convertTimezone=!0;continue}if(a==="--sample-output"){t.sampleOutput=!0;continue}if(a==="--force-author-update"){t.forceAuthorUpdate=!0;continue}if(a==="--force-last-modified-author-update"){t.forceLastModifiedAuthorUpdate=!0;continue}if(a==="--use-gpg-signer-author"){t.useGpgSignerAuthor=!0;continue}if(!a.startsWith("--"))throw new Error(`Unexpected argument: ${a}`);let c=a.slice(2);if(c==="include-folder-non-recursive"){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=Array.isArray(t.includeFolders)?t.includeFolders:[];t.includeFolders=[...m,{path:u,recursive:!1}];continue}if(r[c]){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=r[c],h=Array.isArray(t[m])?t[m]:[];t[m]=Array.from(new Set([...h,u]));continue}if(o[c]){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=o[c];if(m==="copyrightStartYear"||m==="spacing"||m==="margin"){if(t[m]=Number.parseInt(u,10),Number.isNaN(t[m]))throw new Error(`Invalid number for --${c}: ${u}`)}else m==="marker"&&u==="null"?t[m]=null:t[m]=u;continue}let l=ji(c),f=e[i+1];if(!f||f.startsWith("--"))throw new Error(`Unknown or malformed flag: --${c}`);i+=1,t[l]=f}return{options:t,help:n.help,json:n.json,diff:n.diff}}s(Ri,"parseCliArgs");function Mi(e){return re(e,"config")}s(Mi,"applyConfigFile");function Je(e){if(!e||typeof e!="object")return[];let t=e;return(Array.isArray(t.changes)?t.changes:[]).filter(r=>r&&r.changed===!0&&r.sample&&typeof r.sample.newValue=="string")}s(Je,"getSampledChanges");function or(e){return typeof e=="string"?`"${e}"`:"(missing)"}s(or,"formatIssueValue");function Pi(e,t){for(let n of Je(t)){let r=Array.isArray(n.sample.issues)?n.sample.issues:[];if(e(`issues: ${n.file||"<unknown-file>"}`),r.length===0){e(" (no field differences; header formatting only)");continue}for(let o of r)e(` ${o?.field||"<unknown-field>"}: found ${or(o?.previous)}, expected ${or(o?.detected)}`)}}s(Pi,"printIssues");function Ii(e,t){for(let n of Je(t))typeof n.sample.diff=="string"&&n.sample.diff.length>0&&e(n.sample.diff)}s(Ii,"printDiffs");function Oi(e,t){for(let n of Je(t))e(`sample: ${n.file||"<unknown-file>"}`),e("previous:"),e(n.sample.previousValue===null?"(none)":String(n.sample.previousValue)),e("new:"),e(n.sample.newValue),n.sample.detectedValues&&typeof n.sample.detectedValues=="object"&&(e("detected-values:"),e(JSON.stringify(n.sample.detectedValues,null,2)))}s(Oi,"printSampleOutput");function Ti(e,t){if(!t||typeof t!="object")return;let n=t,o=(Array.isArray(n.changes)?n.changes:[]).filter(i=>i&&i.changed===!0).map(i=>i.file||"<unknown-file>");for(let i of o)e(`updated: ${i}`)}s(Ti,"printChangedFiles");function ir(e,t){let n=Array.isArray(t.copyrightWarnings)?t.copyrightWarnings:[];for(let r of n)e(`warning: ${r?.file||"<unknown-file>"} keeps an additional @Copyright: ${r?.copyright??""}`)}s(ir,"printCopyrightWarnings");function Hi(e,t){let n=Array.isArray(t.skipped)?t.skipped:[];for(let r of n)e(`skipped: ${r?.file||"<unknown-file>"} (${r?.reason||"no reason given"})`)}s(Hi,"printSkipped");function sr(e,t,n,r){let o=n.sampleOutput===!0||r;n.verbose===!0&&(Ti(e,t),o&&Pi(e,t)),n.sampleOutput===!0&&Oi(e,t),r&&Ii(e,t)}s(sr,"printDetails");function _i(e,t,n){let r=Array.isArray(t.changes)?t.changes:[];for(let o of r){let i=Array.isArray(o?.dateIssues)?o.dateIssues:[];for(let a of i)a.advisory===!0&&!n||e(`${a.advisory===!0?"advisory":"drift"}: ${o.file||"<unknown-file>"}: ${a.message}`)}}s(_i,"printDateIssues");async function Ui(e,t={}){let n=t.runner||nr,r=t.stdout||console.log,o=t.stderr||console.error;try{let i=Ri(e);if(i.help)return r(Li),0;let a=await Mi(i.options),c=await n(i.diff?{...a,sampleOutput:!0}:a),l=c&&typeof c=="object"&&c.check===!0?c:null,f=l&&Number(l.filesWithDateDrift)>0?1:0;if(i.json)return r(JSON.stringify(c,null,2)),f;if(l)return r(`fix-headers check: scanned=${l.filesScanned??0}, drift=${l.filesWithDateDrift??0}, advisories=${l.dateAdvisories??0}`),_i(r,l,a.verbose===!0),ir(r,c),f;if(c&&typeof c=="object"){let u=c,m=Number(u.filesSkipped)>0?`, skipped=${u.filesSkipped}`:"",h=Array.isArray(u.copyrightWarnings)&&u.copyrightWarnings.length>0?`, warnings=${u.copyrightWarnings.length}`:"";r(`fix-headers complete: scanned=${u.filesScanned??0}, updated=${u.filesUpdated??0}${m}${h}, dryRun=${u.dryRun===!0}`),Hi(r,u),ir(r,u),sr(r,c,a,i.diff)}else sr(r,c,a,i.diff),r("fix-headers complete");return 0}catch(i){let a=i instanceof Error?i.message:String(i);return o(`fix-headers failed: ${a}`),1}}s(Ui,"runCli");function Wi(e=process.argv,t=import.meta.url,n=Ui){let r=!1;if(e[1])try{let o=rr(e[1]),i=rr(Ni(t));r=o===i}catch{r=t===Fi(e[1]).href}return r?(n(e.slice(2)).then(o=>{process.exitCode=o}),!0):!1}s(Wi,"runCliAsMain");Wi();export{Mi as applyConfigFile,Ri as parseCliArgs,Ui as runCli,Wi as runCliAsMain};
|
|
85
89
|
//# sourceMappingURL=fix-headers.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`)
|
|
4
|
-
`)}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
`)}
|
|
9
|
-
|
|
1
|
+
var ur=Object.defineProperty;var i=(e,t)=>ur(e,"name",{value:t,configurable:!0});import{readFile as fi,stat as mi,writeFile as pi}from"node:fs/promises";import{relative as Ye,resolve as Qn}from"node:path";import{readFile as dr}from"node:fs/promises";import{createRequire as fr}from"node:module";import{dirname as mr,isAbsolute as pr,resolve as ut}from"node:path";var hr=3e4,gr=new Set(["localhost","127.0.0.1","[::1]"]);function xe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(xe,"isPlainObject");function we(e,t){let n={...e};for(let[r,o]of Object.entries(t))r!=="__proto__"&&(n[r]=xe(n[r])&&xe(o)?we(n[r],o):o);return n}i(we,"mergeConfig");function dt(e){return e.kind==="file"?e.path:e.href}i(dt,"describeSource");async function yr(e){if(e.kind==="file")return{text:await dr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(hr)})}catch(n){let r=n.cause instanceof Error?n.cause.message:n.message;throw new Error(`Failed to fetch config ${e.href}: ${r}`,{cause:n})}if(!t.ok)throw new Error(`Failed to fetch config ${e.href}: HTTP ${t.status} ${t.statusText}`);return{text:await t.text(),source:{kind:"url",href:t.url}}}i(yr,"readSource");function lt(e){if(e.protocol==="http:"&&!gr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(lt,"toUrlSource");function xr(e,t){if(/^https?:\/\//i.test(e))return lt(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${dt(t)}; use https, a file path or a package path`);let n=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(n||e.startsWith("/"))return lt(new URL(e,t.href));throw new Error(`Cannot extend package "${e}" from the remote config ${t.href}; use a URL or a relative path`)}if(n||pr(e))return{kind:"file",path:ut(mr(t.path),e)};try{return{kind:"file",path:fr(t.path).resolve(e)}}catch(r){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${r.message}`,{cause:r})}}i(xr,"resolveReference");function wr(e,t){if(e===void 0)return[];let n=Array.isArray(e)?e:[e];if(!n.every(r=>typeof r=="string"&&r.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return n.map(r=>r.trim())}i(wr,"readExtends");async function ft(e,t){let n=dt(e);if(t.includes(n))throw new Error(`Config extends cycle: ${[...t,n].join(" -> ")}`);let{text:r,source:o}=await yr(e),s;try{s=JSON.parse(r)}catch(u){throw new Error(`Config ${n} is not valid JSON: ${u.message}`,{cause:u})}if(!xe(s))throw new Error(`Config file must contain a JSON object: ${n}`);let{extends:a,...c}=s,l={};for(let u of wr(a,n))l=we(l,await ft(xr(u,o),[...t,n]));return we(l,c)}i(ft,"loadSource");function br(e,t=process.cwd()){return ft({kind:"file",path:ut(t,e)},[])}i(br,"loadConfigFile");async function mt(e,t){let n=typeof e[t]=="string"?e[t].trim():"";if(n.length===0)return e;let r=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await br(n,r),...e};return delete o[t],o}i(mt,"applyConfigOption");import{extname as be}from"node:path";import{extname as Er}from"node:path";var ht=[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],kr=400,Sr=/\bcopyright\b|\blicen[cs]e[ds]?\b|SPDX-License-Identifier|\bpublic domain\b/i,pt=/^[\s*/]*@(?:Project|Filename):/m;function $r(e){let t=Er(e).toLowerCase();return ht.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i($r,"resolveCCommentSyntax");function Dr(e){let t=e.replace(/^\uFEFF/,"").split(`
|
|
2
|
+
`).slice(0,kr),n=[],r=null,o=null,s=!1;for(let a of t){let c=a.replace(/\r$/,"");if(r){r.push(c),c.includes("*/")&&(n.push(r.join(`
|
|
3
|
+
`)),r=null);continue}if(s){s=c.endsWith("\\");continue}let l=c.trim();if(o&&!l.startsWith("//")&&(n.push(o.join(`
|
|
4
|
+
`)),o=null),l.length!==0){if(l.startsWith("//")){(o??=[]).push(l);continue}if(l.startsWith("/*")){let u=l.indexOf("*/",2);if(u===-1){r=[l];continue}if(n.push(l.slice(0,u+2)),l.slice(u+2).trim().length>0)break;continue}if(l.startsWith("#")){s=l.endsWith("\\");continue}break}}return o&&n.push(o.join(`
|
|
5
|
+
`)),n}i(Dr,"prologueComments");var gt={id:"c",extensions:ht,enabledByDefault:!0,resolveContentSkipReason(e){let t=Dr(e);return t.length>0&&pt.test(t[0])?null:t.some(n=>!pt.test(n)&&Sr.test(n))?"the file starts with a license or copyright notice that is not a fix-headers header (third-party code)":null},resolveCommentSyntax(e){return $r(e)}};import{extname as Cr}from"node:path";var yt=[".css"];function Ar(e){let t=Cr(e).toLowerCase();return yt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Ar,"resolveCssCommentSyntax");var xt={id:"css",extensions:yt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Ar(e)}};import{extname as Lr}from"node:path";var Fr=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,Nr=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,vr=new Set(["et","expandtab","ai","autoindent","si","smartindent","ro","readonly","bin","binary","noet","noexpandtab","noai","noautoindent","nosi","nosmartindent","noro","noreadonly","nobin","nobinary","nowrap","nolist","nospell","nofen","nofoldenable","noeol","nofixeol","nofixendofline"]);function re(e){let t=e.match(Fr);if(!t)return!1;let n=t[2].trim();if(n.endsWith("-->"))n=n.slice(0,-3).trimEnd();else if(n.endsWith("*/")){let s=n.length-2;for(;s>0&&n[s-1]==="*";)s-=1;n=n.slice(0,s).trimEnd()}let r=n.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!r&&t[1]==="Vim")return!1;let o=r?r[1].match(/(?:\\.|[^\s\\])+/g):n.match(/(?:\\.|[^\s:\\])+/g);return o!==null&&o.every(s=>Nr.test(s))&&o.some(s=>s.includes("=")||vr.has(s))}i(re,"isModeline");function oe(e,t){return t===0&&e.startsWith("#!")}i(oe,"isShebang");function ie(e,t,n=0){let r=0,o=n;for(;r<e.length;){let s=e.indexOf(`
|
|
6
|
+
`,r),a=s===-1?e.length:s+1;if(!t(e.slice(r,a).replace(/\r?\n$/,""),o))break;r=a,o+=1}return e.slice(0,r)}i(ie,"takeTopLines");var bt=[".go"];function Rr(e){let t=Lr(e).toLowerCase();return bt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Rr,"resolveGoCommentSyntax");var wt=/^\/\/(?:go:build|\s*\+build)\s/;function Mr(e,t){let n=ie(t,o=>wt.test(o)||re(o));if(!n.split(/\r?\n/).some(o=>wt.test(o)))return"";let r=t.slice(n.length);return`${n}${r.slice(0,r.length-r.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}i(Mr,"resolveGoPreservedPrefix");var Et={id:"go",extensions:bt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Mr(e,t)},resolveCommentSyntax(e){return Rr(e)}};import{extname as jr}from"node:path";var kt=[".html",".htm"];function Pr(e){let t=jr(e).toLowerCase();return kt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Pr,"resolveHtmlCommentSyntax");var St={id:"html",extensions:kt,enabledByDefault:!0,resolveCommentSyntax(e){return Pr(e)}};import{extname as Ir}from"node:path";var $t=[".jsonv",".jsonc",".json5"];function Tr(e){let t=Ir(e).toLowerCase();return $t.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Tr,"resolveJsonCommentSyntax");var Dt={id:"json",extensions:$t,enabledByDefault:!0,resolveCommentSyntax(e){return Tr(e)}};import{extname as Or}from"node:path";var Ct=[".md",".markdown"];function Hr(e){let t=Or(e).toLowerCase();return Ct.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Hr,"resolveMarkdownCommentSyntax");function _r(e,t){let n=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return n?n[0]:""}i(_r,"resolveMarkdownPreservedPrefix");var At={id:"markdown",extensions:Ct,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return _r(e,t)},resolveCommentSyntax(e){return Hr(e)}};import{extname as Br}from"node:path";var Ft=[".js",".mjs",".cjs",".ts",".mts",".cts",".tsx",".jsx"];function Ur(e){let t=Br(e).toLowerCase();return Ft.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Ur,"resolveNodeCommentSyntax");var Nt={id:"node",extensions:Ft,enabledByDefault:!0,keepsAboveHeader:oe,resolveCommentSyntax(e){return Ur(e)}};import{extname as Wr}from"node:path";var Lt=[".php"];function zr(e){let t=Wr(e).toLowerCase();return Lt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(zr,"resolvePhpCommentSyntax");var vt=/^<\?php(?:\s|$)/i,Rt={id:"php",extensions:Lt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&vt.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return vt.test(e.replace(/^\uFEFF/,""))?null:"the file does not start with <?php, so a comment at the top would be output as text"},resolveCommentSyntax(e){return zr(e)}};import{extname as Gr}from"node:path";var Mt=[".py"],Yr=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function Vr(e,t){return oe(e,t)||t<=1&&Yr.test(e)}i(Vr,"keepsAboveHeader");var jt={id:"python",extensions:Mt,enabledByDefault:!0,keepsAboveHeader:Vr,resolveCommentSyntax(e){let t=Gr(e).toLowerCase();return Mt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Jr}from"node:path";var Pt=[".rs"];function qr(e){let t=Jr(e).toLowerCase();return Pt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(qr,"resolveRustCommentSyntax");var It={id:"rust",extensions:Pt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return qr(e)}};import{extname as Kr}from"node:path";var Tt=[".yaml",".yml"];function Zr(e){let t=Kr(e).toLowerCase();return Tt.includes(t)?{kind:"line",linePrefix:"#"}:null}i(Zr,"resolveYamlCommentSyntax");var Ot={id:"yaml",extensions:Tt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Zr(e)}};var se=[gt,xt,Et,St,Dt,At,Nt,Rt,jt,It,Ot],Xr=new Map(se.map(e=>[e.id,e]));function Qr(e,t){return!t||typeof t!="object"?e:e.kind==="line"?{...e,linePrefix:typeof t.linePrefix=="string"&&t.linePrefix.length>0?t.linePrefix:e.linePrefix,lineSeparator:typeof t.lineSeparator=="string"?t.lineSeparator:e.lineSeparator}:{...e,blockStart:typeof t.blockStart=="string"&&t.blockStart.length>0?t.blockStart:e.blockStart,blockLinePrefix:typeof t.blockLinePrefix=="string"&&t.blockLinePrefix.length>0?t.blockLinePrefix:e.blockLinePrefix,blockEnd:typeof t.blockEnd=="string"&&t.blockEnd.length>0?t.blockEnd:e.blockEnd}}i(Qr,"applySyntaxOverride");function Ht(e){if(e==null)return[];if(!Array.isArray(e)||e.some(n=>typeof n!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=se.filter(n=>n.requiresForce===!0).map(n=>n.id);for(let n of e){if(!Xr.has(n))throw new Error(`forcedDetectors: unknown detector "${n}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(n))throw new Error(`forcedDetectors: "${n}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}i(Ht,"resolveForcedDetectors");function T(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),n=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),r=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return se.filter(o=>o.requiresForce===!0?r.has(o.id)&&!n.has(o.id):t.size>0?t.has(o.id):n.has(o.id)?!1:o.enabledByDefault)}i(T,"getEnabledDetectors");function _t(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(n=>n.toLowerCase()));let t=T(e);return new Set(t.flatMap(n=>n.extensions))}i(_t,"getAllowedExtensions");function Bt(e,t={}){let n=be(e).toLowerCase();if(T(t).some(a=>a.extensions.includes(n)&&a.resolveCommentSyntax(e)!==null))return null;if(n.length===0)return"the file has no extension, so its comment syntax is unknown";let o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),s=se.find(a=>a.requiresForce===!0&&a.extensions.includes(n)&&!o.has(a.id));return s?`${n} files get a header only when forced (--force-detector ${s.id} / forcedDetectors: ["${s.id}"])`:`no enabled detector handles ${n} files`}i(Bt,"getHeaderSkipReason");function Ut(e,t={}){let n=be(e).toLowerCase(),r=Array.isArray(t.detectors)?t.detectors:T(t);for(let o of r){if(!o.extensions.includes(n))continue;let s=o.resolveCommentSyntax(e);if(s){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return Qr(s,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(Ut,"getCommentSyntaxForFile");function Wt(e,t){let n=be(e).toLowerCase();return T(t).find(r=>r.extensions.includes(n))}i(Wt,"detectorForFile");function ae(e,t,n={}){let r=Wt(e,n);if(!r)return"";let o=typeof r.resolvePreservedPrefix=="function"?r.resolvePreservedPrefix(e,t):"",s=r.keepsAboveHeader,a=ie(t.slice(o.length),(c,l)=>re(c)||typeof s=="function"&&s(c,l),o.split(`
|
|
7
|
+
`).length-1);return`${o}${a}`}i(ae,"getPreservedPrefixForFile");function zt(e,t,n={}){let r=Wt(e,n);return r&&typeof r.resolveContentSkipReason=="function"?r.resolveContentSkipReason(t):null}i(zt,"getContentSkipReason");var Gt=200,Z=1,ce=2;function O(e,t,n){if(e==null)return n;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(e)}`);return e}i(O,"resolveLayoutCount");import{existsSync as fo}from"node:fs";import{join as Fe,relative as on,resolve as Ne,sep as Ce}from"node:path";import{realpath as mo,stat as po}from"node:fs/promises";import{access as eo,readdir as to,readFile as Ls,stat as no}from"node:fs/promises";import{constants as ro}from"node:fs";import{dirname as js,join as oo,resolve as Ps}from"node:path";async function Ee(e){try{return await eo(e,ro.F_OK),!0}catch{return!1}}i(Ee,"pathExists");async function ke(e,t){let n=[],r=await to(e,{withFileTypes:!0});for(let o of r){let s=oo(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(s,o.name)===!0)continue;if(o.isDirectory()){let l=await ke(s,t);n.push(...l);continue}if(!o.isFile())continue;let a=o.name.lastIndexOf(".");if(a===-1)continue;let c=o.name.slice(a).toLowerCase();t.allowedExtensions.has(c)&&n.push(s)}return n}i(ke,"walkFiles");async function Yt(e){let t=await no(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(Yt,"readFileDates");function Vt(e){let t=e.indexOf("<");for(;t!==-1;){let n=e.indexOf(">",t+1);if(n===-1)return!1;if(n>t+1)return!0;t=e.indexOf("<",n+1)}return!1}i(Vt,"hasAngleTag");function Jt(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}i(Jt,"trimTrailingSlashes");import{execFile as io}from"node:child_process";import{lstat as so,readFile as ao}from"node:fs/promises";import{dirname as qt,isAbsolute as co,join as Xt,relative as Qt,resolve as Se,sep as en}from"node:path";import lo from"ignore";function Kt(e,t){return new Promise(n=>{io("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(r,o)=>{if(!r){n({code:0,stdout:o});return}n({code:typeof r.code=="number"?r.code:-1,stdout:""})})})}i(Kt,"runGitCommand");function De(e,t){return Qt(e,t).split(en).join("/")}i(De,"toPosixRelative");async function tn(e){try{return lo().add(await ao(e,"utf8"))}catch{return null}}i(tn,"readIgnoreFile");async function uo(e){return so(Xt(e,".git")).then(()=>!0,()=>!1)}i(uo,"hasGitEntry");function Zt(e,t,n){for(let r=e.length-1;r>=0;r--){let{base:o,rules:s}=e[r],a=s.test(`${De(o,t)}${n?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}i(Zt,"matchesRules");async function nn(e,t){let n=await tn(Xt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:n?[...t,{base:e,rules:n}]:t}}i(nn,"buildRulesContext");async function $e(e){let[t,n]=await Promise.all([Kt(e,["check-ignore","-q","."]),Kt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||n.code!==0)return nn(e,[]);let r=new Set,o=new Set;for(let s of n.stdout.split("\0")){let a=s.endsWith("/")?s.slice(0,-1):s;if(a.length!==0){r.add(a);for(let c=a.indexOf("/");c!==-1;c=a.indexOf("/",c+1))o.add(a.slice(0,c))}}return{kind:"git",root:e,entries:r,dirs:o}}i($e,"resolveScopeContext");function rn(e){let t=Se(e.root),n=e.gitignore;if(n===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let r=new Map,o=i(async()=>{if(typeof n!="string"&&!Array.isArray(n))return $e(t);let c=typeof n=="string"?[n]:n.filter(u=>typeof u=="string"),l=[];for(let u of c){let f=await tn(Se(t,u));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),s=i(c=>{let l=r.get(c);return l||(l=c===t?o():a(c),r.set(c,l)),l},"contextFor"),a=i(async c=>{let l=await s(qt(c));return l.kind==="git"?l.entries.has(De(l.root,c))?$e(c):l:!l.nested||l.excluded?l:Zt(l.matchers,c,!0)?{...l,excluded:!0}:await uo(c)?$e(c):nn(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let u=Se(c),f=Qt(t,u);if(f.length===0||f===".."||f.startsWith(`..${en}`)||co(f))return!1;let p=await s(qt(u));if(p.kind==="git"){let y=De(p.root,u);return!(p.entries.has(y)||l&&p.dirs.has(y))}return p.excluded||Zt(p.matchers,u,l)}}}i(rn,"createIgnoreFilter");function ho(e){return _t(e)}i(ho,"resolveExtensions");var go=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),cn=new Set([".git",...go]),yo=Object.freeze(["autoload.php","modules.txt"]);function sn(e,t){return cn.has(t)?!0:t==="vendor"&&yo.some(n=>fo(Fe(e,n)))}i(sn,"isNeverWalked");function Ae(e){return Jt(e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}i(Ae,"normalizeFolderPath");function xo(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{path:t,recursive:!0};if(t&&typeof t=="object"&&typeof t.path=="string")return{path:t.path,recursive:t.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(t)} (expected a path string or { path, recursive? })`)}):[]}i(xo,"resolveIncludeFolders");function an(e,t){let n=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${n})`)}i(an,"reportSkippedIncludeFolder");function wo(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let n=Ne(e),r=[],o=new Set;for(let s of t){if(typeof s!="string")continue;let a=Ae(s);if(a.length!==0){if(a.includes("/")){r.push(Ne(n,a));continue}o.add(a)}}return(s,a)=>{if(o.has(a))return!0;for(let l of r)if(s===l||s.startsWith(`${l}/`))return!0;let c=Ae(on(n,s));return r.some(l=>{let u=Ae(on(n,l));return c===u||c.startsWith(`${u}/`)})}}i(wo,"buildExclusionMatcher");async function ve(e){let t=ho(e),n=xo(e.includeFolders),r=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=wo(e.projectRoot,r),s=rn({root:e.projectRoot,gitignore:e.gitignore}),a=i(async(d,m)=>sn(d,m)||o(d,m)||await s.isIgnored(d,!0),"shouldSkipDirectory"),c=n.length>0?n.map(d=>({includeFolder:d.path,rootPath:Fe(e.projectRoot,d.path),recursive:d.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let d of c){let m=await po(d.rootPath).catch(b=>b);if(m instanceof Error){if(m.code==="ENOENT"){an(d.includeFolder,m);continue}throw m}if(!m.isDirectory()){an(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let w=await mo(d.rootPath).catch(()=>Ne(d.rootPath));l.push({...d,realRoot:w})}let u=i((d,m)=>{if(d.realRoot===m.realRoot)return d.recursive||!m.recursive;let w=d.realRoot.endsWith(Ce)?d.realRoot:`${d.realRoot}${Ce}`;if(!d.recursive||!m.realRoot.startsWith(w))return!1;let b=d.rootPath;for(let S of m.realRoot.slice(w.length).split(Ce))if(b=Fe(b,S),sn(b,S)||o(b,S))return!1;return!0},"covers"),f=[...l].sort((d,m)=>d.realRoot.length-m.realRoot.length||Number(m.recursive)-Number(d.recursive)),p=[];for(let d of f)p.some(m=>u(m,d))||p.push(d);let y=[];for(let d of l){if(!p.includes(d))continue;let m=await ke(d.rootPath,{allowedExtensions:t,ignoreFolders:cn,shouldSkipDirectory:a,recursive:d.recursive});y.push(...m)}let g=[];for(let d of new Set(y))!o(d,d.split("/").at(-1)||"")&&!await s.isIgnored(d,!1)&&g.push(d);return g}i(ve,"discoverFiles");import{basename as Go,dirname as Yo,extname as Vo,resolve as Ie}from"node:path";import{dirname as bn,isAbsolute as vo,join as En,relative as Lo,resolve as kn,sep as Ro}from"node:path";import{readFile as bo}from"node:fs/promises";import{join as Eo}from"node:path";async function ko(e){try{return await bo(e,"utf8")}catch{return null}}i(ko,"readManifest");async function R(e,t){let n=[];for(let r of t){let o=await ko(Eo(e,r));o!==null&&n.push({file:r,content:o})}return n.length>0?{dir:e,manifest:n[0].file,files:n}:null}i(R,"detectManifests");function H(e,t){return e.files.find(n=>n.file===t)?.content??null}i(H,"manifestContent");function C(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(C,"cleanName");function Le(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return C(t===-1?e:e.slice(0,t))}i(Le,"personName");function le(e){try{return JSON.parse(e)}catch{return}}i(le,"parseJsonManifest");function*Re(e,t){let n="";for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.startsWith("[")){let s=o.match(/^\[([^[\]]+)\]/);n=s?s[1].split(".").map(a=>a.trim()).join("."):"";continue}n===t&&(yield o)}}i(Re,"sectionLines");function X(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of Re(e,t)){let s=o.match(r);if(s)return C(s[1]??s[2])}}i(X,"readTomlString");function Me(e,t,n){let r=new RegExp(`^${n}\\s*[=:](.*)$`);for(let o of Re(e,t)){let s=o.match(r);if(s)return C(s[1])}}i(Me,"readIniValue");function So(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*\\[`),o=null;for(let s of Re(e,t)){if(o!==null){o.push(s);continue}let a=s.match(r);a&&(o=[s.slice(a[0].length)])}return o===null?null:o.join(`
|
|
8
|
+
`)}i(So,"tomlArrayText");function $o(e,t){let n=t;for(;n<e.length;)if(e[n]==="#"){let r=e.indexOf(`
|
|
9
|
+
`,n);n=r===-1?e.length:r+1}else if(/\s/.test(e[n]))n+=1;else break;return n}i($o,"skipTomlSpace");function Q(e,t){let n=So(e,t,"authors");if(n===null)return;let r=n.slice($o(n,0)),o=r.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return Le(o[1]??o[2]);let a=r.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return a?C(a[1]??a[2]):void 0}i(Q,"readTomlAuthor");var ln=["go.mod"];function Do(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return C(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(Do,"readModulePath");var un={id:"go",languages:["go"],manifests:ln,detect(e){return R(e,ln)},read(e){return{name:Do(e.files[0].content)}}};var dn=["package.json"];function Co(e){let t=C(e?.name),n=C(e?.publisher),r=typeof e?.engines?.vscode=="string";return t&&n&&r?`${n}.${t}`:t}i(Co,"readPublishedName");function Ao(e){if(e!==null&&typeof e=="object"){let t=e;return C(t.company)??C(t.name)}return Le(e)}i(Ao,"readAuthorCompany");var fn={id:"node",languages:["node"],manifests:dn,detect(e){return R(e,dn)},read(e){let t=le(e.files[0].content);return{name:Co(t),company:Ao(t?.author)}}};var mn=["composer.json"],pn={id:"php",languages:["php"],manifests:mn,detect(e){return R(e,mn)},read(e){let t=le(e.files[0].content),n=t?.authors;return{name:C(t?.name),company:Array.isArray(n)?C(n[0]?.name):void 0}}};var hn=["pyproject.toml","setup.cfg","setup.py"];function gn(e,t){let n=e.indexOf("setup(");if(n===-1)return;let r=e.slice(n).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return r&&r[2].trim()||void 0}i(gn,"readSetupPyArgument");function Fo(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:X(t,"project","name")??X(t,"tool.poetry","name"))??(n===null?void 0:Me(n,"metadata","name"))??(r===null?void 0:gn(r,"name"))}i(Fo,"readPythonName");function No(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Q(t,"project")??Q(t,"tool.poetry"))??(n===null?void 0:Me(n,"metadata","author"))??(r===null?void 0:gn(r,"author"))}i(No,"readPythonCompany");var yn={id:"python",languages:["python"],manifests:hn,detect(e){return R(e,hn)},read(e){return{name:Fo(e),company:No(e)}}};var xn=["Cargo.toml"],wn={id:"rust",languages:["rust"],manifests:xn,detect(e){return R(e,xn)},read(e){let t=e.files[0].content;return{name:X(t,"package","name"),company:Q(t,"package")}}};var Mo=[fn,yn,pn,wn,un],Sn=["name","company"];async function je(e,t,n){let o=(await Promise.all(t.map(async a=>({driver:a,detection:await a.detect(e)})))).filter(a=>a.detection!==null),s=o.filter(a=>typeof n=="string"&&a.driver.languages.includes(n));return[...s,...o.filter(a=>!s.includes(a))]}i(je,"claimFolder");function jo(e,t){let n=Lo(t,e);return n!==""&&n!==".."&&!n.startsWith(`..${Ro}`)&&!vo(n)}i(jo,"isStrictlyInside");async function $n(e,t={}){let n=Array.isArray(t.drivers)?t.drivers:Mo,r=typeof t.scanRoot=="string"?kn(t.scanRoot):null,o=kn(e),s=await je(o,n,t.language);for(;s.length===0;){if(await Ee(En(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=bn(o);if(f===o)return null;o=f,s=await je(o,n,t.language)}let a={},c={},l=o,u=s;for(;;){for(let{driver:p,detection:y}of u){let g=p.read(y);for(let d of Sn)a[d]===void 0&&g[d]!==void 0&&(a[d]=g[d],c[d]={driver:p.id,manifest:y.manifest,dir:l})}if(Sn.every(p=>a[p]!==void 0)||r===null||!jo(l,r)||await Ee(En(l,".git")))break;l=bn(l),u=await je(l,n,t.language)}return{root:o,marker:s[0].detection.manifest,drivers:s.map(f=>f.driver.id),fields:a,sources:c}}i($n,"resolveManifestProject");import{execFile as Po}from"node:child_process";import{basename as Io,dirname as To}from"node:path";import{promisify as Oo}from"node:util";var Pe=Oo(Po);async function v(e,t){try{let{stdout:n}=await Pe("git",t,{cwd:e}),r=n.trim();return r.length>0?r:null}catch{return null}}i(v,"runGit");function Dn(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}i(Dn,"isEscaped");function Ho(e){let t=e.trim();if(!t.endsWith(")")||Dn(t,t.length-1))return t;let n=0;for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(o!=="("&&o!==")"||Dn(t,r))&&(n+=o===")"?1:-1,n===0))return t.slice(0,r).trim()}return t}i(Ho,"stripUidComment");function _o(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let n=t.match(/<([^>\n]+)>\s*$/),r=n?.[1]?.trim()||null,o=(n?t.slice(0,n.index):t).trim();return{authorName:Ho(o)||o||null,authorEmail:r}}i(_o,"parseSignerUid");async function Bo(e,t){try{let{stdout:n}=await Pe(e,t),r=n.trim();return r.length>0?r:null}catch{return null}}i(Bo,"runProgram");function Uo(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16)))}i(Uo,"decodeColonField");async function Wo(e){let t=await v(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let n=await v(e,["config","--get","user.signingkey"]);if(!n)return null;let r=await v(e,["config","--get","gpg.openpgp.program"])||await v(e,["config","--get","gpg.program"])||"gpg",o=await Bo(r,["--batch","--with-colons","--list-keys",n]);if(!o)return null;for(let s of o.split(`
|
|
10
|
+
`)){let a=s.split(":");if(a[0]==="uid"&&a[1]!=="r"&&a[1]!=="e"&&a[9])return Uo(a[9])}return null}i(Wo,"readSigningKeyUid");async function Cn(e,t={}){let n=await v(e,["config","--get","user.name"]),r=await v(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Wo(e)||await v(e,["log","-1","--format=%GS"]),s=_o(o||"");n=s.authorName||n,r=r||s.authorEmail}if(!n||!r){let o=await v(e,["log","-1","--format=%an|%ae"]);if(o){let[s,a]=o.split("|");n=n||s||null,r=r||a||null}}return{authorName:n,authorEmail:r}}i(Cn,"detectGitAuthor");function An(e){return e.replace(/z$/i,"+00:00")}i(An,"canonicalGitDate");async function Fn(e,t){let n=await v(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!n)return null;let r=n.split(`
|
|
11
|
+
`)[0],[o,s]=r.split("|");if(!o||!s)return null;let a=Number.parseInt(s,10);return Number.isNaN(a)?null:{date:An(o),timestamp:a}}i(Fn,"getGitCreationDate");async function Nn(e,t){let n=await v(e,["log","-1","--format=%aI|%at","--",t]);if(!n)return null;let[r,o]=n.split("|");if(!r||!o)return null;let s=Number.parseInt(o,10);return Number.isNaN(s)?null:{date:An(r),timestamp:s}}i(Nn,"getGitLastModifiedDate");var zo=256*1024*1024;async function vn(e){let t=To(e);if(await v(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:n}=await Pe("git",["show",`HEAD:./${Io(e)}`],{cwd:t,encoding:"utf8",maxBuffer:zo});return{state:"tracked",content:n}}catch{return{state:"untracked",content:null}}}i(vn,"readGitHeadFile");function Jo(e){return Go(e)||"project"}i(Jo,"folderName");function qo(e,t){if(typeof t!="string")return e;let n=t.trim();return n.length===0||Vt(e)?e:`${e} <${n}>`}i(qo,"formatAuthorNameWithCompany");async function Ko(e,t={}){let n=Array.isArray(t.detectors)?t.detectors:T(t),r=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=r.length>0?n.find(u=>u.extensions.includes(r)):void 0,s=await $n(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),a=s?s.root:Ie(e),c=s?.sources.name,l=s?.sources.company;return{language:o?.id??s?.drivers[0]??"unknown",rootDir:a,marker:s?s.marker:null,projectName:s?.fields.name??Jo(a),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:a},companyName:s?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:s?s.drivers:[]}}i(Ko,"detectProjectFromMarkers");async function Te(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),n=Ie(t),r=T(e),o=e.targetFilePath?Yo(n):n,s=e.targetFilePath?Vo(n).toLowerCase():"",a=Ie(e.projectRoot||e.cwd||process.cwd()),c=await Ko(o,{detectors:r,preferredExtension:s,scanRoot:a}),l=await Cn(c.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),u=e.authorName||l.authorName||"Unknown Author",f=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||c.projectName,projectNameSource:e.projectName?{from:"option"}:c.projectNameSource,language:e.language||c.language,projectRoot:e.projectRoot||c.rootDir,marker:e.marker===void 0?c.marker:e.marker,authorName:qo(u,e.company),authorEmail:e.authorEmail||l.authorEmail||"unknown@example.com",companyName:f||c.companyName,companyNameSource:f?{from:"option"}:c.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}i(Te,"resolveProjectMetadata");function Zo(e){return Oe({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(Zo,"formatDateWithTimezone");function Oe(e){return`${jn(e," ")} ${Pn(e.offsetMinutes)}`}i(Oe,"formatSpaceDate");function Rn(e){if(typeof e!="string")throw new Error(`timezone must be an IANA time zone name string, such as "America/Los_Angeles" or "UTC" (got ${typeof e})`);try{Mn(e)}catch(t){throw new Error(`Unknown time zone "${e}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:t})}return e}i(Rn,"assertTimeZone");var Ln=new Map;function Mn(e){let t=Ln.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),Ln.set(e,t)),t}i(Mn,"getZoneFormatter");function He(e,t){let n={};for(let o of Mn(t).formatToParts(new Date(e*1e3)))n[o.type]=Number(o.value);let r=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)/1e3;return{year:n.year,month:n.month,day:n.day,hour:n.hour,minute:n.minute,second:n.second,offsetMinutes:(r-e)/60}}i(He,"toZonedDateParts");function jn(e,t){let n=i(r=>String(r).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${n(e.month)}-${n(e.day)}${t}${n(e.hour)}:${n(e.minute)}:${n(e.second)}`}i(jn,"formatWallClock");function Pn(e){let t=i(r=>String(r).padStart(2,"0"),"pad"),n=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(n/60))}:${t(n%60)}`}i(Pn,"formatOffset");function ue(e=new Date){return{date:Zo(e),timestamp:Math.floor(e.getTime()/1e3)}}i(ue,"toDatePayload");var Xo=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function _(e){let t=Xo.exec(e.trim());if(!t)return null;let[n,r,o,s,a,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),u=t[8]==="-"?-l:l,f=new Date(Date.UTC(n,r-1,o,s,a,c));return!(f.getUTCFullYear()===n&&f.getUTCMonth()===r-1&&f.getUTCDate()===o&&f.getUTCHours()===s&&f.getUTCMinutes()===a&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:n,month:r,day:o,hour:s,minute:a,second:c,offsetMinutes:u,timestamp:Math.floor(f.getTime()/1e3)-u*60}}i(_,"parseHeaderDate");function _e(e){return`${jn(e,"T")}${Pn(e.offsetMinutes)}`}i(_e,"formatIsoDate");var Qo={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function In(e,t){let n=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return n?n[1].trim():null}i(In,"readHeaderField");function Be(e){let t=null;for(let{source:n,payload:r}of e)r&&(!t||r.timestamp<t.payload.timestamp)&&(t={source:n,payload:r});return t}i(Be,"pickOldestDate");function On({existing:e,gitCreated:t,filesystemCreated:n,fixCreatedDate:r=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:n}];if(!e)return Be(o);if(!r)return{source:"existing-header",payload:e};let s=_(e.date)?e:null;return Be([{source:"existing-header",payload:s},...o])}i(On,"resolveCreatedDate");function Hn(e,t=null){if(t)return He(e.timestamp,t).year;let n=_(e.date);return n?n.year:new Date(e.timestamp*1e3).getFullYear()}i(Hn,"dateYear");function Tn(e,t,n,r){let o=e.match(/^(.+?)\s*\((\d+)\)$/),s=o?_(o[1]):null;if(!o||!s)return r.push({check:`${n}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let a=Number.parseInt(o[2],10);return a!==s.timestamp&&r.push({check:`${n}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${s.timestamp})`,message:`${t} epoch ${a} does not match ${o[1]} (expected ${s.timestamp})`}),{text:o[1],timestamp:s.timestamp}}i(Tn,"checkDateValue");function _n(e,t={},n={}){let r=[],o=In(e,"@Date"),s=o===null?null:Tn(o,"@Date","created",r),a=Be([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(s&&a&&s.timestamp>a.payload.timestamp){let f=Qo[a.source];r.push({check:"created-newer-than-source",field:"@Date",advisory:n.strictCreatedDate!==!0,value:o,expected:`${a.payload.date} (${a.payload.timestamp})`,source:a.source,message:`@Date ${s.text} is later than the ${f} ${a.payload.date} (${a.payload.timestamp})`})}let c=In(e,"@Last modified time"),l=c===null?null:Tn(c,"@Last modified time","modified",r),u=t.gitLastModified;return l&&u&&l.timestamp!==u.timestamp&&r.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${u.date} (${u.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${u.date} (${u.timestamp})`}),r}i(_n,"checkHeaderDates");function Ue(e){if(!e)return null;let t=_(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i(Ue,"repairDateEpoch");function Bn(e){let t=_(e.date);return t?{date:_e(t),timestamp:t.timestamp}:e}i(Bn,"normalizeDatePayload");function Un(e,t){let n=_(e.date);if(!n)return e;let r=He(n.timestamp,t);return r.offsetMinutes===n.offsetMinutes||!Number.isInteger(r.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?_e(r):Oe(r),timestamp:n.timestamp}}i(Un,"convertDatePayload");import{relative as ti}from"node:path";import{extname as ei}from"node:path";function B(e,t={}){let n=ei(e).toLowerCase(),r=O(t.spacing,"spacing",Z);return n.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:r}:{...Ut(e,t),spacing:r}}i(B,"getHeaderSyntaxForFile");function Wn(e,t){let n=e.spacing??Z;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",u=Array.from({length:n},()=>c);return[...u,...t.map(f=>`${c}${l}${f}`),...u].join(`
|
|
12
|
+
`)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),s=e.blockEnd||(e.kind==="html"?"-->":" */"),a=Array.from({length:n},()=>o.trimEnd());return[r,...a,...t.map(c=>`${o}${c}`),...a,s].join(`
|
|
13
|
+
`)}i(Wn,"renderHeaderLines");function zn(e){let t=`/${ti(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,n=B(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),r=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,s=e.lastModifiedByName||e.authorName,a=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",u=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${r}`,`@Email: <${o}>`,"-----",`@Last modified by: ${s} (${a})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return Wn(n,u)}i(zn,"buildHeader");var ni=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function I(e,t){let n=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),r=n?n[1].trim():"";return r.length>0?r:null}i(I,"readTag");function ri(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),n=t.indexOf("(",t.lastIndexOf(")")+1);return n===-1?{name:e,email:null}:{name:t.slice(0,n).trimEnd()||null,email:t.slice(n+1)||null}}i(ri,"splitLastModifiedBy");function oi(e){let t={startYear:null,endYear:null,companyName:null},n=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!n)return t;let r=e.slice(n[0].length),o=r.match(/^\s*-\s*(\d{4})/);o&&(r=r.slice(o[0].length));let s=r.toLowerCase(),a=s.endsWith("all rights reserved.")?20:s.endsWith("all rights reserved")?19:0;return a===0||!/^\s/.test(r)?t:{startYear:n[1],endYear:o?o[1]:null,companyName:r.slice(0,-a).trim()||null}}i(oi,"splitCopyright");function Gn(e){let t=ri(I(e,"Last modified by")),n=oi(I(e,"Copyright")),r=I(e,"Email");return{projectName:I(e,"Project"),filename:I(e,"Filename"),createdAt:I(e,"Date"),authorName:I(e,"Author"),authorEmail:r===null?null:r.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:I(e,"Last modified time"),copyrightStartYear:n.startYear,copyrightEndYear:n.endYear,companyName:n.companyName}}i(Gn,"parseHeaderFields");function Yn(e,t){let n=Gn(e??""),r=Gn(t);return ni.filter(o=>n[o]!==r[o]).map(o=>({field:o,previous:n[o],detected:r[o]}))}i(Yn,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(ee,"escapeRegex");function We(e,t,n={}){let r=t.startsWith("\uFEFF")?"\uFEFF":"",o=t.slice(r.length),s=`${r}${ae(e,o,n)}`;return{prefix:s,body:t.slice(s.length)}}i(We,"splitPreservedPrefix");function de(e){let t=e.indexOf(`
|
|
10
14
|
`);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
|
|
11
15
|
`:`
|
|
12
|
-
`}i(de,"lineEnding");function
|
|
13
|
-
`).map(p=>{let y=p.replace(/\r$/,"");return{raw:y,text:y.replace(f,"").trim()}})}let
|
|
14
|
-
`).map((f,p)=>({raw:p===0&&f.trim()!==""?`${s}${f.trim()}`:f.trimEnd(),text:(p===0?f:f.replace(a,"")).trim()})),l=c[0].raw===""?1:0,u=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,u)}i(
|
|
15
|
-
`),o=
|
|
16
|
-
`)}i(
|
|
17
|
-
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}i(
|
|
18
|
-
`),n
|
|
19
|
-
`)}i(
|
|
16
|
+
`}i(de,"lineEnding");function z(e,t){if(t.kind==="html"){let r=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${r}[\\s\\S]*?${o}(?:\\r?\\n)*`))}if(t.kind==="line"){let r=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${r}[^\\n]*\\n)+(?:\\r?\\n)*`))}let n=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${n}(?:\\r?\\n)*`))}i(z,"matchHeaderSegment");var qn=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,ii="Moved out of the file header by fix-headers:";function Kn(e){return e.some(t=>/^@(?:Project|Filename):/.test(t.text))}i(Kn,"isFileHeader");function ze(e,t){let n=e.replace(/(?:\r?\n)+$/,"");if(t.kind==="line"){let f=new RegExp(`^${ee(t.linePrefix||"#")}[ \\t]*`);return n.split(`
|
|
17
|
+
`).map(p=>{let y=p.replace(/\r$/,"");return{raw:y,text:y.replace(f,"").trim()}})}let r=t.kind==="html",o=r?n.replace(/^<!--/,"").replace(/--!?>\s*$/,""):n.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),s=t.blockLinePrefix||(r?" ":" * "),a=r?/^\s*/:/^\s*\*?[ \t]*/,c=o.split(`
|
|
18
|
+
`).map((f,p)=>({raw:p===0&&f.trim()!==""?`${s}${f.trim()}`:f.trimEnd(),text:(p===0?f:f.replace(a,"")).trim()})),l=c[0].raw===""?1:0,u=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,u)}i(ze,"segmentLines");function si(e,t){let n=e.map(o=>{let s=o.text.match(qn);return o.text===""?"blank":s&&s[1]==="Copyright"?t.copyright?"copyright":(t.copyright=!0,"field"):s?"field":/^-{3,}$/.test(o.text)?"dash":"text"}),r=i((o,s)=>{for(let a=o+s;a>=0&&a<n.length;a+=s)if(n[a]!=="blank"&&n[a]!=="dash")return n[a]==="copyright"?"field":n[a]},"neighbour");return n.map((o,s)=>o==="dash"?r(s,-1)==="field"||r(s,1)==="field"?"separator":"text":o)}i(si,"classifyLines");function ai(e,t="",n={}){let r=B(t,n),o=[],s=[],a={copyright:!1},c=e,l=z(c,r),u=!0;for(;l&&l[0].length>0;){let m=ze(l[0],r),w=si(m,a),b=m.findIndex(S=>S.text!=="");!u&&b!==-1&&m[b].text===ii&&(w[b]="separator"),m.forEach((S,A)=>{w[A]==="copyright"&&s.push(S.text.replace(qn,"").trim()),o.push({raw:S.raw,kind:w[A]})}),c=c.slice(l[0].length),l=z(c,r),u=!1}let f=o.findIndex(m=>m.kind==="text");if(f===-1)return{foreign:[],copyrights:s};let p=o.map(m=>m.kind).lastIndexOf("text"),y=[],g=[],d=!1;for(let m of o.slice(f,p+1))m.kind==="text"?(y.push(...d?[]:g,m.raw),g=[],d=!1):m.kind==="blank"?g.push(m.raw):d=!0;return{foreign:y,copyrights:s}}i(ai,"splitHeaderText");function ci(e,t,n){let r=t.kind==="html";return t.kind==="line"?e.join(n):[t.blockStart||(r?"<!--":"/**"),...e,t.blockEnd||(r?"-->":" */")].join(n)}i(ci,"renderForeignBlock");function li(e,t,n){let r=e.split(`
|
|
19
|
+
`),o=n.kind==="html",s=n.kind==="line"?n.linePrefix||"#":(n.blockLinePrefix||(o?" ":" * ")).trimEnd(),a=Math.min(r.length-1,(n.spacing??1)+(n.kind==="line"?0:1)),c=r.length-a;return[...r.slice(0,c),s,...t,...r.slice(c)].join(`
|
|
20
|
+
`)}i(li,"appendToHeader");function Vn(e){let t=e.trim(),n=t.match(/^copyright\b/i);t=n?t.slice(n[0].length).trimStart():t;for(let c=t.match(/^(?:\(c\)|©)/i);c;c=t.match(/^(?:\(c\)|©)/i))t=t.slice(c[0].length).trimStart();let r=t.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);t=r?t.slice(r[0].length):t,t=t.trimEnd();let o=t.toLowerCase(),s=o.endsWith("all rights reserved.")?20:o.endsWith("all rights reserved")?19:0;t=t.slice(0,t.length-s);let a=t.length;for(;a>0&&`.,; \r
|
|
21
|
+
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}i(Vn,"copyrightHolder");function ui(e,t){let n=e.split(`
|
|
22
|
+
`),r=n.findIndex(c=>c.includes("@Copyright:")),o=n.map(c=>/@[A-Za-z][A-Za-z ]*:/.test(c)).lastIndexOf(!0),s=r!==-1?r:o;if(t.length===0||s===-1)return e;let a=n[s].slice(0,n[s].indexOf("@"));return[...n.slice(0,s+1),...t.map(c=>`${a}@Copyright: ${c}`),...n.slice(s+1)].join(`
|
|
23
|
+
`)}i(ui,"insertCopyrights");function Jn(e,t){let n=0,r=z(e,t);for(;r&&r[0].length>0&&Kn(ze(r[0],t));)n+=r[0].length,r=z(e.slice(n),t);return n}i(Jn,"leadingHeadersLength");function fe(e,t="",n={}){let r=e.startsWith("\uFEFF")?"\uFEFF":"",o=e.slice(r.length),s=ae(t,o,n),a=B(t,n),c=s.length,l=Jn(o.slice(c),a);if(l===0)return e;let u=r===""&&c===0&&o.startsWith("\uFEFF",l);u&&(r="\uFEFF",o=`${o.slice(0,l)}${o.slice(l+1)}`,l+=Jn(o.slice(l),a));let f=o.slice(c,c+l),p=o.slice(c+l),y=ae(t,`${s}${p}`,n),g=y.length>s.length?y.slice(s.length):"";if(g===""&&!u)return e;let d=g===""||g.endsWith(`
|
|
20
24
|
`)?g:`${g}${de(e)??`
|
|
21
|
-
`}`;return`${
|
|
22
|
-
`).slice(0,
|
|
23
|
-
`),a=B(t,
|
|
24
|
-
`?k:k.replace(/\r?\n/g
|
|
25
|
-
`,j=u(t,D),V
|
|
26
|
-
`)?D:"",P=`${k}${h}${V.trim()===""?`${j}${D}`:`${j}${D.repeat(l+1)}${V}`}`;return{nextContent:P,changed:P!==e,header:j,written:j,extraCopyrights:[]}}let f=o.slice(s.start,s.end),{foreign:p,copyrights:y}=
|
|
27
|
-
`).find(k=>k.includes("@Copyright:")),d=new Set(g===void 0?[]:[
|
|
28
|
-
`,b=w.repeat(l+1)
|
|
25
|
+
`}`;return`${r}${s}${d}${f}${p.slice(g.length)}`}i(fe,"restoreTopLines");function me(e,t="",n={}){let{prefix:r,body:o}=We(t,e,n),s=o.split(`
|
|
26
|
+
`).slice(0,Gt).join(`
|
|
27
|
+
`),a=B(t,n);if(!z(s,a))return null;let l=0,u=0;for(;;){let f=s.slice(l),p=z(f,a);if(!p||!Kn(ze(p[0],a)))break;l+=p[0].length,u=l}return u===0?null:{start:r.length,end:r.length+u}}i(me,"findProjectHeader");function pe(e,t,n="",r={}){let o=fe(e,n,r),s=me(o,n,r),a=B(n,r),c=O(r.margin,"margin",ce),l=a.kind==="line"?Math.max(1,c):c,u=i((k,$)=>$===`
|
|
28
|
+
`?k:k.replace(/\r?\n/g,$),"withEol");if(!s){let{prefix:k,body:$}=We(n,o,r),D=de(o)??`
|
|
29
|
+
`,j=u(t,D),V=$.replace(/^(?:\r?\n)+/,""),h=k.replace(/^\uFEFF/,"")!==""&&!k.endsWith(`
|
|
30
|
+
`)?D:"",P=`${k}${h}${V.trim()===""?`${j}${D}`:`${j}${D.repeat(l+1)}${V}`}`;return{nextContent:P,changed:P!==e,header:j,written:j,extraCopyrights:[]}}let f=o.slice(s.start,s.end),{foreign:p,copyrights:y}=ai(f,n,r),g=t.split(`
|
|
31
|
+
`).find(k=>k.includes("@Copyright:")),d=new Set(g===void 0?[]:[Vn(g.slice(g.indexOf("@Copyright:")+11))]),m=[];for(let k of y){let $=Vn(k);d.has($)||(d.add($),m.push(k))}let w=de(o.slice(s.end))??de(f)??`
|
|
32
|
+
`,b=w.repeat(l+1),S=r.strictHeaderBlock!==!1,A=ui(t,m),M=u(p.length>0&&!S?li(A,p,a):A,w),E=p.length>0&&S?ci(p,a,w):"",U=o.slice(s.end).replace(/^(?:\r?\n)+/,""),G=E===""?U:`${E}${U.trim()===""?w:`${b}${U}`}`,Y=`${o.slice(0,s.start)}${G.trim()===""?`${M}${w}`:`${M}${b}${G}`}`,x=`${M}${E===""?"":`${b}${E}`}`;return{nextContent:Y,changed:Y!==e,header:M,written:x,extraCopyrights:m}}i(pe,"replaceOrInsertHeader");function Ge(e,t="",n={}){let r=fe(e,t,n),o=me(r,t,n);if(o){let l=r.slice(0,o.start),f=pe(r,"",t,{...n,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${f.trim()===""?"":f}`}let{prefix:s,body:a}=We(t,r,n),c=a.replace(/^(?:\r?\n)+/,"");return`${s}${c.trim()===""?"":c}`}i(Ge,"extractHeaderlessBody");function di(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let l=n-1;l>=0;l-=1)for(let u=r-1;u>=0;u-=1)o[l][u]=e[l]===t[u]?o[l+1][u+1]+1:Math.max(o[l+1][u],o[l][u+1]);let s=[],a=0,c=0;for(;a<n&&c<r;)e[a]===t[c]?(s.push({type:" ",line:e[a]}),a+=1,c+=1):o[a+1][c]>=o[a][c+1]?(s.push({type:"-",line:e[a]}),a+=1):(s.push({type:"+",line:t[c]}),c+=1);for(;a<n;a+=1)s.push({type:"-",line:e[a]});for(;c<r;c+=1)s.push({type:"+",line:t[c]});return s}i(di,"diffLines");function Zn(e,t){return`${t===0?e:e+1},${t}`}i(Zn,"formatRange");function Xn(e,t,n={}){let r=e===null?[]:e.split(`
|
|
29
33
|
`),o=t.split(`
|
|
30
|
-
`),s=
|
|
31
|
-
`)}i(
|
|
32
|
-
`).length-1;
|
|
34
|
+
`),s=di(r,o),a=Math.max(0,n.context??3),c=n.lineOffset??0,l=[];if(s.forEach((y,g)=>{if(y.type===" ")return;let d=l[l.length-1];d&&g-d.last<=a*2+1?d.last=g:l.push({first:g,last:g})}),l.length===0)return"";let u=n.fromFile??"a",f=n.toFile??"b",p=[`--- ${e===null?"/dev/null":u}`,`+++ ${f}`];for(let y of l){let g=Math.max(0,y.first-a),d=Math.min(s.length,y.last+a+1),m=s.slice(0,g),w=s.slice(g,d),b=m.filter(E=>E.type!=="+").length+c,S=m.filter(E=>E.type!=="-").length+c,A=w.filter(E=>E.type!=="+").length,M=w.filter(E=>E.type!=="-").length;p.push(`@@ -${Zn(b,A)} +${Zn(S,M)} @@`);for(let E of w)p.push(`${E.type}${E.line}`)}return p.join(`
|
|
35
|
+
`)}i(Xn,"createUnifiedDiff");function hi(e){return mt(e,"configFile")}i(hi,"resolveRuntimeOptions");function gi(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(n=>typeof n!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(n=>n.trim().length>0)}i(gi,"resolveInputs");function yi(e){let t=e.match(/@Author:\s*(.+)$/m),n=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:n?.[1]?.trim()}}i(yi,"extractHeaderAuthorIdentity");function xi(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(xi,"extractHeaderLastModifiedIdentity");function wi(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}i(wi,"extractHeaderCreatedAt");function bi(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}i(bi,"extractHeaderLastModifiedAt");async function Ei(e,t,n){let r=await vn(t);return r.state!=="tracked"?{edited:r.state==="untracked",state:r.state}:{edited:Ge(r.content,t,n)!==Ge(e,t,n),state:"tracked"}}i(Ei,"detectContentEdit");async function er(e={}){let t=await hi(e),n=t.timezone===void 0||t.timezone===null?null:Rn(t.timezone),r=t.convertTimezone===!0;if(r&&!n)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=Ht(t.forcedDetectors),s=Qn(t.projectRoot||t.cwd||process.cwd()),a=await Te({...t,cwd:s});O(t.spacing,"spacing",Z),O(t.margin,"margin",ce);let c=t.check===!0,l=c||t.dryRun===!0,u=t.fixCreatedDate===!0,f=i(x=>x,"keepDate"),p=t.normalizeDateFormat===!0?Bn:f,y=n?x=>Un(x,n):f,g=r?y:f,d={language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore},m=gi(t.input),w;if(m.length>0){let x=new Set;for(let k of m){let $=Qn(s,k),D=await mi($).catch(()=>null);if(!D)throw new Error(`Input path does not exist: ${k}`);if(D.isFile())x.add($);else if(D.isDirectory())for(let j of await ve({...d,projectRoot:$}))x.add(j);else throw new Error(`Input path must be a file or directory: ${k}`)}w=Array.from(x)}else w=await ve({...d,projectRoot:s});let b=new Date().getFullYear(),S=[],A=[],M=new Set,E=0,U=0,G=0,Y=[];for(let x of w){let k=Bt(x,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(k!==null){A.push({file:Ye(s,x),reason:k});continue}let $=Ye(s,x),D=await fi(x,"utf8"),j={enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides},V=zt(x,fe(D,x,j),j);if(V!==null){A.push({file:$,reason:V});continue}let h=await Te({...t,cwd:s,targetFilePath:x});M.add(`${h.language}:${h.projectRoot}`);let P={language:h.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin,strictHeaderBlock:t.strictHeaderBlock!==!1},he=me(D,x,P),F=he?D.slice(he.start,he.end):"",Ve=F.length>0?yi(F):{},Je=F.length>0?xi(F):{},tr=F.length>0?wi(F):null,nr=F.length>0?bi(F):null,qe=await Yt(x),Ke=Ye(h.projectRoot,x),Ze=await Fn(h.projectRoot,Ke),J=await Nn(h.projectRoot,Ke),Xe=ue(qe.createdAt),ge=On({existing:Ue(tr),gitCreated:Ze,filesystemCreated:Xe,fixCreatedDate:u}),q=Ue(nr),Qe=ge.source,rr=q?"existing-header":J?"git-last-modified":"filesystem-updated",ye=p(Qe==="existing-header"?g(ge.payload):y(ge.payload)),or=h.copyrightStartYear===null?"created-date":"option",et=h.copyrightStartYear??Hn(ye,n),tt=p(q?g(q):y(J||ue(qe.updatedAt))),nt=t.forceAuthorUpdate===!0,ir=t.forceLastModifiedAuthorUpdate===!0,rt=await Ei(D,x,P),ot=ir||rt.edited,it=i(N=>zn({absoluteFilePath:x,language:h.language,syntaxOptions:P,projectRoot:h.projectRoot,projectName:h.projectName,createdByName:nt?h.authorName:Ve.authorName||h.authorName,createdByEmail:nt?h.authorEmail:Ve.authorEmail||h.authorEmail,lastModifiedByName:ot?h.authorName:Je.authorName||h.authorName,lastModifiedByEmail:ot?h.authorEmail:Je.authorEmail||h.authorEmail,authorName:h.authorName,authorEmail:h.authorEmail,createdAt:ye,lastModifiedAt:N,copyrightStartYear:et,companyName:h.companyName,currentYear:b}),"renderHeader"),st=it(tt),at=pe(D,st,x,P),sr=rt.edited&&q!==null&&J!==null&&q.timestamp<J.timestamp,te=at.changed||sr,ct=te?p(y(ue(new Date))):tt,ar=te?"current-time-on-change":rr,cr=te?it(ct):st,L=te?pe(D,cr,x,P):at,ne={file:$,changed:L.changed};if(c){let N=_n(F,{gitCreated:Ze,gitLastModified:J,filesystemCreated:Xe},{strictCreatedDate:t.strictCreatedDate===!0}),K=N.filter(W=>W.advisory).length;ne.dateIssues=N,G+=K,U+=N.length>K?1:0}if(t.sampleOutput===!0&&L.changed){let N=F.length>0?F.trimEnd():null,K=$.replace(/\\/g,"/"),W=L.written,lr=L.nextContent.slice(0,L.nextContent.indexOf(W)).split(`
|
|
36
|
+
`).length-1;ne.sample={previousValue:N,newValue:W,diff:Xn(N,W,{fromFile:`a/${K}`,toFile:`b/${K}`,lineOffset:lr}),issues:Yn(N,W),detectedValues:{projectName:h.projectName,projectNameSource:h.projectNameSource,language:h.language,projectRoot:h.projectRoot,marker:h.marker,authorName:h.authorName,authorEmail:h.authorEmail,companyName:h.companyName,companyNameSource:h.companyNameSource,copyrightStartYear:et,copyrightStartYearSource:or,createdAtSource:Qe,lastModifiedAtSource:ar,createdAt:ye,lastModifiedAt:ct}}}if(L.extraCopyrights.length>0){ne.extraCopyrights=L.extraCopyrights;for(let N of L.extraCopyrights)Y.push({file:$,copyright:N})}S.push(ne),L.changed&&(E+=1,l||await pi(x,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(M),filesScanned:w.length-A.length,filesUpdated:E,filesSkipped:A.length,dryRun:l,check:c,...c?{filesWithDateDrift:U,dateAdvisories:G}:{},copyrightWarnings:Y,changes:S,skipped:A}}i(er,"fixHeaders");function ki(e){return er(e)}i(ki,"fixHeaders");var Cc=ki;export{Cc as default,ki as fixHeaders};
|
|
33
37
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/fix-headers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Multi-language project header normalizer with auto-detection and override support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build:ci": "npm run lint --if-present && npm run format:check --if-present && npm run types:check && npm run types:build && npm run build",
|
|
34
|
-
"test": "node tests/run-vitest.mjs && npm run test:cjs",
|
|
34
|
+
"test": "node tests/run-vitest.mjs && npm run test:cjs && npm run test:dist",
|
|
35
35
|
"test:cjs": "npm run build && node --conditions=fix-headers-dev --test tests/cjs/entry.test.cjs",
|
|
36
|
+
"test:dist": "npm run build && node tests/run-vitest.mjs --mode=dist",
|
|
36
37
|
"test:watch": "vitest --config .configs/vitest.config.mjs",
|
|
37
38
|
"coverage": "node tests/run-vitest.mjs --coverage-quiet && npm run test:cjs",
|
|
38
|
-
"ci:coverage": "npm run coverage",
|
|
39
|
+
"ci:coverage": "npm run coverage && npm run test:dist",
|
|
39
40
|
"types:build": "tsc -p .configs/tsconfig.json --noCheck",
|
|
40
41
|
"types:check": "tsc -p .configs/tsconfig.json --noEmit",
|
|
41
42
|
"cli": "node --conditions=fix-headers-dev ./src/cli.mjs",
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
"license": "Apache-2.0",
|
|
95
96
|
"sideEffects": false,
|
|
96
97
|
"devDependencies": {
|
|
97
|
-
"@cldmv/configs": "^1.
|
|
98
|
+
"@cldmv/configs": "^1.4.0",
|
|
98
99
|
"@cldmv/eslint-plugin-jsonv": "^1.0.10",
|
|
99
100
|
"@cldmv/jsonv": "^1.0.9",
|
|
100
101
|
"@cldmv/prettier-plugin-jsonv": "^1.0.6",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export namespace detector {
|
|
2
|
+
export let id: string;
|
|
3
|
+
export { extensions };
|
|
4
|
+
export let enabledByDefault: boolean;
|
|
5
|
+
export function resolveContentSkipReason(content: any): string;
|
|
6
|
+
export function resolveCommentSyntax(filePath: any): {
|
|
7
|
+
kind: "block";
|
|
8
|
+
blockStart: string;
|
|
9
|
+
blockLinePrefix: string;
|
|
10
|
+
blockEnd: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @fileoverview C and C++ detector implementation.
|
|
15
|
+
* @module fix-headers/detectors/c
|
|
16
|
+
*/
|
|
17
|
+
declare const extensions: string[];
|
|
18
|
+
export {};
|
|
@@ -96,7 +96,7 @@ export function getPreservedPrefixForFile(filePath: string, content: string, opt
|
|
|
96
96
|
}): string;
|
|
97
97
|
/**
|
|
98
98
|
* Says why a file's content cannot carry a header (a PHP file that does not open with `<?php`,
|
|
99
|
-
* where a comment at the top would be output as text), or null when it can.
|
|
99
|
+
* where a comment at the top would be output as text; third-party C with its own license notice), or null when it can.
|
|
100
100
|
* @param {string} filePath - File path.
|
|
101
101
|
* @param {string} content - File content.
|
|
102
102
|
* @param {{ enabledDetectors?: string[], disabledDetectors?: string[], forcedDetectors?: string[] }} [options={}] - Runtime options.
|