Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console: External integration #11434

Merged
merged 7 commits into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions commands/login.js
@@ -1,7 +1,5 @@
'use strict';

const _ = require('lodash');

const resolveIsDashboardEnabled = require('../lib/configuration/is-dashboard-enabled');

module.exports = async (context) => {
Expand All @@ -10,14 +8,9 @@ module.exports = async (context) => {
if (options.console) return 'console';
if (options.dashboard) return 'dashboard';

const isConsoleEnabled = Boolean(_.get(configuration, 'console'));
const isDashboardEnabled = resolveIsDashboardEnabled({ configuration, options });

if (isConsoleEnabled) {
if (!isDashboardEnabled) return 'console';
} else if (isDashboardEnabled) {
return 'dashboard';
}
if (isDashboardEnabled) return 'dashboard';

const promptWithHistory = require('@serverless/utils/inquirer/prompt-with-history');
const { StepHistory } = require('@serverless/utils/telemetry');
Expand Down
10 changes: 10 additions & 0 deletions docs/deprecations.md
Expand Up @@ -36,6 +36,16 @@ Note:
- The `serverless.yml` setting is ineffective for deprecations reported before the configuration is read.
- `SLS_DEPRECATION_DISABLE` and `disabledDeprecations` remain respected, and no errors will be thrown for mentioned deprecation codes.

<a name="CONSOLE_CONFIGURATION"><div>&nbsp;</div></a>

## Property `console`

Deprecation code: `CONSOLE_CONFIGURATION`

Starting with v3.24.0, Serverless will no longer recognize inner `console` configuration. All Serverless Console related configuration is expected to be maintained at https://console.serverless.com

Learn more about configuration validation here: http://slss.io/configuration-validation

<a name="VARIABLES_RESOLUTION_MODE"><div>&nbsp;</div></a>

## Property `variablesResolutionMode`
Expand Down
239 changes: 0 additions & 239 deletions lib/classes/console.js

This file was deleted.

7 changes: 7 additions & 0 deletions lib/classes/service.js
Expand Up @@ -280,6 +280,13 @@ class Service {
'You can safely remove it from the configuration'
);
}
if (userConfig.console != null) {
this.serverless._logDeprecation(
'CONSOLE_CONFIGURATION',
'Starting with v3.24.0, the "console" option is no longer recognized. ' +
'Please remove it from the configuration'
);
}
return this;
}

Expand Down
38 changes: 4 additions & 34 deletions lib/cli/interactive-setup/console-login.js
@@ -1,20 +1,13 @@
'use strict';

const _ = require('lodash');
const resolveAuthMode = require('@serverless/utils/auth/resolve-mode');
const promptWithHistory = require('@serverless/utils/inquirer/prompt-with-history');
const login = require('../../commands/login/console');
const { showOnboardingWelcome } = require('./utils');

const loginOrRegisterQuestion = async (context) => {
let message;
if (context.initial.isInServiceContext) {
message = 'Press [Enter] to create a free Serverless Console account';
} else {
message = 'Do you want to login/register to Serverless Console?';
}
return promptWithHistory({
message,
message: 'Press [Enter] to login to Serverless Console.',
type: 'confirm',
name: 'shouldLoginOrRegister',
stepHistory: context.stepHistory,
Expand All @@ -23,52 +16,29 @@ const loginOrRegisterQuestion = async (context) => {

const steps = {
loginOrRegister: async (context) => {
const shouldLoginOrRegister =
context.options.org || context.configuration.org || (await loginOrRegisterQuestion(context));
const shouldLoginOrRegister = await loginOrRegisterQuestion(context);
if (shouldLoginOrRegister) await login({ clientOriginCommand: 'onboarding' });
},
};

module.exports = {
async isApplicable(context) {
const { isConsole, configuration, serviceDir } = context;
const { isConsole } = context;

if (!isConsole) {
context.inapplicabilityReasonCode = 'NON_CONSOLE_CONTEXT';
return false;
}

if (!serviceDir) {
context.inapplicabilityReasonCode = 'NOT_IN_SERVICE_DIRECTORY';
return false;
}

if (await resolveAuthMode()) {
context.inapplicabilityReasonCode = 'ALREADY_LOGGED_IN';
return false;
}

if (
_.get(configuration, 'provider') !== 'aws' &&
_.get(configuration, 'provider.name') !== 'aws'
) {
context.inapplicabilityReasonCode = 'NON_AWS_PROVIDER';
return false;
}

const runtime = _.get(configuration.provider, 'runtime') || 'nodejs14.x';
if (!runtime.startsWith('nodejs')) {
context.inapplicabilityReasonCode = 'UNSUPPORTED_RUNTIME';
return false;
}
return true;
},
async run(context) {
const isOrgProvided = context.options.org || context.configuration.org;

if (context.initial.isInServiceContext && !context.initial.isConsoleEnabled && !isOrgProvided) {
showOnboardingWelcome(context);
}
showOnboardingWelcome(context);

return steps.loginOrRegister(context);
},
Expand Down