create-disposabl-app 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/disposabl.js +44 -39
  2. package/dist/index.js +73 -5
  3. package/dist/templates/default/.github/scripts/apple.sh +62 -0
  4. package/dist/templates/default/.github/scripts/disposabl.mjs +31 -14
  5. package/dist/templates/default/.github/scripts/mobile.sh +9 -9
  6. package/dist/templates/default/.github/scripts/platforms.sh +3 -3
  7. package/dist/templates/default/.github/scripts/release.sh +1 -1
  8. package/dist/templates/default/.github/workflows/pipeline.yml +115 -6
  9. package/dist/templates/default/apps/desktop/.oxfmtrc.json +5 -0
  10. package/dist/templates/default/apps/desktop/.oxlintrc.json +6 -0
  11. package/dist/templates/default/apps/desktop/README.md +90 -0
  12. package/dist/templates/default/apps/desktop/build-ci.mjs +56 -0
  13. package/dist/templates/default/apps/desktop/forge.config.mts +124 -0
  14. package/dist/templates/default/apps/desktop/gitignore +146 -0
  15. package/dist/templates/default/apps/desktop/index.html +16 -0
  16. package/dist/templates/default/apps/desktop/package.json +55 -0
  17. package/dist/templates/default/apps/desktop/rpm.spec.ejs +84 -0
  18. package/dist/templates/default/apps/desktop/src/assets/icon.icns +0 -0
  19. package/dist/templates/default/apps/desktop/src/assets/icon.ico +0 -0
  20. package/dist/templates/default/apps/desktop/src/assets/icon.png +0 -0
  21. package/dist/templates/default/apps/desktop/src/assets/logo.svg +8 -0
  22. package/dist/templates/default/apps/desktop/src/declarations.d.ts +4 -0
  23. package/dist/templates/default/apps/desktop/src/index.css +27 -0
  24. package/dist/templates/default/apps/desktop/src/main.ts +54 -0
  25. package/dist/templates/default/apps/desktop/src/preload.ts +3 -0
  26. package/dist/templates/default/apps/desktop/src/renderer.ts +1 -0
  27. package/dist/templates/default/apps/desktop/tsconfig.json +14 -0
  28. package/dist/templates/default/apps/desktop/vite.main.config.mts +9 -0
  29. package/dist/templates/default/apps/desktop/vite.preload.config.mts +4 -0
  30. package/dist/templates/default/apps/desktop/vite.renderer.config.mts +4 -0
  31. package/dist/templates/default/apps/mobile/README.md +1 -1
  32. package/dist/templates/default/apps/mobile/eas.json +2 -2
  33. package/dist/templates/default/apps/web/src/components/connections/provider-logo.tsx +38 -0
  34. package/dist/templates/default/apps/web/src/index.css +0 -22
  35. package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.connections.tsx +244 -153
  36. package/dist/templates/default/bun.lock +4 -0
  37. package/dist/templates/default/dev.ts +22 -6
  38. package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +10 -0
  39. package/dist/templates/default/packages/backend/convex/apps/actions/cleanup.ts +1 -0
  40. package/dist/templates/default/packages/backend/convex/apps/internal.ts +17 -1
  41. package/dist/templates/default/packages/backend/convex/connections/actions/github.ts +5 -4
  42. package/dist/templates/default/packages/backend/convex/connections/actions/oauth.ts +2 -2
  43. package/dist/templates/default/packages/backend/convex/downloads/action.ts +136 -0
  44. package/dist/templates/default/packages/backend/convex/downloads/http.ts +32 -0
  45. package/dist/templates/default/packages/backend/convex/downloads/internal.ts +58 -0
  46. package/dist/templates/default/packages/backend/convex/github/actions/http.ts +37 -8
  47. package/dist/templates/default/packages/backend/convex/github/actions/internal.ts +1 -0
  48. package/dist/templates/default/packages/backend/convex/github/actions/provision.ts +1 -1
  49. package/dist/templates/default/packages/backend/convex/github/actions/secrets.ts +38 -6
  50. package/dist/templates/default/packages/backend/convex/github/actions/signing.ts +41 -0
  51. package/dist/templates/default/packages/backend/convex/github/actions/tokens.ts +82 -16
  52. package/dist/templates/default/packages/backend/convex/github/identityCache.ts +54 -0
  53. package/dist/templates/default/packages/backend/convex/http.ts +3 -0
  54. package/dist/templates/default/packages/backend/convex/previews/token/actions/create.ts +21 -3
  55. package/dist/templates/default/packages/backend/convex/previews/token/actions/management.ts +17 -2
  56. package/dist/templates/default/packages/backend/convex/previews/token/internal.ts +4 -0
  57. package/dist/templates/default/packages/backend/convex/schema.ts +7 -0
  58. package/dist/templates/default/packages/backend/generated/openapi.json +107 -1
  59. package/dist/templates/default/packages/backend/generated/platforms.ts +12 -10
  60. package/dist/templates/default/packages/backend/package.json +3 -1
  61. package/dist/templates/default/packages/cli/preview.ts +63 -0
  62. package/dist/templates/default/packages/disposabl-kit/platforms.ts +3 -0
  63. package/dist/templates/default/packages/sdk/src/generated/index.ts +5 -0
  64. package/dist/templates/default/packages/sdk/src/generated/sdk.gen.ts +20 -0
  65. package/dist/templates/default/packages/sdk/src/generated/types.gen.ts +69 -0
  66. package/dist/templates/default/packages/skill/SKILL.md +38 -0
  67. package/package.json +1 -1
