@cldmv/fix-headers 1.3.12 → 2.1.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/LICENSE +202 -0
- package/README.md +354 -25
- package/bin/fix-headers.mjs +64 -0
- package/dist/index.cjs +28 -0
- package/dist/index.mjs +15 -0
- package/package.json +39 -19
- package/types/src/cli.d.mts +20 -2
- package/types/src/config/load.d.mts +36 -0
- package/types/src/constants.d.mts +15 -23
- package/types/src/core/file-discovery.d.mts +17 -5
- package/types/src/core/fix-headers.d.mts +61 -4
- package/types/src/core/ignore-rules.d.mts +38 -0
- package/types/src/detect/project.d.mts +64 -15
- package/types/src/detectors/css.d.mts +0 -8
- package/types/src/detectors/go.d.mts +0 -8
- package/types/src/detectors/html.d.mts +0 -8
- package/types/src/detectors/index.d.mts +31 -8
- package/types/src/detectors/json.d.mts +0 -8
- package/types/src/detectors/node.d.mts +0 -8
- package/types/src/detectors/php.d.mts +0 -8
- package/types/src/detectors/python.d.mts +0 -8
- package/types/src/detectors/rust.d.mts +0 -8
- package/types/src/detectors/yaml.d.mts +0 -8
- package/types/src/drivers/go.d.mts +2 -0
- package/types/src/drivers/index.d.mts +154 -0
- package/types/src/drivers/node.d.mts +2 -0
- package/types/src/drivers/php.d.mts +2 -0
- package/types/src/drivers/python.d.mts +2 -0
- package/types/src/drivers/rust.d.mts +2 -0
- package/types/src/drivers/shared.d.mts +78 -0
- package/types/src/header/dates.d.mts +108 -0
- package/types/src/header/fields.d.mts +48 -0
- package/types/src/header/parser.d.mts +6 -2
- package/types/src/header/syntax.d.mts +8 -3
- package/types/src/header/template.d.mts +7 -4
- package/types/src/utils/diff.d.mts +53 -0
- package/types/src/utils/fs.d.mts +10 -3
- package/types/src/utils/git.d.mts +27 -0
- package/types/src/utils/time.d.mts +55 -0
- package/index.cjs +0 -39
- package/index.mjs +0 -20
- package/src/cli.mjs +0 -323
- package/src/constants.mjs +0 -50
- package/src/core/file-discovery.mjs +0 -213
- package/src/core/fix-headers.mjs +0 -413
- package/src/detect/project.mjs +0 -190
- package/src/detectors/css.mjs +0 -67
- package/src/detectors/go.mjs +0 -65
- package/src/detectors/html.mjs +0 -67
- package/src/detectors/index.mjs +0 -187
- package/src/detectors/json.mjs +0 -76
- package/src/detectors/node.mjs +0 -90
- package/src/detectors/php.mjs +0 -66
- package/src/detectors/python.mjs +0 -75
- package/src/detectors/rust.mjs +0 -62
- package/src/detectors/shared.mjs +0 -45
- package/src/detectors/yaml.mjs +0 -79
- package/src/fix-header.mjs +0 -30
- package/src/header/parser.mjs +0 -145
- package/src/header/syntax.mjs +0 -69
- package/src/header/template.mjs +0 -65
- package/src/utils/fs.mjs +0 -138
- package/src/utils/git.mjs +0 -135
- package/src/utils/time.mjs +0 -44
- package/types/src/detectors/shared.d.mts +0 -14
package/src/header/template.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Project: @cldmv/fix-headers
|
|
3
|
-
* @Filename: /src/header/template.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
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { relative } from "node:path";
|
|
15
|
-
import { getHeaderSyntaxForFile, renderHeaderLines } from "./syntax.mjs";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @fileoverview Header template builder used to generate normalized file headers.
|
|
19
|
-
* @module fix-headers/header/template
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Builds a normalized header block for a source file.
|
|
24
|
-
* @param {{
|
|
25
|
-
* absoluteFilePath: string,
|
|
26
|
-
* language?: string,
|
|
27
|
-
* syntaxOptions?: { language?: string, enabledDetectors?: string[], disabledDetectors?: string[], detectorSyntaxOverrides?: Record<string, { linePrefix?: string, lineSeparator?: string, blockStart?: string, blockLinePrefix?: string, blockEnd?: string }> },
|
|
28
|
-
* projectRoot: string,
|
|
29
|
-
* createdByName?: string,
|
|
30
|
-
* createdByEmail?: string,
|
|
31
|
-
* lastModifiedByName?: string,
|
|
32
|
-
* lastModifiedByEmail?: string,
|
|
33
|
-
* projectName: string,
|
|
34
|
-
* authorName: string,
|
|
35
|
-
* authorEmail: string,
|
|
36
|
-
* createdAt: {date: string, timestamp: number},
|
|
37
|
-
* lastModifiedAt: {date: string, timestamp: number},
|
|
38
|
-
* copyrightStartYear: number,
|
|
39
|
-
* companyName: string,
|
|
40
|
-
* currentYear: number
|
|
41
|
-
* }} data - Header data.
|
|
42
|
-
* @returns {string} Header block text.
|
|
43
|
-
*/
|
|
44
|
-
export function buildHeader(data) {
|
|
45
|
-
const relativePath = `/${relative(data.projectRoot, data.absoluteFilePath).replace(/\\/g, "/")}`;
|
|
46
|
-
const syntax = getHeaderSyntaxForFile(data.absoluteFilePath, data.syntaxOptions || { language: data.language });
|
|
47
|
-
const createdByName = data.createdByName || data.authorName;
|
|
48
|
-
const createdByEmail = data.createdByEmail || data.authorEmail;
|
|
49
|
-
const lastModifiedByName = data.lastModifiedByName || data.authorName;
|
|
50
|
-
const lastModifiedByEmail = data.lastModifiedByEmail || data.authorEmail;
|
|
51
|
-
const headerLines = [
|
|
52
|
-
`@Project: ${data.projectName}`,
|
|
53
|
-
`@Filename: ${relativePath}`,
|
|
54
|
-
`@Date: ${data.createdAt.date} (${data.createdAt.timestamp})`,
|
|
55
|
-
`@Author: ${createdByName}`,
|
|
56
|
-
`@Email: <${createdByEmail}>`,
|
|
57
|
-
"-----",
|
|
58
|
-
`@Last modified by: ${lastModifiedByName} (${lastModifiedByEmail})`,
|
|
59
|
-
`@Last modified time: ${data.lastModifiedAt.date} (${data.lastModifiedAt.timestamp})`,
|
|
60
|
-
"-----",
|
|
61
|
-
`@Copyright: Copyright (c) ${data.copyrightStartYear}-${data.currentYear} ${data.companyName} All rights reserved.`
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
return renderHeaderLines(syntax, headerLines);
|
|
65
|
-
}
|
package/src/utils/fs.mjs
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Project: @cldmv/fix-headers
|
|
3
|
-
* @Filename: /src/utils/fs.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
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { access, readdir, readFile, stat } from "node:fs/promises";
|
|
15
|
-
import { constants as fsConstants } from "node:fs";
|
|
16
|
-
import { dirname, join, resolve } from "node:path";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @fileoverview Filesystem helpers for project discovery and recursive scanning.
|
|
20
|
-
* @module fix-headers/utils/fs
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Checks whether a file exists and is readable.
|
|
25
|
-
* @param {string} filePath - Absolute or relative path.
|
|
26
|
-
* @returns {Promise<boolean>} True when the path exists.
|
|
27
|
-
*/
|
|
28
|
-
export async function pathExists(filePath) {
|
|
29
|
-
try {
|
|
30
|
-
await access(filePath, fsConstants.F_OK);
|
|
31
|
-
return true;
|
|
32
|
-
} catch {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Finds a marker file by traversing upward from a directory.
|
|
39
|
-
* @param {string} startDir - Starting directory.
|
|
40
|
-
* @param {string[]} markerFiles - Candidate marker file names.
|
|
41
|
-
* @returns {Promise<{root: string, marker: string} | null>} First match with root path.
|
|
42
|
-
*/
|
|
43
|
-
export async function findProjectRoot(startDir, markerFiles) {
|
|
44
|
-
let currentDir = resolve(startDir);
|
|
45
|
-
|
|
46
|
-
while (true) {
|
|
47
|
-
for (const marker of markerFiles) {
|
|
48
|
-
const markerPath = join(currentDir, marker);
|
|
49
|
-
if (await pathExists(markerPath)) {
|
|
50
|
-
return { root: currentDir, marker };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const parent = dirname(currentDir);
|
|
55
|
-
if (parent === currentDir) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
currentDir = parent;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Reads UTF-8 file content if it exists.
|
|
65
|
-
* @param {string} filePath - File path.
|
|
66
|
-
* @returns {Promise<string | null>} File content or null when missing.
|
|
67
|
-
*/
|
|
68
|
-
export async function readTextIfExists(filePath) {
|
|
69
|
-
if (!(await pathExists(filePath))) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return readFile(filePath, "utf8");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Recursively discovers files matching allowed extensions.
|
|
78
|
-
* @param {string} dirPath - Root directory to scan.
|
|
79
|
-
* @param {{
|
|
80
|
-
* allowedExtensions: Set<string>,
|
|
81
|
-
* ignoreFolders: Set<string>,
|
|
82
|
-
* shouldSkipDirectory?: (directoryPath: string, directoryName: string) => boolean
|
|
83
|
-
* }} options - Scan options.
|
|
84
|
-
* @returns {Promise<string[]>} Matching file paths.
|
|
85
|
-
*/
|
|
86
|
-
export async function walkFiles(dirPath, options) {
|
|
87
|
-
const files = [];
|
|
88
|
-
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
89
|
-
|
|
90
|
-
for (const entry of entries) {
|
|
91
|
-
const fullPath = join(dirPath, entry.name);
|
|
92
|
-
|
|
93
|
-
if (entry.isDirectory() && options.ignoreFolders.has(entry.name)) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (entry.isDirectory() && options.shouldSkipDirectory?.(fullPath, entry.name) === true) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (entry.isDirectory()) {
|
|
102
|
-
const nested = await walkFiles(fullPath, options);
|
|
103
|
-
files.push(...nested);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!entry.isFile()) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const extensionStart = entry.name.lastIndexOf(".");
|
|
112
|
-
if (extensionStart === -1) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const extension = entry.name.slice(extensionStart).toLowerCase();
|
|
117
|
-
if (options.allowedExtensions.has(extension)) {
|
|
118
|
-
files.push(fullPath);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return files;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Gets creation-like and modified timestamps from filesystem stats.
|
|
127
|
-
* @param {string} filePath - Absolute file path.
|
|
128
|
-
* @returns {Promise<{createdAt: Date, updatedAt: Date}>} Date pair.
|
|
129
|
-
*/
|
|
130
|
-
export async function readFileDates(filePath) {
|
|
131
|
-
const fileStats = await stat(filePath);
|
|
132
|
-
const createdAt = fileStats.birthtimeMs > 0 ? fileStats.birthtime : fileStats.mtime;
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
createdAt,
|
|
136
|
-
updatedAt: fileStats.mtime
|
|
137
|
-
};
|
|
138
|
-
}
|
package/src/utils/git.mjs
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Project: @cldmv/fix-headers
|
|
3
|
-
* @Filename: /src/utils/git.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
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { execFile } from "node:child_process";
|
|
15
|
-
import { promisify } from "node:util";
|
|
16
|
-
|
|
17
|
-
const execFileAsync = promisify(execFile);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @fileoverview Git helpers for author identity and file history metadata.
|
|
21
|
-
* @module fix-headers/utils/git
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Runs a git command and returns trimmed stdout.
|
|
26
|
-
* @param {string} cwd - Working directory.
|
|
27
|
-
* @param {string[]} args - Git command arguments.
|
|
28
|
-
* @returns {Promise<string | null>} Trimmed stdout or null on failure.
|
|
29
|
-
*/
|
|
30
|
-
export async function runGit(cwd, args) {
|
|
31
|
-
try {
|
|
32
|
-
const { stdout } = await execFileAsync("git", args, { cwd });
|
|
33
|
-
const value = stdout.trim();
|
|
34
|
-
return value.length > 0 ? value : null;
|
|
35
|
-
} catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Parses a signer UID string into author name and optional email.
|
|
42
|
-
* @param {string} signerUid - Raw signer UID (for example: "Name (Comment) <email@example.com>").
|
|
43
|
-
* @returns {{authorName: string | null, authorEmail: string | null}} Parsed signer identity.
|
|
44
|
-
*/
|
|
45
|
-
function parseSignerUid(signerUid) {
|
|
46
|
-
const trimmed = signerUid.trim();
|
|
47
|
-
if (trimmed.length === 0) {
|
|
48
|
-
return { authorName: null, authorEmail: null };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const emailMatch = trimmed.match(/<([^>\n]+)>\s*$/);
|
|
52
|
-
const authorEmail = emailMatch?.[1]?.trim() || null;
|
|
53
|
-
const authorName = (emailMatch ? trimmed.slice(0, emailMatch.index) : trimmed).trim() || null;
|
|
54
|
-
|
|
55
|
-
return { authorName, authorEmail };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Detects git author name and email from config or commit history.
|
|
60
|
-
* @param {string} cwd - Project directory.
|
|
61
|
-
* @param {{useGpgSignerAuthor?: boolean}} [options={}] - Detection options.
|
|
62
|
-
* @returns {Promise<{authorName: string | null, authorEmail: string | null}>} Author information.
|
|
63
|
-
*/
|
|
64
|
-
export async function detectGitAuthor(cwd, options = {}) {
|
|
65
|
-
let authorName = await runGit(cwd, ["config", "--get", "user.name"]);
|
|
66
|
-
let authorEmail = await runGit(cwd, ["config", "--get", "user.email"]);
|
|
67
|
-
if (options.useGpgSignerAuthor === true) {
|
|
68
|
-
const signerUid = await runGit(cwd, ["log", "-1", "--format=%GS"]);
|
|
69
|
-
const signerIdentity = parseSignerUid(signerUid || "");
|
|
70
|
-
authorName = signerIdentity.authorName || authorName;
|
|
71
|
-
authorEmail = authorEmail || signerIdentity.authorEmail;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!authorName || !authorEmail) {
|
|
75
|
-
const fallback = await runGit(cwd, ["log", "-1", "--format=%an|%ae"]);
|
|
76
|
-
if (fallback) {
|
|
77
|
-
const [fallbackName, fallbackEmail] = fallback.split("|");
|
|
78
|
-
authorName = authorName || fallbackName || null;
|
|
79
|
-
authorEmail = authorEmail || fallbackEmail || null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return { authorName, authorEmail };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Gets a file's first commit date from git history.
|
|
88
|
-
* @param {string} cwd - Project directory.
|
|
89
|
-
* @param {string} filePath - Relative file path.
|
|
90
|
-
* @returns {Promise<{date: string, timestamp: number} | null>} Git creation date payload.
|
|
91
|
-
*/
|
|
92
|
-
export async function getGitCreationDate(cwd, filePath) {
|
|
93
|
-
const output = await runGit(cwd, ["log", "--follow", "--format=%aI|%at", "--reverse", "--", filePath]);
|
|
94
|
-
if (!output) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const firstLine = output.split("\n")[0];
|
|
99
|
-
const [date, timestampText] = firstLine.split("|");
|
|
100
|
-
if (!date || !timestampText) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const timestamp = Number.parseInt(timestampText, 10);
|
|
105
|
-
if (Number.isNaN(timestamp)) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return { date, timestamp };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Gets a file's latest commit date from git history.
|
|
114
|
-
* @param {string} cwd - Project directory.
|
|
115
|
-
* @param {string} filePath - Relative file path.
|
|
116
|
-
* @returns {Promise<{date: string, timestamp: number} | null>} Git last-modified payload.
|
|
117
|
-
*/
|
|
118
|
-
export async function getGitLastModifiedDate(cwd, filePath) {
|
|
119
|
-
const output = await runGit(cwd, ["log", "-1", "--format=%aI|%at", "--", filePath]);
|
|
120
|
-
if (!output) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const [date, timestampText] = output.split("|");
|
|
125
|
-
if (!date || !timestampText) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const timestamp = Number.parseInt(timestampText, 10);
|
|
130
|
-
if (Number.isNaN(timestamp)) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return { date, timestamp };
|
|
135
|
-
}
|
package/src/utils/time.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @fileoverview Date/time helpers used for header timestamp formatting.
|
|
16
|
-
* @module fix-headers/utils/time
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Formats a date as `YYYY-MM-DD HH:mm:ss ±HH:MM`.
|
|
21
|
-
* @param {Date} date - Input date.
|
|
22
|
-
* @returns {string} Formatted date string.
|
|
23
|
-
*/
|
|
24
|
-
export function formatDateWithTimezone(date) {
|
|
25
|
-
const pad = (value) => String(value).padStart(2, "0");
|
|
26
|
-
const tzOffset = -date.getTimezoneOffset();
|
|
27
|
-
const sign = tzOffset >= 0 ? "+" : "-";
|
|
28
|
-
const tzHours = pad(Math.floor(Math.abs(tzOffset) / 60));
|
|
29
|
-
const tzMinutes = pad(Math.abs(tzOffset) % 60);
|
|
30
|
-
|
|
31
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())} ${sign}${tzHours}:${tzMinutes}`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns a formatted date and unix timestamp.
|
|
36
|
-
* @param {Date} [date=new Date()] - Date value to format.
|
|
37
|
-
* @returns {{ date: string, timestamp: number }} Formatted datetime payload.
|
|
38
|
-
*/
|
|
39
|
-
export function toDatePayload(date = new Date()) {
|
|
40
|
-
return {
|
|
41
|
-
date: formatDateWithTimezone(date),
|
|
42
|
-
timestamp: Math.floor(date.getTime() / 1000)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Shared detector helpers for nearest marker search.
|
|
3
|
-
* @module fix-headers/detectors/shared
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Finds the closest marker file by walking up parent directories.
|
|
7
|
-
* @param {string} startPath - Starting directory or file path.
|
|
8
|
-
* @param {string[]} markers - Marker filenames to search.
|
|
9
|
-
* @returns {Promise<{root: string, marker: string} | null>} Closest located marker.
|
|
10
|
-
*/
|
|
11
|
-
export function findNearestMarker(startPath: string, markers: string[]): Promise<{
|
|
12
|
-
root: string;
|
|
13
|
-
marker: string;
|
|
14
|
-
} | null>;
|