Skip to content

Commit

Permalink
refactor: use sdk-meta for quickstart ordering (#390)
Browse files Browse the repository at this point in the history
* refactor: use sdk-meta for quickstart ordering
  • Loading branch information
cwaldren-ld authored Aug 13, 2024
1 parent b0e03ca commit 881fd5a
Show file tree
Hide file tree
Showing 19 changed files with 310 additions and 35 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/google/uuid v1.6.0
github.com/iancoleman/strcase v0.3.0
github.com/launchdarkly/api-client-go/v14 v14.0.0
github.com/launchdarkly/sdk-meta/api v0.1.1
github.com/launchdarkly/sdk-meta/api v0.2.0
github.com/mitchellh/go-homedir v1.1.0
github.com/muesli/reflow v0.3.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/launchdarkly/api-client-go/v14 v14.0.0 h1:fZfi5zKwgjpaOgK4NKcU5mJT2C8sYsR8nnuJYTaFvNU=
github.com/launchdarkly/api-client-go/v14 v14.0.0/go.mod h1:K7ejD5nn9ar94p/5qrQ0t9iJygdIQyH70U9M9rYvw5Y=
github.com/launchdarkly/sdk-meta/api v0.1.1 h1:B9UaOFTDGQSDzbSTwqiBmaTN3xDfrlIu1JQ9LCs2UiA=
github.com/launchdarkly/sdk-meta/api v0.1.1/go.mod h1:vXfR0z4XBz49IYT/2GDEza+Iat3PcuBCC438AZT6oDg=
github.com/launchdarkly/sdk-meta/api v0.2.0 h1:bBUBGodr52+3ObGOu1tf9CHR/jNh6HcZ3/yYxGPR7JI=
github.com/launchdarkly/sdk-meta/api v0.2.0/go.mod h1:vXfR0z4XBz49IYT/2GDEza+Iat3PcuBCC438AZT6oDg=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
Expand Down
33 changes: 3 additions & 30 deletions internal/quickstart/choose_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,6 @@ var sdkExamples = map[string]string{
"lua-server-server": "https://github.com/launchdarkly/lua-server-sdk/tree/main/examples/hello-lua-server",
}

// sdkOrder is a list of IDs the SDKs in order that they should be rendered based on popularity.
var sdkOrder = []string{
"react-client-sdk",
"node-server",
"python-server-sdk",
"java-server-sdk",
"dotnet-server-sdk",
"js-client-sdk",
"vue",
"swift-client-sdk",
"go-server-sdk",
"android",
"react-native",
"ruby-server-sdk",
"flutter-client-sdk",
"dotnet-client-sdk",
"erlang-server-sdk",
"rust-server-sdk",
"cpp-client-sdk",
"roku",
"node-client-sdk",
"cpp-server-sdk",
"lua-server-sdk",
"haskell-server-sdk",
"php-server-sdk",
}

// initSDKs is responsible for loading SDK quickstart instructions from the embedded filesystem.
//
// The names of the files are special: they are the ID of the SDK (e.g. react-native), and are used as an index or
Expand All @@ -130,15 +103,15 @@ func initSDKs() []sdkDetail {
if _, ok := sdkmeta.Names[id]; !ok {
continue
}
index := slices.Index(sdkOrder, id)
if index == -1 {
popularity, ok := sdkmeta.Popularity[id]
if !ok {
// if we missed an SDK don't add it with an invalid index
continue
}

details = append(details, sdkDetail{
id: id,
index: index,
index: popularity - 1, // subtract one since popularity is one-indexed
displayName: sdkmeta.Names[id],
sdkType: sdkmeta.Types[id],
url: sdkExamples[id],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 881fd5a

Please sign in to comment.