@cldmv/fix-headers 1.0.0 → 1.1.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.
@@ -4,52 +4,23 @@
4
4
  */
5
5
  /**
6
6
  * Fixes headers in a project using auto-detected metadata unless overridden.
7
- * @param {{
8
- * cwd?: string,
9
- * input?: string,
10
- * dryRun?: boolean,
11
- * configFile?: string,
12
- * enabledDetectors?: string[],
13
- * disabledDetectors?: string[],
14
- * detectorSyntaxOverrides?: Record<string, { linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }>,
15
- * includeFolders?: string[],
16
- * excludeFolders?: string[],
17
- * includeExtensions?: string[],
18
- * projectName?: string,
19
- * language?: string,
20
- * projectRoot?: string,
21
- * marker?: string | null,
22
- * authorName?: string,
23
- * authorEmail?: string,
24
- * companyName?: string,
25
- * copyrightStartYear?: number
26
- * }} [options={}] - Runtime options.
27
- * @returns {Promise<{
28
- * metadata: {
29
- * projectName: string,
30
- * language: string,
31
- * projectRoot: string,
32
- * marker: string | null,
33
- * authorName: string,
34
- * authorEmail: string,
35
- * companyName: string,
36
- * copyrightStartYear: number
37
- * },
38
- * filesScanned: number,
39
- * filesUpdated: number,
40
- * dryRun: boolean,
41
- * changes: Array<{file: string, changed: boolean}>
42
- * }>} Process report.
7
+ * @param {FixHeadersOptions} [options={}] - Runtime options.
8
+ * @returns {Promise<FixHeadersResult>} Process report.
43
9
  */
44
- export function fixHeaders(options?: {
10
+ export function fixHeaders(options?: FixHeadersOptions): Promise<FixHeadersResult>;
11
+ export type FixHeadersOptions = {
45
12
  cwd?: string;
46
13
  input?: string;
47
14
  dryRun?: boolean;
48
15
  configFile?: string;
16
+ sampleOutput?: boolean;
17
+ forceAuthorUpdate?: boolean;
18
+ useGpgSignerAuthor?: boolean;
49
19
  enabledDetectors?: string[];
50
20
  disabledDetectors?: string[];
51
21
  detectorSyntaxOverrides?: Record<string, {
52
22
  linePrefix?: string;
23
+ lineSeparator?: string;
53
24
  blockStart?: string;
54
25
  blockLinePrefix?: string;
55
26
  blockEnd?: string;
@@ -65,7 +36,8 @@ export function fixHeaders(options?: {
65
36
  authorEmail?: string;
66
37
  companyName?: string;
67
38
  copyrightStartYear?: number;
68
- }): Promise<{
39
+ };
40
+ export type FixHeadersResult = {
69
41
  metadata: {
70
42
  projectName: string;
71
43
  language: string;
@@ -76,11 +48,36 @@ export function fixHeaders(options?: {
76
48
  companyName: string;
77
49
  copyrightStartYear: number;
78
50
  };
51
+ detectedProjects: string[];
79
52
  filesScanned: number;
80
53
  filesUpdated: number;
81
54
  dryRun: boolean;
82
55
  changes: Array<{
83
56
  file: string;
84
57
  changed: boolean;
58
+ sample?: {
59
+ previousValue: string | null;
60
+ newValue: string;
61
+ detectedValues?: {
62
+ projectName: string;
63
+ language: string;
64
+ projectRoot: string;
65
+ marker: string | null;
66
+ authorName: string;
67
+ authorEmail: string;
68
+ companyName: string;
69
+ copyrightStartYear: number;
70
+ createdAtSource: string;
71
+ lastModifiedAtSource: string;
72
+ createdAt: {
73
+ date: string;
74
+ timestamp: number;
75
+ };
76
+ lastModifiedAt: {
77
+ date: string;
78
+ timestamp: number;
79
+ };
80
+ };
81
+ };
85
82
  }>;
86
- }>;
83
+ };
@@ -40,6 +40,7 @@ export function detectProjectFromMarkers(cwd: string, options?: {
40
40
  * language?: string,
41
41
  * projectRoot?: string,
42
42
  * marker?: string | null,
43
+ * useGpgSignerAuthor?: boolean,
43
44
  * authorName?: string,
44
45
  * authorEmail?: string,
45
46
  * companyName?: string,
@@ -65,6 +66,7 @@ export function resolveProjectMetadata(options?: {
65
66
  language?: string;
66
67
  projectRoot?: string;
67
68
  marker?: string | null;
69
+ useGpgSignerAuthor?: boolean;
68
70
  authorName?: string;
69
71
  authorEmail?: string;
70
72
  companyName?: string;
@@ -26,8 +26,8 @@ export function getDetectorById(id: string): (typeof DETECTOR_PROFILES)[number]
26
26
  /**
27
27
  * Resolves comment syntax for a file path using detector-specific templates.
28
28
  * @param {string} filePath - File path.
29
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [options={}] - Runtime options.
30
- * @returns {{kind: "block" | "line" | "html", linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string}} Syntax descriptor.
29
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [options={}] - Runtime options.
30
+ * @returns {{kind: "block" | "line" | "html", linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string}} Syntax descriptor.
31
31
  */
32
32
  export function getCommentSyntaxForFile(filePath: string, options?: {
33
33
  language?: string;
@@ -35,6 +35,7 @@ export function getCommentSyntaxForFile(filePath: string, options?: {
35
35
  disabledDetectors?: string[];
36
36
  detectorSyntaxOverrides?: Record<string, {
37
37
  linePrefix?: string;
38
+ lineSeparator?: string;
38
39
  blockStart?: string;
39
40
  blockLinePrefix?: string;
40
41
  blockEnd?: string;
@@ -42,11 +43,25 @@ export function getCommentSyntaxForFile(filePath: string, options?: {
42
43
  }): {
43
44
  kind: "block" | "line" | "html";
44
45
  linePrefix?: string;
46
+ lineSeparator?: string;
45
47
  blockStart?: string;
46
48
  blockLinePrefix?: string;
47
49
  blockEnd?: string;
48
50
  };
49
- export const DETECTOR_PROFILES: {
51
+ /**
52
+ * Resolves detector-specific leading content that must be preserved above inserted headers.
53
+ * @param {string} filePath - File path.
54
+ * @param {string} content - Full file content.
55
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[] }} [options={}] - Runtime options.
56
+ * @returns {string} Preserved prefix (possibly empty).
57
+ */
58
+ export function getPreservedPrefixForFile(filePath: string, content: string, options?: {
59
+ language?: string;
60
+ enabledDetectors?: string[];
61
+ disabledDetectors?: string[];
62
+ }): string;
63
+ export const DETECTOR_PROFILES: DetectorProfile[];
64
+ export type DetectorProfile = {
50
65
  id: string;
51
66
  markers: string[];
52
67
  extensions: string[];
@@ -56,11 +71,14 @@ export const DETECTOR_PROFILES: {
56
71
  marker: string;
57
72
  } | null>;
58
73
  parseProjectName: (marker: string, markerContent: string, rootDirName: string) => string;
59
- resolveCommentSyntax: (filePath: string) => {
74
+ resolveCommentSyntax: (filePath: string) => ({
60
75
  kind: "block" | "line" | "html";
61
76
  linePrefix?: string;
77
+ lineSeparator?: string;
62
78
  blockStart?: string;
63
79
  blockLinePrefix?: string;
64
80
  blockEnd?: string;
65
- } | null;
66
- }[];
81
+ } | null);
82
+ resolvePreservedPrefix?: (filePath: string, content: string) => string;
83
+ priority?: number;
84
+ };
@@ -9,6 +9,7 @@ export namespace detector {
9
9
  marker: string;
10
10
  }>;
11
11
  export function parseProjectName(_marker: any, markerContent: any, rootDirName: any): string;
12
+ export function resolvePreservedPrefix(filePath: any, content: any): string;
12
13
  export function resolveCommentSyntax(filePath: any): {
13
14
  kind: "block";
14
15
  blockStart: string;
@@ -9,6 +9,7 @@ export namespace detector {
9
9
  marker: string;
10
10
  }>;
11
11
  export function parseProjectName(_marker: any, markerContent: any, rootDirName: any): string;
12
+ export function resolvePreservedPrefix(filePath: any, content: any): string;
12
13
  export function resolveCommentSyntax(filePath: any): {
13
14
  kind: string;
14
15
  linePrefix: string;
@@ -0,0 +1,23 @@
1
+ export namespace detector {
2
+ export let id: string;
3
+ export let priority: number;
4
+ export { markers };
5
+ export { extensions };
6
+ export let enabledByDefault: boolean;
7
+ export function findNearestConfig(startPath: any): Promise<{
8
+ root: string;
9
+ marker: string;
10
+ }>;
11
+ export function parseProjectName(marker: any, markerContent: any, rootDirName: any): string;
12
+ export function resolveCommentSyntax(filePath: any): {
13
+ kind: "line";
14
+ linePrefix: string;
15
+ };
16
+ }
17
+ /**
18
+ * @fileoverview YAML detector implementation.
19
+ * @module fix-headers/detectors/yaml
20
+ */
21
+ declare const markers: string[];
22
+ declare const extensions: string[];
23
+ export {};
@@ -2,7 +2,7 @@
2
2
  * Finds the first top-level project header block in a file.
3
3
  * @param {string} content - File content.
4
4
  * @param {string} [filePath=""] - File path used for syntax selection.
5
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [syntaxOptions={}] - Syntax resolution options.
5
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [syntaxOptions={}] - Syntax resolution options.
6
6
  * @returns {{start: number, end: number} | null} Header location.
7
7
  */
8
8
  export function findProjectHeader(content: string, filePath?: string, syntaxOptions?: {
@@ -11,6 +11,7 @@ export function findProjectHeader(content: string, filePath?: string, syntaxOpti
11
11
  disabledDetectors?: string[];
12
12
  detectorSyntaxOverrides?: Record<string, {
13
13
  linePrefix?: string;
14
+ lineSeparator?: string;
14
15
  blockStart?: string;
15
16
  blockLinePrefix?: string;
16
17
  blockEnd?: string;
@@ -24,7 +25,7 @@ export function findProjectHeader(content: string, filePath?: string, syntaxOpti
24
25
  * @param {string} content - Original file content.
25
26
  * @param {string} newHeader - Generated header text.
26
27
  * @param {string} [filePath=""] - File path used for syntax selection.
27
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [syntaxOptions={}] - Syntax resolution options.
28
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [syntaxOptions={}] - Syntax resolution options.
28
29
  * @returns {{nextContent: string, changed: boolean}} Updated content result.
29
30
  */
30
31
  export function replaceOrInsertHeader(content: string, newHeader: string, filePath?: string, syntaxOptions?: {
@@ -33,6 +34,7 @@ export function replaceOrInsertHeader(content: string, newHeader: string, filePa
33
34
  disabledDetectors?: string[];
34
35
  detectorSyntaxOverrides?: Record<string, {
35
36
  linePrefix?: string;
37
+ lineSeparator?: string;
36
38
  blockStart?: string;
37
39
  blockLinePrefix?: string;
38
40
  blockEnd?: string;
@@ -6,6 +6,7 @@
6
6
  * @typedef {{
7
7
  * kind: "block" | "line" | "html",
8
8
  * linePrefix?: string,
9
+ * lineSeparator?: string,
9
10
  * blockStart?: string,
10
11
  * blockLinePrefix?: string,
11
12
  * blockEnd?: string
@@ -14,7 +15,7 @@
14
15
  /**
15
16
  * Resolves comment syntax for a file path based on extension.
16
17
  * @param {string} filePath - Absolute or relative file path.
17
- * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [options={}] - Syntax resolution options.
18
+ * @param {{ language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> }} [options={}] - Syntax resolution options.
18
19
  * @returns {HeaderSyntax} Header syntax descriptor.
19
20
  */
20
21
  export function getHeaderSyntaxForFile(filePath: string, options?: {
@@ -23,6 +24,7 @@ export function getHeaderSyntaxForFile(filePath: string, options?: {
23
24
  disabledDetectors?: string[];
24
25
  detectorSyntaxOverrides?: Record<string, {
25
26
  linePrefix?: string;
27
+ lineSeparator?: string;
26
28
  blockStart?: string;
27
29
  blockLinePrefix?: string;
28
30
  blockEnd?: string;
@@ -38,6 +40,7 @@ export function renderHeaderLines(syntax: HeaderSyntax, lines: string[]): string
38
40
  export type HeaderSyntax = {
39
41
  kind: "block" | "line" | "html";
40
42
  linePrefix?: string;
43
+ lineSeparator?: string;
41
44
  blockStart?: string;
42
45
  blockLinePrefix?: string;
43
46
  blockEnd?: string;
@@ -7,8 +7,12 @@
7
7
  * @param {{
8
8
  * absoluteFilePath: string,
9
9
  * language?: string,
10
- * syntaxOptions?: { language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> },
10
+ * syntaxOptions?: { language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> },
11
11
  * projectRoot: string,
12
+ * createdByName?: string,
13
+ * createdByEmail?: string,
14
+ * lastModifiedByName?: string,
15
+ * lastModifiedByEmail?: string,
12
16
  * projectName: string,
13
17
  * authorName: string,
14
18
  * authorEmail: string,
@@ -29,12 +33,17 @@ export function buildHeader(data: {
29
33
  disabledDetectors?: string[];
30
34
  detectorSyntaxOverrides?: Record<string, {
31
35
  linePrefix?: string;
36
+ lineSeparator?: string;
32
37
  blockStart?: string;
33
38
  blockLinePrefix?: string;
34
39
  blockEnd?: string;
35
40
  }>;
36
41
  };
37
42
  projectRoot: string;
43
+ createdByName?: string;
44
+ createdByEmail?: string;
45
+ lastModifiedByName?: string;
46
+ lastModifiedByEmail?: string;
38
47
  projectName: string;
39
48
  authorName: string;
40
49
  authorEmail: string;
@@ -12,9 +12,12 @@ export function runGit(cwd: string, args: string[]): Promise<string | null>;
12
12
  /**
13
13
  * Detects git author name and email from config or commit history.
14
14
  * @param {string} cwd - Project directory.
15
+ * @param {{useGpgSignerAuthor?: boolean}} [options={}] - Detection options.
15
16
  * @returns {Promise<{authorName: string | null, authorEmail: string | null}>} Author information.
16
17
  */
17
- export function detectGitAuthor(cwd: string): Promise<{
18
+ export function detectGitAuthor(cwd: string, options?: {
19
+ useGpgSignerAuthor?: boolean;
20
+ }): Promise<{
18
21
  authorName: string | null;
19
22
  authorEmail: string | null;
20
23
  }>;
@@ -1,3 +1,15 @@
1
+ /**
2
+ * @Project: @cldmv/fix-headers
3
+ * @Filename: /src/utils/time.mjs
4
+ * @Date: 2026-03-01T17:59:32-08:00 (1772416772)
5
+ * @Author: Nate Corcoran <CLDMV>
6
+ * @Email: <Shinrai@users.noreply.github.com>
7
+ * -----
8
+ * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
9
+ * @Last modified time: 2026-03-01T17:59:32-08:00 (1772416772)
10
+ * -----
11
+ * @Copyright: Copyright (c) 2026-2026 Catalyzed Motivation Inc. All rights reserved.
12
+ */
1
13
  /**
2
14
  * @fileoverview Date/time helpers used for header timestamp formatting.
3
15
  * @module fix-headers/utils/time