Skip to content

Commit 1380b02

Browse files
authored
[eas-cli] Deprecate isGlobal GraphQL input property of environment variables (#3190)
<!-- 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 See expo/universe#22108. # How - Updated GraphQL code. - Adjusted code to the updated GraphQL code (no `isGlobal`). - Updated types in `EnvironmentVariableMutation` so they don't re-implement what GraphQL is generating for us. - Updated types in `env:push`. # Test Plan Adjusted tests.
1 parent adfc79a commit 1380b02

File tree

6 files changed

+19
-62
lines changed

6 files changed

+19
-62
lines changed

packages/eas-cli/graphql.schema.json

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eas-cli/src/commands/env/__tests__/EnvCreate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe(EnvCreate, () => {
4747
createdAt: new Date().toISOString(),
4848
updatedAt: new Date().toISOString(),
4949
scope: EnvironmentVariableScope.Project,
50+
type: EnvironmentSecretType.String,
5051
}));
5152
jest
5253
.mocked(EnvironmentVariableMutation.createSharedVariableAsync)
@@ -56,6 +57,7 @@ describe(EnvCreate, () => {
5657
createdAt: new Date().toISOString(),
5758
updatedAt: new Date().toISOString(),
5859
scope: EnvironmentVariableScope.Shared,
60+
type: EnvironmentSecretType.String,
5961
}));
6062
jest
6163
.mocked(EnvironmentVariableMutation.updateAsync)
@@ -199,7 +201,6 @@ describe(EnvCreate, () => {
199201
{
200202
name: 'VarName',
201203
value: 'VarValue',
202-
isGlobal: true,
203204
environments: [EnvironmentVariableEnvironment.Production],
204205
visibility: EnvironmentVariableVisibility.Public,
205206
type: EnvironmentSecretType.String,
@@ -324,7 +325,6 @@ describe(EnvCreate, () => {
324325
EnvironmentVariableEnvironment.Development,
325326
],
326327
visibility: EnvironmentVariableVisibility.Public,
327-
isGlobal: true,
328328
type: EnvironmentSecretType.String,
329329
},
330330
testAccountId

packages/eas-cli/src/commands/env/create.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ export default class EnvCreate extends EasCommand {
220220
value,
221221
visibility,
222222
environments,
223-
isGlobal: true, // TODO: every account-wide variable is global for now so it's not user facing
224223
type: type ?? EnvironmentSecretType.String,
225224
},
226225
ownerAccount.id

packages/eas-cli/src/commands/env/push.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ import path from 'path';
66
import EasCommand from '../../commandUtils/EasCommand';
77
import { EASMultiEnvironmentFlag } from '../../commandUtils/flags';
88
import {
9+
CreateEnvironmentVariableInput,
910
EnvironmentVariableEnvironment,
1011
EnvironmentVariableFragment,
1112
EnvironmentVariableScope,
1213
EnvironmentVariableVisibility,
1314
} from '../../graphql/generated';
14-
import {
15-
EnvironmentVariableMutation,
16-
EnvironmentVariablePushInput,
17-
} from '../../graphql/mutations/EnvironmentVariableMutation';
15+
import { EnvironmentVariableMutation } from '../../graphql/mutations/EnvironmentVariableMutation';
1816
import { EnvironmentVariablesQuery } from '../../graphql/queries/EnvironmentVariablesQuery';
1917
import Log from '../../log';
2018
import { confirmAsync, promptAsync } from '../../prompts';
@@ -66,8 +64,7 @@ export default class EnvPush extends EasCommand {
6664
});
6765
}
6866

69-
const updateVariables: Record<string, EnvironmentVariablePushInput> =
70-
await this.parseEnvFileAsync(envPath, environments);
67+
const updateVariables = await this.parseEnvFileAsync(envPath, environments);
7168

7269
const variableNames = Object.keys(updateVariables);
7370

@@ -219,11 +216,16 @@ export default class EnvPush extends EasCommand {
219216
private async parseEnvFileAsync(
220217
envPath: string,
221218
environments: EnvironmentVariableEnvironment[]
222-
): Promise<Record<string, EnvironmentVariablePushInput>> {
219+
): Promise<
220+
Record<
221+
string,
222+
CreateEnvironmentVariableInput & { environments: EnvironmentVariableEnvironment[] }
223+
>
224+
> {
223225
if (!(await fs.exists(envPath))) {
224226
throw new Error(`File ${envPath} does not exist.`);
225227
}
226-
const pushInput: Record<string, EnvironmentVariablePushInput> = {};
228+
const pushInput: Awaited<ReturnType<typeof this.parseEnvFileAsync>> = {};
227229

228230
const variables: Record<string, string> = dotenv.parse(await fs.readFile(envPath, 'utf8'));
229231

packages/eas-cli/src/graphql/generated.ts

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eas-cli/src/graphql/mutations/EnvironmentVariableMutation.ts

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,19 @@ import {
77
CreateBulkEnvironmentVariablesForAppMutation,
88
CreateEnvironmentVariableForAccountMutation,
99
CreateEnvironmentVariableForAppMutation,
10+
CreateEnvironmentVariableInput,
11+
CreateSharedEnvironmentVariableInput,
1012
DeleteEnvironmentVariableMutation,
11-
EnvironmentSecretType,
12-
EnvironmentVariableEnvironment,
1313
EnvironmentVariableFragment,
14-
EnvironmentVariableVisibility,
14+
UpdateEnvironmentVariableInput,
1515
UpdateEnvironmentVariableMutation,
1616
} from '../generated';
1717
import { EnvironmentVariableFragmentNode } from '../types/EnvironmentVariable';
1818

19-
type CreateVariableArgs = {
20-
value: string;
21-
name: string;
22-
visibility: EnvironmentVariableVisibility;
23-
environments: EnvironmentVariableEnvironment[];
24-
type: EnvironmentSecretType;
25-
isGlobal?: boolean;
26-
fileName?: string;
27-
};
28-
29-
export type EnvironmentVariablePushInput = {
30-
name: string;
31-
value: string;
32-
environments: EnvironmentVariableEnvironment[];
33-
visibility: EnvironmentVariableVisibility;
34-
overwrite?: boolean;
35-
};
36-
3719
export const EnvironmentVariableMutation = {
3820
async createSharedVariableAsync(
3921
graphqlClient: ExpoGraphqlClient,
40-
input: CreateVariableArgs,
22+
input: CreateSharedEnvironmentVariableInput,
4123
accountId: string
4224
): Promise<EnvironmentVariableFragment> {
4325
const data = await withErrorHandlingAsync(
@@ -69,7 +51,7 @@ export const EnvironmentVariableMutation = {
6951
},
7052
async createForAppAsync(
7153
graphqlClient: ExpoGraphqlClient,
72-
input: CreateVariableArgs,
54+
input: CreateEnvironmentVariableInput,
7355
appId: string
7456
): Promise<EnvironmentVariableFragment> {
7557
const data = await withErrorHandlingAsync(
@@ -98,7 +80,7 @@ export const EnvironmentVariableMutation = {
9880
},
9981
async updateAsync(
10082
graphqlClient: ExpoGraphqlClient,
101-
input: Partial<CreateVariableArgs> & { id: string }
83+
input: UpdateEnvironmentVariableInput
10284
): Promise<EnvironmentVariableFragment> {
10385
const data = await withErrorHandlingAsync(
10486
graphqlClient
@@ -143,7 +125,7 @@ export const EnvironmentVariableMutation = {
143125
},
144126
async createBulkEnvironmentVariablesForAppAsync(
145127
graphqlClient: ExpoGraphqlClient,
146-
input: EnvironmentVariablePushInput[],
128+
input: CreateEnvironmentVariableInput[],
147129
appId: string
148130
): Promise<boolean> {
149131
await withErrorHandlingAsync(

0 commit comments

Comments
 (0)