Skip to content

Commit 3147de1

Browse files
authored
Merge pull request #62 from serverless/update-google-deploy-plugin
Update GoogleDeploy plugin
2 parents ccd81a5 + bb36a23 commit 3147de1

15 files changed

+18
-903
lines changed

deploy/googleDeploy.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ const BbPromise = require('bluebird');
55
const validate = require('../shared/validate');
66
const utils = require('../shared/utils');
77
const setDeploymentBucketName = require('../shared/setDeploymentBucketName');
8-
const prepareDeployment = require('./lib/prepareDeployment');
98
const createDeployment = require('./lib/createDeployment');
109
const monitorDeployment = require('../shared/monitorDeployment');
11-
const generateArtifactDirectoryName = require('./lib/generateArtifactDirectoryName');
12-
const compileFunctions = require('./lib/compileFunctions');
13-
const mergeServiceResources = require('./lib/mergeServiceResources');
1410
const uploadArtifacts = require('./lib/uploadArtifacts');
1511
const updateDeployment = require('./lib/updateDeployment');
1612
const cleanupDeploymentBucket = require('./lib/cleanupDeploymentBucket');
@@ -26,36 +22,24 @@ class GoogleDeploy {
2622
validate,
2723
utils,
2824
setDeploymentBucketName,
29-
prepareDeployment,
3025
createDeployment,
3126
monitorDeployment,
32-
generateArtifactDirectoryName,
33-
compileFunctions,
34-
mergeServiceResources,
3527
uploadArtifacts,
3628
updateDeployment,
3729
cleanupDeploymentBucket);
3830

3931
this.hooks = {
40-
'before:deploy:initialize': () => BbPromise.bind(this)
32+
'before:deploy:deploy': () => BbPromise.bind(this)
4133
.then(this.validate)
4234
.then(this.setDefaults),
4335

44-
'deploy:initialize': () => BbPromise.bind(this)
45-
.then(this.setDeploymentBucketName)
46-
.then(this.prepareDeployment),
47-
48-
'deploy:setupProviderConfiguration': () => BbPromise.bind(this)
49-
.then(this.createDeployment),
50-
51-
'before:deploy:compileFunctions': () => BbPromise.bind(this)
52-
.then(this.generateArtifactDirectoryName)
53-
.then(this.compileFunctions),
54-
5536
'deploy:deploy': () => BbPromise.bind(this)
56-
.then(this.mergeServiceResources)
37+
.then(this.setDeploymentBucketName)
38+
.then(this.createDeployment)
5739
.then(this.uploadArtifacts)
58-
.then(this.updateDeployment)
40+
.then(this.updateDeployment),
41+
42+
'after:deploy:deploy': () => BbPromise.bind(this)
5943
.then(this.cleanupDeploymentBucket),
6044
};
6145
}

