Skip to content

Commit 64ed267

Browse files
committed
alpha: plugin list and update, app deployment info
1 parent 0383965 commit 64ed267

36 files changed

+835
-159
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# {{ .Info.Title }}
2+
{{ range .Versions }}
3+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }}
4+
5+
> {{ ternary now .Tag.Date (eq (.Tag.Date | datetime "2006") "0001") | datetime "2006-01-02" }}
6+
7+
{{ range .CommitGroups -}}
8+
### {{ .Title }}
9+
10+
{{ range .Commits -}}
11+
* [[{{ .Hash.Short }}]({{ $.Info.RepositoryURL }}/commit/{{ .Hash.Long }})] {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
12+
{{ end }}
13+
{{ end -}}
14+
15+
{{- if .RevertCommits -}}
16+
### Reverts
17+
18+
{{ range .RevertCommits -}}
19+
* {{ .Revert.Header }}
20+
{{ end }}
21+
{{ end -}}
22+
23+
{{- if .MergeCommits -}}
24+
### Pull Requests
25+
26+
{{ range .MergeCommits -}}
27+
* {{ .Header }}
28+
{{ end }}
29+
{{ end -}}
30+
31+
{{- if .NoteGroups -}}
32+
{{ range .NoteGroups -}}
33+
### {{ .Title }}
34+
35+
{{ range .Notes }}
36+
{{ .Body }}
37+
{{ end }}
38+
{{ end -}}
39+
{{ end -}}
40+
{{ end -}}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bin/
22
vendor/
33
outblocks-cli
4-
example/
4+
example*/
55
.outblocks

.semverbot.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ mode = "auto"
1212

1313
[semver.detection]
1414
patch = ["fix/", "[fix]", "fix:"]
15-
minor = ["feature/", "[feature]", "feat:"]
15+
minor = ["feature/", "[feature]", "feat:", "feat/"]
1616
major = ["release/", "[release]", "release:"]

cmd/deploy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func (e *Executor) newDeployCmd() *cobra.Command {
2828

2929
f := cmd.Flags()
3030
f.BoolVar(&opts.Verify, "verify", false, "verify existing resources")
31+
f.BoolVar(&opts.Destroy, "destroy", false, "destroy all existing resources")
3132

3233
return cmd
3334
}

cmd/executor_config.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (e *Executor) loadPlugins(ctx context.Context, cfg *config.Project) error {
4646
pluginsToDownload := make(map[int]*config.Plugin)
4747

4848
for i, plug := range cfg.Plugins {
49-
plugin, err := e.loader.LoadPlugin(plug.Name, plug.Source, plug.VerRange(), cfg.PluginLock(plug))
49+
plugin, err := e.loader.LoadPlugin(ctx, plug.Name, plug.Source, plug.VerRange(), cfg.PluginLock(plug))
5050
if err != nil {
5151
if err != plugins.ErrPluginNotFound {
5252
return err
@@ -58,22 +58,26 @@ func (e *Executor) loadPlugins(ctx context.Context, cfg *config.Project) error {
5858
}
5959

6060
plugs[i] = plugin
61+
62+
plug.SetLoaded(plugin)
6163
}
6264

6365
if len(pluginsToDownload) != 0 {
64-
prog, _ := e.log.ProgressBar().WithTotal(len(pluginsToDownload)).WithTitle("Downloading plugins").Start()
66+
prog, _ := e.log.ProgressBar().WithTotal(len(pluginsToDownload)).WithTitle("Downloading plugins...").Start()
6567

6668
for i, plug := range pluginsToDownload {
67-
prog.Title = fmt.Sprintf("Downloading plugin '%s'", plug.Name)
69+
title := fmt.Sprintf("Downloading plugin '%s'", plug.Name)
6870
if plug.Version != "" {
69-
prog.Title += fmt.Sprintf(" with version: %s", plug.Version)
71+
title += fmt.Sprintf(" with version: %s", plug.Version)
7072
}
7173

72-
prog.Add(0) // force title update
74+
prog.UpdateTitle(title)
7375

7476
plugin, err := e.loader.DownloadPlugin(ctx, plug.Name, plug.VerRange(), plug.Source, cfg.PluginLock(plug))
7577
plugs[i] = plugin
7678

79+
plug.SetLoaded(plugin)
80+
7781
if err != nil {
7882
_, _ = prog.Stop()
7983

@@ -83,8 +87,6 @@ func (e *Executor) loadPlugins(ctx context.Context, cfg *config.Project) error {
8387
prog.Increment()
8488
pterm.Success.Printf("Downloaded plugin '%s' at version: %s\n", plug.Name, plugin.Version)
8589
}
86-
87-
_, _ = prog.Stop()
8890
}
8991

9092
// Normalize and start plugins.
@@ -104,7 +106,7 @@ func (e *Executor) loadPlugins(ctx context.Context, cfg *config.Project) error {
104106
}
105107
}
106108

107-
cfg.SetPlugins(plugs)
109+
cfg.SetLoadedPlugins(plugs)
108110

109111
return nil
110112
}

cmd/plugins.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package cmd
2+
3+
import (
4+
"github.com/outblocks/outblocks-cli/pkg/actions"
5+
"github.com/outblocks/outblocks-cli/pkg/config"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func (e *Executor) newPluginsCmd() *cobra.Command {
10+
cmd := &cobra.Command{
11+
Use: "plugins",
12+
Aliases: []string{"plugin"},
13+
Short: "Plugin management",
14+
Long: `Plugin management - list, update, add or remove.`,
15+
Annotations: map[string]string{
16+
cmdGroupAnnotation: cmdGroupMain,
17+
},
18+
}
19+
20+
list := &cobra.Command{
21+
Use: "list",
22+
Short: "List plugins",
23+
Long: `List installed plugins.`,
24+
Annotations: map[string]string{
25+
cmdGroupAnnotation: cmdGroupMain,
26+
},
27+
SilenceUsage: true,
28+
RunE: func(cmd *cobra.Command, args []string) error {
29+
if e.cfg == nil {
30+
return config.ErrProjectConfigNotFound
31+
}
32+
33+
return actions.NewPluginList(e.Log(), e.loader).Run(cmd.Context(), e.cfg)
34+
},
35+
}
36+
37+
update := &cobra.Command{
38+
Use: "update",
39+
Short: "Update plugins",
40+
Long: `Update installed plugins to matching versions from config.`,
41+
Annotations: map[string]string{
42+
cmdGroupAnnotation: cmdGroupMain,
43+
},
44+
SilenceUsage: true,
45+
RunE: func(cmd *cobra.Command, args []string) error {
46+
if e.cfg == nil {
47+
return config.ErrProjectConfigNotFound
48+
}
49+
50+
return actions.NewPluginUpdate(e.Log(), e.loader).Run(cmd.Context(), e.cfg)
51+
},
52+
}
53+
54+
cmd.AddCommand(
55+
list,
56+
update,
57+
)
58+
59+
return cmd
60+
}

cmd/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ func (e *Executor) newRoot() *cobra.Command {
269269
return err
270270
}
271271

272+
return nil
273+
},
274+
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
272275
if e.cfg != nil {
273276
if err := e.saveLockfile(); err != nil {
274277
_ = e.cleanupProject()
@@ -294,6 +297,7 @@ func (e *Executor) newRoot() *cobra.Command {
294297
e.newCompletionCmd(),
295298
e.newRunCmd(),
296299
e.newDeployCmd(),
300+
e.newPluginsCmd(),
297301
e.newForceUnlockCmd(),
298302
)
299303

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/mitchellh/go-homedir v1.1.0
1919
github.com/mitchellh/mapstructure v1.4.1 // indirect
2020
github.com/otiai10/copy v1.6.0
21-
github.com/outblocks/outblocks-plugin-go v0.0.0-20210705152117-95220fb1419c
21+
github.com/outblocks/outblocks-plugin-go v0.0.0-20210708180736-d828c58a8710
2222
github.com/pelletier/go-toml v1.9.1 // indirect
2323
github.com/pterm/pterm v0.12.22
2424
github.com/spf13/afero v1.6.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ github.com/outblocks/outblocks-plugin-go v0.0.0-20210630200127-298dfde78363 h1:V
280280
github.com/outblocks/outblocks-plugin-go v0.0.0-20210630200127-298dfde78363/go.mod h1:vAn4Vv7fXTyrjNEvAVcKtKJ2Bwaqk3Oy63lqnBRIct4=
281281
github.com/outblocks/outblocks-plugin-go v0.0.0-20210705152117-95220fb1419c h1:cyHK1LsYbaCS0lNG2J+fjZu2Ja8hu6Qod20Q9nrj4UQ=
282282
github.com/outblocks/outblocks-plugin-go v0.0.0-20210705152117-95220fb1419c/go.mod h1:vAn4Vv7fXTyrjNEvAVcKtKJ2Bwaqk3Oy63lqnBRIct4=
283+
github.com/outblocks/outblocks-plugin-go v0.0.0-20210708180736-d828c58a8710 h1:ToXKorA7tnQaJSdc/XrexdWuiwOHSiCE4g7VvzIfQuw=
284+
github.com/outblocks/outblocks-plugin-go v0.0.0-20210708180736-d828c58a8710/go.mod h1:vAn4Vv7fXTyrjNEvAVcKtKJ2Bwaqk3Oy63lqnBRIct4=
283285
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
284286
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
285287
github.com/pelletier/go-toml v1.9.1 h1:a6qW1EVNZWH9WGI6CsYdD8WAylkoXBS5yv0XHlh17Tc=

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func main() {
2121

2222
go func() {
2323
<-ch
24+
25+
exec.Log().Warnln("Canceling execution... Please wait for all pending tasks to finish...")
2426
cancel()
2527
}()
2628

@@ -33,7 +35,6 @@ func main() {
3335
err := exec.Execute(ctx)
3436

3537
cancel()
36-
close(ch)
3738

3839
if err != nil {
3940
exec.Log().Errorln(err)

0 commit comments

Comments
 (0)