@@ -109,7 +109,7 @@ export const sandboxKillCommand = new Command()
109109 const res = await ( client . sandboxes as any ) . kill . mutate ( {
110110 org : orgAndApp . org ,
111111 sandboxId,
112- clusterHostname : [ cluster . hostname ]
112+ clusterHostname : [ cluster . hostname ] ,
113113 } ) ;
114114
115115 if ( res . success ) {
@@ -143,22 +143,42 @@ export const sandboxSshCommand = new Command()
143143 ( client . orgs as any ) . accessTokens . create . mutate ( {
144144 org : orgAndApp . org ,
145145 description : "$$DENO_DEPLOY_CLI_SSH_TOKEN$$" ,
146- expiresAt : new Date ( Date . now ( ) + 1000 * 60 * 60 ) ,
146+ expiresAt : new Date ( Date . now ( ) + 1000 * 60 * 60 ) . toISOString ( ) ,
147147 } ) ,
148148 ] ) ;
149149
150- await using sandbox = Sandbox . connect ( {
150+ await using sandbox = await Sandbox . connect ( {
151151 id : sandboxId ,
152- endpoint : cluster . hostname ,
152+ region : cluster . region ,
153153 debug : options . debug ,
154154 token : token . token ,
155155 } ) ;
156156
157157 const ssh = await sandbox . exposeSsh ( ) ;
158158
159- console . log (
160- `Started ssh session, you can now connect to ${ ssh . username } @${ ssh . hostname } .\nUse Ctrl+C to exit.` ,
161- ) ;
159+ const connectInfo = ssh . username + "@" + ssh . hostname ;
160+
161+ const which = await new Deno . Command ( "which" , {
162+ args : [ "ssh" ] ,
163+ stdout : "null" ,
164+ stderr : "null" ,
165+ } ) . output ( ) ;
166+
167+ if ( which . success ) {
168+ // If ssh is available, directly spawn ssh process
169+ const command = new Deno . Command ( "ssh" , {
170+ args : [ connectInfo ] ,
171+ stdin : "inherit" ,
172+ stdout : "inherit" ,
173+ stderr : "inherit" ,
174+ } ) ;
175+
176+ const _sshProcess = command . spawn ( ) ;
177+ } else {
178+ console . log (
179+ `Started ssh session, you can now connect to ${ connectInfo } .\nUse Ctrl+C to exit.` ,
180+ ) ;
181+ }
162182 } ) ;
163183
164184export function formatPassedTime ( ms : number , roundToSeconds = false ) {
0 commit comments