This repository was archived by the owner on Jan 28, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy pathServerlessPluginBuilder.js
More file actions
74 lines (65 loc) · 1.35 KB
/
ServerlessPluginBuilder.js
File metadata and controls
74 lines (65 loc) · 1.35 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
const merge = require("lodash.merge");
const ServerlessNextJsPlugin = require("../..");
class ServerlessPluginBuilder {
constructor() {
this.serverless = {
cli: {
consoleLog: () => {}
},
getPlugins: () => {},
getProvider: () => {
return {
request: () => {},
getRegion: () => "us-west-2",
getStage: () => "test"
};
},
pluginManager: {
run: () => {}
},
service: {
package: {
include: []
},
setFunctionNames: () => {},
functions: {},
provider: {
compiledCloudFormationTemplate: {}
},
custom: {
"serverless-nextjs": {
nextConfigDir: "/path/to/next"
}
}
}
};
}
withService(service) {
merge(this.serverless, {
service
});
return this;
}
withPluginManager(pluginManager) {
merge(this.serverless, {
pluginManager
});
return this;
}
withPluginConfig(config) {
merge(this.serverless, {
service: {
custom: {
"serverless-nextjs": config
}
}
});
return this;
}
build() {
const plugin = new ServerlessNextJsPlugin(this.serverless, {});
plugin.initializeVariables();
return plugin;
}
}
module.exports = ServerlessPluginBuilder;