Home / File/ dependencies.ts — astro Source File

dependencies.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 7 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a["dependencies.ts"]
  0d2ed6a4_ba13_53b9_91e8_1ccbdcaac22b["../messages.js"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> 0d2ed6a4_ba13_53b9_91e8_1ccbdcaac22b
  e51f17cb_f71d_9bde_fbf6_41f051063da5["./shell.js"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> e51f17cb_f71d_9bde_fbf6_41f051063da5
  6d4ff623_63ed_2360_85a7_197d38173f66["./actions/context.js"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> 6d4ff623_63ed_2360_85a7_197d38173f66
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> c52a5f83_66e3_37d7_9ebb_767f7129bc62
  5706e760_ec16_7da6_75dc_3f937461d99a["cli"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> 5706e760_ec16_7da6_75dc_3f937461d99a
  44da03af_fba3_824c_9c9c_2685d1d33d31["cli-kit"]
  ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a --> 44da03af_fba3_824c_9c9c_2685d1d33d31
  style ed06fbb8_fa50_eed4_1fe7_4e2bd1cca13a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fs from 'node:fs';
import path from 'node:path';
import { assertValidPackageName } from '@astrojs/internal-helpers/cli';
import { color } from '@astrojs/cli-kit';
import { error, info, title } from '../messages.js';
import { shell } from '../shell.js';
import type { Context } from './context.js';

export async function dependencies(
	ctx: Pick<
		Context,
		'install' | 'yes' | 'prompt' | 'packageManager' | 'cwd' | 'dryRun' | 'tasks' | 'add'
	>,
) {
	let deps = ctx.install ?? ctx.yes;
	if (deps === undefined) {
		({ deps } = await ctx.prompt({
			name: 'deps',
			type: 'confirm',
			label: title('deps'),
			message: `Install dependencies?`,
			hint: 'recommended',
			initial: true,
		}));
		ctx.install = deps;
	}
	ctx.add = ctx.add?.reduce<string[]>((acc, item) => acc.concat(item.split(',')), []);

	if (ctx.add) {
		for (const addValue of ctx.add) {
			// Validate package name to prevent command injection attacks
			assertValidPackageName(addValue);
		}
	}

	if (ctx.dryRun) {
		await info(
			'--dry-run',
			`Skipping dependency installation${ctx.add ? ` and adding ${ctx.add.join(', ')}` : ''}`,
		);
	} else if (deps) {
		ctx.tasks.push({
			pending: 'Dependencies',
			start: `Dependencies installing with ${ctx.packageManager}...`,
			end: 'Dependencies installed',
			onError: (e) => {
				error('error', e);
				error(
					'error',
					`Dependencies failed to install, please run ${color.bold(
						ctx.packageManager + ' install',
					)} to install them manually after setup.`,
				);
			},
			while: () => install({ packageManager: ctx.packageManager, cwd: ctx.cwd }),
		});

		let add = ctx.add;

		if (add) {
// ... (65 more lines)

Domain

Subdomains

Dependencies

  • ../messages.js
  • ./actions/context.js
  • ./shell.js
  • cli
  • cli-kit
  • node:fs
  • node:path

Frequently Asked Questions

What does dependencies.ts do?
dependencies.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 dependencies.ts?
dependencies.ts defines 4 function(s): astroAdd, dependencies, ensureYarnLock, install.
What does dependencies.ts depend on?
dependencies.ts imports 7 module(s): ../messages.js, ./actions/context.js, ./shell.js, cli, cli-kit, node:fs, node:path.
Where is dependencies.ts in the architecture?
dependencies.ts is located at packages/create-astro/src/actions/dependencies.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