Home / File/ cli-debug-info-provider.ts — astro Source File

cli-debug-info-provider.ts — astro Source File

Architecture documentation for cli-debug-info-provider.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 4 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  ba2ed2e7_598d_d3c6_77bf_644cc65cf4d9["cli-debug-info-provider.ts"]
  baa53824_73a3_1e03_2043_4d0c058ecca5["../types/public/index.js"]
  ba2ed2e7_598d_d3c6_77bf_644cc65cf4d9 --> baa53824_73a3_1e03_2043_4d0c058ecca5
  7db42c05_e873_0887_a39f_34451c181149["../definitions.js"]
  ba2ed2e7_598d_d3c6_77bf_644cc65cf4d9 --> 7db42c05_e873_0887_a39f_34451c181149
  f458772b_5926_6ea0_4412_a27162311db0["../definitions.js"]
  ba2ed2e7_598d_d3c6_77bf_644cc65cf4d9 --> f458772b_5926_6ea0_4412_a27162311db0
  e5ceaf46_c86f_15d7_841c_6af002438fd8["../domain/debug-info.js"]
  ba2ed2e7_598d_d3c6_77bf_644cc65cf4d9 --> e5ceaf46_c86f_15d7_841c_6af002438fd8
  style ba2ed2e7_598d_d3c6_77bf_644cc65cf4d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { AstroConfig } from '../../../types/public/index.js';
import type { AstroVersionProvider, OperatingSystemProvider } from '../../definitions.js';
import type { DebugInfoProvider, NodeVersionProvider, PackageManager } from '../definitions.js';
import type { DebugInfo } from '../domain/debug-info.js';

function withVersion(name: string, version: string | undefined): string {
	let result = name;
	if (version) {
		result += ` (${version})`;
	}
	return result;
}

export class CliDebugInfoProvider implements DebugInfoProvider {
	readonly #config: Pick<AstroConfig, 'output' | 'adapter' | 'integrations'>;
	readonly #astroVersionProvider: AstroVersionProvider;
	readonly #packageManager: PackageManager;
	readonly #operatingSystemProvider: OperatingSystemProvider;
	readonly #nodeVersionProvider: NodeVersionProvider;

	constructor({
		config,
		astroVersionProvider,
		packageManager,
		operatingSystemProvider,
		nodeVersionProvider,
	}: {
		config: Pick<AstroConfig, 'output' | 'adapter' | 'integrations'>;
		astroVersionProvider: AstroVersionProvider;
		packageManager: PackageManager;
		operatingSystemProvider: OperatingSystemProvider;
		nodeVersionProvider: NodeVersionProvider;
	}) {
		this.#config = config;
		this.#astroVersionProvider = astroVersionProvider;
		this.#packageManager = packageManager;
		this.#operatingSystemProvider = operatingSystemProvider;
		this.#nodeVersionProvider = nodeVersionProvider;
	}

	async get(): Promise<DebugInfo> {
		const debugInfo: DebugInfo = [
			['Astro', `v${this.#astroVersionProvider.version}`],
			['Node', this.#nodeVersionProvider.version],
			['System', this.#operatingSystemProvider.displayName],
			['Package Manager', this.#packageManager.name],
			['Output', this.#config.output],
		];

		const viteVersion = await this.#packageManager.getPackageVersion('vite');

		if (viteVersion) {
			debugInfo.splice(1, 0, ['Vite', viteVersion]);
		}

		debugInfo.push([
			'Adapter',
			this.#config.adapter
				? withVersion(
						this.#config.adapter.name,
						await this.#packageManager.getPackageVersion(this.#config.adapter.name),
					)
				: 'none',
		]);

		const integrations = await Promise.all(
			this.#config.integrations.map(async ({ name }) =>
				withVersion(name, await this.#packageManager.getPackageVersion(name)),
			),
		);

		debugInfo.push(['Integrations', integrations.length > 0 ? integrations : 'none']);

		return debugInfo;
	}
}

Domain

Subdomains

Functions

Dependencies

  • ../definitions.js
  • ../definitions.js
  • ../domain/debug-info.js
  • ../types/public/index.js

Frequently Asked Questions

What does cli-debug-info-provider.ts do?
cli-debug-info-provider.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in cli-debug-info-provider.ts?
cli-debug-info-provider.ts defines 1 function(s): withVersion.
What does cli-debug-info-provider.ts depend on?
cli-debug-info-provider.ts imports 4 module(s): ../definitions.js, ../definitions.js, ../domain/debug-info.js, ../types/public/index.js.
Where is cli-debug-info-provider.ts in the architecture?
cli-debug-info-provider.ts is located at packages/astro/src/cli/info/infra/cli-debug-info-provider.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/cli/info/infra).

Analyze Your Own Codebase

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

Try Supermodel Free