eas-cli 10.2.2 → 10.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +60 -60
  2. package/build/build/local.js +1 -1
  3. package/build/build/metadata.js +1 -0
  4. package/build/build/runBuildAndSubmit.js +11 -0
  5. package/build/commandUtils/flags.d.ts +13 -0
  6. package/build/commandUtils/flags.js +47 -1
  7. package/build/commands/env/create.d.ts +23 -0
  8. package/build/commands/env/create.js +164 -0
  9. package/build/commands/env/delete.d.ts +18 -0
  10. package/build/commands/env/delete.js +92 -0
  11. package/build/commands/env/get.d.ts +19 -0
  12. package/build/commands/env/get.js +92 -0
  13. package/build/commands/env/link.d.ts +15 -0
  14. package/build/commands/env/link.js +57 -0
  15. package/build/commands/env/list.d.ts +16 -0
  16. package/build/commands/env/list.js +55 -0
  17. package/build/commands/env/unlink.d.ts +15 -0
  18. package/build/commands/env/unlink.js +62 -0
  19. package/build/commands/env/update.d.ts +21 -0
  20. package/build/commands/env/update.js +130 -0
  21. package/build/env.d.ts +5 -0
  22. package/build/env.js +5 -0
  23. package/build/graphql/generated.d.ts +555 -52
  24. package/build/graphql/generated.js +42 -2
  25. package/build/graphql/mutations/EnvironmentVariableMutation.d.ts +38 -0
  26. package/build/graphql/mutations/EnvironmentVariableMutation.js +113 -0
  27. package/build/graphql/queries/EnvironmentVariablesQuery.d.ts +13 -0
  28. package/build/graphql/queries/EnvironmentVariablesQuery.js +83 -0
  29. package/build/graphql/types/EnvironmentVariable.d.ts +1 -0
  30. package/build/graphql/types/EnvironmentVariable.js +16 -0
  31. package/build/project/ios/bundleIdentifier.js +4 -0
  32. package/build/utils/formatVariable.d.ts +2 -0
  33. package/build/utils/formatVariable.js +16 -0
  34. package/build/utils/prompts.d.ts +9 -0
  35. package/build/utils/prompts.js +68 -0
  36. package/oclif.manifest.json +410 -1
  37. package/package.json +5 -5
