eas-cli 21.7.1 → 22.0.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 (90) hide show
  1. package/README.md +258 -153
  2. package/build/build/android/prepareJob.js +1 -0
  3. package/build/build/ios/prepareJob.js +1 -0
  4. package/build/build/metadata.js +0 -1
  5. package/build/build/runBuildAndSubmit.js +1 -1
  6. package/build/build/utils/formatBuild.js +2 -2
  7. package/build/build/utils/url.js +3 -5
  8. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +10 -3
  9. package/build/commandUtils/new/configs.js +1 -1
  10. package/build/commandUtils/supabase.d.ts +13 -0
  11. package/build/commandUtils/supabase.js +82 -0
  12. package/build/commands/account/view.js +1 -2
  13. package/build/commands/build/cancel.js +3 -3
  14. package/build/commands/build/download.js +1 -1
  15. package/build/commands/go.js +2 -45
  16. package/build/commands/integrations/supabase/connect.d.ts +26 -0
  17. package/build/commands/integrations/supabase/connect.js +404 -0
  18. package/build/commands/integrations/supabase/dashboard.d.ts +14 -0
  19. package/build/commands/integrations/supabase/dashboard.js +69 -0
  20. package/build/commands/integrations/supabase/disconnect.d.ts +15 -0
  21. package/build/commands/integrations/supabase/disconnect.js +87 -0
  22. package/build/commands/project/icon/set.js +4 -40
  23. package/build/commands/project/init.d.ts +1 -0
  24. package/build/commands/project/init.js +13 -0
  25. package/build/commands/submit.d.ts +1 -0
  26. package/build/commands/submit.js +8 -1
  27. package/build/commands/update/index.js +1 -1
  28. package/build/commands/update/revert-update-rollout.js +1 -1
  29. package/build/commands/update/rollback.js +1 -1
  30. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.js +20 -13
  31. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.d.ts +14 -2
  32. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.js +47 -7
  33. package/build/credentials/ios/appstore/ensureTestFlightGroup.d.ts +3 -1
  34. package/build/credentials/ios/appstore/ensureTestFlightGroup.js +14 -11
  35. package/build/environments/defaults.d.ts +2 -0
  36. package/build/environments/defaults.js +5 -0
  37. package/build/environments/resolve.d.ts +10 -0
  38. package/build/environments/resolve.js +67 -0
  39. package/build/environments/variables.d.ts +18 -0
  40. package/build/environments/variables.js +124 -0
  41. package/build/graphql/client.d.ts +8 -0
  42. package/build/graphql/client.js +15 -0
  43. package/build/graphql/generated.d.ts +824 -948
  44. package/build/graphql/generated.js +12 -2
  45. package/build/graphql/mutations/SupabaseMutation.d.ts +14 -0
  46. package/build/graphql/mutations/SupabaseMutation.js +145 -0
  47. package/build/graphql/queries/ChannelInsightsQuery.js +4 -1
  48. package/build/graphql/queries/SupabaseQuery.d.ts +10 -0
  49. package/build/graphql/queries/SupabaseQuery.js +54 -0
  50. package/build/graphql/types/Account.js +1 -4
  51. package/build/graphql/types/Build.js +13 -8
  52. package/build/graphql/types/Submission.js +0 -1
  53. package/build/graphql/types/SupabaseConnection.d.ts +8 -0
  54. package/build/graphql/types/SupabaseConnection.js +25 -0
  55. package/build/graphql/types/Update.js +4 -1
  56. package/build/integrations/shared/envFile.d.ts +7 -0
  57. package/build/integrations/shared/envFile.js +94 -0
  58. package/build/integrations/shared/sdk.d.ts +24 -0
  59. package/build/integrations/shared/sdk.js +87 -0
  60. package/build/integrations/supabase/env.d.ts +14 -0
  61. package/build/integrations/supabase/env.js +68 -0
  62. package/build/integrations/supabase/provision.d.ts +32 -0
  63. package/build/integrations/supabase/provision.js +245 -0
  64. package/build/project/accountSelection.js +1 -3
  65. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +3 -5
  66. package/build/project/projectIcon.d.ts +40 -0
  67. package/build/project/projectIcon.js +132 -0
  68. package/build/project/projectNotConfiguredError.d.ts +17 -0
  69. package/build/project/projectNotConfiguredError.js +24 -0
  70. package/build/submit/ArchiveSource.js +3 -3
  71. package/build/submit/context.d.ts +2 -0
  72. package/build/submit/context.js +1 -0
  73. package/build/submit/ios/AppProduce.js +1 -1
  74. package/build/submit/ios/IosSubmitCommand.js +2 -0
  75. package/build/submit/ios/ensureTestFlightSetup.d.ts +7 -0
  76. package/build/submit/ios/ensureTestFlightSetup.js +81 -0
  77. package/build/submit/status.js +1 -1
  78. package/build/submit/utils/formatSubmission.js +2 -2
  79. package/build/update/queries.js +1 -1
  80. package/build/update/republish.js +3 -3
  81. package/build/update/roll-back-to-embedded.js +1 -1
  82. package/build/update/utils.d.ts +2 -1
  83. package/build/update/utils.js +7 -7
  84. package/build/user/User.js +1 -1
  85. package/build/utils/pollForBackgroundJobReceiptAsync.d.ts +2 -0
  86. package/build/utils/pollForBackgroundJobReceiptAsync.js +11 -2
  87. package/build/utils/prompts.d.ts +0 -1
  88. package/build/utils/prompts.js +6 -17
  89. package/oclif.manifest.json +1725 -1411
  90. package/package.json +6 -6
