Skip to content
Open
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
33 changes: 33 additions & 0 deletions plugins/expo/access_token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package expo

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/importer"
"github.com/1Password/shell-plugins/sdk/provision"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

func AccessToken() schema.CredentialType {
return schema.CredentialType{
Name: credname.AccessToken,
DocsURL: sdk.URL("https://docs.expo.dev/accounts/programmatic-access/"),
ManagementURL: sdk.URL("https://expo.dev/accounts/[account]/settings/access-tokens"),
Fields: []schema.CredentialField{
{
Name: fieldname.Token,
MarkdownDescription: "Access token used to authenticate to Expo.",
Secret: true,
},
},
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
Importer: importer.TryAll(
importer.TryEnvVarPair(defaultEnvVarMapping),
),
}
}

var defaultEnvVarMapping = map[string]sdk.FieldName{
"EXPO_TOKEN": fieldname.Token,
}
41 changes: 41 additions & 0 deletions plugins/expo/access_token_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package expo

import (
"testing"

"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/plugintest"
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

func TestAccessTokenProvisioner(t *testing.T) {
plugintest.TestProvisioner(t, AccessToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{
"default": {
ItemFields: map[sdk.FieldName]string{
fieldname.Token: "EXAMPLEEXPOTOKEN123",
},
ExpectedOutput: sdk.ProvisionOutput{
Environment: map[string]string{
"EXPO_TOKEN": "EXAMPLEEXPOTOKEN123",
},
},
},
})
}

func TestAccessTokenImporter(t *testing.T) {
plugintest.TestImporter(t, AccessToken().Importer, map[string]plugintest.ImportCase{
"environment": {
Environment: map[string]string{
"EXPO_TOKEN": "EXAMPLEEXPOTOKEN123",
},
ExpectedCandidates: []sdk.ImportCandidate{
{
Fields: map[sdk.FieldName]string{
fieldname.Token: "EXAMPLEEXPOTOKEN123",
},
},
},
},
})
}
27 changes: 27 additions & 0 deletions plugins/expo/eas.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package expo

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/needsauth"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
)

func EASCLI() schema.Executable {
return schema.Executable{
Name: "EAS CLI",
Runs: []string{"eas"},
DocsURL: sdk.URL("https://docs.expo.dev/build/setup/"),
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
needsauth.NotWhenContainsArgs("login"),
needsauth.NotWhenContainsArgs("logout"),
),
Uses: []schema.CredentialUsage{
{
Name: credname.AccessToken,
},
},
}
}
28 changes: 28 additions & 0 deletions plugins/expo/expo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package expo

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/needsauth"
"github.com/1Password/shell-plugins/sdk/schema"
"github.com/1Password/shell-plugins/sdk/schema/credname"
)

func ExpoCLI() schema.Executable {
return schema.Executable{
Name: "Expo CLI",
Runs: []string{"expo"},
DocsURL: sdk.URL("https://docs.expo.dev/more/expo-cli/"),
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
needsauth.NotWhenContainsArgs("login"),
needsauth.NotWhenContainsArgs("logout"),
needsauth.NotWhenContainsArgs("register"),
),
Uses: []schema.CredentialUsage{
{
Name: credname.AccessToken,
},
},
}
}
23 changes: 23 additions & 0 deletions plugins/expo/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package expo

import (
"github.com/1Password/shell-plugins/sdk"
"github.com/1Password/shell-plugins/sdk/schema"
)

func New() schema.Plugin {
return schema.Plugin{
Name: "expo",
Platform: schema.PlatformInfo{
Name: "Expo",
Homepage: sdk.URL("https://expo.dev"),
},
Credentials: []schema.CredentialType{
AccessToken(),
},
Executables: []schema.Executable{
ExpoCLI(),
EASCLI(),
},
}
}