UNPKG

@mintlify/prebuild

Version:

Helpful functions for Mintlify's prebuild step

42 lines (41 loc) 1.73 kB
import { getConfigPath, getMintIgnore } from '../utils.js'; import { categorizeFilePaths } from './categorizeFilePaths.js'; import { update } from './update/index.js'; import { clearWarnings, checkStrictMode } from './warnings.js'; export const prebuild = async (contentDirectoryPath, { localSchema, groups, disableOpenApi, strict, } = {}) => { if (process.env.IS_MULTI_TENANT === 'true') { console.log('Skipping prebuild in multi-tenant mode.'); return; } // Clear any warnings from previous runs clearWarnings(); const docsConfigPath = await getConfigPath(contentDirectoryPath, 'docs'); const mintConfigPath = await getConfigPath(contentDirectoryPath, 'mint'); if (mintConfigPath == null && docsConfigPath == null) { throw Error('must be run in a directory where a docs.json file exists.'); } const mintIgnore = await getMintIgnore(contentDirectoryPath); const { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2, fileImportsMap, } = await categorizeFilePaths(contentDirectoryPath, mintIgnore, disableOpenApi); await update({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames: snippetsV2, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, strict, }); // In strict mode, fail if there were any warnings checkStrictMode(strict); return { fileImportsMap }; }; export * from './categorizeFilePaths.js'; export * from '../createPage/index.js'; export * from '../createPage/preparseMdx/index.js'; export * from './update/index.js';