Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/cache/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ export interface DocsCacheLockSource {
fileCount: number;
manifestSha256: string;
rulesSha256?: string;
updatedAt: string;
}

export interface DocsCacheLock {
version: 1;
generatedAt: string;
toolVersion: string;
sources: Record<string, DocsCacheLockSource>;
}
Expand Down Expand Up @@ -54,7 +52,6 @@ export const validateLock = (input: unknown): DocsCacheLock => {
if (version !== 1) {
throw new Error("Lock file version must be 1.");
}
const generatedAt = assertString(input.generatedAt, "generatedAt");
const toolVersion = assertString(input.toolVersion, "toolVersion");
if (!isRecord(input.sources)) {
Comment thread
fbosch marked this conversation as resolved.
throw new Error("sources must be an object.");
Expand Down Expand Up @@ -84,12 +81,10 @@ export const validateLock = (input: unknown): DocsCacheLock => {
value.rulesSha256 === undefined
? undefined
: assertString(value.rulesSha256, `sources.${key}.rulesSha256`),
updatedAt: assertString(value.updatedAt, `sources.${key}.updatedAt`),
};
}
return {
version: 1,
generatedAt,
toolVersion,
sources,
};
Expand Down
6 changes: 1 addition & 5 deletions src/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ const loadToolVersion = async () => {
const buildLockSource = (
result: SyncResult,
prior: DocsCacheLock["sources"][string] | undefined,
now: string,
) => ({
repo: result.repo,
ref: result.ref,
Expand All @@ -231,15 +230,13 @@ const buildLockSource = (
manifestSha256:
result.manifestSha256 ?? prior?.manifestSha256 ?? result.resolvedCommit,
rulesSha256: result.rulesSha256 ?? prior?.rulesSha256,
updatedAt: now,
});

const buildLock = async (
plan: Awaited<ReturnType<typeof getSyncPlan>>,
previous: Awaited<ReturnType<typeof readLock>> | null,
) => {
const toolVersion = await loadToolVersion();
const now = new Date().toISOString();
const configSourceIds = new Set(
plan.config.sources.map((source) => source.id),
);
Expand All @@ -253,11 +250,10 @@ const buildLock = async (
}
for (const result of plan.results) {
const prior = sources[result.id];
sources[result.id] = buildLockSource(result, prior, now);
sources[result.id] = buildLockSource(result, prior);
}
return {
version: 1 as const,
generatedAt: now,
toolVersion,
sources,
};
Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/docs-lock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"version": 1,
"generatedAt": "2026-01-30T12:00:00+01:00",
"toolVersion": "0.1.0",
"sources": {
"vitest": {
Expand All @@ -10,8 +9,7 @@
"bytes": 123456,
"fileCount": 512,
"manifestSha256": "abcd",
"rulesSha256": "efgh",
"updatedAt": "2026-01-30T12:00:00+01:00"
"rulesSha256": "efgh"
}
}
}
1 change: 0 additions & 1 deletion tests/fixtures/empty.docs-lock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"version": 1,
"generatedAt": "2026-01-30T12:00:00+01:00",
"toolVersion": "0.1.0",
"sources": {}
}
3 changes: 1 addition & 2 deletions tests/lock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ test("writeLock produces readable JSON", async (t) => {
const tmpPath = path.join(tmpdir(), `docs-lock-${Date.now()}.json`);
const lock = {
version: 1,
generatedAt: "2026-01-30T12:00:00+01:00",
toolVersion: "0.1.0",
sources: {},
};
await module.writeLock(tmpPath, lock);
const parsed = await module.readLock(tmpPath);
assert.equal(parsed.generatedAt, lock.generatedAt);
assert.equal(parsed.toolVersion, lock.toolVersion);
});
4 changes: 0 additions & 4 deletions tests/sync-materialize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ test("sync re-materializes when docs missing even if commit unchanged", async ()
path.join(tmpRoot, DEFAULT_LOCK_FILENAME),
JSON.stringify({
version: 1,
generatedAt: new Date().toISOString(),
toolVersion: "0.1.0",
sources: {
local: {
Expand All @@ -240,7 +239,6 @@ test("sync re-materializes when docs missing even if commit unchanged", async ()
bytes: 0,
fileCount: 0,
manifestSha256: "abc123",
updatedAt: new Date().toISOString(),
},
},
}),
Expand Down Expand Up @@ -315,7 +313,6 @@ test("sync offline materializes from cache when lock exists", async () => {
path.join(tmpRoot, DEFAULT_LOCK_FILENAME),
JSON.stringify({
version: 1,
generatedAt: new Date().toISOString(),
toolVersion: "0.1.0",
sources: {
local: {
Expand All @@ -325,7 +322,6 @@ test("sync offline materializes from cache when lock exists", async () => {
bytes: 0,
fileCount: 0,
manifestSha256: "abc123",
updatedAt: new Date().toISOString(),
},
},
}),
Expand Down
4 changes: 0 additions & 4 deletions tests/sync-offline-fail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ test("sync offline uses lock entries without resolving remotes", async () => {
lockPath,
JSON.stringify({
version: 1,
generatedAt: new Date().toISOString(),
toolVersion: "0.1.0",
sources: {
local: {
Expand All @@ -85,7 +84,6 @@ test("sync offline uses lock entries without resolving remotes", async () => {
bytes: 4,
fileCount: 1,
manifestSha256: "abc123",
updatedAt: new Date().toISOString(),
},
},
}),
Expand Down Expand Up @@ -145,7 +143,6 @@ test("sync offline fails when lock exists but cache missing", async () => {
lockPath,
JSON.stringify({
version: 1,
generatedAt: new Date().toISOString(),
toolVersion: "0.1.0",
sources: {
local: {
Expand All @@ -155,7 +152,6 @@ test("sync offline fails when lock exists but cache missing", async () => {
bytes: 4,
fileCount: 1,
manifestSha256: "abc123",
updatedAt: new Date().toISOString(),
},
},
}),
Expand Down
Loading