cmd() — astro Function Reference
Architecture documentation for the cmd() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 536e72f7_741f_9774_fd21_6923299f4850["cmd()"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21["index.ts"] 536e72f7_741f_9774_fd21_6923299f4850 -->|defined in| 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 style 536e72f7_741f_9774_fd21_6923299f4850 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/db/src/core/cli/commands/execute/index.ts lines 20–73
export async function cmd({
astroConfig,
dbConfig,
flags,
}: {
astroConfig: AstroConfig;
dbConfig: DBConfig;
flags: Arguments;
}) {
const filePath = flags._[4];
if (typeof filePath !== 'string') {
console.error(MISSING_EXECUTE_PATH_ERROR);
process.exit(1);
}
const fileUrl = new URL(filePath, astroConfig.root);
if (!existsSync(fileUrl)) {
console.error(FILE_NOT_FOUND_ERROR(filePath));
process.exit(1);
}
let virtualModContents: string;
if (flags.remote) {
const dbInfo = getRemoteDatabaseInfo();
const appToken = resolveDbAppToken(flags, dbInfo.token);
virtualModContents = getRemoteVirtualModContents({
tables: dbConfig.tables ?? {},
appToken,
isBuild: false,
output: 'server',
localExecution: true,
});
} else {
virtualModContents = getLocalVirtualModContents({
tables: dbConfig.tables ?? {},
root: astroConfig.root,
localExecution: true,
});
}
const { code } = await bundleFile({ virtualModContents, root: astroConfig.root, fileUrl });
const mod = await importBundledFile({ code, root: astroConfig.root });
if (typeof mod.default !== 'function') {
console.error(EXEC_DEFAULT_EXPORT_ERROR(filePath));
process.exit(1);
}
try {
await mod.default();
console.info(`${colors.green('✔')} File run successfully.`);
} catch (e) {
if (isDbError(e)) throw new Error(EXEC_ERROR(e.message));
else throw e;
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does cmd() do?
cmd() is a function in the astro codebase, defined in packages/db/src/core/cli/commands/execute/index.ts.
Where is cmd() defined?
cmd() is defined in packages/db/src/core/cli/commands/execute/index.ts at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free