@@ -0,0 +1,23 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { EnvironmentVariableEnvironment, EnvironmentVariableScope, EnvironmentVariableVisibility } from '../../graphql/generated';
3
+ export default class EnvironmentVariableCreate extends EasCommand {
4
+ static description: string;
5
+ static hidden: boolean;
6
+ static flags: {
7
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
9
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableScope>;
10
+ visibility: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableVisibility | undefined>;
11
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
+ value: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
13
+ link: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ static contextDefinition: {
17
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
18
+ analytics: import("../../commandUtils/context/AnalyticsContextField").default;
19
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
20
+ };
21
+ runAsync(): Promise<void>;
22
+ private validateFlags;
23
+ }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../commandUtils/flags");
9
+ const generated_1 = require("../../graphql/generated");
10
+ const EnvironmentVariableMutation_1 = require("../../graphql/mutations/EnvironmentVariableMutation");
11
+ const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
12
+ const log_1 = tslib_1.__importDefault(require("../../log"));
13
+ const projectUtils_1 = require("../../project/projectUtils");
14
+ const prompts_1 = require("../../prompts");
15
+ const prompts_2 = require("../../utils/prompts");
16
+ class EnvironmentVariableCreate extends EasCommand_1.default {
17
+ async runAsync() {
18
+ const { flags } = await this.parse(_a);
19
+ let { name, value, scope, 'non-interactive': nonInteractive, environment, visibility, link, force, } = this.validateFlags(flags);
20
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
21
+ nonInteractive,
22
+ });
23
+ const [projectDisplayName, ownerAccount] = await Promise.all([
24
+ (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId),
25
+ (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId),
26
+ ]);
27
+ if (!name) {
28
+ name = await (0, prompts_2.promptVariableNameAsync)(nonInteractive);
29
+ }
30
+ let overwrite = false;
31
+ visibility = visibility ?? generated_1.EnvironmentVariableVisibility.Public;
32
+ if (!value) {
33
+ value = await (0, prompts_2.promptVariableValueAsync)({
34
+ nonInteractive,
35
+ hidden: visibility !== generated_1.EnvironmentVariableVisibility.Public,
36
+ });
37
+ }
38
+ if (scope === generated_1.EnvironmentVariableScope.Project) {
39
+ if (!environment) {
40
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
41
+ }
42
+ const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, projectId, environment);
43
+ const existingVariable = existingVariables.find(variable => variable.name === name);
44
+ if (existingVariable) {
45
+ if (existingVariable.scope === generated_1.EnvironmentVariableScope.Shared) {
46
+ if (!nonInteractive) {
47
+ const confirmation = await (0, prompts_1.confirmAsync)({
48
+ message: `Shared variable ${name} already exists on this project. Do you want to unlink it first?`,
49
+ });
50
+ if (!confirmation) {
51
+ log_1.default.log('Aborting');
52
+ throw new Error(`Shared variable ${name} already exists on this project.`);
53
+ }
54
+ }
55
+ else if (!force) {
56
+ throw new Error(`Shared variable ${name} already exists on this project. Use --force to overwrite it.`);
57
+ }
58
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, existingVariable.id, projectId, environment);
59
+ log_1.default.withTick(`Unlinking shared variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
60
+ }
61
+ else {
62
+ if (!nonInteractive) {
63
+ const confirmation = await (0, prompts_1.confirmAsync)({
64
+ message: `Variable ${name} already exists on this project. Do you want to overwrite it?`,
65
+ });
66
+ if (!confirmation) {
67
+ log_1.default.log('Aborting');
68
+ throw new Error(`Variable ${name} already exists on this project. Use --force to overwrite it.`);
69
+ }
70
+ }
71
+ else if (!force) {
72
+ throw new Error(`Variable ${name} already exists on this project. Use --force to overwrite it.`);
73
+ }
74
+ overwrite = true;
75
+ }
76
+ }
77
+ const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createForAppAsync(graphqlClient, {
78
+ name,
79
+ value,
80
+ environment,
81
+ visibility,
82
+ overwrite,
83
+ }, projectId);
84
+ if (!variable) {
85
+ throw new Error(`Could not create variable with name ${name} on project ${projectDisplayName}`);
86
+ }
87
+ log_1.default.withTick(`Created a new variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
88
+ }
89
+ else if (scope === generated_1.EnvironmentVariableScope.Shared) {
90
+ const sharedVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, projectId);
91
+ const existingVariable = sharedVariables.find(variable => variable.name === name);
92
+ if (existingVariable) {
93
+ throw new Error(`Shared variable with ${name} name already exists on this account.\n` +
94
+ `Use a different name or delete the existing variable on website or by using eas env:delete --name ${name} --scope shared command.`);
95
+ }
96
+ if (environment && !link) {
97
+ const confirmation = await (0, prompts_1.confirmAsync)({
98
+ message: `Unexpected argument: --environment can only be used with --link flag. Do you want to link the variable to the current project?`,
99
+ });
100
+ if (!confirmation) {
101
+ log_1.default.log('Aborting');
102
+ throw new Error('Unexpected argument: --environment can only be used with --link flag.');
103
+ }
104
+ }
105
+ if (!environment && link) {
106
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
107
+ }
108
+ const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createSharedVariableAsync(graphqlClient, {
109
+ name,
110
+ value,
111
+ visibility,
112
+ }, ownerAccount.id);
113
+ if (!variable) {
114
+ throw new Error(`Could not create variable with name ${name} on account ${ownerAccount.name}`);
115
+ }
116
+ log_1.default.withTick(`Created a new variable ${chalk_1.default.bold(name)} on account ${chalk_1.default.bold(ownerAccount.name)}.`);
117
+ if (link && environment) {
118
+ log_1.default.withTick(`Linking shared variable ${chalk_1.default.bold(name)} to project ${chalk_1.default.bold(projectDisplayName)}.`);
119
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, variable.id, projectId, environment);
120
+ log_1.default.withTick(`Linked shared variable ${chalk_1.default.bold(name)} to project ${chalk_1.default.bold(projectDisplayName)}.`);
121
+ }
122
+ }
123
+ }
124
+ validateFlags(flags) {
125
+ if (flags.scope !== generated_1.EnvironmentVariableScope.Shared && flags.link) {
126
+ throw new Error(`Unexpected argument: --link can only be used when creating shared variables`);
127
+ }
128
+ if (flags.scope === generated_1.EnvironmentVariableScope.Shared &&
129
+ flags.environment &&
130
+ !flags.link &&
131
+ flags['non-interactive']) {
132
+ throw new Error('Unexpected argument: --environment in non-interactive mode can only be used with --link flag.');
133
+ }
134
+ return flags;
135
+ }
136
+ }
137
+ _a = EnvironmentVariableCreate;
138
+ EnvironmentVariableCreate.description = 'create an environment variable on the current project or owner account';
139
+ EnvironmentVariableCreate.hidden = true;
140
+ EnvironmentVariableCreate.flags = {
141
+ name: core_1.Flags.string({
142
+ description: 'Name of the variable',
143
+ }),
144
+ value: core_1.Flags.string({
145
+ description: 'Text value or the variable',
146
+ }),
147
+ link: core_1.Flags.boolean({
148
+ description: 'Link shared variable to the current project',
149
+ }),
150
+ force: core_1.Flags.boolean({
151
+ description: 'Overwrite existing variable',
152
+ default: false,
153
+ }),
154
+ ...flags_1.EASVariableVisibilityFlag,
155
+ ...flags_1.EASVariableScopeFlag,
156
+ ...flags_1.EASEnvironmentFlag,
157
+ ...flags_1.EASNonInteractiveFlag,
158
+ };
159
+ EnvironmentVariableCreate.contextDefinition = {
160
+ ..._a.ContextOptions.ProjectConfig,
161
+ ..._a.ContextOptions.Analytics,
162
+ ..._a.ContextOptions.LoggedIn,
163
+ };
164
+ exports.default = EnvironmentVariableCreate;
@@ -0,0 +1,18 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { EnvironmentVariableEnvironment, EnvironmentVariableScope } from '../../graphql/generated';
3
+ export default class EnvironmentVariableDelete extends EasCommand {
4
+ static description: string;
5
+ static hidden: boolean;
6
+ static flags: {
7
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
9
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableScope>;
10
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
+ };
12
+ static contextDefinition: {
13
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
14
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
15
+ };
16
+ runAsync(): Promise<void>;
17
+ private validateFlags;
18
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../commandUtils/flags");
9
+ const generated_1 = require("../../graphql/generated");
10
+ const EnvironmentVariableMutation_1 = require("../../graphql/mutations/EnvironmentVariableMutation");
11
+ const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
12
+ const log_1 = tslib_1.__importDefault(require("../../log"));
13
+ const prompts_1 = require("../../prompts");
14
+ const prompts_2 = require("../../utils/prompts");
15
+ class EnvironmentVariableDelete extends EasCommand_1.default {
16
+ async runAsync() {
17
+ const { flags } = await this.parse(_a);
18
+ let { name, environment, 'non-interactive': nonInteractive, scope } = this.validateFlags(flags);
19
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
20
+ nonInteractive,
21
+ });
22
+ if (scope === generated_1.EnvironmentVariableScope.Project) {
23
+ if (!environment) {
24
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
25
+ }
26
+ }
27
+ const variables = scope === generated_1.EnvironmentVariableScope.Project && environment
28
+ ? await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, projectId, environment)
29
+ : await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, projectId);
30
+ if (!name) {
31
+ ({ name } = await (0, prompts_1.promptAsync)({
32
+ type: 'select',
33
+ name: 'name',
34
+ message: 'Pick the variable to be deleted:',
35
+ choices: variables
36
+ .filter(({ scope: variableScope }) => scope === variableScope)
37
+ .map(variable => ({
38
+ title: variable.name,
39
+ value: variable.name,
40
+ })),
41
+ }));
42
+ if (!name) {
43
+ throw new Error(`Environment variable wasn't selected. Run the command again and select existing variable or run it with ${chalk_1.default.bold('--name VARIABLE_NAME')} flag to fix the issue.`);
44
+ }
45
+ }
46
+ const selectedVariable = variables.find(variable => variable.name === name);
47
+ if (!selectedVariable) {
48
+ throw new Error(`Variable "${name}" not found.`);
49
+ }
50
+ if (!nonInteractive) {
51
+ log_1.default.addNewLineIfNone();
52
+ log_1.default.warn(`You are about to permanently delete variable ${selectedVariable.name}.`);
53
+ log_1.default.warn('This action is irreversible.');
54
+ log_1.default.newLine();
55
+ const confirmed = await (0, prompts_1.toggleConfirmAsync)({
56
+ message: `Are you sure you wish to proceed?${selectedVariable.scope === generated_1.EnvironmentVariableScope.Shared
57
+ ? ' This variable is applied across your whole account and may affect multiple apps.'
58
+ : ''}`,
59
+ });
60
+ if (!confirmed) {
61
+ log_1.default.error(`Canceled deletion of variable ${selectedVariable.name}.`);
62
+ throw new Error(`Variable "${name}" not deleted.`);
63
+ }
64
+ }
65
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.deleteAsync(graphqlClient, selectedVariable.id);
66
+ log_1.default.withTick(`️Deleted variable ${selectedVariable.name}".`);
67
+ }
68
+ validateFlags(flags) {
69
+ if (flags['non-interactive']) {
70
+ if (!flags.name) {
71
+ throw new Error(`Environment variable needs 'name' to be specified when running in non-interactive mode. Run the command with ${chalk_1.default.bold('--name VARIABLE_NAME')} flag to fix the issue`);
72
+ }
73
+ }
74
+ return flags;
75
+ }
76
+ }
77
+ _a = EnvironmentVariableDelete;
78
+ EnvironmentVariableDelete.description = 'delete an environment variable by name';
79
+ EnvironmentVariableDelete.hidden = true;
80
+ EnvironmentVariableDelete.flags = {
81
+ name: core_1.Flags.string({
82
+ description: 'Name of the variable to delete',
83
+ }),
84
+ ...flags_1.EASVariableScopeFlag,
85
+ ...flags_1.EASEnvironmentFlag,
86
+ ...flags_1.EASNonInteractiveFlag,
87
+ };
88
+ EnvironmentVariableDelete.contextDefinition = {
89
+ ..._a.ContextOptions.ProjectConfig,
90
+ ..._a.ContextOptions.LoggedIn,
91
+ };
92
+ exports.default = EnvironmentVariableDelete;
@@ -0,0 +1,19 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { EnvironmentVariableEnvironment, EnvironmentVariableScope } from '../../graphql/generated';
3
+ export default class EnvironmentVariableGet extends EasCommand {
4
+ static description: string;
5
+ static hidden: boolean;
6
+ static contextDefinition: {
7
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
8
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
9
+ };
10
+ static flags: {
11
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
12
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableScope>;
14
+ format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
15
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
16
+ };
17
+ runAsync(): Promise<void>;
18
+ private validateFlags;
19
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../commandUtils/flags");
9
+ const generated_1 = require("../../graphql/generated");
10
+ const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
11
+ const log_1 = tslib_1.__importDefault(require("../../log"));
12
+ const formatVariable_1 = require("../../utils/formatVariable");
13
+ const prompts_1 = require("../../utils/prompts");
14
+ class EnvironmentVariableGet extends EasCommand_1.default {
15
+ async runAsync() {
16
+ const { flags } = await this.parse(_a);
17
+ let { environment, name, 'non-interactive': nonInteractive, format, scope, } = this.validateFlags(flags);
18
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
19
+ nonInteractive,
20
+ });
21
+ if (!name) {
22
+ name = await (0, prompts_1.promptVariableNameAsync)(nonInteractive);
23
+ }
24
+ if (!environment && scope === generated_1.EnvironmentVariableScope.Project) {
25
+ environment = await (0, prompts_1.promptVariableEnvironmentAsync)(nonInteractive);
26
+ }
27
+ const variable = await getVariableAsync(graphqlClient, scope, projectId, name, environment);
28
+ if (!variable) {
29
+ log_1.default.error(`Variable with name "${name}" not found`);
30
+ return;
31
+ }
32
+ if (!variable.value) {
33
+ throw new Error(`${chalk_1.default.bold(variable.name)} is a secret variable and cannot be displayed once it has been created.`);
34
+ }
35
+ if (format === 'short') {
36
+ log_1.default.log(`${chalk_1.default.bold(variable.name)}=${variable.value}`);
37
+ }
38
+ else {
39
+ log_1.default.log((0, formatVariable_1.formatVariable)(variable));
40
+ }
41
+ }
42
+ validateFlags(flags) {
43
+ if (flags.environment && flags.scope === generated_1.EnvironmentVariableScope.Shared) {
44
+ throw new Error(`Unexpected argument: --environment can only be used with project variables`);
45
+ }
46
+ if (flags['non-interactive']) {
47
+ if (!flags.name) {
48
+ throw new Error('Variable name is required. Run the command with --name flag.');
49
+ }
50
+ if (!flags.scope) {
51
+ throw new Error('Scope is required. Run the command with --scope flag.');
52
+ }
53
+ if (!flags.environment && flags.scope === generated_1.EnvironmentVariableScope.Project) {
54
+ throw new Error('Environment is required.');
55
+ }
56
+ }
57
+ return flags;
58
+ }
59
+ }
60
+ _a = EnvironmentVariableGet;
61
+ EnvironmentVariableGet.description = 'get environment variable';
62
+ EnvironmentVariableGet.hidden = true;
63
+ EnvironmentVariableGet.contextDefinition = {
64
+ ..._a.ContextOptions.ProjectConfig,
65
+ ..._a.ContextOptions.LoggedIn,
66
+ };
67
+ EnvironmentVariableGet.flags = {
68
+ name: core_1.Flags.string({
69
+ description: 'Name of the variable',
70
+ }),
71
+ ...flags_1.EASVariableFormatFlag,
72
+ ...flags_1.EASVariableScopeFlag,
73
+ ...flags_1.EASNonInteractiveFlag,
74
+ ...flags_1.EASEnvironmentFlag,
75
+ };
76
+ exports.default = EnvironmentVariableGet;
77
+ async function getVariableAsync(graphqlClient, scope, projectId, name, environment) {
78
+ if (!environment && scope === generated_1.EnvironmentVariableScope.Project) {
79
+ throw new Error('Environment is required.');
80
+ }
81
+ if (environment && scope === generated_1.EnvironmentVariableScope.Project) {
82
+ const appVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, projectId, environment, [name]);
83
+ return appVariables[0];
84
+ }
85
+ if (scope === generated_1.EnvironmentVariableScope.Shared) {
86
+ const sharedVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, projectId, [
87
+ name,
88
+ ]);
89
+ return sharedVariables[0];
90
+ }
91
+ return null;
92
+ }
@@ -0,0 +1,15 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class EnvironmentVariableLink extends EasCommand {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ static flags: {
6
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../../graphql/generated").EnvironmentVariableEnvironment | undefined>;
8
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ };
10
+ static contextDefinition: {
11
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
12
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
13
+ };
14
+ runAsync(): Promise<void>;
15
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../commandUtils/flags");
9
+ const EnvironmentVariableMutation_1 = require("../../graphql/mutations/EnvironmentVariableMutation");
10
+ const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
11
+ const log_1 = tslib_1.__importDefault(require("../../log"));
12
+ const projectUtils_1 = require("../../project/projectUtils");
13
+ const prompts_1 = require("../../prompts");
14
+ const prompts_2 = require("../../utils/prompts");
15
+ class EnvironmentVariableLink extends EasCommand_1.default {
16
+ async runAsync() {
17
+ let { flags: { name, 'non-interactive': nonInteractive, environment }, } = await this.parse(_a);
18
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
19
+ nonInteractive,
20
+ });
21
+ const projectDisplayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
22
+ const variables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, projectId);
23
+ if (!name) {
24
+ name = await (0, prompts_1.selectAsync)('Select shared variable', variables.map(variable => ({
25
+ title: variable.name,
26
+ value: variable.name,
27
+ })));
28
+ }
29
+ const selectedVariable = variables.find(variable => variable.name === name);
30
+ if (!selectedVariable) {
31
+ throw new Error(`Shared variable ${name} doesn't exist`);
32
+ }
33
+ if (!environment) {
34
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
35
+ }
36
+ const linkedVariable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
37
+ if (!linkedVariable) {
38
+ throw new Error(`Could not link variable with name ${selectedVariable.name} to project with id ${projectId}`);
39
+ }
40
+ log_1.default.withTick(`Linked variable ${chalk_1.default.bold(linkedVariable.name)} to project ${chalk_1.default.bold(projectDisplayName)}.`);
41
+ }
42
+ }
43
+ _a = EnvironmentVariableLink;
44
+ EnvironmentVariableLink.description = 'link a shared environment variable to the current project';
45
+ EnvironmentVariableLink.hidden = true;
46
+ EnvironmentVariableLink.flags = {
47
+ name: core_1.Flags.string({
48
+ description: 'Name of the variable',
49
+ }),
50
+ ...flags_1.EASEnvironmentFlag,
51
+ ...flags_1.EASNonInteractiveFlag,
52
+ };
53
+ EnvironmentVariableLink.contextDefinition = {
54
+ ..._a.ContextOptions.ProjectConfig,
55
+ ..._a.ContextOptions.LoggedIn,
56
+ };
57
+ exports.default = EnvironmentVariableLink;
@@ -0,0 +1,16 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { EnvironmentVariableScope } from '../../graphql/generated';
3
+ export default class EnvironmentValueList extends EasCommand {
4
+ static description: string;
5
+ static hidden: boolean;
6
+ static contextDefinition: {
7
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
8
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
9
+ };
10
+ static flags: {
11
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../../graphql/generated").EnvironmentVariableEnvironment | undefined>;
12
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableScope>;
13
+ format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
14
+ };
15
+ runAsync(): Promise<void>;
16
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
7
+ const flags_1 = require("../../commandUtils/flags");
8
+ const generated_1 = require("../../graphql/generated");
9
+ const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
10
+ const log_1 = tslib_1.__importDefault(require("../../log"));
11
+ const formatVariable_1 = require("../../utils/formatVariable");
12
+ const prompts_1 = require("../../utils/prompts");
13
+ class EnvironmentValueList extends EasCommand_1.default {
14
+ async runAsync() {
15
+ let { flags: { environment, format, scope }, } = await this.parse(_a);
16
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
17
+ nonInteractive: true,
18
+ });
19
+ if (scope === generated_1.EnvironmentVariableScope.Project && !environment) {
20
+ environment = await (0, prompts_1.promptVariableEnvironmentAsync)(false);
21
+ }
22
+ const variables = scope === generated_1.EnvironmentVariableScope.Project && environment
23
+ ? await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, projectId, environment)
24
+ : await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, projectId);
25
+ if (format === 'short') {
26
+ for (const variable of variables) {
27
+ // TODO: Add Learn more link
28
+ log_1.default.log(`${chalk_1.default.bold(variable.name)}=${variable.value ??
29
+ "***** (This is a secret env variable that can only be accessed on EAS builder and can't be read in any UI. Learn more.)"}`);
30
+ }
31
+ }
32
+ else {
33
+ if (scope === generated_1.EnvironmentVariableScope.Shared) {
34
+ log_1.default.log(chalk_1.default.bold('Shared variables for this account:'));
35
+ }
36
+ else {
37
+ log_1.default.log(chalk_1.default.bold(`Variables for this project for environment ${environment}:`));
38
+ }
39
+ log_1.default.log(variables.map(variable => (0, formatVariable_1.formatVariable)(variable)).join(`\n\n${chalk_1.default.dim('———')}\n\n`));
40
+ }
41
+ }
42
+ }
43
+ _a = EnvironmentValueList;
44
+ EnvironmentValueList.description = 'list environment variables for the current project';
45
+ EnvironmentValueList.hidden = true;
46
+ EnvironmentValueList.contextDefinition = {
47
+ ..._a.ContextOptions.ProjectConfig,
48
+ ..._a.ContextOptions.LoggedIn,
49
+ };
50
+ EnvironmentValueList.flags = {
51
+ ...flags_1.EASVariableFormatFlag,
52
+ ...flags_1.EASVariableScopeFlag,
53
+ ...flags_1.EASEnvironmentFlag,
54
+ };
55
+ exports.default = EnvironmentValueList;
@@ -0,0 +1,15 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class EnvironmentVariableUnlink extends EasCommand {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ static flags: {
6
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../../graphql/generated").EnvironmentVariableEnvironment | undefined>;
8
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ };
10
+ static contextDefinition: {
11
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
12
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
13
+ };
14
+ runAsync(): Promise<void>;
15
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../commandUtils/flags");
9
+ const generated_1 = require("../../graphql/generated");
10
+ const EnvironmentVariableMutation_1 = require("../../graphql/mutations/EnvironmentVariableMutation");
11
+ const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
12
+ const log_1 = tslib_1.__importDefault(require("../../log"));
13
+ const projectUtils_1 = require("../../project/projectUtils");
14
+ const prompts_1 = require("../../prompts");
15
+ const prompts_2 = require("../../utils/prompts");
16
+ class EnvironmentVariableUnlink extends EasCommand_1.default {
17
+ async runAsync() {
18
+ let { flags: { name, 'non-interactive': nonInteractive, environment }, } = await this.parse(_a);
19
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
20
+ nonInteractive,
21
+ });
22
+ if (!environment) {
23
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
24
+ }
25
+ const projectDisplayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
26
+ const appVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, projectId, environment);
27
+ const linkedVariables = appVariables.filter(({ scope }) => scope === generated_1.EnvironmentVariableScope.Shared);
28
+ if (linkedVariables.length === 0) {
29
+ throw new Error(`There are no linked shared env variables for project ${projectDisplayName}`);
30
+ }
31
+ if (!name) {
32
+ name = await (0, prompts_1.selectAsync)('Select shared variable to unlink', linkedVariables.map(variable => ({
33
+ title: variable.name,
34
+ value: variable.name,
35
+ })));
36
+ }
37
+ const selectedVariable = linkedVariables.find(variable => variable.name === name);
38
+ if (!selectedVariable) {
39
+ throw new Error(`Shared variable ${name} doesn't exist`);
40
+ }
41
+ const unlinkedVariable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
42
+ if (!unlinkedVariable) {
43
+ throw new Error(`Could not unlink variable with name ${selectedVariable.name} from project ${projectDisplayName}`);
44
+ }
45
+ log_1.default.withTick(`Unlinked variable ${chalk_1.default.bold(unlinkedVariable.name)} from the project ${chalk_1.default.bold(projectDisplayName)}.`);
46
+ }
47
+ }
48
+ _a = EnvironmentVariableUnlink;
49
+ EnvironmentVariableUnlink.description = 'unlink a shared environment variable to the current project';
50
+ EnvironmentVariableUnlink.hidden = true;
51
+ EnvironmentVariableUnlink.flags = {
52
+ name: core_1.Flags.string({
53
+ description: 'Name of the variable',
54
+ }),
55
+ ...flags_1.EASEnvironmentFlag,
56
+ ...flags_1.EASNonInteractiveFlag,
57
+ };
58
+ EnvironmentVariableUnlink.contextDefinition = {
59
+ ..._a.ContextOptions.ProjectConfig,
60
+ ..._a.ContextOptions.LoggedIn,
61
+ };
62
+ exports.default = EnvironmentVariableUnlink;