@yawlabs/ctxlint 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pre-commit-hooks.yaml +1 -1
- package/dist/index.js +42 -29
- package/package.json +1 -1
package/.pre-commit-hooks.yaml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Version-pinned so a checkout at `rev: vX.Y.Z` runs exactly that release
|
|
5
5
|
# of ctxlint — matches the pinning done by `ctxlint init`. release.sh keeps
|
|
6
6
|
# this in sync with package.json on each bump.
|
|
7
|
-
entry: npx @yawlabs/ctxlint@0.13.
|
|
7
|
+
entry: npx @yawlabs/ctxlint@0.13.1 --strict
|
|
8
8
|
language: node
|
|
9
9
|
always_run: true
|
|
10
10
|
pass_filenames: false
|
package/dist/index.js
CHANGED
|
@@ -40905,6 +40905,45 @@ async function getCommitsSinceBatch(projectRoot, paths, since) {
|
|
|
40905
40905
|
}
|
|
40906
40906
|
return out;
|
|
40907
40907
|
}
|
|
40908
|
+
function normalizeRenamePath(p2) {
|
|
40909
|
+
return p2.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
40910
|
+
}
|
|
40911
|
+
function parseRenameLog(result, targetPath) {
|
|
40912
|
+
if (!result.trim()) return null;
|
|
40913
|
+
const want = targetPath ? normalizeRenamePath(targetPath) : void 0;
|
|
40914
|
+
const wantBase = want ? want.split("/").pop() ?? want : void 0;
|
|
40915
|
+
let currentHash = "unknown";
|
|
40916
|
+
let currentDateStr;
|
|
40917
|
+
let basenameFallback = null;
|
|
40918
|
+
const lines = result.trim().split("\n");
|
|
40919
|
+
for (const line of lines) {
|
|
40920
|
+
const headerMatch = line.match(/^([a-f0-9]{7,40})\s+(.+)$/);
|
|
40921
|
+
if (headerMatch) {
|
|
40922
|
+
currentHash = headerMatch[1].substring(0, 7);
|
|
40923
|
+
currentDateStr = headerMatch[2];
|
|
40924
|
+
continue;
|
|
40925
|
+
}
|
|
40926
|
+
if (line.startsWith("R")) {
|
|
40927
|
+
const parts = line.split(" ");
|
|
40928
|
+
if (parts.length >= 3) {
|
|
40929
|
+
const daysAgo = currentDateStr ? Math.floor((Date.now() - new Date(currentDateStr).getTime()) / (1e3 * 60 * 60 * 24)) : 0;
|
|
40930
|
+
const info2 = {
|
|
40931
|
+
oldPath: parts[1],
|
|
40932
|
+
newPath: parts[2],
|
|
40933
|
+
commitHash: currentHash,
|
|
40934
|
+
daysAgo
|
|
40935
|
+
};
|
|
40936
|
+
if (!want) return info2;
|
|
40937
|
+
const oldNorm = normalizeRenamePath(info2.oldPath);
|
|
40938
|
+
if (oldNorm === want) return info2;
|
|
40939
|
+
if (!basenameFallback && wantBase && (oldNorm.split("/").pop() ?? oldNorm) === wantBase) {
|
|
40940
|
+
basenameFallback = info2;
|
|
40941
|
+
}
|
|
40942
|
+
}
|
|
40943
|
+
}
|
|
40944
|
+
}
|
|
40945
|
+
return basenameFallback;
|
|
40946
|
+
}
|
|
40908
40947
|
async function findRenames(projectRoot, filePath) {
|
|
40909
40948
|
try {
|
|
40910
40949
|
const git = getGit(projectRoot);
|
|
@@ -40914,35 +40953,9 @@ async function findRenames(projectRoot, filePath) {
|
|
|
40914
40953
|
"--find-renames",
|
|
40915
40954
|
"--name-status",
|
|
40916
40955
|
"--format=%H %ai",
|
|
40917
|
-
"-
|
|
40918
|
-
"--",
|
|
40919
|
-
filePath
|
|
40956
|
+
"-50"
|
|
40920
40957
|
]);
|
|
40921
|
-
|
|
40922
|
-
let currentHash = "unknown";
|
|
40923
|
-
let currentDateStr;
|
|
40924
|
-
const lines = result.trim().split("\n");
|
|
40925
|
-
for (const line of lines) {
|
|
40926
|
-
const headerMatch = line.match(/^([a-f0-9]{7,40})\s+(.+)$/);
|
|
40927
|
-
if (headerMatch) {
|
|
40928
|
-
currentHash = headerMatch[1].substring(0, 7);
|
|
40929
|
-
currentDateStr = headerMatch[2];
|
|
40930
|
-
continue;
|
|
40931
|
-
}
|
|
40932
|
-
if (line.startsWith("R")) {
|
|
40933
|
-
const parts = line.split(" ");
|
|
40934
|
-
if (parts.length >= 3) {
|
|
40935
|
-
const daysAgo = currentDateStr ? Math.floor((Date.now() - new Date(currentDateStr).getTime()) / (1e3 * 60 * 60 * 24)) : 0;
|
|
40936
|
-
return {
|
|
40937
|
-
oldPath: parts[1],
|
|
40938
|
-
newPath: parts[2],
|
|
40939
|
-
commitHash: currentHash,
|
|
40940
|
-
daysAgo
|
|
40941
|
-
};
|
|
40942
|
-
}
|
|
40943
|
-
}
|
|
40944
|
-
}
|
|
40945
|
-
return null;
|
|
40958
|
+
return parseRenameLog(result, filePath);
|
|
40946
40959
|
} catch {
|
|
40947
40960
|
return null;
|
|
40948
40961
|
}
|
|
@@ -46573,7 +46586,7 @@ import { readFileSync as readFileSync7 } from "node:fs";
|
|
|
46573
46586
|
import { resolve as resolve11, dirname as dirname5 } from "node:path";
|
|
46574
46587
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
46575
46588
|
function loadVersion() {
|
|
46576
|
-
if (true) return "0.
|
|
46589
|
+
if (true) return "0.13.0";
|
|
46577
46590
|
const __dir = dirname5(fileURLToPath2(import.meta.url));
|
|
46578
46591
|
const pkgPath = resolve11(__dir, "../package.json");
|
|
46579
46592
|
const pkg = JSON.parse(readFileSync7(pkgPath, "utf-8"));
|
package/package.json
CHANGED