@cldmv/fix-headers 2.2.2 → 2.2.4
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 +72 -6
- package/bin/fix-headers.mjs +34 -15
- package/dist/index.cjs +6 -4
- package/dist/index.mjs +31 -14
- package/package.json +11 -7
- package/types/index.d.mts +2 -2
- package/types/src/core/fix-headers.d.mts +14 -2
- package/types/src/detectors/css.d.mts +1 -0
- package/types/src/detectors/go.d.mts +1 -0
- package/types/src/detectors/index.d.mts +32 -7
- package/types/src/detectors/node.d.mts +2 -1
- package/types/src/detectors/php.d.mts +2 -0
- package/types/src/detectors/python.d.mts +9 -1
- package/types/src/detectors/rust.d.mts +1 -0
- package/types/src/detectors/top-lines.d.mts +30 -0
- package/types/src/detectors/yaml.d.mts +1 -0
- package/types/src/header/parser.d.mts +75 -7
- package/types/src/utils/text.d.mts +33 -0
- /package/types/src/{fix-header.d.mts → index.d.mts} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
var _r=Object.defineProperty;var i=(e,t)=>_r(e,"name",{value:t,configurable:!0});import{readFile as Co,stat as vo,writeFile as Fo}from"node:fs/promises";import{relative as Re,resolve as Lr}from"node:path";import{readFile as Ur}from"node:fs/promises";import{createRequire as Br}from"node:module";import{dirname as zr,isAbsolute as Yr,resolve as et}from"node:path";var Gr=3e4,Wr=new Set(["localhost","127.0.0.1","[::1]"]);function se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(se,"isPlainObject");function ae(e,t){let r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=se(r[n])&&se(o)?ae(r[n],o):o);return r}i(ae,"mergeConfig");function tt(e){return e.kind==="file"?e.path:e.href}i(tt,"describeSource");async function Vr(e){if(e.kind==="file")return{text:await Ur(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(Gr)})}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 Qe(e){if(e.protocol==="http:"&&!Wr.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}i(Qe,"toUrlSource");function Jr(e,t){if(/^https?:\/\//i.test(e))return Qe(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${tt(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 Qe(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||Yr(e))return{kind:"file",path:et(zr(t.path),e)};try{return{kind:"file",path:Br(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(Jr,"resolveReference");function qr(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(qr,"readExtends");async function rt(e,t){let r=tt(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await Vr(e),s;try{s=JSON.parse(n)}catch(u){throw new Error(`Config ${r} is not valid JSON: ${u.message}`,{cause:u})}if(!se(s))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:a,...l}=s,c={};for(let u of qr(a,r))c=ae(c,await rt(Jr(u,o),[...t,r]));return ae(c,l)}i(rt,"loadSource");function Kr(e,t=process.cwd()){return rt({kind:"file",path:et(t,e)},[])}i(Kr,"loadConfigFile");async function nt(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 Kr(r,n),...e};return delete o[t],o}i(nt,"applyConfigOption");import{extname as ce}from"node:path";import{extname as Xr}from"node:path";var ot=[".css"];function Zr(e){let t=Xr(e).toLowerCase();return ot.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Zr,"resolveCssCommentSyntax");var it={id:"css",extensions:ot,enabledByDefault:!0,resolveCommentSyntax(e){return Zr(e)}};import{extname as Qr}from"node:path";var st=[".go"];function en(e){let t=Qr(e).toLowerCase();return st.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(en,"resolveGoCommentSyntax");var at={id:"go",extensions:st,enabledByDefault:!0,resolveCommentSyntax(e){return en(e)}};import{extname as tn}from"node:path";var ct=[".html",".htm"];function rn(e){let t=tn(e).toLowerCase();return ct.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(rn,"resolveHtmlCommentSyntax");var lt={id:"html",extensions:ct,enabledByDefault:!0,resolveCommentSyntax(e){return rn(e)}};import{extname as nn}from"node:path";var ut=[".jsonv",".jsonc",".json5"];function on(e){let t=nn(e).toLowerCase();return ut.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(on,"resolveJsonCommentSyntax");var dt={id:"json",extensions:ut,enabledByDefault:!0,resolveCommentSyntax(e){return on(e)}};import{extname as sn}from"node:path";var ft=[".md",".markdown"];function an(e){let t=sn(e).toLowerCase();return ft.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(an,"resolveMarkdownCommentSyntax");function cn(e,t){let r=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return r?r[0]:""}i(cn,"resolveMarkdownPreservedPrefix");var mt={id:"markdown",extensions:ft,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return cn(e,t)},resolveCommentSyntax(e){return an(e)}};import{extname as ln}from"node:path";var pt=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function un(e){let t=ln(e).toLowerCase();return pt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(un,"resolveNodeCommentSyntax");function dn(e,t){let r=t.match(/^#!.*\b(node|bun|deno|tsx|ts-node)\b.*(?:\r?\n|$)/);return r?r[0]:""}i(dn,"resolveNodePreservedPrefix");var ht={id:"node",extensions:pt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return dn(e,t)},resolveCommentSyntax(e){return un(e)}};import{extname as fn}from"node:path";var gt=[".php"];function mn(e){let t=fn(e).toLowerCase();return gt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(mn,"resolvePhpCommentSyntax");var yt={id:"php",extensions:gt,enabledByDefault:!0,resolveCommentSyntax(e){return mn(e)}};import{extname as pn}from"node:path";var xt=[".py"];function hn(e,t){let r=t.match(/^#!.*\bpython(?:\d+(?:\.\d+)*)?\b.*(?:\r?\n|$)/);return r?r[0]:""}i(hn,"resolvePythonPreservedPrefix");var wt={id:"python",extensions:xt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return hn(e,t)},resolveCommentSyntax(e){let t=pn(e).toLowerCase();return xt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as gn}from"node:path";var bt=[".rs"];function yn(e){let t=gn(e).toLowerCase();return bt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(yn,"resolveRustCommentSyntax");var Et={id:"rust",extensions:bt,enabledByDefault:!0,resolveCommentSyntax(e){return yn(e)}};import{extname as xn}from"node:path";var St=[".yaml",".yml"];function wn(e){let t=xn(e).toLowerCase();return St.includes(t)?{kind:"line",linePrefix:"#"}:null}i(wn,"resolveYamlCommentSyntax");var kt={id:"yaml",extensions:St,enabledByDefault:!0,resolveCommentSyntax(e){return wn(e)}};var q=[it,at,lt,dt,mt,ht,yt,wt,Et,kt],bn=new Map(q.map(e=>[e.id,e]));function En(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(En,"applySyntaxOverride");function Dt(e){if(e==null)return[];if(!Array.isArray(e)||e.some(r=>typeof r!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=q.filter(r=>r.requiresForce===!0).map(r=>r.id);for(let r of e){if(!bn.has(r))throw new Error(`forcedDetectors: unknown detector "${r}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(r))throw new Error(`forcedDetectors: "${r}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}i(Dt,"resolveForcedDetectors");function F(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),n=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return q.filter(o=>o.requiresForce===!0?n.has(o.id)&&!r.has(o.id):t.size>0?t.has(o.id):r.has(o.id)?!1:o.enabledByDefault)}i(F,"getEnabledDetectors");function $t(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=F(e);return new Set(t.flatMap(r=>r.extensions))}i($t,"getAllowedExtensions");function At(e,t={}){let r=ce(e).toLowerCase();if(F(t).some(a=>a.extensions.includes(r)&&a.resolveCommentSyntax(e)!==null))return null;if(r.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=q.find(a=>a.requiresForce===!0&&a.extensions.includes(r)&&!o.has(a.id));return s?`${r} files get a header only when forced (--force-detector ${s.id} / forcedDetectors: ["${s.id}"])`:`no enabled detector handles ${r} files`}i(At,"getHeaderSkipReason");function Nt(e,t={}){let r=ce(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:F(t);for(let o of n){if(!o.extensions.includes(r))continue;let s=o.resolveCommentSyntax(e);if(s){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return En(s,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(Nt,"getCommentSyntaxForFile");function Ct(e,t,r={}){let n=ce(e).toLowerCase(),o=F(r);for(let s of o)if(s.extensions.includes(n))return typeof s.resolvePreservedPrefix=="function"?s.resolvePreservedPrefix(e,t):"";return""}i(Ct,"getPreservedPrefixForFile");var vt=200,z=1,K=2;function L(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(L,"resolveLayoutCount");import{existsSync as Pn}from"node:fs";import{join as ge,relative as _t,resolve as ye,sep as pe}from"node:path";import{realpath as Rn,stat as jn}from"node:fs/promises";import{access as Sn,readdir as kn,readFile as Ti,stat as Dn}from"node:fs/promises";import{constants as $n}from"node:fs";import{dirname as _i,join as An,resolve as Ui}from"node:path";async function le(e){try{return await Sn(e,$n.F_OK),!0}catch{return!1}}i(le,"pathExists");async function ue(e,t){let r=[],n=await kn(e,{withFileTypes:!0});for(let o of n){let s=An(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 c=await ue(s,t);r.push(...c);continue}if(!o.isFile())continue;let a=o.name.lastIndexOf(".");if(a===-1)continue;let l=o.name.slice(a).toLowerCase();t.allowedExtensions.has(l)&&r.push(s)}return r}i(ue,"walkFiles");async function Ft(e){let t=await Dn(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(Ft,"readFileDates");import{execFile as Nn}from"node:child_process";import{lstat as Cn,readFile as vn}from"node:fs/promises";import{dirname as Lt,isAbsolute as Fn,join as Rt,relative as jt,resolve as de,sep as It}from"node:path";import Ln from"ignore";function Mt(e,t){return new Promise(r=>{Nn("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 me(e,t){return jt(e,t).split(It).join("/")}i(me,"toPosixRelative");async function Tt(e){try{return Ln().add(await vn(e,"utf8"))}catch{return null}}i(Tt,"readIgnoreFile");async function Mn(e){return Cn(Rt(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:s}=e[n],a=s.test(`${me(o,t)}${r?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}i(Pt,"matchesRules");async function Ot(e,t){let r=await Tt(Rt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(Ot,"buildRulesContext");async function fe(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 Ot(e,[]);let n=new Set,o=new Set;for(let s of r.stdout.split("\0")){let a=s.endsWith("/")?s.slice(0,-1):s;if(a.length!==0){n.add(a);for(let l=a.indexOf("/");l!==-1;l=a.indexOf("/",l+1))o.add(a.slice(0,l))}}return{kind:"git",root:e,entries:n,dirs:o}}i(fe,"resolveScopeContext");function Ht(e){let t=de(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 fe(t);let l=typeof r=="string"?[r]:r.filter(u=>typeof u=="string"),c=[];for(let u of l){let f=await Tt(de(t,u));f&&c.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:c}},"buildRootContext"),s=i(l=>{let c=n.get(l);return c||(c=l===t?o():a(l),n.set(l,c)),c},"contextFor"),a=i(async l=>{let c=await s(Lt(l));return c.kind==="git"?c.entries.has(me(c.root,l))?fe(l):c:!c.nested||c.excluded?c:Pt(c.matchers,l,!0)?{...c,excluded:!0}:await Mn(l)?fe(l):Ot(l,c.matchers)},"deriveContext");return{async isIgnored(l,c){let u=de(l),f=jt(t,u);if(f.length===0||f===".."||f.startsWith(`..${It}`)||Fn(f))return!1;let p=await s(Lt(u));if(p.kind==="git"){let g=me(p.root,u);return!(p.entries.has(g)||c&&p.dirs.has(g))}return p.excluded||Pt(p.matchers,u,c)}}}i(Ht,"createIgnoreFilter");function In(e){return $t(e)}i(In,"resolveExtensions");var Tn=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),zt=new Set([".git",...Tn]),On=Object.freeze(["autoload.php","modules.txt"]);function Ut(e,t){return zt.has(t)?!0:t==="vendor"&&On.some(r=>Pn(ge(e,r)))}i(Ut,"isNeverWalked");function he(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}i(he,"normalizeFolderPath");function Hn(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(Hn,"resolveIncludeFolders");function Bt(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i(Bt,"reportSkippedIncludeFolder");function _n(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=ye(e),n=[],o=new Set;for(let s of t){if(typeof s!="string")continue;let a=he(s);if(a.length!==0){if(a.includes("/")){n.push(ye(r,a));continue}o.add(a)}}return(s,a)=>{if(o.has(a))return!0;for(let c of n)if(s===c||s.startsWith(`${c}/`))return!0;let l=he(_t(r,s));return n.some(c=>{let u=he(_t(r,c));return l===u||l.startsWith(`${u}/`)})}}i(_n,"buildExclusionMatcher");async function xe(e){let t=In(e),r=Hn(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=_n(e.projectRoot,n),s=Ht({root:e.projectRoot,gitignore:e.gitignore}),a=i(async(d,h)=>Ut(d,h)||o(d,h)||await s.isIgnored(d,!0),"shouldSkipDirectory"),l=r.length>0?r.map(d=>({includeFolder:d.path,rootPath:ge(e.projectRoot,d.path),recursive:d.recursive})):[{includeFolder:".",rootPath:e.projectRoot,recursive:!0}],c=[];for(let d of l){let h=await jn(d.rootPath).catch(D=>D);if(h instanceof Error){if(h.code==="ENOENT"){Bt(d.includeFolder,h);continue}throw h}if(!h.isDirectory()){Bt(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let b=await Rn(d.rootPath).catch(()=>ye(d.rootPath));c.push({...d,realRoot:b})}let u=i((d,h)=>{if(d.realRoot===h.realRoot)return d.recursive||!h.recursive;let b=d.realRoot.endsWith(pe)?d.realRoot:`${d.realRoot}${pe}`;if(!d.recursive||!h.realRoot.startsWith(b))return!1;let D=d.rootPath;for(let N of h.realRoot.slice(b.length).split(pe))if(D=ge(D,N),Ut(D,N)||o(D,N))return!1;return!0},"covers"),f=[...c].sort((d,h)=>d.realRoot.length-h.realRoot.length||Number(h.recursive)-Number(d.recursive)),p=[];for(let d of f)p.some(h=>u(h,d))||p.push(d);let g=[];for(let d of c){if(!p.includes(d))continue;let h=await ue(d.rootPath,{allowedExtensions:t,ignoreFolders:zt,shouldSkipDirectory:a,recursive:d.recursive});g.push(...h)}let x=[];for(let d of new Set(g))!o(d,d.split("/").at(-1)||"")&&!await s.isIgnored(d,!1)&&x.push(d);return x}i(xe,"discoverFiles");import{basename as mo,dirname as po,extname as ho,resolve as De}from"node:path";import{dirname as tr,isAbsolute as Xn,join as rr,relative as Zn,resolve as nr,sep as Qn}from"node:path";import{readFile as Un}from"node:fs/promises";import{join as Bn}from"node:path";async function zn(e){try{return await Un(e,"utf8")}catch{return null}}i(zn,"readManifest");async function $(e,t){let r=[];for(let n of t){let o=await zn(Bn(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 M(e,t){return e.files.find(r=>r.file===t)?.content??null}i(M,"manifestContent");function w(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(w,"cleanName");function we(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return w(t===-1?e:e.slice(0,t))}i(we,"personName");function X(e){try{return JSON.parse(e)}catch{return}}i(X,"parseJsonManifest");function*be(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let s=o.match(/^\[([^[\]]+)\]/);r=s?s[1].split(".").map(a=>a.trim()).join("."):"";continue}r===t&&(yield o)}}i(be,"sectionLines");function Y(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of be(e,t)){let s=o.match(n);if(s)return w(s[1]??s[2])}}i(Y,"readTomlString");function Ee(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of be(e,t)){let s=o.match(n);if(s)return w(s[1])}}i(Ee,"readIniValue");function Yn(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let s of be(e,t)){if(o!==null){o.push(s);continue}let a=s.match(n);a&&(o=[s.slice(a[0].length)])}return o===null?null:o.join(`
|
|
2
|
-
`)}i(
|
|
3
|
-
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
`)}let
|
|
7
|
-
`)}i(
|
|
8
|
-
`).
|
|
9
|
-
`),a=
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var cn=Object.defineProperty;var i=(e,t)=>cn(e,"name",{value:t,configurable:!0});import{readFile as ii,stat as si,writeFile as ai}from"node:fs/promises";import{relative as Ye,resolve as qr}from"node:path";import{readFile as ln}from"node:fs/promises";import{createRequire as un}from"node:module";import{dirname as dn,isAbsolute as fn,resolve as ut}from"node:path";var mn=3e4,pn=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 r={...e};for(let[n,o]of Object.entries(t))n!=="__proto__"&&(r[n]=xe(r[n])&&xe(o)?we(r[n],o):o);return r}i(we,"mergeConfig");function dt(e){return e.kind==="file"?e.path:e.href}i(dt,"describeSource");async function hn(e){if(e.kind==="file")return{text:await ln(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(mn)})}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(hn,"readSource");function lt(e){if(e.protocol==="http:"&&!pn.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 gn(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 r=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(r||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(r||fn(e))return{kind:"file",path:ut(dn(t.path),e)};try{return{kind:"file",path:un(t.path).resolve(e)}}catch(n){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${n.message}`,{cause:n})}}i(gn,"resolveReference");function yn(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(yn,"readExtends");async function ft(e,t){let r=dt(e);if(t.includes(r))throw new Error(`Config extends cycle: ${[...t,r].join(" -> ")}`);let{text:n,source:o}=await hn(e),s;try{s=JSON.parse(n)}catch(u){throw new Error(`Config ${r} is not valid JSON: ${u.message}`,{cause:u})}if(!xe(s))throw new Error(`Config file must contain a JSON object: ${r}`);let{extends:a,...c}=s,l={};for(let u of yn(a,r))l=we(l,await ft(gn(u,o),[...t,r]));return we(l,c)}i(ft,"loadSource");function xn(e,t=process.cwd()){return ft({kind:"file",path:ut(t,e)},[])}i(xn,"loadConfigFile");async function mt(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 xn(r,n),...e};return delete o[t],o}i(mt,"applyConfigOption");import{extname as be}from"node:path";import{extname as wn}from"node:path";var pt=[".css"];function bn(e){let t=wn(e).toLowerCase();return pt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}i(bn,"resolveCssCommentSyntax");var ht={id:"css",extensions:pt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return bn(e)}};import{extname as Sn}from"node:path";var En=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,kn=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,$n=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 ne(e){let t=e.match(En);if(!t)return!1;let r=t[2].trim();if(r.endsWith("-->"))r=r.slice(0,-3).trimEnd();else if(r.endsWith("*/")){let s=r.length-2;for(;s>0&&r[s-1]==="*";)s-=1;r=r.slice(0,s).trimEnd()}let n=r.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!n&&t[1]==="Vim")return!1;let o=n?n[1].match(/(?:\\.|[^\s\\])+/g):r.match(/(?:\\.|[^\s:\\])+/g);return o!==null&&o.every(s=>kn.test(s))&&o.some(s=>s.includes("=")||$n.has(s))}i(ne,"isModeline");function oe(e,t){return t===0&&e.startsWith("#!")}i(oe,"isShebang");function ie(e,t,r=0){let n=0,o=r;for(;n<e.length;){let s=e.indexOf(`
|
|
2
|
+
`,n),a=s===-1?e.length:s+1;if(!t(e.slice(n,a).replace(/\r?\n$/,""),o))break;n=a,o+=1}return e.slice(0,n)}i(ie,"takeTopLines");var yt=[".go"];function Dn(e){let t=Sn(e).toLowerCase();return yt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Dn,"resolveGoCommentSyntax");var gt=/^\/\/(?:go:build|\s*\+build)\s/;function An(e,t){let r=ie(t,o=>gt.test(o)||ne(o));if(!r.split(/\r?\n/).some(o=>gt.test(o)))return"";let n=t.slice(r.length);return`${r}${n.slice(0,n.length-n.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}i(An,"resolveGoPreservedPrefix");var xt={id:"go",extensions:yt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return An(e,t)},resolveCommentSyntax(e){return Dn(e)}};import{extname as Cn}from"node:path";var wt=[".html",".htm"];function Fn(e){let t=Cn(e).toLowerCase();return wt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Fn,"resolveHtmlCommentSyntax");var bt={id:"html",extensions:wt,enabledByDefault:!0,resolveCommentSyntax(e){return Fn(e)}};import{extname as Nn}from"node:path";var Et=[".jsonv",".jsonc",".json5"];function vn(e){let t=Nn(e).toLowerCase();return Et.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(vn,"resolveJsonCommentSyntax");var kt={id:"json",extensions:Et,enabledByDefault:!0,resolveCommentSyntax(e){return vn(e)}};import{extname as Ln}from"node:path";var $t=[".md",".markdown"];function Mn(e){let t=Ln(e).toLowerCase();return $t.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}i(Mn,"resolveMarkdownCommentSyntax");function Rn(e,t){let r=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return r?r[0]:""}i(Rn,"resolveMarkdownPreservedPrefix");var St={id:"markdown",extensions:$t,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return Rn(e,t)},resolveCommentSyntax(e){return Mn(e)}};import{extname as jn}from"node:path";var Dt=[".js",".mjs",".cjs",".ts",".tsx",".jsx"];function Pn(e){let t=jn(e).toLowerCase();return Dt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Pn,"resolveNodeCommentSyntax");var At={id:"node",extensions:Dt,enabledByDefault:!0,keepsAboveHeader:oe,resolveCommentSyntax(e){return Pn(e)}};import{extname as In}from"node:path";var Ft=[".php"];function Tn(e){let t=In(e).toLowerCase();return Ft.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Tn,"resolvePhpCommentSyntax");var Ct=/^<\?php(?:\s|$)/i,Nt={id:"php",extensions:Ft,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&Ct.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return Ct.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 Tn(e)}};import{extname as On}from"node:path";var vt=[".py"],Hn=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function _n(e,t){return oe(e,t)||t<=1&&Hn.test(e)}i(_n,"keepsAboveHeader");var Lt={id:"python",extensions:vt,enabledByDefault:!0,keepsAboveHeader:_n,resolveCommentSyntax(e){let t=On(e).toLowerCase();return vt.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as Bn}from"node:path";var Mt=[".rs"];function Un(e){let t=Bn(e).toLowerCase();return Mt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}i(Un,"resolveRustCommentSyntax");var Rt={id:"rust",extensions:Mt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Un(e)}};import{extname as zn}from"node:path";var jt=[".yaml",".yml"];function Wn(e){let t=zn(e).toLowerCase();return jt.includes(t)?{kind:"line",linePrefix:"#"}:null}i(Wn,"resolveYamlCommentSyntax");var Pt={id:"yaml",extensions:jt,enabledByDefault:!0,keepsAboveHeader:i((e,t)=>t===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Wn(e)}};var se=[ht,xt,bt,kt,St,At,Nt,Lt,Rt,Pt],Gn=new Map(se.map(e=>[e.id,e]));function Yn(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(Yn,"applySyntaxOverride");function It(e){if(e==null)return[];if(!Array.isArray(e)||e.some(r=>typeof r!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=se.filter(r=>r.requiresForce===!0).map(r=>r.id);for(let r of e){if(!Gn.has(r))throw new Error(`forcedDetectors: unknown detector "${r}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(r))throw new Error(`forcedDetectors: "${r}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}i(It,"resolveForcedDetectors");function T(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),r=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),n=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return se.filter(o=>o.requiresForce===!0?n.has(o.id)&&!r.has(o.id):t.size>0?t.has(o.id):r.has(o.id)?!1:o.enabledByDefault)}i(T,"getEnabledDetectors");function Tt(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));let t=T(e);return new Set(t.flatMap(r=>r.extensions))}i(Tt,"getAllowedExtensions");function Ot(e,t={}){let r=be(e).toLowerCase();if(T(t).some(a=>a.extensions.includes(r)&&a.resolveCommentSyntax(e)!==null))return null;if(r.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(r)&&!o.has(a.id));return s?`${r} files get a header only when forced (--force-detector ${s.id} / forcedDetectors: ["${s.id}"])`:`no enabled detector handles ${r} files`}i(Ot,"getHeaderSkipReason");function Ht(e,t={}){let r=be(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:T(t);for(let o of n){if(!o.extensions.includes(r))continue;let s=o.resolveCommentSyntax(e);if(s){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return Yn(s,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}i(Ht,"getCommentSyntaxForFile");function _t(e,t){let r=be(e).toLowerCase();return T(t).find(n=>n.extensions.includes(r))}i(_t,"detectorForFile");function ae(e,t,r={}){let n=_t(e,r);if(!n)return"";let o=typeof n.resolvePreservedPrefix=="function"?n.resolvePreservedPrefix(e,t):"",s=n.keepsAboveHeader,a=ie(t.slice(o.length),(c,l)=>ne(c)||typeof s=="function"&&s(c,l),o.split(`
|
|
3
|
+
`).length-1);return`${o}${a}`}i(ae,"getPreservedPrefixForFile");function Bt(e,t,r={}){let n=_t(e,r);return n&&typeof n.resolveContentSkipReason=="function"?n.resolveContentSkipReason(t):null}i(Bt,"getContentSkipReason");var Ut=200,Z=1,ce=2;function O(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(O,"resolveLayoutCount");import{existsSync as oo}from"node:fs";import{join as Fe,relative as tr,resolve as Ne,sep as Ae}from"node:path";import{realpath as io,stat as so}from"node:fs/promises";import{access as Vn,readdir as Jn,readFile as bs,stat as qn}from"node:fs/promises";import{constants as Kn}from"node:fs";import{dirname as $s,join as Zn,resolve as Ss}from"node:path";async function Ee(e){try{return await Vn(e,Kn.F_OK),!0}catch{return!1}}i(Ee,"pathExists");async function ke(e,t){let r=[],n=await Jn(e,{withFileTypes:!0});for(let o of n){let s=Zn(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);r.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)&&r.push(s)}return r}i(ke,"walkFiles");async function zt(e){let t=await qn(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(zt,"readFileDates");function Wt(e){let t=e.indexOf("<");for(;t!==-1;){let r=e.indexOf(">",t+1);if(r===-1)return!1;if(r>t+1)return!0;t=e.indexOf("<",r+1)}return!1}i(Wt,"hasAngleTag");function Gt(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}i(Gt,"trimTrailingSlashes");import{execFile as Xn}from"node:child_process";import{lstat as Qn,readFile as eo}from"node:fs/promises";import{dirname as Yt,isAbsolute as to,join as qt,relative as Kt,resolve as $e,sep as Zt}from"node:path";import ro from"ignore";function Vt(e,t){return new Promise(r=>{Xn("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(Vt,"runGitCommand");function De(e,t){return Kt(e,t).split(Zt).join("/")}i(De,"toPosixRelative");async function Xt(e){try{return ro().add(await eo(e,"utf8"))}catch{return null}}i(Xt,"readIgnoreFile");async function no(e){return Qn(qt(e,".git")).then(()=>!0,()=>!1)}i(no,"hasGitEntry");function Jt(e,t,r){for(let n=e.length-1;n>=0;n--){let{base:o,rules:s}=e[n],a=s.test(`${De(o,t)}${r?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}i(Jt,"matchesRules");async function Qt(e,t){let r=await Xt(qt(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:r?[...t,{base:e,rules:r}]:t}}i(Qt,"buildRulesContext");async function Se(e){let[t,r]=await Promise.all([Vt(e,["check-ignore","-q","."]),Vt(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(t.code!==1||r.code!==0)return Qt(e,[]);let n=new Set,o=new Set;for(let s of r.stdout.split("\0")){let a=s.endsWith("/")?s.slice(0,-1):s;if(a.length!==0){n.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:n,dirs:o}}i(Se,"resolveScopeContext");function er(e){let t=$e(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($e(t,u));f&&l.push({base:t,rules:f})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),s=i(c=>{let l=n.get(c);return l||(l=c===t?o():a(c),n.set(c,l)),l},"contextFor"),a=i(async c=>{let l=await s(Yt(c));return l.kind==="git"?l.entries.has(De(l.root,c))?Se(c):l:!l.nested||l.excluded?l:Jt(l.matchers,c,!0)?{...l,excluded:!0}:await no(c)?Se(c):Qt(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let u=$e(c),f=Kt(t,u);if(f.length===0||f===".."||f.startsWith(`..${Zt}`)||to(f))return!1;let p=await s(Yt(u));if(p.kind==="git"){let y=De(p.root,u);return!(p.entries.has(y)||l&&p.dirs.has(y))}return p.excluded||Jt(p.matchers,u,l)}}}i(er,"createIgnoreFilter");function ao(e){return Tt(e)}i(ao,"resolveExtensions");var co=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),or=new Set([".git",...co]),lo=Object.freeze(["autoload.php","modules.txt"]);function rr(e,t){return or.has(t)?!0:t==="vendor"&&lo.some(r=>oo(Fe(e,r)))}i(rr,"isNeverWalked");function Ce(e){return Gt(e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}i(Ce,"normalizeFolderPath");function uo(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(uo,"resolveIncludeFolders");function nr(e,t){let r=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${r})`)}i(nr,"reportSkippedIncludeFolder");function fo(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let r=Ne(e),n=[],o=new Set;for(let s of t){if(typeof s!="string")continue;let a=Ce(s);if(a.length!==0){if(a.includes("/")){n.push(Ne(r,a));continue}o.add(a)}}return(s,a)=>{if(o.has(a))return!0;for(let l of n)if(s===l||s.startsWith(`${l}/`))return!0;let c=Ce(tr(r,s));return n.some(l=>{let u=Ce(tr(r,l));return c===u||c.startsWith(`${u}/`)})}}i(fo,"buildExclusionMatcher");async function ve(e){let t=ao(e),r=uo(e.includeFolders),n=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=fo(e.projectRoot,n),s=er({root:e.projectRoot,gitignore:e.gitignore}),a=i(async(d,m)=>rr(d,m)||o(d,m)||await s.isIgnored(d,!0),"shouldSkipDirectory"),c=r.length>0?r.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 so(d.rootPath).catch(b=>b);if(m instanceof Error){if(m.code==="ENOENT"){nr(d.includeFolder,m);continue}throw m}if(!m.isDirectory()){nr(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let w=await io(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(Ae)?d.realRoot:`${d.realRoot}${Ae}`;if(!d.recursive||!m.realRoot.startsWith(w))return!1;let b=d.rootPath;for(let $ of m.realRoot.slice(w.length).split(Ae))if(b=Fe(b,$),rr(b,$)||o(b,$))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:or,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 Oo,dirname as Ho,extname as _o,resolve as Ie}from"node:path";import{dirname as gr,isAbsolute as $o,join as yr,relative as So,resolve as xr,sep as Do}from"node:path";import{readFile as mo}from"node:fs/promises";import{join as po}from"node:path";async function ho(e){try{return await mo(e,"utf8")}catch{return null}}i(ho,"readManifest");async function M(e,t){let r=[];for(let n of t){let o=await ho(po(e,n));o!==null&&r.push({file:n,content:o})}return r.length>0?{dir:e,manifest:r[0].file,files:r}:null}i(M,"detectManifests");function H(e,t){return e.files.find(r=>r.file===t)?.content??null}i(H,"manifestContent");function A(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}i(A,"cleanName");function Le(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return A(t===-1?e:e.slice(0,t))}i(Le,"personName");function le(e){try{return JSON.parse(e)}catch{return}}i(le,"parseJsonManifest");function*Me(e,t){let r="";for(let n of e.split(/\r?\n/)){let o=n.trim();if(o.startsWith("[")){let s=o.match(/^\[([^[\]]+)\]/);r=s?s[1].split(".").map(a=>a.trim()).join("."):"";continue}r===t&&(yield o)}}i(Me,"sectionLines");function X(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of Me(e,t)){let s=o.match(n);if(s)return A(s[1]??s[2])}}i(X,"readTomlString");function Re(e,t,r){let n=new RegExp(`^${r}\\s*[=:](.*)$`);for(let o of Me(e,t)){let s=o.match(n);if(s)return A(s[1])}}i(Re,"readIniValue");function go(e,t,r){let n=new RegExp(`^${r}\\s*=\\s*\\[`),o=null;for(let s of Me(e,t)){if(o!==null){o.push(s);continue}let a=s.match(n);a&&(o=[s.slice(a[0].length)])}return o===null?null:o.join(`
|
|
4
|
+
`)}i(go,"tomlArrayText");function yo(e,t){let r=t;for(;r<e.length;)if(e[r]==="#"){let n=e.indexOf(`
|
|
5
|
+
`,r);r=n===-1?e.length:n+1}else if(/\s/.test(e[r]))r+=1;else break;return r}i(yo,"skipTomlSpace");function Q(e,t){let r=go(e,t,"authors");if(r===null)return;let n=r.slice(yo(r,0)),o=n.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return Le(o[1]??o[2]);let a=n.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return a?A(a[1]??a[2]):void 0}i(Q,"readTomlAuthor");var ir=["go.mod"];function xo(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return A(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}i(xo,"readModulePath");var sr={id:"go",languages:["go"],manifests:ir,detect(e){return M(e,ir)},read(e){return{name:xo(e.files[0].content)}}};var ar=["package.json"];function wo(e){let t=A(e?.name),r=A(e?.publisher),n=typeof e?.engines?.vscode=="string";return t&&r&&n?`${r}.${t}`:t}i(wo,"readPublishedName");function bo(e){if(e!==null&&typeof e=="object"){let t=e;return A(t.company)??A(t.name)}return Le(e)}i(bo,"readAuthorCompany");var cr={id:"node",languages:["node"],manifests:ar,detect(e){return M(e,ar)},read(e){let t=le(e.files[0].content);return{name:wo(t),company:bo(t?.author)}}};var lr=["composer.json"],ur={id:"php",languages:["php"],manifests:lr,detect(e){return M(e,lr)},read(e){let t=le(e.files[0].content),r=t?.authors;return{name:A(t?.name),company:Array.isArray(r)?A(r[0]?.name):void 0}}};var dr=["pyproject.toml","setup.cfg","setup.py"];function fr(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(fr,"readSetupPyArgument");function Eo(e){let t=H(e,"pyproject.toml"),r=H(e,"setup.cfg"),n=H(e,"setup.py");return(t===null?void 0:X(t,"project","name")??X(t,"tool.poetry","name"))??(r===null?void 0:Re(r,"metadata","name"))??(n===null?void 0:fr(n,"name"))}i(Eo,"readPythonName");function ko(e){let t=H(e,"pyproject.toml"),r=H(e,"setup.cfg"),n=H(e,"setup.py");return(t===null?void 0:Q(t,"project")??Q(t,"tool.poetry"))??(r===null?void 0:Re(r,"metadata","author"))??(n===null?void 0:fr(n,"author"))}i(ko,"readPythonCompany");var mr={id:"python",languages:["python"],manifests:dr,detect(e){return M(e,dr)},read(e){return{name:Eo(e),company:ko(e)}}};var pr=["Cargo.toml"],hr={id:"rust",languages:["rust"],manifests:pr,detect(e){return M(e,pr)},read(e){let t=e.files[0].content;return{name:X(t,"package","name"),company:Q(t,"package")}}};var Ao=[cr,mr,ur,hr,sr],wr=["name","company"];async function je(e,t,r){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 r=="string"&&a.driver.languages.includes(r));return[...s,...o.filter(a=>!s.includes(a))]}i(je,"claimFolder");function Co(e,t){let r=So(t,e);return r!==""&&r!==".."&&!r.startsWith(`..${Do}`)&&!$o(r)}i(Co,"isStrictlyInside");async function br(e,t={}){let r=Array.isArray(t.drivers)?t.drivers:Ao,n=typeof t.scanRoot=="string"?xr(t.scanRoot):null,o=xr(e),s=await je(o,r,t.language);for(;s.length===0;){if(await Ee(yr(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let f=gr(o);if(f===o)return null;o=f,s=await je(o,r,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 wr)a[d]===void 0&&g[d]!==void 0&&(a[d]=g[d],c[d]={driver:p.id,manifest:y.manifest,dir:l})}if(wr.every(p=>a[p]!==void 0)||n===null||!Co(l,n)||await Ee(yr(l,".git")))break;l=gr(l),u=await je(l,r,t.language)}return{root:o,marker:s[0].detection.manifest,drivers:s.map(f=>f.driver.id),fields:a,sources:c}}i(br,"resolveManifestProject");import{execFile as Fo}from"node:child_process";import{basename as No,dirname as vo}from"node:path";import{promisify as Lo}from"node:util";var Pe=Lo(Fo);async function v(e,t){try{let{stdout:r}=await Pe("git",t,{cwd:e}),n=r.trim();return n.length>0?n:null}catch{return null}}i(v,"runGit");function Er(e,t){let r=0;for(let n=t-1;n>=0&&e[n]==="\\";n--)r++;return r%2===1}i(Er,"isEscaped");function Mo(e){let t=e.trim();if(!t.endsWith(")")||Er(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!==")"||Er(t,n))&&(r+=o===")"?1:-1,r===0))return t.slice(0,n).trim()}return t}i(Mo,"stripUidComment");function Ro(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:Mo(o)||o||null,authorEmail:n}}i(Ro,"parseSignerUid");async function jo(e,t){try{let{stdout:r}=await Pe(e,t),n=r.trim();return n.length>0?n:null}catch{return null}}i(jo,"runProgram");function Po(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)))}i(Po,"decodeColonField");async function Io(e){let t=await v(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let r=await v(e,["config","--get","user.signingkey"]);if(!r)return null;let n=await v(e,["config","--get","gpg.openpgp.program"])||await v(e,["config","--get","gpg.program"])||"gpg",o=await jo(n,["--batch","--with-colons","--list-keys",r]);if(!o)return null;for(let s of o.split(`
|
|
6
|
+
`)){let a=s.split(":");if(a[0]==="uid"&&a[1]!=="r"&&a[1]!=="e"&&a[9])return Po(a[9])}return null}i(Io,"readSigningKeyUid");async function kr(e,t={}){let r=await v(e,["config","--get","user.name"]),n=await v(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await Io(e)||await v(e,["log","-1","--format=%GS"]),s=Ro(o||"");r=s.authorName||r,n=n||s.authorEmail}if(!r||!n){let o=await v(e,["log","-1","--format=%an|%ae"]);if(o){let[s,a]=o.split("|");r=r||s||null,n=n||a||null}}return{authorName:r,authorEmail:n}}i(kr,"detectGitAuthor");function $r(e){return e.replace(/z$/i,"+00:00")}i($r,"canonicalGitDate");async function Sr(e,t){let r=await v(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!r)return null;let n=r.split(`
|
|
7
|
+
`)[0],[o,s]=n.split("|");if(!o||!s)return null;let a=Number.parseInt(s,10);return Number.isNaN(a)?null:{date:$r(o),timestamp:a}}i(Sr,"getGitCreationDate");async function Dr(e,t){let r=await v(e,["log","-1","--format=%aI|%at","--",t]);if(!r)return null;let[n,o]=r.split("|");if(!n||!o)return null;let s=Number.parseInt(o,10);return Number.isNaN(s)?null:{date:$r(n),timestamp:s}}i(Dr,"getGitLastModifiedDate");var To=256*1024*1024;async function Ar(e){let t=vo(e);if(await v(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:r}=await Pe("git",["show",`HEAD:./${No(e)}`],{cwd:t,encoding:"utf8",maxBuffer:To});return{state:"tracked",content:r}}catch{return{state:"untracked",content:null}}}i(Ar,"readGitHeadFile");function Bo(e){return Oo(e)||"project"}i(Bo,"folderName");function Uo(e,t){if(typeof t!="string")return e;let r=t.trim();return r.length===0||Wt(e)?e:`${e} <${r}>`}i(Uo,"formatAuthorNameWithCompany");async function zo(e,t={}){let r=Array.isArray(t.detectors)?t.detectors:T(t),n=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=n.length>0?r.find(u=>u.extensions.includes(n)):void 0,s=await br(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??Bo(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(zo,"detectProjectFromMarkers");async function Te(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),r=Ie(t),n=T(e),o=e.targetFilePath?Ho(r):r,s=e.targetFilePath?_o(r).toLowerCase():"",a=Ie(e.projectRoot||e.cwd||process.cwd()),c=await zo(o,{detectors:n,preferredExtension:s,scanRoot:a}),l=await kr(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:Uo(u,e.company),authorEmail:e.authorEmail||l.authorEmail||"unknown@example.com",companyName:f||c.companyName,companyNameSource:f?{from:"option"}:c.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}i(Te,"resolveProjectMetadata");function Wo(e){return Oe({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}i(Wo,"formatDateWithTimezone");function Oe(e){return`${vr(e," ")} ${Lr(e.offsetMinutes)}`}i(Oe,"formatSpaceDate");function Fr(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{Nr(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(Fr,"assertTimeZone");var Cr=new Map;function Nr(e){let t=Cr.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"}),Cr.set(e,t)),t}i(Nr,"getZoneFormatter");function He(e,t){let r={};for(let o of Nr(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(He,"toZonedDateParts");function vr(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(vr,"formatWallClock");function Lr(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(Lr,"formatOffset");function ue(e=new Date){return{date:Wo(e),timestamp:Math.floor(e.getTime()/1e3)}}i(ue,"toDatePayload");var Go=/^(\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=Go.exec(e.trim());if(!t)return null;let[r,n,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(r,n-1,o,s,a,c));return!(f.getUTCFullYear()===r&&f.getUTCMonth()===n-1&&f.getUTCDate()===o&&f.getUTCHours()===s&&f.getUTCMinutes()===a&&f.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:r,month:n,day:o,hour:s,minute:a,second:c,offsetMinutes:u,timestamp:Math.floor(f.getTime()/1e3)-u*60}}i(_,"parseHeaderDate");function _e(e){return`${vr(e,"T")}${Lr(e.offsetMinutes)}`}i(_e,"formatIsoDate");var Yo={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function Mr(e,t){let r=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return r?r[1].trim():null}i(Mr,"readHeaderField");function Be(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(Be,"pickOldestDate");function jr({existing:e,gitCreated:t,filesystemCreated:r,fixCreatedDate:n=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:r}];if(!e)return Be(o);if(!n)return{source:"existing-header",payload:e};let s=_(e.date)?e:null;return Be([{source:"existing-header",payload:s},...o])}i(jr,"resolveCreatedDate");function Pr(e,t=null){if(t)return He(e.timestamp,t).year;let r=_(e.date);return r?r.year:new Date(e.timestamp*1e3).getFullYear()}i(Pr,"dateYear");function Rr(e,t,r,n){let o=e.match(/^(.+?)\s*\((\d+)\)$/),s=o?_(o[1]):null;if(!o||!s)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 a=Number.parseInt(o[2],10);return a!==s.timestamp&&n.push({check:`${r}-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(Rr,"checkDateValue");function Ir(e,t={},r={}){let n=[],o=Mr(e,"@Date"),s=o===null?null:Rr(o,"@Date","created",n),a=Be([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(s&&a&&s.timestamp>a.payload.timestamp){let f=Yo[a.source];n.push({check:"created-newer-than-source",field:"@Date",advisory:r.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=Mr(e,"@Last modified time"),l=c===null?null:Rr(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(Ir,"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 Tr(e){let t=_(e.date);return t?{date:_e(t),timestamp:t.timestamp}:e}i(Tr,"normalizeDatePayload");function Or(e,t){let r=_(e.date);if(!r)return e;let n=He(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())?_e(n):Oe(n),timestamp:r.timestamp}}i(Or,"convertDatePayload");import{relative as Jo}from"node:path";import{extname as Vo}from"node:path";function B(e,t={}){let r=Vo(e).toLowerCase(),n=O(t.spacing,"spacing",Z);return r.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:n}:{...Ht(e,t),spacing:n}}i(B,"getHeaderSyntaxForFile");function Hr(e,t){let r=e.spacing??Z;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(`
|
|
8
|
+
`)}let n=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),s=e.blockEnd||(e.kind==="html"?"-->":" */"),a=Array.from({length:r},()=>o.trimEnd());return[n,...a,...t.map(c=>`${o}${c}`),...a,s].join(`
|
|
9
|
+
`)}i(Hr,"renderHeaderLines");function _r(e){let t=`/${Jo(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/")}`,r=B(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),n=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: ${n}`,`@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 Hr(r,u)}i(_r,"buildHeader");var qo=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function I(e,t){let r=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),n=r?r[1].trim():"";return n.length>0?n:null}i(I,"readTag");function Ko(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(Ko,"splitLastModifiedBy");function Zo(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 s=n.toLowerCase(),a=s.endsWith("all rights reserved.")?20:s.endsWith("all rights reserved")?19:0;return a===0||!/^\s/.test(n)?t:{startYear:r[1],endYear:o?o[1]:null,companyName:n.slice(0,-a).trim()||null}}i(Zo,"splitCopyright");function Br(e){let t=Ko(I(e,"Last modified by")),r=Zo(I(e,"Copyright")),n=I(e,"Email");return{projectName:I(e,"Project"),filename:I(e,"Filename"),createdAt:I(e,"Date"),authorName:I(e,"Author"),authorEmail:n===null?null:n.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:I(e,"Last modified time"),copyrightStartYear:r.startYear,copyrightEndYear:r.endYear,companyName:r.companyName}}i(Br,"parseHeaderFields");function Ur(e,t){let r=Br(e??""),n=Br(t);return qo.filter(o=>r[o]!==n[o]).map(o=>({field:o,previous:r[o],detected:n[o]}))}i(Ur,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(ee,"escapeRegex");function ze(e,t,r={}){let n=t.startsWith("\uFEFF")?"\uFEFF":"",o=t.slice(n.length),s=`${n}${ae(e,o,r)}`;return{prefix:s,body:t.slice(s.length)}}i(ze,"splitPreservedPrefix");function de(e){let t=e.indexOf(`
|
|
10
|
+
`);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
|
|
11
|
+
`:`
|
|
12
|
+
`}i(de,"lineEnding");function W(e,t){if(t.kind==="html"){let n=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${n}[\\s\\S]*?${o}(?:\\r?\\n)*`))}if(t.kind==="line"){let n=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${n}[^\\n]*\\n)+(?:\\r?\\n)*`))}let r=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${r}(?:\\r?\\n)*`))}i(W,"matchHeaderSegment");var Gr=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,Xo="Moved out of the file header by fix-headers:";function Yr(e){return e.some(t=>/^@(?:Project|Filename):/.test(t.text))}i(Yr,"isFileHeader");function We(e,t){let r=e.replace(/(?:\r?\n)+$/,"");if(t.kind==="line"){let f=new RegExp(`^${ee(t.linePrefix||"#")}[ \\t]*`);return r.split(`
|
|
13
|
+
`).map(p=>{let y=p.replace(/\r$/,"");return{raw:y,text:y.replace(f,"").trim()}})}let n=t.kind==="html",o=n?r.replace(/^<!--/,"").replace(/--!?>\s*$/,""):r.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),s=t.blockLinePrefix||(n?" ":" * "),a=n?/^\s*/:/^\s*\*?[ \t]*/,c=o.split(`
|
|
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(We,"segmentLines");function Qo(e,t){let r=e.map(o=>{let s=o.text.match(Gr);return o.text===""?"blank":s&&s[1]==="Copyright"?t.copyright?"copyright":(t.copyright=!0,"field"):s?"field":/^-{3,}$/.test(o.text)?"dash":"text"}),n=i((o,s)=>{for(let a=o+s;a>=0&&a<r.length;a+=s)if(r[a]!=="blank"&&r[a]!=="dash")return r[a]==="copyright"?"field":r[a]},"neighbour");return r.map((o,s)=>o==="dash"?n(s,-1)==="field"||n(s,1)==="field"?"separator":"text":o)}i(Qo,"classifyLines");function ei(e,t="",r={}){let n=B(t,r),o=[],s=[],a={copyright:!1},c=e,l=W(c,n),u=!0;for(;l&&l[0].length>0;){let m=We(l[0],n),w=Qo(m,a),b=m.findIndex($=>$.text!=="");!u&&b!==-1&&m[b].text===Xo&&(w[b]="separator"),m.forEach(($,C)=>{w[C]==="copyright"&&s.push($.text.replace(Gr,"").trim()),o.push({raw:$.raw,kind:w[C]})}),c=c.slice(l[0].length),l=W(c,n),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(ei,"splitHeaderText");function ti(e,t,r){let n=t.kind==="html";return t.kind==="line"?e.join(r):[t.blockStart||(n?"<!--":"/**"),...e,t.blockEnd||(n?"-->":" */")].join(r)}i(ti,"renderForeignBlock");function ri(e,t,r){let n=e.split(`
|
|
15
|
+
`),o=r.kind==="html",s=r.kind==="line"?r.linePrefix||"#":(r.blockLinePrefix||(o?" ":" * ")).trimEnd(),a=Math.min(n.length-1,(r.spacing??1)+(r.kind==="line"?0:1)),c=n.length-a;return[...n.slice(0,c),s,...t,...n.slice(c)].join(`
|
|
16
|
+
`)}i(ri,"appendToHeader");function zr(e){let t=e.trim(),r=t.match(/^copyright\b/i);t=r?t.slice(r[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 n=t.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);t=n?t.slice(n[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
|
|
17
|
+
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}i(zr,"copyrightHolder");function ni(e,t){let r=e.split(`
|
|
18
|
+
`),n=r.findIndex(c=>c.includes("@Copyright:")),o=r.map(c=>/@[A-Za-z][A-Za-z ]*:/.test(c)).lastIndexOf(!0),s=n!==-1?n:o;if(t.length===0||s===-1)return e;let a=r[s].slice(0,r[s].indexOf("@"));return[...r.slice(0,s+1),...t.map(c=>`${a}@Copyright: ${c}`),...r.slice(s+1)].join(`
|
|
19
|
+
`)}i(ni,"insertCopyrights");function Wr(e,t){let r=0,n=W(e,t);for(;n&&n[0].length>0&&Yr(We(n[0],t));)r+=n[0].length,n=W(e.slice(r),t);return r}i(Wr,"leadingHeadersLength");function fe(e,t="",r={}){let n=e.startsWith("\uFEFF")?"\uFEFF":"",o=e.slice(n.length),s=ae(t,o,r),a=B(t,r),c=s.length,l=Wr(o.slice(c),a);if(l===0)return e;let u=n===""&&c===0&&o.startsWith("\uFEFF",l);u&&(n="\uFEFF",o=`${o.slice(0,l)}${o.slice(l+1)}`,l+=Wr(o.slice(l),a));let f=o.slice(c,c+l),p=o.slice(c+l),y=ae(t,`${s}${p}`,r),g=y.length>s.length?y.slice(s.length):"";if(g===""&&!u)return e;let d=g===""||g.endsWith(`
|
|
20
|
+
`)?g:`${g}${de(e)??`
|
|
21
|
+
`}`;return`${n}${s}${d}${f}${p.slice(g.length)}`}i(fe,"restoreTopLines");function me(e,t="",r={}){let{prefix:n,body:o}=ze(t,e,r),s=o.split(`
|
|
22
|
+
`).slice(0,Ut).join(`
|
|
23
|
+
`),a=B(t,r);if(!W(s,a))return null;let l=0,u=0;for(;;){let f=s.slice(l),p=W(f,a);if(!p||!Yr(We(p[0],a)))break;l+=p[0].length,u=l}return u===0?null:{start:n.length,end:n.length+u}}i(me,"findProjectHeader");function pe(e,t,r="",n={}){let o=fe(e,r,n),s=me(o,r,n),a=B(r,n),c=O(n.margin,"margin",ce),l=a.kind==="line"?Math.max(1,c):c,u=i((k,S)=>S===`
|
|
24
|
+
`?k:k.replace(/\r?\n/g,S),"withEol");if(!s){let{prefix:k,body:S}=ze(r,o,n),D=de(o)??`
|
|
25
|
+
`,j=u(t,D),V=S.replace(/^(?:\r?\n)+/,""),h=k.replace(/^\uFEFF/,"")!==""&&!k.endsWith(`
|
|
26
|
+
`)?D:"",P=`${k}${h}${V.trim()===""?`${j}${D}`:`${j}${D.repeat(l+1)}${V}`}`;return{nextContent:P,changed:P!==e,header:j,written:j,extraCopyrights:[]}}let f=o.slice(s.start,s.end),{foreign:p,copyrights:y}=ei(f,r,n),g=t.split(`
|
|
27
|
+
`).find(k=>k.includes("@Copyright:")),d=new Set(g===void 0?[]:[zr(g.slice(g.indexOf("@Copyright:")+11))]),m=[];for(let k of y){let S=zr(k);d.has(S)||(d.add(S),m.push(k))}let w=de(o.slice(s.end))??de(f)??`
|
|
28
|
+
`,b=w.repeat(l+1),$=n.strictHeaderBlock!==!1,C=ni(t,m),R=u(p.length>0&&!$?ri(C,p,a):C,w),E=p.length>0&&$?ti(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()===""?`${R}${w}`:`${R}${b}${G}`}`,x=`${R}${E===""?"":`${b}${E}`}`;return{nextContent:Y,changed:Y!==e,header:R,written:x,extraCopyrights:m}}i(pe,"replaceOrInsertHeader");function Ge(e,t="",r={}){let n=fe(e,t,r),o=me(n,t,r);if(o){let l=n.slice(0,o.start),f=pe(n,"",t,{...r,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${f.trim()===""?"":f}`}let{prefix:s,body:a}=ze(t,n,r),c=a.replace(/^(?:\r?\n)+/,"");return`${s}${c.trim()===""?"":c}`}i(Ge,"extractHeaderlessBody");function oi(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 s=[],a=0,c=0;for(;a<r&&c<n;)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<r;a+=1)s.push({type:"-",line:e[a]});for(;c<n;c+=1)s.push({type:"+",line:t[c]});return s}i(oi,"diffLines");function Vr(e,t){return`${t===0?e:e+1},${t}`}i(Vr,"formatRange");function Jr(e,t,r={}){let n=e===null?[]:e.split(`
|
|
12
29
|
`),o=t.split(`
|
|
13
|
-
`),s=
|
|
14
|
-
`)}i(
|
|
15
|
-
`).length-1;
|
|
30
|
+
`),s=oi(n,o),a=Math.max(0,r.context??3),c=r.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=r.fromFile??"a",f=r.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,$=m.filter(E=>E.type!=="-").length+c,C=w.filter(E=>E.type!=="+").length,R=w.filter(E=>E.type!=="-").length;p.push(`@@ -${Vr(b,C)} +${Vr($,R)} @@`);for(let E of w)p.push(`${E.type}${E.line}`)}return p.join(`
|
|
31
|
+
`)}i(Jr,"createUnifiedDiff");function ci(e){return mt(e,"configFile")}i(ci,"resolveRuntimeOptions");function li(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(r=>typeof r!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(r=>r.trim().length>0)}i(li,"resolveInputs");function ui(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(ui,"extractHeaderAuthorIdentity");function di(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}i(di,"extractHeaderLastModifiedIdentity");function fi(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(fi,"extractHeaderCreatedAt");function mi(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(mi,"extractHeaderLastModifiedAt");async function pi(e,t,r){let n=await Ar(t);return n.state!=="tracked"?{edited:n.state==="untracked",state:n.state}:{edited:Ge(n.content,t,r)!==Ge(e,t,r),state:"tracked"}}i(pi,"detectContentEdit");async function Kr(e={}){let t=await ci(e),r=t.timezone===void 0||t.timezone===null?null:Fr(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=It(t.forcedDetectors),s=qr(t.projectRoot||t.cwd||process.cwd()),a=await Te({...t,cwd:s});O(t.spacing,"spacing",Z),O(t.margin,"margin",ce);let c=t.check===!0,l=c||t.dryRun===!0,u=t.fixCreatedDate===!0,f=i(x=>x,"keepDate"),p=t.normalizeDateFormat===!0?Tr:f,y=r?x=>Or(x,r):f,g=n?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=li(t.input),w;if(m.length>0){let x=new Set;for(let k of m){let S=qr(s,k),D=await si(S).catch(()=>null);if(!D)throw new Error(`Input path does not exist: ${k}`);if(D.isFile())x.add(S);else if(D.isDirectory())for(let j of await ve({...d,projectRoot:S}))x.add(j);else throw new Error(`Input path must be a file or directory: ${k}`)}w=Array.from(x)}else w=await ve({...d,projectRoot:s});let b=new Date().getFullYear(),$=[],C=[],R=new Set,E=0,U=0,G=0,Y=[];for(let x of w){let k=Ot(x,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(k!==null){C.push({file:Ye(s,x),reason:k});continue}let S=Ye(s,x),D=await ii(x,"utf8"),j={enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides},V=Bt(x,fe(D,x,j),j);if(V!==null){C.push({file:S,reason:V});continue}let h=await Te({...t,cwd:s,targetFilePath:x});R.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?ui(F):{},Je=F.length>0?di(F):{},Xr=F.length>0?fi(F):null,Qr=F.length>0?mi(F):null,qe=await zt(x),Ke=Ye(h.projectRoot,x),Ze=await Sr(h.projectRoot,Ke),J=await Dr(h.projectRoot,Ke),Xe=ue(qe.createdAt),ge=jr({existing:Ue(Xr),gitCreated:Ze,filesystemCreated:Xe,fixCreatedDate:u}),q=Ue(Qr),Qe=ge.source,en=q?"existing-header":J?"git-last-modified":"filesystem-updated",ye=p(Qe==="existing-header"?g(ge.payload):y(ge.payload)),tn=h.copyrightStartYear===null?"created-date":"option",et=h.copyrightStartYear??Pr(ye,r),tt=p(q?g(q):y(J||ue(qe.updatedAt))),rt=t.forceAuthorUpdate===!0,rn=t.forceLastModifiedAuthorUpdate===!0,nt=await pi(D,x,P),ot=rn||nt.edited,it=i(N=>_r({absoluteFilePath:x,language:h.language,syntaxOptions:P,projectRoot:h.projectRoot,projectName:h.projectName,createdByName:rt?h.authorName:Ve.authorName||h.authorName,createdByEmail:rt?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),nn=nt.edited&&q!==null&&J!==null&&q.timestamp<J.timestamp,te=at.changed||nn,ct=te?p(y(ue(new Date))):tt,on=te?"current-time-on-change":en,sn=te?it(ct):st,L=te?pe(D,sn,x,P):at,re={file:S,changed:L.changed};if(c){let N=Ir(F,{gitCreated:Ze,gitLastModified:J,filesystemCreated:Xe},{strictCreatedDate:t.strictCreatedDate===!0}),K=N.filter(z=>z.advisory).length;re.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=S.replace(/\\/g,"/"),z=L.written,an=L.nextContent.slice(0,L.nextContent.indexOf(z)).split(`
|
|
32
|
+
`).length-1;re.sample={previousValue:N,newValue:z,diff:Jr(N,z,{fromFile:`a/${K}`,toFile:`b/${K}`,lineOffset:an}),issues:Ur(N,z),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:tn,createdAtSource:Qe,lastModifiedAtSource:on,createdAt:ye,lastModifiedAt:ct}}}if(L.extraCopyrights.length>0){re.extraCopyrights=L.extraCopyrights;for(let N of L.extraCopyrights)Y.push({file:S,copyright:N})}$.push(re),L.changed&&(E+=1,l||await ai(x,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(R),filesScanned:w.length-C.length,filesUpdated:E,filesSkipped:C.length,dryRun:l,check:c,...c?{filesWithDateDrift:U,dateAdvisories:G}:{},copyrightWarnings:Y,changes:$,skipped:C}}i(Kr,"fixHeaders");var Zr=typeof process>"u"?void 0:process.getBuiltinModule?.("node:module");if(Zr)try{Zr.createRequire(import.meta.url)("../devcheck.mjs")}catch(e){if(e?.code!=="MODULE_NOT_FOUND")throw e}function hi(e){return Kr(e)}i(hi,"fixHeaders");var hc=hi;export{hc as default,hi as fixHeaders};
|
|
16
33
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/fix-headers",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "Multi-language project header normalizer with auto-detection and override support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dist/",
|
|
11
11
|
"!dist/**/*.map",
|
|
12
12
|
"types/",
|
|
13
|
+
"!types/devcheck.d.mts",
|
|
13
14
|
"bin/",
|
|
14
15
|
"!bin/**/*.map"
|
|
15
16
|
],
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
".": {
|
|
18
19
|
"fix-headers-dev": {
|
|
19
20
|
"types": "./types/index.d.mts",
|
|
20
|
-
"import": "./src/
|
|
21
|
+
"import": "./src/index.mjs",
|
|
22
|
+
"require": "./src/index.cjs"
|
|
21
23
|
},
|
|
22
24
|
"types": "./types/index.d.mts",
|
|
23
25
|
"import": "./dist/index.mjs",
|
|
@@ -31,13 +33,13 @@
|
|
|
31
33
|
"scripts": {
|
|
32
34
|
"build:ci": "npm run lint --if-present && npm run format:check --if-present && npm run types:check && npm run types:build && npm run build",
|
|
33
35
|
"test": "node tests/run-vitest.mjs && npm run test:cjs",
|
|
34
|
-
"test:cjs": "npm run build && node --test tests/cjs/entry.test.cjs",
|
|
36
|
+
"test:cjs": "npm run build && node --conditions=fix-headers-dev --test tests/cjs/entry.test.cjs",
|
|
35
37
|
"test:watch": "vitest --config .configs/vitest.config.mjs",
|
|
36
38
|
"coverage": "node tests/run-vitest.mjs --coverage-quiet && npm run test:cjs",
|
|
37
39
|
"ci:coverage": "npm run coverage",
|
|
38
40
|
"types:build": "tsc -p .configs/tsconfig.json --noCheck",
|
|
39
41
|
"types:check": "tsc -p .configs/tsconfig.json --noEmit",
|
|
40
|
-
"cli": "node ./src/cli.mjs",
|
|
42
|
+
"cli": "node --conditions=fix-headers-dev ./src/cli.mjs",
|
|
41
43
|
"build": "node -e \"for (const d of ['dist', 'bin']) require('node:fs').rmSync(d, { recursive: true, force: true })\" && tsup",
|
|
42
44
|
"prepack": "node -e \"const fs=require('node:fs');const hasTsup=fs.existsSync('node_modules/.bin/tsup')||fs.existsSync('node_modules/.bin/tsup.cmd');if(hasTsup){require('node:child_process').execSync('npm run build',{stdio:'inherit'})}else if(!fs.existsSync('dist/index.mjs')){throw new Error('dist/ is missing and tsup is unavailable to build it (expected in a bare package-contents publish dir with a prebuilt dist/; unexpected anywhere else)')}\"",
|
|
43
45
|
"lint": "eslint --config .configs/eslint.config.mjs .",
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"format": "prettier --config .configs/.prettierrc --write .",
|
|
46
48
|
"format:check": "prettier --config .configs/.prettierrc --check .",
|
|
47
49
|
"prepare": "node -e \"import('./.githooks/install.mjs').catch(()=>{})\"",
|
|
48
|
-
"fix:headers": "node ./src/cli.mjs --config .configs/fix-headers.json"
|
|
50
|
+
"fix:headers": "node --conditions=fix-headers-dev ./src/cli.mjs --config .configs/fix-headers.json"
|
|
49
51
|
},
|
|
50
52
|
"keywords": [
|
|
51
53
|
"headers",
|
|
@@ -62,7 +64,7 @@
|
|
|
62
64
|
},
|
|
63
65
|
"homepage": "https://github.com/CLDMV/fix-headers#readme",
|
|
64
66
|
"engines": {
|
|
65
|
-
"node": ">=22.
|
|
67
|
+
"node": ">=22.13.0"
|
|
66
68
|
},
|
|
67
69
|
"author": {
|
|
68
70
|
"name": "Shinrai",
|
|
@@ -109,6 +111,8 @@
|
|
|
109
111
|
"ignore": "^7.0.5"
|
|
110
112
|
},
|
|
111
113
|
"overrides": {
|
|
112
|
-
"esbuild": "$esbuild"
|
|
114
|
+
"esbuild": "$esbuild",
|
|
115
|
+
"katex": ">=0.19.1 <1.0.0",
|
|
116
|
+
"minimatch": "^11.0.3"
|
|
113
117
|
}
|
|
114
118
|
}
|
package/types/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./src/
|
|
2
|
-
export { default } from "./src/
|
|
1
|
+
export * from "./src/index.mjs";
|
|
2
|
+
export { default } from "./src/index.mjs";
|
|
@@ -15,6 +15,7 @@ export type FixHeadersOptions = {
|
|
|
15
15
|
check?: boolean;
|
|
16
16
|
fixCreatedDate?: boolean;
|
|
17
17
|
strictCreatedDate?: boolean;
|
|
18
|
+
strictHeaderBlock?: boolean;
|
|
18
19
|
normalizeDateFormat?: boolean;
|
|
19
20
|
timezone?: string;
|
|
20
21
|
convertTimezone?: boolean;
|
|
@@ -90,8 +91,14 @@ export type DateRewrite = (payload: {
|
|
|
90
91
|
* Files whose format cannot carry the header comment are not processed: each is listed in
|
|
91
92
|
* `skipped` as `{ file, reason }` and counted in `filesSkipped`, not in `filesScanned` or
|
|
92
93
|
* `changes`. That covers strict `.json`, files with no extension or an extension no enabled
|
|
93
|
-
* detector handles (for example one added through `includeExtensions`),
|
|
94
|
-
* `forcedDetectors` includes `"markdown"`.
|
|
94
|
+
* detector handles (for example one added through `includeExtensions`), Markdown unless
|
|
95
|
+
* `forcedDetectors` includes `"markdown"`, and a `.php` file that does not open with `<?php`.
|
|
96
|
+
*
|
|
97
|
+
* `copyrightWarnings` lists, as `{ file, copyright }`, every additional `@Copyright` a header
|
|
98
|
+
* keeps: a `@Copyright` line after the header's own (in the header or a stacked copy of it)
|
|
99
|
+
* that names another holder. The same values are on the file's entry in `changes` as
|
|
100
|
+
* `extraCopyrights`. A warning is reported on every run that finds it and changes nothing on
|
|
101
|
+
* its own.
|
|
95
102
|
*/
|
|
96
103
|
export type FixHeadersResult = {
|
|
97
104
|
metadata: {
|
|
@@ -118,9 +125,14 @@ export type FixHeadersResult = {
|
|
|
118
125
|
check: boolean;
|
|
119
126
|
filesWithDateDrift?: number;
|
|
120
127
|
dateAdvisories?: number;
|
|
128
|
+
copyrightWarnings: Array<{
|
|
129
|
+
file: string;
|
|
130
|
+
copyright: string;
|
|
131
|
+
}>;
|
|
121
132
|
changes: Array<{
|
|
122
133
|
file: string;
|
|
123
134
|
changed: boolean;
|
|
135
|
+
extraCopyrights?: string[];
|
|
124
136
|
dateIssues?: import("../header/dates.mjs").DateCheckIssue[];
|
|
125
137
|
sample?: {
|
|
126
138
|
previousValue: string | null;
|
|
@@ -2,6 +2,7 @@ export namespace detector {
|
|
|
2
2
|
export let id: string;
|
|
3
3
|
export { extensions };
|
|
4
4
|
export let enabledByDefault: boolean;
|
|
5
|
+
export function keepsAboveHeader(line: any, index: any): boolean;
|
|
5
6
|
export function resolveCommentSyntax(filePath: any): {
|
|
6
7
|
kind: "block";
|
|
7
8
|
blockStart: string;
|
|
@@ -2,6 +2,7 @@ export namespace detector {
|
|
|
2
2
|
export let id: string;
|
|
3
3
|
export { extensions };
|
|
4
4
|
export let enabledByDefault: boolean;
|
|
5
|
+
export function resolvePreservedPrefix(filePath: any, content: any): string;
|
|
5
6
|
export function resolveCommentSyntax(filePath: any): {
|
|
6
7
|
kind: "block";
|
|
7
8
|
blockStart: string;
|