@mintlify/previewing 4.0.1574 → 4.0.1576

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,5 +1,6 @@
1
- import { prebuild } from '@mintlify/prebuild';
1
+ import { getFileListSync, prebuild } from '@mintlify/prebuild';
2
2
  import fse from 'fs-extra';
3
+ import path from 'path';
3
4
  import { mockProcessExit } from 'vitest-mock-process';
4
5
  import { dev } from '../index.js';
5
6
  import { isOnline } from '../local-preview/is-online.js';
@@ -15,6 +16,8 @@ vi.mock('fs-extra', () => {
15
16
  readFileSync: vi.fn().mockReturnValue('0.0.100'),
16
17
  emptyDirSync: vi.fn().mockResolvedValue(undefined),
17
18
  outputFileSync: vi.fn(),
19
+ existsSync: vi.fn().mockReturnValue(true),
20
+ removeSync: vi.fn(),
18
21
  };
19
22
  return {
20
23
  ...mocks,
@@ -32,6 +35,7 @@ vi.mock('../local-preview/is-online.js', () => ({
32
35
  }));
33
36
  vi.mock('@mintlify/prebuild', () => ({
34
37
  prebuild: vi.fn().mockResolvedValue(undefined),
38
+ getFileListSync: vi.fn().mockReturnValue([]),
35
39
  }));
36
40
  vi.mock('../local-preview/run.js', () => ({
37
41
  run: vi.fn().mockResolvedValue(undefined),
@@ -107,4 +111,23 @@ describe('dev', () => {
107
111
  }));
108
112
  expect(processExitMock).toHaveBeenCalledWith(1);
109
113
  });
114
+ it('drops processed snippets from public on warm starts', async () => {
115
+ vi.mocked(fse.readFileSync).mockImplementation((path) => String(path).endsWith('.mint-content-source') ? process.cwd() : '0.0.100');
116
+ vi.mocked(getFileListSync).mockReturnValueOnce([
117
+ 'snippets/snip.mdx',
118
+ 'snippets/comp.jsx',
119
+ 'components/note.md',
120
+ 'images/logo.png',
121
+ 'favicons/favicon.ico',
122
+ ]);
123
+ await dev(defaultYargs);
124
+ const removed = vi
125
+ .mocked(fse.removeSync)
126
+ .mock.calls.map(([removedPath]) => String(removedPath));
127
+ expect(removed).toHaveLength(3);
128
+ expect(removed.some((removedPath) => removedPath.endsWith(path.join('snippets/snip.mdx')))).toBe(true);
129
+ expect(removed.some((removedPath) => removedPath.endsWith(path.join('snippets/comp.jsx')))).toBe(true);
130
+ expect(removed.some((removedPath) => removedPath.endsWith(path.join('components/note.md')))).toBe(true);
131
+ vi.mocked(fse.readFileSync).mockReturnValue('0.0.100');
132
+ });
110
133
  });
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { isSnippetExtension } from '@mintlify/common';
2
3
  import { getFileListSync, prebuild } from '@mintlify/prebuild';
3
4
  import fse, { pathExists } from 'fs-extra';
4
5
  import pathUtil from 'path';
@@ -26,7 +27,8 @@ const prunePublicOrphans = () => {
26
27
  if (PRUNE_EXEMPT_PREFIXES.some((prefix) => relativePath.startsWith(prefix))) {
27
28
  continue;
28
29
  }
29
- if (!fse.existsSync(pathUtil.join(CMD_EXEC_PATH, relativePath))) {
30
+ if (isSnippetExtension(pathUtil.extname(relativePath)) ||
31
+ !fse.existsSync(pathUtil.join(CMD_EXEC_PATH, relativePath))) {
30
32
  fse.removeSync(pathUtil.join(NEXT_PUBLIC_PATH, relativePath));
31
33
  }
32
34
  }