deploy/googleDeploy.test.js

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ describe('GoogleDeploy', () => {
3939
let validateStub;
4040
let setDefaultsStub;
4141
let setDeploymentBucketNameStub;
42-
let prepareDeploymentStub;
4342
let createDeploymentStub;
44-
let generateArtifactDirectoryNameStub;
45-
let compileFunctionsStub;
46-
let mergeServiceResourcesStub;
4743
let uploadArtifactsStub;
4844
let updateDeploymentStub;
4945
let cleanupDeploymentBucketStub;
@@ -55,17 +51,8 @@ describe('GoogleDeploy', () => {
5551
.returns(BbPromise.resolve());
5652
setDeploymentBucketNameStub = sinon.stub(googleDeploy, 'setDeploymentBucketName')
5753
.returns(BbPromise.resolve());
58-
prepareDeploymentStub = sinon.stub(googleDeploy, 'prepareDeployment')
59-
.returns(BbPromise.resolve());
6054
createDeploymentStub = sinon.stub(googleDeploy, 'createDeployment')
6155
.returns(BbPromise.resolve());
62-
generateArtifactDirectoryNameStub = sinon
63-
.stub(googleDeploy, 'generateArtifactDirectoryName')
64-
.returns(BbPromise.resolve());
65-
compileFunctionsStub = sinon.stub(googleDeploy, 'compileFunctions')
66-
.returns(BbPromise.resolve());
67-
mergeServiceResourcesStub = sinon.stub(googleDeploy, 'mergeServiceResources')
68-
.returns(BbPromise.resolve());
6956
uploadArtifactsStub = sinon.stub(googleDeploy, 'uploadArtifacts')
7057
.returns(BbPromise.resolve());
7158
updateDeploymentStub = sinon.stub(googleDeploy, 'updateDeployment')
@@ -78,46 +65,29 @@ describe('GoogleDeploy', () => {
7865
googleDeploy.validate.restore();
7966
googleDeploy.setDefaults.restore();
8067
googleDeploy.setDeploymentBucketName.restore();
81-
googleDeploy.prepareDeployment.restore();
8268
googleDeploy.createDeployment.restore();
83-
googleDeploy.generateArtifactDirectoryName.restore();
84-
googleDeploy.compileFunctions.restore();
85-
googleDeploy.mergeServiceResources.restore();
8669
googleDeploy.uploadArtifacts.restore();
8770
googleDeploy.updateDeployment.restore();
8871
googleDeploy.cleanupDeploymentBucket.restore();
8972
});
9073

91-
it('should run "before:deploy:initialize" promise chain', () => googleDeploy
92-
.hooks['before:deploy:initialize']().then(() => {
74+
it('should run "before:deploy:deploy" promise chain', () => googleDeploy
75+
.hooks['before:deploy:deploy']().then(() => {
9376
expect(validateStub.calledOnce).toEqual(true);
9477
expect(setDefaultsStub.calledAfter(validateStub)).toEqual(true);
9578
}));
9679

97-
it('should run "deploy:initialize" promise chain', () => googleDeploy
98-
.hooks['deploy:initialize']().then(() => {
99-
expect(setDeploymentBucketNameStub.calledOnce).toEqual(true);
100-
expect(prepareDeploymentStub.calledAfter(setDeploymentBucketNameStub)).toEqual(true);
101-
}));
102-
103-
it('it should run "deploy:setupProviderConfiguration" promise chain', () => googleDeploy
104-
.hooks['deploy:setupProviderConfiguration']().then(() => {
105-
expect(createDeploymentStub.calledOnce).toEqual(true);
106-
}),
107-
);
108-
109-
it('should run "before:deploy:compileFunctions" promise chain', () => googleDeploy
110-
.hooks['before:deploy:compileFunctions']().then(() => {
111-
expect(generateArtifactDirectoryNameStub.calledOnce).toEqual(true);
112-
expect(compileFunctionsStub.calledAfter(generateArtifactDirectoryNameStub)).toEqual(true);
113-
}));
114-
11580
it('should run "deploy:deploy" promise chain', () => googleDeploy
11681
.hooks['deploy:deploy']().then(() => {
117-
expect(mergeServiceResourcesStub.calledOnce).toEqual(true);
118-
expect(uploadArtifactsStub.calledAfter(mergeServiceResourcesStub)).toEqual(true);
82+
expect(setDeploymentBucketNameStub.calledOnce).toEqual(true);
83+
expect(createDeploymentStub.calledAfter(setDeploymentBucketNameStub)).toEqual(true);
84+
expect(uploadArtifactsStub.calledAfter(createDeploymentStub)).toEqual(true);
11985
expect(updateDeploymentStub.calledAfter(uploadArtifactsStub)).toEqual(true);
120-
expect(cleanupDeploymentBucketStub.calledAfter(updateDeploymentStub)).toEqual(true);
86+
}));
87+
88+
it('should run "after:deploy:deploy" promise chain', () => googleDeploy
89+
.hooks['after:deploy:deploy']().then(() => {
90+
expect(cleanupDeploymentBucketStub.calledOnce).toEqual(true);
12191
}));
12292
});
12393
});

deploy/lib/compileFunctions.js

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)