mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Closes: https://linear.app/vercel/issue/DOC-4686/clean-up-routing-section Redirects: https://github.com/vercel/front/pull/47151 --------- Co-authored-by: Joseph <[email protected]> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
70 lines
1.5 KiB
JavaScript
70 lines
1.5 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const serverExternals = require('../packages/next/src/lib/server-external-packages.json')
|
|
|
|
function validate(docPath) {
|
|
const docContent = fs.readFileSync(
|
|
path.join(__dirname, '..', docPath),
|
|
'utf8'
|
|
)
|
|
|
|
const docPkgs = []
|
|
const extraPkgs = []
|
|
const missingPkgs = []
|
|
|
|
for (let docPkg of docContent
|
|
.split('opt-ed out:')
|
|
.pop()
|
|
.split('| Version')
|
|
.shift()
|
|
.split('\n')) {
|
|
docPkg = docPkg.split('`')[1]
|
|
|
|
if (!docPkg) {
|
|
continue
|
|
}
|
|
docPkgs.push(docPkg)
|
|
|
|
if (!serverExternals.includes(docPkg)) {
|
|
extraPkgs.push(docPkg)
|
|
}
|
|
}
|
|
|
|
for (const pkg of serverExternals) {
|
|
if (!docPkgs.includes(pkg)) {
|
|
missingPkgs.push(pkg)
|
|
}
|
|
}
|
|
|
|
if (extraPkgs.length || missingPkgs.length) {
|
|
console.log(
|
|
'server externals doc out of sync!\n' +
|
|
`Extra packages included: ` +
|
|
JSON.stringify(extraPkgs, null, 2) +
|
|
'\n' +
|
|
`Missing packages: ` +
|
|
JSON.stringify(missingPkgs, null, 2) +
|
|
'\n' +
|
|
`doc path: ${docPath}`
|
|
)
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
const appRouterValid = validate(
|
|
`docs/01-app/03-api-reference/05-config/01-next-config-js/serverExternalPackages.mdx`
|
|
)
|
|
const pagesRouterValid = validate(
|
|
`docs/02-pages/04-api-reference/04-config/01-next-config-js/serverExternalPackages.mdx`
|
|
)
|
|
|
|
if (appRouterValid && pagesRouterValid) {
|
|
console.log('server externals doc is in sync')
|
|
process.exit(0)
|
|
} else {
|
|
process.exit(1)
|
|
}
|