mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
remove platform code
This commit is contained in:
parent
70e94c9640
commit
fd5d67b427
@ -15,8 +15,6 @@ const Service = require('./classes/Service');
|
||||
const Variables = require('./classes/Variables');
|
||||
const ServerlessError = require('./classes/Error').ServerlessError;
|
||||
const Version = require('./../package.json').version;
|
||||
const configUtils = require('./utils/config');
|
||||
const getUser = require('./utils/getUser');
|
||||
|
||||
class Serverless {
|
||||
constructor(config) {
|
||||
@ -78,25 +76,6 @@ class Serverless {
|
||||
}
|
||||
|
||||
run() {
|
||||
const config = configUtils.getConfig();
|
||||
const currentId = config.userId;
|
||||
const globalConfig = configUtils.getGlobalConfig();
|
||||
|
||||
let isTokenExpired = false;
|
||||
if (globalConfig
|
||||
&& globalConfig.users
|
||||
&& globalConfig.users[currentId]
|
||||
&& globalConfig.users[currentId].auth
|
||||
&& globalConfig.users[currentId].auth.id_token
|
||||
&& !globalConfig.users[currentId].dashboard) {
|
||||
isTokenExpired = true;
|
||||
}
|
||||
|
||||
if (isTokenExpired && !this.processedInput.commands[0] === 'login') {
|
||||
this.cli
|
||||
.log('WARNING: Your login token has expired. Please run "serverless login" to login.');
|
||||
}
|
||||
|
||||
this.utils.logStat(this).catch(() => BbPromise.resolve());
|
||||
|
||||
if (this.cli.displayHelp(this.processedInput)) {
|
||||
@ -113,35 +92,8 @@ class Serverless {
|
||||
!this.processedInput.commands.includes('remove')) || !this.config.servicePath) {
|
||||
return BbPromise.resolve();
|
||||
}
|
||||
|
||||
return getUser().then(user => {
|
||||
if (!user) return BbPromise.resolve();
|
||||
if (!this.service.tenant && !this.service.app) {
|
||||
this.cli.log('WARNING: Missing "tenant" and "app" properties in serverless.yml. Without these properties, you can not publish the service to the Serverless Platform.'); // eslint-disable-line
|
||||
return BbPromise.resolve();
|
||||
} else if (this.service.tenant && !this.service.app) {
|
||||
const errorMessage = ['Missing "app" property in serverless.yml'].join('');
|
||||
throw new this.classes.Error(errorMessage);
|
||||
} else if (!this.service.tenant && this.service.app) {
|
||||
const errorMessage = ['Missing "tenant" property in serverless.yml'].join('');
|
||||
throw new this.classes.Error(errorMessage);
|
||||
}
|
||||
|
||||
const listTenantsData = {
|
||||
idToken: user.idToken,
|
||||
username: user.username,
|
||||
};
|
||||
|
||||
return platform.listTenants(listTenantsData).then((tenants) => {
|
||||
const tenantsList = tenants.map(tenant => tenant.tenantName);
|
||||
if (!tenantsList.includes(this.service.tenant)) {
|
||||
const errorMessage = [`tenant "${this.service
|
||||
.tenant}" does not exist.`].join('');
|
||||
throw new this.classes.Error(errorMessage);
|
||||
}
|
||||
});
|
||||
});
|
||||
}).then(() => {
|
||||
})
|
||||
.then(() => {
|
||||
// merge arrays after variables have been populated
|
||||
// (https://github.com/serverless/serverless/issues/3511)
|
||||
this.service.mergeArrays();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user