rampup 0.1.0 ā 0.1.2
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/auth.js +1 -1
- package/index.js +25 -39
- package/package.json +1 -1
package/auth.js
CHANGED
|
@@ -222,7 +222,7 @@ export async function loginWithBrowser() {
|
|
|
222
222
|
} else if (url.pathname === '/') {
|
|
223
223
|
// Redirect to Firebase auth
|
|
224
224
|
res.writeHead(302, {
|
|
225
|
-
Location: `https://rampup.dev/cli-
|
|
225
|
+
Location: `https://app.rampup.dev/cli-login?redirect=http://localhost:${PORT}/callback`,
|
|
226
226
|
});
|
|
227
227
|
res.end();
|
|
228
228
|
} else {
|
package/index.js
CHANGED
|
@@ -992,49 +992,35 @@ program
|
|
|
992
992
|
console.log(banner);
|
|
993
993
|
console.log(chalk.bold.blue('š Login\n'));
|
|
994
994
|
|
|
995
|
-
const configDir = path.join(process.env.HOME, '.ramp');
|
|
996
|
-
const authFile = path.join(configDir, 'auth.json');
|
|
997
|
-
|
|
998
995
|
// Check if already logged in
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
console.log(chalk.dim('\nLogged out.\n'));
|
|
1012
|
-
}
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
} catch {}
|
|
1016
|
-
|
|
1017
|
-
console.log(chalk.dim('Create an account at: https://rampup.dev\n'));
|
|
1018
|
-
|
|
1019
|
-
const { email, token } = await inquirer.prompt([
|
|
1020
|
-
{
|
|
1021
|
-
type: 'input',
|
|
1022
|
-
name: 'email',
|
|
1023
|
-
message: 'Email:'
|
|
1024
|
-
},
|
|
1025
|
-
{
|
|
1026
|
-
type: 'password',
|
|
1027
|
-
name: 'token',
|
|
1028
|
-
message: 'API Token (from rampup.dev/settings):'
|
|
996
|
+
const userInfo = await getUserInfo();
|
|
997
|
+
if (userInfo) {
|
|
998
|
+
console.log(chalk.green(`Already logged in as ${userInfo.email}\n`));
|
|
999
|
+
const { logout } = await inquirer.prompt([{
|
|
1000
|
+
type: 'confirm',
|
|
1001
|
+
name: 'logout',
|
|
1002
|
+
message: 'Log out?',
|
|
1003
|
+
default: false
|
|
1004
|
+
}]);
|
|
1005
|
+
if (logout) {
|
|
1006
|
+
await clearCredentials();
|
|
1007
|
+
console.log(chalk.dim('\nLogged out.\n'));
|
|
1029
1008
|
}
|
|
1030
|
-
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1031
1011
|
|
|
1032
|
-
//
|
|
1033
|
-
|
|
1034
|
-
await fs.mkdir(configDir, { recursive: true });
|
|
1035
|
-
await fs.writeFile(authFile, JSON.stringify({ email, token, created: new Date().toISOString() }, null, 2));
|
|
1012
|
+
// Browser-based OAuth login
|
|
1013
|
+
const spinner = ora('Opening browser for authentication...').start();
|
|
1036
1014
|
|
|
1037
|
-
|
|
1015
|
+
try {
|
|
1016
|
+
const result = await loginWithBrowser();
|
|
1017
|
+
spinner.succeed(chalk.green(`Logged in as ${result.displayName || result.email}`));
|
|
1018
|
+
console.log(chalk.dim('\nYou can now use all Ramp CLI features.\n'));
|
|
1019
|
+
} catch (error) {
|
|
1020
|
+
spinner.fail(chalk.red('Login failed'));
|
|
1021
|
+
console.log(chalk.dim(`\nError: ${error.message}\n`));
|
|
1022
|
+
console.log(chalk.dim('Try again or visit https://app.rampup.dev to create an account.\n'));
|
|
1023
|
+
}
|
|
1038
1024
|
});
|
|
1039
1025
|
|
|
1040
1026
|
program
|