create-disposabl-app 0.6.8 → 0.7.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/dist/disposabl.js +32 -8
- package/dist/index.js +16 -6
- package/dist/templates/default/.github/scripts/mobile.sh +123 -0
- package/dist/templates/default/.github/scripts/release.sh +83 -0
- package/dist/templates/default/.github/workflows/pipeline.yml +22 -14
- package/dist/templates/default/AGENTS.md +2 -1
- package/dist/templates/default/apps/mobile/gitignore +43 -0
- package/dist/templates/default/apps/web/src/routeTree.gen.ts +23 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.connections.tsx +354 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +1 -0
- package/dist/templates/default/packages/backend/AGENTS.md +2 -1
- package/dist/templates/default/packages/backend/README.md +4 -2
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +14 -0
- package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +5 -5
- package/dist/templates/default/packages/backend/convex/apps/actions/create.ts +11 -13
- package/dist/templates/default/packages/backend/convex/apps/actions/setup.ts +21 -7
- package/dist/templates/default/packages/backend/convex/apps/internal.ts +1 -6
- package/dist/templates/default/packages/backend/convex/connections/actions/credentials.ts +56 -0
- package/dist/templates/default/packages/backend/convex/connections/actions/expo.ts +79 -0
- package/dist/templates/default/packages/backend/convex/connections/actions/github.ts +120 -0
- package/dist/templates/default/packages/backend/convex/connections/actions/oauth.ts +128 -0
- package/dist/templates/default/packages/backend/convex/connections/index.ts +80 -0
- package/dist/templates/default/packages/backend/convex/connections/internal.ts +148 -0
- package/dist/templates/default/packages/backend/convex/connections/validator.ts +35 -0
- package/dist/templates/default/packages/backend/convex/convex.config.ts +5 -5
- package/dist/templates/default/packages/backend/convex/github/actions/provision.ts +2 -6
- package/dist/templates/default/packages/backend/convex/github/actions/secrets.ts +25 -11
- package/dist/templates/default/packages/backend/convex/github/actions/tokens.ts +19 -15
- package/dist/templates/default/packages/backend/convex/github/internal.ts +6 -8
- package/dist/templates/default/packages/backend/convex/previews/token/actions/create.ts +4 -3
- package/dist/templates/default/packages/backend/convex/previews/token/internal.ts +28 -1
- package/dist/templates/default/packages/backend/convex/schema.ts +17 -1
- package/dist/templates/default/packages/backend/generated/openapi.json +123 -1
- package/dist/templates/default/packages/backend/generated/pages.json +4 -0
- package/dist/templates/default/packages/backend/generated/platforms.ts +12 -10
- package/dist/templates/default/packages/backend/gitignore +16 -0
- package/dist/templates/default/packages/cli/auth.ts +15 -17
- package/dist/templates/default/packages/cli/commands.ts +31 -1
- package/dist/templates/default/packages/disposabl-kit/client/components/logo.tsx +5 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +118 -84
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +127 -89
- package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +2 -5
- package/dist/templates/default/packages/sdk/src/generated/index.ts +5 -0
- package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +20 -0
- package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +53 -0
- package/package.json +1 -1
- package/dist/templates/default/.github/scripts/android-build.sh +0 -27
- package/dist/templates/default/.github/scripts/expo-channel.sh +0 -10
- package/dist/templates/default/.github/scripts/expo-env.sh +0 -37
- package/dist/templates/default/.github/scripts/expo-fingerprint.sh +0 -31
- package/dist/templates/default/.github/scripts/expo-update.sh +0 -13
- package/dist/templates/default/.github/scripts/package-release.sh +0 -23
- package/dist/templates/default/.github/scripts/release-publish.sh +0 -28
- package/dist/templates/default/.github/scripts/release-source.sh +0 -14
- package/dist/templates/default/.github/scripts/verify-artifacts.sh +0 -13
- package/dist/templates/default/.github/scripts/web-deploy.sh +0 -10
- package/dist/templates/default/apps/mobile/.env.example +0 -2
- package/dist/templates/default/apps/web/.env.example +0 -3
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
8
8
|
import { v } from "convex/values";
|
|
9
9
|
import { internal } from "../../_generated/api";
|
|
10
|
-
import {
|
|
10
|
+
import { credential, unseal } from "../../connections/actions/credentials";
|
|
11
|
+
import { validateExpo } from "../../connections/actions/expo";
|
|
11
12
|
import {
|
|
12
13
|
management,
|
|
13
14
|
ensureProduction,
|
|
@@ -25,7 +26,10 @@ export const configure = internalAction({
|
|
|
25
26
|
const app = await ctx.runQuery(internal.apps.internal.githubApp, {
|
|
26
27
|
appId: args.appId,
|
|
27
28
|
});
|
|
28
|
-
if (!app)
|
|
29
|
+
if (!app)
|
|
30
|
+
throw new Error(
|
|
31
|
+
"Reconnect the GitHub account that owns this app before continuing setup.",
|
|
32
|
+
);
|
|
29
33
|
const repository = `${app.githubOwner}/${app.githubRepo}`;
|
|
30
34
|
const token = await githubToken(
|
|
31
35
|
app.installationId,
|
|
@@ -61,9 +65,11 @@ export const configure = internalAction({
|
|
|
61
65
|
"PUT",
|
|
62
66
|
);
|
|
63
67
|
};
|
|
64
|
-
const managementToken =
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const { token: managementToken } = await credential(
|
|
69
|
+
ctx,
|
|
70
|
+
args.userId,
|
|
71
|
+
"convex",
|
|
72
|
+
);
|
|
67
73
|
if (!names.has("CONVEX_DEPLOY_KEY")) {
|
|
68
74
|
const deployment = await ensureProduction(
|
|
69
75
|
managementToken,
|
|
@@ -90,12 +96,20 @@ export const configure = internalAction({
|
|
|
90
96
|
throw new Error("Expected a preview deploy key.");
|
|
91
97
|
await save("CONVEX_DEPLOY_KEY_PREVIEW", previewDeployKey);
|
|
92
98
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
+
const expo = await ctx.runQuery(internal.connections.internal.get, {
|
|
100
|
+
userId: args.userId,
|
|
101
|
+
provider: "expo",
|
|
102
|
+
});
|
|
103
|
+
if (expo) {
|
|
104
|
+
const token = unseal(expo.token, `${args.userId}:expo`);
|
|
105
|
+
const accounts = await validateExpo(token);
|
|
106
|
+
if (!accounts.some((account) => account.id === expo.accountId))
|
|
107
|
+
throw new Error(
|
|
108
|
+
"Reconnect your Expo account before setting up mobile builds.",
|
|
109
|
+
);
|
|
110
|
+
await save("EXPO_TOKEN", token);
|
|
111
|
+
await save("EXPO_OWNER", expo.name);
|
|
112
|
+
}
|
|
99
113
|
return null;
|
|
100
114
|
},
|
|
101
115
|
});
|
|
@@ -8,6 +8,24 @@ export async function githubToken(
|
|
|
8
8
|
permissions: string[],
|
|
9
9
|
repository?: string,
|
|
10
10
|
) {
|
|
11
|
+
const token = await vercelIdentity();
|
|
12
|
+
return getToken(
|
|
13
|
+
env.GITHUB_CONNECTOR!,
|
|
14
|
+
{
|
|
15
|
+
subject: { type: "app" },
|
|
16
|
+
installationId,
|
|
17
|
+
authorizationDetails: [
|
|
18
|
+
{
|
|
19
|
+
type: "github_app_installation",
|
|
20
|
+
permissions,
|
|
21
|
+
...(repository ? { repositories: [repository] } : {}),
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
{ vercelToken: token },
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export async function vercelIdentity() {
|
|
11
29
|
if (
|
|
12
30
|
!env.VERCEL_TOKEN ||
|
|
13
31
|
!env.VERCEL_PROJECT_ID ||
|
|
@@ -27,21 +45,7 @@ export async function githubToken(
|
|
|
27
45
|
if (!response.ok)
|
|
28
46
|
throw new Error(`GitHub connection failed (${response.status}).`);
|
|
29
47
|
const { token } = (await response.json()) as { token: string };
|
|
30
|
-
return
|
|
31
|
-
env.GITHUB_CONNECTOR,
|
|
32
|
-
{
|
|
33
|
-
subject: { type: "app" },
|
|
34
|
-
installationId,
|
|
35
|
-
authorizationDetails: [
|
|
36
|
-
{
|
|
37
|
-
type: "github_app_installation",
|
|
38
|
-
permissions,
|
|
39
|
-
...(repository ? { repositories: [repository] } : {}),
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
{ vercelToken: token },
|
|
44
|
-
);
|
|
48
|
+
return token;
|
|
45
49
|
}
|
|
46
50
|
export async function githubRequest<T>(
|
|
47
51
|
token: string,
|
|
@@ -21,14 +21,12 @@ export const connect = internalMutation({
|
|
|
21
21
|
q.eq("userId", userId).eq("owner", owner),
|
|
22
22
|
)
|
|
23
23
|
.unique();
|
|
24
|
-
if (existing)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
installationId,
|
|
31
|
-
});
|
|
24
|
+
if (existing) await ctx.db.delete("githubConnections", existing._id);
|
|
25
|
+
await ctx.db.insert("githubConnections", {
|
|
26
|
+
userId,
|
|
27
|
+
owner,
|
|
28
|
+
installationId,
|
|
29
|
+
});
|
|
32
30
|
return null;
|
|
33
31
|
},
|
|
34
32
|
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
"use node";
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
identityFields,
|
|
3
5
|
internalAction,
|
|
4
6
|
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
5
7
|
import { v } from "convex/values";
|
|
6
8
|
import { internal } from "../../../_generated/api";
|
|
7
|
-
import {
|
|
9
|
+
import { credential } from "../../../connections/actions/credentials";
|
|
8
10
|
import { previewIdentity, deployment } from "../../../validator";
|
|
9
11
|
import { validateReference } from "../../internal";
|
|
10
12
|
import { ensureDevelopment } from "./management";
|
|
11
13
|
|
|
12
14
|
export const create = internalAction({
|
|
13
|
-
platforms: true,
|
|
14
15
|
args: { ...identityFields, ...previewIdentity },
|
|
15
16
|
returns: v.object({
|
|
16
17
|
appId: v.string(),
|
|
@@ -40,7 +41,7 @@ export const create = internalAction({
|
|
|
40
41
|
appId: args.appId,
|
|
41
42
|
});
|
|
42
43
|
const { deployKey, ...deployment } = await ensureDevelopment(
|
|
43
|
-
|
|
44
|
+
(await credential(ctx, args.userId, "convex")).token,
|
|
44
45
|
projectId,
|
|
45
46
|
args.reference,
|
|
46
47
|
);
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
identityFields,
|
|
3
|
+
internalAction,
|
|
4
|
+
} from "@disposabl/disposabl-kit/server/lib/functions";
|
|
5
|
+
import { v } from "convex/values";
|
|
6
|
+
import { internal } from "../../_generated/api";
|
|
7
|
+
import { deployment, previewIdentity } from "../../validator";
|
|
8
|
+
|
|
9
|
+
export const create = internalAction({
|
|
10
|
+
platforms: true,
|
|
11
|
+
args: { ...identityFields, ...previewIdentity },
|
|
12
|
+
returns: v.object({
|
|
13
|
+
appId: v.string(),
|
|
14
|
+
...deployment.fields,
|
|
15
|
+
deployKey: v.string(),
|
|
16
|
+
}),
|
|
17
|
+
handler: async (
|
|
18
|
+
ctx,
|
|
19
|
+
args,
|
|
20
|
+
): Promise<{
|
|
21
|
+
appId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
reference: string;
|
|
24
|
+
convexUrl: string;
|
|
25
|
+
convexSiteUrl: string;
|
|
26
|
+
deployKey: string;
|
|
27
|
+
}> => ctx.runAction(internal.previews.token.actions.create.create, args),
|
|
28
|
+
});
|
|
@@ -3,7 +3,23 @@ import { v } from "convex/values";
|
|
|
3
3
|
import { deployment, platform, releases } from "./validator";
|
|
4
4
|
|
|
5
5
|
export default defineSchema({
|
|
6
|
-
users: defineTable({
|
|
6
|
+
users: defineTable({
|
|
7
|
+
connectionState: v.optional(
|
|
8
|
+
v.object({
|
|
9
|
+
provider: v.union(v.literal("github"), v.literal("convex")),
|
|
10
|
+
hash: v.string(),
|
|
11
|
+
verifier: v.string(),
|
|
12
|
+
expiresAt: v.number(),
|
|
13
|
+
}),
|
|
14
|
+
),
|
|
15
|
+
}),
|
|
16
|
+
connections: defineTable({
|
|
17
|
+
userId: v.string(),
|
|
18
|
+
provider: v.union(v.literal("convex"), v.literal("expo")),
|
|
19
|
+
accountId: v.string(),
|
|
20
|
+
name: v.string(),
|
|
21
|
+
token: v.string(),
|
|
22
|
+
}).index("by_userId_provider", ["userId", "provider"]),
|
|
7
23
|
apps: defineTable({
|
|
8
24
|
appId: v.string(),
|
|
9
25
|
userId: v.string(),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.1.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Application API",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.1.0"
|
|
6
6
|
},
|
|
7
7
|
"security": [
|
|
8
8
|
{
|
|
@@ -400,6 +400,128 @@
|
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
},
|
|
403
|
+
"/api/connections/status": {
|
|
404
|
+
"get": {
|
|
405
|
+
"operationId": "connectionsStatus",
|
|
406
|
+
"x-convex-function": "connections/internal:status",
|
|
407
|
+
"parameters": [],
|
|
408
|
+
"responses": {
|
|
409
|
+
"200": {
|
|
410
|
+
"description": "Success",
|
|
411
|
+
"content": {
|
|
412
|
+
"application/json": {
|
|
413
|
+
"schema": {
|
|
414
|
+
"type": "object",
|
|
415
|
+
"properties": {
|
|
416
|
+
"github": {
|
|
417
|
+
"anyOf": [
|
|
418
|
+
{
|
|
419
|
+
"type": "object",
|
|
420
|
+
"properties": {
|
|
421
|
+
"owner": {
|
|
422
|
+
"type": "string"
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
"required": ["owner"],
|
|
426
|
+
"additionalProperties": false
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"type": "null"
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
},
|
|
433
|
+
"convex": {
|
|
434
|
+
"anyOf": [
|
|
435
|
+
{
|
|
436
|
+
"type": "object",
|
|
437
|
+
"properties": {
|
|
438
|
+
"name": {
|
|
439
|
+
"type": "string"
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
"required": ["name"],
|
|
443
|
+
"additionalProperties": false
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"type": "null"
|
|
447
|
+
}
|
|
448
|
+
]
|
|
449
|
+
},
|
|
450
|
+
"expo": {
|
|
451
|
+
"anyOf": [
|
|
452
|
+
{
|
|
453
|
+
"type": "object",
|
|
454
|
+
"properties": {
|
|
455
|
+
"name": {
|
|
456
|
+
"type": "string"
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
"required": ["name"],
|
|
460
|
+
"additionalProperties": false
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"type": "null"
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
"ready": {
|
|
468
|
+
"type": "boolean"
|
|
469
|
+
},
|
|
470
|
+
"available": {
|
|
471
|
+
"type": "object",
|
|
472
|
+
"properties": {
|
|
473
|
+
"github": {
|
|
474
|
+
"type": "boolean"
|
|
475
|
+
},
|
|
476
|
+
"convex": {
|
|
477
|
+
"type": "boolean"
|
|
478
|
+
},
|
|
479
|
+
"expo": {
|
|
480
|
+
"type": "boolean"
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
"required": ["github", "convex", "expo"],
|
|
484
|
+
"additionalProperties": false
|
|
485
|
+
},
|
|
486
|
+
"githubInstallUrl": {
|
|
487
|
+
"anyOf": [
|
|
488
|
+
{
|
|
489
|
+
"type": "string"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"type": "null"
|
|
493
|
+
}
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
"required": [
|
|
498
|
+
"github",
|
|
499
|
+
"convex",
|
|
500
|
+
"expo",
|
|
501
|
+
"ready",
|
|
502
|
+
"available",
|
|
503
|
+
"githubInstallUrl"
|
|
504
|
+
],
|
|
505
|
+
"additionalProperties": false
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
"400": {
|
|
511
|
+
"description": "Invalid arguments"
|
|
512
|
+
},
|
|
513
|
+
"401": {
|
|
514
|
+
"description": "Authentication required"
|
|
515
|
+
},
|
|
516
|
+
"403": {
|
|
517
|
+
"description": "Insufficient scope"
|
|
518
|
+
},
|
|
519
|
+
"500": {
|
|
520
|
+
"description": "Internal error"
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
},
|
|
403
525
|
"/api/previews/get": {
|
|
404
526
|
"get": {
|
|
405
527
|
"operationId": "previewsGet",
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// Generated by bun run generate. Do not edit.
|
|
2
2
|
import * as m0 from "../convex/apps/internal";
|
|
3
|
-
import * as m1 from "../convex/
|
|
4
|
-
import * as m2 from "../convex/
|
|
5
|
-
import * as m3 from "../convex/previews/
|
|
6
|
-
import * as m4 from "../convex/
|
|
7
|
-
import * as m5 from "../convex/
|
|
3
|
+
import * as m1 from "../convex/connections/internal";
|
|
4
|
+
import * as m2 from "../convex/github/internal";
|
|
5
|
+
import * as m3 from "../convex/previews/internal";
|
|
6
|
+
import * as m4 from "../convex/previews/token/internal";
|
|
7
|
+
import * as m5 from "../convex/releases/internal";
|
|
8
|
+
import * as m6 from "../convex/users/internal";
|
|
8
9
|
export default {
|
|
9
10
|
"apps/internal": m0,
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"previews/
|
|
13
|
-
"
|
|
14
|
-
"
|
|
11
|
+
"connections/internal": m1,
|
|
12
|
+
"github/internal": m2,
|
|
13
|
+
"previews/internal": m3,
|
|
14
|
+
"previews/token/internal": m4,
|
|
15
|
+
"releases/internal": m5,
|
|
16
|
+
"users/internal": m6,
|
|
15
17
|
};
|
|
@@ -21,6 +21,20 @@ import { homedir } from "node:os";
|
|
|
21
21
|
import { join } from "node:path";
|
|
22
22
|
import { spawn } from "node:child_process";
|
|
23
23
|
|
|
24
|
+
export function openUrl(url: string) {
|
|
25
|
+
const command =
|
|
26
|
+
process.platform === "darwin"
|
|
27
|
+
? "open"
|
|
28
|
+
: process.platform === "win32"
|
|
29
|
+
? "rundll32"
|
|
30
|
+
: "xdg-open";
|
|
31
|
+
const args =
|
|
32
|
+
process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
33
|
+
const child = spawn(command, args, { stdio: "ignore" });
|
|
34
|
+
child.on("error", () => console.error("Open the URL manually."));
|
|
35
|
+
child.unref();
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
export class NotAuthenticated extends Error {}
|
|
25
39
|
|
|
26
40
|
type Session = {
|
|
@@ -159,23 +173,7 @@ async function unlockedLogin(url: string, openBrowser = true) {
|
|
|
159
173
|
if (authorizationUrl.origin !== url)
|
|
160
174
|
throw new Error("Unexpected authorization server.");
|
|
161
175
|
console.error(`Open this URL to sign in:\n${authorizationUrl.href}`);
|
|
162
|
-
if (openBrowser)
|
|
163
|
-
const command =
|
|
164
|
-
process.platform === "darwin"
|
|
165
|
-
? "open"
|
|
166
|
-
: process.platform === "win32"
|
|
167
|
-
? "rundll32"
|
|
168
|
-
: "xdg-open";
|
|
169
|
-
const args =
|
|
170
|
-
process.platform === "win32"
|
|
171
|
-
? ["url.dll,FileProtocolHandler", authorizationUrl.href]
|
|
172
|
-
: [authorizationUrl.href];
|
|
173
|
-
const child = spawn(command, args, { stdio: "ignore" });
|
|
174
|
-
child.on("error", () =>
|
|
175
|
-
console.error("Open the sign-in URL manually."),
|
|
176
|
-
);
|
|
177
|
-
child.unref();
|
|
178
|
-
}
|
|
176
|
+
if (openBrowser) openUrl(authorizationUrl.href);
|
|
179
177
|
},
|
|
180
178
|
state,
|
|
181
179
|
);
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
hasCredentials,
|
|
8
8
|
login,
|
|
9
9
|
logout,
|
|
10
|
+
openUrl,
|
|
10
11
|
} from "./auth";
|
|
11
12
|
import { readFile } from "node:fs/promises";
|
|
12
13
|
import { join } from "node:path";
|
|
@@ -118,6 +119,12 @@ export async function runCli(
|
|
|
118
119
|
parent.commands.find((command) => command.name() === part) ??
|
|
119
120
|
parent.command(part);
|
|
120
121
|
const command = parent.command(parts.at(-1)!);
|
|
122
|
+
const connectionStatus = path === "/api/connections/status";
|
|
123
|
+
if (connectionStatus)
|
|
124
|
+
command.option(
|
|
125
|
+
"--wait",
|
|
126
|
+
"Open Connections and continue when GitHub and Convex are connected",
|
|
127
|
+
);
|
|
121
128
|
const previewGet = path === "/api/previews/get";
|
|
122
129
|
const tokenCreate = path === "/api/previews/token/create";
|
|
123
130
|
if (previewGet)
|
|
@@ -208,7 +215,30 @@ export async function runCli(
|
|
|
208
215
|
throw new Error(
|
|
209
216
|
`API request failed (${result.status}): ${await result.text()}`,
|
|
210
217
|
);
|
|
211
|
-
|
|
218
|
+
let value = await result.json();
|
|
219
|
+
if (connectionStatus && options.wait && !value.ready) {
|
|
220
|
+
const url = `${base}/dashboard/connections`;
|
|
221
|
+
console.error(
|
|
222
|
+
`Connect your GitHub and Convex accounts:\n${url}\nWaiting for connections. Press Ctrl+C to keep your files and finish later.`,
|
|
223
|
+
);
|
|
224
|
+
openUrl(url);
|
|
225
|
+
const deadline = Date.now() + 15 * 60_000;
|
|
226
|
+
while (!value.ready && Date.now() < deadline) {
|
|
227
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
228
|
+
result = await send();
|
|
229
|
+
if (result.status === 401 && !process.env.DISPOSABL_API_KEY)
|
|
230
|
+
result = await send(true);
|
|
231
|
+
if (!result.ok)
|
|
232
|
+
throw new Error(
|
|
233
|
+
`Connection status failed (${result.status}). Your login and app files are saved.`,
|
|
234
|
+
);
|
|
235
|
+
value = await result.json();
|
|
236
|
+
}
|
|
237
|
+
if (!value.ready)
|
|
238
|
+
throw new Error(
|
|
239
|
+
`Connections are still incomplete. Finish at ${url}, then retry setup.`,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
212
242
|
if (tokenCreate && options.configure) {
|
|
213
243
|
await configureDevelopment(options.configure, value);
|
|
214
244
|
const { deployKey: _secret, ...details } = value;
|