Skip to content

Commit

Permalink
fix(CLI Onboarding): Don't crash if Dashboar server is inaccessible
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jan 27, 2023
1 parent 0249dde commit 983a3b9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/cli/interactive-setup/dashboard-login.js
Expand Up @@ -4,6 +4,7 @@ const _ = require('lodash');
const { ServerlessSDK } = require('@serverless/platform-client');
const configUtils = require('@serverless/utils/config');
const promptWithHistory = require('@serverless/utils/inquirer/prompt-with-history');
const log = require('@serverless/utils/log').log.get('onboarding');
const login = require('../../commands/login/dashboard');
const { showOnboardingWelcome } = require('./utils');

Expand Down Expand Up @@ -51,7 +52,19 @@ module.exports = {
}

const sdk = new ServerlessSDK();
const { supportedRegions, supportedRuntimes } = await sdk.metadata.get();
const sdkMetadata = await (async () => {
try {
return await sdk.metadata.get();
} catch (error) {
log.info("Cannot connect to Serverless Platform. Skipping 'dashboard-login' step", error);
return null;
}
})();
if (!sdkMetadata) {
context.inapplicabilityReasonCode = 'SERVER_UNAVAILABLE';
return false;
}
const { supportedRegions, supportedRuntimes } = sdkMetadata;
if (!supportedRuntimes.includes(_.get(configuration.provider, 'runtime') || 'nodejs12.x')) {
context.inapplicabilityReasonCode = 'UNSUPPORTED_RUNTIME';
return false;
Expand Down

0 comments on commit 983a3b9

Please sign in to comment.