From b3bfc92374402a38bd539792b3d6321c0d9e4aaa Mon Sep 17 00:00:00 2001 From: Szymon Dziedzic Date: Wed, 20 Nov 2024 17:15:56 +0100 Subject: [PATCH 1/2] [ENG-14223][eas-cli] improve class names and descriptions of env commands --- ...riableCreate.test.ts => EnvCreate.test.ts} | 18 +++++++------- ...riableDelete.test.ts => EnvDelete.test.ts} | 17 ++++++------- ...mentVariableGet.test.ts => EnvGet.test.ts} | 10 ++++---- ...ntVariableLink.test.ts => EnvLink.test.ts} | 24 +++++++------------ ...ntVariableList.test.ts => EnvList.test.ts} | 17 ++++++------- ...riableUnlink.test.ts => EnvUnlink.test.ts} | 22 +++++++---------- ...riableUpdate.test.ts => EnvUpdate.test.ts} | 15 +++++------- packages/eas-cli/src/commands/env/create.ts | 9 ++++--- packages/eas-cli/src/commands/env/delete.ts | 8 +++---- packages/eas-cli/src/commands/env/exec.ts | 2 +- packages/eas-cli/src/commands/env/get.ts | 9 +++---- packages/eas-cli/src/commands/env/link.ts | 6 ++--- packages/eas-cli/src/commands/env/list.ts | 8 +++---- packages/eas-cli/src/commands/env/pull.ts | 9 +++---- packages/eas-cli/src/commands/env/push.ts | 9 +++---- packages/eas-cli/src/commands/env/unlink.ts | 6 ++--- packages/eas-cli/src/commands/env/update.ts | 9 ++++--- 17 files changed, 89 insertions(+), 109 deletions(-) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableCreate.test.ts => EnvCreate.test.ts} (95%) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableDelete.test.ts => EnvDelete.test.ts} (89%) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableGet.test.ts => EnvGet.test.ts} (92%) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableLink.test.ts => EnvLink.test.ts} (93%) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableList.test.ts => EnvList.test.ts} (91%) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableUnlink.test.ts => EnvUnlink.test.ts} (93%) rename packages/eas-cli/src/commands/env/__tests__/{EnvironmentVariableUpdate.test.ts => EnvUpdate.test.ts} (93%) diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableCreate.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvCreate.test.ts similarity index 95% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableCreate.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvCreate.test.ts index 9219d24a75..187c179164 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableCreate.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvCreate.test.ts @@ -19,14 +19,14 @@ import { promptVariableTypeAsync, promptVariableValueAsync, } from '../../../utils/prompts'; -import EnvironmentVariableCreate from '../create'; +import EnvCreate from '../create'; jest.mock('../../../graphql/mutations/EnvironmentVariableMutation'); jest.mock('../../../graphql/queries/AppQuery'); jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../utils/prompts'); -describe(EnvironmentVariableCreate, () => { +describe(EnvCreate, () => { const graphqlClient = {} as any as ExpoGraphqlClient; const mockConfig = {} as unknown as Config; const variableId = 'testId'; @@ -74,7 +74,7 @@ describe(EnvironmentVariableCreate, () => { describe('in interactive mode', () => { it('creates a project variable', async () => { - const command = new EnvironmentVariableCreate( + const command = new EnvCreate( [ '--name', 'VarName', @@ -110,7 +110,7 @@ describe(EnvironmentVariableCreate, () => { }); it('updates an existing variable in the same environment', async () => { - const command = new EnvironmentVariableCreate( + const command = new EnvCreate( [ '--name', 'VarName', @@ -172,7 +172,7 @@ describe(EnvironmentVariableCreate, () => { }); it('creates an account-wide variable', async () => { - const command = new EnvironmentVariableCreate( + const command = new EnvCreate( [ '--name', 'VarName', @@ -208,7 +208,7 @@ describe(EnvironmentVariableCreate, () => { }); it('throws if an account-wide variable already exists', async () => { - const command = new EnvironmentVariableCreate( + const command = new EnvCreate( [ '--name', 'VarName', @@ -243,7 +243,7 @@ describe(EnvironmentVariableCreate, () => { }); it('updates if an account-wide variable already exists and --force flag is set', async () => { - const command = new EnvironmentVariableCreate( + const command = new EnvCreate( [ '--name', 'VarName', @@ -289,7 +289,7 @@ describe(EnvironmentVariableCreate, () => { }); it('creates an account-wide variable and links it', async () => { - const command = new EnvironmentVariableCreate( + const command = new EnvCreate( [ '--name', 'VarName', @@ -343,7 +343,7 @@ describe(EnvironmentVariableCreate, () => { }); it('prompts for missing arguments', async () => { - const command = new EnvironmentVariableCreate([], mockConfig); + const command = new EnvCreate([], mockConfig); jest.mocked(promptVariableNameAsync).mockImplementation(async () => 'VarName'); jest.mocked(promptVariableValueAsync).mockImplementation(async () => 'VarValue'); diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableDelete.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvDelete.test.ts similarity index 89% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableDelete.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvDelete.test.ts index cbf5efde38..adc9c41a7f 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableDelete.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvDelete.test.ts @@ -8,14 +8,14 @@ import { EnvironmentVariableMutation } from '../../../graphql/mutations/Environm import { EnvironmentVariablesQuery } from '../../../graphql/queries/EnvironmentVariablesQuery'; import Log from '../../../log'; import { promptAsync, toggleConfirmAsync } from '../../../prompts'; -import EnvironmentVariableDelete from '../delete'; +import EnvDelete from '../delete'; jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../graphql/mutations/EnvironmentVariableMutation'); jest.mock('../../../prompts'); jest.mock('../../../log'); -describe(EnvironmentVariableDelete, () => { +describe(EnvDelete, () => { const projectId = 'test-project-id'; const variableId = '1'; const graphqlClient = {}; @@ -40,7 +40,7 @@ describe(EnvironmentVariableDelete, () => { ]; (EnvironmentVariablesQuery.byAppIdAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableDelete( + const command = new EnvDelete( [ '--variable-name', 'TEST_VARIABLE', @@ -66,7 +66,7 @@ describe(EnvironmentVariableDelete, () => { (promptAsync as jest.Mock).mockResolvedValue({ variable: mockVariables[0] }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableDelete([], mockConfig); + const command = new EnvDelete([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); await command.runAsync(); @@ -82,10 +82,7 @@ describe(EnvironmentVariableDelete, () => { ]; (EnvironmentVariablesQuery.byAppIdAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableDelete( - ['--variable-name', 'NON_EXISTENT_VARIABLE'], - mockConfig - ); + const command = new EnvDelete(['--variable-name', 'NON_EXISTENT_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); @@ -99,7 +96,7 @@ describe(EnvironmentVariableDelete, () => { ]; (EnvironmentVariablesQuery.byAppIdAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableDelete(['--variable-name', 'TEST_VARIABLE'], mockConfig); + const command = new EnvDelete(['--variable-name', 'TEST_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); @@ -116,7 +113,7 @@ describe(EnvironmentVariableDelete, () => { (promptAsync as jest.Mock).mockResolvedValue({ variable: mockVariables[0] }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(false); - const command = new EnvironmentVariableDelete(['--non-interactive'], mockConfig); + const command = new EnvDelete(['--non-interactive'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableGet.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvGet.test.ts similarity index 92% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableGet.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvGet.test.ts index 7aab0f66d8..0660afd43a 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableGet.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvGet.test.ts @@ -12,14 +12,14 @@ import { import { EnvironmentVariablesQuery } from '../../../graphql/queries/EnvironmentVariablesQuery'; import Log from '../../../log'; import { promptVariableEnvironmentAsync, promptVariableNameAsync } from '../../../utils/prompts'; -import EnvironmentVariableGet from '../get'; +import EnvGet from '../get'; jest.mock('../../../graphql/mutations/EnvironmentVariableMutation'); jest.mock('../../../graphql/queries/AppQuery'); jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../utils/prompts'); -describe(EnvironmentVariableGet, () => { +describe(EnvGet, () => { const graphqlClient = {} as any as ExpoGraphqlClient; const mockConfig = {} as unknown as Config; const mockVariables: EnvironmentVariableFragment[] = [ @@ -42,7 +42,7 @@ describe(EnvironmentVariableGet, () => { .mockResolvedValueOnce(mockVariables); jest.spyOn(Log, 'log').mockImplementation(() => {}); - const command = new EnvironmentVariableGet(['--variable-name', 'TEST_VAR_1'], mockConfig); + const command = new EnvGet(['--variable-name', 'TEST_VAR_1'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ @@ -68,7 +68,7 @@ describe(EnvironmentVariableGet, () => { const errorMessage = "Variable name is required. Run the command with '--variable-name VARIABLE_NAME' flag"; - const command = new EnvironmentVariableGet([], mockConfig); + const command = new EnvGet([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ @@ -85,7 +85,7 @@ describe(EnvironmentVariableGet, () => { .mockResolvedValueOnce(EnvironmentVariableEnvironment.Production); jest.mocked(promptVariableNameAsync).mockResolvedValueOnce('TEST_VAR_1'); - const command = new EnvironmentVariableGet([], mockConfig); + const command = new EnvGet([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableLink.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvLink.test.ts similarity index 93% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableLink.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvLink.test.ts index 8799b50983..8db2c3dea1 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableLink.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvLink.test.ts @@ -11,7 +11,7 @@ import { AppQuery } from '../../../graphql/queries/AppQuery'; import { EnvironmentVariablesQuery } from '../../../graphql/queries/EnvironmentVariablesQuery'; import Log from '../../../log'; import { promptAsync, selectAsync, toggleConfirmAsync } from '../../../prompts'; -import EnvironmentVariableLink from '../link'; +import EnvLink from '../link'; jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../graphql/mutations/EnvironmentVariableMutation'); @@ -19,7 +19,7 @@ jest.mock('../../../prompts'); jest.mock('../../../graphql/queries/AppQuery'); jest.mock('../../../log'); -describe(EnvironmentVariableLink, () => { +describe(EnvLink, () => { const projectId = 'test-project-id'; const variableId = '1'; const graphqlClient = {}; @@ -53,7 +53,7 @@ describe(EnvironmentVariableLink, () => { mockVariables[0] ); - const command = new EnvironmentVariableLink( + const command = new EnvLink( ['--variable-name', 'TEST_VARIABLE', '--non-interactive'], mockConfig ); @@ -89,7 +89,7 @@ describe(EnvironmentVariableLink, () => { mockVariables[0] ); - const command = new EnvironmentVariableLink( + const command = new EnvLink( ['--variable-name', 'TEST_VARIABLE', '--environment', 'production', '--non-interactive'], mockConfig ); @@ -137,7 +137,7 @@ describe(EnvironmentVariableLink, () => { ); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableLink( + const command = new EnvLink( [ '--variable-name', 'TEST_VARIABLE', @@ -186,7 +186,7 @@ describe(EnvironmentVariableLink, () => { (promptAsync as jest.Mock).mockResolvedValue({ environments: mockVariables[0].environments }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableLink([], mockConfig); + const command = new EnvLink([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); await command.runAsync(); @@ -207,10 +207,7 @@ describe(EnvironmentVariableLink, () => { const mockVariables: never[] = []; (EnvironmentVariablesQuery.sharedAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableLink( - ['--variable-name', 'NON_EXISTENT_VARIABLE'], - mockConfig - ); + const command = new EnvLink(['--variable-name', 'NON_EXISTENT_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); @@ -239,7 +236,7 @@ describe(EnvironmentVariableLink, () => { }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableLink([], mockConfig); + const command = new EnvLink([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); await command.runAsync(); @@ -263,10 +260,7 @@ describe(EnvironmentVariableLink, () => { const mockVariables: never[] = []; (EnvironmentVariablesQuery.sharedAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableLink( - ['--variable-name', 'NON_EXISTENT_VARIABLE'], - mockConfig - ); + const command = new EnvLink(['--variable-name', 'NON_EXISTENT_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableList.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvList.test.ts similarity index 91% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableList.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvList.test.ts index 222e539d29..461a7f51b2 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableList.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvList.test.ts @@ -13,7 +13,7 @@ import { import { AppQuery } from '../../../graphql/queries/AppQuery'; import { EnvironmentVariablesQuery } from '../../../graphql/queries/EnvironmentVariablesQuery'; import Log from '../../../log'; -import EnvironmentVariableList from '../list'; +import EnvList from '../list'; jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../graphql/queries/AppQuery'); @@ -44,7 +44,7 @@ const mockVariables: EnvironmentVariableFragment[] = [ }, ]; -describe(EnvironmentVariableList, () => { +describe(EnvList, () => { const graphqlClient = {} as any as ExpoGraphqlClient; const mockConfig = {} as unknown as Config; @@ -56,7 +56,7 @@ describe(EnvironmentVariableList, () => { it('lists project environment variables successfully', async () => { jest.mocked(EnvironmentVariablesQuery.byAppIdAsync).mockResolvedValueOnce(mockVariables); - const command = new EnvironmentVariableList([], mockConfig); + const command = new EnvList([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ @@ -77,7 +77,7 @@ describe(EnvironmentVariableList, () => { it('lists project environment variables in specified environments', async () => { jest.mocked(EnvironmentVariablesQuery.byAppIdAsync).mockResolvedValueOnce(mockVariables); - const command = new EnvironmentVariableList(['--environment', 'production'], mockConfig); + const command = new EnvList(['--environment', 'production'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ @@ -100,7 +100,7 @@ describe(EnvironmentVariableList, () => { .mocked(EnvironmentVariablesQuery.byAppIdWithSensitiveAsync) .mockResolvedValueOnce(mockVariables); - const command = new EnvironmentVariableList(['--include-sensitive'], mockConfig); + const command = new EnvList(['--include-sensitive'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ @@ -124,7 +124,7 @@ describe(EnvironmentVariableList, () => { it('lists account-wide environment variables successfully', async () => { jest.mocked(EnvironmentVariablesQuery.sharedAsync).mockResolvedValueOnce(mockVariables); - const command = new EnvironmentVariableList(['--scope', 'account'], mockConfig); + const command = new EnvList(['--scope', 'account'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ @@ -147,10 +147,7 @@ describe(EnvironmentVariableList, () => { .mocked(EnvironmentVariablesQuery.sharedWithSensitiveAsync) .mockResolvedValueOnce(mockVariables); - const command = new EnvironmentVariableList( - ['--include-sensitive', '--scope', 'account'], - mockConfig - ); + const command = new EnvList(['--include-sensitive', '--scope', 'account'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue({ diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableUnlink.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvUnlink.test.ts similarity index 93% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableUnlink.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvUnlink.test.ts index 1f803fab72..c99772812f 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableUnlink.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvUnlink.test.ts @@ -11,7 +11,7 @@ import { AppQuery } from '../../../graphql/queries/AppQuery'; import { EnvironmentVariablesQuery } from '../../../graphql/queries/EnvironmentVariablesQuery'; import Log from '../../../log'; import { promptAsync, selectAsync, toggleConfirmAsync } from '../../../prompts'; -import EnvironmentVariableUnlink from '../unlink'; +import EnvUnlink from '../unlink'; jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../graphql/mutations/EnvironmentVariableMutation'); @@ -19,7 +19,7 @@ jest.mock('../../../prompts'); jest.mock('../../../graphql/queries/AppQuery'); jest.mock('../../../log'); -describe(EnvironmentVariableUnlink, () => { +describe(EnvUnlink, () => { const projectId = 'test-project-id'; const variableId = '1'; const graphqlClient = {}; @@ -54,7 +54,7 @@ describe(EnvironmentVariableUnlink, () => { EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync as jest.Mock ).mockResolvedValue(mockVariables[0]); - const command = new EnvironmentVariableUnlink( + const command = new EnvUnlink( ['--variable-name', 'TEST_VARIABLE', '--non-interactive'], mockConfig ); @@ -91,7 +91,7 @@ describe(EnvironmentVariableUnlink, () => { EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync as jest.Mock ).mockResolvedValue(mockVariables[0]); - const command = new EnvironmentVariableUnlink( + const command = new EnvUnlink( ['--variable-name', 'TEST_VARIABLE', '--environment', 'production', '--non-interactive'], mockConfig ); @@ -141,7 +141,7 @@ describe(EnvironmentVariableUnlink, () => { }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableUnlink([], mockConfig); + const command = new EnvUnlink([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); await command.runAsync(); @@ -162,10 +162,7 @@ describe(EnvironmentVariableUnlink, () => { const mockVariables: never[] = []; (EnvironmentVariablesQuery.sharedAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableUnlink( - ['--variable-name', 'NON_EXISTENT_VARIABLE'], - mockConfig - ); + const command = new EnvUnlink(['--variable-name', 'NON_EXISTENT_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); @@ -194,7 +191,7 @@ describe(EnvironmentVariableUnlink, () => { }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableUnlink([], mockConfig); + const command = new EnvUnlink([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); await command.runAsync(); @@ -218,10 +215,7 @@ describe(EnvironmentVariableUnlink, () => { const mockVariables: never[] = []; (EnvironmentVariablesQuery.sharedAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableUnlink( - ['--variable-name', 'NON_EXISTENT_VARIABLE'], - mockConfig - ); + const command = new EnvUnlink(['--variable-name', 'NON_EXISTENT_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); diff --git a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableUpdate.test.ts b/packages/eas-cli/src/commands/env/__tests__/EnvUpdate.test.ts similarity index 93% rename from packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableUpdate.test.ts rename to packages/eas-cli/src/commands/env/__tests__/EnvUpdate.test.ts index 6ea65d93b4..927ae42a85 100644 --- a/packages/eas-cli/src/commands/env/__tests__/EnvironmentVariableUpdate.test.ts +++ b/packages/eas-cli/src/commands/env/__tests__/EnvUpdate.test.ts @@ -12,7 +12,7 @@ import { AppQuery } from '../../../graphql/queries/AppQuery'; import { EnvironmentVariablesQuery } from '../../../graphql/queries/EnvironmentVariablesQuery'; import Log from '../../../log'; import { promptAsync, toggleConfirmAsync } from '../../../prompts'; -import EnvironmentVariableUpdate from '../update'; +import EnvUpdate from '../update'; jest.mock('../../../graphql/queries/EnvironmentVariablesQuery'); jest.mock('../../../graphql/mutations/EnvironmentVariableMutation'); @@ -20,7 +20,7 @@ jest.mock('../../../prompts'); jest.mock('../../../graphql/queries/AppQuery'); jest.mock('../../../log'); -describe(EnvironmentVariableUpdate, () => { +describe(EnvUpdate, () => { const projectId = 'test-project-id'; const variableId = '1'; const graphqlClient = {}; @@ -47,7 +47,7 @@ describe(EnvironmentVariableUpdate, () => { (EnvironmentVariablesQuery.byAppIdAsync as jest.Mock).mockResolvedValue(mockVariables); (EnvironmentVariableMutation.updateAsync as jest.Mock).mockResolvedValue(mockVariables[0]); - const command = new EnvironmentVariableUpdate( + const command = new EnvUpdate( [ '--variable-name', 'TEST_VARIABLE', @@ -93,7 +93,7 @@ describe(EnvironmentVariableUpdate, () => { (EnvironmentVariablesQuery.sharedAsync as jest.Mock).mockResolvedValue(mockVariables); (EnvironmentVariableMutation.updateAsync as jest.Mock).mockResolvedValue(mockVariables[0]); - const command = new EnvironmentVariableUpdate( + const command = new EnvUpdate( [ '--variable-name', 'TEST_VARIABLE', @@ -135,7 +135,7 @@ describe(EnvironmentVariableUpdate, () => { (promptAsync as jest.Mock).mockResolvedValue({ name: mockVariables[0].name }); (toggleConfirmAsync as jest.Mock).mockResolvedValue(true); - const command = new EnvironmentVariableUpdate([], mockConfig); + const command = new EnvUpdate([], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); await command.runAsync(); @@ -154,10 +154,7 @@ describe(EnvironmentVariableUpdate, () => { const mockVariables: never[] = []; (EnvironmentVariablesQuery.byAppIdAsync as jest.Mock).mockResolvedValue(mockVariables); - const command = new EnvironmentVariableUpdate( - ['--variable-name', 'NON_EXISTENT_VARIABLE'], - mockConfig - ); + const command = new EnvUpdate(['--variable-name', 'NON_EXISTENT_VARIABLE'], mockConfig); // @ts-expect-error jest.spyOn(command, 'getContextAsync').mockReturnValue(mockContext); diff --git a/packages/eas-cli/src/commands/env/create.ts b/packages/eas-cli/src/commands/env/create.ts index ed75db396f..d5518e6c61 100644 --- a/packages/eas-cli/src/commands/env/create.ts +++ b/packages/eas-cli/src/commands/env/create.ts @@ -59,9 +59,8 @@ interface CreateFlags { 'non-interactive': boolean; } -export default class EnvironmentVariableCreate extends EasCommand { - static override description = - 'create an environment variable on the current project or owner account'; +export default class EnvCreate extends EasCommand { + static override description = 'create an environment variable for the current project or account'; static override hidden = true; @@ -106,7 +105,7 @@ export default class EnvironmentVariableCreate extends EasCommand { }; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariableCreate); + const { args, flags } = await this.parse(EnvCreate); const validatedFlags = this.sanitizeFlags(flags); @@ -126,7 +125,7 @@ export default class EnvironmentVariableCreate extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariableCreate, { + } = await this.getContextAsync(EnvCreate, { nonInteractive, }); diff --git a/packages/eas-cli/src/commands/env/delete.ts b/packages/eas-cli/src/commands/env/delete.ts index f95c4786fd..31e47588d6 100644 --- a/packages/eas-cli/src/commands/env/delete.ts +++ b/packages/eas-cli/src/commands/env/delete.ts @@ -30,8 +30,8 @@ interface RawDeleteFlags { scope: EASEnvironmentVariableScopeFlagValue; } -export default class EnvironmentVariableDelete extends EasCommand { - static override description = 'delete an environment variable by name'; +export default class EnvDelete extends EasCommand { + static override description = 'delete an environment variable for the current project or account'; static override hidden = true; @@ -62,7 +62,7 @@ export default class EnvironmentVariableDelete extends EasCommand { }; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariableDelete); + const { args, flags } = await this.parse(EnvDelete); const { 'variable-name': name, 'variable-environment': environment, @@ -72,7 +72,7 @@ export default class EnvironmentVariableDelete extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariableDelete, { + } = await this.getContextAsync(EnvDelete, { nonInteractive, }); diff --git a/packages/eas-cli/src/commands/env/exec.ts b/packages/eas-cli/src/commands/env/exec.ts index bd20f25fb4..20b6be0bc5 100644 --- a/packages/eas-cli/src/commands/env/exec.ts +++ b/packages/eas-cli/src/commands/env/exec.ts @@ -28,7 +28,7 @@ interface RawFlags { export default class EnvExec extends EasCommand { static override description = - 'execute a bash command with environment variables from the selected environment'; + 'execute a command with environment variables from the selected environment'; static override hidden = true; diff --git a/packages/eas-cli/src/commands/env/get.ts b/packages/eas-cli/src/commands/env/get.ts index d845478072..2b6c5ecd6b 100644 --- a/packages/eas-cli/src/commands/env/get.ts +++ b/packages/eas-cli/src/commands/env/get.ts @@ -37,8 +37,9 @@ interface GetFlags { scope: EnvironmentVariableScope; } -export default class EnvironmentVariableGet extends EasCommand { - static override description = 'get environment variable'; +export default class EnvGet extends EasCommand { + static override description = + 'get information about an environment variable for the current project or account'; static override hidden = true; @@ -70,7 +71,7 @@ export default class EnvironmentVariableGet extends EasCommand { }; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariableGet); + const { args, flags } = await this.parse(EnvGet); let { 'variable-environment': environment, @@ -83,7 +84,7 @@ export default class EnvironmentVariableGet extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariableGet, { + } = await this.getContextAsync(EnvGet, { nonInteractive, }); diff --git a/packages/eas-cli/src/commands/env/link.ts b/packages/eas-cli/src/commands/env/link.ts index 67c619ac5c..85b17bb296 100644 --- a/packages/eas-cli/src/commands/env/link.ts +++ b/packages/eas-cli/src/commands/env/link.ts @@ -23,7 +23,7 @@ type LinkFlags = { environment?: EnvironmentVariableEnvironment[]; }; -export default class EnvironmentVariableLink extends EasCommand { +export default class EnvLink extends EasCommand { static override description = 'link an account-wide environment variable to the current project'; // for now we only roll out global account-wide env variables so this should stay hidden @@ -56,7 +56,7 @@ export default class EnvironmentVariableLink extends EasCommand { }; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariableLink); + const { args, flags } = await this.parse(EnvLink); let { 'variable-name': name, @@ -68,7 +68,7 @@ export default class EnvironmentVariableLink extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariableLink, { + } = await this.getContextAsync(EnvLink, { nonInteractive, }); diff --git a/packages/eas-cli/src/commands/env/list.ts b/packages/eas-cli/src/commands/env/list.ts index 83c0f18f80..a3dffb5434 100644 --- a/packages/eas-cli/src/commands/env/list.ts +++ b/packages/eas-cli/src/commands/env/list.ts @@ -85,8 +85,8 @@ interface ListFlags { 'non-interactive': boolean; } -export default class EnvironmentValueList extends EasCommand { - static override description = 'list environment variables for the current project'; +export default class EnvList extends EasCommand { + static override description = 'list environment variables for the current project or account'; static override hidden = true; @@ -119,7 +119,7 @@ export default class EnvironmentValueList extends EasCommand { ]; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentValueList); + const { args, flags } = await this.parse(EnvList); let { format, @@ -133,7 +133,7 @@ export default class EnvironmentValueList extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentValueList, { + } = await this.getContextAsync(EnvList, { nonInteractive: true, }); diff --git a/packages/eas-cli/src/commands/env/pull.ts b/packages/eas-cli/src/commands/env/pull.ts index f7226452a1..84b845b0c6 100644 --- a/packages/eas-cli/src/commands/env/pull.ts +++ b/packages/eas-cli/src/commands/env/pull.ts @@ -15,8 +15,9 @@ import { confirmAsync } from '../../prompts'; import { promptVariableEnvironmentAsync } from '../../utils/prompts'; import { isEnvironment } from '../../utils/variableUtils'; -export default class EnvironmentVariablePull extends EasCommand { - static override description = 'pull env file'; +export default class EnvPull extends EasCommand { + static override description = + 'pull environment variables for the selected environment to .env file'; static override hidden = true; @@ -48,7 +49,7 @@ export default class EnvironmentVariablePull extends EasCommand { let { args: { environment: argEnvironment }, flags: { environment: flagEnvironment, path: targetPath, 'non-interactive': nonInteractive }, - } = await this.parse(EnvironmentVariablePull); + } = await this.parse(EnvPull); let environment = flagEnvironment?.toUpperCase() ?? argEnvironment?.toUpperCase(); @@ -64,7 +65,7 @@ export default class EnvironmentVariablePull extends EasCommand { projectId, loggedIn: { graphqlClient }, projectDir, - } = await this.getContextAsync(EnvironmentVariablePull, { + } = await this.getContextAsync(EnvPull, { nonInteractive, }); diff --git a/packages/eas-cli/src/commands/env/push.ts b/packages/eas-cli/src/commands/env/push.ts index f63ef92f9a..340bc4f3e0 100644 --- a/packages/eas-cli/src/commands/env/push.ts +++ b/packages/eas-cli/src/commands/env/push.ts @@ -21,8 +21,9 @@ import { confirmAsync, promptAsync } from '../../prompts'; import { promptVariableEnvironmentAsync } from '../../utils/prompts'; import { isEnvironment } from '../../utils/variableUtils'; -export default class EnvironmentVariablePush extends EasCommand { - static override description = 'push env file'; +export default class EnvPush extends EasCommand { + static override description = + 'push environment variables from .env file to the selected environment'; static override hidden = true; @@ -49,14 +50,14 @@ export default class EnvironmentVariablePush extends EasCommand { ]; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariablePush); + const { args, flags } = await this.parse(EnvPush); let { environment: environments, path: envPath } = this.parseFlagsAndArgs(flags, args); const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariablePush, { + } = await this.getContextAsync(EnvPush, { nonInteractive: false, }); diff --git a/packages/eas-cli/src/commands/env/unlink.ts b/packages/eas-cli/src/commands/env/unlink.ts index ed687cf432..047814ef05 100644 --- a/packages/eas-cli/src/commands/env/unlink.ts +++ b/packages/eas-cli/src/commands/env/unlink.ts @@ -18,7 +18,7 @@ type UnlinkFlags = { environment?: EnvironmentVariableEnvironment[]; }; -export default class EnvironmentVariableUnlink extends EasCommand { +export default class EnvUnlink extends EasCommand { static override description = 'unlink an account-wide environment variable from the current project'; @@ -48,7 +48,7 @@ export default class EnvironmentVariableUnlink extends EasCommand { ]; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariableUnlink); + const { args, flags } = await this.parse(EnvUnlink); let { 'variable-name': name, @@ -59,7 +59,7 @@ export default class EnvironmentVariableUnlink extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariableUnlink, { + } = await this.getContextAsync(EnvUnlink, { nonInteractive, }); diff --git a/packages/eas-cli/src/commands/env/update.ts b/packages/eas-cli/src/commands/env/update.ts index ac40035f2d..2573925819 100644 --- a/packages/eas-cli/src/commands/env/update.ts +++ b/packages/eas-cli/src/commands/env/update.ts @@ -62,9 +62,8 @@ interface UpdateFlags { 'non-interactive': boolean; } -export default class EnvironmentVariableUpdate extends EasCommand { - static override description = - 'update an environment variable on the current project or owner account'; +export default class EnvUpdate extends EasCommand { + static override description = 'update an environment variable on the current project or account'; static override hidden = true; @@ -108,7 +107,7 @@ export default class EnvironmentVariableUpdate extends EasCommand { }; async runAsync(): Promise { - const { args, flags } = await this.parse(EnvironmentVariableUpdate); + const { args, flags } = await this.parse(EnvUpdate); const { name, value: rawValue, @@ -124,7 +123,7 @@ export default class EnvironmentVariableUpdate extends EasCommand { const { projectId, loggedIn: { graphqlClient }, - } = await this.getContextAsync(EnvironmentVariableUpdate, { + } = await this.getContextAsync(EnvUpdate, { nonInteractive, }); From e2d65d92c0aafe0cab99ff78f6196435518f21df Mon Sep 17 00:00:00 2001 From: Szymon Dziedzic Date: Wed, 20 Nov 2024 17:44:12 +0100 Subject: [PATCH 2/2] fix tests --- .../env/__tests__/__snapshots__/EnvDelete.test.ts.snap | 3 +++ .../__snapshots__/EnvironmentVariableDelete.test.ts.snap | 3 --- packages/eas-cli/src/commands/env/get.ts | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvDelete.test.ts.snap delete mode 100644 packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvironmentVariableDelete.test.ts.snap diff --git a/packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvDelete.test.ts.snap b/packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvDelete.test.ts.snap new file mode 100644 index 0000000000..a2d7f43d52 --- /dev/null +++ b/packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvDelete.test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EnvDelete cancels deletion when user does not confirm 1`] = `"Environment variable needs 'name' to be specified when running in non-interactive mode. Run the command with --variable-name VARIABLE_NAME flag to fix the issue"`; diff --git a/packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvironmentVariableDelete.test.ts.snap b/packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvironmentVariableDelete.test.ts.snap deleted file mode 100644 index e746669c17..0000000000 --- a/packages/eas-cli/src/commands/env/__tests__/__snapshots__/EnvironmentVariableDelete.test.ts.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EnvironmentVariableDelete cancels deletion when user does not confirm 1`] = `"Environment variable needs 'name' to be specified when running in non-interactive mode. Run the command with --variable-name VARIABLE_NAME flag to fix the issue"`; diff --git a/packages/eas-cli/src/commands/env/get.ts b/packages/eas-cli/src/commands/env/get.ts index 2b6c5ecd6b..9b83aaa2b8 100644 --- a/packages/eas-cli/src/commands/env/get.ts +++ b/packages/eas-cli/src/commands/env/get.ts @@ -38,8 +38,7 @@ interface GetFlags { } export default class EnvGet extends EasCommand { - static override description = - 'get information about an environment variable for the current project or account'; + static override description = 'view an environment variable for the current project or account'; static override hidden = true;