@rshono/create 1.0.0-rc.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 +105 -0
- package/bin/create-rshono.mjs +29 -0
- package/dist/api.mjs +749 -0
- package/dist/cli.mjs +3930 -0
- package/package.json +59 -0
- package/templates/base/README.md +42 -0
- package/templates/base/_env +9 -0
- package/templates/base/_gitignore +8 -0
- package/templates/base/public/favicon.svg +1 -0
- package/templates/base/public/robots.txt +2 -0
- package/templates/base/rshono.config.ts +35 -0
- package/templates/base/src/actions.ts +19 -0
- package/templates/base/src/components/404.tsx +17 -0
- package/templates/base/src/components/500.tsx +21 -0
- package/templates/base/src/components/greet-form.tsx +27 -0
- package/templates/base/src/components/home.tsx +50 -0
- package/templates/base/src/components/layout.tsx +45 -0
- package/templates/base/src/env.d.ts +2 -0
- package/templates/base/src/lib/env.ts +26 -0
- package/templates/base/src/routes.ts +32 -0
- package/templates/base/src/server.ts +59 -0
- package/templates/base/src/styles.css +178 -0
- package/templates/base/tsconfig.json +20 -0
- package/templates/biome/biome.json +7 -0
- package/templates/biome-tailwind/biome.json +7 -0
- package/templates/oxfmt/_oxfmtrc.json +7 -0
- package/templates/oxlint/_oxlintrc.json +7 -0
- package/templates/prettier/_prettierignore +10 -0
- package/templates/prettier/_prettierrc.json +7 -0
- package/templates/tailwind/postcss.config.mjs +9 -0
- package/templates/tailwind/rshono.config.ts +45 -0
- package/templates/tailwind/src/components/home.tsx +50 -0
- package/templates/tailwind/src/components/layout.tsx +45 -0
- package/templates/tailwind/src/styles.css +40 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.5.6/schema.json",
|
|
3
|
+
"files": { "includes": ["**", "!dist", "!wrangler.jsonc"] },
|
|
4
|
+
"formatter": { "indentStyle": "space", "indentWidth": 2, "lineWidth": 140 },
|
|
5
|
+
"javascript": { "formatter": { "quoteStyle": "single", "jsxQuoteStyle": "double" } },
|
|
6
|
+
"linter": { "enabled": true, "rules": { "preset": "recommended" } }
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.5.6/schema.json",
|
|
3
|
+
"files": { "includes": ["**", "!dist", "!wrangler.jsonc", "!**/*.css"] },
|
|
4
|
+
"formatter": { "indentStyle": "space", "indentWidth": 2, "lineWidth": 140 },
|
|
5
|
+
"javascript": { "formatter": { "quoteStyle": "single", "jsxQuoteStyle": "double" } },
|
|
6
|
+
"linter": { "enabled": true, "rules": { "preset": "recommended" } }
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
dist/
|
|
3
|
+
pnpm-lock.yaml
|
|
4
|
+
package-lock.json
|
|
5
|
+
yarn.lock
|
|
6
|
+
bun.lock
|
|
7
|
+
|
|
8
|
+
# Written by `rshono build` for the Cloudflare target, in the shape the build decided. Yours to edit —
|
|
9
|
+
# just not the formatter's to reflow on every build.
|
|
10
|
+
wrangler.jsonc
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineConfig } from '@rshono/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Every field is optional — delete this file to accept all the defaults. The commented lines are the
|
|
5
|
+
* defaults, kept as documentation of what is there to change.
|
|
6
|
+
*
|
|
7
|
+
* The framework settings are compiled into the server bundle at build time, so changing one means a
|
|
8
|
+
* rebuild; there is no env-var interface for them. `--port`/`PORT` and `HOST` are the two exceptions,
|
|
9
|
+
* and they win over what is written here.
|
|
10
|
+
*/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
/** Where `build` targets. Overridable per build with `--deploy` or `RSHONO_DEPLOY`. */
|
|
13
|
+
deploy: '__DEPLOY_TARGET__',
|
|
14
|
+
|
|
15
|
+
// The public origin, baked into prerendered pages' absolute URLs. Set it if you use `render: 'static'`
|
|
16
|
+
// and build canonical tags, `og:url` or absolute links — there is no request to read a Host from.
|
|
17
|
+
// siteUrl: 'https://example.com',
|
|
18
|
+
|
|
19
|
+
// port: 3000, // default for dev/start
|
|
20
|
+
// host: '0.0.0.0', // bind address for start
|
|
21
|
+
|
|
22
|
+
// trustProxy: false, // honour X-Forwarded-Host/-Proto — only behind a proxy you control
|
|
23
|
+
// checkOrigin: true, // CSRF origin check on server-action POSTs
|
|
24
|
+
// allowedOrigins: [], // extra origins allowed to post actions
|
|
25
|
+
// csp: false, // strict per-request-nonce Content-Security-Policy
|
|
26
|
+
// cspDirectives: {}, // widen it, e.g. { 'img-src': "'self' https://cdn.example.com" }
|
|
27
|
+
// bodySizeLimit: '1mb',// request body cap before a 413; false disables it
|
|
28
|
+
// renderTimeout: 10_000, // ms deadline for a request (action + flight + SSR)
|
|
29
|
+
// compress: true, // gzip; turn off behind a proxy that already does it
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Tailwind, and the only thing the build needs to know about it.
|
|
33
|
+
*
|
|
34
|
+
* Rspack compiles CSS natively, which is fast and is all a plain stylesheet needs — but that parser
|
|
35
|
+
* reads *finished* CSS, and `@import 'tailwindcss'`, `@theme` and `@apply` are not that. Tailwind is a
|
|
36
|
+
* PostCSS plugin, so it has to run in front of the parser, which is what this rule does. The plugin
|
|
37
|
+
* list itself is in `postcss.config.mjs`, where postcss-loader looks for it.
|
|
38
|
+
*
|
|
39
|
+
* The hook is called once per compiler, so the rule reaches the client and the server graph both.
|
|
40
|
+
* Delete all of this, and the four Tailwind packages, to go back to plain CSS.
|
|
41
|
+
*/
|
|
42
|
+
rspack(config) {
|
|
43
|
+
config.module!.rules!.push({ test: /\.css$/i, use: ['postcss-loader'], type: 'css/auto' });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PageProps } from '@rshono/core';
|
|
2
|
+
import { publicEnv } from '../lib/env';
|
|
3
|
+
import type { AppEnv } from '../server';
|
|
4
|
+
import { GreetForm } from './greet-form';
|
|
5
|
+
import { Layout } from './layout';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A page is a React **server component**: it runs on the server only, may be `async`, and can await data
|
|
9
|
+
* directly — no loaders, no client bundle for any of this.
|
|
10
|
+
*
|
|
11
|
+
* The `AppEnv` type argument is what types `ctx.var` key by key; without it `ctx.var` is an open record.
|
|
12
|
+
*/
|
|
13
|
+
export default function Home({ url, ctx }: PageProps<'/', AppEnv>) {
|
|
14
|
+
return (
|
|
15
|
+
<Layout description="A new rshono app.">
|
|
16
|
+
<h1 className="mb-2 text-4xl font-semibold tracking-tight">{publicEnv.appName}</h1>
|
|
17
|
+
<p className="mb-4">
|
|
18
|
+
Edit <code>src/components/home.tsx</code> and save. The page re-renders in place — the form below keeps whatever you have typed in it.
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<h2 className="mt-10 mb-2 text-lg font-semibold">Server actions</h2>
|
|
22
|
+
<p className="mb-4">
|
|
23
|
+
This form calls a <code>'use server'</code> function in <code>src/actions.ts</code>. It works before hydration and with JavaScript disabled.
|
|
24
|
+
</p>
|
|
25
|
+
<GreetForm />
|
|
26
|
+
|
|
27
|
+
<h2 className="mt-10 mb-2 text-lg font-semibold">Where things are</h2>
|
|
28
|
+
<ul className="mb-4 list-disc space-y-1 pl-5">
|
|
29
|
+
<li>
|
|
30
|
+
<code>src/routes.ts</code> — the route table, the one file rshono requires
|
|
31
|
+
</li>
|
|
32
|
+
<li>
|
|
33
|
+
<code>src/server.ts</code> — a Hono app for middleware and API routes, mounted ahead of the pages
|
|
34
|
+
</li>
|
|
35
|
+
<li>
|
|
36
|
+
<code>src/components/</code> — pages and components; <code>src/lib/</code> — everything else
|
|
37
|
+
</li>
|
|
38
|
+
<li>
|
|
39
|
+
<code>rshono.config.ts</code> — deploy target, security and build settings
|
|
40
|
+
</li>
|
|
41
|
+
</ul>
|
|
42
|
+
|
|
43
|
+
<p className="text-sm text-zinc-500 dark:text-zinc-400">
|
|
44
|
+
{/* `ctx` is the request context — cookies, headers, env, middleware variables — handed to the page as a
|
|
45
|
+
prop, so reading it needs no import. It is server-only and never crosses into a client component. */}
|
|
46
|
+
Rendered on the server for <code>{url.pathname}</code>, request <code>{ctx.var.requestId}</code>.
|
|
47
|
+
</p>
|
|
48
|
+
</Layout>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NavigationProgress } from '@rshono/core/client';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { publicEnv } from '../lib/env';
|
|
4
|
+
import '../styles.css';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A page renders the whole document, so the shell lives in one component every page wraps its content
|
|
8
|
+
* in. Importing the stylesheet here is what attaches it to each of those pages.
|
|
9
|
+
*/
|
|
10
|
+
export function Layout({ title, description, children }: { title?: string; description?: string; children: ReactNode }) {
|
|
11
|
+
const heading = title ? `${title} · ${publicEnv.appName}` : publicEnv.appName;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<head>
|
|
16
|
+
<meta charSet="utf-8" />
|
|
17
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
18
|
+
<title>{heading}</title>
|
|
19
|
+
{description && <meta name="description" content={description} />}
|
|
20
|
+
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
|
21
|
+
</head>
|
|
22
|
+
<body className="bg-zinc-50 text-zinc-900 antialiased dark:bg-zinc-950 dark:text-zinc-100">
|
|
23
|
+
{/* Paints during a soft navigation, so a slow page still feels answered. */}
|
|
24
|
+
<NavigationProgress />
|
|
25
|
+
<header className="mx-auto max-w-2xl px-6 py-5">
|
|
26
|
+
<nav className="flex items-center justify-between gap-4">
|
|
27
|
+
<a href="/" className="font-semibold no-underline">
|
|
28
|
+
{publicEnv.appName}
|
|
29
|
+
</a>
|
|
30
|
+
{/* `data-prefetch` warms a page on hover; `data-native` opts a link out of soft navigation. */}
|
|
31
|
+
<a href="/api/health" data-native className="text-sm">
|
|
32
|
+
/api/health
|
|
33
|
+
</a>
|
|
34
|
+
</nav>
|
|
35
|
+
</header>
|
|
36
|
+
<main className="mx-auto max-w-2xl px-6 pt-4 pb-16">{children}</main>
|
|
37
|
+
<footer className="mx-auto max-w-2xl border-t border-zinc-200 px-6 py-8 text-sm text-zinc-500 dark:border-zinc-800 dark:text-zinc-400">
|
|
38
|
+
<p>
|
|
39
|
+
Built with <a href="https://github.com/rshono/rshono">rshono</a> — Hono + Rspack + React Server Components.
|
|
40
|
+
</p>
|
|
41
|
+
</footer>
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Element defaults for the parts of the app whose markup carries no classes — the form in
|
|
5
|
+
* `components/greet-form.tsx`, and code and links wherever they appear. Everything else is styled with
|
|
6
|
+
* utilities in the markup; see `components/layout.tsx` and `components/home.tsx`.
|
|
7
|
+
*/
|
|
8
|
+
@layer base {
|
|
9
|
+
a {
|
|
10
|
+
@apply text-blue-600 underline decoration-1 underline-offset-2 dark:text-blue-400;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
code {
|
|
14
|
+
@apply rounded border border-zinc-200 bg-white px-1.5 py-0.5 font-mono text-[0.875em] dark:border-zinc-800 dark:bg-zinc-900;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
pre {
|
|
18
|
+
@apply overflow-x-auto rounded-lg border border-zinc-200 bg-white p-4 font-mono text-xs dark:border-zinc-800 dark:bg-zinc-900;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
form {
|
|
22
|
+
@apply flex flex-wrap items-center gap-2 rounded-lg border border-zinc-200 bg-white p-4 dark:border-zinc-800 dark:bg-zinc-900;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
label {
|
|
26
|
+
@apply basis-full text-sm text-zinc-500 dark:text-zinc-400;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
input {
|
|
30
|
+
@apply flex-1 basis-48 rounded-md border border-zinc-200 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-950;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
button {
|
|
34
|
+
@apply cursor-pointer rounded-md bg-blue-600 px-4 py-2 font-medium text-white disabled:cursor-progress disabled:opacity-60;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
output {
|
|
38
|
+
@apply basis-full text-zinc-500 dark:text-zinc-400;
|
|
39
|
+
}
|
|
40
|
+
}
|