@mintlify/prebuild 1.0.768 → 1.0.770

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.
@@ -1,6 +1,6 @@
1
1
  import { AsyncAPIFile } from '@mintlify/common';
2
2
  import { OpenApiFile } from '@mintlify/models';
3
- export declare const categorizeFilePaths: (contentDirectoryPath: string, mintIgnore?: string[], disableOpenApi?: boolean) => Promise<{
3
+ export declare const categorizeFilePaths: (contentDirectoryPath: string, mintIgnore?: string[], disableOpenApi?: boolean, snippetPatterns?: string[]) => Promise<{
4
4
  contentFilenames: string[];
5
5
  staticFilenames: string[];
6
6
  openApiFiles: OpenApiFile[];
@@ -1,11 +1,11 @@
1
- import { openApiCheck } from '@mintlify/common';
1
+ import { openApiCheck, isSnippetPath } from '@mintlify/common';
2
2
  import { validateAsyncApi } from '@mintlify/common';
3
3
  import { readFile } from 'fs/promises';
4
4
  import yaml from 'js-yaml';
5
5
  import * as path from 'path';
6
6
  import { getFileList } from '../fs/index.js';
7
7
  import { getFileExtension } from '../utils.js';
8
- export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [], disableOpenApi) => {
8
+ export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [], disableOpenApi, snippetPatterns) => {
9
9
  const allFilesInCmdExecutionPath = getFileList(contentDirectoryPath, contentDirectoryPath, mintIgnore);
10
10
  const contentFilenames = [];
11
11
  const staticFilenames = [];
@@ -23,7 +23,7 @@ export const categorizeFilePaths = async (contentDirectoryPath, mintIgnore = [],
23
23
  snippets.push(filename);
24
24
  break;
25
25
  }
26
- if (filename.startsWith('/snippets/')) {
26
+ if (isSnippetPath(filename, snippetPatterns)) {
27
27
  snippetsV2.push(filename);
28
28
  break;
29
29
  }
@@ -1,4 +1,4 @@
1
- import { getConfigPath, getMintIgnore } from '../utils.js';
1
+ import { getConfigPath, getMintIgnore, getSnippetPatterns } from '../utils.js';
2
2
  import { categorizeFilePaths } from './categorizeFilePaths.js';
3
3
  import { update } from './update/index.js';
4
4
  export const prebuild = async (contentDirectoryPath, { localSchema, groups, disableOpenApi, } = {}) => {
@@ -11,8 +11,11 @@ export const prebuild = async (contentDirectoryPath, { localSchema, groups, disa
11
11
  if (mintConfigPath == null && docsConfigPath == null) {
12
12
  throw Error('must be run in a directory where a docs.json file exists.');
13
13
  }
14
- const mintIgnore = await getMintIgnore(contentDirectoryPath);
15
- const { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2 } = await categorizeFilePaths(contentDirectoryPath, mintIgnore, disableOpenApi);
14
+ const [mintIgnore, snippetPatterns] = await Promise.all([
15
+ getMintIgnore(contentDirectoryPath),
16
+ getSnippetPatterns(contentDirectoryPath),
17
+ ]);
18
+ const { contentFilenames, staticFilenames, openApiFiles, asyncApiFiles, snippets, snippetsV2 } = await categorizeFilePaths(contentDirectoryPath, mintIgnore, disableOpenApi, snippetPatterns);
16
19
  await update({
17
20
  contentDirectoryPath,
18
21
  staticFilenames,
@@ -26,6 +29,7 @@ export const prebuild = async (contentDirectoryPath, { localSchema, groups, disa
26
29
  groups,
27
30
  mintIgnore,
28
31
  disableOpenApi,
32
+ snippetPatterns,
29
33
  });
30
34
  };
31
35
  export * from './categorizeFilePaths.js';
@@ -343,6 +343,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
343
343
  interaction?: {
344
344
  drilldown?: boolean | undefined;
345
345
  } | undefined;
346
+ snippets?: string[] | undefined;
346
347
  } | {
347
348
  name: string;
348
349
  $schema: string;
@@ -666,6 +667,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
666
667
  interaction?: {
667
668
  drilldown?: boolean | undefined;
668
669
  } | undefined;
670
+ snippets?: string[] | undefined;
669
671
  } | {
670
672
  name: string;
671
673
  $schema: string;
@@ -989,6 +991,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
989
991
  interaction?: {
990
992
  drilldown?: boolean | undefined;
991
993
  } | undefined;
994
+ snippets?: string[] | undefined;
992
995
  } | {
993
996
  name: string;
994
997
  $schema: string;
@@ -1312,6 +1315,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1312
1315
  interaction?: {
1313
1316
  drilldown?: boolean | undefined;
1314
1317
  } | undefined;
1318
+ snippets?: string[] | undefined;
1315
1319
  } | {
1316
1320
  name: string;
1317
1321
  $schema: string;
@@ -1635,6 +1639,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1635
1639
  interaction?: {
1636
1640
  drilldown?: boolean | undefined;
1637
1641
  } | undefined;
1642
+ snippets?: string[] | undefined;
1638
1643
  } | {
1639
1644
  name: string;
1640
1645
  $schema: string;
@@ -1958,6 +1963,7 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
1958
1963
  interaction?: {
1959
1964
  drilldown?: boolean | undefined;
1960
1965
  } | undefined;
1966
+ snippets?: string[] | undefined;
1961
1967
  } | {
1962
1968
  name: string;
1963
1969
  $schema: string;
@@ -2281,4 +2287,5 @@ export declare const DocsConfigUpdater: ConfigUpdater<{
2281
2287
  interaction?: {
2282
2288
  drilldown?: boolean | undefined;
2283
2289
  } | undefined;
2290
+ snippets?: string[] | undefined;
2284
2291
  }>;
@@ -14,8 +14,9 @@ type UpdateArgs = {
14
14
  groups?: string[];
15
15
  mintIgnore?: string[];
16
16
  disableOpenApi?: boolean;
17
+ snippetPatterns?: string[];
17
18
  };
18
- export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, }: UpdateArgs) => Promise<{
19
+ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, snippetPatterns, }: UpdateArgs) => Promise<{
19
20
  name: string;
20
21
  $schema: string;
21
22
  theme: "mint";
@@ -338,6 +339,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
338
339
  interaction?: {
339
340
  drilldown?: boolean | undefined;
340
341
  } | undefined;
342
+ snippets?: string[] | undefined;
341
343
  } | {
342
344
  name: string;
343
345
  $schema: string;
@@ -661,6 +663,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
661
663
  interaction?: {
662
664
  drilldown?: boolean | undefined;
663
665
  } | undefined;
666
+ snippets?: string[] | undefined;
664
667
  } | {
665
668
  name: string;
666
669
  $schema: string;
@@ -984,6 +987,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
984
987
  interaction?: {
985
988
  drilldown?: boolean | undefined;
986
989
  } | undefined;
990
+ snippets?: string[] | undefined;
987
991
  } | {
988
992
  name: string;
989
993
  $schema: string;
@@ -1307,6 +1311,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1307
1311
  interaction?: {
1308
1312
  drilldown?: boolean | undefined;
1309
1313
  } | undefined;
1314
+ snippets?: string[] | undefined;
1310
1315
  } | {
1311
1316
  name: string;
1312
1317
  $schema: string;
@@ -1630,6 +1635,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1630
1635
  interaction?: {
1631
1636
  drilldown?: boolean | undefined;
1632
1637
  } | undefined;
1638
+ snippets?: string[] | undefined;
1633
1639
  } | {
1634
1640
  name: string;
1635
1641
  $schema: string;
@@ -1953,6 +1959,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
1953
1959
  interaction?: {
1954
1960
  drilldown?: boolean | undefined;
1955
1961
  } | undefined;
1962
+ snippets?: string[] | undefined;
1956
1963
  } | {
1957
1964
  name: string;
1958
1965
  $schema: string;
@@ -2276,6 +2283,7 @@ export declare const update: ({ contentDirectoryPath, staticFilenames, openApiFi
2276
2283
  interaction?: {
2277
2284
  drilldown?: boolean | undefined;
2278
2285
  } | undefined;
2286
+ snippets?: string[] | undefined;
2279
2287
  }>;
2280
2288
  export declare const writeMdxFilesWithNoImports: (mdxFilesWithNoImports: {
2281
2289
  targetPath: string;
@@ -11,7 +11,7 @@ import { writeAsyncApiFiles } from './write/writeAsyncApiFiles.js';
11
11
  import { writeFiles, writeFile } from './write/writeFiles.js';
12
12
  import { writeOpenApiData } from './write/writeOpenApiData.js';
13
13
  import { writeRssFiles } from './write/writeRssFiles.js';
14
- export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, }) => {
14
+ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFiles, asyncApiFiles, contentFilenames, snippets, snippetV2Filenames, docsConfigPath, localSchema, groups, mintIgnore, disableOpenApi, snippetPatterns, }) => {
15
15
  const mintConfigResult = await updateMintConfigFile(contentDirectoryPath, openApiFiles, localSchema);
16
16
  // we used the original mint config without openapi pages injected
17
17
  // because we will do it in `updateDocsConfigFile`, this will avoid duplicated openapi pages
@@ -54,6 +54,7 @@ export const update = async ({ contentDirectoryPath, staticFilenames, openApiFil
54
54
  pagesAcc,
55
55
  snippetsV2: snippetV2Contents,
56
56
  filesWithImports,
57
+ snippetPatterns,
57
58
  }),
58
59
  writeFile(newOpenApiFiles, 'src/_props/openApiFiles.json'),
59
60
  writeFile(customLanguages, 'src/_props/customLanguages.json'),
@@ -7,6 +7,7 @@ type ResolveImportsAndWriteFilesArgs = {
7
7
  pagesAcc: Record<string, DecoratedNavigationPage>;
8
8
  snippetsV2: FileType[];
9
9
  filesWithImports: FileWithImports[];
10
+ snippetPatterns?: string[];
10
11
  };
11
- export declare const resolveImportsAndWriteFiles: ({ openApiFiles, asyncApiFiles, pagesAcc, snippetsV2, filesWithImports, }: ResolveImportsAndWriteFilesArgs) => Promise<void>;
12
+ export declare const resolveImportsAndWriteFiles: ({ openApiFiles, asyncApiFiles, pagesAcc, snippetsV2, filesWithImports, snippetPatterns, }: ResolveImportsAndWriteFilesArgs) => Promise<void>;
12
13
  export {};
@@ -1,8 +1,8 @@
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
- export const resolveImportsAndWriteFiles = async ({ openApiFiles, asyncApiFiles, pagesAcc, snippetsV2, filesWithImports, }) => {
5
- const snippetsWithResolvedImports = await resolveImportsInSnippets(snippetsV2);
4
+ export const resolveImportsAndWriteFiles = async ({ openApiFiles, asyncApiFiles, pagesAcc, snippetsV2, filesWithImports, snippetPatterns, }) => {
5
+ const snippetsWithResolvedImports = await resolveImportsInSnippets(snippetsV2, snippetPatterns);
6
6
  const writeSnippetsWithImportsPromises = await writeSnippets(snippetsWithResolvedImports);
7
7
  const pagesWithResolvedImports = await resolveImportsInPages({
8
8
  openApiFiles,
@@ -10,11 +10,12 @@ export const resolveImportsAndWriteFiles = async ({ openApiFiles, asyncApiFiles,
10
10
  snippetsWithResolvedImports,
11
11
  filesWithImports,
12
12
  pagesAcc,
13
+ snippetPatterns,
13
14
  });
14
15
  const writePagesPromise = writePages(pagesWithResolvedImports);
15
16
  await Promise.all([...writeSnippetsWithImportsPromises, ...writePagesPromise]);
16
17
  };
17
- const resolveImportsInSnippets = async (snippetsV2) => {
18
+ const resolveImportsInSnippets = async (snippetsV2, snippetPatterns) => {
18
19
  const snippetsWithImportsPromises = snippetsV2.map(async (snippet) => ({
19
20
  ...(await findAndRemoveImports(snippet.tree)),
20
21
  filename: snippet.filename,
@@ -35,6 +36,7 @@ const resolveImportsInSnippets = async (snippetsV2) => {
35
36
  snippetWithImports.tree = await resolveAllImports({
36
37
  snippets: orderedSnippetsWithImports,
37
38
  fileWithImports: snippetWithImports,
39
+ snippetPatterns,
38
40
  });
39
41
  }
40
42
  }
@@ -46,11 +48,12 @@ const writeSnippets = async (snippetsWithImports) => snippetsWithImports.map(asy
46
48
  flag: 'w',
47
49
  });
48
50
  });
49
- const resolveImportsInPages = async ({ openApiFiles, asyncApiFiles, snippetsWithResolvedImports, filesWithImports, pagesAcc, }) => {
51
+ const resolveImportsInPages = async ({ openApiFiles, asyncApiFiles, snippetsWithResolvedImports, filesWithImports, pagesAcc, snippetPatterns, }) => {
50
52
  const filesWithResolvedImportsPromises = filesWithImports.map(async (fileWithImports) => {
51
53
  const tree = await resolveAllImports({
52
54
  snippets: snippetsWithResolvedImports,
53
55
  fileWithImports,
56
+ snippetPatterns,
54
57
  });
55
58
  const contentStr = stringifyTree(tree);
56
59
  const { slug, pageMetadata } = getDecoratedNavPageAndSlug(fileWithImports.filename, contentStr, openApiFiles, asyncApiFiles);