prunelle 0.1.1 → 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 +137 -40
- package/package.json +11 -2
- package/src/a11y/declaration.ts +373 -0
- package/src/a11y/index.ts +477 -0
- package/src/a11y/rgaa-map.ts +230 -0
- package/src/attrs.ts +11 -3
- package/src/build/bundle.ts +89 -41
- package/src/build/byte-size.ts +11 -0
- package/src/build/client-entries.ts +3 -2
- package/src/build/client-plugin.ts +11 -5
- package/src/build/client-prune.ts +56 -6
- package/src/build/compile.ts +13 -10
- package/src/build/ecoindex.ts +238 -0
- package/src/build/files.ts +15 -0
- package/src/build/first-load.ts +85 -14
- package/src/build/graph.ts +29 -39
- package/src/build/index.ts +225 -122
- package/src/build/island-promote.ts +311 -0
- package/src/build/islands.ts +14 -203
- package/src/build/manifest.ts +56 -116
- package/src/build/output.ts +3 -6
- package/src/build/plugin-host.ts +115 -41
- package/src/build/precompress.ts +16 -3
- package/src/build/prerender.ts +177 -39
- package/src/build/reach.ts +200 -0
- package/src/build/render-rules.ts +2 -2
- package/src/build/report.ts +48 -5
- package/src/build/resolve.ts +8 -6
- package/src/build/routes.ts +175 -10
- package/src/build/static-headers.ts +112 -0
- package/src/build/static.ts +139 -39
- 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 +101 -26
- package/src/cli/commands.ts +120 -11
- package/src/cli/docs.ts +403 -0
- package/src/cli/inspect.ts +105 -15
- package/src/cli/mcp-tools.ts +492 -0
- package/src/cli/mcp.ts +205 -0
- package/src/cli/new.ts +16 -5
- package/src/cli/render.ts +416 -0
- package/src/cli/upgrade-names.ts +73 -13
- package/src/cli/upgrade.ts +156 -22
- package/src/compiler/analyze.ts +87 -54
- package/src/compiler/browser-globals.ts +140 -17
- 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 +407 -352
- package/src/compiler/data-keys.ts +199 -192
- package/src/compiler/dev-source.ts +87 -0
- package/src/compiler/dom-attrs.ts +138 -65
- package/src/compiler/dom.ts +517 -442
- package/src/compiler/expr-context.ts +260 -81
- package/src/compiler/foreign-imports.ts +88 -0
- package/src/compiler/mistakes.ts +23 -2
- package/src/compiler/props-body.ts +60 -0
- package/src/compiler/props.ts +87 -36
- package/src/compiler/scope.ts +400 -333
- package/src/compiler/server-only.ts +190 -151
- package/src/compiler/shared.ts +42 -14
- package/src/compiler/signal-reads.ts +6 -2
- package/src/compiler/spread-handlers.ts +295 -0
- package/src/compiler/ssr-prunelle-tags.ts +27 -14
- package/src/compiler/ssr.ts +220 -89
- package/src/context.ts +34 -0
- package/src/dev/error-log.ts +177 -0
- package/src/dev/host-check.ts +32 -0
- package/src/dev/index.ts +94 -34
- package/src/dev/open-editor.ts +228 -0
- package/src/dev/protocol.ts +3 -0
- package/src/dev/reload.ts +5 -3
- package/src/dev/supervisor.ts +50 -25
- package/src/dev/watchers.ts +74 -13
- package/src/dom/action.ts +47 -21
- package/src/dom/attrs.ts +15 -3
- package/src/dom/extras.ts +57 -40
- package/src/dom/index.ts +54 -14
- package/src/dom/island.ts +102 -68
- package/src/dom/loop.ts +66 -32
- package/src/eco/declaration.ts +328 -0
- package/src/eco/index.ts +69 -0
- package/src/index.ts +2 -2
- package/src/jsx-runtime.ts +2 -2
- package/src/plugins/config.ts +18 -12
- package/src/plugins/context.ts +44 -1
- package/src/plugins/index.ts +2 -2
- package/src/plugins/load.ts +30 -10
- package/src/plugins/order.ts +38 -1
- package/src/plugins/public.ts +6 -3
- package/src/plugins/services.ts +84 -0
- package/src/plugins/types.ts +51 -2
- package/src/reactivity/graph.ts +10 -0
- package/src/reactivity/index.ts +24 -16
- package/src/reactivity/selector.ts +31 -4
- package/src/reactivity/store.ts +64 -20
- package/src/server/action-flash.ts +158 -0
- package/src/server/action-protect.ts +199 -0
- package/src/server/action-registry.ts +1 -1
- package/src/server/action.ts +188 -152
- package/src/server/app-secret.ts +63 -0
- package/src/server/assets.ts +34 -2
- package/src/server/compress.ts +96 -10
- package/src/server/consent.ts +59 -22
- package/src/server/cookies.ts +16 -2
- package/src/server/document.ts +25 -10
- package/src/server/env.ts +14 -0
- package/src/server/errors.ts +308 -65
- package/src/server/form-schema.ts +337 -0
- package/src/server/health.ts +275 -0
- package/src/server/http.ts +186 -39
- package/src/server/index.ts +272 -273
- package/src/server/loader.ts +15 -2
- package/src/server/page.ts +15 -0
- package/src/server/param-matchers.ts +112 -0
- package/src/server/plugin-host.ts +125 -88
- package/src/server/public.ts +6 -5
- package/src/server/rate-limit.ts +102 -36
- package/src/server/request-body.ts +1 -1
- package/src/server/route-cache.ts +541 -0
- package/src/server/route-table.ts +356 -11
- package/src/server/router.ts +125 -40
- package/src/server/routing.ts +112 -63
- package/src/server/sanitize-html.ts +309 -0
- package/src/server/security.ts +279 -52
- package/src/server/serve-handlers.ts +31 -7
- package/src/server/standard-schema.ts +17 -0
- package/src/server/start.ts +60 -16
- package/src/server/static-dir.ts +91 -12
- package/src/server/stream.ts +68 -27
- package/src/ssr/consent-banner.ts +58 -0
- package/src/ssr/context.ts +106 -8
- package/src/ssr/index.ts +151 -4
- package/src/ssr/navigation.ts +2 -2
- package/src/ssr/region.ts +40 -19
- package/src/style.ts +64 -1
- package/src/test/browser.ts +28 -13
- package/src/test/index.ts +97 -12
- 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/templates/_shared/AGENTS.md +2 -2
- package/templates/_shared/gitignore +5 -0
- package/templates/_shared/mcp.json +11 -0
- package/templates/_shared/src/routes/legal.tsx +15 -1
- package/templates/_shared/tsconfig.json +5 -0
- package/templates/app/.env.example +4 -0
- package/templates/app/package.json +2 -1
- package/templates/app/prunelle.config.ts +2 -0
- package/templates/app/src/auth.ts +4 -6
- package/templates/app/src/mail.ts +4 -0
- package/templates/app/src/routes/_layout.tsx +9 -1
- package/templates/app/src/routes/dashboard/index.tsx +42 -8
- package/templates/app/src/routes/login.tsx +49 -30
- package/templates/app/src/routes/privacy.tsx +25 -0
- package/templates/app/src/styles/app.css +8 -1
- package/templates/app/tests/app.test.ts +44 -3
- package/templates/blog/package.json +1 -1
- package/templates/blog/prunelle.config.ts +1 -1
- package/templates/blog/src/routes/_layout.tsx +6 -1
- package/templates/blog/src/routes/index.tsx +5 -1
- package/templates/blog/src/styles/app.css +6 -1
- package/templates/fullstack/package.json +1 -1
- package/templates/fullstack/src/components/GreetForm.tsx +2 -1
- package/templates/fullstack/src/routes/_layout.tsx +4 -0
- package/templates/fullstack/src/styles/app.css +11 -1
- package/templates/minimal/package.json +1 -1
- package/templates/minimal/src/routes/_layout.tsx +4 -0
- package/templates/minimal/src/styles/app.css +11 -1
- package/ts-plugin.cjs +4277 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
// Diagnostic codes and mechanical quick fixes for the Prunelle TypeScript language-service plugin.
|
|
2
|
+
|
|
3
|
+
import type { JSXAttribute, Node } from 'oxc-parser'
|
|
4
|
+
import type ts from 'typescript'
|
|
5
|
+
import { unwrapParens, unwrapTsExpr } from '../compiler/shared'
|
|
6
|
+
|
|
7
|
+
export const PRUNELLE_CODE = {
|
|
8
|
+
ERROR: 98001,
|
|
9
|
+
WARNING: 98002,
|
|
10
|
+
BARE_SIGNAL: 98101,
|
|
11
|
+
LOWERCASE_EVENT: 98102,
|
|
12
|
+
RENAMED_EVENT: 98103,
|
|
13
|
+
NAMESPACED_EVENT: 98104,
|
|
14
|
+
CLIENT_DIRECTIVE: 98105,
|
|
15
|
+
SET_HTML: 98106,
|
|
16
|
+
STRIP_NAMESPACE: 98107,
|
|
17
|
+
CAMEL_ARIA: 98108,
|
|
18
|
+
CAMEL_SVG: 98109,
|
|
19
|
+
REACT_DEFAULT: 98110,
|
|
20
|
+
BOOLEAN_FALSE_STRING: 98111,
|
|
21
|
+
DANGEROUSLY_SET_HTML: 98112,
|
|
22
|
+
INNER_HTML_OBJECT: 98113,
|
|
23
|
+
HANDLER_MUTATION: 98114,
|
|
24
|
+
DIRECTIVE: 98115,
|
|
25
|
+
NON_BUBBLING_FOCUS: 98116,
|
|
26
|
+
TEXT_INPUT_ONCHANGE: 98117,
|
|
27
|
+
KAY_IMPORT: 98118,
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
export const PRUNELLE_FIXABLE_CODES: readonly number[] = [
|
|
31
|
+
PRUNELLE_CODE.BARE_SIGNAL,
|
|
32
|
+
PRUNELLE_CODE.LOWERCASE_EVENT,
|
|
33
|
+
PRUNELLE_CODE.RENAMED_EVENT,
|
|
34
|
+
PRUNELLE_CODE.NAMESPACED_EVENT,
|
|
35
|
+
PRUNELLE_CODE.CLIENT_DIRECTIVE,
|
|
36
|
+
PRUNELLE_CODE.SET_HTML,
|
|
37
|
+
PRUNELLE_CODE.STRIP_NAMESPACE,
|
|
38
|
+
PRUNELLE_CODE.CAMEL_ARIA,
|
|
39
|
+
PRUNELLE_CODE.CAMEL_SVG,
|
|
40
|
+
PRUNELLE_CODE.REACT_DEFAULT,
|
|
41
|
+
PRUNELLE_CODE.BOOLEAN_FALSE_STRING,
|
|
42
|
+
PRUNELLE_CODE.DANGEROUSLY_SET_HTML,
|
|
43
|
+
PRUNELLE_CODE.INNER_HTML_OBJECT,
|
|
44
|
+
PRUNELLE_CODE.HANDLER_MUTATION,
|
|
45
|
+
PRUNELLE_CODE.DIRECTIVE,
|
|
46
|
+
PRUNELLE_CODE.NON_BUBBLING_FOCUS,
|
|
47
|
+
PRUNELLE_CODE.TEXT_INPUT_ONCHANGE,
|
|
48
|
+
PRUNELLE_CODE.KAY_IMPORT,
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
export interface PrunelleFixDescriptor {
|
|
52
|
+
fixName: string
|
|
53
|
+
description: string
|
|
54
|
+
span: { start: number, length: number }
|
|
55
|
+
newText: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ClassifiedFix {
|
|
59
|
+
code: number
|
|
60
|
+
/** Highlight span for the diagnostic itself (may differ from edit span, e.g. handler mutation). */
|
|
61
|
+
diagSpan: { start: number, length: number }
|
|
62
|
+
fix: PrunelleFixDescriptor
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const CLIENT_HYDRATE_MAP: Record<string, string> = {
|
|
66
|
+
load: 'load',
|
|
67
|
+
visible: 'visible',
|
|
68
|
+
idle: 'idle',
|
|
69
|
+
only: 'client',
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const WRITE_PROP_RE = /^write ([a-zA-Z0-9_:-]+)=\{\.\.\.\}/
|
|
73
|
+
const WRITE_IMPORT_RE = /^write '([^']+)'/
|
|
74
|
+
const BUBBLING_FOCUS_RE = /focus does not bubble, write (onFocus(?:In|Out))=\{\.\.\.\}/
|
|
75
|
+
|
|
76
|
+
function findNode<T extends Node['type']>(nodes: readonly Node[], type: T): Extract<Node, { type: T }> | undefined {
|
|
77
|
+
for (const node of nodes) {
|
|
78
|
+
if (node.type === type)
|
|
79
|
+
return node as Extract<Node, { type: T }>
|
|
80
|
+
}
|
|
81
|
+
return undefined
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function spanOf(start: number, end: number): { start: number, length: number } {
|
|
85
|
+
return { start, length: Math.max(1, end - start) }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function attrRenameFix(
|
|
89
|
+
code: number,
|
|
90
|
+
attr: JSXAttribute,
|
|
91
|
+
fromName: string,
|
|
92
|
+
toName: string,
|
|
93
|
+
fixName: string,
|
|
94
|
+
): ClassifiedFix {
|
|
95
|
+
const span = spanOf(attr.name.start, attr.name.end)
|
|
96
|
+
return {
|
|
97
|
+
code,
|
|
98
|
+
diagSpan: span,
|
|
99
|
+
fix: { fixName, description: `Change '${fromName}' to '${toName}'`, span, newText: toName },
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function extractHtmlObjectExpr(value: JSXAttribute['value'], source: string): string | undefined {
|
|
104
|
+
if (value?.type !== 'JSXExpressionContainer' || value.expression.type === 'JSXEmptyExpression')
|
|
105
|
+
return undefined
|
|
106
|
+
const obj = unwrapParens(value.expression)
|
|
107
|
+
if (obj.type !== 'ObjectExpression')
|
|
108
|
+
return undefined
|
|
109
|
+
const prop = obj.properties.find(p =>
|
|
110
|
+
p.type === 'Property'
|
|
111
|
+
&& ((p.key.type === 'Identifier' && p.key.name === '__html')
|
|
112
|
+
|| (p.key.type === 'Literal' && p.key.value === '__html')),
|
|
113
|
+
)
|
|
114
|
+
return prop?.type === 'Property' ? source.slice(prop.value.start, prop.value.end) : undefined
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function staticLiteralString(value: JSXAttribute['value']): string | undefined {
|
|
118
|
+
if (value?.type === 'Literal' && typeof value.value === 'string')
|
|
119
|
+
return value.value
|
|
120
|
+
if (value?.type === 'JSXExpressionContainer' && value.expression.type !== 'JSXEmptyExpression') {
|
|
121
|
+
const inner = unwrapTsExpr(value.expression)
|
|
122
|
+
if (inner.type === 'Literal' && typeof inner.value === 'string')
|
|
123
|
+
return inner.value
|
|
124
|
+
}
|
|
125
|
+
return undefined
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function directiveDeleteSpan(code: string, start: number, end: number): { start: number, length: number } {
|
|
129
|
+
let delStart = start
|
|
130
|
+
let lineStart = start
|
|
131
|
+
while (lineStart > 0 && code.charCodeAt(lineStart - 1) !== 10 && code.charCodeAt(lineStart - 1) !== 13)
|
|
132
|
+
lineStart--
|
|
133
|
+
if (/^[ \t]*$/.test(code.slice(lineStart, start)))
|
|
134
|
+
delStart = lineStart
|
|
135
|
+
|
|
136
|
+
let delEnd = end
|
|
137
|
+
while (delEnd < code.length && (code.charCodeAt(delEnd) === 32 || code.charCodeAt(delEnd) === 9))
|
|
138
|
+
delEnd++
|
|
139
|
+
if (code.charCodeAt(delEnd) === 13 && code.charCodeAt(delEnd + 1) === 10)
|
|
140
|
+
delEnd += 2
|
|
141
|
+
else if (code.charCodeAt(delEnd) === 10)
|
|
142
|
+
delEnd += 1
|
|
143
|
+
return { start: delStart, length: delEnd - delStart }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function classifyNamespacedAttrFix(attr: JSXAttribute, what: string, fixText: string): ClassifiedFix | undefined {
|
|
147
|
+
if (attr.name.type !== 'JSXNamespacedName')
|
|
148
|
+
return undefined
|
|
149
|
+
const ns = attr.name.namespace.name
|
|
150
|
+
const local = attr.name.name.name
|
|
151
|
+
if (ns === 'on') {
|
|
152
|
+
const match = WRITE_PROP_RE.exec(fixText)
|
|
153
|
+
return match !== null ? attrRenameFix(PRUNELLE_CODE.NAMESPACED_EVENT, attr, what, match[1]!, 'prunelle-namespaced-event') : undefined
|
|
154
|
+
}
|
|
155
|
+
if (ns === 'client') {
|
|
156
|
+
let mode = CLIENT_HYDRATE_MAP[local]
|
|
157
|
+
if (mode === undefined && local === 'media') {
|
|
158
|
+
const query = staticLiteralString(attr.value)
|
|
159
|
+
if (query !== undefined && query.trim() !== '')
|
|
160
|
+
mode = `media(${query})`
|
|
161
|
+
}
|
|
162
|
+
if (mode === undefined)
|
|
163
|
+
return undefined
|
|
164
|
+
const span = spanOf(attr.start, attr.end)
|
|
165
|
+
const newText = `$hydrate="${mode}"`
|
|
166
|
+
return {
|
|
167
|
+
code: PRUNELLE_CODE.CLIENT_DIRECTIVE,
|
|
168
|
+
diagSpan: span,
|
|
169
|
+
fix: { fixName: 'prunelle-client-directive', description: `Replace '${what}' with '${newText}'`, span, newText },
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (what === 'set:html')
|
|
173
|
+
return attrRenameFix(PRUNELLE_CODE.SET_HTML, attr, 'set:html', 'innerHTML', 'prunelle-set-html')
|
|
174
|
+
if (ns === 'prop' || ns === 'attr' || ns === 'bool')
|
|
175
|
+
return attrRenameFix(PRUNELLE_CODE.STRIP_NAMESPACE, attr, what, local, 'prunelle-strip-namespace')
|
|
176
|
+
return undefined
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function classifyInnerHtmlFix(attr: JSXAttribute, what: string, code: string): ClassifiedFix | undefined {
|
|
180
|
+
const isDangerous = what === 'dangerouslySetInnerHTML'
|
|
181
|
+
if (!isDangerous && what !== 'innerHTML={{ __html }}')
|
|
182
|
+
return undefined
|
|
183
|
+
const expr = extractHtmlObjectExpr(attr.value, code)
|
|
184
|
+
if (expr === undefined)
|
|
185
|
+
return undefined
|
|
186
|
+
const span = spanOf(attr.start, attr.end)
|
|
187
|
+
const newText = `innerHTML={${expr}}`
|
|
188
|
+
return {
|
|
189
|
+
code: isDangerous ? PRUNELLE_CODE.DANGEROUSLY_SET_HTML : PRUNELLE_CODE.INNER_HTML_OBJECT,
|
|
190
|
+
diagSpan: span,
|
|
191
|
+
fix: {
|
|
192
|
+
fixName: isDangerous ? 'prunelle-dangerously-set-html' : 'prunelle-inner-html-object',
|
|
193
|
+
description: `Replace with '${newText}'`,
|
|
194
|
+
span,
|
|
195
|
+
newText,
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function classifyJsxAttrMistake(attr: JSXAttribute, what: string, fixText: string, code: string): ClassifiedFix | undefined {
|
|
201
|
+
if (attr.name.type === 'JSXNamespacedName')
|
|
202
|
+
return classifyNamespacedAttrFix(attr, what, fixText)
|
|
203
|
+
const attrName = attr.name.name
|
|
204
|
+
const htmlFix = classifyInnerHtmlFix(attr, what, code)
|
|
205
|
+
if (htmlFix !== undefined)
|
|
206
|
+
return htmlFix
|
|
207
|
+
if (fixText.includes('prunelle binds camelCase event props only')) {
|
|
208
|
+
const match = WRITE_PROP_RE.exec(fixText)
|
|
209
|
+
return match !== null ? attrRenameFix(PRUNELLE_CODE.LOWERCASE_EVENT, attr, attrName, match[1]!, 'prunelle-lowercase-event') : undefined
|
|
210
|
+
}
|
|
211
|
+
if (fixText.includes('ARIA attributes use kebab-case')) {
|
|
212
|
+
const match = WRITE_PROP_RE.exec(fixText)
|
|
213
|
+
return match !== null ? attrRenameFix(PRUNELLE_CODE.CAMEL_ARIA, attr, attrName, match[1]!, 'prunelle-kebab-aria') : undefined
|
|
214
|
+
}
|
|
215
|
+
if (fixText.includes('SVG attributes are case-sensitive') || what === 'xlinkHref') {
|
|
216
|
+
const target = what === 'xlinkHref' ? 'xlink:href' : WRITE_PROP_RE.exec(fixText)?.[1]
|
|
217
|
+
return target !== undefined ? attrRenameFix(PRUNELLE_CODE.CAMEL_SVG, attr, attrName, target, 'prunelle-kebab-svg') : undefined
|
|
218
|
+
}
|
|
219
|
+
if (what === 'defaultValue' || what === 'defaultChecked') {
|
|
220
|
+
const target = what === 'defaultValue' ? 'value' : 'checked'
|
|
221
|
+
return attrRenameFix(PRUNELLE_CODE.REACT_DEFAULT, attr, attrName, target, 'prunelle-react-default')
|
|
222
|
+
}
|
|
223
|
+
if (fixText.includes('any string turns it on')) {
|
|
224
|
+
const span = spanOf(attr.start, attr.end)
|
|
225
|
+
const newText = `${attrName}={false}`
|
|
226
|
+
return {
|
|
227
|
+
code: PRUNELLE_CODE.BOOLEAN_FALSE_STRING,
|
|
228
|
+
diagSpan: span,
|
|
229
|
+
fix: { fixName: 'prunelle-boolean-false', description: `Change '${what}' to '${newText}'`, span, newText },
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (what.includes(' runs ') && what.endsWith(' at render') && attr.value?.type === 'JSXExpressionContainer' && attr.value.expression.type !== 'JSXEmptyExpression') {
|
|
233
|
+
const inner = unwrapParens(attr.value.expression)
|
|
234
|
+
const exprSrc = code.slice(inner.start, inner.end)
|
|
235
|
+
const newText = `() => ${exprSrc}`
|
|
236
|
+
return {
|
|
237
|
+
code: PRUNELLE_CODE.HANDLER_MUTATION,
|
|
238
|
+
diagSpan: spanOf(attr.start, attr.end),
|
|
239
|
+
fix: {
|
|
240
|
+
fixName: 'prunelle-wrap-handler',
|
|
241
|
+
description: `Wrap handler in '${newText}'`,
|
|
242
|
+
span: spanOf(attr.value.expression.start, attr.value.expression.end),
|
|
243
|
+
newText,
|
|
244
|
+
},
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const focusMatch = BUBBLING_FOCUS_RE.exec(fixText)
|
|
248
|
+
if (focusMatch !== null)
|
|
249
|
+
return attrRenameFix(PRUNELLE_CODE.NON_BUBBLING_FOCUS, attr, attrName, focusMatch[1]!, 'prunelle-bubbling-focus')
|
|
250
|
+
if (what === attrName && attrName.startsWith('on')) {
|
|
251
|
+
const match = WRITE_PROP_RE.exec(fixText)
|
|
252
|
+
if (match !== null && match[1]!.startsWith('on'))
|
|
253
|
+
return attrRenameFix(PRUNELLE_CODE.RENAMED_EVENT, attr, attrName, match[1]!, 'prunelle-renamed-event')
|
|
254
|
+
}
|
|
255
|
+
return undefined
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Splits a standard `prunelle compiler: <what> in <file>: <fix>.` message. */
|
|
259
|
+
function parseMistakeParts(message: string, fileName: string): { what: string, fixText: string } | undefined {
|
|
260
|
+
const prefix = 'prunelle compiler: '
|
|
261
|
+
if (!message.startsWith(prefix))
|
|
262
|
+
return undefined
|
|
263
|
+
const marker = ` in ${fileName}: `
|
|
264
|
+
const idx = message.indexOf(marker, prefix.length)
|
|
265
|
+
if (idx === -1)
|
|
266
|
+
return undefined
|
|
267
|
+
const what = message.slice(prefix.length, idx)
|
|
268
|
+
const rawFix = message.slice(idx + marker.length)
|
|
269
|
+
const fixText = rawFix.endsWith('.') ? rawFix.slice(0, -1) : rawFix
|
|
270
|
+
return { what, fixText }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Classifies a compiler mistake and builds a mechanical quick fix when one exists. */
|
|
274
|
+
export function classifyMistakeFix(
|
|
275
|
+
message: string,
|
|
276
|
+
fileName: string,
|
|
277
|
+
nodesAtStart: readonly Node[],
|
|
278
|
+
code: string,
|
|
279
|
+
): ClassifiedFix | undefined {
|
|
280
|
+
const parts = parseMistakeParts(message, fileName)
|
|
281
|
+
if (parts === undefined)
|
|
282
|
+
return undefined
|
|
283
|
+
const { what, fixText } = parts
|
|
284
|
+
|
|
285
|
+
if (what.endsWith(' without .value')) {
|
|
286
|
+
const name = what.slice(0, -' without .value'.length)
|
|
287
|
+
const node = name.includes('.') ? findNode(nodesAtStart, 'MemberExpression') : findNode(nodesAtStart, 'Identifier')
|
|
288
|
+
if (node === undefined)
|
|
289
|
+
return undefined
|
|
290
|
+
const span = spanOf(node.start, node.end)
|
|
291
|
+
const exprText = code.slice(node.start, node.end)
|
|
292
|
+
return {
|
|
293
|
+
code: PRUNELLE_CODE.BARE_SIGNAL,
|
|
294
|
+
diagSpan: span,
|
|
295
|
+
fix: { fixName: 'prunelle-add-signal-value', description: `Add '.value' to '${name}'`, span, newText: `${exprText}.value` },
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (what === "'use client'" || what === "'use server'") {
|
|
300
|
+
const stmt = findNode(nodesAtStart, 'ExpressionStatement')
|
|
301
|
+
if (stmt === undefined)
|
|
302
|
+
return undefined
|
|
303
|
+
return {
|
|
304
|
+
code: PRUNELLE_CODE.DIRECTIVE,
|
|
305
|
+
diagSpan: spanOf(stmt.start, stmt.end),
|
|
306
|
+
fix: {
|
|
307
|
+
fixName: 'prunelle-remove-directive',
|
|
308
|
+
description: `Remove ${what} directive`,
|
|
309
|
+
span: directiveDeleteSpan(code, stmt.start, stmt.end),
|
|
310
|
+
newText: '',
|
|
311
|
+
},
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (what.startsWith("import from '@kayjs/")) {
|
|
316
|
+
const lit = findNode(nodesAtStart, 'Literal')
|
|
317
|
+
const match = WRITE_IMPORT_RE.exec(fixText)
|
|
318
|
+
if (lit === undefined || match === null)
|
|
319
|
+
return undefined
|
|
320
|
+
const quote = code[lit.start] === '"' ? '"' : "'"
|
|
321
|
+
const replacement = match[1]!
|
|
322
|
+
const span = spanOf(lit.start, lit.end)
|
|
323
|
+
return {
|
|
324
|
+
code: PRUNELLE_CODE.KAY_IMPORT,
|
|
325
|
+
diagSpan: span,
|
|
326
|
+
fix: {
|
|
327
|
+
fixName: 'prunelle-rewrite-kay-import',
|
|
328
|
+
description: `Replace import with '${replacement}'`,
|
|
329
|
+
span,
|
|
330
|
+
newText: `${quote}${replacement}${quote}`,
|
|
331
|
+
},
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const attr = findNode(nodesAtStart, 'JSXAttribute')
|
|
336
|
+
if (attr !== undefined)
|
|
337
|
+
return classifyJsxAttrMistake(attr, what, fixText, code)
|
|
338
|
+
return undefined
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Classifies a compiler warning and builds a mechanical quick fix when one exists. */
|
|
342
|
+
export function classifyWarningFix(message: string, nodesAtStart: readonly Node[]): ClassifiedFix | undefined {
|
|
343
|
+
if (message.includes('fires when the field loses focus, not per keystroke; write onInput={...}')) {
|
|
344
|
+
const attr = findNode(nodesAtStart, 'JSXAttribute')
|
|
345
|
+
if (attr !== undefined)
|
|
346
|
+
return attrRenameFix(PRUNELLE_CODE.TEXT_INPUT_ONCHANGE, attr, 'onChange', 'onInput', 'prunelle-text-input-oninput')
|
|
347
|
+
}
|
|
348
|
+
return undefined
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Converts a Prunelle quick fix descriptor into a TypeScript `CodeFixAction`. */
|
|
352
|
+
export function toCodeFixAction(fileName: string, fix: PrunelleFixDescriptor): ts.CodeFixAction {
|
|
353
|
+
return {
|
|
354
|
+
fixName: fix.fixName,
|
|
355
|
+
description: fix.description,
|
|
356
|
+
changes: [{
|
|
357
|
+
fileName,
|
|
358
|
+
textChanges: [{
|
|
359
|
+
span: { start: fix.span.start, length: fix.span.length },
|
|
360
|
+
newText: fix.newText,
|
|
361
|
+
}],
|
|
362
|
+
}],
|
|
363
|
+
}
|
|
364
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// TypeScript Language Service plugin surfacing Prunelle compiler errors, compliance warnings, and quick fixes in editors.
|
|
2
|
+
|
|
3
|
+
import type ts from 'typescript'
|
|
4
|
+
import type { ComplianceConfig } from '../compiler/compliance'
|
|
5
|
+
import type { PrunelleDiagnosticItem, PrunellePluginOptions } from './diagnostics'
|
|
6
|
+
import { collectPrunelleDiagnostics, isCheckableFile, PRUNELLE_DIAG_SOURCE, toTsDiagnostic } from './diagnostics'
|
|
7
|
+
import { PRUNELLE_CODE, PRUNELLE_FIXABLE_CODES, toCodeFixAction } from './fixes'
|
|
8
|
+
|
|
9
|
+
const MAX_CACHE_ENTRIES = 200
|
|
10
|
+
|
|
11
|
+
interface CachedFileDiagnostics {
|
|
12
|
+
text: string
|
|
13
|
+
projectVersion: string
|
|
14
|
+
items: PrunelleDiagnosticItem[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function readPluginConfig(raw: unknown): Pick<PrunellePluginOptions, 'compliance' | 'site'> {
|
|
18
|
+
if (raw === null || typeof raw !== 'object')
|
|
19
|
+
return {}
|
|
20
|
+
const rec = raw as Record<string, unknown>
|
|
21
|
+
const site = typeof rec.site === 'string' ? rec.site : undefined
|
|
22
|
+
const compliance = rec.compliance !== null && typeof rec.compliance === 'object'
|
|
23
|
+
? (rec.compliance as ComplianceConfig)
|
|
24
|
+
: undefined
|
|
25
|
+
return { site, compliance }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Advertises Prunelle's custom fixable diagnostic codes to tsserver/VS Code when TypeScript's supported-codes array is extensible.
|
|
29
|
+
function registerSupportedCodeFixes(tsLib: typeof ts): void {
|
|
30
|
+
if (typeof tsLib.getSupportedCodeFixes !== 'function')
|
|
31
|
+
return
|
|
32
|
+
try {
|
|
33
|
+
const supported = tsLib.getSupportedCodeFixes() as string[]
|
|
34
|
+
if (!Array.isArray(supported) || Object.isFrozen(supported))
|
|
35
|
+
return
|
|
36
|
+
const existing = new Set(supported)
|
|
37
|
+
for (const code of PRUNELLE_FIXABLE_CODES) {
|
|
38
|
+
const str = String(code)
|
|
39
|
+
if (!existing.has(str))
|
|
40
|
+
supported.push(str)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Some TypeScript builds freeze the supported-codes array; editors still invoke getCodeFixesAtPosition directly.
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readFileSource(
|
|
50
|
+
prior: ts.LanguageService,
|
|
51
|
+
host: ts.LanguageServiceHost,
|
|
52
|
+
fileName: string,
|
|
53
|
+
): { sourceFile: ts.SourceFile | undefined, text: string | undefined } {
|
|
54
|
+
const sourceFile = prior.getProgram()?.getSourceFile(fileName)
|
|
55
|
+
if (sourceFile !== undefined)
|
|
56
|
+
return { sourceFile, text: sourceFile.text }
|
|
57
|
+
const snapshot = host.getScriptSnapshot(fileName)
|
|
58
|
+
if (snapshot !== undefined)
|
|
59
|
+
return { sourceFile: undefined, text: snapshot.getText(0, snapshot.getLength()) }
|
|
60
|
+
return { sourceFile: undefined, text: undefined }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Direct helper for retrieving TypeScript `ts.Diagnostic`s for a single file. */
|
|
64
|
+
export function getPrunelleDiagnostics(
|
|
65
|
+
tsLib: typeof ts,
|
|
66
|
+
fileName: string,
|
|
67
|
+
code: string,
|
|
68
|
+
options: PrunellePluginOptions = {},
|
|
69
|
+
sourceFile?: ts.SourceFile,
|
|
70
|
+
): ts.Diagnostic[] {
|
|
71
|
+
return collectPrunelleDiagnostics(fileName, code, options).map(item => toTsDiagnostic(tsLib, item, sourceFile))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Direct helper for retrieving TypeScript `ts.CodeFixAction`s overlapping `[start, end]`. */
|
|
75
|
+
export function getPrunelleCodeFixes(
|
|
76
|
+
fileName: string,
|
|
77
|
+
code: string,
|
|
78
|
+
start: number,
|
|
79
|
+
end: number,
|
|
80
|
+
errorCodes: readonly number[],
|
|
81
|
+
options: PrunellePluginOptions = {},
|
|
82
|
+
): ts.CodeFixAction[] {
|
|
83
|
+
const items = collectPrunelleDiagnostics(fileName, code, options)
|
|
84
|
+
return selectCodeFixes(fileName, items, start, end, errorCodes)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function selectCodeFixes(
|
|
88
|
+
fileName: string,
|
|
89
|
+
items: readonly PrunelleDiagnosticItem[],
|
|
90
|
+
start: number,
|
|
91
|
+
end: number,
|
|
92
|
+
errorCodes: readonly number[],
|
|
93
|
+
): ts.CodeFixAction[] {
|
|
94
|
+
const out: ts.CodeFixAction[] = []
|
|
95
|
+
for (const item of items) {
|
|
96
|
+
if (item.fix === undefined)
|
|
97
|
+
continue
|
|
98
|
+
if (errorCodes.length > 0 && !errorCodes.includes(item.code))
|
|
99
|
+
continue
|
|
100
|
+
const itemEnd = item.start + item.length
|
|
101
|
+
if (item.start <= end && start <= itemEnd)
|
|
102
|
+
out.push(toCodeFixAction(fileName, item.fix))
|
|
103
|
+
}
|
|
104
|
+
return out
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Creates the wrapped `ts.LanguageService` for a TypeScript plugin instance. */
|
|
108
|
+
export function createPrunellePlugin(tsLib: typeof ts, info: ts.server.PluginCreateInfo): ts.LanguageService {
|
|
109
|
+
const prior = info.languageService
|
|
110
|
+
const log = (msg: string): void => {
|
|
111
|
+
info.project?.projectService?.logger?.info(`[prunelle/ts-plugin] ${msg}`)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
registerSupportedCodeFixes(tsLib)
|
|
115
|
+
|
|
116
|
+
const cache = new Map<string, CachedFileDiagnostics>()
|
|
117
|
+
const pluginCfg = readPluginConfig(info.config)
|
|
118
|
+
const readFile = (path: string): string | undefined => readFileSource(prior, info.languageServiceHost, path).text
|
|
119
|
+
const getOptions = (): PrunellePluginOptions => ({
|
|
120
|
+
projectRoot: typeof info.project?.getCurrentDirectory === 'function' ? info.project.getCurrentDirectory() : undefined,
|
|
121
|
+
compliance: pluginCfg.compliance,
|
|
122
|
+
site: pluginCfg.site,
|
|
123
|
+
readFile,
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const getItems = (fileName: string): { sourceFile: ts.SourceFile | undefined, items: PrunelleDiagnosticItem[] } => {
|
|
127
|
+
if (!isCheckableFile(fileName))
|
|
128
|
+
return { sourceFile: undefined, items: [] }
|
|
129
|
+
const { sourceFile, text } = readFileSource(prior, info.languageServiceHost, fileName)
|
|
130
|
+
if (text === undefined)
|
|
131
|
+
return { sourceFile, items: [] }
|
|
132
|
+
const projectVersion = typeof info.languageServiceHost.getProjectVersion === 'function'
|
|
133
|
+
? info.languageServiceHost.getProjectVersion()
|
|
134
|
+
: ''
|
|
135
|
+
const cached = cache.get(fileName)
|
|
136
|
+
if (cached !== undefined && cached.text === text && cached.projectVersion === projectVersion)
|
|
137
|
+
return { sourceFile, items: cached.items }
|
|
138
|
+
try {
|
|
139
|
+
const items = collectPrunelleDiagnostics(fileName, text, getOptions())
|
|
140
|
+
if (cache.size >= MAX_CACHE_ENTRIES) {
|
|
141
|
+
const oldest = cache.keys().next().value
|
|
142
|
+
if (oldest !== undefined)
|
|
143
|
+
cache.delete(oldest)
|
|
144
|
+
}
|
|
145
|
+
cache.set(fileName, { text, projectVersion, items })
|
|
146
|
+
return { sourceFile, items }
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
log(`analysis failed for ${fileName}: ${err instanceof Error ? err.message : String(err)}`)
|
|
150
|
+
return { sourceFile, items: [] }
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const proxy = Object.create(null) as ts.LanguageService
|
|
155
|
+
for (const key of Object.keys(prior) as (keyof ts.LanguageService)[]) {
|
|
156
|
+
const member = prior[key]
|
|
157
|
+
if (typeof member === 'function') {
|
|
158
|
+
;(proxy as unknown as Record<string, unknown>)[key] = (...args: unknown[]) =>
|
|
159
|
+
(member as (...a: unknown[]) => unknown).apply(prior, args)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
proxy.getSemanticDiagnostics = (fileName) => {
|
|
164
|
+
const base = prior.getSemanticDiagnostics(fileName)
|
|
165
|
+
const { sourceFile, items } = getItems(fileName)
|
|
166
|
+
if (items.length === 0)
|
|
167
|
+
return base
|
|
168
|
+
return [...base, ...items.map(item => toTsDiagnostic(tsLib, item, sourceFile))]
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
proxy.getCodeFixesAtPosition = (fileName, start, end, errorCodes, formatOptions, preferences) => {
|
|
172
|
+
const base = prior.getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences)
|
|
173
|
+
const { items } = getItems(fileName)
|
|
174
|
+
if (items.length === 0)
|
|
175
|
+
return base
|
|
176
|
+
const prunelleFixes = selectCodeFixes(fileName, items, start, end, errorCodes)
|
|
177
|
+
return prunelleFixes.length === 0 ? base : [...base, ...prunelleFixes]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return proxy
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function init(modules: { typescript: typeof ts }): ts.server.PluginModule {
|
|
184
|
+
const tsLib = modules.typescript
|
|
185
|
+
return {
|
|
186
|
+
create(info: ts.server.PluginCreateInfo): ts.LanguageService {
|
|
187
|
+
return createPrunellePlugin(tsLib, info)
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default init
|
|
193
|
+
export type { PrunelleDiagnosticItem, PrunellePluginOptions }
|
|
194
|
+
export { collectPrunelleDiagnostics, PRUNELLE_CODE, PRUNELLE_DIAG_SOURCE, PRUNELLE_FIXABLE_CODES }
|
|
@@ -4,7 +4,7 @@ A prunelle app. Read `node_modules/prunelle/llms.txt` before writing code: it ho
|
|
|
4
4
|
|
|
5
5
|
## Workflow
|
|
6
6
|
|
|
7
|
-
- **Verify changes**: run `bun run check` (`prunelle check` + TypeScript), `bun test` (in-process `testApp` from `prunelle/test` — no dev server needed), and `prunelle build --analyze` to inspect each route's JS weight and islands.
|
|
8
|
-
- **Discover, don't guess**: use plugin commands when installed — `prunelle icons-find <words>` for icon names, `prunelle i18n-check` for translation keys, and `prunelle mcp-footprint` for MCP tool token budgets.
|
|
7
|
+
- **Verify changes**: run `bun run check` (`prunelle check` + TypeScript), `prunelle render <url>` to inspect a rendered response without starting a dev server, `bun test` (in-process `testApp` from `prunelle/test` — no dev server needed), and `prunelle build --analyze` to inspect each route's JS weight and islands.
|
|
8
|
+
- **Discover, don't guess**: use `prunelle docs <words> [--json]` to search installed `llms.txt` files, `.mcp.json` (`prunelle mcp`) for MCP tooling, and plugin commands when installed — `prunelle icons-find <words>` for icon names, `prunelle i18n-check` for translation keys, and `prunelle mcp-footprint` for MCP tool token budgets.
|
|
9
9
|
|
|
10
10
|
@node_modules/prunelle/llms.txt
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
import { Head } from 'prunelle'
|
|
2
|
+
|
|
3
|
+
// French law (LCEN art. 1-1) asks every site for these details; `prunelle check` warns until every placeholder below is replaced.
|
|
4
|
+
// A private individual publishing without a business may give only the host's details, the host keeping their identity.
|
|
1
5
|
export default function LegalNotice() {
|
|
2
6
|
return (
|
|
3
7
|
<section>
|
|
8
|
+
<Head>
|
|
9
|
+
<title>Legal Notice</title>
|
|
10
|
+
</Head>
|
|
4
11
|
<h1>Legal Notice</h1>
|
|
5
|
-
<
|
|
12
|
+
<h2>Publisher</h2>
|
|
13
|
+
<p>__APP_NAME__ is published by [to fill in: your full name, or your company's name, legal form and share capital].</p>
|
|
14
|
+
<p>Address: [to fill in: your home address, or your company's registered office]</p>
|
|
15
|
+
<p>Phone: [to fill in] / Email: [to fill in]</p>
|
|
16
|
+
<p>Registration: [to fill in: RCS or RNE number and VAT number, or remove this line if you have none]</p>
|
|
17
|
+
<p>Publication director: [to fill in: full name]</p>
|
|
18
|
+
<h2>Host</h2>
|
|
19
|
+
<p>[to fill in: the host's name, address and phone number]</p>
|
|
6
20
|
</section>
|
|
7
21
|
)
|
|
8
22
|
}
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"prunelle": "__PRUNELLE_VERSION__",
|
|
14
14
|
"@prunellejs/auth": "__PRUNELLE_VERSION__",
|
|
15
|
+
"@prunellejs/mail": "__PRUNELLE_VERSION__",
|
|
15
16
|
"@prunellejs/ui": "__PRUNELLE_VERSION__"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@types/bun": "
|
|
19
|
+
"@types/bun": "^1.4.4",
|
|
19
20
|
"typescript": "^6.0.3"
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ui } from '@prunellejs/ui/plugin'
|
|
2
2
|
import { defineConfig } from 'prunelle/config'
|
|
3
3
|
import { auth } from './src/auth'
|
|
4
|
+
import { mail } from './src/mail'
|
|
4
5
|
|
|
5
6
|
export default defineConfig({
|
|
6
7
|
lang: 'en',
|
|
7
8
|
plugins: [
|
|
8
9
|
ui({ grammar: 'editorial' }),
|
|
10
|
+
mail,
|
|
9
11
|
auth,
|
|
10
12
|
],
|
|
11
13
|
})
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { join } from 'node:path'
|
|
2
1
|
import { createAuth } from '@prunellejs/auth'
|
|
3
2
|
import { sqliteAuthStore } from '@prunellejs/auth/sqlite'
|
|
3
|
+
import { mail } from './mail'
|
|
4
4
|
|
|
5
5
|
// Set AUTH_SECRET (at least 32 bytes) in production — see .env.example.
|
|
6
|
-
const defaultDb = import.meta.dir.startsWith('/$bunfs')
|
|
7
|
-
? './data/auth.sqlite'
|
|
8
|
-
: join(import.meta.dir, '../data/auth.sqlite')
|
|
9
|
-
|
|
10
6
|
export const auth = createAuth({
|
|
11
|
-
|
|
7
|
+
// A relative path lands under the app's folder, out of dist/.
|
|
8
|
+
store: sqliteAuthStore(process.env.AUTH_DB || 'data/auth.sqlite'),
|
|
12
9
|
secret: process.env.AUTH_SECRET || undefined,
|
|
13
10
|
defaultRedirect: '/dashboard',
|
|
11
|
+
mailer: mail,
|
|
14
12
|
})
|