Home / File/ context.ts — astro Source File

context.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 6 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  c681252d_5f25_a22f_ed87_079b092a96de["context.ts"]
  c89134d8_c71b_d6ca_daa8_c15e8542e1b1["../data/seasonal.js"]
  c681252d_5f25_a22f_ed87_079b092a96de --> c89134d8_c71b_d6ca_daa8_c15e8542e1b1
  0d2ed6a4_ba13_53b9_91e8_1ccbdcaac22b["../messages.js"]
  c681252d_5f25_a22f_ed87_079b092a96de --> 0d2ed6a4_ba13_53b9_91e8_1ccbdcaac22b
  b326953c_dc9d_ec9e_dc34_4beead549f6e["node:os"]
  c681252d_5f25_a22f_ed87_079b092a96de --> b326953c_dc9d_ec9e_dc34_4beead549f6e
  44da03af_fba3_824c_9c9c_2685d1d33d31["cli-kit"]
  c681252d_5f25_a22f_ed87_079b092a96de --> 44da03af_fba3_824c_9c9c_2685d1d33d31
  3b35366d_8979_cafe_57a9_c7ee6fd913bc["utils"]
  c681252d_5f25_a22f_ed87_079b092a96de --> 3b35366d_8979_cafe_57a9_c7ee6fd913bc
  1ebc273e_6893_8f45_2d8f_9ad5840c6521["arg"]
  c681252d_5f25_a22f_ed87_079b092a96de --> 1ebc273e_6893_8f45_2d8f_9ad5840c6521
  style c681252d_5f25_a22f_ed87_079b092a96de fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import os from 'node:os';
import { prompt, type Task } from '@astrojs/cli-kit';
import { random } from '@astrojs/cli-kit/utils';
import arg from 'arg';

import getSeasonalData from '../data/seasonal.js';
import { getName, getVersion } from '../messages.js';

export interface Context {
	help: boolean;
	prompt: typeof prompt;
	cwd: string;
	packageManager: string;
	username: Promise<string>;
	version: Promise<string>;
	skipHouston: boolean;
	fancy?: boolean;
	add?: string[];
	dryRun?: boolean;
	yes?: boolean;
	projectName?: string;
	template?: string;
	ref: string;
	install?: boolean;
	git?: boolean;
	typescript?: string;
	stdin?: typeof process.stdin;
	stdout?: typeof process.stdout;
	exit(code: number): never;
	welcome?: string;
	hat?: string;
	tie?: string;
	tasks: Task[];
}

function getPackageTag(packageSpecifier: string | undefined): string | undefined {
	switch (packageSpecifier) {
		case 'alpha':
		case 'beta':
		case 'rc':
			return packageSpecifier;
		// Will fallback to latest
		case undefined:
		default:
			return undefined;
	}
}

export async function getContext(argv: string[]): Promise<Context> {
	const packageSpecifier = argv
		.find((argItem) => /^(astro|create-astro)@/.exec(argItem))
		?.split('@')[1];

	const flags = arg(
		{
			'--template': String,
			'--ref': String,
			'--yes': Boolean,
			'--no': Boolean,
			'--install': Boolean,
// ... (95 more lines)

Domain

Subdomains

Types

Dependencies

  • ../data/seasonal.js
  • ../messages.js
  • arg
  • cli-kit
  • node:os
  • utils

Frequently Asked Questions

What does context.ts do?
context.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in context.ts?
context.ts defines 3 function(s): detectPackageManager, getContext, getPackageTag.
What does context.ts depend on?
context.ts imports 6 module(s): ../data/seasonal.js, ../messages.js, arg, cli-kit, node:os, utils.
Where is context.ts in the architecture?
context.ts is located at packages/create-astro/src/actions/context.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/create-astro/src/actions).

Analyze Your Own Codebase

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

Try Supermodel Free