tickmarkr 2.7.3 → 2.7.4
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/dist/cli/commands/verify.js +2 -2
- package/dist/gates/cache.d.ts +1 -0
- package/dist/gates/cache.js +27 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { allAdapters, probeAll, readDoctor, rolePools, writeDoctor } from "../..
|
|
|
7
7
|
import { channelKey } from "../../adapters/types.js";
|
|
8
8
|
import { loadConfig } from "../../config/config.js";
|
|
9
9
|
import { captureBaseline, detectGateCommands, staleFileCountCommands } from "../../gates/baseline.js";
|
|
10
|
-
import { getVerdictStore, runnerInputsHash } from "../../gates/cache.js";
|
|
10
|
+
import { getVerdictStore, lockfileKeyBytes, runnerInputsHash } from "../../gates/cache.js";
|
|
11
11
|
import { modelProvider } from "../../gates/review.js";
|
|
12
12
|
import { runGates } from "../../gates/run-gates.js";
|
|
13
13
|
import { getTask, loadGraph } from "../../graph/graph.js";
|
|
@@ -92,7 +92,7 @@ export function baselineCachePath(cwd, baseSha, commands) {
|
|
|
92
92
|
const lockParts = [];
|
|
93
93
|
for (const file of LOCKFILES) {
|
|
94
94
|
const path = join(cwd, file);
|
|
95
|
-
lockParts.push(file, existsSync(path) ? readFileSync(path) : "<absent>");
|
|
95
|
+
lockParts.push(file, existsSync(path) ? lockfileKeyBytes(file, readFileSync(path)) : "<absent>");
|
|
96
96
|
}
|
|
97
97
|
const commandParts = Object.entries(commands).sort(([a], [b]) => a.localeCompare(b)).map(([name, command]) => `${name}\0${command}\0`);
|
|
98
98
|
return join(realpathSync(tmpdir()), "tickmarkr-verify", "cache", `baseline-${baseSha.slice(0, 12)}-${hashParts(lockParts)}-${hashParts(commandParts)}-${runnerInputsHash()}.json`);
|
package/dist/gates/cache.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const DEFAULT_VERDICT_CACHE_BOUND = 128;
|
|
|
5
5
|
export declare function setVerdictCacheBoundForTests(bound: number | undefined): void;
|
|
6
6
|
export declare function resetVerdictCacheBoundForTests(): void;
|
|
7
7
|
export declare const LOCKFILES: readonly ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lock", "bun.lockb"];
|
|
8
|
+
export declare function lockfileKeyBytes(file: string, bytes: Buffer): Buffer | string;
|
|
8
9
|
export declare function lockfileHash(worktree: string): string;
|
|
9
10
|
export declare function canonicalJson(obj: unknown): string;
|
|
10
11
|
export declare function baselineIdentity(baseline?: Baseline): string;
|
package/dist/gates/cache.js
CHANGED
|
@@ -23,6 +23,32 @@ export const LOCKFILES = [
|
|
|
23
23
|
"bun.lock",
|
|
24
24
|
"bun.lockb",
|
|
25
25
|
];
|
|
26
|
+
// Queue row 122: a version-only bump rewrites an npm v2/v3 lockfile's root `version` and `packages[""].version` and nothing
|
|
27
|
+
// a dependency resolves from, so those two fields leave the key; every other byte keys as written. Other lockfile kinds, a
|
|
28
|
+
// v1 or unversioned npm lockfile, and an unparseable one key on their raw bytes, which can only miss, never falsely hit.
|
|
29
|
+
export function lockfileKeyBytes(file, bytes) {
|
|
30
|
+
if (file !== "package-lock.json" && file !== "npm-shrinkwrap.json")
|
|
31
|
+
return bytes;
|
|
32
|
+
let lock;
|
|
33
|
+
try {
|
|
34
|
+
lock = JSON.parse(bytes.toString("utf8"));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return bytes;
|
|
38
|
+
}
|
|
39
|
+
if (!lock || typeof lock !== "object" || Array.isArray(lock))
|
|
40
|
+
return bytes;
|
|
41
|
+
const { version: _version, ...rest } = lock;
|
|
42
|
+
if (rest.lockfileVersion !== 2 && rest.lockfileVersion !== 3)
|
|
43
|
+
return bytes;
|
|
44
|
+
const packages = rest.packages;
|
|
45
|
+
const own = packages?.[""];
|
|
46
|
+
if (own && typeof own === "object" && !Array.isArray(own)) {
|
|
47
|
+
const { version: _ownVersion, ...ownRest } = own;
|
|
48
|
+
rest.packages = { ...packages, "": ownRest };
|
|
49
|
+
}
|
|
50
|
+
return canonicalJson(rest);
|
|
51
|
+
}
|
|
26
52
|
export function lockfileHash(worktree) {
|
|
27
53
|
const hash = createHash("sha256");
|
|
28
54
|
let found = false;
|
|
@@ -31,7 +57,7 @@ export function lockfileHash(worktree) {
|
|
|
31
57
|
if (existsSync(p)) {
|
|
32
58
|
found = true;
|
|
33
59
|
try {
|
|
34
|
-
hash.update(file).update("\0").update(readFileSync(p)).update("\0");
|
|
60
|
+
hash.update(file).update("\0").update(lockfileKeyBytes(file, readFileSync(p))).update("\0");
|
|
35
61
|
}
|
|
36
62
|
catch {
|
|
37
63
|
hash.update(file).update("\0unreadable\0");
|