-
Notifications
You must be signed in to change notification settings - Fork 38
/
plugins.go
42 lines (35 loc) · 949 Bytes
/
plugins.go
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
package javascript
import (
"github.com/klothoplatform/klotho/pkg/config"
"github.com/klothoplatform/klotho/pkg/core"
"go.uber.org/zap"
)
type (
JavascriptPlugins struct {
Plugins []core.Plugin
}
)
func NewJavascriptPlugins(cfg *config.Application, runtime Runtime) *JavascriptPlugins {
return &JavascriptPlugins{
Plugins: []core.Plugin{
ExpressHandler{Config: cfg},
NestJsHandler{Config: cfg},
AddExecRuntimeFiles{runtime: runtime},
Persist{runtime: runtime},
Pubsub{runtime: runtime},
},
}
}
func (c JavascriptPlugins) Name() string { return "javascript" }
func (c JavascriptPlugins) Transform(result *core.CompilationResult, deps *core.Dependencies) error {
for _, p := range c.Plugins {
log := zap.L().With(zap.String("plugin", p.Name()))
log.Debug("starting")
err := p.Transform(result, deps)
if err != nil {
return core.NewPluginError(p.Name(), err)
}
log.Debug("completed")
}
return nil
}