import path from 'node:path' import process from 'node:process' import picocolors from 'picocolors' import { base, hostname, isMirror, productionHostname, } from '../docs/.vuepress/configs/deployment.js' import { checkDeployment } from './docsDeployment.js' // Fail when the docs build cannot be served from where it is deployed. // // Runs after `docs:build`, with the base and the origin read from the `BASE` // and `SITE_HOSTNAME` environment variables, so the GitHub Pages workflow // checks its own sub path build. const DIST = path.resolve(import.meta.dirname, '../docs/.vuepress/dist') const errors = await checkDeployment({ base, canonicalHostname: productionHostname, dist: DIST, hostname, indexable: !isMirror, }) if (errors.length > 0) { console.error( picocolors.red(`${errors.length} deployment problem(s) in ${DIST}:`), ) for (const error of errors) console.error(` ${error}`) console.error( picocolors.red(`The build is not deployable at ${hostname}${base}`), ) process.exitCode = 1 } else { console.log(picocolors.green(`The build is deployable at ${hostname}${base}`)) }