MCPcopy Create free account
hub / github.com/ChinaSiro/claude-code-sourcemap / izY

Function izY

package/cli.js:4686–4703  ·  view source on GitHub ↗
(q,K,_,z)

Source from the content-addressed store, hash-verified

4684
4685Original error: ${q.stderr}`};if(q.stderr.includes("timed out")||q.stderr.includes("Could not resolve host"))return{...q,stderr:`Network error while updating marketplace. Please check your internet connection.
4686
4687Original error: ${q.stderr}`};return q}async function tfK(){try{let q=await a8("ssh",["-T","-o","BatchMode=yes","-o","ConnectTimeout=2","-o","StrictHostKeyChecking=yes","git@github.com"],{timeout:3000}),K=q.code===1&&(q.stderr?.includes("successfully authenticated")||q.stdout?.includes("successfully authenticated"));return N(`SSH config check: code=${q.code} configured=${K}`),K}catch(q){return N(`SSH configuration check failed: ${d6(q)}`,{level:"warn"}),!1}}function nzY(q){return q.includes("Authentication failed")||q.includes("could not read Username")||q.includes("terminal prompts disabled")||q.includes("403")||q.includes("401")}function afK(q){return q.match(/^[^@]+@([^:]+):/)?.[1]??null}async function izY(q,K,_,z){let Y=z&&z.length>0,$=["-c","core.sshCommand=ssh -o BatchMode=yes -o StrictHostKeyChecking=yes","clone","--depth","1"];if(Y)$.push("--filter=blob:none","--no-checkout");else $.push("--recurse-submodules","--shallow-submodules");if(_)$.push("--branch",_);$.push(q,K);let A=ga();N(`git clone: url=${EH6(q)} ref=${_??"default"} timeout=${A}ms`);let O=await S7(L7(),$,{timeout:A,stdin:"ignore",env:{...process.env,...b18}}),w=EH6(q);if(q!==w){if(O.error)O.error=O.error.replaceAll(q,w);if(O.stderr)O.stderr=O.stderr.replaceAll(q,w)}if(O.code===0){if(Y){let j=await S7(L7(),["sparse-checkout","set","--cone","--",...z],{cwd:K,timeout:A,stdin:"ignore",env:{...process.env,...b18}});if(j.code!==0)return{code:j.code,stderr:`git sparse-checkout set failed: ${j.stderr}`};let H=await S7(L7(),["checkout","HEAD"],{cwd:K,timeout:A,stdin:"ignore",env:{...process.env,...b18}});if(H.code!==0)return{code:H.code,stderr:`git checkout after sparse-checkout failed: ${H.stderr}`}}return N(`git clone succeeded: ${EH6(q)}`),O}if(N(`git clone failed: url=${EH6(q)} code=${O.code} error=${O.error??"none"} stderr=${O.stderr}`,{level:"warn"}),O.error?.includes("timed out"))return{...O,stderr:`Git clone timed out after ${Math.round(A/1000)}s. The repository may be too large for the current timeout. Set CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS to increase it (e.g., 300000 for 5 minutes).
4688
4689Original error: ${O.stderr}`};if(O.stderr){if(O.stderr.includes("REMOTE HOST IDENTIFICATION HAS CHANGED")){let j=afK(q),H=j?`ssh-keygen -R ${j}`:"ssh-keygen -R <host>";return{...O,stderr:`SSH host key has changed (server key rotation or possible MITM). Remove the stale known_hosts entry:
4690 ${H}
4691Then connect once manually to verify and accept the new key.
4692
4693Original error: ${O.stderr}`}}if(O.stderr.includes("Host key verification failed")){let j=afK(q),H=j?`ssh -T git@${j}`:"ssh -T git@<host>";return{...O,stderr:`SSH host key is not in your known_hosts file. To add it, connect once manually (this will show the fingerprint for you to verify):
4694 ${H}
4695
4696Or use an HTTPS URL instead (recommended for public repos).
4697
4698Original error: ${O.stderr}`}}if(O.stderr.includes("Permission denied (publickey)")||O.stderr.includes("Could not read from remote repository"))return{...O,stderr:`SSH authentication failed. Please ensure your SSH keys are configured for GitHub, or use an HTTPS URL instead.
4699
4700Original error: ${O.stderr}`};if(nzY(O.stderr))return{...O,stderr:`HTTPS authentication failed. Please ensure your credential helper is configured (e.g., gh auth login).
4701
4702Original error: ${O.stderr}`};if(O.stderr.includes("timed out")||O.stderr.includes("timeout")||O.stderr.includes("Could not resolve host"))return{...O,stderr:`Network error or timeout while cloning repository. Please check your internet connection and try again.
4703
4704Original error: ${O.stderr}`}}if(!O.stderr)return{code:O.code,stderr:O.error||`git clone exited with code ${O.code} (no stderr output). Run with --debug to see the full command.`};return O}function Cb(q,K){if(!q)return;try{q(K)}catch(_){N(`Progress callback error: ${d6(_)}`,{level:"warn"})}}async function rzY(q,K){let _={...process.env,...b18};if(K&&K.length>0)return S7(L7(),["sparse-checkout","set","--cone","--",...K],{cwd:q,timeout:ga(),stdin:"ignore",env:_});let z=await S7(L7(),["config","--get","core.sparseCheckout"],{cwd:q,stdin:"ignore",env:_});if(z.code===0&&z.stdout.trim()==="true")return{code:1,stderr:"sparsePaths removed from config but repository is sparse; re-cloning for full checkout"};return{code:0,stderr:""}}async function Ba(q,K,_,z,Y,$){let A=X8(),O=Math.round(ga()/1000);Cb(Y,`Refreshing marketplace cache (timeout: ${O}s)…`);let w=await rzY(K,z);if(w.code===0){let M=performance.now(),X=await lzY(K,_,{disableCredentialHelper:$?.disableCredentialHelper,sparsePaths:z});if(KD("marketplace_pull",q,X.code===0?"success":"failure",performance.now()-M,X.code===0?void 0:zC(X.stderr)),X.code===0)return;N(`git pull failed, will re-clone: ${X.stderr}`,{level:"warn"})}else N(`sparse-checkout reconcile requires re-clone: ${w.stderr}`);try{await A.rm(K,{recursive:!0}),N(`Found stale marketplace directory at ${K}, cleaning up to allow re-clone`,{level:"warn"}),Cb(Y,"Found stale directory, cleaning up and re-cloning…")}catch(M){if(!_7(M)){let X=d6(M);throw Error(`Failed to clean up existing marketplace directory. Please manually delete the directory at ${K} and try again.
4705
4706Technical details: ${X}`)}}let j=_?` (ref: ${_})`:"";Cb(Y,`Cloning repository (timeout: ${O}s): ${EH6(q)}${j}`);let H=performance.now(),J=await izY(q,K,_,z);if(KD("marketplace_clone",q,J.code===0?"success":"failure",performance.now()-H,J.code===0?void 0:zC(J.stderr)),J.code!==0){try{await A.rm(K,{recursive:!0,force:!0})}catch{}throw Error(`Failed to clone marketplace repository: ${J.stderr}`)}Cb(Y,"Clone complete, validating marketplace…")}function ozY(q){return Object.fromEntries(Object.entries(q).map(([K])=>[K,"***REDACTED***"]))}function EH6(q){try{let K=new URL(q);if((K.protocol==="http:"||K.protocol==="https:")&&(K.username||K.password)){if(K.username)K.username="***";if(K.password)K.password="***";return K.toString()}}catch{}return q}async function efK(q,K,_,z){let Y=X8(),$=EH6(q);if(Cb(z,`Downloading marketplace from ${$}`),N(`Downloading marketplace from URL: ${$}`),_&&Object.keys(_).length>0)N(`Using custom headers: ${g6(ozY(_))}`);let A={..._,"User-Agent":"Claude-Code-Plugin-Manager"},O,w=performance.now();try{O=await $1.get(q,{timeout:1e4,headers:A})}catch(J){if(KD("marketplace_url",q,"failure",performance.now()-w,zC(J)),$1.isAxiosError(J)){if(J.code==="ECONNREFUSED"||J.code==="ENOTFOUND")throw Error(`Could not connect to ${$}. Please check your internet connection and verify the URL is correct.

Callers 1

BaFunction · 0.85

Calls 8

gaFunction · 0.85
NFunction · 0.85
EH6Function · 0.85
S7Function · 0.85
afKFunction · 0.85
nzYFunction · 0.85
includesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected