Skip to content

Commit

Permalink
remove platform code
Browse files Browse the repository at this point in the history
  • Loading branch information
austencollins committed Jan 12, 2019
1 parent 70e94c9 commit fd5d67b
Showing 1 changed file with 2 additions and 50 deletions.
52 changes: 2 additions & 50 deletions lib/Serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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();
Expand Down

0 comments on commit fd5d67b

Please sign in to comment.