@mintlify/prebuild 1.0.834 → 1.0.840
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/dist/generate.js +5 -2
- package/dist/prebuild/categorizeFilePaths.js +5 -1
- package/dist/prebuild/index.js +5 -0
- package/dist/prebuild/update/resolveImportsAndWriteFiles.js +3 -0
- package/dist/prebuild/warnings.d.ts +7 -0
- package/dist/prebuild/warnings.js +14 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -6
package/dist/generate.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { slugToTitle, optionallyAddLeadingSlash, removeLeadingSlash, optionallyRemoveTrailingSlash, } from '@mintlify/common';
|
|
2
2
|
import { divisions, } from '@mintlify/validation';
|
|
3
|
-
import
|
|
3
|
+
import { addWarning } from './prebuild/warnings.js';
|
|
4
4
|
const handleUnknownPage = (page, type) => {
|
|
5
|
-
|
|
5
|
+
addWarning({
|
|
6
|
+
type: 'missing-nav-page',
|
|
7
|
+
message: `"${page}" is referenced in the ${type}.json navigation but the file does not exist.`,
|
|
8
|
+
});
|
|
6
9
|
return {
|
|
7
10
|
title: slugToTitle(page),
|
|
8
11
|
href: optionallyAddLeadingSlash(page),
|
|
@@ -5,6 +5,7 @@ import * as path from 'path';
|
|
|
5
5
|
import { formatError } from '../errorMessages/formatError.js';
|
|
6
6
|
import { getFileList } from '../fs/index.js';
|
|
7
7
|
import { getFileExtension } from '../utils.js';
|
|
8
|
+
import { addWarning } from './warnings.js';
|
|
8
9
|
export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [], disableOpenApi) => {
|
|
9
10
|
const allFiles = getFileList(contentDirectoryPath, contentDirectoryPath, mintIgnore);
|
|
10
11
|
const mdxFiles = [];
|
|
@@ -72,7 +73,10 @@ export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [],
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
catch (error) {
|
|
75
|
-
|
|
76
|
+
addWarning({
|
|
77
|
+
type: 'openapi',
|
|
78
|
+
message: `Error validating OpenAPI file ${filename}: ${error}`,
|
|
79
|
+
});
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
if (isAsyncApi) {
|
package/dist/prebuild/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { getConfigPath, getMintIgnore } from '../utils.js';
|
|
2
2
|
import { categorizeFilePaths } from './categorizeFilePaths.js';
|
|
3
3
|
import { update } from './update/index.js';
|
|
4
|
+
import { clearWarnings, checkStrictMode } from './warnings.js';
|
|
4
5
|
export const prebuild = async (contentDirectoryPath, { localSchema, groups, disableOpenApi, strict, } = {}) => {
|
|
5
6
|
if (process.env.IS_MULTI_TENANT === 'true') {
|
|
6
7
|
console.log('Skipping prebuild in multi-tenant mode.');
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
10
|
+
// Clear any warnings from previous runs
|
|
11
|
+
clearWarnings();
|
|
9
12
|
const docsConfigPath = await getConfigPath(contentDirectoryPath, 'docs');
|
|
10
13
|
const mintConfigPath = await getConfigPath(contentDirectoryPath, 'mint');
|
|
11
14
|
if (mintConfigPath == null && docsConfigPath == null) {
|
|
@@ -28,6 +31,8 @@ export const prebuild = async (contentDirectoryPath, { localSchema, groups, disa
|
|
|
28
31
|
disableOpenApi,
|
|
29
32
|
strict,
|
|
30
33
|
});
|
|
34
|
+
// In strict mode, fail if there were any warnings
|
|
35
|
+
checkStrictMode(strict);
|
|
31
36
|
return { fileImportsMap };
|
|
32
37
|
};
|
|
33
38
|
export * from './categorizeFilePaths.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveAllImports, hasImports, findAndRemoveImports, getDecoratedNavPageAndSlug, topologicalSort, stringifyTree, } from '@mintlify/common';
|
|
2
2
|
import { outputFile } from 'fs-extra';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
+
import { addWarning } from '../warnings.js';
|
|
4
5
|
export const resolveImportsAndWriteFiles = async ({ openApiFiles, asyncApiFiles, pagesAcc, snippetsV2, filesWithImports, }) => {
|
|
5
6
|
const snippetsWithResolvedImports = await resolveImportsInSnippets(snippetsV2);
|
|
6
7
|
const writeSnippetsWithImportsPromises = await writeSnippets(snippetsWithResolvedImports);
|
|
@@ -35,6 +36,7 @@ const resolveImportsInSnippets = async (snippetsV2) => {
|
|
|
35
36
|
snippetWithImports.tree = await resolveAllImports({
|
|
36
37
|
snippets: orderedSnippetsWithImports,
|
|
37
38
|
fileWithImports: snippetWithImports,
|
|
39
|
+
onWarning: addWarning,
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -51,6 +53,7 @@ const resolveImportsInPages = async ({ openApiFiles, asyncApiFiles, snippetsWith
|
|
|
51
53
|
const tree = await resolveAllImports({
|
|
52
54
|
snippets: snippetsWithResolvedImports,
|
|
53
55
|
fileWithImports,
|
|
56
|
+
onWarning: addWarning,
|
|
54
57
|
});
|
|
55
58
|
const contentStr = stringifyTree(tree);
|
|
56
59
|
const { slug, pageMetadata } = getDecoratedNavPageAndSlug(fileWithImports.filename, contentStr, openApiFiles, asyncApiFiles);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Warning = {
|
|
2
|
+
type: 'missing-file' | 'missing-nav-page' | 'openapi' | 'invalid-import-path' | 'import-resolution-error';
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const clearWarnings: () => void;
|
|
6
|
+
export declare const addWarning: (warning: Warning) => void;
|
|
7
|
+
export declare const checkStrictMode: (strict?: boolean) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
let warnings = [];
|
|
3
|
+
export const clearWarnings = () => {
|
|
4
|
+
warnings = [];
|
|
5
|
+
};
|
|
6
|
+
export const addWarning = (warning) => {
|
|
7
|
+
warnings.push(warning);
|
|
8
|
+
console.log(chalk.yellow.bold('warning') + ' - ' + warning.message);
|
|
9
|
+
};
|
|
10
|
+
export const checkStrictMode = (strict) => {
|
|
11
|
+
if (strict && warnings.length > 0) {
|
|
12
|
+
throw new Error(`Build validation failed with ${warnings.length} warning(s). See above for details.`);
|
|
13
|
+
}
|
|
14
|
+
};
|