@scolladon/tsgit 2.0.1 → 3.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/README.md +14 -2
- package/dist/cjs/adapters/browser/index.cjs +1 -2
- package/dist/cjs/adapters/memory/index.cjs +1 -2
- package/dist/cjs/adapters/node/index.cjs +1 -2
- package/dist/cjs/chunks/adapter-detect-DW9fsw9d.cjs +1 -0
- package/dist/cjs/chunks/browser-http-transport-DGwW5YL7.cjs +1 -0
- package/dist/cjs/chunks/context-BcoAzPuU.cjs +0 -1
- package/dist/cjs/chunks/error-CfLWDui_.cjs +1 -0
- package/dist/cjs/chunks/index-Cy44GVR6.cjs +1 -0
- package/dist/cjs/chunks/inflate-CmCtM4-w.cjs +1 -0
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs +0 -1
- package/dist/cjs/chunks/memory-http-transport-CGriODcQ.cjs +1 -0
- package/dist/cjs/chunks/node-ssh-transport-PFu3ijfp.cjs +1 -0
- package/dist/cjs/chunks/{progress-CxU62NC1.cjs → progress-D8Dqbftk.cjs} +1 -2
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs +0 -1
- package/dist/cjs/chunks/repository-Ci-BBxk0.cjs +1 -0
- package/dist/cjs/chunks/write-sparse-checkout-C1dsHCAD.cjs +1 -0
- package/dist/cjs/commands/index.cjs +1 -2
- package/dist/cjs/index.browser.cjs +1 -2
- package/dist/cjs/index.cjs +1 -2
- package/dist/cjs/index.default.cjs +1 -2
- package/dist/cjs/index.node.cjs +1 -2
- package/dist/cjs/operators/index.cjs +0 -1
- package/dist/cjs/primitives/index.cjs +1 -2
- package/dist/cjs/transport/index.cjs +0 -1
- package/dist/esm/adapters/browser/index.js +1 -2
- package/dist/esm/adapters/memory/index.js +1 -2
- package/dist/esm/adapters/node/index.js +1 -2
- package/dist/esm/chunks/adapter-detect-BkCMnjrI.js +1 -0
- package/dist/esm/chunks/browser-http-transport-CSxAte5h.js +1 -0
- package/dist/esm/chunks/context-CumKOV7K.js +0 -1
- package/dist/esm/chunks/error-BotOd-nD.js +1 -0
- package/dist/esm/chunks/index-DsvINN8n.js +1 -0
- package/dist/esm/chunks/inflate-BCIXqeeE.js +1 -0
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js +0 -1
- package/dist/esm/chunks/memory-http-transport-caqmMGR1.js +1 -0
- package/dist/esm/chunks/node-ssh-transport-BgSv2IhT.js +1 -0
- package/dist/esm/chunks/{progress-BZobfl7p.js → progress-B_AJnOHx.js} +1 -2
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js +0 -1
- package/dist/esm/chunks/repository-DyxknzvE.js +1 -0
- package/dist/esm/chunks/write-sparse-checkout-BwHbNKNS.js +1 -0
- package/dist/esm/commands/index.js +1 -2
- package/dist/esm/index.browser.js +1 -2
- package/dist/esm/index.default.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.node.js +1 -2
- package/dist/esm/operators/index.js +0 -1
- package/dist/esm/primitives/index.js +1 -2
- package/dist/esm/transport/index.js +0 -1
- package/dist/types/adapters/browser/index.d.cts +5 -3
- package/dist/types/adapters/browser/index.d.ts +5 -3
- package/dist/types/adapters/memory/index.d.cts +31 -4
- package/dist/types/adapters/memory/index.d.ts +31 -4
- package/dist/types/adapters/node/index.d.cts +146 -40
- package/dist/types/adapters/node/index.d.ts +146 -40
- package/dist/types/chunks/{context-YDw6qicq.d.cts → context-CF1YF2S8.d.cts} +165 -6
- package/dist/types/chunks/{context-CCL0_F8R.d.ts → context-sIhhtk2u.d.ts} +165 -6
- package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
- package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
- package/dist/types/chunks/index-B5Dps3fg.d.ts +2468 -0
- package/dist/types/chunks/index-B_A8VLaf.d.ts +1221 -0
- package/dist/types/chunks/index-Dfh8cvEs.d.cts +2468 -0
- package/dist/types/chunks/index-Dqxddhav.d.cts +1221 -0
- package/dist/types/chunks/progress-BjAKfkam.d.ts +1217 -0
- package/dist/types/chunks/progress-Ldnfb8st.d.cts +1217 -0
- package/dist/types/chunks/reflog-entry-Cqh3QrPH.d.ts +697 -0
- package/dist/types/chunks/reflog-entry-Dy-O27Dd.d.cts +697 -0
- package/dist/types/chunks/{repository-FoS_Laoy.d.ts → repository-D8QBTkEz.d.ts} +58 -20
- package/dist/types/chunks/{repository-BeifCqp0.d.cts → repository-D9YrVhcH.d.cts} +58 -20
- package/dist/types/commands/index.d.cts +4 -1259
- package/dist/types/commands/index.d.ts +4 -1259
- package/dist/types/index.browser.d.cts +7 -8
- package/dist/types/index.browser.d.ts +7 -8
- package/dist/types/index.d.cts +61 -124
- package/dist/types/index.d.ts +61 -124
- package/dist/types/index.default.d.cts +7 -8
- package/dist/types/index.default.d.ts +7 -8
- package/dist/types/index.node.d.cts +7 -8
- package/dist/types/index.node.d.ts +7 -8
- package/dist/types/primitives/index.d.cts +4 -692
- package/dist/types/primitives/index.d.ts +4 -692
- package/dist/types/transport/index.d.cts +1 -1
- package/dist/types/transport/index.d.ts +1 -1
- package/package.json +94 -28
- package/dist/cjs/adapters/browser/index.cjs.map +0 -1
- package/dist/cjs/adapters/memory/index.cjs.map +0 -1
- package/dist/cjs/adapters/node/index.cjs.map +0 -1
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs +0 -2
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs.map +0 -1
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs +0 -2
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs.map +0 -1
- package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +0 -1
- package/dist/cjs/chunks/error-CfjFO3x_.cjs +0 -2
- package/dist/cjs/chunks/error-CfjFO3x_.cjs.map +0 -1
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs +0 -2
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs.map +0 -1
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs.map +0 -1
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs +0 -2
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs.map +0 -1
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs +0 -2
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs.map +0 -1
- package/dist/cjs/chunks/progress-CxU62NC1.cjs.map +0 -1
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs.map +0 -1
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs +0 -2
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs.map +0 -1
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs +0 -2
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs.map +0 -1
- package/dist/cjs/commands/index.cjs.map +0 -1
- package/dist/cjs/index.browser.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.default.cjs.map +0 -1
- package/dist/cjs/index.node.cjs.map +0 -1
- package/dist/cjs/operators/index.cjs.map +0 -1
- package/dist/cjs/primitives/index.cjs.map +0 -1
- package/dist/cjs/transport/index.cjs.map +0 -1
- package/dist/esm/adapters/browser/index.js.map +0 -1
- package/dist/esm/adapters/memory/index.js.map +0 -1
- package/dist/esm/adapters/node/index.js.map +0 -1
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js +0 -2
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js.map +0 -1
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js +0 -2
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js.map +0 -1
- package/dist/esm/chunks/context-CumKOV7K.js.map +0 -1
- package/dist/esm/chunks/error-Dc-SRSJK.js +0 -2
- package/dist/esm/chunks/error-Dc-SRSJK.js.map +0 -1
- package/dist/esm/chunks/index-jH0UMhh-.js +0 -2
- package/dist/esm/chunks/index-jH0UMhh-.js.map +0 -1
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js.map +0 -1
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js +0 -2
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js.map +0 -1
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js +0 -2
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js.map +0 -1
- package/dist/esm/chunks/progress-BZobfl7p.js.map +0 -1
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js.map +0 -1
- package/dist/esm/chunks/repository-DF6ePd1x.js +0 -2
- package/dist/esm/chunks/repository-DF6ePd1x.js.map +0 -1
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js +0 -2
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js.map +0 -1
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.default.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.node.js.map +0 -1
- package/dist/esm/operators/index.js.map +0 -1
- package/dist/esm/primitives/index.js.map +0 -1
- package/dist/esm/transport/index.js.map +0 -1
- package/dist/types/chunks/index-entry-DtEbVpOG.d.cts +0 -47
- package/dist/types/chunks/index-entry-UD4dvtKh.d.ts +0 -47
- package/dist/types/chunks/progress-7KKiXXfX.d.ts +0 -405
- package/dist/types/chunks/progress-By8yFaUE.d.cts +0 -405
- package/dist/types/chunks/reflog-entry-BbNnXCTC.d.cts +0 -368
- package/dist/types/chunks/reflog-entry-CSzjnZd4.d.ts +0 -368
- package/dist/types/chunks/write-tree-C3oNxOlX.d.cts +0 -196
- package/dist/types/chunks/write-tree-DRI-LzSr.d.ts +0 -196
package/dist/esm/index.node.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{realpath as
|
|
2
|
-
//# sourceMappingURL=index.node.js.map
|
|
1
|
+
import{realpath as e,stat as r}from"node:fs/promises";import*as o from"node:path";import{N as s,a as t,g as p,c as m,b as h,d as l,e as f,f as w,n as u}from"./chunks/node-ssh-transport-BgSv2IhT.js";import{S as k,c as j}from"./chunks/lru-cache-Cy7C7Lx2.js";import{o as g}from"./chunks/repository-DyxknzvE.js";export{d as detectRuntime,i as isBrowser,a as isNode}from"./chunks/adapter-detect-BkCMnjrI.js";export{c as consoleProgress,n as noopProgress}from"./chunks/progress-B_AJnOHx.js";export{F as FilePath,O as ObjectId,R as RefName}from"./chunks/write-sparse-checkout-BwHbNKNS.js";import"node:child_process";import"node:zlib";import"./chunks/error-BotOd-nD.js";import"node:fs";import"node:os";import"node:stream/promises";import"node:crypto";import"node:http";import"node:https";import"node:stream";import"./chunks/index-DsvINN8n.js";import"./chunks/readable-stream-CGuf8k1J.js";import"./transport/index.js";import"./primitives/index.js";const x=(e,r)=>e.slice(r.rootOf(e).length).split(r.sep).filter(Boolean),y=(e,r,o)=>void 0!==e&&o.normalizeForCompare(e)===o.normalizeForCompare(r),C=async(r={})=>{const a=r.cwd??process.cwd(),n=await e(o.resolve(a)).catch(()=>o.resolve(a)),i=await v(n)??{workDir:n,gitDir:o.join(n,".git"),bare:!1},c={fs:new p(i.workDir),hash:new w,compressor:new f,transport:new l({allowInsecureHttp:r.allowInsecureHttp??!1}),hooks:new t,command:new s,env:new h,ssh:new m,runtime:"node",layout:i,hashConfig:k,deltaCache:j(r.deltaCacheMaxBytes??16777216,r.deltaCacheMaxEntries??65536),makeWorktreeFs:e=>new p(((e,r)=>{const o=e.map(e=>r.resolve(e)),[s,...t]=o;if(void 0===s)return r.sep;const a=r.rootOf(s);if(!o.every(e=>r.normalizeForCompare(r.rootOf(e))===r.normalizeForCompare(a)))return s;const n=t.map(e=>x(e,r)),i=[];for(const e of x(s,r)){if(!n.every(o=>y(o[i.length],e,r)))break;i.push(e)}return a+i.join(r.sep)})([i.workDir,...e],u),u)},{cwd:d,allowInsecureHttp:C,deltaCacheMaxBytes:b,deltaCacheMaxEntries:D,...F}=r;return g({...F,cwd:n},c)},v=async e=>{let s=e;for(;;){const e=o.join(s,".git"),t=await r(e).catch(()=>{});if(t?.isDirectory())return{workDir:s,gitDir:e,bare:!1};const a=o.dirname(s);if(a===s)return;s=a}};export{C as openRepository};
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
export{r as readableStreamToAsyncIterable}from"../chunks/readable-stream-CGuf8k1J.js";function n(n){return async function*(t){for await(const r of t)await n(r)&&(yield r)}}function t(n){return async t=>{for await(const r of t)if(await n(r))return r}}function e(n){return async function*(t){for await(const r of t){const t=await n(r);for await(const n of t)yield n}}}function o(n,t=Number.POSITIVE_INFINITY){if(Number.isNaN(t)||t<0)throw new RangeError("groupBy(limit): must be a non-negative number or Infinity");return async r=>{const e=new Map;let o=0;for await(const a of r){if(o>=t)throw new RangeError(`groupBy: exceeded limit of ${t} items`);const r=await n(a),i=e.get(r);i?i.push(a):e.set(r,[a]),o+=1}return e}}function a(n){return async function*(t){for await(const r of t)yield await n(r)}}function i(n,...t){return t.reduce((n,t)=>t(n),n)}function u(n){if(!Number.isInteger(n)||n<0)throw new RangeError("take(count): count must be a non-negative integer");return async function*(t){if(0===n)return;let r=0;for await(const e of t)if(yield e,r+=1,r>=n)return}}async function f(n,t=Number.POSITIVE_INFINITY){if(Number.isNaN(t)||t<0)throw new RangeError("toArray(limit): must be a non-negative number or Infinity");const r=[];for await(const e of n){if(r.length>=t)throw new RangeError(`toArray: exceeded limit of ${t} items`);r.push(e)}return r}export{n as filter,t as find,e as flatMap,o as groupBy,a as map,i as pipe,u as take,f as toArray};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{b as a,ap as i,cc as c,cd as l}from"../chunks/write-sparse-checkout-BwHbNKNS.js";export{ce as DEFAULT_NOTES_REF,cf as MAX_SPARSE_PATTERN_FILE_BYTES,bW as appendReflog,bL as applyChangeset,c0 as applyConfigOpInText,bZ as buildIndexFromTree,aC as buildPack,E as catFileBatch,bf as compareWorkingTreeDelta,aO as compareWorkingTreeEntry,cg as computeChangeset,D as createCommit,c6 as createTag,bU as deleteReflog,B as diffTrees,bs as enumerateObjects,ca as enumeratePushObjects,aB as enumerateRefs,aZ as fetchPack,a3 as findFirstValuelessEntry,aQ as flattenTree,b5 as getAllConfigValues,b4 as getConfigValue,A as getRepoRoot,bi as hasObject,z as hashBlob,ch as invalidateConfigCache,ci as invalidateScopedConfigCache,bM as isWorkingTreeDirty,br as listReflogs,bG as loadNotesTree,a6 as loadSparseMatcher,a8 as materializeTree,b$ as materializeWorktreeFromHead,y as mergeBase,aU as parseIniSections,d as readBlob,a5 as readConfig,b6 as readConfigSections,be as readHeadTree,r as readIndex,g as readReflog,cj as readShallow,bN as readSparsePatternText,x as readTree,am as reflogExists,b8 as removeConfigSection,b9 as renameConfigSection,bF as resolveNotesRef,h as resolveRef,bV as resolveReflogIdentity,b2 as resolveSigningSelector,v as runHook,aH as runInformationalHook,ba as setConfigEntry,ck as setConfigEntryInText,cl as setCoreConfigEntryInText,b1 as signPayload,cm as sparseCheckoutPath,t as streamBlob,aJ as synthesizeTreeFromIndex,bc as unsetAllConfigEntries,bb as unsetConfigEntry,b0 as updateConfigEntries,bO as updateCoreConfig,s as updateRef,a_ as updateShallow,q as walkCommits,p as walkCommitsByDate,o as walkSubmodules,e as walkTree,w as walkWorkingTree,bH as writeNotesTree,n as writeObject,au as writeReflog,bS as writeSparsePatternText,m as writeTree}from"../chunks/write-sparse-checkout-BwHbNKNS.js";import{D as f,o as u}from"../chunks/error-BotOd-nD.js";import"../chunks/readable-stream-CGuf8k1J.js";const b=e=>{if(e<3)return 0;const a=Math.floor(Math.log2(e)),t=1<<a;return t<3*(e-t)?a:a-1},C=(e,a)=>{const t=new Set,s=[e];for(;s.length>0;){const e=s.pop();if(t.has(e))continue;const n=a.get(e);t.add(e);for(const e of n.parents)t.has(e)||s.push(e)}return t.size},T=(e,a)=>{const t=2*e-a;return t>=-1&&t<=1},k=(e,a,t)=>{if(a.has(e.id)||1!==e.parents.length)return;const s=a.get(e.parents[0]);if(void 0===s)return;const n=s+1;return a.set(e.id,n),T(n,t)?{nextCommit:e.id,candidateCount:t,reaches:n}:null},S=async(e,t)=>{const s=await a(e,t);if("commit"!==s.type)throw f(`bisectMidpoint: ${t} is not a commit`);return{date:s.data.committer.timestamp,parents:s.data.parents}},R=(e,a)=>e.date>a.date||e.date===a.date&&e.ins<a.ins,I=async(e,a,t)=>{const s=await(async(e,a)=>{const t=new Map,s=[...a];let n=0;for(;n<s.length;){const a=s[n++];if(t.has(a))continue;const r=await S(e,a);t.set(a,r);for(const e of r.parents)t.has(e)||s.push(e)}return t})(e,a),n=await(async(e,a,t)=>{const s=(e=>{const a=new Map;return async t=>{const s=a.get(t);if(void 0!==s)return s;const n=await S(e,t);return a.set(t,n),n}})(e),n=await s(a);if(t.has(a))return[];const r=await(async(e,a,t,s)=>{let n=0;const r=new Set,o=[],c=new i(R);for(c.push({id:a,date:t,ins:n++});c.size()>0;){const{id:a}=c.pop();if(r.has(a))continue;r.add(a);const t=await e(a);o.push({id:a,date:t.date,parents:t.parents});for(const a of t.parents){if(r.has(a)||s.has(a))continue;const t=await e(a);c.push({id:a,date:t.date,ins:n++})}}return o})(s,a,n.date,t);return(e=>{const a=new Set;for(const t of e)a.add(t.id);return e.slice().reverse().map(e=>({id:e.id,parents:e.parents.filter(e=>a.has(e)),date:e.date}))})(r)})(e,t,s),r=(e=>{if(0===e.length)return;const a=e.length,t=new Map(e.map(e=>[e.id,e])),s=new Map;((e,a)=>{for(const t of e)0===t.parents.length&&a.set(t.id,1)})(e,s);const n=((e,a,t,s)=>{for(const n of e){if(n.parents.length<2)continue;const e=C(n.id,a);if(t.set(n.id,e),T(e,s))return{nextCommit:n.id,candidateCount:s,reaches:e}}})(e,t,s,a);if(void 0!==n)return n;const r=((e,a,t)=>{let s=!0;for(;s;){s=!1;for(const n of e){const e=k(n,a,t);if(void 0!==e){if(null!==e)return e;s=!0}}}})(e,s,a);if(void 0!==r)return r;const o=((e,a,t)=>{const s=e[0],n=a.get(s.id);let r=s.id,o=Math.min(n,t-n),i=n;for(let s=1;s<e.length;s+=1){const n=e[s],c=a.get(n.id),d=Math.min(c,t-c);d>o&&(o=d,r=n.id,i=c)}return{id:r,weight:i}})(e,s,a);return{nextCommit:o.id,candidateCount:a,reaches:o.weight}})(n);return void 0===r?void 0:(e=>({nextCommit:e.nextCommit,candidateCount:e.candidateCount,remainingIfGood:e.candidateCount-e.reaches-1,remainingIfBad:e.reaches-1,remainingSteps:b(e.candidateCount)}))(r)},M=async(e,a)=>{if(e.signal?.aborted)throw u();if(0===a.length)return[];const t=await c(e),s=[...t.base],n=new Set,r=async e=>{for(const a of(e=>{const a=e.split("/");if(a.length<=1)return[];const t=[];for(let e=1;e<a.length;e+=1)t.push(a.slice(0,e).join("/"));return t})(e)){if(n.has(a))continue;n.add(a);const e=await t.loadDirRules(a);e.length>0&&s.push({basedir:a,rules:e,kind:"gitignore"})}},o=[];for(const t of a){if(e.signal?.aborted)throw u();await r(t.path);const a=l(s,t.path,!0===t.isDirectory);if("ignored"!==a.verdict||void 0===a.level||void 0===a.ruleIndex){o.push({path:t.path,ignored:!1});continue}const n=a.level.rules[a.ruleIndex];o.push(void 0!==n?{path:t.path,ignored:!0,source:{kind:a.level.kind??"gitignore",basedir:a.level.basedir,line:n.lineNumber,pattern:n.pattern}}:{path:t.path,ignored:!1})}return o};export{I as bisectMidpoint,M as isIgnored,a as readObject};
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
const e=new TextEncoder,r=r=>((e=>{"bearer"===e.type&&(e=>{if(""===e)throw new TypeError("withAuth: token is empty")})(e.token),"basic"===e.type&&(e=>{if(e.includes(":"))throw new TypeError('withAuth: basic username must not contain ":"')})(e.username)})(r),t=>({request:async o=>{if(Object.keys(o.headers).some(e=>"authorization"===e.toLowerCase()))return t.request(o);const s=await(async(r,t)=>{if("bearer"===r.type)return`Bearer ${r.token}`;if("basic"===r.type)return`Basic ${(r=>{const t=e.encode(r);let o="";for(let e=0;e<t.byteLength;e+=1)o+=String.fromCharCode(t[e]??0);return btoa(o)})(`${r.username}:${r.password}`)}`;const o=await r.header(t);if(""===o||null==o)throw new TypeError("withAuth: custom returned empty value");return o})(r,o);return t.request(((e,r)=>({...e,headers:{...e.headers,authorization:r}}))(o,s))}})),t=new Set(["authorization","cookie","set-cookie","proxy-authorization"]),o=/^(access[_-]?token|api[_-]?key|password|secret|token|sig|signature)$/i,s=(e,r)=>{const o=r.map(e=>e.toLowerCase()),s={};for(const[r,n]of Object.entries(e)){const e=r.toLowerCase();t.has(e)||o.includes(e)||(s[r]=n)}return s},n=(e,r)=>{try{e.log(r)}catch{}},a=e=>e instanceof Error?e.message:String(e),i=e=>{const r=e.now??(()=>performance.now()),t=e.redactHeaders??[];return i=>({request:async c=>{const u=(e=>{let r;try{r=new URL(e)}catch{return e}const t=[];for(const e of r.searchParams.keys())o.test(e)&&t.push(e);for(const e of t)r.searchParams.delete(e);return r.toString()})(c.url),h=s(c.headers,t),m=r();n(e.logger,((e,r,t)=>({kind:"request",method:e.method,url:r,headers:t,bodyBytes:e.body?.byteLength??0}))(c,u,h));try{const o=await i.request(c),a=s(o.headers,t);return n(e.logger,((e,r,t,o)=>({kind:"response",statusCode:e.statusCode,url:r,elapsedMs:t,headers:o}))(o,u,r()-m,a)),o}catch(t){throw n(e.logger,((e,r,t)=>({kind:"error",url:e,elapsedMs:r,errorMessage:a(t)}))(u,r()-m,t)),t}}})},c=({error:e,response:r})=>{return r?!((t=r.statusCode)<429||t>429&&t<500||501===t||t>=600):!(e instanceof DOMException&&"AbortError"===e.name)&&void 0!==e;var t},u=e=>{if(e)try{e.cancel().catch(()=>{})}catch{}},h=(e,r)=>r?.aborted?Promise.reject(r.reason):0===e?Promise.resolve():new Promise((t,o)=>{let s;const n=()=>{void 0!==s&&clearTimeout(s),o(r?.reason)};s=setTimeout(()=>{r?.removeEventListener("abort",n),t()},e),r&&r.addEventListener("abort",n,{once:!0})}),m=(e,r)=>{const t=r.baseMs??250,o=r.jitter??.2,s=Math.min("exponential"===(r.backoff??"fixed")?t*2**(e-1):t,r.maxDelayMs??3e4),n=1-o+2*o*Math.random();return Math.floor(s*n)},d=async(e,r)=>{try{return{response:await e.request(r)}}catch(e){return{error:e}}},w=e=>{if(void 0!==e.response)return e.response;throw e.error},p=(e,r)=>{return void 0!==e.outcome.error&&(t=e.outcome.error)instanceof DOMException&&"AbortError"===t.name||!!e.isLast||!r((o=e.outcome,s=e.attempt,void 0!==o.response?{response:o.response,attempt:s}:{error:o.error,attempt:s}));var t,o,s},y=e=>{(e=>{(e=>{if(!Number.isFinite(e)||!Number.isInteger(e)||e<1||e>10)throw new RangeError("withRetry: attempts must be 1..10")})(e.attempts),(e=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw new RangeError("withRetry: baseMs must be ≥ 0")})(e.baseMs),((e,r)=>{if(void 0===r)return;const t=e??250;if(!Number.isFinite(r)||r<t)throw new RangeError("withRetry: maxDelayMs must be ≥ baseMs")})(e.baseMs,e.maxDelayMs),(e=>{if(void 0!==e&&(!Number.isFinite(e)||e<0||e>1))throw new RangeError("withRetry: jitter must be in [0, 1]")})(e.jitter)})(e);const r=e.isRetryable??c,t=e.delay??h;return o=>({request:async s=>{if(s.signal?.aborted)throw s.signal.reason;let n={};for(let a=1;a<=e.attempts;a+=1){if(n=await d(o,s),p({attempt:a,isLast:a===e.attempts,outcome:n},r))return w(n);void 0!==n.response&&u(n.response.body),await t(m(a,e),s.signal)}return w(n)}})};export{r as withAuth,i as withLogging,y as withRetry};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as Context, a as Compressor, I as InflateStreamResult, g as FileSystem, f as FileStat, D as DirEntry, y as FileHandle, h as HashService, i as Hasher } from '../../chunks/context-CF1YF2S8.cjs';
|
|
2
|
+
import { b as HttpTransport, H as HttpRequest, a as HttpResponse } from '../../chunks/http-transport-DirKfK2S.cjs';
|
|
3
3
|
|
|
4
4
|
interface BrowserAdapterOptions {
|
|
5
5
|
readonly rootHandle: FileSystemDirectoryHandle;
|
|
@@ -12,7 +12,8 @@ interface BrowserAdapterOptions {
|
|
|
12
12
|
declare function createBrowserContext(options: BrowserAdapterOptions): Context;
|
|
13
13
|
|
|
14
14
|
declare class BrowserCompressor implements Compressor {
|
|
15
|
-
deflate(data: Uint8Array): Promise<Uint8Array>;
|
|
15
|
+
deflate(data: Uint8Array, _level?: number): Promise<Uint8Array>;
|
|
16
|
+
deflateRaw(data: Uint8Array, _level?: number): Promise<Uint8Array>;
|
|
16
17
|
inflate(data: Uint8Array): Promise<Uint8Array>;
|
|
17
18
|
streamInflate(bytes: Uint8Array, offset: number): Promise<InflateStreamResult>;
|
|
18
19
|
createInflateStream(): TransformStream<Uint8Array, Uint8Array>;
|
|
@@ -28,6 +29,7 @@ declare class BrowserFileSystem implements FileSystem {
|
|
|
28
29
|
readSlice(path: string, offset: number, length: number): Promise<Uint8Array>;
|
|
29
30
|
readUtf8(path: string): Promise<string>;
|
|
30
31
|
write(path: string, data: Uint8Array): Promise<void>;
|
|
32
|
+
writeStream(path: string, source: AsyncIterable<Uint8Array>): Promise<void>;
|
|
31
33
|
writeExclusive(path: string, data: Uint8Array): Promise<void>;
|
|
32
34
|
writeUtf8(path: string, content: string): Promise<void>;
|
|
33
35
|
appendUtf8(path: string, content: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as Context, a as Compressor, I as InflateStreamResult, g as FileSystem, f as FileStat, D as DirEntry, y as FileHandle, h as HashService, i as Hasher } from '../../chunks/context-sIhhtk2u.js';
|
|
2
|
+
import { b as HttpTransport, H as HttpRequest, a as HttpResponse } from '../../chunks/http-transport-DirKfK2S.js';
|
|
3
3
|
|
|
4
4
|
interface BrowserAdapterOptions {
|
|
5
5
|
readonly rootHandle: FileSystemDirectoryHandle;
|
|
@@ -12,7 +12,8 @@ interface BrowserAdapterOptions {
|
|
|
12
12
|
declare function createBrowserContext(options: BrowserAdapterOptions): Context;
|
|
13
13
|
|
|
14
14
|
declare class BrowserCompressor implements Compressor {
|
|
15
|
-
deflate(data: Uint8Array): Promise<Uint8Array>;
|
|
15
|
+
deflate(data: Uint8Array, _level?: number): Promise<Uint8Array>;
|
|
16
|
+
deflateRaw(data: Uint8Array, _level?: number): Promise<Uint8Array>;
|
|
16
17
|
inflate(data: Uint8Array): Promise<Uint8Array>;
|
|
17
18
|
streamInflate(bytes: Uint8Array, offset: number): Promise<InflateStreamResult>;
|
|
18
19
|
createInflateStream(): TransformStream<Uint8Array, Uint8Array>;
|
|
@@ -28,6 +29,7 @@ declare class BrowserFileSystem implements FileSystem {
|
|
|
28
29
|
readSlice(path: string, offset: number, length: number): Promise<Uint8Array>;
|
|
29
30
|
readUtf8(path: string): Promise<string>;
|
|
30
31
|
write(path: string, data: Uint8Array): Promise<void>;
|
|
32
|
+
writeStream(path: string, source: AsyncIterable<Uint8Array>): Promise<void>;
|
|
31
33
|
writeExclusive(path: string, data: Uint8Array): Promise<void>;
|
|
32
34
|
writeUtf8(path: string, content: string): Promise<void>;
|
|
33
35
|
appendUtf8(path: string, content: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { m as HookRunner, C as CommandRunner, e as EnvReader, c as Context, z as CommandRequest, B as CommandResult, a as Compressor, I as InflateStreamResult, g as FileSystem, f as FileStat, D as DirEntry, y as FileHandle, h as HashService, i as Hasher, j as HookName, l as HookResult, k as HookRequest } from '../../chunks/context-CF1YF2S8.cjs';
|
|
2
|
+
import { b as HttpTransport, H as HttpRequest, a as HttpResponse } from '../../chunks/http-transport-DirKfK2S.cjs';
|
|
3
3
|
|
|
4
4
|
interface MemoryAdapterOptions {
|
|
5
5
|
readonly files?: Readonly<Record<string, Uint8Array>>;
|
|
@@ -11,6 +11,10 @@ interface MemoryAdapterOptions {
|
|
|
11
11
|
readonly homeDir?: string;
|
|
12
12
|
/** Optional hook runner exposed via `ctx.hooks` (default: undefined — hooks inert). */
|
|
13
13
|
readonly hooks?: HookRunner;
|
|
14
|
+
/** Optional command runner exposed via `ctx.command` (default: undefined — drivers fall back). */
|
|
15
|
+
readonly command?: CommandRunner;
|
|
16
|
+
/** Optional environment-variable reader exposed via `ctx.env` (default: undefined — every var is unset). */
|
|
17
|
+
readonly env?: EnvReader;
|
|
14
18
|
/** Override for `fs.homedir()` (default: `'/home/user'`). */
|
|
15
19
|
readonly home?: string;
|
|
16
20
|
/** Override for `fs.xdgConfigHome()` (default: `'/home/user/.config'`). */
|
|
@@ -20,9 +24,25 @@ interface MemoryAdapterOptions {
|
|
|
20
24
|
}
|
|
21
25
|
declare function createMemoryContext(options?: MemoryAdapterOptions): Context;
|
|
22
26
|
|
|
27
|
+
/**
|
|
28
|
+
* In-memory `CommandRunner` test double. Constructed with a behaviour callback
|
|
29
|
+
* that simulates the driver (e.g. editing the `%A` file on the shared `ctx.fs`)
|
|
30
|
+
* and returns the exit code. Every invocation is recorded on `calls` so a test
|
|
31
|
+
* can assert the command, cwd, and env without spawning a process.
|
|
32
|
+
*/
|
|
33
|
+
declare class MemoryCommandRunner implements CommandRunner {
|
|
34
|
+
private readonly behaviour;
|
|
35
|
+
private readonly recorded;
|
|
36
|
+
constructor(behaviour?: (request: CommandRequest) => Promise<number> | number);
|
|
37
|
+
/** Every `CommandRequest` received, in invocation order. */
|
|
38
|
+
get calls(): ReadonlyArray<CommandRequest>;
|
|
39
|
+
run(request: CommandRequest): Promise<CommandResult>;
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
declare class MemoryCompressor implements Compressor {
|
|
24
43
|
constructor();
|
|
25
|
-
deflate: (data: Uint8Array) => Promise<Uint8Array>;
|
|
44
|
+
deflate: (data: Uint8Array, _level?: number) => Promise<Uint8Array>;
|
|
45
|
+
deflateRaw: (data: Uint8Array, _level?: number) => Promise<Uint8Array>;
|
|
26
46
|
inflate: (data: Uint8Array) => Promise<Uint8Array>;
|
|
27
47
|
streamInflate: (bytes: Uint8Array, offset: number) => Promise<InflateStreamResult>;
|
|
28
48
|
createInflateStream: () => TransformStream<Uint8Array, Uint8Array>;
|
|
@@ -52,6 +72,7 @@ declare class MemoryFileSystem implements FileSystem {
|
|
|
52
72
|
readSlice: (path: string, offset: number, length: number) => Promise<Uint8Array>;
|
|
53
73
|
readUtf8: (path: string) => Promise<string>;
|
|
54
74
|
write: (path: string, data: Uint8Array) => Promise<void>;
|
|
75
|
+
writeStream: (path: string, source: AsyncIterable<Uint8Array>) => Promise<void>;
|
|
55
76
|
writeExclusive: (path: string, data: Uint8Array) => Promise<void>;
|
|
56
77
|
writeUtf8: (path: string, content: string) => Promise<void>;
|
|
57
78
|
appendUtf8: (path: string, content: string) => Promise<void>;
|
|
@@ -66,6 +87,12 @@ declare class MemoryFileSystem implements FileSystem {
|
|
|
66
87
|
mkdir: (path: string) => Promise<void>;
|
|
67
88
|
rm: (path: string) => Promise<void>;
|
|
68
89
|
rename: (src: string, dst: string) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Move a directory subtree by re-keying every files/symlinks/times/directories
|
|
92
|
+
* entry at `src` or under `src/` to the corresponding `dst` path. Mirrors a
|
|
93
|
+
* POSIX directory rename (what the node adapter does natively).
|
|
94
|
+
*/
|
|
95
|
+
private renameDirectory;
|
|
69
96
|
readlink: (path: string) => Promise<string>;
|
|
70
97
|
symlink: (target: string, path: string) => Promise<void>;
|
|
71
98
|
chmod: (path: string, _mode: number) => Promise<void>;
|
|
@@ -127,5 +154,5 @@ declare class MemoryHttpTransport implements HttpTransport {
|
|
|
127
154
|
clearMocks(): void;
|
|
128
155
|
}
|
|
129
156
|
|
|
130
|
-
export { MemoryCompressor, MemoryFileSystem, MemoryHashService, MemoryHookRunner, MemoryHttpTransport, createMemoryContext };
|
|
157
|
+
export { MemoryCommandRunner, MemoryCompressor, MemoryFileSystem, MemoryHashService, MemoryHookRunner, MemoryHttpTransport, createMemoryContext };
|
|
131
158
|
export type { MemoryAdapterOptions, MemoryFileSystemOptions, MockSetup };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { m as HookRunner, C as CommandRunner, e as EnvReader, c as Context, z as CommandRequest, B as CommandResult, a as Compressor, I as InflateStreamResult, g as FileSystem, f as FileStat, D as DirEntry, y as FileHandle, h as HashService, i as Hasher, j as HookName, l as HookResult, k as HookRequest } from '../../chunks/context-sIhhtk2u.js';
|
|
2
|
+
import { b as HttpTransport, H as HttpRequest, a as HttpResponse } from '../../chunks/http-transport-DirKfK2S.js';
|
|
3
3
|
|
|
4
4
|
interface MemoryAdapterOptions {
|
|
5
5
|
readonly files?: Readonly<Record<string, Uint8Array>>;
|
|
@@ -11,6 +11,10 @@ interface MemoryAdapterOptions {
|
|
|
11
11
|
readonly homeDir?: string;
|
|
12
12
|
/** Optional hook runner exposed via `ctx.hooks` (default: undefined — hooks inert). */
|
|
13
13
|
readonly hooks?: HookRunner;
|
|
14
|
+
/** Optional command runner exposed via `ctx.command` (default: undefined — drivers fall back). */
|
|
15
|
+
readonly command?: CommandRunner;
|
|
16
|
+
/** Optional environment-variable reader exposed via `ctx.env` (default: undefined — every var is unset). */
|
|
17
|
+
readonly env?: EnvReader;
|
|
14
18
|
/** Override for `fs.homedir()` (default: `'/home/user'`). */
|
|
15
19
|
readonly home?: string;
|
|
16
20
|
/** Override for `fs.xdgConfigHome()` (default: `'/home/user/.config'`). */
|
|
@@ -20,9 +24,25 @@ interface MemoryAdapterOptions {
|
|
|
20
24
|
}
|
|
21
25
|
declare function createMemoryContext(options?: MemoryAdapterOptions): Context;
|
|
22
26
|
|
|
27
|
+
/**
|
|
28
|
+
* In-memory `CommandRunner` test double. Constructed with a behaviour callback
|
|
29
|
+
* that simulates the driver (e.g. editing the `%A` file on the shared `ctx.fs`)
|
|
30
|
+
* and returns the exit code. Every invocation is recorded on `calls` so a test
|
|
31
|
+
* can assert the command, cwd, and env without spawning a process.
|
|
32
|
+
*/
|
|
33
|
+
declare class MemoryCommandRunner implements CommandRunner {
|
|
34
|
+
private readonly behaviour;
|
|
35
|
+
private readonly recorded;
|
|
36
|
+
constructor(behaviour?: (request: CommandRequest) => Promise<number> | number);
|
|
37
|
+
/** Every `CommandRequest` received, in invocation order. */
|
|
38
|
+
get calls(): ReadonlyArray<CommandRequest>;
|
|
39
|
+
run(request: CommandRequest): Promise<CommandResult>;
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
declare class MemoryCompressor implements Compressor {
|
|
24
43
|
constructor();
|
|
25
|
-
deflate: (data: Uint8Array) => Promise<Uint8Array>;
|
|
44
|
+
deflate: (data: Uint8Array, _level?: number) => Promise<Uint8Array>;
|
|
45
|
+
deflateRaw: (data: Uint8Array, _level?: number) => Promise<Uint8Array>;
|
|
26
46
|
inflate: (data: Uint8Array) => Promise<Uint8Array>;
|
|
27
47
|
streamInflate: (bytes: Uint8Array, offset: number) => Promise<InflateStreamResult>;
|
|
28
48
|
createInflateStream: () => TransformStream<Uint8Array, Uint8Array>;
|
|
@@ -52,6 +72,7 @@ declare class MemoryFileSystem implements FileSystem {
|
|
|
52
72
|
readSlice: (path: string, offset: number, length: number) => Promise<Uint8Array>;
|
|
53
73
|
readUtf8: (path: string) => Promise<string>;
|
|
54
74
|
write: (path: string, data: Uint8Array) => Promise<void>;
|
|
75
|
+
writeStream: (path: string, source: AsyncIterable<Uint8Array>) => Promise<void>;
|
|
55
76
|
writeExclusive: (path: string, data: Uint8Array) => Promise<void>;
|
|
56
77
|
writeUtf8: (path: string, content: string) => Promise<void>;
|
|
57
78
|
appendUtf8: (path: string, content: string) => Promise<void>;
|
|
@@ -66,6 +87,12 @@ declare class MemoryFileSystem implements FileSystem {
|
|
|
66
87
|
mkdir: (path: string) => Promise<void>;
|
|
67
88
|
rm: (path: string) => Promise<void>;
|
|
68
89
|
rename: (src: string, dst: string) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Move a directory subtree by re-keying every files/symlinks/times/directories
|
|
92
|
+
* entry at `src` or under `src/` to the corresponding `dst` path. Mirrors a
|
|
93
|
+
* POSIX directory rename (what the node adapter does natively).
|
|
94
|
+
*/
|
|
95
|
+
private renameDirectory;
|
|
69
96
|
readlink: (path: string) => Promise<string>;
|
|
70
97
|
symlink: (target: string, path: string) => Promise<void>;
|
|
71
98
|
chmod: (path: string, _mode: number) => Promise<void>;
|
|
@@ -127,5 +154,5 @@ declare class MemoryHttpTransport implements HttpTransport {
|
|
|
127
154
|
clearMocks(): void;
|
|
128
155
|
}
|
|
129
156
|
|
|
130
|
-
export { MemoryCompressor, MemoryFileSystem, MemoryHashService, MemoryHookRunner, MemoryHttpTransport, createMemoryContext };
|
|
157
|
+
export { MemoryCommandRunner, MemoryCompressor, MemoryFileSystem, MemoryHashService, MemoryHookRunner, MemoryHttpTransport, createMemoryContext };
|
|
131
158
|
export type { MemoryAdapterOptions, MemoryFileSystemOptions, MockSetup };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as Context, C as CommandRunner, z as CommandRequest, B as CommandResult, a as Compressor, I as InflateStreamResult, g as FileSystem, f as FileStat, D as DirEntry, y as FileHandle, h as HashService, i as Hasher, m as HookRunner, k as HookRequest, l as HookResult } from '../../chunks/context-CF1YF2S8.cjs';
|
|
2
|
+
import { b as HttpTransport, H as HttpRequest, a as HttpResponse } from '../../chunks/http-transport-DirKfK2S.cjs';
|
|
3
3
|
|
|
4
4
|
interface NodeAdapterOptions {
|
|
5
5
|
readonly workDir: string;
|
|
@@ -15,9 +15,62 @@ interface NodeAdapterOptions {
|
|
|
15
15
|
* `process.env` — disable it for repositories you do not trust.
|
|
16
16
|
*/
|
|
17
17
|
readonly hooks?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Wire the merge-driver command runner (default true). Pass `false` to
|
|
20
|
+
* disable external merge drivers. A wired runner executes the configured
|
|
21
|
+
* `[merge "<driver>"].driver` shell command with the full `process.env`.
|
|
22
|
+
*/
|
|
23
|
+
readonly command?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Wire the ssh transport (default true). Pass `false` to refuse ssh/scp
|
|
26
|
+
* remotes. A wired transport spawns the resolved ssh command
|
|
27
|
+
* (`GIT_SSH_COMMAND`/`GIT_SSH`/`core.sshCommand`, else `ssh`) inheriting
|
|
28
|
+
* the full `process.env`.
|
|
29
|
+
*/
|
|
30
|
+
readonly ssh?: boolean;
|
|
18
31
|
}
|
|
19
32
|
declare function createNodeContext(options: NodeAdapterOptions): Context;
|
|
20
33
|
|
|
34
|
+
/** Minimal child-process surface `NodeCommandRunner` consumes. */
|
|
35
|
+
interface CommandChild {
|
|
36
|
+
on(event: 'error', listener: (err: Error) => void): void;
|
|
37
|
+
on(event: 'close', listener: (code: number | null) => void): void;
|
|
38
|
+
kill(): void;
|
|
39
|
+
readonly stdin: {
|
|
40
|
+
write(chunk: Uint8Array): void;
|
|
41
|
+
end(): void;
|
|
42
|
+
};
|
|
43
|
+
readonly stdout: {
|
|
44
|
+
on(event: 'data', listener: (chunk: Uint8Array) => void): void;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Injectable process surface. Production uses `node:child_process` spawn; unit
|
|
49
|
+
* tests inject a fake so every branch runs deterministically without a real
|
|
50
|
+
* process (mirrors `HookRunnerOps`).
|
|
51
|
+
*/
|
|
52
|
+
interface CommandRunnerOps {
|
|
53
|
+
readonly spawn: (command: string, args: ReadonlyArray<string>, options: {
|
|
54
|
+
readonly cwd: string;
|
|
55
|
+
readonly env: NodeJS.ProcessEnv;
|
|
56
|
+
readonly stdio: ['pipe', 'pipe', 'inherit'];
|
|
57
|
+
}) => CommandChild;
|
|
58
|
+
}
|
|
59
|
+
declare const realCommandRunnerOps: CommandRunnerOps;
|
|
60
|
+
/**
|
|
61
|
+
* Node `CommandRunner`: runs a command line through the platform shell
|
|
62
|
+
* (`sh -c` on POSIX, `cmd /c` on Windows) with `cwd` and an environment that
|
|
63
|
+
* merges `request.env` over `process.env`. Stdin is piped from `request.stdin`
|
|
64
|
+
* when present; stdout is captured into `result.stdout`. Never rejects for a
|
|
65
|
+
* non-zero exit.
|
|
66
|
+
*/
|
|
67
|
+
declare class NodeCommandRunner implements CommandRunner {
|
|
68
|
+
private readonly isWindows;
|
|
69
|
+
private readonly ops;
|
|
70
|
+
constructor(platform?: NodeJS.Platform, ops?: CommandRunnerOps);
|
|
71
|
+
run(request: CommandRequest): Promise<CommandResult>;
|
|
72
|
+
}
|
|
73
|
+
|
|
21
74
|
interface NodeCompressorOptions {
|
|
22
75
|
/** Override the inflated-output cap. Tests use a small value to exercise the overflow branch. */
|
|
23
76
|
readonly maxInflatedBytes?: number;
|
|
@@ -25,7 +78,8 @@ interface NodeCompressorOptions {
|
|
|
25
78
|
declare class NodeCompressor implements Compressor {
|
|
26
79
|
private readonly maxInflatedBytes;
|
|
27
80
|
constructor(options?: NodeCompressorOptions);
|
|
28
|
-
deflate: (data: Uint8Array) => Promise<Uint8Array>;
|
|
81
|
+
deflate: (data: Uint8Array, level?: number) => Promise<Uint8Array>;
|
|
82
|
+
deflateRaw: (data: Uint8Array, level?: number) => Promise<Uint8Array>;
|
|
29
83
|
inflate: (data: Uint8Array) => Promise<Uint8Array>;
|
|
30
84
|
streamInflate: (bytes: Uint8Array, offset: number) => Promise<InflateStreamResult>;
|
|
31
85
|
createInflateStream: () => TransformStream<Uint8Array, Uint8Array>;
|
|
@@ -95,61 +149,86 @@ declare class NodeFileSystem implements FileSystem {
|
|
|
95
149
|
private readonly fsOps;
|
|
96
150
|
/**
|
|
97
151
|
* Memoised realpath of an *existing* parent directory, keyed by the raw
|
|
98
|
-
* (pre-realpath) parent path
|
|
99
|
-
* `
|
|
100
|
-
*
|
|
101
|
-
*
|
|
152
|
+
* (pre-realpath) parent path, paired with that parent's containment
|
|
153
|
+
* verdict (`isContainedInEitherRoot(realParent, …)`, computed once right
|
|
154
|
+
* after the realpath resolves). The cached value is mode-independent, so
|
|
155
|
+
* this single cache serves BOTH `resolveForCreation` (creation mode) and
|
|
156
|
+
* `resolveForMode`'s lstat arm (lstat mode): a clone/checkout writing N
|
|
157
|
+
* files into the same tree, or a status walk lstat-ing N entries under
|
|
158
|
+
* the same directory, pays the realpath walk-up — and, for the lstat
|
|
159
|
+
* arm, the containment POST-check — once per parent rather than once per
|
|
160
|
+
* file/entry. The verdict is a per-clean-leaf equivalence
|
|
161
|
+
* (`isContainedInEitherRoot(join(realParent, basename))` ≡
|
|
162
|
+
* `isContainedInEitherRoot(realParent)`, see the design doc's proof) and
|
|
163
|
+
* is consulted ONLY by the lstat arm; `read`/`creation` realpath the full
|
|
164
|
+
* leaf and keep their own per-entry post-check.
|
|
102
165
|
*
|
|
103
166
|
* Invariants:
|
|
104
167
|
* - Only EXISTING parents are cached. ENOENT walks fall back to
|
|
105
|
-
* `realpathNearestExisting` and are
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
168
|
+
* `realpathNearestExisting` (creation) or propagate (lstat) and are
|
|
169
|
+
* never recorded.
|
|
170
|
+
* - The realpath and the verdict are set together — never divergent.
|
|
171
|
+
* - `rmRecursive` and `rename` clear the cache (invalidating BOTH the
|
|
172
|
+
* realpath and the verdict), which is correct (the parent realpath may
|
|
173
|
+
* have changed) and cheap relative to a re-walk. `rm` clears neither —
|
|
174
|
+
* a leaf removal does not change the parent's realpath or containment.
|
|
175
|
+
* - Sized to exceed the 256 loose-object fanout directories so a
|
|
176
|
+
* full-history walk does not thrash the cache.
|
|
109
177
|
*/
|
|
110
|
-
private readonly
|
|
178
|
+
private readonly parentRealpathCache;
|
|
111
179
|
/**
|
|
112
|
-
* Lazy long-name canonicalisation of `rootDir` for containment checks
|
|
113
|
-
*
|
|
114
|
-
* rejection so a transient
|
|
180
|
+
* Lazy long-name canonicalisation of `rootDir` for containment checks,
|
|
181
|
+
* resolving to the canonical root's `RootPrefix`. Promise so concurrent
|
|
182
|
+
* first calls share one `realpath`; cleared on rejection so a transient
|
|
183
|
+
* ENOENT can be retried.
|
|
115
184
|
*/
|
|
116
185
|
private canonicalRootPromise;
|
|
117
186
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
187
|
+
* Synchronous cache of the resolved canonical-root `RootPrefix`, set on
|
|
188
|
+
* `getCanonicalRoot()`'s promise-resolution arm and cleared on its
|
|
189
|
+
* rejection arm — always in lockstep with `canonicalRootPromise`. Lets
|
|
190
|
+
* hot-path callers (`checkContainment`, `exists`, `symlink`) read the
|
|
191
|
+
* settled value directly, without an `await` (and its microtask), once
|
|
192
|
+
* the root has resolved at least once.
|
|
121
193
|
*/
|
|
122
|
-
private
|
|
194
|
+
private resolvedCanonicalRootPrefix;
|
|
123
195
|
/**
|
|
124
|
-
* Memoised
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* canonical root).
|
|
196
|
+
* Memoised `{ normalized, withSep }` pair for `pathPolicy.normalizeForCompare(rootDir)`.
|
|
197
|
+
* The rootDir is `readonly` for the adapter's lifetime, so a single
|
|
198
|
+
* normalisation (and its `+sep` prefix) is amortised across every
|
|
199
|
+
* containment check. Bundled in one field — never two — so the prefix
|
|
200
|
+
* can never diverge from the root it was derived from.
|
|
130
201
|
*/
|
|
131
|
-
private
|
|
202
|
+
private normalizedRootDirPrefix;
|
|
132
203
|
constructor(rootDir: string, pathPolicy?: PathPolicy, fsOps?: FsOperations);
|
|
204
|
+
/**
|
|
205
|
+
* Lazily normalises `rootDir` and its `+sep` prefix as one bundled
|
|
206
|
+
* `RootPrefix`, memoised for the adapter's lifetime.
|
|
207
|
+
*/
|
|
208
|
+
private getRootDirPrefix;
|
|
133
209
|
private getNormalizedRootDir;
|
|
134
210
|
/**
|
|
135
|
-
*
|
|
136
|
-
* `
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* Kept synchronous (vs `async` + `await this.getCanonicalRoot()`
|
|
141
|
-
* inside) so the hot path doesn't pay an extra microtask suspension
|
|
142
|
-
* per containment check on a settled promise. The `!` is the only
|
|
143
|
-
* machine-readable form of "trust the post-await invariant"; the
|
|
144
|
-
* private `await getCanonicalRoot()` discipline at every call site is
|
|
145
|
-
* what makes it safe.
|
|
211
|
+
* Resolves and memoises the canonical-root `RootPrefix`. Returns the
|
|
212
|
+
* bundled `{ normalized, withSep }` value directly from the promise
|
|
213
|
+
* chain — callers thread the returned value onward, so there is no
|
|
214
|
+
* synchronous "trust it's been set" field read: the type system proves
|
|
215
|
+
* the value is defined via the `await`'s return, not a nullable field.
|
|
146
216
|
*/
|
|
147
|
-
private getResolvedNormalizedCanonicalRoot;
|
|
148
217
|
private getCanonicalRoot;
|
|
218
|
+
/**
|
|
219
|
+
* Synchronous-first-path accessor for the canonical root: returns the
|
|
220
|
+
* already-settled `resolvedCanonicalRootPrefix` field when populated (no
|
|
221
|
+
* `await`, no microtask), falling back to `getCanonicalRoot()` only on
|
|
222
|
+
* the first call or after a rejection cleared the field. Used by every
|
|
223
|
+
* hot-path call site (`checkContainment`, `exists`, `symlink`) instead of
|
|
224
|
+
* an unconditional `await this.getCanonicalRoot()`.
|
|
225
|
+
*/
|
|
226
|
+
private resolveCanonicalRoot;
|
|
149
227
|
read: (path: string) => Promise<Uint8Array>;
|
|
150
228
|
readSlice: (path: string, offset: number, length: number) => Promise<Uint8Array>;
|
|
151
229
|
readUtf8: (path: string) => Promise<string>;
|
|
152
230
|
write: (path: string, data: Uint8Array) => Promise<void>;
|
|
231
|
+
writeStream: (path: string, source: AsyncIterable<Uint8Array>) => Promise<void>;
|
|
153
232
|
writeExclusive: (path: string, data: Uint8Array) => Promise<void>;
|
|
154
233
|
writeUtf8: (path: string, content: string) => Promise<void>;
|
|
155
234
|
appendUtf8: (path: string, content: string) => Promise<void>;
|
|
@@ -168,8 +247,35 @@ declare class NodeFileSystem implements FileSystem {
|
|
|
168
247
|
private isSymlinkLeaf;
|
|
169
248
|
private removeTree;
|
|
170
249
|
private resolveForCreation;
|
|
250
|
+
private cachedParentRealpath;
|
|
171
251
|
private realpathForCreation;
|
|
252
|
+
/**
|
|
253
|
+
* Resolves `resolved` to its real, containment-checkable form. `contained`
|
|
254
|
+
* is `undefined` for `read`/`creation` — those arms realpath a full leaf,
|
|
255
|
+
* so `checkContainment` still runs its own per-entry POST-check on the
|
|
256
|
+
* returned `real`. For `lstat`, `contained` carries the per-parent
|
|
257
|
+
* verdict `cachedParentRealpath` already computed (once per parent,
|
|
258
|
+
* proven verdict-identical to a per-entry check for a single clean leaf)
|
|
259
|
+
* — `checkContainment` consults it directly instead of re-normalising.
|
|
260
|
+
*/
|
|
172
261
|
private resolveForMode;
|
|
262
|
+
/**
|
|
263
|
+
* `abs` is normalised ONCE (not once per root) and compared against
|
|
264
|
+
* both roots' precomputed `+sep` prefixes. Both the `=== root` equality
|
|
265
|
+
* arm and the `startsWith(root + sep)` prefix arm are retained per
|
|
266
|
+
* root — dropping either changes the verdict (a bare `startsWith(root)`
|
|
267
|
+
* would admit the prefix-only sibling `root-evil`). Both roots are
|
|
268
|
+
* passed in as already-resolved `RootPrefix` values — no field read-back.
|
|
269
|
+
*/
|
|
270
|
+
private isContainedInEitherRoot;
|
|
271
|
+
/**
|
|
272
|
+
* Single source of truth for the two-root, two-arm containment test —
|
|
273
|
+
* `isContainedInEitherRoot` and the lstat arm's PRE-check both delegate
|
|
274
|
+
* here so the "is `abs` exactly one of the roots" fact (needed by the
|
|
275
|
+
* lstat arm's exact-root shortcut) is derived from the SAME normalise
|
|
276
|
+
* call as the containment verdict, not a second one.
|
|
277
|
+
*/
|
|
278
|
+
private containmentVerdict;
|
|
173
279
|
private checkContainment;
|
|
174
280
|
homedir(): string;
|
|
175
281
|
xdgConfigHome(): string;
|
|
@@ -249,5 +355,5 @@ declare class NodeHttpTransport implements HttpTransport {
|
|
|
249
355
|
request: (req: HttpRequest) => Promise<HttpResponse>;
|
|
250
356
|
}
|
|
251
357
|
|
|
252
|
-
export { NodeCompressor, NodeFileSystem, NodeHashService, NodeHookRunner, NodeHttpTransport, createNodeContext };
|
|
253
|
-
export type { NodeAdapterOptions, NodeHttpTransportOptions };
|
|
358
|
+
export { NodeCommandRunner, NodeCompressor, NodeFileSystem, NodeHashService, NodeHookRunner, NodeHttpTransport, createNodeContext, realCommandRunnerOps };
|
|
359
|
+
export type { CommandRunnerOps, NodeAdapterOptions, NodeHttpTransportOptions };
|