validateIntegrations() — astro Function Reference
Architecture documentation for the validateIntegrations() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD ffb00280_f878_7381_fa3f_c64fddb70bbc["validateIntegrations()"] 9151bb3d_ee1e_da42_752a_45a9db1dd918["index.ts"] ffb00280_f878_7381_fa3f_c64fddb70bbc -->|defined in| 9151bb3d_ee1e_da42_752a_45a9db1dd918 e251add5_ea46_2280_c246_1b5a023acc3b["add()"] e251add5_ea46_2280_c246_1b5a023acc3b -->|calls| ffb00280_f878_7381_fa3f_c64fddb70bbc f68e7235_000e_755e_ddd2_771a306eb9c9["parseIntegrationName()"] ffb00280_f878_7381_fa3f_c64fddb70bbc -->|calls| f68e7235_000e_755e_ddd2_771a306eb9c9 2ee262d1_8614_9c2d_75fd_5bb9c01ac63c["askToContinue()"] ffb00280_f878_7381_fa3f_c64fddb70bbc -->|calls| 2ee262d1_8614_9c2d_75fd_5bb9c01ac63c style ffb00280_f878_7381_fa3f_c64fddb70bbc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/cli/add/index.ts lines 900–1017
async function validateIntegrations(
integrations: string[],
flags: yargsParser.Arguments,
logger: Logger,
): Promise<IntegrationInfo[]> {
// First, validate all package names to prevent command injection
for (const integration of integrations) {
assertValidPackageName(integration);
}
const spinner = yoctoSpinner({ text: 'Resolving packages...' }).start();
try {
const integrationEntries = await Promise.all(
integrations.map(async (integration): Promise<IntegrationInfo> => {
const parsed = parseIntegrationName(integration);
if (!parsed) {
throw new Error(`${bold(integration)} does not appear to be a valid package name!`);
}
let { scope, name, tag } = parsed;
let pkgJson;
let pkgType: 'first-party' | 'third-party';
if (scope && scope !== '@astrojs') {
pkgType = 'third-party';
} else {
const firstPartyPkgCheck = await fetchPackageJson('@astrojs', name, tag);
if (firstPartyPkgCheck instanceof Error) {
if (firstPartyPkgCheck.message) {
spinner.warning(yellow(firstPartyPkgCheck.message));
}
spinner.warning(yellow(`${bold(integration)} is not an official Astro package.`));
if (!(await askToContinue({ flags, logger }))) {
throw new Error(
`No problem! Find our official integrations at ${cyan(
'https://astro.build/integrations',
)}`,
);
}
spinner.start('Resolving with third party packages...');
pkgType = 'third-party';
} else {
pkgType = 'first-party';
pkgJson = firstPartyPkgCheck as any;
}
}
if (pkgType === 'third-party') {
const thirdPartyPkgCheck = await fetchPackageJson(scope, name, tag);
if (thirdPartyPkgCheck instanceof Error) {
if (thirdPartyPkgCheck.message) {
spinner.warning(yellow(thirdPartyPkgCheck.message));
}
throw new Error(`Unable to fetch ${bold(integration)}. Does the package exist?`);
} else {
pkgJson = thirdPartyPkgCheck as any;
}
}
const resolvedScope = pkgType === 'first-party' ? '@astrojs' : scope;
const packageName = `${resolvedScope ? `${resolvedScope}/` : ''}${name}`;
let integrationName = packageName;
let dependencies: IntegrationInfo['dependencies'] = [
[pkgJson['name'], `^${pkgJson['version']}`],
];
if (pkgJson['peerDependencies']) {
const meta = pkgJson['peerDependenciesMeta'] || {};
for (const peer in pkgJson['peerDependencies']) {
const optional = meta[peer]?.optional || false;
const isAstro = peer === 'astro';
if (!optional && !isAstro) {
dependencies.push([peer, pkgJson['peerDependencies'][peer]]);
}
}
}
let integrationType: IntegrationInfo['type'];
const keywords = Array.isArray(pkgJson['keywords']) ? pkgJson['keywords'] : [];
if (keywords.includes('astro-integration')) {
integrationType = 'integration';
} else if (keywords.includes('astro-adapter')) {
integrationType = 'adapter';
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does validateIntegrations() do?
validateIntegrations() is a function in the astro codebase, defined in packages/astro/src/cli/add/index.ts.
Where is validateIntegrations() defined?
validateIntegrations() is defined in packages/astro/src/cli/add/index.ts at line 900.
What does validateIntegrations() call?
validateIntegrations() calls 2 function(s): askToContinue, parseIntegrationName.
What calls validateIntegrations()?
validateIntegrations() is called by 1 function(s): add.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free