MCPcopy Create free account
hub / github.com/vercel/vercel / detectDjangoPythonEntrypoint

Function detectDjangoPythonEntrypoint

packages/python/src/entrypoint.ts:446–487  ·  view source on GitHub ↗
(workPath: string)

Source from the content-addressed store, hash-verified

444 * DJANGO_SETTINGS_MODULE, then fall back to AST-based detection if needed.
445 */
446export async function detectDjangoPythonEntrypoint(workPath: string): Promise<{
447 detected: DetectedPythonEntrypoint | null;
448 findDiagnostics: FindResult;
449}> {
450 const emptyResult = {
451 detected: null,
452 findDiagnostics: {
453 entrypoint: null,
454 existingWithoutEntrypoint: [],
455 } as FindResult,
456 };
457 try {
458 // Get root directories (workPath root + immediate subdirs)
459 const subdirs = await getSubdirectories(workPath);
460 const rootDirs = ['', ...subdirs];
461
462 // Look for a Django manage.py in workPath and immediate subdirectories.
463 for (const rootDir of rootDirs) {
464 const currPath = join(workPath, rootDir);
465 const isDjango = await checkDjangoManage(currPath);
466 if (isDjango) {
467 // Defer to the Django framework hook for entrypoint resolution.
468 return {
469 detected: { baseDir: rootDir },
470 findDiagnostics: { entrypoint: null, existingWithoutEntrypoint: [] },
471 };
472 }
473 }
474
475 // Fall back to AST-based detection,
476 // Look in all immediate subdirectories, not just those specified in PYTHON_ENTRYPOINT_DIRS.
477 const candidates = getCandidateEntrypointsInDirs(rootDirs);
478 const result = await findValidEntrypoint(workPath, candidates);
479 return {
480 detected: result.entrypoint ? { entrypoint: result.entrypoint } : null,
481 findDiagnostics: result,
482 };
483 } catch {
484 debug('Failed to discover Django Python entrypoint');
485 return emptyResult;
486 }
487}
488
489/**
490 * Detect a Python entrypoint path for a given framework relative to workPath, or return null if not found.

Callers 1

detectPythonEntrypointFunction · 0.85

Calls 5

debugFunction · 0.90
getSubdirectoriesFunction · 0.85
checkDjangoManageFunction · 0.85
findValidEntrypointFunction · 0.85

Tested by

no test coverage detected