Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed May 29, 2023
1 parent 5a91457 commit 9689e72
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 1 addition & 6 deletions plugins/vercel/api_token.go
Expand Up @@ -13,7 +13,7 @@ import (
func APIToken() schema.CredentialType {
return schema.CredentialType{
Name: credname.APIToken,
DocsURL: sdk.URL("https://vercel.com/docs/cli/login"),
DocsURL: sdk.URL("https://vercel.com/docs/rest-api"),
ManagementURL: sdk.URL("https://vercel.com/account/tokens"),
Fields: []schema.CredentialField{
{
Expand All @@ -32,11 +32,6 @@ func APIToken() schema.CredentialType {
},
DefaultProvisioner: vercelProvisioner{},
Importer: importer.TryAll(
importer.TryEnvVarPair(
map[string]sdk.FieldName{
"VERCEL_TOKEN": fieldname.Token,
},
),
importer.MacOnly(TryVercelConfigFile("~/Library/Application Support/com.vercel.cli/auth.json")),
importer.LinuxOnly(TryVercelConfigFile("~/.config/com.vercel.cli/auth.json")),
),
Expand Down
11 changes: 6 additions & 5 deletions plugins/vercel/api_token_test.go
Expand Up @@ -26,9 +26,10 @@ func TestAPITokenProvisioner(t *testing.T) {
func TestAPITokenImporter(t *testing.T) {
plugintest.TestImporter(
t, APIToken().Importer, map[string]plugintest.ImportCase{
"environment": {
Environment: map[string]string{
"VERCEL_TOKEN": "tZk79pLyPLGgUVlkHbnLeXgl",
"config file (macOS)": {
OS: "darwin",
Files: map[string]string{
"~/Library/Application Support/com.vercel.cli/auth.json": plugintest.LoadFixture(t, "auth.json"),
},
ExpectedCandidates: []sdk.ImportCandidate{
{
Expand All @@ -38,10 +39,10 @@ func TestAPITokenImporter(t *testing.T) {
},
},
},
"config file": {
"config file (Linux)": {
OS: "darwin",
Files: map[string]string{
"~/Library/Application Support/com.vercel.cli/auth.json": plugintest.LoadFixture(t, "auth.json"),
"~/.config/com.vercel.cli/auth.json": plugintest.LoadFixture(t, "auth.json"),
},
ExpectedCandidates: []sdk.ImportCandidate{
{
Expand Down
1 change: 1 addition & 0 deletions plugins/vercel/vercel.go
Expand Up @@ -15,6 +15,7 @@ func VercelCLI() schema.Executable {
NeedsAuth: needsauth.IfAll(
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
needsauth.NotWhenContainsArgs("login"),
),
Uses: []schema.CredentialUsage{
{
Expand Down

0 comments on commit 9689e72

Please sign in to comment.