@cldmv/fix-headers 2.4.0 → 2.5.1
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 +8 -7
- package/dist/cli.mjs +56 -0
- package/dist/config/load.mjs +2 -0
- package/dist/constants.mjs +2 -0
- package/dist/core/file-discovery.mjs +2 -0
- package/dist/core/fix-headers.mjs +3 -0
- package/dist/core/ignore-rules.mjs +2 -0
- package/dist/detect/project.mjs +2 -0
- package/dist/detectors/c.mjs +6 -0
- package/dist/detectors/css.mjs +2 -0
- package/dist/detectors/go.mjs +2 -0
- package/dist/detectors/html.mjs +2 -0
- package/dist/detectors/index.mjs +3 -0
- package/dist/detectors/json.mjs +2 -0
- package/dist/detectors/markdown.mjs +2 -0
- package/dist/detectors/node.mjs +2 -0
- package/dist/detectors/php.mjs +2 -0
- package/dist/detectors/python.mjs +2 -0
- package/dist/detectors/rust.mjs +2 -0
- package/dist/detectors/top-lines.mjs +3 -0
- package/dist/detectors/yaml.mjs +2 -0
- package/dist/drivers/go.mjs +2 -0
- package/dist/drivers/index.mjs +2 -0
- package/dist/drivers/node.mjs +2 -0
- package/dist/drivers/php.mjs +2 -0
- package/dist/drivers/python.mjs +2 -0
- package/dist/drivers/rust.mjs +2 -0
- package/dist/drivers/shared.mjs +4 -0
- package/dist/header/dates.mjs +2 -0
- package/dist/header/fields.mjs +2 -0
- package/dist/header/parser.mjs +21 -0
- package/dist/header/syntax.mjs +4 -0
- package/dist/header/template.mjs +2 -0
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +2 -37
- package/dist/utils/diff.mjs +5 -0
- package/dist/utils/fs.mjs +2 -0
- package/dist/utils/git.mjs +4 -0
- package/dist/utils/text.mjs +2 -0
- package/dist/utils/time.mjs +2 -0
- package/package.json +5 -8
- package/types/src/core/fix-headers.d.mts +1 -0
- package/types/src/detectors/node.d.mts +17 -0
- package/bin/fix-headers.mjs +0 -89
package/README.md
CHANGED
|
@@ -14,18 +14,17 @@ Headers stay correct without hand-editing: `@Date` follows the file's real creat
|
|
|
14
14
|
|
|
15
15
|
## ✨ What's New
|
|
16
16
|
|
|
17
|
-
### Latest: v2.
|
|
17
|
+
### Latest: v2.5.1 (November 2026)
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- [View full v2.4.0 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.4.0.md)
|
|
19
|
+
- **Unbundled build** — `dist/` now mirrors `src/` one file per module instead of a bundle, and the CLI (`dist/cli.mjs`) imports the library rather than shipping its own copy. The `fix-headers` command is unchanged; the `bin/` folder is no longer published ([#206](https://github.com/CLDMV/fix-headers/pull/206), fixes [#205](https://github.com/CLDMV/fix-headers/issues/205)).
|
|
20
|
+
- [View full v2.5.1 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.5.1.md)
|
|
22
21
|
|
|
23
22
|
### Recent Releases
|
|
24
23
|
|
|
24
|
+
- **v2.5.0** (November 2026) — generated declarations carrying `tsc`'s copy of their source's header are restamped for where they ship; `rewriteDeclarationCopies: false` opts out ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.5.0.md))
|
|
25
|
+
- **v2.4.0** (November 2026) — `@Filename` is written without a leading slash (`src/index.mjs`), and declarations carrying `tsc`'s copy of their source's header are skipped ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.4.0.md))
|
|
25
26
|
- **v2.3.0** (November 2026) — `.mts`/`.cts` in the `node` detector and a new `c` detector for C/C++; C files carrying another holder's license notice are skipped ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.3.0.md))
|
|
26
27
|
- **v2.2.7** (November 2026) — no library code changed: the tests get the `fix-headers-dev` condition through `devCondition()`, and `npm run test:dist` runs the same suite against `dist/` ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.7.md))
|
|
27
|
-
- **v2.2.6** (November 2026) — `engines.node` is back to `>=18.0.0`, the runtime floor; the 22.22.0 development toolchain floor moves to `devEngines`, and the `require()` error names ^20.19.0 or >=22.13.0 ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.6.md))
|
|
28
|
-
- **v2.2.5** (November 2026) — the source-checkout development check is removed (the `fix-headers-dev` condition already picks `src/` or `dist/`), and `engines.node` went to `>=22.22.0` ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.2.5.md))
|
|
29
28
|
|
|
30
29
|
📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder.
|
|
31
30
|
|
|
@@ -118,6 +117,7 @@ Common CLI options:
|
|
|
118
117
|
- `--check` - validate header dates without writing; exits `1` on date drift (see [Date checks](#-date-checks))
|
|
119
118
|
- `--fix-created-date`
|
|
120
119
|
- `--strict-created-date`
|
|
120
|
+
- `--rewrite-declaration-copies [true|false]` / `--no-rewrite-declaration-copies` - set `rewriteDeclarationCopies` (on by default); `--no-rewrite-declaration-copies` skips declarations that carry `tsc`'s copy of their source's header
|
|
121
121
|
- `--strict-header-block [true|false]` / `--no-strict-header-block` - set `strictHeaderBlock` (on by default); `--no-strict-header-block` (or `--strict-header-block false`) keeps text found in a header that is not a header field inside the header, after the fields, instead of moving it to its own block below (see [Text in the header block](#text-in-the-header-block))
|
|
122
122
|
- `--normalize-date-format`
|
|
123
123
|
- `--timezone <name>` - write new header dates in an IANA time zone (see [Time zone](#-time-zone))
|
|
@@ -160,6 +160,7 @@ Important options:
|
|
|
160
160
|
- `check?: boolean` - validate each existing header's dates and write nothing (implies `dryRun`). Each result entry gets `dateIssues`, and the result gets `filesWithDateDrift` and `dateAdvisories`. See [Date checks](#-date-checks)
|
|
161
161
|
- `fixCreatedDate?: boolean` - move an existing `@Date` back to the oldest of itself, the file's git first commit, and its filesystem creation time (see [Creation date](#-creation-date)). It only ever moves `@Date` earlier. Off by default: an existing `@Date` is kept as written
|
|
162
162
|
- `strictCreatedDate?: boolean` - with `check`, count a `@Date` later than the file's git first commit or filesystem creation time as drift (fails the run). Off by default, where it is an advisory
|
|
163
|
+
- `rewriteDeclarationCopies?: boolean` - restamp a declaration file that carries `tsc`'s copy of its own source's header for the path and package it ships in, keeping the source's dates and editor (see the skip rules below). On by default. `false` skips those declarations instead, for repos that still commit generated `types/`
|
|
163
164
|
- `strictHeaderBlock?: boolean` - the header block holds only header fields. On by default: text in an existing header that is not a header field (a description, an unknown `@Tag:` line) is moved, verbatim and in order, to its own comment block directly below the header. `false` keeps it inside the header, after the fields. It is never deleted either way. See [Text in the header block](#text-in-the-header-block)
|
|
164
165
|
- `normalizeDateFormat?: boolean` - write every header date in the git `%aI` form (`2026-03-01T17:59:32-08:00`), keeping each date's offset and instant. Off by default; the first run rewrites (and restamps) every managed file whose dates use the space form (`2026-03-01 17:59:32 -08:00`)
|
|
165
166
|
- `timezone?: string` - an IANA time zone name (`America/Los_Angeles`, `UTC`, `Asia/Kolkata`, ...). Every date fix-headers writes (a new header's `@Date`, and `@Last modified time`) is expressed in that zone; the instant and its epoch never change. Unset (the default): dates are written as today. An unknown zone name throws. See [Time zone](#-time-zone)
|
|
@@ -579,7 +580,7 @@ Every other file is skipped and left byte-for-byte unchanged, including when you
|
|
|
579
580
|
- **Files with no extension, or an extension no enabled detector handles** (`.txt`, `.toml`, a disabled detector's extensions, …) are skipped instead of being given a guessed comment.
|
|
580
581
|
- **A PHP file that does not open with `<?php`** (a template starting with HTML) is skipped: a comment at the top would be output as text. A file where only a fix-headers header (and blank lines) comes before `<?php` is not skipped: an earlier version wrote that header there, and it is moved back below `<?php` (see [What stays above the header](#what-stays-above-the-header)).
|
|
581
582
|
- **Third-party C and C++** is skipped: a `c` file whose prologue (the comments, blank lines and preprocessor directives before its first line of code) holds a comment with license or copyright wording (`Copyright`, `License`, `SPDX-License-Identifier`, `public domain`) that is not a fix-headers header is left untouched, so a vendored library such as the SQLite amalgamation (`sqlite3.c`, `sqlite3.h`) keeps its own notice. A file whose first comment is already a fix-headers header is never skipped this way. To keep a whole folder of vendored code out of the run regardless of its comments, use `excludeFolders` / `--exclude-folder`.
|
|
582
|
-
- **A declaration file `tsc` generated from a source with a header**
|
|
583
|
+
- **A declaration file `tsc` generated from a source with a header** gets a header of its own. `tsc` copies the source's header into the `.d.ts` / `.d.mts` / `.d.cts` it emits, `@Filename` included, so the declaration an IDE shows would name the source. A declaration whose header names its own source (`types/src/x.d.mts` with `@Filename: src/x.mts`, or `.mjs`; `.d.ts` pairs with `.ts .tsx .js .jsx`, `.d.cts` with `.cts .cjs`) is restamped for the path it ships at: `@Filename: types/src/x.d.mts` and that package's `@Project`, with `@Date`, `@Author`, `@Last modified by` and `@Last modified time` kept from the source's header, since a generated file has no git history of its own. A staged package folder with its own `package.json` is its own project root, so `dist-packages/x-types/lib/x.d.mts` gets `@Filename: lib/x.d.mts`. Run fix-headers after `tsc` where the declarations are built (CI, `prepack`) and keep them out of git: a repo that commits `types/` sees `tsc` and fix-headers rewrite each other's `@Filename` on every build, and should set `rewriteDeclarationCopies: false` (`--no-rewrite-declaration-copies`), which skips these declarations and leaves `tsc`'s copy as it is. A declaration with no header, or one whose header names any other file, is fixed as usual either way.
|
|
583
584
|
- **Markdown** is skipped unless the `markdown` detector is forced with `--force-detector markdown` (`forcedDetectors: ["markdown"]` in the API or a config file). Naming a `.md` file with `--input` does not force it. A forced header is an HTML comment, which Markdown renderers do not display; it goes below any YAML front matter (`---` … `---`), and later runs update it in place. Forcing applies to discovery too, so a repo-wide run with the option also stamps `README.md` and changelogs; to stamp one file, pass the option together with `--input <file>`. `.mdx` is not covered, because MDX does not accept HTML comments.
|
|
584
585
|
|
|
585
586
|
A skipped file is listed in the result's `skipped` array as `{ file, reason }` and counted in `filesSkipped`, not in `filesScanned` or `changes`. The CLI adds `skipped=<n>` to its summary and prints one `skipped: <file> (<reason>)` line per file:
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var k=Object.defineProperty;var l=(t,e)=>k(t,"name",{value:e,configurable:!0});import{realpathSync as m}from"node:fs";import{fileURLToPath as b,pathToFileURL as v}from"node:url";import{applyConfigOption as x}from"./config/load.mjs";import A from"./index.mjs";const $=`fix-headers CLI
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
fix-headers [options]
|
|
6
|
+
|
|
7
|
+
Options:
|
|
8
|
+
-h, --help Show help
|
|
9
|
+
--dry-run Compute changes without writing files
|
|
10
|
+
--check Validate header dates without writing; exit 1 on date drift
|
|
11
|
+
--fix-created-date Move an existing @Date back to the oldest of git first commit / file creation
|
|
12
|
+
--strict-created-date With --check, fail when @Date is later than git first commit / file creation
|
|
13
|
+
--rewrite-declaration-copies [true|false] Restamp .d.ts/.d.mts/.d.cts files carrying tsc's copy of their source's header, keeping its dates (default: true)
|
|
14
|
+
--no-rewrite-declaration-copies Skip those declarations and leave tsc's copied header as it is
|
|
15
|
+
--strict-header-block [true|false] Move non-field text found in a header to its own block below it (default: true)
|
|
16
|
+
--no-strict-header-block Keep non-field text found in a header inside it, after the fields
|
|
17
|
+
--normalize-date-format Write every header date in the ISO 8601 T-form (git %aI)
|
|
18
|
+
--timezone <name> Write new dates in an IANA time zone (e.g. America/Los_Angeles, UTC); the instant never changes
|
|
19
|
+
--convert-timezone With --timezone, also rewrite existing @Date/@Last modified time values into that zone
|
|
20
|
+
--json Print JSON output
|
|
21
|
+
--verbose Print updated file paths in summary mode; with --sample-output or --diff, also print each file's field differences
|
|
22
|
+
--sample-output Show previous/new header sample for changed files
|
|
23
|
+
--diff Print a unified diff of each changed file's header (implies sample output)
|
|
24
|
+
--force-author-update Replace an existing @Author/@Email with the detected/current values
|
|
25
|
+
--force-last-modified-author-update Write the detected identity as @Last modified by on every file, edited or not
|
|
26
|
+
--use-gpg-signer-author Use signed-commit UID (%GS) for detected @Author
|
|
27
|
+
--cwd <path> Working directory for project detection
|
|
28
|
+
--input <path> File or folder to process instead of the whole project (repeatable)
|
|
29
|
+
--include-folder <path> Include folder (repeatable)
|
|
30
|
+
--include-folder-non-recursive <path> Include only a folder's own files, not its subfolders (repeatable)
|
|
31
|
+
--exclude-folder <path> Exclude folder name/path (repeatable)
|
|
32
|
+
--include-extension <ext> Include extension (repeatable)
|
|
33
|
+
--enable-detector <id> Enable only specific detector (repeatable)
|
|
34
|
+
--disable-detector <id> Disable detector by id (repeatable)
|
|
35
|
+
--force-detector <id> Use a force-only detector, e.g. markdown (HTML-comment headers in .md files) (repeatable)
|
|
36
|
+
--project-name <name> Override project name
|
|
37
|
+
--language <id> Override language id
|
|
38
|
+
--project-root <path> Override project root
|
|
39
|
+
--marker <name|null> Override marker filename
|
|
40
|
+
--author-name <name> Override author name
|
|
41
|
+
--author-email <email> Override author email
|
|
42
|
+
--company <name> Append company suffix to @Author (Name <Company>)
|
|
43
|
+
--company-name <name> @Copyright holder (default: the project manifest's author; omitted when none)
|
|
44
|
+
--copyright-start-year <year> Set the copyright start year (default: each file's @Date year)
|
|
45
|
+
--spacing <n> Empty comment lines just inside the header's opening and closing (default: 1)
|
|
46
|
+
--margin <n> Blank lines between the header and the file's next content (default: 2)
|
|
47
|
+
--config <path> Load JSON options file; its 'extends' can pull in shared configs (URL, package or path)
|
|
48
|
+
|
|
49
|
+
Examples:
|
|
50
|
+
fix-headers --dry-run --include-folder src
|
|
51
|
+
fix-headers --dry-run --diff --verbose
|
|
52
|
+
fix-headers --check --verbose
|
|
53
|
+
fix-headers --timezone America/Los_Angeles --convert-timezone
|
|
54
|
+
fix-headers --project-name @scope/pkg --company-name "Catalyzed Motivation Inc."
|
|
55
|
+
`;function C(t){return t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}l(C,"toCamelCase");function j(t){const e={},n={help:!1,json:!1,diff:!1},r={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors","force-detector":"forcedDetectors",input:"input"},c={cwd:"cwd","project-name":"projectName",language:"language","project-root":"projectRoot",marker:"marker","author-name":"authorName","author-email":"authorEmail",company:"company","company-name":"companyName","copyright-start-year":"copyrightStartYear",spacing:"spacing",margin:"margin",timezone:"timezone",config:"config"};for(let i=0;i<t.length;i+=1){const o=t[i];if(o==="-h"||o==="--help"){n.help=!0;continue}if(o==="--json"){n.json=!0;continue}if(o==="--diff"){n.diff=!0;continue}if(o==="--verbose"){e.verbose=!0;continue}if(o==="--dry-run"){e.dryRun=!0;continue}if(o==="--check"){e.check=!0;continue}if(o==="--fix-created-date"){e.fixCreatedDate=!0;continue}if(o==="--rewrite-declaration-copies"){const a=t[i+1];(a==="true"||a==="false")&&(i+=1),e.rewriteDeclarationCopies=a!=="false";continue}if(o==="--no-rewrite-declaration-copies"){e.rewriteDeclarationCopies=!1;continue}if(o==="--strict-created-date"){e.strictCreatedDate=!0;continue}if(o==="--strict-header-block"){const a=t[i+1];(a==="true"||a==="false")&&(i+=1),e.strictHeaderBlock=a!=="false";continue}if(o==="--no-strict-header-block"){e.strictHeaderBlock=!1;continue}if(o==="--normalize-date-format"){e.normalizeDateFormat=!0;continue}if(o==="--convert-timezone"){e.convertTimezone=!0;continue}if(o==="--sample-output"){e.sampleOutput=!0;continue}if(o==="--force-author-update"){e.forceAuthorUpdate=!0;continue}if(o==="--force-last-modified-author-update"){e.forceLastModifiedAuthorUpdate=!0;continue}if(o==="--use-gpg-signer-author"){e.useGpgSignerAuthor=!0;continue}if(!o.startsWith("--"))throw new Error(`Unexpected argument: ${o}`);const s=o.slice(2);if(s==="include-folder-non-recursive"){const a=t[i+1];if(!a||a.startsWith("--"))throw new Error(`Missing value for --${s}`);i+=1;const f=Array.isArray(e.includeFolders)?e.includeFolders:[];e.includeFolders=[...f,{path:a,recursive:!1}];continue}if(r[s]){const a=t[i+1];if(!a||a.startsWith("--"))throw new Error(`Missing value for --${s}`);i+=1;const f=r[s],p=Array.isArray(e[f])?e[f]:[];e[f]=Array.from(new Set([...p,a]));continue}if(c[s]){const a=t[i+1];if(!a||a.startsWith("--"))throw new Error(`Missing value for --${s}`);i+=1;const f=c[s];if(f==="copyrightStartYear"||f==="spacing"||f==="margin"){if(e[f]=Number.parseInt(a,10),Number.isNaN(e[f]))throw new Error(`Invalid number for --${s}: ${a}`)}else f==="marker"&&a==="null"?e[f]=null:e[f]=a;continue}const d=C(s),u=t[i+1];if(!u||u.startsWith("--"))throw new Error(`Unknown or malformed flag: --${s}`);i+=1,e[d]=u}return{options:e,help:n.help,json:n.json,diff:n.diff}}l(j,"parseCliArgs");function S(t){return x(t,"config")}l(S,"applyConfigFile");function h(t){if(!t||typeof t!="object")return[];const e=t;return(Array.isArray(e.changes)?e.changes:[]).filter(r=>r&&r.changed===!0&&r.sample&&typeof r.sample.newValue=="string")}l(h,"getSampledChanges");function g(t){return typeof t=="string"?`"${t}"`:"(missing)"}l(g,"formatIssueValue");function D(t,e){for(const n of h(e)){const r=Array.isArray(n.sample.issues)?n.sample.issues:[];if(t(`issues: ${n.file||"<unknown-file>"}`),r.length===0){t(" (no field differences; header formatting only)");continue}for(const c of r)t(` ${c?.field||"<unknown-field>"}: found ${g(c?.previous)}, expected ${g(c?.detected)}`)}}l(D,"printIssues");function O(t,e){for(const n of h(e))typeof n.sample.diff=="string"&&n.sample.diff.length>0&&t(n.sample.diff)}l(O,"printDiffs");function W(t,e){for(const n of h(e))t(`sample: ${n.file||"<unknown-file>"}`),t("previous:"),t(n.sample.previousValue===null?"(none)":String(n.sample.previousValue)),t("new:"),t(n.sample.newValue),n.sample.detectedValues&&typeof n.sample.detectedValues=="object"&&(t("detected-values:"),t(JSON.stringify(n.sample.detectedValues,null,2)))}l(W,"printSampleOutput");function z(t,e){if(!e||typeof e!="object")return;const n=e,c=(Array.isArray(n.changes)?n.changes:[]).filter(i=>i&&i.changed===!0).map(i=>i.file||"<unknown-file>");for(const i of c)t(`updated: ${i}`)}l(z,"printChangedFiles");function y(t,e){const n=Array.isArray(e.copyrightWarnings)?e.copyrightWarnings:[];for(const r of n)t(`warning: ${r?.file||"<unknown-file>"} keeps an additional @Copyright: ${r?.copyright??""}`)}l(y,"printCopyrightWarnings");function E(t,e){const n=Array.isArray(e.skipped)?e.skipped:[];for(const r of n)t(`skipped: ${r?.file||"<unknown-file>"} (${r?.reason||"no reason given"})`)}l(E,"printSkipped");function w(t,e,n,r){const c=n.sampleOutput===!0||r;n.verbose===!0&&(z(t,e),c&&D(t,e)),n.sampleOutput===!0&&W(t,e),r&&O(t,e)}l(w,"printDetails");function I(t,e,n){const r=Array.isArray(e.changes)?e.changes:[];for(const c of r){const i=Array.isArray(c?.dateIssues)?c.dateIssues:[];for(const o of i)o.advisory===!0&&!n||t(`${o.advisory===!0?"advisory":"drift"}: ${c.file||"<unknown-file>"}: ${o.message}`)}}l(I,"printDateIssues");async function N(t,e={}){const n=e.runner||A,r=e.stdout||console.log,c=e.stderr||console.error;try{const i=j(t);if(i.help)return r($),0;const o=await S(i.options),s=await n(i.diff?{...o,sampleOutput:!0}:o),d=s&&typeof s=="object"&&s.check===!0?s:null,u=d&&Number(d.filesWithDateDrift)>0?1:0;if(i.json)return r(JSON.stringify(s,null,2)),u;if(d)return r(`fix-headers check: scanned=${d.filesScanned??0}, drift=${d.filesWithDateDrift??0}, advisories=${d.dateAdvisories??0}`),I(r,d,o.verbose===!0),y(r,s),u;if(s&&typeof s=="object"){const a=s,f=Number(a.filesSkipped)>0?`, skipped=${a.filesSkipped}`:"",p=Array.isArray(a.copyrightWarnings)&&a.copyrightWarnings.length>0?`, warnings=${a.copyrightWarnings.length}`:"";r(`fix-headers complete: scanned=${a.filesScanned??0}, updated=${a.filesUpdated??0}${f}${p}, dryRun=${a.dryRun===!0}`),E(r,a),y(r,a),w(r,s,o,i.diff)}else w(r,s,o,i.diff),r("fix-headers complete");return 0}catch(i){const o=i instanceof Error?i.message:String(i);return c(`fix-headers failed: ${o}`),1}}l(N,"runCli");function U(t=process.argv,e=import.meta.url,n=N){let r=!1;if(t[1])try{const c=m(t[1]),i=m(b(e));r=c===i}catch{r=e===v(t[1]).href}return r?(n(t.slice(2)).then(c=>{process.exitCode=c}),!0):!1}l(U,"runCliAsMain"),U();export{S as applyConfigFile,j as parseCliArgs,N as runCli,U as runCliAsMain};
|
|
56
|
+
//# sourceMappingURL=cli.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=Object.defineProperty;var o=(t,r)=>m(t,"name",{value:r,configurable:!0});import{readFile as $}from"node:fs/promises";import{createRequire as y}from"node:module";import{dirname as x,isAbsolute as E,resolve as u}from"node:path";const S=3e4,C=new Set(["localhost","127.0.0.1","[::1]"]);function f(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}o(f,"isPlainObject");function h(t,r){const e={...t};for(const[n,i]of Object.entries(r))n!=="__proto__"&&(e[n]=f(e[n])&&f(i)?h(e[n],i):i);return e}o(h,"mergeConfig");function l(t){return t.kind==="file"?t.path:t.href}o(l,"describeSource");async function b(t){if(t.kind==="file")return{text:await $(t.path,"utf8"),source:t};let r;try{r=await fetch(t.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(S)})}catch(e){const n=e.cause instanceof Error?e.cause.message:e.message;throw new Error(`Failed to fetch config ${t.href}: ${n}`,{cause:e})}if(!r.ok)throw new Error(`Failed to fetch config ${t.href}: HTTP ${r.status} ${r.statusText}`);return{text:await r.text(),source:{kind:"url",href:r.url}}}o(b,"readSource");function d(t){if(t.protocol==="http:"&&!C.has(t.hostname))throw new Error(`Refusing to fetch config over plain http: ${t.href} (use https)`);return{kind:"url",href:t.href}}o(d,"toUrlSource");function k(t,r){if(/^https?:\/\//i.test(t))return d(new URL(t));if(/^[a-z][a-z\d+.-]+:\/\//i.test(t))throw new Error(`Unsupported extends URL "${t}" in ${l(r)}; use https, a file path or a package path`);const e=/^\.{1,2}[\\/]/.test(t);if(r.kind==="url"){if(e||t.startsWith("/"))return d(new URL(t,r.href));throw new Error(`Cannot extend package "${t}" from the remote config ${r.href}; use a URL or a relative path`)}if(e||E(t))return{kind:"file",path:u(x(r.path),t)};try{return{kind:"file",path:y(r.path).resolve(t)}}catch(n){throw new Error(`Cannot resolve extends "${t}" from ${r.path}: ${n.message}`,{cause:n})}}o(k,"resolveReference");function O(t,r){if(t===void 0)return[];const e=Array.isArray(t)?t:[t];if(!e.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${r}`);return e.map(n=>n.trim())}o(O,"readExtends");async function p(t,r){const e=l(t);if(r.includes(e))throw new Error(`Config extends cycle: ${[...r,e].join(" -> ")}`);const{text:n,source:i}=await b(t);let s;try{s=JSON.parse(n)}catch(a){throw new Error(`Config ${e} is not valid JSON: ${a.message}`,{cause:a})}if(!f(s))throw new Error(`Config file must contain a JSON object: ${e}`);const{extends:w,...g}=s;let c={};for(const a of O(w,e))c=h(c,await p(k(a,i),[...r,e]));return h(c,g)}o(p,"loadSource");function _(t,r=process.cwd()){return p({kind:"file",path:u(r,t)},[])}o(_,"loadConfigFile");async function j(t,r){const e=typeof t[r]=="string"?t[r].trim():"";if(e.length===0)return t;const n=typeof t.cwd=="string"&&t.cwd.length>0?t.cwd:process.cwd(),i={...await _(e,n),...t};return delete i[r],i}o(j,"applyConfigOption");export{j as applyConfigOption,_ as loadConfigFile,h as mergeConfig};
|
|
2
|
+
//# sourceMappingURL=load.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n=Object.defineProperty;var r=(o,t)=>n(o,"name",{value:t,configurable:!0});import{DETECTOR_PROFILES as m,getAllowedExtensions as p,getEnabledDetectors as x}from"./detectors/index.mjs";const A=200,s=1,_=2;function f(o,t,e){if(o==null)return e;if(typeof o!="number"||!Number.isInteger(o)||o<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(o)}`);return o}r(f,"resolveLayoutCount");export{_ as DEFAULT_HEADER_MARGIN,s as DEFAULT_HEADER_SPACING,A as DEFAULT_MAX_HEADER_SCAN_LINES,m as DETECTOR_PROFILES,p as getAllowedExtensions,x as getEnabledDetectors,f as resolveLayoutCount};
|
|
2
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var A=Object.defineProperty;var n=(r,o)=>A(r,"name",{value:o,configurable:!0});import{existsSync as D}from"node:fs";import{join as g,relative as y,resolve as R,sep as E}from"node:path";import{realpath as N,stat as $}from"node:fs/promises";import{getAllowedExtensions as k}from"../detectors/index.mjs";import{walkFiles as O}from"../utils/fs.mjs";import{trimTrailingSlashes as _}from"../utils/text.mjs";import{createIgnoreFilter as I}from"./ignore-rules.mjs";function W(r){return k(r)}n(W,"resolveExtensions");const z=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),S=new Set([".git",...z]),L=Object.freeze(["autoload.php","modules.txt"]);function P(r,o){return S.has(o)?!0:o==="vendor"&&L.some(s=>D(g(r,s)))}n(P,"isNeverWalked");function x(r){return _(r.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}n(x,"normalizeFolderPath");function M(r){return Array.isArray(r)?r.map(o=>{if(typeof o=="string")return{path:o,recursive:!0};if(o&&typeof o=="object"&&typeof o.path=="string")return{path:o.path,recursive:o.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(o)} (expected a path string or { path, recursive? })`)}):[]}n(M,"resolveIncludeFolders");function b(r,o){const s=o instanceof Error?o.message:String(o);console.warn(`fix-headers: skipped include folder "${r}" (${s})`)}n(b,"reportSkippedIncludeFolder");function T(r,o){if(!Array.isArray(o)||o.length===0)return()=>!1;const s=R(r),f=[],u=new Set;for(const i of o){if(typeof i!="string")continue;const c=x(i);if(c.length!==0){if(c.includes("/")){f.push(R(s,c));continue}u.add(c)}}return(i,c)=>{if(u.has(c))return!0;for(const l of f)if(i===l||i.startsWith(`${l}/`))return!0;const p=x(y(s,i));return f.some(l=>{const d=x(y(s,l));return p===d||p.startsWith(`${d}/`)})}}n(T,"buildExclusionMatcher");async function H(r){const o=W(r),s=M(r.includeFolders),f=Array.isArray(r.excludeFolders)?r.excludeFolders:[],u=T(r.projectRoot,f),i=I({root:r.projectRoot,gitignore:r.gitignore}),c=n(async(e,t)=>P(e,t)||u(e,t)||await i.isIgnored(e,!0),"shouldSkipDirectory"),p=s.length>0?s.map(e=>({includeFolder:e.path,rootPath:g(r.projectRoot,e.path),recursive:e.recursive})):[{includeFolder:".",rootPath:r.projectRoot,recursive:!0}],l=[];for(const e of p){const t=await $(e.rootPath).catch(a=>a);if(t instanceof Error){if(t.code==="ENOENT"){b(e.includeFolder,t);continue}throw t}if(!t.isDirectory()){b(e.includeFolder,`path is not a directory: ${e.rootPath}`);continue}const h=await N(e.rootPath).catch(()=>R(e.rootPath));l.push({...e,realRoot:h})}const d=n((e,t)=>{if(e.realRoot===t.realRoot)return e.recursive||!t.recursive;const h=e.realRoot.endsWith(E)?e.realRoot:`${e.realRoot}${E}`;if(!e.recursive||!t.realRoot.startsWith(h))return!1;let a=e.rootPath;for(const v of t.realRoot.slice(h.length).split(E))if(a=g(a,v),P(a,v)||u(a,v))return!1;return!0},"covers"),j=[...l].sort((e,t)=>e.realRoot.length-t.realRoot.length||Number(t.recursive)-Number(e.recursive)),m=[];for(const e of j)m.some(t=>d(t,e))||m.push(e);const F=[];for(const e of l){if(!m.includes(e))continue;const t=await O(e.rootPath,{allowedExtensions:o,ignoreFolders:S,shouldSkipDirectory:c,recursive:e.recursive});F.push(...t)}const w=[];for(const e of new Set(F))!u(e,e.split("/").at(-1)||"")&&!await i.isIgnored(e,!1)&&w.push(e);return w}n(H,"discoverFiles");export{z as DEPENDENCY_FOLDERS,H as discoverFiles};
|
|
2
|
+
//# sourceMappingURL=file-discovery.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var He=Object.defineProperty;var s=(a,e)=>He(a,"name",{value:e,configurable:!0});import{readFile as je,stat as ke,writeFile as Ie}from"node:fs/promises";import{relative as j,resolve as pe}from"node:path";import{applyConfigOption as Oe}from"../config/load.mjs";import{DEFAULT_HEADER_MARGIN as Pe,DEFAULT_HEADER_SPACING as ze,resolveLayoutCount as he}from"../constants.mjs";import{discoverFiles as ge}from"./file-discovery.mjs";import{getContentSkipReason as $e,getHeaderSkipReason as Ue,resolveForcedDetectors as Be}from"../detectors/index.mjs";import{declarationCopySkipReason as Te,isDeclarationFile as Ye}from"../detectors/node.mjs";import{resolveProjectMetadata as ye}from"../detect/project.mjs";import{checkHeaderDates as Ge,convertDatePayload as Ze,dateYear as _e,normalizeDatePayload as Ve,repairDateEpoch as De,resolveCreatedDate as We}from"../header/dates.mjs";import{buildHeader as qe}from"../header/template.mjs";import{compareHeaderFields as Je}from"../header/fields.mjs";import{extractHeaderlessBody as Ne,findProjectHeader as Ke,replaceOrInsertHeader as we,restoreTopLines as Qe}from"../header/parser.mjs";import{createUnifiedDiff as Xe}from"../utils/diff.mjs";import{readFileDates as et}from"../utils/fs.mjs";import{getGitCreationDate as tt,getGitLastModifiedDate as ot,readGitHeadFile as at}from"../utils/git.mjs";import{assertTimeZone as rt,toDatePayload as k}from"../utils/time.mjs";function nt(a){return Oe(a,"configFile")}s(nt,"resolveRuntimeOptions");function it(a){if(a==null)return[];const e=Array.isArray(a)?a:[a];if(e.some(r=>typeof r!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(a)}`);return e.filter(r=>r.trim().length>0)}s(it,"resolveInputs");function st(a){const e=a.match(/@Author:\s*(.+)$/m),r=a.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:e?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}s(st,"extractHeaderAuthorIdentity");function ct(a){const e=a.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:e?.[1]?.trim(),authorEmail:e?.[2]?.trim()}}s(ct,"extractHeaderLastModifiedIdentity");function dt(a){const e=a.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!e||!e[1]||!e[2])return null;const r=Number.parseInt(e[2],10);return Number.isNaN(r)?null:{date:e[1].trim(),timestamp:r}}s(dt,"extractHeaderCreatedAt");function lt(a){const e=a.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!e||!e[1]||!e[2])return null;const r=Number.parseInt(e[2],10);return Number.isNaN(r)?null:{date:e[1].trim(),timestamp:r}}s(lt,"extractHeaderLastModifiedAt");async function mt(a,e,r){const m=await at(e);return m.state!=="tracked"?{edited:m.state==="untracked",state:m.state}:{edited:Ne(m.content,e,r)!==Ne(a,e,r),state:"tracked"}}s(mt,"detectContentEdit");async function Ft(a={}){const e=await nt(a),r=e.timezone===void 0||e.timezone===null?null:rt(e.timezone),m=e.convertTimezone===!0;if(m&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");const g=Be(e.forcedDetectors),u=pe(e.projectRoot||e.cwd||process.cwd()),I=await ye({...e,cwd:u});he(e.spacing,"spacing",ze),he(e.margin,"margin",Pe);const x=e.check===!0,O=x||e.dryRun===!0,xe=e.fixCreatedDate===!0,P=e.rewriteDeclarationCopies!==!1,v=s(o=>o,"keepDate"),b=e.normalizeDateFormat===!0?Ve:v,A=r?o=>Ze(o,r):v,z=m?A:v,$={language:I.language,enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:g,includeFolders:e.includeFolders,excludeFolders:e.excludeFolders,includeExtensions:e.includeExtensions,gitignore:e.gitignore},U=it(e.input);let C;if(U.length>0){const o=new Set;for(const f of U){const l=pe(u,f),c=await ke(l).catch(()=>null);if(!c)throw new Error(`Input path does not exist: ${f}`);if(c.isFile())o.add(l);else if(c.isDirectory())for(const E of await ge({...$,projectRoot:l}))o.add(E);else throw new Error(`Input path must be a file or directory: ${f}`)}C=Array.from(o)}else C=await ge({...$,projectRoot:u});const Ae=new Date().getFullYear(),B=[],y=[],T=new Set;let Y=0,G=0,Z=0;const _=[];for(const o of C){const f=Ue(o,{enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:g});if(f!==null){y.push({file:j(u,o),reason:f});continue}const l=j(u,o),c=await je(o,"utf8"),E={enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:g,detectorSyntaxOverrides:e.detectorSyntaxOverrides},V=Qe(c,o,E),M=P&&Te(V,o)!==null,W=M?null:$e(o,V,E);if(W!==null){y.push({file:l,reason:W});continue}const t=await ye({...e,cwd:u,targetFilePath:o});T.add(`${t.language}:${t.projectRoot}`);const D={language:t.language,enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:g,detectorSyntaxOverrides:e.detectorSyntaxOverrides,spacing:e.spacing,margin:e.margin,strictHeaderBlock:e.strictHeaderBlock!==!1},R=Ke(c,o,D),n=R?c.slice(R.start,R.end):"",q=n.length>0?st(n):{},J=n.length>0?ct(n):{},Ce=n.length>0?dt(n):null,Ee=n.length>0?lt(n):null,K=await et(o),Q=j(t.projectRoot,o),X=await tt(t.projectRoot,Q),N=await ot(t.projectRoot,Q),ee=k(K.createdAt),F=We({existing:De(Ce),gitCreated:X,filesystemCreated:ee,fixCreatedDate:xe}),p=De(Ee),te=F.source,Se=p?"existing-header":N?"git-last-modified":"filesystem-updated",L=b(te==="existing-header"?z(F.payload):A(F.payload)),ve=t.copyrightStartYear===null?"created-date":"option",oe=t.copyrightStartYear??_e(L,r),ae=b(p?z(p):A(N||k(K.updatedAt))),re=e.forceAuthorUpdate===!0,be=e.forceLastModifiedAuthorUpdate===!0,ne=M?null:await mt(c,o,D),ie=M||P&&ne?.state==="untracked"&&n.length>0&&Ye(o),se=ie?{edited:!1,state:"no-git"}:ne,ce=be||se.edited,de=s(i=>qe({absoluteFilePath:o,language:t.language,syntaxOptions:D,projectRoot:t.projectRoot,projectName:t.projectName,createdByName:re?t.authorName:q.authorName||t.authorName,createdByEmail:re?t.authorEmail:q.authorEmail||t.authorEmail,lastModifiedByName:ce?t.authorName:J.authorName||t.authorName,lastModifiedByEmail:ce?t.authorEmail:J.authorEmail||t.authorEmail,authorName:t.authorName,authorEmail:t.authorEmail,createdAt:L,lastModifiedAt:i,copyrightStartYear:oe,companyName:t.companyName,currentYear:Ae}),"renderHeader"),le=de(ae),me=we(c,le,o,D),Me=se.edited&&p!==null&&N!==null&&p.timestamp<N.timestamp,ue=me.changed||Me,H=ue&&!(ie&&p!==null),fe=H?b(A(k(new Date))):ae,Re=H?"current-time-on-change":Se,Fe=H?de(fe):le,d=ue?we(c,Fe,o,D):me,S={file:l,changed:d.changed};if(x){const i=Ge(n,{gitCreated:X,gitLastModified:N,filesystemCreated:ee},{strictCreatedDate:e.strictCreatedDate===!0}),w=i.filter(h=>h.advisory).length;S.dateIssues=i,Z+=w,G+=i.length>w?1:0}if(e.sampleOutput===!0&&d.changed){const i=n.length>0?n.trimEnd():null,w=l.replace(/\\/g,"/"),h=d.written,Le=d.nextContent.slice(0,d.nextContent.indexOf(h)).split(`
|
|
2
|
+
`).length-1;S.sample={previousValue:i,newValue:h,diff:Xe(i,h,{fromFile:`a/${w}`,toFile:`b/${w}`,lineOffset:Le}),issues:Je(i,h),detectedValues:{projectName:t.projectName,projectNameSource:t.projectNameSource,language:t.language,projectRoot:t.projectRoot,marker:t.marker,authorName:t.authorName,authorEmail:t.authorEmail,companyName:t.companyName,companyNameSource:t.companyNameSource,copyrightStartYear:oe,copyrightStartYearSource:ve,createdAtSource:te,lastModifiedAtSource:Re,createdAt:L,lastModifiedAt:fe}}}if(d.extraCopyrights.length>0){S.extraCopyrights=d.extraCopyrights;for(const i of d.extraCopyrights)_.push({file:l,copyright:i})}B.push(S),d.changed&&(Y+=1,O||await Ie(o,d.nextContent,"utf8"))}return{metadata:I,detectedProjects:Array.from(T),filesScanned:C.length-y.length,filesUpdated:Y,filesSkipped:y.length,dryRun:O,check:x,...x?{filesWithDateDrift:G,dateAdvisories:Z}:{},copyrightWarnings:_,changes:B,skipped:y}}s(Ft,"fixHeaders");export{Ft as fixHeaders};
|
|
3
|
+
//# sourceMappingURL=fix-headers.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var R=Object.defineProperty;var i=(e,r)=>R(e,"name",{value:r,configurable:!0});import{execFile as v}from"node:child_process";import{lstat as S,readFile as A}from"node:fs/promises";import{dirname as p,isAbsolute as N,join as w,relative as b,resolve as g,sep as h}from"node:path";import O from"ignore";function I(e,r){return new Promise(o=>{v("git",r,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(s,u)=>{if(!s){o({code:0,stdout:u});return}o({code:typeof s.code=="number"?s.code:-1,stdout:""})})})}i(I,"runGitCommand");function x(e,r){return b(e,r).split(h).join("/")}i(x,"toPosixRelative");async function k(e){try{return O().add(await A(e,"utf8"))}catch{return null}}i(k,"readIgnoreFile");async function $(e){return S(w(e,".git")).then(()=>!0,()=>!1)}i($,"hasGitEntry");function C(e,r,o){for(let s=e.length-1;s>=0;s--){const{base:u,rules:l}=e[s],c=l.test(`${x(u,r)}${o?"/":""}`);if(c.ignored||c.unignored)return c.ignored}return!1}i(C,"matchesRules");async function F(e,r){const o=await k(w(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:o?[...r,{base:e,rules:o}]:r}}i(F,"buildRulesContext");async function m(e){const[r,o]=await Promise.all([I(e,["check-ignore","-q","."]),I(e,["ls-files","--cached","--others","--exclude-standard","-z"])]);if(r.code!==1||o.code!==0)return F(e,[]);const s=new Set,u=new Set;for(const l of o.stdout.split("\0")){const c=l.endsWith("/")?l.slice(0,-1):l;if(c.length!==0){s.add(c);for(let t=c.indexOf("/");t!==-1;t=c.indexOf("/",t+1))u.add(c.slice(0,t))}}return{kind:"git",root:e,entries:s,dirs:u}}i(m,"resolveScopeContext");function q(e){const r=g(e.root),o=e.gitignore;if(o===!1)return{isIgnored:i(async()=>!1,"isIgnored")};const s=new Map,u=i(async()=>{if(typeof o!="string"&&!Array.isArray(o))return m(r);const t=typeof o=="string"?[o]:o.filter(f=>typeof f=="string"),n=[];for(const f of t){const a=await k(g(r,f));a&&n.push({base:r,rules:a})}return{kind:"rules",nested:!1,excluded:!1,matchers:n}},"buildRootContext"),l=i(t=>{let n=s.get(t);return n||(n=t===r?u():c(t),s.set(t,n)),n},"contextFor"),c=i(async t=>{const n=await l(p(t));return n.kind==="git"?n.entries.has(x(n.root,t))?m(t):n:!n.nested||n.excluded?n:C(n.matchers,t,!0)?{...n,excluded:!0}:await $(t)?m(t):F(t,n.matchers)},"deriveContext");return{async isIgnored(t,n){const f=g(t),a=b(r,f);if(a.length===0||a===".."||a.startsWith(`..${h}`)||N(a))return!1;const d=await l(p(f));if(d.kind==="git"){const y=x(d.root,f);return!(d.entries.has(y)||n&&d.dirs.has(y))}return d.excluded||C(d.matchers,f,n)}}}i(q,"createIgnoreFilter");export{q as createIgnoreFilter};
|
|
2
|
+
//# sourceMappingURL=ignore-rules.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.defineProperty;var m=(e,r)=>g(e,"name",{value:r,configurable:!0});import{basename as p,dirname as y,extname as h,resolve as d}from"node:path";import{getEnabledDetectors as l}from"../detectors/index.mjs";import{resolveManifestProject as N}from"../drivers/index.mjs";import{detectGitAuthor as j}from"../utils/git.mjs";import{hasAngleTag as S}from"../utils/text.mjs";function w(e){return p(e)||"project"}m(w,"folderName");function k(e,r){if(typeof r!="string")return e;const o=r.trim();return o.length===0||S(e)?e:`${e} <${o}>`}m(k,"formatAuthorNameWithCompany");async function A(e,r={}){const o=Array.isArray(r.detectors)?r.detectors:l(r),u=typeof r.preferredExtension=="string"?r.preferredExtension.trim().toLowerCase():"",s=u.length>0?o.find(i=>i.extensions.includes(u)):void 0,t=await N(e,{drivers:r.drivers,language:s?.id,scanRoot:r.scanRoot}),c=t?t.root:d(e),a=t?.sources.name,n=t?.sources.company;return{language:s?.id??t?.drivers[0]??"unknown",rootDir:c,marker:t?t.marker:null,projectName:t?.fields.name??w(c),projectNameSource:a?{from:"manifest",...a}:{from:"folder",dir:c},companyName:t?.fields.company??null,companyNameSource:n?{from:"manifest",...n}:{from:"none"},drivers:t?t.drivers:[]}}m(A,"detectProjectFromMarkers");async function D(e={}){const r=e.targetFilePath||e.cwd||process.cwd(),o=d(r),u=l(e),s=e.targetFilePath?y(o):o,t=e.targetFilePath?h(o).toLowerCase():"",c=d(e.projectRoot||e.cwd||process.cwd()),a=await A(s,{detectors:u,preferredExtension:t,scanRoot:c}),n=await j(a.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),i=e.authorName||n.authorName||"Unknown Author",f=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||a.projectName,projectNameSource:e.projectName?{from:"option"}:a.projectNameSource,language:e.language||a.language,projectRoot:e.projectRoot||a.rootDir,marker:e.marker===void 0?a.marker:e.marker,authorName:k(i,e.company),authorEmail:e.authorEmail||n.authorEmail||"unknown@example.com",companyName:f||a.companyName,companyNameSource:f?{from:"option"}:a.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}m(D,"resolveProjectMetadata");export{A as detectProjectFromMarkers,D as resolveProjectMetadata};
|
|
2
|
+
//# sourceMappingURL=project.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var p=Object.defineProperty;var u=(e,n)=>p(e,"name",{value:n,configurable:!0});import{extname as d}from"node:path";const h=[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],m=400,b=/\bcopyright\b|\blicen[cs]e[ds]?\b|SPDX-License-Identifier|\bpublic domain\b/i,a=/^[\s*/]*@(?:Project|Filename):/m;function x(e){const n=d(e).toLowerCase();return h.includes(n)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}u(x,"resolveCCommentSyntax");function E(e){const n=e.replace(/^\uFEFF/,"").split(`
|
|
2
|
+
`).slice(0,m),i=[];let s=null,o=null,l=!1;for(const f of n){const c=f.replace(/\r$/,"");if(s){s.push(c),c.includes("*/")&&(i.push(s.join(`
|
|
3
|
+
`)),s=null);continue}if(l){l=c.endsWith("\\");continue}const t=c.trim();if(o&&!t.startsWith("//")&&(i.push(o.join(`
|
|
4
|
+
`)),o=null),t.length!==0){if(t.startsWith("//")){(o??=[]).push(t);continue}if(t.startsWith("/*")){const r=t.indexOf("*/",2);if(r===-1){s=[t];continue}if(i.push(t.slice(0,r+2)),t.slice(r+2).trim().length>0)break;continue}if(t.startsWith("#")){l=t.endsWith("\\");continue}break}}return o&&i.push(o.join(`
|
|
5
|
+
`)),i}u(E,"prologueComments");const L={id:"c",extensions:h,enabledByDefault:!0,resolveContentSkipReason(e){const n=E(e);return n.length>0&&a.test(n[0])?null:n.some(i=>!a.test(i)&&b.test(i))?"the file starts with a license or copyright notice that is not a fix-headers header (third-party code)":null},resolveCommentSyntax(e){return x(e)}};export{L as detector};
|
|
6
|
+
//# sourceMappingURL=c.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var n=(e,t)=>s(e,"name",{value:t,configurable:!0});import{extname as r}from"node:path";const o=[".css"];function c(e){const t=r(e).toLowerCase();return o.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}n(c,"resolveCssCommentSyntax");const a={id:"css",extensions:o,enabledByDefault:!0,keepsAboveHeader:n((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return c(e)}};export{a as detector};
|
|
2
|
+
//# sourceMappingURL=css.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var s=(e,t)=>c(e,"name",{value:t,configurable:!0});import{extname as u}from"node:path";import{isModeline as d,takeTopLines as f}from"./top-lines.mjs";const i=[".go"];function a(e){const t=u(e).toLowerCase();return i.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(a,"resolveGoCommentSyntax");const l=/^\/\/(?:go:build|\s*\+build)\s/;function m(e,t){const r=f(t,n=>l.test(n)||d(n));if(!r.split(/\r?\n/).some(n=>l.test(n)))return"";const o=t.slice(r.length);return`${r}${o.slice(0,o.length-o.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}s(m,"resolveGoPreservedPrefix");const k={id:"go",extensions:i,enabledByDefault:!0,resolvePreservedPrefix(e,t){return m(e,t)},resolveCommentSyntax(e){return a(e)}};export{k as detector};
|
|
2
|
+
//# sourceMappingURL=go.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=Object.defineProperty;var n=(t,e)=>r(t,"name",{value:e,configurable:!0});import{extname as l}from"node:path";const o=[".html",".htm"];function m(t){const e=l(t).toLowerCase();return o.includes(e)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}n(m,"resolveHtmlCommentSyntax");const c={id:"html",extensions:o,enabledByDefault:!0,resolveCommentSyntax(t){return m(t)}};export{c as detector};
|
|
2
|
+
//# sourceMappingURL=html.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});import{extname as d}from"node:path";import{detector as y}from"./c.mjs";import{detector as b}from"./css.mjs";import{detector as k}from"./go.mjs";import{detector as S}from"./html.mjs";import{detector as D}from"./json.mjs";import{detector as g}from"./markdown.mjs";import{detector as h}from"./node.mjs";import{detector as w}from"./php.mjs";import{detector as E}from"./python.mjs";import{detector as A}from"./rust.mjs";import{detector as P}from"./yaml.mjs";import{isModeline as L,takeTopLines as C}from"./top-lines.mjs";const f=[y,b,k,S,D,g,h,w,E,A,P],u=new Map(f.map(e=>[e.id,e]));function F(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}}c(F,"applySyntaxOverride");function G(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)}`);const t=f.filter(r=>r.requiresForce===!0).map(r=>r.id);for(const r of e){if(!u.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))}c(G,"resolveForcedDetectors");function l(e={}){const 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 f.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)}c(l,"getEnabledDetectors");function K(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(r=>r.toLowerCase()));const t=l(e);return new Set(t.flatMap(r=>r.extensions))}c(K,"getAllowedExtensions");function Q(e,t={}){const r=d(e).toLowerCase();if(l(t).some(s=>s.extensions.includes(r)&&s.resolveCommentSyntax(e)!==null))return null;if(r.length===0)return"the file has no extension, so its comment syntax is unknown";const o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),i=f.find(s=>s.requiresForce===!0&&s.extensions.includes(r)&&!o.has(s.id));return i?`${r} files get a header only when forced (--force-detector ${i.id} / forcedDetectors: ["${i.id}"])`:`no enabled detector handles ${r} files`}c(Q,"getHeaderSkipReason");function U(e){return u.get(e)}c(U,"getDetectorById");function V(e,t={}){const r=d(e).toLowerCase(),n=Array.isArray(t.detectors)?t.detectors:l(t);for(const o of n){if(!o.extensions.includes(r))continue;const i=o.resolveCommentSyntax(e);if(i){const s=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return F(i,s[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}c(V,"getCommentSyntaxForFile");function m(e,t){const r=d(e).toLowerCase();return l(t).find(n=>n.extensions.includes(r))}c(m,"detectorForFile");function W(e,t,r={}){const n=m(e,r);if(!n)return"";const o=typeof n.resolvePreservedPrefix=="function"?n.resolvePreservedPrefix(e,t):"",i=n.keepsAboveHeader,s=C(t.slice(o.length),(a,p)=>L(a)||typeof i=="function"&&i(a,p),o.split(`
|
|
2
|
+
`).length-1);return`${o}${s}`}c(W,"getPreservedPrefixForFile");function X(e,t,r={}){const n=m(e,r);return n&&typeof n.resolveContentSkipReason=="function"?n.resolveContentSkipReason(t,e):null}c(X,"getContentSkipReason");export{f as DETECTOR_PROFILES,K as getAllowedExtensions,V as getCommentSyntaxForFile,X as getContentSkipReason,U as getDetectorById,l as getEnabledDetectors,Q as getHeaderSkipReason,W as getPreservedPrefixForFile,G as resolveForcedDetectors};
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=Object.defineProperty;var o=(n,e)=>r(n,"name",{value:e,configurable:!0});import{extname as s}from"node:path";const t=[".jsonv",".jsonc",".json5"];function c(n){const e=s(n).toLowerCase();return t.includes(e)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}o(c,"resolveJsonCommentSyntax");const u={id:"json",extensions:t,enabledByDefault:!0,resolveCommentSyntax(n){return c(n)}};export{u as detector};
|
|
2
|
+
//# sourceMappingURL=json.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var n=(e,r)=>s(e,"name",{value:r,configurable:!0});import{extname as a}from"node:path";const o=[".md",".markdown"];function i(e){const r=a(e).toLowerCase();return o.includes(r)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}n(i,"resolveMarkdownCommentSyntax");function l(e,r){const t=r.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return t?t[0]:""}n(l,"resolveMarkdownPreservedPrefix");const m={id:"markdown",extensions:o,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,r){return l(e,r)},resolveCommentSyntax(e){return i(e)}};export{m as detector};
|
|
2
|
+
//# sourceMappingURL=markdown.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var d=Object.defineProperty;var s=(e,t)=>d(e,"name",{value:t,configurable:!0});import{basename as o,extname as x}from"node:path";import{isShebang as f}from"./top-lines.mjs";const i=[".js",".mjs",".cjs",".ts",".mts",".cts",".tsx",".jsx"];function p(e){const t=x(e).toLowerCase();return i.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(p,"resolveNodeCommentSyntax");const a=/^(.+)\.d\.(ts|mts|cts)$/i,S={ts:[".ts",".tsx",".js",".jsx"],mts:[".mts",".mjs"],cts:[".cts",".cjs"]};function C(e){const t=/^\s*\/\*[\s\S]*?\*\//.exec(e.replace(/^\uFEFF/,""));if(!t)return null;const n=/^[\s*]*@Filename:[ \t]*(\S+)/m.exec(t[0]);return n?n[1]:null}s(C,"leadingHeaderFilename");function E(e){return a.test(o(e))}s(E,"isDeclarationFile");function k(e,t){const n=a.exec(o(t));if(!n)return null;const r=C(e);if(r===null)return null;const c=o(r),[,l,u]=n;return S[u.toLowerCase()].some(m=>c===`${l}${m}`)?`the file is a declaration generated from ${c} and carries its header (tsc copies it)`:null}s(k,"declarationCopySkipReason");const L={id:"node",extensions:i,enabledByDefault:!0,keepsAboveHeader:f,resolveContentSkipReason(e,t){return k(e,t)},resolveCommentSyntax(e){return p(e)}};export{k as declarationCopySkipReason,L as detector,E as isDeclarationFile};
|
|
2
|
+
//# sourceMappingURL=node.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var o=(e,t)=>s(e,"name",{value:t,configurable:!0});import{extname as l}from"node:path";const n=[".php"];function p(e){const t=l(e).toLowerCase();return n.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}o(p,"resolvePhpCommentSyntax");const r=/^<\?php(?:\s|$)/i,u={id:"php",extensions:n,enabledByDefault:!0,keepsAboveHeader:o((e,t)=>t===0&&r.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return r.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 p(e)}};export{u as detector};
|
|
2
|
+
//# sourceMappingURL=php.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=Object.defineProperty;var n=(e,t)=>r(e,"name",{value:t,configurable:!0});import{extname as s}from"node:path";import{isShebang as i}from"./top-lines.mjs";const o=[".py"],a=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function c(e,t){return i(e,t)||t<=1&&a.test(e)}n(c,"keepsAboveHeader");const d={id:"python",extensions:o,enabledByDefault:!0,keepsAboveHeader:c,resolveCommentSyntax(e){const t=s(e).toLowerCase();return o.includes(t)?{kind:"line",linePrefix:"#"}:null}};export{d as detector};
|
|
2
|
+
//# sourceMappingURL=python.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=Object.defineProperty;var n=(e,t)=>r(e,"name",{value:t,configurable:!0});import{extname as s}from"node:path";const o=[".rs"];function c(e){const t=s(e).toLowerCase();return o.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}n(c,"resolveRustCommentSyntax");const u={id:"rust",extensions:o,enabledByDefault:!0,keepsAboveHeader:n((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return c(e)}};export{u as detector};
|
|
2
|
+
//# sourceMappingURL=rust.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var l=Object.defineProperty;var r=(t,i)=>l(t,"name",{value:i,configurable:!0});const d=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,c=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,f=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 m(t){const i=t.match(d);if(!i)return!1;let n=i[2].trim();if(n.endsWith("-->"))n=n.slice(0,-3).trimEnd();else if(n.endsWith("*/")){let e=n.length-2;for(;e>0&&n[e-1]==="*";)e-=1;n=n.slice(0,e).trimEnd()}const o=n.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!o&&i[1]==="Vim")return!1;const s=o?o[1].match(/(?:\\.|[^\s\\])+/g):n.match(/(?:\\.|[^\s:\\])+/g);return s!==null&&s.every(e=>c.test(e))&&s.some(e=>e.includes("=")||f.has(e))}r(m,"isModeline");function u(t,i){return i===0&&t.startsWith("#!")}r(u,"isShebang");function x(t,i,n=0){let o=0,s=n;for(;o<t.length;){const e=t.indexOf(`
|
|
2
|
+
`,o),a=e===-1?t.length:e+1;if(!i(t.slice(o,a).replace(/\r?\n$/,""),s))break;o=a,s+=1}return t.slice(0,o)}r(x,"takeTopLines");export{m as isModeline,u as isShebang,x as takeTopLines};
|
|
3
|
+
//# sourceMappingURL=top-lines.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=Object.defineProperty;var t=(e,n)=>r(e,"name",{value:n,configurable:!0});import{extname as l}from"node:path";const o=[".yaml",".yml"];function s(e){const n=l(e).toLowerCase();return o.includes(n)?{kind:"line",linePrefix:"#"}:null}t(s,"resolveYamlCommentSyntax");const a={id:"yaml",extensions:o,enabledByDefault:!0,keepsAboveHeader:t((e,n)=>n===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return s(e)}};export{a as detector};
|
|
2
|
+
//# sourceMappingURL=yaml.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var a=Object.defineProperty;var n=(e,t)=>a(e,"name",{value:t,configurable:!0});import{cleanName as o,detectManifests as c}from"./shared.mjs";const r=["go.mod"];function d(e){const t=e.match(/^\s*module\s+(.+)$/m);if(t)return o(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}n(d,"readModulePath");const i={id:"go",languages:["go"],manifests:r,detect(e){return c(e,r)},read(e){return{name:d(e.files[0].content)}}};export{i as driver};
|
|
2
|
+
//# sourceMappingURL=go.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var A=Object.defineProperty;var d=(n,e)=>A(n,"name",{value:e,configurable:!0});import{dirname as y,isAbsolute as E,join as w,relative as R,resolve as h,sep as S}from"node:path";import{pathExists as D}from"../utils/fs.mjs";import{driver as F}from"./go.mjs";import{driver as k}from"./node.mjs";import{driver as M}from"./php.mjs";import{driver as P}from"./python.mjs";import{driver as b}from"./rust.mjs";const x=[k,P,M,b,F],I=["name","company"];function $(n){return x.find(e=>e.id===n)}d($,"getDriverById");async function m(n,e,i){const t=(await Promise.all(e.map(async r=>({driver:r,detection:await r.detect(n)})))).filter(r=>r.detection!==null),o=t.filter(r=>typeof i=="string"&&r.driver.languages.includes(i));return[...o,...t.filter(r=>!o.includes(r))]}d(m,"claimFolder");function j(n,e){const i=R(e,n);return i!==""&&i!==".."&&!i.startsWith(`..${S}`)&&!E(i)}d(j,"isStrictlyInside");async function q(n,e={}){const i=Array.isArray(e.drivers)?e.drivers:x,f=typeof e.scanRoot=="string"?h(e.scanRoot):null;let t=h(n),o=await m(t,i,e.language);for(;o.length===0;){if(await D(w(t,".git")))return{root:t,marker:".git",drivers:[],fields:{},sources:{}};const s=y(t);if(s===t)return null;t=s,o=await m(t,i,e.language)}const r={},u={};let a=t,v=o;for(;;){for(const{driver:l,detection:p}of v){const g=l.read(p);for(const c of I)r[c]===void 0&&g[c]!==void 0&&(r[c]=g[c],u[c]={driver:l.id,manifest:p.manifest,dir:a})}if(I.every(l=>r[l]!==void 0)||f===null||!j(a,f)||await D(w(a,".git")))break;a=y(a),v=await m(a,i,e.language)}return{root:t,marker:o[0].detection.manifest,drivers:o.map(s=>s.driver.id),fields:r,sources:u}}d(q,"resolveManifestProject");export{x as MANIFEST_DRIVERS,I as MANIFEST_FIELDS,m as claimFolder,$ as getDriverById,q as resolveManifestProject};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var o=(e,n)=>c(e,"name",{value:n,configurable:!0});import{cleanName as t,detectManifests as i,parseJsonManifest as p,personName as d}from"./shared.mjs";const r=["package.json"];function m(e){const n=t(e?.name),s=t(e?.publisher),a=typeof e?.engines?.vscode=="string";return n&&s&&a?`${s}.${n}`:n}o(m,"readPublishedName");function u(e){if(e!==null&&typeof e=="object"){const n=e;return t(n.company)??t(n.name)}return d(e)}o(u,"readAuthorCompany");const g={id:"node",languages:["node"],manifests:r,detect(e){return i(e,r)},read(e){const n=p(e.files[0].content);return{name:m(n),company:u(n?.author)}}};export{g as driver};
|
|
2
|
+
//# sourceMappingURL=node.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{cleanName as s,detectManifests as r,parseJsonManifest as o}from"./shared.mjs";const a=["composer.json"],i={id:"php",languages:["php"],manifests:a,detect(e){return r(e,a)},read(e){const n=o(e.files[0].content),t=n?.authors;return{name:s(n?.name),company:Array.isArray(t)?s(t[0]?.name):void 0}}};export{i as driver};
|
|
2
|
+
//# sourceMappingURL=php.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c=Object.defineProperty;var o=(e,n)=>c(e,"name",{value:n,configurable:!0});import{detectManifests as f,manifestContent as r,readIniValue as p,readTomlAuthor as a,readTomlString as s}from"./shared.mjs";const d=["pyproject.toml","setup.cfg","setup.py"];function l(e,n){const t=e.indexOf("setup(");if(t===-1)return;const u=e.slice(t).match(new RegExp(`\\b${n}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return u&&u[2].trim()||void 0}o(l,"readSetupPyArgument");function m(e){const n=r(e,"pyproject.toml"),t=r(e,"setup.cfg"),u=r(e,"setup.py");return(n===null?void 0:s(n,"project","name")??s(n,"tool.poetry","name"))??(t===null?void 0:p(t,"metadata","name"))??(u===null?void 0:l(u,"name"))}o(m,"readPythonName");function i(e){const n=r(e,"pyproject.toml"),t=r(e,"setup.cfg"),u=r(e,"setup.py");return(n===null?void 0:a(n,"project")??a(n,"tool.poetry"))??(t===null?void 0:p(t,"metadata","author"))??(u===null?void 0:l(u,"author"))}o(i,"readPythonCompany");const h={id:"python",languages:["python"],manifests:d,detect(e){return f(e,d)},read(e){return{name:m(e),company:i(e)}}};export{h as driver};
|
|
2
|
+
//# sourceMappingURL=python.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{detectManifests as n,readTomlAuthor as a,readTomlString as o}from"./shared.mjs";const r=["Cargo.toml"],c={id:"rust",languages:["rust"],manifests:r,detect(t){return n(t,r)},read(t){const e=t.files[0].content;return{name:o(e,"package","name"),company:a(e,"package")}}};export{c as driver};
|
|
2
|
+
//# sourceMappingURL=rust.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var u=Object.defineProperty;var s=(n,e)=>u(n,"name",{value:e,configurable:!0});import{readFile as a}from"node:fs/promises";import{join as m}from"node:path";async function p(n){try{return await a(n,"utf8")}catch{return null}}s(p,"readManifest");async function T(n,e){const t=[];for(const i of e){const r=await p(m(n,i));r!==null&&t.push({file:i,content:r})}return t.length>0?{dir:n,manifest:t[0].file,files:t}:null}s(T,"detectManifests");function $(n,e){return n.files.find(t=>t.file===e)?.content??null}s($,"manifestContent");function f(n){return typeof n=="string"&&n.trim().length>0?n.trim():void 0}s(f,"cleanName");function d(n){if(typeof n!="string")return;const e=n.search(/[<(]/);return f(e===-1?n:n.slice(0,e))}s(d,"personName");function b(n){try{return JSON.parse(n)}catch{return}}s(b,"parseJsonManifest");function*l(n,e){let t="";for(const i of n.split(/\r?\n/)){const r=i.trim();if(r.startsWith("[")){const o=r.match(/^\[([^[\]]+)\]/);t=o?o[1].split(".").map(c=>c.trim()).join("."):"";continue}t===e&&(yield r)}}s(l,"sectionLines");function j(n,e,t){const i=new RegExp(`^${t}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(const r of l(n,e)){const o=r.match(i);if(o)return f(o[1]??o[2])}}s(j,"readTomlString");function E(n,e,t){const i=new RegExp(`^${t}\\s*[=:](.*)$`);for(const r of l(n,e)){const o=r.match(i);if(o)return f(o[1])}}s(E,"readIniValue");function h(n,e,t){const i=new RegExp(`^${t}\\s*=\\s*\\[`);let r=null;for(const o of l(n,e)){if(r!==null){r.push(o);continue}const c=o.match(i);c&&(r=[o.slice(c[0].length)])}return r===null?null:r.join(`
|
|
2
|
+
`)}s(h,"tomlArrayText");function g(n,e){let t=e;for(;t<n.length;)if(n[t]==="#"){const i=n.indexOf(`
|
|
3
|
+
`,t);t=i===-1?n.length:i+1}else if(/\s/.test(n[t]))t+=1;else break;return t}s(g,"skipTomlSpace");function M(n,e){const t=h(n,e,"authors");if(t===null)return;const i=t.slice(g(t,0)),r=i.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(r)return d(r[1]??r[2]);const c=i.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return c?f(c[1]??c[2]):void 0}s(M,"readTomlAuthor");export{f as cleanName,T as detectManifests,$ as manifestContent,b as parseJsonManifest,d as personName,E as readIniValue,M as readTomlAuthor,j as readTomlString};
|
|
4
|
+
//# sourceMappingURL=shared.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var D=Object.defineProperty;var m=(e,t)=>D(e,"name",{value:t,configurable:!0});import{formatIsoDate as l,formatSpaceDate as y,parseHeaderDate as d,toZonedDateParts as f}from"../utils/time.mjs";const x={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function h(e,t){const a=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return a?a[1].trim():null}m(h,"readHeaderField");function u(e){let t=null;for(const{source:a,payload:s}of e)s&&(!t||s.timestamp<t.payload.timestamp)&&(t={source:a,payload:s});return t}m(u,"pickOldestDate");function v({existing:e,gitCreated:t,filesystemCreated:a,fixCreatedDate:s=!1}){const r=[{source:"git-created",payload:t},{source:"filesystem-created",payload:a}];if(!e)return u(r);if(!s)return{source:"existing-header",payload:e};const i=d(e.date)?e:null;return u([{source:"existing-header",payload:i},...r])}m(v,"resolveCreatedDate");function C(e,t=null){if(t)return f(e.timestamp,t).year;const a=d(e.date);return a?a.year:new Date(e.timestamp*1e3).getFullYear()}m(C,"dateYear");function $(e,t,a,s){const r=e.match(/^(.+?)\s*\((\d+)\)$/),i=r?d(r[1]):null;if(!r||!i)return s.push({check:`${a}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;const o=Number.parseInt(r[2],10);return o!==i.timestamp&&s.push({check:`${a}-epoch`,field:t,advisory:!1,value:e,expected:`${r[1]} (${i.timestamp})`,message:`${t} epoch ${o} does not match ${r[1]} (expected ${i.timestamp})`}),{text:r[1],timestamp:i.timestamp}}m($,"checkDateValue");function I(e,t={},a={}){const s=[],r=h(e,"@Date"),i=r===null?null:$(r,"@Date","created",s),o=u([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(i&&o&&i.timestamp>o.payload.timestamp){const g=x[o.source];s.push({check:"created-newer-than-source",field:"@Date",advisory:a.strictCreatedDate!==!0,value:r,expected:`${o.payload.date} (${o.payload.timestamp})`,source:o.source,message:`@Date ${i.text} is later than the ${g} ${o.payload.date} (${o.payload.timestamp})`})}const n=h(e,"@Last modified time"),p=n===null?null:$(n,"@Last modified time","modified",s),c=t.gitLastModified;return p&&c&&p.timestamp!==c.timestamp&&s.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:n,expected:`${c.date} (${c.timestamp})`,message:`@Last modified time ${p.text} does not match the git last commit ${c.date} (${c.timestamp})`}),s}m(I,"checkHeaderDates");function M(e){if(!e)return null;const t=d(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}m(M,"repairDateEpoch");function S(e){const t=d(e.date);return t?{date:l(t),timestamp:t.timestamp}:e}m(S,"normalizeDatePayload");function w(e,t){const a=d(e.date);if(!a)return e;const s=f(a.timestamp,t);return s.offsetMinutes===a.offsetMinutes||!Number.isInteger(s.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?l(s):y(s),timestamp:a.timestamp}}m(w,"convertDatePayload");export{I as checkHeaderDates,w as convertDatePayload,C as dateYear,S as normalizeDatePayload,u as pickOldestDate,M as repairDateEpoch,v as resolveCreatedDate};
|
|
2
|
+
//# sourceMappingURL=dates.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=Object.defineProperty;var l=(t,n)=>m(t,"name",{value:n,configurable:!0});const d=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function r(t,n){const e=t.match(new RegExp(`@${n}:[ \\t]*(.*)$`,"m")),i=e?e[1].trim():"";return i.length>0?i:null}l(r,"readTag");function u(t){if(t===null)return{name:null,email:null};if(!t.endsWith(")"))return{name:t,email:null};const n=t.slice(0,-1),e=n.indexOf("(",n.lastIndexOf(")")+1);return e===-1?{name:t,email:null}:{name:n.slice(0,e).trimEnd()||null,email:n.slice(e+1)||null}}l(u,"splitLastModifiedBy");function p(t){const n={startYear:null,endYear:null,companyName:null},e=t?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!e)return n;let i=t.slice(e[0].length);const a=i.match(/^\s*-\s*(\d{4})/);a&&(i=i.slice(a[0].length));const o=i.toLowerCase(),s=o.endsWith("all rights reserved.")?20:o.endsWith("all rights reserved")?19:0;return s===0||!/^\s/.test(i)?n:{startYear:e[1],endYear:a?a[1]:null,companyName:i.slice(0,-s).trim()||null}}l(p,"splitCopyright");function c(t){const n=u(r(t,"Last modified by")),e=p(r(t,"Copyright")),i=r(t,"Email");return{projectName:r(t,"Project"),filename:r(t,"Filename"),createdAt:r(t,"Date"),authorName:r(t,"Author"),authorEmail:i===null?null:i.replace(/^<(.*)>$/,"$1"),lastModifiedByName:n.name,lastModifiedByEmail:n.email,lastModifiedAt:r(t,"Last modified time"),copyrightStartYear:e.startYear,copyrightEndYear:e.endYear,companyName:e.companyName}}l(c,"parseHeaderFields");function y(t,n){const e=c(t??""),i=c(n);return d.filter(a=>e[a]!==i[a]).map(a=>({field:a,previous:e[a],detected:i[a]}))}l(y,"compareHeaderFields");export{d as HEADER_FIELDS,y as compareHeaderFields,c as parseHeaderFields};
|
|
2
|
+
//# sourceMappingURL=fields.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var X=Object.defineProperty;var d=(r,e)=>X(r,"name",{value:e,configurable:!0});import{DEFAULT_HEADER_MARGIN as q,DEFAULT_MAX_HEADER_SCAN_LINES as J,resolveLayoutCount as Q}from"../constants.mjs";import{getPreservedPrefixForFile as D}from"../detectors/index.mjs";import{getHeaderSyntaxForFile as j}from"./syntax.mjs";function L(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}d(L,"escapeRegex");function I(r,e,t={}){const n=e.startsWith("\uFEFF")?"\uFEFF":"",i=e.slice(n.length),s=`${n}${D(r,i,t)}`;return{prefix:s,body:e.slice(s.length)}}d(I,"splitPreservedPrefix");function _(r){const e=r.indexOf(`
|
|
2
|
+
`);return e===-1?null:e>0&&r[e-1]==="\r"?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`}d(_,"lineEnding");function w(r,e){if(e.kind==="html"){const n=L(e.blockStart||"<!--"),i=L(e.blockEnd||"-->");return r.match(new RegExp(`^${n}[\\s\\S]*?${i}(?:\\r?\\n)*`))}if(e.kind==="line"){const n=L(e.linePrefix||"#");return r.match(new RegExp(`^(?:${n}[^\\n]*\\n)+(?:\\r?\\n)*`))}const t=L((e.blockEnd||" */").trim());return r.match(new RegExp(`^/\\*[\\s\\S]*?${t}(?:\\r?\\n)*`))}d(w,"matchHeaderSegment");const T=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,Y="Moved out of the file header by fix-headers:";function P(r){return r.some(e=>/^@(?:Project|Filename):/.test(e.text))}d(P,"isFileHeader");function M(r,e){const t=r.replace(/(?:\r?\n)+$/,"");if(e.kind==="line"){const a=new RegExp(`^${L(e.linePrefix||"#")}[ \\t]*`);return t.split(`
|
|
5
|
+
`).map(f=>{const p=f.replace(/\r$/,"");return{raw:p,text:p.replace(a,"").trim()}})}const n=e.kind==="html",i=n?t.replace(/^<!--/,"").replace(/--!?>\s*$/,""):t.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),s=e.blockLinePrefix||(n?" ":" * "),c=n?/^\s*/:/^\s*\*?[ \t]*/,o=i.split(`
|
|
6
|
+
`).map((a,f)=>({raw:f===0&&a.trim()!==""?`${s}${a.trim()}`:a.trimEnd(),text:(f===0?a:a.replace(c,"")).trim()})),l=o[0].raw===""?1:0,g=o.length>l&&o[o.length-1].raw.trim()===""?o.length-1:o.length;return o.slice(l,g)}d(M,"segmentLines");function O(r,e){const t=r.map(i=>{const s=i.text.match(T);return i.text===""?"blank":s&&s[1]==="Copyright"?e.copyright?"copyright":(e.copyright=!0,"field"):s?"field":/^-{3,}$/.test(i.text)?"dash":"text"}),n=d((i,s)=>{for(let c=i+s;c>=0&&c<t.length;c+=s)if(t[c]!=="blank"&&t[c]!=="dash")return t[c]==="copyright"?"field":t[c]},"neighbour");return t.map((i,s)=>i==="dash"?n(s,-1)==="field"||n(s,1)==="field"?"separator":"text":i)}d(O,"classifyLines");function N(r,e="",t={}){const n=j(e,t),i=[],s=[],c={copyright:!1};let o=r,l=w(o,n),g=!0;for(;l&&l[0].length>0;){const h=M(l[0],n),$=O(h,c),x=h.findIndex(E=>E.text!=="");!g&&x!==-1&&h[x].text===Y&&($[x]="separator"),h.forEach((E,b)=>{$[b]==="copyright"&&s.push(E.text.replace(T,"").trim()),i.push({raw:E.raw,kind:$[b]})}),o=o.slice(l[0].length),l=w(o,n),g=!1}const a=i.findIndex(h=>h.kind==="text");if(a===-1)return{foreign:[],copyrights:s};const f=i.map(h=>h.kind).lastIndexOf("text"),p=[];let u=[],k=!1;for(const h of i.slice(a,f+1))h.kind==="text"?(p.push(...k?[]:u,h.raw),u=[],k=!1):h.kind==="blank"?u.push(h.raw):k=!0;return{foreign:p,copyrights:s}}d(N,"splitHeaderText");function le(r,e="",t={}){return N(r,e,t).foreign}d(le,"extractForeignHeaderLines");function ee(r,e,t){const n=e.kind==="html";return e.kind==="line"?r.join(t):[e.blockStart||(n?"<!--":"/**"),...r,e.blockEnd||(n?"-->":" */")].join(t)}d(ee,"renderForeignBlock");function te(r,e,t){const n=r.split(`
|
|
7
|
+
`),i=t.kind==="html",s=t.kind==="line"?t.linePrefix||"#":(t.blockLinePrefix||(i?" ":" * ")).trimEnd(),c=Math.min(n.length-1,(t.spacing??1)+(t.kind==="line"?0:1)),o=n.length-c;return[...n.slice(0,o),s,...e,...n.slice(o)].join(`
|
|
8
|
+
`)}d(te,"appendToHeader");function G(r){let e=r.trim();const t=e.match(/^copyright\b/i);e=t?e.slice(t[0].length).trimStart():e;for(let o=e.match(/^(?:\(c\)|©)/i);o;o=e.match(/^(?:\(c\)|©)/i))e=e.slice(o[0].length).trimStart();const n=e.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);e=n?e.slice(n[0].length):e,e=e.trimEnd();const i=e.toLowerCase(),s=i.endsWith("all rights reserved.")?20:i.endsWith("all rights reserved")?19:0;e=e.slice(0,e.length-s);let c=e.length;for(;c>0&&`.,; \r
|
|
9
|
+
`.includes(e[c-1]);)c-=1;return e.slice(0,c).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}d(G,"copyrightHolder");function ne(r,e){const t=r.split(`
|
|
10
|
+
`),n=t.findIndex(o=>o.includes("@Copyright:")),i=t.map(o=>/@[A-Za-z][A-Za-z ]*:/.test(o)).lastIndexOf(!0),s=n!==-1?n:i;if(e.length===0||s===-1)return r;const c=t[s].slice(0,t[s].indexOf("@"));return[...t.slice(0,s+1),...e.map(o=>`${c}@Copyright: ${o}`),...t.slice(s+1)].join(`
|
|
11
|
+
`)}d(ne,"insertCopyrights");function z(r,e){let t=0,n=w(r,e);for(;n&&n[0].length>0&&P(M(n[0],e));)t+=n[0].length,n=w(r.slice(t),e);return t}d(z,"leadingHeadersLength");function U(r,e="",t={}){let n=r.startsWith("\uFEFF")?"\uFEFF":"",i=r.slice(n.length);const s=D(e,i,t),c=j(e,t),o=s.length;let l=z(i.slice(o),c);if(l===0)return r;const g=n===""&&o===0&&i.startsWith("\uFEFF",l);g&&(n="\uFEFF",i=`${i.slice(0,l)}${i.slice(l+1)}`,l+=z(i.slice(l),c));const a=i.slice(o,o+l),f=i.slice(o+l),p=D(e,`${s}${f}`,t),u=p.length>s.length?p.slice(s.length):"";if(u===""&&!g)return r;const k=u===""||u.endsWith(`
|
|
12
|
+
`)?u:`${u}${_(r)??`
|
|
13
|
+
`}`;return`${n}${s}${k}${a}${f.slice(u.length)}`}d(U,"restoreTopLines");function Z(r,e="",t={}){const{prefix:n,body:i}=I(e,r,t),s=i.split(`
|
|
14
|
+
`).slice(0,J).join(`
|
|
15
|
+
`),c=j(e,t);if(!w(s,c))return null;let l=0,g=0;for(;;){const a=s.slice(l),f=w(a,c);if(!f||!P(M(f[0],c)))break;l+=f[0].length,g=l}return g===0?null:{start:n.length,end:n.length+g}}d(Z,"findProjectHeader");function re(r,e,t="",n={}){const i=U(r,t,n),s=Z(i,t,n),c=j(t,n),o=Q(n.margin,"margin",q),l=c.kind==="line"?Math.max(1,o):o,g=d((m,F)=>F===`
|
|
16
|
+
`?m:m.replace(/\r?\n/g,F),"withEol");if(!s){const{prefix:m,body:F}=I(t,i,n),H=_(i)??`
|
|
17
|
+
`,S=g(e,H),B=F.replace(/^(?:\r?\n)+/,""),V=m.replace(/^\uFEFF/,"")!==""&&!m.endsWith(`
|
|
18
|
+
`)?H:"",W=`${m}${V}${B.trim()===""?`${S}${H}`:`${S}${H.repeat(l+1)}${B}`}`;return{nextContent:W,changed:W!==r,header:S,written:S,extraCopyrights:[]}}const a=i.slice(s.start,s.end),{foreign:f,copyrights:p}=N(a,t,n),u=e.split(`
|
|
19
|
+
`).find(m=>m.includes("@Copyright:")),k=new Set(u===void 0?[]:[G(u.slice(u.indexOf("@Copyright:")+11))]),h=[];for(const m of p){const F=G(m);k.has(F)||(k.add(F),h.push(m))}const $=_(i.slice(s.end))??_(a)??`
|
|
20
|
+
`,x=$.repeat(l+1),E=n.strictHeaderBlock!==!1,b=ne(e,h),C=g(f.length>0&&!E?te(b,f,c):b,$),A=f.length>0&&E?ee(f,c,$):"",v=i.slice(s.end).replace(/^(?:\r?\n)+/,""),R=A===""?v:`${A}${v.trim()===""?$:`${x}${v}`}`,y=`${i.slice(0,s.start)}${R.trim()===""?`${C}${$}`:`${C}${x}${R}`}`,K=`${C}${A===""?"":`${x}${A}`}`;return{nextContent:y,changed:y!==r,header:C,written:K,extraCopyrights:h}}d(re,"replaceOrInsertHeader");function de(r,e="",t={}){const n=U(r,e,t),i=Z(n,e,t);if(i){const l=n.slice(0,i.start),a=re(n,"",e,{...t,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${a.trim()===""?"":a}`}const{prefix:s,body:c}=I(e,n,t),o=c.replace(/^(?:\r?\n)+/,"");return`${s}${o.trim()===""?"":o}`}d(de,"extractHeaderlessBody");export{G as copyrightHolder,le as extractForeignHeaderLines,de as extractHeaderlessBody,Z as findProjectHeader,re as replaceOrInsertHeader,U as restoreTopLines,N as splitHeaderText};
|
|
21
|
+
//# sourceMappingURL=parser.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var d=Object.defineProperty;var i=(e,n)=>d(e,"name",{value:n,configurable:!0});import{extname as g}from"node:path";import{getCommentSyntaxForFile as b}from"../detectors/index.mjs";import{DEFAULT_HEADER_SPACING as p,resolveLayoutCount as S}from"../constants.mjs";function h(e,n={}){const r=g(e).toLowerCase(),o=S(n.spacing,"spacing",p);return r.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:o}:{...b(e,n),spacing:o}}i(h,"getHeaderSyntaxForFile");function A(e,n){const r=e.spacing??p;if(e.kind==="line"){const t=e.linePrefix||"#",a=typeof e.lineSeparator=="string"?e.lineSeparator:" ",m=Array.from({length:r},()=>t);return[...m,...n.map(f=>`${t}${a}${f}`),...m].join(`
|
|
2
|
+
`)}const o=e.blockStart||(e.kind==="html"?"<!--":"/**"),c=e.blockLinePrefix||(e.kind==="html"?" ":" * "),k=e.blockEnd||(e.kind==="html"?"-->":" */"),l=Array.from({length:r},()=>c.trimEnd());return[o,...l,...n.map(t=>`${c}${t}`),...l,k].join(`
|
|
3
|
+
`)}i(A,"renderHeaderLines");export{h as getHeaderSyntaxForFile,A as renderHeaderLines};
|
|
4
|
+
//# sourceMappingURL=syntax.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var y=Object.defineProperty;var o=(e,t)=>y(e,"name",{value:t,configurable:!0});import{relative as p}from"node:path";import{getHeaderSyntaxForFile as h,renderHeaderLines as $}from"./syntax.mjs";function d(e){const t=p(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/"),r=h(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),m=e.createdByName||e.authorName,l=e.createdByEmail||e.authorEmail,s=e.lastModifiedByName||e.authorName,n=e.lastModifiedByEmail||e.authorEmail,i=typeof e.companyName=="string"?e.companyName.trim():"",c=i.length>0?`${i} `:"",a=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${m}`,`@Email: <${l}>`,"-----",`@Last modified by: ${s} (${n})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${c}All rights reserved.`];return $(r,a)}o(d,"buildHeader");export{d as buildHeader};
|
|
2
|
+
//# sourceMappingURL=template.mjs.map
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
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-11-
|
|
10
|
+
* @Last modified time: 2026-11-25T19:44:18-08:00 (1795664658)
|
|
11
11
|
* -----
|
|
12
12
|
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
13
|
*
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
* Node's `require()` loads an ES module synchronously and returns its namespace, as
|
|
20
20
|
* long as that module has no top-level await (dist/index.mjs has none). The wrapper
|
|
21
21
|
* returns the default export, keeping the historical `module.exports = fixHeaders`
|
|
22
|
-
* shape, instead of
|
|
22
|
+
* shape, instead of a second full copy of the library built for CJS.
|
|
23
23
|
*
|
|
24
24
|
* Node.js versions without require(esm) (20.x before 20.19, 22.x before 22.12, and
|
|
25
25
|
* anything older) would fail with a bare ERR_REQUIRE_ESM, so the check below fails
|
|
26
26
|
* early with a message that says what to do instead.
|
|
27
27
|
*
|
|
28
28
|
* It sits next to the ESM entry under the same name, so `require("./index.mjs")` resolves
|
|
29
|
-
* to src/index.mjs from source and to dist/index.mjs once built.
|
|
30
|
-
* it verbatim into dist
|
|
29
|
+
* to src/index.mjs from source and to dist/index.mjs once built. scripts/build.mjs copies
|
|
30
|
+
* it verbatim into dist/; it never passes through esbuild, so it stays
|
|
31
31
|
* this small however much the library grows.
|
|
32
32
|
* @module fix-headers/cjs-entry
|
|
33
33
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
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(`
|
|
14
|
-
`);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
|
|
15
|
-
`:`
|
|
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(`
|
|
24
|
-
`)?g:`${g}${de(e)??`
|
|
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(`
|
|
33
|
-
`),o=t.split(`
|
|
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};
|
|
37
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
var o=Object.defineProperty;var r=(e,f)=>o(e,"name",{value:f,configurable:!0});import{fixHeaders as t}from"./core/fix-headers.mjs";function a(e){return t(e)}r(a,"fixHeaders");var d=a;export{d as default,a as fixHeaders};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var A=Object.defineProperty;var g=(t,l)=>A(t,"name",{value:l,configurable:!0});function C(t,l){const f=t.length,u=l.length,i=Array.from({length:f+1},()=>new Array(u+1).fill(0));for(let o=f-1;o>=0;o-=1)for(let c=u-1;c>=0;c-=1)i[o][c]=t[o]===l[c]?i[o+1][c+1]+1:Math.max(i[o+1][c],i[o][c+1]);const s=[];let e=0,n=0;for(;e<f&&n<u;)t[e]===l[n]?(s.push({type:" ",line:t[e]}),e+=1,n+=1):i[e+1][n]>=i[e][n+1]?(s.push({type:"-",line:t[e]}),e+=1):(s.push({type:"+",line:l[n]}),n+=1);for(;e<f;e+=1)s.push({type:"-",line:t[e]});for(;n<u;n+=1)s.push({type:"+",line:l[n]});return s}g(C,"diffLines");function w(t,l){return`${l===0?t:t+1},${l}`}g(w,"formatRange");function d(t,l,f={}){const u=t===null?[]:t.split(`
|
|
2
|
+
`),i=l.split(`
|
|
3
|
+
`),s=C(u,i),e=Math.max(0,f.context??3),n=f.lineOffset??0,o=[];if(s.forEach((p,h)=>{if(p.type===" ")return;const a=o[o.length-1];a&&h-a.last<=e*2+1?a.last=h:o.push({first:h,last:h})}),o.length===0)return"";const c=f.fromFile??"a",F=f.toFile??"b",y=[`--- ${t===null?"/dev/null":c}`,`+++ ${F}`];for(const p of o){const h=Math.max(0,p.first-e),a=Math.min(s.length,p.last+e+1),$=s.slice(0,h),m=s.slice(h,a),M=$.filter(r=>r.type!=="+").length+n,b=$.filter(r=>r.type!=="-").length+n,x=m.filter(r=>r.type!=="+").length,L=m.filter(r=>r.type!=="-").length;y.push(`@@ -${w(M,x)} +${w(b,L)} @@`);for(const r of m)y.push(`${r.type}${r.line}`)}return y.join(`
|
|
4
|
+
`)}g(d,"createUnifiedDiff");export{d as createUnifiedDiff,C as diffLines};
|
|
5
|
+
//# sourceMappingURL=diff.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=Object.defineProperty;var i=(e,t)=>m(e,"name",{value:t,configurable:!0});import{access as d,readdir as y,readFile as h,stat as w}from"node:fs/promises";import{constants as x}from"node:fs";import{dirname as p,join as c,resolve as D}from"node:path";async function u(e){try{return await d(e,x.F_OK),!0}catch{return!1}}i(u,"pathExists");async function S(e,t){let n=D(e);for(;;){for(const r of t){const s=c(n,r);if(await u(s))return{root:n,marker:r}}const a=p(n);if(a===n)return null;n=a}}i(S,"findProjectRoot");async function j(e){return await u(e)?h(e,"utf8"):null}i(j,"readTextIfExists");async function F(e,t){const n=[],a=await y(e,{withFileTypes:!0});for(const r of a){const s=c(e,r.name);if(r.isDirectory()&&t.recursive===!1||r.isDirectory()&&t.ignoreFolders.has(r.name)||r.isDirectory()&&await t.shouldSkipDirectory?.(s,r.name)===!0)continue;if(r.isDirectory()){const l=await F(s,t);n.push(...l);continue}if(!r.isFile())continue;const o=r.name.lastIndexOf(".");if(o===-1)continue;const f=r.name.slice(o).toLowerCase();t.allowedExtensions.has(f)&&n.push(s)}return n}i(F,"walkFiles");async function v(e){const t=await w(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}i(v,"readFileDates");export{S as findProjectRoot,u as pathExists,v as readFileDates,j as readTextIfExists,F as walkFiles};
|
|
2
|
+
//# sourceMappingURL=fs.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var m=Object.defineProperty;var o=(n,t)=>m(n,"name",{value:t,configurable:!0});import{execFile as g}from"node:child_process";import{basename as p,dirname as d}from"node:path";import{promisify as h}from"node:util";const s=h(g);async function u(n,t){try{const{stdout:e}=await s("git",t,{cwd:n}),r=e.trim();return r.length>0?r:null}catch{return null}}o(u,"runGit");function c(n,t){let e=0;for(let r=t-1;r>=0&&n[r]==="\\";r--)e++;return e%2===1}o(c,"isEscaped");function y(n){const t=n.trim();if(!t.endsWith(")")||c(t,t.length-1))return t;let e=0;for(let r=t.length-1;r>=0;r--){const i=t[r];if(!(i!=="("&&i!==")"||c(t,r))&&(e+=i===")"?1:-1,e===0))return t.slice(0,r).trim()}return t}o(y,"stripUidComment");function x(n){const t=n.trim();if(t.length===0)return{authorName:null,authorEmail:null};const e=t.match(/<([^>\n]+)>\s*$/),r=e?.[1]?.trim()||null,i=(e?t.slice(0,e.index):t).trim();return{authorName:y(i)||i||null,authorEmail:r}}o(x,"parseSignerUid");async function N(n,t){try{const{stdout:e}=await s(n,t),r=e.trim();return r.length>0?r:null}catch{return null}}o(N,"runProgram");function w(n){return n.replace(/\\x([0-9a-fA-F]{2})/g,(t,e)=>String.fromCharCode(Number.parseInt(e,16)))}o(w,"decodeColonField");async function b(n){const t=await u(n,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;const e=await u(n,["config","--get","user.signingkey"]);if(!e)return null;const r=await u(n,["config","--get","gpg.openpgp.program"])||await u(n,["config","--get","gpg.program"])||"gpg",i=await N(r,["--batch","--with-colons","--list-keys",e]);if(!i)return null;for(const a of i.split(`
|
|
2
|
+
`)){const l=a.split(":");if(l[0]==="uid"&&l[1]!=="r"&&l[1]!=="e"&&l[9])return w(l[9])}return null}o(b,"readSigningKeyUid");async function I(n,t={}){let e=await u(n,["config","--get","user.name"]),r=await u(n,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){const i=await b(n)||await u(n,["log","-1","--format=%GS"]),a=x(i||"");e=a.authorName||e,r=r||a.authorEmail}if(!e||!r){const i=await u(n,["log","-1","--format=%an|%ae"]);if(i){const[a,l]=i.split("|");e=e||a||null,r=r||l||null}}return{authorName:e,authorEmail:r}}o(I,"detectGitAuthor");function f(n){return n.replace(/z$/i,"+00:00")}o(f,"canonicalGitDate");async function C(n,t){const e=await u(n,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!e)return null;const r=e.split(`
|
|
3
|
+
`)[0],[i,a]=r.split("|");if(!i||!a)return null;const l=Number.parseInt(a,10);return Number.isNaN(l)?null:{date:f(i),timestamp:l}}o(C,"getGitCreationDate");async function D(n,t){const e=await u(n,["log","-1","--format=%aI|%at","--",t]);if(!e)return null;const[r,i]=e.split("|");if(!r||!i)return null;const a=Number.parseInt(i,10);return Number.isNaN(a)?null:{date:f(r),timestamp:a}}o(D,"getGitLastModifiedDate");const E=256*1024*1024;async function S(n){const t=d(n);if(await u(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{const{stdout:e}=await s("git",["show",`HEAD:./${p(n)}`],{cwd:t,encoding:"utf8",maxBuffer:E});return{state:"tracked",content:e}}catch{return{state:"untracked",content:null}}}o(S,"readGitHeadFile");export{I as detectGitAuthor,C as getGitCreationDate,D as getGitLastModifiedDate,x as parseSignerUid,S as readGitHeadFile,b as readSigningKeyUid,u as runGit};
|
|
4
|
+
//# sourceMappingURL=git.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var l=Object.defineProperty;var r=(n,e)=>l(n,"name",{value:e,configurable:!0});function s(n){let e=n.indexOf("<");for(;e!==-1;){const i=n.indexOf(">",e+1);if(i===-1)return!1;if(i>e+1)return!0;e=n.indexOf("<",i+1)}return!1}r(s,"hasAngleTag");function o(n){let e=n.length;for(;e>0&&n[e-1]==="/";)e-=1;return n.slice(0,e)}r(o,"trimTrailingSlashes");export{s as hasAngleTag,o as trimTrailingSlashes};
|
|
2
|
+
//# sourceMappingURL=text.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var T=Object.defineProperty;var o=(t,n)=>T(t,"name",{value:n,configurable:!0});function y(t){return $({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),offsetMinutes:-t.getTimezoneOffset()})}o(y,"formatDateWithTimezone");function $(t){return`${g(t," ")} ${h(t.offsetMinutes)}`}o($,"formatSpaceDate");function M(t){if(typeof t!="string")throw new Error(`timezone must be an IANA time zone name string, such as "America/Los_Angeles" or "UTC" (got ${typeof t})`);try{l(t)}catch(n){throw new Error(`Unknown time zone "${t}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:n})}return t}o(M,"assertTimeZone");const d=new Map;function l(t){let n=d.get(t);return n||(n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),d.set(t,n)),n}o(l,"getZoneFormatter");function w(t,n){const e={};for(const u of l(n).formatToParts(new Date(t*1e3)))e[u.type]=Number(u.value);const r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second)/1e3;return{year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:e.second,offsetMinutes:(r-t)/60}}o(w,"toZonedDateParts");function g(t,n){const e=o(r=>String(r).padStart(2,"0"),"pad");return`${String(t.year).padStart(4,"0")}-${e(t.month)}-${e(t.day)}${n}${e(t.hour)}:${e(t.minute)}:${e(t.second)}`}o(g,"formatWallClock");function h(t){const n=o(r=>String(r).padStart(2,"0"),"pad"),e=Math.abs(t);return`${t>=0?"+":"-"}${n(Math.floor(e/60))}:${n(e%60)}`}o(h,"formatOffset");function U(t=new Date){return{date:y(t),timestamp:Math.floor(t.getTime()/1e3)}}o(U,"toDatePayload");const C=/^(\d{4})-(\d{2})-(\d{2})(?:T|\s+)(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(?:(Z)|([+-])(\d{2}):?(\d{2}))$/i;function A(t){const n=C.exec(t.trim());if(!n)return null;const[e,r,u,s,i,c]=n.slice(1,7).map(Number),f=n[7]?0:Number(n[9])*60+Number(n[10]),m=n[8]==="-"?-f:f,a=new Date(Date.UTC(e,r-1,u,s,i,c));return!(a.getUTCFullYear()===e&&a.getUTCMonth()===r-1&&a.getUTCDate()===u&&a.getUTCHours()===s&&a.getUTCMinutes()===i&&a.getUTCSeconds()===c)||Number(n[10]??0)>59?null:{year:e,month:r,day:u,hour:s,minute:i,second:c,offsetMinutes:m,timestamp:Math.floor(a.getTime()/1e3)-m*60}}o(A,"parseHeaderDate");function S(t){return`${g(t,"T")}${h(t.offsetMinutes)}`}o(S,"formatIsoDate");export{M as assertTimeZone,y as formatDateWithTimezone,S as formatIsoDate,$ as formatSpaceDate,A as parseHeaderDate,U as toDatePayload,w as toZonedDateParts};
|
|
2
|
+
//# sourceMappingURL=time.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/fix-headers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Multi-language project header normalizer with auto-detection and override support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/",
|
|
11
11
|
"!dist/**/*.map",
|
|
12
|
-
"types/"
|
|
13
|
-
"bin/",
|
|
14
|
-
"!bin/**/*.map"
|
|
12
|
+
"types/"
|
|
15
13
|
],
|
|
16
14
|
"exports": {
|
|
17
15
|
".": {
|
|
@@ -27,7 +25,7 @@
|
|
|
27
25
|
"./package.json": "./package.json"
|
|
28
26
|
},
|
|
29
27
|
"bin": {
|
|
30
|
-
"fix-headers": "./
|
|
28
|
+
"fix-headers": "./dist/cli.mjs"
|
|
31
29
|
},
|
|
32
30
|
"scripts": {
|
|
33
31
|
"build:ci": "npm run lint --if-present && npm run format:check --if-present && npm run types:check && npm run types:build && npm run build",
|
|
@@ -40,8 +38,8 @@
|
|
|
40
38
|
"types:build": "tsc -p .configs/tsconfig.json --noCheck",
|
|
41
39
|
"types:check": "tsc -p .configs/tsconfig.json --noEmit",
|
|
42
40
|
"cli": "node --conditions=fix-headers-dev ./src/cli.mjs",
|
|
43
|
-
"build": "node
|
|
44
|
-
"prepack": "node -e \"const fs=require('node:fs');
|
|
41
|
+
"build": "node scripts/build.mjs",
|
|
42
|
+
"prepack": "node -e \"const fs=require('node:fs');if(fs.existsSync('node_modules/esbuild')){require('node:child_process').execSync('npm run build',{stdio:'inherit'})}else if(!fs.existsSync('dist/index.mjs')){throw new Error('dist/ is missing and esbuild is unavailable to build it')}\"",
|
|
45
43
|
"lint": "eslint --config .configs/eslint.config.mjs .",
|
|
46
44
|
"lint:fix": "eslint --config .configs/eslint.config.mjs . --fix",
|
|
47
45
|
"format": "prettier --config .configs/.prettierrc --write .",
|
|
@@ -110,7 +108,6 @@
|
|
|
110
108
|
"eslint": "^10.11.0",
|
|
111
109
|
"globals": "^17.14.0",
|
|
112
110
|
"prettier": "^3.9.9",
|
|
113
|
-
"tsup": "^9.0.0",
|
|
114
111
|
"typescript": "^6.0.3",
|
|
115
112
|
"vitest": "^5.0.0"
|
|
116
113
|
},
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a path names a TypeScript declaration file (`.d.ts`, `.d.mts` or `.d.cts`).
|
|
3
|
+
* @param {string} filePath - File path.
|
|
4
|
+
* @returns {boolean} True for a declaration file.
|
|
5
|
+
*/
|
|
6
|
+
export function isDeclarationFile(filePath: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Says why a generated declaration file is skipped. `tsc` copies the source file's header into
|
|
9
|
+
* the `.d.ts` / `.d.mts` / `.d.cts` it emits, `@Filename` included, and the source run already
|
|
10
|
+
* maintains that header. Rewriting the copy only makes fix-headers and `tsc` undo each other on
|
|
11
|
+
* every run, so a declaration file whose header names its own source file is left alone. A
|
|
12
|
+
* declaration whose header names any other file (a hand-written one that was moved) is fixed as usual.
|
|
13
|
+
* @param {string} content - File content.
|
|
14
|
+
* @param {string} filePath - File path.
|
|
15
|
+
* @returns {string | null} Skip reason, or null.
|
|
16
|
+
*/
|
|
17
|
+
export function declarationCopySkipReason(content: string, filePath: string): string | null;
|
|
1
18
|
export namespace detector {
|
|
2
19
|
export let id: string;
|
|
3
20
|
export { extensions };
|
package/bin/fix-headers.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var yr=Object.defineProperty;var s=(e,t)=>yr(e,"name",{value:t,configurable:!0});import{realpathSync as or}from"node:fs";import{fileURLToPath as Mi,pathToFileURL as Ii}from"node:url";import{readFile as xr}from"node:fs/promises";import{createRequire as wr}from"node:module";import{dirname as br,isAbsolute as kr,resolve as dt}from"node:path";var Er=3e4,$r=new Set(["localhost","127.0.0.1","[::1]"]);function we(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(we,"isPlainObject");function be(e,t){let n={...e};for(let[r,o]of Object.entries(t))r!=="__proto__"&&(n[r]=we(n[r])&&we(o)?be(n[r],o):o);return n}s(be,"mergeConfig");function mt(e){return e.kind==="file"?e.path:e.href}s(mt,"describeSource");async function Sr(e){if(e.kind==="file")return{text:await xr(e.path,"utf8"),source:e};let t;try{t=await fetch(e.href,{cache:"no-store",redirect:"follow",signal:AbortSignal.timeout(Er)})}catch(n){let r=n.cause instanceof Error?n.cause.message:n.message;throw new Error(`Failed to fetch config ${e.href}: ${r}`,{cause:n})}if(!t.ok)throw new Error(`Failed to fetch config ${e.href}: HTTP ${t.status} ${t.statusText}`);return{text:await t.text(),source:{kind:"url",href:t.url}}}s(Sr,"readSource");function ft(e){if(e.protocol==="http:"&&!$r.has(e.hostname))throw new Error(`Refusing to fetch config over plain http: ${e.href} (use https)`);return{kind:"url",href:e.href}}s(ft,"toUrlSource");function Ar(e,t){if(/^https?:\/\//i.test(e))return ft(new URL(e));if(/^[a-z][a-z\d+.-]+:\/\//i.test(e))throw new Error(`Unsupported extends URL "${e}" in ${mt(t)}; use https, a file path or a package path`);let n=/^\.{1,2}[\\/]/.test(e);if(t.kind==="url"){if(n||e.startsWith("/"))return ft(new URL(e,t.href));throw new Error(`Cannot extend package "${e}" from the remote config ${t.href}; use a URL or a relative path`)}if(n||kr(e))return{kind:"file",path:dt(br(t.path),e)};try{return{kind:"file",path:wr(t.path).resolve(e)}}catch(r){throw new Error(`Cannot resolve extends "${e}" from ${t.path}: ${r.message}`,{cause:r})}}s(Ar,"resolveReference");function Cr(e,t){if(e===void 0)return[];let n=Array.isArray(e)?e:[e];if(!n.every(r=>typeof r=="string"&&r.trim().length>0))throw new Error(`Config "extends" must be a string or an array of strings: ${t}`);return n.map(r=>r.trim())}s(Cr,"readExtends");async function pt(e,t){let n=mt(e);if(t.includes(n))throw new Error(`Config extends cycle: ${[...t,n].join(" -> ")}`);let{text:r,source:o}=await Sr(e),i;try{i=JSON.parse(r)}catch(f){throw new Error(`Config ${n} is not valid JSON: ${f.message}`,{cause:f})}if(!we(i))throw new Error(`Config file must contain a JSON object: ${n}`);let{extends:a,...c}=i,l={};for(let f of Cr(a,n))l=be(l,await pt(Ar(f,o),[...t,n]));return be(l,c)}s(pt,"loadSource");function Dr(e,t=process.cwd()){return pt({kind:"file",path:dt(t,e)},[])}s(Dr,"loadConfigFile");async function re(e,t){let n=typeof e[t]=="string"?e[t].trim():"";if(n.length===0)return e;let r=typeof e.cwd=="string"&&e.cwd.length>0?e.cwd:process.cwd(),o={...await Dr(n,r),...e};return delete o[t],o}s(re,"applyConfigOption");import{readFile as $i,stat as Si,writeFile as Ai}from"node:fs/promises";import{relative as Ve,resolve as tr}from"node:path";import{extname as ke}from"node:path";import{extname as vr}from"node:path";var gt=[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],Fr=400,Nr=/\bcopyright\b|\blicen[cs]e[ds]?\b|SPDX-License-Identifier|\bpublic domain\b/i,ht=/^[\s*/]*@(?:Project|Filename):/m;function Lr(e){let t=vr(e).toLowerCase();return gt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Lr,"resolveCCommentSyntax");function jr(e){let t=e.replace(/^\uFEFF/,"").split(`
|
|
3
|
-
`).slice(0,Fr),n=[],r=null,o=null,i=!1;for(let a of t){let c=a.replace(/\r$/,"");if(r){r.push(c),c.includes("*/")&&(n.push(r.join(`
|
|
4
|
-
`)),r=null);continue}if(i){i=c.endsWith("\\");continue}let l=c.trim();if(o&&!l.startsWith("//")&&(n.push(o.join(`
|
|
5
|
-
`)),o=null),l.length!==0){if(l.startsWith("//")){(o??=[]).push(l);continue}if(l.startsWith("/*")){let f=l.indexOf("*/",2);if(f===-1){r=[l];continue}if(n.push(l.slice(0,f+2)),l.slice(f+2).trim().length>0)break;continue}if(l.startsWith("#")){i=l.endsWith("\\");continue}break}}return o&&n.push(o.join(`
|
|
6
|
-
`)),n}s(jr,"prologueComments");var yt={id:"c",extensions:gt,enabledByDefault:!0,resolveContentSkipReason(e){let t=jr(e);return t.length>0&&ht.test(t[0])?null:t.some(n=>!ht.test(n)&&Nr.test(n))?"the file starts with a license or copyright notice that is not a fix-headers header (third-party code)":null},resolveCommentSyntax(e){return Lr(e)}};import{extname as Rr}from"node:path";var xt=[".css"];function Mr(e){let t=Rr(e).toLowerCase();return xt.includes(t)?{kind:"block",blockStart:"/*",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Mr,"resolveCssCommentSyntax");var wt={id:"css",extensions:xt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&/^@charset "[^"]*";/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return Mr(e)}};import{extname as Tr}from"node:path";var Ir=/^(?:#|\/\/|\/\*+|<!--)[ \t]+(vi|vim(?:[<=>]?\d+)?|Vim|ex):(.*)$/,Pr=/^[a-z]+(?:[!&]|[+^-]?=(?:\\.|[^\s:\\])*)?$/,Or=new Set(["et","expandtab","ai","autoindent","si","smartindent","ro","readonly","bin","binary","noet","noexpandtab","noai","noautoindent","nosi","nosmartindent","noro","noreadonly","nobin","nobinary","nowrap","nolist","nospell","nofen","nofoldenable","noeol","nofixeol","nofixendofline"]);function oe(e){let t=e.match(Ir);if(!t)return!1;let n=t[2].trim();if(n.endsWith("-->"))n=n.slice(0,-3).trimEnd();else if(n.endsWith("*/")){let i=n.length-2;for(;i>0&&n[i-1]==="*";)i-=1;n=n.slice(0,i).trimEnd()}let r=n.match(/^se(?:t)?[ \t]((?:\\.|[^:\\])*):/);if(!r&&t[1]==="Vim")return!1;let o=r?r[1].match(/(?:\\.|[^\s\\])+/g):n.match(/(?:\\.|[^\s:\\])+/g);return o!==null&&o.every(i=>Pr.test(i))&&o.some(i=>i.includes("=")||Or.has(i))}s(oe,"isModeline");function ie(e,t){return t===0&&e.startsWith("#!")}s(ie,"isShebang");function se(e,t,n=0){let r=0,o=n;for(;r<e.length;){let i=e.indexOf(`
|
|
7
|
-
`,r),a=i===-1?e.length:i+1;if(!t(e.slice(r,a).replace(/\r?\n$/,""),o))break;r=a,o+=1}return e.slice(0,r)}s(se,"takeTopLines");var kt=[".go"];function Hr(e){let t=Tr(e).toLowerCase();return kt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Hr,"resolveGoCommentSyntax");var bt=/^\/\/(?:go:build|\s*\+build)\s/;function _r(e,t){let n=se(t,o=>bt.test(o)||oe(o));if(!n.split(/\r?\n/).some(o=>bt.test(o)))return"";let r=t.slice(n.length);return`${n}${r.slice(0,r.length-r.replace(/^(?:[ \t]*\r?\n)*/,"").length)}`}s(_r,"resolveGoPreservedPrefix");var Et={id:"go",extensions:kt,enabledByDefault:!0,resolvePreservedPrefix(e,t){return _r(e,t)},resolveCommentSyntax(e){return Hr(e)}};import{extname as Ur}from"node:path";var $t=[".html",".htm"];function Wr(e){let t=Ur(e).toLowerCase();return $t.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}s(Wr,"resolveHtmlCommentSyntax");var St={id:"html",extensions:$t,enabledByDefault:!0,resolveCommentSyntax(e){return Wr(e)}};import{extname as Br}from"node:path";var At=[".jsonv",".jsonc",".json5"];function zr(e){let t=Br(e).toLowerCase();return At.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(zr,"resolveJsonCommentSyntax");var Ct={id:"json",extensions:At,enabledByDefault:!0,resolveCommentSyntax(e){return zr(e)}};import{extname as Gr}from"node:path";var Dt=[".md",".markdown"];function Yr(e){let t=Gr(e).toLowerCase();return Dt.includes(t)?{kind:"html",blockStart:"<!--",blockLinePrefix:" ",blockEnd:"-->"}:null}s(Yr,"resolveMarkdownCommentSyntax");function Vr(e,t){let n=t.match(/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);return n?n[0]:""}s(Vr,"resolveMarkdownPreservedPrefix");var vt={id:"markdown",extensions:Dt,enabledByDefault:!1,requiresForce:!0,resolvePreservedPrefix(e,t){return Vr(e,t)},resolveCommentSyntax(e){return Yr(e)}};import{basename as Ft,extname as Jr}from"node:path";var Nt=[".js",".mjs",".cjs",".ts",".mts",".cts",".tsx",".jsx"];function Kr(e){let t=Jr(e).toLowerCase();return Nt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(Kr,"resolveNodeCommentSyntax");var qr=/^(.+)\.d\.(ts|mts|cts)$/i,Xr={ts:[".ts",".tsx",".js",".jsx"],mts:[".mts",".mjs"],cts:[".cts",".cjs"]};function Zr(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}s(Zr,"leadingHeaderFilename");function Qr(e,t){let n=qr.exec(Ft(t));if(!n)return null;let r=Zr(e);if(r===null)return null;let o=Ft(r),[,i,a]=n;return Xr[a.toLowerCase()].some(l=>o===`${i}${l}`)?`the file is a declaration generated from ${o} and carries its header (tsc copies it)`:null}s(Qr,"declarationCopySkipReason");var Lt={id:"node",extensions:Nt,enabledByDefault:!0,keepsAboveHeader:ie,resolveContentSkipReason(e,t){return Qr(e,t)},resolveCommentSyntax(e){return Kr(e)}};import{extname as eo}from"node:path";var Rt=[".php"];function to(e){let t=eo(e).toLowerCase();return Rt.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(to,"resolvePhpCommentSyntax");var jt=/^<\?php(?:\s|$)/i,Mt={id:"php",extensions:Rt,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&jt.test(e),"keepsAboveHeader"),resolveContentSkipReason(e){return jt.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 to(e)}};import{extname as no}from"node:path";var It=[".py"],ro=/^#.*?(?<![A-Za-z])coding[:=]\s*[-\w.]+/;function oo(e,t){return ie(e,t)||t<=1&&ro.test(e)}s(oo,"keepsAboveHeader");var Pt={id:"python",extensions:It,enabledByDefault:!0,keepsAboveHeader:oo,resolveCommentSyntax(e){let t=no(e).toLowerCase();return It.includes(t)?{kind:"line",linePrefix:"#"}:null}};import{extname as io}from"node:path";var Ot=[".rs"];function so(e){let t=io(e).toLowerCase();return Ot.includes(t)?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}:null}s(so,"resolveRustCommentSyntax");var Tt={id:"rust",extensions:Ot,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&e.startsWith("#!")&&!/^#!\s*\[/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return so(e)}};import{extname as ao}from"node:path";var Ht=[".yaml",".yml"];function co(e){let t=ao(e).toLowerCase();return Ht.includes(t)?{kind:"line",linePrefix:"#"}:null}s(co,"resolveYamlCommentSyntax");var _t={id:"yaml",extensions:Ht,enabledByDefault:!0,keepsAboveHeader:s((e,t)=>t===0&&/^#cloud-config\s*$/.test(e),"keepsAboveHeader"),resolveCommentSyntax(e){return co(e)}};var ae=[yt,wt,Et,St,Ct,vt,Lt,Mt,Pt,Tt,_t],lo=new Map(ae.map(e=>[e.id,e]));function uo(e,t){return!t||typeof t!="object"?e:e.kind==="line"?{...e,linePrefix:typeof t.linePrefix=="string"&&t.linePrefix.length>0?t.linePrefix:e.linePrefix,lineSeparator:typeof t.lineSeparator=="string"?t.lineSeparator:e.lineSeparator}:{...e,blockStart:typeof t.blockStart=="string"&&t.blockStart.length>0?t.blockStart:e.blockStart,blockLinePrefix:typeof t.blockLinePrefix=="string"&&t.blockLinePrefix.length>0?t.blockLinePrefix:e.blockLinePrefix,blockEnd:typeof t.blockEnd=="string"&&t.blockEnd.length>0?t.blockEnd:e.blockEnd}}s(uo,"applySyntaxOverride");function Ut(e){if(e==null)return[];if(!Array.isArray(e)||e.some(n=>typeof n!="string"))throw new Error(`forcedDetectors must be an array of detector ids, got ${JSON.stringify(e)}`);let t=ae.filter(n=>n.requiresForce===!0).map(n=>n.id);for(let n of e){if(!lo.has(n))throw new Error(`forcedDetectors: unknown detector "${n}" (force-only detectors: ${t.join(", ")})`);if(!t.includes(n))throw new Error(`forcedDetectors: "${n}" does not need forcing (force-only detectors: ${t.join(", ")})`)}return Array.from(new Set(e))}s(Ut,"resolveForcedDetectors");function O(e={}){let t=new Set(Array.isArray(e.enabledDetectors)?e.enabledDetectors:[]),n=new Set(Array.isArray(e.disabledDetectors)?e.disabledDetectors:[]),r=new Set(Array.isArray(e.forcedDetectors)?e.forcedDetectors:[]);return ae.filter(o=>o.requiresForce===!0?r.has(o.id)&&!n.has(o.id):t.size>0?t.has(o.id):n.has(o.id)?!1:o.enabledByDefault)}s(O,"getEnabledDetectors");function Wt(e={}){if(Array.isArray(e.includeExtensions)&&e.includeExtensions.length>0)return new Set(e.includeExtensions.map(n=>n.toLowerCase()));let t=O(e);return new Set(t.flatMap(n=>n.extensions))}s(Wt,"getAllowedExtensions");function Bt(e,t={}){let n=ke(e).toLowerCase();if(O(t).some(a=>a.extensions.includes(n)&&a.resolveCommentSyntax(e)!==null))return null;if(n.length===0)return"the file has no extension, so its comment syntax is unknown";let o=new Set(Array.isArray(t.forcedDetectors)?t.forcedDetectors:[]),i=ae.find(a=>a.requiresForce===!0&&a.extensions.includes(n)&&!o.has(a.id));return i?`${n} files get a header only when forced (--force-detector ${i.id} / forcedDetectors: ["${i.id}"])`:`no enabled detector handles ${n} files`}s(Bt,"getHeaderSkipReason");function zt(e,t={}){let n=ke(e).toLowerCase(),r=Array.isArray(t.detectors)?t.detectors:O(t);for(let o of r){if(!o.extensions.includes(n))continue;let i=o.resolveCommentSyntax(e);if(i){let a=t.detectorSyntaxOverrides&&typeof t.detectorSyntaxOverrides=="object"?t.detectorSyntaxOverrides:{};return uo(i,a[o.id])}}return{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */"}}s(zt,"getCommentSyntaxForFile");function Gt(e,t){let n=ke(e).toLowerCase();return O(t).find(r=>r.extensions.includes(n))}s(Gt,"detectorForFile");function ce(e,t,n={}){let r=Gt(e,n);if(!r)return"";let o=typeof r.resolvePreservedPrefix=="function"?r.resolvePreservedPrefix(e,t):"",i=r.keepsAboveHeader,a=se(t.slice(o.length),(c,l)=>oe(c)||typeof i=="function"&&i(c,l),o.split(`
|
|
8
|
-
`).length-1);return`${o}${a}`}s(ce,"getPreservedPrefixForFile");function Yt(e,t,n={}){let r=Gt(e,n);return r&&typeof r.resolveContentSkipReason=="function"?r.resolveContentSkipReason(t,e):null}s(Yt,"getContentSkipReason");var Vt=200,X=1,le=2;function T(e,t,n){if(e==null)return n;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${t} must be a whole number of 0 or more, got ${JSON.stringify(e)}`);return e}s(T,"resolveLayoutCount");import{existsSync as $o}from"node:fs";import{join as Fe,relative as an,resolve as Ne,sep as De}from"node:path";import{realpath as So,stat as Ao}from"node:fs/promises";import{access as fo,readdir as mo,readFile as na,stat as po}from"node:fs/promises";import{constants as ho}from"node:fs";import{dirname as ia,join as go,resolve as sa}from"node:path";async function Ee(e){try{return await fo(e,ho.F_OK),!0}catch{return!1}}s(Ee,"pathExists");async function $e(e,t){let n=[],r=await mo(e,{withFileTypes:!0});for(let o of r){let i=go(e,o.name);if(o.isDirectory()&&t.recursive===!1||o.isDirectory()&&t.ignoreFolders.has(o.name)||o.isDirectory()&&await t.shouldSkipDirectory?.(i,o.name)===!0)continue;if(o.isDirectory()){let l=await $e(i,t);n.push(...l);continue}if(!o.isFile())continue;let a=o.name.lastIndexOf(".");if(a===-1)continue;let c=o.name.slice(a).toLowerCase();t.allowedExtensions.has(c)&&n.push(i)}return n}s($e,"walkFiles");async function Jt(e){let t=await po(e);return{createdAt:t.birthtimeMs>0&&t.birthtime<t.mtime?t.birthtime:t.mtime,updatedAt:t.mtime}}s(Jt,"readFileDates");function Kt(e){let t=e.indexOf("<");for(;t!==-1;){let n=e.indexOf(">",t+1);if(n===-1)return!1;if(n>t+1)return!0;t=e.indexOf("<",n+1)}return!1}s(Kt,"hasAngleTag");function qt(e){let t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}s(qt,"trimTrailingSlashes");import{execFile as yo}from"node:child_process";import{lstat as xo,readFile as wo}from"node:fs/promises";import{dirname as Xt,isAbsolute as bo,join as en,relative as tn,resolve as Se,sep as nn}from"node:path";import ko from"ignore";function Zt(e,t){return new Promise(n=>{yo("git",t,{cwd:e,encoding:"utf8",maxBuffer:Number.POSITIVE_INFINITY},(r,o)=>{if(!r){n({code:0,stdout:o});return}n({code:typeof r.code=="number"?r.code:-1,stdout:""})})})}s(Zt,"runGitCommand");function Ce(e,t){return tn(e,t).split(nn).join("/")}s(Ce,"toPosixRelative");async function rn(e){try{return ko().add(await wo(e,"utf8"))}catch{return null}}s(rn,"readIgnoreFile");async function Eo(e){return xo(en(e,".git")).then(()=>!0,()=>!1)}s(Eo,"hasGitEntry");function Qt(e,t,n){for(let r=e.length-1;r>=0;r--){let{base:o,rules:i}=e[r],a=i.test(`${Ce(o,t)}${n?"/":""}`);if(a.ignored||a.unignored)return a.ignored}return!1}s(Qt,"matchesRules");async function on(e,t){let n=await rn(en(e,".gitignore"));return{kind:"rules",nested:!0,excluded:!1,matchers:n?[...t,{base:e,rules:n}]:t}}s(on,"buildRulesContext");async function Ae(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 on(e,[]);let r=new Set,o=new Set;for(let i of n.stdout.split("\0")){let a=i.endsWith("/")?i.slice(0,-1):i;if(a.length!==0){r.add(a);for(let c=a.indexOf("/");c!==-1;c=a.indexOf("/",c+1))o.add(a.slice(0,c))}}return{kind:"git",root:e,entries:r,dirs:o}}s(Ae,"resolveScopeContext");function sn(e){let t=Se(e.root),n=e.gitignore;if(n===!1)return{isIgnored:s(async()=>!1,"isIgnored")};let r=new Map,o=s(async()=>{if(typeof n!="string"&&!Array.isArray(n))return Ae(t);let c=typeof n=="string"?[n]:n.filter(f=>typeof f=="string"),l=[];for(let f of c){let u=await rn(Se(t,f));u&&l.push({base:t,rules:u})}return{kind:"rules",nested:!1,excluded:!1,matchers:l}},"buildRootContext"),i=s(c=>{let l=r.get(c);return l||(l=c===t?o():a(c),r.set(c,l)),l},"contextFor"),a=s(async c=>{let l=await i(Xt(c));return l.kind==="git"?l.entries.has(Ce(l.root,c))?Ae(c):l:!l.nested||l.excluded?l:Qt(l.matchers,c,!0)?{...l,excluded:!0}:await Eo(c)?Ae(c):on(c,l.matchers)},"deriveContext");return{async isIgnored(c,l){let f=Se(c),u=tn(t,f);if(u.length===0||u===".."||u.startsWith(`..${nn}`)||bo(u))return!1;let m=await i(Xt(f));if(m.kind==="git"){let h=Ce(m.root,f);return!(m.entries.has(h)||l&&m.dirs.has(h))}return m.excluded||Qt(m.matchers,f,l)}}}s(sn,"createIgnoreFilter");function Co(e){return Wt(e)}s(Co,"resolveExtensions");var Do=Object.freeze(["node_modules","bower_components","jspm_packages",".pnpm-store",".yarn"]),un=new Set([".git",...Do]),vo=Object.freeze(["autoload.php","modules.txt"]);function cn(e,t){return un.has(t)?!0:t==="vendor"&&vo.some(n=>$o(Fe(e,n)))}s(cn,"isNeverWalked");function ve(e){return qt(e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""))}s(ve,"normalizeFolderPath");function Fo(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{path:t,recursive:!0};if(t&&typeof t=="object"&&typeof t.path=="string")return{path:t.path,recursive:t.recursive!==!1};throw new TypeError(`Invalid includeFolders entry: ${JSON.stringify(t)} (expected a path string or { path, recursive? })`)}):[]}s(Fo,"resolveIncludeFolders");function ln(e,t){let n=t instanceof Error?t.message:String(t);console.warn(`fix-headers: skipped include folder "${e}" (${n})`)}s(ln,"reportSkippedIncludeFolder");function No(e,t){if(!Array.isArray(t)||t.length===0)return()=>!1;let n=Ne(e),r=[],o=new Set;for(let i of t){if(typeof i!="string")continue;let a=ve(i);if(a.length!==0){if(a.includes("/")){r.push(Ne(n,a));continue}o.add(a)}}return(i,a)=>{if(o.has(a))return!0;for(let l of r)if(i===l||i.startsWith(`${l}/`))return!0;let c=ve(an(n,i));return r.some(l=>{let f=ve(an(n,l));return c===f||c.startsWith(`${f}/`)})}}s(No,"buildExclusionMatcher");async function Le(e){let t=Co(e),n=Fo(e.includeFolders),r=Array.isArray(e.excludeFolders)?e.excludeFolders:[],o=No(e.projectRoot,r),i=sn({root:e.projectRoot,gitignore:e.gitignore}),a=s(async(d,p)=>cn(d,p)||o(d,p)||await i.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 p=await Ao(d.rootPath).catch(b=>b);if(p instanceof Error){if(p.code==="ENOENT"){ln(d.includeFolder,p);continue}throw p}if(!p.isDirectory()){ln(d.includeFolder,`path is not a directory: ${d.rootPath}`);continue}let w=await So(d.rootPath).catch(()=>Ne(d.rootPath));l.push({...d,realRoot:w})}let f=s((d,p)=>{if(d.realRoot===p.realRoot)return d.recursive||!p.recursive;let w=d.realRoot.endsWith(De)?d.realRoot:`${d.realRoot}${De}`;if(!d.recursive||!p.realRoot.startsWith(w))return!1;let b=d.rootPath;for(let $ of p.realRoot.slice(w.length).split(De))if(b=Fe(b,$),cn(b,$)||o(b,$))return!1;return!0},"covers"),u=[...l].sort((d,p)=>d.realRoot.length-p.realRoot.length||Number(p.recursive)-Number(d.recursive)),m=[];for(let d of u)m.some(p=>f(p,d))||m.push(d);let h=[];for(let d of l){if(!m.includes(d))continue;let p=await $e(d.rootPath,{allowedExtensions:t,ignoreFolders:un,shouldSkipDirectory:a,recursive:d.recursive});h.push(...p)}let y=[];for(let d of new Set(h))!o(d,d.split("/").at(-1)||"")&&!await i.isIgnored(d,!1)&&y.push(d);return y}s(Le,"discoverFiles");import{basename as ni,dirname as ri,extname as oi,resolve as Oe}from"node:path";import{dirname as En,isAbsolute as Uo,join as $n,relative as Wo,resolve as Sn,sep as Bo}from"node:path";import{readFile as Lo}from"node:fs/promises";import{join as jo}from"node:path";async function Ro(e){try{return await Lo(e,"utf8")}catch{return null}}s(Ro,"readManifest");async function j(e,t){let n=[];for(let r of t){let o=await Ro(jo(e,r));o!==null&&n.push({file:r,content:o})}return n.length>0?{dir:e,manifest:n[0].file,files:n}:null}s(j,"detectManifests");function H(e,t){return e.files.find(n=>n.file===t)?.content??null}s(H,"manifestContent");function C(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}s(C,"cleanName");function je(e){if(typeof e!="string")return;let t=e.search(/[<(]/);return C(t===-1?e:e.slice(0,t))}s(je,"personName");function ue(e){try{return JSON.parse(e)}catch{return}}s(ue,"parseJsonManifest");function*Re(e,t){let n="";for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.startsWith("[")){let i=o.match(/^\[([^[\]]+)\]/);n=i?i[1].split(".").map(a=>a.trim()).join("."):"";continue}n===t&&(yield o)}}s(Re,"sectionLines");function Z(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*(?:"([^"\\\\]*)"|'([^']*)')`);for(let o of Re(e,t)){let i=o.match(r);if(i)return C(i[1]??i[2])}}s(Z,"readTomlString");function Me(e,t,n){let r=new RegExp(`^${n}\\s*[=:](.*)$`);for(let o of Re(e,t)){let i=o.match(r);if(i)return C(i[1])}}s(Me,"readIniValue");function Mo(e,t,n){let r=new RegExp(`^${n}\\s*=\\s*\\[`),o=null;for(let i of Re(e,t)){if(o!==null){o.push(i);continue}let a=i.match(r);a&&(o=[i.slice(a[0].length)])}return o===null?null:o.join(`
|
|
9
|
-
`)}s(Mo,"tomlArrayText");function Io(e,t){let n=t;for(;n<e.length;)if(e[n]==="#"){let r=e.indexOf(`
|
|
10
|
-
`,n);n=r===-1?e.length:r+1}else if(/\s/.test(e[n]))n+=1;else break;return n}s(Io,"skipTomlSpace");function Q(e,t){let n=Mo(e,t,"authors");if(n===null)return;let r=n.slice(Io(n,0)),o=r.match(/^(?:"([^"\\\n]*)"|'([^'\n]*)')/);if(o)return je(o[1]??o[2]);let a=r.match(/^\{([^}\n]*)\}/)?.[1].match(/(?:^|,)\s*name\s*=\s*(?:"([^"\\\n]*)"|'([^'\n]*)')/);return a?C(a[1]??a[2]):void 0}s(Q,"readTomlAuthor");var fn=["go.mod"];function Po(e){let t=e.match(/^\s*module\s+(.+)$/m);if(t)return C(t[1].replace(/\/\/.*$/,"").trim().replace(/^["`](.*)["`]$/,"$1"))}s(Po,"readModulePath");var dn={id:"go",languages:["go"],manifests:fn,detect(e){return j(e,fn)},read(e){return{name:Po(e.files[0].content)}}};var mn=["package.json"];function Oo(e){let t=C(e?.name),n=C(e?.publisher),r=typeof e?.engines?.vscode=="string";return t&&n&&r?`${n}.${t}`:t}s(Oo,"readPublishedName");function To(e){if(e!==null&&typeof e=="object"){let t=e;return C(t.company)??C(t.name)}return je(e)}s(To,"readAuthorCompany");var pn={id:"node",languages:["node"],manifests:mn,detect(e){return j(e,mn)},read(e){let t=ue(e.files[0].content);return{name:Oo(t),company:To(t?.author)}}};var hn=["composer.json"],gn={id:"php",languages:["php"],manifests:hn,detect(e){return j(e,hn)},read(e){let t=ue(e.files[0].content),n=t?.authors;return{name:C(t?.name),company:Array.isArray(n)?C(n[0]?.name):void 0}}};var yn=["pyproject.toml","setup.cfg","setup.py"];function xn(e,t){let n=e.indexOf("setup(");if(n===-1)return;let r=e.slice(n).match(new RegExp(`\\b${t}\\s*=\\s*(["'])([^"'\\n]+)\\1`));return r&&r[2].trim()||void 0}s(xn,"readSetupPyArgument");function Ho(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Z(t,"project","name")??Z(t,"tool.poetry","name"))??(n===null?void 0:Me(n,"metadata","name"))??(r===null?void 0:xn(r,"name"))}s(Ho,"readPythonName");function _o(e){let t=H(e,"pyproject.toml"),n=H(e,"setup.cfg"),r=H(e,"setup.py");return(t===null?void 0:Q(t,"project")??Q(t,"tool.poetry"))??(n===null?void 0:Me(n,"metadata","author"))??(r===null?void 0:xn(r,"author"))}s(_o,"readPythonCompany");var wn={id:"python",languages:["python"],manifests:yn,detect(e){return j(e,yn)},read(e){return{name:Ho(e),company:_o(e)}}};var bn=["Cargo.toml"],kn={id:"rust",languages:["rust"],manifests:bn,detect(e){return j(e,bn)},read(e){let t=e.files[0].content;return{name:Z(t,"package","name"),company:Q(t,"package")}}};var zo=[pn,wn,gn,kn,dn],An=["name","company"];async function Ie(e,t,n){let o=(await Promise.all(t.map(async a=>({driver:a,detection:await a.detect(e)})))).filter(a=>a.detection!==null),i=o.filter(a=>typeof n=="string"&&a.driver.languages.includes(n));return[...i,...o.filter(a=>!i.includes(a))]}s(Ie,"claimFolder");function Go(e,t){let n=Wo(t,e);return n!==""&&n!==".."&&!n.startsWith(`..${Bo}`)&&!Uo(n)}s(Go,"isStrictlyInside");async function Cn(e,t={}){let n=Array.isArray(t.drivers)?t.drivers:zo,r=typeof t.scanRoot=="string"?Sn(t.scanRoot):null,o=Sn(e),i=await Ie(o,n,t.language);for(;i.length===0;){if(await Ee($n(o,".git")))return{root:o,marker:".git",drivers:[],fields:{},sources:{}};let u=En(o);if(u===o)return null;o=u,i=await Ie(o,n,t.language)}let a={},c={},l=o,f=i;for(;;){for(let{driver:m,detection:h}of f){let y=m.read(h);for(let d of An)a[d]===void 0&&y[d]!==void 0&&(a[d]=y[d],c[d]={driver:m.id,manifest:h.manifest,dir:l})}if(An.every(m=>a[m]!==void 0)||r===null||!Go(l,r)||await Ee($n(l,".git")))break;l=En(l),f=await Ie(l,n,t.language)}return{root:o,marker:i[0].detection.manifest,drivers:i.map(u=>u.driver.id),fields:a,sources:c}}s(Cn,"resolveManifestProject");import{execFile as Yo}from"node:child_process";import{basename as Vo,dirname as Jo}from"node:path";import{promisify as Ko}from"node:util";var Pe=Ko(Yo);async function N(e,t){try{let{stdout:n}=await Pe("git",t,{cwd:e}),r=n.trim();return r.length>0?r:null}catch{return null}}s(N,"runGit");function Dn(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r--)n++;return n%2===1}s(Dn,"isEscaped");function qo(e){let t=e.trim();if(!t.endsWith(")")||Dn(t,t.length-1))return t;let n=0;for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(o!=="("&&o!==")"||Dn(t,r))&&(n+=o===")"?1:-1,n===0))return t.slice(0,r).trim()}return t}s(qo,"stripUidComment");function Xo(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:qo(o)||o||null,authorEmail:r}}s(Xo,"parseSignerUid");async function Zo(e,t){try{let{stdout:n}=await Pe(e,t),r=n.trim();return r.length>0?r:null}catch{return null}}s(Zo,"runProgram");function Qo(e){return e.replace(/\\x([0-9a-fA-F]{2})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16)))}s(Qo,"decodeColonField");async function ei(e){let t=await N(e,["config","--get","gpg.format"]);if(t!==null&&t!=="openpgp")return null;let n=await N(e,["config","--get","user.signingkey"]);if(!n)return null;let r=await N(e,["config","--get","gpg.openpgp.program"])||await N(e,["config","--get","gpg.program"])||"gpg",o=await Zo(r,["--batch","--with-colons","--list-keys",n]);if(!o)return null;for(let i of o.split(`
|
|
11
|
-
`)){let a=i.split(":");if(a[0]==="uid"&&a[1]!=="r"&&a[1]!=="e"&&a[9])return Qo(a[9])}return null}s(ei,"readSigningKeyUid");async function vn(e,t={}){let n=await N(e,["config","--get","user.name"]),r=await N(e,["config","--get","user.email"]);if(t.useGpgSignerAuthor===!0){let o=await ei(e)||await N(e,["log","-1","--format=%GS"]),i=Xo(o||"");n=i.authorName||n,r=r||i.authorEmail}if(!n||!r){let o=await N(e,["log","-1","--format=%an|%ae"]);if(o){let[i,a]=o.split("|");n=n||i||null,r=r||a||null}}return{authorName:n,authorEmail:r}}s(vn,"detectGitAuthor");function Fn(e){return e.replace(/z$/i,"+00:00")}s(Fn,"canonicalGitDate");async function Nn(e,t){let n=await N(e,["log","--follow","--format=%aI|%at","--reverse","--",t]);if(!n)return null;let r=n.split(`
|
|
12
|
-
`)[0],[o,i]=r.split("|");if(!o||!i)return null;let a=Number.parseInt(i,10);return Number.isNaN(a)?null:{date:Fn(o),timestamp:a}}s(Nn,"getGitCreationDate");async function Ln(e,t){let n=await N(e,["log","-1","--format=%aI|%at","--",t]);if(!n)return null;let[r,o]=n.split("|");if(!r||!o)return null;let i=Number.parseInt(o,10);return Number.isNaN(i)?null:{date:Fn(r),timestamp:i}}s(Ln,"getGitLastModifiedDate");var ti=256*1024*1024;async function jn(e){let t=Jo(e);if(await N(t,["rev-parse","--is-inside-work-tree"])!=="true")return{state:"no-git",content:null};try{let{stdout:n}=await Pe("git",["show",`HEAD:./${Vo(e)}`],{cwd:t,encoding:"utf8",maxBuffer:ti});return{state:"tracked",content:n}}catch{return{state:"untracked",content:null}}}s(jn,"readGitHeadFile");function ii(e){return ni(e)||"project"}s(ii,"folderName");function si(e,t){if(typeof t!="string")return e;let n=t.trim();return n.length===0||Kt(e)?e:`${e} <${n}>`}s(si,"formatAuthorNameWithCompany");async function ai(e,t={}){let n=Array.isArray(t.detectors)?t.detectors:O(t),r=typeof t.preferredExtension=="string"?t.preferredExtension.trim().toLowerCase():"",o=r.length>0?n.find(f=>f.extensions.includes(r)):void 0,i=await Cn(e,{drivers:t.drivers,language:o?.id,scanRoot:t.scanRoot}),a=i?i.root:Oe(e),c=i?.sources.name,l=i?.sources.company;return{language:o?.id??i?.drivers[0]??"unknown",rootDir:a,marker:i?i.marker:null,projectName:i?.fields.name??ii(a),projectNameSource:c?{from:"manifest",...c}:{from:"folder",dir:a},companyName:i?.fields.company??null,companyNameSource:l?{from:"manifest",...l}:{from:"none"},drivers:i?i.drivers:[]}}s(ai,"detectProjectFromMarkers");async function Te(e={}){let t=e.targetFilePath||e.cwd||process.cwd(),n=Oe(t),r=O(e),o=e.targetFilePath?ri(n):n,i=e.targetFilePath?oi(n).toLowerCase():"",a=Oe(e.projectRoot||e.cwd||process.cwd()),c=await ai(o,{detectors:r,preferredExtension:i,scanRoot:a}),l=await vn(c.rootDir,{useGpgSignerAuthor:e.useGpgSignerAuthor===!0}),f=e.authorName||l.authorName||"Unknown Author",u=typeof e.companyName=="string"?e.companyName.trim():"";return{projectName:e.projectName||c.projectName,projectNameSource:e.projectName?{from:"option"}:c.projectNameSource,language:e.language||c.language,projectRoot:e.projectRoot||c.rootDir,marker:e.marker===void 0?c.marker:e.marker,authorName:si(f,e.company),authorEmail:e.authorEmail||l.authorEmail||"unknown@example.com",companyName:u||c.companyName,companyNameSource:u?{from:"option"}:c.companyNameSource,copyrightStartYear:Number.isInteger(e.copyrightStartYear)?Number(e.copyrightStartYear):null}}s(Te,"resolveProjectMetadata");function ci(e){return He({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),offsetMinutes:-e.getTimezoneOffset()})}s(ci,"formatDateWithTimezone");function He(e){return`${Pn(e," ")} ${On(e.offsetMinutes)}`}s(He,"formatSpaceDate");function Mn(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{In(e)}catch(t){throw new Error(`Unknown time zone "${e}": expected an IANA time zone name, such as "America/Los_Angeles" or "UTC"`,{cause:t})}return e}s(Mn,"assertTimeZone");var Rn=new Map;function In(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}s(In,"getZoneFormatter");function _e(e,t){let n={};for(let o of In(t).formatToParts(new Date(e*1e3)))n[o.type]=Number(o.value);let r=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)/1e3;return{year:n.year,month:n.month,day:n.day,hour:n.hour,minute:n.minute,second:n.second,offsetMinutes:(r-e)/60}}s(_e,"toZonedDateParts");function Pn(e,t){let n=s(r=>String(r).padStart(2,"0"),"pad");return`${String(e.year).padStart(4,"0")}-${n(e.month)}-${n(e.day)}${t}${n(e.hour)}:${n(e.minute)}:${n(e.second)}`}s(Pn,"formatWallClock");function On(e){let t=s(r=>String(r).padStart(2,"0"),"pad"),n=Math.abs(e);return`${e>=0?"+":"-"}${t(Math.floor(n/60))}:${t(n%60)}`}s(On,"formatOffset");function fe(e=new Date){return{date:ci(e),timestamp:Math.floor(e.getTime()/1e3)}}s(fe,"toDatePayload");var li=/^(\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=li.exec(e.trim());if(!t)return null;let[n,r,o,i,a,c]=t.slice(1,7).map(Number),l=t[7]?0:Number(t[9])*60+Number(t[10]),f=t[8]==="-"?-l:l,u=new Date(Date.UTC(n,r-1,o,i,a,c));return!(u.getUTCFullYear()===n&&u.getUTCMonth()===r-1&&u.getUTCDate()===o&&u.getUTCHours()===i&&u.getUTCMinutes()===a&&u.getUTCSeconds()===c)||Number(t[10]??0)>59?null:{year:n,month:r,day:o,hour:i,minute:a,second:c,offsetMinutes:f,timestamp:Math.floor(u.getTime()/1e3)-f*60}}s(_,"parseHeaderDate");function Ue(e){return`${Pn(e,"T")}${On(e.offsetMinutes)}`}s(Ue,"formatIsoDate");var ui={"git-created":"git first commit","filesystem-created":"filesystem creation time"};function Tn(e,t){let n=e.match(new RegExp(`${t}:[^\\S\\n]*(.*)$`,"m"));return n?n[1].trim():null}s(Tn,"readHeaderField");function We(e){let t=null;for(let{source:n,payload:r}of e)r&&(!t||r.timestamp<t.payload.timestamp)&&(t={source:n,payload:r});return t}s(We,"pickOldestDate");function _n({existing:e,gitCreated:t,filesystemCreated:n,fixCreatedDate:r=!1}){let o=[{source:"git-created",payload:t},{source:"filesystem-created",payload:n}];if(!e)return We(o);if(!r)return{source:"existing-header",payload:e};let i=_(e.date)?e:null;return We([{source:"existing-header",payload:i},...o])}s(_n,"resolveCreatedDate");function Un(e,t=null){if(t)return _e(e.timestamp,t).year;let n=_(e.date);return n?n.year:new Date(e.timestamp*1e3).getFullYear()}s(Un,"dateYear");function Hn(e,t,n,r){let o=e.match(/^(.+?)\s*\((\d+)\)$/),i=o?_(o[1]):null;if(!o||!i)return r.push({check:`${n}-format`,field:t,advisory:!1,value:e,message:`${t} value "${e}" is not a "<datetime> (<epoch>)" pair with a recognised datetime`}),null;let a=Number.parseInt(o[2],10);return a!==i.timestamp&&r.push({check:`${n}-epoch`,field:t,advisory:!1,value:e,expected:`${o[1]} (${i.timestamp})`,message:`${t} epoch ${a} does not match ${o[1]} (expected ${i.timestamp})`}),{text:o[1],timestamp:i.timestamp}}s(Hn,"checkDateValue");function Wn(e,t={},n={}){let r=[],o=Tn(e,"@Date"),i=o===null?null:Hn(o,"@Date","created",r),a=We([{source:"git-created",payload:t.gitCreated},{source:"filesystem-created",payload:t.filesystemCreated}]);if(i&&a&&i.timestamp>a.payload.timestamp){let u=ui[a.source];r.push({check:"created-newer-than-source",field:"@Date",advisory:n.strictCreatedDate!==!0,value:o,expected:`${a.payload.date} (${a.payload.timestamp})`,source:a.source,message:`@Date ${i.text} is later than the ${u} ${a.payload.date} (${a.payload.timestamp})`})}let c=Tn(e,"@Last modified time"),l=c===null?null:Hn(c,"@Last modified time","modified",r),f=t.gitLastModified;return l&&f&&l.timestamp!==f.timestamp&&r.push({check:"modified-git",field:"@Last modified time",advisory:!0,value:c,expected:`${f.date} (${f.timestamp})`,message:`@Last modified time ${l.text} does not match the git last commit ${f.date} (${f.timestamp})`}),r}s(Wn,"checkHeaderDates");function Be(e){if(!e)return null;let t=_(e.date);return t&&t.timestamp!==e.timestamp?{date:e.date,timestamp:t.timestamp}:e}s(Be,"repairDateEpoch");function Bn(e){let t=_(e.date);return t?{date:Ue(t),timestamp:t.timestamp}:e}s(Bn,"normalizeDatePayload");function zn(e,t){let n=_(e.date);if(!n)return e;let r=_e(n.timestamp,t);return r.offsetMinutes===n.offsetMinutes||!Number.isInteger(r.offsetMinutes)?e:{date:/^\d{4}-\d{2}-\d{2}T/i.test(e.date.trim())?Ue(r):He(r),timestamp:n.timestamp}}s(zn,"convertDatePayload");import{relative as di}from"node:path";import{extname as fi}from"node:path";function U(e,t={}){let n=fi(e).toLowerCase(),r=T(t.spacing,"spacing",X);return n.length===0?{kind:"block",blockStart:"/**",blockLinePrefix:" * ",blockEnd:" */",spacing:r}:{...zt(e,t),spacing:r}}s(U,"getHeaderSyntaxForFile");function Gn(e,t){let n=e.spacing??X;if(e.kind==="line"){let c=e.linePrefix||"#",l=typeof e.lineSeparator=="string"?e.lineSeparator:" ",f=Array.from({length:n},()=>c);return[...f,...t.map(u=>`${c}${l}${u}`),...f].join(`
|
|
13
|
-
`)}let r=e.blockStart||(e.kind==="html"?"<!--":"/**"),o=e.blockLinePrefix||(e.kind==="html"?" ":" * "),i=e.blockEnd||(e.kind==="html"?"-->":" */"),a=Array.from({length:n},()=>o.trimEnd());return[r,...a,...t.map(c=>`${o}${c}`),...a,i].join(`
|
|
14
|
-
`)}s(Gn,"renderHeaderLines");function Yn(e){let t=di(e.projectRoot,e.absoluteFilePath).replace(/\\/g,"/"),n=U(e.absoluteFilePath,e.syntaxOptions||{language:e.language}),r=e.createdByName||e.authorName,o=e.createdByEmail||e.authorEmail,i=e.lastModifiedByName||e.authorName,a=e.lastModifiedByEmail||e.authorEmail,c=typeof e.companyName=="string"?e.companyName.trim():"",l=c.length>0?`${c} `:"",f=[`@Project: ${e.projectName}`,`@Filename: ${t}`,`@Date: ${e.createdAt.date} (${e.createdAt.timestamp})`,`@Author: ${r}`,`@Email: <${o}>`,"-----",`@Last modified by: ${i} (${a})`,`@Last modified time: ${e.lastModifiedAt.date} (${e.lastModifiedAt.timestamp})`,"-----",`@Copyright: Copyright (c) ${e.copyrightStartYear}-${e.currentYear} ${l}All rights reserved.`];return Gn(n,f)}s(Yn,"buildHeader");var mi=Object.freeze(["projectName","filename","createdAt","authorName","authorEmail","lastModifiedByName","lastModifiedByEmail","lastModifiedAt","copyrightStartYear","copyrightEndYear","companyName"]);function P(e,t){let n=e.match(new RegExp(`@${t}:[ \\t]*(.*)$`,"m")),r=n?n[1].trim():"";return r.length>0?r:null}s(P,"readTag");function pi(e){if(e===null)return{name:null,email:null};if(!e.endsWith(")"))return{name:e,email:null};let t=e.slice(0,-1),n=t.indexOf("(",t.lastIndexOf(")")+1);return n===-1?{name:e,email:null}:{name:t.slice(0,n).trimEnd()||null,email:t.slice(n+1)||null}}s(pi,"splitLastModifiedBy");function hi(e){let t={startYear:null,endYear:null,companyName:null},n=e?.match(/^Copyright\s+\(c\)\s+(\d{4})/i);if(!n)return t;let r=e.slice(n[0].length),o=r.match(/^\s*-\s*(\d{4})/);o&&(r=r.slice(o[0].length));let i=r.toLowerCase(),a=i.endsWith("all rights reserved.")?20:i.endsWith("all rights reserved")?19:0;return a===0||!/^\s/.test(r)?t:{startYear:n[1],endYear:o?o[1]:null,companyName:r.slice(0,-a).trim()||null}}s(hi,"splitCopyright");function Vn(e){let t=pi(P(e,"Last modified by")),n=hi(P(e,"Copyright")),r=P(e,"Email");return{projectName:P(e,"Project"),filename:P(e,"Filename"),createdAt:P(e,"Date"),authorName:P(e,"Author"),authorEmail:r===null?null:r.replace(/^<(.*)>$/,"$1"),lastModifiedByName:t.name,lastModifiedByEmail:t.email,lastModifiedAt:P(e,"Last modified time"),copyrightStartYear:n.startYear,copyrightEndYear:n.endYear,companyName:n.companyName}}s(Vn,"parseHeaderFields");function Jn(e,t){let n=Vn(e??""),r=Vn(t);return mi.filter(o=>n[o]!==r[o]).map(o=>({field:o,previous:n[o],detected:r[o]}))}s(Jn,"compareHeaderFields");function ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}s(ee,"escapeRegex");function ze(e,t,n={}){let r=t.startsWith("\uFEFF")?"\uFEFF":"",o=t.slice(r.length),i=`${r}${ce(e,o,n)}`;return{prefix:i,body:t.slice(i.length)}}s(ze,"splitPreservedPrefix");function de(e){let t=e.indexOf(`
|
|
15
|
-
`);return t===-1?null:t>0&&e[t-1]==="\r"?`\r
|
|
16
|
-
`:`
|
|
17
|
-
`}s(de,"lineEnding");function z(e,t){if(t.kind==="html"){let r=ee(t.blockStart||"<!--"),o=ee(t.blockEnd||"-->");return e.match(new RegExp(`^${r}[\\s\\S]*?${o}(?:\\r?\\n)*`))}if(t.kind==="line"){let r=ee(t.linePrefix||"#");return e.match(new RegExp(`^(?:${r}[^\\n]*\\n)+(?:\\r?\\n)*`))}let n=ee((t.blockEnd||" */").trim());return e.match(new RegExp(`^/\\*[\\s\\S]*?${n}(?:\\r?\\n)*`))}s(z,"matchHeaderSegment");var Xn=/^@(Project|Filename|Date|Author|Email|Last modified by|Last modified time|Copyright):/,gi="Moved out of the file header by fix-headers:";function Zn(e){return e.some(t=>/^@(?:Project|Filename):/.test(t.text))}s(Zn,"isFileHeader");function Ge(e,t){let n=e.replace(/(?:\r?\n)+$/,"");if(t.kind==="line"){let u=new RegExp(`^${ee(t.linePrefix||"#")}[ \\t]*`);return n.split(`
|
|
18
|
-
`).map(m=>{let h=m.replace(/\r$/,"");return{raw:h,text:h.replace(u,"").trim()}})}let r=t.kind==="html",o=r?n.replace(/^<!--/,"").replace(/--!?>\s*$/,""):n.replace(/^\/\*+/,"").replace(/\*+\/\s*$/,""),i=t.blockLinePrefix||(r?" ":" * "),a=r?/^\s*/:/^\s*\*?[ \t]*/,c=o.split(`
|
|
19
|
-
`).map((u,m)=>({raw:m===0&&u.trim()!==""?`${i}${u.trim()}`:u.trimEnd(),text:(m===0?u:u.replace(a,"")).trim()})),l=c[0].raw===""?1:0,f=c.length>l&&c[c.length-1].raw.trim()===""?c.length-1:c.length;return c.slice(l,f)}s(Ge,"segmentLines");function yi(e,t){let n=e.map(o=>{let i=o.text.match(Xn);return o.text===""?"blank":i&&i[1]==="Copyright"?t.copyright?"copyright":(t.copyright=!0,"field"):i?"field":/^-{3,}$/.test(o.text)?"dash":"text"}),r=s((o,i)=>{for(let a=o+i;a>=0&&a<n.length;a+=i)if(n[a]!=="blank"&&n[a]!=="dash")return n[a]==="copyright"?"field":n[a]},"neighbour");return n.map((o,i)=>o==="dash"?r(i,-1)==="field"||r(i,1)==="field"?"separator":"text":o)}s(yi,"classifyLines");function xi(e,t="",n={}){let r=U(t,n),o=[],i=[],a={copyright:!1},c=e,l=z(c,r),f=!0;for(;l&&l[0].length>0;){let p=Ge(l[0],r),w=yi(p,a),b=p.findIndex($=>$.text!=="");!f&&b!==-1&&p[b].text===gi&&(w[b]="separator"),p.forEach(($,D)=>{w[D]==="copyright"&&i.push($.text.replace(Xn,"").trim()),o.push({raw:$.raw,kind:w[D]})}),c=c.slice(l[0].length),l=z(c,r),f=!1}let u=o.findIndex(p=>p.kind==="text");if(u===-1)return{foreign:[],copyrights:i};let m=o.map(p=>p.kind).lastIndexOf("text"),h=[],y=[],d=!1;for(let p of o.slice(u,m+1))p.kind==="text"?(h.push(...d?[]:y,p.raw),y=[],d=!1):p.kind==="blank"?y.push(p.raw):d=!0;return{foreign:h,copyrights:i}}s(xi,"splitHeaderText");function wi(e,t,n){let r=t.kind==="html";return t.kind==="line"?e.join(n):[t.blockStart||(r?"<!--":"/**"),...e,t.blockEnd||(r?"-->":" */")].join(n)}s(wi,"renderForeignBlock");function bi(e,t,n){let r=e.split(`
|
|
20
|
-
`),o=n.kind==="html",i=n.kind==="line"?n.linePrefix||"#":(n.blockLinePrefix||(o?" ":" * ")).trimEnd(),a=Math.min(r.length-1,(n.spacing??1)+(n.kind==="line"?0:1)),c=r.length-a;return[...r.slice(0,c),i,...t,...r.slice(c)].join(`
|
|
21
|
-
`)}s(bi,"appendToHeader");function Kn(e){let t=e.trim(),n=t.match(/^copyright\b/i);t=n?t.slice(n[0].length).trimStart():t;for(let c=t.match(/^(?:\(c\)|©)/i);c;c=t.match(/^(?:\(c\)|©)/i))t=t.slice(c[0].length).trimStart();let r=t.match(/^\d{4}(?:\s*[-–,]\s*\d{4})*/);t=r?t.slice(r[0].length):t,t=t.trimEnd();let o=t.toLowerCase(),i=o.endsWith("all rights reserved.")?20:o.endsWith("all rights reserved")?19:0;t=t.slice(0,t.length-i);let a=t.length;for(;a>0&&`.,; \r
|
|
22
|
-
`.includes(t[a-1]);)a-=1;return t.slice(0,a).split(/\s+/).filter(Boolean).join(" ").toLowerCase()}s(Kn,"copyrightHolder");function ki(e,t){let n=e.split(`
|
|
23
|
-
`),r=n.findIndex(c=>c.includes("@Copyright:")),o=n.map(c=>/@[A-Za-z][A-Za-z ]*:/.test(c)).lastIndexOf(!0),i=r!==-1?r:o;if(t.length===0||i===-1)return e;let a=n[i].slice(0,n[i].indexOf("@"));return[...n.slice(0,i+1),...t.map(c=>`${a}@Copyright: ${c}`),...n.slice(i+1)].join(`
|
|
24
|
-
`)}s(ki,"insertCopyrights");function qn(e,t){let n=0,r=z(e,t);for(;r&&r[0].length>0&&Zn(Ge(r[0],t));)n+=r[0].length,r=z(e.slice(n),t);return n}s(qn,"leadingHeadersLength");function me(e,t="",n={}){let r=e.startsWith("\uFEFF")?"\uFEFF":"",o=e.slice(r.length),i=ce(t,o,n),a=U(t,n),c=i.length,l=qn(o.slice(c),a);if(l===0)return e;let f=r===""&&c===0&&o.startsWith("\uFEFF",l);f&&(r="\uFEFF",o=`${o.slice(0,l)}${o.slice(l+1)}`,l+=qn(o.slice(l),a));let u=o.slice(c,c+l),m=o.slice(c+l),h=ce(t,`${i}${m}`,n),y=h.length>i.length?h.slice(i.length):"";if(y===""&&!f)return e;let d=y===""||y.endsWith(`
|
|
25
|
-
`)?y:`${y}${de(e)??`
|
|
26
|
-
`}`;return`${r}${i}${d}${u}${m.slice(y.length)}`}s(me,"restoreTopLines");function pe(e,t="",n={}){let{prefix:r,body:o}=ze(t,e,n),i=o.split(`
|
|
27
|
-
`).slice(0,Vt).join(`
|
|
28
|
-
`),a=U(t,n);if(!z(i,a))return null;let l=0,f=0;for(;;){let u=i.slice(l),m=z(u,a);if(!m||!Zn(Ge(m[0],a)))break;l+=m[0].length,f=l}return f===0?null:{start:r.length,end:r.length+f}}s(pe,"findProjectHeader");function he(e,t,n="",r={}){let o=me(e,n,r),i=pe(o,n,r),a=U(n,r),c=T(r.margin,"margin",le),l=a.kind==="line"?Math.max(1,c):c,f=s((E,S)=>S===`
|
|
29
|
-
`?E:E.replace(/\r?\n/g,S),"withEol");if(!i){let{prefix:E,body:S}=ze(n,o,r),A=de(o)??`
|
|
30
|
-
`,M=f(t,A),V=S.replace(/^(?:\r?\n)+/,""),g=E.replace(/^\uFEFF/,"")!==""&&!E.endsWith(`
|
|
31
|
-
`)?A:"",I=`${E}${g}${V.trim()===""?`${M}${A}`:`${M}${A.repeat(l+1)}${V}`}`;return{nextContent:I,changed:I!==e,header:M,written:M,extraCopyrights:[]}}let u=o.slice(i.start,i.end),{foreign:m,copyrights:h}=xi(u,n,r),y=t.split(`
|
|
32
|
-
`).find(E=>E.includes("@Copyright:")),d=new Set(y===void 0?[]:[Kn(y.slice(y.indexOf("@Copyright:")+11))]),p=[];for(let E of h){let S=Kn(E);d.has(S)||(d.add(S),p.push(E))}let w=de(o.slice(i.end))??de(u)??`
|
|
33
|
-
`,b=w.repeat(l+1),$=r.strictHeaderBlock!==!1,D=ki(t,p),R=f(m.length>0&&!$?bi(D,m,a):D,w),k=m.length>0&&$?wi(m,a,w):"",W=o.slice(i.end).replace(/^(?:\r?\n)+/,""),G=k===""?W:`${k}${W.trim()===""?w:`${b}${W}`}`,Y=`${o.slice(0,i.start)}${G.trim()===""?`${R}${w}`:`${R}${b}${G}`}`,x=`${R}${k===""?"":`${b}${k}`}`;return{nextContent:Y,changed:Y!==e,header:R,written:x,extraCopyrights:p}}s(he,"replaceOrInsertHeader");function Ye(e,t="",n={}){let r=me(e,t,n),o=pe(r,t,n);if(o){let l=r.slice(0,o.start),u=he(r,"",t,{...n,strictHeaderBlock:!0}).nextContent.slice(l.length).replace(/^(?:\r?\n)+/,"");return`${l}${u.trim()===""?"":u}`}let{prefix:i,body:a}=ze(t,r,n),c=a.replace(/^(?:\r?\n)+/,"");return`${i}${c.trim()===""?"":c}`}s(Ye,"extractHeaderlessBody");function Ei(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let l=n-1;l>=0;l-=1)for(let f=r-1;f>=0;f-=1)o[l][f]=e[l]===t[f]?o[l+1][f+1]+1:Math.max(o[l+1][f],o[l][f+1]);let i=[],a=0,c=0;for(;a<n&&c<r;)e[a]===t[c]?(i.push({type:" ",line:e[a]}),a+=1,c+=1):o[a+1][c]>=o[a][c+1]?(i.push({type:"-",line:e[a]}),a+=1):(i.push({type:"+",line:t[c]}),c+=1);for(;a<n;a+=1)i.push({type:"-",line:e[a]});for(;c<r;c+=1)i.push({type:"+",line:t[c]});return i}s(Ei,"diffLines");function Qn(e,t){return`${t===0?e:e+1},${t}`}s(Qn,"formatRange");function er(e,t,n={}){let r=e===null?[]:e.split(`
|
|
34
|
-
`),o=t.split(`
|
|
35
|
-
`),i=Ei(r,o),a=Math.max(0,n.context??3),c=n.lineOffset??0,l=[];if(i.forEach((h,y)=>{if(h.type===" ")return;let d=l[l.length-1];d&&y-d.last<=a*2+1?d.last=y:l.push({first:y,last:y})}),l.length===0)return"";let f=n.fromFile??"a",u=n.toFile??"b",m=[`--- ${e===null?"/dev/null":f}`,`+++ ${u}`];for(let h of l){let y=Math.max(0,h.first-a),d=Math.min(i.length,h.last+a+1),p=i.slice(0,y),w=i.slice(y,d),b=p.filter(k=>k.type!=="+").length+c,$=p.filter(k=>k.type!=="-").length+c,D=w.filter(k=>k.type!=="+").length,R=w.filter(k=>k.type!=="-").length;m.push(`@@ -${Qn(b,D)} +${Qn($,R)} @@`);for(let k of w)m.push(`${k.type}${k.line}`)}return m.join(`
|
|
36
|
-
`)}s(er,"createUnifiedDiff");function Ci(e){return re(e,"configFile")}s(Ci,"resolveRuntimeOptions");function Di(e){if(e==null)return[];let t=Array.isArray(e)?e:[e];if(t.some(n=>typeof n!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(e)}`);return t.filter(n=>n.trim().length>0)}s(Di,"resolveInputs");function vi(e){let t=e.match(/@Author:\s*(.+)$/m),n=e.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:t?.[1]?.trim(),authorEmail:n?.[1]?.trim()}}s(vi,"extractHeaderAuthorIdentity");function Fi(e){let t=e.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:t?.[1]?.trim(),authorEmail:t?.[2]?.trim()}}s(Fi,"extractHeaderLastModifiedIdentity");function Ni(e){let t=e.match(/@Date:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}s(Ni,"extractHeaderCreatedAt");function Li(e){let t=e.match(/@Last modified time:\s*(.+?)\s*\((\d+)\)$/m);if(!t||!t[1]||!t[2])return null;let n=Number.parseInt(t[2],10);return Number.isNaN(n)?null:{date:t[1].trim(),timestamp:n}}s(Li,"extractHeaderLastModifiedAt");async function ji(e,t,n){let r=await jn(t);return r.state!=="tracked"?{edited:r.state==="untracked",state:r.state}:{edited:Ye(r.content,t,n)!==Ye(e,t,n),state:"tracked"}}s(ji,"detectContentEdit");async function nr(e={}){let t=await Ci(e),n=t.timezone===void 0||t.timezone===null?null:Mn(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=Ut(t.forcedDetectors),i=tr(t.projectRoot||t.cwd||process.cwd()),a=await Te({...t,cwd:i});T(t.spacing,"spacing",X),T(t.margin,"margin",le);let c=t.check===!0,l=c||t.dryRun===!0,f=t.fixCreatedDate===!0,u=s(x=>x,"keepDate"),m=t.normalizeDateFormat===!0?Bn:u,h=n?x=>zn(x,n):u,y=r?h:u,d={language:a.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,includeFolders:t.includeFolders,excludeFolders:t.excludeFolders,includeExtensions:t.includeExtensions,gitignore:t.gitignore},p=Di(t.input),w;if(p.length>0){let x=new Set;for(let E of p){let S=tr(i,E),A=await Si(S).catch(()=>null);if(!A)throw new Error(`Input path does not exist: ${E}`);if(A.isFile())x.add(S);else if(A.isDirectory())for(let M of await Le({...d,projectRoot:S}))x.add(M);else throw new Error(`Input path must be a file or directory: ${E}`)}w=Array.from(x)}else w=await Le({...d,projectRoot:i});let b=new Date().getFullYear(),$=[],D=[],R=new Set,k=0,W=0,G=0,Y=[];for(let x of w){let E=Bt(x,{enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o});if(E!==null){D.push({file:Ve(i,x),reason:E});continue}let S=Ve(i,x),A=await $i(x,"utf8"),M={enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides},V=Yt(x,me(A,x,M),M);if(V!==null){D.push({file:S,reason:V});continue}let g=await Te({...t,cwd:i,targetFilePath:x});R.add(`${g.language}:${g.projectRoot}`);let I={language:g.language,enabledDetectors:t.enabledDetectors,disabledDetectors:t.disabledDetectors,forcedDetectors:o,detectorSyntaxOverrides:t.detectorSyntaxOverrides,spacing:t.spacing,margin:t.margin,strictHeaderBlock:t.strictHeaderBlock!==!1},ge=pe(A,x,I),v=ge?A.slice(ge.start,ge.end):"",Ke=v.length>0?vi(v):{},qe=v.length>0?Fi(v):{},cr=v.length>0?Ni(v):null,lr=v.length>0?Li(v):null,Xe=await Jt(x),Ze=Ve(g.projectRoot,x),Qe=await Nn(g.projectRoot,Ze),J=await Ln(g.projectRoot,Ze),et=fe(Xe.createdAt),ye=_n({existing:Be(cr),gitCreated:Qe,filesystemCreated:et,fixCreatedDate:f}),K=Be(lr),tt=ye.source,ur=K?"existing-header":J?"git-last-modified":"filesystem-updated",xe=m(tt==="existing-header"?y(ye.payload):h(ye.payload)),fr=g.copyrightStartYear===null?"created-date":"option",nt=g.copyrightStartYear??Un(xe,n),rt=m(K?y(K):h(J||fe(Xe.updatedAt))),ot=t.forceAuthorUpdate===!0,dr=t.forceLastModifiedAuthorUpdate===!0,it=await ji(A,x,I),st=dr||it.edited,at=s(F=>Yn({absoluteFilePath:x,language:g.language,syntaxOptions:I,projectRoot:g.projectRoot,projectName:g.projectName,createdByName:ot?g.authorName:Ke.authorName||g.authorName,createdByEmail:ot?g.authorEmail:Ke.authorEmail||g.authorEmail,lastModifiedByName:st?g.authorName:qe.authorName||g.authorName,lastModifiedByEmail:st?g.authorEmail:qe.authorEmail||g.authorEmail,authorName:g.authorName,authorEmail:g.authorEmail,createdAt:xe,lastModifiedAt:F,copyrightStartYear:nt,companyName:g.companyName,currentYear:b}),"renderHeader"),ct=at(rt),lt=he(A,ct,x,I),mr=it.edited&&K!==null&&J!==null&&K.timestamp<J.timestamp,te=lt.changed||mr,ut=te?m(h(fe(new Date))):rt,pr=te?"current-time-on-change":ur,hr=te?at(ut):ct,L=te?he(A,hr,x,I):lt,ne={file:S,changed:L.changed};if(c){let F=Wn(v,{gitCreated:Qe,gitLastModified:J,filesystemCreated:et},{strictCreatedDate:t.strictCreatedDate===!0}),q=F.filter(B=>B.advisory).length;ne.dateIssues=F,G+=q,W+=F.length>q?1:0}if(t.sampleOutput===!0&&L.changed){let F=v.length>0?v.trimEnd():null,q=S.replace(/\\/g,"/"),B=L.written,gr=L.nextContent.slice(0,L.nextContent.indexOf(B)).split(`
|
|
37
|
-
`).length-1;ne.sample={previousValue:F,newValue:B,diff:er(F,B,{fromFile:`a/${q}`,toFile:`b/${q}`,lineOffset:gr}),issues:Jn(F,B),detectedValues:{projectName:g.projectName,projectNameSource:g.projectNameSource,language:g.language,projectRoot:g.projectRoot,marker:g.marker,authorName:g.authorName,authorEmail:g.authorEmail,companyName:g.companyName,companyNameSource:g.companyNameSource,copyrightStartYear:nt,copyrightStartYearSource:fr,createdAtSource:tt,lastModifiedAtSource:pr,createdAt:xe,lastModifiedAt:ut}}}if(L.extraCopyrights.length>0){ne.extraCopyrights=L.extraCopyrights;for(let F of L.extraCopyrights)Y.push({file:S,copyright:F})}$.push(ne),L.changed&&(k+=1,l||await Ai(x,L.nextContent,"utf8"))}return{metadata:a,detectedProjects:Array.from(R),filesScanned:w.length-D.length,filesUpdated:k,filesSkipped:D.length,dryRun:l,check:c,...c?{filesWithDateDrift:W,dateAdvisories:G}:{},copyrightWarnings:Y,changes:$,skipped:D}}s(nr,"fixHeaders");function Ri(e){return nr(e)}s(Ri,"fixHeaders");var rr=Ri;var Pi=`fix-headers CLI
|
|
38
|
-
|
|
39
|
-
Usage:
|
|
40
|
-
fix-headers [options]
|
|
41
|
-
|
|
42
|
-
Options:
|
|
43
|
-
-h, --help Show help
|
|
44
|
-
--dry-run Compute changes without writing files
|
|
45
|
-
--check Validate header dates without writing; exit 1 on date drift
|
|
46
|
-
--fix-created-date Move an existing @Date back to the oldest of git first commit / file creation
|
|
47
|
-
--strict-created-date With --check, fail when @Date is later than git first commit / file creation
|
|
48
|
-
--strict-header-block [true|false] Move non-field text found in a header to its own block below it (default: true)
|
|
49
|
-
--no-strict-header-block Keep non-field text found in a header inside it, after the fields
|
|
50
|
-
--normalize-date-format Write every header date in the ISO 8601 T-form (git %aI)
|
|
51
|
-
--timezone <name> Write new dates in an IANA time zone (e.g. America/Los_Angeles, UTC); the instant never changes
|
|
52
|
-
--convert-timezone With --timezone, also rewrite existing @Date/@Last modified time values into that zone
|
|
53
|
-
--json Print JSON output
|
|
54
|
-
--verbose Print updated file paths in summary mode; with --sample-output or --diff, also print each file's field differences
|
|
55
|
-
--sample-output Show previous/new header sample for changed files
|
|
56
|
-
--diff Print a unified diff of each changed file's header (implies sample output)
|
|
57
|
-
--force-author-update Replace an existing @Author/@Email with the detected/current values
|
|
58
|
-
--force-last-modified-author-update Write the detected identity as @Last modified by on every file, edited or not
|
|
59
|
-
--use-gpg-signer-author Use signed-commit UID (%GS) for detected @Author
|
|
60
|
-
--cwd <path> Working directory for project detection
|
|
61
|
-
--input <path> File or folder to process instead of the whole project (repeatable)
|
|
62
|
-
--include-folder <path> Include folder (repeatable)
|
|
63
|
-
--include-folder-non-recursive <path> Include only a folder's own files, not its subfolders (repeatable)
|
|
64
|
-
--exclude-folder <path> Exclude folder name/path (repeatable)
|
|
65
|
-
--include-extension <ext> Include extension (repeatable)
|
|
66
|
-
--enable-detector <id> Enable only specific detector (repeatable)
|
|
67
|
-
--disable-detector <id> Disable detector by id (repeatable)
|
|
68
|
-
--force-detector <id> Use a force-only detector, e.g. markdown (HTML-comment headers in .md files) (repeatable)
|
|
69
|
-
--project-name <name> Override project name
|
|
70
|
-
--language <id> Override language id
|
|
71
|
-
--project-root <path> Override project root
|
|
72
|
-
--marker <name|null> Override marker filename
|
|
73
|
-
--author-name <name> Override author name
|
|
74
|
-
--author-email <email> Override author email
|
|
75
|
-
--company <name> Append company suffix to @Author (Name <Company>)
|
|
76
|
-
--company-name <name> @Copyright holder (default: the project manifest's author; omitted when none)
|
|
77
|
-
--copyright-start-year <year> Set the copyright start year (default: each file's @Date year)
|
|
78
|
-
--spacing <n> Empty comment lines just inside the header's opening and closing (default: 1)
|
|
79
|
-
--margin <n> Blank lines between the header and the file's next content (default: 2)
|
|
80
|
-
--config <path> Load JSON options file; its 'extends' can pull in shared configs (URL, package or path)
|
|
81
|
-
|
|
82
|
-
Examples:
|
|
83
|
-
fix-headers --dry-run --include-folder src
|
|
84
|
-
fix-headers --dry-run --diff --verbose
|
|
85
|
-
fix-headers --check --verbose
|
|
86
|
-
fix-headers --timezone America/Los_Angeles --convert-timezone
|
|
87
|
-
fix-headers --project-name @scope/pkg --company-name "Catalyzed Motivation Inc."
|
|
88
|
-
`;function Oi(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}s(Oi,"toCamelCase");function Ti(e){let t={},n={help:!1,json:!1,diff:!1},r={"include-folder":"includeFolders","exclude-folder":"excludeFolders","include-extension":"includeExtensions","enable-detector":"enabledDetectors","disable-detector":"disabledDetectors","force-detector":"forcedDetectors",input:"input"},o={cwd:"cwd","project-name":"projectName",language:"language","project-root":"projectRoot",marker:"marker","author-name":"authorName","author-email":"authorEmail",company:"company","company-name":"companyName","copyright-start-year":"copyrightStartYear",spacing:"spacing",margin:"margin",timezone:"timezone",config:"config"};for(let i=0;i<e.length;i+=1){let a=e[i];if(a==="-h"||a==="--help"){n.help=!0;continue}if(a==="--json"){n.json=!0;continue}if(a==="--diff"){n.diff=!0;continue}if(a==="--verbose"){t.verbose=!0;continue}if(a==="--dry-run"){t.dryRun=!0;continue}if(a==="--check"){t.check=!0;continue}if(a==="--fix-created-date"){t.fixCreatedDate=!0;continue}if(a==="--strict-created-date"){t.strictCreatedDate=!0;continue}if(a==="--strict-header-block"){let u=e[i+1];(u==="true"||u==="false")&&(i+=1),t.strictHeaderBlock=u!=="false";continue}if(a==="--no-strict-header-block"){t.strictHeaderBlock=!1;continue}if(a==="--normalize-date-format"){t.normalizeDateFormat=!0;continue}if(a==="--convert-timezone"){t.convertTimezone=!0;continue}if(a==="--sample-output"){t.sampleOutput=!0;continue}if(a==="--force-author-update"){t.forceAuthorUpdate=!0;continue}if(a==="--force-last-modified-author-update"){t.forceLastModifiedAuthorUpdate=!0;continue}if(a==="--use-gpg-signer-author"){t.useGpgSignerAuthor=!0;continue}if(!a.startsWith("--"))throw new Error(`Unexpected argument: ${a}`);let c=a.slice(2);if(c==="include-folder-non-recursive"){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=Array.isArray(t.includeFolders)?t.includeFolders:[];t.includeFolders=[...m,{path:u,recursive:!1}];continue}if(r[c]){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=r[c],h=Array.isArray(t[m])?t[m]:[];t[m]=Array.from(new Set([...h,u]));continue}if(o[c]){let u=e[i+1];if(!u||u.startsWith("--"))throw new Error(`Missing value for --${c}`);i+=1;let m=o[c];if(m==="copyrightStartYear"||m==="spacing"||m==="margin"){if(t[m]=Number.parseInt(u,10),Number.isNaN(t[m]))throw new Error(`Invalid number for --${c}: ${u}`)}else m==="marker"&&u==="null"?t[m]=null:t[m]=u;continue}let l=Oi(c),f=e[i+1];if(!f||f.startsWith("--"))throw new Error(`Unknown or malformed flag: --${c}`);i+=1,t[l]=f}return{options:t,help:n.help,json:n.json,diff:n.diff}}s(Ti,"parseCliArgs");function Hi(e){return re(e,"config")}s(Hi,"applyConfigFile");function Je(e){if(!e||typeof e!="object")return[];let t=e;return(Array.isArray(t.changes)?t.changes:[]).filter(r=>r&&r.changed===!0&&r.sample&&typeof r.sample.newValue=="string")}s(Je,"getSampledChanges");function ir(e){return typeof e=="string"?`"${e}"`:"(missing)"}s(ir,"formatIssueValue");function _i(e,t){for(let n of Je(t)){let r=Array.isArray(n.sample.issues)?n.sample.issues:[];if(e(`issues: ${n.file||"<unknown-file>"}`),r.length===0){e(" (no field differences; header formatting only)");continue}for(let o of r)e(` ${o?.field||"<unknown-field>"}: found ${ir(o?.previous)}, expected ${ir(o?.detected)}`)}}s(_i,"printIssues");function Ui(e,t){for(let n of Je(t))typeof n.sample.diff=="string"&&n.sample.diff.length>0&&e(n.sample.diff)}s(Ui,"printDiffs");function Wi(e,t){for(let n of Je(t))e(`sample: ${n.file||"<unknown-file>"}`),e("previous:"),e(n.sample.previousValue===null?"(none)":String(n.sample.previousValue)),e("new:"),e(n.sample.newValue),n.sample.detectedValues&&typeof n.sample.detectedValues=="object"&&(e("detected-values:"),e(JSON.stringify(n.sample.detectedValues,null,2)))}s(Wi,"printSampleOutput");function Bi(e,t){if(!t||typeof t!="object")return;let n=t,o=(Array.isArray(n.changes)?n.changes:[]).filter(i=>i&&i.changed===!0).map(i=>i.file||"<unknown-file>");for(let i of o)e(`updated: ${i}`)}s(Bi,"printChangedFiles");function sr(e,t){let n=Array.isArray(t.copyrightWarnings)?t.copyrightWarnings:[];for(let r of n)e(`warning: ${r?.file||"<unknown-file>"} keeps an additional @Copyright: ${r?.copyright??""}`)}s(sr,"printCopyrightWarnings");function zi(e,t){let n=Array.isArray(t.skipped)?t.skipped:[];for(let r of n)e(`skipped: ${r?.file||"<unknown-file>"} (${r?.reason||"no reason given"})`)}s(zi,"printSkipped");function ar(e,t,n,r){let o=n.sampleOutput===!0||r;n.verbose===!0&&(Bi(e,t),o&&_i(e,t)),n.sampleOutput===!0&&Wi(e,t),r&&Ui(e,t)}s(ar,"printDetails");function Gi(e,t,n){let r=Array.isArray(t.changes)?t.changes:[];for(let o of r){let i=Array.isArray(o?.dateIssues)?o.dateIssues:[];for(let a of i)a.advisory===!0&&!n||e(`${a.advisory===!0?"advisory":"drift"}: ${o.file||"<unknown-file>"}: ${a.message}`)}}s(Gi,"printDateIssues");async function Yi(e,t={}){let n=t.runner||rr,r=t.stdout||console.log,o=t.stderr||console.error;try{let i=Ti(e);if(i.help)return r(Pi),0;let a=await Hi(i.options),c=await n(i.diff?{...a,sampleOutput:!0}:a),l=c&&typeof c=="object"&&c.check===!0?c:null,f=l&&Number(l.filesWithDateDrift)>0?1:0;if(i.json)return r(JSON.stringify(c,null,2)),f;if(l)return r(`fix-headers check: scanned=${l.filesScanned??0}, drift=${l.filesWithDateDrift??0}, advisories=${l.dateAdvisories??0}`),Gi(r,l,a.verbose===!0),sr(r,c),f;if(c&&typeof c=="object"){let u=c,m=Number(u.filesSkipped)>0?`, skipped=${u.filesSkipped}`:"",h=Array.isArray(u.copyrightWarnings)&&u.copyrightWarnings.length>0?`, warnings=${u.copyrightWarnings.length}`:"";r(`fix-headers complete: scanned=${u.filesScanned??0}, updated=${u.filesUpdated??0}${m}${h}, dryRun=${u.dryRun===!0}`),zi(r,u),sr(r,u),ar(r,c,a,i.diff)}else ar(r,c,a,i.diff),r("fix-headers complete");return 0}catch(i){let a=i instanceof Error?i.message:String(i);return o(`fix-headers failed: ${a}`),1}}s(Yi,"runCli");function Vi(e=process.argv,t=import.meta.url,n=Yi){let r=!1;if(e[1])try{let o=or(e[1]),i=or(Mi(t));r=o===i}catch{r=t===Ii(e[1]).href}return r?(n(e.slice(2)).then(o=>{process.exitCode=o}),!0):!1}s(Vi,"runCliAsMain");Vi();export{Hi as applyConfigFile,Ti as parseCliArgs,Yi as runCli,Vi as runCliAsMain};
|
|
89
|
-
//# sourceMappingURL=fix-headers.mjs.map
|