forked from Accenture/serverless-ephemeral
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
62 lines (52 loc) · 1.96 KB
/
index.js
File metadata and controls
62 lines (52 loc) · 1.96 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
/**
* Serverles Plugin that adds stateless libraries to the Lambdas deployment package
*/
const BbPromise = require('bluebird');
const vlog = require('./src/util/cli').vlog;
const createDirectories = require('./src/action/createDirectories');
const copyServerlessArtifacts = require('./src/action/copyServerlessArtifacts');
const downloadLibraries = require('./src/action/downloadLibraries');
const packDependencies = require('./src/action/packDependencies');
const EPHEMERAL_DIR_NAME = '.ephemeral';
/**
* ServerlessEphemeral plugin class
*/
class ServerlessEphemeral {
/**
* Constructor
*/
constructor (serverless, options) {
this.serverless = serverless;
this.options = options;
this.ephemeral = {
config: serverless.service.custom.ephemeral,
paths: {
base: `${this.serverless.config.servicePath}/${EPHEMERAL_DIR_NAME}`,
lib: `${this.serverless.config.servicePath}/${EPHEMERAL_DIR_NAME}/lib`,
pkg: `${this.serverless.config.servicePath}/${EPHEMERAL_DIR_NAME}/pkg`,
},
};
Object.assign(
this,
createDirectories,
copyServerlessArtifacts,
downloadLibraries,
packDependencies // eslint-disable-line comma-dangle
);
// Extend the Serverless CLI
this.serverless.cli.vlog = vlog.bind(this);
/**
* Hooks that fire before or after core Serverless lifecycle events
*/
this.hooks = {
'after:package:cleanup': () => BbPromise.bind(this)
.then(this.createDirectories),
'after:package:createDeploymentArtifacts': () => BbPromise.bind(this)
.then(this.copyServerlessArtifacts)
.then(this.downloadLibraries),
'after:package:finalize': () => BbPromise.bind(this)
.then(this.packDependencies),
};
}
}
module.exports = ServerlessEphemeral;