File tree Expand file tree Collapse file tree 5 files changed +152
-0
lines changed
Expand file tree Collapse file tree 5 files changed +152
-0
lines changed Original file line number Diff line number Diff line change 1+ package expo
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/importer"
6+ "github.com/1Password/shell-plugins/sdk/provision"
7+ "github.com/1Password/shell-plugins/sdk/schema"
8+ "github.com/1Password/shell-plugins/sdk/schema/credname"
9+ "github.com/1Password/shell-plugins/sdk/schema/fieldname"
10+ )
11+
12+ func AccessToken () schema.CredentialType {
13+ return schema.CredentialType {
14+ Name : credname .AccessToken ,
15+ DocsURL : sdk .URL ("https://docs.expo.dev/accounts/programmatic-access/" ),
16+ ManagementURL : sdk .URL ("https://expo.dev/accounts/[account]/settings/access-tokens" ),
17+ Fields : []schema.CredentialField {
18+ {
19+ Name : fieldname .Token ,
20+ MarkdownDescription : "Access token used to authenticate to Expo." ,
21+ Secret : true ,
22+ },
23+ },
24+ DefaultProvisioner : provision .EnvVars (defaultEnvVarMapping ),
25+ Importer : importer .TryAll (
26+ importer .TryEnvVarPair (defaultEnvVarMapping ),
27+ ),
28+ }
29+ }
30+
31+ var defaultEnvVarMapping = map [string ]sdk.FieldName {
32+ "EXPO_TOKEN" : fieldname .Token ,
33+ }
Original file line number Diff line number Diff line change 1+ package expo
2+
3+ import (
4+ "testing"
5+
6+ "github.com/1Password/shell-plugins/sdk"
7+ "github.com/1Password/shell-plugins/sdk/plugintest"
8+ "github.com/1Password/shell-plugins/sdk/schema/fieldname"
9+ )
10+
11+ func TestAccessTokenProvisioner (t * testing.T ) {
12+ plugintest .TestProvisioner (t , AccessToken ().DefaultProvisioner , map [string ]plugintest.ProvisionCase {
13+ "default" : {
14+ ItemFields : map [sdk.FieldName ]string {
15+ fieldname .Token : "EXAMPLEEXPOTOKEN123" ,
16+ },
17+ ExpectedOutput : sdk.ProvisionOutput {
18+ Environment : map [string ]string {
19+ "EXPO_TOKEN" : "EXAMPLEEXPOTOKEN123" ,
20+ },
21+ },
22+ },
23+ })
24+ }
25+
26+ func TestAccessTokenImporter (t * testing.T ) {
27+ plugintest .TestImporter (t , AccessToken ().Importer , map [string ]plugintest.ImportCase {
28+ "environment" : {
29+ Environment : map [string ]string {
30+ "EXPO_TOKEN" : "EXAMPLEEXPOTOKEN123" ,
31+ },
32+ ExpectedCandidates : []sdk.ImportCandidate {
33+ {
34+ Fields : map [sdk.FieldName ]string {
35+ fieldname .Token : "EXAMPLEEXPOTOKEN123" ,
36+ },
37+ },
38+ },
39+ },
40+ })
41+ }
Original file line number Diff line number Diff line change 1+ package expo
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/needsauth"
6+ "github.com/1Password/shell-plugins/sdk/schema"
7+ "github.com/1Password/shell-plugins/sdk/schema/credname"
8+ )
9+
10+ func EASCLI () schema.Executable {
11+ return schema.Executable {
12+ Name : "EAS CLI" ,
13+ Runs : []string {"eas" },
14+ DocsURL : sdk .URL ("https://docs.expo.dev/build/setup/" ),
15+ NeedsAuth : needsauth .IfAll (
16+ needsauth .NotForHelpOrVersion (),
17+ needsauth .NotWithoutArgs (),
18+ needsauth .NotWhenContainsArgs ("login" ),
19+ needsauth .NotWhenContainsArgs ("logout" ),
20+ ),
21+ Uses : []schema.CredentialUsage {
22+ {
23+ Name : credname .AccessToken ,
24+ },
25+ },
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ package expo
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/needsauth"
6+ "github.com/1Password/shell-plugins/sdk/schema"
7+ "github.com/1Password/shell-plugins/sdk/schema/credname"
8+ )
9+
10+ func ExpoCLI () schema.Executable {
11+ return schema.Executable {
12+ Name : "Expo CLI" ,
13+ Runs : []string {"expo" },
14+ DocsURL : sdk .URL ("https://docs.expo.dev/more/expo-cli/" ),
15+ NeedsAuth : needsauth .IfAll (
16+ needsauth .NotForHelpOrVersion (),
17+ needsauth .NotWithoutArgs (),
18+ needsauth .NotWhenContainsArgs ("login" ),
19+ needsauth .NotWhenContainsArgs ("logout" ),
20+ needsauth .NotWhenContainsArgs ("register" ),
21+ ),
22+ Uses : []schema.CredentialUsage {
23+ {
24+ Name : credname .AccessToken ,
25+ },
26+ },
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ package expo
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/schema"
6+ )
7+
8+ func New () schema.Plugin {
9+ return schema.Plugin {
10+ Name : "expo" ,
11+ Platform : schema.PlatformInfo {
12+ Name : "Expo" ,
13+ Homepage : sdk .URL ("https://expo.dev" ),
14+ },
15+ Credentials : []schema.CredentialType {
16+ AccessToken (),
17+ },
18+ Executables : []schema.Executable {
19+ ExpoCLI (),
20+ EASCLI (),
21+ },
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments