@cldmv/fix-headers 1.2.0 → 1.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/fix-headers",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Multi-language project header normalizer with auto-detection and override support.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
@@ -6,12 +6,13 @@
6
6
  * @Email: <Shinrai@users.noreply.github.com>
7
7
  * -----
8
8
  * @Last modified by: Nate Corcoran <CLDMV> (Shinrai@users.noreply.github.com)
9
- * @Last modified time: 2026-03-01T17:59:32-08:00 (1772416772)
9
+ * @Last modified time: 2026-03-04 20:59:30 -08:00 (1772686770)
10
10
  * -----
11
- * @Copyright: Copyright (c) 2026-2026 Catalyzed Motivation Inc. All rights reserved.
11
+ * @Copyright: Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
12
12
  */
13
13
 
14
14
  import { join, relative, resolve } from "node:path";
15
+ import { stat } from "node:fs/promises";
15
16
  import { DEFAULT_IGNORE_FOLDERS } from "../constants.mjs";
16
17
  import { getAllowedExtensions } from "../detectors/index.mjs";
17
18
  import { walkFiles } from "../utils/fs.mjs";
@@ -58,6 +59,17 @@ function resolveIncludeFolders(includeFolders) {
58
59
  return [];
59
60
  }
60
61
 
62
+ /**
63
+ * Warns when an include folder cannot be scanned and is skipped.
64
+ * @param {string} includeFolder - Project-relative include folder.
65
+ * @param {unknown} error - Original filesystem error.
66
+ * @returns {void}
67
+ */
68
+ function reportSkippedIncludeFolder(includeFolder, error) {
69
+ const message = error instanceof Error ? error.message : String(error);
70
+ console.warn(`fix-headers: skipped include folder \"${includeFolder}\" (${message})`);
71
+ }
72
+
61
73
  /**
62
74
  * Builds a directory exclusion matcher from path and folder-name lists.
63
75
  * @param {string} projectRoot - Project root path.
@@ -128,13 +140,29 @@ export async function discoverFiles(options) {
128
140
  const includeFolders = resolveIncludeFolders(options.includeFolders);
129
141
  const excludeFolders = Array.isArray(options.excludeFolders) ? options.excludeFolders : [];
130
142
  const exclusionMatcher = buildExclusionMatcher(options.projectRoot, excludeFolders);
131
-
132
143
  const roots =
133
- includeFolders.length > 0 ? includeFolders.map((relativePath) => join(options.projectRoot, relativePath)) : [options.projectRoot];
144
+ includeFolders.length > 0
145
+ ? includeFolders.map((includeFolder) => ({ includeFolder, rootPath: join(options.projectRoot, includeFolder) }))
146
+ : [{ includeFolder: ".", rootPath: options.projectRoot }];
134
147
 
135
148
  const files = [];
136
- for (const rootPath of roots) {
137
- const discovered = await walkFiles(rootPath, {
149
+ for (const root of roots) {
150
+ const rootStats = await stat(root.rootPath).catch((error) => error);
151
+ if (rootStats instanceof Error) {
152
+ if (/** @type {{ code?: string }} */ (rootStats).code === "ENOENT") {
153
+ reportSkippedIncludeFolder(root.includeFolder, rootStats);
154
+ continue;
155
+ }
156
+
157
+ throw rootStats;
158
+ }
159
+
160
+ if (!rootStats.isDirectory()) {
161
+ reportSkippedIncludeFolder(root.includeFolder, `path is not a directory: ${root.rootPath}`);
162
+ continue;
163
+ }
164
+
165
+ const discovered = await walkFiles(root.rootPath, {
138
166
  allowedExtensions,
139
167
  ignoreFolders: DEFAULT_IGNORED_FOLDERS,
140
168
  shouldSkipDirectory: exclusionMatcher
@@ -34,6 +34,7 @@ export type FixHeadersOptions = {
34
34
  marker?: string | null;
35
35
  authorName?: string;
36
36
  authorEmail?: string;
37
+ company?: string;
37
38
  companyName?: string;
38
39
  copyrightStartYear?: number;
39
40
  };
@@ -43,6 +43,7 @@ export function detectProjectFromMarkers(cwd: string, options?: {
43
43
  * useGpgSignerAuthor?: boolean,
44
44
  * authorName?: string,
45
45
  * authorEmail?: string,
46
+ * company?: string,
46
47
  * companyName?: string,
47
48
  * copyrightStartYear?: number
48
49
  * }} [options={}] - Detection options and overrides.
@@ -69,6 +70,7 @@ export function resolveProjectMetadata(options?: {
69
70
  useGpgSignerAuthor?: boolean;
70
71
  authorName?: string;
71
72
  authorEmail?: string;
73
+ company?: string;
72
74
  companyName?: string;
73
75
  copyrightStartYear?: number;
74
76
  }): Promise<{
@@ -0,0 +1,25 @@
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: "block";
14
+ blockStart: string;
15
+ blockLinePrefix: string;
16
+ blockEnd: string;
17
+ };
18
+ }
19
+ /**
20
+ * @fileoverview JSON-family detector implementation.
21
+ * @module fix-headers/detectors/json
22
+ */
23
+ declare const markers: string[];
24
+ declare const extensions: string[];
25
+ export {};