This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
765 additions
and
3,141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ linters: | |
- ireturn | ||
- varnamelen | ||
- exhaustruct | ||
- depguard | ||
|
||
issues: | ||
exclude-rules: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package magetasks | ||
|
||
import ( | ||
"github.com/magefile/mage/mg" | ||
"context" | ||
|
||
"github.com/wavesoftware/go-magetasks/config" | ||
"github.com/wavesoftware/go-magetasks/pkg/deps" | ||
"github.com/wavesoftware/go-magetasks/pkg/targets" | ||
"github.com/wavesoftware/go-magetasks/pkg/tasks" | ||
) | ||
|
||
// Check will run all lints checks. | ||
func Check() { | ||
mg.Deps(deps.Install) | ||
func Check(ctx context.Context) { | ||
targets.Deps(ctx, deps.Install) | ||
t := tasks.Start("🔍", "Checking", len(config.Actual().Checks) > 0) | ||
for _, check := range config.Actual().Checks { | ||
p := t.Part(check.Name) | ||
pp := p.Starting() | ||
pp.Done(check.Operation(pp)) | ||
} | ||
t.End(nil) | ||
t.End() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/cardil/ghet/pkg/ghet/download" | ||
"github.com/cardil/ghet/pkg/ghet/install" | ||
"github.com/wavesoftware/go-magetasks/pkg/tasks" | ||
) | ||
|
||
type Binaries interface { | ||
Configurator | ||
Install(ctx context.Context, t *tasks.Task, destination string) error | ||
Count() int | ||
|
||
merge(b *binaries) | ||
} | ||
|
||
func NewBinaries(bins ...string) Binaries { | ||
return &binaries{ | ||
bins: bins, | ||
} | ||
} | ||
|
||
type binaries struct { | ||
bins []string | ||
} | ||
|
||
func (b *binaries) Count() int { | ||
return len(b.bins) | ||
} | ||
|
||
func (b *binaries) Install(ctx context.Context, t *tasks.Task, destination string) error { | ||
for _, binSpec := range b.bins { | ||
p := t.Part(fmt.Sprintf("Pre-built binary %q", binSpec)) | ||
pp := p.Starting() | ||
args := download.Args{ | ||
Args: install.Parse(binSpec), | ||
Destination: destination, | ||
} | ||
bin := args.Asset.FileName.ToString() | ||
path := fmt.Sprintf("%s/%s", destination, bin) | ||
if fileExist(path) { | ||
log.Println("Skipping installation of", binSpec, | ||
"because it already exists:", path) | ||
p.Skip("already installed") | ||
continue | ||
} | ||
if err := download.Action(ctx, args); err != nil { | ||
pp.Done(err) | ||
return err | ||
} | ||
pp.Notify("installed") | ||
} | ||
return nil | ||
} | ||
|
||
func (b *binaries) Configure(cfg Configurable) { | ||
cfg.Config().Dependencies.Binaries.merge(b) | ||
} | ||
|
||
func (b *binaries) merge(b2 *binaries) { | ||
b.bins = append(b.bins, b2.bins...) | ||
} | ||
|
||
func fileExist(path string) bool { | ||
_, err := os.Stat(path) | ||
return err == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.