/
deploy.go
52 lines (43 loc) · 1.33 KB
/
deploy.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
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2021 Guy A. Ross
// This source code is licensed under the GNU GPLv3 found in the
// license file in the root directory of this source tree.
package cmd
import (
"github.com/GuyARoss/orbit/internal"
"github.com/GuyARoss/orbit/pkg/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var deployCMD = &cobra.Command{
Use: "deploy",
Short: "deploy",
Run: func(cmd *cobra.Command, args []string) {
logger := log.NewDefaultLogger()
buildOpts := &internal.BuildOpts{
Packname: viper.GetString("pacname"),
OutDir: viper.GetString("out"),
WebDir: viper.GetString("webdir"),
Mode: viper.GetString("mode"),
NodeModulePath: viper.GetString("nodemod"),
PublicDir: viper.GetString("publicdir"),
NoWrite: true,
Dirs: []string{
viper.GetString("staticout"),
},
}
components, err := internal.Build(buildOpts)
if err != nil {
panic(err)
}
staticBuild := internal.NewStaticBuild(buildOpts, viper.GetString("staticout"))
err = staticBuild.Build(components)
if err != nil {
logger.Error(err.Error())
}
},
}
func init() {
var staticOut string
deployCMD.PersistentFlags().StringVar(&staticOut, "staticout", "./static", "path for the static file directory")
viper.BindPFlag("staticout", deployCMD.PersistentFlags().Lookup("staticout"))
}