Skip to content

Commit

Permalink
refactor(Console): Support login with Console
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Mar 1, 2022
1 parent df08283 commit 4ce1088
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/cli/commands-schema/no-service.js
Expand Up @@ -151,6 +151,7 @@ commands.set('install', {

commands.set('login', {
usage: 'Login or sign up for Serverless',
serviceDependencyMode: 'optional',
lifecycleEvents: ['login'],
});

Expand Down
9 changes: 5 additions & 4 deletions lib/cli/interactive-setup/dashboard-login.js
Expand Up @@ -7,22 +7,23 @@ const configUtils = require('@serverless/utils/config');
const promptWithHistory = require('@serverless/utils/inquirer/prompt-with-history');
const { showOnboardingWelcome } = require('./utils');

const loginOrRegisterQuestion = async (stepHistory) =>
const loginOrRegisterQuestion = async (stepHistory, isConsole) =>
promptWithHistory({
message: 'Do you want to login/register to Serverless Dashboard?',
message: `Do you want to login/register to Serverless ${isConsole ? 'Console' : 'Dashboard'}?`,
type: 'confirm',
name: 'shouldLoginOrRegister',
stepHistory,
});

const steps = {
loginOrRegister: async (context) => {
const isConsole = Boolean(context.configuration.console && !context.configuration.dashboard);
const shouldLoginOrRegister =
context.options.org ||
context.configuration.org ||
(await loginOrRegisterQuestion(context.stepHistory));
(await loginOrRegisterQuestion(context.stepHistory, isConsole));
if (shouldLoginOrRegister) {
await login({ isInteractive: true });
await login({ isInteractive: true, isConsole });
}
},
};
Expand Down
7 changes: 6 additions & 1 deletion lib/cli/interactive-setup/utils.js
Expand Up @@ -100,7 +100,12 @@ module.exports = {
},
showOnboardingWelcome: memoizee(
(context) => {
log.notice(`Onboarding "${context.configuration.service}" to the Serverless Dashboard`);
const isConsole = Boolean(context.configuration.console && !context.configuration.dashboard);
log.notice(
`Onboarding "${context.configuration.service}" to the Serverless ${
isConsole ? 'Console' : 'Dashboard'
}`
);
log.notice();
},
{ length: 0 }
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -23,8 +23,8 @@
},
"dependencies": {
"@serverless/aws-lambda-otel-extension-dist": "^0.1.5",
"@serverless/dashboard-plugin": "^6.1.2",
"@serverless/platform-client": "^4.3.1",
"@serverless/dashboard-plugin": "^6.1.3",
"@serverless/platform-client": "^4.3.2",
"@serverless/utils": "^6.0.2",
"ajv": "^8.10.0",
"ajv-formats": "^2.1.1",
Expand Down

0 comments on commit 4ce1088

Please sign in to comment.