create-disposabl-app 0.6.1 → 0.6.3

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/index.js CHANGED
@@ -8,7 +8,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8
8
  import { Command, CommanderError } from "commander";
9
9
  import * as p2 from "@clack/prompts";
10
10
  // package.json
11
- var version = "0.6.1";
11
+ var version = "0.6.3";
12
12
 
13
13
  // ../disposabl-kit/platforms.ts
14
14
  var platforms = [
@@ -328,7 +328,6 @@ async function createApp(template, destination, name, config, overwrite = false)
328
328
  "packages/disposabl-kit/client/routes/_auth-pages",
329
329
  "packages/disposabl-kit/client/routes/consent.tsx",
330
330
  "apps/web/src/router/_authenticated/dashboard.api-keys.tsx",
331
- "apps/web/tests/auth-branches.test.tsx",
332
331
  "apps/mobile/src/app/(auth)",
333
332
  "apps/mobile/src/app/(authenticated)/account.tsx"
334
333
  ]) {
@@ -368,8 +367,7 @@ export const Route = createFileRoute("/_providers/_authenticated/dashboard")({
368
367
  delete turbo.tasks["@disposabl/web#build"];
369
368
  await writeFile(turboPath, JSON.stringify(turbo, null, 2) + `
370
369
  `);
371
- for (const file of ["docs.ts", "docs.test.ts"])
372
- await rm(join(destination, "packages/disposabl-kit/server/lib", file));
370
+ await rm(join(destination, "packages/disposabl-kit/server/lib/docs.ts"));
373
371
  }
374
372
  for (const kind of ["cli", "sdk"]) {
375
373
  const folder = join(destination, "packages", kind);
@@ -0,0 +1,5 @@
1
+ # Development
2
+
3
+ - Do not write automated tests or add test files.
4
+ - Validate changes through real user behavior. Behavior-based test flows will be added later.
5
+ - Keep code concise and source files under 300 lines. Simplify related code with each change.
@@ -0,0 +1,54 @@
1
+ import { readFile, writeFile, access } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { parseEnv } from "node:util";
4
+
5
+ const root = import.meta.dir;
6
+ const backend = join(root, "packages/backend");
7
+ const read = (path: string) => readFile(path, "utf8").catch(() => "");
8
+ const backendEnv = () => read(join(backend, ".env.local")).then(parseEnv);
9
+ let env = await backendEnv();
10
+ if (!env.CONVEX_DEPLOYMENT && !env.CONVEX_DEPLOY_KEY) {
11
+ const configure = Bun.spawn(
12
+ ["bun", "x", "--no-install", "convex", "dev", "--once"],
13
+ {
14
+ cwd: backend,
15
+ stdin: "inherit",
16
+ stdout: "inherit",
17
+ stderr: "inherit",
18
+ },
19
+ );
20
+ if (await configure.exited)
21
+ throw new Error("Complete Convex setup before starting development.");
22
+ env = await backendEnv();
23
+ }
24
+ const url = env.CONVEX_URL;
25
+ const site =
26
+ env.CONVEX_SITE_URL || url?.replace(/\.convex\.cloud$/, ".convex.site");
27
+ if (!url || !site)
28
+ throw new Error(
29
+ "Configure CONVEX_URL and CONVEX_SITE_URL in packages/backend/.env.local.",
30
+ );
31
+ for (const [app, prefix] of [
32
+ ["web", "VITE"],
33
+ ["mobile", "EXPO_PUBLIC"],
34
+ ]) {
35
+ const directory = join(root, "apps", app);
36
+ if (
37
+ !(await access(directory)
38
+ .then(() => true)
39
+ .catch(() => false))
40
+ )
41
+ continue;
42
+ const path = join(directory, ".env.local");
43
+ const lines = (await read(path))
44
+ .split("\n")
45
+ .filter(
46
+ (line) =>
47
+ !line.startsWith(`${prefix}_CONVEX_URL=`) &&
48
+ !line.startsWith(`${prefix}_CONVEX_SITE_URL=`),
49
+ );
50
+ await writeFile(
51
+ path,
52
+ `${lines.join("\n").trim()}\n${prefix}_CONVEX_URL=${url}\n${prefix}_CONVEX_SITE_URL=${site}\n`,
53
+ );
54
+ }
@@ -9,7 +9,8 @@
9
9
  "format": "turbo format",
10
10
  "typecheck": "turbo typecheck",
11
11
  "generate": "bun run --cwd packages/backend generate",
12
- "prebuild": "bun run generate"
12
+ "prebuild": "bun run generate",
13
+ "predev": "bun dev.ts"
13
14
  },
14
15
  "devDependencies": {
15
16
  "prettier": "^3.9.10",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,128 +0,0 @@
1
- import { test } from "node:test";
2
- import assert from "node:assert/strict";
3
- import configure from "../app.config.js";
4
-
5
- function withEnv(values, action) {
6
- const previous = { ...process.env };
7
- for (const key of Object.keys(process.env)) {
8
- if (/^(EXPO_|DISPOSABL_|CONVEX_)/.test(key)) delete process.env[key];
9
- }
10
- Object.assign(process.env, values);
11
- try {
12
- return action();
13
- } finally {
14
- process.env = previous;
15
- }
16
- }
17
-
18
- test("PR installations and update channels are isolated from production", () => {
19
- const config = {
20
- slug: "app",
21
- name: "App",
22
- android: {
23
- package: "app.example.mobile",
24
- runtimeVersion: { policy: "appVersion" },
25
- },
26
- };
27
- const result = withEnv(
28
- { EXPO_PROJECT_ID: "test-id", DISPOSABL_ANDROID_CHANNEL: "pr-12" },
29
- () => configure({ config }),
30
- );
31
- assert.equal(result.android.package, "app.example.mobile.pr12");
32
- assert.equal(result.updates.requestHeaders["expo-channel-name"], "pr-12");
33
- assert.deepEqual(result.android.runtimeVersion, { policy: "fingerprint" });
34
- const production = withEnv(
35
- { EXPO_PROJECT_ID: "test-id", DISPOSABL_ANDROID_CHANNEL: "production" },
36
- () => configure({ config }),
37
- );
38
- assert.equal(production.android.package, "app.example.mobile");
39
- assert.equal(
40
- production.updates.requestHeaders["expo-channel-name"],
41
- "production",
42
- );
43
- });
44
-
45
- test("EAS cannot silently replace a deployed preview backend URL", () => {
46
- assert.throws(
47
- () =>
48
- withEnv(
49
- {
50
- CONVEX_URL: "https://correct.convex.cloud",
51
- EXPO_PUBLIC_CONVEX_URL: "https://wrong.convex.cloud",
52
- },
53
- () => configure({ config: {} }),
54
- ),
55
- /conflicts with the web deployment/,
56
- );
57
- });
58
-
59
- test("invalid version codes and channel input fail before native compilation", () => {
60
- for (const version of ["0", "-1", "1.2", "2100000001", "bad"]) {
61
- assert.throws(
62
- () =>
63
- withEnv({ DISPOSABL_ANDROID_VERSION_CODE: version }, () =>
64
- configure({ config: {} }),
65
- ),
66
- /version code/,
67
- );
68
- }
69
- assert.throws(
70
- () =>
71
- withEnv({ DISPOSABL_ANDROID_CHANNEL: "pr-12\nother" }, () =>
72
- configure({ config: {} }),
73
- ),
74
- /CHANNEL/,
75
- );
76
- });
77
-
78
- test("iOS previews share a provisionable identity while their channels remain isolated", () => {
79
- const config = { ios: { bundleIdentifier: "app.example.mobile" } };
80
- const preview = (channel) =>
81
- withEnv(
82
- {
83
- EXPO_PROJECT_ID: "test",
84
- DISPOSABL_MOBILE_CHANNEL: channel,
85
- DISPOSABL_IOS_BUILD_NUMBER: "42",
86
- },
87
- () => configure({ config }),
88
- );
89
- const first = preview("pr-12");
90
- const second = preview("pr-13");
91
- assert.equal(first.ios.bundleIdentifier, "app.example.mobile.preview");
92
- assert.equal(second.ios.bundleIdentifier, first.ios.bundleIdentifier);
93
- assert.equal(first.ios.buildNumber, "42");
94
- assert.equal(first.updates.requestHeaders["expo-channel-name"], "pr-12");
95
- assert.equal(second.updates.requestHeaders["expo-channel-name"], "pr-13");
96
- assert.equal(
97
- preview("production").ios.bundleIdentifier,
98
- "app.example.mobile",
99
- );
100
- assert.throws(
101
- () =>
102
- withEnv({ DISPOSABL_IOS_BUILD_NUMBER: "bad" }, () =>
103
- configure({ config }),
104
- ),
105
- /BUILD_NUMBER/,
106
- );
107
- });
108
-
109
- test("preview naming can change without hardcoded PR syntax", () => {
110
- const config = withEnv(
111
- { EXPO_PROJECT_ID: "test", DISPOSABL_MOBILE_CHANNEL: "preview-42" },
112
- () => configure({ config: { ios: { runtimeVersion: "old" } } }),
113
- );
114
- assert.equal(
115
- config.updates.requestHeaders["expo-channel-name"],
116
- "preview-42",
117
- );
118
- assert.deepEqual(config.ios.runtimeVersion, { policy: "fingerprint" });
119
- assert.ok(config.android.package.endsWith(".preview42"));
120
- });
121
-
122
- test("manual EAS iOS builds use their profile channel", () => {
123
- const config = withEnv(
124
- { EXPO_PROJECT_ID: "test", EAS_BUILD_PROFILE: "ios-preview" },
125
- () => configure({ config: {} }),
126
- );
127
- assert.equal(config.updates.requestHeaders["expo-channel-name"], "preview");
128
- });
@@ -1,44 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { Outlet } from "@tanstack/react-router";
3
- import { Authenticated, type ConvexReactClient } from "convex/react";
4
- import { AuthProvider } from "../../../packages/disposabl-kit/client/routes/route";
5
- import { AuthenticatedLayout } from "../../../packages/disposabl-kit/client/routes/_authenticated/route";
6
- import { createRoutes } from "../../../packages/disposabl-kit/client/vite.config";
7
-
8
- describe("frontend authentication branches", () => {
9
- test("selects the correct Convex provider", () => {
10
- const client = {} as ConvexReactClient;
11
- expect(
12
- AuthProvider({ client, enabled: true, children: null }).type.name,
13
- ).toBe("ConvexAuthProvider");
14
- expect(
15
- AuthProvider({ client, enabled: false, children: null }).type.name,
16
- ).toBe("ConvexProvider");
17
- });
18
-
19
- test("gates authenticated routes only when enabled", () => {
20
- expect(AuthenticatedLayout({ enabled: false }).type).toBe(Outlet);
21
- const enabled = AuthenticatedLayout({ enabled: true });
22
- expect(enabled.props.children[0].type).toBe(Authenticated);
23
- });
24
-
25
- test("registers auth routes only when authentication is enabled", () => {
26
- const paths = (enabled: boolean) => {
27
- const config = createRoutes(enabled);
28
- const providers = config.children?.[0];
29
- if (!providers || !("children" in providers))
30
- throw new Error("Missing providers layout");
31
- return (
32
- providers.children?.flatMap((child) =>
33
- "path" in child ? [child.path] : [],
34
- ) ?? []
35
- );
36
- };
37
- expect(paths(true)).toEqual(
38
- expect.arrayContaining(["/login", "/signup", "/consent"]),
39
- );
40
- expect(paths(false)).not.toContain("/login");
41
- expect(paths(false)).not.toContain("/signup");
42
- expect(paths(false)).not.toContain("/consent");
43
- });
44
- });
@@ -1,111 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { test } from "node:test";
3
- import {
4
- httpRouter,
5
- type GenericActionCtx,
6
- type GenericDataModel,
7
- } from "convex/server";
8
- import { registerDocsRoutes } from "./docs";
9
-
10
- function setup() {
11
- const router = httpRouter();
12
- registerDocsRoutes(router);
13
- const paths: string[] = [];
14
- const assets = new Map([
15
- [
16
- "/docs/index.html",
17
- { contentType: "text/html", storageUrl: "data:text/html,Docs" },
18
- ],
19
- [
20
- "/docs/guides/writing/index.html",
21
- { contentType: "text/html", storageUrl: "data:text/html,Writing" },
22
- ],
23
- [
24
- "/docs/404.html",
25
- { contentType: "text/html", storageUrl: "data:text/html,Missing" },
26
- ],
27
- [
28
- "/docs/RSC/R/guides/writing.txt",
29
- { contentType: "text/plain", storageUrl: "data:text/plain,RSC" },
30
- ],
31
- ]);
32
- const ctx = {
33
- runQuery: (
34
- _query: unknown,
35
- args: { path: string; spaFallback: boolean },
36
- ) => {
37
- assert.equal(args.spaFallback, false);
38
- paths.push(args.path);
39
- return Promise.resolve(assets.get(args.path) ?? null);
40
- },
41
- } as unknown as GenericActionCtx<GenericDataModel>;
42
- async function get(path: string, accept = "text/html") {
43
- const request = new Request(`https://example.convex.site${path}`, {
44
- headers: { Accept: accept },
45
- });
46
- const match = router.lookup(new URL(request.url).pathname, "GET");
47
- assert.ok(match);
48
- const action = match[0] as unknown as {
49
- _handler: (context: typeof ctx, request: Request) => Promise<Response>;
50
- };
51
- return action._handler(ctx, request);
52
- }
53
- return { router, paths, get };
54
- }
55
-
56
- test("docs root redirects to the Waku base path and preserves query parameters", async () => {
57
- const { get, paths } = setup();
58
- const response = await get("/docs?q=writing");
59
- assert.equal(response.status, 308);
60
- assert.equal(
61
- response.headers.get("Location"),
62
- "https://example.convex.site/docs/?q=writing",
63
- );
64
- assert.deepEqual(paths, []);
65
- });
66
-
67
- test("root and nested clean URLs resolve their directory indexes", async () => {
68
- const { get } = setup();
69
- assert.equal(await (await get("/docs/")).text(), "Docs");
70
- for (const path of ["/docs/guides/writing", "/docs/guides/writing/"]) {
71
- const response = await get(path);
72
- assert.equal(response.status, 200);
73
- assert.equal(response.headers.get("Content-Type"), "text/html");
74
- assert.equal(await response.text(), "Writing");
75
- }
76
- });
77
-
78
- test("RSC files are served at their exact path with their content type", async () => {
79
- const { get, paths } = setup();
80
- const response = await get("/docs/RSC/R/guides/writing.txt", "*/*");
81
- assert.equal(response.status, 200);
82
- assert.equal(response.headers.get("Content-Type"), "text/plain");
83
- assert.equal(await response.text(), "RSC");
84
- assert.deepEqual(paths, ["/docs/RSC/R/guides/writing.txt"]);
85
- });
86
-
87
- test("missing pages retain HTTP 404 and never use the app homepage", async () => {
88
- const { get, paths } = setup();
89
- const response = await get("/docs/missing");
90
- assert.equal(response.status, 404);
91
- assert.equal(await response.text(), "Missing");
92
- assert.ok(!paths.includes("/index.html"));
93
- const asset = await get("/docs/assets/missing.js", "*/*");
94
- assert.equal(asset.status, 404);
95
- assert.equal(await asset.text(), "Not Found");
96
- });
97
-
98
- test("malformed paths are rejected and other routes remain outside the docs handler", async () => {
99
- const { get, paths, router } = setup();
100
- for (const path of [
101
- "/docs/%",
102
- "/docs/%2e%2e%2fprivate",
103
- "/docs/%5cprivate",
104
- "/docs/%00",
105
- ]) {
106
- assert.equal((await get(path)).status, 400);
107
- }
108
- assert.deepEqual(paths, []);
109
- assert.equal(router.lookup("/dashboard", "GET"), null);
110
- assert.equal(router.lookup("/docs-other", "GET"), null);
111
- });