-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathgoogleDeploy.js
59 lines (49 loc) · 1.67 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
54
55
56
57
58
59
'use strict';
const BbPromise = require('bluebird');
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.provider = this.serverless.getProvider('google');
let deployProgress;
if (this.provider.progress) {
deployProgress = this.provider.progress.create({
message: 'Beginning deployment',
name: 'deploy',
});
}
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)
.finally(() => deployProgress && deployProgress.remove()),
};
}
}
module.exports = GoogleDeploy;