boltdocs 2.5.4 → 2.5.6
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/bin/boltdocs.js +1 -1
- package/dist/cache-Cr8W2zgZ.cjs +6 -0
- package/dist/cache-DFdakSmR.mjs +6 -0
- package/dist/client/index.d.mts +1276 -861
- package/dist/client/index.d.ts +1276 -861
- package/dist/client/index.js +6 -1
- package/dist/client/index.mjs +6 -1
- package/dist/client/ssr.cjs +6 -0
- package/dist/client/ssr.d.cts +80 -0
- package/dist/client/ssr.d.mts +63 -61
- package/dist/client/ssr.mjs +6 -1
- package/dist/client/theme/neutral.css +388 -0
- package/dist/node/cli-entry.cjs +8 -0
- package/dist/node/cli-entry.d.cts +2 -0
- package/dist/node/cli-entry.d.mts +2 -1
- package/dist/node/cli-entry.mjs +7 -5
- package/dist/node/index.cjs +6 -0
- package/dist/node/index.d.cts +574 -0
- package/dist/node/index.d.mts +385 -378
- package/dist/node/index.mjs +6 -1
- package/dist/node-CWXme96p.mjs +73 -0
- package/dist/node-VYfhzGrh.cjs +73 -0
- package/dist/package-BY8Jd2j4.cjs +6 -0
- package/dist/package-OFZf0s2j.mjs +6 -0
- package/dist/search-dialog-BeNyI_KQ.mjs +6 -0
- package/dist/search-dialog-dYsCAk5S.js +6 -0
- package/dist/use-search-D25n0PrV.mjs +6 -0
- package/dist/use-search-WuzdH1cJ.js +6 -0
- package/package.json +16 -12
- package/src/client/app/index.tsx +15 -12
- package/src/client/components/default-layout.tsx +21 -19
- package/src/client/hooks/use-i18n.ts +1 -1
- package/src/client/hooks/use-routes.ts +1 -1
- package/src/client/hooks/use-version.ts +1 -1
- package/src/client/store/boltdocs-context.tsx +119 -0
- package/CHANGELOG.md +0 -92
- package/dist/cache-3FOEPC2P.mjs +0 -1
- package/dist/chunk-IMEKU5U3.mjs +0 -75
- package/dist/chunk-J2PTDWZM.mjs +0 -1
- package/dist/chunk-TP5KMRD3.mjs +0 -1
- package/dist/chunk-Y4RE5KI7.mjs +0 -1
- package/dist/client/ssr.d.ts +0 -78
- package/dist/client/ssr.js +0 -1
- package/dist/node/cli-entry.d.ts +0 -1
- package/dist/node/cli-entry.js +0 -80
- package/dist/node/index.d.ts +0 -567
- package/dist/node/index.js +0 -75
- package/dist/package-KCTE4HFV.mjs +0 -1
- package/dist/search-dialog-O6VLVSOA.mjs +0 -1
- package/src/client/store/use-boltdocs-store.ts +0 -44
- package/src/node/cache.ts +0 -408
- package/src/node/cli/build.ts +0 -53
- package/src/node/cli/dev.ts +0 -22
- package/src/node/cli/doctor.ts +0 -243
- package/src/node/cli/index.ts +0 -9
- package/src/node/cli/ui.ts +0 -54
- package/src/node/cli-entry.ts +0 -24
- package/src/node/config.ts +0 -382
- package/src/node/errors.ts +0 -44
- package/src/node/index.ts +0 -84
- package/src/node/mdx/cache.ts +0 -12
- package/src/node/mdx/highlighter.ts +0 -47
- package/src/node/mdx/index.ts +0 -122
- package/src/node/mdx/rehype-shiki.ts +0 -62
- package/src/node/mdx/remark-code-meta.ts +0 -35
- package/src/node/mdx/remark-shiki.ts +0 -61
- package/src/node/plugin/entry.ts +0 -87
- package/src/node/plugin/html.ts +0 -99
- package/src/node/plugin/index.ts +0 -464
- package/src/node/plugin/types.ts +0 -9
- package/src/node/plugins/index.ts +0 -17
- package/src/node/plugins/plugin-errors.ts +0 -62
- package/src/node/plugins/plugin-lifecycle.ts +0 -117
- package/src/node/plugins/plugin-sandbox.ts +0 -59
- package/src/node/plugins/plugin-store.ts +0 -54
- package/src/node/plugins/plugin-types.ts +0 -107
- package/src/node/plugins/plugin-validator.ts +0 -105
- package/src/node/routes/cache.ts +0 -28
- package/src/node/routes/index.ts +0 -293
- package/src/node/routes/parser.ts +0 -262
- package/src/node/routes/sorter.ts +0 -42
- package/src/node/routes/types.ts +0 -61
- package/src/node/schema/config.ts +0 -195
- package/src/node/schema/frontmatter.ts +0 -17
- package/src/node/search/index.ts +0 -55
- package/src/node/security/constants/index.ts +0 -10
- package/src/node/security/csp.ts +0 -31
- package/src/node/security/headers.ts +0 -27
- package/src/node/ssg/index.ts +0 -205
- package/src/node/ssg/meta.ts +0 -33
- package/src/node/ssg/options.ts +0 -15
- package/src/node/ssg/robots.ts +0 -53
- package/src/node/ssg/sitemap.ts +0 -55
- package/src/node/utils.ts +0 -349
- package/tsconfig.json +0 -26
- package/tsup.config.ts +0 -56
package/src/node/cli/doctor.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import fastGlob from 'fast-glob'
|
|
4
|
-
import { resolveConfig } from '../config'
|
|
5
|
-
import { parseFrontmatter, normalizePath } from '../utils'
|
|
6
|
-
import * as ui from './ui'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Interface representing a documentation hygiene issue.
|
|
10
|
-
*/
|
|
11
|
-
interface Issue {
|
|
12
|
-
level: 'high' | 'warning' | 'low'
|
|
13
|
-
message: string
|
|
14
|
-
suggestion?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Logic for the `boltdocs doctor` command.
|
|
19
|
-
* Scans the documentation directory for broken links, missing frontmatter,
|
|
20
|
-
* and orphaned translations.
|
|
21
|
-
*
|
|
22
|
-
* @param root - The project root directory
|
|
23
|
-
*/
|
|
24
|
-
export async function doctorAction(root: string = process.cwd()) {
|
|
25
|
-
const { colors } = ui
|
|
26
|
-
ui.info(
|
|
27
|
-
`${colors.bold}Running documentation health check...${colors.reset}\n`,
|
|
28
|
-
)
|
|
29
|
-
const start = performance.now()
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const config = await resolveConfig('docs', root)
|
|
33
|
-
const docsDir = path.resolve(root, 'docs')
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(docsDir)) {
|
|
36
|
-
ui.error(`Documentation directory not found at ${docsDir}`)
|
|
37
|
-
process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const files = await fastGlob(['**/*.md', '**/*.mdx'], {
|
|
41
|
-
cwd: docsDir,
|
|
42
|
-
absolute: true,
|
|
43
|
-
suppressErrors: true,
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
let highCount = 0
|
|
47
|
-
let warningCount = 0
|
|
48
|
-
let lowCount = 0
|
|
49
|
-
const issuesMap = new Map<string, Issue[]>()
|
|
50
|
-
|
|
51
|
-
const addIssue = (file: string, issue: Issue) => {
|
|
52
|
-
const relPath = path.relative(docsDir, file)
|
|
53
|
-
let issues = issuesMap.get(relPath)
|
|
54
|
-
if (!issues) {
|
|
55
|
-
issues = []
|
|
56
|
-
issuesMap.set(relPath, issues)
|
|
57
|
-
}
|
|
58
|
-
issues.push(issue)
|
|
59
|
-
if (issue.level === 'high') highCount++
|
|
60
|
-
else if (issue.level === 'warning') warningCount++
|
|
61
|
-
else if (issue.level === 'low') lowCount++
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const basePath = '/docs'
|
|
65
|
-
|
|
66
|
-
// 1. Scan for Frontmatter, Links, and Content Issues
|
|
67
|
-
for (const file of files) {
|
|
68
|
-
const { data, content } = parseFrontmatter(file)
|
|
69
|
-
|
|
70
|
-
// Frontmatter Validation
|
|
71
|
-
if (!data.title) {
|
|
72
|
-
addIssue(file, {
|
|
73
|
-
level: 'warning',
|
|
74
|
-
message: 'Missing "title" in frontmatter.',
|
|
75
|
-
suggestion:
|
|
76
|
-
'Add `title: Your Title` to the YAML frontmatter at the top of the file.',
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!data.description) {
|
|
81
|
-
addIssue(file, {
|
|
82
|
-
level: 'low',
|
|
83
|
-
message: 'Missing "description" in frontmatter.',
|
|
84
|
-
suggestion:
|
|
85
|
-
'Adding a description helps with SEO and search previews.',
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Link Validation
|
|
90
|
-
const linkRegex = /\[.*?\]\((.*?)\)/g
|
|
91
|
-
const htmlLinkRegex = /<a\s+[^>]*href=["']([^"']+)["'][^>]*>/g
|
|
92
|
-
const links = [
|
|
93
|
-
...content.matchAll(linkRegex),
|
|
94
|
-
...content.matchAll(htmlLinkRegex),
|
|
95
|
-
]
|
|
96
|
-
|
|
97
|
-
for (const match of links) {
|
|
98
|
-
let link = match[1]
|
|
99
|
-
if (
|
|
100
|
-
!link ||
|
|
101
|
-
link.startsWith('http') ||
|
|
102
|
-
link.startsWith('https') ||
|
|
103
|
-
link.startsWith('#') ||
|
|
104
|
-
link.startsWith('mailto:') ||
|
|
105
|
-
link.startsWith('tel:')
|
|
106
|
-
) {
|
|
107
|
-
continue
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
link = link.split('#')[0]
|
|
111
|
-
if (!link) continue
|
|
112
|
-
|
|
113
|
-
let targetPath: string
|
|
114
|
-
if (link.startsWith('/')) {
|
|
115
|
-
let pathAfterBase = link
|
|
116
|
-
if (link.startsWith(basePath + '/') || link === basePath) {
|
|
117
|
-
pathAfterBase = link.substring(basePath.length)
|
|
118
|
-
}
|
|
119
|
-
targetPath = path.join(docsDir, pathAfterBase)
|
|
120
|
-
} else {
|
|
121
|
-
targetPath = path.resolve(path.dirname(file), link)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const extensions = ['', '.md', '.mdx', '/index.md', '/index.mdx']
|
|
125
|
-
let exists = false
|
|
126
|
-
for (const ext of extensions) {
|
|
127
|
-
const finalPath = targetPath + ext
|
|
128
|
-
if (fs.existsSync(finalPath) && fs.statSync(finalPath).isFile()) {
|
|
129
|
-
exists = true
|
|
130
|
-
break
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!exists) {
|
|
135
|
-
addIssue(file, {
|
|
136
|
-
level: 'high',
|
|
137
|
-
message: `Broken internal link: "${link}"`,
|
|
138
|
-
suggestion: `Ensure the file exists at "${targetPath}". If it's a directory, ensure it has an "index.md" or "index.mdx".`,
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// 2. Scan for Orphaned Translations
|
|
145
|
-
if (config.i18n) {
|
|
146
|
-
const { defaultLocale, locales } = config.i18n
|
|
147
|
-
const otherLocales = Object.keys(locales).filter(
|
|
148
|
-
(l) => l !== defaultLocale,
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
for (const file of files) {
|
|
152
|
-
const relPath = normalizePath(path.relative(docsDir, file))
|
|
153
|
-
const parts = relPath.split('/')
|
|
154
|
-
|
|
155
|
-
if (parts[0] === defaultLocale) {
|
|
156
|
-
const pathAfterLocale = parts.slice(1).join('/')
|
|
157
|
-
for (const locale of otherLocales) {
|
|
158
|
-
const localeParts = [locale, ...parts.slice(1)]
|
|
159
|
-
const targetLocaleFile = path.join(docsDir, ...localeParts)
|
|
160
|
-
|
|
161
|
-
if (!fs.existsSync(targetLocaleFile)) {
|
|
162
|
-
addIssue(file, {
|
|
163
|
-
level: 'warning',
|
|
164
|
-
message: `Missing translation for locale "${locale}"`,
|
|
165
|
-
suggestion: `Create a translated version of this file at "${locale}/${pathAfterLocale}".`,
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Final Reporting
|
|
174
|
-
if (issuesMap.size === 0) {
|
|
175
|
-
ui.success('All documentation files are healthy!\n')
|
|
176
|
-
} else {
|
|
177
|
-
for (const [file, issues] of issuesMap.entries()) {
|
|
178
|
-
console.log(`📄 ${colors.bold}${file}${colors.reset}`)
|
|
179
|
-
|
|
180
|
-
const sortedIssues = issues.sort((a, b) => {
|
|
181
|
-
const order = { high: 1, warning: 2, low: 3 }
|
|
182
|
-
return order[a.level] - order[b.level]
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
for (const issue of sortedIssues) {
|
|
186
|
-
let prefix = ''
|
|
187
|
-
let color = ''
|
|
188
|
-
if (issue.level === 'high') {
|
|
189
|
-
prefix = '❌'
|
|
190
|
-
color = colors.red
|
|
191
|
-
} else if (issue.level === 'warning') {
|
|
192
|
-
prefix = '⚠️'
|
|
193
|
-
color = colors.yellow
|
|
194
|
-
} else {
|
|
195
|
-
prefix = 'ℹ️'
|
|
196
|
-
color = colors.cyan
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
console.log(
|
|
200
|
-
` ${color}${prefix} ${issue.level.toUpperCase()}:${colors.reset} ${issue.message}`,
|
|
201
|
-
)
|
|
202
|
-
if (issue.suggestion) {
|
|
203
|
-
console.log(
|
|
204
|
-
` ${colors.gray}💡 Suggestion: ${issue.suggestion}${colors.reset}`,
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
console.log('')
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
console.log(`${colors.bold}Summary:${colors.reset}`)
|
|
212
|
-
console.log(
|
|
213
|
-
` ${colors.red}${highCount} high-level errors${colors.reset}`,
|
|
214
|
-
)
|
|
215
|
-
console.log(` ${colors.yellow}${warningCount} warnings${colors.reset}`)
|
|
216
|
-
console.log(
|
|
217
|
-
` ${colors.cyan}${lowCount} minor improvements${colors.reset}\n`,
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
if (highCount > 0) {
|
|
221
|
-
ui.error(
|
|
222
|
-
'HIGH ERROR: Fix these to ensure your documentation builds correctly.',
|
|
223
|
-
)
|
|
224
|
-
}
|
|
225
|
-
if (warningCount > 0 || lowCount > 0) {
|
|
226
|
-
ui.info(
|
|
227
|
-
'TIP: Address warnings and suggestions for premium quality docs.',
|
|
228
|
-
)
|
|
229
|
-
}
|
|
230
|
-
console.log('')
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const duration = performance.now() - start
|
|
234
|
-
ui.info(`Finished in ${duration.toFixed(2)}ms\n`)
|
|
235
|
-
|
|
236
|
-
if (highCount > 0) {
|
|
237
|
-
process.exit(1)
|
|
238
|
-
}
|
|
239
|
-
} catch (e) {
|
|
240
|
-
ui.error('Failed to run doctor check:', e)
|
|
241
|
-
process.exit(1)
|
|
242
|
-
}
|
|
243
|
-
}
|
package/src/node/cli/index.ts
DELETED
package/src/node/cli/ui.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ANSI Escape sequences for terminal coloring and styling.
|
|
3
|
-
* Used to provide a premium and consistent CLI experience.
|
|
4
|
-
*/
|
|
5
|
-
export const colors = {
|
|
6
|
-
reset: '\x1b[0m',
|
|
7
|
-
bold: '\x1b[1m',
|
|
8
|
-
red: '\x1b[31m',
|
|
9
|
-
green: '\x1b[32m',
|
|
10
|
-
yellow: '\x1b[33m',
|
|
11
|
-
blue: '\x1b[34m',
|
|
12
|
-
cyan: '\x1b[36m',
|
|
13
|
-
gray: '\x1b[90m',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Formats a message with the boltdocs prefix and provided styling.
|
|
18
|
-
*
|
|
19
|
-
* @param message - The content to log
|
|
20
|
-
* @param style - Optional ANSI style prefix
|
|
21
|
-
* @returns The formatted string
|
|
22
|
-
*/
|
|
23
|
-
export function formatLog(message: string, style: string = ''): string {
|
|
24
|
-
return `${style}${colors.bold}[boltdocs]${colors.reset} ${message}${colors.reset}`
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Logs a standard informational message to the console.
|
|
29
|
-
*
|
|
30
|
-
* @param message - The message to display
|
|
31
|
-
*/
|
|
32
|
-
export function info(message: string) {
|
|
33
|
-
console.log(formatLog(message))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Logs an error message to the console with red styling.
|
|
38
|
-
*
|
|
39
|
-
* @param message - The error description
|
|
40
|
-
* @param error - Optional error object for stack tracing
|
|
41
|
-
*/
|
|
42
|
-
export function error(message: string, error?: any) {
|
|
43
|
-
console.error(formatLog(message, colors.red))
|
|
44
|
-
if (error) console.error(error)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Logs a success message to the console with green styling.
|
|
49
|
-
*
|
|
50
|
-
* @param message - The success description
|
|
51
|
-
*/
|
|
52
|
-
export function success(message: string) {
|
|
53
|
-
console.log(formatLog(message, colors.green))
|
|
54
|
-
}
|
package/src/node/cli-entry.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import cac from 'cac'
|
|
3
|
-
import {
|
|
4
|
-
devAction,
|
|
5
|
-
buildAction,
|
|
6
|
-
previewAction,
|
|
7
|
-
doctorAction,
|
|
8
|
-
} from './cli/index'
|
|
9
|
-
|
|
10
|
-
const cli = cac('boltdocs')
|
|
11
|
-
|
|
12
|
-
cli.command('[root]', 'Start development server').alias('dev').action(devAction)
|
|
13
|
-
|
|
14
|
-
cli.command('build [root]', 'Build for production').action(buildAction)
|
|
15
|
-
|
|
16
|
-
cli.command('preview [root]', 'Preview production build').action(previewAction)
|
|
17
|
-
|
|
18
|
-
cli.command('doctor [root]', 'Check documentation health').action(doctorAction)
|
|
19
|
-
|
|
20
|
-
cli.help()
|
|
21
|
-
// This will be replaced at build time or package publishing, but hardcoded to 2.0.0 for now
|
|
22
|
-
cli.version('2.0.0')
|
|
23
|
-
|
|
24
|
-
cli.parse()
|