create-thexjs-app 0.1.0 → 0.1.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.
- package/README.md +6 -4
- package/dist/index.js +23 -2
- package/package.json +36 -1
- package/templates/default/components.json +19 -0
- package/templates/default/src/layouts/main.tsx +28 -0
- package/templates/default/src/pages/index.tsx +66 -0
- package/templates/default/src/styles/globals.css +55 -0
- package/templates/default/src/x-routes.ts +17 -0
- package/templates/default/tsconfig.json +5 -0
- package/templates/default/x.config.ts +6 -0
- package/templates/landing/src/pages/docs/_layout.tsx +62 -44
- package/templates/landing/src/pages/docs/getting-started.tsx +19 -9
- package/templates/landing/src/pages/docs/index.tsx +86 -22
- package/templates/landing/src/pages/docs/installation.tsx +147 -0
- package/templates/landing/src/pages/docs/introduction.tsx +117 -0
- package/templates/landing/src/pages/docs/packages/cli.tsx +130 -0
- package/templates/landing/src/pages/docs/packages/core.tsx +172 -0
- package/templates/landing/src/pages/docs/packages/env.tsx +128 -0
- package/templates/landing/src/pages/index.tsx +51 -32
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { RouteProps } from "@thexjs/core";
|
|
2
|
+
import { ArrowRight } from "lucide-react";
|
|
3
|
+
import { CodeBlock } from "../../../components/code-block";
|
|
4
|
+
|
|
5
|
+
export const mode = "static";
|
|
6
|
+
|
|
7
|
+
export default function DocPage({}: RouteProps) {
|
|
8
|
+
return (
|
|
9
|
+
<div>
|
|
10
|
+
<p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Packages</p>
|
|
11
|
+
<h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">@thexjs/env</h1>
|
|
12
|
+
<p className="mt-4 text-lg text-muted-foreground">
|
|
13
|
+
Type-safe environment variable validation for x apps. Define a schema once, get parsed and
|
|
14
|
+
typed values back, and fail fast with a clear error if something is missing or malformed.
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<CodeBlock label="terminal" lang="bash" code="bun add @thexjs/env" />
|
|
18
|
+
|
|
19
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">Quick start</h2>
|
|
20
|
+
<CodeBlock
|
|
21
|
+
label="env.ts"
|
|
22
|
+
code={`import { createEnv, str, num, bool, oneOf, url } from "@thexjs/env";
|
|
23
|
+
|
|
24
|
+
export const env = createEnv({
|
|
25
|
+
server: {
|
|
26
|
+
DATABASE_URL: url(),
|
|
27
|
+
PORT: num(),
|
|
28
|
+
NODE_ENV: oneOf(["development", "production", "test"]),
|
|
29
|
+
},
|
|
30
|
+
client: {
|
|
31
|
+
NEXT_PUBLIC_API_URL: url(),
|
|
32
|
+
},
|
|
33
|
+
clientPrefix: "NEXT_PUBLIC_",
|
|
34
|
+
runtimeEnv: process.env,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
env.DATABASE_URL; // string, validated as a URL
|
|
38
|
+
env.PORT; // number
|
|
39
|
+
env.NODE_ENV; // "development" | "production" | "test"`}
|
|
40
|
+
/>
|
|
41
|
+
<p className="mt-4 text-muted-foreground">
|
|
42
|
+
If any variable is missing or fails validation,{" "}
|
|
43
|
+
<span className="text-foreground">createEnv</span> throws a single error listing every
|
|
44
|
+
failure:
|
|
45
|
+
</p>
|
|
46
|
+
<CodeBlock
|
|
47
|
+
label="validation error"
|
|
48
|
+
code={`Environment validation failed:
|
|
49
|
+
server.DATABASE_URL: Expected a valid URL, got "not-a-url"
|
|
50
|
+
server.PORT: Expected a number, got undefined`}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">Validators</h2>
|
|
54
|
+
<CodeBlock
|
|
55
|
+
label="built-in validators"
|
|
56
|
+
code={`Validator Accepts Notes
|
|
57
|
+
──────────────────────────────────────────────────────────────────────
|
|
58
|
+
str() any non-undefined string
|
|
59
|
+
num() numeric strings rejects NaN
|
|
60
|
+
bool() "true"/"1" → true, "false"/"0" → false
|
|
61
|
+
oneOf([...values]) one of the given string literals narrows return type
|
|
62
|
+
url() string parseable by new URL(...)`}
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">Custom validators</h2>
|
|
66
|
+
<p className="mt-3 text-muted-foreground">
|
|
67
|
+
Each validator is{" "}
|
|
68
|
+
<span className="text-foreground">{"{ parse(input: string | undefined): T }"}</span> — write
|
|
69
|
+
your own for anything not covered:
|
|
70
|
+
</p>
|
|
71
|
+
<CodeBlock
|
|
72
|
+
label="custom validator"
|
|
73
|
+
code={`import type { EnvValidator } from "@thexjs/env";
|
|
74
|
+
|
|
75
|
+
function json<T>(): EnvValidator<T> {
|
|
76
|
+
return {
|
|
77
|
+
parse(input) {
|
|
78
|
+
if (input === undefined) throw new Error("Expected JSON, got undefined");
|
|
79
|
+
return JSON.parse(input) as T;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}`}
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">client / clientPrefix</h2>
|
|
86
|
+
<p className="mt-3 text-muted-foreground">
|
|
87
|
+
The <span className="text-foreground">client</span> schema is for variables safe to expose to
|
|
88
|
+
the browser. <span className="text-foreground">clientPrefix</span> enforces that every
|
|
89
|
+
client key starts with that prefix (e.g.{" "}
|
|
90
|
+
<span className="text-foreground">NEXT_PUBLIC_</span>,{" "}
|
|
91
|
+
<span className="text-foreground">PUBLIC_</span>) — a key that does not match fails
|
|
92
|
+
validation, so you cannot accidentally leak a server-only variable through the client
|
|
93
|
+
schema.
|
|
94
|
+
</p>
|
|
95
|
+
|
|
96
|
+
<h2 className="mt-12 text-xl font-bold tracking-tight">Notes</h2>
|
|
97
|
+
<ul className="mt-3 list-inside list-disc space-y-2 text-muted-foreground">
|
|
98
|
+
<li>
|
|
99
|
+
Every field is currently required — no built-in{" "}
|
|
100
|
+
<span className="text-foreground">optional()</span> or{" "}
|
|
101
|
+
<span className="text-foreground">default()</span>. For optional vars, read from{" "}
|
|
102
|
+
<span className="text-foreground">process.env</span> directly or write a validator with a
|
|
103
|
+
fallback.
|
|
104
|
+
</li>
|
|
105
|
+
<li>
|
|
106
|
+
<span className="text-foreground">runtimeEnv</span> is passed explicitly so this works on
|
|
107
|
+
Bun, in bundlers that inline <span className="text-foreground">process.env.*</span> at
|
|
108
|
+
build time, or in tests with a mocked env object.
|
|
109
|
+
</li>
|
|
110
|
+
</ul>
|
|
111
|
+
|
|
112
|
+
<div className="mt-16 flex flex-wrap gap-6 border-t border-border pt-8">
|
|
113
|
+
<a
|
|
114
|
+
href="/docs/packages/core"
|
|
115
|
+
className="inline-flex items-center gap-1 text-sm font-medium text-primary transition-colors hover:text-primary/80"
|
|
116
|
+
>
|
|
117
|
+
@thexjs/core <ArrowRight className="h-3.5 w-3.5" />
|
|
118
|
+
</a>
|
|
119
|
+
<a
|
|
120
|
+
href="/docs"
|
|
121
|
+
className="inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
122
|
+
>
|
|
123
|
+
<ArrowRight className="h-3.5 w-3.5 rotate-180" /> Back to docs
|
|
124
|
+
</a>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -34,37 +34,51 @@ const features = [
|
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
36
|
|
|
37
|
+
export const mode = "static";
|
|
38
|
+
|
|
37
39
|
export default function HomePage() {
|
|
38
40
|
return (
|
|
39
41
|
<div className="pb-32">
|
|
40
42
|
{/* ── Hero ── */}
|
|
41
|
-
<section className="relative flex min-h-[
|
|
42
|
-
<div
|
|
43
|
-
|
|
43
|
+
<section className="relative flex min-h-[92vh] flex-col items-center justify-center overflow-hidden px-6">
|
|
44
|
+
<div
|
|
45
|
+
className="pointer-events-none absolute inset-0 opacity-[0.22]"
|
|
46
|
+
style={{
|
|
47
|
+
backgroundImage:
|
|
48
|
+
"linear-gradient(to right, oklch(0.22 0.015 265) 1px, transparent 1px), linear-gradient(to bottom, oklch(0.22 0.015 265) 1px, transparent 1px)",
|
|
49
|
+
backgroundSize: "56px 56px",
|
|
50
|
+
maskImage: "radial-gradient(ellipse 75% 65% at 50% 35%, black 15%, transparent 100%)",
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
<div className="pointer-events-none absolute inset-0 flex items-start justify-center pt-12">
|
|
54
|
+
<div className="h-[480px] w-[480px] animate-pulse-glow rounded-full bg-primary/15 sm:h-[640px] sm:w-[640px]" />
|
|
44
55
|
</div>
|
|
45
56
|
<div className="relative z-10 flex flex-col items-center text-center">
|
|
46
|
-
<
|
|
47
|
-
|
|
57
|
+
<p className="font-mono text-[11px] uppercase tracking-[0.32em] text-primary/90">
|
|
58
|
+
Fullstack · Bun · React
|
|
59
|
+
</p>
|
|
60
|
+
<h1 className="mt-6 max-w-4xl text-5xl font-bold tracking-tight leading-[1.05] sm:text-7xl">
|
|
61
|
+
One runtime.
|
|
48
62
|
<br />
|
|
49
|
-
<span className="text-primary">
|
|
63
|
+
<span className="text-primary">Every layer.</span>
|
|
50
64
|
</h1>
|
|
51
|
-
<p className="mt-6 max-w-xl text-lg text-muted-foreground sm:text-xl">
|
|
52
|
-
|
|
53
|
-
in
|
|
65
|
+
<p className="mt-6 max-w-xl text-lg leading-relaxed text-muted-foreground sm:text-xl">
|
|
66
|
+
x is a fullstack framework for Bun — file-based routing, SSR, static export, API routes,
|
|
67
|
+
and server functions in a single process.
|
|
54
68
|
</p>
|
|
55
69
|
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
|
|
56
70
|
<a
|
|
57
|
-
href="/docs/
|
|
71
|
+
href="/docs/installation"
|
|
58
72
|
className="group inline-flex h-12 items-center gap-2 rounded-xl bg-primary px-6 text-sm font-semibold text-primary-foreground shadow-xl shadow-primary/30 transition-all hover:bg-primary/90 hover:shadow-primary/40 active:scale-[0.97]"
|
|
59
73
|
>
|
|
60
|
-
|
|
74
|
+
Install x{" "}
|
|
61
75
|
<ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-0.5" />
|
|
62
76
|
</a>
|
|
63
77
|
<a
|
|
64
|
-
href="/docs"
|
|
78
|
+
href="/docs/introduction"
|
|
65
79
|
className="group inline-flex h-12 items-center gap-2 rounded-xl border border-border bg-card/50 px-6 text-sm font-medium text-foreground backdrop-blur-sm transition-all hover:bg-muted active:scale-[0.97]"
|
|
66
80
|
>
|
|
67
|
-
<BookOpen className="h-4 w-4" />
|
|
81
|
+
<BookOpen className="h-4 w-4" /> Introduction
|
|
68
82
|
</a>
|
|
69
83
|
</div>
|
|
70
84
|
</div>
|
|
@@ -103,39 +117,44 @@ export default function HomePage() {
|
|
|
103
117
|
Quick start
|
|
104
118
|
</p>
|
|
105
119
|
<h2 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">
|
|
106
|
-
|
|
120
|
+
Scaffold in one command
|
|
107
121
|
</h2>
|
|
108
122
|
<p className="mt-4 text-muted-foreground">
|
|
109
|
-
Create a project
|
|
123
|
+
Create a project with the default template — a single home page, ready to edit.
|
|
110
124
|
</p>
|
|
111
125
|
</div>
|
|
112
126
|
<CodeBlock
|
|
113
127
|
label="~/project — bash"
|
|
114
128
|
lang="bash"
|
|
115
|
-
code={
|
|
116
|
-
bun create x@latest
|
|
117
|
-
Creating a new x project...
|
|
118
|
-
Done!
|
|
129
|
+
code={`$ bun create thexjs-app@latest my-app
|
|
119
130
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
Available templates:
|
|
132
|
+
|
|
133
|
+
default Blank slate with a single home page. (recommended)
|
|
134
|
+
basic Pages, API route, auth, and dashboard.
|
|
135
|
+
blog Markdown content collections.
|
|
136
|
+
saas Dashboard, pricing, and data layer.
|
|
137
|
+
landing Marketing site with docs pages.
|
|
138
|
+
|
|
139
|
+
Choose a template (default): █
|
|
140
|
+
|
|
141
|
+
$ cd my-app && bun run dev
|
|
129
142
|
dev server running at http://localhost:3000`}
|
|
130
143
|
/>
|
|
131
|
-
<div className="mt-8
|
|
144
|
+
<div className="mt-8 flex flex-wrap items-center justify-center gap-4">
|
|
132
145
|
<a
|
|
133
|
-
href="/docs/
|
|
146
|
+
href="/docs/installation"
|
|
134
147
|
className="group inline-flex h-11 items-center gap-2 rounded-xl bg-primary px-6 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90 active:scale-[0.97]"
|
|
135
148
|
>
|
|
136
|
-
|
|
149
|
+
Installation guide{" "}
|
|
137
150
|
<ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-0.5" />
|
|
138
151
|
</a>
|
|
152
|
+
<a
|
|
153
|
+
href="/docs/packages/core"
|
|
154
|
+
className="inline-flex h-11 items-center rounded-xl border border-border px-6 text-sm font-medium text-foreground transition-colors hover:bg-muted"
|
|
155
|
+
>
|
|
156
|
+
Package docs
|
|
157
|
+
</a>
|
|
139
158
|
</div>
|
|
140
159
|
</section>
|
|
141
160
|
|
|
@@ -156,7 +175,7 @@ x dev
|
|
|
156
175
|
<BookOpen className="h-4 w-4" /> Read the docs
|
|
157
176
|
</a>
|
|
158
177
|
<a
|
|
159
|
-
href="https://github.com/
|
|
178
|
+
href="https://github.com/abdelkabirouadoukou/x"
|
|
160
179
|
target="_blank"
|
|
161
180
|
rel="noopener noreferrer"
|
|
162
181
|
className="group inline-flex h-12 items-center gap-2 rounded-xl border border-border bg-card/50 px-6 text-sm font-medium text-foreground backdrop-blur-sm transition-all hover:bg-muted active:scale-[0.97]"
|