docs-cache 0.1.0 → 0.1.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/dist/lock.mjs +3 -0
- package/package.json +2 -1
package/dist/lock.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{readFile as m,writeFile as w}from"node:fs/promises";import c from"node:path";const u="docs.lock",a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),i=(e,r)=>{if(typeof e!="string"||e.length===0)throw new Error(`${r} must be a non-empty string.`);return e},d=(e,r)=>{if(typeof e!="number"||Number.isNaN(e))throw new Error(`${r} must be a number.`);return e},f=(e,r)=>{const s=d(e,r);if(s<0)throw new Error(`${r} must be zero or greater.`);return s},l=e=>{if(!a(e))throw new Error("Lock file must be a JSON object.");if(e.version!==1)throw new Error("Lock file version must be 1.");const r=i(e.generatedAt,"generatedAt"),s=i(e.toolVersion,"toolVersion");if(!a(e.sources))throw new Error("sources must be an object.");const t={};for(const[o,n]of Object.entries(e.sources)){if(!a(n))throw new Error(`sources.${o} must be an object.`);t[o]={repo:i(n.repo,`sources.${o}.repo`),ref:i(n.ref,`sources.${o}.ref`),resolvedCommit:i(n.resolvedCommit,`sources.${o}.resolvedCommit`),bytes:f(n.bytes,`sources.${o}.bytes`),fileCount:f(n.fileCount,`sources.${o}.fileCount`),manifestSha256:i(n.manifestSha256,`sources.${o}.manifestSha256`),updatedAt:i(n.updatedAt,`sources.${o}.updatedAt`)}}return{version:1,generatedAt:r,toolVersion:s,sources:t}},b=e=>c.resolve(c.dirname(e),u),h=async e=>{let r;try{r=await m(e,"utf8")}catch(t){const o=t instanceof Error?t.message:String(t);throw new Error(`Failed to read lock file at ${e}: ${o}`)}let s;try{s=JSON.parse(r)}catch(t){const o=t instanceof Error?t.message:String(t);throw new Error(`Invalid JSON in ${e}: ${o}`)}return l(s)},$=async(e,r)=>{const s=`${JSON.stringify(r,null,2)}
|
|
2
|
+
`;await w(e,s,"utf8")};export{u as DEFAULT_LOCK_FILENAME,h as readLock,b as resolveLockPath,l as validateLock,$ as writeLock};
|
|
3
|
+
//# sourceMappingURL=lock.mjs.map
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "docs-cache",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.1",
|
|
6
6
|
"description": "CLI for deterministic local caching of external documentation for agents and tools",
|
|
7
7
|
"author": "Frederik Bosch",
|
|
8
8
|
"license": "MIT",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"bin",
|
|
35
35
|
"dist/cli.mjs",
|
|
36
36
|
"dist/chunks/*.mjs",
|
|
37
|
+
"dist/lock.mjs",
|
|
37
38
|
"dist/shared/*.mjs",
|
|
38
39
|
"README.md",
|
|
39
40
|
"LICENSE"
|