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
@@ -9,58 +9,65 @@ const flags_1 = require("../../commandUtils/flags");
9
9
  const generated_1 = require("../../graphql/generated");
10
10
  const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
11
11
  const log_1 = tslib_1.__importDefault(require("../../log"));
12
- const formatVariable_1 = require("../../utils/formatVariable");
13
12
  const prompts_1 = require("../../utils/prompts");
13
+ const variableUtils_1 = require("../../utils/variableUtils");
14
+ async function getVariablesForScopeAsync(graphqlClient, { scope, includingSensitive, environment, projectId, }) {
15
+ if (scope === generated_1.EnvironmentVariableScope.Project) {
16
+ if (includingSensitive) {
17
+ return await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdWithSensitiveAsync(graphqlClient, {
18
+ appId: projectId,
19
+ environment,
20
+ });
21
+ }
22
+ return await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
23
+ appId: projectId,
24
+ environment,
25
+ });
26
+ }
27
+ return includingSensitive
28
+ ? await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedWithSensitiveAsync(graphqlClient, {
29
+ appId: projectId,
30
+ environment,
31
+ })
32
+ : await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, { appId: projectId, environment });
33
+ }
14
34
  class EnvironmentValueList extends EasCommand_1.default {
15
35
  async runAsync() {
16
- let { flags: { environment, format, scope, 'include-sensitive': includeSensitive }, } = await this.parse(_a);
36
+ let { flags: { environment: environments, format, scope, 'include-sensitive': includeSensitive, 'non-interactive': nonInteractive, }, } = await this.parse(_a);
17
37
  const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
18
38
  nonInteractive: true,
19
39
  });
20
- if (scope === generated_1.EnvironmentVariableScope.Project && !environment) {
21
- environment = await (0, prompts_1.promptVariableEnvironmentAsync)(false);
40
+ if (!environments) {
41
+ environments = await (0, prompts_1.promptVariableEnvironmentAsync)({ nonInteractive, multiple: true });
22
42
  }
23
- const variables = await this.getVariablesForScopeAsync(graphqlClient, {
24
- scope,
25
- includingSensitive: includeSensitive,
26
- environment,
27
- projectId,
28
- });
29
- if (format === 'short') {
30
- for (const variable of variables) {
31
- // TODO: Add Learn more link
32
- log_1.default.log(`${chalk_1.default.bold(variable.name)}=${variable.value ??
33
- "***** (This is a secret env variable that can only be accessed on EAS builder and can't be read in any UI. Learn more.)"}`);
43
+ await (0, variableUtils_1.performForEnvironmentsAsync)(environments, async (environment) => {
44
+ const variables = await getVariablesForScopeAsync(graphqlClient, {
45
+ scope,
46
+ includingSensitive: includeSensitive,
47
+ environment,
48
+ projectId,
49
+ });
50
+ log_1.default.addNewLineIfNone();
51
+ if (environment) {
52
+ log_1.default.log(chalk_1.default.bold(`Environment: ${environment}`));
34
53
  }
35
- }
36
- else {
37
- if (scope === generated_1.EnvironmentVariableScope.Shared) {
38
- log_1.default.log(chalk_1.default.bold('Shared variables for this account:'));
54
+ if (format === 'short') {
55
+ for (const variable of variables) {
56
+ // TODO: Add Learn more link
57
+ log_1.default.log(`${chalk_1.default.bold(variable.name)}=${variable.value ??
58
+ "***** (This is a secret env variable that can only be accessed on EAS builder and can't be read in any UI. Learn more.)"}`);
59
+ }
39
60
  }
40
61
  else {
41
- log_1.default.log(chalk_1.default.bold(`Variables for this project for environment ${environment}:`));
42
- }
43
- log_1.default.log(variables.map(variable => (0, formatVariable_1.formatVariable)(variable)).join(`\n\n${chalk_1.default.dim('———')}\n\n`));
44
- }
45
- }
46
- async getVariablesForScopeAsync(graphqlClient, { scope, includingSensitive, environment, projectId, }) {
47
- if (scope === generated_1.EnvironmentVariableScope.Project && environment) {
48
- if (includingSensitive) {
49
- return await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdWithSensitiveAsync(graphqlClient, {
50
- appId: projectId,
51
- environment,
52
- });
62
+ if (scope === generated_1.EnvironmentVariableScope.Shared) {
63
+ log_1.default.log(chalk_1.default.bold('Shared variables for this account:'));
64
+ }
65
+ else {
66
+ log_1.default.log(chalk_1.default.bold(`Variables for this project:`));
67
+ }
68
+ log_1.default.log(variables.map(variable => (0, variableUtils_1.formatVariable)(variable)).join(`\n\n${chalk_1.default.dim('———')}\n\n`));
53
69
  }
54
- return await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
55
- appId: projectId,
56
- environment,
57
- });
58
- }
59
- return includingSensitive
60
- ? await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedWithSensitiveAsync(graphqlClient, {
61
- appId: projectId,
62
- })
63
- : await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, { appId: projectId });
70
+ });
64
71
  }
