Skip to content

Commit

Permalink
Merge pull request #154 from hofstadter-io/more-mod-work
Browse files Browse the repository at this point in the history
hof/mod: add validate, introspection, and psuedoversions
  • Loading branch information
verdverm authored Mar 10, 2023
2 parents 87f83a9 + e0a3261 commit 1fd5402
Show file tree
Hide file tree
Showing 37 changed files with 721 additions and 1,627 deletions.
1 change: 1 addition & 0 deletions .hof/shadow/cli/cmd/hof/cmd/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func init() {

ModCmd.AddCommand(cmdmod.InitCmd)
ModCmd.AddCommand(cmdmod.GetCmd)
ModCmd.AddCommand(cmdmod.VerifyCmd)
ModCmd.AddCommand(cmdmod.TidyCmd)
ModCmd.AddCommand(cmdmod.LinkCmd)
ModCmd.AddCommand(cmdmod.VendorCmd)
Expand Down
88 changes: 88 additions & 0 deletions .hof/shadow/cli/cmd/hof/cmd/mod/verify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package cmdmod

import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/lib/mod"

"github.com/hofstadter-io/hof/cmd/hof/flags"

"github.com/hofstadter-io/hof/cmd/hof/ga"
)

var verifyLong = `verify integrity of dependencies`

func VerifyRun(args []string) (err error) {

err = mod.Verify(flags.RootPflags)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

return err
}

var VerifyCmd = &cobra.Command{

Use: "verify",

Short: "verify integrity of dependencies",

Long: verifyLong,

PreRun: func(cmd *cobra.Command, args []string) {

ga.SendCommandPath(cmd.CommandPath())

},

Run: func(cmd *cobra.Command, args []string) {
var err error

// Argument Parsing

err = VerifyRun(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}

func init() {
extra := func(cmd *cobra.Command) bool {

return false
}

ohelp := VerifyCmd.HelpFunc()
ousage := VerifyCmd.UsageFunc()
help := func(cmd *cobra.Command, args []string) {
if extra(cmd) {
return
}
ohelp(cmd, args)
}
usage := func(cmd *cobra.Command) error {
if extra(cmd) {
return nil
}
return ousage(cmd)
}

thelp := func(cmd *cobra.Command, args []string) {
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
VerifyCmd.SetHelpFunc(thelp)
VerifyCmd.SetUsageFunc(tusage)

}
1 change: 1 addition & 0 deletions cmd/hof/cmd/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func init() {

ModCmd.AddCommand(cmdmod.InitCmd)
ModCmd.AddCommand(cmdmod.GetCmd)
ModCmd.AddCommand(cmdmod.VerifyCmd)
ModCmd.AddCommand(cmdmod.TidyCmd)
ModCmd.AddCommand(cmdmod.LinkCmd)
ModCmd.AddCommand(cmdmod.VendorCmd)
Expand Down
88 changes: 88 additions & 0 deletions cmd/hof/cmd/mod/verify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package cmdmod

import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/lib/mod"

"github.com/hofstadter-io/hof/cmd/hof/flags"

"github.com/hofstadter-io/hof/cmd/hof/ga"
)

var verifyLong = `verify integrity of dependencies`

func VerifyRun(args []string) (err error) {

err = mod.Verify(flags.RootPflags)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

return err
}

var VerifyCmd = &cobra.Command{

Use: "verify",

Short: "verify integrity of dependencies",

Long: verifyLong,

PreRun: func(cmd *cobra.Command, args []string) {

ga.SendCommandPath(cmd.CommandPath())

},

Run: func(cmd *cobra.Command, args []string) {
var err error

// Argument Parsing

err = VerifyRun(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}

func init() {
extra := func(cmd *cobra.Command) bool {

return false
}

ohelp := VerifyCmd.HelpFunc()
ousage := VerifyCmd.UsageFunc()
help := func(cmd *cobra.Command, args []string) {
if extra(cmd) {
return
}
ohelp(cmd, args)
}
usage := func(cmd *cobra.Command) error {
if extra(cmd) {
return nil
}
return ousage(cmd)
}

thelp := func(cmd *cobra.Command, args []string) {
ga.SendCommandPath(cmd.CommandPath() + " help")
help(cmd, args)
}
tusage := func(cmd *cobra.Command) error {
ga.SendCommandPath(cmd.CommandPath() + " usage")
return usage(cmd)
}
VerifyCmd.SetHelpFunc(thelp)
VerifyCmd.SetUsageFunc(tusage)

}
2 changes: 1 addition & 1 deletion cmd/hof/verinfo/verinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
// the value gets injected into templates in various places
// the default here is set to something useful for dev
// the release version is the same as the cli running it
HofVersion = "v0.6.8-create.1"
HofVersion = "v0.6.8-beta.9"
)

func init() {
Expand Down
9 changes: 9 additions & 0 deletions design/cmds/mod.cue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ import (
os.Exit(1)
}
"""
}, {
Name: "verify"
Usage: "verify"
Short: "verify integrity of dependencies"
Long: Short

Imports: #ModCmdImports

Body: (#body & { func: "Verify" }).content
}, {
Name: "tidy"
Usage: "tidy"
Expand Down
1 change: 1 addition & 0 deletions docs/code/cmd-help/mod
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Available Commands:
link symlink dependencies to cue.mod/pkg
tidy recalculate dependencies and update mod files
vendor copy dependencies to cue.mod/pkg
verify verify integrity of dependencies

Flags:
-h, --help help for mod
Expand Down
4 changes: 2 additions & 2 deletions flow/tasks/csp/schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Chan: {
// Send a message to a mailbox
Send: {
@task(csp.Send)
$task(csp.Send)
$task: "csp.Send"

// the name of the channel
mailbox: string
Expand All @@ -35,7 +35,7 @@ Send: {
// Recv is a coroutine which runs indefinitely
Recv: {
@task(csp.Recv)
$task(csp.Recv)
$task: "csp.Recv"

// the name of the channel
mailbox: string
Expand Down
11 changes: 5 additions & 6 deletions lib/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,19 @@ func Create(module string, extra []string, rootflags flags.RootPflagpole, cmdfla
}

ref := ver

if looksLikeRepo(url) && ver == "latest" {
// ensure we have the most up-to-date code
_, err = cache.FetchRepoSource(url, "")
// ensure we have the most up-to-date code
if looksLikeRepo(url) {
_, err = cache.FetchRepoSource(url, ver)
if err != nil {
return err
}

ref, err = cache.GetLatestTag(url, false)
ref, err = cache.UpgradePsuedoVersion(url, ver)
if err != nil {
return err
}
}


fmt.Println("setting up...")
tmpdir, subdir, err = setupTmpdir(url, ref)
if err != nil {
Expand Down
Loading

0 comments on commit 1fd5402

Please sign in to comment.