getAstroInstall() — astro Function Reference
Architecture documentation for the getAstroInstall() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b6a73a73_4f0f_a757_19fd_8fe8bf8be658["getAstroInstall()"] 95a68fc5_3ffe_042b_2c60_3f03f30904cf["utils.ts"] b6a73a73_4f0f_a757_19fd_8fe8bf8be658 -->|defined in| 95a68fc5_3ffe_042b_2c60_3f03f30904cf style b6a73a73_4f0f_a757_19fd_8fe8bf8be658 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/language-tools/language-server/src/utils.ts lines 9–61
export function getAstroInstall(
basePaths: string[],
checkForAstro?: {
nearestPackageJson: string | undefined;
readDirectory: typeof import('typescript').sys.readDirectory;
},
): PackageInfo | 'not-an-astro-project' | 'not-found' {
if (checkForAstro && checkForAstro.nearestPackageJson) {
basePaths.push(path.dirname(checkForAstro.nearestPackageJson));
let deps = new Set<string>();
try {
const packageJSON = require(checkForAstro.nearestPackageJson);
[
...Object.keys(packageJSON.dependencies ?? {}),
...Object.keys(packageJSON.devDependencies ?? {}),
...Object.keys(packageJSON.peerDependencies ?? {}),
].forEach((dep) => deps.add(dep));
} catch {}
if (!deps.has('astro')) {
const directoryContent = checkForAstro.readDirectory(
path.dirname(checkForAstro.nearestPackageJson),
['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'],
undefined,
undefined,
1,
);
if (!directoryContent.some((file) => path.basename(file).startsWith('astro.config'))) {
return 'not-an-astro-project';
}
}
}
let astroPackage = getPackageInfo('astro', basePaths);
if (!astroPackage) {
// If we couldn't find it inside the workspace's node_modules, it might means we're in the Astro development monorepo
astroPackage = getPackageInfo('./packages/astro', basePaths);
if (!astroPackage) {
console.error(
`${basePaths[0]} seems to be an Astro project, but we couldn't find Astro or Astro is not installed`,
);
// If we still couldn't find it, it probably just doesn't exist
return 'not-found';
}
}
return astroPackage;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does getAstroInstall() do?
getAstroInstall() is a function in the astro codebase, defined in packages/language-tools/language-server/src/utils.ts.
Where is getAstroInstall() defined?
getAstroInstall() is defined in packages/language-tools/language-server/src/utils.ts at line 9.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free