Home / File/ adapter-validation.ts — astro Source File

adapter-validation.ts — astro Source File

Architecture documentation for adapter-validation.ts, a typescript file in the astro codebase. 5 imports, 0 dependents.

File typescript CoreAstro CoreMiddleware 5 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  3505fa2b_e453_959a_1c3e_5d3e5935e4cf["adapter-validation.ts"]
  577a88ec_9794_724f_6dca_ea21d7e8dc40["../../integrations/features-validation.js"]
  3505fa2b_e453_959a_1c3e_5d3e5935e4cf --> 577a88ec_9794_724f_6dca_ea21d7e8dc40
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  3505fa2b_e453_959a_1c3e_5d3e5935e4cf --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  4c453c0b_17bb_ebc3_f7de_e2a632e42c1e["../types/public/integrations.js"]
  3505fa2b_e453_959a_1c3e_5d3e5935e4cf --> 4c453c0b_17bb_ebc3_f7de_e2a632e42c1e
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  3505fa2b_e453_959a_1c3e_5d3e5935e4cf --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"]
  3505fa2b_e453_959a_1c3e_5d3e5935e4cf --> d3861967_b647_84d2_ff48_15013353bd56
  style 3505fa2b_e453_959a_1c3e_5d3e5935e4cf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { getAdapterStaticRecommendation } from '../../integrations/features-validation.js';
import type { AstroSettings } from '../../types/astro.js';
import type { AstroAdapter } from '../../types/public/integrations.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';

let hasWarnedMissingAdapter = false;

export function warnMissingAdapter(logger: Logger, settings: AstroSettings) {
	if (hasWarnedMissingAdapter) return;
	if (settings.buildOutput === 'server' && !settings.config.adapter) {
		logger.warn(
			'config',
			'This project contains server-rendered routes, but no adapter is installed. This is fine for development, but an adapter will be required to build your site for production.',
		);
		hasWarnedMissingAdapter = true;
	}
}

export function validateSetAdapter(
	logger: Logger,
	settings: AstroSettings,
	adapter: AstroAdapter,
	maybeConflictingIntegration: string,
	command?: 'dev' | 'build' | string,
) {
	if (settings.adapter && settings.adapter.name !== adapter.name) {
		throw new Error(
			`Integration "${maybeConflictingIntegration}" conflicts with "${settings.adapter.name}". You can only configure one deployment integration.`,
		);
	}

	if (settings.buildOutput === 'server' && adapter.adapterFeatures?.buildOutput === 'static') {
		// If the adapter is not compatible with the build output, throw an error
		if (command === 'build') {
			const adapterRecommendation = getAdapterStaticRecommendation(adapter.name);

			throw new AstroError({
				...AstroErrorData.AdapterSupportOutputMismatch,
				message: AstroErrorData.AdapterSupportOutputMismatch.message(adapter.name),
				hint: adapterRecommendation ? adapterRecommendation : undefined,
			});
		} else if (command === 'dev') {
			logger.warn(
				null,
				`The adapter ${adapter.name} does not support emitting a server output, but the project contain server-rendered pages. Your project will not build correctly.`,
			);
		}
	}
}

Domain

Subdomains

Dependencies

  • ../../integrations/features-validation.js
  • ../core/errors/index.js
  • ../core/logger/core.js
  • ../types/astro.js
  • ../types/public/integrations.js

Frequently Asked Questions

What does adapter-validation.ts do?
adapter-validation.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in adapter-validation.ts?
adapter-validation.ts defines 2 function(s): validateSetAdapter, warnMissingAdapter.
What does adapter-validation.ts depend on?
adapter-validation.ts imports 5 module(s): ../../integrations/features-validation.js, ../core/errors/index.js, ../core/logger/core.js, ../types/astro.js, ../types/public/integrations.js.
Where is adapter-validation.ts in the architecture?
adapter-validation.ts is located at packages/astro/src/core/dev/adapter-validation.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/astro/src/core/dev).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free