65
72
  }
66
73
  _a = EnvironmentValueList;
@@ -77,6 +84,6 @@ EnvironmentValueList.flags = {
77
84
  }),
78
85
  ...flags_1.EASVariableFormatFlag,
79
86
  ...flags_1.EASVariableScopeFlag,
80
- ...flags_1.EASEnvironmentFlag,
87
+ ...flags_1.EASMultiEnvironmentFlag,
81
88
  };
82
89
  exports.default = EnvironmentValueList;
@@ -14,7 +14,7 @@ class EnvironmentVariablePull extends EasCommand_1.default {
14
14
  async runAsync() {
15
15
  let { flags: { environment, path: targetPath, 'non-interactive': nonInteractive }, } = await this.parse(_a);
16
16
  if (!environment) {
17
- environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
17
+ environment = await (0, prompts_2.promptVariableEnvironmentAsync)({ nonInteractive });
18
18
  }
19
19
  const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
20
20
  nonInteractive,
@@ -1,11 +1,12 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
+ import { EnvironmentVariableEnvironment } from '../../graphql/generated';
2
3
  export default class EnvironmentVariableUnlink extends EasCommand {
3
4
  static description: string;
4
5
  static hidden: boolean;
5
6
  static flags: {
6
7
  '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>;
8
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment[] | undefined>;
9
+ 'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
10
  };
10
11
  static contextDefinition: {
11
12
  loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
@@ -13,49 +13,76 @@ 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 EnvironmentVariableUnlink extends EasCommand_1.default {
17
18
  async runAsync() {
18
- let { flags: { name, 'non-interactive': nonInteractive, environment }, } = await this.parse(_a);
19
+ let { flags: { 'variable-name': name, 'non-interactive': nonInteractive, environment: unlinkEnvironments, }, } = await this.parse(_a);
19
20
  const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
20
21
  nonInteractive,
21
22
  });
22
- if (!environment) {
23
- environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
24
- }
25
23
  const projectDisplayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
26
- const appVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
24
+ const variables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
27
25
  appId: projectId,
28
- environment,
26
+ filterNames: name ? [name] : undefined,
29
27
  });
30
- const linkedVariables = appVariables.filter(({ scope }) => scope === generated_1.EnvironmentVariableScope.Shared);
31
- if (linkedVariables.length === 0) {
32
- throw new Error(`There are no linked shared env variables for project ${projectDisplayName}`);
33
- }
34
- if (!name) {
35
- name = await (0, prompts_1.selectAsync)('Select shared variable to unlink', linkedVariables.map(variable => ({
36
- title: variable.name,
37
- value: variable.name,
28
+ let selectedVariable = variables[0];
29
+ if (variables.length > 1) {
30
+ if (nonInteractive) {
31
+ throw new Error("Multiple variables found, please select one using '--variable-name'");
32
+ }
33
+ selectedVariable = await (0, prompts_1.selectAsync)('Select shared variable', variables.map(variable => ({
34
+ title: (0, variableUtils_1.formatVariableName)(variable),
35
+ value: variable,
38
36
  })));
39
37
  }
40
- const selectedVariable = linkedVariables.find(variable => variable.name === name);
41
38
  if (!selectedVariable) {
42
39
  throw new Error(`Shared variable ${name} doesn't exist`);
43
40
  }
44
- const unlinkedVariable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
45
- if (!unlinkedVariable) {
46
- throw new Error(`Could not unlink variable with name ${selectedVariable.name} from project ${projectDisplayName}`);
41
+ let explicitSelect = false;
42
+ if (!nonInteractive && !unlinkEnvironments) {
43
+ const selectedEnvironments = (selectedVariable.linkedEnvironments ?? []).length > 0
44
+ ? selectedVariable.linkedEnvironments
45
+ : selectedVariable.environments;
46
+ const environments = await (0, prompts_2.promptVariableEnvironmentAsync)({
47
+ nonInteractive,
48
+ multiple: true,
49
+ selectedEnvironments: selectedEnvironments ?? [],
50
+ });
51
+ explicitSelect = true;
52
+ unlinkEnvironments = Object.values(generated_1.EnvironmentVariableEnvironment).filter(env => !environments.includes(env));
53
+ }
54
+ if (!unlinkEnvironments) {
55
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId);
56
+ log_1.default.withTick(`Unlinked variable ${chalk_1.default.bold(selectedVariable.name)} from project ${chalk_1.default.bold(projectDisplayName)} in ${selectedVariable.environments?.join(', ').toLocaleLowerCase()}.`);
57
+ return;
58
+ }
59
+ for (const environment of Object.values(generated_1.EnvironmentVariableEnvironment)) {
60
+ if (selectedVariable.linkedEnvironments?.includes(environment) !==
61
+ unlinkEnvironments.includes(environment)) {
62
+ if (!explicitSelect && unlinkEnvironments.includes(environment)) {
63
+ log_1.default.withTick(`Variable ${chalk_1.default.bold(selectedVariable.name)} is already unlinked from ${environment.toLocaleLowerCase()}.`);
64
+ }
65
+ continue;
66
+ }
67
+ if (unlinkEnvironments.includes(environment)) {
68
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
69
+ log_1.default.withTick(`Unlinked variable ${chalk_1.default.bold(selectedVariable.name)} from project ${chalk_1.default.bold(projectDisplayName)} in ${environment.toLocaleLowerCase()}.`);
70
+ }
71
+ else if (explicitSelect) {
72
+ await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
73
+ log_1.default.withTick(`Linked variable ${chalk_1.default.bold(selectedVariable.name)} to project ${chalk_1.default.bold(projectDisplayName)} in ${environment.toLocaleLowerCase()}.`);
74
+ }
47
75
  }
48
- log_1.default.withTick(`Unlinked variable ${chalk_1.default.bold(unlinkedVariable.name)} from the project ${chalk_1.default.bold(projectDisplayName)}.`);
49
76
  }
50
77
  }
51
78
  _a = EnvironmentVariableUnlink;
52
79
  EnvironmentVariableUnlink.description = 'unlink a shared environment variable to the current project';
53
80
  EnvironmentVariableUnlink.hidden = true;
54
81
  EnvironmentVariableUnlink.flags = {
55
- name: core_1.Flags.string({
82
+ 'variable-name': core_1.Flags.string({
56
83
  description: 'Name of the variable',
57
84
  }),
58
- ...flags_1.EASEnvironmentFlag,
85
+ ...flags_1.EASMultiEnvironmentFlag,
59
86
  ...flags_1.EASNonInteractiveFlag,
60
87
  };
61
88
  EnvironmentVariableUnlink.contextDefinition = {
@@ -1,13 +1,15 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
- import { EnvironmentVariableScope, EnvironmentVariableVisibility } from '../../graphql/generated';
2
+ import { EnvironmentVariableEnvironment, EnvironmentVariableScope, EnvironmentVariableVisibility } from '../../graphql/generated';
3
3
  export default class EnvironmentVariableUpdate extends EasCommand {
4
4
  static description: string;
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<import("../../graphql/generated").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
+ 'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
+ 'variable-environment': import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
11
13
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
14
  value: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
13
15
  };
@@ -3,6 +3,7 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@oclif/core");
6
+ const assert_1 = tslib_1.__importDefault(require("assert"));
6
7
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
8
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
8
9
  const flags_1 = require("../../commandUtils/flags");
@@ -13,10 +14,11 @@ const log_1 = tslib_1.__importDefault(require("../../log"));
13
14
  const projectUtils_1 = require("../../project/projectUtils");
14
15
  const prompts_1 = require("../../prompts");
15
16
  const prompts_2 = require("../../utils/prompts");
17
+ const variableUtils_1 = require("../../utils/variableUtils");
16
18
  class EnvironmentVariableUpdate extends EasCommand_1.default {
17
19
  async runAsync() {
18
20
  const { flags } = await this.parse(_a);
19
- let { name, value, scope, 'non-interactive': nonInteractive, environment, visibility, } = this.validateFlags(flags);
21
+ let { name, value, scope, 'variable-name': currentName, 'variable-environment': currentEnvironment, 'non-interactive': nonInteractive, environment: environments, visibility, } = this.validateFlags(flags);
20
22
  const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
21
23
  nonInteractive,
22
24
  });
@@ -24,89 +26,82 @@ class EnvironmentVariableUpdate extends EasCommand_1.default {
24
26
  (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId),
25
27
  (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId),
26
28
  ]);
29
+ let selectedVariable;
30
+ let existingVariables = [];
31
+ const suffix = scope === generated_1.EnvironmentVariableScope.Project
32
+ ? `on project ${projectDisplayName}`
33
+ : `on account ${ownerAccount.name}`;
27
34
  if (scope === generated_1.EnvironmentVariableScope.Project) {
28
- if (!environment) {
29
- environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
30
- }
31
- const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
35
+ existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
32
36
  appId: projectId,
33
- environment,
37
+ environment: currentEnvironment,
38
+ filterNames: currentName ? [currentName] : undefined,
34
39
  });
35
- if (!name) {
36
- name = await (0, prompts_1.selectAsync)('Select variable', existingVariables.map(variable => ({
37
- title: variable.name,
38
- value: variable.name,
39
- })));
40
- }
41
- const existingVariable = existingVariables.find(variable => variable.name === name);
42
- if (!existingVariable) {
43
- throw new Error(`Variable with name ${name} does not exist on project ${projectDisplayName}`);
44
- }
45
- if (!value) {
46
- value = await (0, prompts_2.promptVariableValueAsync)({
47
- nonInteractive,
48
- required: false,
49
- initial: existingVariable.value,
50
- });
51
- if (!value || value.length === 0) {
52
- value = '';
53
- }
54
- }
55
- const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createForAppAsync(graphqlClient, {
56
- name,
57
- value,
58
- environment,
59
- visibility,
60
- overwrite: true,
61
- }, projectId);
62
- if (!variable) {
63
- throw new Error(`Could not update variable with name ${name} on project ${projectDisplayName}`);
64
- }
65
- log_1.default.withTick(`Updated variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
66
40
  }
67
- else if (scope === generated_1.EnvironmentVariableScope.Shared) {
68
- const sharedVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
41
+ if (scope === generated_1.EnvironmentVariableScope.Shared) {
42
+ existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
69
43
  appId: projectId,
44
+ environment: currentEnvironment,
45
+ filterNames: currentName ? [currentName] : undefined,
70
46
  });
47
+ }
48
+ if (existingVariables.length === 0) {
49
+ throw new Error(`Variable with name ${currentName} ${currentEnvironment ? `in environment ${currentEnvironment}` : ''} does not exist ${suffix}.`);
50
+ }
51
+ else if (existingVariables.length > 1) {
52
+ selectedVariable = await (0, prompts_1.selectAsync)('Select variable', existingVariables.map(variable => ({
53
+ title: (0, variableUtils_1.formatVariableName)(variable),
54
+ value: variable,
55
+ })));
56
+ }
57
+ else {
58
+ selectedVariable = existingVariables[0];
59
+ }
60
+ (0, assert_1.default)(selectedVariable, 'Variable must be selected');
61
+ if (!nonInteractive) {
71
62
  if (!name) {
72
- name = await (0, prompts_1.selectAsync)('Select variable', sharedVariables.map(variable => ({
73
- title: variable.name,
74
- value: variable.name,
75
- })));
76
- }
77
- const existingVariable = sharedVariables.find(variable => variable.name === name);
78
- if (!existingVariable) {
79
- throw new Error("Variable with this name doesn't exist on this account. Use a different name.");
63
+ name = await (0, prompts_2.promptVariableNameAsync)(nonInteractive, selectedVariable.name);
64
+ if (!name || name.length === 0) {
65
+ name = undefined;
66
+ }
80
67
  }
81
68
  if (!value) {
82
69
  value = await (0, prompts_2.promptVariableValueAsync)({
83
70
  nonInteractive,
84
71
  required: false,
85
- initial: existingVariable.value,
72
+ initial: selectedVariable.value,
86
73
  });
87
74
  if (!value || value.length === 0) {
88
- value = '';
75
+ value = undefined;
89
76
  }
90
77
  }
91
- const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createSharedVariableAsync(graphqlClient, {
92
- name,
93
- value,
94
- visibility,
95
- overwrite: true,
96
- }, ownerAccount.id);
97
- if (!variable) {
98
- throw new Error(`Could not update variable with name ${name} on account ${ownerAccount.name}`);
78
+ if (!environments || environments.length === 0) {
79
+ environments = await (0, prompts_2.promptVariableEnvironmentAsync)({
80
+ nonInteractive,
81
+ multiple: true,
82
+ selectedEnvironments: selectedVariable.environments ?? [],
83
+ });
99
84
  }
100
- log_1.default.withTick(`Updated shared variable ${chalk_1.default.bold(name)} on account ${chalk_1.default.bold(ownerAccount.name)}.`);
85
+ if (!visibility) {
86
+ visibility = await (0, prompts_2.promptVariableVisibilityAsync)(nonInteractive, selectedVariable.visibility);
87
+ }
88
+ }
89
+ const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.updateAsync(graphqlClient, {
90
+ id: selectedVariable.id,
91
+ name,
92
+ value,
93
+ environments,
94
+ visibility,
95
+ });
96
+ if (!variable) {
97
+ throw new Error(`Could not update variable with name ${name} ${suffix}`);
101
98
  }
99
+ log_1.default.withTick(`Updated variable ${chalk_1.default.bold(selectedVariable.name)} ${suffix}.`);
102
100
  }
103
101
  validateFlags(flags) {
104
102
  if (flags['non-interactive']) {
105
- if (!flags.name) {
106
- throw new Error('Variable name is required in non-interactive mode. Run the command with --name flag.');
107
- }
108
- if (flags.scope === generated_1.EnvironmentVariableScope.Project && !flags.environment) {
109
- throw new Error('Environment is required when updating project-wide variable in non-interactive mode. Run the command with --environment flag.');
103
+ if (!flags['variable-name']) {
104
+ throw new Error('Current name is required in non-interactive mode. Run the command with --variable-name flag.');
110
105
  }
111
106
  }
112
107
  return flags;
@@ -116,15 +111,22 @@ _a = EnvironmentVariableUpdate;
116
111
  EnvironmentVariableUpdate.description = 'update an environment variable on the current project or owner account';
117
112
  EnvironmentVariableUpdate.hidden = true;
118
113
  EnvironmentVariableUpdate.flags = {
114
+ 'variable-name': core_1.Flags.string({
115
+ description: 'Current name of the variable',
116
+ }),
117
+ 'variable-environment': core_1.Flags.enum({
118
+ ...flags_1.EasEnvironmentFlagParameters,
119
+ description: 'Current environment of the variable to update',
120
+ }),
119
121
  name: core_1.Flags.string({
120
- description: 'Name of the variable',
122
+ description: 'New name of the variable',
121
123
  }),
122
124
  value: core_1.Flags.string({
123
- description: 'Text value or the variable',
125
+ description: 'New value or the variable',
124
126
  }),
125
127
  ...flags_1.EASVariableVisibilityFlag,
126
128
  ...flags_1.EASVariableScopeFlag,
127
- ...flags_1.EASEnvironmentFlag,
129
+ ...flags_1.EASMultiEnvironmentFlag,
128
130
  ...flags_1.EASNonInteractiveFlag,
129
131
  };
130
132
  EnvironmentVariableUpdate.contextDefinition = {
@@ -426,7 +426,6 @@ UpdatePublish.flags = {
426
426
  'rollout-percentage': core_1.Flags.integer({
427
427
  description: `Percentage of users this update should be immediately available to. Users not in the rollout will be served the previous latest update on the branch, even if that update is itself being rolled out. The specified number must be an integer between 1 and 100. When not specified, this defaults to 100.`,
428
428
  required: false,
429
- hidden: true,
430
429
  min: 0,
431
430
  max: 100,
432
431
  }),
@@ -7,6 +7,8 @@ export default class UpdateRepublish extends EasCommand {
7
7
  channel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
8
  branch: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
9
  group: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
+ 'destination-channel': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
+ 'destination-branch': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
12
  message: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
13
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string>;
12
14
  'private-key-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
@@ -8,10 +8,11 @@ const queries_2 = require("../../channel/queries");
8
8
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
9
9
  const flags_1 = require("../../commandUtils/flags");
10
10
  const pagination_1 = require("../../commandUtils/pagination");
11
+ const BranchQuery_1 = require("../../graphql/queries/BranchQuery");
11
12
  const UpdateQuery_1 = require("../../graphql/queries/UpdateQuery");
12
13
  const log_1 = tslib_1.__importDefault(require("../../log"));
13
14
  const prompts_1 = require("../../prompts");
14
- const getBranchNameFromChannelNameAsync_1 = require("../../update/getBranchNameFromChannelNameAsync");
15
+ const getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync_1 = require("../../update/getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync");
15
16
  const queries_3 = require("../../update/queries");
16
17
  const republish_1 = require("../../update/republish");
17
18
  const utils_1 = require("../../update/utils");
@@ -47,13 +48,14 @@ class UpdateRepublish extends EasCommand_1.default {
47
48
  }
48
49
  log_1.default.withTick(`The republished update group will appear on the same platforms it was originally published on: ${platformsFromUpdates.join(', ')}`);
49
50
  }
50
- const updateMessage = await getOrAskUpdateMessageAsync(updatesToPublish, flags);
51
51
  const arbitraryUpdate = updatesToPublish[0];
52
+ const targetBranch = await getOrAskTargetBranchAsync(graphqlClient, projectId, flags, arbitraryUpdate);
53
+ const updateMessage = await getOrAskUpdateMessageAsync(updatesToPublish, flags);
52
54
  await (0, republish_1.republishAsync)({
53
55
  graphqlClient,
54
56
  app: { exp, projectId },
55
57
  updatesToPublish,
56
- targetBranch: { branchId: arbitraryUpdate.branchId, branchName: arbitraryUpdate.branchName },
58
+ targetBranch,
57
59
  updateMessage,
58
60
  codeSigningInfo,
59
61
  json: flags.json,
@@ -63,6 +65,8 @@ class UpdateRepublish extends EasCommand_1.default {
63
65
  const branchName = rawFlags.branch;
64
66
  const channelName = rawFlags.channel;
65
67
  const groupId = rawFlags.group;
68
+ const destinationChannelName = rawFlags['destination-channel'];
69
+ const destinationBranchName = rawFlags['destination-branch'];
66
70
  const nonInteractive = rawFlags['non-interactive'];
67
71
  const privateKeyPath = rawFlags['private-key-path'];
68
72
  if (nonInteractive && !groupId) {
@@ -72,6 +76,8 @@ class UpdateRepublish extends EasCommand_1.default {
72
76
  return {
73
77
  branchName,
74
78
  channelName,
79
+ destinationChannelName,
80
+ destinationBranchName,
75
81
  groupId,
76
82
  platform,
77
83
  updateMessage: rawFlags.message,
@@ -96,6 +102,14 @@ UpdateRepublish.flags = {
96
102
  description: 'Update group ID to republish',
97
103
  exclusive: ['branch', 'channel'],
98
104
  }),
105
+ 'destination-channel': core_1.Flags.string({
106
+ description: 'Channel name to select a branch to republish to if republishing to a different branch',
107
+ exclusive: ['destination-branch'],
108
+ }),
109
+ 'destination-branch': core_1.Flags.string({
110
+ description: 'Branch name to republish to if republishing to a different branch',
111
+ exclusive: ['destination-channel'],
112
+ }),
99
113
  message: core_1.Flags.string({
100
114
  char: 'm',
101
115
  description: 'Short message describing the republished update group',
@@ -118,6 +132,22 @@ UpdateRepublish.contextDefinition = {
118
132
  ..._a.ContextOptions.LoggedIn,
119
133
  };
120
134
  exports.default = UpdateRepublish;
135
+ async function getOrAskTargetBranchAsync(graphqlClient, projectId, flags, arbitraryUpdate) {
136
+ // if branch name supplied, use that
137
+ if (flags.destinationBranchName) {
138
+ const branch = await BranchQuery_1.BranchQuery.getBranchByNameAsync(graphqlClient, {
139
+ appId: projectId,
140
+ name: flags.destinationBranchName,
141
+ });
142
+ return { branchId: branch.id, branchName: branch.name };
143
+ }
144
+ // if provided channel name but was non-interactive
145
+ if (flags.destinationChannelName) {
146
+ return await (0, getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync_1.getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync)(graphqlClient, projectId, flags.destinationChannelName);
147
+ }
148
+ // if neither provided, assume republish on same branch
149
+ return { branchId: arbitraryUpdate.branchId, branchName: arbitraryUpdate.branchName };
150
+ }
121
151
  /** Retrieve the update group from either the update group id, or select from branch name. */
122
152
  async function getOrAskUpdatesAsync(graphqlClient, projectId, flags) {
123
153
  if (flags.groupId) {
@@ -213,7 +243,7 @@ async function askUpdatesFromBranchNameAsync(graphqlClient, { projectId, branchN
213
243
  }
214
244
  /** Ask the user which update needs to be republished by channel name, this requires interactive mode */
215
245
  async function askUpdatesFromChannelNameAsync(graphqlClient, { projectId, channelName, json, nonInteractive, }) {
216
- const branchName = await (0, getBranchNameFromChannelNameAsync_1.getBranchNameFromChannelNameAsync)(graphqlClient, projectId, channelName);
246
+ const { branchName } = await (0, getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync_1.getBranchFromChannelNameAndCreateAndLinkIfNotExistsAsync)(graphqlClient, projectId, channelName);
217
247
  return await askUpdatesFromBranchNameAsync(graphqlClient, {
218
248
  projectId,
219
249
  branchName,