-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathgooglePackage.js
More file actions
82 lines (71 loc) · 2.66 KB
/
googlePackage.js
File metadata and controls
82 lines (71 loc) · 2.66 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const BbPromise = require('bluebird');
const path = require('path');
const cleanupServerlessDir = require('./lib/cleanupServerlessDir');
const validate = require('../shared/validate');
const utils = require('../shared/utils');
const setDeploymentBucketName = require('../shared/setDeploymentBucketName');
const prepareDeployment = require('./lib/prepareDeployment');
const saveCreateTemplateFile = require('./lib/writeFilesToDisk');
const mergeServiceResources = require('./lib/mergeServiceResources');
const generateArtifactDirectoryName = require('./lib/generateArtifactDirectoryName');
const compileFunctions = require('./lib/compileFunctions');
const saveUpdateTemplateFile = require('./lib/writeFilesToDisk');
class GooglePackage {
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');
this.serverless.configSchemaHandler.defineFunctionEvent('google', 'http', { type: 'string' });
this.serverless.configSchemaHandler.defineFunctionEvent('google', 'event', {
type: 'object',
properties: {
eventType: {
type: 'string',
},
path: {
type: 'string',
},
resource: {
type: 'string',
},
},
required: ['eventType', 'resource'],
additionalProperties: false,
});
Object.assign(
this,
cleanupServerlessDir,
validate,
utils,
setDeploymentBucketName,
prepareDeployment,
saveCreateTemplateFile,
generateArtifactDirectoryName,
compileFunctions,
mergeServiceResources,
saveUpdateTemplateFile
);
this.hooks = {
'package:cleanup': () => BbPromise.bind(this).then(this.cleanupServerlessDir),
'before:package:initialize': () =>
BbPromise.bind(this).then(this.validate).then(this.setDefaults),
'package:initialize': () =>
BbPromise.bind(this)
.then(this.setDeploymentBucketName)
.then(this.prepareDeployment)
.then(this.saveCreateTemplateFile),
'before:package:compileFunctions': () =>
BbPromise.bind(this).then(this.generateArtifactDirectoryName),
'package:compileFunctions': () => BbPromise.bind(this).then(this.compileFunctions),
'package:finalize': () =>
BbPromise.bind(this).then(this.mergeServiceResources).then(this.saveUpdateTemplateFile),
};
}
}
module.exports = GooglePackage;