create-disposabl-app 0.3.1 → 0.3.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 (39) hide show
  1. package/dist/index.js +36 -8
  2. package/dist/templates/default/.github/README.md +99 -57
  3. package/dist/templates/default/.github/actionlint.yaml +6 -0
  4. package/dist/templates/default/.github/workflows/pipeline.yml.example +492 -0
  5. package/dist/templates/default/apps/desktop/README.md +44 -14
  6. package/dist/templates/default/apps/desktop/build-ci.mjs +56 -0
  7. package/dist/templates/default/apps/desktop/forge.config.mts +36 -17
  8. package/dist/templates/default/apps/desktop/package.json +5 -5
  9. package/dist/templates/default/apps/mobile/README.md +127 -0
  10. package/dist/templates/default/apps/mobile/app.config.js +78 -0
  11. package/dist/templates/default/apps/mobile/assets/expo.icon/icon.json +21 -26
  12. package/dist/templates/default/apps/mobile/eas.json +22 -0
  13. package/dist/templates/default/apps/mobile/eslint.config.js +3 -3
  14. package/dist/templates/default/apps/mobile/package.json +5 -3
  15. package/dist/templates/default/apps/mobile/plugins/with-android-signing.js +29 -0
  16. package/dist/templates/default/apps/mobile/scripts/android-config.test.mjs +128 -0
  17. package/dist/templates/default/apps/mobile/tsconfig.json +3 -12
  18. package/dist/templates/default/apps/web/src/index.css +124 -73
  19. package/dist/templates/default/apps/web/src/routeTree.gen.ts +0 -9
  20. package/dist/templates/default/bun.lock +121 -11
  21. package/dist/templates/default/bunfig.toml +8 -1
  22. package/dist/templates/default/disposabl.json +9 -4
  23. package/dist/templates/default/gitignore +2 -0
  24. package/dist/templates/default/package.json +1 -0
  25. package/dist/templates/default/packages/backend/convex/todos/internal.ts +3 -3
  26. package/dist/templates/default/packages/backend/package.json +2 -3
  27. package/dist/templates/default/packages/disposabl-kit/client/styles/globals.css +43 -43
  28. package/dist/templates/default/packages/disposabl-kit/eslint.config.js +2 -2
  29. package/dist/templates/default/packages/disposabl-kit/package.json +2 -1
  30. package/dist/templates/default/packages/disposabl-kit/platforms.ts +87 -0
  31. package/dist/templates/default/packages/disposabl-kit/server/http.ts +20 -7
  32. package/dist/templates/default/packages/disposabl-kit/server/lib/functions.ts +1 -10
  33. package/dist/templates/default/packages/disposabl-kit/server/lib/platform-spec.ts +137 -0
  34. package/dist/templates/default/turbo.json +16 -5
  35. package/package.json +1 -1
  36. package/dist/templates/default/.github/workflows/pipeline.yml +0 -141
  37. package/dist/templates/default/packages/disposabl-kit/server/dev-setup.mjs +0 -39
  38. package/dist/templates/default/packages/disposabl-kit/server/lib/mcp-tools.ts +0 -47
  39. package/dist/templates/default/packages/disposabl-kit/server/lib/platforms.ts +0 -20
@@ -8,53 +8,53 @@
8
8
  @source "../**/*.{ts,tsx}";
9
9
 
