runcloud 0.1.26 → 0.1.27
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/commands/login.js +30 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/login.js
CHANGED
|
@@ -215,6 +215,31 @@ export async function revokeRunCloudCredential(apiUrl, token) {
|
|
|
215
215
|
'revoke it from the run.cloud dashboard.');
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
+
export function existingLoginSummary(creds) {
|
|
219
|
+
const who = creds.account ? ` as ${creds.account}` : '';
|
|
220
|
+
const expiry = creds.expiresAt < Number.MAX_SAFE_INTEGER
|
|
221
|
+
? `, valid until ${new Date(creds.expiresAt * 1000).toLocaleString()}`
|
|
222
|
+
: '';
|
|
223
|
+
return `You are already logged in${who} (${creds.apiUrl}${expiry}).`;
|
|
224
|
+
}
|
|
225
|
+
export async function confirmReplaceExistingLogin(creds) {
|
|
226
|
+
if (!creds)
|
|
227
|
+
return true;
|
|
228
|
+
const terminal = acquirePromptIO();
|
|
229
|
+
if (!terminal)
|
|
230
|
+
return true;
|
|
231
|
+
try {
|
|
232
|
+
console.log(`\n ${existingLoginSummary(creds)}`);
|
|
233
|
+
const choice = await select(' Do you want to continue?', [
|
|
234
|
+
{ value: 'keep', label: 'Keep this session', hint: 'nothing to do' },
|
|
235
|
+
{ value: 'again', label: 'Log in again', hint: 'replaces the saved credential' },
|
|
236
|
+
], terminal.io);
|
|
237
|
+
return choice === 'again';
|
|
238
|
+
}
|
|
239
|
+
finally {
|
|
240
|
+
terminal.close();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
218
243
|
export function registerLogin(program) {
|
|
219
244
|
const isRunCloud = program.name() === 'runcloud';
|
|
220
245
|
const defaultAppUrl = isRunCloud
|
|
@@ -265,6 +290,10 @@ export function registerLogin(program) {
|
|
|
265
290
|
console.log(`Logged in headlessly. Credentials written for API ${apiUrl}.`);
|
|
266
291
|
return;
|
|
267
292
|
}
|
|
293
|
+
if (!(await confirmReplaceExistingLogin(loadCredentials()))) {
|
|
294
|
+
console.log(` Keeping the credential at ${credentialsDisplayPath()}\n`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
268
297
|
if (opts.manual && !isRunCloud) {
|
|
269
298
|
const { createInterface } = await import('node:readline/promises');
|
|
270
299
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -303,6 +332,7 @@ export function registerLogin(program) {
|
|
|
303
332
|
appUrl: opts.appUrl,
|
|
304
333
|
expiresAt: Number.MAX_SAFE_INTEGER,
|
|
305
334
|
revocable: true,
|
|
335
|
+
account: email,
|
|
306
336
|
});
|
|
307
337
|
console.log(`\n Signed in as ${email}`);
|
|
308
338
|
console.log(` Credential saved to ${credentialsDisplayPath()}\n`);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.1.
|
|
1
|
+
export const CLI_VERSION = '0.1.27';
|