Skip to content

Commit

Permalink
[ENG-14223][eas-cli] improve class names and descriptions of env comm…
Browse files Browse the repository at this point in the history
…ands (#2711)

<!-- If this PR requires a changelog entry, add it by commenting the PR with the command `/changelog-entry [breaking-change|new-feature|bug-fix|chore] [message]`. -->
<!-- You can skip the changelog check by labeling the PR with "no changelog". -->

# Why

Make class names more consistent with other commands

Improve descriptions

# How

Make class names more consistent with other commands

Improve descriptions

# Test Plan

Tests
  • Loading branch information
szdziedzic authored Nov 20, 2024
1 parent bb3915d commit fc3c1e7
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -172,7 +172,7 @@ describe(EnvironmentVariableCreate, () => {
});

it('creates an account-wide variable', async () => {
const command = new EnvironmentVariableCreate(
const command = new EnvCreate(
[
'--name',
'VarName',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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',
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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');
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 = {};
Expand Down Expand Up @@ -53,7 +53,7 @@ describe(EnvironmentVariableLink, () => {
mockVariables[0]
);

const command = new EnvironmentVariableLink(
const command = new EnvLink(
['--variable-name', 'TEST_VARIABLE', '--non-interactive'],
mockConfig
);
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -137,7 +137,7 @@ describe(EnvironmentVariableLink, () => {
);
(toggleConfirmAsync as jest.Mock).mockResolvedValue(true);

const command = new EnvironmentVariableLink(
const command = new EnvLink(
[
'--variable-name',
'TEST_VARIABLE',
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -44,7 +44,7 @@ const mockVariables: EnvironmentVariableFragment[] = [
},
];

describe(EnvironmentVariableList, () => {
describe(EnvList, () => {
const graphqlClient = {} as any as ExpoGraphqlClient;
const mockConfig = {} as unknown as Config;

Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand Down
Loading

0 comments on commit fc3c1e7

Please sign in to comment.