Home / File/ cli-astro-config-resolver.ts — astro Source File

cli-astro-config-resolver.ts — astro Source File

Architecture documentation for cli-astro-config-resolver.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  1aaedba5_1fb6_804c_dc52_1d6ee0080168["cli-astro-config-resolver.ts"]
  0b371444_fc7b_922f_b8b5_b663fe1868ae["../config/config.js"]
  1aaedba5_1fb6_804c_dc52_1d6ee0080168 --> 0b371444_fc7b_922f_b8b5_b663fe1868ae
  baa53824_73a3_1e03_2043_4d0c058ecca5["../types/public/index.js"]
  1aaedba5_1fb6_804c_dc52_1d6ee0080168 --> baa53824_73a3_1e03_2043_4d0c058ecca5
  9323e55c_9236_cd3d_d0b3_e20df52a4e84["../flags.js"]
  1aaedba5_1fb6_804c_dc52_1d6ee0080168 --> 9323e55c_9236_cd3d_d0b3_e20df52a4e84
  f458772b_5926_6ea0_4412_a27162311db0["../definitions.js"]
  1aaedba5_1fb6_804c_dc52_1d6ee0080168 --> f458772b_5926_6ea0_4412_a27162311db0
  style 1aaedba5_1fb6_804c_dc52_1d6ee0080168 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { resolveConfig } from '../../../core/config/config.js';
import type { AstroConfig } from '../../../types/public/index.js';
import type { Flags } from '../../flags.js';
import type { AstroConfigResolver } from '../definitions.js';
export class CliAstroConfigResolver implements AstroConfigResolver {
	// TODO: find something better
	readonly #flags: Flags;

	constructor({ flags }: { flags: Flags }) {
		this.#flags = flags;
	}

	async resolve(): Promise<AstroConfig> {
		const { astroConfig } = await resolveConfig(
			// TODO: consider testing flags => astro inline config
			{
				// Inline-only configs
				configFile: typeof this.#flags.config === 'string' ? this.#flags.config : undefined,
				mode: typeof this.#flags.mode === 'string' ? this.#flags.mode : undefined,
				logLevel: this.#flags.verbose ? 'debug' : this.#flags.silent ? 'silent' : undefined,
				force: this.#flags.force ? true : undefined,

				// Astro user configs
				root: typeof this.#flags.root === 'string' ? this.#flags.root : undefined,
				site: typeof this.#flags.site === 'string' ? this.#flags.site : undefined,
				base: typeof this.#flags.base === 'string' ? this.#flags.base : undefined,
				outDir: typeof this.#flags.outDir === 'string' ? this.#flags.outDir : undefined,
				server: {
					port: typeof this.#flags.port === 'number' ? this.#flags.port : undefined,
					host:
						typeof this.#flags.host === 'string' || typeof this.#flags.host === 'boolean'
							? this.#flags.host
							: undefined,
					open:
						typeof this.#flags.open === 'string' || typeof this.#flags.open === 'boolean'
							? this.#flags.open
							: undefined,
					allowedHosts:
						typeof this.#flags.allowedHosts === 'string'
							? this.#flags.allowedHosts.split(',')
							: typeof this.#flags.allowedHosts === 'boolean' && this.#flags.allowedHosts === true
								? this.#flags.allowedHosts
								: [],
				},
			},
			'info',
		);

		return astroConfig;
	}
}

Domain

Subdomains

Dependencies

  • ../config/config.js
  • ../definitions.js
  • ../flags.js
  • ../types/public/index.js

Frequently Asked Questions

What does cli-astro-config-resolver.ts do?
cli-astro-config-resolver.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What does cli-astro-config-resolver.ts depend on?
cli-astro-config-resolver.ts imports 4 module(s): ../config/config.js, ../definitions.js, ../flags.js, ../types/public/index.js.
Where is cli-astro-config-resolver.ts in the architecture?
cli-astro-config-resolver.ts is located at packages/astro/src/cli/info/infra/cli-astro-config-resolver.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