@cldmv/fix-headers 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,18 +10,17 @@ Multi-language source header normalizer for Node.js projects.
10
10
 
11
11
  ## ✨ What's New
12
12
 
13
- ### Latest: v2.0.0 (September 2026)
13
+ ### Latest: v2.1.0 (September 2026)
14
14
 
15
- - **Breaking: built package, discovery and `@Project`** — npm now ships a tsup-built `dist/` and `bin/` instead of `src/`, so deep imports into `src/` stop resolving; the package entry point and the `fix-headers` binary work as before ([#56](https://github.com/CLDMV/fix-headers/pull/56), [#65](https://github.com/CLDMV/fix-headers/pull/65), [#78](https://github.com/CLDMV/fix-headers/pull/78)). Nothing is skipped by name any more: `node_modules`, `dist`, `build`, `coverage`, `tmp`, `.next` and `.turbo` are processed unless an ignore file (everything git honours) or `excludeFolders` excludes them ([#73](https://github.com/CLDMV/fix-headers/pull/73)). `@Project` and the project root come from the project's manifest (`package.json`, `pyproject.toml`, `Cargo.toml`, …) whatever the file's type, so some CSS, HTML, YAML, JSON and Python headers are rewritten on the next run ([#72](https://github.com/CLDMV/fix-headers/pull/72), [#75](https://github.com/CLDMV/fix-headers/pull/75)). The `@Copyright` holder has no built-in default: it is the manifest's author unless `companyName` is set, and is left out when there is none; the start year is the year of each file's `@Date` ([#91](https://github.com/CLDMV/fix-headers/pull/91), [#89](https://github.com/CLDMV/fix-headers/pull/89)). Preview the first run with `--dry-run --diff --verbose`.
16
- - **Date checks, time zones, header diffs and include options** — `--check` validates header dates without writing and exits `1` on drift, `@Date` follows "oldest wins" across the header, git and the filesystem, and mismatched epochs are repaired ([#67](https://github.com/CLDMV/fix-headers/pull/67)); an opt-in `--timezone` writes, and `--convert-timezone` sweeps, header dates into one IANA zone ([#81](https://github.com/CLDMV/fix-headers/pull/81)). `--diff` prints a unified header diff and `sampleOutput` lists per-field issues ([#66](https://github.com/CLDMV/fix-headers/pull/66)); `includeFolders` takes non-recursive entries and never processes a file twice ([#60](https://github.com/CLDMV/fix-headers/pull/60)); a config file can `extends` a shared config by URL, npm package or path ([#88](https://github.com/CLDMV/fix-headers/pull/88)).
17
- - [View full v2.0.0 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.0.0.md)
15
+ - **Header layout: `spacing` and `margin`** — every header is now framed with empty comment lines (`/**`, ` *`, fields, ` *`, ` */` for block headers; a bare `#` above and below for line-comment headers) and followed by two blank lines, set by the new `spacing` (default `1`) and `margin` (default `2`) options in a config file, the API and the CLI (`--spacing`, `--margin`) ([#101](https://github.com/CLDMV/fix-headers/pull/101)). This fixes YAML and Python headers losing their padded `#` lines on the first run. Existing headers are restyled on the next run; use `spacing: 0` and `margin: 1` to keep the compact layout.
16
+ - [View full v2.1.0 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.1.0.md)
18
17
 
19
18
  ### Recent Releases
20
19
 
20
+ - **v2.0.0** (September 2026) — built package (`dist/` and `bin/` instead of `src/`), discovery without name-based skips, `@Project` and the copyright holder from the project manifest, `--check` date validation, `--diff`, `--timezone` and config `extends` ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.0.0.md))
21
21
  - **v1.3.12** (September 2026) — `engines.node` raised to `>=22.12.0` with the move to vitest 5; `ignore` bumped to 7.0.8 ([#38](https://github.com/CLDMV/fix-headers/pull/38), [#40](https://github.com/CLDMV/fix-headers/pull/40), [#43](https://github.com/CLDMV/fix-headers/pull/43)) ([Release](https://github.com/CLDMV/fix-headers/releases/tag/v1.3.12))
22
22
  - **v1.3.11** (September 2026) — CI and release automation only, no runtime change: bot identity and GPG secrets passed to the v4 release and hotfix-redirect workflows ([#32](https://github.com/CLDMV/fix-headers/pull/32), [#36](https://github.com/CLDMV/fix-headers/pull/36)) ([Release](https://github.com/CLDMV/fix-headers/releases/tag/v1.3.11))
23
23
  - **v1.3.10** (August 2026) — tests only, no runtime change: fallback-path tests run in a workspace with no project ancestry ([#28](https://github.com/CLDMV/fix-headers/pull/28)) ([Release](https://github.com/CLDMV/fix-headers/releases/tag/v1.3.10))
24
- - **v1.3.9** (August 2026) — an existing header's `@Last modified by` identity is preserved unless `forceLastModifiedAuthorUpdate` / `--force-last-modified-author-update` is set, so a different local git identity no longer rewrites headers tree-wide ([#25](https://github.com/CLDMV/fix-headers/pull/25)) ([Release](https://github.com/CLDMV/fix-headers/releases/tag/v1.3.9))
25
24
 
26
25
  📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder and the [GitHub Releases](https://github.com/CLDMV/fix-headers/releases).
27
26
 
@@ -94,6 +93,7 @@ Common CLI options:
94
93
  - `--author-name <name>` / `--author-email <email>`
95
94
  - `--company-name <name>` - the `@Copyright` holder for every file, instead of the one the manifests provide (see [Copyright holder](#copyright-holder))
96
95
  - `--copyright-start-year <year>` - the `@Copyright` start year for every file (default: the year of each file's `@Date`)
96
+ - `--spacing <n>` / `--margin <n>` - the header's layout: empty comment lines inside the header's edges (default `1`) and blank lines after it (default `2`), see [Header layout](#header-layout)
97
97
  - `--config <json-file>` - load options from a JSON file, which may use `extends` to build on shared configs (see [Shared configs](#shared-configs)); flags on the command line win over the file
98
98
 
99
99
  ### CommonJS
@@ -142,6 +142,8 @@ Important options:
142
142
  - `useGpgSignerAuthor?: boolean` - take the detected `@Author` name from the user ID of the OpenPGP key git signs commits with (`user.signingkey`, read through `gpg.openpgp.program` / `gpg.program` / `gpg`; the first user ID that is not revoked or expired). The OpenPGP UID comment is dropped, so `Nate Corcoran (2023 PC) <nate@example.com>` becomes `Nate Corcoran` (with `company: "CLDMV"`: `Nate Corcoran <CLDMV>`). It describes whoever runs the tool, whatever the last commit is — a squash merge made by GitHub or a bot has no locally verifiable signer. With no readable OpenPGP signing key (none configured, `gpg.format` is `ssh`/`x509`, or gpg is unavailable) it falls back to the last commit's signer (`%GS`), then `git config user.name`, then the last commit's author
143
143
  - `companyName?: string` - the `@Copyright` holder for every file, instead of the one the project's manifests provide. There is no built-in default: unset, the holder comes from the manifests, and with none it is left out of the line (see [Copyright holder](#copyright-holder))
144
144
  - `copyrightStartYear?: number` - the `@Copyright` start year for every file. Unset (the default): each file's start year is the year of its own `@Date`, see [Copyright years](#copyright-years)
145
+ - `spacing?: number` - empty comment lines just inside the header's opening and just before its closing. Default `1`, see [Header layout](#header-layout)
146
+ - `margin?: number` - blank lines between the header and the file's next content. Default `2`, see [Header layout](#header-layout)
145
147
 
146
148
  Example:
147
149
 
@@ -300,6 +302,45 @@ The filesystem creation time is the earlier of the file's birth time and its mod
300
302
 
301
303
  A file created in 2019 therefore gets `2019-2026` when fix-headers runs in 2026, not `2026-2026`.
302
304
 
305
+ ## Header layout
306
+
307
+ Two options set the shape of the header, and both apply to every file type.
308
+
309
+ - **`spacing`** (default `1`) is the number of empty comment lines just inside the header's opening and just before its closing. A block header gets an empty ` *` line under `/**` and above ` */`; a line-comment header gets a bare `#` (or the language's own prefix) above and below the fields.
310
+ - **`margin`** (default `2`) is the number of blank lines between the header and the file's next content.
311
+
312
+ With the defaults a JavaScript file and a YAML file look like this:
313
+
314
+ ```text
315
+ /**
316
+ *
317
+ * @Project: @cldmv/example
318
+ * @Filename: /src/index.mjs
319
+ * ...
320
+ * @Copyright: Copyright (c) 2026-2026 Example Inc. All rights reserved.
321
+ *
322
+ */
323
+
324
+
325
+ export const value = 1;
326
+ ```
327
+
328
+ ```text
329
+ #
330
+ # @Project: @cldmv/example
331
+ # @Filename: /.github/workflows/ci.yml
332
+ # ...
333
+ # @Copyright: Copyright (c) 2026-2026 Example Inc. All rights reserved.
334
+ #
335
+
336
+
337
+ name: CI
338
+ ```
339
+
340
+ With `spacing: 0, margin: 1` the header is compact, with no empty comment lines and a single blank line after it. Both accept any whole number of `0` or more; anything else is rejected before a file is touched.
341
+
342
+ An existing header is restyled in place to match, so changing either option rewrites the layout of every header on the next run, and a run with unchanged options finds nothing to update. A line-comment header always keeps at least one blank line after it, even with `margin: 0`, so a comment that follows the file's header is not read as part of it.
343
+
303
344
  ## Date checks
304
345
 
305
346
  `check: true` / `--check` validates the `@Date` and `@Last modified time` values of every existing header and writes nothing. It compares instants, not strings, so the same moment written with another offset or in the space/`T` form is not drift. It is independent of the rendered-header diff: an author, identity, copyright, or other content difference never fails the check. Files without a header are skipped.
@@ -1,26 +1,18 @@
1
1
  #!/usr/bin/env node
2
- var vr=Object.defineProperty;var i=(e,t)=>vr(e,"name",{value:t,configurable:!0});import{realpathSync as yr}from"node:fs";import{fileURLToPath as fo,pathToFileURL as mo}from"node:url";import{readFile as Dr}from"node:fs/promises";import{createRequire as Nr}from"node:module";import{dirname as Ar,isAbsolute as Cr,resolve as Ue}from"node:path";var Fr=3e4,jr=new Set(["localhost","127.0.0.1","[::1]"]);function re(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(re,"isPlainObject");function ne(e,t){let r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=re(r[n])&&re(o)?ne(r[n],o):o);return r}i(ne,"mergeConfig");function ze(e){return e.kind==="file"?e.path:e.href}i(ze,"describeSource");async function Mr(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(Fr)})}catch(r){let n=r.cause instanceof Error?r.cause.message:r.message;throw new Error(`Failed to fetch config ${e.href}: ${n}`,{cause:r})}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(Mr,"readSource");function Te(e){if(e.protocol==="http:"&&!jr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(Te,"toUrlSource");function Pr(e,t){if(/^https?:\/\//i.test(e))return Te(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${ze(t)}; use https, a file path or a package path`);let r=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(r||e.startsWith("/"))return Te(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(r||Cr(e))return{kind:"file",path:Ue(Ar(t.path),e)};try{return{kind:"file",path:Nr(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(Pr,"resolveReference");function Lr(e,t){if(e===void 0)return[];let r=Array.isArray(e)?e:[e];if(!r.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return r.map(n=>n.trim())}i(Lr,"readExtends");async function He(e,t){let r=ze(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await Mr(e),a;try{a=JSON.parse(n)}catch(u){throw new Error(`Config ${r} is not valid JSON: ${u.message}`,{cause:u})}if(!re(a))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:s,...c}=a,l={};for(let u of Lr(s,r))l=ne(l,await He(Pr(u,o),[...t,r]));return ne(l,c)}i(He,"loadSource");function Rr(e,t=process.cwd()){return He({kind:"file",path:Ue(t,e)},[])}i(Rr,"loadConfigFile");async function W(e,t){let r=typeof e[t]=="string"?e[t].trim():"";if(r.length===0)return e;let n=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Rr(r,n),...e};return delete o[t],o}i(W,"applyConfigOption");import{readFile as ro,stat as no,writeFile as oo}from"node:fs/promises";import{relative as mr,resolve as pr}from"node:path";import{join as St,relative as Et,resolve as de,sep as le}from"node:path";import{realpath as pn,stat as hn}from"node:fs/promises";import{extname as at}from"node:path";import{extname as Ir}from"node:path";var Be=[".css"];function Or(e){let t=Ir(e).toLowerCase();return Be.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Or,"resolveCssCommentSyntax");var _e={id:"css",extensions:Be,enabledByDefault:!0,resolveCommentSyntax(e){return Or(e)}};import{extname as Tr}from"node:path";var We=[".go"];function Ur(e){let t=Tr(e).toLowerCase();return We.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Ur,"resolveGoCommentSyntax");var Ye={id:"go",extensions:We,enabledByDefault:!0,resolveCommentSyntax(e){return Ur(e)}};import{extname as zr}from"node:path";var Ve=[".html",".htm"];function Hr(e){let t=zr(e).toLowerCase();return Ve.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Hr,"resolveHtmlCommentSyntax");var Ge={id:"html",extensions:Ve,enabledByDefault:!0,resolveCommentSyntax(e){return Hr(e)}};import{extname as Br}from"node:path";var Je=[".jsonv",".jsonc",".json5"];function _r(e){let t=Br(e).toLowerCase();return Je.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(_r,"resolveJsonCommentSyntax");var Ke={id:"json",extensions:Je,enabledByDefault:!0,resolveCommentSyntax(e){return _r(e)}};import{extname as Wr}from"node:path";var qe=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function Yr(e){let t=Wr(e).toLowerCase();return qe.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Yr,"resolveNodeCommentSyntax");function Vr(e,t){let r=t.match(/^#!.*\b(node|bun|deno|tsx|ts-node)\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Vr,"resolveNodePreservedPrefix");var Xe={id:"node",extensions:qe,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Vr(e,t)},resolveCommentSyntax(e){return Yr(e)}};import{extname as Gr}from"node:path";var Ze=[".php"];function Jr(e){let t=Gr(e).toLowerCase();return Ze.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Jr,"resolvePhpCommentSyntax");var Qe={id:"php",extensions:Ze,enabledByDefault:!0,resolveCommentSyntax(e){return Jr(e)}};import{extname as Kr}from"node:path";var et=[".py"];function qr(e,t){let r=t.match(/^#!.*\bpython(?:\d+(?:\.\d+)*)?\b.*(?:\r?\n|$)/);return r?r[0]:""}i(qr,"resolvePythonPreservedPrefix");var tt={id:"python",extensions:et,enabledByDefault:!0,resolvePreservedPrefix(e,t){return qr(e,t)},resolveCommentSyntax(e){let t=Kr(e).toLowerCase();return et.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Xr}from"node:path";var rt=[".rs"];function Zr(e){let t=Xr(e).toLowerCase();return rt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Zr,"resolveRustCommentSyntax");var nt={id:"rust",extensions:rt,enabledByDefault:!0,resolveCommentSyntax(e){return Zr(e)}};import{extname as Qr}from"node:path";var ot=[".yaml",".yml"];function en(e){let t=Qr(e).toLowerCase();return ot.includes(t)?{kind:"line",linePrefix:"#"}:null}i(en,"resolveYamlCommentSyntax");var it={id:"yaml",extensions:ot,enabledByDefault:!0,resolveCommentSyntax(e){return en(e)}};var st=[_e,Ye,Ge,Ke,Xe,Qe,tt,nt,it],pi=new Map(st.map(e=>[e.id,e]));function tn(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(tn,"applySyntaxOverride");function j(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]);return st.filter(n=>t.size>0?t.has(n.id):r.has(n.id)?!1:n.enabledByDefault)}i(j,"getEnabledDetectors");function ct(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=j(e);return new Set(t.flatMap(r=>r.extensions))}i(ct,"getAllowedExtensions");function lt(e,t={}){let r=at(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:j(t);for(let o of n){if(!o.extensions.includes(r))continue;let a=o.resolveCommentSyntax(e);if(a){let s=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return tn(a,s[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(lt,"getCommentSyntaxForFile");function ut(e,t,r={}){let n=at(e).toLowerCase(),o=j(r);for(let a of o)if(a.extensions.includes(n))return typeof a.resolvePreservedPrefix=="function"?a.resolvePreservedPrefix(e,t):"";return""}i(ut,"getPreservedPrefixForFile");import{access as rn,readdir as nn,readFile as xi,stat as on}from"node:fs/promises";import{constants as an}from"node:fs";import{dirname as Si,join as sn,resolve as Ei}from"node:path";async function oe(e){try{return await rn(e,an.F_OK),!0}catch{return!1}}i(oe,"pathExists");async function ie(e,t){let r=[],n=await nn(e,{withFileTypes:!0});for(let o of n){let a=sn(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(a,o.name)===!0)continue;if(o.isDirectory()){let l=await ie(a,t);r.push(...l);continue}if(!o.isFile())continue;let s=o.name.lastIndexOf(".");if(s===-1)continue;let c=o.name.slice(s).toLowerCase();t.allowedExtensions.has(c)&&r.push(a)}return r}i(ie,"walkFiles");async function dt(e){let t=await on(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(dt,"readFileDates");import{execFile as cn}from"node:child_process";import{lstat as ln,readFile as un}from"node:fs/promises";import{dirname as ft,isAbsolute as dn,join as ht,relative as gt,resolve as ae,sep as yt}from"node:path";import fn from"ignore";function mt(e,t){return new Promise(r=>{cn("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(n,o)=>{if(!n){r({code:0,stdout:o});return}r({code:typeof n.code=="number"?n.code:-1,stdout:""})})})}i(mt,"runGitCommand");function ce(e,t){return gt(e,t).split(yt).join("/")}i(ce,"toPosixRelative");async function xt(e){try{return fn().add(await un(e,"utf8"))}catch{return null}}i(xt,"readIgnoreFile");async function mn(e){return ln(ht(e,".git")).then(()=>!0,()=>!1)}i(mn,"hasGitEntry");function pt(e,t,r){for(let n=e.length-1;n>=0;n--){let{base:o,rules:a}=e[n],s=a.test(`${ce(o,t)}${r?"/":""}`);if(s.ignored||s.unignored)return s.ignored}return!1}i(pt,"matchesRules");async function bt(e,t){let r=await xt(ht(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(bt,"buildRulesContext");async function se(e){let[t,r]=await Promise.all([mt(e,["check-ignore","-q","."]),mt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||r.code!==0)return bt(e,[]);let n=new Set,o=new Set;for(let a of r.stdout.split("\0")){let s=a.endsWith("/")?a.slice(0,-1):a;if(s.length!==0){n.add(s);for(let c=s.indexOf("/");c!==-1;c=s.indexOf("/",c+1))o.add(s.slice(0,c))}}return{kind:"git",root:e,entries:n,dirs:o}}i(se,"resolveScopeContext");function wt(e){let t=ae(e.root),r=e.gitignore;if(r===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let n=new Map,o=i(async()=>{if(typeof r!="string"&&!Array.isArray(r))return se(t);let c=typeof r=="string"?[r]:r.filter(u=>typeof u=="string"),l=[];for(let u of c){let f=await xt(ae(t,u));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),a=i(c=>{let l=n.get(c);return l||(l=c===t?o():s(c),n.set(c,l)),l},"contextFor"),s=i(async c=>{let l=await a(ft(c));return l.kind==="git"?l.entries.has(ce(l.root,c))?se(c):l:!l.nested||l.excluded?l:pt(l.matchers,c,!0)?{...l,excluded:!0}:await mn(c)?se(c):bt(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let u=ae(c),f=gt(t,u);if(f.length===0||f===".."||f.startsWith(`..${yt}`)||dn(f))return!1;let p=await a(ft(u));if(p.kind==="git"){let x=ce(p.root,u);return!(p.entries.has(x)||l&&p.dirs.has(x))}return p.excluded||pt(p.matchers,u,l)}}}i(wt,"createIgnoreFilter");function gn(e){return ct(e)}i(gn,"resolveExtensions");var kt=new Set([".git"]);function ue(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}i(ue,"normalizeFolderPath");function yn(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(yn,"resolveIncludeFolders");function $t(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i($t,"reportSkippedIncludeFolder");function xn(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=de(e),n=[],o=new Set;for(let a of t){if(typeof a!="string")continue;let s=ue(a);if(s.length!==0){if(s.includes("/")){n.push(de(r,s));continue}o.add(s)}}return(a,s)=>{if(o.has(s))return!0;for(let l of n)if(a===l||a.startsWith(`${l}/`))return!0;let c=ue(Et(r,a));return n.some(l=>{let u=ue(Et(r,l));return c===u||c.startsWith(`${u}/`)})}}i(xn,"buildExclusionMatcher");async function fe(e){let t=gn(e),r=yn(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=xn(e.projectRoot,n),a=wt({root:e.projectRoot,gitignore:e.gitignore}),s=i(async(m,h)=>o(m,h)||await a.isIgnored(m,!0),"shouldSkipDirectory"),c=r.length>0?r.map(m=>({includeFolder:m.path,rootPath:St(e.projectRoot,m.path),recursive:m.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let m of c){let h=await hn(m.rootPath).catch(E=>E);if(h instanceof Error){if(h.code==="ENOENT"){$t(m.includeFolder,h);continue}throw h}if(!h.isDirectory()){$t(m.includeFolder,`path is not a directory: ${m.rootPath}`);continue}let w=await pn(m.rootPath).catch(()=>de(m.rootPath));l.push({...m,realRoot:w})}let u=i((m,h)=>{if(m.realRoot===h.realRoot)return m.recursive||!h.recursive;let w=m.realRoot.endsWith(le)?m.realRoot:`${m.realRoot}${le}`;if(!m.recursive||!h.realRoot.startsWith(w))return!1;let E=m.rootPath;for(let v of h.realRoot.slice(w.length).split(le))if(E=St(E,v),kt.has(v)||o(E,v))return!1;return!0},"covers"),f=[...l].sort((m,h)=>m.realRoot.length-h.realRoot.length||Number(h.recursive)-Number(m.recursive)),p=[];for(let m of f)p.some(h=>u(h,m))||p.push(m);let x=[];for(let m of l){if(!p.includes(m))continue;let h=await ie(m.rootPath,{allowedExtensions:t,ignoreFolders:kt,shouldSkipDirectory:s,recursive:m.recursive});x.push(...h)}let y=[];for(let m of new Set(x))!o(m,m.split("/").at(-1)||"")&&!await a.isIgnored(m,!1)&&y.push(m);return y}i(fe,"discoverFiles");import{basename as Hn,dirname as Bn,extname as _n,resolve as ye}from"node:path";import{dirname as It,isAbsolute as Cn,join as Ot,relative as Fn,resolve as Tt,sep as jn}from"node:path";import{readFile as bn}from"node:fs/promises";import{join as wn}from"node:path";async function Sn(e){try{return await bn(e,"utf8")}catch{return null}}i(Sn,"readManifest");async function k(e,t){let r=[];for(let n of t){let o=await Sn(wn(e,n));o!==null&&r.push({file:n,content:o})}return r.length>0?{dir:e,manifest:r[0].file,files:r}:null}i(k,"detectManifests");function A(e,t){return e.files.find(r=>r.file===t)?.content??null}i(A,"manifestContent");function b(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(b,"cleanName");function me(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return b(t===-1?e:e.slice(0,t))}i(me,"personName");function Y(e){try{return JSON.parse(e)}catch{return}}i(Y,"parseJsonManifest");function*pe(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let a=o.match(/^\[([^[\]]+)\]/);r=a?a[1].split(".").map(s=>s.trim()).join("."):"";continue}r===t&&(yield o)}}i(pe,"sectionLines");function L(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of pe(e,t)){let a=o.match(n);if(a)return b(a[1]??a[2])}}i(L,"readTomlString");function he(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of pe(e,t)){let a=o.match(n);if(a)return b(a[1])}}i(he,"readIniValue");function En(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let a of pe(e,t)){if(o!==null){o.push(a);continue}let s=a.match(n);s&&(o=[a.slice(s[0].length)])}return o===null?null:o.join(`
3
- `)}i(En,"tomlArrayText");function kn(e,t){let r=t;for(;r<e.length;)if(e[r]==="#"){let n=e.indexOf(`
4
- `,r);r=n===-1?e.length:n+1}else if(/\s/.test(e[r]))r+=1;else break;return r}i(kn,"skipTomlSpace");function R(e,t){let r=En(e,t,"authors");if(r===null)return;let n=r.slice(kn(r,0)),o=n.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return me(o[1]??o[2]);let s=n.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return s?b(s[1]??s[2]):void 0}i(R,"readTomlAuthor");var vt=["go.mod"];function $n(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return b(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i($n,"readModulePath");var Dt={id:"go",languages:["go"],manifests:vt,detect(e){return k(e,vt)},read(e){return{name:$n(e.files[0].content)}}};var Nt=["package.json"];function vn(e){let t=b(e?.name),r=b(e?.publisher),n=typeof e?.engines?.vscode=="string";return t&&r&&n?`${r}.${t}`:t}i(vn,"readPublishedName");function Dn(e){if(e!==null&&typeof e=="object"){let t=e;return b(t.company)??b(t.name)}return me(e)}i(Dn,"readAuthorCompany");var At={id:"node",languages:["node"],manifests:Nt,detect(e){return k(e,Nt)},read(e){let t=Y(e.files[0].content);return{name:vn(t),company:Dn(t?.author)}}};var Ct=["composer.json"],Ft={id:"php",languages:["php"],manifests:Ct,detect(e){return k(e,Ct)},read(e){let t=Y(e.files[0].content),r=t?.authors;return{name:b(t?.name),company:Array.isArray(r)?b(r[0]?.name):void 0}}};var jt=["pyproject.toml","setup.cfg","setup.py"];function Mt(e,t){let r=e.indexOf("setup(");if(r===-1)return;let n=e.slice(r).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return n&&n[2].trim()||void 0}i(Mt,"readSetupPyArgument");function Nn(e){let t=A(e,"pyproject.toml"),r=A(e,"setup.cfg"),n=A(e,"setup.py");return(t===null?void 0:L(t,"project","name")??L(t,"tool.poetry","name"))??(r===null?void 0:he(r,"metadata","name"))??(n===null?void 0:Mt(n,"name"))}i(Nn,"readPythonName");function An(e){let t=A(e,"pyproject.toml"),r=A(e,"setup.cfg"),n=A(e,"setup.py");return(t===null?void 0:R(t,"project")??R(t,"tool.poetry"))??(r===null?void 0:he(r,"metadata","author"))??(n===null?void 0:Mt(n,"author"))}i(An,"readPythonCompany");var Pt={id:"python",languages:["python"],manifests:jt,detect(e){return k(e,jt)},read(e){return{name:Nn(e),company:An(e)}}};var Lt=["Cargo.toml"],Rt={id:"rust",languages:["rust"],manifests:Lt,detect(e){return k(e,Lt)},read(e){let t=e.files[0].content;return{name:L(t,"package","name"),company:R(t,"package")}}};var Mn=[At,Pt,Ft,Rt,Dt],Ut=["name","company"];async function ge(e,t,r){let o=(await Promise.all(t.map(async s=>({driver:s,detection:await s.detect(e)})))).filter(s=>s.detection!==null),a=o.filter(s=>typeof r=="string"&&s.driver.languages.includes(r));return[...a,...o.filter(s=>!a.includes(s))]}i(ge,"claimFolder");function Pn(e,t){let r=Fn(t,e);return r!==""&&r!==".."&&!r.startsWith(`..${jn}`)&&!Cn(r)}i(Pn,"isStrictlyInside");async function zt(e,t={}){let r=Array.isArray(t.drivers)?t.drivers:Mn,n=typeof t.scanRoot=="string"?Tt(t.scanRoot):null,o=Tt(e),a=await ge(o,r,t.language);for(;a.length===0;){if(await oe(Ot(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=It(o);if(f===o)return null;o=f,a=await ge(o,r,t.language)}let s={},c={},l=o,u=a;for(;;){for(let{driver:p,detection:x}of u){let y=p.read(x);for(let m of Ut)s[m]===void 0&&y[m]!==void 0&&(s[m]=y[m],c[m]={driver:p.id,manifest:x.manifest,dir:l})}if(Ut.every(p=>s[p]!==void 0)||n===null||!Pn(l,n)||await oe(Ot(l,".git")))break;l=It(l),u=await ge(l,r,t.language)}return{root:o,marker:a[0].detection.manifest,drivers:a.map(f=>f.driver.id),fields:s,sources:c}}i(zt,"resolveManifestProject");import{execFile as Ln}from"node:child_process";import{promisify as Rn}from"node:util";var Bt=Rn(Ln);async function $(e,t){try{let{stdout:r}=await Bt("git",t,{cwd:e}),n=r.trim();return n.length>0?n:null}catch{return null}}i($,"runGit");function Ht(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}i(Ht,"isEscaped");function In(e){let t=e.trim();if(!t.endsWith(")")||Ht(t,t.length-1))return t;let r=0;for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(o!=="("&&o!==")"||Ht(t,n))&&(r+=o===")"?1:-1,r===0))return t.slice(0,n).trim()}return t}i(In,"stripUidComment");function On(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let r=t.match(/<([^>\n]+)>\s*$/),n=r?.[1]?.trim()||null,o=(r?t.slice(0,r.index):t).trim();return{authorName:In(o)||o||null,authorEmail:n}}i(On,"parseSignerUid");async function Tn(e,t){try{let{stdout:r}=await Bt(e,t),n=r.trim();return n.length>0?n:null}catch{return null}}i(Tn,"runProgram");function Un(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)))}i(Un,"decodeColonField");async function zn(e){let t=await $(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let r=await $(e,["config","--get","user.signingkey"]);if(!r)return null;let n=await $(e,["config","--get","gpg.openpgp.program"])||await $(e,["config","--get","gpg.program"])||"gpg",o=await Tn(n,["--batch","--with-colons","--list-keys",r]);if(!o)return null;for(let a of o.split(`
5
- `)){let s=a.split(":");if(s[0]==="uid"&&s[1]!=="r"&&s[1]!=="e"&&s[9])return Un(s[9])}return null}i(zn,"readSigningKeyUid");async function _t(e,t={}){let r=await $(e,["config","--get","user.name"]),n=await $(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await zn(e)||await $(e,["log","-1","--format=%GS"]),a=On(o||"");r=a.authorName||r,n=n||a.authorEmail}if(!r||!n){let o=await $(e,["log","-1","--format=%an|%ae"]);if(o){let[a,s]=o.split("|");r=r||a||null,n=n||s||null}}return{authorName:r,authorEmail:n}}i(_t,"detectGitAuthor");function Wt(e){return e.replace(/z$/i,"+00:00")}i(Wt,"canonicalGitDate");async function Yt(e,t){let r=await $(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!r)return null;let n=r.split(`
6
- `)[0],[o,a]=n.split("|");if(!o||!a)return null;let s=Number.parseInt(a,10);return Number.isNaN(s)?null:{date:Wt(o),timestamp:s}}i(Yt,"getGitCreationDate");async function Vt(e,t){let r=await $(e,["log","-1","--format=%aI|%at","--",t]);if(!r)return null;let[n,o]=r.split("|");if(!n||!o)return null;let a=Number.parseInt(o,10);return Number.isNaN(a)?null:{date:Wt(n),timestamp:a}}i(Vt,"getGitLastModifiedDate");function Wn(e){return Hn(e)||"project"}i(Wn,"folderName");function Yn(e,t){if(typeof t!="string")return e;let r=t.trim();return r.length===0||/<[^>]+>/.test(e)?e:`${e} <${r}>`}i(Yn,"formatAuthorNameWithCompany");async function Vn(e,t={}){let r=Array.isArray(t.detectors)?t.detectors:j(t),n=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=n.length>0?r.find(u=>u.extensions.includes(n)):void 0,a=await zt(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),s=a?a.root:ye(e),c=a?.sources.name,l=a?.sources.company;return{language:o?.id??a?.drivers[0]??"unknown",rootDir:s,marker:a?a.marker:null,projectName:a?.fields.name??Wn(s),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:s},companyName:a?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:a?a.drivers:[]}}i(Vn,"detectProjectFromMarkers");async function xe(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),r=ye(t),n=j(e),o=e.targetFilePath?Bn(r):r,a=e.targetFilePath?_n(r).toLowerCase():"",s=ye(e.projectRoot||e.cwd||process.cwd()),c=await Vn(o,{detectors:n,preferredExtension:a,scanRoot:s}),l=await _t(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:Yn(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(xe,"resolveProjectMetadata");function Gn(e){return be({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(Gn,"formatDateWithTimezone");function be(e){return`${qt(e," ")} ${Xt(e.offsetMinutes)}`}i(be,"formatSpaceDate");function Jt(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{Kt(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(Jt,"assertTimeZone");var Gt=new Map;function Kt(e){let t=Gt.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"}),Gt.set(e,t)),t}i(Kt,"getZoneFormatter");function we(e,t){let r={};for(let o of Kt(t).formatToParts(new Date(e*1e3)))r[o.type]=Number(o.value);let n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)/1e3;return{year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute,second:r.second,offsetMinutes:(n-e)/60}}i(we,"toZonedDateParts");function qt(e,t){let r=i(n=>String(n).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${r(e.month)}-${r(e.day)}${t}${r(e.hour)}:${r(e.minute)}:${r(e.second)}`}i(qt,"formatWallClock");function Xt(e){let t=i(n=>String(n).padStart(2,"0"),"pad"),r=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(r/60))}:${t(r%60)}`}i(Xt,"formatOffset");function V(e=new Date){return{date:Gn(e),timestamp:Math.floor(e.getTime()/1e3)}}i(V,"toDatePayload");var Jn=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function C(e){let t=Jn.exec(e.trim());if(!t)return null;let[r,n,o,a,s,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(r,n-1,o,a,s,c));return!(f.getUTCFullYear()===r&&f.getUTCMonth()===n-1&&f.getUTCDate()===o&&f.getUTCHours()===a&&f.getUTCMinutes()===s&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:r,month:n,day:o,hour:a,minute:s,second:c,offsetMinutes:u,timestamp:Math.floor(f.getTime()/1e3)-u*60}}i(C,"parseHeaderDate");function Se(e){return`${qt(e,"T")}${Xt(e.offsetMinutes)}`}i(Se,"formatIsoDate");var Kn={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function Zt(e,t){let r=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return r?r[1].trim():null}i(Zt,"readHeaderField");function Ee(e){let t=null;for(let{source:r,payload:n}of e)n&&(!t||n.timestamp<t.payload.timestamp)&&(t={source:r,payload:n});return t}i(Ee,"pickOldestDate");function er({existing:e,gitCreated:t,filesystemCreated:r,fixCreatedDate:n=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:r}];if(!e)return Ee(o);if(!n)return{source:"existing-header",payload:e};let a=C(e.date)?e:null;return Ee([{source:"existing-header",payload:a},...o])}i(er,"resolveCreatedDate");function tr(e,t=null){if(t)return we(e.timestamp,t).year;let r=C(e.date);return r?r.year:new Date(e.timestamp*1e3).getFullYear()}i(tr,"dateYear");function Qt(e,t,r,n){let o=e.match(/^(.+?)\s*\((\d+)\)$/),a=o?C(o[1]):null;if(!o||!a)return n.push({check:`${r}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let s=Number.parseInt(o[2],10);return s!==a.timestamp&&n.push({check:`${r}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${a.timestamp})`,message:`${t} epoch ${s} does not match ${o[1]} (expected ${a.timestamp})`}),{text:o[1],timestamp:a.timestamp}}i(Qt,"checkDateValue");function rr(e,t={},r={}){let n=[],o=Zt(e,"@Date"),a=o===null?null:Qt(o,"@Date","created",n),s=Ee([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(a&&s&&a.timestamp>s.payload.timestamp){let f=Kn[s.source];n.push({check:"created-newer-than-source",field:"@Date",advisory:r.strictCreatedDate!==!0,value:o,expected:`${s.payload.date} (${s.payload.timestamp})`,source:s.source,message:`@Date ${a.text} is later than the ${f} ${s.payload.date} (${s.payload.timestamp})`})}let c=Zt(e,"@Last modified time"),l=c===null?null:Qt(c,"@Last modified time","modified",n),u=t.gitLastModified;return l&&u&&l.timestamp!==u.timestamp&&n.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})`}),n}i(rr,"checkHeaderDates");function ke(e){if(!e)return null;let t=C(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i(ke,"repairDateEpoch");function nr(e){let t=C(e.date);return t?{date:Se(t),timestamp:t.timestamp}:e}i(nr,"normalizeDatePayload");function or(e,t){let r=C(e.date);if(!r)return e;let n=we(r.timestamp,t);return n.offsetMinutes===r.offsetMinutes||!Number.isInteger(n.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?Se(n):be(n),timestamp:r.timestamp}}i(or,"convertDatePayload");import{relative as Xn}from"node:path";import{extname as qn}from"node:path";function G(e,t={}){return qn(e).toLowerCase().length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:lt(e,t)}i(G,"getHeaderSyntaxForFile");function ir(e,t){if(e.kind==="line"){let a=typeof e.lineSeparator=="string"?e.lineSeparator:" ";return t.map(s=>`${e.linePrefix||"#"}${a}${s}`).join(`
7
- `)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),n=e.blockLinePrefix||(e.kind==="html"?" ":" * "),o=e.blockEnd||(e.kind==="html"?"-->":" */");return e.kind==="html"?`${r}
8
- ${t.map(a=>`${n}${a}`).join(`
9
- `)}
10
- ${o}`:`${r}
11
- ${t.map(a=>`${n}${a}`).join(`
12
- `)}
13
- ${o}`}i(ir,"renderHeaderLines");function $e(e){let t=`/${Xn(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,r=G(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),n=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,a=e.lastModifiedByName||e.authorName,s=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: ${n}`,`@Email: <${o}>`,"-----",`@Last modified by: ${a} (${s})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return ir(r,u)}i($e,"buildHeader");var Zn=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function D(e,t){let r=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),n=r?r[1].trim():"";return n.length>0?n:null}i(D,"readTag");function Qn(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),r=t.indexOf("(",t.lastIndexOf(")")+1);return r===-1?{name:e,email:null}:{name:t.slice(0,r).trimEnd()||null,email:t.slice(r+1)||null}}i(Qn,"splitLastModifiedBy");function eo(e){let t={startYear:null,endYear:null,companyName:null},r=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!r)return t;let n=e.slice(r[0].length),o=n.match(/^\s*-\s*(\d{4})/);o&&(n=n.slice(o[0].length));let a=n.toLowerCase(),s=a.endsWith("all rights reserved.")?20:a.endsWith("all rights reserved")?19:0;return s===0||!/^\s/.test(n)?t:{startYear:r[1],endYear:o?o[1]:null,companyName:n.slice(0,-s).trim()||null}}i(eo,"splitCopyright");function ar(e){let t=Qn(D(e,"Last modified by")),r=eo(D(e,"Copyright")),n=D(e,"Email");return{projectName:D(e,"Project"),filename:D(e,"Filename"),createdAt:D(e,"Date"),authorName:D(e,"Author"),authorEmail:n===null?null:n.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:D(e,"Last modified time"),copyrightStartYear:r.startYear,copyrightEndYear:r.endYear,companyName:r.companyName}}i(ar,"parseHeaderFields");function sr(e,t){let r=ar(e??""),n=ar(t);return Zn.filter(o=>r[o]!==n[o]).map(o=>({field:o,previous:r[o],detected:n[o]}))}i(sr,"compareHeaderFields");var cr=200;function J(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(J,"escapeRegex");function ur(e,t,r={}){let n=ut(e,t,r);return n.length===0?{prefix:"",body:t}:{prefix:n,body:t.slice(n.length)}}i(ur,"splitPreservedPrefix");function lr(e,t){if(t.kind==="html"){let n=J(t.blockStart||"<!--"),o=J(t.blockEnd||"-->");return e.match(new RegExp(`^${n}[\\s\\S]*?${o}\\n*`))}if(t.kind==="line"){let n=J(t.linePrefix||"#");return e.match(new RegExp(`^(?:${n}.*\\n)+\\n*`))}let r=J((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${r}\\n*`))}i(lr,"matchHeaderSegment");function ve(e,t="",r={}){let{prefix:n,body:o}=ur(t,e,r),a=o.split(`
14
- `).slice(0,cr).join(`
15
- `),s=G(t,r);if(!lr(a,s))return null;let l=0,u=0;for(;;){let f=a.slice(l),p=lr(f,s);if(!p||!p[0].includes("@Project:"))break;l+=p[0].length,u=l}return u===0?null:{start:n.length,end:n.length+u}}i(ve,"findProjectHeader");function De(e,t,r="",n={}){let o=ve(e,r,n);if(!o){let{prefix:l,body:u}=ur(r,e,n),f=`${l}${t}
16
-
17
- ${u.replace(/^\n+/,"")}`;return{nextContent:f,changed:f!==e}}let a=e.slice(0,o.start),s=e.slice(o.end).replace(/^\n+/,""),c=`${a}${t}
18
-
19
- ${s}`;return{nextContent:c,changed:c!==e}}i(De,"replaceOrInsertHeader");function to(e,t){let r=e.length,n=t.length,o=Array.from({length:r+1},()=>new Array(n+1).fill(0));for(let l=r-1;l>=0;l-=1)for(let u=n-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 a=[],s=0,c=0;for(;s<r&&c<n;)e[s]===t[c]?(a.push({type:" ",line:e[s]}),s+=1,c+=1):o[s+1][c]>=o[s][c+1]?(a.push({type:"-",line:e[s]}),s+=1):(a.push({type:"+",line:t[c]}),c+=1);for(;s<r;s+=1)a.push({type:"-",line:e[s]});for(;c<n;c+=1)a.push({type:"+",line:t[c]});return a}i(to,"diffLines");function dr(e,t){return`${t===0?e:e+1},${t}`}i(dr,"formatRange");function fr(e,t,r={}){let n=e===null?[]:e.split(`
2
+ var Nr=Object.defineProperty;var i=(e,t)=>Nr(e,"name",{value:t,configurable:!0});import{realpathSync as wr}from"node:fs";import{fileURLToPath as ho,pathToFileURL as go}from"node:url";import{readFile as Cr}from"node:fs/promises";import{createRequire as Fr}from"node:module";import{dirname as jr,isAbsolute as Lr,resolve as ze}from"node:path";var Mr=3e4,Pr=new Set(["localhost","127.0.0.1","[::1]"]);function ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(ie,"isPlainObject");function ae(e,t){let r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=ie(r[n])&&ie(o)?ae(r[n],o):o);return r}i(ae,"mergeConfig");function Be(e){return e.kind==="file"?e.path:e.href}i(Be,"describeSource");async function Rr(e){if(e.kind==="file")return{text:await Cr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(Mr)})}catch(r){let n=r.cause instanceof Error?r.cause.message:r.message;throw new Error(`Failed to fetch config ${e.href}: ${n}`,{cause:r})}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(Rr,"readSource");function He(e){if(e.protocol==="http:"&&!Pr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(He,"toUrlSource");function Ir(e,t){if(/^https?:\/\//i.test(e))return He(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${Be(t)}; use https, a file path or a package path`);let r=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(r||e.startsWith("/"))return He(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(r||Lr(e))return{kind:"file",path:ze(jr(t.path),e)};try{return{kind:"file",path:Fr(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(Ir,"resolveReference");function Or(e,t){if(e===void 0)return[];let r=Array.isArray(e)?e:[e];if(!r.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return r.map(n=>n.trim())}i(Or,"readExtends");async function We(e,t){let r=Be(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await Rr(e),a;try{a=JSON.parse(n)}catch(u){throw new Error(`Config ${r} is not valid JSON: ${u.message}`,{cause:u})}if(!ie(a))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:s,...c}=a,l={};for(let u of Or(s,r))l=ae(l,await We(Ir(u,o),[...t,r]));return ae(l,c)}i(We,"loadSource");function Tr(e,t=process.cwd()){return We({kind:"file",path:ze(t,e)},[])}i(Tr,"loadConfigFile");async function V(e,t){let r=typeof e[t]=="string"?e[t].trim():"";if(r.length===0)return e;let n=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Tr(r,n),...e};return delete o[t],o}i(V,"applyConfigOption");import{readFile as io,stat as ao,writeFile as so}from"node:fs/promises";import{relative as gr,resolve as yr}from"node:path";import{extname as lt}from"node:path";import{extname as Ur}from"node:path";var Ye=[".css"];function _r(e){let t=Ur(e).toLowerCase();return Ye.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(_r,"resolveCssCommentSyntax");var Ge={id:"css",extensions:Ye,enabledByDefault:!0,resolveCommentSyntax(e){return _r(e)}};import{extname as Hr}from"node:path";var Ve=[".go"];function zr(e){let t=Hr(e).toLowerCase();return Ve.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(zr,"resolveGoCommentSyntax");var Je={id:"go",extensions:Ve,enabledByDefault:!0,resolveCommentSyntax(e){return zr(e)}};import{extname as Br}from"node:path";var Ke=[".html",".htm"];function Wr(e){let t=Br(e).toLowerCase();return Ke.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Wr,"resolveHtmlCommentSyntax");var qe={id:"html",extensions:Ke,enabledByDefault:!0,resolveCommentSyntax(e){return Wr(e)}};import{extname as Yr}from"node:path";var Xe=[".jsonv",".jsonc",".json5"];function Gr(e){let t=Yr(e).toLowerCase();return Xe.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Gr,"resolveJsonCommentSyntax");var Ze={id:"json",extensions:Xe,enabledByDefault:!0,resolveCommentSyntax(e){return Gr(e)}};import{extname as Vr}from"node:path";var Qe=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function Jr(e){let t=Vr(e).toLowerCase();return Qe.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Jr,"resolveNodeCommentSyntax");function Kr(e,t){let r=t.match(/^#!.*\b(node|bun|deno|tsx|ts-node)\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Kr,"resolveNodePreservedPrefix");var et={id:"node",extensions:Qe,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Kr(e,t)},resolveCommentSyntax(e){return Jr(e)}};import{extname as qr}from"node:path";var tt=[".php"];function Xr(e){let t=qr(e).toLowerCase();return tt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Xr,"resolvePhpCommentSyntax");var rt={id:"php",extensions:tt,enabledByDefault:!0,resolveCommentSyntax(e){return Xr(e)}};import{extname as Zr}from"node:path";var nt=[".py"];function Qr(e,t){let r=t.match(/^#!.*\bpython(?:\d+(?:\.\d+)*)?\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Qr,"resolvePythonPreservedPrefix");var ot={id:"python",extensions:nt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Qr(e,t)},resolveCommentSyntax(e){let t=Zr(e).toLowerCase();return nt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as en}from"node:path";var it=[".rs"];function tn(e){let t=en(e).toLowerCase();return it.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(tn,"resolveRustCommentSyntax");var at={id:"rust",extensions:it,enabledByDefault:!0,resolveCommentSyntax(e){return tn(e)}};import{extname as rn}from"node:path";var st=[".yaml",".yml"];function nn(e){let t=rn(e).toLowerCase();return st.includes(t)?{kind:"line",linePrefix:"#"}:null}i(nn,"resolveYamlCommentSyntax");var ct={id:"yaml",extensions:st,enabledByDefault:!0,resolveCommentSyntax(e){return nn(e)}};var ut=[Ge,Je,qe,Ze,et,rt,ot,at,ct],yi=new Map(ut.map(e=>[e.id,e]));function on(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(on,"applySyntaxOverride");function L(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]);return ut.filter(n=>t.size>0?t.has(n.id):r.has(n.id)?!1:n.enabledByDefault)}i(L,"getEnabledDetectors");function dt(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=L(e);return new Set(t.flatMap(r=>r.extensions))}i(dt,"getAllowedExtensions");function ft(e,t={}){let r=lt(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:L(t);for(let o of n){if(!o.extensions.includes(r))continue;let a=o.resolveCommentSyntax(e);if(a){let s=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return on(a,s[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(ft,"getCommentSyntaxForFile");function mt(e,t,r={}){let n=lt(e).toLowerCase(),o=L(r);for(let a of o)if(a.extensions.includes(n))return typeof a.resolvePreservedPrefix=="function"?a.resolvePreservedPrefix(e,t):"";return""}i(mt,"getPreservedPrefixForFile");var pt=200,R=1,J=2;function N(e,t,r){if(e==null)return r;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(N,"resolveLayoutCount");import{join as At,relative as $t,resolve as pe,sep as fe}from"node:path";import{realpath as yn,stat as xn}from"node:fs/promises";import{access as an,readdir as sn,readFile as Di,stat as cn}from"node:fs/promises";import{constants as ln}from"node:fs";import{dirname as $i,join as un,resolve as vi}from"node:path";async function se(e){try{return await an(e,ln.F_OK),!0}catch{return!1}}i(se,"pathExists");async function ce(e,t){let r=[],n=await sn(e,{withFileTypes:!0});for(let o of n){let a=un(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(a,o.name)===!0)continue;if(o.isDirectory()){let l=await ce(a,t);r.push(...l);continue}if(!o.isFile())continue;let s=o.name.lastIndexOf(".");if(s===-1)continue;let c=o.name.slice(s).toLowerCase();t.allowedExtensions.has(c)&&r.push(a)}return r}i(ce,"walkFiles");async function ht(e){let t=await cn(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(ht,"readFileDates");import{execFile as dn}from"node:child_process";import{lstat as fn,readFile as mn}from"node:fs/promises";import{dirname as gt,isAbsolute as pn,join as bt,relative as wt,resolve as le,sep as Et}from"node:path";import hn from"ignore";function yt(e,t){return new Promise(r=>{dn("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(n,o)=>{if(!n){r({code:0,stdout:o});return}r({code:typeof n.code=="number"?n.code:-1,stdout:""})})})}i(yt,"runGitCommand");function de(e,t){return wt(e,t).split(Et).join("/")}i(de,"toPosixRelative");async function St(e){try{return hn().add(await mn(e,"utf8"))}catch{return null}}i(St,"readIgnoreFile");async function gn(e){return fn(bt(e,".git")).then(()=>!0,()=>!1)}i(gn,"hasGitEntry");function xt(e,t,r){for(let n=e.length-1;n>=0;n--){let{base:o,rules:a}=e[n],s=a.test(`${de(o,t)}${r?"/":""}`);if(s.ignored||s.unignored)return s.ignored}return!1}i(xt,"matchesRules");async function Dt(e,t){let r=await St(bt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(Dt,"buildRulesContext");async function ue(e){let[t,r]=await Promise.all([yt(e,["check-ignore","-q","."]),yt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||r.code!==0)return Dt(e,[]);let n=new Set,o=new Set;for(let a of r.stdout.split("\0")){let s=a.endsWith("/")?a.slice(0,-1):a;if(s.length!==0){n.add(s);for(let c=s.indexOf("/");c!==-1;c=s.indexOf("/",c+1))o.add(s.slice(0,c))}}return{kind:"git",root:e,entries:n,dirs:o}}i(ue,"resolveScopeContext");function kt(e){let t=le(e.root),r=e.gitignore;if(r===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let n=new Map,o=i(async()=>{if(typeof r!="string"&&!Array.isArray(r))return ue(t);let c=typeof r=="string"?[r]:r.filter(u=>typeof u=="string"),l=[];for(let u of c){let f=await St(le(t,u));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),a=i(c=>{let l=n.get(c);return l||(l=c===t?o():s(c),n.set(c,l)),l},"contextFor"),s=i(async c=>{let l=await a(gt(c));return l.kind==="git"?l.entries.has(de(l.root,c))?ue(c):l:!l.nested||l.excluded?l:xt(l.matchers,c,!0)?{...l,excluded:!0}:await gn(c)?ue(c):Dt(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let u=le(c),f=wt(t,u);if(f.length===0||f===".."||f.startsWith(`..${Et}`)||pn(f))return!1;let p=await a(gt(u));if(p.kind==="git"){let x=de(p.root,u);return!(p.entries.has(x)||l&&p.dirs.has(x))}return p.excluded||xt(p.matchers,u,l)}}}i(kt,"createIgnoreFilter");function bn(e){return dt(e)}i(bn,"resolveExtensions");var vt=new Set([".git"]);function me(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}i(me,"normalizeFolderPath");function wn(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(wn,"resolveIncludeFolders");function Nt(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i(Nt,"reportSkippedIncludeFolder");function En(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=pe(e),n=[],o=new Set;for(let a of t){if(typeof a!="string")continue;let s=me(a);if(s.length!==0){if(s.includes("/")){n.push(pe(r,s));continue}o.add(s)}}return(a,s)=>{if(o.has(s))return!0;for(let l of n)if(a===l||a.startsWith(`${l}/`))return!0;let c=me($t(r,a));return n.some(l=>{let u=me($t(r,l));return c===u||c.startsWith(`${u}/`)})}}i(En,"buildExclusionMatcher");async function he(e){let t=bn(e),r=wn(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=En(e.projectRoot,n),a=kt({root:e.projectRoot,gitignore:e.gitignore}),s=i(async(m,h)=>o(m,h)||await a.isIgnored(m,!0),"shouldSkipDirectory"),c=r.length>0?r.map(m=>({includeFolder:m.path,rootPath:At(e.projectRoot,m.path),recursive:m.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let m of c){let h=await xn(m.rootPath).catch(S=>S);if(h instanceof Error){if(h.code==="ENOENT"){Nt(m.includeFolder,h);continue}throw h}if(!h.isDirectory()){Nt(m.includeFolder,`path is not a directory: ${m.rootPath}`);continue}let w=await yn(m.rootPath).catch(()=>pe(m.rootPath));l.push({...m,realRoot:w})}let u=i((m,h)=>{if(m.realRoot===h.realRoot)return m.recursive||!h.recursive;let w=m.realRoot.endsWith(fe)?m.realRoot:`${m.realRoot}${fe}`;if(!m.recursive||!h.realRoot.startsWith(w))return!1;let S=m.rootPath;for(let A of h.realRoot.slice(w.length).split(fe))if(S=At(S,A),vt.has(A)||o(S,A))return!1;return!0},"covers"),f=[...l].sort((m,h)=>m.realRoot.length-h.realRoot.length||Number(h.recursive)-Number(m.recursive)),p=[];for(let m of f)p.some(h=>u(h,m))||p.push(m);let x=[];for(let m of l){if(!p.includes(m))continue;let h=await ce(m.rootPath,{allowedExtensions:t,ignoreFolders:vt,shouldSkipDirectory:s,recursive:m.recursive});x.push(...h)}let g=[];for(let m of new Set(x))!o(m,m.split("/").at(-1)||"")&&!await a.isIgnored(m,!1)&&g.push(m);return g}i(he,"discoverFiles");import{basename as Wn,dirname as Yn,extname as Gn,resolve as we}from"node:path";import{dirname as _t,isAbsolute as Ln,join as Ht,relative as Mn,resolve as zt,sep as Pn}from"node:path";import{readFile as Sn}from"node:fs/promises";import{join as Dn}from"node:path";async function kn(e){try{return await Sn(e,"utf8")}catch{return null}}i(kn,"readManifest");async function D(e,t){let r=[];for(let n of t){let o=await kn(Dn(e,n));o!==null&&r.push({file:n,content:o})}return r.length>0?{dir:e,manifest:r[0].file,files:r}:null}i(D,"detectManifests");function C(e,t){return e.files.find(r=>r.file===t)?.content??null}i(C,"manifestContent");function b(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(b,"cleanName");function ge(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return b(t===-1?e:e.slice(0,t))}i(ge,"personName");function K(e){try{return JSON.parse(e)}catch{return}}i(K,"parseJsonManifest");function*ye(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let a=o.match(/^\[([^[\]]+)\]/);r=a?a[1].split(".").map(s=>s.trim()).join("."):"";continue}r===t&&(yield o)}}i(ye,"sectionLines");function I(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of ye(e,t)){let a=o.match(n);if(a)return b(a[1]??a[2])}}i(I,"readTomlString");function xe(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of ye(e,t)){let a=o.match(n);if(a)return b(a[1])}}i(xe,"readIniValue");function An(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let a of ye(e,t)){if(o!==null){o.push(a);continue}let s=a.match(n);s&&(o=[a.slice(s[0].length)])}return o===null?null:o.join(`
3
+ `)}i(An,"tomlArrayText");function $n(e,t){let r=t;for(;r<e.length;)if(e[r]==="#"){let n=e.indexOf(`
4
+ `,r);r=n===-1?e.length:n+1}else if(/\s/.test(e[r]))r+=1;else break;return r}i($n,"skipTomlSpace");function O(e,t){let r=An(e,t,"authors");if(r===null)return;let n=r.slice($n(r,0)),o=n.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return ge(o[1]??o[2]);let s=n.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return s?b(s[1]??s[2]):void 0}i(O,"readTomlAuthor");var Ct=["go.mod"];function vn(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return b(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(vn,"readModulePath");var Ft={id:"go",languages:["go"],manifests:Ct,detect(e){return D(e,Ct)},read(e){return{name:vn(e.files[0].content)}}};var jt=["package.json"];function Nn(e){let t=b(e?.name),r=b(e?.publisher),n=typeof e?.engines?.vscode=="string";return t&&r&&n?`${r}.${t}`:t}i(Nn,"readPublishedName");function Cn(e){if(e!==null&&typeof e=="object"){let t=e;return b(t.company)??b(t.name)}return ge(e)}i(Cn,"readAuthorCompany");var Lt={id:"node",languages:["node"],manifests:jt,detect(e){return D(e,jt)},read(e){let t=K(e.files[0].content);return{name:Nn(t),company:Cn(t?.author)}}};var Mt=["composer.json"],Pt={id:"php",languages:["php"],manifests:Mt,detect(e){return D(e,Mt)},read(e){let t=K(e.files[0].content),r=t?.authors;return{name:b(t?.name),company:Array.isArray(r)?b(r[0]?.name):void 0}}};var Rt=["pyproject.toml","setup.cfg","setup.py"];function It(e,t){let r=e.indexOf("setup(");if(r===-1)return;let n=e.slice(r).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return n&&n[2].trim()||void 0}i(It,"readSetupPyArgument");function Fn(e){let t=C(e,"pyproject.toml"),r=C(e,"setup.cfg"),n=C(e,"setup.py");return(t===null?void 0:I(t,"project","name")??I(t,"tool.poetry","name"))??(r===null?void 0:xe(r,"metadata","name"))??(n===null?void 0:It(n,"name"))}i(Fn,"readPythonName");function jn(e){let t=C(e,"pyproject.toml"),r=C(e,"setup.cfg"),n=C(e,"setup.py");return(t===null?void 0:O(t,"project")??O(t,"tool.poetry"))??(r===null?void 0:xe(r,"metadata","author"))??(n===null?void 0:It(n,"author"))}i(jn,"readPythonCompany");var Ot={id:"python",languages:["python"],manifests:Rt,detect(e){return D(e,Rt)},read(e){return{name:Fn(e),company:jn(e)}}};var Tt=["Cargo.toml"],Ut={id:"rust",languages:["rust"],manifests:Tt,detect(e){return D(e,Tt)},read(e){let t=e.files[0].content;return{name:I(t,"package","name"),company:O(t,"package")}}};var Rn=[Lt,Ot,Pt,Ut,Ft],Bt=["name","company"];async function be(e,t,r){let o=(await Promise.all(t.map(async s=>({driver:s,detection:await s.detect(e)})))).filter(s=>s.detection!==null),a=o.filter(s=>typeof r=="string"&&s.driver.languages.includes(r));return[...a,...o.filter(s=>!a.includes(s))]}i(be,"claimFolder");function In(e,t){let r=Mn(t,e);return r!==""&&r!==".."&&!r.startsWith(`..${Pn}`)&&!Ln(r)}i(In,"isStrictlyInside");async function Wt(e,t={}){let r=Array.isArray(t.drivers)?t.drivers:Rn,n=typeof t.scanRoot=="string"?zt(t.scanRoot):null,o=zt(e),a=await be(o,r,t.language);for(;a.length===0;){if(await se(Ht(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=_t(o);if(f===o)return null;o=f,a=await be(o,r,t.language)}let s={},c={},l=o,u=a;for(;;){for(let{driver:p,detection:x}of u){let g=p.read(x);for(let m of Bt)s[m]===void 0&&g[m]!==void 0&&(s[m]=g[m],c[m]={driver:p.id,manifest:x.manifest,dir:l})}if(Bt.every(p=>s[p]!==void 0)||n===null||!In(l,n)||await se(Ht(l,".git")))break;l=_t(l),u=await be(l,r,t.language)}return{root:o,marker:a[0].detection.manifest,drivers:a.map(f=>f.driver.id),fields:s,sources:c}}i(Wt,"resolveManifestProject");import{execFile as On}from"node:child_process";import{promisify as Tn}from"node:util";var Gt=Tn(On);async function k(e,t){try{let{stdout:r}=await Gt("git",t,{cwd:e}),n=r.trim();return n.length>0?n:null}catch{return null}}i(k,"runGit");function Yt(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}i(Yt,"isEscaped");function Un(e){let t=e.trim();if(!t.endsWith(")")||Yt(t,t.length-1))return t;let r=0;for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(o!=="("&&o!==")"||Yt(t,n))&&(r+=o===")"?1:-1,r===0))return t.slice(0,n).trim()}return t}i(Un,"stripUidComment");function _n(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let r=t.match(/<([^>\n]+)>\s*$/),n=r?.[1]?.trim()||null,o=(r?t.slice(0,r.index):t).trim();return{authorName:Un(o)||o||null,authorEmail:n}}i(_n,"parseSignerUid");async function Hn(e,t){try{let{stdout:r}=await Gt(e,t),n=r.trim();return n.length>0?n:null}catch{return null}}i(Hn,"runProgram");function zn(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)))}i(zn,"decodeColonField");async function Bn(e){let t=await k(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let r=await k(e,["config","--get","user.signingkey"]);if(!r)return null;let n=await k(e,["config","--get","gpg.openpgp.program"])||await k(e,["config","--get","gpg.program"])||"gpg",o=await Hn(n,["--batch","--with-colons","--list-keys",r]);if(!o)return null;for(let a of o.split(`
5
+ `)){let s=a.split(":");if(s[0]==="uid"&&s[1]!=="r"&&s[1]!=="e"&&s[9])return zn(s[9])}return null}i(Bn,"readSigningKeyUid");async function Vt(e,t={}){let r=await k(e,["config","--get","user.name"]),n=await k(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Bn(e)||await k(e,["log","-1","--format=%GS"]),a=_n(o||"");r=a.authorName||r,n=n||a.authorEmail}if(!r||!n){let o=await k(e,["log","-1","--format=%an|%ae"]);if(o){let[a,s]=o.split("|");r=r||a||null,n=n||s||null}}return{authorName:r,authorEmail:n}}i(Vt,"detectGitAuthor");function Jt(e){return e.replace(/z$/i,"+00:00")}i(Jt,"canonicalGitDate");async function Kt(e,t){let r=await k(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!r)return null;let n=r.split(`
6
+ `)[0],[o,a]=n.split("|");if(!o||!a)return null;let s=Number.parseInt(a,10);return Number.isNaN(s)?null:{date:Jt(o),timestamp:s}}i(Kt,"getGitCreationDate");async function qt(e,t){let r=await k(e,["log","-1","--format=%aI|%at","--",t]);if(!r)return null;let[n,o]=r.split("|");if(!n||!o)return null;let a=Number.parseInt(o,10);return Number.isNaN(a)?null:{date:Jt(n),timestamp:a}}i(qt,"getGitLastModifiedDate");function Vn(e){return Wn(e)||"project"}i(Vn,"folderName");function Jn(e,t){if(typeof t!="string")return e;let r=t.trim();return r.length===0||/<[^>]+>/.test(e)?e:`${e} <${r}>`}i(Jn,"formatAuthorNameWithCompany");async function Kn(e,t={}){let r=Array.isArray(t.detectors)?t.detectors:L(t),n=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=n.length>0?r.find(u=>u.extensions.includes(n)):void 0,a=await Wt(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),s=a?a.root:we(e),c=a?.sources.name,l=a?.sources.company;return{language:o?.id??a?.drivers[0]??"unknown",rootDir:s,marker:a?a.marker:null,projectName:a?.fields.name??Vn(s),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:s},companyName:a?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:a?a.drivers:[]}}i(Kn,"detectProjectFromMarkers");async function Ee(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),r=we(t),n=L(e),o=e.targetFilePath?Yn(r):r,a=e.targetFilePath?Gn(r).toLowerCase():"",s=we(e.projectRoot||e.cwd||process.cwd()),c=await Kn(o,{detectors:n,preferredExtension:a,scanRoot:s}),l=await Vt(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:Jn(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(Ee,"resolveProjectMetadata");function qn(e){return Se({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(qn,"formatDateWithTimezone");function Se(e){return`${er(e," ")} ${tr(e.offsetMinutes)}`}i(Se,"formatSpaceDate");function Zt(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{Qt(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(Zt,"assertTimeZone");var Xt=new Map;function Qt(e){let t=Xt.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"}),Xt.set(e,t)),t}i(Qt,"getZoneFormatter");function De(e,t){let r={};for(let o of Qt(t).formatToParts(new Date(e*1e3)))r[o.type]=Number(o.value);let n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)/1e3;return{year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute,second:r.second,offsetMinutes:(n-e)/60}}i(De,"toZonedDateParts");function er(e,t){let r=i(n=>String(n).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${r(e.month)}-${r(e.day)}${t}${r(e.hour)}:${r(e.minute)}:${r(e.second)}`}i(er,"formatWallClock");function tr(e){let t=i(n=>String(n).padStart(2,"0"),"pad"),r=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(r/60))}:${t(r%60)}`}i(tr,"formatOffset");function q(e=new Date){return{date:qn(e),timestamp:Math.floor(e.getTime()/1e3)}}i(q,"toDatePayload");var Xn=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function F(e){let t=Xn.exec(e.trim());if(!t)return null;let[r,n,o,a,s,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(r,n-1,o,a,s,c));return!(f.getUTCFullYear()===r&&f.getUTCMonth()===n-1&&f.getUTCDate()===o&&f.getUTCHours()===a&&f.getUTCMinutes()===s&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:r,month:n,day:o,hour:a,minute:s,second:c,offsetMinutes:u,timestamp:Math.floor(f.getTime()/1e3)-u*60}}i(F,"parseHeaderDate");function ke(e){return`${er(e,"T")}${tr(e.offsetMinutes)}`}i(ke,"formatIsoDate");var Zn={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function rr(e,t){let r=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return r?r[1].trim():null}i(rr,"readHeaderField");function Ae(e){let t=null;for(let{source:r,payload:n}of e)n&&(!t||n.timestamp<t.payload.timestamp)&&(t={source:r,payload:n});return t}i(Ae,"pickOldestDate");function or({existing:e,gitCreated:t,filesystemCreated:r,fixCreatedDate:n=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:r}];if(!e)return Ae(o);if(!n)return{source:"existing-header",payload:e};let a=F(e.date)?e:null;return Ae([{source:"existing-header",payload:a},...o])}i(or,"resolveCreatedDate");function ir(e,t=null){if(t)return De(e.timestamp,t).year;let r=F(e.date);return r?r.year:new Date(e.timestamp*1e3).getFullYear()}i(ir,"dateYear");function nr(e,t,r,n){let o=e.match(/^(.+?)\s*\((\d+)\)$/),a=o?F(o[1]):null;if(!o||!a)return n.push({check:`${r}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let s=Number.parseInt(o[2],10);return s!==a.timestamp&&n.push({check:`${r}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${a.timestamp})`,message:`${t} epoch ${s} does not match ${o[1]} (expected ${a.timestamp})`}),{text:o[1],timestamp:a.timestamp}}i(nr,"checkDateValue");function ar(e,t={},r={}){let n=[],o=rr(e,"@Date"),a=o===null?null:nr(o,"@Date","created",n),s=Ae([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(a&&s&&a.timestamp>s.payload.timestamp){let f=Zn[s.source];n.push({check:"created-newer-than-source",field:"@Date",advisory:r.strictCreatedDate!==!0,value:o,expected:`${s.payload.date} (${s.payload.timestamp})`,source:s.source,message:`@Date ${a.text} is later than the ${f} ${s.payload.date} (${s.payload.timestamp})`})}let c=rr(e,"@Last modified time"),l=c===null?null:nr(c,"@Last modified time","modified",n),u=t.gitLastModified;return l&&u&&l.timestamp!==u.timestamp&&n.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})`}),n}i(ar,"checkHeaderDates");function $e(e){if(!e)return null;let t=F(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i($e,"repairDateEpoch");function sr(e){let t=F(e.date);return t?{date:ke(t),timestamp:t.timestamp}:e}i(sr,"normalizeDatePayload");function cr(e,t){let r=F(e.date);if(!r)return e;let n=De(r.timestamp,t);return n.offsetMinutes===r.offsetMinutes||!Number.isInteger(n.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?ke(n):Se(n),timestamp:r.timestamp}}i(cr,"convertDatePayload");import{relative as eo}from"node:path";import{extname as Qn}from"node:path";function T(e,t={}){let r=Qn(e).toLowerCase(),n=N(t.spacing,"spacing",R);return r.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:n}:{...ft(e,t),spacing:n}}i(T,"getHeaderSyntaxForFile");function lr(e,t){let r=e.spacing??R;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",u=Array.from({length:r},()=>c);return[...u,...t.map(f=>`${c}${l}${f}`),...u].join(`
7
+ `)}let n=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),a=e.blockEnd||(e.kind==="html"?"-->":" */"),s=Array.from({length:r},()=>o.trimEnd());return[n,...s,...t.map(c=>`${o}${c}`),...s,a].join(`
8
+ `)}i(lr,"renderHeaderLines");function ve(e){let t=`/${eo(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,r=T(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),n=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,a=e.lastModifiedByName||e.authorName,s=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: ${n}`,`@Email: <${o}>`,"-----",`@Last modified by: ${a} (${s})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return lr(r,u)}i(ve,"buildHeader");var to=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function $(e,t){let r=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),n=r?r[1].trim():"";return n.length>0?n:null}i($,"readTag");function ro(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),r=t.indexOf("(",t.lastIndexOf(")")+1);return r===-1?{name:e,email:null}:{name:t.slice(0,r).trimEnd()||null,email:t.slice(r+1)||null}}i(ro,"splitLastModifiedBy");function no(e){let t={startYear:null,endYear:null,companyName:null},r=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!r)return t;let n=e.slice(r[0].length),o=n.match(/^\s*-\s*(\d{4})/);o&&(n=n.slice(o[0].length));let a=n.toLowerCase(),s=a.endsWith("all rights reserved.")?20:a.endsWith("all rights reserved")?19:0;return s===0||!/^\s/.test(n)?t:{startYear:r[1],endYear:o?o[1]:null,companyName:n.slice(0,-s).trim()||null}}i(no,"splitCopyright");function ur(e){let t=ro($(e,"Last modified by")),r=no($(e,"Copyright")),n=$(e,"Email");return{projectName:$(e,"Project"),filename:$(e,"Filename"),createdAt:$(e,"Date"),authorName:$(e,"Author"),authorEmail:n===null?null:n.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:$(e,"Last modified time"),copyrightStartYear:r.startYear,copyrightEndYear:r.endYear,companyName:r.companyName}}i(ur,"parseHeaderFields");function dr(e,t){let r=ur(e??""),n=ur(t);return to.filter(o=>r[o]!==n[o]).map(o=>({field:o,previous:r[o],detected:n[o]}))}i(dr,"compareHeaderFields");function X(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(X,"escapeRegex");function mr(e,t,r={}){let n=mt(e,t,r);return n.length===0?{prefix:"",body:t}:{prefix:n,body:t.slice(n.length)}}i(mr,"splitPreservedPrefix");function fr(e,t){if(t.kind==="html"){let n=X(t.blockStart||"<!--"),o=X(t.blockEnd||"-->");return e.match(new RegExp(`^${n}[\\s\\S]*?${o}\\n*`))}if(t.kind==="line"){let n=X(t.linePrefix||"#");return e.match(new RegExp(`^(?:${n}.*\\n)+\\n*`))}let r=X((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${r}\\n*`))}i(fr,"matchHeaderSegment");function Ne(e,t="",r={}){let{prefix:n,body:o}=mr(t,e,r),a=o.split(`
9
+ `).slice(0,pt).join(`
10
+ `),s=T(t,r);if(!fr(a,s))return null;let l=0,u=0;for(;;){let f=a.slice(l),p=fr(f,s);if(!p||!p[0].includes("@Project:"))break;l+=p[0].length,u=l}return u===0?null:{start:n.length,end:n.length+u}}i(Ne,"findProjectHeader");function Ce(e,t,r="",n={}){let o=Ne(e,r,n),a=N(n.margin,"margin",J),s=T(r,n).kind==="line"?Math.max(1,a):a,c=`
11
+ `.repeat(s+1);if(!o){let{prefix:p,body:x}=mr(r,e,n),g=`${p}${t}${c}${x.replace(/^\n+/,"")}`;return{nextContent:g,changed:g!==e}}let l=e.slice(0,o.start),u=e.slice(o.end).replace(/^\n+/,""),f=`${l}${t}${c}${u}`;return{nextContent:f,changed:f!==e}}i(Ce,"replaceOrInsertHeader");function oo(e,t){let r=e.length,n=t.length,o=Array.from({length:r+1},()=>new Array(n+1).fill(0));for(let l=r-1;l>=0;l-=1)for(let u=n-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 a=[],s=0,c=0;for(;s<r&&c<n;)e[s]===t[c]?(a.push({type:" ",line:e[s]}),s+=1,c+=1):o[s+1][c]>=o[s][c+1]?(a.push({type:"-",line:e[s]}),s+=1):(a.push({type:"+",line:t[c]}),c+=1);for(;s<r;s+=1)a.push({type:"-",line:e[s]});for(;c<n;c+=1)a.push({type:"+",line:t[c]});return a}i(oo,"diffLines");function pr(e,t){return`${t===0?e:e+1},${t}`}i(pr,"formatRange");function hr(e,t,r={}){let n=e===null?[]:e.split(`
20
12
  `),o=t.split(`
21
- `),a=to(n,o),s=Math.max(0,r.context??3),c=r.lineOffset??0,l=[];if(a.forEach((x,y)=>{if(x.type===" ")return;let m=l[l.length-1];m&&y-m.last<=s*2+1?m.last=y:l.push({first:y,last:y})}),l.length===0)return"";let u=r.fromFile??"a",f=r.toFile??"b",p=[`--- ${e===null?"/dev/null":u}`,`+++ ${f}`];for(let x of l){let y=Math.max(0,x.first-s),m=Math.min(a.length,x.last+s+1),h=a.slice(0,y),w=a.slice(y,m),E=h.filter(d=>d.type!=="+").length+c,v=h.filter(d=>d.type!=="-").length+c,I=w.filter(d=>d.type!=="+").length,g=w.filter(d=>d.type!=="-").length;p.push(`@@ -${dr(E,I)} +${dr(v,g)} @@`);for(let d of w)p.push(`${d.type}${d.line}`)}return p.join(`
22
- `)}i(fr,"createUnifiedDiff");function io(e){return W(e,"configFile")}i(io,"resolveRuntimeOptions");function ao(e){let t=e.match(/@Author:\s*(.+)$/m),r=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}i(ao,"extractHeaderAuthorIdentity");function so(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(so,"extractHeaderLastModifiedIdentity");function co(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(co,"extractHeaderCreatedAt");function lo(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(lo,"extractHeaderLastModifiedAt");async function hr(e={}){let t=await io(e),r=t.timezone===void 0||t.timezone===null?null:Jt(t.timezone),n=t.convertTimezone===!0;if(n&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=pr(t.projectRoot||t.cwd||process.cwd()),a=await xe({...t,cwd:o}),s=t.check===!0,c=s||t.dryRun===!0,l=t.fixCreatedDate===!0,u=i(g=>g,"keepDate"),f=t.normalizeDateFormat===!0?nr:u,p=r?g=>or(g,r):u,x=n?p:u,y;if(typeof t.input=="string"&&t.input.trim().length>0){let g=pr(o,t.input),d=await no(g).catch(()=>null);if(!d)throw new Error(`Input path does not exist: ${t.input}`);if(d.isFile())y=[g];else if(d.isDirectory())y=await fe({projectRoot:g,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});else throw new Error(`Input path must be a file or directory: ${t.input}`)}else y=await fe({projectRoot:o,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});let m=new Date().getFullYear(),h=[],w=new Set,E=0,v=0,I=0;for(let g of y){let d=await xe({...t,cwd:o,targetFilePath:g});w.add(`${d.language}:${d.projectRoot}`);let Ae=mr(o,g),O=await ro(g,"utf8"),K=ve(O,g,{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides}),S=K?O.slice(K.start,K.end):"",T=S.length>0?ao(S):{},U=S.length>0?so(S):{},wr=S.length>0?co(S):null,Sr=S.length>0?lo(S):null,Ce=await dt(g),Fe=mr(d.projectRoot,g),je=await Yt(d.projectRoot,Fe),q=await Vt(d.projectRoot,Fe),Me=V(Ce.createdAt),X=er({existing:ke(wr),gitCreated:je,filesystemCreated:Me,fixCreatedDate:l}),Z=ke(Sr),Pe=X.source,Er=Z?"existing-header":q?"git-last-modified":"filesystem-updated",z=f(Pe==="existing-header"?x(X.payload):p(X.payload)),kr=d.copyrightStartYear===null?"created-date":"option",Q=d.copyrightStartYear??tr(z,r),Le=f(Z?x(Z):p(q||V(Ce.updatedAt))),H=t.forceAuthorUpdate===!0,B=t.forceLastModifiedAuthorUpdate===!0,Re=$e({absoluteFilePath:g,language:d.language,syntaxOptions:{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides},projectRoot:d.projectRoot,projectName:d.projectName,createdByName:H?d.authorName:T.authorName||d.authorName,createdByEmail:H?d.authorEmail:T.authorEmail||d.authorEmail,lastModifiedByName:B?d.authorName:U.authorName||d.authorName,lastModifiedByEmail:B?d.authorEmail:U.authorEmail||d.authorEmail,authorName:d.authorName,authorEmail:d.authorEmail,createdAt:z,lastModifiedAt:Le,copyrightStartYear:Q,companyName:d.companyName,currentYear:m}),Ie=De(O,Re,g,{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides}),_=Ie.changed,Oe=_?f(p(V(new Date))):Le,$r=_?"current-time-on-change":Er,M=_?$e({absoluteFilePath:g,language:d.language,syntaxOptions:{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides},projectRoot:d.projectRoot,projectName:d.projectName,createdByName:H?d.authorName:T.authorName||d.authorName,createdByEmail:H?d.authorEmail:T.authorEmail||d.authorEmail,lastModifiedByName:B?d.authorName:U.authorName||d.authorName,lastModifiedByEmail:B?d.authorEmail:U.authorEmail||d.authorEmail,authorName:d.authorName,authorEmail:d.authorEmail,createdAt:z,lastModifiedAt:Oe,copyrightStartYear:Q,companyName:d.companyName,currentYear:m}):Re,F=_?De(O,M,g,{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides}):Ie,ee={file:Ae,changed:F.changed};if(s){let N=rr(S,{gitCreated:je,gitLastModified:q,filesystemCreated:Me},{strictCreatedDate:t.strictCreatedDate===!0}),P=N.filter(te=>te.advisory).length;ee.dateIssues=N,I+=P,v+=N.length>P?1:0}if(t.sampleOutput===!0&&F.changed){let N=S.length>0?S.trimEnd():null,P=Ae.replace(/\\/g,"/"),te=F.nextContent.slice(0,F.nextContent.indexOf(M)).split(`
23
- `).length-1;ee.sample={previousValue:N,newValue:M,diff:fr(N,M,{fromFile:`a/${P}`,toFile:`b/${P}`,lineOffset:te}),issues:sr(N,M),detectedValues:{projectName:d.projectName,projectNameSource:d.projectNameSource,language:d.language,projectRoot:d.projectRoot,marker:d.marker,authorName:d.authorName,authorEmail:d.authorEmail,companyName:d.companyName,companyNameSource:d.companyNameSource,copyrightStartYear:Q,copyrightStartYearSource:kr,createdAtSource:Pe,lastModifiedAtSource:$r,createdAt:z,lastModifiedAt:Oe}}}h.push(ee),F.changed&&(E+=1,c||await oo(g,F.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(w),filesScanned:y.length,filesUpdated:E,dryRun:c,check:s,...s?{filesWithDateDrift:v,dateAdvisories:I}:{},changes:h}}i(hr,"fixHeaders");function uo(e){return hr(e)}i(uo,"fixHeaders");var gr=uo;var po=`fix-headers CLI
13
+ `),a=oo(n,o),s=Math.max(0,r.context??3),c=r.lineOffset??0,l=[];if(a.forEach((x,g)=>{if(x.type===" ")return;let m=l[l.length-1];m&&g-m.last<=s*2+1?m.last=g:l.push({first:g,last:g})}),l.length===0)return"";let u=r.fromFile??"a",f=r.toFile??"b",p=[`--- ${e===null?"/dev/null":u}`,`+++ ${f}`];for(let x of l){let g=Math.max(0,x.first-s),m=Math.min(a.length,x.last+s+1),h=a.slice(0,g),w=a.slice(g,m),S=h.filter(d=>d.type!=="+").length+c,A=h.filter(d=>d.type!=="-").length+c,U=w.filter(d=>d.type!=="+").length,y=w.filter(d=>d.type!=="-").length;p.push(`@@ -${pr(S,U)} +${pr(A,y)} @@`);for(let d of w)p.push(`${d.type}${d.line}`)}return p.join(`
14
+ `)}i(hr,"createUnifiedDiff");function co(e){return V(e,"configFile")}i(co,"resolveRuntimeOptions");function lo(e){let t=e.match(/@Author:\s*(.+)$/m),r=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}i(lo,"extractHeaderAuthorIdentity");function uo(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(uo,"extractHeaderLastModifiedIdentity");function fo(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(fo,"extractHeaderCreatedAt");function mo(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(mo,"extractHeaderLastModifiedAt");async function xr(e={}){let t=await co(e),r=t.timezone===void 0||t.timezone===null?null:Zt(t.timezone),n=t.convertTimezone===!0;if(n&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=yr(t.projectRoot||t.cwd||process.cwd()),a=await Ee({...t,cwd:o});N(t.spacing,"spacing",R),N(t.margin,"margin",J);let s=t.check===!0,c=s||t.dryRun===!0,l=t.fixCreatedDate===!0,u=i(y=>y,"keepDate"),f=t.normalizeDateFormat===!0?sr:u,p=r?y=>cr(y,r):u,x=n?p:u,g;if(typeof t.input=="string"&&t.input.trim().length>0){let y=yr(o,t.input),d=await ao(y).catch(()=>null);if(!d)throw new Error(`Input path does not exist: ${t.input}`);if(d.isFile())g=[y];else if(d.isDirectory())g=await he({projectRoot:y,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});else throw new Error(`Input path must be a file or directory: ${t.input}`)}else g=await he({projectRoot:o,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});let m=new Date().getFullYear(),h=[],w=new Set,S=0,A=0,U=0;for(let y of g){let d=await Ee({...t,cwd:o,targetFilePath:y});w.add(`${d.language}:${d.projectRoot}`);let je=gr(o,y),_=await io(y,"utf8"),Z=Ne(_,y,{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin}),E=Z?_.slice(Z.start,Z.end):"",H=E.length>0?lo(E):{},z=E.length>0?uo(E):{},Dr=E.length>0?fo(E):null,kr=E.length>0?mo(E):null,Le=await ht(y),Me=gr(d.projectRoot,y),Pe=await Kt(d.projectRoot,Me),Q=await qt(d.projectRoot,Me),Re=q(Le.createdAt),ee=or({existing:$e(Dr),gitCreated:Pe,filesystemCreated:Re,fixCreatedDate:l}),te=$e(kr),Ie=ee.source,Ar=te?"existing-header":Q?"git-last-modified":"filesystem-updated",B=f(Ie==="existing-header"?x(ee.payload):p(ee.payload)),$r=d.copyrightStartYear===null?"created-date":"option",re=d.copyrightStartYear??ir(B,r),Oe=f(te?x(te):p(Q||q(Le.updatedAt))),W=t.forceAuthorUpdate===!0,Y=t.forceLastModifiedAuthorUpdate===!0,Te=ve({absoluteFilePath:y,language:d.language,syntaxOptions:{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin},projectRoot:d.projectRoot,projectName:d.projectName,createdByName:W?d.authorName:H.authorName||d.authorName,createdByEmail:W?d.authorEmail:H.authorEmail||d.authorEmail,lastModifiedByName:Y?d.authorName:z.authorName||d.authorName,lastModifiedByEmail:Y?d.authorEmail:z.authorEmail||d.authorEmail,authorName:d.authorName,authorEmail:d.authorEmail,createdAt:B,lastModifiedAt:Oe,copyrightStartYear:re,companyName:d.companyName,currentYear:m}),Ue=Ce(_,Te,y,{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin}),G=Ue.changed,_e=G?f(p(q(new Date))):Oe,vr=G?"current-time-on-change":Ar,M=G?ve({absoluteFilePath:y,language:d.language,syntaxOptions:{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin},projectRoot:d.projectRoot,projectName:d.projectName,createdByName:W?d.authorName:H.authorName||d.authorName,createdByEmail:W?d.authorEmail:H.authorEmail||d.authorEmail,lastModifiedByName:Y?d.authorName:z.authorName||d.authorName,lastModifiedByEmail:Y?d.authorEmail:z.authorEmail||d.authorEmail,authorName:d.authorName,authorEmail:d.authorEmail,createdAt:B,lastModifiedAt:_e,copyrightStartYear:re,companyName:d.companyName,currentYear:m}):Te,j=G?Ce(_,M,y,{language:d.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin}):Ue,ne={file:je,changed:j.changed};if(s){let v=ar(E,{gitCreated:Pe,gitLastModified:Q,filesystemCreated:Re},{strictCreatedDate:t.strictCreatedDate===!0}),P=v.filter(oe=>oe.advisory).length;ne.dateIssues=v,U+=P,A+=v.length>P?1:0}if(t.sampleOutput===!0&&j.changed){let v=E.length>0?E.trimEnd():null,P=je.replace(/\\/g,"/"),oe=j.nextContent.slice(0,j.nextContent.indexOf(M)).split(`
15
+ `).length-1;ne.sample={previousValue:v,newValue:M,diff:hr(v,M,{fromFile:`a/${P}`,toFile:`b/${P}`,lineOffset:oe}),issues:dr(v,M),detectedValues:{projectName:d.projectName,projectNameSource:d.projectNameSource,language:d.language,projectRoot:d.projectRoot,marker:d.marker,authorName:d.authorName,authorEmail:d.authorEmail,companyName:d.companyName,companyNameSource:d.companyNameSource,copyrightStartYear:re,copyrightStartYearSource:$r,createdAtSource:Ie,lastModifiedAtSource:vr,createdAt:B,lastModifiedAt:_e}}}h.push(ne),j.changed&&(S+=1,c||await so(y,j.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(w),filesScanned:g.length,filesUpdated:S,dryRun:c,check:s,...s?{filesWithDateDrift:A,dateAdvisories:U}:{},changes:h}}i(xr,"fixHeaders");function po(e){return xr(e)}i(po,"fixHeaders");var br=po;var yo=`fix-headers CLI
24
16
 
25
17
  Usage:
26
18
  fix-headers [options]
@@ -58,6 +50,8 @@ Options:
58
50
  --company <name> Append company suffix to @Author (Name <Company>)
59
51
  --company-name <name> @Copyright holder (default: the project manifest's author; omitted when none)
60
52
  --copyright-start-year <year> Set the copyright start year (default: each file's @Date year)
53
+ --spacing <n> Empty comment lines just inside the header's opening and closing (default: 1)
54
+ --margin <n> Blank lines between the header and the file's next content (default: 2)
61
55
  --config <path> Load JSON options file; its 'extends' can pull in shared configs (URL, package or path)
62
56
 
63
57
  Examples:
@@ -66,5 +60,5 @@ Examples:
66
60
  fix-headers --check --verbose
67
61
  fix-headers --timezone America/Los_Angeles --convert-timezone
68
62
  fix-headers --project-name @scope/pkg --company-name "Catalyzed Motivation Inc."
69
- `;function ho(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}i(ho,"toCamelCase");function go(e){let t={},r={help:!1,json:!1,diff:!1},n={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors"},o={cwd:"cwd",input:"input","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",timezone:"timezone",config:"config"};for(let a=0;a<e.length;a+=1){let s=e[a];if(s==="-h"||s==="--help"){r.help=!0;continue}if(s==="--json"){r.json=!0;continue}if(s==="--diff"){r.diff=!0;continue}if(s==="--verbose"){t.verbose=!0;continue}if(s==="--dry-run"){t.dryRun=!0;continue}if(s==="--check"){t.check=!0;continue}if(s==="--fix-created-date"){t.fixCreatedDate=!0;continue}if(s==="--strict-created-date"){t.strictCreatedDate=!0;continue}if(s==="--normalize-date-format"){t.normalizeDateFormat=!0;continue}if(s==="--convert-timezone"){t.convertTimezone=!0;continue}if(s==="--sample-output"){t.sampleOutput=!0;continue}if(s==="--force-author-update"){t.forceAuthorUpdate=!0;continue}if(s==="--force-last-modified-author-update"){t.forceLastModifiedAuthorUpdate=!0;continue}if(s==="--use-gpg-signer-author"){t.useGpgSignerAuthor=!0;continue}if(!s.startsWith("--"))throw new Error(`Unexpected argument: ${s}`);let c=s.slice(2);if(c==="include-folder-non-recursive"){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let p=Array.isArray(t.includeFolders)?t.includeFolders:[];t.includeFolders=[...p,{path:f,recursive:!1}];continue}if(n[c]){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let p=n[c],x=Array.isArray(t[p])?t[p]:[];t[p]=Array.from(new Set([...x,f]));continue}if(o[c]){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let p=o[c];if(p==="copyrightStartYear"){if(t[p]=Number.parseInt(f,10),Number.isNaN(t[p]))throw new Error(`Invalid number for --${c}: ${f}`)}else p==="marker"&&f==="null"?t[p]=null:t[p]=f;continue}let l=ho(c),u=e[a+1];if(!u||u.startsWith("--"))throw new Error(`Unknown or malformed flag: --${c}`);a+=1,t[l]=u}return{options:t,help:r.help,json:r.json,diff:r.diff}}i(go,"parseCliArgs");function yo(e){return W(e,"config")}i(yo,"applyConfigFile");function Ne(e){if(!e||typeof e!="object")return[];let t=e;return(Array.isArray(t.changes)?t.changes:[]).filter(n=>n&&n.changed===!0&&n.sample&&typeof n.sample.newValue=="string")}i(Ne,"getSampledChanges");function xr(e){return typeof e=="string"?`"${e}"`:"(missing)"}i(xr,"formatIssueValue");function xo(e,t){for(let r of Ne(t)){let n=Array.isArray(r.sample.issues)?r.sample.issues:[];if(e(`issues: ${r.file||"<unknown-file>"}`),n.length===0){e(" (no field differences; header formatting only)");continue}for(let o of n)e(` ${o?.field||"<unknown-field>"}: found ${xr(o?.previous)}, expected ${xr(o?.detected)}`)}}i(xo,"printIssues");function bo(e,t){for(let r of Ne(t))typeof r.sample.diff=="string"&&r.sample.diff.length>0&&e(r.sample.diff)}i(bo,"printDiffs");function wo(e,t){for(let r of Ne(t))e(`sample: ${r.file||"<unknown-file>"}`),e("previous:"),e(r.sample.previousValue===null?"(none)":String(r.sample.previousValue)),e("new:"),e(r.sample.newValue),r.sample.detectedValues&&typeof r.sample.detectedValues=="object"&&(e("detected-values:"),e(JSON.stringify(r.sample.detectedValues,null,2)))}i(wo,"printSampleOutput");function So(e,t){if(!t||typeof t!="object")return;let r=t,o=(Array.isArray(r.changes)?r.changes:[]).filter(a=>a&&a.changed===!0).map(a=>a.file||"<unknown-file>");for(let a of o)e(`updated: ${a}`)}i(So,"printChangedFiles");function br(e,t,r,n){let o=r.sampleOutput===!0||n;r.verbose===!0&&(So(e,t),o&&xo(e,t)),r.sampleOutput===!0&&wo(e,t),n&&bo(e,t)}i(br,"printDetails");function Eo(e,t,r){let n=Array.isArray(t.changes)?t.changes:[];for(let o of n){let a=Array.isArray(o?.dateIssues)?o.dateIssues:[];for(let s of a)s.advisory===!0&&!r||e(`${s.advisory===!0?"advisory":"drift"}: ${o.file||"<unknown-file>"}: ${s.message}`)}}i(Eo,"printDateIssues");async function ko(e,t={}){let r=t.runner||gr,n=t.stdout||console.log,o=t.stderr||console.error;try{let a=go(e);if(a.help)return n(po),0;let s=await yo(a.options),c=await r(a.diff?{...s,sampleOutput:!0}:s),l=c&&typeof c=="object"&&c.check===!0?c:null,u=l&&Number(l.filesWithDateDrift)>0?1:0;if(a.json)return n(JSON.stringify(c,null,2)),u;if(l)return n(`fix-headers check: scanned=${l.filesScanned??0}, drift=${l.filesWithDateDrift??0}, advisories=${l.dateAdvisories??0}`),Eo(n,l,s.verbose===!0),u;if(c&&typeof c=="object"){let f=c;n(`fix-headers complete: scanned=${f.filesScanned??0}, updated=${f.filesUpdated??0}, dryRun=${f.dryRun===!0}`),br(n,c,s,a.diff)}else br(n,c,s,a.diff),n("fix-headers complete");return 0}catch(a){let s=a instanceof Error?a.message:String(a);return o(`fix-headers failed: ${s}`),1}}i(ko,"runCli");function $o(e=process.argv,t=import.meta.url,r=ko){let n=!1;if(e[1])try{let o=yr(e[1]),a=yr(fo(t));n=o===a}catch{n=t===mo(e[1]).href}return n?(r(e.slice(2)).then(o=>{process.exitCode=o}),!0):!1}i($o,"runCliAsMain");$o();export{yo as applyConfigFile,go as parseCliArgs,ko as runCli,$o as runCliAsMain};
63
+ `;function xo(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}i(xo,"toCamelCase");function bo(e){let t={},r={help:!1,json:!1,diff:!1},n={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors"},o={cwd:"cwd",input:"input","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 a=0;a<e.length;a+=1){let s=e[a];if(s==="-h"||s==="--help"){r.help=!0;continue}if(s==="--json"){r.json=!0;continue}if(s==="--diff"){r.diff=!0;continue}if(s==="--verbose"){t.verbose=!0;continue}if(s==="--dry-run"){t.dryRun=!0;continue}if(s==="--check"){t.check=!0;continue}if(s==="--fix-created-date"){t.fixCreatedDate=!0;continue}if(s==="--strict-created-date"){t.strictCreatedDate=!0;continue}if(s==="--normalize-date-format"){t.normalizeDateFormat=!0;continue}if(s==="--convert-timezone"){t.convertTimezone=!0;continue}if(s==="--sample-output"){t.sampleOutput=!0;continue}if(s==="--force-author-update"){t.forceAuthorUpdate=!0;continue}if(s==="--force-last-modified-author-update"){t.forceLastModifiedAuthorUpdate=!0;continue}if(s==="--use-gpg-signer-author"){t.useGpgSignerAuthor=!0;continue}if(!s.startsWith("--"))throw new Error(`Unexpected argument: ${s}`);let c=s.slice(2);if(c==="include-folder-non-recursive"){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let p=Array.isArray(t.includeFolders)?t.includeFolders:[];t.includeFolders=[...p,{path:f,recursive:!1}];continue}if(n[c]){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let p=n[c],x=Array.isArray(t[p])?t[p]:[];t[p]=Array.from(new Set([...x,f]));continue}if(o[c]){let f=e[a+1];if(!f||f.startsWith("--"))throw new Error(`Missing value for --${c}`);a+=1;let p=o[c];if(p==="copyrightStartYear"||p==="spacing"||p==="margin"){if(t[p]=Number.parseInt(f,10),Number.isNaN(t[p]))throw new Error(`Invalid number for --${c}: ${f}`)}else p==="marker"&&f==="null"?t[p]=null:t[p]=f;continue}let l=xo(c),u=e[a+1];if(!u||u.startsWith("--"))throw new Error(`Unknown or malformed flag: --${c}`);a+=1,t[l]=u}return{options:t,help:r.help,json:r.json,diff:r.diff}}i(bo,"parseCliArgs");function wo(e){return V(e,"config")}i(wo,"applyConfigFile");function Fe(e){if(!e||typeof e!="object")return[];let t=e;return(Array.isArray(t.changes)?t.changes:[]).filter(n=>n&&n.changed===!0&&n.sample&&typeof n.sample.newValue=="string")}i(Fe,"getSampledChanges");function Er(e){return typeof e=="string"?`"${e}"`:"(missing)"}i(Er,"formatIssueValue");function Eo(e,t){for(let r of Fe(t)){let n=Array.isArray(r.sample.issues)?r.sample.issues:[];if(e(`issues: ${r.file||"<unknown-file>"}`),n.length===0){e(" (no field differences; header formatting only)");continue}for(let o of n)e(` ${o?.field||"<unknown-field>"}: found ${Er(o?.previous)}, expected ${Er(o?.detected)}`)}}i(Eo,"printIssues");function So(e,t){for(let r of Fe(t))typeof r.sample.diff=="string"&&r.sample.diff.length>0&&e(r.sample.diff)}i(So,"printDiffs");function Do(e,t){for(let r of Fe(t))e(`sample: ${r.file||"<unknown-file>"}`),e("previous:"),e(r.sample.previousValue===null?"(none)":String(r.sample.previousValue)),e("new:"),e(r.sample.newValue),r.sample.detectedValues&&typeof r.sample.detectedValues=="object"&&(e("detected-values:"),e(JSON.stringify(r.sample.detectedValues,null,2)))}i(Do,"printSampleOutput");function ko(e,t){if(!t||typeof t!="object")return;let r=t,o=(Array.isArray(r.changes)?r.changes:[]).filter(a=>a&&a.changed===!0).map(a=>a.file||"<unknown-file>");for(let a of o)e(`updated: ${a}`)}i(ko,"printChangedFiles");function Sr(e,t,r,n){let o=r.sampleOutput===!0||n;r.verbose===!0&&(ko(e,t),o&&Eo(e,t)),r.sampleOutput===!0&&Do(e,t),n&&So(e,t)}i(Sr,"printDetails");function Ao(e,t,r){let n=Array.isArray(t.changes)?t.changes:[];for(let o of n){let a=Array.isArray(o?.dateIssues)?o.dateIssues:[];for(let s of a)s.advisory===!0&&!r||e(`${s.advisory===!0?"advisory":"drift"}: ${o.file||"<unknown-file>"}: ${s.message}`)}}i(Ao,"printDateIssues");async function $o(e,t={}){let r=t.runner||br,n=t.stdout||console.log,o=t.stderr||console.error;try{let a=bo(e);if(a.help)return n(yo),0;let s=await wo(a.options),c=await r(a.diff?{...s,sampleOutput:!0}:s),l=c&&typeof c=="object"&&c.check===!0?c:null,u=l&&Number(l.filesWithDateDrift)>0?1:0;if(a.json)return n(JSON.stringify(c,null,2)),u;if(l)return n(`fix-headers check: scanned=${l.filesScanned??0}, drift=${l.filesWithDateDrift??0}, advisories=${l.dateAdvisories??0}`),Ao(n,l,s.verbose===!0),u;if(c&&typeof c=="object"){let f=c;n(`fix-headers complete: scanned=${f.filesScanned??0}, updated=${f.filesUpdated??0}, dryRun=${f.dryRun===!0}`),Sr(n,c,s,a.diff)}else Sr(n,c,s,a.diff),n("fix-headers complete");return 0}catch(a){let s=a instanceof Error?a.message:String(a);return o(`fix-headers failed: ${s}`),1}}i($o,"runCli");function vo(e=process.argv,t=import.meta.url,r=$o){let n=!1;if(e[1])try{let o=wr(e[1]),a=wr(ho(t));n=o===a}catch{n=t===go(e[1]).href}return n?(r(e.slice(2)).then(o=>{process.exitCode=o}),!0):!1}i(vo,"runCliAsMain");vo();export{wo as applyConfigFile,bo as parseCliArgs,$o as runCli,vo as runCliAsMain};
70
64
  //# sourceMappingURL=fix-headers.mjs.map
package/dist/index.mjs CHANGED
@@ -1,23 +1,15 @@
1
- var wr=Object.defineProperty;var i=(e,t)=>wr(e,"name",{value:t,configurable:!0});import{readFile as Xn,stat as Zn,writeFile as Qn}from"node:fs/promises";import{relative as mr,resolve as fr}from"node:path";import{readFile as Er}from"node:fs/promises";import{createRequire as Sr}from"node:module";import{dirname as $r,isAbsolute as kr,resolve as Oe}from"node:path";var Dr=3e4,Nr=new Set(["localhost","127.0.0.1","[::1]"]);function te(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(te,"isPlainObject");function re(e,t){let r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=te(r[n])&&te(o)?re(r[n],o):o);return r}i(re,"mergeConfig");function Te(e){return e.kind==="file"?e.path:e.href}i(Te,"describeSource");async function vr(e){if(e.kind==="file")return{text:await Er(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(Dr)})}catch(r){let n=r.cause instanceof Error?r.cause.message:r.message;throw new Error(`Failed to fetch config ${e.href}: ${n}`,{cause:r})}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(vr,"readSource");function Ie(e){if(e.protocol==="http:"&&!Nr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(Ie,"toUrlSource");function Cr(e,t){if(/^https?:\/\//i.test(e))return Ie(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${Te(t)}; use https, a file path or a package path`);let r=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(r||e.startsWith("/"))return Ie(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(r||kr(e))return{kind:"file",path:Oe($r(t.path),e)};try{return{kind:"file",path:Sr(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(Cr,"resolveReference");function Ar(e,t){if(e===void 0)return[];let r=Array.isArray(e)?e:[e];if(!r.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return r.map(n=>n.trim())}i(Ar,"readExtends");async function He(e,t){let r=Te(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await vr(e),a;try{a=JSON.parse(n)}catch(d){throw new Error(`Config ${r} is not valid JSON: ${d.message}`,{cause:d})}if(!te(a))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:s,...l}=a,c={};for(let d of Ar(s,r))c=re(c,await He(Cr(d,o),[...t,r]));return re(c,l)}i(He,"loadSource");function Fr(e,t=process.cwd()){return He({kind:"file",path:Oe(t,e)},[])}i(Fr,"loadConfigFile");async function Be(e,t){let r=typeof e[t]=="string"?e[t].trim():"";if(r.length===0)return e;let n=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Fr(r,n),...e};return delete o[t],o}i(Be,"applyConfigOption");import{join as wt,relative as Et,resolve as ue,sep as ce}from"node:path";import{realpath as ln,stat as un}from"node:fs/promises";import{extname as it}from"node:path";import{extname as Pr}from"node:path";var Ue=[".css"];function jr(e){let t=Pr(e).toLowerCase();return Ue.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(jr,"resolveCssCommentSyntax");var _e={id:"css",extensions:Ue,enabledByDefault:!0,resolveCommentSyntax(e){return jr(e)}};import{extname as Mr}from"node:path";var ze=[".go"];function Lr(e){let t=Mr(e).toLowerCase();return ze.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Lr,"resolveGoCommentSyntax");var Ye={id:"go",extensions:ze,enabledByDefault:!0,resolveCommentSyntax(e){return Lr(e)}};import{extname as Rr}from"node:path";var We=[".html",".htm"];function Ir(e){let t=Rr(e).toLowerCase();return We.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Ir,"resolveHtmlCommentSyntax");var Ge={id:"html",extensions:We,enabledByDefault:!0,resolveCommentSyntax(e){return Ir(e)}};import{extname as Or}from"node:path";var Ve=[".jsonv",".jsonc",".json5"];function Tr(e){let t=Or(e).toLowerCase();return Ve.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Tr,"resolveJsonCommentSyntax");var Je={id:"json",extensions:Ve,enabledByDefault:!0,resolveCommentSyntax(e){return Tr(e)}};import{extname as Hr}from"node:path";var Ke=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function Br(e){let t=Hr(e).toLowerCase();return Ke.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Br,"resolveNodeCommentSyntax");function Ur(e,t){let r=t.match(/^#!.*\b(node|bun|deno|tsx|ts-node)\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Ur,"resolveNodePreservedPrefix");var qe={id:"node",extensions:Ke,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Ur(e,t)},resolveCommentSyntax(e){return Br(e)}};import{extname as _r}from"node:path";var Xe=[".php"];function zr(e){let t=_r(e).toLowerCase();return Xe.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(zr,"resolvePhpCommentSyntax");var Ze={id:"php",extensions:Xe,enabledByDefault:!0,resolveCommentSyntax(e){return zr(e)}};import{extname as Yr}from"node:path";var Qe=[".py"];function Wr(e,t){let r=t.match(/^#!.*\bpython(?:\d+(?:\.\d+)*)?\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Wr,"resolvePythonPreservedPrefix");var et={id:"python",extensions:Qe,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Wr(e,t)},resolveCommentSyntax(e){let t=Yr(e).toLowerCase();return Qe.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Gr}from"node:path";var tt=[".rs"];function Vr(e){let t=Gr(e).toLowerCase();return tt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Vr,"resolveRustCommentSyntax");var rt={id:"rust",extensions:tt,enabledByDefault:!0,resolveCommentSyntax(e){return Vr(e)}};import{extname as Jr}from"node:path";var nt=[".yaml",".yml"];function Kr(e){let t=Jr(e).toLowerCase();return nt.includes(t)?{kind:"line",linePrefix:"#"}:null}i(Kr,"resolveYamlCommentSyntax");var ot={id:"yaml",extensions:nt,enabledByDefault:!0,resolveCommentSyntax(e){return Kr(e)}};var at=[_e,Ye,Ge,Je,qe,Ze,et,rt,ot],qo=new Map(at.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 P(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]);return at.filter(n=>t.size>0?t.has(n.id):r.has(n.id)?!1:n.enabledByDefault)}i(P,"getEnabledDetectors");function st(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=P(e);return new Set(t.flatMap(r=>r.extensions))}i(st,"getAllowedExtensions");function ct(e,t={}){let r=it(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:P(t);for(let o of n){if(!o.extensions.includes(r))continue;let a=o.resolveCommentSyntax(e);if(a){let s=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return qr(a,s[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(ct,"getCommentSyntaxForFile");function lt(e,t,r={}){let n=it(e).toLowerCase(),o=P(r);for(let a of o)if(a.extensions.includes(n))return typeof a.resolvePreservedPrefix=="function"?a.resolvePreservedPrefix(e,t):"";return""}i(lt,"getPreservedPrefixForFile");import{access as Xr,readdir as Zr,readFile as ei,stat as Qr}from"node:fs/promises";import{constants as en}from"node:fs";import{dirname as ni,join as tn,resolve as oi}from"node:path";async function ne(e){try{return await Xr(e,en.F_OK),!0}catch{return!1}}i(ne,"pathExists");async function oe(e,t){let r=[],n=await Zr(e,{withFileTypes:!0});for(let o of n){let a=tn(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(a,o.name)===!0)continue;if(o.isDirectory()){let c=await oe(a,t);r.push(...c);continue}if(!o.isFile())continue;let s=o.name.lastIndexOf(".");if(s===-1)continue;let l=o.name.slice(s).toLowerCase();t.allowedExtensions.has(l)&&r.push(a)}return r}i(oe,"walkFiles");async function ut(e){let t=await Qr(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(ut,"readFileDates");import{execFile as rn}from"node:child_process";import{lstat as nn,readFile as on}from"node:fs/promises";import{dirname as dt,isAbsolute as an,join as pt,relative as ht,resolve as ie,sep as gt}from"node:path";import sn from"ignore";function mt(e,t){return new Promise(r=>{rn("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(n,o)=>{if(!n){r({code:0,stdout:o});return}r({code:typeof n.code=="number"?n.code:-1,stdout:""})})})}i(mt,"runGitCommand");function se(e,t){return ht(e,t).split(gt).join("/")}i(se,"toPosixRelative");async function yt(e){try{return sn().add(await on(e,"utf8"))}catch{return null}}i(yt,"readIgnoreFile");async function cn(e){return nn(pt(e,".git")).then(()=>!0,()=>!1)}i(cn,"hasGitEntry");function ft(e,t,r){for(let n=e.length-1;n>=0;n--){let{base:o,rules:a}=e[n],s=a.test(`${se(o,t)}${r?"/":""}`);if(s.ignored||s.unignored)return s.ignored}return!1}i(ft,"matchesRules");async function xt(e,t){let r=await yt(pt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(xt,"buildRulesContext");async function ae(e){let[t,r]=await Promise.all([mt(e,["check-ignore","-q","."]),mt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||r.code!==0)return xt(e,[]);let n=new Set,o=new Set;for(let a of r.stdout.split("\0")){let s=a.endsWith("/")?a.slice(0,-1):a;if(s.length!==0){n.add(s);for(let l=s.indexOf("/");l!==-1;l=s.indexOf("/",l+1))o.add(s.slice(0,l))}}return{kind:"git",root:e,entries:n,dirs:o}}i(ae,"resolveScopeContext");function bt(e){let t=ie(e.root),r=e.gitignore;if(r===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let n=new Map,o=i(async()=>{if(typeof r!="string"&&!Array.isArray(r))return ae(t);let l=typeof r=="string"?[r]:r.filter(d=>typeof d=="string"),c=[];for(let d of l){let f=await yt(ie(t,d));f&&c.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:c}},"buildRootContext"),a=i(l=>{let c=n.get(l);return c||(c=l===t?o():s(l),n.set(l,c)),c},"contextFor"),s=i(async l=>{let c=await a(dt(l));return c.kind==="git"?c.entries.has(se(c.root,l))?ae(l):c:!c.nested||c.excluded?c:ft(c.matchers,l,!0)?{...c,excluded:!0}:await cn(l)?ae(l):xt(l,c.matchers)},"deriveContext");return{async isIgnored(l,c){let d=ie(l),f=ht(t,d);if(f.length===0||f===".."||f.startsWith(`..${gt}`)||an(f))return!1;let p=await a(dt(d));if(p.kind==="git"){let x=se(p.root,d);return!(p.entries.has(x)||c&&p.dirs.has(x))}return p.excluded||ft(p.matchers,d,c)}}}i(bt,"createIgnoreFilter");function dn(e){return st(e)}i(dn,"resolveExtensions");var St=new Set([".git"]);function le(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}i(le,"normalizeFolderPath");function mn(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(mn,"resolveIncludeFolders");function $t(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i($t,"reportSkippedIncludeFolder");function fn(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=ue(e),n=[],o=new Set;for(let a of t){if(typeof a!="string")continue;let s=le(a);if(s.length!==0){if(s.includes("/")){n.push(ue(r,s));continue}o.add(s)}}return(a,s)=>{if(o.has(s))return!0;for(let c of n)if(a===c||a.startsWith(`${c}/`))return!0;let l=le(Et(r,a));return n.some(c=>{let d=le(Et(r,c));return l===d||l.startsWith(`${d}/`)})}}i(fn,"buildExclusionMatcher");async function de(e){let t=dn(e),r=mn(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=fn(e.projectRoot,n),a=bt({root:e.projectRoot,gitignore:e.gitignore}),s=i(async(m,h)=>o(m,h)||await a.isIgnored(m,!0),"shouldSkipDirectory"),l=r.length>0?r.map(m=>({includeFolder:m.path,rootPath:wt(e.projectRoot,m.path),recursive:m.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],c=[];for(let m of l){let h=await un(m.rootPath).catch(S=>S);if(h instanceof Error){if(h.code==="ENOENT"){$t(m.includeFolder,h);continue}throw h}if(!h.isDirectory()){$t(m.includeFolder,`path is not a directory: ${m.rootPath}`);continue}let w=await ln(m.rootPath).catch(()=>ue(m.rootPath));c.push({...m,realRoot:w})}let d=i((m,h)=>{if(m.realRoot===h.realRoot)return m.recursive||!h.recursive;let w=m.realRoot.endsWith(ce)?m.realRoot:`${m.realRoot}${ce}`;if(!m.recursive||!h.realRoot.startsWith(w))return!1;let S=m.rootPath;for(let D of h.realRoot.slice(w.length).split(ce))if(S=wt(S,D),St.has(D)||o(S,D))return!1;return!0},"covers"),f=[...c].sort((m,h)=>m.realRoot.length-h.realRoot.length||Number(h.recursive)-Number(m.recursive)),p=[];for(let m of f)p.some(h=>d(h,m))||p.push(m);let x=[];for(let m of c){if(!p.includes(m))continue;let h=await oe(m.rootPath,{allowedExtensions:t,ignoreFolders:St,shouldSkipDirectory:s,recursive:m.recursive});x.push(...h)}let y=[];for(let m of new Set(x))!o(m,m.split("/").at(-1)||"")&&!await a.isIgnored(m,!1)&&y.push(m);return y}i(de,"discoverFiles");import{basename as In,dirname as On,extname as Tn,resolve as ge}from"node:path";import{dirname as Rt,isAbsolute as kn,join as It,relative as Dn,resolve as Ot,sep as Nn}from"node:path";import{readFile as pn}from"node:fs/promises";import{join as hn}from"node:path";async function gn(e){try{return await pn(e,"utf8")}catch{return null}}i(gn,"readManifest");async function $(e,t){let r=[];for(let n of t){let o=await gn(hn(e,n));o!==null&&r.push({file:n,content:o})}return r.length>0?{dir:e,manifest:r[0].file,files:r}:null}i($,"detectManifests");function C(e,t){return e.files.find(r=>r.file===t)?.content??null}i(C,"manifestContent");function b(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(b,"cleanName");function me(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return b(t===-1?e:e.slice(0,t))}i(me,"personName");function Y(e){try{return JSON.parse(e)}catch{return}}i(Y,"parseJsonManifest");function*fe(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let a=o.match(/^\[([^[\]]+)\]/);r=a?a[1].split(".").map(s=>s.trim()).join("."):"";continue}r===t&&(yield o)}}i(fe,"sectionLines");function L(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of fe(e,t)){let a=o.match(n);if(a)return b(a[1]??a[2])}}i(L,"readTomlString");function pe(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of fe(e,t)){let a=o.match(n);if(a)return b(a[1])}}i(pe,"readIniValue");function yn(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let a of fe(e,t)){if(o!==null){o.push(a);continue}let s=a.match(n);s&&(o=[a.slice(s[0].length)])}return o===null?null:o.join(`
2
- `)}i(yn,"tomlArrayText");function xn(e,t){let r=t;for(;r<e.length;)if(e[r]==="#"){let n=e.indexOf(`
3
- `,r);r=n===-1?e.length:n+1}else if(/\s/.test(e[r]))r+=1;else break;return r}i(xn,"skipTomlSpace");function R(e,t){let r=yn(e,t,"authors");if(r===null)return;let n=r.slice(xn(r,0)),o=n.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return me(o[1]??o[2]);let s=n.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return s?b(s[1]??s[2]):void 0}i(R,"readTomlAuthor");var kt=["go.mod"];function bn(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return b(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(bn,"readModulePath");var Dt={id:"go",languages:["go"],manifests:kt,detect(e){return $(e,kt)},read(e){return{name:bn(e.files[0].content)}}};var Nt=["package.json"];function wn(e){let t=b(e?.name),r=b(e?.publisher),n=typeof e?.engines?.vscode=="string";return t&&r&&n?`${r}.${t}`:t}i(wn,"readPublishedName");function En(e){if(e!==null&&typeof e=="object"){let t=e;return b(t.company)??b(t.name)}return me(e)}i(En,"readAuthorCompany");var vt={id:"node",languages:["node"],manifests:Nt,detect(e){return $(e,Nt)},read(e){let t=Y(e.files[0].content);return{name:wn(t),company:En(t?.author)}}};var Ct=["composer.json"],At={id:"php",languages:["php"],manifests:Ct,detect(e){return $(e,Ct)},read(e){let t=Y(e.files[0].content),r=t?.authors;return{name:b(t?.name),company:Array.isArray(r)?b(r[0]?.name):void 0}}};var Ft=["pyproject.toml","setup.cfg","setup.py"];function Pt(e,t){let r=e.indexOf("setup(");if(r===-1)return;let n=e.slice(r).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return n&&n[2].trim()||void 0}i(Pt,"readSetupPyArgument");function Sn(e){let t=C(e,"pyproject.toml"),r=C(e,"setup.cfg"),n=C(e,"setup.py");return(t===null?void 0:L(t,"project","name")??L(t,"tool.poetry","name"))??(r===null?void 0:pe(r,"metadata","name"))??(n===null?void 0:Pt(n,"name"))}i(Sn,"readPythonName");function $n(e){let t=C(e,"pyproject.toml"),r=C(e,"setup.cfg"),n=C(e,"setup.py");return(t===null?void 0:R(t,"project")??R(t,"tool.poetry"))??(r===null?void 0:pe(r,"metadata","author"))??(n===null?void 0:Pt(n,"author"))}i($n,"readPythonCompany");var jt={id:"python",languages:["python"],manifests:Ft,detect(e){return $(e,Ft)},read(e){return{name:Sn(e),company:$n(e)}}};var Mt=["Cargo.toml"],Lt={id:"rust",languages:["rust"],manifests:Mt,detect(e){return $(e,Mt)},read(e){let t=e.files[0].content;return{name:L(t,"package","name"),company:R(t,"package")}}};var vn=[vt,jt,At,Lt,Dt],Tt=["name","company"];async function he(e,t,r){let o=(await Promise.all(t.map(async s=>({driver:s,detection:await s.detect(e)})))).filter(s=>s.detection!==null),a=o.filter(s=>typeof r=="string"&&s.driver.languages.includes(r));return[...a,...o.filter(s=>!a.includes(s))]}i(he,"claimFolder");function Cn(e,t){let r=Dn(t,e);return r!==""&&r!==".."&&!r.startsWith(`..${Nn}`)&&!kn(r)}i(Cn,"isStrictlyInside");async function Ht(e,t={}){let r=Array.isArray(t.drivers)?t.drivers:vn,n=typeof t.scanRoot=="string"?Ot(t.scanRoot):null,o=Ot(e),a=await he(o,r,t.language);for(;a.length===0;){if(await ne(It(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=Rt(o);if(f===o)return null;o=f,a=await he(o,r,t.language)}let s={},l={},c=o,d=a;for(;;){for(let{driver:p,detection:x}of d){let y=p.read(x);for(let m of Tt)s[m]===void 0&&y[m]!==void 0&&(s[m]=y[m],l[m]={driver:p.id,manifest:x.manifest,dir:c})}if(Tt.every(p=>s[p]!==void 0)||n===null||!Cn(c,n)||await ne(It(c,".git")))break;c=Rt(c),d=await he(c,r,t.language)}return{root:o,marker:a[0].detection.manifest,drivers:a.map(f=>f.driver.id),fields:s,sources:l}}i(Ht,"resolveManifestProject");import{execFile as An}from"node:child_process";import{promisify as Fn}from"node:util";var Ut=Fn(An);async function k(e,t){try{let{stdout:r}=await Ut("git",t,{cwd:e}),n=r.trim();return n.length>0?n:null}catch{return null}}i(k,"runGit");function Bt(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}i(Bt,"isEscaped");function Pn(e){let t=e.trim();if(!t.endsWith(")")||Bt(t,t.length-1))return t;let r=0;for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(o!=="("&&o!==")"||Bt(t,n))&&(r+=o===")"?1:-1,r===0))return t.slice(0,n).trim()}return t}i(Pn,"stripUidComment");function jn(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let r=t.match(/<([^>\n]+)>\s*$/),n=r?.[1]?.trim()||null,o=(r?t.slice(0,r.index):t).trim();return{authorName:Pn(o)||o||null,authorEmail:n}}i(jn,"parseSignerUid");async function Mn(e,t){try{let{stdout:r}=await Ut(e,t),n=r.trim();return n.length>0?n:null}catch{return null}}i(Mn,"runProgram");function Ln(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)))}i(Ln,"decodeColonField");async function Rn(e){let t=await k(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let r=await k(e,["config","--get","user.signingkey"]);if(!r)return null;let n=await k(e,["config","--get","gpg.openpgp.program"])||await k(e,["config","--get","gpg.program"])||"gpg",o=await Mn(n,["--batch","--with-colons","--list-keys",r]);if(!o)return null;for(let a of o.split(`
4
- `)){let s=a.split(":");if(s[0]==="uid"&&s[1]!=="r"&&s[1]!=="e"&&s[9])return Ln(s[9])}return null}i(Rn,"readSigningKeyUid");async function _t(e,t={}){let r=await k(e,["config","--get","user.name"]),n=await k(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Rn(e)||await k(e,["log","-1","--format=%GS"]),a=jn(o||"");r=a.authorName||r,n=n||a.authorEmail}if(!r||!n){let o=await k(e,["log","-1","--format=%an|%ae"]);if(o){let[a,s]=o.split("|");r=r||a||null,n=n||s||null}}return{authorName:r,authorEmail:n}}i(_t,"detectGitAuthor");function zt(e){return e.replace(/z$/i,"+00:00")}i(zt,"canonicalGitDate");async function Yt(e,t){let r=await k(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!r)return null;let n=r.split(`
5
- `)[0],[o,a]=n.split("|");if(!o||!a)return null;let s=Number.parseInt(a,10);return Number.isNaN(s)?null:{date:zt(o),timestamp:s}}i(Yt,"getGitCreationDate");async function Wt(e,t){let r=await k(e,["log","-1","--format=%aI|%at","--",t]);if(!r)return null;let[n,o]=r.split("|");if(!n||!o)return null;let a=Number.parseInt(o,10);return Number.isNaN(a)?null:{date:zt(n),timestamp:a}}i(Wt,"getGitLastModifiedDate");function Hn(e){return In(e)||"project"}i(Hn,"folderName");function Bn(e,t){if(typeof t!="string")return e;let r=t.trim();return r.length===0||/<[^>]+>/.test(e)?e:`${e} <${r}>`}i(Bn,"formatAuthorNameWithCompany");async function Un(e,t={}){let r=Array.isArray(t.detectors)?t.detectors:P(t),n=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=n.length>0?r.find(d=>d.extensions.includes(n)):void 0,a=await Ht(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),s=a?a.root:ge(e),l=a?.sources.name,c=a?.sources.company;return{language:o?.id??a?.drivers[0]??"unknown",rootDir:s,marker:a?a.marker:null,projectName:a?.fields.name??Hn(s),projectNameSource:l?{from:"manifest",...l}:{from:"folder",dir:s},companyName:a?.fields.company??null,companyNameSource:c?{from:"manifest",...c}:{from:"none"},drivers:a?a.drivers:[]}}i(Un,"detectProjectFromMarkers");async function ye(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),r=ge(t),n=P(e),o=e.targetFilePath?On(r):r,a=e.targetFilePath?Tn(r).toLowerCase():"",s=ge(e.projectRoot||e.cwd||process.cwd()),l=await Un(o,{detectors:n,preferredExtension:a,scanRoot:s}),c=await _t(l.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),d=e.authorName||c.authorName||"Unknown Author",f=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||l.projectName,projectNameSource:e.projectName?{from:"option"}:l.projectNameSource,language:e.language||l.language,projectRoot:e.projectRoot||l.rootDir,marker:e.marker===void 0?l.marker:e.marker,authorName:Bn(d,e.company),authorEmail:e.authorEmail||c.authorEmail||"unknown@example.com",companyName:f||l.companyName,companyNameSource:f?{from:"option"}:l.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}i(ye,"resolveProjectMetadata");function _n(e){return xe({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(_n,"formatDateWithTimezone");function xe(e){return`${Kt(e," ")} ${qt(e.offsetMinutes)}`}i(xe,"formatSpaceDate");function Vt(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{Jt(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(Vt,"assertTimeZone");var Gt=new Map;function Jt(e){let t=Gt.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"}),Gt.set(e,t)),t}i(Jt,"getZoneFormatter");function be(e,t){let r={};for(let o of Jt(t).formatToParts(new Date(e*1e3)))r[o.type]=Number(o.value);let n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)/1e3;return{year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute,second:r.second,offsetMinutes:(n-e)/60}}i(be,"toZonedDateParts");function Kt(e,t){let r=i(n=>String(n).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${r(e.month)}-${r(e.day)}${t}${r(e.hour)}:${r(e.minute)}:${r(e.second)}`}i(Kt,"formatWallClock");function qt(e){let t=i(n=>String(n).padStart(2,"0"),"pad"),r=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(r/60))}:${t(r%60)}`}i(qt,"formatOffset");function W(e=new Date){return{date:_n(e),timestamp:Math.floor(e.getTime()/1e3)}}i(W,"toDatePayload");var zn=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function A(e){let t=zn.exec(e.trim());if(!t)return null;let[r,n,o,a,s,l]=t.slice(1,7).map(Number),c=t[7]?0:Number(t[9])*60+Number(t[10]),d=t[8]==="-"?-c:c,f=new Date(Date.UTC(r,n-1,o,a,s,l));return!(f.getUTCFullYear()===r&&f.getUTCMonth()===n-1&&f.getUTCDate()===o&&f.getUTCHours()===a&&f.getUTCMinutes()===s&&f.getUTCSeconds()===l)||Number(t[10]??0)>59?null:{year:r,month:n,day:o,hour:a,minute:s,second:l,offsetMinutes:d,timestamp:Math.floor(f.getTime()/1e3)-d*60}}i(A,"parseHeaderDate");function we(e){return`${Kt(e,"T")}${qt(e.offsetMinutes)}`}i(we,"formatIsoDate");var Yn={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function Xt(e,t){let r=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return r?r[1].trim():null}i(Xt,"readHeaderField");function Ee(e){let t=null;for(let{source:r,payload:n}of e)n&&(!t||n.timestamp<t.payload.timestamp)&&(t={source:r,payload:n});return t}i(Ee,"pickOldestDate");function Qt({existing:e,gitCreated:t,filesystemCreated:r,fixCreatedDate:n=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:r}];if(!e)return Ee(o);if(!n)return{source:"existing-header",payload:e};let a=A(e.date)?e:null;return Ee([{source:"existing-header",payload:a},...o])}i(Qt,"resolveCreatedDate");function er(e,t=null){if(t)return be(e.timestamp,t).year;let r=A(e.date);return r?r.year:new Date(e.timestamp*1e3).getFullYear()}i(er,"dateYear");function Zt(e,t,r,n){let o=e.match(/^(.+?)\s*\((\d+)\)$/),a=o?A(o[1]):null;if(!o||!a)return n.push({check:`${r}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let s=Number.parseInt(o[2],10);return s!==a.timestamp&&n.push({check:`${r}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${a.timestamp})`,message:`${t} epoch ${s} does not match ${o[1]} (expected ${a.timestamp})`}),{text:o[1],timestamp:a.timestamp}}i(Zt,"checkDateValue");function tr(e,t={},r={}){let n=[],o=Xt(e,"@Date"),a=o===null?null:Zt(o,"@Date","created",n),s=Ee([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(a&&s&&a.timestamp>s.payload.timestamp){let f=Yn[s.source];n.push({check:"created-newer-than-source",field:"@Date",advisory:r.strictCreatedDate!==!0,value:o,expected:`${s.payload.date} (${s.payload.timestamp})`,source:s.source,message:`@Date ${a.text} is later than the ${f} ${s.payload.date} (${s.payload.timestamp})`})}let l=Xt(e,"@Last modified time"),c=l===null?null:Zt(l,"@Last modified time","modified",n),d=t.gitLastModified;return c&&d&&c.timestamp!==d.timestamp&&n.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:l,expected:`${d.date} (${d.timestamp})`,message:`@Last modified time ${c.text} does not match the git last commit ${d.date} (${d.timestamp})`}),n}i(tr,"checkHeaderDates");function Se(e){if(!e)return null;let t=A(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i(Se,"repairDateEpoch");function rr(e){let t=A(e.date);return t?{date:we(t),timestamp:t.timestamp}:e}i(rr,"normalizeDatePayload");function nr(e,t){let r=A(e.date);if(!r)return e;let n=be(r.timestamp,t);return n.offsetMinutes===r.offsetMinutes||!Number.isInteger(n.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?we(n):xe(n),timestamp:r.timestamp}}i(nr,"convertDatePayload");import{relative as Gn}from"node:path";import{extname as Wn}from"node:path";function G(e,t={}){return Wn(e).toLowerCase().length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:ct(e,t)}i(G,"getHeaderSyntaxForFile");function or(e,t){if(e.kind==="line"){let a=typeof e.lineSeparator=="string"?e.lineSeparator:" ";return t.map(s=>`${e.linePrefix||"#"}${a}${s}`).join(`
6
- `)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),n=e.blockLinePrefix||(e.kind==="html"?" ":" * "),o=e.blockEnd||(e.kind==="html"?"-->":" */");return e.kind==="html"?`${r}
7
- ${t.map(a=>`${n}${a}`).join(`
8
- `)}
9
- ${o}`:`${r}
10
- ${t.map(a=>`${n}${a}`).join(`
11
- `)}
12
- ${o}`}i(or,"renderHeaderLines");function $e(e){let t=`/${Gn(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,r=G(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),n=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,a=e.lastModifiedByName||e.authorName,s=e.lastModifiedByEmail||e.authorEmail,l=typeof e.companyName=="string"?e.companyName.trim():"",c=l.length>0?`${l} `:"",d=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${n}`,`@Email: <${o}>`,"-----",`@Last modified by: ${a} (${s})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${c}All rights reserved.`];return or(r,d)}i($e,"buildHeader");var Vn=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function N(e,t){let r=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),n=r?r[1].trim():"";return n.length>0?n:null}i(N,"readTag");function Jn(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),r=t.indexOf("(",t.lastIndexOf(")")+1);return r===-1?{name:e,email:null}:{name:t.slice(0,r).trimEnd()||null,email:t.slice(r+1)||null}}i(Jn,"splitLastModifiedBy");function Kn(e){let t={startYear:null,endYear:null,companyName:null},r=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!r)return t;let n=e.slice(r[0].length),o=n.match(/^\s*-\s*(\d{4})/);o&&(n=n.slice(o[0].length));let a=n.toLowerCase(),s=a.endsWith("all rights reserved.")?20:a.endsWith("all rights reserved")?19:0;return s===0||!/^\s/.test(n)?t:{startYear:r[1],endYear:o?o[1]:null,companyName:n.slice(0,-s).trim()||null}}i(Kn,"splitCopyright");function ir(e){let t=Jn(N(e,"Last modified by")),r=Kn(N(e,"Copyright")),n=N(e,"Email");return{projectName:N(e,"Project"),filename:N(e,"Filename"),createdAt:N(e,"Date"),authorName:N(e,"Author"),authorEmail:n===null?null:n.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:N(e,"Last modified time"),copyrightStartYear:r.startYear,copyrightEndYear:r.endYear,companyName:r.companyName}}i(ir,"parseHeaderFields");function ar(e,t){let r=ir(e??""),n=ir(t);return Vn.filter(o=>r[o]!==n[o]).map(o=>({field:o,previous:r[o],detected:n[o]}))}i(ar,"compareHeaderFields");var sr=200;function V(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(V,"escapeRegex");function lr(e,t,r={}){let n=lt(e,t,r);return n.length===0?{prefix:"",body:t}:{prefix:n,body:t.slice(n.length)}}i(lr,"splitPreservedPrefix");function cr(e,t){if(t.kind==="html"){let n=V(t.blockStart||"<!--"),o=V(t.blockEnd||"-->");return e.match(new RegExp(`^${n}[\\s\\S]*?${o}\\n*`))}if(t.kind==="line"){let n=V(t.linePrefix||"#");return e.match(new RegExp(`^(?:${n}.*\\n)+\\n*`))}let r=V((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${r}\\n*`))}i(cr,"matchHeaderSegment");function ke(e,t="",r={}){let{prefix:n,body:o}=lr(t,e,r),a=o.split(`
13
- `).slice(0,sr).join(`
14
- `),s=G(t,r);if(!cr(a,s))return null;let c=0,d=0;for(;;){let f=a.slice(c),p=cr(f,s);if(!p||!p[0].includes("@Project:"))break;c+=p[0].length,d=c}return d===0?null:{start:n.length,end:n.length+d}}i(ke,"findProjectHeader");function De(e,t,r="",n={}){let o=ke(e,r,n);if(!o){let{prefix:c,body:d}=lr(r,e,n),f=`${c}${t}
15
-
16
- ${d.replace(/^\n+/,"")}`;return{nextContent:f,changed:f!==e}}let a=e.slice(0,o.start),s=e.slice(o.end).replace(/^\n+/,""),l=`${a}${t}
17
-
18
- ${s}`;return{nextContent:l,changed:l!==e}}i(De,"replaceOrInsertHeader");function qn(e,t){let r=e.length,n=t.length,o=Array.from({length:r+1},()=>new Array(n+1).fill(0));for(let c=r-1;c>=0;c-=1)for(let d=n-1;d>=0;d-=1)o[c][d]=e[c]===t[d]?o[c+1][d+1]+1:Math.max(o[c+1][d],o[c][d+1]);let a=[],s=0,l=0;for(;s<r&&l<n;)e[s]===t[l]?(a.push({type:" ",line:e[s]}),s+=1,l+=1):o[s+1][l]>=o[s][l+1]?(a.push({type:"-",line:e[s]}),s+=1):(a.push({type:"+",line:t[l]}),l+=1);for(;s<r;s+=1)a.push({type:"-",line:e[s]});for(;l<n;l+=1)a.push({type:"+",line:t[l]});return a}i(qn,"diffLines");function ur(e,t){return`${t===0?e:e+1},${t}`}i(ur,"formatRange");function dr(e,t,r={}){let n=e===null?[]:e.split(`
1
+ var Dr=Object.defineProperty;var i=(e,t)=>Dr(e,"name",{value:t,configurable:!0});import{readFile as eo,stat as to,writeFile as ro}from"node:fs/promises";import{relative as gr,resolve as hr}from"node:path";import{readFile as Nr}from"node:fs/promises";import{createRequire as kr}from"node:module";import{dirname as $r,isAbsolute as Ar,resolve as _e}from"node:path";var Cr=3e4,vr=new Set(["localhost","127.0.0.1","[::1]"]);function oe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(oe,"isPlainObject");function ie(e,t){let r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=oe(r[n])&&oe(o)?ie(r[n],o):o);return r}i(ie,"mergeConfig");function Ue(e){return e.kind==="file"?e.path:e.href}i(Ue,"describeSource");async function Fr(e){if(e.kind==="file")return{text:await Nr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(Cr)})}catch(r){let n=r.cause instanceof Error?r.cause.message:r.message;throw new Error(`Failed to fetch config ${e.href}: ${n}`,{cause:r})}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(Fr,"readSource");function He(e){if(e.protocol==="http:"&&!vr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(He,"toUrlSource");function Lr(e,t){if(/^https?:\/\//i.test(e))return He(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${Ue(t)}; use https, a file path or a package path`);let r=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(r||e.startsWith("/"))return He(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(r||Ar(e))return{kind:"file",path:_e($r(t.path),e)};try{return{kind:"file",path:kr(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(Lr,"resolveReference");function Pr(e,t){if(e===void 0)return[];let r=Array.isArray(e)?e:[e];if(!r.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return r.map(n=>n.trim())}i(Pr,"readExtends");async function Be(e,t){let r=Ue(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await Fr(e),a;try{a=JSON.parse(n)}catch(m){throw new Error(`Config ${r} is not valid JSON: ${m.message}`,{cause:m})}if(!oe(a))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:s,...c}=a,l={};for(let m of Pr(s,r))l=ie(l,await Be(Lr(m,o),[...t,r]));return ie(l,c)}i(Be,"loadSource");function Mr(e,t=process.cwd()){return Be({kind:"file",path:_e(t,e)},[])}i(Mr,"loadConfigFile");async function ze(e,t){let r=typeof e[t]=="string"?e[t].trim():"";if(r.length===0)return e;let n=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Mr(r,n),...e};return delete o[t],o}i(ze,"applyConfigOption");import{extname as ct}from"node:path";import{extname as jr}from"node:path";var Ye=[".css"];function Rr(e){let t=jr(e).toLowerCase();return Ye.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Rr,"resolveCssCommentSyntax");var Ge={id:"css",extensions:Ye,enabledByDefault:!0,resolveCommentSyntax(e){return Rr(e)}};import{extname as Ir}from"node:path";var We=[".go"];function Tr(e){let t=Ir(e).toLowerCase();return We.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Tr,"resolveGoCommentSyntax");var Ve={id:"go",extensions:We,enabledByDefault:!0,resolveCommentSyntax(e){return Tr(e)}};import{extname as Or}from"node:path";var Je=[".html",".htm"];function Hr(e){let t=Or(e).toLowerCase();return Je.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Hr,"resolveHtmlCommentSyntax");var Ke={id:"html",extensions:Je,enabledByDefault:!0,resolveCommentSyntax(e){return Hr(e)}};import{extname as _r}from"node:path";var qe=[".jsonv",".jsonc",".json5"];function Ur(e){let t=_r(e).toLowerCase();return qe.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Ur,"resolveJsonCommentSyntax");var Xe={id:"json",extensions:qe,enabledByDefault:!0,resolveCommentSyntax(e){return Ur(e)}};import{extname as Br}from"node:path";var Ze=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function zr(e){let t=Br(e).toLowerCase();return Ze.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(zr,"resolveNodeCommentSyntax");function Yr(e,t){let r=t.match(/^#!.*\b(node|bun|deno|tsx|ts-node)\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Yr,"resolveNodePreservedPrefix");var Qe={id:"node",extensions:Ze,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Yr(e,t)},resolveCommentSyntax(e){return zr(e)}};import{extname as Gr}from"node:path";var et=[".php"];function Wr(e){let t=Gr(e).toLowerCase();return et.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Wr,"resolvePhpCommentSyntax");var tt={id:"php",extensions:et,enabledByDefault:!0,resolveCommentSyntax(e){return Wr(e)}};import{extname as Vr}from"node:path";var rt=[".py"];function Jr(e,t){let r=t.match(/^#!.*\bpython(?:\d+(?:\.\d+)*)?\b.*(?:\r?\n|$)/);return r?r[0]:""}i(Jr,"resolvePythonPreservedPrefix");var nt={id:"python",extensions:rt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Jr(e,t)},resolveCommentSyntax(e){let t=Vr(e).toLowerCase();return rt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Kr}from"node:path";var ot=[".rs"];function qr(e){let t=Kr(e).toLowerCase();return ot.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(qr,"resolveRustCommentSyntax");var it={id:"rust",extensions:ot,enabledByDefault:!0,resolveCommentSyntax(e){return qr(e)}};import{extname as Xr}from"node:path";var at=[".yaml",".yml"];function Zr(e){let t=Xr(e).toLowerCase();return at.includes(t)?{kind:"line",linePrefix:"#"}:null}i(Zr,"resolveYamlCommentSyntax");var st={id:"yaml",extensions:at,enabledByDefault:!0,resolveCommentSyntax(e){return Zr(e)}};var lt=[Ge,Ve,Ke,Xe,Qe,tt,nt,it,st],Qo=new Map(lt.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 P(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]);return lt.filter(n=>t.size>0?t.has(n.id):r.has(n.id)?!1:n.enabledByDefault)}i(P,"getEnabledDetectors");function ut(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=P(e);return new Set(t.flatMap(r=>r.extensions))}i(ut,"getAllowedExtensions");function mt(e,t={}){let r=ct(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:P(t);for(let o of n){if(!o.extensions.includes(r))continue;let a=o.resolveCommentSyntax(e);if(a){let s=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return Qr(a,s[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(mt,"getCommentSyntaxForFile");function dt(e,t,r={}){let n=ct(e).toLowerCase(),o=P(r);for(let a of o)if(a.extensions.includes(n))return typeof a.resolvePreservedPrefix=="function"?a.resolvePreservedPrefix(e,t):"";return""}i(dt,"getPreservedPrefixForFile");var ft=200,R=1,V=2;function C(e,t,r){if(e==null)return r;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(C,"resolveLayoutCount");import{join as Nt,relative as kt,resolve as fe,sep as me}from"node:path";import{realpath as dn,stat as fn}from"node:fs/promises";import{access as en,readdir as tn,readFile as ii,stat as rn}from"node:fs/promises";import{constants as nn}from"node:fs";import{dirname as ci,join as on,resolve as li}from"node:path";async function ae(e){try{return await en(e,nn.F_OK),!0}catch{return!1}}i(ae,"pathExists");async function se(e,t){let r=[],n=await tn(e,{withFileTypes:!0});for(let o of n){let a=on(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(a,o.name)===!0)continue;if(o.isDirectory()){let l=await se(a,t);r.push(...l);continue}if(!o.isFile())continue;let s=o.name.lastIndexOf(".");if(s===-1)continue;let c=o.name.slice(s).toLowerCase();t.allowedExtensions.has(c)&&r.push(a)}return r}i(se,"walkFiles");async function pt(e){let t=await rn(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(pt,"readFileDates");import{execFile as an}from"node:child_process";import{lstat as sn,readFile as cn}from"node:fs/promises";import{dirname as gt,isAbsolute as ln,join as xt,relative as bt,resolve as ce,sep as wt}from"node:path";import un from"ignore";function ht(e,t){return new Promise(r=>{an("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(n,o)=>{if(!n){r({code:0,stdout:o});return}r({code:typeof n.code=="number"?n.code:-1,stdout:""})})})}i(ht,"runGitCommand");function ue(e,t){return bt(e,t).split(wt).join("/")}i(ue,"toPosixRelative");async function Et(e){try{return un().add(await cn(e,"utf8"))}catch{return null}}i(Et,"readIgnoreFile");async function mn(e){return sn(xt(e,".git")).then(()=>!0,()=>!1)}i(mn,"hasGitEntry");function yt(e,t,r){for(let n=e.length-1;n>=0;n--){let{base:o,rules:a}=e[n],s=a.test(`${ue(o,t)}${r?"/":""}`);if(s.ignored||s.unignored)return s.ignored}return!1}i(yt,"matchesRules");async function St(e,t){let r=await Et(xt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(St,"buildRulesContext");async function le(e){let[t,r]=await Promise.all([ht(e,["check-ignore","-q","."]),ht(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||r.code!==0)return St(e,[]);let n=new Set,o=new Set;for(let a of r.stdout.split("\0")){let s=a.endsWith("/")?a.slice(0,-1):a;if(s.length!==0){n.add(s);for(let c=s.indexOf("/");c!==-1;c=s.indexOf("/",c+1))o.add(s.slice(0,c))}}return{kind:"git",root:e,entries:n,dirs:o}}i(le,"resolveScopeContext");function Dt(e){let t=ce(e.root),r=e.gitignore;if(r===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let n=new Map,o=i(async()=>{if(typeof r!="string"&&!Array.isArray(r))return le(t);let c=typeof r=="string"?[r]:r.filter(m=>typeof m=="string"),l=[];for(let m of c){let f=await Et(ce(t,m));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),a=i(c=>{let l=n.get(c);return l||(l=c===t?o():s(c),n.set(c,l)),l},"contextFor"),s=i(async c=>{let l=await a(gt(c));return l.kind==="git"?l.entries.has(ue(l.root,c))?le(c):l:!l.nested||l.excluded?l:yt(l.matchers,c,!0)?{...l,excluded:!0}:await mn(c)?le(c):St(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let m=ce(c),f=bt(t,m);if(f.length===0||f===".."||f.startsWith(`..${wt}`)||ln(f))return!1;let p=await a(gt(m));if(p.kind==="git"){let x=ue(p.root,m);return!(p.entries.has(x)||l&&p.dirs.has(x))}return p.excluded||yt(p.matchers,m,l)}}}i(Dt,"createIgnoreFilter");function pn(e){return ut(e)}i(pn,"resolveExtensions");var $t=new Set([".git"]);function de(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}i(de,"normalizeFolderPath");function gn(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(gn,"resolveIncludeFolders");function At(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i(At,"reportSkippedIncludeFolder");function hn(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=fe(e),n=[],o=new Set;for(let a of t){if(typeof a!="string")continue;let s=de(a);if(s.length!==0){if(s.includes("/")){n.push(fe(r,s));continue}o.add(s)}}return(a,s)=>{if(o.has(s))return!0;for(let l of n)if(a===l||a.startsWith(`${l}/`))return!0;let c=de(kt(r,a));return n.some(l=>{let m=de(kt(r,l));return c===m||c.startsWith(`${m}/`)})}}i(hn,"buildExclusionMatcher");async function pe(e){let t=pn(e),r=gn(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=hn(e.projectRoot,n),a=Dt({root:e.projectRoot,gitignore:e.gitignore}),s=i(async(d,g)=>o(d,g)||await a.isIgnored(d,!0),"shouldSkipDirectory"),c=r.length>0?r.map(d=>({includeFolder:d.path,rootPath:Nt(e.projectRoot,d.path),recursive:d.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let d of c){let g=await fn(d.rootPath).catch(S=>S);if(g instanceof Error){if(g.code==="ENOENT"){At(d.includeFolder,g);continue}throw g}if(!g.isDirectory()){At(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let w=await dn(d.rootPath).catch(()=>fe(d.rootPath));l.push({...d,realRoot:w})}let m=i((d,g)=>{if(d.realRoot===g.realRoot)return d.recursive||!g.recursive;let w=d.realRoot.endsWith(me)?d.realRoot:`${d.realRoot}${me}`;if(!d.recursive||!g.realRoot.startsWith(w))return!1;let S=d.rootPath;for(let k of g.realRoot.slice(w.length).split(me))if(S=Nt(S,k),$t.has(k)||o(S,k))return!1;return!0},"covers"),f=[...l].sort((d,g)=>d.realRoot.length-g.realRoot.length||Number(g.recursive)-Number(d.recursive)),p=[];for(let d of f)p.some(g=>m(g,d))||p.push(d);let x=[];for(let d of l){if(!p.includes(d))continue;let g=await se(d.rootPath,{allowedExtensions:t,ignoreFolders:$t,shouldSkipDirectory:s,recursive:d.recursive});x.push(...g)}let h=[];for(let d of new Set(x))!o(d,d.split("/").at(-1)||"")&&!await a.isIgnored(d,!1)&&h.push(d);return h}i(pe,"discoverFiles");import{basename as Hn,dirname as _n,extname as Un,resolve as be}from"node:path";import{dirname as Ht,isAbsolute as An,join as _t,relative as Cn,resolve as Ut,sep as vn}from"node:path";import{readFile as yn}from"node:fs/promises";import{join as xn}from"node:path";async function bn(e){try{return await yn(e,"utf8")}catch{return null}}i(bn,"readManifest");async function D(e,t){let r=[];for(let n of t){let o=await bn(xn(e,n));o!==null&&r.push({file:n,content:o})}return r.length>0?{dir:e,manifest:r[0].file,files:r}:null}i(D,"detectManifests");function v(e,t){return e.files.find(r=>r.file===t)?.content??null}i(v,"manifestContent");function b(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(b,"cleanName");function ge(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return b(t===-1?e:e.slice(0,t))}i(ge,"personName");function J(e){try{return JSON.parse(e)}catch{return}}i(J,"parseJsonManifest");function*he(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let a=o.match(/^\[([^[\]]+)\]/);r=a?a[1].split(".").map(s=>s.trim()).join("."):"";continue}r===t&&(yield o)}}i(he,"sectionLines");function I(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of he(e,t)){let a=o.match(n);if(a)return b(a[1]??a[2])}}i(I,"readTomlString");function ye(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of he(e,t)){let a=o.match(n);if(a)return b(a[1])}}i(ye,"readIniValue");function wn(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let a of he(e,t)){if(o!==null){o.push(a);continue}let s=a.match(n);s&&(o=[a.slice(s[0].length)])}return o===null?null:o.join(`
2
+ `)}i(wn,"tomlArrayText");function En(e,t){let r=t;for(;r<e.length;)if(e[r]==="#"){let n=e.indexOf(`
3
+ `,r);r=n===-1?e.length:n+1}else if(/\s/.test(e[r]))r+=1;else break;return r}i(En,"skipTomlSpace");function T(e,t){let r=wn(e,t,"authors");if(r===null)return;let n=r.slice(En(r,0)),o=n.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return ge(o[1]??o[2]);let s=n.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return s?b(s[1]??s[2]):void 0}i(T,"readTomlAuthor");var Ct=["go.mod"];function Sn(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return b(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(Sn,"readModulePath");var vt={id:"go",languages:["go"],manifests:Ct,detect(e){return D(e,Ct)},read(e){return{name:Sn(e.files[0].content)}}};var Ft=["package.json"];function Dn(e){let t=b(e?.name),r=b(e?.publisher),n=typeof e?.engines?.vscode=="string";return t&&r&&n?`${r}.${t}`:t}i(Dn,"readPublishedName");function Nn(e){if(e!==null&&typeof e=="object"){let t=e;return b(t.company)??b(t.name)}return ge(e)}i(Nn,"readAuthorCompany");var Lt={id:"node",languages:["node"],manifests:Ft,detect(e){return D(e,Ft)},read(e){let t=J(e.files[0].content);return{name:Dn(t),company:Nn(t?.author)}}};var Pt=["composer.json"],Mt={id:"php",languages:["php"],manifests:Pt,detect(e){return D(e,Pt)},read(e){let t=J(e.files[0].content),r=t?.authors;return{name:b(t?.name),company:Array.isArray(r)?b(r[0]?.name):void 0}}};var jt=["pyproject.toml","setup.cfg","setup.py"];function Rt(e,t){let r=e.indexOf("setup(");if(r===-1)return;let n=e.slice(r).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return n&&n[2].trim()||void 0}i(Rt,"readSetupPyArgument");function kn(e){let t=v(e,"pyproject.toml"),r=v(e,"setup.cfg"),n=v(e,"setup.py");return(t===null?void 0:I(t,"project","name")??I(t,"tool.poetry","name"))??(r===null?void 0:ye(r,"metadata","name"))??(n===null?void 0:Rt(n,"name"))}i(kn,"readPythonName");function $n(e){let t=v(e,"pyproject.toml"),r=v(e,"setup.cfg"),n=v(e,"setup.py");return(t===null?void 0:T(t,"project")??T(t,"tool.poetry"))??(r===null?void 0:ye(r,"metadata","author"))??(n===null?void 0:Rt(n,"author"))}i($n,"readPythonCompany");var It={id:"python",languages:["python"],manifests:jt,detect(e){return D(e,jt)},read(e){return{name:kn(e),company:$n(e)}}};var Tt=["Cargo.toml"],Ot={id:"rust",languages:["rust"],manifests:Tt,detect(e){return D(e,Tt)},read(e){let t=e.files[0].content;return{name:I(t,"package","name"),company:T(t,"package")}}};var Fn=[Lt,It,Mt,Ot,vt],Bt=["name","company"];async function xe(e,t,r){let o=(await Promise.all(t.map(async s=>({driver:s,detection:await s.detect(e)})))).filter(s=>s.detection!==null),a=o.filter(s=>typeof r=="string"&&s.driver.languages.includes(r));return[...a,...o.filter(s=>!a.includes(s))]}i(xe,"claimFolder");function Ln(e,t){let r=Cn(t,e);return r!==""&&r!==".."&&!r.startsWith(`..${vn}`)&&!An(r)}i(Ln,"isStrictlyInside");async function zt(e,t={}){let r=Array.isArray(t.drivers)?t.drivers:Fn,n=typeof t.scanRoot=="string"?Ut(t.scanRoot):null,o=Ut(e),a=await xe(o,r,t.language);for(;a.length===0;){if(await ae(_t(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=Ht(o);if(f===o)return null;o=f,a=await xe(o,r,t.language)}let s={},c={},l=o,m=a;for(;;){for(let{driver:p,detection:x}of m){let h=p.read(x);for(let d of Bt)s[d]===void 0&&h[d]!==void 0&&(s[d]=h[d],c[d]={driver:p.id,manifest:x.manifest,dir:l})}if(Bt.every(p=>s[p]!==void 0)||n===null||!Ln(l,n)||await ae(_t(l,".git")))break;l=Ht(l),m=await xe(l,r,t.language)}return{root:o,marker:a[0].detection.manifest,drivers:a.map(f=>f.driver.id),fields:s,sources:c}}i(zt,"resolveManifestProject");import{execFile as Pn}from"node:child_process";import{promisify as Mn}from"node:util";var Gt=Mn(Pn);async function N(e,t){try{let{stdout:r}=await Gt("git",t,{cwd:e}),n=r.trim();return n.length>0?n:null}catch{return null}}i(N,"runGit");function Yt(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}i(Yt,"isEscaped");function jn(e){let t=e.trim();if(!t.endsWith(")")||Yt(t,t.length-1))return t;let r=0;for(let n=t.length-1;n>=0;n--){let o=t[n];if(!(o!=="("&&o!==")"||Yt(t,n))&&(r+=o===")"?1:-1,r===0))return t.slice(0,n).trim()}return t}i(jn,"stripUidComment");function Rn(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let r=t.match(/<([^>\n]+)>\s*$/),n=r?.[1]?.trim()||null,o=(r?t.slice(0,r.index):t).trim();return{authorName:jn(o)||o||null,authorEmail:n}}i(Rn,"parseSignerUid");async function In(e,t){try{let{stdout:r}=await Gt(e,t),n=r.trim();return n.length>0?n:null}catch{return null}}i(In,"runProgram");function Tn(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)))}i(Tn,"decodeColonField");async function On(e){let t=await N(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let r=await N(e,["config","--get","user.signingkey"]);if(!r)return null;let n=await N(e,["config","--get","gpg.openpgp.program"])||await N(e,["config","--get","gpg.program"])||"gpg",o=await In(n,["--batch","--with-colons","--list-keys",r]);if(!o)return null;for(let a of o.split(`
4
+ `)){let s=a.split(":");if(s[0]==="uid"&&s[1]!=="r"&&s[1]!=="e"&&s[9])return Tn(s[9])}return null}i(On,"readSigningKeyUid");async function Wt(e,t={}){let r=await N(e,["config","--get","user.name"]),n=await N(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await On(e)||await N(e,["log","-1","--format=%GS"]),a=Rn(o||"");r=a.authorName||r,n=n||a.authorEmail}if(!r||!n){let o=await N(e,["log","-1","--format=%an|%ae"]);if(o){let[a,s]=o.split("|");r=r||a||null,n=n||s||null}}return{authorName:r,authorEmail:n}}i(Wt,"detectGitAuthor");function Vt(e){return e.replace(/z$/i,"+00:00")}i(Vt,"canonicalGitDate");async function Jt(e,t){let r=await N(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!r)return null;let n=r.split(`
5
+ `)[0],[o,a]=n.split("|");if(!o||!a)return null;let s=Number.parseInt(a,10);return Number.isNaN(s)?null:{date:Vt(o),timestamp:s}}i(Jt,"getGitCreationDate");async function Kt(e,t){let r=await N(e,["log","-1","--format=%aI|%at","--",t]);if(!r)return null;let[n,o]=r.split("|");if(!n||!o)return null;let a=Number.parseInt(o,10);return Number.isNaN(a)?null:{date:Vt(n),timestamp:a}}i(Kt,"getGitLastModifiedDate");function Bn(e){return Hn(e)||"project"}i(Bn,"folderName");function zn(e,t){if(typeof t!="string")return e;let r=t.trim();return r.length===0||/<[^>]+>/.test(e)?e:`${e} <${r}>`}i(zn,"formatAuthorNameWithCompany");async function Yn(e,t={}){let r=Array.isArray(t.detectors)?t.detectors:P(t),n=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=n.length>0?r.find(m=>m.extensions.includes(n)):void 0,a=await zt(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),s=a?a.root:be(e),c=a?.sources.name,l=a?.sources.company;return{language:o?.id??a?.drivers[0]??"unknown",rootDir:s,marker:a?a.marker:null,projectName:a?.fields.name??Bn(s),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:s},companyName:a?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:a?a.drivers:[]}}i(Yn,"detectProjectFromMarkers");async function we(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),r=be(t),n=P(e),o=e.targetFilePath?_n(r):r,a=e.targetFilePath?Un(r).toLowerCase():"",s=be(e.projectRoot||e.cwd||process.cwd()),c=await Yn(o,{detectors:n,preferredExtension:a,scanRoot:s}),l=await Wt(c.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),m=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:zn(m,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(we,"resolveProjectMetadata");function Gn(e){return Ee({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(Gn,"formatDateWithTimezone");function Ee(e){return`${Qt(e," ")} ${er(e.offsetMinutes)}`}i(Ee,"formatSpaceDate");function Xt(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{Zt(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(Xt,"assertTimeZone");var qt=new Map;function Zt(e){let t=qt.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"}),qt.set(e,t)),t}i(Zt,"getZoneFormatter");function Se(e,t){let r={};for(let o of Zt(t).formatToParts(new Date(e*1e3)))r[o.type]=Number(o.value);let n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)/1e3;return{year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute,second:r.second,offsetMinutes:(n-e)/60}}i(Se,"toZonedDateParts");function Qt(e,t){let r=i(n=>String(n).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${r(e.month)}-${r(e.day)}${t}${r(e.hour)}:${r(e.minute)}:${r(e.second)}`}i(Qt,"formatWallClock");function er(e){let t=i(n=>String(n).padStart(2,"0"),"pad"),r=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(r/60))}:${t(r%60)}`}i(er,"formatOffset");function K(e=new Date){return{date:Gn(e),timestamp:Math.floor(e.getTime()/1e3)}}i(K,"toDatePayload");var Wn=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function F(e){let t=Wn.exec(e.trim());if(!t)return null;let[r,n,o,a,s,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),m=t[8]==="-"?-l:l,f=new Date(Date.UTC(r,n-1,o,a,s,c));return!(f.getUTCFullYear()===r&&f.getUTCMonth()===n-1&&f.getUTCDate()===o&&f.getUTCHours()===a&&f.getUTCMinutes()===s&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:r,month:n,day:o,hour:a,minute:s,second:c,offsetMinutes:m,timestamp:Math.floor(f.getTime()/1e3)-m*60}}i(F,"parseHeaderDate");function De(e){return`${Qt(e,"T")}${er(e.offsetMinutes)}`}i(De,"formatIsoDate");var Vn={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function tr(e,t){let r=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return r?r[1].trim():null}i(tr,"readHeaderField");function Ne(e){let t=null;for(let{source:r,payload:n}of e)n&&(!t||n.timestamp<t.payload.timestamp)&&(t={source:r,payload:n});return t}i(Ne,"pickOldestDate");function nr({existing:e,gitCreated:t,filesystemCreated:r,fixCreatedDate:n=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:r}];if(!e)return Ne(o);if(!n)return{source:"existing-header",payload:e};let a=F(e.date)?e:null;return Ne([{source:"existing-header",payload:a},...o])}i(nr,"resolveCreatedDate");function or(e,t=null){if(t)return Se(e.timestamp,t).year;let r=F(e.date);return r?r.year:new Date(e.timestamp*1e3).getFullYear()}i(or,"dateYear");function rr(e,t,r,n){let o=e.match(/^(.+?)\s*\((\d+)\)$/),a=o?F(o[1]):null;if(!o||!a)return n.push({check:`${r}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let s=Number.parseInt(o[2],10);return s!==a.timestamp&&n.push({check:`${r}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${a.timestamp})`,message:`${t} epoch ${s} does not match ${o[1]} (expected ${a.timestamp})`}),{text:o[1],timestamp:a.timestamp}}i(rr,"checkDateValue");function ir(e,t={},r={}){let n=[],o=tr(e,"@Date"),a=o===null?null:rr(o,"@Date","created",n),s=Ne([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(a&&s&&a.timestamp>s.payload.timestamp){let f=Vn[s.source];n.push({check:"created-newer-than-source",field:"@Date",advisory:r.strictCreatedDate!==!0,value:o,expected:`${s.payload.date} (${s.payload.timestamp})`,source:s.source,message:`@Date ${a.text} is later than the ${f} ${s.payload.date} (${s.payload.timestamp})`})}let c=tr(e,"@Last modified time"),l=c===null?null:rr(c,"@Last modified time","modified",n),m=t.gitLastModified;return l&&m&&l.timestamp!==m.timestamp&&n.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${m.date} (${m.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${m.date} (${m.timestamp})`}),n}i(ir,"checkHeaderDates");function ke(e){if(!e)return null;let t=F(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i(ke,"repairDateEpoch");function ar(e){let t=F(e.date);return t?{date:De(t),timestamp:t.timestamp}:e}i(ar,"normalizeDatePayload");function sr(e,t){let r=F(e.date);if(!r)return e;let n=Se(r.timestamp,t);return n.offsetMinutes===r.offsetMinutes||!Number.isInteger(n.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?De(n):Ee(n),timestamp:r.timestamp}}i(sr,"convertDatePayload");import{relative as Kn}from"node:path";import{extname as Jn}from"node:path";function O(e,t={}){let r=Jn(e).toLowerCase(),n=C(t.spacing,"spacing",R);return r.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:n}:{...mt(e,t),spacing:n}}i(O,"getHeaderSyntaxForFile");function cr(e,t){let r=e.spacing??R;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",m=Array.from({length:r},()=>c);return[...m,...t.map(f=>`${c}${l}${f}`),...m].join(`
6
+ `)}let n=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),a=e.blockEnd||(e.kind==="html"?"-->":" */"),s=Array.from({length:r},()=>o.trimEnd());return[n,...s,...t.map(c=>`${o}${c}`),...s,a].join(`
7
+ `)}i(cr,"renderHeaderLines");function $e(e){let t=`/${Kn(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,r=O(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),n=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,a=e.lastModifiedByName||e.authorName,s=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",m=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${n}`,`@Email: <${o}>`,"-----",`@Last modified by: ${a} (${s})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return cr(r,m)}i($e,"buildHeader");var qn=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function $(e,t){let r=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),n=r?r[1].trim():"";return n.length>0?n:null}i($,"readTag");function Xn(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),r=t.indexOf("(",t.lastIndexOf(")")+1);return r===-1?{name:e,email:null}:{name:t.slice(0,r).trimEnd()||null,email:t.slice(r+1)||null}}i(Xn,"splitLastModifiedBy");function Zn(e){let t={startYear:null,endYear:null,companyName:null},r=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!r)return t;let n=e.slice(r[0].length),o=n.match(/^\s*-\s*(\d{4})/);o&&(n=n.slice(o[0].length));let a=n.toLowerCase(),s=a.endsWith("all rights reserved.")?20:a.endsWith("all rights reserved")?19:0;return s===0||!/^\s/.test(n)?t:{startYear:r[1],endYear:o?o[1]:null,companyName:n.slice(0,-s).trim()||null}}i(Zn,"splitCopyright");function lr(e){let t=Xn($(e,"Last modified by")),r=Zn($(e,"Copyright")),n=$(e,"Email");return{projectName:$(e,"Project"),filename:$(e,"Filename"),createdAt:$(e,"Date"),authorName:$(e,"Author"),authorEmail:n===null?null:n.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:$(e,"Last modified time"),copyrightStartYear:r.startYear,copyrightEndYear:r.endYear,companyName:r.companyName}}i(lr,"parseHeaderFields");function ur(e,t){let r=lr(e??""),n=lr(t);return qn.filter(o=>r[o]!==n[o]).map(o=>({field:o,previous:r[o],detected:n[o]}))}i(ur,"compareHeaderFields");function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(q,"escapeRegex");function dr(e,t,r={}){let n=dt(e,t,r);return n.length===0?{prefix:"",body:t}:{prefix:n,body:t.slice(n.length)}}i(dr,"splitPreservedPrefix");function mr(e,t){if(t.kind==="html"){let n=q(t.blockStart||"<!--"),o=q(t.blockEnd||"-->");return e.match(new RegExp(`^${n}[\\s\\S]*?${o}\\n*`))}if(t.kind==="line"){let n=q(t.linePrefix||"#");return e.match(new RegExp(`^(?:${n}.*\\n)+\\n*`))}let r=q((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${r}\\n*`))}i(mr,"matchHeaderSegment");function Ae(e,t="",r={}){let{prefix:n,body:o}=dr(t,e,r),a=o.split(`
8
+ `).slice(0,ft).join(`
9
+ `),s=O(t,r);if(!mr(a,s))return null;let l=0,m=0;for(;;){let f=a.slice(l),p=mr(f,s);if(!p||!p[0].includes("@Project:"))break;l+=p[0].length,m=l}return m===0?null:{start:n.length,end:n.length+m}}i(Ae,"findProjectHeader");function Ce(e,t,r="",n={}){let o=Ae(e,r,n),a=C(n.margin,"margin",V),s=O(r,n).kind==="line"?Math.max(1,a):a,c=`
10
+ `.repeat(s+1);if(!o){let{prefix:p,body:x}=dr(r,e,n),h=`${p}${t}${c}${x.replace(/^\n+/,"")}`;return{nextContent:h,changed:h!==e}}let l=e.slice(0,o.start),m=e.slice(o.end).replace(/^\n+/,""),f=`${l}${t}${c}${m}`;return{nextContent:f,changed:f!==e}}i(Ce,"replaceOrInsertHeader");function Qn(e,t){let r=e.length,n=t.length,o=Array.from({length:r+1},()=>new Array(n+1).fill(0));for(let l=r-1;l>=0;l-=1)for(let m=n-1;m>=0;m-=1)o[l][m]=e[l]===t[m]?o[l+1][m+1]+1:Math.max(o[l+1][m],o[l][m+1]);let a=[],s=0,c=0;for(;s<r&&c<n;)e[s]===t[c]?(a.push({type:" ",line:e[s]}),s+=1,c+=1):o[s+1][c]>=o[s][c+1]?(a.push({type:"-",line:e[s]}),s+=1):(a.push({type:"+",line:t[c]}),c+=1);for(;s<r;s+=1)a.push({type:"-",line:e[s]});for(;c<n;c+=1)a.push({type:"+",line:t[c]});return a}i(Qn,"diffLines");function fr(e,t){return`${t===0?e:e+1},${t}`}i(fr,"formatRange");function pr(e,t,r={}){let n=e===null?[]:e.split(`
19
11
  `),o=t.split(`
20
- `),a=qn(n,o),s=Math.max(0,r.context??3),l=r.lineOffset??0,c=[];if(a.forEach((x,y)=>{if(x.type===" ")return;let m=c[c.length-1];m&&y-m.last<=s*2+1?m.last=y:c.push({first:y,last:y})}),c.length===0)return"";let d=r.fromFile??"a",f=r.toFile??"b",p=[`--- ${e===null?"/dev/null":d}`,`+++ ${f}`];for(let x of c){let y=Math.max(0,x.first-s),m=Math.min(a.length,x.last+s+1),h=a.slice(0,y),w=a.slice(y,m),S=h.filter(u=>u.type!=="+").length+l,D=h.filter(u=>u.type!=="-").length+l,I=w.filter(u=>u.type!=="+").length,g=w.filter(u=>u.type!=="-").length;p.push(`@@ -${ur(S,I)} +${ur(D,g)} @@`);for(let u of w)p.push(`${u.type}${u.line}`)}return p.join(`
21
- `)}i(dr,"createUnifiedDiff");function eo(e){return Be(e,"configFile")}i(eo,"resolveRuntimeOptions");function to(e){let t=e.match(/@Author:\s*(.+)$/m),r=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}i(to,"extractHeaderAuthorIdentity");function ro(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(ro,"extractHeaderLastModifiedIdentity");function no(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(no,"extractHeaderCreatedAt");function oo(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(oo,"extractHeaderLastModifiedAt");async function pr(e={}){let t=await eo(e),r=t.timezone===void 0||t.timezone===null?null:Vt(t.timezone),n=t.convertTimezone===!0;if(n&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=fr(t.projectRoot||t.cwd||process.cwd()),a=await ye({...t,cwd:o}),s=t.check===!0,l=s||t.dryRun===!0,c=t.fixCreatedDate===!0,d=i(g=>g,"keepDate"),f=t.normalizeDateFormat===!0?rr:d,p=r?g=>nr(g,r):d,x=n?p:d,y;if(typeof t.input=="string"&&t.input.trim().length>0){let g=fr(o,t.input),u=await Zn(g).catch(()=>null);if(!u)throw new Error(`Input path does not exist: ${t.input}`);if(u.isFile())y=[g];else if(u.isDirectory())y=await de({projectRoot:g,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});else throw new Error(`Input path must be a file or directory: ${t.input}`)}else y=await de({projectRoot:o,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});let m=new Date().getFullYear(),h=[],w=new Set,S=0,D=0,I=0;for(let g of y){let u=await ye({...t,cwd:o,targetFilePath:g});w.add(`${u.language}:${u.projectRoot}`);let Ne=mr(o,g),O=await Xn(g,"utf8"),J=ke(O,g,{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides}),E=J?O.slice(J.start,J.end):"",T=E.length>0?to(E):{},H=E.length>0?ro(E):{},hr=E.length>0?no(E):null,gr=E.length>0?oo(E):null,ve=await ut(g),Ce=mr(u.projectRoot,g),Ae=await Yt(u.projectRoot,Ce),K=await Wt(u.projectRoot,Ce),Fe=W(ve.createdAt),q=Qt({existing:Se(hr),gitCreated:Ae,filesystemCreated:Fe,fixCreatedDate:c}),X=Se(gr),Pe=q.source,yr=X?"existing-header":K?"git-last-modified":"filesystem-updated",B=f(Pe==="existing-header"?x(q.payload):p(q.payload)),xr=u.copyrightStartYear===null?"created-date":"option",Z=u.copyrightStartYear??er(B,r),je=f(X?x(X):p(K||W(ve.updatedAt))),U=t.forceAuthorUpdate===!0,_=t.forceLastModifiedAuthorUpdate===!0,Me=$e({absoluteFilePath:g,language:u.language,syntaxOptions:{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides},projectRoot:u.projectRoot,projectName:u.projectName,createdByName:U?u.authorName:T.authorName||u.authorName,createdByEmail:U?u.authorEmail:T.authorEmail||u.authorEmail,lastModifiedByName:_?u.authorName:H.authorName||u.authorName,lastModifiedByEmail:_?u.authorEmail:H.authorEmail||u.authorEmail,authorName:u.authorName,authorEmail:u.authorEmail,createdAt:B,lastModifiedAt:je,copyrightStartYear:Z,companyName:u.companyName,currentYear:m}),Le=De(O,Me,g,{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides}),z=Le.changed,Re=z?f(p(W(new Date))):je,br=z?"current-time-on-change":yr,j=z?$e({absoluteFilePath:g,language:u.language,syntaxOptions:{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides},projectRoot:u.projectRoot,projectName:u.projectName,createdByName:U?u.authorName:T.authorName||u.authorName,createdByEmail:U?u.authorEmail:T.authorEmail||u.authorEmail,lastModifiedByName:_?u.authorName:H.authorName||u.authorName,lastModifiedByEmail:_?u.authorEmail:H.authorEmail||u.authorEmail,authorName:u.authorName,authorEmail:u.authorEmail,createdAt:B,lastModifiedAt:Re,copyrightStartYear:Z,companyName:u.companyName,currentYear:m}):Me,F=z?De(O,j,g,{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides}):Le,Q={file:Ne,changed:F.changed};if(s){let v=tr(E,{gitCreated:Ae,gitLastModified:K,filesystemCreated:Fe},{strictCreatedDate:t.strictCreatedDate===!0}),M=v.filter(ee=>ee.advisory).length;Q.dateIssues=v,I+=M,D+=v.length>M?1:0}if(t.sampleOutput===!0&&F.changed){let v=E.length>0?E.trimEnd():null,M=Ne.replace(/\\/g,"/"),ee=F.nextContent.slice(0,F.nextContent.indexOf(j)).split(`
22
- `).length-1;Q.sample={previousValue:v,newValue:j,diff:dr(v,j,{fromFile:`a/${M}`,toFile:`b/${M}`,lineOffset:ee}),issues:ar(v,j),detectedValues:{projectName:u.projectName,projectNameSource:u.projectNameSource,language:u.language,projectRoot:u.projectRoot,marker:u.marker,authorName:u.authorName,authorEmail:u.authorEmail,companyName:u.companyName,companyNameSource:u.companyNameSource,copyrightStartYear:Z,copyrightStartYearSource:xr,createdAtSource:Pe,lastModifiedAtSource:br,createdAt:B,lastModifiedAt:Re}}}h.push(Q),F.changed&&(S+=1,l||await Qn(g,F.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(w),filesScanned:y.length,filesUpdated:S,dryRun:l,check:s,...s?{filesWithDateDrift:D,dateAdvisories:I}:{},changes:h}}i(pr,"fixHeaders");function io(e){return pr(e)}i(io,"fixHeaders");var Ua=io;export{Ua as default,io as fixHeaders};
12
+ `),a=Qn(n,o),s=Math.max(0,r.context??3),c=r.lineOffset??0,l=[];if(a.forEach((x,h)=>{if(x.type===" ")return;let d=l[l.length-1];d&&h-d.last<=s*2+1?d.last=h:l.push({first:h,last:h})}),l.length===0)return"";let m=r.fromFile??"a",f=r.toFile??"b",p=[`--- ${e===null?"/dev/null":m}`,`+++ ${f}`];for(let x of l){let h=Math.max(0,x.first-s),d=Math.min(a.length,x.last+s+1),g=a.slice(0,h),w=a.slice(h,d),S=g.filter(u=>u.type!=="+").length+c,k=g.filter(u=>u.type!=="-").length+c,H=w.filter(u=>u.type!=="+").length,y=w.filter(u=>u.type!=="-").length;p.push(`@@ -${fr(S,H)} +${fr(k,y)} @@`);for(let u of w)p.push(`${u.type}${u.line}`)}return p.join(`
13
+ `)}i(pr,"createUnifiedDiff");function no(e){return ze(e,"configFile")}i(no,"resolveRuntimeOptions");function oo(e){let t=e.match(/@Author:\s*(.+)$/m),r=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}i(oo,"extractHeaderAuthorIdentity");function io(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(io,"extractHeaderLastModifiedIdentity");function ao(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(ao,"extractHeaderCreatedAt");function so(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let r=Number.parseInt(t[2],10);return Number.isNaN(r)?null:{date:t[1].trim(),timestamp:r}}i(so,"extractHeaderLastModifiedAt");async function yr(e={}){let t=await no(e),r=t.timezone===void 0||t.timezone===null?null:Xt(t.timezone),n=t.convertTimezone===!0;if(n&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=hr(t.projectRoot||t.cwd||process.cwd()),a=await we({...t,cwd:o});C(t.spacing,"spacing",R),C(t.margin,"margin",V);let s=t.check===!0,c=s||t.dryRun===!0,l=t.fixCreatedDate===!0,m=i(y=>y,"keepDate"),f=t.normalizeDateFormat===!0?ar:m,p=r?y=>sr(y,r):m,x=n?p:m,h;if(typeof t.input=="string"&&t.input.trim().length>0){let y=hr(o,t.input),u=await to(y).catch(()=>null);if(!u)throw new Error(`Input path does not exist: ${t.input}`);if(u.isFile())h=[y];else if(u.isDirectory())h=await pe({projectRoot:y,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});else throw new Error(`Input path must be a file or directory: ${t.input}`)}else h=await pe({projectRoot:o,language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore});let d=new Date().getFullYear(),g=[],w=new Set,S=0,k=0,H=0;for(let y of h){let u=await we({...t,cwd:o,targetFilePath:y});w.add(`${u.language}:${u.projectRoot}`);let ve=gr(o,y),_=await eo(y,"utf8"),X=Ae(_,y,{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin}),E=X?_.slice(X.start,X.end):"",U=E.length>0?oo(E):{},B=E.length>0?io(E):{},xr=E.length>0?ao(E):null,br=E.length>0?so(E):null,Fe=await pt(y),Le=gr(u.projectRoot,y),Pe=await Jt(u.projectRoot,Le),Z=await Kt(u.projectRoot,Le),Me=K(Fe.createdAt),Q=nr({existing:ke(xr),gitCreated:Pe,filesystemCreated:Me,fixCreatedDate:l}),ee=ke(br),je=Q.source,wr=ee?"existing-header":Z?"git-last-modified":"filesystem-updated",z=f(je==="existing-header"?x(Q.payload):p(Q.payload)),Er=u.copyrightStartYear===null?"created-date":"option",te=u.copyrightStartYear??or(z,r),Re=f(ee?x(ee):p(Z||K(Fe.updatedAt))),Y=t.forceAuthorUpdate===!0,G=t.forceLastModifiedAuthorUpdate===!0,Ie=$e({absoluteFilePath:y,language:u.language,syntaxOptions:{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin},projectRoot:u.projectRoot,projectName:u.projectName,createdByName:Y?u.authorName:U.authorName||u.authorName,createdByEmail:Y?u.authorEmail:U.authorEmail||u.authorEmail,lastModifiedByName:G?u.authorName:B.authorName||u.authorName,lastModifiedByEmail:G?u.authorEmail:B.authorEmail||u.authorEmail,authorName:u.authorName,authorEmail:u.authorEmail,createdAt:z,lastModifiedAt:Re,copyrightStartYear:te,companyName:u.companyName,currentYear:d}),Te=Ce(_,Ie,y,{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin}),W=Te.changed,Oe=W?f(p(K(new Date))):Re,Sr=W?"current-time-on-change":wr,M=W?$e({absoluteFilePath:y,language:u.language,syntaxOptions:{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin},projectRoot:u.projectRoot,projectName:u.projectName,createdByName:Y?u.authorName:U.authorName||u.authorName,createdByEmail:Y?u.authorEmail:U.authorEmail||u.authorEmail,lastModifiedByName:G?u.authorName:B.authorName||u.authorName,lastModifiedByEmail:G?u.authorEmail:B.authorEmail||u.authorEmail,authorName:u.authorName,authorEmail:u.authorEmail,createdAt:z,lastModifiedAt:Oe,copyrightStartYear:te,companyName:u.companyName,currentYear:d}):Ie,L=W?Ce(_,M,y,{language:u.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin}):Te,re={file:ve,changed:L.changed};if(s){let A=ir(E,{gitCreated:Pe,gitLastModified:Z,filesystemCreated:Me},{strictCreatedDate:t.strictCreatedDate===!0}),j=A.filter(ne=>ne.advisory).length;re.dateIssues=A,H+=j,k+=A.length>j?1:0}if(t.sampleOutput===!0&&L.changed){let A=E.length>0?E.trimEnd():null,j=ve.replace(/\\/g,"/"),ne=L.nextContent.slice(0,L.nextContent.indexOf(M)).split(`
14
+ `).length-1;re.sample={previousValue:A,newValue:M,diff:pr(A,M,{fromFile:`a/${j}`,toFile:`b/${j}`,lineOffset:ne}),issues:ur(A,M),detectedValues:{projectName:u.projectName,projectNameSource:u.projectNameSource,language:u.language,projectRoot:u.projectRoot,marker:u.marker,authorName:u.authorName,authorEmail:u.authorEmail,companyName:u.companyName,companyNameSource:u.companyNameSource,copyrightStartYear:te,copyrightStartYearSource:Er,createdAtSource:je,lastModifiedAtSource:Sr,createdAt:z,lastModifiedAt:Oe}}}g.push(re),L.changed&&(S+=1,c||await ro(y,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(w),filesScanned:h.length,filesUpdated:S,dryRun:c,check:s,...s?{filesWithDateDrift:k,dateAdvisories:H}:{},changes:g}}i(yr,"fixHeaders");function co(e){return yr(e)}i(co,"fixHeaders");var Va=co;export{Va as default,co as fixHeaders};
23
15
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/fix-headers",
3
- "version": "2.0.0",
3
+ "version": "2.1.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",
@@ -1,5 +1,19 @@
1
+ /**
2
+ * Reads a layout count option (`spacing` / `margin`): unset means the default, anything but a whole number of 0 or more throws.
3
+ * @param {unknown} value - Option value.
4
+ * @param {string} name - Option name for the error message.
5
+ * @param {number} fallback - Default when unset.
6
+ * @returns {number} Validated count.
7
+ */
8
+ export function resolveLayoutCount(value: unknown, name: string, fallback: number): number;
1
9
  /** Header must sit near the top of the file, but a metadata block can legitimately
2
10
  * run long; cap the scan generously so a long block's closing comment delimiter is still seen.
3
11
  * @type {number} */
4
12
  export const DEFAULT_MAX_HEADER_SCAN_LINES: number;
13
+ /** Empty comment lines just inside a header's opening and closing delimiters (or a bare comment-prefix line above and below a line-comment header).
14
+ * @type {number} */
15
+ export const DEFAULT_HEADER_SPACING: number;
16
+ /** Blank lines between the end of the header and the file's next content.
17
+ * @type {number} */
18
+ export const DEFAULT_HEADER_MARGIN: number;
5
19
  export { DETECTOR_PROFILES, getAllowedExtensions, getEnabledDetectors } from "./detectors/index.mjs";
@@ -48,6 +48,8 @@ export type FixHeadersOptions = {
48
48
  company?: string;
49
49
  companyName?: string;
50
50
  copyrightStartYear?: number;
51
+ spacing?: number;
52
+ margin?: number;
51
53
  };
52
54
  export type HeaderFieldIssue = import("../header/fields.mjs").HeaderFieldIssue;
53
55
  /**
@@ -26,7 +26,7 @@ export function getDetectorById(id: string): (typeof DETECTOR_PROFILES)[number]
26
26
  /**
27
27
  * Resolves comment syntax for a file path using detector-specific templates.
28
28
  * @param {string} filePath - File path.
29
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectors?: DetectorProfile[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [options={}] - Runtime options. `detectors` overrides the enabled-detector set (matching {@link detectProjectFromMarkers}).
29
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectors?: DetectorProfile[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>, spacing?: number, margin?: number }} [options={}] - Runtime options. `detectors` overrides the enabled-detector set (matching {@link detectProjectFromMarkers}).
30
30
  * @returns {{kind: "block" | "line" | "html", linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string}} Syntax descriptor.
31
31
  */
32
32
  export function getCommentSyntaxForFile(filePath: string, options?: {
@@ -41,6 +41,8 @@ export function getCommentSyntaxForFile(filePath: string, options?: {
41
41
  blockLinePrefix?: string;
42
42
  blockEnd?: string;
43
43
  }>;
44
+ spacing?: number;
45
+ margin?: number;
44
46
  }): {
45
47
  kind: "block" | "line" | "html";
46
48
  linePrefix?: string;
@@ -2,7 +2,7 @@
2
2
  * Finds the first top-level project header block in a file.
3
3
  * @param {string} content - File content.
4
4
  * @param {string} [filePath=""] - File path used for syntax selection.
5
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [syntaxOptions={}] - Syntax resolution options.
5
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>, spacing?: number, margin?: number }} [syntaxOptions={}] - Syntax resolution options.
6
6
  * @returns {{start: number, end: number} | null} Header location.
7
7
  */
8
8
  export function findProjectHeader(content: string, filePath?: string, syntaxOptions?: {
@@ -16,6 +16,8 @@ export function findProjectHeader(content: string, filePath?: string, syntaxOpti
16
16
  blockLinePrefix?: string;
17
17
  blockEnd?: string;
18
18
  }>;
19
+ spacing?: number;
20
+ margin?: number;
19
21
  }): {
20
22
  start: number;
21
23
  end: number;
@@ -25,7 +27,7 @@ export function findProjectHeader(content: string, filePath?: string, syntaxOpti
25
27
  * @param {string} content - Original file content.
26
28
  * @param {string} newHeader - Generated header text.
27
29
  * @param {string} [filePath=""] - File path used for syntax selection.
28
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [syntaxOptions={}] - Syntax resolution options.
30
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>, spacing?: number, margin?: number }} [syntaxOptions={}] - Syntax resolution options.
29
31
  * @returns {{nextContent: string, changed: boolean}} Updated content result.
30
32
  */
31
33
  export function replaceOrInsertHeader(content: string, newHeader: string, filePath?: string, syntaxOptions?: {
@@ -39,6 +41,8 @@ export function replaceOrInsertHeader(content: string, newHeader: string, filePa
39
41
  blockLinePrefix?: string;
40
42
  blockEnd?: string;
41
43
  }>;
44
+ spacing?: number;
45
+ margin?: number;
42
46
  }): {
43
47
  nextContent: string;
44
48
  changed: boolean;
@@ -9,13 +9,14 @@
9
9
  * lineSeparator?: string,
10
10
  * blockStart?: string,
11
11
  * blockLinePrefix?: string,
12
- * blockEnd?: string
12
+ * blockEnd?: string,
13
+ * spacing?: number
13
14
  * }} HeaderSyntax
14
15
  */
15
16
  /**
16
17
  * Resolves comment syntax for a file path based on extension.
17
18
  * @param {string} filePath - Absolute or relative file path.
18
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [options={}] - Syntax resolution options.
19
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>, spacing?: number }} [options={}] - Syntax resolution options. `spacing` is the number of empty comment lines just inside the header's opening and closing (default 1).
19
20
  * @returns {HeaderSyntax} Header syntax descriptor.
20
21
  */
21
22
  export function getHeaderSyntaxForFile(filePath: string, options?: {
@@ -29,9 +30,12 @@ export function getHeaderSyntaxForFile(filePath: string, options?: {
29
30
  blockLinePrefix?: string;
30
31
  blockEnd?: string;
31
32
  }>;
33
+ spacing?: number;
32
34
  }): HeaderSyntax;
33
35
  /**
34
- * Renders header body lines using a chosen syntax.
36
+ * Renders header body lines using a chosen syntax. `syntax.spacing` empty comment lines (default 1) sit
37
+ * just inside the opening and just before the closing delimiter, or a bare comment-prefix line above
38
+ * and below a line-comment header.
35
39
  * @param {HeaderSyntax} syntax - Header syntax descriptor.
36
40
  * @param {string[]} lines - Header lines without comment wrappers.
37
41
  * @returns {string} Formatted header block.
@@ -44,4 +48,5 @@ export type HeaderSyntax = {
44
48
  blockStart?: string;
45
49
  blockLinePrefix?: string;
46
50
  blockEnd?: string;
51
+ spacing?: number;
47
52
  };
@@ -7,7 +7,7 @@
7
7
  * @param {{
8
8
  * absoluteFilePath: string,
9
9
  * language?: string,
10
- * syntaxOptions?: { language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> },
10
+ * syntaxOptions?: { language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>, spacing?: number, margin?: number },
11
11
  * projectRoot: string,
12
12
  * createdByName?: string,
13
13
  * createdByEmail?: string,
@@ -39,6 +39,8 @@ export function buildHeader(data: {
39
39
  blockLinePrefix?: string;
40
40
  blockEnd?: string;
41
41
  }>;
42
+ spacing?: number;
43
+ margin?: number;
42
44
  };
43
45
  projectRoot: string;
44
46
  createdByName?: string;