Skip to content
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.43"
".": "0.1.0-alpha.44"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-e588492ce099ac1af79467a22ecac606b1fe8cf78a82fd37137bf8e30ac1a80e.yml
openapi_spec_hash: 7311d0d71ab64604d2b298e3c38b945f
config_hash: b4d273d7503424c98b7d284102d23fb1
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-5c1008fd27f64bcde1a146a4158f1c3113b4e13437a4d880bd6811fb063cfcd6.yml
openapi_spec_hash: 9583f62164b5dc15b10051dad6a7fca4
config_hash: e895f7992a607a15865ed026cbe5470d
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.1.0-alpha.44 (2025-09-22)

Full Changelog: [v0.1.0-alpha.43...v0.1.0-alpha.44](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.43...v0.1.0-alpha.44)

### Features

* **api:** docs ([f0762b0](https://github.com/stainless-api/stainless-api-cli/commit/f0762b08842d63a55f28afc18a77907c24f2513b))
* improved formatting options for command outputs ([f5e6481](https://github.com/stainless-api/stainless-api-cli/commit/f5e6481706b882eaa0c84a3bf8aea2a088087402))
* show full error message on fatal error ([00621a1](https://github.com/stainless-api/stainless-api-cli/commit/00621a1ba20a392670dc8a7bf991c1d0507efc12))


### Bug Fixes

* fix for issue with nil responses ([14f22bf](https://github.com/stainless-api/stainless-api-cli/commit/14f22bfbe6318e849a57b2243c958e3af869b18c))
* fix go client version bump issues ([d59e6ea](https://github.com/stainless-api/stainless-api-cli/commit/d59e6ea0f8363c1ad7ace9c97e243ec972f75c24))


### Chores

* code cleanup for `interface{}` ([30cd6f1](https://github.com/stainless-api/stainless-api-cli/commit/30cd6f10ce33163f4f6b7f13085a259cf738ca49))
* do not install brew dependencies in ./scripts/bootstrap by default ([ff84f98](https://github.com/stainless-api/stainless-api-cli/commit/ff84f986702f63a60e1f5343e180c305877f6171))
* update go dependency ([22a15b8](https://github.com/stainless-api/stainless-api-cli/commit/22a15b85720596afe3dd95d3be4f2ce4ddf1341a))

## 0.1.0-alpha.43 (2025-09-16)

Full Changelog: [v0.1.0-alpha.42...v0.1.0-alpha.43](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.42...v0.1.0-alpha.43)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ stl [resource] [command] [flags]

```sh
stl builds create \
--project project \
--revision string
--project stainless \
--revision main
```

For details about specific commands, use the `--help` flag.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ require (
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/muesli/reflow v0.3.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/stainless-api/stainless-api-go v0.24.0
github.com/tidwall/gjson v1.17.0
github.com/stainless-api/stainless-api-go v0.25.0
github.com/tidwall/gjson v1.18.0
github.com/tidwall/pretty v1.2.1
github.com/tidwall/sjson v1.2.5
github.com/urfave/cli-docs/v3 v3.0.0-alpha6
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stainless-api/stainless-api-go v0.24.0 h1:74rVOCsNiZFzp5WiNFZAF+0WPriyUdaQezUIDRzoqUo=
github.com/stainless-api/stainless-api-go v0.24.0/go.mod h1:9Q2t8xq6EFgw8HYOsVxqKEfSDVe9eqCoh1zC0HMRwTY=
github.com/stainless-api/stainless-api-go v0.25.0 h1:zcKI6oXjvw7kK3LoLOwmIxAGT+KzxBlWRyeZUCZ4s4E=
github.com/stainless-api/stainless-api-go v0.25.0/go.mod h1:apIvLQZziUlztAHBzTCLwf2TepwlPV0fg7dy/HIrKf8=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
Expand Down
36 changes: 21 additions & 15 deletions pkg/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func processSingleTarget(target string) (string, string) {
}

// getBuildTargetInfo extracts completed targets from a build response
func getBuildTargetInfo(buildRes stainless.BuildObject) []BuildTargetInfo {
func getBuildTargetInfo(buildRes stainless.Build) []BuildTargetInfo {
targets := []BuildTargetInfo{}

// Check each target and add it to the list if it's completed or in postgen
Expand Down Expand Up @@ -173,7 +173,7 @@ func isTargetCompleted(status stainless.BuildTargetStatus) bool {
}

// waitForBuildCompletion polls a build until completion and shows progress updates
func waitForBuildCompletion(ctx context.Context, client stainless.Client, build *stainless.BuildObject, waitGroup *Group) (*stainless.BuildObject, error) {
func waitForBuildCompletion(ctx context.Context, client stainless.Client, build *stainless.Build, waitGroup *Group) (*stainless.Build, error) {
ticker := time.NewTicker(3 * time.Second)
defer ticker.Stop()

Expand Down Expand Up @@ -225,7 +225,7 @@ func waitForBuildCompletion(ctx context.Context, client stainless.Client, build

var buildsCreate = cli.Command{
Name: "create",
Usage: "Create a new build",
Usage: "Create a build, on top of a project branch, against a given input revision.",
Flags: []cli.Flag{
&jsonflag.JSONStringFlag{
Name: "project",
Expand Down Expand Up @@ -310,7 +310,7 @@ var buildsCreate = cli.Command{

var buildsRetrieve = cli.Command{
Name: "retrieve",
Usage: "Retrieve a build by ID",
Usage: "Retrieve a build by its ID.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "build-id",
Expand All @@ -322,7 +322,7 @@ var buildsRetrieve = cli.Command{

var buildsList = cli.Command{
Name: "list",
Usage: "List builds for a project",
Usage: "List user-triggered builds for a given project.",
Flags: []cli.Flag{
&jsonflag.JSONStringFlag{
Name: "project",
Expand Down Expand Up @@ -366,7 +366,7 @@ var buildsList = cli.Command{

var buildsCompare = cli.Command{
Name: "compare",
Usage: "Creates two builds whose outputs can be compared directly",
Usage: "Create two builds whose outputs can be directly compared with each other.",
Flags: []cli.Flag{
&jsonflag.JSONStringFlag{
Name: "base.branch",
Expand Down Expand Up @@ -489,21 +489,23 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {

func handleBuildsRetrieve(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
res, err := cc.client.Builds.Get(
var res []byte
_, err := cc.client.Builds.Get(
context.TODO(),
cmd.Value("build-id").(string),
option.WithMiddleware(cc.AsMiddleware()),
option.WithResponseBodyInto(&res),
)
if err != nil {
return err
}

format := cmd.Root().String("format")
return ShowJSON("builds retrieve", res.RawJSON(), format)
return ShowJSON("builds retrieve", string(res), format)
}

// pullBuildOutputs pulls the outputs for a completed build
func pullBuildOutputs(ctx context.Context, client stainless.Client, res stainless.BuildObject, targetPaths map[string]string, pullGroup *Group) error {
func pullBuildOutputs(ctx context.Context, client stainless.Client, res stainless.Build, targetPaths map[string]string, pullGroup *Group) error {
// Get all targets
allTargets := getBuildTargetInfo(res)

Expand Down Expand Up @@ -572,8 +574,8 @@ func pullBuildOutputs(ctx context.Context, client stainless.Client, res stainles
}

// hasFailedCommitStep checks if a target has a fatal commit conclusion
func hasFailedCommitStep(build stainless.BuildObject, target stainless.Target) bool {
buildObj := NewBuildObject(&build)
func hasFailedCommitStep(build stainless.Build, target stainless.Target) bool {
buildObj := NewBuild(&build)
buildTarget := buildObj.BuildTarget(target)
if buildTarget == nil {
return false
Expand Down Expand Up @@ -774,31 +776,35 @@ func pullOutput(output, url, ref, targetDir string, targetGroup *Group) error {
func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainless.BuildListParams{}
res, err := cc.client.Builds.List(
var res []byte
_, err := cc.client.Builds.List(
context.TODO(),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithResponseBodyInto(&res),
)
if err != nil {
return err
}

format := cmd.Root().String("format")
return ShowJSON("builds list", res.RawJSON(), format)
return ShowJSON("builds list", string(res), format)
}

func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainless.BuildCompareParams{}
res, err := cc.client.Builds.Compare(
var res []byte
_, err := cc.client.Builds.Compare(
context.TODO(),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithResponseBodyInto(&res),
)
if err != nil {
return err
}

format := cmd.Root().String("format")
return ShowJSON("builds compare", res.RawJSON(), format)
return ShowJSON("builds compare", string(res), format)
}
8 changes: 5 additions & 3 deletions pkg/cmd/builddiagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

var buildsDiagnosticsList = cli.Command{
Name: "list",
Usage: "Get diagnostics for a build",
Usage: "Get the list of diagnostics for a given build.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "build-id",
Expand Down Expand Up @@ -61,16 +61,18 @@ var buildsDiagnosticsList = cli.Command{
func handleBuildsDiagnosticsList(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainless.BuildDiagnosticListParams{}
res, err := cc.client.Builds.Diagnostics.List(
var res []byte
_, err := cc.client.Builds.Diagnostics.List(
context.TODO(),
cmd.Value("build-id").(string),
params,
option.WithMiddleware(cc.AsMiddleware()),
option.WithResponseBodyInto(&res),
)
if err != nil {
return err
}

format := cmd.Root().String("format")
return ShowJSON("builds:diagnostics list", res.RawJSON(), format)
return ShowJSON("builds:diagnostics list", string(res), format)
}
8 changes: 5 additions & 3 deletions pkg/cmd/buildtargetoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var buildsTargetOutputsRetrieve = cli.Command{
Name: "retrieve",
Usage: "Download the output of a build target",
Usage: "Retrieve a method to download an output for a given build target.",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "pull",
Expand Down Expand Up @@ -85,7 +85,9 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er
}

format := cmd.Root().String("format")
fmt.Printf("%s\n", ShowJSON("builds:target_outputs retrieve", res.RawJSON(), format))
if err := ShowJSON("builds:target_outputs retrieve", res.RawJSON(), format); err != nil {
return err
}

group := Info("Downloading output")
if cmd.Bool("pull") {
Expand All @@ -95,7 +97,7 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er
return nil
}

func getLatestBuild(ctx context.Context, client stainless.Client, project, branch string) (*stainless.BuildObject, error) {
func getLatestBuild(ctx context.Context, client stainless.Client, project, branch string) (*stainless.Build, error) {
if project == "" {
return nil, fmt.Errorf("project is required when build-id is not provided")
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ var ErrUserCancelled = errors.New("user cancelled")

// BuildModel represents the bubbletea model for build monitoring
type BuildModel struct {
start func() (*stainless.BuildObject, error)
start func() (*stainless.Build, error)
started time.Time
ended *time.Time
build *stainless.BuildObject
build *stainless.Build
branch string
diagnostics []stainless.BuildDiagnosticListResponse
diagnostics []stainless.BuildDiagnostic
downloads map[stainless.Target]struct {
status string
path string
Expand All @@ -40,13 +40,13 @@ type BuildModel struct {
}

type tickMsg time.Time
type fetchBuildMsg *stainless.BuildObject
type fetchDiagnosticsMsg []stainless.BuildDiagnosticListResponse
type fetchBuildMsg *stainless.Build
type fetchDiagnosticsMsg []stainless.BuildDiagnostic
type errorMsg error
type downloadMsg stainless.Target
type triggerNewBuildMsg struct{}

func NewBuildModel(cc *apiCommandContext, ctx context.Context, branch string, fn func() (*stainless.BuildObject, error)) BuildModel {
func NewBuildModel(cc *apiCommandContext, ctx context.Context, branch string, fn func() (*stainless.Build, error)) BuildModel {
return BuildModel{
start: fn,
started: time.Now(),
Expand Down Expand Up @@ -117,7 +117,7 @@ func (m BuildModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

m.build = msg
buildObj := NewBuildObject(m.build)
buildObj := NewBuild(m.build)
if !m.isCompleted {
// Check if all commit steps are completed
allCommitsCompleted := true
Expand Down Expand Up @@ -206,7 +206,7 @@ func (m BuildModel) fetchDiagnostics() tea.Cmd {
if m.build == nil {
return errorMsg(fmt.Errorf("no current build to fetch diagnostics for"))
}
diags := []stainless.BuildDiagnosticListResponse{}
diags := []stainless.BuildDiagnostic{}
diagnostics := m.cc.client.Builds.Diagnostics.ListAutoPaging(m.ctx, m.build.ID, stainless.BuildDiagnosticListParams{
Limit: stainless.Float(100),
})
Expand All @@ -225,7 +225,7 @@ func (m *BuildModel) getBuildDuration() time.Duration {
return time.Since(m.started)
}

buildObj := NewBuildObject(m.build)
buildObj := NewBuild(m.build)
if buildObj.IsCompleted() {
if m.ended == nil {
now := time.Now()
Expand Down Expand Up @@ -370,7 +370,7 @@ func runDevBuild(ctx context.Context, cc *apiCommandContext, cmd *cli.Command, b
AllowEmpty: stainless.Bool(true),
}

model := NewBuildModel(cc, ctx, branch, func() (*stainless.BuildObject, error) {
model := NewBuildModel(cc, ctx, branch, func() (*stainless.Build, error) {
build, err := cc.client.Builds.New(ctx, buildReq, option.WithMiddleware(cc.AsMiddleware()))
if err != nil {
return nil, fmt.Errorf("failed to create build: %v", err)
Expand Down
Loading
Loading