This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
building blocks and parts of the whole
- Loading branch information
Showing
25 changed files
with
734 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/hofstadter-io/hofmod-cli v0.3.0 h1:+wCqHV08voZyt87uKKFpNOst6wON+OFOEqTViIF4Enk= | ||
github.com/hofstadter-io/hofmod-cli v0.3.0/cue.mods h1:hvuTtdDNMFf5D9Jv0SfQfg2qRBOkFGb+EVOwkVtYKQI= |
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,35 @@ | ||
# MVS Processing | ||
|
||
This is pseudo code for how MVS handles dependencies | ||
|
||
From: `mvs vendor <lang>` (when no lang, loops over discovered) | ||
|
||
### 1. Read Root Module | ||
|
||
1. Read MVS / mod files | ||
1. `.mvsconfig` if exists (this will configure paths and behaviors for this module) | ||
1. `<lang>.mod` file, EXIT if does not exist, warn to init | ||
1. `<lang>.sum` file, if exists | ||
1. If compare(sum, mod) == Same / Valid | ||
1. Check content is ok | ||
1. If not, EXIT and WARN | ||
1. For each entry in {mod - sum} | ||
1. Fetch: cache -> remote | ||
1. CALL: ReadDepsModule | ||
|
||
|
||
|
||
|
||
|
||
### FN: ReadDepsModule | ||
|
||
|
||
1. Read MVS / mod files | ||
1. `.mvsconfig` if exists (this will configure paths and behaviors for this module) | ||
1. `<lang>.mod` file, EXIT if does not exist, warn to init | ||
1. `<lang>.sum` file, if exists | ||
1. | ||
|
||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cache | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"os" | ||
|
||
"golang.org/x/mod/sumdb/dirhash" | ||
) | ||
|
||
func Checksum(lang, mod, ver string) (string, error) { | ||
|
||
dir := filepath.Join( | ||
LocalCacheBaseDir, | ||
"mod", | ||
lang, | ||
mod, | ||
"@", | ||
ver, | ||
) | ||
|
||
fmt.Println("Cache Load:", dir) | ||
|
||
_, err := os.Lstat(dir) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
h, err := dirhash.HashDir(dir, mod, dirhash.Hash1) | ||
|
||
return h, err | ||
} | ||
|
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,43 @@ | ||
package cache | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/hofstadter-io/mvs/lib/util" | ||
) | ||
|
||
var ( | ||
LocalCacheBaseDir = filepath.Join(util.UserHomeDir(), ".mvs") | ||
) | ||
|
||
func SetBaseDir(basedir string) { | ||
LocalCacheBaseDir = basedir | ||
} | ||
|
||
/* | ||
func Lookup(modFile, mdr, mod, ver string) (zdata []byte, err error) { | ||
dir := filepath.Join( | ||
LocalCacheBaseDir, | ||
"mod", | ||
mdr, | ||
mod, | ||
"@", | ||
ver, | ||
) | ||
fmt.Println("Cache Lookup:", dir) | ||
// TODO, lookup | ||
var buf bytes.Buffer | ||
m := module.Version{ Path: mod, Version: ver } | ||
err = zip.CreateFromDir(&buf, m, dir, modFile, []string{"**.*"}, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return buf.Bytes(), 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cache | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"os" | ||
|
||
"github.com/go-git/go-billy/v5" | ||
"github.com/go-git/go-billy/v5/osfs" | ||
) | ||
|
||
func Load(lang, mod, ver string) (FS billy.Filesystem, err error) { | ||
|
||
dir := filepath.Join( | ||
LocalCacheBaseDir, | ||
"mod", | ||
lang, | ||
mod, | ||
"@", | ||
ver, | ||
) | ||
|
||
fmt.Println("Cache Load:", dir) | ||
|
||
_, err = os.Lstat(dir) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
FS = osfs.New(dir) | ||
|
||
return FS, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package cache | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/go-git/go-billy/v5" | ||
|
||
"github.com/hofstadter-io/mvs/lib/util" | ||
) | ||
|
||
func Write(lang, remote, owner, repo, tag string, FS billy.Filesystem) error { | ||
outdir := filepath.Join( | ||
LocalCacheBaseDir, | ||
"mod", | ||
lang, | ||
remote, | ||
owner, | ||
repo + "@" + tag, | ||
) | ||
|
||
return util.BillyWriteDirToOS(outdir, "/", FS) | ||
} |
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.