prunelle 0.0.0-stage → 0.7.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/LICENSE +21 -0
- package/llms.txt +245 -0
- package/package.json +62 -4
- package/src/a11y/declaration.ts +373 -0
- package/src/a11y/index.ts +477 -0
- package/src/a11y/rgaa-map.ts +230 -0
- package/src/ambient.d.ts +6 -0
- package/src/attrs.ts +43 -0
- package/src/build/bundle.ts +661 -0
- package/src/build/byte-size.ts +11 -0
- package/src/build/carry.ts +57 -0
- package/src/build/client-entries.ts +107 -0
- package/src/build/client-plugin.ts +175 -0
- package/src/build/client-prune.ts +168 -0
- package/src/build/compile.ts +130 -0
- package/src/build/ecoindex.ts +238 -0
- package/src/build/files.ts +171 -0
- package/src/build/first-load.ts +235 -0
- package/src/build/graph.ts +237 -0
- package/src/build/index.ts +678 -0
- package/src/build/is-inside.ts +12 -0
- package/src/build/island-promote.ts +311 -0
- package/src/build/islands.ts +452 -0
- package/src/build/manifest.ts +204 -0
- package/src/build/output.ts +81 -0
- package/src/build/plugin-host.ts +294 -0
- package/src/build/precompress.ts +139 -0
- package/src/build/prerender.ts +288 -0
- package/src/build/reach.ts +200 -0
- package/src/build/render-rules.ts +205 -0
- package/src/build/report.ts +290 -0
- package/src/build/resolve.ts +52 -0
- package/src/build/routes.ts +342 -0
- package/src/build/server-entry.ts +38 -0
- package/src/build/static-headers.ts +112 -0
- package/src/build/static.ts +209 -0
- package/src/build/status-pages.ts +127 -0
- package/src/build/style-bundles.ts +526 -0
- package/src/cli/check-forms.ts +636 -0
- package/src/cli/check-imports.ts +31 -0
- package/src/cli/check-links.ts +632 -0
- package/src/cli/check-security.ts +64 -0
- package/src/cli/check.ts +409 -0
- package/src/cli/commands.ts +372 -0
- package/src/cli/docs.ts +403 -0
- package/src/cli/index.ts +70 -0
- package/src/cli/inspect.ts +406 -0
- package/src/cli/mcp-tools.ts +492 -0
- package/src/cli/mcp.ts +205 -0
- package/src/cli/new.ts +52 -0
- package/src/cli/render.ts +416 -0
- package/src/cli/upgrade-names.ts +209 -0
- package/src/cli/upgrade.ts +367 -0
- package/src/compiler/analyze.ts +651 -0
- package/src/compiler/ast.ts +82 -0
- package/src/compiler/browser-globals.ts +250 -0
- package/src/compiler/cacheability-private.ts +566 -0
- package/src/compiler/cacheability.ts +335 -0
- package/src/compiler/compliance-eco.ts +71 -0
- package/src/compiler/compliance-rgaa.ts +614 -0
- package/src/compiler/compliance-urls.ts +148 -0
- package/src/compiler/compliance.ts +653 -0
- package/src/compiler/data-keys.ts +302 -0
- package/src/compiler/dev-source.ts +87 -0
- package/src/compiler/dom-attrs.ts +452 -0
- package/src/compiler/dom.ts +641 -0
- package/src/compiler/emit.ts +131 -0
- package/src/compiler/expr-context.ts +587 -0
- package/src/compiler/foreign-imports.ts +88 -0
- package/src/compiler/index.ts +8 -0
- package/src/compiler/interactivity.ts +366 -0
- package/src/compiler/mistakes.ts +520 -0
- package/src/compiler/node-env.ts +50 -0
- package/src/compiler/patch.ts +97 -0
- package/src/compiler/props-body.ts +60 -0
- package/src/compiler/props.ts +511 -0
- package/src/compiler/scope.ts +635 -0
- package/src/compiler/server-only.ts +365 -0
- package/src/compiler/shared.ts +397 -0
- package/src/compiler/signal-reads.ts +246 -0
- package/src/compiler/slots.ts +227 -0
- package/src/compiler/spread-handlers.ts +295 -0
- package/src/compiler/ssr-helpers.ts +555 -0
- package/src/compiler/ssr-island.ts +90 -0
- package/src/compiler/ssr-prunelle-tags.ts +69 -0
- package/src/compiler/ssr.ts +525 -0
- package/src/context.ts +199 -0
- package/src/dev/child.ts +30 -0
- package/src/dev/error-log.ts +177 -0
- package/src/dev/host-check.ts +32 -0
- package/src/dev/index.ts +268 -0
- package/src/dev/modules.ts +68 -0
- package/src/dev/open-editor.ts +228 -0
- package/src/dev/protocol.ts +24 -0
- package/src/dev/queue.ts +79 -0
- package/src/dev/reload.ts +159 -0
- package/src/dev/supervisor.ts +212 -0
- package/src/dev/watchers.ts +276 -0
- package/src/dom/action.ts +187 -0
- package/src/dom/attrs.ts +84 -0
- package/src/dom/claim.ts +120 -0
- package/src/dom/extras.ts +579 -0
- package/src/dom/index.ts +329 -0
- package/src/dom/island.ts +318 -0
- package/src/dom/loop.ts +484 -0
- package/src/dom/revive.ts +36 -0
- package/src/eco/declaration.ts +328 -0
- package/src/eco/index.ts +69 -0
- package/src/index.ts +22 -0
- package/src/jsx-runtime.ts +566 -0
- package/src/plugins/config.ts +92 -0
- package/src/plugins/context.ts +109 -0
- package/src/plugins/index.ts +14 -0
- package/src/plugins/load.ts +90 -0
- package/src/plugins/order.ts +148 -0
- package/src/plugins/public.ts +15 -0
- package/src/plugins/requires.ts +47 -0
- package/src/plugins/services.ts +119 -0
- package/src/plugins/types.ts +278 -0
- package/src/reactivity/graph.ts +259 -0
- package/src/reactivity/index.ts +541 -0
- package/src/reactivity/selector.ts +78 -0
- package/src/reactivity/store.ts +252 -0
- package/src/server/action-flash.ts +158 -0
- package/src/server/action-protect.ts +199 -0
- package/src/server/action-registry.ts +78 -0
- package/src/server/action.ts +511 -0
- package/src/server/app-entry.ts +23 -0
- package/src/server/app-secret.ts +63 -0
- package/src/server/assets.ts +168 -0
- package/src/server/compress.ts +646 -0
- package/src/server/consent.ts +290 -0
- package/src/server/cookies.ts +153 -0
- package/src/server/document.ts +286 -0
- package/src/server/env.ts +47 -0
- package/src/server/errors.ts +396 -0
- package/src/server/form-schema.ts +337 -0
- package/src/server/health.ts +275 -0
- package/src/server/http.ts +588 -0
- package/src/server/index.ts +615 -0
- package/src/server/lifecycle.ts +75 -0
- package/src/server/loader.ts +131 -0
- package/src/server/page.ts +122 -0
- package/src/server/param-matchers.ts +112 -0
- package/src/server/plugin-host.ts +267 -0
- package/src/server/prerendered.ts +71 -0
- package/src/server/public.ts +20 -0
- package/src/server/rate-limit.ts +199 -0
- package/src/server/region.ts +96 -0
- package/src/server/request-body.ts +27 -0
- package/src/server/request-path.ts +73 -0
- package/src/server/request-scope.ts +22 -0
- package/src/server/route-cache.ts +541 -0
- package/src/server/route-table.ts +424 -0
- package/src/server/router.ts +261 -0
- package/src/server/routing.ts +388 -0
- package/src/server/sanitize-html.ts +309 -0
- package/src/server/security.ts +550 -0
- package/src/server/serve-handlers.ts +93 -0
- package/src/server/served-file.ts +128 -0
- package/src/server/standard-schema.ts +104 -0
- package/src/server/start.ts +143 -0
- package/src/server/static-dir.ts +246 -0
- package/src/server/stream.ts +233 -0
- package/src/ssr/consent-banner.ts +58 -0
- package/src/ssr/context.ts +399 -0
- package/src/ssr/index.ts +624 -0
- package/src/ssr/navigation.ts +96 -0
- package/src/ssr/region.ts +192 -0
- package/src/style.ts +96 -0
- package/src/test/browser.ts +201 -0
- package/src/test/index.ts +262 -0
- package/src/ts-plugin/diagnostics.ts +505 -0
- package/src/ts-plugin/fixes.ts +364 -0
- package/src/ts-plugin/index.ts +194 -0
- package/src/unrenderable.ts +35 -0
- package/templates/_shared/AGENTS.md +10 -0
- package/templates/_shared/CLAUDE.md +1 -0
- package/templates/_shared/gitignore +8 -0
- package/templates/_shared/mcp.json +11 -0
- package/templates/_shared/public/robots.txt +2 -0
- package/templates/_shared/src/routes/legal.tsx +22 -0
- package/templates/_shared/tsconfig.json +25 -0
- package/templates/app/.env.example +8 -0
- package/templates/app/package.json +22 -0
- package/templates/app/prunelle.config.ts +13 -0
- package/templates/app/src/auth.ts +12 -0
- package/templates/app/src/mail.ts +4 -0
- package/templates/app/src/routes/_layout.tsx +40 -0
- package/templates/app/src/routes/dashboard/_middleware.ts +3 -0
- package/templates/app/src/routes/dashboard/index.tsx +47 -0
- package/templates/app/src/routes/index.tsx +15 -0
- package/templates/app/src/routes/login.tsx +53 -0
- package/templates/app/src/routes/privacy.tsx +25 -0
- package/templates/app/src/styles/app.css +14 -0
- package/templates/app/tests/app.test.ts +73 -0
- package/templates/blog/content/posts/welcome.md +9 -0
- package/templates/blog/package.json +22 -0
- package/templates/blog/prunelle.config.ts +23 -0
- package/templates/blog/src/posts.ts +26 -0
- package/templates/blog/src/routes/_layout.tsx +25 -0
- package/templates/blog/src/routes/blog/[slug].tsx +31 -0
- package/templates/blog/src/routes/index.tsx +33 -0
- package/templates/blog/src/styles/app.css +15 -0
- package/templates/fullstack/package.json +19 -0
- package/templates/fullstack/prunelle.config.ts +6 -0
- package/templates/fullstack/src/actions/greet.ts +19 -0
- package/templates/fullstack/src/components/Counter.tsx +10 -0
- package/templates/fullstack/src/components/GreetForm.tsx +28 -0
- package/templates/fullstack/src/routes/_layout.tsx +18 -0
- package/templates/fullstack/src/routes/api/health.ts +5 -0
- package/templates/fullstack/src/routes/index.tsx +13 -0
- package/templates/fullstack/src/styles/app.css +39 -0
- package/templates/fullstack/tests/app.test.ts +37 -0
- package/templates/minimal/package.json +19 -0
- package/templates/minimal/prunelle.config.ts +6 -0
- package/templates/minimal/src/components/Counter.tsx +10 -0
- package/templates/minimal/src/routes/_layout.tsx +18 -0
- package/templates/minimal/src/routes/index.tsx +11 -0
- package/templates/minimal/src/styles/app.css +32 -0
- package/ts-plugin.cjs +4277 -0
- package/README.md +0 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Generate a 32+ byte secret for production, e.g.:
|
|
2
|
+
# openssl rand -base64 32
|
|
3
|
+
AUTH_SECRET=
|
|
4
|
+
AUTH_DB=./data/auth.sqlite
|
|
5
|
+
|
|
6
|
+
# The SMTP server and the sender of sign-up confirmations and sign-in links, e.g. smtp://user:pass@smtp.example.com:587 and hello@example.com
|
|
7
|
+
MAIL_URL=
|
|
8
|
+
MAIL_FROM=
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "prunelle dev",
|
|
7
|
+
"build": "prunelle build",
|
|
8
|
+
"start": "prunelle start",
|
|
9
|
+
"check": "prunelle check",
|
|
10
|
+
"test": "bun test"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"prunelle": "__PRUNELLE_VERSION__",
|
|
14
|
+
"@prunellejs/auth": "__PRUNELLE_VERSION__",
|
|
15
|
+
"@prunellejs/mail": "__PRUNELLE_VERSION__",
|
|
16
|
+
"@prunellejs/ui": "__PRUNELLE_VERSION__"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/bun": "^1.4.4",
|
|
20
|
+
"typescript": "^6.0.3"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ui } from '@prunellejs/ui/plugin'
|
|
2
|
+
import { defineConfig } from 'prunelle/config'
|
|
3
|
+
import { auth } from './src/auth'
|
|
4
|
+
import { mail } from './src/mail'
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
lang: 'en',
|
|
8
|
+
plugins: [
|
|
9
|
+
ui({ grammar: 'editorial' }),
|
|
10
|
+
mail,
|
|
11
|
+
auth,
|
|
12
|
+
],
|
|
13
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createAuth } from '@prunellejs/auth'
|
|
2
|
+
import { sqliteAuthStore } from '@prunellejs/auth/sqlite'
|
|
3
|
+
import { mail } from './mail'
|
|
4
|
+
|
|
5
|
+
// Set AUTH_SECRET (at least 32 bytes) in production — see .env.example.
|
|
6
|
+
export const auth = createAuth({
|
|
7
|
+
// A relative path lands under the app's folder, out of dist/.
|
|
8
|
+
store: sqliteAuthStore(process.env.AUTH_DB || 'data/auth.sqlite'),
|
|
9
|
+
secret: process.env.AUTH_SECRET || undefined,
|
|
10
|
+
defaultRedirect: '/dashboard',
|
|
11
|
+
mailer: mail,
|
|
12
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LayoutProps } from 'prunelle'
|
|
2
|
+
import { Button, Cluster, Toaster } from '@prunellejs/ui'
|
|
3
|
+
import { Head } from 'prunelle'
|
|
4
|
+
import '../styles/app.css'
|
|
5
|
+
|
|
6
|
+
export default function Layout({ children, locals }: LayoutProps) {
|
|
7
|
+
const user = locals.user
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Head>
|
|
11
|
+
<title>__APP_NAME__</title>
|
|
12
|
+
</Head>
|
|
13
|
+
<a href="#main" class="skip-link">Skip to content</a>
|
|
14
|
+
<div class="wrap">
|
|
15
|
+
<header data-layout="split" class="site-header">
|
|
16
|
+
<a href="/" class="site-brand">__APP_NAME__</a>
|
|
17
|
+
{user
|
|
18
|
+
? (
|
|
19
|
+
<Cluster>
|
|
20
|
+
<Button href="/dashboard" variant="ghost" size="sm">{user.email}</Button>
|
|
21
|
+
<form action="/auth/signout" method="post">
|
|
22
|
+
<Button type="submit" variant="outline" size="sm">Sign out</Button>
|
|
23
|
+
</form>
|
|
24
|
+
</Cluster>
|
|
25
|
+
)
|
|
26
|
+
: <Button href="/login" variant="outline" size="sm">Sign in</Button>}
|
|
27
|
+
</header>
|
|
28
|
+
<main id="main">{children}</main>
|
|
29
|
+
<footer class="site-footer">
|
|
30
|
+
<Cluster>
|
|
31
|
+
<a href="/legal">Legal notice</a>
|
|
32
|
+
<a href="/privacy">Privacy</a>
|
|
33
|
+
<a href="/accessibilite" lang="fr">Accessibilité : non conforme</a>
|
|
34
|
+
</Cluster>
|
|
35
|
+
</footer>
|
|
36
|
+
</div>
|
|
37
|
+
<Toaster />
|
|
38
|
+
</>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PageProps } from 'prunelle'
|
|
2
|
+
import { Button, Card, CardBody, CardHeader, Checkbox, Cluster, Notice, Stack } from '@prunellejs/ui'
|
|
3
|
+
import { Head } from 'prunelle'
|
|
4
|
+
import { auth } from '../../auth'
|
|
5
|
+
|
|
6
|
+
export default async function DashboardPage({ locals, url }: PageProps) {
|
|
7
|
+
// A refused export or deletion comes back here with a code naming why.
|
|
8
|
+
const message = auth.formMessage(url)
|
|
9
|
+
const refusal = message?.form === 'account' ? message : undefined
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Stack gap="lg">
|
|
13
|
+
<Head><title>Dashboard - __APP_NAME__</title></Head>
|
|
14
|
+
<h1 class="page-title">Dashboard</h1>
|
|
15
|
+
<Card>
|
|
16
|
+
<CardBody>
|
|
17
|
+
<p class="m-0">Signed in as <strong>{locals.user?.email}</strong>.</p>
|
|
18
|
+
</CardBody>
|
|
19
|
+
</Card>
|
|
20
|
+
<Card>
|
|
21
|
+
<CardHeader><h2 class="card-title">Your data</h2></CardHeader>
|
|
22
|
+
<CardBody>
|
|
23
|
+
<Stack gap="md">
|
|
24
|
+
{refusal && (
|
|
25
|
+
<Notice tone="danger" role="alert">
|
|
26
|
+
{refusal.text}
|
|
27
|
+
{refusal.code === 'account.reauth-required' && <>. <a href="/login">Sign in</a></>}
|
|
28
|
+
</Notice>
|
|
29
|
+
)}
|
|
30
|
+
<Cluster>
|
|
31
|
+
<Button href="/auth/me/export" variant="outline">Download my data</Button>
|
|
32
|
+
</Cluster>
|
|
33
|
+
<form action="/auth/me/delete" method="post">
|
|
34
|
+
<Stack gap="sm">
|
|
35
|
+
<input type="hidden" name="redirect" value="/" />
|
|
36
|
+
<Checkbox name="confirm" label="Delete my account and everything kept with it, for good" required />
|
|
37
|
+
<Cluster>
|
|
38
|
+
<Button type="submit" tone="danger" variant="outline">Delete my account</Button>
|
|
39
|
+
</Cluster>
|
|
40
|
+
</Stack>
|
|
41
|
+
</form>
|
|
42
|
+
</Stack>
|
|
43
|
+
</CardBody>
|
|
44
|
+
</Card>
|
|
45
|
+
</Stack>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Badge, Button, Cluster, Stack } from '@prunellejs/ui'
|
|
2
|
+
|
|
3
|
+
export default async function Home() {
|
|
4
|
+
return (
|
|
5
|
+
<Stack gap="md">
|
|
6
|
+
<Cluster><Badge tone="accent">Prunelle</Badge><Badge>SQLite Auth</Badge></Cluster>
|
|
7
|
+
<h1 class="page-title">Welcome to __APP_NAME__</h1>
|
|
8
|
+
<p class="page-lead">Zero-dependency Argon2id auth, @prunellejs/ui pure CSS grammar, and Bun speed.</p>
|
|
9
|
+
<Cluster>
|
|
10
|
+
<Button href="/login" tone="accent">Get started</Button>
|
|
11
|
+
<Button href="/dashboard" variant="outline">Dashboard</Button>
|
|
12
|
+
</Cluster>
|
|
13
|
+
</Stack>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PageProps } from 'prunelle'
|
|
2
|
+
import { Button, Card, CardBody, CardHeader, Field, Grid, Notice, Stack } from '@prunellejs/ui'
|
|
3
|
+
import { Head } from 'prunelle'
|
|
4
|
+
import { auth } from '../auth'
|
|
5
|
+
|
|
6
|
+
export default function LoginPage({ url }: PageProps) {
|
|
7
|
+
// A failed sign-in or sign-up comes back here with a code naming its form and, when it is about one, its field.
|
|
8
|
+
const message = auth.formMessage(url)
|
|
9
|
+
const fieldError = (form: 'signin' | 'signup', field: 'email' | 'password') =>
|
|
10
|
+
message?.form === form && message.field === field ? message.text : undefined
|
|
11
|
+
const formNotice = (form: 'signin' | 'signup') =>
|
|
12
|
+
message?.form === form && message.field === undefined
|
|
13
|
+
? <Notice tone={message.tone} role={message.tone === 'danger' ? 'alert' : 'status'}>{message.text}</Notice>
|
|
14
|
+
: undefined
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Stack gap="lg">
|
|
18
|
+
<Head><title>Sign in - __APP_NAME__</title></Head>
|
|
19
|
+
<h1 class="page-title">Sign in or create an account</h1>
|
|
20
|
+
<Grid min="md" gap="lg">
|
|
21
|
+
<Card>
|
|
22
|
+
<CardHeader><h2 class="card-title">Sign in</h2></CardHeader>
|
|
23
|
+
<CardBody>
|
|
24
|
+
<form action="/auth/signin" method="post">
|
|
25
|
+
<Stack gap="sm">
|
|
26
|
+
{formNotice('signin')}
|
|
27
|
+
<input type="hidden" name="redirect" value="/dashboard" />
|
|
28
|
+
<Field id="in-email" label="Email" required><input id="in-email" name="email" type="email" autocomplete="email" required /></Field>
|
|
29
|
+
<Field id="in-pass" label="Password" error={fieldError('signin', 'password')} required><input id="in-pass" name="password" type="password" autocomplete="current-password" required /></Field>
|
|
30
|
+
<Button type="submit" tone="accent">Sign in</Button>
|
|
31
|
+
</Stack>
|
|
32
|
+
</form>
|
|
33
|
+
</CardBody>
|
|
34
|
+
</Card>
|
|
35
|
+
<Card>
|
|
36
|
+
<CardHeader><h2 class="card-title">Create account</h2></CardHeader>
|
|
37
|
+
<CardBody>
|
|
38
|
+
<form action="/auth/signup" method="post">
|
|
39
|
+
<Stack gap="sm">
|
|
40
|
+
{formNotice('signup')}
|
|
41
|
+
<input type="hidden" name="redirect" value="/dashboard" />
|
|
42
|
+
<Field id="up-email" label="Email" error={fieldError('signup', 'email')} required><input id="up-email" name="email" type="email" autocomplete="email" required /></Field>
|
|
43
|
+
<Field id="up-pass" label="Password" hint="Min 12 characters" error={fieldError('signup', 'password')} required><input id="up-pass" name="password" type="password" autocomplete="new-password" minlength="12" required /></Field>
|
|
44
|
+
<p class="form-note">Your email is used only to run your account. <a href="/privacy">How your data is handled</a></p>
|
|
45
|
+
<Button type="submit" tone="accent">Create account</Button>
|
|
46
|
+
</Stack>
|
|
47
|
+
</form>
|
|
48
|
+
</CardBody>
|
|
49
|
+
</Card>
|
|
50
|
+
</Grid>
|
|
51
|
+
</Stack>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Head } from 'prunelle'
|
|
2
|
+
|
|
3
|
+
// What the RGPD (art. 13) asks to tell people when their data is collected, written for what @prunellejs/auth stores by default; `prunelle check` warns until every placeholder below is replaced.
|
|
4
|
+
// Change it when the app collects more, or when you change the auth plugin's storeIp, storeUserAgent or sessionTtlSeconds.
|
|
5
|
+
export default function Privacy() {
|
|
6
|
+
return (
|
|
7
|
+
<section>
|
|
8
|
+
<Head>
|
|
9
|
+
<title>Privacy</title>
|
|
10
|
+
</Head>
|
|
11
|
+
<h1>Privacy</h1>
|
|
12
|
+
<h2>Who is responsible</h2>
|
|
13
|
+
<p>__APP_NAME__ is run by [to fill in: your name or your company's, as on the legal notice]. For any question about your data, write to [to fill in: a contact email].</p>
|
|
14
|
+
<h2>What we collect and why</h2>
|
|
15
|
+
<p>To create your account and sign you in: your email address and a hash of your password, never the password itself. This is needed to provide the service you sign up for (RGPD art. 6.1.b).</p>
|
|
16
|
+
<p>To keep you signed in and protect your account: a session cookie, which the site cannot work without and which therefore needs no consent, and for each session the name of your browser and a shortened IP address with its last part removed.</p>
|
|
17
|
+
<h2>How long we keep it</h2>
|
|
18
|
+
<p>A session ends 30 days after your last visit, or when you sign out, and is then deleted. An account whose email address is not confirmed within 7 days is deleted. Your account is kept until you delete it from your dashboard.</p>
|
|
19
|
+
<h2>Who receives it</h2>
|
|
20
|
+
<p>Nobody else: the data stays with our host, [to fill in: the host's name], and is not shared or sold.</p>
|
|
21
|
+
<h2>Your rights</h2>
|
|
22
|
+
<p>Once signed in, your <a href="/dashboard">dashboard</a> lets you download everything we keep about you and delete your account. To correct your data or object to its use, write to the address above. If you are not satisfied with our answer, you can complain to the CNIL (cnil.fr).</p>
|
|
23
|
+
</section>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
body { margin: 0; background: var(--ui-paper); color: var(--ui-ink); font-family: var(--ui-font-body); }
|
|
2
|
+
.wrap { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
|
|
3
|
+
.site-header { padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--ui-line); }
|
|
4
|
+
.site-brand { display: inline-flex; align-items: center; min-block-size: 2.75rem; font-family: var(--ui-font-display); font-size: 1.3rem; font-weight: 700; text-decoration: none; color: inherit; }
|
|
5
|
+
.page-title { margin: 0; font-family: var(--ui-font-display); }
|
|
6
|
+
.page-lead { margin: 0; color: var(--ui-muted); }
|
|
7
|
+
.m-0 { margin: 0; }
|
|
8
|
+
.site-footer { margin-top: 3rem; padding-top: 0.5rem; border-top: 1px solid var(--ui-line); color: var(--ui-muted); }
|
|
9
|
+
.form-note { margin: 0; color: var(--ui-muted); font-size: 0.9rem; }
|
|
10
|
+
.form-note a, [data-ui="notice"] a { color: inherit; }
|
|
11
|
+
.skip-link { display: inline-flex; align-items: center; min-block-size: 2.75rem; position: absolute; inset-inline-start: 1rem; top: -6rem; z-index: 100; padding: 0.6rem 1rem; background: var(--ui-paper); color: var(--ui-ink); border: 1px solid var(--ui-line); }
|
|
12
|
+
.skip-link:focus { top: 1rem; }
|
|
13
|
+
.site-footer a { display: inline-flex; align-items: center; min-block-size: 2.75rem; color: inherit; }
|
|
14
|
+
.card-title { margin: 0; font: inherit; }
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { TestApp } from 'prunelle/test'
|
|
2
|
+
import { beforeAll, describe, expect, it } from 'bun:test'
|
|
3
|
+
import { mkdtempSync } from 'node:fs'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { join, resolve } from 'node:path'
|
|
6
|
+
import { testApp } from 'prunelle/test'
|
|
7
|
+
|
|
8
|
+
const root = resolve(import.meta.dir, '..')
|
|
9
|
+
// A file the app and this test both open, so a user the test creates can sign in to the app.
|
|
10
|
+
process.env.AUTH_DB ??= join(mkdtempSync(join(tmpdir(), '__APP_NAME__-')), 'auth.sqlite')
|
|
11
|
+
const { auth } = await import('../src/auth')
|
|
12
|
+
|
|
13
|
+
describe('__APP_NAME__', () => {
|
|
14
|
+
let app: TestApp
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
app = await testApp({ root })
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('renders the home and login pages', async () => {
|
|
21
|
+
const home = await app.get('/')
|
|
22
|
+
expect(home.status).toBe(200)
|
|
23
|
+
expect(await home.text()).toContain('Welcome to __APP_NAME__')
|
|
24
|
+
|
|
25
|
+
const login = await app.get('/login')
|
|
26
|
+
expect(login.status).toBe(200)
|
|
27
|
+
const loginHtml = await login.text()
|
|
28
|
+
expect(loginHtml).toContain('/auth/signin')
|
|
29
|
+
expect(loginHtml).toContain('href="/privacy"')
|
|
30
|
+
|
|
31
|
+
const privacy = await app.get('/privacy')
|
|
32
|
+
expect(privacy.status).toBe(200)
|
|
33
|
+
expect(app.errors).toEqual([])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('shows a failed sign-in on the login page, not as JSON', async () => {
|
|
37
|
+
const res = await app.submit('/auth/signin', { email: 'nobody@example.com', password: 'wrong-password-123' }, { referer: 'http://localhost/login' })
|
|
38
|
+
expect(res.status).toBe(303)
|
|
39
|
+
const page = await (await app.get(res.headers.get('location')!)).text()
|
|
40
|
+
expect(page).toContain('role="alert"')
|
|
41
|
+
expect(page).toContain('Invalid email or password')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('lets a signed-in user download their data and delete their account from the dashboard', async () => {
|
|
45
|
+
const credentials = { email: 'ada@example.com', password: 'correct-horse-battery' }
|
|
46
|
+
await auth.createUser({ ...credentials, emailVerified: true })
|
|
47
|
+
const fromLogin = { referer: 'http://localhost/login' }
|
|
48
|
+
const fromDashboard = { referer: 'http://localhost/dashboard' }
|
|
49
|
+
expect((await app.submit('/auth/signin', { ...credentials, redirect: '/dashboard' }, fromLogin)).headers.get('location')).toBe('/dashboard')
|
|
50
|
+
|
|
51
|
+
const dashboard = await (await app.get('/dashboard')).text()
|
|
52
|
+
expect(dashboard).toContain('href="/auth/me/export"')
|
|
53
|
+
expect(dashboard).toContain('action="/auth/me/delete"')
|
|
54
|
+
const refused = await (await app.get('/dashboard?error=account.reauth-required')).text()
|
|
55
|
+
expect(refused).toContain('Sign in again to confirm it is you')
|
|
56
|
+
expect(refused).toContain('<a href="/login">Sign in</a>')
|
|
57
|
+
|
|
58
|
+
const dump = await app.get('/auth/me/export', fromDashboard)
|
|
59
|
+
expect(dump.status).toBe(200)
|
|
60
|
+
expect((await dump.json() as { user: { email: string } }).user.email).toBe('ada@example.com')
|
|
61
|
+
|
|
62
|
+
const deleted = await app.submit('/auth/me/delete', { confirm: 'on', redirect: '/' }, fromDashboard)
|
|
63
|
+
expect(deleted.headers.get('location')).toBe('/')
|
|
64
|
+
expect((await app.get('/dashboard')).status).toBe(302)
|
|
65
|
+
expect((await app.submit('/auth/signin', credentials, fromLogin)).headers.get('location')).toBe('/login?error=signin.invalid-credentials')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('redirects unauthenticated requests from /dashboard to /login', async () => {
|
|
69
|
+
const res = await app.get('/dashboard')
|
|
70
|
+
expect(res.status).toBe(302)
|
|
71
|
+
expect(res.headers.get('location')).toBe('/login?next=%2Fdashboard')
|
|
72
|
+
})
|
|
73
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Welcome to __APP_NAME__
|
|
3
|
+
date: 2026-11-23
|
|
4
|
+
description: A zero-JS static Markdown blog built with Prunelle.
|
|
5
|
+
tags: [prunelle, bun]
|
|
6
|
+
---
|
|
7
|
+
## Fast by Default
|
|
8
|
+
|
|
9
|
+
This post is rendered at build time using Bun's native Zig Markdown engine and ships **0 KB** of client JavaScript.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "prunelle dev",
|
|
7
|
+
"build": "prunelle build",
|
|
8
|
+
"start": "prunelle start",
|
|
9
|
+
"check": "prunelle check",
|
|
10
|
+
"test": "bun test"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"prunelle": "__PRUNELLE_VERSION__",
|
|
14
|
+
"@prunellejs/content": "__PRUNELLE_VERSION__",
|
|
15
|
+
"@prunellejs/seo": "__PRUNELLE_VERSION__",
|
|
16
|
+
"@prunellejs/ui": "__PRUNELLE_VERSION__"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/bun": "^1.4.4",
|
|
20
|
+
"typescript": "^6.0.3"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { content } from '@prunellejs/content'
|
|
2
|
+
import { seo } from '@prunellejs/seo'
|
|
3
|
+
import { ui } from '@prunellejs/ui/plugin'
|
|
4
|
+
import { defineConfig } from 'prunelle/config'
|
|
5
|
+
import { posts } from './src/posts'
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
lang: 'en',
|
|
9
|
+
plugins: [
|
|
10
|
+
ui({ grammar: 'editorial' }),
|
|
11
|
+
seo({ site: 'https://example.com', titleTemplate: '%s — __APP_NAME__', description: 'Articles & notes from __APP_NAME__', image: '/og.png' }),
|
|
12
|
+
content({
|
|
13
|
+
feeds: [{
|
|
14
|
+
path: '/rss.xml',
|
|
15
|
+
title: '__APP_NAME__',
|
|
16
|
+
description: 'Articles & notes',
|
|
17
|
+
site: 'https://example.com',
|
|
18
|
+
linkPrefix: '/blog',
|
|
19
|
+
collection: posts,
|
|
20
|
+
}],
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from 'prunelle/server'
|
|
2
|
+
import { defineCollection } from '@prunellejs/content'
|
|
3
|
+
|
|
4
|
+
export interface PostMeta {
|
|
5
|
+
title: string
|
|
6
|
+
date: string
|
|
7
|
+
description?: string
|
|
8
|
+
tags?: string[]
|
|
9
|
+
draft?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Any Standard Schema validator works here (Zod, Valibot, ArkType); this one keeps the template free of dependencies.
|
|
13
|
+
const postSchema: StandardSchemaV1<unknown, PostMeta> = {
|
|
14
|
+
'~standard': {
|
|
15
|
+
version: 1,
|
|
16
|
+
vendor: 'app',
|
|
17
|
+
validate(raw: unknown) {
|
|
18
|
+
const data = raw as Partial<PostMeta>
|
|
19
|
+
if (typeof data.title !== 'string' || typeof data.date !== 'string')
|
|
20
|
+
return { issues: [{ message: 'A post needs a title and a date', path: ['title'] }] }
|
|
21
|
+
return { value: data as PostMeta }
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const posts = defineCollection({ dir: 'content/posts', schema: postSchema })
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PrunelleChild } from 'prunelle'
|
|
2
|
+
import { Head } from 'prunelle'
|
|
3
|
+
import '../styles/app.css'
|
|
4
|
+
|
|
5
|
+
export default function Layout({ children }: { children: PrunelleChild }) {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Head>
|
|
9
|
+
<title>__APP_NAME__</title>
|
|
10
|
+
</Head>
|
|
11
|
+
<a href="#main" class="skip-link">Skip to content</a>
|
|
12
|
+
<div class="wrap">
|
|
13
|
+
<header data-layout="split" class="site-header">
|
|
14
|
+
<a href="/" class="site-brand">__APP_NAME__</a>
|
|
15
|
+
<a href="/rss.xml" class="site-rss">RSS</a>
|
|
16
|
+
</header>
|
|
17
|
+
<main id="main">{children}</main>
|
|
18
|
+
<footer class="site-footer">
|
|
19
|
+
<a href="/legal">Legal notice</a>
|
|
20
|
+
<a href="/accessibilite" lang="fr">Accessibilité : non conforme</a>
|
|
21
|
+
</footer>
|
|
22
|
+
</div>
|
|
23
|
+
</>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RequestContext } from 'prunelle/server'
|
|
2
|
+
import { Button, Stack } from '@prunellejs/ui'
|
|
3
|
+
import { Head } from 'prunelle'
|
|
4
|
+
import { posts } from '../../posts'
|
|
5
|
+
|
|
6
|
+
export const prerender = true
|
|
7
|
+
export function paths() {
|
|
8
|
+
return posts.paths('/blog')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function load(ctx: RequestContext) {
|
|
12
|
+
const post = posts.get(ctx.params.slug ?? '')
|
|
13
|
+
if (!post)
|
|
14
|
+
return new Response('Not found', { status: 404 })
|
|
15
|
+
return { post }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function PostPage({ data }: { data: { post: NonNullable<ReturnType<typeof posts.get>> } }) {
|
|
19
|
+
const { post } = data
|
|
20
|
+
return (
|
|
21
|
+
<Stack gap="md">
|
|
22
|
+
<Head><title>{post.data.title}</title></Head>
|
|
23
|
+
<article>
|
|
24
|
+
<h1 class="post-title">{post.data.title}</h1>
|
|
25
|
+
<p class="post-meta">{post.data.date} · {post.readingMinutes} min read</p>
|
|
26
|
+
<div innerHTML={post.html} />
|
|
27
|
+
</article>
|
|
28
|
+
<div><Button href="/" variant="outline">← All posts</Button></div>
|
|
29
|
+
</Stack>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Badge, Card, CardBody, CardFooter, CardHeader, Cluster, Stack } from '@prunellejs/ui'
|
|
2
|
+
import { Head } from 'prunelle'
|
|
3
|
+
import { posts } from '../posts'
|
|
4
|
+
|
|
5
|
+
export const prerender = true
|
|
6
|
+
|
|
7
|
+
export default async function BlogIndex() {
|
|
8
|
+
const list = posts.all()
|
|
9
|
+
return (
|
|
10
|
+
<Stack gap="lg">
|
|
11
|
+
<Head>
|
|
12
|
+
<title>Articles</title>
|
|
13
|
+
</Head>
|
|
14
|
+
<h1 class="page-title">Articles</h1>
|
|
15
|
+
{list.map(post => (
|
|
16
|
+
<Card key={post.slug}>
|
|
17
|
+
<CardHeader>
|
|
18
|
+
<h2 class="card-title"><a href={`/blog/${post.slug}`} class="post-link">{post.data.title}</a></h2>
|
|
19
|
+
</CardHeader>
|
|
20
|
+
<CardBody>
|
|
21
|
+
<p class="post-desc">{post.data.description ?? ''}</p>
|
|
22
|
+
</CardBody>
|
|
23
|
+
<CardFooter>
|
|
24
|
+
<Cluster>
|
|
25
|
+
<span>{post.data.date} · {post.readingMinutes} min read</span>
|
|
26
|
+
{(post.data.tags ?? []).map(tag => <Badge key={tag}>{tag}</Badge>)}
|
|
27
|
+
</Cluster>
|
|
28
|
+
</CardFooter>
|
|
29
|
+
</Card>
|
|
30
|
+
))}
|
|
31
|
+
</Stack>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
body { margin: 0; background: var(--ui-paper); color: var(--ui-ink); font-family: var(--ui-font-body); }
|
|
2
|
+
.wrap { max-width: 46rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
|
|
3
|
+
.site-header { padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--ui-line); }
|
|
4
|
+
.site-brand { display: inline-flex; align-items: center; min-block-size: 2.75rem; font-family: var(--ui-font-display); font-size: 1.35rem; font-weight: 700; text-decoration: none; color: inherit; }
|
|
5
|
+
.site-rss { font-size: 0.9rem; color: var(--ui-muted); }
|
|
6
|
+
.page-title { margin: 0; font-family: var(--ui-font-display); }
|
|
7
|
+
.post-link { color: inherit; text-decoration: none; }
|
|
8
|
+
.post-desc { margin: 0; color: var(--ui-muted); }
|
|
9
|
+
.post-title { font-family: var(--ui-font-display); margin-bottom: 0.25rem; }
|
|
10
|
+
.post-meta { color: var(--ui-muted); margin-top: 0; }
|
|
11
|
+
.skip-link { display: inline-flex; align-items: center; min-block-size: 2.75rem; position: absolute; inset-inline-start: 1rem; top: -6rem; z-index: 100; padding: 0.6rem 1rem; background: var(--ui-paper); color: var(--ui-ink); border: 1px solid var(--ui-line); }
|
|
12
|
+
.skip-link:focus { top: 1rem; }
|
|
13
|
+
.site-footer a { display: inline-flex; align-items: center; min-block-size: 2.75rem; color: inherit; }
|
|
14
|
+
.site-footer { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 3rem; padding-top: 0.5rem; border-top: 1px solid var(--ui-line); color: var(--ui-muted); }
|
|
15
|
+
.card-title { margin: 0; font: inherit; }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__APP_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "prunelle dev",
|
|
7
|
+
"build": "prunelle build",
|
|
8
|
+
"start": "prunelle start",
|
|
9
|
+
"check": "prunelle check",
|
|
10
|
+
"test": "bun test"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"prunelle": "__PRUNELLE_VERSION__"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/bun": "^1.4.4",
|
|
17
|
+
"typescript": "^6.0.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from 'prunelle/server'
|
|
2
|
+
import { action } from 'prunelle/server'
|
|
3
|
+
|
|
4
|
+
const nameSchema: StandardSchemaV1<{ name: string }> = {
|
|
5
|
+
'~standard': {
|
|
6
|
+
version: 1,
|
|
7
|
+
vendor: 'prunelle',
|
|
8
|
+
validate(raw: unknown) {
|
|
9
|
+
const name = String((raw as { name?: unknown })?.name ?? '').trim()
|
|
10
|
+
if (name.length < 2)
|
|
11
|
+
return { issues: [{ message: 'Enter at least 2 characters', path: ['name'] }] }
|
|
12
|
+
return { value: { name } }
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const greet = action(nameSchema, async ({ name }) => {
|
|
18
|
+
return { message: `Hello, ${name}!` }
|
|
19
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { signal } from 'prunelle'
|
|
2
|
+
import { greet } from '../actions/greet'
|
|
3
|
+
|
|
4
|
+
export function GreetForm() {
|
|
5
|
+
const name = signal('')
|
|
6
|
+
const reply = signal('')
|
|
7
|
+
|
|
8
|
+
async function onSubmit(e: SubmitEvent) {
|
|
9
|
+
e.preventDefault()
|
|
10
|
+
const res = await greet({ name: name.value })
|
|
11
|
+
reply.value = res.ok ? res.data.message : res.error
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<form class="greet-form" action={greet.url} method="post" onSubmit={onSubmit}>
|
|
16
|
+
<input
|
|
17
|
+
name="name"
|
|
18
|
+
autocomplete="name"
|
|
19
|
+
aria-label="Your name"
|
|
20
|
+
placeholder="Your name"
|
|
21
|
+
value={name.value}
|
|
22
|
+
onInput={(e) => { name.value = (e.target as HTMLInputElement).value }}
|
|
23
|
+
/>
|
|
24
|
+
<button type="submit">Greet</button>
|
|
25
|
+
<span role="status">{reply.value}</span>
|
|
26
|
+
</form>
|
|
27
|
+
)
|
|
28
|
+
}
|