phala 1.1.3-beta.1 → 1.1.3
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -386,7 +386,7 @@ complete -c ${e} -f -a "(__${e}_complete)"
|
|
|
386
386
|
Supported fields: id, uuid, app_id, or instance_id`),1;let o=e["--"]??[],n=MA(o);if(n)return l.error(`${n} is not allowed as it would break the TLS gateway connection.`),1;let s=e.gatewayDomain??t.projectConfig.gateway_domain,i=e.port!=="443"?e.port:t.projectConfig.gateway_port?.toString()??"443",a,c;if(s)c=s,a=r.startsWith("app_")?r.substring(4):r;else try{let x=await W(),w=await cf(x,r);a=w.appId,c=w.gatewayDomain,af(w.baseImage)||l.warn("This CVM is not using a dev image. SSH access may not be available.")}catch(x){return x instanceof On?l.error(x.message):x instanceof zn?(l.error(x.message),l.info("Please start the CVM first using: phala cvms start")):l.error(x instanceof Error?x.message:"Failed to fetch CVM info"),1}let m=sf(c),u=uf(i,m.port),p=mf(a,m.host),f=C0();f&&ff(f),e.verbose&&l.info(`Connecting to ${BA.cyan(p)}:${u}...`);let d=lf(e.verbose,e.timeout),{options:h,command:g}=DA(o),y=[];if(e.verbose&&y.push("-v"),y.push(...d,"-p",u,...h,`root@${p}`,...g),e.dryRun){let x=y.map(w=>pf(w));return t.stdout.write(`ssh ${x.join(" ")}
|
|
387
387
|
`),0}let b=RA("ssh",y,{stdio:"inherit"});return b.on("error",x=>{l.break(),l.error(`SSH connection failed: ${x.message}`)}),new Promise(x=>{b.on("close",w=>{l.break(),w===0?(l.success("Connection closed"),x(0)):(l.error(`Connection failed with code ${w}`),x(w??1))})})}catch(r){return l.error("Failed to connect via SSH"),r instanceof Error?l.error(r.message):l.error(String(r)),1}}function DA(e){let t=[],r=[],o=new Set(["-b","-c","-D","-E","-e","-F","-I","-i","-J","-L","-l","-m","-O","-o","-P","-p","-R","-S","-W","-w"]),n=0,s=!1;for(;n<e.length;){let i=e[n];if(s){r.push(i),n++;continue}if(i.startsWith("-")){t.push(i);let a=i.length===2?i:i.slice(0,2);o.has(a)&&i.length===2&&n+1<e.length&&(n++,t.push(e[n])),n++}else s=!0,r.push(i),n++}return{options:t,command:r}}var Zw=$({path:["ssh"],meta:Ww,schema:Jw,handler:FA});import{spawn as NA}from"child_process";import E0 from"chalk";import{z as go}from"zod";var Yw={name:"cp",description:"Copy files to/from a CVM via SCP",stability:"unstable",arguments:[{name:"source",description:"Source path. Local file or remote in format 'cvm-name:path'. Use ':path' to read cvm_id from phala.toml",required:!0,target:"source"},{name:"destination",description:"Destination path. Local file or remote in format 'cvm-name:path'. Use ':path' to read cvm_id from phala.toml",required:!0,target:"destination"}],options:[{name:"identity",shorthand:"i",description:"SSH identity file (private key)",type:"string",target:"identity"},{name:"port",shorthand:"p",description:"SSH port. Priority: CLI option > phala.toml gateway_port > 443",type:"string",target:"port"},{name:"gateway",shorthand:"g",description:"Gateway domain. Priority: CLI option > phala.toml gateway_domain > API. When specified, skips API call for offline usage",type:"string",target:"gatewayDomain"},{name:"recursive",shorthand:"r",description:"Recursively copy directories",type:"boolean",target:"recursive"},{name:"verbose",shorthand:"v",description:"Show verbose SCP details",type:"boolean",target:"verbose"},{name:"dry-run",description:"Print the SCP command without executing it",type:"boolean",target:"dryRun"}],examples:[{name:"Upload using phala.toml cvm_id",value:"phala cp ./local.txt :/root/remote.txt"},{name:"Upload to a specific CVM (queries API for gateway)",value:"phala cp ./local.txt app_123:/root/remote.txt"},{name:"Download from CVM",value:"phala cp app_123:/root/remote.txt ./local.txt"},{name:"Offline mode: copy without API (using phala.toml gateway)",value:"phala cp -g dstack-gateway.example.com -p 16185 ./file.txt app_123:/root/"},{name:"Upload directory recursively",value:"phala cp -r ./local_dir app_123:/root/remote_dir"},{name:"Copy with custom SSH key",value:"phala cp -i ~/.ssh/custom_key app_123:/root/file.txt ./file.txt"},{name:"Print the SCP command without executing",value:"phala cp ./local.txt app_123:/root/remote.txt --dry-run"}]},Xw=go.object({source:go.string(),destination:go.string(),identity:go.string().optional(),port:go.string().default("443"),gatewayDomain:go.string().optional(),recursive:go.boolean().default(!1),verbose:go.boolean().default(!1),dryRun:go.boolean().default(!1)});function Qw(e){let t=e.match(/^([^:]+):(.+)$/);return t?{isRemote:!0,cvmId:t[1],path:t[2]}:{isRemote:!1,path:e}}async function LA(e,t){try{let r=Qw(e.source),o=Qw(e.destination);if(r.isRemote===o.isRemote)return l.error("Either source or destination must be a remote path in format: cvm-id:path"),l.info("Examples:"),l.info(" phala cp ./local.txt app_123:/root/remote.txt"),l.info(" phala cp app_123:/root/remote.txt ./local.txt"),1;let n=r.isRemote?r:o,s;if(n.cvmId?s=U1(n.cvmId):s=t.cvmId?.id||t.cvmId?.uuid||t.cvmId?.app_id||t.cvmId?.instance_id,!s)return l.error(`No CVM ID provided. Either use format cvm-id:path or configure it in phala.toml.
|
|
388
388
|
Supported fields: id, uuid, app_id, or instance_id`),1;let i=e.gatewayDomain??t.projectConfig.gateway_domain,a=e.port!=="443"?e.port:t.projectConfig.gateway_port?.toString()??"443",c,m;if(i)m=i,c=s.startsWith("app_")?s.substring(4):s;else try{let P=await W(),_=await cf(P,s);c=_.appId,m=_.gatewayDomain,af(_.baseImage)||l.warn("This CVM is not using a dev image. SCP access may not be available.")}catch(P){return P instanceof On?l.error(P.message):P instanceof zn?(l.error(P.message),l.info("Please start the CVM first using: phala cvms start")):l.error(P instanceof Error?P.message:"Failed to fetch CVM info"),1}let u=sf(m),p=uf(a,u.port),f=mf(c,u.host),d=Kw(e.identity);d?ff(d):l.warn("No default SSH key found. SCP will use ssh-agent or prompt for password."),e.verbose&&l.info(`Connecting to ${E0.cyan(f)}:${p}...`);let g=[...lf(e.verbose,"30"),"-P",p];e.verbose&&g.unshift("-v"),d&&g.push("-i",d),e.recursive&&g.push("-r");let y=r.isRemote?`root@${f}:${r.path}`:r.path,b=o.isRemote?`root@${f}:${o.path}`:o.path;if(g.push(y,b),e.dryRun){let P=g.map(_=>pf(_));return t.stdout.write(`scp ${P.join(" ")}
|
|
389
|
-
`),0}let x=r.isRemote?"download":"upload",w=r.isRemote?o.path:r.path,S=r.isRemote?r.path:o.path;l.info(`${x==="upload"?"Uploading":"Downloading"} ${E0.cyan(w)} ${x==="upload"?"to":"from"} ${E0.cyan(S)}...`);let I=NA("scp",g,{stdio:"inherit"});return I.on("error",P=>{l.break(),l.error(`SCP failed: ${P.message}`)}),new Promise(P=>{I.on("close",_=>{l.break(),_===0?(l.success(`${x==="upload"?"Upload":"Download"} completed`),P(0)):(l.error(`Transfer failed with code ${_}`),P(_??1))})})}catch(r){return l.error("Failed to copy file via SCP"),r instanceof Error&&l.error(r.message),1}}var e5=$({path:["cp"],meta:Yw,schema:Xw,handler:LA});var jA=HA(import.meta.url),GA=OA(jA),VA=UA(GA,"../package.json"),t5=JSON.parse(zA(VA,"utf-8")),qA="+
|
|
389
|
+
`),0}let x=r.isRemote?"download":"upload",w=r.isRemote?o.path:r.path,S=r.isRemote?r.path:o.path;l.info(`${x==="upload"?"Uploading":"Downloading"} ${E0.cyan(w)} ${x==="upload"?"to":"from"} ${E0.cyan(S)}...`);let I=NA("scp",g,{stdio:"inherit"});return I.on("error",P=>{l.break(),l.error(`SCP failed: ${P.message}`)}),new Promise(P=>{I.on("close",_=>{l.break(),_===0?(l.success(`${x==="upload"?"Upload":"Download"} completed`),P(0)):(l.error(`Transfer failed with code ${_}`),P(_??1))})})}catch(r){return l.error("Failed to copy file via SCP"),r instanceof Error&&l.error(r.message),1}}var e5=$({path:["cp"],meta:Yw,schema:Xw,handler:LA});var jA=HA(import.meta.url),GA=OA(jA),VA=UA(GA,"../package.json"),t5=JSON.parse(zA(VA,"utf-8")),qA="+c2083bc",KA=`v${t5.version}${qA}`,Me=new Lp;Me.registerCommand(w6);Me.registerCommand(Wv);Me.registerCommand(Iw);Me.registerCommand(Pw);Me.registerCommand(Gw);Me.registerCommand(Zw);Me.registerCommand(e5);Me.registerGroup(Jd.group);for(let e of Jd.commands)Me.registerCommand(e);Me.registerGroup(Qd.group);for(let e of Qd.commands)Me.registerCommand(e);Me.registerGroup(h0.group);for(let e of h0.commands)Me.registerCommand(e);Me.registerGroup(g0.group);for(let e of g0.commands)Me.registerCommand(e);Me.registerGroup(x0.group);for(let e of x0.commands)Me.registerCommand(e);Me.registerGroup(w0.group);for(let e of w0.commands)Me.registerCommand(e);process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function WA(){let e=await m6({registry:Me,argv:process.argv.slice(2),executableName:t5.name??"phala",version:KA,cwd:process.cwd(),env:process.env,stdout:process.stdout,stderr:process.stderr,stdin:process.stdin});process.exit(e)}WA().catch(e=>{console.error("An error occurred:",e),process.exit(1)});
|
|
390
390
|
/*! Bundled license information:
|
|
391
391
|
|
|
392
392
|
@noble/hashes/esm/utils.js:
|