From dc094d691a10db65910b82777ee3ce3b03274b2d Mon Sep 17 00:00:00 2001 From: Shane McLaughlin Date: Mon, 20 Nov 2023 16:04:09 -0600 Subject: [PATCH] Sm/docs-fix (#864) * fix: docs for access token env * fix: allow either access token --- messages/accesstoken.store.md | 2 +- src/commands/org/login/access-token.ts | 3 ++- test/commands/org/login/access-token.nut.ts | 2 +- test/commands/org/login/access-token.test.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/messages/accesstoken.store.md b/messages/accesstoken.store.md index 9fbd7d5d..e546488b 100644 --- a/messages/accesstoken.store.md +++ b/messages/accesstoken.store.md @@ -14,7 +14,7 @@ To use the command in a CI/CD script, set the SFDX_ACCESS_TOKEN environment vari <%= config.bin %> <%= command.id %> --instance-url https://mycompany.my.salesforce.com -- Authorize the org without being prompted; you must have previously set the SFDX_ACCESS_TOKEN environment variable to the access token: +- Authorize the org without being prompted; you must have previously set the SF_ACCESS_TOKEN environment variable to the access token: <%= config.bin %> <%= command.id %> --instance-url https://dev-hub.my.salesforce.com --no-prompt diff --git a/src/commands/org/login/access-token.ts b/src/commands/org/login/access-token.ts index b616756e..37342e36 100644 --- a/src/commands/org/login/access-token.ts +++ b/src/commands/org/login/access-token.ts @@ -116,7 +116,8 @@ export default class LoginAccessToken extends AuthBaseCommand { } private async getAccessToken(): Promise { - const accessToken = env.getString('SFDX_ACCESS_TOKEN') ?? (await this.askForAccessToken()); + const accessToken = + env.getString('SF_ACCESS_TOKEN') ?? env.getString('SFDX_ACCESS_TOKEN') ?? (await this.askForAccessToken()); if (!matchesAccessToken(accessToken)) { throw new SfError(messages.getMessage('invalidAccessTokenFormat', [ACCESS_TOKEN_FORMAT])); diff --git a/test/commands/org/login/access-token.nut.ts b/test/commands/org/login/access-token.nut.ts index 4c765b29..0c4cbd69 100644 --- a/test/commands/org/login/access-token.nut.ts +++ b/test/commands/org/login/access-token.nut.ts @@ -34,7 +34,7 @@ describe('org:login:access-token NUTs', () => { } ); accessToken = res.jsonOutput?.result.accessToken as string; - env.setString('SFDX_ACCESS_TOKEN', accessToken); + env.setString('SF_ACCESS_TOKEN', accessToken); execCmd(`auth:logout -p -o ${username}`, { ensureExitCode: 0 }); }); diff --git a/test/commands/org/login/access-token.test.ts b/test/commands/org/login/access-token.test.ts index 3f3836f5..91923437 100644 --- a/test/commands/org/login/access-token.test.ts +++ b/test/commands/org/login/access-token.test.ts @@ -112,7 +112,7 @@ describe('org:login:access-token', () => { // prompt once; one for access token expect(result).to.deep.equal(authFields); }); - it('should use env var SFDX_ACCESS_TOKEN as input to the store command', async () => { + it('should use env var SF_ACCESS_TOKEN as input to the store command', async () => { const store = await createNewStoreCommand( ['--instance-url', 'https://foo.bar.org.salesforce.com'], accessToken,