Select the types of activity you want to include in your feed.
deps cleanup (#1173)
- switches a bunch of stuff from urfave/cli/v2 to v3 (but not everything) - switches everything to maintained version of versioninfo - tidies a bunch of imports
···11package main
2233import (
44- _ "embed"
44+ "context"
55 "encoding/json"
66 "fmt"
77 "html/template"
···1010 "os"
1111 "slices"
12121313+ _ "embed"
1314 _ "github.com/joho/godotenv/autoload"
14151516 "github.com/bluesky-social/indigo/atproto/atcrypto"
···1819 "github.com/bluesky-social/indigo/atproto/syntax"
19202021 "github.com/gorilla/sessions"
2121- "github.com/urfave/cli/v2"
2222+ "github.com/urfave/cli/v3"
2223)
23242425func main() {
2525- app := cli.App{
2626+ app := cli.Command{
2627 Name: "oauth-web-demo",
2728 Usage: "atproto OAuth web server demo",
2829 Action: runServer,
···3132 Name: "session-secret",
3233 Usage: "random string/token used for session cookie security",
3334 Required: true,
3434- EnvVars: []string{"SESSION_SECRET"},
3535+ Sources: cli.EnvVars("SESSION_SECRET"),
3536 },
3637 &cli.StringFlag{
3738 Name: "hostname",
3839 Usage: "public host name for this client (if not localhost dev mode)",
3939- EnvVars: []string{"CLIENT_HOSTNAME"},
4040+ Sources: cli.EnvVars("CLIENT_HOSTNAME"),
4041 },
4142 &cli.StringFlag{
4243 Name: "client-secret-key",
4344 Usage: "confidential client secret key. should be P-256 private key in multibase encoding",
4444- EnvVars: []string{"CLIENT_SECRET_KEY"},
4545+ Sources: cli.EnvVars("CLIENT_SECRET_KEY"),
4546 },
4647 &cli.StringFlag{
4748 Name: "client-secret-key-id",
4849 Usage: "key id for client-secret-key",
4950 Value: "primary",
5050- EnvVars: []string{"CLIENT_SECRET_KEY_ID"},
5151+ Sources: cli.EnvVars("CLIENT_SECRET_KEY_ID"),
5152 },
5253 },
5354 }
5455 h := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})
5556 slog.SetDefault(slog.New(h))
5656- app.RunAndExitOnError()
5757+ if err := app.Run(context.Background(), os.Args); err != nil {
5858+ slog.Error("command failed", "error", err)
5959+ os.Exit(-1)
6060+ }
5761}
58625963type Server struct {
···7781var tmplPostText string
7882var tmplPost = template.Must(template.Must(template.New("post.html").Parse(tmplBaseText)).Parse(tmplPostText))
79838080-func runServer(cctx *cli.Context) error {
8484+func runServer(ctx context.Context, cmd *cli.Command) error {
81858286 // the 'account:email' scope is requested only as a demo of users not granting a permission during auth flow
8387 scopes := []string{"atproto", "repo:app.bsky.feed.post?action=create", "account:email"}
8488 bind := ":8080"
85898690 var config oauth.ClientConfig
8787- hostname := cctx.String("hostname")
9191+ hostname := cmd.String("hostname")
8892 if hostname == "" {
8993 config = oauth.NewLocalhostConfig(
9094 fmt.Sprintf("http://127.0.0.1%s/oauth/callback", bind),
···100104 }
101105102106 // If a client secret key is provided (as a multibase string), turn this in to a confidential client
103103- if cctx.String("client-secret-key") != "" && hostname != "" {
104104- priv, err := atcrypto.ParsePrivateMultibase(cctx.String("client-secret-key"))
107107+ if cmd.String("client-secret-key") != "" && hostname != "" {
108108+ priv, err := atcrypto.ParsePrivateMultibase(cmd.String("client-secret-key"))
105109 if err != nil {
106110 return err
107111 }
108108- if err := config.SetClientSecret(priv, cctx.String("client-secret-key-id")); err != nil {
112112+ if err := config.SetClientSecret(priv, cmd.String("client-secret-key-id")); err != nil {
109113 return err
110114 }
111115 slog.Info("configuring confidential OAuth client")
···114118 oauthClient := oauth.NewClientApp(&config, oauth.NewMemStore())
115119116120 srv := Server{
117117- CookieStore: sessions.NewCookieStore([]byte(cctx.String("session-secret"))),
121121+ CookieStore: sessions.NewCookieStore([]byte(cmd.String("session-secret"))),
118122 Dir: identity.DefaultDirectory(),
119123 OAuth: oauthClient,
120124 }
+1-1
atproto/identity/apidir/apidir.go
···1212 "github.com/bluesky-social/indigo/atproto/identity"
1313 "github.com/bluesky-social/indigo/atproto/syntax"
14141515- "github.com/carlmjohnson/versioninfo"
1515+ "github.com/earthboundkid/versioninfo/v2"
1616)
17171818// Does HTTP requests to an identity server, using standard Lexicon endpoints
+12-12
atproto/identity/cmd/atp-id/main.go
···1010 "github.com/bluesky-social/indigo/atproto/identity"
1111 "github.com/bluesky-social/indigo/atproto/syntax"
12121313- "github.com/urfave/cli/v2"
1313+ "github.com/urfave/cli/v3"
1414)
15151616func main() {
1717- app := cli.App{
1717+ app := cli.Command{
1818 Name: "atp-id",
1919 Usage: "informal debugging CLI tool for atproto identities",
2020 }
···4040 }
4141 h := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})
4242 slog.SetDefault(slog.New(h))
4343- app.RunAndExitOnError()
4343+ if err := app.Run(context.Background(), os.Args); err != nil {
4444+ slog.Error("command failed", "error", err)
4545+ os.Exit(-1)
4646+ }
4447}
45484646-func runLookup(cctx *cli.Context) error {
4747- ctx := context.Background()
4848- s := cctx.Args().First()
4949+func runLookup(ctx context.Context, cmd *cli.Command) error {
5050+ s := cmd.Args().First()
4951 if s == "" {
5052 return fmt.Errorf("need to provide identifier as an argument")
5153 }
···6567 return nil
6668}
67696868-func runResolveHandle(cctx *cli.Context) error {
6969- ctx := context.Background()
7070- s := cctx.Args().First()
7070+func runResolveHandle(ctx context.Context, cmd *cli.Command) error {
7171+ s := cmd.Args().First()
7172 if s == "" {
7273 return fmt.Errorf("need to provide handle as an argument")
7374 }
···8788 return nil
8889}
89909090-func runResolveDID(cctx *cli.Context) error {
9191- ctx := context.Background()
9292- s := cctx.Args().First()
9191+func runResolveDID(ctx context.Context, cmd *cli.Command) error {
9292+ s := cmd.Args().First()
9393 if s == "" {
9494 fmt.Println("need to provide DID as an argument")
9595 os.Exit(-1)
+1-1
atproto/identity/directory.go
···991010 "github.com/bluesky-social/indigo/atproto/syntax"
11111212- "github.com/carlmjohnson/versioninfo"
1212+ "github.com/earthboundkid/versioninfo/v2"
1313)
14141515// Ergonomic interface for atproto identity lookup, by DID or handle.
+13-9
atproto/lexicon/cmd/lextool/main.go
···11package main
2233import (
44+ "context"
45 "encoding/json"
56 "fmt"
67 "io"
···9101011 "github.com/bluesky-social/indigo/atproto/lexicon"
11121212- "github.com/urfave/cli/v2"
1313+ "github.com/urfave/cli/v3"
1314)
14151516func main() {
1616- app := cli.App{
1717+ app := cli.Command{
1718 Name: "lex-tool",
1819 Usage: "informal debugging CLI tool for atproto lexicons",
1920 }
···4142 }
4243 h := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})
4344 slog.SetDefault(slog.New(h))
4444- app.RunAndExitOnError()
4545+ if err := app.Run(context.Background(), os.Args); err != nil {
4646+ slog.Error("command failed", "error", err)
4747+ os.Exit(-1)
4848+ }
4549}
46504747-func runParseSchema(cctx *cli.Context) error {
4848- p := cctx.Args().First()
5151+func runParseSchema(ctx context.Context, cmd *cli.Command) error {
5252+ p := cmd.Args().First()
4953 if p == "" {
5054 return fmt.Errorf("need to provide path to a schema file as an argument")
5155 }
···7377 return nil
7478}
75797676-func runLoadDirectory(cctx *cli.Context) error {
7777- p := cctx.Args().First()
8080+func runLoadDirectory(ctx context.Context, cmd *cli.Command) error {
8181+ p := cmd.Args().First()
7882 if p == "" {
7983 return fmt.Errorf("need to provide directory path as an argument")
8084 }
···8993 return nil
9094}
91959292-func runResolve(cctx *cli.Context) error {
9393- ref := cctx.Args().First()
9696+func runResolve(ctx context.Context, cmd *cli.Command) error {
9797+ ref := cmd.Args().First()
9498 if ref == "" {
9599 return fmt.Errorf("need to provide NSID as an argument")
96100 }
···1010 "github.com/bluesky-social/indigo/atproto/atdata"
1111 lexutil "github.com/bluesky-social/indigo/lex/util"
12121313- "github.com/carlmjohnson/versioninfo"
1313+ "github.com/earthboundkid/versioninfo/v2"
1414)
15151616// Parses out any blobs from the enclosed record.
···88 comatproto "github.com/bluesky-social/indigo/api/atproto"
99 "github.com/bluesky-social/indigo/events"
1010 "github.com/bluesky-social/indigo/events/schedulers/sequential"
1111+1112 "github.com/gorilla/websocket"
1212- cli "github.com/urfave/cli/v2"
1313+ "github.com/urfave/cli/v2"
1314)
14151516// TODO: WIP - turns out to be more complicated than i initially thought