@@ -1,14 +1,19 @@
1
1
  "use node";
2
2
 
3
3
  import { getToken } from "@vercel/connect";
4
- import { env } from "../../_generated/server";
4
+ import { createHash, randomUUID } from "node:crypto";
5
+ import { ConvexError } from "convex/values";
6
+ import { env, type ActionCtx } from "../../_generated/server";
7
+ import { internal } from "../../_generated/api";
8
+ import { seal, unseal } from "../../connections/actions/credentials";
5
9
 
6
10
  export async function githubToken(
11
+ ctx: ActionCtx,
7
12
  installationId: string,
8
13
  permissions: string[],
9
14
  repository?: string,
10
15
  ) {
11
- const token = await vercelIdentity();
16
+ const token = await vercelIdentity(ctx);
12
17
  return getToken(
13
18
  env.GITHUB_CONNECTOR!,
14
19
  {
@@ -25,7 +30,7 @@ export async function githubToken(
25
30
  { vercelToken: token },
26
31
  );
27
32
  }
28
- export async function vercelIdentity() {
33
+ export async function vercelIdentity(ctx: ActionCtx): Promise<string> {
29
34
  if (
30
35
  !env.VERCEL_TOKEN ||
31
36
  !env.VERCEL_PROJECT_ID ||
@@ -33,19 +38,80 @@ export async function vercelIdentity() {
33
38
  !env.GITHUB_CONNECTOR
34
39
  )
35
40
  throw new Error("GitHub App connection is not configured.");
36
- const response = await fetch(
37
- `https://api.vercel.com/v1/projects/${encodeURIComponent(env.VERCEL_PROJECT_ID)}/token?teamId=${encodeURIComponent(env.VERCEL_TEAM_ID)}`,
38
- {
39
- method: "POST",
40
- redirect: "error",
41
- headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
42
- signal: AbortSignal.timeout(30_000),
43
- },
44
- );
45
- if (!response.ok)
46
- throw new Error(`GitHub connection failed (${response.status}).`);
47
- const { token } = (await response.json()) as { token: string };
48
- return token;
41
+ const key = createHash("sha256")
42
+ .update(
43
+ JSON.stringify([
44
+ env.VERCEL_PROJECT_ID,
45
+ env.VERCEL_TEAM_ID,
46
+ env.VERCEL_TOKEN,
47
+ env.CONNECTIONS_ENCRYPTION_KEY,
48
+ ]),
49
+ )
50
+ .digest("hex");
51
+ const lease = randomUUID();
52
+ const cached = await ctx.runMutation(internal.github.identityCache.acquire, {
53
+ key,
54
+ lease,
55
+ });
56
+ if (cached.token) return unseal(cached.token, `vercel-identity:${key}`);
57
+ if (!cached.acquired)
58
+ throw new ConvexError({
59
+ code: "UPSTREAM_RETRY",
60
+ retryAfter: cached.retryAfter,
61
+ });
62
+ let refreshAfter = Date.now() + 5_000;
63
+ try {
64
+ const response = await fetch(
65
+ `https://api.vercel.com/v1/projects/${encodeURIComponent(env.VERCEL_PROJECT_ID)}/token?teamId=${encodeURIComponent(env.VERCEL_TEAM_ID)}`,
66
+ {
67
+ method: "POST",
68
+ redirect: "error",
69
+ headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
70
+ signal: AbortSignal.timeout(30_000),
71
+ },
72
+ );
73
+ if (!response.ok) {
74
+ if (response.status === 429 || response.status >= 500) {
75
+ const retry = Number(response.headers.get("retry-after"));
76
+ const reset = Number(response.headers.get("x-ratelimit-reset"));
77
+ const delay = Math.max(
78
+ 5,
79
+ Number.isFinite(retry) ? retry : 0,
80
+ Number.isFinite(reset) ? reset - Date.now() / 1000 : 0,
81
+ );
82
+ refreshAfter = Date.now() + Math.min(delay, 3600) * 1000;
83
+ throw new ConvexError({
84
+ code: "UPSTREAM_RETRY",
85
+ retryAfter: Math.ceil((refreshAfter - Date.now()) / 1000),
86
+ });
87
+ }
88
+ throw new Error(`GitHub connection failed (${response.status}).`);
89
+ }
90
+ const { token } = (await response.json()) as { token: string };
91
+ const payload = token.split(".").at(1);
92
+ const expiresAt = payload
93
+ ? Number(JSON.parse(Buffer.from(payload, "base64url").toString()).exp) *
94
+ 1000
95
+ : 0;
96
+ if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() + 60_000)
97
+ throw new Error("Vercel returned an expired identity.");
98
+ await ctx.runMutation(internal.github.identityCache.finish, {
99
+ key,
100
+ lease,
101
+ token: seal(token, `vercel-identity:${key}`),
102
+ expiresAt,
103
+ refreshAfter: 0,
104
+ });
105
+ return token;
106
+ } catch (error) {
107
+ await ctx.runMutation(internal.github.identityCache.finish, {
108
+ key,
109
+ lease,
110
+ expiresAt: 0,
111
+ refreshAfter,
112
+ });
113
+ throw error;
114
+ }
49
115
  }
50
116
  export class GitHubError extends Error {
51
117
  constructor(readonly status: number) {
@@ -0,0 +1,54 @@
1
+ import { internalMutation } from "../_generated/server";
2
+ import { v } from "convex/values";
3
+
4
+ // Internal only: encrypted service identity, shared across action workers.
5
+ export const acquire = internalMutation({
6
+ args: { key: v.string(), lease: v.string() },
7
+ returns: v.object({
8
+ token: v.optional(v.string()),
9
+ acquired: v.boolean(),
10
+ retryAfter: v.number(),
11
+ }),
12
+ handler: async (ctx, { key, lease }) => {
13
+ const row = await ctx.db
14
+ .query("serviceIdentities")
15
+ .withIndex("by_key", (q) => q.eq("key", key))
16
+ .unique();
17
+ const now = Date.now();
18
+ if (row?.token && row.expiresAt > now + 60_000)
19
+ return { token: row.token, acquired: false, retryAfter: 0 };
20
+ if (row && row.refreshAfter > now)
21
+ return {
22
+ acquired: false,
23
+ retryAfter: Math.ceil((row.refreshAfter - now) / 1000),
24
+ };
25
+ const value = { lease, refreshAfter: now + 35_000 };
26
+ if (row) await ctx.db.patch("serviceIdentities", row._id, value);
27
+ else
28
+ await ctx.db.insert("serviceIdentities", { key, expiresAt: 0, ...value });
29
+ return { acquired: true, retryAfter: 0 };
30
+ },
31
+ });
32
+
33
+ export const finish = internalMutation({
34
+ args: {
35
+ key: v.string(),
36
+ lease: v.string(),
37
+ token: v.optional(v.string()),
38
+ expiresAt: v.number(),
39
+ refreshAfter: v.number(),
40
+ },
41
+ returns: v.null(),
42
+ handler: async (ctx, { key, lease, ...value }) => {
43
+ const row = await ctx.db
44
+ .query("serviceIdentities")
45
+ .withIndex("by_key", (q) => q.eq("key", key))
46
+ .unique();
47
+ if (row?.lease === lease)
48
+ await ctx.db.patch("serviceIdentities", row._id, {
49
+ ...value,
50
+ lease: undefined,
51
+ });
52
+ return null;
53
+ },
54
+ });
@@ -1,3 +1,4 @@
1
+ import { download } from "./downloads/http";
1
2
  import { token, report } from "./github/actions/http";
2
3
  import createHttpRouter from "@disposabl/disposabl-kit/server/http";
3
4
 
@@ -5,4 +6,6 @@ const http = createHttpRouter();
5
6
  http.route({ path: "/github/token", method: "POST", handler: token });
6
7
  http.route({ path: "/github/report", method: "POST", handler: report });
7
8
 
9
+ http.route({ pathPrefix: "/downloads/", method: "GET", handler: download });
10
+
8
11
  export default http;
@@ -9,7 +9,7 @@ import { internal } from "../../../_generated/api";
9
9
  import { credential } from "../../../connections/actions/credentials";
10
10
  import { previewIdentity, deployment } from "../../../validator";
11
11
  import { validateReference } from "../../internal";
12
- import { ensureDevelopment } from "./management";
12
+ import { ensureDevelopment, productionDeployment } from "./management";
13
13
 
14
14
  export const create = internalAction({
15
15
  args: { ...identityFields, ...previewIdentity },
@@ -17,6 +17,8 @@ export const create = internalAction({
17
17
  appId: v.string(),
18
18
  ...deployment.fields,
19
19
  deployKey: v.string(),
20
+ productionConvexSiteUrl: v.optional(v.string()),
21
+ repositoryUrl: v.optional(v.string()),
20
22
  }),
21
23
  handler: async (
22
24
  ctx,
@@ -28,6 +30,8 @@ export const create = internalAction({
28
30
  convexUrl: string;
29
31
  convexSiteUrl: string;
30
32
  deployKey: string;
33
+ productionConvexSiteUrl?: string;
34
+ repositoryUrl?: string;
31
35
  }> => {
32
36
  validateReference(args.reference);
33
37
  const identity = { userId: args.userId, appId: args.appId };
@@ -44,8 +48,13 @@ export const create = internalAction({
44
48
  userId: args.userId,
45
49
  appId: args.appId,
46
50
  });
51
+ const token = (await credential(ctx, args.userId, "convex")).token;
52
+ const production = await productionDeployment(token, projectId);
53
+ const app = await ctx.runQuery(internal.apps.internal.get, identity);
54
+ if (!app.githubOwner || !app.githubRepo)
55
+ throw new Error("App repository setup is incomplete.");
47
56
  const { deployKey, ...deployment } = await ensureDevelopment(
48
- (await credential(ctx, args.userId, "convex")).token,
57
+ token,
49
58
  projectId,
50
59
  args.reference,
51
60
  );
@@ -53,7 +62,16 @@ export const create = internalAction({
53
62
  ...args,
54
63
  deployment,
55
64
  });
56
- return { appId: args.appId, ...deployment, deployKey };
65
+ return {
66
+ appId: args.appId,
67
+ ...deployment,
68
+ deployKey,
69
+ productionConvexSiteUrl: production.deploymentUrl.replace(
70
+ /\.convex\.cloud\/?$/,
71
+ ".convex.site",
72
+ ),
73
+ repositoryUrl: `https://github.com/${app.githubOwner}/${app.githubRepo}.git`,
74
+ };
57
75
  } finally {
58
76
  await ctx.runMutation(internal.apps.operations.internal.finish, {
59
77
  ...identity,
@@ -133,7 +133,7 @@ export async function ensureDevelopment(
133
133
  };
134
134
  }
135
135
 
136
- export async function ensureProduction(token: string, projectId: number) {
136
+ export async function productionDeployment(token: string, projectId: number) {
137
137
  const path = `/projects/${projectId}`;
138
138
  const lookup = () =>
139
139
  management<Deployment>(token, `${path}/deployment?defaultProd=true`);
@@ -163,5 +163,20 @@ export async function ensureProduction(token: string, projectId: number) {
163
163
  deployment.projectId !== projectId
164
164
  )
165
165
  throw new Error("Expected this app's production deployment.");
166
- return deployment.name;
166
+ const url = new URL(deployment.deploymentUrl);
167
+ if (
168
+ !/^[a-z0-9-]+$/.test(deployment.name) ||
169
+ url.origin !== `https://${deployment.name}.convex.cloud` ||
170
+ url.pathname !== "/" ||
171
+ url.search ||
172
+ url.hash ||
173
+ url.username ||
174
+ url.password
175
+ )
176
+ throw new Error("Unexpected Convex production URL.");
177
+ return deployment;
178
+ }
179
+
180
+ export async function ensureProduction(token: string, projectId: number) {
181
+ return (await productionDeployment(token, projectId)).name;
167
182
  }
@@ -13,6 +13,8 @@ export const create = internalAction({
13
13
  appId: v.string(),
14
14
  ...deployment.fields,
15
15
  deployKey: v.string(),
16
+ productionConvexSiteUrl: v.optional(v.string()),
17
+ repositoryUrl: v.optional(v.string()),
16
18
  }),
17
19
  handler: async (
18
20
  ctx,
@@ -24,5 +26,7 @@ export const create = internalAction({
24
26
  convexUrl: string;
25
27
  convexSiteUrl: string;
26
28
  deployKey: string;
29
+ productionConvexSiteUrl?: string;
30
+ repositoryUrl?: string;
27
31
  }> => ctx.runAction(internal.previews.token.actions.create.create, args),
28
32
  });
@@ -4,6 +4,13 @@ import { pendingDelete } from "./apps/validator";
4
4
  import { deployment, platform, releases } from "./validator";
5
5
 
6
6
  export default defineSchema({
7
+ serviceIdentities: defineTable({
8
+ key: v.string(),
9
+ token: v.optional(v.string()),
10
+ expiresAt: v.number(),
11
+ refreshAfter: v.number(),
12
+ lease: v.optional(v.string()),
13
+ }).index("by_key", ["key"]),
7
14
  users: defineTable({
8
15
  connectionState: v.optional(
9
16
  v.object({
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Application API",
5
- "version": "2.0.0"
5
+ "version": "3.1.0"
6
6
  },
7
7
  "security": [
8
8
  {
@@ -403,6 +403,106 @@
403
403
  }
404
404
  }
405
405
  },
406
+ "/api/apps/update": {
407
+ "post": {
408
+ "operationId": "appsUpdate",
409
+ "x-convex-function": "apps/internal:update",
410
+ "requestBody": {
411
+ "required": true,
412
+ "content": {
413
+ "application/json": {
414
+ "schema": {
415
+ "type": "object",
416
+ "properties": {
417
+ "appId": {
418
+ "type": "string"
419
+ },
420
+ "platforms": {
421
+ "type": "array",
422
+ "items": {
423
+ "enum": [
424
+ "web",
425
+ "android",
426
+ "ios",
427
+ "macos",
428
+ "windows",
429
+ "linux",
430
+ "api",
431
+ "mcp",
432
+ "typescript-sdk",
433
+ "cli"
434
+ ]
435
+ }
436
+ }
437
+ },
438
+ "required": ["appId", "platforms"],
439
+ "additionalProperties": false
440
+ }
441
+ }
442
+ }
443
+ },
444
+ "responses": {
445
+ "200": {
446
+ "description": "Success",
447
+ "content": {
448
+ "application/json": {
449
+ "schema": {
450
+ "type": "object",
451
+ "properties": {
452
+ "appId": {
453
+ "type": "string"
454
+ },
455
+ "name": {
456
+ "type": "string"
457
+ },
458
+ "platforms": {
459
+ "type": "array",
460
+ "items": {
461
+ "enum": [
462
+ "web",
463
+ "android",
464
+ "ios",
465
+ "macos",
466
+ "windows",
467
+ "linux",
468
+ "api",
469
+ "mcp",
470
+ "typescript-sdk",
471
+ "cli"
472
+ ]
473
+ }
474
+ },
475
+ "githubOwner": {
476
+ "type": "string"
477
+ },
478
+ "githubRepo": {
479
+ "type": "string"
480
+ },
481
+ "createdAt": {
482
+ "type": "number"
483
+ }
484
+ },
485
+ "required": ["appId", "name", "platforms", "createdAt"],
486
+ "additionalProperties": false
487
+ }
488
+ }
489
+ }
490
+ },
491
+ "400": {
492
+ "description": "Invalid arguments"
493
+ },
494
+ "401": {
495
+ "description": "Authentication required"
496
+ },
497
+ "403": {
498
+ "description": "Insufficient scope"
499
+ },
500
+ "500": {
501
+ "description": "Internal error"
502
+ }
503
+ }
504
+ }
505
+ },
406
506
  "/api/connections/status": {
407
507
  "get": {
408
508
  "operationId": "connectionsStatus",
@@ -1008,6 +1108,12 @@
1008
1108
  },
1009
1109
  "deployKey": {
1010
1110
  "type": "string"
1111
+ },
1112
+ "productionConvexSiteUrl": {
1113
+ "type": "string"
1114
+ },
1115
+ "repositoryUrl": {
1116
+ "type": "string"
1011
1117
  }
1012
1118
  },
1013
1119
  "required": [
@@ -2,18 +2,20 @@
2
2
  import * as m0 from "../convex/apps/internal";
3
3
  import * as m1 from "../convex/apps/operations/internal";
4
4
  import * as m2 from "../convex/connections/internal";
5
- import * as m3 from "../convex/github/internal";
6
- import * as m4 from "../convex/previews/internal";
7
- import * as m5 from "../convex/previews/token/internal";
8
- import * as m6 from "../convex/releases/internal";
9
- import * as m7 from "../convex/users/internal";
5
+ import * as m3 from "../convex/downloads/internal";
6
+ import * as m4 from "../convex/github/internal";
7
+ import * as m5 from "../convex/previews/internal";
8
+ import * as m6 from "../convex/previews/token/internal";
9
+ import * as m7 from "../convex/releases/internal";
10
+ import * as m8 from "../convex/users/internal";
10
11
  export default {
11
12
  "apps/internal": m0,
12
13
  "apps/operations/internal": m1,
13
14
  "connections/internal": m2,
14
- "github/internal": m3,
15
- "previews/internal": m4,
16
- "previews/token/internal": m5,
17
- "releases/internal": m6,
18
- "users/internal": m7,
15
+ "downloads/internal": m3,
16
+ "github/internal": m4,
17
+ "previews/internal": m5,
18
+ "previews/token/internal": m6,
19
+ "releases/internal": m7,
20
+ "users/internal": m8,
19
21
  };
@@ -21,13 +21,15 @@
21
21
  "@octokit/rest": "^22.0.1",
22
22
  "@vercel/connect": "^2.5.2",
23
23
  "convex": "catalog:",
24
- "libsodium-wrappers": "^0.8.4"
24
+ "libsodium-wrappers": "^0.8.4",
25
+ "node-forge": "^1.4.2"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@convex-dev/eslint-plugin": "^5.0.1",
28
29
  "@eslint/eslintrc": "^3.3.6",
29
30
  "@eslint/js": "^10.0.1",
30
31
  "@types/node": "^24.13.3",
32
+ "@types/node-forge": "^1.3.14",
31
33
  "@typescript-eslint/eslint-plugin": "^8.66.0",
32
34
  "@typescript-eslint/parser": "^8.66.0",
33
35
  "@typescript/native": "npm:typescript@^7.0.2",
@@ -31,6 +31,8 @@ type Development = {
31
31
  convexUrl: string;
32
32
  convexSiteUrl: string;
33
33
  deployKey: string;
34
+ productionConvexSiteUrl?: string;
35
+ repositoryUrl?: string;
34
36
  };
35
37
  async function updateEnv(
36
38
  file: string,
@@ -86,6 +88,45 @@ export async function configureDevelopment(
86
88
  value.convexSiteUrl !== `https://${value.name}.convex.site`
87
89
  )
88
90
  throw new Error("Development URLs do not match the deployment.");
91
+ if (
92
+ value.productionConvexSiteUrl &&
93
+ !/^https:\/\/[a-z0-9-]+\.convex\.site$/.test(value.productionConvexSiteUrl)
94
+ )
95
+ throw new Error("Unexpected production Convex site URL.");
96
+ if (value.repositoryUrl) {
97
+ const repository =
98
+ /^https:\/\/github\.com\/([a-zA-Z0-9-]+)\/([a-zA-Z0-9_.-]+)\.git$/.exec(
99
+ value.repositoryUrl,
100
+ );
101
+ if (!repository) throw new Error("Unexpected GitHub repository URL.");
102
+ const remote = spawnSync("git", ["remote", "get-url", "origin"], {
103
+ cwd: root,
104
+ encoding: "utf8",
105
+ });
106
+ if (remote.status === 0) {
107
+ const current = remote.stdout.trim();
108
+ const match =
109
+ /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(
110
+ current,
111
+ );
112
+ if (
113
+ !match ||
114
+ `${match[1]}/${match[2]}`.toLowerCase() !==
115
+ `${repository[1]}/${repository[2]}`.toLowerCase()
116
+ )
117
+ throw new Error(
118
+ "Existing origin points to a different repository; it was not changed.",
119
+ );
120
+ } else {
121
+ const added = spawnSync(
122
+ "git",
123
+ ["remote", "add", "origin", value.repositoryUrl],
124
+ { cwd: root, encoding: "utf8" },
125
+ );
126
+ if (added.status !== 0)
127
+ throw new Error(`Could not add origin: ${added.stderr.trim()}`);
128
+ }
129
+ }
89
130
  const files = ["packages/backend/.env.local", "apps/web/.env.local"];
90
131
  if (config.platforms.some((p: string) => p === "android" || p === "ios"))
91
132
  files.push("apps/mobile/.env.local");
@@ -101,6 +142,24 @@ export async function configureDevelopment(
101
142
  if (ignored.status !== 0 || tracked.status !== 1)
102
143
  throw new Error(`${file} must be untracked and ignored by Git.`);
103
144
  }
145
+ if (
146
+ value.productionConvexSiteUrl &&
147
+ config.productionConvexSiteUrl !== value.productionConvexSiteUrl
148
+ ) {
149
+ config.productionConvexSiteUrl = value.productionConvexSiteUrl;
150
+ await writeFile(
151
+ join(root, "disposabl.json"),
152
+ JSON.stringify(config, null, 2) + "\n",
153
+ );
154
+ const formatted = spawnSync("bun", ["fmt", "disposabl.json"], {
155
+ cwd: root,
156
+ stdio: "pipe",
157
+ });
158
+ if (formatted.status !== 0)
159
+ throw new Error(
160
+ "Could not format disposabl.json after configuring development.",
161
+ );
162
+ }
104
163
  await updateEnv(
105
164
  join(root, files[0]!),
106
165
  {
@@ -133,6 +192,8 @@ type Preview = {
133
192
  latest?: {
134
193
  version?: string;
135
194
  status: string;
195
+ reason?: string;
196
+ run?: { url: string };
136
197
  githubReleaseUrl?: string | null;
137
198
  artifactUrl?: string | null;
138
199
  updateUrl?: string | null;
@@ -164,6 +225,8 @@ export function formatPreview(preview: Preview | null) {
164
225
  Release: latest?.githubReleaseUrl,
165
226
  Download: latest?.artifactUrl,
166
227
  Update: latest?.updateUrl,
228
+ "Workflow run": latest?.run?.url,
229
+ Reason: latest?.reason,
167
230
  }))
168
231
  if (url) lines.push(` ${label}: ${url}`);
169
232
  }
@@ -2,6 +2,9 @@ export const platforms = [
2
2
  { id: "web", label: "Web", group: "Required", status: "required" },
3
3
  { id: "android", label: "Android", group: "Mobile", status: "available" },
4
4
  { id: "ios", label: "iOS", group: "Mobile", status: "available" },
5
+ { id: "macos", label: "macOS", group: "Desktop", status: "available" },
6
+ { id: "windows", label: "Windows", group: "Desktop", status: "available" },
7
+ { id: "linux", label: "Linux", group: "Desktop", status: "available" },
5
8
  {
6
9
  id: "mcp",
7
10
  label: "MCP",
@@ -5,6 +5,7 @@ export {
5
5
  appsDelete,
6
6
  appsGet,
7
7
  appsList,
8
+ appsUpdate,
8
9
  connectionsStatus,
9
10
  type Options,
10
11
  previewsGet,
@@ -30,6 +31,10 @@ export type {
30
31
  AppsListErrors,
31
32
  AppsListResponse,
32
33
  AppsListResponses,
34
+ AppsUpdateData,
35
+ AppsUpdateErrors,
36
+ AppsUpdateResponse,
37
+ AppsUpdateResponses,
33
38
  ClientOptions,
34
39
  ConnectionsStatusData,
35
40
  ConnectionsStatusErrors,
@@ -21,6 +21,9 @@ import type {
21
21
  AppsListData,
22
22
  AppsListErrors,
23
23
  AppsListResponses,
24
+ AppsUpdateData,
25
+ AppsUpdateErrors,
26
+ AppsUpdateResponses,
24
27
  ConnectionsStatusData,
25
28
  ConnectionsStatusErrors,
26
29
  ConnectionsStatusResponses,
@@ -120,6 +123,23 @@ export const appsList = <ThrowOnError extends boolean = false>(
120
123
  ...options,
121
124
  });
122
125
 
126
+ export const appsUpdate = <ThrowOnError extends boolean = false>(
127
+ options: Options<AppsUpdateData, ThrowOnError>,
128
+ ): RequestResult<AppsUpdateResponses, AppsUpdateErrors, ThrowOnError> =>
129
+ (options.client ?? client).post<
130
+ AppsUpdateResponses,
131
+ AppsUpdateErrors,
132
+ ThrowOnError
133
+ >({
134
+ security: [{ scheme: "bearer", type: "http" }],
135
+ url: "/api/apps/update",
136
+ ...options,
137
+ headers: {
138
+ "Content-Type": "application/json",
139
+ ...options.headers,
140
+ },
141
+ });
142
+
123
143
  export const connectionsStatus = <ThrowOnError extends boolean = false>(
124
144
  options?: Options<ConnectionsStatusData, ThrowOnError>,
125
145
  ): RequestResult<