eas-cli 21.7.0 → 21.8.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.
- package/README.md +216 -121
- package/build/analytics/AnalyticsManager.js +3 -0
- package/build/analytics/sandbox.d.ts +3 -0
- package/build/analytics/sandbox.js +26 -0
- package/build/commandUtils/supabase.d.ts +13 -0
- package/build/commandUtils/supabase.js +82 -0
- package/build/commands/integrations/supabase/connect.d.ts +26 -0
- package/build/commands/integrations/supabase/connect.js +404 -0
- package/build/commands/integrations/supabase/dashboard.d.ts +14 -0
- package/build/commands/integrations/supabase/dashboard.js +69 -0
- package/build/commands/integrations/supabase/disconnect.d.ts +15 -0
- package/build/commands/integrations/supabase/disconnect.js +87 -0
- package/build/environments/defaults.d.ts +2 -0
- package/build/environments/defaults.js +5 -0
- package/build/environments/resolve.d.ts +10 -0
- package/build/environments/resolve.js +67 -0
- package/build/environments/variables.d.ts +18 -0
- package/build/environments/variables.js +124 -0
- package/build/graphql/client.d.ts +8 -0
- package/build/graphql/client.js +15 -0
- package/build/graphql/generated.d.ts +202 -0
- package/build/graphql/mutations/SupabaseMutation.d.ts +14 -0
- package/build/graphql/mutations/SupabaseMutation.js +145 -0
- package/build/graphql/queries/SupabaseQuery.d.ts +10 -0
- package/build/graphql/queries/SupabaseQuery.js +54 -0
- package/build/graphql/types/SupabaseConnection.d.ts +8 -0
- package/build/graphql/types/SupabaseConnection.js +25 -0
- package/build/integrations/shared/envFile.d.ts +7 -0
- package/build/integrations/shared/envFile.js +94 -0
- package/build/integrations/shared/sdk.d.ts +24 -0
- package/build/integrations/shared/sdk.js +87 -0
- package/build/integrations/supabase/env.d.ts +14 -0
- package/build/integrations/supabase/env.js +68 -0
- package/build/integrations/supabase/provision.d.ts +32 -0
- package/build/integrations/supabase/provision.js +245 -0
- package/build/utils/pollForBackgroundJobReceiptAsync.d.ts +2 -0
- package/build/utils/pollForBackgroundJobReceiptAsync.js +11 -2
- package/build/utils/prompts.d.ts +0 -1
- package/build/utils/prompts.js +6 -17
- package/oclif.manifest.json +4257 -3955
- package/package.json +4 -3
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPABASE_REGION_CHOICES = exports.PROVISION_RECEIPT_MAX_CONSECUTIVE_FETCH_ERRORS = exports.PROVISION_RECEIPT_MAX_CHECKS = void 0;
|
|
4
|
+
exports.projectNameSuffixForEnvironments = projectNameSuffixForEnvironments;
|
|
5
|
+
exports.toProvisionPollError = toProvisionPollError;
|
|
6
|
+
exports.additionalProvisionFailureHint = additionalProvisionFailureHint;
|
|
7
|
+
exports.primaryProvisionFailureHint = primaryProvisionFailureHint;
|
|
8
|
+
exports.pollProvisionReceiptAsync = pollProvisionReceiptAsync;
|
|
9
|
+
exports.authorizeViaBrowserAsync = authorizeViaBrowserAsync;
|
|
10
|
+
exports.loadOrganizationsBestEffortAsync = loadOrganizationsBestEffortAsync;
|
|
11
|
+
exports.pollForConnectionAsync = pollForConnectionAsync;
|
|
12
|
+
exports.resolvePublishableKeyAsync = resolvePublishableKeyAsync;
|
|
13
|
+
exports.resolveRegionAsync = resolveRegionAsync;
|
|
14
|
+
exports.resolveOrganizationAsync = resolveOrganizationAsync;
|
|
15
|
+
const tslib_1 = require("tslib");
|
|
16
|
+
const better_opn_1 = tslib_1.__importDefault(require("better-opn"));
|
|
17
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
18
|
+
const supabase_1 = require("../../commandUtils/supabase");
|
|
19
|
+
const client_1 = require("../../graphql/client");
|
|
20
|
+
const SupabaseMutation_1 = require("../../graphql/mutations/SupabaseMutation");
|
|
21
|
+
const SupabaseQuery_1 = require("../../graphql/queries/SupabaseQuery");
|
|
22
|
+
const log_1 = tslib_1.__importStar(require("../../log"));
|
|
23
|
+
const ora_1 = require("../../ora");
|
|
24
|
+
const prompts_1 = require("../../prompts");
|
|
25
|
+
const promise_1 = require("../../utils/promise");
|
|
26
|
+
const pollForBackgroundJobReceiptAsync_1 = require("../../utils/pollForBackgroundJobReceiptAsync");
|
|
27
|
+
// The server holds the pending OAuth row for 15 minutes; match that so we don't time out on an
|
|
28
|
+
// approval the user completes within the window.
|
|
29
|
+
const CONNECTION_POLL_INTERVAL_MS = 2_000;
|
|
30
|
+
const CONNECTION_POLL_TIMEOUT_MS = 15 * 60 * 1_000;
|
|
31
|
+
const MAX_CONSECUTIVE_CONNECTION_ERRORS = 10;
|
|
32
|
+
// A freshly provisioned project takes a minute or two to become healthy; the publishable key only
|
|
33
|
+
// resolves once it is.
|
|
34
|
+
const READINESS_POLL_INTERVAL_MS = 3_000;
|
|
35
|
+
const READINESS_POLL_TIMEOUT_MS = 5 * 60 * 1_000;
|
|
36
|
+
// A server fault is worth retrying, but not for the full timeout: once it repeats this many
|
|
37
|
+
// times it isn't a provisioning delay, and the user shouldn't wait five minutes to hear it.
|
|
38
|
+
const MAX_CONSECUTIVE_READINESS_ERRORS = 10;
|
|
39
|
+
// Background job create + publishable-key polling can take 5+ minutes; allow 7 min at 1s interval.
|
|
40
|
+
exports.PROVISION_RECEIPT_MAX_CHECKS = 420;
|
|
41
|
+
exports.PROVISION_RECEIPT_MAX_CONSECUTIVE_FETCH_ERRORS = 3;
|
|
42
|
+
exports.SUPABASE_REGION_CHOICES = [
|
|
43
|
+
{ title: 'Americas (US)', value: 'americas' },
|
|
44
|
+
{ title: 'Europe / Middle East / Africa', value: 'emea' },
|
|
45
|
+
{ title: 'Asia Pacific', value: 'apac' },
|
|
46
|
+
];
|
|
47
|
+
function projectNameSuffixForEnvironments(environments) {
|
|
48
|
+
return [...environments]
|
|
49
|
+
.sort()
|
|
50
|
+
.join('-')
|
|
51
|
+
.replace(/[^a-zA-Z0-9._-]+/g, '-')
|
|
52
|
+
.slice(0, 32);
|
|
53
|
+
}
|
|
54
|
+
function toProvisionPollError(error, { hint }) {
|
|
55
|
+
if (!(error instanceof pollForBackgroundJobReceiptAsync_1.BackgroundJobReceiptPollError)) {
|
|
56
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
57
|
+
}
|
|
58
|
+
const trimmedHint = hint.trim();
|
|
59
|
+
const join = (message) => trimmedHint ? `${message.trimEnd()}\n\n${trimmedHint}` : message;
|
|
60
|
+
if (error.errorData.errorType === pollForBackgroundJobReceiptAsync_1.BackgroundJobReceiptPollErrorType.JOB_FAILED_NO_WILL_RETRY) {
|
|
61
|
+
return new Error(join(error.errorData.receiptErrorMessage ?? error.message));
|
|
62
|
+
}
|
|
63
|
+
if (error.errorData.errorType === pollForBackgroundJobReceiptAsync_1.BackgroundJobReceiptPollErrorType.TIMEOUT ||
|
|
64
|
+
error.errorData.errorType === pollForBackgroundJobReceiptAsync_1.BackgroundJobReceiptPollErrorType.NULL_RECEIPT) {
|
|
65
|
+
return new Error(join('Timed out or lost contact while waiting for Supabase project provision.'));
|
|
66
|
+
}
|
|
67
|
+
return error;
|
|
68
|
+
}
|
|
69
|
+
/** Fast-forward guidance when additional (--environment) provision fails permanently. */
|
|
70
|
+
function additionalProvisionFailureHint(environments) {
|
|
71
|
+
return [
|
|
72
|
+
'Free a slot on your Supabase plan (delete, pause, or upgrade a project), then re-run:',
|
|
73
|
+
` eas integrations:supabase:connect --environment ${environments.join(',')}`,
|
|
74
|
+
'Or set EXPO_PUBLIC_SUPABASE_URL and EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY on those EAS environments to an existing Supabase project.',
|
|
75
|
+
].join('\n');
|
|
76
|
+
}
|
|
77
|
+
/** Where to find a project for --link (primary connect path). */
|
|
78
|
+
function primaryProvisionFailureHint() {
|
|
79
|
+
return [
|
|
80
|
+
'If a project already exists in your Supabase dashboard, link it instead of provisioning:',
|
|
81
|
+
' eas integrations:supabase:connect --link <project-url>',
|
|
82
|
+
].join('\n');
|
|
83
|
+
}
|
|
84
|
+
async function pollProvisionReceiptAsync(graphqlClient, receipt, { startMessage, waitingMessage, failureMessage, failureHint, }) {
|
|
85
|
+
const spinner = (0, ora_1.ora)(startMessage).start();
|
|
86
|
+
try {
|
|
87
|
+
spinner.text = waitingMessage;
|
|
88
|
+
const finalized = await (0, pollForBackgroundJobReceiptAsync_1.pollForBackgroundJobReceiptAsync)(graphqlClient, receipt, {
|
|
89
|
+
maxChecks: exports.PROVISION_RECEIPT_MAX_CHECKS,
|
|
90
|
+
maxConsecutiveFetchErrors: exports.PROVISION_RECEIPT_MAX_CONSECUTIVE_FETCH_ERRORS,
|
|
91
|
+
});
|
|
92
|
+
if (!finalized) {
|
|
93
|
+
throw new Error('Supabase project provision finished without a receipt.');
|
|
94
|
+
}
|
|
95
|
+
// Stopped, not succeeded: the caller resolves what was provisioned and owns that message.
|
|
96
|
+
spinner.stop();
|
|
97
|
+
return finalized;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
spinner.fail(failureMessage);
|
|
101
|
+
throw toProvisionPollError(error, { hint: failureHint });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function authorizeViaBrowserAsync(graphqlClient, account, nonInteractive) {
|
|
105
|
+
if (nonInteractive) {
|
|
106
|
+
throw new Error(`Connecting Supabase requires approving access in a browser, which isn't possible in non-interactive mode. Re-run \`eas integrations:supabase:connect\` interactively.`);
|
|
107
|
+
}
|
|
108
|
+
const { url } = await SupabaseMutation_1.SupabaseMutation.beginSupabaseOAuthAsync(graphqlClient, {
|
|
109
|
+
accountId: account.id,
|
|
110
|
+
});
|
|
111
|
+
log_1.default.addNewLineIfNone();
|
|
112
|
+
log_1.default.log(`Authorize Expo to access your Supabase account in the browser. You'll need an existing Supabase account.`);
|
|
113
|
+
log_1.default.log(`If your browser doesn't open automatically, authorize at this link: ${(0, log_1.link)(url)}`);
|
|
114
|
+
void (0, better_opn_1.default)(url).catch(() => false);
|
|
115
|
+
const spinner = (0, ora_1.ora)('Waiting for you to authorize in Supabase (up to 15 minutes; press Ctrl-C to cancel)').start();
|
|
116
|
+
try {
|
|
117
|
+
const connection = await pollForConnectionAsync(graphqlClient, account.id);
|
|
118
|
+
const organizations = await loadOrganizationsBestEffortAsync(graphqlClient, account.id);
|
|
119
|
+
spinner.succeed(`Connected Supabase organization ${chalk_1.default.bold((0, supabase_1.formatSupabaseOrganization)(connection, organizations ?? undefined))}`);
|
|
120
|
+
return connection;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
spinner.fail("Couldn't confirm the Supabase connection");
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function loadOrganizationsBestEffortAsync(graphqlClient, accountId) {
|
|
128
|
+
try {
|
|
129
|
+
return await SupabaseMutation_1.SupabaseMutation.listSupabaseOrganizationsAsync(graphqlClient, accountId);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function pollForConnectionAsync(graphqlClient, accountId) {
|
|
136
|
+
const deadline = Date.now() + CONNECTION_POLL_TIMEOUT_MS;
|
|
137
|
+
let consecutiveErrors = 0;
|
|
138
|
+
for (;;) {
|
|
139
|
+
let connection = null;
|
|
140
|
+
try {
|
|
141
|
+
connection = await SupabaseQuery_1.SupabaseQuery.getSupabaseConnectionByAccountIdAsync(graphqlClient, accountId, { useCache: false });
|
|
142
|
+
consecutiveErrors = 0;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
consecutiveErrors += 1;
|
|
146
|
+
log_1.default.debug(`Polling for the Supabase connection failed: ${error}`);
|
|
147
|
+
if ((0, client_1.isPermanentGraphqlError)(error) ||
|
|
148
|
+
consecutiveErrors >= MAX_CONSECUTIVE_CONNECTION_ERRORS) {
|
|
149
|
+
log_1.default.error('Gave up checking whether the Supabase authorization finished. Fix the error below, then re-run `eas integrations:supabase:connect` — an authorization you already approved is still picked up.');
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (connection) {
|
|
154
|
+
return connection;
|
|
155
|
+
}
|
|
156
|
+
if (Date.now() >= deadline) {
|
|
157
|
+
throw new Error('Timed out waiting for the Supabase connection. If you authorized it in your browser, re-run `eas integrations:supabase:connect` — it will pick up the connection.');
|
|
158
|
+
}
|
|
159
|
+
await (0, promise_1.sleepAsync)(CONNECTION_POLL_INTERVAL_MS);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function resolvePublishableKeyAsync(graphqlClient, appId, project) {
|
|
163
|
+
const spinner = (0, ora_1.ora)('Waiting for the Supabase project to finish provisioning').start();
|
|
164
|
+
const deadline = Date.now() + READINESS_POLL_TIMEOUT_MS;
|
|
165
|
+
// The server returns a null key while the project is still provisioning, and throws for a real
|
|
166
|
+
// problem. A rejected request can't succeed on a retry; a server fault might, but not forever.
|
|
167
|
+
let consecutiveErrors = 0;
|
|
168
|
+
for (;;) {
|
|
169
|
+
let key = null;
|
|
170
|
+
try {
|
|
171
|
+
key = await SupabaseMutation_1.SupabaseMutation.fetchSupabasePublishableKeyAsync(graphqlClient, appId);
|
|
172
|
+
consecutiveErrors = 0;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
consecutiveErrors += 1;
|
|
176
|
+
log_1.default.debug(`Polling for the Supabase project readiness failed: ${error}`);
|
|
177
|
+
if ((0, client_1.isPermanentGraphqlError)(error) || consecutiveErrors >= MAX_CONSECUTIVE_READINESS_ERRORS) {
|
|
178
|
+
spinner.fail("Couldn't reach the Supabase project");
|
|
179
|
+
log_1.default.error(`The project may exist even though EAS can't read its key. Check it at ${(0, supabase_1.getSupabaseProjectDashboardUrl)(project)} before you re-run \`eas integrations:supabase:connect\`.`);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (key) {
|
|
184
|
+
spinner.succeed('Supabase project is ready');
|
|
185
|
+
return key;
|
|
186
|
+
}
|
|
187
|
+
if (Date.now() >= deadline) {
|
|
188
|
+
spinner.fail('Supabase project did not finish provisioning in time');
|
|
189
|
+
throw new Error(`The Supabase project is still provisioning. Once it's healthy (check ${(0, supabase_1.getSupabaseProjectDashboardUrl)(project)}), re-run \`eas integrations:supabase:connect\` to finish writing the environment variables.`);
|
|
190
|
+
}
|
|
191
|
+
await (0, promise_1.sleepAsync)(READINESS_POLL_INTERVAL_MS);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function resolveRegionAsync(flagValue, nonInteractive) {
|
|
195
|
+
if (flagValue !== undefined) {
|
|
196
|
+
// The server accepts both the smart-group values (americas | emea | apac) and raw region
|
|
197
|
+
// codes (e.g. us-east-1), so any non-empty value passes through.
|
|
198
|
+
const region = flagValue.trim();
|
|
199
|
+
if (!region) {
|
|
200
|
+
throw new Error('Pass a Supabase region to --region (americas, emea, apac, or a raw code like us-east-1).');
|
|
201
|
+
}
|
|
202
|
+
return region;
|
|
203
|
+
}
|
|
204
|
+
if (nonInteractive) {
|
|
205
|
+
throw new Error('A Supabase region is required in non-interactive mode. Pass --region (americas, emea, or apac). The region is permanent once the project is created.');
|
|
206
|
+
}
|
|
207
|
+
return await (0, prompts_1.selectAsync)('Select a Supabase region (permanent once the project is created)', exports.SUPABASE_REGION_CHOICES);
|
|
208
|
+
}
|
|
209
|
+
async function resolveOrganizationAsync(graphqlClient, accountId, connection, organizationFlag, nonInteractive, preloadedOrganizations) {
|
|
210
|
+
if (organizationFlag) {
|
|
211
|
+
if (organizationFlag === connection.supabaseOrganizationSlug) {
|
|
212
|
+
return connection;
|
|
213
|
+
}
|
|
214
|
+
const organizations = preloadedOrganizations ??
|
|
215
|
+
(await SupabaseMutation_1.SupabaseMutation.listSupabaseOrganizationsAsync(graphqlClient, accountId));
|
|
216
|
+
if (!organizations.some(organization => organization.slug === organizationFlag)) {
|
|
217
|
+
throw new Error(`Supabase organization ${chalk_1.default.bold(organizationFlag)} isn't one of your connected organizations (${organizations
|
|
218
|
+
.map(organization => organization.slug)
|
|
219
|
+
.join(', ')}).`);
|
|
220
|
+
}
|
|
221
|
+
return await SupabaseMutation_1.SupabaseMutation.setSupabaseConnectionOrganizationAsync(graphqlClient, {
|
|
222
|
+
supabaseConnectionId: connection.id,
|
|
223
|
+
organizationSlug: organizationFlag,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (nonInteractive) {
|
|
227
|
+
return connection;
|
|
228
|
+
}
|
|
229
|
+
const organizations = preloadedOrganizations ??
|
|
230
|
+
(await SupabaseMutation_1.SupabaseMutation.listSupabaseOrganizationsAsync(graphqlClient, accountId));
|
|
231
|
+
if (organizations.length <= 1) {
|
|
232
|
+
return connection;
|
|
233
|
+
}
|
|
234
|
+
const chosen = await (0, prompts_1.selectAsync)('Select the Supabase organization to use', organizations.map(organization => ({
|
|
235
|
+
title: `${organization.name} (${organization.slug})`,
|
|
236
|
+
value: organization.slug,
|
|
237
|
+
})));
|
|
238
|
+
if (chosen === connection.supabaseOrganizationSlug) {
|
|
239
|
+
return connection;
|
|
240
|
+
}
|
|
241
|
+
return await SupabaseMutation_1.SupabaseMutation.setSupabaseConnectionOrganizationAsync(graphqlClient, {
|
|
242
|
+
supabaseConnectionId: connection.id,
|
|
243
|
+
organizationSlug: chosen,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
@@ -26,4 +26,6 @@ export declare function pollForBackgroundJobReceiptAsync(graphqlClient: ExpoGrap
|
|
|
26
26
|
export declare function pollForBackgroundJobReceiptAsync(graphqlClient: ExpoGraphqlClient, backgroundJobReceipt: BackgroundJobReceiptDataFragment, options?: {
|
|
27
27
|
onBackgroundJobReceiptPollError?: BackgroundJobPollErrorCondition;
|
|
28
28
|
pollInterval?: number;
|
|
29
|
+
maxChecks?: number;
|
|
30
|
+
maxConsecutiveFetchErrors?: number;
|
|
29
31
|
}): Promise<BackgroundJobReceiptDataFragment | null>;
|
|
@@ -42,8 +42,11 @@ async function fetchBackgroundJobReceiptAsync(graphqlClient, receiptId) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
async function pollForBackgroundJobReceiptAsync(graphqlClient, backgroundJobReceipt, options) {
|
|
45
|
+
const maxChecks = options?.maxChecks ?? 90;
|
|
46
|
+
const maxConsecutiveFetchErrors = options?.maxConsecutiveFetchErrors ?? 0;
|
|
45
47
|
return await new Promise((resolve, reject) => {
|
|
46
48
|
let numChecks = 0;
|
|
49
|
+
let consecutiveFetchErrors = 0;
|
|
47
50
|
const intervalHandle = (0, set_interval_async_1.setIntervalAsync)(async function pollForDeletionFinishedAsync() {
|
|
48
51
|
function failBackgroundDeletion(error) {
|
|
49
52
|
void (0, set_interval_async_1.clearIntervalAsync)(intervalHandle);
|
|
@@ -58,12 +61,18 @@ async function pollForBackgroundJobReceiptAsync(graphqlClient, backgroundJobRece
|
|
|
58
61
|
resolve(null);
|
|
59
62
|
return;
|
|
60
63
|
}
|
|
64
|
+
consecutiveFetchErrors += 1;
|
|
65
|
+
if (consecutiveFetchErrors <= maxConsecutiveFetchErrors) {
|
|
66
|
+
numChecks++;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
failBackgroundDeletion(new BackgroundJobReceiptPollError({
|
|
63
71
|
errorType: BackgroundJobReceiptPollErrorType.NULL_RECEIPT,
|
|
64
72
|
}));
|
|
65
73
|
return;
|
|
66
74
|
}
|
|
75
|
+
consecutiveFetchErrors = 0;
|
|
67
76
|
// job failed and will not retry
|
|
68
77
|
if (receipt.state === generated_1.BackgroundJobState.Failure && !receipt.willRetry) {
|
|
69
78
|
failBackgroundDeletion(new BackgroundJobReceiptPollError({
|
|
@@ -72,10 +81,10 @@ async function pollForBackgroundJobReceiptAsync(graphqlClient, backgroundJobRece
|
|
|
72
81
|
}));
|
|
73
82
|
return;
|
|
74
83
|
}
|
|
75
|
-
// all else fails, stop polling after
|
|
84
|
+
// all else fails, stop polling after maxChecks. This should only happen if there's an
|
|
76
85
|
// issue with receipts not setting `willRetry` to false when they fail within a reasonable
|
|
77
86
|
// amount of time.
|
|
78
|
-
if (numChecks >
|
|
87
|
+
if (numChecks > maxChecks) {
|
|
79
88
|
failBackgroundDeletion(new BackgroundJobReceiptPollError({
|
|
80
89
|
errorType: BackgroundJobReceiptPollErrorType.TIMEOUT,
|
|
81
90
|
}));
|
package/build/utils/prompts.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
2
|
import { EnvironmentSecretType, EnvironmentVariableVisibility } from '../graphql/generated';
|
|
3
3
|
import { RequestedPlatform } from '../platform';
|
|
4
|
-
export declare function getProjectEnvironmentVariableEnvironmentsAsync(graphqlClient: ExpoGraphqlClient, projectId: string): Promise<string[]>;
|
|
5
4
|
export declare function promptVariableTypeAsync(nonInteractive: boolean, initialType?: EnvironmentSecretType): Promise<EnvironmentSecretType>;
|
|
6
5
|
export declare function parseVisibility(stringVisibility: 'plaintext' | 'sensitive' | 'secret'): EnvironmentVariableVisibility;
|
|
7
6
|
export declare function promptVariableVisibilityAsync(nonInteractive: boolean, selectedVisibility?: EnvironmentVariableVisibility | null): Promise<EnvironmentVariableVisibility>;
|
package/build/utils/prompts.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectEnvironmentVariableEnvironmentsAsync = getProjectEnvironmentVariableEnvironmentsAsync;
|
|
4
3
|
exports.promptVariableTypeAsync = promptVariableTypeAsync;
|
|
5
4
|
exports.parseVisibility = parseVisibility;
|
|
6
5
|
exports.promptVariableVisibilityAsync = promptVariableVisibilityAsync;
|
|
@@ -10,21 +9,11 @@ exports.promptVariableNameAsync = promptVariableNameAsync;
|
|
|
10
9
|
exports.promptPlatformAsync = promptPlatformAsync;
|
|
11
10
|
const tslib_1 = require("tslib");
|
|
12
11
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
13
|
-
const
|
|
12
|
+
const defaults_1 = require("../environments/defaults");
|
|
13
|
+
const variables_1 = require("../environments/variables");
|
|
14
14
|
const generated_1 = require("../graphql/generated");
|
|
15
|
-
const EnvironmentVariablesQuery_1 = require("../graphql/queries/EnvironmentVariablesQuery");
|
|
16
15
|
const platform_1 = require("../platform");
|
|
17
16
|
const prompts_1 = require("../prompts");
|
|
18
|
-
const DEFAULT_ENVIRONMENTS = Object.values(environment_1.DefaultEnvironment);
|
|
19
|
-
async function getProjectEnvironmentVariableEnvironmentsAsync(graphqlClient, projectId) {
|
|
20
|
-
try {
|
|
21
|
-
const environments = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.environmentVariableEnvironmentsAsync(graphqlClient, projectId);
|
|
22
|
-
return environments;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
throw new Error('Failed to fetch available environments');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
17
|
const CUSTOM_ENVIRONMENT_VALUE = '~~CUSTOM~~';
|
|
29
18
|
async function promptVariableTypeAsync(nonInteractive, initialType) {
|
|
30
19
|
if (nonInteractive) {
|
|
@@ -97,12 +86,12 @@ async function promptVariableVisibilityAsync(nonInteractive, selectedVisibility)
|
|
|
97
86
|
}
|
|
98
87
|
async function promptVariableEnvironmentAsync({ nonInteractive, selectedEnvironments, multiple = false, canEnterCustomEnvironment = false, graphqlClient, projectId, }) {
|
|
99
88
|
if (nonInteractive) {
|
|
100
|
-
throw new Error(`The \`--environment\` flag must be set when running in \`--non-interactive\` mode. Default environments: ${DEFAULT_ENVIRONMENTS.join(', ')}.`);
|
|
89
|
+
throw new Error(`The \`--environment\` flag must be set when running in \`--non-interactive\` mode. Default environments: ${defaults_1.DEFAULT_ENVIRONMENTS.join(', ')}.`);
|
|
101
90
|
}
|
|
102
|
-
let allEnvironments = DEFAULT_ENVIRONMENTS;
|
|
91
|
+
let allEnvironments = defaults_1.DEFAULT_ENVIRONMENTS;
|
|
103
92
|
if (graphqlClient && projectId) {
|
|
104
|
-
const projectEnvironments = await getProjectEnvironmentVariableEnvironmentsAsync(graphqlClient, projectId);
|
|
105
|
-
allEnvironments = [...new Set([...DEFAULT_ENVIRONMENTS, ...projectEnvironments])];
|
|
93
|
+
const projectEnvironments = await (0, variables_1.getProjectEnvironmentVariableEnvironmentsAsync)(graphqlClient, projectId);
|
|
94
|
+
allEnvironments = [...new Set([...defaults_1.DEFAULT_ENVIRONMENTS, ...projectEnvironments])];
|
|
106
95
|
}
|
|
107
96
|
if (!multiple) {
|
|
108
97
|
const choices = allEnvironments.map(environment => ({
|