Home / Function/ cmd() — astro Function Reference

cmd() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  cb6d44e4_ba68_60e2_0075_6166737a50e4["cmd()"]
  a931fece_62f1_4c62_c89f_02de71023cb2["index.ts"]
  cb6d44e4_ba68_60e2_0075_6166737a50e4 -->|defined in| a931fece_62f1_4c62_c89f_02de71023cb2
  style cb6d44e4_ba68_60e2_0075_6166737a50e4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/db/src/core/cli/commands/verify/index.ts lines 13–54

export async function cmd({
	dbConfig,
	flags,
}: {
	astroConfig: AstroConfig;
	dbConfig: DBConfig;
	flags: Arguments;
}) {
	const isJson = flags.json;
	const dbInfo = getRemoteDatabaseInfo();
	const appToken = resolveDbAppToken(flags, dbInfo.token);
	const productionSnapshot = await getProductionCurrentSnapshot({ ...dbInfo, token: appToken });
	const currentSnapshot = createCurrentSnapshot(dbConfig);
	const { queries: migrationQueries, confirmations } = await getMigrationQueries({
		oldSnapshot: productionSnapshot || createEmptySnapshot(),
		newSnapshot: currentSnapshot,
	});

	const result = { exitCode: 0, message: '', code: '', data: undefined as unknown };
	if (migrationQueries.length === 0) {
		result.code = 'MATCH';
		result.message = `Database schema is up to date.`;
	} else {
		result.code = 'NO_MATCH';
		result.message = `Database schema is out of date.\nRun 'astro db push' to push up your latest changes.`;
	}

	if (confirmations.length > 0) {
		result.code = 'DATA_LOSS';
		result.exitCode = 1;
		result.data = confirmations;
		result.message = formatDataLossMessage(confirmations, !isJson);
	}

	if (isJson) {
		console.log(JSON.stringify(result));
	} else {
		console.log(result.message);
	}

	process.exit(result.exitCode);
}

Domain

Subdomains

Frequently Asked Questions

What does cmd() do?
cmd() is a function in the astro codebase, defined in packages/db/src/core/cli/commands/verify/index.ts.
Where is cmd() defined?
cmd() is defined in packages/db/src/core/cli/commands/verify/index.ts at line 13.

Analyze Your Own Codebase

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

Try Supermodel Free