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

Dxcdt 393 ensure status and progress indicator #949

Merged
merged 29 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4461350
Bump github.com/auth0/go-auth0 from 1.2.0 to 1.3.0 (#908)
dependabot[bot] Nov 13, 2023
2054394
dxcdt-615-goreleaser-upgrade (#909)
Nov 13, 2023
1da3631
DXCDT-582: Convert audience into a drop down in interactive mode in t…
sergiught Nov 11, 2023
7dbf8ea
Merge branch 'main' of https://github.com/auth0/auth0-cli
Nov 13, 2023
1fd7dc2
Merge branch 'main' of https://github.com/auth0/auth0-cli
Nov 16, 2023
60f801c
Merge branch 'main' of https://github.com/auth0/auth0-cli
Nov 22, 2023
b0fd941
Merge remote-tracking branch 'upstream/main'
Nov 29, 2023
be1ef00
Merge branch 'main' of https://github.com/auth0/auth0-cli
Dec 1, 2023
3068c07
Bump goreleaser version
Dec 1, 2023
5265f19
Merge remote-tracking branch 'origin/main'
Dec 8, 2023
c0deaff
Use progress bars for long multistep processes
Dec 13, 2023
09d32e9
Bump github.com/google/uuid from 1.4.0 to 1.5.0 (#942)
dependabot[bot] Dec 13, 2023
f51b8f7
Dxcdt 578 increase results amount in lists (#940)
Dec 13, 2023
a2550ed
Bump github.com/auth0/go-auth0 from 1.3.1 to 1.4.0 (#944)
dependabot[bot] Dec 15, 2023
364b643
DXCDT-396: Standardize error messages (#943)
sergiught Dec 19, 2023
a87580d
Bump golang.org/x/crypto from 0.16.0 to 0.17.0 (#947)
dependabot[bot] Dec 19, 2023
10d585c
Merge branch 'main' of github.com:auth0/auth0-cli into DXCDT-393-ensu…
Dec 20, 2023
a6e3565
Ignore err for adding steps to the ProgressBar
Dec 20, 2023
d56d66c
Merge branch 'main' of github.com:auth0/auth0-cli into DXCDT-393-ensu…
Dec 21, 2023
ba1bf27
Organize imports
Dec 21, 2023
d588b4f
Improve error messages in APIs
Dec 21, 2023
070b652
Add documentation comment for ProgressBar
Dec 21, 2023
8f759cf
Normalize delete error messages
Dec 21, 2023
463832a
Merge remote-tracking branch 'origin/DXCDT-393-ensure-status-and-prog…
Dec 21, 2023
2c258c3
Discard duplicate path escape
Dec 21, 2023
ca57dfd
Revert data file
Dec 21, 2023
973a813
Return nil on 0 case
Dec 21, 2023
8733ebf
Ensure ID isn't empty when deleting an organization
Dec 21, 2023
becfda9
Merge branch 'main' into DXCDT-393-ensure-status-and-progress-indicator
Dec 21, 2023
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
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2
github.com/pkg/errors v0.9.1
github.com/schollz/progressbar/v3 v3.14.1
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -76,12 +77,13 @@ require (
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/microcosm-cc/bluemonday v1.0.23 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/yuin/goldmark v1.5.2 // indirect
Expand Down
11 changes: 10 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down Expand Up @@ -171,6 +172,8 @@ github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssn
github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
github.com/microcosm-cc/bluemonday v1.0.23 h1:SMZe2IGa0NuHvnVNAZ+6B38gsTbi5e4sViiWJyDDqFY=
github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.13.0 h1:wK20DRpJdDX8b7Ek2QfhvqhRQFZ237RGRO0RQ/Iqdy0=
Expand All @@ -193,11 +196,14 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.14.1 h1:VD+MJPCr4s3wdhTc7OEJ/Z3dAeBzJ7yKH/P4lC5yRTI=
github.com/schollz/progressbar/v3 v3.14.1/go.mod h1:Zc9xXneTzWXF81TGoqL71u0sBPjULtEHYtj/WVgVy8E=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
Expand All @@ -210,6 +216,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down Expand Up @@ -295,6 +302,7 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -303,6 +311,7 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
29 changes: 29 additions & 0 deletions internal/ansi/progress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ansi
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved

import (
"errors"
"github.com/schollz/progressbar/v3"
)

func ProgressBar[T comparable](desc string, items []T, fn func(int, T) error) error {
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved
switch len(items) {
case 0:
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved
return Spinner(desc, func() error {
return nil
})
case 1:
return Spinner(desc, func() error {
return fn(1, items[0])
})
default:
bar := progressbar.Default(int64(len(items)), desc)
var errs []error
for i, item := range items {
_ = bar.Add(1)
if err := fn(i, item); err != nil {
errs = append(errs, err)
}
}
return errors.Join(errs...)
}
}
2 changes: 1 addition & 1 deletion internal/auth/authutil/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func WaitForBrowserCallback(addr string) (code string, state string, err error)

if cb.code == "" {
_, _ = w.Write([]byte(resultPage("Login Failed",
"Unable to extract code from request, please try authenticating again.",
"Failed to extract code from request, please try authenticating again.",
"error-denied")))
} else {
_, _ = w.Write([]byte(resultPage("Login Successful",
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/authutil/browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestWaitForBrowserCallback(t *testing.T) {
_ = resp.Body.Close()
}()

assert.Contains(t, body, "Unable to extract code from request, please try authenticating again")
assert.Contains(t, body, "Failed to extract code from request, please try authenticating again")
})

code, state, callbackErr := WaitForBrowserCallback("localhost:1234")
Expand Down
13 changes: 4 additions & 9 deletions internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,11 @@ func deleteActionCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting action(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if err := cli.api.Action.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete action with ID %q: %w", id, err))
}
}
return ansi.ProgressBar("Deleting action(s)", ids, func(i int, id string) error {
if id != "" {
return cli.api.Action.Delete(cmd.Context(), id)
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
22 changes: 8 additions & 14 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,21 +445,15 @@ func deleteAPICmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting API(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.ResourceServer.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete API with ID %q: %w", id, err))
continue
}

if err := cli.api.ResourceServer.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete API with ID %q: %w", id, err))
}
}
return ansi.ProgressBar("Deleting API(s)", ids, func(_ int, id string) error {
if _, err := cli.api.ResourceServer.Read(cmd.Context(), url.PathEscape(id)); err != nil {
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("failed to delete API (%s): %w", id, err)
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved
}

if err := cli.api.ResourceServer.Delete(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete API (%s): %w", id, err)
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
22 changes: 9 additions & 13 deletions internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,21 +347,17 @@ func deleteAppCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Application(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Client.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete application with ID %q: %w", id, err))
continue
}

if err := cli.api.Client.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete application with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Application(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Client.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete application (%s): %w", id, err)
}

if err := cli.api.Client.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete application (%s): %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
23 changes: 9 additions & 14 deletions internal/cli/custom_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cli

import (
"context"
"errors"
"fmt"
"net/url"

Expand Down Expand Up @@ -348,21 +347,17 @@ func deleteCustomDomainCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting custom domain", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.CustomDomain.Read(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err)
}

if err := cli.api.CustomDomain.Delete(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err)
}
return ansi.ProgressBar("Deleting custom domain", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.CustomDomain.Read(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain (%s): %w", id, err)
}
}

return errors.Join(errs...)
if err := cli.api.CustomDomain.Delete(cmd.Context(), url.PathEscape(id)); err != nil {
return fmt.Errorf("failed to delete custom domain (%s): %w", id, err)
}
}
return nil
})
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/data/universal-login/assets/index-89540052.js
Original file line number Diff line number Diff line change
Expand Up @@ -9363,7 +9363,7 @@ function encode_char(c) {
return _ENCODE_HTML_RULES[c] || c;
};
`;e.escapeXML=function(g){return g==null?"":String(g).replace(i,r)};function p(){return Function.prototype.toString.call(this)+`;
`+c}try{typeof Object.defineProperty=="function"?Object.defineProperty(e.escapeXML,"toString",{value:p}):e.escapeXML.toString=p}catch{console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)")}e.shallowCopy=function(g,h){if(h=h||{},g!=null)for(var b in h)a(h,b)&&(b==="__proto__"||b==="constructor"||(g[b]=h[b]));return g},e.shallowCopyFromList=function(g,h,b){if(b=b||[],h=h||{},g!=null)for(var y=0;y<b.length;y++){var _=b[y];if(typeof h[_]<"u"){if(!a(h,_)||_==="__proto__"||_==="constructor")continue;g[_]=h[_]}}return g},e.cache={_data:{},set:function(g,h){this._data[g]=h},get:function(g){return this._data[g]},remove:function(g){delete this._data[g]},reset:function(){this._data={}}},e.hyphenToCamel=function(g){return g.replace(/-[a-z]/g,function(h){return h[1].toUpperCase()})},e.createNullProtoObjWherePossible=function(){return typeof Object.create=="function"?function(){return Object.create(null)}:{__proto__:null}instanceof Object?function(){return{}}:function(){return{__proto__:null}}}()})(j4);const zct="ejs",Pct="Embedded JavaScript templates",Sct=["template","engine","ejs"],Ect="3.1.9",Oct="Matthew Eernisse <[email protected]> (http://fleegix.org)",Cct="Apache-2.0",Bct={ejs:"./bin/cli.js"},Mct="./lib/ejs.js",Lct="ejs.min.js",Ict="ejs.min.js",Rct={type:"git",url:"git://github.com/mde/ejs.git"},Fct="https://github.com/mde/ejs/issues",Dct="https://github.com/mde/ejs",Vct={jake:"^10.8.5"},Uct={browserify:"^16.5.1",eslint:"^6.8.0","git-directory-deploy":"^1.5.1",jsdoc:"^4.0.2","lru-cache":"^4.0.1",mocha:"^10.2.0","uglify-js":"^3.3.16"},Kct={node:">=0.10.0"},Gct={test:"mocha -u tdd"},qct={name:zct,description:Pct,keywords:Sct,version:Ect,author:Oct,license:Cct,bin:Bct,main:Mct,jsdelivr:Lct,unpkg:Ict,repository:Rct,bugs:Fct,homepage:Dct,dependencies:Vct,devDependencies:Uct,engines:Kct,scripts:Gct};(function(e){/**
`+c}try{typeof Object.defineProperty=="function"?Object.defineProperty(e.escapeXML,"toString",{value:p}):e.escapeXML.toString=p}catch{console.warn("Failed to set escapeXML.toString (is the Function prototype frozen?)")}e.shallowCopy=function(g,h){if(h=h||{},g!=null)for(var b in h)a(h,b)&&(b==="__proto__"||b==="constructor"||(g[b]=h[b]));return g},e.shallowCopyFromList=function(g,h,b){if(b=b||[],h=h||{},g!=null)for(var y=0;y<b.length;y++){var _=b[y];if(typeof h[_]<"u"){if(!a(h,_)||_==="__proto__"||_==="constructor")continue;g[_]=h[_]}}return g},e.cache={_data:{},set:function(g,h){this._data[g]=h},get:function(g){return this._data[g]},remove:function(g){delete this._data[g]},reset:function(){this._data={}}},e.hyphenToCamel=function(g){return g.replace(/-[a-z]/g,function(h){return h[1].toUpperCase()})},e.createNullProtoObjWherePossible=function(){return typeof Object.create=="function"?function(){return Object.create(null)}:{__proto__:null}instanceof Object?function(){return{}}:function(){return{__proto__:null}}}()})(j4);const zct="ejs",Pct="Embedded JavaScript templates",Sct=["template","engine","ejs"],Ect="3.1.9",Oct="Matthew Eernisse <[email protected]> (http://fleegix.org)",Cct="Apache-2.0",Bct={ejs:"./bin/cli.js"},Mct="./lib/ejs.js",Lct="ejs.min.js",Ict="ejs.min.js",Rct={type:"git",url:"git://github.com/mde/ejs.git"},Fct="https://github.com/mde/ejs/issues",Dct="https://github.com/mde/ejs",Vct={jake:"^10.8.5"},Uct={browserify:"^16.5.1",eslint:"^6.8.0","git-directory-deploy":"^1.5.1",jsdoc:"^4.0.2","lru-cache":"^4.0.1",mocha:"^10.2.0","uglify-js":"^3.3.16"},Kct={node:">=0.10.0"},Gct={test:"mocha -u tdd"},qct={name:zct,description:Pct,keywords:Sct,version:Ect,author:Oct,license:Cct,bin:Bct,main:Mct,jsdelivr:Lct,unpkg:Ict,repository:Rct,bugs:Fct,homepage:Dct,dependencies:Vct,devDependencies:Uct,engines:Kct,scripts:Gct};(function(e){/**
m3talsmith marked this conversation as resolved.
Show resolved Hide resolved
* @file Embedded JavaScript templating engine. {@link http://ejs.co}
* @author Matthew Eernisse <[email protected]>
* @author Tiancheng "Timothy" Gu <[email protected]>
Expand Down
21 changes: 8 additions & 13 deletions internal/cli/log_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,16 @@ func deleteLogStreamCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Log Stream(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.LogStream.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete log stream with ID %q: %w", id, err))
continue
}
if err := cli.api.LogStream.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete log stream with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Log Stream(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.LogStream.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete log stream (%s): %w", id, err)
}
if err := cli.api.LogStream.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete log stream (%s): %w", id, err)
}
}

return errors.Join(errs...)
return nil
})
},
}
Expand Down
23 changes: 8 additions & 15 deletions internal/cli/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,21 +437,15 @@ func deleteOrganizationCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting organization(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Organization.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete organization with ID %q: %w", id, err))
continue
}

if err := cli.api.Organization.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete organization with ID %q: %w", id, err))
}
}
return ansi.ProgressBar("Deleting organization(s)", ids, func(_ int, id string) error {
if _, err := cli.api.Organization.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete organization (%s): %w", id, err)
}

if err := cli.api.Organization.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete organization (%s): %w", id, err)
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down Expand Up @@ -597,7 +591,6 @@ func listRolesOrganizationCmd(cli *cli) *cobra.Command {
} else {
inputs.OrgID = args[0]
}

members, err := cli.getOrgMembersWithSpinner(cmd.Context(), inputs.OrgID, inputs.Number)
if err != nil {
return err
Expand Down
22 changes: 9 additions & 13 deletions internal/cli/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,21 +306,17 @@ func deleteRoleCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Role(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Role.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete role with ID %q: %w", id, err))
continue
}

if err := cli.api.Role.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete role with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Role(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Role.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete role (%s): %w", id, err)
}

if err := cli.api.Role.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete role (%s): %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
22 changes: 9 additions & 13 deletions internal/cli/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,17 @@ func deleteRuleCmd(cli *cli) *cobra.Command {
}
}

return ansi.Spinner("Deleting Rule(s)", func() error {
var errs []error
for _, id := range ids {
if id != "" {
if _, err := cli.api.Rule.Read(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete rule with ID %q: %w", id, err))
continue
}

if err := cli.api.Rule.Delete(cmd.Context(), id); err != nil {
errs = append(errs, fmt.Errorf("failed to delete rule with ID %q: %w", id, err))
}
return ansi.ProgressBar("Deleting Rule(s)", ids, func(_ int, id string) error {
if id != "" {
if _, err := cli.api.Rule.Read(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete rule (%s): %w", id, err)
}

if err := cli.api.Rule.Delete(cmd.Context(), id); err != nil {
return fmt.Errorf("failed to delete rule (%s): %w", id, err)
}
}
return errors.Join(errs...)
return nil
})
},
}
Expand Down
Loading
Loading