Skip to content

Commit

Permalink
Add login for archiveService
Browse files Browse the repository at this point in the history
  • Loading branch information
RaeesBhatti committed Sep 14, 2017
1 parent 344a3b7 commit e29b633
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions lib/plugins/platform/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,36 @@ class Platform {
if (this.provider) {
this.hooks = {
'after:deploy:deploy': this.publishService.bind(this),
'after:remove:remove': this.removeService.bind(this),
'after:remove:remove': this.archiveService.bind(this),
};
}
}

removeService() {
// TODO implement platform removal here
return BbPromise.resolve();
archiveService() {
const authToken = this.getAuthToken();
const publishFlag = selectServicePublish(this.serverless.service);
if (!authToken || !publishFlag) {
// NOTE removeService is an opt-in feature and no warning is needed
return BbPromise.resolve();
}

if (authToken && authToken.length > 8000) {
this.serverless.cli.log('Your serverless login has expired');
this.serverless.cli.log('Please run `serverless login` again');
return BbPromise.resolve();
}

const clientWithAuth = createApolloClient(config.GRAPHQL_ENDPOINT_URL, authToken);
return clientWithAuth.mutate({
mutation: gql`
mutation archiveService($name: String!) {
archiveService(name: $name) {
archived
}
}
`,
variables: { name: this.serverless.service.service },
}).then(response => response.data);
}

publishServiceRequest(service, client) {
Expand Down

0 comments on commit e29b633

Please sign in to comment.