@@ -0,0 +1,404 @@
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 zod_1 = require("zod");
7
+ const EasCommand_1 = tslib_1.__importDefault(require("../../../commandUtils/EasCommand"));
8
+ const flags_1 = require("../../../commandUtils/flags");
9
+ const supabase_1 = require("../../../commandUtils/supabase");
10
+ const SupabaseMutation_1 = require("../../../graphql/mutations/SupabaseMutation");
11
+ const SupabaseQuery_1 = require("../../../graphql/queries/SupabaseQuery");
12
+ const log_1 = tslib_1.__importStar(require("../../../log"));
13
+ const projectUtils_1 = require("../../../project/projectUtils");
14
+ const prompts_1 = require("../../../prompts");
15
+ const json_1 = require("../../../utils/json");
16
+ const resolve_1 = require("../../../environments/resolve");
17
+ const variables_1 = require("../../../environments/variables");
18
+ const envFile_1 = require("../../../integrations/shared/envFile");
19
+ const sdk_1 = require("../../../integrations/shared/sdk");
20
+ const env_1 = require("../../../integrations/supabase/env");
21
+ const provision_1 = require("../../../integrations/supabase/provision");
22
+ const SDK_PACKAGES = ['@supabase/supabase-js', 'expo-sqlite'];
23
+ const CONFIG_PLUGIN = 'expo-sqlite';
24
+ const PrimaryProvisionResultSchema = zod_1.z.object({
25
+ supabaseProjectId: zod_1.z.string().optional(),
26
+ supabaseProjectRef: zod_1.z.string().optional(),
27
+ });
28
+ const AdditionalProvisionResultSchema = zod_1.z.object({
29
+ supabaseProjectRef: zod_1.z.string(),
30
+ supabaseProjectName: zod_1.z.string().optional(),
31
+ supabaseProjectUrl: zod_1.z.string(),
32
+ supabaseRegion: zod_1.z.string().optional(),
33
+ publishableKey: zod_1.z.string(),
34
+ });
35
+ class IntegrationsSupabaseConnect extends EasCommand_1.default {
36
+ static description = 'authorize Supabase, link or provision a project, install the SDK, and write EXPO_PUBLIC_SUPABASE_URL / EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY';
37
+ static examples = [
38
+ '<%= config.bin %> <%= command.id %>',
39
+ '<%= config.bin %> <%= command.id %> --link <project-url>',
40
+ '<%= config.bin %> <%= command.id %> --environment preview',
41
+ '<%= config.bin %> <%= command.id %> --environment preview --region americas --non-interactive --overwrite',
42
+ '<%= config.bin %> <%= command.id %> --reauth',
43
+ ];
44
+ static contextDefinition = {
45
+ ...this.ContextOptions.ProjectConfig,
46
+ };
47
+ static flags = {
48
+ ...flags_1.EasNonInteractiveAndJsonFlags,
49
+ region: core_1.Flags.string({
50
+ description: 'Region when provisioning (americas | emea | apac, or e.g. us-east-1). Required with --non-interactive if provisioning. Ignored with --link or if already linked',
51
+ }),
52
+ organization: core_1.Flags.string({
53
+ description: 'Supabase org slug for a new primary project. Ignored with --link; incompatible with --environment',
54
+ }),
55
+ link: core_1.Flags.string({
56
+ description: 'Existing project URL or Reference ID (Project Settings → General). Sets the app primary instead of provisioning. Incompatible with --environment',
57
+ }),
58
+ reauth: core_1.Flags.boolean({
59
+ description: 'Disconnect the existing Supabase OAuth connection, then re-authorize in the browser. Removes the EAS connection and primary project link (Supabase projects are kept). Then prompts to link an existing project (default) or provision a new one; pass --link to skip the prompt. Interactive only; incompatible with --environment',
60
+ default: false,
61
+ }),
62
+ overwrite: core_1.Flags.boolean({
63
+ description: 'Replace existing EXPO_PUBLIC_SUPABASE_* in .env.local and EAS without prompting',
64
+ default: false,
65
+ }),
66
+ environment: core_1.Flags.string({
67
+ description: 'EAS environments for a separate hosted project (e.g. preview). Requires prior primary connect; writes URL/key only there. Incompatible with --link and --reauth',
68
+ }),
69
+ };
70
+ async runAsync() {
71
+ const { flags } = await this.parse(IntegrationsSupabaseConnect);
72
+ const { region: regionFlag, organization: organizationFlag, link: linkRefFlag, reauth, overwrite, environment: environmentFlag, } = flags;
73
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
74
+ const requestedEnvironments = (0, resolve_1.parseEnvironmentFlag)(environmentFlag);
75
+ const linkProjectRef = linkRefFlag ? (0, supabase_1.parseSupabaseProjectRef)(linkRefFlag) : undefined;
76
+ if (jsonFlag) {
77
+ (0, json_1.enableJsonOutput)();
78
+ }
79
+ const { privateProjectConfig: { projectId, projectDir, exp }, loggedIn: { graphqlClient }, } = await this.getContextAsync(IntegrationsSupabaseConnect, {
80
+ nonInteractive,
81
+ withServerSideEnvironment: null,
82
+ });
83
+ if (requestedEnvironments) {
84
+ if (linkRefFlag) {
85
+ throw new Error('Cannot combine --environment with --link. --link sets the primary project; --environment provisions an additional one for the listed EAS environments.');
86
+ }
87
+ if (reauth) {
88
+ throw new Error('Cannot combine --environment with --reauth. Re-authorize first, then re-run with --environment.');
89
+ }
90
+ if (organizationFlag) {
91
+ throw new Error('Cannot use --organization with --environment. The additional project uses the organization from the existing connection.');
92
+ }
93
+ const targetEnvironments = await (0, resolve_1.resolveTargetEnvironmentsAsync)(graphqlClient, projectId, requestedEnvironments, nonInteractive, {
94
+ defaultEnvironments: env_1.EAS_SUPABASE_ENVIRONMENTS,
95
+ cancelMessage: env_1.supabaseEnvironmentCancelMessage,
96
+ });
97
+ await this.runAdditionalEnvironmentSetupAsync({
98
+ graphqlClient,
99
+ projectId,
100
+ targetEnvironments,
101
+ regionFlag,
102
+ nonInteractive,
103
+ overwrite,
104
+ jsonFlag,
105
+ });
106
+ return;
107
+ }
108
+ const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId);
109
+ let connection = await SupabaseQuery_1.SupabaseQuery.getSupabaseConnectionByAccountIdAsync(graphqlClient, account.id);
110
+ let didReauth = false;
111
+ if (reauth) {
112
+ if (!connection) {
113
+ if (!nonInteractive) {
114
+ log_1.default.warn('--reauth ignored: no existing Supabase connection to reset.');
115
+ }
116
+ }
117
+ else if (nonInteractive) {
118
+ throw new Error("--reauth re-authorizes in the browser, which isn't possible in non-interactive mode. Re-run `eas integrations:supabase:connect --reauth` interactively.");
119
+ }
120
+ else {
121
+ log_1.default.warn('Resetting the Supabase connection. This removes the EAS connection and its project link (your Supabase projects are preserved). After authorizing, you will be asked to link an existing project (recommended) or provision a new one.');
122
+ await SupabaseMutation_1.SupabaseMutation.disconnectSupabaseAsync(graphqlClient, connection.id);
123
+ log_1.default.withTick('Reset the existing Supabase connection');
124
+ connection = null;
125
+ didReauth = true;
126
+ }
127
+ }
128
+ let organizations = null;
129
+ let authorizedConnection;
130
+ if (connection) {
131
+ organizations = await (0, provision_1.loadOrganizationsBestEffortAsync)(graphqlClient, account.id);
132
+ log_1.default.withTick(`Using existing Supabase organization ${chalk_1.default.bold((0, supabase_1.formatSupabaseOrganization)(connection, organizations ?? undefined))}`);
133
+ authorizedConnection = connection;
134
+ }
135
+ else {
136
+ authorizedConnection = await (0, provision_1.authorizeViaBrowserAsync)(graphqlClient, account, nonInteractive);
137
+ }
138
+ connection = authorizedConnection;
139
+ let project = await SupabaseQuery_1.SupabaseQuery.getSupabaseProjectByAppIdAsync(graphqlClient, projectId);
140
+ if (project) {
141
+ log_1.default.withTick(`Using existing Supabase project ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(project))}`);
142
+ if (linkProjectRef && linkProjectRef !== project.supabaseProjectRef) {
143
+ log_1.default.warn(`Ignoring --link ${chalk_1.default.bold(linkProjectRef)}: this app is already linked to ${chalk_1.default.bold(project.supabaseProjectRef)}. Run \`eas integrations:supabase:disconnect\` first to link a different project.`);
144
+ }
145
+ else if (regionFlag || organizationFlag) {
146
+ log_1.default.warn('Ignoring --region/--organization: this app is already linked to a Supabase project.');
147
+ }
148
+ }
149
+ else if (linkProjectRef) {
150
+ // No org picker here: the project ref determines its organization, and the server validates
151
+ // that it matches the connection's organization.
152
+ project = await SupabaseMutation_1.SupabaseMutation.linkSupabaseProjectAsync(graphqlClient, {
153
+ appId: projectId,
154
+ supabaseProjectRef: linkProjectRef,
155
+ });
156
+ log_1.default.withTick(`Linked Supabase project ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(project))}`);
157
+ }
158
+ else if (didReauth) {
159
+ const afterReauth = await this.resolveProjectAfterReauthAsync({
160
+ graphqlClient,
161
+ projectId,
162
+ accountId: account.id,
163
+ connection: authorizedConnection,
164
+ organizationFlag,
165
+ regionFlag,
166
+ nonInteractive,
167
+ organizations,
168
+ });
169
+ project = afterReauth.project;
170
+ authorizedConnection = afterReauth.connection;
171
+ connection = authorizedConnection;
172
+ }
173
+ else {
174
+ authorizedConnection = await (0, provision_1.resolveOrganizationAsync)(graphqlClient, account.id, authorizedConnection, organizationFlag, nonInteractive, organizations);
175
+ connection = authorizedConnection;
176
+ const region = await (0, provision_1.resolveRegionAsync)(regionFlag, nonInteractive);
177
+ project = await this.provisionAndPollPrimaryProjectAsync(graphqlClient, projectId, region);
178
+ }
179
+ const publishableKey = await (0, provision_1.resolvePublishableKeyAsync)(graphqlClient, projectId, project);
180
+ const envVars = (0, env_1.createSupabaseEnvVars)(project.supabaseProjectUrl, publishableKey);
181
+ const manualSteps = await (0, sdk_1.setupSdkAndConfigAsync)(projectDir, exp, {
182
+ packages: SDK_PACKAGES,
183
+ plugin: CONFIG_PLUGIN,
184
+ label: env_1.SUPABASE_ENV_LABEL,
185
+ jsonFlag,
186
+ });
187
+ const envLocalWritten = await (0, envFile_1.writeEnvLocalAsync)(projectDir, envVars, {
188
+ label: env_1.SUPABASE_ENV_LABEL,
189
+ nonInteractive,
190
+ overwrite,
191
+ });
192
+ const easWritten = await (0, variables_1.upsertEnvVarsSequentiallyAsync)(envVars, envVar => (0, variables_1.upsertEnvVarAsync)(graphqlClient, projectId, envVar, env_1.EAS_SUPABASE_ENVIRONMENTS, nonInteractive, overwrite, { mode: 'replaceOtherEnvironments' }));
193
+ if (jsonFlag) {
194
+ (0, json_1.printJsonOnlyOutput)({
195
+ organizationConnection: {
196
+ id: connection.id,
197
+ organizationSlug: connection.supabaseOrganizationSlug,
198
+ },
199
+ project: {
200
+ id: project.id,
201
+ ref: project.supabaseProjectRef,
202
+ url: project.supabaseProjectUrl,
203
+ region: project.supabaseRegion,
204
+ },
205
+ dashboardUrl: (0, supabase_1.getSupabaseProjectDashboardUrl)(project),
206
+ envLocalWritten,
207
+ environmentVariables: envVars.map((v, i) => ({ name: v.name, easWritten: easWritten[i] })),
208
+ manualSteps,
209
+ });
210
+ return;
211
+ }
212
+ this.printNextSteps(project, manualSteps);
213
+ }
214
+ async resolveProjectAfterReauthAsync({ graphqlClient, projectId, accountId, connection, organizationFlag, regionFlag, nonInteractive, organizations, }) {
215
+ // --reauth already required interactive mode when a connection existed.
216
+ const choice = await (0, prompts_1.selectAsync)('The previous EAS project link was removed. What next?', [
217
+ { title: 'Link an existing Supabase project (recommended)', value: 'link' },
218
+ { title: 'Provision a new Supabase project', value: 'provision' },
219
+ ], { initial: 'link' });
220
+ if (choice === 'link') {
221
+ const { linkValue } = await (0, prompts_1.promptAsync)({
222
+ type: 'text',
223
+ name: 'linkValue',
224
+ message: 'Supabase project ref or URL',
225
+ validate: (value) => {
226
+ try {
227
+ (0, supabase_1.parseSupabaseProjectRef)(value);
228
+ return true;
229
+ }
230
+ catch (error) {
231
+ return error instanceof Error ? error.message : 'Invalid project ref or URL';
232
+ }
233
+ },
234
+ });
235
+ const project = await SupabaseMutation_1.SupabaseMutation.linkSupabaseProjectAsync(graphqlClient, {
236
+ appId: projectId,
237
+ supabaseProjectRef: (0, supabase_1.parseSupabaseProjectRef)(linkValue),
238
+ });
239
+ log_1.default.withTick(`Linked Supabase project ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(project))}`);
240
+ return { project, connection };
241
+ }
242
+ const nextConnection = await (0, provision_1.resolveOrganizationAsync)(graphqlClient, accountId, connection, organizationFlag, nonInteractive, organizations);
243
+ const region = await (0, provision_1.resolveRegionAsync)(regionFlag, nonInteractive);
244
+ const project = await this.provisionAndPollPrimaryProjectAsync(graphqlClient, projectId, region);
245
+ return { project, connection: nextConnection };
246
+ }
247
+ async provisionAndPollPrimaryProjectAsync(graphqlClient, projectId, region) {
248
+ const receipt = await SupabaseMutation_1.SupabaseMutation.provisionSupabaseProjectAsync(graphqlClient, {
249
+ appId: projectId,
250
+ region,
251
+ });
252
+ const finalized = await (0, provision_1.pollProvisionReceiptAsync)(graphqlClient, receipt, {
253
+ startMessage: 'Provisioning Supabase project (this can take a minute)…',
254
+ waitingMessage: 'Waiting for Expo to finish Supabase setup…',
255
+ failureMessage: 'Failed to provision the Supabase project',
256
+ failureHint: (0, provision_1.primaryProvisionFailureHint)(),
257
+ });
258
+ const parsedResult = PrimaryProvisionResultSchema.safeParse(finalized.resultData);
259
+ const resultData = parsedResult.success ? parsedResult.data : undefined;
260
+ const project = await SupabaseQuery_1.SupabaseQuery.getSupabaseProjectByAppIdAsync(graphqlClient, projectId, {
261
+ useCache: false,
262
+ });
263
+ if (!project) {
264
+ throw new Error(resultData?.supabaseProjectRef
265
+ ? `Provision succeeded for project ${resultData.supabaseProjectRef}, but the Expo project link was not found. Try again, or link with --link ${resultData.supabaseProjectRef}.`
266
+ : 'Provision succeeded but the Expo project link was not found. Try again, or link an existing project with --link.');
267
+ }
268
+ log_1.default.withTick(`Provisioned Supabase project ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(project))}`);
269
+ return project;
270
+ }
271
+ async runAdditionalEnvironmentSetupAsync({ graphqlClient, projectId, targetEnvironments, regionFlag, nonInteractive, overwrite, jsonFlag, }) {
272
+ const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId);
273
+ let connection = await SupabaseQuery_1.SupabaseQuery.getSupabaseConnectionByAccountIdAsync(graphqlClient, account.id);
274
+ if (!connection) {
275
+ throw new Error('No Supabase connection found. Run `eas integrations:supabase:connect` first, then re-run with --environment.');
276
+ }
277
+ const primaryProject = await SupabaseQuery_1.SupabaseQuery.getSupabaseProjectByAppIdAsync(graphqlClient, projectId);
278
+ if (!primaryProject) {
279
+ throw new Error('No primary Supabase project is linked yet. Run `eas integrations:supabase:connect` without --environment first.');
280
+ }
281
+ const organizations = await (0, provision_1.loadOrganizationsBestEffortAsync)(graphqlClient, account.id);
282
+ log_1.default.withTick(`Using existing Supabase organization ${chalk_1.default.bold((0, supabase_1.formatSupabaseOrganization)(connection, organizations ?? undefined))}`);
283
+ log_1.default.withTick(`Primary project remains ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(primaryProject))}; provisioning an additional project for ${targetEnvironments.join(', ')}`);
284
+ const region = await (0, provision_1.resolveRegionAsync)(regionFlag, nonInteractive);
285
+ const projectNameSuffix = (0, provision_1.projectNameSuffixForEnvironments)(targetEnvironments);
286
+ // Fail closed before billing: refuse to provision if we already know env writes will be skipped.
287
+ const { forceOverwrite } = await (0, env_1.confirmOverwriteForAdditionalProjectAsync)(graphqlClient, projectId, targetEnvironments, nonInteractive, overwrite);
288
+ const effectiveOverwrite = overwrite || forceOverwrite;
289
+ const additional = await this.provisionAndPollAdditionalProjectAsync(graphqlClient, projectId, {
290
+ region,
291
+ projectNameSuffix,
292
+ targetEnvironments,
293
+ });
294
+ const envVars = (0, env_1.createSupabaseEnvVars)(additional.supabaseProjectUrl, additional.publishableKey);
295
+ const dashboardUrl = (0, supabase_1.getSupabaseProjectDashboardUrl)({
296
+ supabaseProjectRef: additional.supabaseProjectRef,
297
+ });
298
+ let easWritten = [];
299
+ try {
300
+ easWritten = await (0, variables_1.upsertEnvVarsSequentiallyAsync)(envVars, envVar => (0, variables_1.upsertEnvVarAsync)(graphqlClient, projectId, envVar, targetEnvironments, nonInteractive, effectiveOverwrite, {
301
+ mode: 'keepOtherEnvironments',
302
+ moveConfirmMessage: env_1.supabaseMoveConfirmMessage,
303
+ }));
304
+ }
305
+ catch (error) {
306
+ const message = error instanceof Error ? error.message : String(error);
307
+ throw this.additionalEnvWriteFailureError({
308
+ additional,
309
+ targetEnvironments,
310
+ dashboardUrl,
311
+ headline: `Provisioned additional Supabase project ${additional.supabaseProjectRef}, but could not write EAS environment variables for ${targetEnvironments.join(', ')}: ${message}`,
312
+ });
313
+ }
314
+ if (easWritten.some(written => !written)) {
315
+ throw this.additionalEnvWriteFailureError({
316
+ additional,
317
+ targetEnvironments,
318
+ dashboardUrl,
319
+ headline: `Provisioned additional Supabase project ${additional.supabaseProjectRef}, but did not write all EAS environment variables for ${targetEnvironments.join(', ')}.`,
320
+ });
321
+ }
322
+ if (jsonFlag) {
323
+ (0, json_1.printJsonOnlyOutput)({
324
+ additionalProject: {
325
+ ref: additional.supabaseProjectRef,
326
+ url: additional.supabaseProjectUrl,
327
+ region: additional.supabaseRegion,
328
+ },
329
+ environments: targetEnvironments,
330
+ dashboardUrl,
331
+ environmentVariables: envVars.map((v, i) => ({ name: v.name, easWritten: easWritten[i] })),
332
+ });
333
+ return;
334
+ }
335
+ log_1.default.addNewLineIfNone();
336
+ log_1.default.log(chalk_1.default.green('Additional Supabase project is ready!'));
337
+ log_1.default.newLine();
338
+ log_1.default.log(`${chalk_1.default.bold('Dashboard')}: ${(0, log_1.link)(dashboardUrl, { dim: false })}`);
339
+ log_1.default.log(`EAS environment variables updated for: ${targetEnvironments.map(env => chalk_1.default.bold(env)).join(', ')}`);
340
+ log_1.default.log(`Primary linked project is unchanged (${chalk_1.default.bold(primaryProject.supabaseProjectRef)}).`);
341
+ }
342
+ async provisionAndPollAdditionalProjectAsync(graphqlClient, projectId, { region, projectNameSuffix, targetEnvironments, }) {
343
+ const receipt = await SupabaseMutation_1.SupabaseMutation.provisionAdditionalSupabaseProjectAsync(graphqlClient, {
344
+ appId: projectId,
345
+ region,
346
+ projectNameSuffix,
347
+ });
348
+ const finalized = await (0, provision_1.pollProvisionReceiptAsync)(graphqlClient, receipt, {
349
+ startMessage: `Provisioning additional Supabase project for ${targetEnvironments.join(', ')}…`,
350
+ waitingMessage: 'Waiting for Expo to finish additional Supabase setup…',
351
+ failureMessage: 'Failed to provision the additional Supabase project',
352
+ failureHint: (0, provision_1.additionalProvisionFailureHint)(targetEnvironments),
353
+ });
354
+ const parsedResult = AdditionalProvisionResultSchema.safeParse(finalized.resultData);
355
+ if (!parsedResult.success) {
356
+ throw new Error('Additional provision succeeded but did not return project credentials. Open your Supabase dashboard, copy the project URL and publishable key, and set EXPO_PUBLIC_SUPABASE_URL / EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY on the target EAS environments. Do not re-run connect --environment — that would create another project.');
357
+ }
358
+ const resultData = parsedResult.data;
359
+ const additional = {
360
+ supabaseProjectRef: resultData.supabaseProjectRef,
361
+ supabaseProjectName: resultData.supabaseProjectName ?? resultData.supabaseProjectRef,
362
+ supabaseProjectUrl: resultData.supabaseProjectUrl,
363
+ supabaseRegion: resultData.supabaseRegion ?? region,
364
+ publishableKey: resultData.publishableKey,
365
+ };
366
+ log_1.default.withTick(`Provisioned additional Supabase project ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(additional))}`);
367
+ return additional;
368
+ }
369
+ additionalEnvWriteFailureError({ additional, targetEnvironments, dashboardUrl, headline, }) {
370
+ return new Error([
371
+ headline,
372
+ `Do not re-run connect --environment — the Supabase project already exists. Set these on ${targetEnvironments.join(', ')}:`,
373
+ ` EXPO_PUBLIC_SUPABASE_URL=${additional.supabaseProjectUrl}`,
374
+ ` EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY=${additional.publishableKey}`,
375
+ `Dashboard: ${dashboardUrl}`,
376
+ ].join('\n'));
377
+ }
378
+ printNextSteps(project, manualSteps) {
379
+ log_1.default.addNewLineIfNone();
380
+ log_1.default.log(chalk_1.default.green('Supabase is connected!'));
381
+ log_1.default.newLine();
382
+ log_1.default.log(`${chalk_1.default.bold('Dashboard')}: ${(0, log_1.link)((0, supabase_1.getSupabaseProjectDashboardUrl)(project), { dim: false })}`);
383
+ log_1.default.newLine();
384
+ log_1.default.log('Next steps:');
385
+ log_1.default.log(` 1. Create a Supabase client (e.g. ${chalk_1.default.bold('src/lib/supabase.ts')}) following our guide (${chalk_1.default.cyan('https://docs.expo.dev/guides/using-supabase')}). It reads ${chalk_1.default.bold(env_1.EAS_SUPABASE_URL_ENV_VAR_NAME)} and ${chalk_1.default.bold(env_1.EAS_SUPABASE_PUBLISHABLE_KEY_ENV_VAR_NAME)}, and runs in Expo Go.`);
386
+ log_1.default.log(` 2. For local development, run ${chalk_1.default.cyan('supabase start')} and point ${chalk_1.default.bold(env_1.EAS_SUPABASE_URL_ENV_VAR_NAME)} at the local stack (see the guide).`);
387
+ log_1.default.log(` 3. For a separate hosted project for Preview (or other EAS environments), re-run ${chalk_1.default.cyan('eas integrations:supabase:connect --environment preview')}.`);
388
+ if (manualSteps.length > 0) {
389
+ log_1.default.newLine();
390
+ log_1.default.warn('Finish setup manually:');
391
+ for (const step of manualSteps) {
392
+ if (step.includes('\n')) {
393
+ for (const line of step.split('\n')) {
394
+ log_1.default.warn(` ${line}`);
395
+ }
396
+ }
397
+ else {
398
+ log_1.default.warn(` • ${step}`);
399
+ }
400
+ }
401
+ }
402
+ }
403
+ }
404
+ exports.default = IntegrationsSupabaseConnect;
@@ -0,0 +1,14 @@
1
+ import EasCommand from '../../../commandUtils/EasCommand';
2
+ export default class IntegrationsSupabaseDashboard extends EasCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ static contextDefinition: {
10
+ loggedIn: import("../../../commandUtils/context/LoggedInContextField").default;
11
+ privateProjectConfig: import("../../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
12
+ };
13
+ runAsync(): Promise<void>;
14
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const better_opn_1 = tslib_1.__importDefault(require("better-opn"));
5
+ const EasCommand_1 = tslib_1.__importDefault(require("../../../commandUtils/EasCommand"));
6
+ const flags_1 = require("../../../commandUtils/flags");
7
+ const supabase_1 = require("../../../commandUtils/supabase");
8
+ const SupabaseQuery_1 = require("../../../graphql/queries/SupabaseQuery");
9
+ const log_1 = tslib_1.__importDefault(require("../../../log"));
10
+ const ora_1 = require("../../../ora");
11
+ const json_1 = require("../../../utils/json");
12
+ class IntegrationsSupabaseDashboard extends EasCommand_1.default {
13
+ static description = "open this app's primary Supabase project in the dashboard (or print the URL with --non-interactive)";
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %>',
16
+ '<%= config.bin %> <%= command.id %> --non-interactive',
17
+ ];
18
+ static flags = {
19
+ ...flags_1.EasNonInteractiveAndJsonFlags,
20
+ };
21
+ static contextDefinition = {
22
+ ...this.ContextOptions.ProjectConfig,
23
+ };
24
+ async runAsync() {
25
+ const { flags } = await this.parse(IntegrationsSupabaseDashboard);
26
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
27
+ if (jsonFlag) {
28
+ (0, json_1.enableJsonOutput)();
29
+ }
30
+ const { privateProjectConfig: { projectId, exp }, loggedIn: { graphqlClient }, } = await this.getContextAsync(IntegrationsSupabaseDashboard, {
31
+ nonInteractive,
32
+ withServerSideEnvironment: null,
33
+ });
34
+ const project = await SupabaseQuery_1.SupabaseQuery.getSupabaseProjectByAppIdAsync(graphqlClient, projectId);
35
+ if (!project) {
36
+ if (jsonFlag) {
37
+ (0, json_1.printJsonOnlyOutput)({ dashboardUrl: null });
38
+ }
39
+ else {
40
+ (0, supabase_1.logNoSupabaseProject)(exp.slug);
41
+ }
42
+ return;
43
+ }
44
+ const dashboardUrl = (0, supabase_1.getSupabaseProjectDashboardUrl)(project);
45
+ if (jsonFlag) {
46
+ (0, json_1.printJsonOnlyOutput)({ dashboardUrl });
47
+ return;
48
+ }
49
+ if (nonInteractive) {
50
+ log_1.default.log(dashboardUrl);
51
+ return;
52
+ }
53
+ const spinner = (0, ora_1.ora)('Opening your Supabase dashboard').start();
54
+ try {
55
+ const opened = await (0, better_opn_1.default)(dashboardUrl);
56
+ if (opened) {
57
+ spinner.succeed('Opened your Supabase dashboard');
58
+ }
59
+ else {
60
+ spinner.fail(`Unable to open a web browser. Supabase dashboard: ${dashboardUrl}`);
61
+ }
62
+ }
63
+ catch (error) {
64
+ spinner.fail(`Unable to open a web browser. Supabase dashboard: ${dashboardUrl}`);
65
+ throw error;
66
+ }
67
+ }
68
+ }
69
+ exports.default = IntegrationsSupabaseDashboard;
@@ -0,0 +1,15 @@
1
+ import EasCommand from '../../../commandUtils/EasCommand';
2
+ export default class IntegrationsSupabaseDisconnect extends EasCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ yes: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ static contextDefinition: {
11
+ loggedIn: import("../../../commandUtils/context/LoggedInContextField").default;
12
+ privateProjectConfig: import("../../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
13
+ };
14
+ runAsync(): Promise<void>;
15
+ }
@@ -0,0 +1,87 @@
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 supabase_1 = require("../../../commandUtils/supabase");
9
+ const SupabaseMutation_1 = require("../../../graphql/mutations/SupabaseMutation");
10
+ const SupabaseQuery_1 = require("../../../graphql/queries/SupabaseQuery");
11
+ const log_1 = tslib_1.__importDefault(require("../../../log"));
12
+ const ora_1 = require("../../../ora");
13
+ const prompts_1 = require("../../../prompts");
14
+ const json_1 = require("../../../utils/json");
15
+ class IntegrationsSupabaseDisconnect extends EasCommand_1.default {
16
+ static description = "remove this app's Supabase project link from EAS (keeps the Supabase project; does not delete EXPO_PUBLIC_SUPABASE_* env vars)";
17
+ static examples = [
18
+ '<%= config.bin %> <%= command.id %>',
19
+ '<%= config.bin %> <%= command.id %> --yes',
20
+ ];
21
+ static flags = {
22
+ ...flags_1.EasNonInteractiveAndJsonFlags,
23
+ yes: core_1.Flags.boolean({
24
+ char: 'y',
25
+ description: 'Skip confirmation prompt',
26
+ default: false,
27
+ }),
28
+ };
29
+ static contextDefinition = {
30
+ ...this.ContextOptions.ProjectConfig,
31
+ };
32
+ async runAsync() {
33
+ const { flags } = await this.parse(IntegrationsSupabaseDisconnect);
34
+ const { yes } = flags;
35
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
36
+ if (jsonFlag) {
37
+ (0, json_1.enableJsonOutput)();
38
+ }
39
+ const { privateProjectConfig: { projectId, exp }, loggedIn: { graphqlClient }, } = await this.getContextAsync(IntegrationsSupabaseDisconnect, {
40
+ nonInteractive,
41
+ withServerSideEnvironment: null,
42
+ });
43
+ const project = await SupabaseQuery_1.SupabaseQuery.getSupabaseProjectByAppIdAsync(graphqlClient, projectId);
44
+ if (!project) {
45
+ if (jsonFlag) {
46
+ (0, json_1.printJsonOnlyOutput)({ id: null });
47
+ }
48
+ else {
49
+ (0, supabase_1.logNoSupabaseProject)(exp.slug);
50
+ }
51
+ return;
52
+ }
53
+ if (!jsonFlag) {
54
+ log_1.default.addNewLineIfNone();
55
+ log_1.default.log((0, supabase_1.formatSupabaseProject)(project));
56
+ log_1.default.newLine();
57
+ }
58
+ if (!nonInteractive && !yes) {
59
+ const confirmed = await (0, prompts_1.confirmAsync)({
60
+ message: 'Remove this Supabase project link from EAS servers? This does not delete the project on Supabase.',
61
+ });
62
+ if (!confirmed) {
63
+ log_1.default.warn('Canceled removal of the Supabase project link.');
64
+ return;
65
+ }
66
+ }
67
+ else if (!jsonFlag) {
68
+ log_1.default.warn('Removing the Supabase project link from EAS servers. This does not delete the project on Supabase.');
69
+ }
70
+ const spinner = jsonFlag ? null : (0, ora_1.ora)('Removing Supabase project link').start();
71
+ try {
72
+ await SupabaseMutation_1.SupabaseMutation.deleteSupabaseProjectAsync(graphqlClient, project.id);
73
+ spinner?.succeed(`Removed Supabase project ${chalk_1.default.bold((0, supabase_1.formatSupabaseProjectLabel)(project))} from EAS servers`);
74
+ }
75
+ catch (error) {
76
+ spinner?.fail('Failed to remove Supabase project link');
77
+ throw error;
78
+ }
79
+ if (jsonFlag) {
80
+ (0, json_1.printJsonOnlyOutput)({ id: project.id, ref: project.supabaseProjectRef });
81
+ return;
82
+ }
83
+ log_1.default.newLine();
84
+ log_1.default.log(`The ${chalk_1.default.bold('EXPO_PUBLIC_SUPABASE_URL')} and ${chalk_1.default.bold('EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY')} values remain in ${chalk_1.default.bold('.env.local')} and in your EAS environment variables. Remove them if you no longer need them.`);
85
+ }
86
+ }
87
+ exports.default = IntegrationsSupabaseDisconnect;