index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21["index.ts"] e4a7cb59_3c1e_4823_8146_150431eedb41["./utils.js"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> e4a7cb59_3c1e_4823_8146_150431eedb41 57319c2a_db71_c5b3_0171_5f4c55721d69["./errors.js"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> 57319c2a_db71_c5b3_0171_5f4c55721d69 b81d717b_ec28_afd6_a1fc_5f065ee1b5a2["./integration/vite-plugin-db.js"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> b81d717b_ec28_afd6_a1fc_5f065ee1b5a2 49fbaf05_0dfa_cb97_d06e_040957f39092["../load-file.js"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> 49fbaf05_0dfa_cb97_d06e_040957f39092 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8["./core/types.js"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8 6ae6435e_1314_7d59_4826_25e9a2ada03f["./utils.js"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> 6ae6435e_1314_7d59_4826_25e9a2ada03f e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 f16d8c76_2866_6150_bd14_0347b59abfe9["astro"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> f16d8c76_2866_6150_bd14_0347b59abfe9 10250468_0e83_bd69_43e9_3bcef2294a91["piccolore"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> 10250468_0e83_bd69_43e9_3bcef2294a91 efd0f150_4239_ba62_fbb9_bcf24bd27236["yargs-parser"] 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 --> efd0f150_4239_ba62_fbb9_bcf24bd27236 style 707e93ba_120b_cdd8_3cb6_f2c9c6e9bf21 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { existsSync } from 'node:fs';
import type { AstroConfig } from 'astro';
import colors from 'piccolore';
import type { Arguments } from 'yargs-parser';
import { isDbError } from '../../../../runtime/utils.js';
import {
EXEC_DEFAULT_EXPORT_ERROR,
EXEC_ERROR,
FILE_NOT_FOUND_ERROR,
MISSING_EXECUTE_PATH_ERROR,
} from '../../../errors.js';
import {
getLocalVirtualModContents,
getRemoteVirtualModContents,
} from '../../../integration/vite-plugin-db.js';
import { bundleFile, importBundledFile } from '../../../load-file.js';
import type { DBConfig } from '../../../types.js';
import { getRemoteDatabaseInfo, resolveDbAppToken } from '../../../utils.js';
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
Functions
Dependencies
- ../load-file.js
- ./core/types.js
- ./errors.js
- ./integration/vite-plugin-db.js
- ./utils.js
- ./utils.js
- astro
- node:fs
- piccolore
- yargs-parser
Source
Frequently Asked Questions
What does index.ts do?
index.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in index.ts?
index.ts defines 1 function(s): cmd.
What does index.ts depend on?
index.ts imports 10 module(s): ../load-file.js, ./core/types.js, ./errors.js, ./integration/vite-plugin-db.js, ./utils.js, ./utils.js, astro, node:fs, and 2 more.
Where is index.ts in the architecture?
index.ts is located at packages/db/src/core/cli/commands/execute/index.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/db/src/core/cli/commands/execute).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free