create-disposabl-app 0.4.2 → 0.5.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/README.md +6 -0
- package/dist/index.js +67 -57
- package/dist/templates/default/apps/docs/README.md +37 -0
- package/dist/templates/default/apps/docs/content/guides/writing.mdx +15 -0
- package/dist/templates/default/apps/docs/content/index.mdx +10 -0
- package/dist/templates/default/apps/docs/package.json +29 -1
- package/dist/templates/default/apps/docs/press.config.ts +20 -0
- package/dist/templates/default/apps/docs/src/app.css +4 -0
- package/dist/templates/default/apps/docs/tsconfig.json +14 -0
- package/dist/templates/default/apps/docs/vite.config.ts +8 -0
- package/dist/templates/default/apps/mobile/.env.example +2 -0
- package/dist/templates/default/apps/mobile/README.md +63 -4
- package/dist/templates/default/apps/mobile/app.json +2 -0
- package/dist/templates/default/apps/mobile/package.json +16 -3
- package/dist/templates/default/apps/mobile/src/app/(auth)/_layout.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(auth)/login.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(auth)/signup.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(authenticated)/_layout.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/(authenticated)/account.tsx +1 -0
- package/dist/templates/default/apps/mobile/src/app/_layout.tsx +1 -5
- package/dist/templates/default/apps/mobile/src/app/index.tsx +1 -17
- package/dist/templates/default/apps/mobile/tsconfig.json +8 -1
- package/dist/templates/default/apps/web/package.json +2 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +1 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.tsx +2 -0
- package/dist/templates/default/apps/web/src/router/_authenticated/todos/$id.tsx +1 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/todos/index.tsx +1 -1
- package/dist/templates/default/apps/web/tests/auth-branches.test.tsx +44 -0
- package/dist/templates/default/apps/web/vite.config.ts +15 -0
- package/dist/templates/default/bun.lock +564 -18
- package/dist/templates/default/disposabl.json +2 -13
- package/dist/templates/default/packages/backend/convex/users.ts +23 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/ui/log-out.tsx +16 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/prerender.ts +6 -3
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/login.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/_auth-pages/signUp.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/_authenticated/route.tsx +25 -16
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +1 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +23 -2
- package/dist/templates/default/packages/disposabl-kit/client/vite.config.ts +20 -9
- package/dist/templates/default/packages/disposabl-kit/eslint.config.js +1 -1
- package/dist/templates/default/packages/disposabl-kit/features.ts +4 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/components/auth-form.tsx +125 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/components/auth-ui.tsx +107 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/expo-plugin.cjs +26 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/index.ts +10 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/layout.tsx +101 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/auth-errors.ts +40 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/auth-storage.ts +9 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/lib/convex.ts +1 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/account.tsx +67 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/home.tsx +50 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/login.tsx +5 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/signup.tsx +5 -0
- package/dist/templates/default/packages/disposabl-kit/package.json +24 -1
- package/dist/templates/default/packages/disposabl-kit/platforms.ts +1 -27
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +6 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/docs.test.ts +111 -0
- package/dist/templates/default/packages/disposabl-kit/server/lib/docs.ts +62 -0
- package/dist/templates/default/packages/disposabl-kit/tsconfig.json +1 -1
- package/dist/templates/default/turbo.json +7 -0
- package/package.json +1 -1
- package/dist/templates/default/apps/blog/package.json +0 -1
- package/dist/templates/default/apps/changelog/package.json +0 -1
- package/dist/templates/default/apps/desktop/.oxfmtrc.json +0 -5
- package/dist/templates/default/apps/desktop/.oxlintrc.json +0 -6
- package/dist/templates/default/apps/desktop/README.md +0 -88
- package/dist/templates/default/apps/desktop/build-ci.mjs +0 -56
- package/dist/templates/default/apps/desktop/forge.config.mts +0 -109
- package/dist/templates/default/apps/desktop/index.html +0 -12
- package/dist/templates/default/apps/desktop/package.json +0 -55
- package/dist/templates/default/apps/desktop/src/declarations.d.ts +0 -2
- package/dist/templates/default/apps/desktop/src/index.css +0 -8
- package/dist/templates/default/apps/desktop/src/main.ts +0 -58
- package/dist/templates/default/apps/desktop/src/preload.ts +0 -3
- package/dist/templates/default/apps/desktop/src/renderer.ts +0 -19
- package/dist/templates/default/apps/desktop/tsconfig.json +0 -14
- package/dist/templates/default/apps/desktop/vite.main.config.mts +0 -4
- package/dist/templates/default/apps/desktop/vite.preload.config.mts +0 -4
- package/dist/templates/default/apps/desktop/vite.renderer.config.mts +0 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SignInWithUsernamePasswordResult,
|
|
3
|
+
SignUpWithUsernamePasswordResult,
|
|
4
|
+
} from "@convex-dev/auth/methods/username-password/react";
|
|
5
|
+
|
|
6
|
+
type AuthError = Extract<
|
|
7
|
+
SignInWithUsernamePasswordResult | SignUpWithUsernamePasswordResult,
|
|
8
|
+
{ status: "error" }
|
|
9
|
+
>["userError"];
|
|
10
|
+
|
|
11
|
+
export function authErrorMessage(error: AuthError): string {
|
|
12
|
+
switch (error.error) {
|
|
13
|
+
case "USER_NOT_FOUND":
|
|
14
|
+
case "INVALID_CREDENTIALS":
|
|
15
|
+
return "Incorrect username or password.";
|
|
16
|
+
case "USERNAME_TAKEN":
|
|
17
|
+
return "That username is already taken.";
|
|
18
|
+
case "USERNAME_TOO_SHORT":
|
|
19
|
+
return `Username must be at least ${error.minimumLength} characters.`;
|
|
20
|
+
case "USERNAME_HAS_SURROUNDING_WHITESPACE":
|
|
21
|
+
return "Username can't start or end with spaces.";
|
|
22
|
+
case "USERNAME_HAS_INVALID_CHARACTERS":
|
|
23
|
+
return "Username contains characters that aren't allowed.";
|
|
24
|
+
case "PASSWORD_TOO_SHORT":
|
|
25
|
+
return `Password must be at least ${error.minimumLength} characters.`;
|
|
26
|
+
case "PASSWORD_TOO_LONG":
|
|
27
|
+
return `Password must be at most ${error.maximumLength} characters.`;
|
|
28
|
+
case "PASSWORD_HAS_SURROUNDING_WHITESPACE":
|
|
29
|
+
return "Password can't start or end with spaces.";
|
|
30
|
+
case "PASSWORD_TOO_COMMON":
|
|
31
|
+
return "This password is too common. Choose a different one.";
|
|
32
|
+
case "RATE_LIMITED":
|
|
33
|
+
return `Too many attempts. Try again in ${Math.ceil(error.retryAfterMs / 1000)} seconds.`;
|
|
34
|
+
case "OTHER_ERROR":
|
|
35
|
+
return "Couldn't sign in. Check your connection and try again.";
|
|
36
|
+
default:
|
|
37
|
+
error satisfies never;
|
|
38
|
+
return "Something went wrong. Please try again.";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TokenStorage } from "@convex-dev/auth/react";
|
|
2
|
+
import * as SecureStore from "expo-secure-store";
|
|
3
|
+
|
|
4
|
+
// Convex Auth namespaces these keys by deployment and owns refresh and cleanup.
|
|
5
|
+
export const authStorage: TokenStorage = {
|
|
6
|
+
getItem: SecureStore.getItemAsync,
|
|
7
|
+
setItem: SecureStore.setItemAsync,
|
|
8
|
+
removeItem: SecureStore.deleteItemAsync,
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { api } from "../../../backend/convex/_generated/api";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useAuthActions } from "@convex-dev/auth/react";
|
|
2
|
+
import { useQuery } from "convex/react";
|
|
3
|
+
import { Link, router } from "expo-router";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Text, View } from "react-native";
|
|
6
|
+
import { AuthButton, AuthScreen, styles } from "../components/auth-ui";
|
|
7
|
+
import { api } from "../lib/convex";
|
|
8
|
+
|
|
9
|
+
export function AccountScreen() {
|
|
10
|
+
const user = useQuery(api.users.current);
|
|
11
|
+
const { signOut } = useAuthActions();
|
|
12
|
+
const [pending, setPending] = useState(false);
|
|
13
|
+
const [error, setError] = useState<string | null>(null);
|
|
14
|
+
|
|
15
|
+
async function logOut() {
|
|
16
|
+
if (pending) return;
|
|
17
|
+
setPending(true);
|
|
18
|
+
setError(null);
|
|
19
|
+
try {
|
|
20
|
+
await signOut();
|
|
21
|
+
router.replace("/");
|
|
22
|
+
} catch {
|
|
23
|
+
setError("Couldn't clear your session. Please try logging out again.");
|
|
24
|
+
} finally {
|
|
25
|
+
setPending(false);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<AuthScreen>
|
|
31
|
+
<Text style={styles.title}>
|
|
32
|
+
{user?.username ? `Hi, ${user.username}` : "Your account"}
|
|
33
|
+
</Text>
|
|
34
|
+
{user === undefined ? (
|
|
35
|
+
<Text style={styles.body}>Loading your account...</Text>
|
|
36
|
+
) : user === null ? (
|
|
37
|
+
<Text style={styles.error}>Your account could not be found.</Text>
|
|
38
|
+
) : (
|
|
39
|
+
<View style={styles.card}>
|
|
40
|
+
<Text style={styles.label}>You are logged in</Text>
|
|
41
|
+
<Text style={styles.body}>
|
|
42
|
+
Username: {user.username ?? "Not set"}
|
|
43
|
+
</Text>
|
|
44
|
+
<Text style={styles.body} selectable>
|
|
45
|
+
User ID: {user.id}
|
|
46
|
+
</Text>
|
|
47
|
+
<Text style={styles.body}>
|
|
48
|
+
Your account was verified by the server.
|
|
49
|
+
</Text>
|
|
50
|
+
</View>
|
|
51
|
+
)}
|
|
52
|
+
<AuthButton
|
|
53
|
+
title={pending ? "Logging out..." : "Log out"}
|
|
54
|
+
pending={pending}
|
|
55
|
+
onPress={() => void logOut()}
|
|
56
|
+
/>
|
|
57
|
+
{error && (
|
|
58
|
+
<Text accessibilityRole="alert" style={styles.error}>
|
|
59
|
+
{error}
|
|
60
|
+
</Text>
|
|
61
|
+
)}
|
|
62
|
+
<Link href="/" style={styles.link}>
|
|
63
|
+
Back to home
|
|
64
|
+
</Link>
|
|
65
|
+
</AuthScreen>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useConvexAuth } from "convex/react";
|
|
2
|
+
import { router, Stack } from "expo-router";
|
|
3
|
+
import { Text } from "react-native";
|
|
4
|
+
import { AuthButton, AuthScreen, styles } from "../components/auth-ui";
|
|
5
|
+
|
|
6
|
+
export function HomeScreen() {
|
|
7
|
+
return (
|
|
8
|
+
<AuthScreen>
|
|
9
|
+
<Text style={styles.title}>Welcome to Disposabl</Text>
|
|
10
|
+
<Text style={styles.body}>This home screen is public.</Text>
|
|
11
|
+
<AccountLinks />
|
|
12
|
+
</AuthScreen>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function AccountLinks() {
|
|
17
|
+
const { isAuthenticated, isLoading } = useConvexAuth();
|
|
18
|
+
if (isLoading)
|
|
19
|
+
return <Text style={styles.body}>Restoring your session...</Text>;
|
|
20
|
+
if (isAuthenticated) {
|
|
21
|
+
return (
|
|
22
|
+
<AuthButton
|
|
23
|
+
title="Your account"
|
|
24
|
+
onPress={() => router.push("/(authenticated)/account")}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Text style={styles.body}>
|
|
31
|
+
Log in to see your account, or create one to get started.
|
|
32
|
+
</Text>
|
|
33
|
+
<AuthButton title="Log in" onPress={() => router.push("/(auth)/login")} />
|
|
34
|
+
<AuthButton
|
|
35
|
+
title="Create account"
|
|
36
|
+
onPress={() => router.push("/(auth)/signup")}
|
|
37
|
+
/>
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function PublicHomeScreen() {
|
|
43
|
+
return (
|
|
44
|
+
<AuthScreen>
|
|
45
|
+
<Stack.Screen options={{ title: "Disposabl" }} />
|
|
46
|
+
<Text style={styles.title}>Welcome to Disposabl</Text>
|
|
47
|
+
<Text style={styles.body}>This home screen is public.</Text>
|
|
48
|
+
</AuthScreen>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -57,6 +57,29 @@
|
|
|
57
57
|
"./server/http": "./server/http.ts",
|
|
58
58
|
"./server/lib/functions": "./server/lib/functions.ts",
|
|
59
59
|
"./client/vite.config": "./client/vite.config.ts",
|
|
60
|
-
"./platforms": "./platforms.ts"
|
|
60
|
+
"./platforms": "./platforms.ts",
|
|
61
|
+
"./mobile": "./mobile/index.ts",
|
|
62
|
+
"./features": "./features.ts",
|
|
63
|
+
"./mobile/expo-plugin": "./mobile/expo-plugin.cjs"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"expo": "~58.0.19",
|
|
67
|
+
"expo-router": "~58.0.26",
|
|
68
|
+
"expo-secure-store": "~58.0.2",
|
|
69
|
+
"react-native": "0.88.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"expo": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"expo-router": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"expo-secure-store": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"react-native": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
61
84
|
}
|
|
62
85
|
}
|
|
@@ -2,38 +2,15 @@ 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: "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
5
|
{
|
|
9
6
|
id: "mcp",
|
|
10
7
|
label: "MCP",
|
|
11
|
-
group: "
|
|
8
|
+
group: "Developer tools",
|
|
12
9
|
status: "available",
|
|
13
10
|
description: "Tools for AI assistants",
|
|
14
11
|
},
|
|
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
12
|
{ id: "api", label: "API", group: "Developer tools", status: "available" },
|
|
30
13
|
{ id: "cli", label: "CLI", group: "Developer tools", status: "available" },
|
|
31
|
-
{
|
|
32
|
-
id: "python-sdk",
|
|
33
|
-
label: "Python SDK",
|
|
34
|
-
group: "Coming soon",
|
|
35
|
-
status: "disabled",
|
|
36
|
-
},
|
|
37
14
|
{
|
|
38
15
|
id: "typescript-sdk",
|
|
39
16
|
label: "TypeScript SDK",
|
|
@@ -48,10 +25,7 @@ export const requiredPlatform: Platform = "web";
|
|
|
48
25
|
export const platformDependencies: Partial<
|
|
49
26
|
Record<Platform, readonly Platform[]>
|
|
50
27
|
> = {
|
|
51
|
-
"openai-plugin": ["mcp"],
|
|
52
|
-
"claude-code-plugin": ["mcp"],
|
|
53
28
|
cli: ["api"],
|
|
54
|
-
"python-sdk": ["api"],
|
|
55
29
|
"typescript-sdk": ["api"],
|
|
56
30
|
};
|
|
57
31
|
|
|
@@ -7,6 +7,9 @@ import modules from "../../backend/generated/platforms";
|
|
|
7
7
|
import openapi from "../../backend/generated/openapi.json";
|
|
8
8
|
import config from "../../../disposabl.json";
|
|
9
9
|
import { validatePlatforms } from "../platforms";
|
|
10
|
+
// docs:start
|
|
11
|
+
import { registerDocsRoutes } from "./lib/docs";
|
|
12
|
+
// docs:end
|
|
10
13
|
import { createOpenApi, createPlatforms } from "./lib/platform-spec";
|
|
11
14
|
import { registerPageRoutes } from "./lib/static";
|
|
12
15
|
|
|
@@ -93,6 +96,9 @@ export default function createHttpRouter() {
|
|
|
93
96
|
}),
|
|
94
97
|
});
|
|
95
98
|
}
|
|
99
|
+
// docs:start
|
|
100
|
+
registerDocsRoutes(http);
|
|
101
|
+
// docs:end
|
|
96
102
|
registerPageRoutes(http);
|
|
97
103
|
return http;
|
|
98
104
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { httpActionGeneric, type HttpRouter } from "convex/server";
|
|
2
|
+
import type { GenericId } from "convex/values";
|
|
3
|
+
import { components } from "../../../backend/convex/_generated/api";
|
|
4
|
+
|
|
5
|
+
/** Fumapress emits directory indexes; the static component resolves exact paths. */
|
|
6
|
+
export function registerDocsRoutes(http: HttpRouter) {
|
|
7
|
+
const handler = httpActionGeneric(async (ctx, request) => {
|
|
8
|
+
const url = new URL(request.url);
|
|
9
|
+
if (url.pathname === "/docs") {
|
|
10
|
+
url.pathname = "/docs/";
|
|
11
|
+
return Response.redirect(url, 308);
|
|
12
|
+
}
|
|
13
|
+
let path: string;
|
|
14
|
+
try {
|
|
15
|
+
path = decodeURIComponent(url.pathname);
|
|
16
|
+
} catch {
|
|
17
|
+
return new Response("Bad Request", { status: 400 });
|
|
18
|
+
}
|
|
19
|
+
if (
|
|
20
|
+
!path.startsWith("/docs/") ||
|
|
21
|
+
path.includes("\\") ||
|
|
22
|
+
path.includes("\0") ||
|
|
23
|
+
path.split("/").some((part) => part === "." || part === "..")
|
|
24
|
+
) {
|
|
25
|
+
return new Response("Bad Request", { status: 400 });
|
|
26
|
+
}
|
|
27
|
+
const resolve = (assetPath: string) =>
|
|
28
|
+
ctx.runQuery(components.staticHosting.lib.resolveAssetForHttp, {
|
|
29
|
+
path: assetPath,
|
|
30
|
+
spaFallback: false,
|
|
31
|
+
});
|
|
32
|
+
let asset = await resolve(path);
|
|
33
|
+
asset ??= await resolve(`${path.replace(/\/$/, "")}/index.html`);
|
|
34
|
+
const status = asset ? 200 : 404;
|
|
35
|
+
if (!asset && request.headers.get("Accept")?.includes("text/html"))
|
|
36
|
+
asset = await resolve("/docs/404.html");
|
|
37
|
+
if (!asset) return new Response("Not Found", { status: 404 });
|
|
38
|
+
if (asset.blobId && !asset.contentType.startsWith("text/html"))
|
|
39
|
+
return Response.redirect(
|
|
40
|
+
new URL(`/fs/blobs/${encodeURIComponent(asset.blobId)}`, url),
|
|
41
|
+
302,
|
|
42
|
+
);
|
|
43
|
+
const body = asset.appStorageId
|
|
44
|
+
? await ctx.storage.get(asset.appStorageId as GenericId<"_storage">)
|
|
45
|
+
: asset.storageUrl
|
|
46
|
+
? await fetch(asset.storageUrl).then((response) =>
|
|
47
|
+
response.ok ? response.body : null,
|
|
48
|
+
)
|
|
49
|
+
: null;
|
|
50
|
+
if (!body) return new Response("Asset not available", { status: 502 });
|
|
51
|
+
return new Response(body, {
|
|
52
|
+
status,
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": asset.contentType,
|
|
55
|
+
"Cache-Control": "no-cache",
|
|
56
|
+
"X-Content-Type-Options": "nosniff",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
http.route({ path: "/docs", method: "GET", handler });
|
|
61
|
+
http.route({ pathPrefix: "/docs/", method: "GET", handler });
|
|
62
|
+
}
|
|
@@ -52,6 +52,13 @@
|
|
|
52
52
|
"generate:watch": {
|
|
53
53
|
"cache": false,
|
|
54
54
|
"persistent": true
|
|
55
|
+
},
|
|
56
|
+
"@disposabl/docs#build": {
|
|
57
|
+
"cache": false
|
|
58
|
+
},
|
|
59
|
+
"@disposabl/web#build": {
|
|
60
|
+
"dependsOn": ["^build"],
|
|
61
|
+
"cache": false
|
|
55
62
|
}
|
|
56
63
|
},
|
|
57
64
|
"globalDependencies": ["disposabl.json"]
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# Desktop
|
|
2
|
-
|
|
3
|
-
Electron Forge with Vite and TypeScript, managed by the repository's Bun workspace.
|
|
4
|
-
Requires Bun 1.4.4 and Node.js 22.13 or newer.
|
|
5
|
-
|
|
6
|
-
Run these commands from the repository root:
|
|
7
|
-
|
|
8
|
-
```sh
|
|
9
|
-
bun install
|
|
10
|
-
bun run --cwd apps/desktop dev
|
|
11
|
-
bun run --cwd apps/desktop typecheck
|
|
12
|
-
bun run --cwd apps/desktop lint
|
|
13
|
-
bun run --cwd apps/desktop build
|
|
14
|
-
bun run --cwd apps/desktop make
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
`dev` opens the app with Vite hot reload. `build` packages the application into
|
|
18
|
-
`apps/desktop/out/`. `make` also creates distributables for the current platform.
|
|
19
|
-
The desktop app participates in the root Turbo tasks, so
|
|
20
|
-
`bun run dev --filter=desktop` also starts it.
|
|
21
|
-
|
|
22
|
-
Use the root `bun.lock`; do not generate a separate npm lockfile or run npm install
|
|
23
|
-
inside this workspace. Forge 8 still probes npm's version during its CLI system
|
|
24
|
-
check, so its output can say `Found npm`. Bun installs the dependencies and runs
|
|
25
|
-
the project scripts; Forge and Electron still use Node.js.
|
|
26
|
-
|
|
27
|
-
## Distribution targets
|
|
28
|
-
|
|
29
|
-
| Platform | Architecture | Distributables | Bun script |
|
|
30
|
-
| -------- | -------------------- | ------------------------------------------ | -------------- |
|
|
31
|
-
| Windows | x64 | Squirrel `Setup.exe`, `.nupkg`, `RELEASES` | `make:windows` |
|
|
32
|
-
| Linux | x64 | `.deb` and `.rpm` | `make:linux` |
|
|
33
|
-
| macOS | arm64, Apple Silicon | `.dmg` containing the `.app` | `make:macos` |
|
|
34
|
-
|
|
35
|
-
Run each script with `bun run --cwd apps/desktop <script>`. Packaging rejects other
|
|
36
|
-
platform and architecture combinations, including Windows ARM and Intel macOS.
|
|
37
|
-
Build Windows installers on Windows, Linux packages on Linux, and macOS packages
|
|
38
|
-
on macOS. Linux builders need `fakeroot`, `dpkg`, and `rpm` installed.
|
|
39
|
-
|
|
40
|
-
## CI releases
|
|
41
|
-
|
|
42
|
-
The single root `.github/workflows/pipeline.yml` selects affected desktop targets from
|
|
43
|
-
`disposabl.json`. Windows x64, Linux x64 and macOS arm64 build in parallel alongside
|
|
44
|
-
web/backend deployment on Blacksmith. Each runner uses:
|
|
45
|
-
|
|
46
|
-
```sh
|
|
47
|
-
DISPOSABL_DESKTOP_PLATFORM=linux DISPOSABL_RELEASE_VERSION=1.0.42 bun run --cwd apps/desktop preview
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Use the matching platform value on Windows or macOS. The helper temporarily sets
|
|
51
|
-
the package version, makes the installers, restores `package.json` even on failure,
|
|
52
|
-
and collects outputs into the repository root `dist/release`. Each platform job
|
|
53
|
-
then uploads directly to its own GitHub prerelease using its job-scoped write
|
|
54
|
-
token, without waiting for other platforms. PR tags such as `app-pr-2-macos` stay
|
|
55
|
-
constant while their assets and source commit update after successful builds.
|
|
56
|
-
Main releases use separate platform/run tags. Forge itself does not publish.
|
|
57
|
-
|
|
58
|
-
Windows and Linux installers are unsigned. macOS builds use ad hoc signing by
|
|
59
|
-
default; Developer ID signing and notarization are optional. In-app updates are not configured. The release version is
|
|
60
|
-
`1.0.<workflow run number>`. See the root `.github/README.md` for release behavior.
|
|
61
|
-
|
|
62
|
-
## macOS signing
|
|
63
|
-
|
|
64
|
-
To enable Developer ID signing and notarization, configure all five repository
|
|
65
|
-
secrets, or grant this repository access to equivalent organization secrets:
|
|
66
|
-
|
|
67
|
-
- `MACOS_CERTIFICATES_P12_PRODUCTION`: base64-encoded Developer ID Application
|
|
68
|
-
certificate and private key exported as `.p12`.
|
|
69
|
-
- `MACOS_CERTIFICATES_PASSWORD_PRODUCTION`: the `.p12` export password.
|
|
70
|
-
- `MACOS_APPLE_API_KEY_P8_PRODUCTION`: the raw App Store Connect API private key.
|
|
71
|
-
- `MACOS_APPLE_API_KEY_ID_PRODUCTION`: its Key ID.
|
|
72
|
-
- `MACOS_APPLE_API_ISSUER_PRODUCTION`: its Issuer ID.
|
|
73
|
-
|
|
74
|
-
With all five secrets present, the same credentials sign and notarize prereleases
|
|
75
|
-
and production releases. The suffix is a naming convention. The workflow imports
|
|
76
|
-
the certificate into a temporary keychain, lets Forge sign, notarize and staple
|
|
77
|
-
the app, and checks the app mounted from the DMG with `codesign`, Gatekeeper and `stapler`.
|
|
78
|
-
The keychain and temporary notarization key are cleaned up. Configured signing or
|
|
79
|
-
notarization failures stop publication; they do not silently downgrade the app.
|
|
80
|
-
|
|
81
|
-
Without the complete credential set, previews and production still publish an ad
|
|
82
|
-
hoc signed DMG. This signature does not verify the developer's identity. The
|
|
83
|
-
release notes identify it as unnotarized and link to Apple's installation guidance.
|
|
84
|
-
Users may need **System Settings > Privacy & Security > Open Anyway**; managed Macs
|
|
85
|
-
may disallow this. Local `make:macos` builds also use ad hoc signing by default.
|
|
86
|
-
|
|
87
|
-
Change `MACOS_BUNDLE_ID` at the top of the workflow to set your desktop bundle
|
|
88
|
-
identifier. CI builds only Apple Silicon (`arm64`), never Intel macOS packages.
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { cp, mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
|
|
6
|
-
const root = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
-
const targets = {
|
|
8
|
-
windows: ['win32', 'x64'],
|
|
9
|
-
linux: ['linux', 'x64'],
|
|
10
|
-
macos: ['darwin', 'arm64'],
|
|
11
|
-
};
|
|
12
|
-
const target = process.env.DISPOSABL_DESKTOP_PLATFORM;
|
|
13
|
-
const version = process.env.DISPOSABL_RELEASE_VERSION;
|
|
14
|
-
if (!Object.hasOwn(targets, target ?? ''))
|
|
15
|
-
throw new Error('Invalid DISPOSABL_DESKTOP_PLATFORM');
|
|
16
|
-
if (!version || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(version))
|
|
17
|
-
throw new Error('DISPOSABL_RELEASE_VERSION must be numeric semver');
|
|
18
|
-
if (
|
|
19
|
-
process.platform !== targets[target][0] ||
|
|
20
|
-
process.arch !== targets[target][1]
|
|
21
|
-
)
|
|
22
|
-
throw new Error(`Build ${target} on ${targets[target].join('/')}`);
|
|
23
|
-
const packagePath = join(root, 'package.json');
|
|
24
|
-
const original = await readFile(packagePath, 'utf8');
|
|
25
|
-
try {
|
|
26
|
-
await rm(join(root, 'out'), { recursive: true, force: true });
|
|
27
|
-
await rm(join(root, '../../dist/release'), { recursive: true, force: true });
|
|
28
|
-
await writeFile(
|
|
29
|
-
packagePath,
|
|
30
|
-
JSON.stringify({ ...JSON.parse(original), version }, null, 2) + '\n',
|
|
31
|
-
);
|
|
32
|
-
const result = spawnSync('bun', ['run', `make:${target}`], {
|
|
33
|
-
cwd: root,
|
|
34
|
-
stdio: 'inherit',
|
|
35
|
-
});
|
|
36
|
-
if (result.status !== 0)
|
|
37
|
-
throw new Error(`Forge failed: ${result.error ?? result.status}`);
|
|
38
|
-
const destination = join(root, '../../dist/release');
|
|
39
|
-
await mkdir(destination, { recursive: true });
|
|
40
|
-
async function collect(dir) {
|
|
41
|
-
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
42
|
-
const path = join(dir, entry.name);
|
|
43
|
-
if (entry.isDirectory()) await collect(path);
|
|
44
|
-
else if (entry.isFile())
|
|
45
|
-
await cp(path, join(destination, entry.name), {
|
|
46
|
-
errorOnExist: true,
|
|
47
|
-
force: false,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
await collect(join(root, 'out', 'make'));
|
|
52
|
-
if (!(await readdir(destination)).length)
|
|
53
|
-
throw new Error('Forge produced no artifacts');
|
|
54
|
-
} finally {
|
|
55
|
-
await writeFile(packagePath, original);
|
|
56
|
-
}
|