10
10
  @theme inline {
11
- --font-heading: var(--font-sans);
12
- --color-sidebar-ring: var(--sidebar-ring);
13
- --color-sidebar-border: var(--sidebar-border);
14
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
15
- --color-sidebar-accent: var(--sidebar-accent);
16
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
17
- --color-sidebar-primary: var(--sidebar-primary);
18
- --color-sidebar-foreground: var(--sidebar-foreground);
19
- --color-sidebar: var(--sidebar);
20
- --color-chart-5: var(--chart-5);
21
- --color-chart-4: var(--chart-4);
22
- --color-chart-3: var(--chart-3);
23
- --color-chart-2: var(--chart-2);
24
- --color-chart-1: var(--chart-1);
25
- --color-ring: var(--ring);
26
- --color-input: var(--input);
27
- --color-border: var(--border);
28
- --color-destructive: var(--destructive);
29
- --color-accent-foreground: var(--accent-foreground);
30
- --color-accent: var(--accent);
31
- --color-muted-foreground: var(--muted-foreground);
32
- --color-muted: var(--muted);
33
- --color-secondary-foreground: var(--secondary-foreground);
34
- --color-secondary: var(--secondary);
35
- --color-primary-foreground: var(--primary-foreground);
36
- --color-primary: var(--primary);
37
- --color-popover-foreground: var(--popover-foreground);
38
- --color-popover: var(--popover);
39
- --color-card-foreground: var(--card-foreground);
40
- --color-card: var(--card);
41
- --color-foreground: var(--foreground);
42
- --color-background: var(--background);
43
- --radius-sm: calc(var(--radius) * 0.6);
44
- --radius-md: calc(var(--radius) * 0.8);
45
- --radius-lg: var(--radius);
46
- --radius-xl: calc(var(--radius) * 1.4);
47
- --radius-2xl: calc(var(--radius) * 1.8);
48
- --radius-3xl: calc(var(--radius) * 2.2);
49
- --radius-4xl: calc(var(--radius) * 2.6);
50
- --font-sans: 'Inter Variable', sans-serif;
11
+ --font-heading: var(--font-sans);
12
+ --color-sidebar-ring: var(--sidebar-ring);
13
+ --color-sidebar-border: var(--sidebar-border);
14
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
15
+ --color-sidebar-accent: var(--sidebar-accent);
16
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
17
+ --color-sidebar-primary: var(--sidebar-primary);
18
+ --color-sidebar-foreground: var(--sidebar-foreground);
19
+ --color-sidebar: var(--sidebar);
20
+ --color-chart-5: var(--chart-5);
21
+ --color-chart-4: var(--chart-4);
22
+ --color-chart-3: var(--chart-3);
23
+ --color-chart-2: var(--chart-2);
24
+ --color-chart-1: var(--chart-1);
25
+ --color-ring: var(--ring);
26
+ --color-input: var(--input);
27
+ --color-border: var(--border);
28
+ --color-destructive: var(--destructive);
29
+ --color-accent-foreground: var(--accent-foreground);
30
+ --color-accent: var(--accent);
31
+ --color-muted-foreground: var(--muted-foreground);
32
+ --color-muted: var(--muted);
33
+ --color-secondary-foreground: var(--secondary-foreground);
34
+ --color-secondary: var(--secondary);
35
+ --color-primary-foreground: var(--primary-foreground);
36
+ --color-primary: var(--primary);
37
+ --color-popover-foreground: var(--popover-foreground);
38
+ --color-popover: var(--popover);
39
+ --color-card-foreground: var(--card-foreground);
40
+ --color-card: var(--card);
41
+ --color-foreground: var(--foreground);
42
+ --color-background: var(--background);
43
+ --radius-sm: calc(var(--radius) * 0.6);
44
+ --radius-md: calc(var(--radius) * 0.8);
45
+ --radius-lg: var(--radius);
46
+ --radius-xl: calc(var(--radius) * 1.4);
47
+ --radius-2xl: calc(var(--radius) * 1.8);
48
+ --radius-3xl: calc(var(--radius) * 2.2);
49
+ --radius-4xl: calc(var(--radius) * 2.6);
50
+ --font-sans: 'Inter Variable', sans-serif;
51
51
  }
52
52
 
53
53
  @layer base {
54
54
  * {
55
55
  @apply border-border outline-ring/50;
56
- }
56
+ }
57
57
  body {
58
58
  @apply bg-background text-foreground;
59
- }
60
- }
59
+ }
60
+ }
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
 
3
- import { tanstackConfig } from "@tanstack/eslint-config"
3
+ import { tanstackConfig } from "@tanstack/eslint-config";
4
4
 
5
5
  export default [
6
6
  ...tanstackConfig,
@@ -18,4 +18,4 @@ export default [
18
18
  {
19
19
  ignores: ["eslint.config.js", ".prettierrc"],
20
20
  },
21
- ]
21
+ ];
@@ -54,6 +54,7 @@
54
54
  "./client/hooks/*": "./client/hooks/*.ts",
55
55
  "./server/http": "./server/http.ts",
56
56
  "./server/lib/functions": "./server/lib/functions.ts",
57
- "./client/vite.config": "./client/vite.config.ts"
57
+ "./client/vite.config": "./client/vite.config.ts",
58
+ "./platforms": "./platforms.ts"
58
59
  }
59
60
  }
@@ -0,0 +1,87 @@
1
+ export const platforms = [
2
+ { id: "web", label: "Web", group: "Required", status: "required" },
3
+ { id: "android", label: "Android", group: "Mobile", status: "available" },
4
+ { id: "ios", label: "iOS", group: "Mobile", status: "available" },
5
+ { id: "windows", label: "Windows", group: "Desktop", status: "available" },
6
+ { id: "linux", label: "Linux", group: "Desktop", status: "available" },
7
+ { id: "macos", label: "macOS", group: "Desktop", status: "available" },
8
+ {
9
+ id: "mcp",
10
+ label: "MCP",
11
+ group: "MCP & plugins",
12
+ status: "available",
13
+ description: "Tools for AI assistants",
14
+ },
15
+ {
16
+ id: "openai-plugin",
17
+ label: "OpenAI Plugin",
18
+ description: "Tools and skills for OpenAI",
19
+ group: "MCP & plugins",
20
+ status: "available",
21
+ },
22
+ {
23
+ id: "claude-code-plugin",
24
+ label: "Claude Code Plugin",
25
+ description: "Tools and skills for Claude Code",
26
+ group: "MCP & plugins",
27
+ status: "available",
28
+ },
29
+ { id: "api", label: "API", group: "Coming soon", status: "disabled" },
30
+ { id: "cli", label: "CLI", group: "Coming soon", status: "disabled" },
31
+ {
32
+ id: "python-sdk",
33
+ label: "Python SDK",
34
+ group: "Coming soon",
35
+ status: "disabled",
36
+ },
37
+ {
38
+ id: "typescript-sdk",
39
+ label: "TypeScript SDK",
40
+ group: "Coming soon",
41
+ status: "disabled",
42
+ },
43
+ ] as const;
44
+
45
+ export type Platform = (typeof platforms)[number]["id"];
46
+ export const platformIds = platforms.map(({ id }) => id);
47
+ export const requiredPlatform: Platform = "web";
48
+ export const platformDependencies: Partial<
49
+ Record<Platform, readonly Platform[]>
50
+ > = {
51
+ "openai-plugin": ["mcp"],
52
+ "claude-code-plugin": ["mcp"],
53
+ cli: ["api"],
54
+ "python-sdk": ["api"],
55
+ "typescript-sdk": ["api"],
56
+ };
57
+
58
+ export function isPlatform(value: unknown): value is Platform {
59
+ return typeof value === "string" && platformIds.includes(value as Platform);
60
+ }
61
+ export function parsePlatform(value: unknown): Platform {
62
+ if (isPlatform(value)) return value;
63
+ throw new Error(`Unknown platform ${JSON.stringify(value)}`);
64
+ }
65
+
66
+ /** Validate persisted selections without silently dropping or adding platforms. */
67
+ export function validatePlatforms(values: readonly unknown[]): Platform[] {
68
+ const selected = new Set(values.map(parsePlatform));
69
+ if (!selected.has(requiredPlatform)) throw new Error("Web is required");
70
+ for (const id of selected) {
71
+ for (const dependency of platformDependencies[id] ?? []) {
72
+ if (!selected.has(dependency))
73
+ throw new Error(`${id} requires ${dependency}`);
74
+ }
75
+ }
76
+ return platformIds.filter((id) => selected.has(id));
77
+ }
78
+
79
+ /** UI selection adds the required Web platform and dependent transports. */
80
+ export function resolvePlatforms(values: readonly unknown[]): Platform[] {
81
+ const selected = new Set(values.map(parsePlatform));
82
+ selected.add(requiredPlatform);
83
+ for (const id of selected)
84
+ for (const dependency of platformDependencies[id] ?? [])
85
+ selected.add(dependency);
86
+ return platformIds.filter((id) => selected.has(id));
87
+ }
@@ -1,16 +1,22 @@
1
1
  import { getAuthUserId } from "@convex-dev/auth/server";
2
2
  import { McpServer } from "@convex-dev/mcp";
3
3
  import { registerStaticRoutes } from "@convex-dev/static-hosting";
4
- import { httpRouter } from "convex/server";
4
+ import { httpActionGeneric, httpRouter } from "convex/server";
5
5
  import { components } from "../../backend/convex/_generated/api";
6
6
  import { env } from "../../backend/convex/_generated/server";
7
- import { createMcpTools } from "./lib/mcp-tools";
8
- import { getPlatforms } from "./lib/platforms";
7
+ import * as todos from "../../backend/convex/todos/internal";
8
+ import config from "../../../disposabl.json";
9
+ import { validatePlatforms } from "../platforms";
10
+ import { createPlatforms } from "./lib/platform-spec";
9
11
 
10
12
  export { tool } from "@convex-dev/mcp";
11
13
  export type { McpServerOptions, McpUser, ToolCtx } from "@convex-dev/mcp";
12
14
 
13
- const mcp = getPlatforms().isMcpEnabled
15
+ const platforms = createPlatforms({ "todos/internal": todos });
16
+ export const platformSpec = platforms.spec;
17
+
18
+ const enabled = validatePlatforms(config.platforms);
19
+ const mcp = enabled.some((platform) => platform === "mcp" || platform === "api")
14
20
  ? new McpServer(components.mcp, {
15
21
  name: "disposabl",
16
22
  title: "Disposabl",
@@ -18,8 +24,7 @@ const mcp = getPlatforms().isMcpEnabled
18
24
  siteUrl: env.CONVEX_SITE_URL,
19
25
  consentUrl: `${env.CONVEX_SITE_URL}/consent`,
20
26
  scopes: {},
21
- // Discovery is disabled; platform flags do not register tools yet.
22
- tools: createMcpTools({}),
27
+ tools: platforms.tools,
23
28
  })
24
29
  : undefined;
25
30
 
@@ -36,7 +41,15 @@ export const {
36
41
 
37
42
  export default function createHttpRouter() {
38
43
  const http = httpRouter();
39
- mcp?.registerRoutes(http);
44
+ if (mcp && enabled.includes("mcp")) mcp.registerRoutes(http);
45
+ if (mcp && enabled.includes("api"))
46
+ http.route({
47
+ pathPrefix: "/api/",
48
+ method: "POST",
49
+ handler: httpActionGeneric((ctx, request) =>
50
+ platforms.handleApi(ctx, request, mcp.authenticate.bind(mcp)),
51
+ ),
52
+ });
40
53
  registerStaticRoutes(http, components.staticHosting);
41
54
  return http;
42
55
  }
@@ -8,7 +8,6 @@ import {
8
8
  internalMutation as nativeMutation,
9
9
  internalQuery as nativeQuery,
10
10
  } from "../../../backend/convex/_generated/server";
11
- import type { Platforms } from "./platforms";
12
11
 
13
12
  // Trusted server entrypoints must supply the user ID after authentication.
14
13
  export const identityFields = {
@@ -22,19 +21,11 @@ const withPlatforms = <TDefinition, TResult extends object>(
22
21
  definition: TDefinition & {
23
22
  args: PropertyValidators;
24
23
  returns: GenericValidator;
25
- platforms?: Platforms;
26
- mcp?: boolean;
24
+ platforms?: true;
27
25
  },
28
26
  ): TResult => {
29
- const mcpEnabled =
30
- definition.platforms === undefined
31
- ? definition.mcp === true
32
- : definition.platforms === true ||
33
- (typeof definition.platforms === "object" &&
34
- definition.platforms.mcp === true);
35
27
  return Object.assign(builder(definition), {
36
28
  platforms: definition.platforms,
37
- mcp: mcpEnabled ? (definition.mcp ?? true) : false,
38
29
  args: definition.args,
39
30
  returns: definition.returns,
40
31
  });
@@ -0,0 +1,137 @@
1
+ import {
2
+ checkValue,
3
+ toJsonSchema,
4
+ tool,
5
+ type McpServer,
6
+ type ToolCtx,
7
+ type ToolDefinition,
8
+ } from "@convex-dev/mcp";
9
+ import { makeFunctionReference as reference } from "convex/server";
10
+ import {
11
+ v,
12
+ ConvexError,
13
+ type GenericValidator,
14
+ type PropertyValidators,
15
+ } from "convex/values";
16
+
17
+ type PlatformFunction = {
18
+ isInternal?: boolean;
19
+ isQuery?: boolean;
20
+ isMutation?: boolean;
21
+ isAction?: boolean;
22
+ platforms?: true;
23
+ args: PropertyValidators;
24
+ returns: GenericValidator;
25
+ };
26
+
27
+ type Operation = {
28
+ name: string;
29
+ path: string;
30
+ type: "query" | "mutation" | "action";
31
+ args: ReturnType<typeof toJsonSchema>;
32
+ returns: ReturnType<typeof toJsonSchema>;
33
+ };
34
+
35
+ /** One opt-in produces the shared JSON contract and both transport adapters. */
36
+ export function createPlatforms(
37
+ modules: Record<string, Record<string, unknown>>,
38
+ ) {
39
+ const spec: Operation[] = [];
40
+ const tools: Record<string, ToolDefinition> = Object.create(null);
41
+ const routes = new Map<string, ToolDefinition>();
42
+ for (const [path, exports] of Object.entries(modules)) {
43
+ for (const [exportName, value] of Object.entries(exports)) {
44
+ const fn = value as Partial<PlatformFunction> | null;
45
+ if (!fn?.isInternal || fn.platforms !== true) continue;
46
+ const id = `${path}:${exportName}`;
47
+ const name = id.replace(/[^A-Za-z0-9_.-]/g, "_");
48
+ const route = `/api/${id.replace(/\/internal:/, "/").replace(":", "/")}`;
49
+ if (Object.hasOwn(tools, name))
50
+ throw new Error(`Duplicate platform tool name: ${name}`);
51
+ if (routes.has(route)) throw new Error(`Duplicate API path: ${route}`);
52
+ if (
53
+ !fn.args ||
54
+ !fn.returns ||
55
+ !(fn.isQuery || fn.isMutation || fn.isAction)
56
+ )
57
+ throw new Error(`${id}: expected function kind, args and returns`);
58
+ const { userId, ...args } = fn.args;
59
+ const type = fn.isQuery ? "query" : fn.isMutation ? "mutation" : "action";
60
+ spec.push({
61
+ name: id,
62
+ path: route,
63
+ type,
64
+ args: toJsonSchema(v.object(args)),
65
+ returns: toJsonSchema(fn.returns),
66
+ });
67
+ tools[name] = tool({
68
+ description: `Call ${id}.`,
69
+ ...(fn.isQuery ? { annotations: { readOnlyHint: true } } : {}),
70
+ args,
71
+ returns: fn.returns,
72
+ handler: async (ctx, input, user) => {
73
+ const params = {
74
+ ...input,
75
+ ...(userId ? { userId: user.userId } : {}),
76
+ };
77
+ if (type === "query")
78
+ return ctx.runQuery(reference<"query">(id), params);
79
+ if (type === "mutation")
80
+ return ctx.runMutation(reference<"mutation">(id), params);
81
+ return ctx.runAction(reference<"action">(id), params);
82
+ },
83
+ });
84
+ routes.set(route, tools[name]);
85
+ }
86
+ }
87
+ return {
88
+ spec,
89
+ tools,
90
+ async handleApi(
91
+ ctx: ToolCtx,
92
+ request: Request,
93
+ authenticate: McpServer["authenticate"],
94
+ ) {
95
+ const definition = routes.get(new URL(request.url).pathname);
96
+ if (!definition)
97
+ return Response.json({ error: "not_found" }, { status: 404 });
98
+ try {
99
+ const user = await authenticate(ctx, request);
100
+ if (!user)
101
+ return Response.json({ error: "unauthenticated" }, { status: 401 });
102
+ if (definition.scope && !user.scopes.includes(definition.scope))
103
+ return Response.json({ error: "forbidden" }, { status: 403 });
104
+ const input = checkValue(
105
+ v.object(definition.args ?? {}),
106
+ await request.json(),
107
+ );
108
+ if (!input.ok)
109
+ return Response.json({ error: input.error }, { status: 400 });
110
+ const result = await definition.handler(
111
+ ctx,
112
+ input.value as Record<string, unknown>,
113
+ user,
114
+ );
115
+ return new Response(
116
+ JSON.stringify(result ?? null, (_, value) =>
117
+ typeof value === "bigint"
118
+ ? value.toString()
119
+ : value instanceof ArrayBuffer
120
+ ? btoa(
121
+ Array.from(new Uint8Array(value), (byte) =>
122
+ String.fromCharCode(byte),
123
+ ).join(""),
124
+ )
125
+ : value,
126
+ ),
127
+ { headers: { "Content-Type": "application/json" } },
128
+ );
129
+ } catch (error) {
130
+ if (error instanceof SyntaxError || error instanceof ConvexError)
131
+ return Response.json({ error: "invalid_request" }, { status: 400 });
132
+ console.error(error);
133
+ return Response.json({ error: "internal_error" }, { status: 500 });
134
+ }
135
+ },
136
+ };
137
+ }
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "$schema": "https://turbo.build/schema.json",
3
3
  "ui": "tui",
4
+ "globalEnv": ["BUN_VERSION", "NODE_VERSION"],
4
5
  "tasks": {
5
6
  "build": {
6
7
  "dependsOn": ["^build"],
@@ -23,16 +24,26 @@
23
24
  "inputs": ["$TURBO_DEFAULT$", "!src/routeTree.gen.ts"],
24
25
  "outputs": ["src/routeTree.gen.ts"]
25
26
  },
26
- "@disposabl/backend#dev:setup": {
27
- "cache": false,
28
- "passThroughEnv": ["CONVEX_DEPLOY_KEY"]
27
+ "@disposabl/disposabl-kit#build": {
28
+ "dependsOn": ["^build"],
29
+ "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/packages/backend/convex/**"]
30
+ },
31
+ "@disposabl/disposabl-kit#lint": {
32
+ "dependsOn": ["^lint"],
33
+ "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/packages/backend/convex/**"]
34
+ },
35
+ "@disposabl/disposabl-kit#typecheck": {
36
+ "dependsOn": ["^typecheck"],
37
+ "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/packages/backend/convex/**"]
38
+ },
39
+ "create-disposabl-app#build": {
40
+ "cache": false
29
41
  },
30
42
  "dev": {
31
- "dependsOn": ["@disposabl/backend#dev:setup"],
32
43
  "cache": false,
33
44
  "persistent": true,
34
45
  "passThroughEnv": ["VITE_*"]
35
46
  }
36
47
  },
37
- "globalDependencies": ["disposabl.json", "packages/backend/convex/**"]
48
+ "globalDependencies": ["disposabl.json"]
38
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,141 +0,0 @@
1
- name: CI and deploy
2
-
3
- on:
4
- pull_request:
5
- branches: [main]
6
- types: [opened, synchronize, reopened]
7
- push:
8
- branches: [main]
9
- workflow_dispatch:
10
- inputs:
11
- runner:
12
- description: Machine to compare
13
- type: choice
14
- options: [ubuntu-latest, boat-small, boat]
15
- default: boat
16
- preview:
17
- description: Deploy an isolated Convex preview, including the web build
18
- type: boolean
19
- default: false
20
- cache_scope:
21
- description: Use a new value for a cold run; reuse it for warm runs
22
- type: string
23
- default: benchmark-v1
24
-
25
- permissions:
26
- contents: read
27
-
28
- concurrency:
29
- group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && 'manual' || github.head_ref || github.ref_name }}-${{ inputs.runner || 'default' }}
30
- cancel-in-progress: false
31
-
32
- jobs:
33
- pipeline:
34
- if: github.event.deleted != true
35
- # Install the Boat CI GitHub App first. Fork PRs use GitHub-hosted runners.
36
- # DISPOSABL_CI_RUNNER can select boat-small or ubuntu-latest for normal runs.
37
- runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest' || inputs.runner || vars.DISPOSABL_CI_RUNNER || 'boat' }}
38
- env:
39
- CI_RUNNER: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest' || inputs.runner || vars.DISPOSABL_CI_RUNNER || 'boat' }}
40
- timeout-minutes: 30
41
- steps:
42
- - name: Check out repository
43
- uses: actions/checkout@v6
44
- with:
45
- persist-credentials: false
46
-
47
- - name: Record machine
48
- run: |
49
- printf 'CPUs: %s\n' "$(nproc)"
50
- lscpu
51
- free -h
52
- cat /etc/os-release
53
-
54
- - name: Install Node.js
55
- uses: actions/setup-node@v6
56
- with:
57
- node-version: "24"
58
- package-manager-cache: false
59
-
60
- - name: Install Bun
61
- uses: oven-sh/setup-bun@v2
62
- with:
63
- bun-version: "1.4.4"
64
-
65
- - name: Cache Turbo tasks
66
- uses: actions/cache@v4
67
- with:
68
- path: .turbo/cache
69
- key: turbo-${{ inputs.cache_scope || 'ci' }}-${{ env.CI_RUNNER }}-${{ runner.os }}-${{ runner.arch }}-node24-bun1.4.4-${{ github.sha }}
70
- restore-keys: |
71
- turbo-${{ inputs.cache_scope || 'ci' }}-${{ env.CI_RUNNER }}-${{ runner.os }}-${{ runner.arch }}-node24-bun1.4.4-
72
-
73
- - name: Install dependencies
74
- run: bun install --frozen-lockfile
75
-
76
- - name: Typecheck
77
- run: bun run typecheck
78
-
79
- - name: Lint
80
- run: bun run lint
81
-
82
- - name: Check formatting
83
- run: bun fmt --check
84
-
85
- - name: Test
86
- # The starter currently has no tests. Run any tests added later.
87
- run: bun test --pass-with-no-tests
88
-
89
- - name: Build
90
- # Trusted branches build once below, with their actual deployment URLs.
91
- if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || (github.event_name == 'workflow_dispatch' && !inputs.preview)
92
- env:
93
- VITE_CONVEX_URL: https://ci.invalid
94
- VITE_CONVEX_SITE_URL: https://ci.invalid
95
- run: bun run build
96
-
97
- - name: Deploy production
98
- id: production
99
- if: github.event_name == 'push'
100
- working-directory: packages/backend
101
- env:
102
- CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}
103
- run: |
104
- bun x --no-install convex deploy --yes \
105
- --cmd-url-env-var-name VITE_CONVEX_URL \
106
- --cmd '
107
- bun x --no-install --package @convex-dev/auth auth --keys-only --prod &&
108
- build_started=$(date +%s) &&
109
- VITE_CONVEX_SITE_URL="$CONVEX_SITE_URL" bun run --cwd ../.. build &&
110
- echo "Web build seconds: $(($(date +%s) - build_started))" &&
111
- echo "url=$CONVEX_SITE_URL" >> "$GITHUB_OUTPUT"
112
- '
113
- bun x --no-install static-hosting upload --prod --no-spa --dist ../../apps/web/dist/client
114
-
115
- - name: Deploy preview
116
- id: preview
117
- if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'workflow_dispatch' && inputs.preview)
118
- working-directory: packages/backend
119
- env:
120
- CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY_PREVIEW }}
121
- # Each benchmark runner gets its own preview to avoid concurrent writes.
122
- PREVIEW_NAME: ${{ github.head_ref || format('ci-benchmark-{0}', inputs.runner) }}
123
- run: |
124
- bun x --no-install convex deploy --yes --preview-name "$PREVIEW_NAME" \
125
- --cmd-url-env-var-name VITE_CONVEX_URL \
126
- --cmd '
127
- bun x --no-install --package @convex-dev/auth auth --keys-only --preview-name "$PREVIEW_NAME" &&
128
- build_started=$(date +%s) &&
129
- VITE_CONVEX_SITE_URL="$CONVEX_SITE_URL" bun run --cwd ../.. build &&
130
- echo "Web build seconds: $(($(date +%s) - build_started))" &&
131
- echo "url=$CONVEX_SITE_URL" >> "$GITHUB_OUTPUT"
132
- '
133
- bun x --no-install static-hosting upload --preview-name "$PREVIEW_NAME" --no-spa --dist ../../apps/web/dist/client
134
-
135
- - name: Show deployment URL
136
- if: steps.production.outcome == 'success' || steps.preview.outcome == 'success'
137
- env:
138
- DEPLOYMENT_URL: ${{ steps.production.outputs.url || steps.preview.outputs.url }}
139
- run: |
140
- printf 'Deployed app: %s\n' "$DEPLOYMENT_URL"
141
- printf '### Deployment\n\n[Open app](%s)\n' "$DEPLOYMENT_URL" >> "$GITHUB_STEP_SUMMARY"
@@ -1,39 +0,0 @@
1
- import { $ } from "bun";
2
- import { dirname, resolve } from "node:path";
3
- import { parseEnv } from "node:util";
4
-
5
- const root = resolve(import.meta.dir, "../../..");
6
- const backend = `${root}/packages/backend`;
7
- const read = async (path) => (await Bun.file(path).exists()) ? parseEnv(await Bun.file(path).text()) : {};
8
- const save = async (path, values) => {
9
- const previous = await read(path);
10
- if (Object.entries(values).every(([key, value]) => previous[key] === value)) return;
11
- process.umask(0o077);
12
- await Bun.write(path, Object.entries({ ...previous, ...values }).filter(([, value]) => value !== undefined).map(([key, value]) => `${key}=${JSON.stringify(value)}\n`).join(""));
13
- };
14
-
15
- $.cwd(root);
16
- if ((await $`git rev-parse --git-dir`.quiet().nothrow()).exitCode !== 0) await $`git init --initial-branch=main`.quiet();
17
- const branch = (await $`git branch --show-current`.text()).trim();
18
- if (!branch) throw new Error("Create a named Git branch before running dev.");
19
- const original = dirname((await $`git rev-parse --path-format=absolute --git-common-dir`.text()).trim());
20
- const key = process.env.CONVEX_DEPLOY_KEY ?? (await read(`${root}/.env.local`)).CONVEX_DEPLOY_KEY ?? (await read(`${original}/.env.local`)).CONVEX_DEPLOY_KEY;
21
- const match = key?.match(/^preview:([\w-]+):([\w-]+)\|[A-Za-z0-9_+/=-]+$/);
22
- if (!match) throw new Error("Set CONVEX_DEPLOY_KEY to the project preview key in root .env.local.");
23
- let saved = await read(`${backend}/.env.local`);
24
- if (saved.DISPOSABL_PREVIEW_BRANCH !== branch || saved.CONVEX_SELF_HOSTED_ADMIN_KEY !== key || !saved.CONVEX_SELF_HOSTED_URL) {
25
- // Convex CLI's create-or-reuse API. Explicit URL/key config lets native `convex dev` use the preview.
26
- const response = await fetch("https://api.convex.dev/api/claim_preview_deployment", {
27
- method: "POST", redirect: "error", headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
28
- body: JSON.stringify({ projectSelection: { kind: "teamAndProjectSlugs", teamSlug: match[1], projectSlug: match[2] }, identifier: branch, reuse: true }),
29
- });
30
- if (!response.ok) throw new Error(`Preview setup failed (${response.status}).`);
31
- const { instanceUrl, adminKey } = await response.json();
32
- if (!/^https:\/\/[a-z0-9-]+\.convex\.cloud$/.test(instanceUrl) || !adminKey) throw new Error("Invalid preview credentials returned by Convex.");
33
- await $`bun --no-env-file node_modules/@convex-dev/auth/dist/cli/init.js --keys-only --preview-name ${branch}`.cwd(backend).env({ ...process.env, CONVEX_DEPLOY_KEY: key });
34
- saved = { DISPOSABL_PREVIEW_BRANCH: branch, CONVEX_SELF_HOSTED_URL: instanceUrl, CONVEX_SELF_HOSTED_ADMIN_KEY: adminKey };
35
- await save(`${backend}/.env.local`, { ...saved, CONVEX_DEPLOY_KEY: undefined, CONVEX_DEPLOYMENT_TOKEN: undefined, CONVEX_DEPLOYMENT: undefined });
36
- }
37
- for await (const manifest of new Bun.Glob("apps/*/package.json").scan({ cwd: root, absolute: true }))
38
- await save(`${dirname(manifest)}/.env.local`, { VITE_CONVEX_URL: saved.CONVEX_SELF_HOSTED_URL, VITE_CONVEX_SITE_URL: saved.CONVEX_SELF_HOSTED_URL.replace(/\.cloud$/, ".site") });
39
- console.log(`Using preview ${branch}.`);