mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
refactor(Console): Do not disable dashboard with console
This commit is contained in:
parent
6da0b6554e
commit
e6cdc9d68b
@ -251,23 +251,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
const isConsole = Boolean(options.console || configuration.console);
|
||||
const isDashboard = Boolean(
|
||||
(() => {
|
||||
if (configuration.console) return configuration.dashboard;
|
||||
if (options.console) return configuration.app;
|
||||
return true;
|
||||
})()
|
||||
);
|
||||
const isDashboard = Boolean(!isConsole || configuration.app || options.app);
|
||||
const isConsolePreconfigured = Boolean(configuration.console);
|
||||
const isMonitoringPreconfigured = Boolean(configuration.org);
|
||||
|
||||
if (isConsole && !isDashboard) {
|
||||
const isFullyPreconfigured = isConsolePreconfigured && isMonitoringPreconfigured;
|
||||
if (options.app) {
|
||||
log.error();
|
||||
log.error('"--app" is not supported in console integrated serviced.');
|
||||
delete options.app;
|
||||
}
|
||||
const orgName = options.org || configuration.org;
|
||||
|
||||
const isMonitoringOverridenByCli =
|
||||
|
||||
@ -15,7 +15,6 @@ const yamlExtensions = new Set(['.yml', '.yaml']);
|
||||
const appPattern = /^(?:#\s*)?app\s*:.+/m;
|
||||
const orgPattern = /^(?:#\s*)?org\s*:.+/m;
|
||||
const consolePattern = /^(?:#\s*)?console\s*:(.*)/m;
|
||||
const dashboardPattern = /^(?:#\s*)?dashboard\s*:.+/m;
|
||||
|
||||
const ServerlessError = require('../../serverless-error');
|
||||
const resolveStage = require('../../utils/resolve-stage');
|
||||
@ -102,14 +101,6 @@ module.exports = {
|
||||
ymlString = `console: true\n${ymlString}`;
|
||||
}
|
||||
}
|
||||
if (isConsole && isDashboard) {
|
||||
const dashboardMatch = ymlString.match(dashboardPattern);
|
||||
if (dashboardMatch) {
|
||||
ymlString = ymlString.replace(dashboardMatch[0], 'dashboard: true');
|
||||
} else {
|
||||
ymlString = `dashboard: true\n${ymlString}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (appName) {
|
||||
const appMatch = ymlString.match(appPattern);
|
||||
@ -131,7 +122,6 @@ module.exports = {
|
||||
if (appName) configuration.app = appName;
|
||||
if (isConsole) {
|
||||
if (!configuration.console) configuration.console = true;
|
||||
if (isDashboard) configuration.dashboard = true;
|
||||
}
|
||||
},
|
||||
showOnboardingWelcome: memoizee(
|
||||
|
||||
@ -22,7 +22,11 @@ const schema = {
|
||||
required: [],
|
||||
// User is free to add any properties for its own purpose
|
||||
},
|
||||
dashboard: { type: 'boolean' },
|
||||
dashboard: {
|
||||
type: 'object',
|
||||
properties: { disableMonitoring: { type: 'boolean' } },
|
||||
additionalProperties: false,
|
||||
},
|
||||
deprecationNotificationMode: {
|
||||
enum: ['error', 'warn', 'warn:summary'],
|
||||
},
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = ({ configuration, options }) => {
|
||||
if (configuration) {
|
||||
if (configuration.console && !configuration.dashboard) return false;
|
||||
if (configuration.org) return true;
|
||||
}
|
||||
return Boolean(options.org);
|
||||
};
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = ({ configuration, options }) =>
|
||||
Boolean(_.get(configuration, 'org') || options.org) &&
|
||||
Boolean(_.get(configuration, 'app') || options.app) &&
|
||||
!_.get(configuration, 'dashboard.disableMonitoring');
|
||||
|
||||
@ -693,11 +693,9 @@ describe('test/unit/lib/cli/interactive-setup/dashboard-set-org.test.js', functi
|
||||
expect(serviceConfig.org).to.equal('testinteractivecli');
|
||||
expect(serviceConfig.app).to.equal('some-aws-service-app');
|
||||
expect(serviceConfig.console).to.be.true;
|
||||
expect(serviceConfig.dashboard).to.be.true;
|
||||
expect(context.configuration.org).to.equal('testinteractivecli');
|
||||
expect(context.configuration.app).to.equal('some-aws-service-app');
|
||||
expect(context.configuration.console).to.be.true;
|
||||
expect(context.configuration.dashboard).to.be.true;
|
||||
expect(Array.from(context.stepHistory.valuesMap())).to.deep.equal(Array.from(new Map()));
|
||||
});
|
||||
});
|
||||
|
||||
@ -61,7 +61,7 @@ describe('test/unit/lib/cli/interactive-setup/deploy.test.js', () => {
|
||||
|
||||
expect(
|
||||
await mockedStep.isApplicable({
|
||||
configuration: { provider: { name: 'aws' }, org: 'someorg' },
|
||||
configuration: { provider: { name: 'aws' }, org: 'someorg', app: 'someapp' },
|
||||
serviceDir: '/foo',
|
||||
options: {},
|
||||
history: new Map([['awsCredentials', []]]),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user