Home / Function/ listPreferences() — astro Function Reference

listPreferences() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  f72816d7_841e_fbeb_de77_6ad73e837140["listPreferences()"]
  f7d3fd10_bcd7_7c85_17b8_a4feb9026da8["index.ts"]
  f72816d7_841e_fbeb_de77_6ad73e837140 -->|defined in| f7d3fd10_bcd7_7c85_17b8_a4feb9026da8
  4ec23106_e310_07dc_a9e9_e382aeb6a997["preferences()"]
  4ec23106_e310_07dc_a9e9_e382aeb6a997 -->|calls| f72816d7_841e_fbeb_de77_6ad73e837140
  b045d455_54ca_d251_cfbc_9130e3a1cb5c["userValues()"]
  f72816d7_841e_fbeb_de77_6ad73e837140 -->|calls| b045d455_54ca_d251_cfbc_9130e3a1cb5c
  b7a701fd_4441_5459_1118_014908ce259d["formatTable()"]
  f72816d7_841e_fbeb_de77_6ad73e837140 -->|calls| b7a701fd_4441_5459_1118_014908ce259d
  2e7fb051_23e9_f08d_c196_584783577142["annotate()"]
  f72816d7_841e_fbeb_de77_6ad73e837140 -->|calls| 2e7fb051_23e9_f08d_c196_584783577142
  style f72816d7_841e_fbeb_de77_6ad73e837140 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/preferences/index.ts lines 244–298

async function listPreferences(settings: AstroSettings, { location, json }: SubcommandOptions) {
	if (json) {
		const resolved = await settings.preferences.getAll();
		console.log(JSON.stringify(resolved, null, 2));
		return 0;
	}
	const { global, project, fromAstroConfig, defaults } = await settings.preferences.list({
		location,
	});
	const flatProject = flattie(project);
	const flatGlobal = flattie(global);
	const flatDefault = flattie(defaults);
	const flatUser = userValues(flatDefault, flatProject, flatGlobal);

	const userKeys = Object.keys(flatUser);

	if (userKeys.length > 0) {
		const badge = bgGreen(black(` Your Preferences `));
		const table = formatTable(flatUser, ['Preference', 'Value']);

		console.log(['', badge, table].join('\n'));
	} else {
		const badge = bgGreen(black(` Your Preferences `));
		const message = dim('No preferences set');
		console.log(['', badge, '', message].join('\n'));
	}
	const flatUnset = annotate(Object.assign({}, flatDefault), '');
	for (const key of userKeys) {
		delete flatUnset[key];
	}
	const unsetKeys = Object.keys(flatUnset);

	if (unsetKeys.length > 0) {
		const badge = bgGreen(black(` Default Preferences `));
		const table = formatTable(flatUnset, ['Preference', 'Value']);

		console.log(['', badge, table].join('\n'));
	} else {
		const badge = bgGreen(black(` Default Preferences `));
		const message = dim('All preferences have been set');
		console.log(['', badge, '', message].join('\n'));
	}
	if (
		fromAstroConfig.devToolbar?.enabled === false &&
		flatUser['devToolbar.enabled']?.value !== false
	) {
		console.log(
			yellow(
				'The dev toolbar is currently disabled. To enable it, set devToolbar: {enabled: true} in your astroConfig file.',
			),
		);
	}

	return 0;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does listPreferences() do?
listPreferences() is a function in the astro codebase, defined in packages/astro/src/cli/preferences/index.ts.
Where is listPreferences() defined?
listPreferences() is defined in packages/astro/src/cli/preferences/index.ts at line 244.
What does listPreferences() call?
listPreferences() calls 3 function(s): annotate, formatTable, userValues.
What calls listPreferences()?
listPreferences() is called by 1 function(s): preferences.

Analyze Your Own Codebase

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

Try Supermodel Free