-
Notifications
You must be signed in to change notification settings - Fork 557
/
typescript.go
50 lines (37 loc) · 1.28 KB
/
typescript.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sdk
import (
"context"
"os"
"strconv"
"github.com/magefile/mage/mg"
"github.com/dagger/dagger/ci/mage/util"
)
type TypeScript mg.Namespace
var _ SDK = TypeScript{}
// Lint lints the TypeScript SDK
func (t TypeScript) Lint(ctx context.Context) error {
return util.DaggerCall(ctx, "sdk", "typescript", "lint")
}
// Test tests the TypeScript SDK
func (t TypeScript) Test(ctx context.Context) error {
return util.DaggerCall(ctx, "sdk", "typescript", "test")
}
// Generate re-generates the SDK API
func (t TypeScript) Generate(ctx context.Context) error {
return util.DaggerCall(ctx, "sdk", "typescript", "generate", "export", "--path=.")
}
// Publish publishes the TypeScript SDK
func (t TypeScript) Publish(ctx context.Context, tag string) error {
args := []string{"sdk", "typescript", "publish", "--tag=" + tag}
if dryRun, _ := strconv.ParseBool(os.Getenv("DRY_RUN")); dryRun {
args = append(args, "--dry-run=true")
}
if _, ok := os.LookupEnv("NPM_TOKEN"); ok {
args = append(args, "--npm-token=env:NPM_TOKEN")
}
return util.DaggerCall(ctx, args...)
}
// Bump the TypeScript SDK's Engine dependency
func (t TypeScript) Bump(ctx context.Context, version string) error {
return util.DaggerCall(ctx, "sdk", "typescript", "bump", "--version="+version, "export", "--path=.")
}