Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memo v2: thunk-based bass.lock #71

Merged
merged 3 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 71 additions & 58 deletions bass.lock
Original file line number Diff line number Diff line change
@@ -1,40 +1,16 @@
{
"memo": {
"git-ls-remote": [
"2d1f994e0a8e466595818ce55744edef890a6d45dfea1d1b22987f85e6fec074:resolve": [
{
"input": {
"ref": "main",
"uri": "https://github.com/vito/tabs"
},
"output": "d133c67adcbb15e548915bffcd9fd204a985aee5"
}
],
"resolve-image": [
{
"input": {
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
},
"output": {
"digest": "sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300",
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
}
},
{
"input": {
"platform": {
"os": "linux"
},
"repository": "alpine/git",
"tag": "latest"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "alpine/git",
"tag": "latest"
}
],
"output": {
"digest": "sha256:d4740deff7f05d2d48771ff66d9d9c26dfb76f0db0aa833b1ea0ee346fa1e48f",
"platform": {
Expand All @@ -45,15 +21,17 @@
}
},
{
"input": {
"platform": {
"os": "linux"
},
"repository": "golang",
"tag": "1.17"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "golang",
"tag": "1.17"
}
],
"output": {
"digest": "sha256:301609ebecc0ec4cd3174294220a4d9c92aab9015b3a2958297d7663aac627a1",
"digest": "sha256:1a35cc2c5338409227c7293add327ebe42e1ee5465049f6c57c829588e3f8a39",
"platform": {
"os": "linux"
},
Expand All @@ -62,30 +40,34 @@
}
},
{
"input": {
"platform": {
"os": "linux"
},
"repository": "golang",
"tag": "latest"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
}
],
"output": {
"digest": "sha256:301609ebecc0ec4cd3174294220a4d9c92aab9015b3a2958297d7663aac627a1",
"digest": "sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300",
"platform": {
"os": "linux"
},
"repository": "golang",
"repository": "alpine",
"tag": "latest"
}
},
{
"input": {
"platform": {
"os": "linux"
},
"repository": "ubuntu",
"tag": "latest"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "ubuntu",
"tag": "latest"
}
],
"output": {
"digest": "sha256:669e010b58baf5beb2836b253c1fd5768333f0d1dbcb834f7c07a4dc93f474be",
"platform": {
Expand All @@ -95,6 +77,37 @@
"tag": "latest"
}
}
],
"97ea7bc7e38a8f9dbbd589a3d00e96c1a9808a27a44524339c93faadbc4a10a3:ls-remote": [
{
"input": [
"https://github.com/vito/tabs",
"main"
],
"output": "d133c67adcbb15e548915bffcd9fd204a985aee5"
}
]
},
"thunks": {
"2d1f994e0a8e466595818ce55744edef890a6d45dfea1d1b22987f85e6fec074": {
"cmd": {
"command": "run"
}
},
"97ea7bc7e38a8f9dbbd589a3d00e96c1a9808a27a44524339c93faadbc4a10a3": {
"cmd": {
"command": "git"
},
"stdin": [
{
"digest": "sha256:d4740deff7f05d2d48771ff66d9d9c26dfb76f0db0aa833b1ea0ee346fa1e48f",
"platform": {
"os": "linux"
},
"repository": "alpine/git",
"tag": "latest"
}
]
}
}
}
2 changes: 1 addition & 1 deletion cmd/bass/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func repl(ctx context.Context) error {
env := bass.ImportSystemEnv()

scope := runtimes.NewScope(bass.Ground, runtimes.RunState{
Dir: bass.NewHostPath("."),
Dir: bass.NewHostDir("."),
Stdin: bass.Stdin,
Stdout: bass.Stdout,
Env: env,
Expand Down
2 changes: 1 addition & 1 deletion cmd/bass/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func run(ctx context.Context, filePath string, argv ...string) error {
env := bass.ImportSystemEnv()

scope := runtimes.NewScope(bass.Ground, runtimes.RunState{
Dir: bass.NewHostPath(filepath.Dir(filePath) + string(os.PathSeparator)),
Dir: bass.NewHostDir(filepath.Dir(filePath) + string(os.PathSeparator)),
Stdin: bass.Stdin,
Stdout: stdout,
Env: env,
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildGoModule rec {
src = ./.;

# get using ./hack/get-nix-vendorsha
vendorSha256 = "sha256-EVkMwAZhVeTJOYPaMP7clzmTAIcZBF8+zpm9aOUJyI0=";
vendorSha256 = "sha256-V7Jv9QOWz7zxC7w6be/j6bi7LGWPDzXJAPNOaTIMqh0=";

nativeBuildInputs = [ makeWrapper ];

Expand Down
130 changes: 95 additions & 35 deletions demos/bass.lock
Original file line number Diff line number Diff line change
@@ -1,74 +1,134 @@
{
"memo": {
"resolve-image": [
"2d1f994e0a8e466595818ce55744edef890a6d45dfea1d1b22987f85e6fec074:resolve": [
{
"input": {
"platform": {
"os": "linux"
},
"repository": "alpine/git",
"tag": "latest"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "ubuntu",
"tag": "latest"
}
],
"output": {
"digest": "sha256:d4740deff7f05d2d48771ff66d9d9c26dfb76f0db0aa833b1ea0ee346fa1e48f",
"digest": "sha256:669e010b58baf5beb2836b253c1fd5768333f0d1dbcb834f7c07a4dc93f474be",
"platform": {
"os": "linux"
},
"repository": "alpine/git",
"repository": "ubuntu",
"tag": "latest"
}
},
{
"input": {
"platform": {
"os": "linux"
},
"repository": "ubuntu",
"tag": "latest"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
}
],
"output": {
"digest": "sha256:669e010b58baf5beb2836b253c1fd5768333f0d1dbcb834f7c07a4dc93f474be",
"digest": "sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300",
"platform": {
"os": "linux"
},
"repository": "ubuntu",
"repository": "alpine",
"tag": "latest"
}
},
{
"input": {
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
},
"input": [
{
"platform": {
"os": "linux"
},
"repository": "alpine/git",
"tag": "latest"
}
],
"output": {
"digest": "sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300",
"digest": "sha256:d4740deff7f05d2d48771ff66d9d9c26dfb76f0db0aa833b1ea0ee346fa1e48f",
"platform": {
"os": "linux"
},
"repository": "alpine",
"repository": "alpine/git",
"tag": "latest"
}
},
{
"input": {
"input": [
{
"platform": {
"os": "linux"
},
"repository": "golang",
"tag": "latest"
}
],
"output": {
"digest": "sha256:1a35cc2c5338409227c7293add327ebe42e1ee5465049f6c57c829588e3f8a39",
"platform": {
"os": "linux"
},
"repository": "golang",
"tag": "latest"
},
"output": {
"digest": "sha256:301609ebecc0ec4cd3174294220a4d9c92aab9015b3a2958297d7663aac627a1",
}
}
],
"97ea7bc7e38a8f9dbbd589a3d00e96c1a9808a27a44524339c93faadbc4a10a3:ls-remote": [
{
"input": [
"https://github.com/vito/bass",
"main"
],
"output": "501a938070e1d431ba098224e44262e6518914ca"
},
{
"input": [
"https://github.com/vito/booklit",
"master"
],
"output": "d8a431dd40f9b3eb6f7dec42baec73eb063fc897"
},
{
"input": [
"https://github.com/vito/tabs",
"main"
],
"output": "d133c67adcbb15e548915bffcd9fd204a985aee5"
},
{
"input": [
"https://github.com/vito/booklit",
"HEAD"
],
"output": "d8a431dd40f9b3eb6f7dec42baec73eb063fc897"
}
]
},
"thunks": {
"2d1f994e0a8e466595818ce55744edef890a6d45dfea1d1b22987f85e6fec074": {
"cmd": {
"command": "run"
}
},
"97ea7bc7e38a8f9dbbd589a3d00e96c1a9808a27a44524339c93faadbc4a10a3": {
"cmd": {
"command": "git"
},
"stdin": [
{
"digest": "sha256:d4740deff7f05d2d48771ff66d9d9c26dfb76f0db0aa833b1ea0ee346fa1e48f",
"platform": {
"os": "linux"
},
"repository": "golang",
"repository": "alpine/git",
"tag": "latest"
}
}
]
]
}
}
}
4 changes: 2 additions & 2 deletions docs/go/bass.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (plugin *Plugin) GroundDocs() (booklit.Content, error) {

func (plugin *Plugin) ScriptDocs() (booklit.Content, error) {
scp := runtimes.NewScope(bass.NewEmptyScope(), runtimes.RunState{
Dir: bass.NewHostPath("."),
Dir: bass.NewHostDir("."),
Env: bass.Bindings{"SECRET_TOKEN": bass.String("im a spooky value")}.Scope(),
})
return plugin.scopeDocs("script", scp.Parents[0])
Expand Down Expand Up @@ -313,7 +313,7 @@ func initBassCtx() (context.Context, error) {
func newScope() (*bass.Scope, *bass.InMemorySink, error) {
stdoutSink := bass.NewInMemorySink()
scope := runtimes.NewScope(bass.Ground, runtimes.RunState{
Dir: bass.NewHostPath("."),
Dir: bass.NewHostDir("."),
Stdout: bass.NewSink(stdoutSink),
Stdin: bass.NewSource(bass.NewInMemorySource()),
})
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ require (
github.com/vito/progrock v0.0.0-20220202232206-ae3f74215901
github.com/vito/vt100 v0.0.0-20211217051322-45a31b434dad
go.uber.org/zap v1.19.1
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
)

Expand Down
Loading