Home / File/ index.ts — astro Source File

index.ts — astro Source File

Architecture documentation for index.ts, a typescript file in the astro codebase. 1 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  0c4bed6a_6435_4d3c_5d6b_f506169521dd["index.ts"]
  96259777_5f31_6fa7_d14e_b558b64371d6["yargs-parser"]
  0c4bed6a_6435_4d3c_5d6b_f506169521dd --> 96259777_5f31_6fa7_d14e_b558b64371d6
  style 0c4bed6a_6435_4d3c_5d6b_f506169521dd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import yargs from 'yargs-parser';

type CLICommand =
	| 'help'
	| 'version'
	| 'add'
	| 'create-key'
	| 'docs'
	| 'dev'
	| 'build'
	| 'preview'
	| 'db'
	| 'sync'
	| 'check'
	| 'info'
	| 'preferences'
	| 'telemetry';

/** Determine which command the user requested */
function resolveCommand(flags: yargs.Arguments): CLICommand {
	const cmd = flags._[2] as string;
	if (flags.version) return 'version';

	const supportedCommands = new Set([
		'add',
		'sync',
		'telemetry',
		'preferences',
		'dev',
		'build',
		'preview',
		'check',
		'create-key',
		'docs',
		'db',
		'info',
		'login',
		'logout',
		'link',
		'init',
	]);
	if (supportedCommands.has(cmd)) {
		return cmd as CLICommand;
	}
	return 'help';
}

/**
 * Run the given command with the given flags.
 * NOTE: This function provides no error handling, so be sure
 * to present user-friendly error output where the fn is called.
 **/
async function runCommand(cmd: string, flags: yargs.Arguments) {
	const [
		{ createLoggerFromFlags },
		{ piccoloreTextStyler: textStyler },
		{ BuildTimeAstroVersionProvider },
		{ LoggerHelpDisplay },
		{ CliCommandRunner },
	] = await Promise.all([
// ... (223 more lines)

Domain

Subdomains

Types

Dependencies

  • yargs-parser

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 FrameworkCore domain, IntegrationHooks subdomain.
What functions are defined in index.ts?
index.ts defines 3 function(s): cli, resolveCommand, runCommand.
What does index.ts depend on?
index.ts imports 1 module(s): yargs-parser.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/cli/index.ts (domain: FrameworkCore, subdomain: IntegrationHooks, directory: packages/astro/src/cli).

Analyze Your Own Codebase

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

Try Supermodel Free