eas-cli 16.13.3 → 16.14.0

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 (33) hide show
  1. package/README.md +128 -78
  2. package/build/commands/env/create.d.ts +0 -1
  3. package/build/commands/env/create.js +1 -28
  4. package/build/commands/update/delete.js +2 -20
  5. package/build/commands/update/republish.js +2 -139
  6. package/build/commands/update/revert-update-rollout.d.ts +24 -0
  7. package/build/commands/update/revert-update-rollout.js +264 -0
  8. package/build/commands/update/roll-back-to-embedded.d.ts +0 -2
  9. package/build/commands/update/roll-back-to-embedded.js +13 -133
  10. package/build/commands/upload.d.ts +0 -1
  11. package/build/commands/upload.js +0 -1
  12. package/build/graphql/generated.d.ts +91 -109
  13. package/build/graphql/generated.js +15 -3
  14. package/build/graphql/mutations/EnvironmentVariableMutation.d.ts +0 -2
  15. package/build/graphql/mutations/EnvironmentVariableMutation.js +0 -48
  16. package/build/graphql/types/Update.js +1 -0
  17. package/build/project/publish.js +1 -0
  18. package/build/update/delete.d.ts +5 -0
  19. package/build/update/delete.js +24 -0
  20. package/build/update/queries.d.ts +13 -1
  21. package/build/update/queries.js +62 -1
  22. package/build/update/republish.d.ts +27 -0
  23. package/build/update/republish.js +242 -1
  24. package/build/update/roll-back-to-embedded.d.ts +18 -0
  25. package/build/update/roll-back-to-embedded.js +119 -0
  26. package/build/user/fetchUser.js +15 -13
  27. package/build/utils/statuspageService.js +1 -0
  28. package/oclif.manifest.json +78 -115
  29. package/package.json +3 -2
  30. package/build/commands/env/link.d.ts +0 -23
  31. package/build/commands/env/link.js +0 -128
  32. package/build/commands/env/unlink.d.ts +0 -22
  33. package/build/commands/env/unlink.js +0 -117
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishRollBackToEmbeddedUpdateAsync = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
6
+ const utils_1 = require("./utils");
7
+ const url_1 = require("../build/utils/url");
8
+ const fetch_1 = tslib_1.__importDefault(require("../fetch"));
9
+ const PublishMutation_1 = require("../graphql/mutations/PublishMutation");
10
+ const log_1 = tslib_1.__importStar(require("../log"));
11
+ const ora_1 = require("../ora");
12
+ const projectUtils_1 = require("../project/projectUtils");
13
+ const publish_1 = require("../project/publish");
14
+ const code_signing_1 = require("../utils/code-signing");
15
+ const uniqBy_1 = tslib_1.__importDefault(require("../utils/expodash/uniqBy"));
16
+ const formatFields_1 = tslib_1.__importDefault(require("../utils/formatFields"));
17
+ const json_1 = require("../utils/json");
18
+ async function publishRollBackToEmbeddedUpdateAsync({ graphqlClient, projectId, exp, updateMessage, branch, codeSigningInfo, platforms, runtimeVersion, json, }) {
19
+ const runtimeToPlatformsAndFingerprintInfoMapping = (0, publish_1.getRuntimeToPlatformsAndFingerprintInfoMappingFromRuntimeVersionInfoObjects)(platforms.map(platform => ({
20
+ platform,
21
+ runtimeVersionInfo: {
22
+ runtimeVersion,
23
+ expoUpdatesRuntimeFingerprint: null,
24
+ expoUpdatesRuntimeFingerprintHash: null,
25
+ },
26
+ })));
27
+ let newUpdates;
28
+ const publishSpinner = (0, ora_1.ora)('Publishing...').start();
29
+ try {
30
+ newUpdates = await publishRollbacksAsync({
31
+ graphqlClient,
32
+ updateMessage,
33
+ branchId: branch.id,
34
+ codeSigningInfo,
35
+ runtimeToPlatformsAndFingerprintInfoMapping,
36
+ platforms,
37
+ });
38
+ publishSpinner.succeed('Published!');
39
+ }
40
+ catch (e) {
41
+ publishSpinner.fail('Failed to publish updates');
42
+ throw e;
43
+ }
44
+ if (json) {
45
+ (0, json_1.printJsonOnlyOutput)((0, utils_1.getUpdateJsonInfosForUpdates)(newUpdates));
46
+ }
47
+ else {
48
+ log_1.default.addNewLineIfNone();
49
+ for (const runtime of (0, uniqBy_1.default)(runtimeToPlatformsAndFingerprintInfoMapping, version => version.runtimeVersion)) {
50
+ const newUpdatesForRuntimeVersion = newUpdates.filter(update => update.runtimeVersion === runtime.runtimeVersion);
51
+ if (newUpdatesForRuntimeVersion.length === 0) {
52
+ throw new Error(`Publish response is missing updates with runtime ${runtime.runtimeVersion}.`);
53
+ }
54
+ const platforms = newUpdatesForRuntimeVersion.map(update => update.platform);
55
+ const newAndroidUpdate = newUpdatesForRuntimeVersion.find(update => update.platform === 'android');
56
+ const newIosUpdate = newUpdatesForRuntimeVersion.find(update => update.platform === 'ios');
57
+ const updateGroupId = newUpdatesForRuntimeVersion[0].group;
58
+ const projectName = exp.slug;
59
+ const accountName = (await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId)).name;
60
+ const updateGroupUrl = (0, url_1.getUpdateGroupUrl)(accountName, projectName, updateGroupId);
61
+ const updateGroupLink = (0, log_1.link)(updateGroupUrl, { dim: false });
62
+ log_1.default.log((0, formatFields_1.default)([
63
+ { label: 'Branch', value: branch.name },
64
+ { label: 'Runtime version', value: runtime.runtimeVersion },
65
+ { label: 'Platform', value: platforms.join(', ') },
66
+ { label: 'Update group ID', value: updateGroupId },
67
+ ...(newAndroidUpdate ? [{ label: 'Android update ID', value: newAndroidUpdate.id }] : []),
68
+ ...(newIosUpdate ? [{ label: 'iOS update ID', value: newIosUpdate.id }] : []),
69
+ { label: 'Message', value: updateMessage ?? '' },
70
+ { label: 'EAS Dashboard', value: updateGroupLink },
71
+ ]));
72
+ log_1.default.addNewLineIfNone();
73
+ }
74
+ }
75
+ }
76
+ exports.publishRollBackToEmbeddedUpdateAsync = publishRollBackToEmbeddedUpdateAsync;
77
+ async function publishRollbacksAsync({ graphqlClient, updateMessage, branchId, codeSigningInfo, runtimeToPlatformsAndFingerprintInfoMapping, platforms, }) {
78
+ const rollbackInfoGroups = Object.fromEntries(platforms.map(platform => [platform, true]));
79
+ // Sort the updates into different groups based on their platform specific runtime versions
80
+ const updateGroups = runtimeToPlatformsAndFingerprintInfoMapping.map(({ runtimeVersion, platforms }) => {
81
+ const localRollbackInfoGroup = Object.fromEntries(platforms.map(platform => [platform, rollbackInfoGroups[platform]]));
82
+ return {
83
+ branchId,
84
+ rollBackToEmbeddedInfoGroup: localRollbackInfoGroup,
85
+ runtimeVersion,
86
+ message: updateMessage,
87
+ awaitingCodeSigningInfo: !!codeSigningInfo,
88
+ };
89
+ });
90
+ const newUpdates = await PublishMutation_1.PublishMutation.publishUpdateGroupAsync(graphqlClient, updateGroups);
91
+ if (codeSigningInfo) {
92
+ log_1.default.log('🔒 Signing roll back');
93
+ const updatesTemp = [...newUpdates];
94
+ const updateGroupsAndTheirUpdates = updateGroups.map(updateGroup => {
95
+ const newUpdates = updatesTemp.splice(0, Object.keys((0, nullthrows_1.default)(updateGroup.rollBackToEmbeddedInfoGroup)).length);
96
+ return {
97
+ updateGroup,
98
+ newUpdates,
99
+ };
100
+ });
101
+ await Promise.all(updateGroupsAndTheirUpdates.map(async ({ newUpdates }) => {
102
+ await Promise.all(newUpdates.map(async (newUpdate) => {
103
+ const response = await (0, fetch_1.default)(newUpdate.manifestPermalink, {
104
+ method: 'GET',
105
+ headers: { accept: 'multipart/mixed' },
106
+ });
107
+ const directiveBody = (0, nullthrows_1.default)(await (0, code_signing_1.getDirectiveBodyAsync)(response));
108
+ (0, code_signing_1.checkDirectiveBodyAgainstUpdateInfoGroup)(directiveBody);
109
+ const directiveSignature = (0, code_signing_1.signBody)(directiveBody, codeSigningInfo);
110
+ await PublishMutation_1.PublishMutation.setCodeSigningInfoAsync(graphqlClient, newUpdate.id, {
111
+ alg: codeSigningInfo.codeSigningMetadata.alg,
112
+ keyid: codeSigningInfo.codeSigningMetadata.keyid,
113
+ sig: directiveSignature,
114
+ });
115
+ }));
116
+ }));
117
+ }
118
+ return newUpdates;
119
+ }
@@ -4,24 +4,26 @@ exports.fetchUserAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
6
6
  const createGraphqlClient_1 = require("../commandUtils/context/contextUtils/createGraphqlClient");
