eas-cli 12.5.0 → 12.5.2

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 (76) hide show
  1. package/README.md +72 -64
  2. package/build/build/build.js +4 -4
  3. package/build/build/evaluateConfigWithEnvVarsAsync.d.ts +1 -4
  4. package/build/build/evaluateConfigWithEnvVarsAsync.js +3 -6
  5. package/build/build/runBuildAndSubmit.d.ts +0 -2
  6. package/build/build/runBuildAndSubmit.js +0 -1
  7. package/build/commandUtils/flags.d.ts +9 -2
  8. package/build/commandUtils/flags.js +14 -21
  9. package/build/commands/build/index.d.ts +0 -2
  10. package/build/commands/build/index.js +0 -2
  11. package/build/commands/build/resign.d.ts +0 -1
  12. package/build/commands/build/resign.js +0 -2
  13. package/build/commands/build/version/get.d.ts +0 -1
  14. package/build/commands/build/version/get.js +0 -2
  15. package/build/commands/build/version/set.d.ts +0 -1
  16. package/build/commands/build/version/set.js +0 -3
  17. package/build/commands/build/version/sync.d.ts +0 -1
  18. package/build/commands/build/version/sync.js +0 -3
  19. package/build/commands/config.d.ts +0 -1
  20. package/build/commands/config.js +0 -2
  21. package/build/commands/env/create.d.ts +3 -1
  22. package/build/commands/env/create.js +106 -74
  23. package/build/commands/env/delete.d.ts +2 -2
  24. package/build/commands/env/delete.js +37 -26
  25. package/build/commands/env/exec.d.ts +23 -0
  26. package/build/commands/env/exec.js +125 -0
  27. package/build/commands/env/get.d.ts +2 -2
  28. package/build/commands/env/get.js +40 -26
  29. package/build/commands/env/link.d.ts +4 -2
  30. package/build/commands/env/link.js +53 -14
  31. package/build/commands/env/list.d.ts +1 -2
  32. package/build/commands/env/list.js +49 -42
  33. package/build/commands/env/pull.js +1 -1
  34. package/build/commands/env/unlink.d.ts +3 -2
  35. package/build/commands/env/unlink.js +48 -21
  36. package/build/commands/env/update.d.ts +4 -2
  37. package/build/commands/env/update.js +68 -66
  38. package/build/commands/update/index.js +0 -1
  39. package/build/commands/update/republish.d.ts +2 -0
  40. package/build/commands/update/republish.js +34 -4
  41. package/build/commands/worker/deploy.js +44 -21
  42. package/build/credentials/manager/Actions.d.ts +4 -2
  43. package/build/credentials/manager/Actions.js +2 -0
  44. package/build/credentials/manager/AndroidActions.js +5 -0
  45. package/build/credentials/manager/IosActions.js +5 -0
  46. package/build/credentials/manager/ManageAndroid.js +3 -0
  47. package/build/credentials/manager/ManageIos.js +3 -0
  48. package/build/graphql/generated.d.ts +103 -22
  49. package/build/graphql/mutations/EnvironmentVariableMutation.d.ts +13 -22
  50. package/build/graphql/mutations/EnvironmentVariableMutation.js +18 -2
  51. package/build/graphql/queries/EnvironmentVariablesQuery.d.ts +13 -7
  52. package/build/graphql/queries/EnvironmentVariablesQuery.js +21 -9
  53. package/build/graphql/types/EnvironmentVariable.js +2 -1
  54. package/build/graphql/types/Submission.js +1 -1
  55. package/build/project/publish.js +3 -2
  56. package/build/submit/utils/logs.js +16 -17
  57. package/build/update/getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync.d.ts +5 -0
  58. package/build/update/{getBranchNameFromChannelNameAsync.js → getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync.js} +8 -7
  59. package/build/update/republish.js +3 -2
  60. package/build/utils/prompts.d.ts +15 -3
  61. package/build/utils/prompts.js +33 -8
  62. package/build/utils/variableUtils.d.ts +4 -0
  63. package/build/utils/variableUtils.js +31 -0
  64. package/build/worker/assets.d.ts +7 -2
  65. package/build/worker/assets.js +5 -4
  66. package/build/worker/deployment.d.ts +10 -0
  67. package/build/worker/deployment.js +33 -22
  68. package/build/worker/upload.d.ts +1 -0
  69. package/build/worker/upload.js +29 -7
  70. package/build/worker/utils/logs.d.ts +14 -13
  71. package/build/worker/utils/logs.js +18 -18
  72. package/oclif.manifest.json +118 -108
  73. package/package.json +3 -3
  74. package/build/update/getBranchNameFromChannelNameAsync.d.ts +0 -2
  75. package/build/utils/formatVariable.d.ts +0 -2
  76. package/build/utils/formatVariable.js +0 -16
