Skip to content

Commit 676aa5b

Browse files
authored
feat(apps): officially support remote taskfiles (#625)
* feat(apps): officially support remote taskfiles * chore: ignore temporary task directory * fix(app): safely execute tasks in other working directories * chore(deps): update deps
1 parent 3be6d92 commit 676aa5b

File tree

6 files changed

+143
-85
lines changed

6 files changed

+143
-85
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ bin/
1717
.idea/
1818
dist/
1919

20-
.DS_Store
20+
# Local artifacts
21+
.task/
22+
23+
.DS_Store

cmd/lk/app.go

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"errors"
2020
"fmt"
21+
"maps"
2122
"os"
2223
"regexp"
2324
"strings"
@@ -453,9 +454,7 @@ func instantiateEnv(ctx context.Context, cmd *cli.Command, rootPath string, addl
453454
}
454455

455456
if addlEnv != nil {
456-
for k, v := range *addlEnv {
457-
env[k] = v
458-
}
457+
maps.Copy(env, *addlEnv)
459458
}
460459

461460
prompt := func(key, oldValue string) (string, error) {
@@ -526,16 +525,42 @@ func doInstall(ctx context.Context, task bootstrap.KnownTask, rootPath string, v
526525
func runTask(ctx context.Context, cmd *cli.Command) error {
527526
verbose := cmd.Bool("verbose")
528527
rootDir := "."
529-
tf, err := bootstrap.ParseTaskfile(rootDir)
528+
529+
args := cmd.Args().Tail()
530+
if len(args) > 0 {
531+
dirPath := args[0]
532+
if stat, err := os.Stat(dirPath); os.IsNotExist(err) {
533+
return fmt.Errorf("directory does not exist: %s", dirPath)
534+
} else if err != nil {
535+
return fmt.Errorf("error accessing directory %s: %v", dirPath, err)
536+
} else {
537+
if !stat.IsDir() {
538+
return fmt.Errorf("path is not a directory: %s", dirPath)
539+
}
540+
rootDir = dirPath
541+
}
542+
}
543+
544+
_, err := bootstrap.ParseTaskfile(rootDir)
530545
if err != nil {
531546
return err
532547
}
533548

549+
exe := bootstrap.NewTaskExecutor(rootDir, verbose)
550+
if err := exe.Setup(); err != nil {
551+
return fmt.Errorf("could not initialize task executor: %w", err)
552+
}
553+
534554
taskName := cmd.Args().First()
535555
if taskName == "" {
556+
tasks, err := exe.GetTaskList()
557+
if err != nil {
558+
return err
559+
}
560+
536561
var options []huh.Option[string]
537-
for name := range tf.Tasks.Keys(nil) {
538-
options = append(options, huh.NewOption(name, name))
562+
for _, t := range tasks {
563+
options = append(options, huh.NewOption(t.Name(), t.Name()))
539564
}
540565

541566
if err := huh.NewForm(
@@ -549,16 +574,9 @@ func runTask(ctx context.Context, cmd *cli.Command) error {
549574
}
550575
}
551576

552-
task, err := bootstrap.NewTask(ctx, tf, rootDir, taskName, verbose)
577+
task, err := bootstrap.NewTaskWithExecutor(ctx, exe, taskName, verbose)
553578
if err != nil {
554579
return err
555580
}
556-
var cmdErr error
557-
if err := util.Await(
558-
"Running task "+taskName+"...",
559-
func() { cmdErr = task() },
560-
); err != nil {
561-
return err
562-
}
563-
return cmdErr
581+
return task()
564582
}

go.mod

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ toolchain go1.24.3
66

77
require (
88
github.com/BurntSushi/toml v1.5.0
9+
github.com/Masterminds/semver/v3 v3.4.0
910
github.com/charmbracelet/huh v0.7.0
1011
github.com/charmbracelet/huh/spinner v0.0.0-20250602115108-fe12c0e929d3
1112
github.com/charmbracelet/lipgloss v1.1.0
1213
github.com/frostbyte73/core v0.1.1
1314
github.com/go-logr/logr v1.4.3
14-
github.com/go-task/task/v3 v3.43.3
15+
github.com/go-task/task/v3 v3.44.1
1516
github.com/google/osv-scanner v1.9.2
1617
github.com/joho/godotenv v1.5.1
1718
github.com/livekit/protocol v1.39.4-0.20250718180328-5934235d53ec
@@ -27,7 +28,7 @@ require (
2728
github.com/twitchtv/twirp v8.1.3+incompatible
2829
github.com/urfave/cli/v3 v3.3.3
2930
go.uber.org/atomic v1.11.0
30-
golang.org/x/sync v0.15.0
31+
golang.org/x/sync v0.16.0
3132
golang.org/x/time v0.11.0
3233
google.golang.org/protobuf v1.36.6
3334
gopkg.in/yaml.v3 v3.0.1
@@ -39,13 +40,12 @@ require (
3940
buf.build/go/protovalidate v0.13.1 // indirect
4041
buf.build/go/protoyaml v0.6.0 // indirect
4142
cel.dev/expr v0.24.0 // indirect
42-
dario.cat/mergo v1.0.1 // indirect
43+
dario.cat/mergo v1.0.2 // indirect
4344
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
4445
github.com/Ladicle/tabwriter v1.0.0 // indirect
45-
github.com/Masterminds/semver/v3 v3.3.1 // indirect
4646
github.com/Microsoft/go-winio v0.6.2 // indirect
47-
github.com/ProtonMail/go-crypto v1.1.6 // indirect
48-
github.com/alecthomas/chroma/v2 v2.16.0 // indirect
47+
github.com/ProtonMail/go-crypto v1.3.0 // indirect
48+
github.com/alecthomas/chroma/v2 v2.19.0 // indirect
4949
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
5050
github.com/atotto/clipboard v0.1.4 // indirect
5151
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
@@ -91,11 +91,11 @@ require (
9191
github.com/gammazero/deque v1.0.0 // indirect
9292
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
9393
github.com/go-git/go-billy/v5 v5.6.2 // indirect
94-
github.com/go-git/go-git/v5 v5.16.0 // indirect
94+
github.com/go-git/go-git/v5 v5.16.2 // indirect
9595
github.com/go-jose/go-jose/v3 v3.0.4 // indirect
9696
github.com/go-logr/stdr v1.2.2 // indirect
9797
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
98-
github.com/go-task/template v0.1.0 // indirect
98+
github.com/go-task/template v0.2.0 // indirect
9999
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
100100
github.com/gofrs/flock v0.12.1 // indirect
101101
github.com/gogo/protobuf v1.3.2 // indirect
@@ -116,14 +116,14 @@ require (
116116
github.com/jxskiss/base62 v1.1.0 // indirect
117117
github.com/kevinburke/ssh_config v1.2.0 // indirect
118118
github.com/klauspost/compress v1.18.0 // indirect
119-
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
119+
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
120120
github.com/lithammer/shortuuid/v4 v4.2.0 // indirect
121121
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 // indirect
122122
github.com/livekit/mediatransportutil v0.0.0-20250519131108-fb90f5acfded // indirect
123123
github.com/livekit/psrpc v0.6.1-0.20250511053145-465289d72c3c // indirect
124124
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
125125
github.com/magefile/mage v1.15.0 // indirect
126-
github.com/mattn/go-colorable v0.1.13 // indirect
126+
github.com/mattn/go-colorable v0.1.14 // indirect
127127
github.com/mattn/go-isatty v0.0.20 // indirect
128128
github.com/mattn/go-localereader v0.0.1 // indirect
129129
github.com/mattn/go-runewidth v0.0.16 // indirect
@@ -157,7 +157,7 @@ require (
157157
github.com/pion/stun/v3 v3.0.0 // indirect
158158
github.com/pion/transport/v3 v3.0.7 // indirect
159159
github.com/pion/turn/v4 v4.0.2 // indirect
160-
github.com/pjbgf/sha1cd v0.3.2 // indirect
160+
github.com/pjbgf/sha1cd v0.4.0 // indirect
161161
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
162162
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
163163
github.com/prometheus/client_golang v1.22.0 // indirect
@@ -169,7 +169,7 @@ require (
169169
github.com/rivo/uniseg v0.4.7 // indirect
170170
github.com/sajari/fuzzy v1.0.0 // indirect
171171
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
172-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
172+
github.com/sergi/go-diff v1.4.0 // indirect
173173
github.com/shibumi/go-pathspec v1.3.0 // indirect
174174
github.com/sirupsen/logrus v1.9.3 // indirect
175175
github.com/skeema/knownhosts v1.3.1 // indirect
@@ -197,17 +197,17 @@ require (
197197
go.uber.org/multierr v1.11.0 // indirect
198198
go.uber.org/zap v1.27.0 // indirect
199199
go.uber.org/zap/exp v0.3.0 // indirect
200-
golang.org/x/crypto v0.39.0 // indirect
200+
golang.org/x/crypto v0.40.0 // indirect
201201
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
202202
golang.org/x/mod v0.25.0 // indirect
203-
golang.org/x/net v0.41.0 // indirect
204-
golang.org/x/sys v0.33.0 // indirect
205-
golang.org/x/term v0.32.0 // indirect
206-
golang.org/x/text v0.26.0 // indirect
203+
golang.org/x/net v0.42.0 // indirect
204+
golang.org/x/sys v0.34.0 // indirect
205+
golang.org/x/term v0.33.0 // indirect
206+
golang.org/x/text v0.27.0 // indirect
207207
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
208208
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
209209
google.golang.org/grpc v1.73.0 // indirect
210210
gopkg.in/inf.v0 v0.9.1 // indirect
211211
gopkg.in/warnings.v0 v0.1.2 // indirect
212-
mvdan.cc/sh/v3 v3.11.0 // indirect
212+
mvdan.cc/sh/v3 v3.12.0 // indirect
213213
)

0 commit comments

Comments
 (0)