@mintlify/prebuild 1.0.833 → 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 CHANGED
@@ -1,8 +1,11 @@
1
1
  import { slugToTitle, optionallyAddLeadingSlash, removeLeadingSlash, optionallyRemoveTrailingSlash, } from '@mintlify/common';
2
2
  import { divisions, } from '@mintlify/validation';
3
- import chalk from 'chalk';
3
+ import { addWarning } from './prebuild/warnings.js';
4
4
  const handleUnknownPage = (page, type) => {
5
- console.log(`${chalk.yellow.bold('warning')} - "${page}" is referenced in the ${type}.json navigation but the file does not exist.`);
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
- console.error(`Error validating OpenAPI file ${filename}: ${error}`);
76
+ addWarning({
77
+ type: 'openapi',
78
+ message: `Error validating OpenAPI file ${filename}: ${error}`,
79
+ });
76
80
  }
77
81
  }
78
82
  if (isAsyncApi) {
@@ -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';
@@ -224,9 +224,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
224
224
  frontchat?: {
225
225
  snippetId: string;
226
226
  } | undefined;
227
- osano?: {
228
- scriptSource: string;
229
- } | undefined;
230
227
  telemetry?: {
231
228
  enabled?: boolean | undefined;
232
229
  } | undefined;
@@ -549,9 +546,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
549
546
  frontchat?: {
550
547
  snippetId: string;
551
548
  } | undefined;
552
- osano?: {
553
- scriptSource: string;
554
- } | undefined;
555
549
  telemetry?: {
556
550
  enabled?: boolean | undefined;
557
551
  } | undefined;
@@ -874,9 +868,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
874
868
  frontchat?: {
875
869
  snippetId: string;
876
870
  } | undefined;
877
- osano?: {
878
- scriptSource: string;
879
- } | undefined;
880
871
  telemetry?: {
881
872
  enabled?: boolean | undefined;
882
873
  } | undefined;
@@ -1199,9 +1190,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1199
1190
  frontchat?: {
1200
1191
  snippetId: string;
1201
1192
  } | undefined;
1202
- osano?: {
1203
- scriptSource: string;
1204
- } | undefined;
1205
1193
  telemetry?: {
1206
1194
  enabled?: boolean | undefined;
1207
1195
  } | undefined;
@@ -1524,9 +1512,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1524
1512
  frontchat?: {
1525
1513
  snippetId: string;
1526
1514
  } | undefined;
1527
- osano?: {
1528
- scriptSource: string;
1529
- } | undefined;
1530
1515
  telemetry?: {
1531
1516
  enabled?: boolean | undefined;
1532
1517
  } | undefined;
@@ -1849,9 +1834,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1849
1834
  frontchat?: {
1850
1835
  snippetId: string;
1851
1836
  } | undefined;
1852
- osano?: {
1853
- scriptSource: string;
1854
- } | undefined;
1855
1837
  telemetry?: {
1856
1838
  enabled?: boolean | undefined;
1857
1839
  } | undefined;
@@ -2174,9 +2156,6 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
2174
2156
  frontchat?: {
2175
2157
  snippetId: string;
2176
2158
  } | undefined;
2177
- osano?: {
2178
- scriptSource: string;
2179
- } | undefined;
2180
2159
  telemetry?: {
2181
2160
  enabled?: boolean | undefined;
2182
2161
  } | undefined;
@@ -220,9 +220,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
220
220
  frontchat?: {
221
221
  snippetId: string;
222
222
  } | undefined;
223
- osano?: {
224
- scriptSource: string;
225
- } | undefined;
226
223
  telemetry?: {
227
224
  enabled?: boolean | undefined;
228
225
  } | undefined;
@@ -545,9 +542,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
545
542
  frontchat?: {
546
543
  snippetId: string;
547
544
  } | undefined;
548
- osano?: {
549
- scriptSource: string;
550
- } | undefined;
551
545
  telemetry?: {
552
546
  enabled?: boolean | undefined;
553
547
  } | undefined;
@@ -870,9 +864,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
870
864
  frontchat?: {
871
865
  snippetId: string;
872
866
  } | undefined;
873
- osano?: {
874
- scriptSource: string;
875
- } | undefined;
876
867
  telemetry?: {
877
868
  enabled?: boolean | undefined;
878
869
  } | undefined;
@@ -1195,9 +1186,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1195
1186
  frontchat?: {
1196
1187
  snippetId: string;
1197
1188
  } | undefined;
1198
- osano?: {
1199
- scriptSource: string;
1200
- } | undefined;
1201
1189
  telemetry?: {
1202
1190
  enabled?: boolean | undefined;
1203
1191
  } | undefined;
@@ -1520,9 +1508,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1520
1508
  frontchat?: {
1521
1509
  snippetId: string;
1522
1510
  } | undefined;
1523
- osano?: {
1524
- scriptSource: string;
1525
- } | undefined;
1526
1511
  telemetry?: {
1527
1512
  enabled?: boolean | undefined;
1528
1513
  } | undefined;
@@ -1845,9 +1830,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1845
1830
  frontchat?: {
1846
1831
  snippetId: string;
1847
1832
  } | undefined;
1848
- osano?: {
1849
- scriptSource: string;
1850
- } | undefined;
1851
1833
  telemetry?: {
1852
1834
  enabled?: boolean | undefined;
1853
1835
  } | undefined;
@@ -2170,9 +2152,6 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
2170
2152
  frontchat?: {
2171
2153
  snippetId: string;
2172
2154
  } | undefined;
2173
- osano?: {
2174
- scriptSource: string;
2175
- } | undefined;
2176
2155
  telemetry?: {
2177
2156
  enabled?: boolean | undefined;
2178
2157
  } | undefined;
@@ -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
+ };