@@ -4,7 +4,6 @@ import { LocalBuildOptions } from './local';
4
4
  import { Analytics } from '../analytics/AnalyticsManager';
5
5
  import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
6
6
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
7
- import { EnvironmentVariableEnvironment } from '../graphql/generated';
8
7
  import { RequestedPlatform } from '../platform';
9
8
  import { Actor } from '../user/User';
10
9
  import { Client } from '../vcs/vcs';
@@ -23,7 +22,6 @@ export interface BuildFlags {
23
22
  buildLoggerLevel?: LoggerLevel;
24
23
  freezeCredentials: boolean;
25
24
  repack: boolean;
26
- environment?: EnvironmentVariableEnvironment;
27
25
  }
28
26
  export declare function runBuildAndSubmitAsync(graphqlClient: ExpoGraphqlClient, analytics: Analytics, vcsClient: Client, projectDir: string, flags: BuildFlags, actor: Actor, getDynamicPrivateProjectConfigAsync: DynamicConfigContextFn): Promise<{
29
27
  buildIds: string[];
@@ -98,7 +98,6 @@ async function runBuildAndSubmitAsync(graphqlClient, analytics, vcsClient, proje
98
98
  for (const buildProfile of buildProfiles) {
99
99
  const platform = (0, AppPlatform_1.toAppPlatform)(buildProfile.platform);
100
100
  const { env } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
101
- flags,
102
101
  buildProfile: buildProfile.profile,
103
102
  buildProfileName: buildProfile.profileName,
104
103
  graphqlClient,
@@ -1,13 +1,19 @@
1
1
  import { EnvironmentVariableEnvironment, EnvironmentVariableScope, EnvironmentVariableVisibility } from '../graphql/generated';
2
+ declare function upperCaseAsync<T>(input: string): Promise<T>;
2
3
  export declare const EasNonInteractiveAndJsonFlags: {
3
4
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
4
5
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
5
6
  };
7
+ export declare const EasEnvironmentFlagParameters: {
8
+ description: string;
9
+ parse: typeof upperCaseAsync;
10
+ options: EnvironmentVariableEnvironment[];
11
+ };
6
12
  export declare const EASEnvironmentFlag: {
7
13
  environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
8
14
  };
9
- export declare const EASEnvironmentFlagHidden: {
10
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
15
+ export declare const EASMultiEnvironmentFlag: {
16
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment[] | undefined>;
11
17
  };
12
18
  export declare const EASVariableFormatFlag: {
13
19
  format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
@@ -24,3 +30,4 @@ export declare const EASNonInteractiveFlag: {
24
30
  export declare const EasJsonOnlyFlag: {
25
31
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
32
  };
33
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EasJsonOnlyFlag = exports.EASNonInteractiveFlag = exports.EASVariableScopeFlag = exports.EASVariableVisibilityFlag = exports.EASVariableFormatFlag = exports.EASEnvironmentFlagHidden = exports.EASEnvironmentFlag = exports.EasNonInteractiveAndJsonFlags = void 0;
3
+ exports.EasJsonOnlyFlag = exports.EASNonInteractiveFlag = exports.EASVariableScopeFlag = exports.EASVariableVisibilityFlag = exports.EASVariableFormatFlag = exports.EASMultiEnvironmentFlag = exports.EASEnvironmentFlag = exports.EasEnvironmentFlagParameters = exports.EasNonInteractiveAndJsonFlags = void 0;
4
4
  const core_1 = require("@oclif/core");
5
5
  const generated_1 = require("../graphql/generated");
6
6
  // NOTE: not exactly true, but, provided mapToLowercase and upperCaseAsync
@@ -20,29 +20,22 @@ exports.EasNonInteractiveAndJsonFlags = {
20
20
  description: 'Run the command in non-interactive mode.',
21
21
  }),
22
22
  };
23
+ exports.EasEnvironmentFlagParameters = {
24
+ description: "Environment variable's environment",
25
+ parse: upperCaseAsync,
26
+ options: mapToLowercase([
27
+ generated_1.EnvironmentVariableEnvironment.Development,
28
+ generated_1.EnvironmentVariableEnvironment.Preview,
29
+ generated_1.EnvironmentVariableEnvironment.Production,
30
+ ]),
31
+ };
23
32
  exports.EASEnvironmentFlag = {
24
- environment: core_1.Flags.enum({
25
- description: "Environment variable's environment",
26
- parse: upperCaseAsync,
27
- options: mapToLowercase([
28
- generated_1.EnvironmentVariableEnvironment.Development,
29
- generated_1.EnvironmentVariableEnvironment.Preview,
30
- generated_1.EnvironmentVariableEnvironment.Production,
31
- ]),
32
- }),
33
+ environment: core_1.Flags.enum(exports.EasEnvironmentFlagParameters),
33
34
  };
34
- // NOTE: Used in build commands, should be replaced with EASEnvironmentFlag when
35
- // the feature is public
36
- exports.EASEnvironmentFlagHidden = {
35
+ exports.EASMultiEnvironmentFlag = {
37
36
  environment: core_1.Flags.enum({
38
- description: "Environment variable's environment",
39
- parse: upperCaseAsync,
40
- hidden: true,
41
- options: mapToLowercase([
42
- generated_1.EnvironmentVariableEnvironment.Development,
43
- generated_1.EnvironmentVariableEnvironment.Preview,
44
- generated_1.EnvironmentVariableEnvironment.Production,
45
- ]),
37
+ ...exports.EasEnvironmentFlagParameters,
38
+ multiple: true,
46
39
  }),
47
40
  };
48
41
  exports.EASVariableFormatFlag = {
@@ -1,11 +1,9 @@
1
1
  import { ResourceClass } from '@expo/eas-json';
2
2
  import { LoggerLevel } from '@expo/logger';
3
3
  import EasCommand from '../../commandUtils/EasCommand';
4
- import { EnvironmentVariableEnvironment } from '../../graphql/generated';
5
4
  export default class Build extends EasCommand {
6
5
  static description: string;
7
6
  static flags: {
8
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
9
7
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
8
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
9
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
@@ -90,7 +90,6 @@ class Build extends EasCommand_1.default {
90
90
  buildLoggerLevel: flags['build-logger-level'],
91
91
  freezeCredentials: flags['freeze-credentials'],
92
92
  repack: flags.repack,
93
- environment: flags.environment,
94
93
  };
95
94
  }
96
95
  async ensurePlatformSelectedAsync(flags) {
@@ -193,7 +192,6 @@ Build.flags = {
193
192
  description: 'Use the golden dev client build repack flow as it works for onboarding',
194
193
  }),
195
194
  ...flags_1.EasNonInteractiveAndJsonFlags,
196
- ...flags_1.EASEnvironmentFlagHidden,
197
195
  };
198
196
  Build.contextDefinition = {
199
197
  ..._a.ContextOptions.LoggedIn,
@@ -29,7 +29,6 @@ interface RawBuildResignFlags {
29
29
  export default class BuildResign extends EasCommand {
30
30
  static description: string;
31
31
  static flags: {
32
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
33
32
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
34
33
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
35
34
  offset: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
@@ -54,7 +54,6 @@ class BuildResign extends EasCommand_1.default {
54
54
  const easJsonCliConfig = (await eas_json_1.EasJsonUtils.getCliConfigAsync(easJsonAccessor)) ?? {};
55
55
  const buildProfile = await eas_json_1.EasJsonUtils.getBuildProfileAsync(easJsonAccessor, platform, flags.targetProfile ?? 'production');
56
56
  const { exp, projectId, env } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
57
- flags,
58
57
  buildProfile,
59
58
  buildProfileName: flags.targetProfile ?? 'production',
60
59
  graphqlClient,
@@ -224,7 +223,6 @@ BuildResign.flags = {
224
223
  }),
225
224
  ...pagination_1.EasPaginatedQueryFlags,
226
225
  ...flags_1.EasNonInteractiveAndJsonFlags,
227
- ...flags_1.EASEnvironmentFlagHidden,
228
226
  };
229
227
  BuildResign.contextDefinition = {
230
228
  ..._a.ContextOptions.LoggedIn,
@@ -4,7 +4,6 @@ export default class BuildVersionGetView extends EasCommand {
4
4
  static flags: {
5
5
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
6
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
- environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../../../graphql/generated").EnvironmentVariableEnvironment | undefined>;
8
7
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
8
  profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
9
  };
@@ -44,7 +44,6 @@ class BuildVersionGetView extends EasCommand_1.default {
44
44
  const results = {};
45
45
  for (const { profile, platform } of buildProfiles) {
46
46
  const { exp, projectId, env } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
47
- flags,
48
47
  buildProfile: profile,
49
48
  buildProfileName: flags.profile ?? 'production',
50
49
  graphqlClient,
@@ -104,7 +103,6 @@ BuildVersionGetView.flags = {
104
103
  description: 'Name of the build profile from eas.json. Defaults to "production" if defined in eas.json.',
105
104
  helpValue: 'PROFILE_NAME',
106
105
  }),
107
- ...flags_1.EASEnvironmentFlagHidden,
108
106
  ...flags_1.EasNonInteractiveAndJsonFlags,
109
107
  };
110
108
  BuildVersionGetView.contextDefinition = {
@@ -2,7 +2,6 @@ import EasCommand from '../../../commandUtils/EasCommand';
2
2
  export default class BuildVersionSetView extends EasCommand {
3
3
  static description: string;
4
4
  static flags: {
5
- environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../../../graphql/generated").EnvironmentVariableEnvironment | undefined>;
6
5
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
6
  profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
7
  };
@@ -9,7 +9,6 @@ const core_1 = require("@oclif/core");
9
9
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
10
  const evaluateConfigWithEnvVarsAsync_1 = require("../../../build/evaluateConfigWithEnvVarsAsync");
11
11
  const EasCommand_1 = tslib_1.__importDefault(require("../../../commandUtils/EasCommand"));
12
- const flags_1 = require("../../../commandUtils/flags");
13
12
  const AppVersionMutation_1 = require("../../../graphql/mutations/AppVersionMutation");
14
13
  const AppVersionQuery_1 = require("../../../graphql/queries/AppVersionQuery");
15
14
  const AppPlatform_1 = require("../../../graphql/types/AppPlatform");
@@ -32,7 +31,6 @@ class BuildVersionSetView extends EasCommand_1.default {
32
31
  await (0, remoteVersionSource_1.ensureVersionSourceIsRemoteAsync)(easJsonAccessor, { nonInteractive: false });
33
32
  const profile = await eas_json_1.EasJsonUtils.getBuildProfileAsync(easJsonAccessor, platform, flags.profile ?? undefined);
34
33
  const { exp, projectId, env } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
35
- flags,
36
34
  buildProfile: profile,
37
35
  buildProfileName: flags.profile ?? 'production',
38
36
  graphqlClient,
@@ -90,7 +88,6 @@ BuildVersionSetView.flags = {
90
88
  description: 'Name of the build profile from eas.json. Defaults to "production" if defined in eas.json.',
91
89
  helpValue: 'PROFILE_NAME',
92
90
  }),
93
- ...flags_1.EASEnvironmentFlagHidden,
94
91
  };
95
92
  BuildVersionSetView.contextDefinition = {
96
93
  ..._a.ContextOptions.LoggedIn,
@@ -2,7 +2,6 @@ import EasCommand from '../../../commandUtils/EasCommand';
2
2
  export default class BuildVersionSyncView extends EasCommand {
3
3
  static description: string;
4
4
  static flags: {
5
- environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../../../graphql/generated").EnvironmentVariableEnvironment | undefined>;
6
5
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
6
  profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
7
  };
@@ -10,7 +10,6 @@ const version_1 = require("../../../build/android/version");
10
10
  const evaluateConfigWithEnvVarsAsync_1 = require("../../../build/evaluateConfigWithEnvVarsAsync");
11
11
  const version_2 = require("../../../build/ios/version");
12
12
  const EasCommand_1 = tslib_1.__importDefault(require("../../../commandUtils/EasCommand"));
13
- const flags_1 = require("../../../commandUtils/flags");
14
13
  const AppVersionQuery_1 = require("../../../graphql/queries/AppVersionQuery");
15
14
  const AppPlatform_1 = require("../../../graphql/types/AppPlatform");
16
15
  const log_1 = tslib_1.__importDefault(require("../../../log"));
@@ -43,7 +42,6 @@ class BuildVersionSyncView extends EasCommand_1.default {
43
42
  });
44
43
  for (const profileInfo of buildProfiles) {
45
44
  const { exp, projectId, env } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
46
- flags,
47
45
  buildProfile: profileInfo.profile,
48
46
  buildProfileName: profileInfo.profileName,
49
47
  graphqlClient,
@@ -142,7 +140,6 @@ BuildVersionSyncView.flags = {
142
140
  description: 'Name of the build profile from eas.json. Defaults to "production" if defined in eas.json.',
143
141
  helpValue: 'PROFILE_NAME',
144
142
  }),
145
- ...flags_1.EASEnvironmentFlagHidden,
146
143
  };
147
144
  BuildVersionSyncView.contextDefinition = {
148
145
  ..._a.ContextOptions.LoggedIn,
@@ -5,7 +5,6 @@ export default class Config extends EasCommand {
5
5
  static flags: {
6
6
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
7
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
- environment: import("@oclif/core/lib/interfaces").OptionFlag<import("../graphql/generated").EnvironmentVariableEnvironment | undefined>;
9
8
  platform: import("@oclif/core/lib/interfaces").OptionFlag<Platform | undefined>;
10
9
  profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
10
  'eas-json-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -62,7 +62,6 @@ class Config extends EasCommand_1.default {
62
62
  });
63
63
  const graphqlClient = (0, createGraphqlClient_1.createGraphqlClient)(authenticationInfo);
64
64
  const { exp: appConfig } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
65
- flags,
66
65
  buildProfile: profile,
67
66
  buildProfileName: profileName,
68
67
  graphqlClient,
@@ -101,7 +100,6 @@ Config.flags = {
101
100
  'eas-json-only': core_1.Flags.boolean({
102
101
  hidden: true,
103
102
  }),
104
- ...flags_1.EASEnvironmentFlagHidden,
105
103
  ...flags_1.EasNonInteractiveAndJsonFlags,
106
104
  };
107
105
  Config.contextDefinition = {
@@ -5,7 +5,7 @@ export default class EnvironmentVariableCreate extends EasCommand {
5
5
  static hidden: boolean;
6
6
  static flags: {
7
7
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
8
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment[] | undefined>;
9
9
  scope: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableScope>;
10
10
  visibility: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableVisibility | undefined>;
11
11
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
@@ -19,5 +19,7 @@ export default class EnvironmentVariableCreate extends EasCommand {
19
19
  privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
20
20
  };
21
21
  runAsync(): Promise<void>;
22
+ private promptForOverwriteAsync;
23
+ private promptForMissingFlagsAsync;
22
24
  private validateFlags;
23
25
  }
@@ -13,10 +13,12 @@ const log_1 = tslib_1.__importDefault(require("../../log"));
13
13
  const projectUtils_1 = require("../../project/projectUtils");
14
14
  const prompts_1 = require("../../prompts");
15
15
  const prompts_2 = require("../../utils/prompts");
16
+ const variableUtils_1 = require("../../utils/variableUtils");
16
17
  class EnvironmentVariableCreate extends EasCommand_1.default {
17
18
  async runAsync() {
18
19
  const { flags } = await this.parse(_a);
19
- let { name, value, scope, 'non-interactive': nonInteractive, environment, visibility, link, force, } = this.validateFlags(flags);
20
+ const validatedFlags = this.validateFlags(flags);
21
+ const { name, value, scope, 'non-interactive': nonInteractive, environment: environments, visibility, link, force, } = await this.promptForMissingFlagsAsync(validatedFlags);
20
22
  const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
21
23
  nonInteractive,
22
24
  });
@@ -24,108 +26,138 @@ class EnvironmentVariableCreate extends EasCommand_1.default {
24
26
  (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId),
25
27
  (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId),
26
28
  ]);
27
- if (!name) {
28
- name = await (0, prompts_2.promptVariableNameAsync)(nonInteractive);
29
- }
30
29
  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
30
  if (scope === generated_1.EnvironmentVariableScope.Project) {
39
- if (!environment) {
40
- environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
41
- }
42
31
  const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
43
32
  appId: projectId,
44
- environment,
33
+ filterNames: [name],
45
34
  });
46
- const existingVariable = existingVariables.find(variable => variable.name === name);
35
+ const existingVariable = existingVariables.find(variable => !environments || variable.environments?.some(env => environments?.includes(env)));
47
36
  if (existingVariable) {
37
+ if (existingVariable.scope === generated_1.EnvironmentVariableScope.Project) {
38
+ await this.promptForOverwriteAsync({
39
+ nonInteractive,
40
+ force,
41
+ message: `Variable ${name} already exists on this project.`,
42
+ suggestion: 'Do you want to overwrite it?',
43
+ });
44
+ overwrite = true;
45
+ }
48
46
  if (existingVariable.scope === generated_1.EnvironmentVariableScope.Shared) {
49
- if (!nonInteractive) {
50
- const confirmation = await (0, prompts_1.confirmAsync)({
51
- message: `Shared variable ${name} already exists on this project. Do you want to unlink it first?`,
52
- });
53
- if (!confirmation) {
54
- log_1.default.log('Aborting');
55
- throw new Error(`Shared variable ${name} already exists on this project.`);
56
- }
57
- }
58
- else if (!force) {
59
- throw new Error(`Shared variable ${name} already exists on this project. Use --force to overwrite it.`);
60
- }
61
- await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, existingVariable.id, projectId, environment);
47
+ await this.promptForOverwriteAsync({
48
+ nonInteractive,
49
+ force,
50
+ message: `Shared variable with ${name} name already exists on this account.`,
51
+ suggestion: 'Do you want to unlink it first?',
52
+ });
62
53
  log_1.default.withTick(`Unlinking shared variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
63
- }
64
- else {
65
- if (!nonInteractive) {
66
- const confirmation = await (0, prompts_1.confirmAsync)({
67
- message: `Variable ${name} already exists on this project. Do you want to overwrite it?`,
68
- });
69
- if (!confirmation) {
70
- log_1.default.log('Aborting');
71
- throw new Error(`Variable ${name} already exists on this project. Use --force to overwrite it.`);
72
- }
73
- }
74
- else if (!force) {
75
- throw new Error(`Variable ${name} already exists on this project. Use --force to overwrite it.`);
76
- }
77
- overwrite = true;
54
+ await (0, variableUtils_1.performForEnvironmentsAsync)(environments, async (environment) => {
55
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, existingVariable.id, projectId, environment);
56
+ });
78
57
  }
79
58
  }
80
- const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createForAppAsync(graphqlClient, {
81
- name,
82
- value,
83
- environment,
84
- visibility,
85
- overwrite,
86
- }, projectId);
59
+ const variable = overwrite && existingVariable
60
+ ? await EnvironmentVariableMutation_1.EnvironmentVariableMutation.updateAsync(graphqlClient, {
61
+ id: existingVariable.id,
62
+ name,
63
+ value,
64
+ visibility,
65
+ environments,
66
+ })
67
+ : await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createForAppAsync(graphqlClient, {
68
+ name,
69
+ value,
70
+ environments,
71
+ visibility,
72
+ type: generated_1.EnvironmentSecretType.String,
73
+ }, projectId);
87
74
  if (!variable) {
88
75
  throw new Error(`Could not create variable with name ${name} on project ${projectDisplayName}`);
89
76
  }
90
77
  log_1.default.withTick(`Created a new variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
91
78
  }
92
79
  else if (scope === generated_1.EnvironmentVariableScope.Shared) {
93
- const sharedVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
80
+ const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
94
81
  appId: projectId,
82
+ filterNames: [name],
95
83
  });
96
- const existingVariable = sharedVariables.find(variable => variable.name === name);
84
+ const existingVariable = existingVariables.find(variable => !environments || variable.environments?.some(env => environments?.includes(env)));
97
85
  if (existingVariable) {
98
- throw new Error(`Shared variable with ${name} name already exists on this account.\n` +
99
- `Use a different name or delete the existing variable on website or by using eas env:delete --name ${name} --scope shared command.`);
100
- }
101
- if (environment && !link) {
102
- const confirmation = await (0, prompts_1.confirmAsync)({
103
- message: `Unexpected argument: --environment can only be used with --link flag. Do you want to link the variable to the current project?`,
104
- });
105
- if (!confirmation) {
106
- log_1.default.log('Aborting');
107
- throw new Error('Unexpected argument: --environment can only be used with --link flag.');
86
+ if (force) {
87
+ overwrite = true;
88
+ }
89
+ else {
90
+ throw new Error(`Shared variable with ${name} name already exists on this account.\n` +
91
+ `Use a different name or delete the existing variable on website or by using eas env:delete --name ${name} --scope shared command.`);
108
92
  }
109
93
  }
110
- if (!environment && link) {
111
- environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
112
- }
113
- const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createSharedVariableAsync(graphqlClient, {
114
- name,
115
- value,
116
- visibility,
117
- }, ownerAccount.id);
94
+ const variable = overwrite && existingVariable
95
+ ? await EnvironmentVariableMutation_1.EnvironmentVariableMutation.updateAsync(graphqlClient, {
96
+ id: existingVariable.id,
97
+ name,
98
+ value,
99
+ visibility,
100
+ environments,
101
+ })
102
+ : await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createSharedVariableAsync(graphqlClient, {
103
+ name,
104
+ value,
105
+ visibility,
106
+ environments,
107
+ type: generated_1.EnvironmentSecretType.String,
108
+ }, ownerAccount.id);
118
109
  if (!variable) {
119
110
  throw new Error(`Could not create variable with name ${name} on account ${ownerAccount.name}`);
120
111
  }
121
112
  log_1.default.withTick(`Created a new variable ${chalk_1.default.bold(name)} on account ${chalk_1.default.bold(ownerAccount.name)}.`);
122
- if (link && environment) {
113
+ if (link) {
123
114
  log_1.default.withTick(`Linking shared variable ${chalk_1.default.bold(name)} to project ${chalk_1.default.bold(projectDisplayName)}.`);
124
- await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, variable.id, projectId, environment);
115
+ await (0, variableUtils_1.performForEnvironmentsAsync)(environments, async (environment) => {
116
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, variable.id, projectId, environment);
117
+ });
125
118
  log_1.default.withTick(`Linked shared variable ${chalk_1.default.bold(name)} to project ${chalk_1.default.bold(projectDisplayName)}.`);
126
119
  }
127
120
  }
128
121
  }
122
+ async promptForOverwriteAsync({ nonInteractive, force, message, suggestion, }) {
123
+ if (!nonInteractive) {
124
+ const confirmation = await (0, prompts_1.confirmAsync)({
125
+ message: `${message} ${suggestion}`,
126
+ });
127
+ if (!confirmation) {
128
+ log_1.default.log('Aborting');
129
+ throw new Error(`${message}`);
130
+ }
131
+ }
132
+ else if (!force) {
133
+ throw new Error(`${message} Use --force to overwrite it.`);
134
+ }
135
+ }
136
+ async promptForMissingFlagsAsync({ name, value, environment, visibility = generated_1.EnvironmentVariableVisibility.Public, 'non-interactive': nonInteractive, ...rest }) {
137
+ if (!name) {
138
+ name = await (0, prompts_2.promptVariableNameAsync)(nonInteractive);
139
+ }
140
+ if (!value) {
141
+ value = await (0, prompts_2.promptVariableValueAsync)({
142
+ nonInteractive,
143
+ hidden: visibility !== generated_1.EnvironmentVariableVisibility.Public,
144
+ });
145
+ }
146
+ if (!environment) {
147
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)({ nonInteractive, multiple: true });
148
+ }
149
+ return {
150
+ name,
151
+ value,
152
+ environment,
153
+ visibility,
154
+ link: rest.link ?? false,
155
+ force: rest.force ?? false,
156
+ scope: rest.scope ?? generated_1.EnvironmentVariableScope.Project,
157
+ 'non-interactive': nonInteractive,
158
+ ...rest,
159
+ };
160
+ }
129
161
  validateFlags(flags) {
130
162
  if (flags.scope !== generated_1.EnvironmentVariableScope.Shared && flags.link) {
131
163
  throw new Error(`Unexpected argument: --link can only be used when creating shared variables`);
@@ -158,7 +190,7 @@ EnvironmentVariableCreate.flags = {
158
190
  }),
159
191
  ...flags_1.EASVariableVisibilityFlag,
160
192
  ...flags_1.EASVariableScopeFlag,
161
- ...flags_1.EASEnvironmentFlag,
193
+ ...flags_1.EASMultiEnvironmentFlag,
162
194
  ...flags_1.EASNonInteractiveFlag,
163
195
  };
164
196
  EnvironmentVariableCreate.contextDefinition = {
@@ -5,9 +5,9 @@ export default class EnvironmentVariableDelete extends EasCommand {
5
5
  static hidden: boolean;
6
6
  static flags: {
7
7
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
9
8
  scope: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableScope>;
10
- name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ 'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
+ 'variable-environment': import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
11
11
  };
12
12
  static contextDefinition: {
13
13
  loggedIn: import("../../commandUtils/context/LoggedInContextField").default;