@mintlify/previewing 4.0.790 → 4.0.792

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,4 +1,4 @@
1
- import { categorizeFilePaths, createPage, generateDecoratedDocsNavigationFromPages, } from '@mintlify/prebuild';
1
+ import { categorizeFilePaths, createPage, generateDecoratedDocsNavigationFromPages, getMintIgnore, } from '@mintlify/prebuild';
2
2
  import { promises as _promises } from 'fs';
3
3
  import { join } from 'path';
4
4
  import { CMD_EXEC_PATH } from '../../constants.js';
@@ -20,7 +20,8 @@ const createFilenamePageMetadataMap = async ({ contentDirectoryPath, contentFile
20
20
  return pagesAcc;
21
21
  };
22
22
  export const generateNav = async (pagesAcc, docsConfig) => {
23
- const { contentFilenames, openApiFiles, asyncApiFiles } = await categorizeFilePaths(CMD_EXEC_PATH);
23
+ const mintIgnore = await getMintIgnore(CMD_EXEC_PATH);
24
+ const { contentFilenames, openApiFiles, asyncApiFiles } = await categorizeFilePaths(CMD_EXEC_PATH, mintIgnore);
24
25
  const filenamePageMetadataMap = await createFilenamePageMetadataMap({
25
26
  contentDirectoryPath: CMD_EXEC_PATH,
26
27
  contentFilenames,
@@ -1,10 +1,11 @@
1
- import { generateOpenApiAnchorsOrTabs, categorizeFilePaths, generateOpenApiDivisions, MintConfigUpdater, DocsConfigUpdater, } from '@mintlify/prebuild';
1
+ import { generateOpenApiAnchorsOrTabs, categorizeFilePaths, generateOpenApiDivisions, getMintIgnore, MintConfigUpdater, DocsConfigUpdater, } from '@mintlify/prebuild';
2
2
  import { upgradeToDocsConfig } from '@mintlify/validation';
3
3
  import fse from 'fs-extra';
4
4
  import { join } from 'path';
5
5
  import { CMD_EXEC_PATH, CLIENT_PATH } from '../../constants.js';
6
6
  export const getDocsState = async () => {
7
- const { openApiFiles } = await categorizeFilePaths(CMD_EXEC_PATH);
7
+ const mintIgnore = await getMintIgnore(CMD_EXEC_PATH);
8
+ const { openApiFiles } = await categorizeFilePaths(CMD_EXEC_PATH, mintIgnore);
8
9
  try {
9
10
  const mintConfig = await MintConfigUpdater.getConfig(join(CMD_EXEC_PATH, 'mint.json'));
10
11
  const docsConfig = upgradeToDocsConfig(mintConfig);
@@ -1,2 +1,5 @@
1
- declare const listener: (callback: () => void) => void;
1
+ declare const listener: (callback: () => void, options?: {
2
+ localSchema?: boolean;
3
+ groups?: string[];
4
+ }) => void;
2
5
  export default listener;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { findAndRemoveImports, hasImports, getFileCategory, openApiCheck, stringifyTree, } from '@mintlify/common';
3
- import { createPage, MintConfigUpdater, DocsConfigUpdater, preparseMdxTree, } from '@mintlify/prebuild';
2
+ import { findAndRemoveImports, hasImports, getFileCategory, openApiCheck, stringifyTree, processMintIgnoreString, isMintIgnored, DEFAULT_MINT_IGNORES, } from '@mintlify/common';
3
+ import { createPage, MintConfigUpdater, DocsConfigUpdater, preparseMdxTree, prebuild, } from '@mintlify/prebuild';
4
4
  import Chalk from 'chalk';
5
5
  import chokidar from 'chokidar';
6
6
  import { promises as _promises } from 'fs';
@@ -10,7 +10,7 @@ import yaml from 'js-yaml';
10
10
  import pathUtil from 'path';
11
11
  import { CMD_EXEC_PATH, NEXT_PROPS_PATH, NEXT_PUBLIC_PATH, CLIENT_PATH } from '../../constants.js';
12
12
  import { addChangeLog } from '../../logging-state.js';
13
- import { AddedLog, DeletedLog, EditedLog } from '../../logs.js';
13
+ import { AddedLog, DeletedLog, EditedLog, WarningLog, InfoLog } from '../../logs.js';
14
14
  import { generateDependentSnippets } from './generateDependentSnippets.js';
15
15
  import { generatePagesWithImports } from './generatePagesWithImports.js';
16
16
  import { getDocsState } from './getDocsState.js';
@@ -19,36 +19,53 @@ import { updateCustomLanguages, updateGeneratedNav, updateOpenApiFiles, upsertOp
19
19
  import { isFileSizeValid, shouldRegenerateNavForPage } from './utils.js';
20
20
  const { readFile } = _promises;
21
21
  const frontmatterHashes = new Map();
22
- const listener = (callback) => {
22
+ const listener = (callback, options = {}) => {
23
23
  chokidar
24
24
  .watch(CMD_EXEC_PATH, {
25
25
  ignoreInitial: true,
26
- ignored: ['node_modules', '.git', '.idea'],
26
+ ignored: DEFAULT_MINT_IGNORES,
27
27
  cwd: CMD_EXEC_PATH,
28
28
  })
29
- .on('add', (filename) => onAddEvent(filename, callback))
30
- .on('change', (filename) => onChangeEvent(filename, callback))
31
- .on('unlink', onUnlinkEvent);
29
+ .on('add', (filename) => onAddEvent(filename, callback, options))
30
+ .on('change', (filename) => onChangeEvent(filename, callback, options))
31
+ .on('unlink', (filename) => onUnlinkEvent(filename, options));
32
32
  };
33
- const onAddEvent = async (filename, callback) => {
33
+ const getMintIgnoreGlobs = () => {
34
+ const mintIgnorePath = pathUtil.join(CMD_EXEC_PATH, '.mintignore');
35
+ if (fse.existsSync(mintIgnorePath)) {
36
+ const content = fse.readFileSync(mintIgnorePath, 'utf8');
37
+ return processMintIgnoreString(content);
38
+ }
39
+ return [];
40
+ };
41
+ const onAddEvent = async (filename, callback, options) => {
42
+ if (isMintIgnored(filename, getMintIgnoreGlobs())) {
43
+ return;
44
+ }
34
45
  try {
35
- await onUpdateEvent(filename, callback);
46
+ await onUpdateEvent(filename, callback, options);
36
47
  addChangeLog(_jsx(AddedLog, { filename: filename }));
37
48
  }
38
49
  catch (error) {
39
50
  console.error(error.message);
40
51
  }
41
52
  };
42
- const onChangeEvent = async (filename, callback) => {
53
+ const onChangeEvent = async (filename, callback, options) => {
54
+ if (isMintIgnored(filename, getMintIgnoreGlobs())) {
55
+ return;
56
+ }
43
57
  try {
44
- await onUpdateEvent(filename, callback);
58
+ await onUpdateEvent(filename, callback, options);
45
59
  addChangeLog(_jsx(EditedLog, { filename: filename }));
46
60
  }
47
61
  catch (error) {
48
62
  console.error(error.message);
49
63
  }
50
64
  };
51
- const onUnlinkEvent = async (filename) => {
65
+ const onUnlinkEvent = async (filename, options) => {
66
+ if (isMintIgnored(filename, getMintIgnoreGlobs())) {
67
+ return;
68
+ }
52
69
  try {
53
70
  const potentialCategory = getFileCategory(filename);
54
71
  const targetPath = getTargetPath(potentialCategory, filename);
@@ -72,6 +89,17 @@ const onUnlinkEvent = async (filename) => {
72
89
  console.error('docs.json has been deleted.');
73
90
  await validateConfigFiles();
74
91
  break;
92
+ case 'mintIgnore':
93
+ addChangeLog(_jsx(WarningLog, { message: ".mintignore has been deleted. Rebuilding..." }));
94
+ try {
95
+ await fse.emptyDir(NEXT_PUBLIC_PATH);
96
+ await fse.emptyDir(NEXT_PROPS_PATH);
97
+ await prebuild(CMD_EXEC_PATH, options);
98
+ }
99
+ catch (err) {
100
+ console.error('Error rebuilding after .mintignore deletion:', err);
101
+ }
102
+ break;
75
103
  }
76
104
  addChangeLog(_jsx(DeletedLog, { filename: filename }));
77
105
  }
@@ -92,6 +120,8 @@ const getTargetPath = (potentialCategory, filePath) => {
92
120
  return pathUtil.join(NEXT_PROPS_PATH, 'openApiFiles.json');
93
121
  case 'generatedStaticFile':
94
122
  return pathUtil.join(NEXT_PUBLIC_PATH, filePath);
123
+ case 'mintIgnore':
124
+ return pathUtil.join(NEXT_PROPS_PATH, 'mint-ignore.json');
95
125
  case 'snippet':
96
126
  case 'staticFile':
97
127
  case 'snippet-v2':
@@ -122,7 +152,7 @@ const validateConfigFiles = async () => {
122
152
  * @param filename
123
153
  * @returns FileCategory
124
154
  */
125
- const onUpdateEvent = async (filename, callback) => {
155
+ const onUpdateEvent = async (filename, callback, options = {}) => {
126
156
  const filePath = pathUtil.join(CMD_EXEC_PATH, filename);
127
157
  const potentialCategory = getFileCategory(filename);
128
158
  const targetPath = getTargetPath(potentialCategory, filename);
@@ -182,6 +212,18 @@ const onUpdateEvent = async (filename, callback) => {
182
212
  }
183
213
  break;
184
214
  }
215
+ case 'mintIgnore': {
216
+ try {
217
+ addChangeLog(_jsx(InfoLog, { message: ".mintignore has been updated. Rebuilding..." }));
218
+ await fse.emptyDir(NEXT_PUBLIC_PATH);
219
+ await fse.emptyDir(NEXT_PROPS_PATH);
220
+ await prebuild(CMD_EXEC_PATH, options);
221
+ }
222
+ catch (err) {
223
+ console.error(err.message);
224
+ }
225
+ break;
226
+ }
185
227
  case 'potentialYamlOpenApiSpec':
186
228
  case 'potentialJsonOpenApiSpec': {
187
229
  let doc;