getContext() — astro Function Reference
Architecture documentation for the getContext() function in context.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD f1c523e9_47f3_0df8_b232_69ccf3789a51["getContext()"] c681252d_5f25_a22f_ed87_079b092a96de["context.ts"] f1c523e9_47f3_0df8_b232_69ccf3789a51 -->|defined in| c681252d_5f25_a22f_ed87_079b092a96de 53c566d3_df05_f23d_3735_7142f26932a7["detectPackageManager()"] f1c523e9_47f3_0df8_b232_69ccf3789a51 -->|calls| 53c566d3_df05_f23d_3735_7142f26932a7 bd44da83_464b_cc04_2da8_b0da33b88415["getPackageTag()"] f1c523e9_47f3_0df8_b232_69ccf3789a51 -->|calls| bd44da83_464b_cc04_2da8_b0da33b88415 style f1c523e9_47f3_0df8_b232_69ccf3789a51 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/create-astro/src/actions/context.ts lines 49–147
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,
'--no-install': Boolean,
'--git': Boolean,
'--no-git': Boolean,
'--skip-houston': Boolean,
'--dry-run': Boolean,
'--help': Boolean,
'--fancy': Boolean,
'--add': [String],
'-y': '--yes',
'-n': '--no',
'-h': '--help',
},
{ argv, permissive: true },
);
const packageManager = detectPackageManager() ?? 'npm';
let cwd = flags['_'][0];
let {
'--help': help = false,
'--template': template,
'--no': no,
'--yes': yes,
'--install': install,
'--no-install': noInstall,
'--git': git,
'--no-git': noGit,
'--fancy': fancy,
'--skip-houston': skipHouston,
'--dry-run': dryRun,
'--ref': ref,
'--add': add,
} = flags;
if (add?.length && noInstall) {
console.error(
'The --add flag requires dependencies to be installed. Remove --no-install or run `astro add` manually after installation.',
);
process.exit(1);
}
let projectName = cwd;
if (no) {
yes = false;
if (install == undefined) install = false;
if (git == undefined) git = false;
}
skipHouston =
((os.platform() === 'win32' && !fancy) || skipHouston) ??
[yes, no, install, git].some((v) => v !== undefined);
const { messages, hats, ties } = getSeasonalData({ fancy });
const context: Context = {
help,
prompt,
packageManager,
username: getName(),
version: getVersion(
packageManager,
'astro',
getPackageTag(packageSpecifier),
process.env.ASTRO_VERSION,
),
skipHouston,
fancy,
add,
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does getContext() do?
getContext() is a function in the astro codebase, defined in packages/create-astro/src/actions/context.ts.
Where is getContext() defined?
getContext() is defined in packages/create-astro/src/actions/context.ts at line 49.
What does getContext() call?
getContext() calls 2 function(s): detectPackageManager, getPackageTag.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free