Skip to content

Commit 7a290fc

Browse files
committed
fix(ci): repair clean-install validation
1 parent 38e093e commit 7a290fc

25 files changed

Lines changed: 310 additions & 510 deletions

File tree

docs/app/components/DocsFeatures.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
interface Feature { title: string, description: string, href?: string }
33
44
const props = defineProps<{ features: Feature[] }>()
5+
const INLINE_CODE_RE = /`([^`]+)`/g
56
67
const patternId = useId()
78
@@ -10,7 +11,7 @@ function getGridSize(index: number) {
1011
}
1112
1213
function renderDescription(desc: string) {
13-
return desc.replace(/`([^`]+)`/g, '<code class="font-mono text-xs bg-black/5 dark:bg-white/10 px-1 py-0.5 rounded">$1</code>')
14+
return desc.replace(INLINE_CODE_RE, '<code class="font-mono text-xs bg-black/5 dark:bg-white/10 px-1 py-0.5 rounded">$1</code>')
1415
}
1516
</script>
1617

docs/server/api/better-auth/client-plugins.get.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
const DOCS_PLUGIN_RE = /\/docs\/plugins\/([a-z0-9-]+)(?=["\\])/g
2+
const CLIENT_EXPORT_RE = /export\s+(?:declare\s+)?(?:const|function)\s+(\w+)/g
3+
const CLIENT_SUFFIX_RE = /Client$/
4+
const CAMEL_TO_KEBAB_BOUNDARY_RE = /([a-z0-9])([A-Z])/g
5+
const CAMEL_TO_KEBAB_ACRONYM_RE = /([A-Z]+)([A-Z][a-z0-9]+)/g
6+
17
export default defineEventHandler(async () => {
28
const baseDocsUrl = 'https://www.better-auth.com/docs'
39

410
const html = await fetch(`${baseDocsUrl}/introduction`).then(r => r.text())
511

612
const pluginSlugs = new Set<string>()
7-
const pluginRe = /\/docs\/plugins\/([a-z0-9-]+)(?=["\\])/g
8-
for (const pluginMatch of html.matchAll(pluginRe)) {
13+
for (const pluginMatch of html.matchAll(DOCS_PLUGIN_RE)) {
914
if (pluginMatch[1])
1015
pluginSlugs.add(pluginMatch[1])
1116
}
@@ -14,25 +19,24 @@ export default defineEventHandler(async () => {
1419
const dts = await fetch(clientDtsUrl).then(r => r.text())
1520

1621
const exportNames = new Set<string>()
17-
const exportRe = /export\s+(?:declare\s+)?(?:const|function)\s+(\w+)/g
18-
for (const exportMatch of dts.matchAll(exportRe)) {
22+
for (const exportMatch of dts.matchAll(CLIENT_EXPORT_RE)) {
1923
const name = exportMatch[1]
2024
if (name)
2125
exportNames.add(name)
2226
}
2327

2428
const clientPluginNames = Array.from(exportNames)
25-
.filter(name => name.endsWith('Client'))
29+
.filter(name => CLIENT_SUFFIX_RE.test(name))
2630
.sort((a, b) => a.localeCompare(b))
2731

2832
const camelToKebab = (input: string) =>
2933
input
30-
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
31-
.replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, '$1-$2')
34+
.replace(CAMEL_TO_KEBAB_BOUNDARY_RE, '$1-$2')
35+
.replace(CAMEL_TO_KEBAB_ACRONYM_RE, '$1-$2')
3236
.toLowerCase()
3337

3438
const toSlug = (clientExport: string) => {
35-
const base = clientExport.replace(/Client$/, '')
39+
const base = clientExport.replace(CLIENT_SUFFIX_RE, '')
3640
const candidate = camelToKebab(base)
3741
const overrides: Record<string, string> = {
3842
'two-factor': '2fa',

docs/server/api/better-auth/plugins.get.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1+
const WORD_SEPARATOR_RE = /[-_]+/g
2+
const WORD_INITIAL_RE = /\b\w/g
3+
const OAUTH_RE = /\bOauth\b/g
4+
const OIDC_RE = /\bOidc\b/g
5+
const API_RE = /\bApi\b/g
6+
const DOCS_PLUGIN_RE = /\/docs\/plugins\/([a-z0-9-]+)(?=["\\])/g
7+
18
export default defineEventHandler(async () => {
29
const baseDocsUrl = 'https://www.better-auth.com/docs'
310

411
const titleCase = (slug: string) =>
512
slug
6-
.replace(/[-_]+/g, ' ')
7-
.replace(/\b\w/g, c => c.toUpperCase())
8-
.replace(/\bOauth\b/g, 'OAuth')
9-
.replace(/\bOidc\b/g, 'OIDC')
10-
.replace(/\bApi\b/g, 'API')
13+
.replace(WORD_SEPARATOR_RE, ' ')
14+
.replace(WORD_INITIAL_RE, c => c.toUpperCase())
15+
.replace(OAUTH_RE, 'OAuth')
16+
.replace(OIDC_RE, 'OIDC')
17+
.replace(API_RE, 'API')
1118

1219
const html = await fetch(`${baseDocsUrl}/introduction`).then(r => r.text())
1320

1421
const slugs = new Set<string>()
15-
const re = /\/docs\/plugins\/([a-z0-9-]+)(?=["\\])/g
16-
for (const match of html.matchAll(re)) {
22+
for (const match of html.matchAll(DOCS_PLUGIN_RE)) {
1723
const slug = match[1]
1824
if (!slug)
1925
continue

docs/server/api/better-auth/providers.get.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
const WORD_SEPARATOR_RE = /[-_]+/g
2+
const WORD_INITIAL_RE = /\b\w/g
3+
const AUTHENTICATION_DOCS_RE = /\/docs\/authentication\/([a-z0-9-]+)(?=["\\])/g
4+
15
export default defineEventHandler(async () => {
26
const baseDocsUrl = 'https://www.better-auth.com/docs'
37

48
const titleCase = (id: string) =>
59
id
6-
.replace(/[-_]+/g, ' ')
7-
.replace(/\b\w/g, c => c.toUpperCase())
10+
.replace(WORD_SEPARATOR_RE, ' ')
11+
.replace(WORD_INITIAL_RE, c => c.toUpperCase())
812

913
const html = await fetch(`${baseDocsUrl}/introduction`).then(r => r.text())
1014

1115
const ids = new Set<string>()
12-
const re = /\/docs\/authentication\/([a-z0-9-]+)(?=["\\])/g
13-
for (const match of html.matchAll(re)) {
16+
for (const match of html.matchAll(AUTHENTICATION_DOCS_RE)) {
1417
const id = match[1]
1518
if (!id || id === 'oauth' || id === 'other-social-providers')
1619
continue

playground/app/pages/two-factor/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
definePageMeta({ layout: 'auth' })
33
4+
const DIGITS_ONLY_RE = /^\d+$/
5+
46
const { client } = useUserSession()
57
const toast = useToast()
68
@@ -14,7 +16,7 @@ const code = ref('')
1416
const loading = ref(false)
1517
1618
async function handleVerify() {
17-
if (code.value.length !== 6 || !/^\d+$/.test(code.value)) {
19+
if (code.value.length !== 6 || !DIGITS_ONLY_RE.test(code.value)) {
1820
toast.add({ title: 'Error', description: 'TOTP code must be 6 digits', color: 'error' })
1921
return
2022
}

0 commit comments

Comments
 (0)