MCPcopy
hub / github.com/vercel/next.js / findNextjsInWorkspace

Function findNextjsInWorkspace

packages/next-codemod/lib/agents-md.ts:502–521  ·  view source on GitHub ↗
(cwd: string, patterns: string[])

Source from the content-addressed store, hash-verified

500}
501
502function findNextjsInWorkspace(cwd: string, patterns: string[]): string | null {
503 const packagePaths = expandWorkspacePatterns(cwd, patterns)
504 const versions: string[] = []
505
506 for (const pkgPath of packagePaths) {
507 try {
508 const nextPkgPath = require.resolve('next/package.json', {
509 paths: [pkgPath],
510 })
511 const pkg = JSON.parse(fs.readFileSync(nextPkgPath, 'utf-8'))
512 if (pkg.version) {
513 versions.push(pkg.version)
514 }
515 } catch {
516 // Next.js not installed in this package
517 }
518 }
519
520 return findHighestVersion(versions)
521}
522
523function expandWorkspacePatterns(cwd: string, patterns: string[]): string[] {
524 const packagePaths: string[] = []

Callers 1

getNextjsVersionFunction · 0.85

Calls 6

expandWorkspacePatternsFunction · 0.85
findHighestVersionFunction · 0.85
readFileSyncMethod · 0.80
resolveMethod · 0.65
pushMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected