@mintlify/cli 4.0.944 → 4.0.946

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.
@@ -6,6 +6,8 @@ import { outputFile } from 'fs-extra';
6
6
 
7
7
  import { migrateMdx } from '../src/migrateMdx.js';
8
8
 
9
+ const normalizePath = (p: string) => p.replace(/[\\/]+/g, '/');
10
+
9
11
  vi.mock('../src/constants.js', () => ({
10
12
  HOME_DIR: '/home/test-user',
11
13
  CMD_EXEC_PATH: '/project',
@@ -91,13 +93,15 @@ describe('migrateMdx', () => {
91
93
 
92
94
  const existsSyncSpy = vi.spyOn(fs, 'existsSync');
93
95
  existsSyncSpy.mockImplementation((p: fs.PathLike) => {
94
- const value = String(p);
96
+ const value = normalizePath(String(p));
95
97
  return value === '/project/api/pets.mdx' || value === 'openapi.json';
96
98
  });
97
99
 
98
100
  const readFileSpy = vi.spyOn(fs.promises, 'readFile');
99
101
  readFileSpy.mockImplementation(async (p: Parameters<typeof fs.promises.readFile>[0]) => {
100
- const value = typeof p === 'string' ? p : (p as unknown as { toString(): string }).toString();
102
+ const value = normalizePath(
103
+ typeof p === 'string' ? p : (p as unknown as { toString(): string }).toString()
104
+ );
101
105
  if (value === '/project/api/pets.mdx') {
102
106
  return `---\nopenapi: openapi.json GET /pets\n---\n\n# Title\nContent`;
103
107
  }
@@ -142,7 +146,9 @@ describe('migrateMdx', () => {
142
146
  expect.objectContaining({ href: '/api/pets' })
143
147
  );
144
148
 
145
- expect(unlinkSpy).toHaveBeenCalledWith('/project/api/pets.mdx');
149
+ expect(
150
+ unlinkSpy.mock.calls.some((c) => normalizePath(c[0] as string) === '/project/api/pets.mdx')
151
+ ).toBe(true);
146
152
 
147
153
  expect(addLogSpy).toHaveBeenCalledWith(
148
154
  expect.objectContaining({ props: { message: 'migration complete' } })
@@ -167,13 +173,15 @@ describe('migrateMdx', () => {
167
173
 
168
174
  const existsSyncSpy = vi.spyOn(fs, 'existsSync');
169
175
  existsSyncSpy.mockImplementation((p: fs.PathLike) => {
170
- const value = String(p);
176
+ const value = normalizePath(String(p));
171
177
  return value === '/project/webhooks/newPet.mdx' || value === 'openapi1.json';
172
178
  });
173
179
 
174
180
  const readFileSpy = vi.spyOn(fs.promises, 'readFile');
175
181
  readFileSpy.mockImplementation(async (p: Parameters<typeof fs.promises.readFile>[0]) => {
176
- const value = typeof p === 'string' ? p : (p as unknown as { toString(): string }).toString();
182
+ const value = normalizePath(
183
+ typeof p === 'string' ? p : (p as unknown as { toString(): string }).toString()
184
+ );
177
185
  if (value === '/project/webhooks/newPet.mdx') {
178
186
  return `---\nopenapi: openapi1.json webhook newPet\n---\n\n# Webhook\nBody`;
179
187
  }