7
+ const client_1 = require("../graphql/client");
7
8
  async function fetchUserAsync({ sessionSecret, }) {
8
9
  const graphqlClient = (0, createGraphqlClient_1.createGraphqlClient)({ accessToken: null, sessionSecret });
9
- const result = await graphqlClient
10
+ const result = await (0, client_1.withErrorHandlingAsync)(graphqlClient
10
11
  .query((0, graphql_tag_1.default) `
11
- query UserQuery {
12
- meUserActor {
13
- id
14
- username
12
+ query MeUserActorQuery {
13
+ meUserActor {
14
+ id
15
+ username
16
+ }
15
17
  }
16
- }
17
- `, {}, {
18
- additionalTypenames: [] /* UserQuery has immutable fields */,
19
- })
20
- .toPromise();
21
- const { data } = result;
18
+ `, {}, { additionalTypenames: ['UserActor'] })
19
+ .toPromise());
20
+ const meUserActor = result.meUserActor;
21
+ if (!meUserActor) {
22
+ throw new Error('Failed to fetch user data after login.');
23
+ }
22
24
  return {
23
- id: data.meUserActor.id,
24
- username: data.meUserActor.username,
25
+ id: meUserActor.id,
26
+ username: meUserActor.username,
25
27
  };
26
28
  }
27
29
  exports.fetchUserAsync = fetchUserAsync;
@@ -19,6 +19,7 @@ const humanReadableServiceName = {
19
19
  [generated_1.StatuspageServiceName.EasUpdate]: 'EAS Update',
20
20
  [generated_1.StatuspageServiceName.GithubApiRequests]: 'GitHub API Requests',
21
21
  [generated_1.StatuspageServiceName.GithubWebhooks]: 'Github Webhooks',
22
+ [generated_1.StatuspageServiceName.EasWorkflows]: 'EAS Workflows',
22
23
  };
23
24
  function warnAboutServiceOutage(service) {
24
25
  if (service.status === generated_1.StatuspageServiceStatus.Operational) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "16.13.3",
2
+ "version": "16.14.0",
3
3
  "commands": {
4
4
  "analytics": {
5
5
  "id": "analytics",
@@ -234,7 +234,6 @@
234
234
  "pluginName": "eas-cli",
235
235
  "pluginAlias": "eas-cli",
236
236
  "pluginType": "core",
237
- "hidden": true,
238
237
  "aliases": [],
239
238
  "flags": {
240
239
  "platform": {
@@ -2284,13 +2283,6 @@
2284
2283
  "description": "Text value or the variable",
2285
2284
  "multiple": false
2286
2285
  },
2287
- "link": {
2288
- "name": "link",
2289
- "type": "boolean",
2290
- "description": "Link account-wide variable to the current project",
2291
- "hidden": true,
2292
- "allowNo": false
2293
- },
2294
2286
  "force": {
2295
2287
  "name": "force",
2296
2288
  "type": "boolean",
@@ -2525,65 +2517,6 @@
2525
2517
  "loggedIn": {}
2526
2518
  }
2527
2519
  },
2528
- "env:link": {
2529
- "id": "env:link",
2530
- "description": "link an account-wide environment variable to the current project",
2531
- "strict": true,
2532
- "pluginName": "eas-cli",
2533
- "pluginAlias": "eas-cli",
2534
- "pluginType": "core",
2535
- "hidden": true,
2536
- "aliases": [],
2537
- "flags": {
2538
- "variable-name": {
2539
- "name": "variable-name",
2540
- "type": "option",
2541
- "description": "Name of the variable",
2542
- "multiple": false
2543
- },
2544
- "variable-environment": {
2545
- "name": "variable-environment",
2546
- "type": "option",
2547
- "description": "Current environment of the variable to link",
2548
- "helpValue": "(development|preview|production)",
2549
- "multiple": false,
2550
- "options": [
2551
- "development",
2552
- "preview",
2553
- "production"
2554
- ]
2555
- },
2556
- "environment": {
2557
- "name": "environment",
2558
- "type": "option",
2559
- "description": "Environment variable's environment",
2560
- "helpValue": "(development|preview|production)",
2561
- "multiple": true,
2562
- "options": [
2563
- "development",
2564
- "preview",
2565
- "production"
2566
- ]
2567
- },
2568
- "non-interactive": {
2569
- "name": "non-interactive",
2570
- "type": "boolean",
2571
- "description": "Run the command in non-interactive mode.",
2572
- "allowNo": false
2573
- }
2574
- },
2575
- "args": {
2576
- "environment": {
2577
- "name": "environment",
2578
- "description": "Environment to pull variables from. One of 'production', 'preview', or 'development'.",
2579
- "required": false
2580
- }
2581
- },
2582
- "contextDefinition": {
2583
- "projectId": {},
2584
- "loggedIn": {}
2585
- }
2586
- },
2587
2520
  "env:list": {
2588
2521
  "id": "env:list",
2589
2522
  "description": "list environment variables for the current project or account",
@@ -2743,53 +2676,6 @@
2743
2676
  "loggedIn": {}
2744
2677
  }
2745
2678
  },
2746
- "env:unlink": {
2747
- "id": "env:unlink",
2748
- "description": "unlink an account-wide environment variable from the current project",
2749
- "strict": true,
2750
- "pluginName": "eas-cli",
2751
- "pluginAlias": "eas-cli",
2752
- "pluginType": "core",
2753
- "hidden": true,
2754
- "aliases": [],
2755
- "flags": {
2756
- "variable-name": {
2757
- "name": "variable-name",
2758
- "type": "option",
2759
- "description": "Name of the variable",
2760
- "multiple": false
2761
- },
2762
- "environment": {
2763
- "name": "environment",
2764
- "type": "option",
2765
- "description": "Environment variable's environment",
2766
- "helpValue": "(development|preview|production)",
2767
- "multiple": true,
2768
- "options": [
2769
- "development",
2770
- "preview",
2771
- "production"
2772
- ]
2773
- },
2774
- "non-interactive": {
2775
- "name": "non-interactive",
2776
- "type": "boolean",
2777
- "description": "Run the command in non-interactive mode.",
2778
- "allowNo": false
2779
- }
2780
- },
2781
- "args": {
2782
- "environment": {
2783
- "name": "environment",
2784
- "description": "Environment to unlink the variable from. One of 'production', 'preview', or 'development'.",
2785
- "required": false
2786
- }
2787
- },
2788
- "contextDefinition": {
2789
- "projectId": {},
2790
- "loggedIn": {}
2791
- }
2792
- },
2793
2679
  "env:update": {
2794
2680
  "id": "env:update",
2795
2681
  "description": "update an environment variable on the current project or account",
@@ -3856,6 +3742,83 @@
3856
3742
  "privateProjectConfig": {}
3857
3743
  }
3858
3744
  },
3745
+ "update:revert-update-rollout": {
3746
+ "id": "update:revert-update-rollout",
3747
+ "description": "revert a rollout update for a project",
3748
+ "strict": true,
3749
+ "pluginName": "eas-cli",
3750
+ "pluginAlias": "eas-cli",
3751
+ "pluginType": "core",
3752
+ "aliases": [],
3753
+ "flags": {
3754
+ "channel": {
3755
+ "name": "channel",
3756
+ "type": "option",
3757
+ "description": "Channel name to select an update group to revert the rollout update from",
3758
+ "multiple": false,
3759
+ "exclusive": [
3760
+ "branch",
3761
+ "group"
3762
+ ]
3763
+ },
3764
+ "branch": {
3765
+ "name": "branch",
3766
+ "type": "option",
3767
+ "description": "Branch name to select an update group to revert the rollout update from",
3768
+ "multiple": false,
3769
+ "exclusive": [
3770
+ "channel",
3771
+ "group"
3772
+ ]
3773
+ },
3774
+ "group": {
3775
+ "name": "group",
3776
+ "type": "option",
3777
+ "description": "Rollout update group ID to revert",
3778
+ "multiple": false,
3779
+ "exclusive": [
3780
+ "branch",
3781
+ "channel"
3782
+ ]
3783
+ },
3784
+ "message": {
3785
+ "name": "message",
3786
+ "type": "option",
3787
+ "char": "m",
3788
+ "description": "Short message describing the revert",
3789
+ "required": false,
3790
+ "multiple": false
3791
+ },
3792
+ "private-key-path": {
3793
+ "name": "private-key-path",
3794
+ "type": "option",
3795
+ "description": "File containing the PEM-encoded private key corresponding to the certificate in expo-updates' configuration. Defaults to a file named \"private-key.pem\" in the certificate's directory. Only relevant if you are using code signing: https://docs.expo.dev/eas-update/code-signing/",
3796
+ "required": false,
3797
+ "multiple": false
3798
+ },
3799
+ "json": {
3800
+ "name": "json",
3801
+ "type": "boolean",
3802
+ "description": "Enable JSON output, non-JSON messages will be printed to stderr.",
3803
+ "allowNo": false,
3804
+ "dependsOn": [
3805
+ "non-interactive"
3806
+ ]
3807
+ },
3808
+ "non-interactive": {
3809
+ "name": "non-interactive",
3810
+ "type": "boolean",
3811
+ "description": "Run the command in non-interactive mode.",
3812
+ "allowNo": false
3813
+ }
3814
+ },
3815
+ "args": {},
3816
+ "contextDefinition": {
3817
+ "loggedIn": {},
3818
+ "privateProjectConfig": {},
3819
+ "vcsClient": {}
3820
+ }
3821
+ },
3859
3822
  "update:roll-back-to-embedded": {
3860
3823
  "id": "update:roll-back-to-embedded",
3861
3824
  "description": "roll back to the embedded update",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eas-cli",
3
3
  "description": "EAS command line tool",
4
- "version": "16.13.3",
4
+ "version": "16.14.0",
5
5
  "author": "Expo <support@expo.dev>",
6
6
  "bin": {
7
7
  "eas": "./bin/run"
@@ -234,11 +234,12 @@
234
234
  "test": "jest",
235
235
  "version": "yarn oclif readme && node scripts/patch-readme && git add README.md",
236
236
  "generate-graphql-code": "graphql-codegen --config graphql-codegen.yml",
237
+ "verify-graphql-code": "./scripts/verify-graphql.sh",
237
238
  "clean": "rimraf dist build tmp node_modules yarn-error.log"
238
239
  },
239
240
  "volta": {
240
241
  "node": "20.11.0",
241
242
  "yarn": "1.22.21"
242
243
  },
243
- "gitHead": "3cfb6725e7b87f7bb330939a1200d570d5580f68"
244
+ "gitHead": "bf27ec5238e337c0a0bdba524e5815e0e646f8e9"
244
245
  }
@@ -1,23 +0,0 @@
1
- import EasCommand from '../../commandUtils/EasCommand';
2
- import { EnvironmentVariableEnvironment } from '../../graphql/generated';
3
- export default class EnvLink 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
- 'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
- 'variable-environment': import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
11
- };
12
- static args: {
13
- name: string;
14
- description: string;
15
- required: boolean;
16
- }[];
17
- static contextDefinition: {
18
- loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
19
- projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
20
- };
21
- runAsync(): Promise<void>;
22
- private validateInputs;
23
- }
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const core_1 = require("@oclif/core");
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 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
- const variableUtils_1 = require("../../utils/variableUtils");
16
- class EnvLink extends EasCommand_1.default {
17
- static description = 'link an account-wide environment variable to the current project';
18
- // for now we only roll out global account-wide env variables so this should stay hidden
19
- static hidden = true;
20
- static flags = {
21
- 'variable-name': core_1.Flags.string({
22
- description: 'Name of the variable',
23
- }),
24
- 'variable-environment': core_1.Flags.enum({
25
- ...flags_1.EasEnvironmentFlagParameters,
26
- description: 'Current environment of the variable to link',
27
- }),
28
- ...flags_1.EASMultiEnvironmentFlag,
29
- ...flags_1.EASNonInteractiveFlag,
30
- };
31
- static args = [
32
- {
33
- name: 'environment',
34
- description: "Environment to pull variables from. One of 'production', 'preview', or 'development'.",
35
- required: false,
36
- },
37
- ];
38
- static contextDefinition = {
39
- ...this.ContextOptions.ProjectId,
40
- ...this.ContextOptions.LoggedIn,
41
- };
42
- async runAsync() {
43
- const { args, flags } = await this.parse(EnvLink);
44
- let { 'variable-name': name, 'variable-environment': currentEnvironment, 'non-interactive': nonInteractive, environment: environments, } = this.validateInputs(flags, args);
45
- const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(EnvLink, {
46
- nonInteractive,
47
- });
48
- const projectDisplayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
49
- const variables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
50
- appId: projectId,
51
- environment: currentEnvironment,
52
- filterNames: name ? [name] : undefined,
53
- });
54
- let selectedVariable = variables[0];
55
- if (variables.length > 1) {
56
- if (nonInteractive) {
57
- throw new Error('Multiple variables found, run command with --variable-name and --variable-environment arguments.');
58
- }
59
- selectedVariable = await (0, prompts_1.selectAsync)('Select account-wide variable', variables.map(variable => ({
60
- title: (0, variableUtils_1.formatVariableName)(variable),
61
- value: variable,
62
- })));
63
- }
64
- if (!selectedVariable) {
65
- throw new Error(`Account-wide variable ${name} doesn't exist`);
66
- }
67
- let explicitSelect = false;
68
- if (!nonInteractive && !environments) {
69
- const selectedEnvironments = (selectedVariable.linkedEnvironments ?? []).length > 0
70
- ? selectedVariable.linkedEnvironments
71
- : selectedVariable.environments;
72
- environments = await (0, prompts_2.promptVariableEnvironmentAsync)({
73
- nonInteractive,
74
- multiple: true,
75
- selectedEnvironments: selectedEnvironments ?? [],
76
- });
77
- explicitSelect = true;
78
- }
79
- if (!environments) {
80
- await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId);
81
- log_1.default.withTick(`Linked variable ${chalk_1.default.bold(selectedVariable.name)} to project ${chalk_1.default.bold(projectDisplayName)} in ${selectedVariable.environments?.join(', ').toLocaleLowerCase()}.`);
82
- return;
83
- }
84
- for (const environment of Object.values(generated_1.EnvironmentVariableEnvironment)) {
85
- try {
86
- if (selectedVariable.linkedEnvironments?.includes(environment) ===
87
- environments.includes(environment)) {
88
- if (!explicitSelect && environments.includes(environment)) {
89
- log_1.default.withTick(`Variable ${chalk_1.default.bold(selectedVariable.name)} is already linked to ${environment.toLocaleLowerCase()}.`);
90
- }
91
- continue;
92
- }
93
- if (environments.includes(environment)) {
94
- await EnvironmentVariableMutation_1.EnvironmentVariableMutation.linkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
95
- log_1.default.withTick(`Linked variable ${chalk_1.default.bold(selectedVariable.name)} to project ${chalk_1.default.bold(projectDisplayName)} in ${environment.toLocaleLowerCase()}.`);
96
- }
97
- else if (explicitSelect) {
98
- await EnvironmentVariableMutation_1.EnvironmentVariableMutation.unlinkSharedEnvironmentVariableAsync(graphqlClient, selectedVariable.id, projectId, environment);
99
- log_1.default.withTick(`Unlinked variable ${chalk_1.default.bold(selectedVariable.name)} from project ${chalk_1.default.bold(projectDisplayName)} in ${environment.toLocaleLowerCase()}.`);
100
- }
101
- }
102
- catch (err) {
103
- log_1.default.warn(err.message);
104
- }
105
- }
106
- }
107
- validateInputs(flags, { environment }) {
108
- environment = environment?.toUpperCase();
109
- if (environment && !(0, variableUtils_1.isEnvironment)(environment)) {
110
- throw new Error("Invalid environment. Use one of 'production', 'preview', or 'development'.");
111
- }
112
- const environments = flags.environment
113
- ? flags.environment
114
- : environment
115
- ? [environment]
116
- : undefined;
117
- if (flags['non-interactive']) {
118
- if (!flags['variable-name']) {
119
- throw new Error(`Environment variable needs 'name' to be specified when running in non-interactive mode. Run the command with ${chalk_1.default.bold('--variable-name VARIABLE_NAME')} flag to fix the issue`);
120
- }
121
- }
122
- return {
123
- ...flags,
124
- environment: environments,
125
- };
126
- }
127
- }
128
- exports.default = EnvLink;
@@ -1,22 +0,0 @@
1
- import EasCommand from '../../commandUtils/EasCommand';
2
- import { EnvironmentVariableEnvironment } from '../../graphql/generated';
3
- export default class EnvUnlink 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
- 'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
- };
11
- static contextDefinition: {
12
- loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
13
- projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
14
- };
15
- static args: {
16
- name: string;
17
- description: string;
18
- required: boolean;
19
- }[];
20
- runAsync(): Promise<void>;
21
- private validateInputs;
22
- }