@cldmv/fix-headers 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/cli.mjs +57 -0
- package/dist/config/load.mjs +2 -0
- package/dist/constants.mjs +2 -0
- package/dist/core/declaration-sources.mjs +4 -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 +16 -16
- 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 +9 -12
- package/types/src/cli.d.mts +15 -0
- package/types/src/config/load.d.mts +15 -0
- package/types/src/constants.d.mts +15 -0
- package/types/src/core/declaration-sources.d.mts +58 -0
- package/types/src/core/file-discovery.d.mts +15 -0
- package/types/src/core/fix-headers.d.mts +16 -0
- package/types/src/core/ignore-rules.d.mts +15 -0
- package/types/src/detect/project.d.mts +15 -0
- package/types/src/detectors/c.d.mts +15 -0
- package/types/src/detectors/css.d.mts +15 -0
- package/types/src/detectors/go.d.mts +15 -0
- package/types/src/detectors/html.d.mts +15 -0
- package/types/src/detectors/index.d.mts +15 -0
- package/types/src/detectors/json.d.mts +15 -0
- package/types/src/detectors/markdown.d.mts +15 -0
- package/types/src/detectors/node.d.mts +15 -0
- package/types/src/detectors/php.d.mts +15 -0
- package/types/src/detectors/python.d.mts +15 -0
- package/types/src/detectors/rust.d.mts +15 -0
- package/types/src/detectors/top-lines.d.mts +15 -0
- package/types/src/detectors/yaml.d.mts +15 -0
- package/types/src/drivers/go.d.mts +15 -0
- package/types/src/drivers/index.d.mts +15 -0
- package/types/src/drivers/node.d.mts +15 -0
- package/types/src/drivers/php.d.mts +15 -0
- package/types/src/drivers/python.d.mts +15 -0
- package/types/src/drivers/rust.d.mts +15 -0
- package/types/src/drivers/shared.d.mts +15 -0
- package/types/src/header/dates.d.mts +15 -0
- package/types/src/header/fields.d.mts +15 -0
- package/types/src/header/parser.d.mts +15 -0
- package/types/src/header/syntax.d.mts +15 -0
- package/types/src/header/template.d.mts +15 -0
- package/types/src/index.d.mts +15 -0
- package/types/src/utils/diff.d.mts +2 -1
- package/types/src/utils/fs.d.mts +15 -0
- package/types/src/utils/git.d.mts +15 -0
- package/types/src/utils/text.d.mts +2 -1
- package/types/src/utils/time.d.mts +2 -1
- package/bin/fix-headers.mjs +0 -91
- package/types/devcheck.d.mts +0 -1
- package/types/index.d.mts +0 -2
package/README.md
CHANGED
|
@@ -14,17 +14,19 @@ 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.6.0 (November 2026)
|
|
18
18
|
|
|
19
|
-
- **
|
|
20
|
-
-
|
|
19
|
+
- **Headerless declarations take their source's header** — a `.d.ts` / `.d.mts` / `.d.cts` that `tsc` emitted without a header gets its source's `@Date`, `@Author` and `@Last modified` values, found through the tsconfig the declarations were built with (new `tsconfig` option, `--tsconfig`), so rebuilding them no longer stamps the build time; `@Filename` still names the declaration (fixes [#214](https://github.com/CLDMV/fix-headers/issues/214)).
|
|
20
|
+
- **Generic CommonJS shim** — `src/index.cjs` is the standard CLDMV drop-in shim; `require("@cldmv/fix-headers")` still returns the `fixHeaders` function ([#212](https://github.com/CLDMV/fix-headers/pull/212), fixes [#209](https://github.com/CLDMV/fix-headers/issues/209)).
|
|
21
|
+
- **Generated declarations** — `types/` is built and header-stamped at build and pack time instead of being committed; the package's `types` entry is now `types/src/index.d.mts` ([#215](https://github.com/CLDMV/fix-headers/pull/215), fixes [#211](https://github.com/CLDMV/fix-headers/issues/211)).
|
|
22
|
+
- [View full v2.6.0 Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.6.0.md)
|
|
21
23
|
|
|
22
24
|
### Recent Releases
|
|
23
25
|
|
|
26
|
+
- **v2.5.1** (November 2026) — `dist/` is built one file per module instead of a bundle, and the CLI (`dist/cli.mjs`) imports the library; `bin/` is no longer published ([Changelog](https://github.com/CLDMV/fix-headers/blob/master/docs/changelog/v2/v2.5.1.md))
|
|
27
|
+
- **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))
|
|
24
28
|
- **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
29
|
- **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
|
-
- **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
30
|
|
|
29
31
|
📚 For complete release notes, see the [docs/changelog/](https://github.com/CLDMV/fix-headers/tree/master/docs/changelog/) folder.
|
|
30
32
|
|
|
@@ -118,6 +120,7 @@ Common CLI options:
|
|
|
118
120
|
- `--fix-created-date`
|
|
119
121
|
- `--strict-created-date`
|
|
120
122
|
- `--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
|
|
123
|
+
- `--tsconfig <path>` - set `tsconfig`
|
|
121
124
|
- `--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
125
|
- `--normalize-date-format`
|
|
123
126
|
- `--timezone <name>` - write new header dates in an IANA time zone (see [Time zone](#-time-zone))
|
|
@@ -161,6 +164,7 @@ Important options:
|
|
|
161
164
|
- `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
165
|
- `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
166
|
- `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/`
|
|
167
|
+
- `tsconfig?: string` - the tsconfig the declarations were built with, relative to `cwd`, used to find the source of a declaration `tsc` emitted without a header (see the skip rules below). Default: `.configs/tsconfig.json`, then `tsconfig.json`; a default that is missing or can't be read is ignored
|
|
164
168
|
- `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)
|
|
165
169
|
- `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`)
|
|
166
170
|
- `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)
|
|
@@ -580,7 +584,8 @@ Every other file is skipped and left byte-for-byte unchanged, including when you
|
|
|
580
584
|
- **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.
|
|
581
585
|
- **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)).
|
|
582
586
|
- **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`.
|
|
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
|
|
587
|
+
- **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 whose header names any other file is fixed as usual either way.
|
|
588
|
+
- **A declaration `tsc` emitted without a header** takes its source's header instead of being stamped as new. `tsc` drops the source's leading comment when `import` lines follow it, so most declarations arrive with no header. fix-headers finds the source through the tsconfig the declarations were built with (`tsconfig`, following `extends`): the declaration's path inside `declarationDir` (else `outDir`), under `rootDir` (else the tsconfig's folder), with the first matching source extension. `types/src/x.d.mts` built with `rootDir: ".."` and `outDir: "../types"` in `.configs/tsconfig.json` comes from `src/x.mts` or `src/x.mjs`. The header names the declaration (`@Filename: types/src/x.d.mts`) and takes `@Date`, `@Author`, `@Last modified by` and `@Last modified time` from the source's header, so rebuilding the declarations doesn't change them. Without a tsconfig, a source, or a header on the source, or with `rewriteDeclarationCopies: false`, the declaration is stamped like any new file. A declaration whose header names any other file is fixed as usual.
|
|
584
589
|
- **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.
|
|
585
590
|
|
|
586
591
|
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,57 @@
|
|
|
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
|
+
--tsconfig <path> tsconfig the declarations were built with, to find a headerless declaration's source (default: .configs/tsconfig.json, then tsconfig.json)
|
|
16
|
+
--strict-header-block [true|false] Move non-field text found in a header to its own block below it (default: true)
|
|
17
|
+
--no-strict-header-block Keep non-field text found in a header inside it, after the fields
|
|
18
|
+
--normalize-date-format Write every header date in the ISO 8601 T-form (git %aI)
|
|
19
|
+
--timezone <name> Write new dates in an IANA time zone (e.g. America/Los_Angeles, UTC); the instant never changes
|
|
20
|
+
--convert-timezone With --timezone, also rewrite existing @Date/@Last modified time values into that zone
|
|
21
|
+
--json Print JSON output
|
|
22
|
+
--verbose Print updated file paths in summary mode; with --sample-output or --diff, also print each file's field differences
|
|
23
|
+
--sample-output Show previous/new header sample for changed files
|
|
24
|
+
--diff Print a unified diff of each changed file's header (implies sample output)
|
|
25
|
+
--force-author-update Replace an existing @Author/@Email with the detected/current values
|
|
26
|
+
--force-last-modified-author-update Write the detected identity as @Last modified by on every file, edited or not
|
|
27
|
+
--use-gpg-signer-author Use signed-commit UID (%GS) for detected @Author
|
|
28
|
+
--cwd <path> Working directory for project detection
|
|
29
|
+
--input <path> File or folder to process instead of the whole project (repeatable)
|
|
30
|
+
--include-folder <path> Include folder (repeatable)
|
|
31
|
+
--include-folder-non-recursive <path> Include only a folder's own files, not its subfolders (repeatable)
|
|
32
|
+
--exclude-folder <path> Exclude folder name/path (repeatable)
|
|
33
|
+
--include-extension <ext> Include extension (repeatable)
|
|
34
|
+
--enable-detector <id> Enable only specific detector (repeatable)
|
|
35
|
+
--disable-detector <id> Disable detector by id (repeatable)
|
|
36
|
+
--force-detector <id> Use a force-only detector, e.g. markdown (HTML-comment headers in .md files) (repeatable)
|
|
37
|
+
--project-name <name> Override project name
|
|
38
|
+
--language <id> Override language id
|
|
39
|
+
--project-root <path> Override project root
|
|
40
|
+
--marker <name|null> Override marker filename
|
|
41
|
+
--author-name <name> Override author name
|
|
42
|
+
--author-email <email> Override author email
|
|
43
|
+
--company <name> Append company suffix to @Author (Name <Company>)
|
|
44
|
+
--company-name <name> @Copyright holder (default: the project manifest's author; omitted when none)
|
|
45
|
+
--copyright-start-year <year> Set the copyright start year (default: each file's @Date year)
|
|
46
|
+
--spacing <n> Empty comment lines just inside the header's opening and closing (default: 1)
|
|
47
|
+
--margin <n> Blank lines between the header and the file's next content (default: 2)
|
|
48
|
+
--config <path> Load JSON options file; its 'extends' can pull in shared configs (URL, package or path)
|
|
49
|
+
|
|
50
|
+
Examples:
|
|
51
|
+
fix-headers --dry-run --include-folder src
|
|
52
|
+
fix-headers --dry-run --diff --verbose
|
|
53
|
+
fix-headers --check --verbose
|
|
54
|
+
fix-headers --timezone America/Los_Angeles --convert-timezone
|
|
55
|
+
fix-headers --project-name @scope/pkg --company-name "Catalyzed Motivation Inc."
|
|
56
|
+
`;function j(t){return t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}l(j,"toCamelCase");function C(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",tsconfig:"tsconfig",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=j(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(C,"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=C(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,C as parseCliArgs,N as runCli,U as runCliAsMain};
|
|
57
|
+
//# 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,4 @@
|
|
|
1
|
+
var p=Object.defineProperty;var l=(n,t)=>p(n,"name",{value:t,configurable:!0});import{readFile as w,stat as y}from"node:fs/promises";import{createRequire as h}from"node:module";import{basename as x,dirname as a,isAbsolute as m,join as g,relative as j,resolve as u,sep as E}from"node:path";const S=/^(.+)\.d\.(ts|mts|cts)$/i,$={ts:[".ts",".tsx",".js",".jsx"],mts:[".mts",".mjs"],cts:[".cts",".cjs"]},A=[".configs/tsconfig.json","tsconfig.json"];function L(n){let t="",i=!1;for(let o=0;o<n.length;o+=1){const r=n[o],e=n[o+1];if(i){t+=r,r==="\\"?(t+=e??"",o+=1):r==='"'&&(i=!1);continue}if(r==='"')i=!0,t+=r;else if(r==="/"&&e==="/"){for(;o<n.length&&n[o]!==`
|
|
2
|
+
`;)o+=1;t+=`
|
|
3
|
+
`}else if(r==="/"&&e==="*"){const s=n.indexOf("*/",o+2);o=s===-1?n.length:s+1}else if(r==="}"||r==="]"){const s=t.trimEnd();t=(s.endsWith(",")?s.slice(0,-1):t)+r}else t+=r}return JSON.parse(t)}l(L,"parseJsonc");function O(n,t){if(n.startsWith(".")||m(n)){const i=u(a(t),n);return i.endsWith(".json")?i:`${i}.json`}return h(t).resolve(n)}l(O,"resolveExtends");async function f(n,t=new Set){if(t.has(n))throw new Error(`tsconfig extends itself: ${n}`);t.add(n);const i=L(await w(n,"utf8"));let o={rootDir:null,outDir:null,declarationDir:null,configDir:a(n)};const r=i.extends===void 0?[]:Array.isArray(i.extends)?i.extends:[i.extends];for(const s of r){const c=await f(O(s,n),t);o={rootDir:c.rootDir??o.rootDir,outDir:c.outDir??o.outDir,declarationDir:c.declarationDir??o.declarationDir,configDir:o.configDir}}const e=i.compilerOptions??{};for(const s of["rootDir","outDir","declarationDir"])typeof e[s]=="string"&&(o[s]=u(a(n),e[s]));return o}l(f,"readDeclarationLayout");async function d(n){const t=await y(n).catch(()=>null);return t!==null&&t.isFile()}l(d,"isFile");async function F(n,t){const i=S.exec(x(n)),o=t.declarationDir??t.outDir;if(!i||o===null)return null;const r=j(o,n);if(r===".."||r.startsWith(`..${E}`)||m(r))return null;const[,e,s]=i,c=g(t.rootDir??t.configDir,a(r),e);for(const D of $[s.toLowerCase()])if(await d(`${c}${D}`))return`${c}${D}`;return null}l(F,"findDeclarationSource");function R({scanRoot:n,tsconfig:t=null}){let i=null;const o=l(async()=>{if(typeof t=="string"&&t.length>0){const r=u(n,t);if(!await d(r))throw new Error(`tsconfig not found: ${t}`);return f(r)}for(const r of A){const e=u(n,r);if(await d(e))return f(e).catch(()=>null)}return null},"loadLayout");return async r=>{i??=o();const e=await i;return e===null?null:F(r,e)}}l(R,"createDeclarationSourceResolver");export{R as createDeclarationSourceResolver,F as findDeclarationSource,L as parseJsonc,f as readDeclarationLayout};
|
|
4
|
+
//# sourceMappingURL=declaration-sources.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 $e=Object.defineProperty;var n=(o,e)=>$e(o,"name",{value:e,configurable:!0});import{readFile as ye,stat as Ue,writeFile as Te}from"node:fs/promises";import{relative as I,resolve as De}from"node:path";import{applyConfigOption as Be}from"../config/load.mjs";import{DEFAULT_HEADER_MARGIN as Ye,DEFAULT_HEADER_SPACING as Ge,resolveLayoutCount as we}from"../constants.mjs";import{discoverFiles as Ne}from"./file-discovery.mjs";import{getContentSkipReason as Ze,getHeaderSkipReason as _e,resolveForcedDetectors as Ve}from"../detectors/index.mjs";import{declarationCopySkipReason as We,isDeclarationFile as xe}from"../detectors/node.mjs";import{createDeclarationSourceResolver as qe}from"./declaration-sources.mjs";import{resolveProjectMetadata as Ae}from"../detect/project.mjs";import{checkHeaderDates as Je,convertDatePayload as Ke,dateYear as Qe,normalizeDatePayload as Xe,repairDateEpoch as Ce,resolveCreatedDate as et}from"../header/dates.mjs";import{buildHeader as tt}from"../header/template.mjs";import{compareHeaderFields as ot}from"../header/fields.mjs";import{extractHeaderlessBody as Ee,findProjectHeader as Se,replaceOrInsertHeader as ve,restoreTopLines as at}from"../header/parser.mjs";import{createUnifiedDiff as rt}from"../utils/diff.mjs";import{readFileDates as nt}from"../utils/fs.mjs";import{getGitCreationDate as it,getGitLastModifiedDate as st,readGitHeadFile as ct}from"../utils/git.mjs";import{assertTimeZone as dt,toDatePayload as O}from"../utils/time.mjs";function lt(o){return Be(o,"configFile")}n(lt,"resolveRuntimeOptions");function mt(o){if(o==null)return[];const e=Array.isArray(o)?o:[o];if(e.some(r=>typeof r!="string"))throw new Error(`input must be a path or an array of paths, got ${JSON.stringify(o)}`);return e.filter(r=>r.trim().length>0)}n(mt,"resolveInputs");function ut(o){const e=o.match(/@Author:\s*(.+)$/m),r=o.match(/@Email:\s*<([^>\n]+)>/m);return{authorName:e?.[1]?.trim(),authorEmail:r?.[1]?.trim()}}n(ut,"extractHeaderAuthorIdentity");function ft(o){const e=o.match(/@Last modified by:\s*(.+?)\s*\(([^)\n]+)\)\s*$/m);return{authorName:e?.[1]?.trim(),authorEmail:e?.[2]?.trim()}}n(ft,"extractHeaderLastModifiedIdentity");function pt(o){const e=o.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}}n(pt,"extractHeaderCreatedAt");function ht(o){const e=o.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}}n(ht,"extractHeaderLastModifiedAt");async function gt(o,e){if(o===null)return"";const r=await ye(o,"utf8"),i=Se(r,o,e);return i?r.slice(i.start,i.end):""}n(gt,"readSourceHeader");async function yt(o,e,r){const i=await ct(e);return i.state!=="tracked"?{edited:i.state==="untracked",state:i.state}:{edited:Ee(i.content,e,r)!==Ee(o,e,r),state:"tracked"}}n(yt,"detectContentEdit");async function zt(o={}){const e=await lt(o),r=e.timezone===void 0||e.timezone===null?null:dt(e.timezone),i=e.convertTimezone===!0;if(i&&!r)throw new Error("convertTimezone requires timezone: set timezone (CLI --timezone <name>) to the IANA zone to convert header dates into");const D=Ve(e.forcedDetectors),u=De(e.projectRoot||e.cwd||process.cwd()),z=await Ae({...e,cwd:u});we(e.spacing,"spacing",Ge),we(e.margin,"margin",Ye);const A=e.check===!0,P=A||e.dryRun===!0,Re=e.fixCreatedDate===!0,R=e.rewriteDeclarationCopies!==!1,b=n(a=>a,"keepDate"),M=e.normalizeDateFormat===!0?Xe:b,C=r?a=>Ke(a,r):b,$=i?C:b,U={language:z.language,enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:D,includeFolders:e.includeFolders,excludeFolders:e.excludeFolders,includeExtensions:e.includeExtensions,gitignore:e.gitignore},T=mt(e.input),be=qe({scanRoot:u,tsconfig:e.tsconfig});let E;if(T.length>0){const a=new Set;for(const f of T){const l=De(u,f),c=await Ue(l).catch(()=>null);if(!c)throw new Error(`Input path does not exist: ${f}`);if(c.isFile())a.add(l);else if(c.isDirectory())for(const S of await Ne({...U,projectRoot:l}))a.add(S);else throw new Error(`Input path must be a file or directory: ${f}`)}E=Array.from(a)}else E=await Ne({...U,projectRoot:u});const Me=new Date().getFullYear(),B=[],w=[],Y=new Set;let G=0,Z=0,_=0;const V=[];for(const a of E){const f=_e(a,{enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:D});if(f!==null){w.push({file:I(u,a),reason:f});continue}const l=I(u,a),c=await ye(a,"utf8"),S={enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:D,detectorSyntaxOverrides:e.detectorSyntaxOverrides},W=at(c,a,S),H=R&&We(W,a)!==null,q=H?null:Ze(a,W,S);if(q!==null){w.push({file:l,reason:q});continue}const t=await Ae({...e,cwd:u,targetFilePath:a});Y.add(`${t.language}:${t.projectRoot}`);const p={language:t.language,enabledDetectors:e.enabledDetectors,disabledDetectors:e.disabledDetectors,forcedDetectors:D,detectorSyntaxOverrides:e.detectorSyntaxOverrides,spacing:e.spacing,margin:e.margin,strictHeaderBlock:e.strictHeaderBlock!==!1},F=Se(c,a,p),h=F?c.slice(F.start,F.end):"",J=R&&h.length===0&&xe(a)?await gt(await be(a),p):"",m=h||J,K=m.length>0?ut(m):{},Q=m.length>0?ft(m):{},He=m.length>0?pt(m):null,Fe=m.length>0?ht(m):null,X=await nt(a),ee=I(t.projectRoot,a),te=await it(t.projectRoot,ee),N=await st(t.projectRoot,ee),oe=O(X.createdAt),L=et({existing:Ce(He),gitCreated:te,filesystemCreated:oe,fixCreatedDate:Re}),g=Ce(Fe),ae=L.source,Le=g?"existing-header":N?"git-last-modified":"filesystem-updated",j=M(ae==="existing-header"?$(L.payload):C(L.payload)),je=t.copyrightStartYear===null?"created-date":"option",re=t.copyrightStartYear??Qe(j,r),ne=M(g?$(g):C(N||O(X.updatedAt))),ie=e.forceAuthorUpdate===!0,ke=e.forceLastModifiedAuthorUpdate===!0,se=J.length>0,ce=H||se?null:await yt(c,a,p),de=H||se||R&&ce?.state==="untracked"&&h.length>0&&xe(a),le=de?{edited:!1,state:"no-git"}:ce,me=ke||le.edited,ue=n(s=>tt({absoluteFilePath:a,language:t.language,syntaxOptions:p,projectRoot:t.projectRoot,projectName:t.projectName,createdByName:ie?t.authorName:K.authorName||t.authorName,createdByEmail:ie?t.authorEmail:K.authorEmail||t.authorEmail,lastModifiedByName:me?t.authorName:Q.authorName||t.authorName,lastModifiedByEmail:me?t.authorEmail:Q.authorEmail||t.authorEmail,authorName:t.authorName,authorEmail:t.authorEmail,createdAt:j,lastModifiedAt:s,copyrightStartYear:re,companyName:t.companyName,currentYear:Me}),"renderHeader"),fe=ue(ne),pe=ve(c,fe,a,p),Ie=le.edited&&g!==null&&N!==null&&g.timestamp<N.timestamp,he=pe.changed||Ie,k=he&&!(de&&g!==null),ge=k?M(C(O(new Date))):ne,Oe=k?"current-time-on-change":Le,ze=k?ue(ge):fe,d=he?ve(c,ze,a,p):pe,v={file:l,changed:d.changed};if(A){const s=Je(h,{gitCreated:te,gitLastModified:N,filesystemCreated:oe},{strictCreatedDate:e.strictCreatedDate===!0}),x=s.filter(y=>y.advisory).length;v.dateIssues=s,_+=x,Z+=s.length>x?1:0}if(e.sampleOutput===!0&&d.changed){const s=h.length>0?h.trimEnd():null,x=l.replace(/\\/g,"/"),y=d.written,Pe=d.nextContent.slice(0,d.nextContent.indexOf(y)).split(`
|
|
2
|
+
`).length-1;v.sample={previousValue:s,newValue:y,diff:rt(s,y,{fromFile:`a/${x}`,toFile:`b/${x}`,lineOffset:Pe}),issues:ot(s,y),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:re,copyrightStartYearSource:je,createdAtSource:ae,lastModifiedAtSource:Oe,createdAt:j,lastModifiedAt:ge}}}if(d.extraCopyrights.length>0){v.extraCopyrights=d.extraCopyrights;for(const s of d.extraCopyrights)V.push({file:l,copyright:s})}B.push(v),d.changed&&(G+=1,P||await Te(a,d.nextContent,"utf8"))}return{metadata:z,detectedProjects:Array.from(Y),filesScanned:E.length-w.length,filesUpdated:G,filesSkipped:w.length,dryRun:P,check:A,...A?{filesWithDateDrift:Z,dateAdvisories:_}:{},copyrightWarnings:V,changes:B,skipped:w}}n(zt,"fixHeaders");export{zt 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,28 +7,20 @@
|
|
|
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-27T12:16:43-08:00 (1795810603)
|
|
11
11
|
* -----
|
|
12
12
|
* @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @fileoverview CommonJS entry point
|
|
17
|
+
* @fileoverview CommonJS entry point: the generic CLDMV drop-in shim
|
|
18
|
+
* (CLDMV/.github docs/conventions/package-layout.md).
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Node.js versions without require(esm) (20.x before 20.19, 22.x before 22.12, and
|
|
25
|
-
* anything older) would fail with a bare ERR_REQUIRE_ESM, so the check below fails
|
|
26
|
-
* early with a message that says what to do instead.
|
|
27
|
-
*
|
|
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. tsup's `onSuccess` copies
|
|
30
|
-
* it verbatim into dist/ (tsup.config.mjs); it never passes through esbuild, so it stays
|
|
31
|
-
* this small however much the library grows.
|
|
20
|
+
* It returns what `import` gives: the single distinct exported value when there is one
|
|
21
|
+
* (here `fixHeaders`, which is also the default export), so `require("@cldmv/fix-headers")`
|
|
22
|
+
* is the function itself; otherwise the module object. scripts/build.mjs copies it
|
|
23
|
+
* verbatim into dist/, where `./index.mjs` resolves to the built entry.
|
|
32
24
|
* @module fix-headers/cjs-entry
|
|
33
25
|
*/
|
|
34
26
|
"use strict";
|
|
@@ -41,4 +33,12 @@ if (!process.features?.require_module) {
|
|
|
41
33
|
throw error;
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
// Same exports as `import`. One distinct exported value (aliases of it count once) comes back as that value,
|
|
37
|
+
// so require(x)(...) works; anything else comes back as the module object ({ default, ...named }).
|
|
38
|
+
const esm = require("./index.mjs");
|
|
39
|
+
const values = new Set(
|
|
40
|
+
Object.keys(esm)
|
|
41
|
+
.filter((key) => key !== "__esModule")
|
|
42
|
+
.map((key) => esm[key])
|
|
43
|
+
);
|
|
44
|
+
module.exports = values.size === 1 ? values.values().next().value : esm;
|