Home / Function/ updateAstroConfig() — astro Function Reference

updateAstroConfig() — astro Function Reference

Architecture documentation for the updateAstroConfig() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  b580bf78_66fd_0e74_f9b4_b1847fcf475e["updateAstroConfig()"]
  9151bb3d_ee1e_da42_752a_45a9db1dd918["index.ts"]
  b580bf78_66fd_0e74_f9b4_b1847fcf475e -->|defined in| 9151bb3d_ee1e_da42_752a_45a9db1dd918
  e251add5_ea46_2280_c246_1b5a023acc3b["add()"]
  e251add5_ea46_2280_c246_1b5a023acc3b -->|calls| b580bf78_66fd_0e74_f9b4_b1847fcf475e
  6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4["getDiffContent()"]
  b580bf78_66fd_0e74_f9b4_b1847fcf475e -->|calls| 6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4
  2ee262d1_8614_9c2d_75fd_5bb9c01ac63c["askToContinue()"]
  b580bf78_66fd_0e74_f9b4_b1847fcf475e -->|calls| 2ee262d1_8614_9c2d_75fd_5bb9c01ac63c
  style b580bf78_66fd_0e74_f9b4_b1847fcf475e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/add/index.ts lines 655–717

async function updateAstroConfig({
	configURL,
	mod,
	flags,
	logger,
	logAdapterInstructions,
}: {
	configURL: URL;
	mod: ProxifiedModule<any>;
	flags: Flags;
	logger: Logger;
	logAdapterInstructions: boolean;
}): Promise<UpdateResult> {
	const input = await fs.readFile(fileURLToPath(configURL), { encoding: 'utf-8' });
	const output = generateCode(mod, {
		format: {
			objectCurlySpacing: true,
			useTabs: false,
			tabWidth: 2,
		},
	}).code;

	if (input === output) {
		return UpdateResult.none;
	}

	const diff = getDiffContent(input, output);

	if (!diff) {
		return UpdateResult.none;
	}

	const message = `\n${boxen(diff, {
		margin: 0.5,
		padding: 0.5,
		borderStyle: 'round',
		title: configURL.pathname.split('/').pop(),
	})}\n`;

	logger.info(
		'SKIP_FORMAT',
		`\n  ${magenta('Astro will make the following changes to your config file:')}\n${message}`,
	);

	if (logAdapterInstructions) {
		logger.info(
			'SKIP_FORMAT',
			magenta(
				`  For complete deployment options, visit\n  ${bold(
					'https://docs.astro.build/en/guides/deploy/',
				)}\n`,
			),
		);
	}

	if (await askToContinue({ flags, logger })) {
		await fs.writeFile(fileURLToPath(configURL), output, { encoding: 'utf-8' });
		logger.debug('add', `Updated astro config`);
		return UpdateResult.updated;
	} else {
		return UpdateResult.cancelled;
	}
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does updateAstroConfig() do?
updateAstroConfig() is a function in the astro codebase, defined in packages/astro/src/cli/add/index.ts.
Where is updateAstroConfig() defined?
updateAstroConfig() is defined in packages/astro/src/cli/add/index.ts at line 655.
What does updateAstroConfig() call?
updateAstroConfig() calls 2 function(s): askToContinue, getDiffContent.
What calls updateAstroConfig()?
updateAstroConfig() 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