@next/codemod 16.5.0-canary.39 → 16.5.0-canary.40

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.
@@ -27,6 +27,12 @@ function execNodeWithoutNodePath(script, options = {}) {
27
27
  * npx @next/codemod agents-md --version 15.0.0 --output AGENTS.md
28
28
  */
29
29
  describe('agents-md e2e (CLI invocation)', () => {
30
+ // A stable cwd to return to after every test. Tests chdir into their temp
31
+ // project, and the cleanup below deletes it. If a test times out, its body
32
+ // keeps running and never restores the cwd itself, so without this every
33
+ // later test would start in (and capture as its "original" cwd) a
34
+ // directory that no longer exists.
35
+ const suiteCwd = process.cwd()
30
36
  let testProjectDir
31
37
  let originalConsoleLog
32
38
  let consoleOutput
@@ -52,6 +58,8 @@ describe('agents-md e2e (CLI invocation)', () => {
52
58
  // Restore console.log
53
59
  console.log = originalConsoleLog
54
60
 
61
+ process.chdir(suiteCwd)
62
+
55
63
  // Clean up test directory
56
64
  if (testProjectDir && fs.existsSync(testProjectDir)) {
57
65
  fs.rmSync(testProjectDir, { recursive: true, force: true })
@@ -300,7 +308,7 @@ This is my project documentation.
300
308
  } finally {
301
309
  process.chdir(originalCwd)
302
310
  }
303
- }, 30000) // Increase timeout for git clone
311
+ })
304
312
 
305
313
  describe('bundled docs (Next.js >= 16.2.0)', () => {
306
314
  // Simulate an install of a Next.js version that ships docs inside the
@@ -395,12 +403,24 @@ This is my project documentation.
395
403
  it('falls back to downloading when --version differs from the installed version', async () => {
396
404
  setupBundledNext(testProjectDir, '16.2.0')
397
405
 
406
+ // This test is about choosing the download path, not about the download
407
+ // itself (covered by the tests above), so stub it to stay offline.
408
+ const pullDocsSpy = jest
409
+ .spyOn(require('../../lib/agents-md'), 'pullDocs')
410
+ .mockImplementation(async ({ docsDir }) => {
411
+ fs.mkdirSync(path.join(docsDir, '01-app'), { recursive: true })
412
+ fs.writeFileSync(path.join(docsDir, '01-app', 'index.md'), '# Docs')
413
+ return { success: true, docsPath: docsDir }
414
+ })
415
+
398
416
  const originalCwd = process.cwd()
399
417
  process.chdir(testProjectDir)
400
418
 
401
419
  try {
402
420
  await runAgentsMd({ version: '15.0.0', output: 'AGENTS.md' })
403
421
 
422
+ expect(pullDocsSpy).toHaveBeenCalledTimes(1)
423
+ expect(pullDocsSpy.mock.calls[0][0].version).toBe('15.0.0')
404
424
  expect(fs.existsSync(path.join(testProjectDir, '.next-docs'))).toBe(
405
425
  true
406
426
  )
@@ -415,8 +435,9 @@ This is my project documentation.
415
435
  expect(output).toContain('Downloading')
416
436
  } finally {
417
437
  process.chdir(originalCwd)
438
+ pullDocsSpy.mockRestore()
418
439
  }
419
- }, 30000) // Increase timeout for git clone
440
+ })
420
441
  })
421
442
 
422
443
  // The index `root` is resolved by agents from the directory of the output
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next/codemod",
3
- "version": "16.5.0-canary.39",
3
+ "version": "16.5.0-canary.40",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",