@cldmv/fix-headers 2.2.7 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -33
- package/bin/fix-headers.mjs +29 -25
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +32 -28
- package/package.json +1 -1
- package/types/src/detectors/c.d.mts +18 -0
- package/types/src/detectors/index.d.mts +4 -3
- package/types/src/detectors/node.d.mts +1 -0
- package/types/src/header/fields.d.mts +2 -2
- package/types/src/utils/diff.d.mts +2 -2
- package/types/src/utils/text.d.mts +2 -2
- package/types/src/utils/time.d.mts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`)
|
|
4
|
-
`)}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
`)}
|
|
9
|
-
|
|
1
|
+
var dr=Object.defineProperty;var i=(e,t)=>dr(e,"name",{value:t,configurable:!0});import{readFile as yi,stat as xi,writeFile as wi}from"node:fs/promises";import{relative as Ye,resolve as er}from"node:path";import{readFile as fr}from"node:fs/promises";import{createRequire as mr}from"node:module";import{dirname as pr,isAbsolute as hr,resolve as ut}from"node:path";var gr=3e4,yr=new Set(["localhost","127.0.0.1","[::1]"]);function xe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(xe,"isPlainObject");function we(e,t){let n={...e};for(let[r,o]of Object.entries(t))r!=="__proto__"&&(n[r]=xe(n[r])&&xe(o)?we(n[r],o):o);return n}i(we,"mergeConfig");function dt(e){return e.kind==="file"?e.path:e.href}i(dt,"describeSource");async function xr(e){if(e.kind==="file")return{text:await fr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(gr)})}catch(n){let r=n.cause instanceof Error?n.cause.message:n.message;throw new Error(`Failed to fetch config ${e.href}: ${r}`,{cause:n})}if(!t.ok)throw new Error(`Failed to fetch config ${e.href}: HTTP ${t.status} ${t.statusText}`);return{text:await t.text(),source:{kind:"url",href:t.url}}}i(xr,"readSource");function lt(e){if(e.protocol==="http:"&&!yr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(lt,"toUrlSource");function wr(e,t){if(/^https?:\/\//i.test(e))return lt(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${dt(t)}; use https, a file path or a package path`);let n=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(n||e.startsWith("/"))return lt(new URL(e,t.href));throw new Error(`Cannot extend package "${e}" from the remote config ${t.href}; use a URL or a relative path`)}if(n||hr(e))return{kind:"file",path:ut(pr(t.path),e)};try{return{kind:"file",path:mr(t.path).resolve(e)}}catch(r){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${r.message}`,{cause:r})}}i(wr,"resolveReference");function br(e,t){if(e===void 0)return[];let n=Array.isArray(e)?e:[e];if(!n.every(r=>typeof r=="string"&&r.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return n.map(r=>r.trim())}i(br,"readExtends");async function ft(e,t){let n=dt(e);if(t.includes(n))throw new Error(`Config extends cycle: ${[...t,n].join(" -> ")}`);let{text:r,source:o}=await xr(e),s;try{s=JSON.parse(r)}catch(u){throw new Error(`Config ${n} is not valid JSON: ${u.message}`,{cause:u})}if(!xe(s))throw new Error(`Config file must contain a JSON object: ${n}`);let{extends:a,...c}=s,l={};for(let u of br(a,n))l=we(l,await ft(wr(u,o),[...t,n]));return we(l,c)}i(ft,"loadSource");function Er(e,t=process.cwd()){return ft({kind:"file",path:ut(t,e)},[])}i(Er,"loadConfigFile");async function mt(e,t){let n=typeof e[t]=="string"?e[t].trim():"";if(n.length===0)return e;let r=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Er(n,r),...e};return delete o[t],o}i(mt,"applyConfigOption");import{extname as be}from"node:path";import{extname as kr}from"node:path";var ht=[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],Sr=400,$r=/\bcopyright\b|\blicen[cs]e[ds]?\b|SPDX-License-Identifier|\bpublic domain\b/i,pt=/^[\s*/]*@(?:Project|Filename):/m;function Dr(e){let t=kr(e).toLowerCase();return ht.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Dr,"resolveCCommentSyntax");function Cr(e){let t=e.replace(/^\uFEFF/,"").split(`
|
|
2
|
+
`).slice(0,Sr),n=[],r=null,o=null,s=!1;for(let a of t){let c=a.replace(/\r$/,"");if(r){r.push(c),c.includes("*/")&&(n.push(r.join(`
|
|
3
|
+
`)),r=null);continue}if(s){s=c.endsWith("\\");continue}let l=c.trim();if(o&&!l.startsWith("//")&&(n.push(o.join(`
|
|
4
|
+
`)),o=null),l.length!==0){if(l.startsWith("//")){(o??=[]).push(l);continue}if(l.startsWith("/*")){let u=l.indexOf("*/",2);if(u===-1){r=[l];continue}if(n.push(l.slice(0,u+2)),l.slice(u+2).trim().length>0)break;continue}if(l.startsWith("#")){s=l.endsWith("\\");continue}break}}return o&&n.push(o.join(`
|
|
5
|
+
`)),n}i(Cr,"prologueComments");var gt={id:"c",extensions:ht,enabledByDefault:!0,resolveContentSkipReason(e){let t=Cr(e);return t.length>0&&pt.test(t[0])?null:t.some(n=>!pt.test(n)&&$r.test(n))?"the file starts with a license or copyright notice that is not a fix-headers header (third-party code)":null},resolveCommentSyntax(e){return Dr(e)}};import{extname as Ar}from"node:path";var yt=[".css"];function Fr(e){let t=Ar(e).toLowerCase();return yt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Fr,"resolveCssCommentSyntax");var xt={id:"css",extensions:yt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Fr(e)}};import{extname as Rr}from"node:path";var Nr=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,vr=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,Lr=new Set(["et","expandtab","ai","autoindent","si","smartindent","ro","readonly","bin","binary","noet","noexpandtab","noai","noautoindent","nosi","nosmartindent","noro","noreadonly","nobin","nobinary","nowrap","nolist","nospell","nofen","nofoldenable","noeol","nofixeol","nofixendofline"]);function re(e){let t=e.match(Nr);if(!t)return!1;let n=t[2].trim();if(n.endsWith("-->"))n=n.slice(0,-3).trimEnd();else if(n.endsWith("*/")){let s=n.length-2;for(;s>0&&n[s-1]==="*";)s-=1;n=n.slice(0,s).trimEnd()}let r=n.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!r&&t[1]==="Vim")return!1;let o=r?r[1].match(/(?:\\.|[^\s\\])+/g):n.match(/(?:\\.|[^\s:\\])+/g);return o!==null&&o.every(s=>vr.test(s))&&o.some(s=>s.includes("=")||Lr.has(s))}i(re,"isModeline");function oe(e,t){return t===0&&e.startsWith("#!")}i(oe,"isShebang");function ie(e,t,n=0){let r=0,o=n;for(;r<e.length;){let s=e.indexOf(`
|
|
6
|
+
`,r),a=s===-1?e.length:s+1;if(!t(e.slice(r,a).replace(/\r?\n$/,""),o))break;r=a,o+=1}return e.slice(0,r)}i(ie,"takeTopLines");var bt=[".go"];function jr(e){let t=Rr(e).toLowerCase();return bt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(jr,"resolveGoCommentSyntax");var wt=/^\/\/(?:go:build|\s*\+build)\s/;function Mr(e,t){let n=ie(t,o=>wt.test(o)||re(o));if(!n.split(/\r?\n/).some(o=>wt.test(o)))return"";let r=t.slice(n.length);return`${n}${r.slice(0,r.length-r.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}i(Mr,"resolveGoPreservedPrefix");var Et={id:"go",extensions:bt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return Mr(e,t)},resolveCommentSyntax(e){return jr(e)}};import{extname as Pr}from"node:path";var kt=[".html",".htm"];function Ir(e){let t=Pr(e).toLowerCase();return kt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Ir,"resolveHtmlCommentSyntax");var St={id:"html",extensions:kt,enabledByDefault:!0,resolveCommentSyntax(e){return Ir(e)}};import{extname as Or}from"node:path";var $t=[".jsonv",".jsonc",".json5"];function Tr(e){let t=Or(e).toLowerCase();return $t.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Tr,"resolveJsonCommentSyntax");var Dt={id:"json",extensions:$t,enabledByDefault:!0,resolveCommentSyntax(e){return Tr(e)}};import{extname as Hr}from"node:path";var Ct=[".md",".markdown"];function _r(e){let t=Hr(e).toLowerCase();return Ct.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(_r,"resolveMarkdownCommentSyntax");function Br(e,t){let n=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return n?n[0]:""}i(Br,"resolveMarkdownPreservedPrefix");var At={id:"markdown",extensions:Ct,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return Br(e,t)},resolveCommentSyntax(e){return _r(e)}};import{basename as Ft,extname as Ur}from"node:path";var Nt=[".js",".mjs",".cjs",".ts",".mts",".cts",".tsx",".jsx"];function Wr(e){let t=Ur(e).toLowerCase();return Nt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Wr,"resolveNodeCommentSyntax");var zr=/^(.+)\.d\.(ts|mts|cts)$/i,Gr={ts:[".ts",".tsx",".js",".jsx"],mts:[".mts",".mjs"],cts:[".cts",".cjs"]};function Yr(e){let t=/^\s*\/\*[\s\S]*?\*\//.exec(e.replace(/^\uFEFF/,""));if(!t)return null;let n=/^[\s*]*@Filename:[ \t]*(\S+)/m.exec(t[0]);return n?n[1]:null}i(Yr,"leadingHeaderFilename");function Vr(e,t){let n=zr.exec(Ft(t));if(!n)return null;let r=Yr(e);if(r===null)return null;let o=Ft(r),[,s,a]=n;return Gr[a.toLowerCase()].some(l=>o===`${s}${l}`)?`the file is a declaration generated from ${o} and carries its header (tsc copies it)`:null}i(Vr,"declarationCopySkipReason");var vt={id:"node",extensions:Nt,enabledByDefault:!0,keepsAboveHeader:oe,resolveContentSkipReason(e,t){return Vr(e,t)},resolveCommentSyntax(e){return Wr(e)}};import{extname as Jr}from"node:path";var Rt=[".php"];function qr(e){let t=Jr(e).toLowerCase();return Rt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(qr,"resolvePhpCommentSyntax");var Lt=/^<\?php(?:\s|$)/i,jt={id:"php",extensions:Rt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&Lt.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return Lt.test(e.replace(/^\uFEFF/,""))?null:"the file does not start with <?php, so a comment at the top would be output as text"},resolveCommentSyntax(e){return qr(e)}};import{extname as Kr}from"node:path";var Mt=[".py"],Zr=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function Xr(e,t){return oe(e,t)||t<=1&&Zr.test(e)}i(Xr,"keepsAboveHeader");var Pt={id:"python",extensions:Mt,enabledByDefault:!0,keepsAboveHeader:Xr,resolveCommentSyntax(e){let t=Kr(e).toLowerCase();return Mt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Qr}from"node:path";var It=[".rs"];function eo(e){let t=Qr(e).toLowerCase();return It.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(eo,"resolveRustCommentSyntax");var Ot={id:"rust",extensions:It,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return eo(e)}};import{extname as to}from"node:path";var Tt=[".yaml",".yml"];function no(e){let t=to(e).toLowerCase();return Tt.includes(t)?{kind:"line",linePrefix:"#"}:null}i(no,"resolveYamlCommentSyntax");var Ht={id:"yaml",extensions:Tt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return no(e)}};var se=[gt,xt,Et,St,Dt,At,vt,jt,Pt,Ot,Ht],ro=new Map(se.map(e=>[e.id,e]));function oo(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(oo,"applySyntaxOverride");function _t(e){if(e==null)return[];if(!Array.isArray(e)||e.some(n=>typeof n!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=se.filter(n=>n.requiresForce===!0).map(n=>n.id);for(let n of e){if(!ro.has(n))throw new Error(`forcedDetectors: unknown detector "${n}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(n))throw new Error(`forcedDetectors: "${n}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}i(_t,"resolveForcedDetectors");function O(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),n=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),r=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return se.filter(o=>o.requiresForce===!0?r.has(o.id)&&!n.has(o.id):t.size>0?t.has(o.id):n.has(o.id)?!1:o.enabledByDefault)}i(O,"getEnabledDetectors");function Bt(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(n=>n.toLowerCase()));let t=O(e);return new Set(t.flatMap(n=>n.extensions))}i(Bt,"getAllowedExtensions");function Ut(e,t={}){let n=be(e).toLowerCase();if(O(t).some(a=>a.extensions.includes(n)&&a.resolveCommentSyntax(e)!==null))return null;if(n.length===0)return"the file has no extension, so its comment syntax is unknown";let o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),s=se.find(a=>a.requiresForce===!0&&a.extensions.includes(n)&&!o.has(a.id));return s?`${n} files get a header only when forced (--force-detector ${s.id} / forcedDetectors: ["${s.id}"])`:`no enabled detector handles ${n} files`}i(Ut,"getHeaderSkipReason");function Wt(e,t={}){let n=be(e).toLowerCase(),r=Array.isArray(t.detectors)?t.detectors:O(t);for(let o of r){if(!o.extensions.includes(n))continue;let s=o.resolveCommentSyntax(e);if(s){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return oo(s,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(Wt,"getCommentSyntaxForFile");function zt(e,t){let n=be(e).toLowerCase();return O(t).find(r=>r.extensions.includes(n))}i(zt,"detectorForFile");function ae(e,t,n={}){let r=zt(e,n);if(!r)return"";let o=typeof r.resolvePreservedPrefix=="function"?r.resolvePreservedPrefix(e,t):"",s=r.keepsAboveHeader,a=ie(t.slice(o.length),(c,l)=>re(c)||typeof s=="function"&&s(c,l),o.split(`
|
|
7
|
+
`).length-1);return`${o}${a}`}i(ae,"getPreservedPrefixForFile");function Gt(e,t,n={}){let r=zt(e,n);return r&&typeof r.resolveContentSkipReason=="function"?r.resolveContentSkipReason(t,e):null}i(Gt,"getContentSkipReason");var Yt=200,Z=1,ce=2;function T(e,t,n){if(e==null)return n;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(e)}`);return e}i(T,"resolveLayoutCount");import{existsSync as yo}from"node:fs";import{join as Fe,relative as sn,resolve as Ne,sep as Ce}from"node:path";import{realpath as xo,stat as wo}from"node:fs/promises";import{access as io,readdir as so,readFile as Is,stat as ao}from"node:fs/promises";import{constants as co}from"node:fs";import{dirname as Hs,join as lo,resolve as _s}from"node:path";async function Ee(e){try{return await io(e,co.F_OK),!0}catch{return!1}}i(Ee,"pathExists");async function ke(e,t){let n=[],r=await so(e,{withFileTypes:!0});for(let o of r){let s=lo(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(s,o.name)===!0)continue;if(o.isDirectory()){let l=await ke(s,t);n.push(...l);continue}if(!o.isFile())continue;let a=o.name.lastIndexOf(".");if(a===-1)continue;let c=o.name.slice(a).toLowerCase();t.allowedExtensions.has(c)&&n.push(s)}return n}i(ke,"walkFiles");async function Vt(e){let t=await ao(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(Vt,"readFileDates");function Jt(e){let t=e.indexOf("<");for(;t!==-1;){let n=e.indexOf(">",t+1);if(n===-1)return!1;if(n>t+1)return!0;t=e.indexOf("<",n+1)}return!1}i(Jt,"hasAngleTag");function qt(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}i(qt,"trimTrailingSlashes");import{execFile as uo}from"node:child_process";import{lstat as fo,readFile as mo}from"node:fs/promises";import{dirname as Kt,isAbsolute as po,join as Qt,relative as en,resolve as Se,sep as tn}from"node:path";import ho from"ignore";function Zt(e,t){return new Promise(n=>{uo("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(r,o)=>{if(!r){n({code:0,stdout:o});return}n({code:typeof r.code=="number"?r.code:-1,stdout:""})})})}i(Zt,"runGitCommand");function De(e,t){return en(e,t).split(tn).join("/")}i(De,"toPosixRelative");async function nn(e){try{return ho().add(await mo(e,"utf8"))}catch{return null}}i(nn,"readIgnoreFile");async function go(e){return fo(Qt(e,".git")).then(()=>!0,()=>!1)}i(go,"hasGitEntry");function Xt(e,t,n){for(let r=e.length-1;r>=0;r--){let{base:o,rules:s}=e[r],a=s.test(`${De(o,t)}${n?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}i(Xt,"matchesRules");async function rn(e,t){let n=await nn(Qt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:n?[...t,{base:e,rules:n}]:t}}i(rn,"buildRulesContext");async function $e(e){let[t,n]=await Promise.all([Zt(e,["check-ignore","-q","."]),Zt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||n.code!==0)return rn(e,[]);let r=new Set,o=new Set;for(let s of n.stdout.split("\0")){let a=s.endsWith("/")?s.slice(0,-1):s;if(a.length!==0){r.add(a);for(let c=a.indexOf("/");c!==-1;c=a.indexOf("/",c+1))o.add(a.slice(0,c))}}return{kind:"git",root:e,entries:r,dirs:o}}i($e,"resolveScopeContext");function on(e){let t=Se(e.root),n=e.gitignore;if(n===!1)return{isIgnored:i(async()=>!1,"isIgnored")};let r=new Map,o=i(async()=>{if(typeof n!="string"&&!Array.isArray(n))return $e(t);let c=typeof n=="string"?[n]:n.filter(u=>typeof u=="string"),l=[];for(let u of c){let f=await nn(Se(t,u));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),s=i(c=>{let l=r.get(c);return l||(l=c===t?o():a(c),r.set(c,l)),l},"contextFor"),a=i(async c=>{let l=await s(Kt(c));return l.kind==="git"?l.entries.has(De(l.root,c))?$e(c):l:!l.nested||l.excluded?l:Xt(l.matchers,c,!0)?{...l,excluded:!0}:await go(c)?$e(c):rn(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let u=Se(c),f=en(t,u);if(f.length===0||f===".."||f.startsWith(`..${tn}`)||po(f))return!1;let p=await s(Kt(u));if(p.kind==="git"){let y=De(p.root,u);return!(p.entries.has(y)||l&&p.dirs.has(y))}return p.excluded||Xt(p.matchers,u,l)}}}i(on,"createIgnoreFilter");function bo(e){return Bt(e)}i(bo,"resolveExtensions");var Eo=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),ln=new Set([".git",...Eo]),ko=Object.freeze(["autoload.php","modules.txt"]);function an(e,t){return ln.has(t)?!0:t==="vendor"&&ko.some(n=>yo(Fe(e,n)))}i(an,"isNeverWalked");function Ae(e){return qt(e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}i(Ae,"normalizeFolderPath");function So(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{path:t,recursive:!0};if(t&&typeof t=="object"&&typeof t.path=="string")return{path:t.path,recursive:t.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(t)} (expected a path string or { path, recursive? })`)}):[]}i(So,"resolveIncludeFolders");function cn(e,t){let n=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${n})`)}i(cn,"reportSkippedIncludeFolder");function $o(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let n=Ne(e),r=[],o=new Set;for(let s of t){if(typeof s!="string")continue;let a=Ae(s);if(a.length!==0){if(a.includes("/")){r.push(Ne(n,a));continue}o.add(a)}}return(s,a)=>{if(o.has(a))return!0;for(let l of r)if(s===l||s.startsWith(`${l}/`))return!0;let c=Ae(sn(n,s));return r.some(l=>{let u=Ae(sn(n,l));return c===u||c.startsWith(`${u}/`)})}}i($o,"buildExclusionMatcher");async function ve(e){let t=bo(e),n=So(e.includeFolders),r=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=$o(e.projectRoot,r),s=on({root:e.projectRoot,gitignore:e.gitignore}),a=i(async(d,m)=>an(d,m)||o(d,m)||await s.isIgnored(d,!0),"shouldSkipDirectory"),c=n.length>0?n.map(d=>({includeFolder:d.path,rootPath:Fe(e.projectRoot,d.path),recursive:d.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],l=[];for(let d of c){let m=await wo(d.rootPath).catch(b=>b);if(m instanceof Error){if(m.code==="ENOENT"){cn(d.includeFolder,m);continue}throw m}if(!m.isDirectory()){cn(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let w=await xo(d.rootPath).catch(()=>Ne(d.rootPath));l.push({...d,realRoot:w})}let u=i((d,m)=>{if(d.realRoot===m.realRoot)return d.recursive||!m.recursive;let w=d.realRoot.endsWith(Ce)?d.realRoot:`${d.realRoot}${Ce}`;if(!d.recursive||!m.realRoot.startsWith(w))return!1;let b=d.rootPath;for(let S of m.realRoot.slice(w.length).split(Ce))if(b=Fe(b,S),an(b,S)||o(b,S))return!1;return!0},"covers"),f=[...l].sort((d,m)=>d.realRoot.length-m.realRoot.length||Number(m.recursive)-Number(d.recursive)),p=[];for(let d of f)p.some(m=>u(m,d))||p.push(d);let y=[];for(let d of l){if(!p.includes(d))continue;let m=await ke(d.rootPath,{allowedExtensions:t,ignoreFolders:ln,shouldSkipDirectory:a,recursive:d.recursive});y.push(...m)}let g=[];for(let d of new Set(y))!o(d,d.split("/").at(-1)||"")&&!await s.isIgnored(d,!1)&&g.push(d);return g}i(ve,"discoverFiles");import{basename as Ko,dirname as Zo,extname as Xo,resolve as Ie}from"node:path";import{dirname as En,isAbsolute as Po,join as kn,relative as Io,resolve as Sn,sep as Oo}from"node:path";import{readFile as Do}from"node:fs/promises";import{join as Co}from"node:path";async function Ao(e){try{return await Do(e,"utf8")}catch{return null}}i(Ao,"readManifest");async function R(e,t){let n=[];for(let r of t){let o=await Ao(Co(e,r));o!==null&&n.push({file:r,content:o})}return n.length>0?{dir:e,manifest:n[0].file,files:n}:null}i(R,"detectManifests");function H(e,t){return e.files.find(n=>n.file===t)?.content??null}i(H,"manifestContent");function C(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(C,"cleanName");function Le(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return C(t===-1?e:e.slice(0,t))}i(Le,"personName");function le(e){try{return JSON.parse(e)}catch{return}}i(le,"parseJsonManifest");function*Re(e,t){let n="";for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.startsWith("[")){let s=o.match(/^\[([^[\]]+)\]/);n=s?s[1].split(".").map(a=>a.trim()).join("."):"";continue}n===t&&(yield o)}}i(Re,"sectionLines");function X(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of Re(e,t)){let s=o.match(r);if(s)return C(s[1]??s[2])}}i(X,"readTomlString");function je(e,t,n){let r=new RegExp(`^${n}\\s*[=:](.*)$`);for(let o of Re(e,t)){let s=o.match(r);if(s)return C(s[1])}}i(je,"readIniValue");function Fo(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*\\[`),o=null;for(let s of Re(e,t)){if(o!==null){o.push(s);continue}let a=s.match(r);a&&(o=[s.slice(a[0].length)])}return o===null?null:o.join(`
|
|
8
|
+
`)}i(Fo,"tomlArrayText");function No(e,t){let n=t;for(;n<e.length;)if(e[n]==="#"){let r=e.indexOf(`
|
|
9
|
+
`,n);n=r===-1?e.length:r+1}else if(/\s/.test(e[n]))n+=1;else break;return n}i(No,"skipTomlSpace");function Q(e,t){let n=Fo(e,t,"authors");if(n===null)return;let r=n.slice(No(n,0)),o=r.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return Le(o[1]??o[2]);let a=r.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return a?C(a[1]??a[2]):void 0}i(Q,"readTomlAuthor");var un=["go.mod"];function vo(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return C(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(vo,"readModulePath");var dn={id:"go",languages:["go"],manifests:un,detect(e){return R(e,un)},read(e){return{name:vo(e.files[0].content)}}};var fn=["package.json"];function Lo(e){let t=C(e?.name),n=C(e?.publisher),r=typeof e?.engines?.vscode=="string";return t&&n&&r?`${n}.${t}`:t}i(Lo,"readPublishedName");function Ro(e){if(e!==null&&typeof e=="object"){let t=e;return C(t.company)??C(t.name)}return Le(e)}i(Ro,"readAuthorCompany");var mn={id:"node",languages:["node"],manifests:fn,detect(e){return R(e,fn)},read(e){let t=le(e.files[0].content);return{name:Lo(t),company:Ro(t?.author)}}};var pn=["composer.json"],hn={id:"php",languages:["php"],manifests:pn,detect(e){return R(e,pn)},read(e){let t=le(e.files[0].content),n=t?.authors;return{name:C(t?.name),company:Array.isArray(n)?C(n[0]?.name):void 0}}};var gn=["pyproject.toml","setup.cfg","setup.py"];function yn(e,t){let n=e.indexOf("setup(");if(n===-1)return;let r=e.slice(n).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return r&&r[2].trim()||void 0}i(yn,"readSetupPyArgument");function jo(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:X(t,"project","name")??X(t,"tool.poetry","name"))??(n===null?void 0:je(n,"metadata","name"))??(r===null?void 0:yn(r,"name"))}i(jo,"readPythonName");function Mo(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Q(t,"project")??Q(t,"tool.poetry"))??(n===null?void 0:je(n,"metadata","author"))??(r===null?void 0:yn(r,"author"))}i(Mo,"readPythonCompany");var xn={id:"python",languages:["python"],manifests:gn,detect(e){return R(e,gn)},read(e){return{name:jo(e),company:Mo(e)}}};var wn=["Cargo.toml"],bn={id:"rust",languages:["rust"],manifests:wn,detect(e){return R(e,wn)},read(e){let t=e.files[0].content;return{name:X(t,"package","name"),company:Q(t,"package")}}};var To=[mn,xn,hn,bn,dn],$n=["name","company"];async function Me(e,t,n){let o=(await Promise.all(t.map(async a=>({driver:a,detection:await a.detect(e)})))).filter(a=>a.detection!==null),s=o.filter(a=>typeof n=="string"&&a.driver.languages.includes(n));return[...s,...o.filter(a=>!s.includes(a))]}i(Me,"claimFolder");function Ho(e,t){let n=Io(t,e);return n!==""&&n!==".."&&!n.startsWith(`..${Oo}`)&&!Po(n)}i(Ho,"isStrictlyInside");async function Dn(e,t={}){let n=Array.isArray(t.drivers)?t.drivers:To,r=typeof t.scanRoot=="string"?Sn(t.scanRoot):null,o=Sn(e),s=await Me(o,n,t.language);for(;s.length===0;){if(await Ee(kn(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=En(o);if(f===o)return null;o=f,s=await Me(o,n,t.language)}let a={},c={},l=o,u=s;for(;;){for(let{driver:p,detection:y}of u){let g=p.read(y);for(let d of $n)a[d]===void 0&&g[d]!==void 0&&(a[d]=g[d],c[d]={driver:p.id,manifest:y.manifest,dir:l})}if($n.every(p=>a[p]!==void 0)||r===null||!Ho(l,r)||await Ee(kn(l,".git")))break;l=En(l),u=await Me(l,n,t.language)}return{root:o,marker:s[0].detection.manifest,drivers:s.map(f=>f.driver.id),fields:a,sources:c}}i(Dn,"resolveManifestProject");import{execFile as _o}from"node:child_process";import{basename as Bo,dirname as Uo}from"node:path";import{promisify as Wo}from"node:util";var Pe=Wo(_o);async function v(e,t){try{let{stdout:n}=await Pe("git",t,{cwd:e}),r=n.trim();return r.length>0?r:null}catch{return null}}i(v,"runGit");function Cn(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}i(Cn,"isEscaped");function zo(e){let t=e.trim();if(!t.endsWith(")")||Cn(t,t.length-1))return t;let n=0;for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(o!=="("&&o!==")"||Cn(t,r))&&(n+=o===")"?1:-1,n===0))return t.slice(0,r).trim()}return t}i(zo,"stripUidComment");function Go(e){let t=e.trim();if(t.length===0)return{authorName:null,authorEmail:null};let n=t.match(/<([^>\n]+)>\s*$/),r=n?.[1]?.trim()||null,o=(n?t.slice(0,n.index):t).trim();return{authorName:zo(o)||o||null,authorEmail:r}}i(Go,"parseSignerUid");async function Yo(e,t){try{let{stdout:n}=await Pe(e,t),r=n.trim();return r.length>0?r:null}catch{return null}}i(Yo,"runProgram");function Vo(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16)))}i(Vo,"decodeColonField");async function Jo(e){let t=await v(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let n=await v(e,["config","--get","user.signingkey"]);if(!n)return null;let r=await v(e,["config","--get","gpg.openpgp.program"])||await v(e,["config","--get","gpg.program"])||"gpg",o=await Yo(r,["--batch","--with-colons","--list-keys",n]);if(!o)return null;for(let s of o.split(`
|
|
10
|
+
`)){let a=s.split(":");if(a[0]==="uid"&&a[1]!=="r"&&a[1]!=="e"&&a[9])return Vo(a[9])}return null}i(Jo,"readSigningKeyUid");async function An(e,t={}){let n=await v(e,["config","--get","user.name"]),r=await v(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Jo(e)||await v(e,["log","-1","--format=%GS"]),s=Go(o||"");n=s.authorName||n,r=r||s.authorEmail}if(!n||!r){let o=await v(e,["log","-1","--format=%an|%ae"]);if(o){let[s,a]=o.split("|");n=n||s||null,r=r||a||null}}return{authorName:n,authorEmail:r}}i(An,"detectGitAuthor");function Fn(e){return e.replace(/z$/i,"+00:00")}i(Fn,"canonicalGitDate");async function Nn(e,t){let n=await v(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!n)return null;let r=n.split(`
|
|
11
|
+
`)[0],[o,s]=r.split("|");if(!o||!s)return null;let a=Number.parseInt(s,10);return Number.isNaN(a)?null:{date:Fn(o),timestamp:a}}i(Nn,"getGitCreationDate");async function vn(e,t){let n=await v(e,["log","-1","--format=%aI|%at","--",t]);if(!n)return null;let[r,o]=n.split("|");if(!r||!o)return null;let s=Number.parseInt(o,10);return Number.isNaN(s)?null:{date:Fn(r),timestamp:s}}i(vn,"getGitLastModifiedDate");var qo=256*1024*1024;async function Ln(e){let t=Uo(e);if(await v(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:n}=await Pe("git",["show",`HEAD:./${Bo(e)}`],{cwd:t,encoding:"utf8",maxBuffer:qo});return{state:"tracked",content:n}}catch{return{state:"untracked",content:null}}}i(Ln,"readGitHeadFile");function Qo(e){return Ko(e)||"project"}i(Qo,"folderName");function ei(e,t){if(typeof t!="string")return e;let n=t.trim();return n.length===0||Jt(e)?e:`${e} <${n}>`}i(ei,"formatAuthorNameWithCompany");async function ti(e,t={}){let n=Array.isArray(t.detectors)?t.detectors:O(t),r=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=r.length>0?n.find(u=>u.extensions.includes(r)):void 0,s=await Dn(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),a=s?s.root:Ie(e),c=s?.sources.name,l=s?.sources.company;return{language:o?.id??s?.drivers[0]??"unknown",rootDir:a,marker:s?s.marker:null,projectName:s?.fields.name??Qo(a),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:a},companyName:s?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:s?s.drivers:[]}}i(ti,"detectProjectFromMarkers");async function Oe(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),n=Ie(t),r=O(e),o=e.targetFilePath?Zo(n):n,s=e.targetFilePath?Xo(n).toLowerCase():"",a=Ie(e.projectRoot||e.cwd||process.cwd()),c=await ti(o,{detectors:r,preferredExtension:s,scanRoot:a}),l=await An(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:ei(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(Oe,"resolveProjectMetadata");function ni(e){return Te({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(ni,"formatDateWithTimezone");function Te(e){return`${Pn(e," ")} ${In(e.offsetMinutes)}`}i(Te,"formatSpaceDate");function jn(e){if(typeof e!="string")throw new Error(`timezone must be an IANA time zone name string, such as "America/Los_Angeles" or "UTC" (got ${typeof e})`);try{Mn(e)}catch(t){throw new Error(`Unknown time zone "${e}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:t})}return e}i(jn,"assertTimeZone");var Rn=new Map;function Mn(e){let t=Rn.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"}),Rn.set(e,t)),t}i(Mn,"getZoneFormatter");function He(e,t){let n={};for(let o of Mn(t).formatToParts(new Date(e*1e3)))n[o.type]=Number(o.value);let r=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)/1e3;return{year:n.year,month:n.month,day:n.day,hour:n.hour,minute:n.minute,second:n.second,offsetMinutes:(r-e)/60}}i(He,"toZonedDateParts");function Pn(e,t){let n=i(r=>String(r).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${n(e.month)}-${n(e.day)}${t}${n(e.hour)}:${n(e.minute)}:${n(e.second)}`}i(Pn,"formatWallClock");function In(e){let t=i(r=>String(r).padStart(2,"0"),"pad"),n=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(n/60))}:${t(n%60)}`}i(In,"formatOffset");function ue(e=new Date){return{date:ni(e),timestamp:Math.floor(e.getTime()/1e3)}}i(ue,"toDatePayload");var ri=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function _(e){let t=ri.exec(e.trim());if(!t)return null;let[n,r,o,s,a,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),u=t[8]==="-"?-l:l,f=new Date(Date.UTC(n,r-1,o,s,a,c));return!(f.getUTCFullYear()===n&&f.getUTCMonth()===r-1&&f.getUTCDate()===o&&f.getUTCHours()===s&&f.getUTCMinutes()===a&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:n,month:r,day:o,hour:s,minute:a,second:c,offsetMinutes:u,timestamp:Math.floor(f.getTime()/1e3)-u*60}}i(_,"parseHeaderDate");function _e(e){return`${Pn(e,"T")}${In(e.offsetMinutes)}`}i(_e,"formatIsoDate");var oi={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function On(e,t){let n=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return n?n[1].trim():null}i(On,"readHeaderField");function Be(e){let t=null;for(let{source:n,payload:r}of e)r&&(!t||r.timestamp<t.payload.timestamp)&&(t={source:n,payload:r});return t}i(Be,"pickOldestDate");function Hn({existing:e,gitCreated:t,filesystemCreated:n,fixCreatedDate:r=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:n}];if(!e)return Be(o);if(!r)return{source:"existing-header",payload:e};let s=_(e.date)?e:null;return Be([{source:"existing-header",payload:s},...o])}i(Hn,"resolveCreatedDate");function _n(e,t=null){if(t)return He(e.timestamp,t).year;let n=_(e.date);return n?n.year:new Date(e.timestamp*1e3).getFullYear()}i(_n,"dateYear");function Tn(e,t,n,r){let o=e.match(/^(.+?)\s*\((\d+)\)$/),s=o?_(o[1]):null;if(!o||!s)return r.push({check:`${n}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let a=Number.parseInt(o[2],10);return a!==s.timestamp&&r.push({check:`${n}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${s.timestamp})`,message:`${t} epoch ${a} does not match ${o[1]} (expected ${s.timestamp})`}),{text:o[1],timestamp:s.timestamp}}i(Tn,"checkDateValue");function Bn(e,t={},n={}){let r=[],o=On(e,"@Date"),s=o===null?null:Tn(o,"@Date","created",r),a=Be([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(s&&a&&s.timestamp>a.payload.timestamp){let f=oi[a.source];r.push({check:"created-newer-than-source",field:"@Date",advisory:n.strictCreatedDate!==!0,value:o,expected:`${a.payload.date} (${a.payload.timestamp})`,source:a.source,message:`@Date ${s.text} is later than the ${f} ${a.payload.date} (${a.payload.timestamp})`})}let c=On(e,"@Last modified time"),l=c===null?null:Tn(c,"@Last modified time","modified",r),u=t.gitLastModified;return l&&u&&l.timestamp!==u.timestamp&&r.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${u.date} (${u.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${u.date} (${u.timestamp})`}),r}i(Bn,"checkHeaderDates");function Ue(e){if(!e)return null;let t=_(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}i(Ue,"repairDateEpoch");function Un(e){let t=_(e.date);return t?{date:_e(t),timestamp:t.timestamp}:e}i(Un,"normalizeDatePayload");function Wn(e,t){let n=_(e.date);if(!n)return e;let r=He(n.timestamp,t);return r.offsetMinutes===n.offsetMinutes||!Number.isInteger(r.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?_e(r):Te(r),timestamp:n.timestamp}}i(Wn,"convertDatePayload");import{relative as si}from"node:path";import{extname as ii}from"node:path";function B(e,t={}){let n=ii(e).toLowerCase(),r=T(t.spacing,"spacing",Z);return n.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:r}:{...Wt(e,t),spacing:r}}i(B,"getHeaderSyntaxForFile");function zn(e,t){let n=e.spacing??Z;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",u=Array.from({length:n},()=>c);return[...u,...t.map(f=>`${c}${l}${f}`),...u].join(`
|
|
12
|
+
`)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),s=e.blockEnd||(e.kind==="html"?"-->":" */"),a=Array.from({length:n},()=>o.trimEnd());return[r,...a,...t.map(c=>`${o}${c}`),...a,s].join(`
|
|
13
|
+
`)}i(zn,"renderHeaderLines");function Gn(e){let t=si(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/"),n=B(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),r=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,s=e.lastModifiedByName||e.authorName,a=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",u=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${r}`,`@Email: <${o}>`,"-----",`@Last modified by: ${s} (${a})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return zn(n,u)}i(Gn,"buildHeader");var ai=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function I(e,t){let n=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),r=n?n[1].trim():"";return r.length>0?r:null}i(I,"readTag");function ci(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),n=t.indexOf("(",t.lastIndexOf(")")+1);return n===-1?{name:e,email:null}:{name:t.slice(0,n).trimEnd()||null,email:t.slice(n+1)||null}}i(ci,"splitLastModifiedBy");function li(e){let t={startYear:null,endYear:null,companyName:null},n=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!n)return t;let r=e.slice(n[0].length),o=r.match(/^\s*-\s*(\d{4})/);o&&(r=r.slice(o[0].length));let s=r.toLowerCase(),a=s.endsWith("all rights reserved.")?20:s.endsWith("all rights reserved")?19:0;return a===0||!/^\s/.test(r)?t:{startYear:n[1],endYear:o?o[1]:null,companyName:r.slice(0,-a).trim()||null}}i(li,"splitCopyright");function Yn(e){let t=ci(I(e,"Last modified by")),n=li(I(e,"Copyright")),r=I(e,"Email");return{projectName:I(e,"Project"),filename:I(e,"Filename"),createdAt:I(e,"Date"),authorName:I(e,"Author"),authorEmail:r===null?null:r.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:I(e,"Last modified time"),copyrightStartYear:n.startYear,copyrightEndYear:n.endYear,companyName:n.companyName}}i(Yn,"parseHeaderFields");function Vn(e,t){let n=Yn(e??""),r=Yn(t);return ai.filter(o=>n[o]!==r[o]).map(o=>({field:o,previous:n[o],detected:r[o]}))}i(Vn,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(ee,"escapeRegex");function We(e,t,n={}){let r=t.startsWith("\uFEFF")?"\uFEFF":"",o=t.slice(r.length),s=`${r}${ae(e,o,n)}`;return{prefix:s,body:t.slice(s.length)}}i(We,"splitPreservedPrefix");function de(e){let t=e.indexOf(`
|
|
10
14
|
`);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
|
|
11
15
|
`:`
|
|
12
|
-
`}i(de,"lineEnding");function
|
|
13
|
-
`).map(p=>{let y=p.replace(/\r$/,"");return{raw:y,text:y.replace(f,"").trim()}})}let
|
|
14
|
-
`).map((f,p)=>({raw:p===0&&f.trim()!==""?`${s}${f.trim()}`:f.trimEnd(),text:(p===0?f:f.replace(a,"")).trim()})),l=c[0].raw===""?1:0,u=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,u)}i(
|
|
15
|
-
`),o=
|
|
16
|
-
`)}i(
|
|
17
|
-
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}i(
|
|
18
|
-
`),n
|
|
19
|
-
`)}i(
|
|
16
|
+
`}i(de,"lineEnding");function z(e,t){if(t.kind==="html"){let r=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${r}[\\s\\S]*?${o}(?:\\r?\\n)*`))}if(t.kind==="line"){let r=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${r}[^\\n]*\\n)+(?:\\r?\\n)*`))}let n=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${n}(?:\\r?\\n)*`))}i(z,"matchHeaderSegment");var Kn=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,ui="Moved out of the file header by fix-headers:";function Zn(e){return e.some(t=>/^@(?:Project|Filename):/.test(t.text))}i(Zn,"isFileHeader");function ze(e,t){let n=e.replace(/(?:\r?\n)+$/,"");if(t.kind==="line"){let f=new RegExp(`^${ee(t.linePrefix||"#")}[ \\t]*`);return n.split(`
|
|
17
|
+
`).map(p=>{let y=p.replace(/\r$/,"");return{raw:y,text:y.replace(f,"").trim()}})}let r=t.kind==="html",o=r?n.replace(/^<!--/,"").replace(/--!?>\s*$/,""):n.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),s=t.blockLinePrefix||(r?" ":" * "),a=r?/^\s*/:/^\s*\*?[ \t]*/,c=o.split(`
|
|
18
|
+
`).map((f,p)=>({raw:p===0&&f.trim()!==""?`${s}${f.trim()}`:f.trimEnd(),text:(p===0?f:f.replace(a,"")).trim()})),l=c[0].raw===""?1:0,u=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,u)}i(ze,"segmentLines");function di(e,t){let n=e.map(o=>{let s=o.text.match(Kn);return o.text===""?"blank":s&&s[1]==="Copyright"?t.copyright?"copyright":(t.copyright=!0,"field"):s?"field":/^-{3,}$/.test(o.text)?"dash":"text"}),r=i((o,s)=>{for(let a=o+s;a>=0&&a<n.length;a+=s)if(n[a]!=="blank"&&n[a]!=="dash")return n[a]==="copyright"?"field":n[a]},"neighbour");return n.map((o,s)=>o==="dash"?r(s,-1)==="field"||r(s,1)==="field"?"separator":"text":o)}i(di,"classifyLines");function fi(e,t="",n={}){let r=B(t,n),o=[],s=[],a={copyright:!1},c=e,l=z(c,r),u=!0;for(;l&&l[0].length>0;){let m=ze(l[0],r),w=di(m,a),b=m.findIndex(S=>S.text!=="");!u&&b!==-1&&m[b].text===ui&&(w[b]="separator"),m.forEach((S,A)=>{w[A]==="copyright"&&s.push(S.text.replace(Kn,"").trim()),o.push({raw:S.raw,kind:w[A]})}),c=c.slice(l[0].length),l=z(c,r),u=!1}let f=o.findIndex(m=>m.kind==="text");if(f===-1)return{foreign:[],copyrights:s};let p=o.map(m=>m.kind).lastIndexOf("text"),y=[],g=[],d=!1;for(let m of o.slice(f,p+1))m.kind==="text"?(y.push(...d?[]:g,m.raw),g=[],d=!1):m.kind==="blank"?g.push(m.raw):d=!0;return{foreign:y,copyrights:s}}i(fi,"splitHeaderText");function mi(e,t,n){let r=t.kind==="html";return t.kind==="line"?e.join(n):[t.blockStart||(r?"<!--":"/**"),...e,t.blockEnd||(r?"-->":" */")].join(n)}i(mi,"renderForeignBlock");function pi(e,t,n){let r=e.split(`
|
|
19
|
+
`),o=n.kind==="html",s=n.kind==="line"?n.linePrefix||"#":(n.blockLinePrefix||(o?" ":" * ")).trimEnd(),a=Math.min(r.length-1,(n.spacing??1)+(n.kind==="line"?0:1)),c=r.length-a;return[...r.slice(0,c),s,...t,...r.slice(c)].join(`
|
|
20
|
+
`)}i(pi,"appendToHeader");function Jn(e){let t=e.trim(),n=t.match(/^copyright\b/i);t=n?t.slice(n[0].length).trimStart():t;for(let c=t.match(/^(?:\(c\)|©)/i);c;c=t.match(/^(?:\(c\)|©)/i))t=t.slice(c[0].length).trimStart();let r=t.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);t=r?t.slice(r[0].length):t,t=t.trimEnd();let o=t.toLowerCase(),s=o.endsWith("all rights reserved.")?20:o.endsWith("all rights reserved")?19:0;t=t.slice(0,t.length-s);let a=t.length;for(;a>0&&`.,; \r
|
|
21
|
+
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}i(Jn,"copyrightHolder");function hi(e,t){let n=e.split(`
|
|
22
|
+
`),r=n.findIndex(c=>c.includes("@Copyright:")),o=n.map(c=>/@[A-Za-z][A-Za-z ]*:/.test(c)).lastIndexOf(!0),s=r!==-1?r:o;if(t.length===0||s===-1)return e;let a=n[s].slice(0,n[s].indexOf("@"));return[...n.slice(0,s+1),...t.map(c=>`${a}@Copyright: ${c}`),...n.slice(s+1)].join(`
|
|
23
|
+
`)}i(hi,"insertCopyrights");function qn(e,t){let n=0,r=z(e,t);for(;r&&r[0].length>0&&Zn(ze(r[0],t));)n+=r[0].length,r=z(e.slice(n),t);return n}i(qn,"leadingHeadersLength");function fe(e,t="",n={}){let r=e.startsWith("\uFEFF")?"\uFEFF":"",o=e.slice(r.length),s=ae(t,o,n),a=B(t,n),c=s.length,l=qn(o.slice(c),a);if(l===0)return e;let u=r===""&&c===0&&o.startsWith("\uFEFF",l);u&&(r="\uFEFF",o=`${o.slice(0,l)}${o.slice(l+1)}`,l+=qn(o.slice(l),a));let f=o.slice(c,c+l),p=o.slice(c+l),y=ae(t,`${s}${p}`,n),g=y.length>s.length?y.slice(s.length):"";if(g===""&&!u)return e;let d=g===""||g.endsWith(`
|
|
20
24
|
`)?g:`${g}${de(e)??`
|
|
21
|
-
`}`;return`${
|
|
22
|
-
`).slice(0,
|
|
23
|
-
`),a=B(t,
|
|
24
|
-
`?k:k.replace(/\r?\n/g
|
|
25
|
-
`,
|
|
26
|
-
`)?D:"",P=`${k}${h}${V.trim()===""?`${
|
|
27
|
-
`).find(k=>k.includes("@Copyright:")),d=new Set(g===void 0?[]:[
|
|
28
|
-
`,b=w.repeat(l+1)
|
|
25
|
+
`}`;return`${r}${s}${d}${f}${p.slice(g.length)}`}i(fe,"restoreTopLines");function me(e,t="",n={}){let{prefix:r,body:o}=We(t,e,n),s=o.split(`
|
|
26
|
+
`).slice(0,Yt).join(`
|
|
27
|
+
`),a=B(t,n);if(!z(s,a))return null;let l=0,u=0;for(;;){let f=s.slice(l),p=z(f,a);if(!p||!Zn(ze(p[0],a)))break;l+=p[0].length,u=l}return u===0?null:{start:r.length,end:r.length+u}}i(me,"findProjectHeader");function pe(e,t,n="",r={}){let o=fe(e,n,r),s=me(o,n,r),a=B(n,r),c=T(r.margin,"margin",ce),l=a.kind==="line"?Math.max(1,c):c,u=i((k,$)=>$===`
|
|
28
|
+
`?k:k.replace(/\r?\n/g,$),"withEol");if(!s){let{prefix:k,body:$}=We(n,o,r),D=de(o)??`
|
|
29
|
+
`,M=u(t,D),V=$.replace(/^(?:\r?\n)+/,""),h=k.replace(/^\uFEFF/,"")!==""&&!k.endsWith(`
|
|
30
|
+
`)?D:"",P=`${k}${h}${V.trim()===""?`${M}${D}`:`${M}${D.repeat(l+1)}${V}`}`;return{nextContent:P,changed:P!==e,header:M,written:M,extraCopyrights:[]}}let f=o.slice(s.start,s.end),{foreign:p,copyrights:y}=fi(f,n,r),g=t.split(`
|
|
31
|
+
`).find(k=>k.includes("@Copyright:")),d=new Set(g===void 0?[]:[Jn(g.slice(g.indexOf("@Copyright:")+11))]),m=[];for(let k of y){let $=Jn(k);d.has($)||(d.add($),m.push(k))}let w=de(o.slice(s.end))??de(f)??`
|
|
32
|
+
`,b=w.repeat(l+1),S=r.strictHeaderBlock!==!1,A=hi(t,m),j=u(p.length>0&&!S?pi(A,p,a):A,w),E=p.length>0&&S?mi(p,a,w):"",U=o.slice(s.end).replace(/^(?:\r?\n)+/,""),G=E===""?U:`${E}${U.trim()===""?w:`${b}${U}`}`,Y=`${o.slice(0,s.start)}${G.trim()===""?`${j}${w}`:`${j}${b}${G}`}`,x=`${j}${E===""?"":`${b}${E}`}`;return{nextContent:Y,changed:Y!==e,header:j,written:x,extraCopyrights:m}}i(pe,"replaceOrInsertHeader");function Ge(e,t="",n={}){let r=fe(e,t,n),o=me(r,t,n);if(o){let l=r.slice(0,o.start),f=pe(r,"",t,{...n,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${f.trim()===""?"":f}`}let{prefix:s,body:a}=We(t,r,n),c=a.replace(/^(?:\r?\n)+/,"");return`${s}${c.trim()===""?"":c}`}i(Ge,"extractHeaderlessBody");function gi(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let l=n-1;l>=0;l-=1)for(let u=r-1;u>=0;u-=1)o[l][u]=e[l]===t[u]?o[l+1][u+1]+1:Math.max(o[l+1][u],o[l][u+1]);let s=[],a=0,c=0;for(;a<n&&c<r;)e[a]===t[c]?(s.push({type:" ",line:e[a]}),a+=1,c+=1):o[a+1][c]>=o[a][c+1]?(s.push({type:"-",line:e[a]}),a+=1):(s.push({type:"+",line:t[c]}),c+=1);for(;a<n;a+=1)s.push({type:"-",line:e[a]});for(;c<r;c+=1)s.push({type:"+",line:t[c]});return s}i(gi,"diffLines");function Xn(e,t){return`${t===0?e:e+1},${t}`}i(Xn,"formatRange");function Qn(e,t,n={}){let r=e===null?[]:e.split(`
|
|
29
33
|
`),o=t.split(`
|
|
30
|
-
`),s=
|
|
31
|
-
`)}i(
|
|
32
|
-
`).length-1;
|
|
34
|
+
`),s=gi(r,o),a=Math.max(0,n.context??3),c=n.lineOffset??0,l=[];if(s.forEach((y,g)=>{if(y.type===" ")return;let d=l[l.length-1];d&&g-d.last<=a*2+1?d.last=g:l.push({first:g,last:g})}),l.length===0)return"";let u=n.fromFile??"a",f=n.toFile??"b",p=[`--- ${e===null?"/dev/null":u}`,`+++ ${f}`];for(let y of l){let g=Math.max(0,y.first-a),d=Math.min(s.length,y.last+a+1),m=s.slice(0,g),w=s.slice(g,d),b=m.filter(E=>E.type!=="+").length+c,S=m.filter(E=>E.type!=="-").length+c,A=w.filter(E=>E.type!=="+").length,j=w.filter(E=>E.type!=="-").length;p.push(`@@ -${Xn(b,A)} +${Xn(S,j)} @@`);for(let E of w)p.push(`${E.type}${E.line}`)}return p.join(`
|
|
35
|
+
`)}i(Qn,"createUnifiedDiff");function bi(e){return mt(e,"configFile")}i(bi,"resolveRuntimeOptions");function Ei(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(n=>typeof n!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(n=>n.trim().length>0)}i(Ei,"resolveInputs");function ki(e){let t=e.match(/@Author:\s*(.+)$/m),n=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:n?.[1]?.trim()}}i(ki,"extractHeaderAuthorIdentity");function Si(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(Si,"extractHeaderLastModifiedIdentity");function $i(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}i($i,"extractHeaderCreatedAt");function Di(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}i(Di,"extractHeaderLastModifiedAt");async function Ci(e,t,n){let r=await Ln(t);return r.state!=="tracked"?{edited:r.state==="untracked",state:r.state}:{edited:Ge(r.content,t,n)!==Ge(e,t,n),state:"tracked"}}i(Ci,"detectContentEdit");async function tr(e={}){let t=await bi(e),n=t.timezone===void 0||t.timezone===null?null:jn(t.timezone),r=t.convertTimezone===!0;if(r&&!n)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");let o=_t(t.forcedDetectors),s=er(t.projectRoot||t.cwd||process.cwd()),a=await Oe({...t,cwd:s});T(t.spacing,"spacing",Z),T(t.margin,"margin",ce);let c=t.check===!0,l=c||t.dryRun===!0,u=t.fixCreatedDate===!0,f=i(x=>x,"keepDate"),p=t.normalizeDateFormat===!0?Un:f,y=n?x=>Wn(x,n):f,g=r?y:f,d={language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore},m=Ei(t.input),w;if(m.length>0){let x=new Set;for(let k of m){let $=er(s,k),D=await xi($).catch(()=>null);if(!D)throw new Error(`Input path does not exist: ${k}`);if(D.isFile())x.add($);else if(D.isDirectory())for(let M of await ve({...d,projectRoot:$}))x.add(M);else throw new Error(`Input path must be a file or directory: ${k}`)}w=Array.from(x)}else w=await ve({...d,projectRoot:s});let b=new Date().getFullYear(),S=[],A=[],j=new Set,E=0,U=0,G=0,Y=[];for(let x of w){let k=Ut(x,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(k!==null){A.push({file:Ye(s,x),reason:k});continue}let $=Ye(s,x),D=await yi(x,"utf8"),M={enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides},V=Gt(x,fe(D,x,M),M);if(V!==null){A.push({file:$,reason:V});continue}let h=await Oe({...t,cwd:s,targetFilePath:x});j.add(`${h.language}:${h.projectRoot}`);let P={language:h.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin,strictHeaderBlock:t.strictHeaderBlock!==!1},he=me(D,x,P),F=he?D.slice(he.start,he.end):"",Ve=F.length>0?ki(F):{},Je=F.length>0?Si(F):{},nr=F.length>0?$i(F):null,rr=F.length>0?Di(F):null,qe=await Vt(x),Ke=Ye(h.projectRoot,x),Ze=await Nn(h.projectRoot,Ke),J=await vn(h.projectRoot,Ke),Xe=ue(qe.createdAt),ge=Hn({existing:Ue(nr),gitCreated:Ze,filesystemCreated:Xe,fixCreatedDate:u}),q=Ue(rr),Qe=ge.source,or=q?"existing-header":J?"git-last-modified":"filesystem-updated",ye=p(Qe==="existing-header"?g(ge.payload):y(ge.payload)),ir=h.copyrightStartYear===null?"created-date":"option",et=h.copyrightStartYear??_n(ye,n),tt=p(q?g(q):y(J||ue(qe.updatedAt))),nt=t.forceAuthorUpdate===!0,sr=t.forceLastModifiedAuthorUpdate===!0,rt=await Ci(D,x,P),ot=sr||rt.edited,it=i(N=>Gn({absoluteFilePath:x,language:h.language,syntaxOptions:P,projectRoot:h.projectRoot,projectName:h.projectName,createdByName:nt?h.authorName:Ve.authorName||h.authorName,createdByEmail:nt?h.authorEmail:Ve.authorEmail||h.authorEmail,lastModifiedByName:ot?h.authorName:Je.authorName||h.authorName,lastModifiedByEmail:ot?h.authorEmail:Je.authorEmail||h.authorEmail,authorName:h.authorName,authorEmail:h.authorEmail,createdAt:ye,lastModifiedAt:N,copyrightStartYear:et,companyName:h.companyName,currentYear:b}),"renderHeader"),st=it(tt),at=pe(D,st,x,P),ar=rt.edited&&q!==null&&J!==null&&q.timestamp<J.timestamp,te=at.changed||ar,ct=te?p(y(ue(new Date))):tt,cr=te?"current-time-on-change":or,lr=te?it(ct):st,L=te?pe(D,lr,x,P):at,ne={file:$,changed:L.changed};if(c){let N=Bn(F,{gitCreated:Ze,gitLastModified:J,filesystemCreated:Xe},{strictCreatedDate:t.strictCreatedDate===!0}),K=N.filter(W=>W.advisory).length;ne.dateIssues=N,G+=K,U+=N.length>K?1:0}if(t.sampleOutput===!0&&L.changed){let N=F.length>0?F.trimEnd():null,K=$.replace(/\\/g,"/"),W=L.written,ur=L.nextContent.slice(0,L.nextContent.indexOf(W)).split(`
|
|
36
|
+
`).length-1;ne.sample={previousValue:N,newValue:W,diff:Qn(N,W,{fromFile:`a/${K}`,toFile:`b/${K}`,lineOffset:ur}),issues:Vn(N,W),detectedValues:{projectName:h.projectName,projectNameSource:h.projectNameSource,language:h.language,projectRoot:h.projectRoot,marker:h.marker,authorName:h.authorName,authorEmail:h.authorEmail,companyName:h.companyName,companyNameSource:h.companyNameSource,copyrightStartYear:et,copyrightStartYearSource:ir,createdAtSource:Qe,lastModifiedAtSource:cr,createdAt:ye,lastModifiedAt:ct}}}if(L.extraCopyrights.length>0){ne.extraCopyrights=L.extraCopyrights;for(let N of L.extraCopyrights)Y.push({file:$,copyright:N})}S.push(ne),L.changed&&(E+=1,l||await wi(x,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(j),filesScanned:w.length-A.length,filesUpdated:E,filesSkipped:A.length,dryRun:l,check:c,...c?{filesWithDateDrift:U,dateAdvisories:G}:{},copyrightWarnings:Y,changes:S,skipped:A}}i(tr,"fixHeaders");function Ai(e){return tr(e)}i(Ai,"fixHeaders");var Lc=Ai;export{Lc as default,Ai as fixHeaders};
|
|
33
37
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export namespace detector {
|
|
2
|
+
export let id: string;
|
|
3
|
+
export { extensions };
|
|
4
|
+
export let enabledByDefault: boolean;
|
|
5
|
+
export function resolveContentSkipReason(content: any): string;
|
|
6
|
+
export function resolveCommentSyntax(filePath: any): {
|
|
7
|
+
kind: "block";
|
|
8
|
+
blockStart: string;
|
|
9
|
+
blockLinePrefix: string;
|
|
10
|
+
blockEnd: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @fileoverview C and C++ detector implementation.
|
|
15
|
+
* @module fix-headers/detectors/c
|
|
16
|
+
*/
|
|
17
|
+
declare const extensions: string[];
|
|
18
|
+
export {};
|
|
@@ -96,7 +96,8 @@ export function getPreservedPrefixForFile(filePath: string, content: string, opt
|
|
|
96
96
|
}): string;
|
|
97
97
|
/**
|
|
98
98
|
* Says why a file's content cannot carry a header (a PHP file that does not open with `<?php`,
|
|
99
|
-
* where a comment at the top would be output as text
|
|
99
|
+
* where a comment at the top would be output as text; third-party C with its own license notice; a
|
|
100
|
+
* declaration file carrying the header `tsc` copied from its source), or null when it can.
|
|
100
101
|
* @param {string} filePath - File path.
|
|
101
102
|
* @param {string} content - File content.
|
|
102
103
|
* @param {{ enabledDetectors?: string[], disabledDetectors?: string[], forcedDetectors?: string[] }} [options={}] - Runtime options.
|
|
@@ -120,7 +121,7 @@ export function getContentSkipReason(filePath: string, content: string, options?
|
|
|
120
121
|
* resolveCommentSyntax: (filePath: string) => ({kind: "block" | "line" | "html", linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string} | null),
|
|
121
122
|
* resolvePreservedPrefix?: (filePath: string, content: string) => string,
|
|
122
123
|
* keepsAboveHeader?: (line: string, index: number) => boolean,
|
|
123
|
-
* resolveContentSkipReason?: (content: string) => string | null
|
|
124
|
+
* resolveContentSkipReason?: (content: string, filePath: string) => string | null
|
|
124
125
|
* }} DetectorProfile
|
|
125
126
|
* A file-type detector: which extensions it handles and the comment syntax of those files, and
|
|
126
127
|
* what stays above the header: `resolvePreservedPrefix` takes a leading block (front matter),
|
|
@@ -162,5 +163,5 @@ export type DetectorProfile = {
|
|
|
162
163
|
} | null);
|
|
163
164
|
resolvePreservedPrefix?: (filePath: string, content: string) => string;
|
|
164
165
|
keepsAboveHeader?: (line: string, index: number) => boolean;
|
|
165
|
-
resolveContentSkipReason?: (content: string) => string | null;
|
|
166
|
+
resolveContentSkipReason?: (content: string, filePath: string) => string | null;
|
|
166
167
|
};
|
|
@@ -3,6 +3,7 @@ export namespace detector {
|
|
|
3
3
|
export { extensions };
|
|
4
4
|
export let enabledByDefault: boolean;
|
|
5
5
|
export { isShebang as keepsAboveHeader };
|
|
6
|
+
export function resolveContentSkipReason(content: any, filePath: any): string;
|
|
6
7
|
export function resolveCommentSyntax(filePath: any): {
|
|
7
8
|
kind: "block";
|
|
8
9
|
blockStart: string;
|
|
@@ -20,13 +20,13 @@ export function compareHeaderFields(previousHeader: string | null, nextHeader: s
|
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
* @Project: @cldmv/fix-headers
|
|
23
|
-
* @Filename:
|
|
23
|
+
* @Filename: src/header/fields.mjs
|
|
24
24
|
* @Date: 2026-09-28T09:14:18-07:00 (1790612058)
|
|
25
25
|
* @Author: Nate Corcoran <CLDMV>
|
|
26
26
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
27
27
|
* -----
|
|
28
28
|
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
29
|
-
* @Last modified time: 2026-
|
|
29
|
+
* @Last modified time: 2026-11-25T13:07:26-08:00 (1795640846)
|
|
30
30
|
* -----
|
|
31
31
|
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
32
32
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @Project: @cldmv/fix-headers
|
|
4
|
-
* @Filename:
|
|
4
|
+
* @Filename: src/utils/diff.mjs
|
|
5
5
|
* @Date: 2026-09-28T09:14:18-07:00 (1790612058)
|
|
6
6
|
* @Author: Nate Corcoran <CLDMV>
|
|
7
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
8
|
* -----
|
|
9
9
|
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
-
* @Last modified time: 2026-
|
|
10
|
+
* @Last modified time: 2026-11-25T13:07:26-08:00 (1795640846)
|
|
11
11
|
* -----
|
|
12
12
|
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
13
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @Project: @cldmv/fix-headers
|
|
4
|
-
* @Filename:
|
|
4
|
+
* @Filename: src/utils/text.mjs
|
|
5
5
|
* @Date: 2026-10-31T16:30:00-07:00 (1793489400)
|
|
6
6
|
* @Author: Nate Corcoran <CLDMV>
|
|
7
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
8
|
* -----
|
|
9
9
|
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
-
* @Last modified time: 2026-
|
|
10
|
+
* @Last modified time: 2026-11-25T13:07:26-08:00 (1795640846)
|
|
11
11
|
* -----
|
|
12
12
|
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
13
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @Project: @cldmv/fix-headers
|
|
4
|
-
* @Filename:
|
|
4
|
+
* @Filename: src/utils/time.mjs
|
|
5
5
|
* @Date: 2026-03-01T17:59:32-08:00 (1772416772)
|
|
6
6
|
* @Author: Nate Corcoran <CLDMV>
|
|
7
7
|
* @Email: <Shinrai@users.noreply.github.com>
|
|
8
8
|
* -----
|
|
9
9
|
* @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
|
|
10
|
-
* @Last modified time: 2026-
|
|
10
|
+
* @Last modified time: 2026-11-25T13:07:26-08:00 (1795640846)
|
|
11
11
|
* -----
|
|
12
12
|
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
13
|
*
|