-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathgoogleDeploy.js
53 lines (45 loc) · 1.64 KB
/
googleDeploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
const BbPromise = require('bluebird');
const path = require('path');
const validate = require('../shared/validate');
const utils = require('../shared/utils');
const createDeployment = require('./lib/createDeployment');
const setDeploymentBucketName = require('../shared/setDeploymentBucketName');
const monitorDeployment = require('../shared/monitorDeployment');
const uploadArtifacts = require('./lib/uploadArtifacts');
const updateDeployment = require('./lib/updateDeployment');
const cleanupDeploymentBucket = require('./lib/cleanupDeploymentBucket');
class GoogleDeploy {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.servicePath = this.serverless.config.servicePath || '';
this.packagePath = this.options.package ||
this.serverless.service.package.path ||
path.join(this.servicePath || '.', '.serverless');
this.provider = this.serverless.getProvider('google');
Object.assign(
this,
validate,
utils,
createDeployment,
setDeploymentBucketName,
monitorDeployment,
uploadArtifacts,
updateDeployment,
cleanupDeploymentBucket);
this.hooks = {
'before:deploy:deploy': () => BbPromise.bind(this)
.then(this.validate)
.then(this.setDefaults),
'deploy:deploy': () => BbPromise.bind(this)
.then(this.createDeployment)
.then(this.setDeploymentBucketName)
.then(this.uploadArtifacts)
.then(this.updateDeployment),
'after:deploy:deploy': () => BbPromise.bind(this)
.then(this.cleanupDeploymentBucket),
};
}
}
module.exports = GoogleDeploy;