Home / File/ messages.ts — astro Source File

messages.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 5 imports 13 functions

Entity Profile

Dependency Diagram

graph LR
  7e47cce3_632a_b102_4402_d13baf44fc8e["messages.ts"]
  e51f17cb_f71d_9bde_fbf6_41f051063da5["./shell.js"]
  7e47cce3_632a_b102_4402_d13baf44fc8e --> e51f17cb_f71d_9bde_fbf6_41f051063da5
  dc804f3e_b1ea_df4a_3cc9_40b536be6a5d["node:child_process"]
  7e47cce3_632a_b102_4402_d13baf44fc8e --> dc804f3e_b1ea_df4a_3cc9_40b536be6a5d
  b4a76fc8_3591_85b4_7b57_55ab21d1030d["node:util"]
  7e47cce3_632a_b102_4402_d13baf44fc8e --> b4a76fc8_3591_85b4_7b57_55ab21d1030d
  44da03af_fba3_824c_9c9c_2685d1d33d31["cli-kit"]
  7e47cce3_632a_b102_4402_d13baf44fc8e --> 44da03af_fba3_824c_9c9c_2685d1d33d31
  3b35366d_8979_cafe_57a9_c7ee6fd913bc["utils"]
  7e47cce3_632a_b102_4402_d13baf44fc8e --> 3b35366d_8979_cafe_57a9_c7ee6fd913bc
  style 7e47cce3_632a_b102_4402_d13baf44fc8e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { exec } from 'node:child_process';
import { stripVTControlCharacters } from 'node:util';
/* eslint no-console: 'off' */
import { color, say as houston, label } from '@astrojs/cli-kit';
import { align, sleep } from '@astrojs/cli-kit/utils';
import { shell } from './shell.js';

// Users might lack access to the global npm registry, this function
// checks the user's project type and will return the proper npm registry
//
// A copy of this function also exists in the astro package
let _registry: string;
async function getRegistry(packageManager: string): Promise<string> {
	if (_registry) return _registry;
	const fallback = 'https://registry.npmjs.org';
	try {
		const { stdout } = await shell(packageManager, ['config', 'get', 'registry']);
		_registry = stdout?.trim()?.replace(/\/$/, '') || fallback;
		// Detect cases where the shell command returned a non-URL (e.g. a warning)
		if (!new URL(_registry).host) _registry = fallback;
	} catch {
		_registry = fallback;
	}
	return _registry;
}

let stdout = process.stdout;
/** @internal Used to mock `process.stdout.write` for testing purposes */
export function setStdout(writable: typeof process.stdout) {
	stdout = writable;
}

export async function say(messages: string | string[], { clear = false, hat = '', tie = '' } = {}) {
	return houston(messages, { clear, hat, tie, stdout });
}

export const title = (text: string) => align(label(text), 'end', 7) + ' ';

export const getName = () =>
	new Promise<string>((resolve) => {
		exec('git config user.name', { encoding: 'utf-8' }, (_1, gitName) => {
			if (gitName.trim()) {
				return resolve(gitName.split(' ')[0].trim());
			}
			exec('whoami', { encoding: 'utf-8' }, (_3, whoami) => {
				if (whoami.trim()) {
					return resolve(whoami.split(' ')[0].trim());
				}
				return resolve('astronaut');
			});
		});
	});

export const getVersion = (
	packageManager: string,
	packageName: string,
	packageTag = 'latest',
	fallback = '',
) =>
	new Promise<string>(async (resolve) => {
// ... (139 more lines)

Domain

Subdomains

Dependencies

  • ./shell.js
  • cli-kit
  • node:child_process
  • node:util
  • utils

Frequently Asked Questions

What does messages.ts do?
messages.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 messages.ts?
messages.ts defines 13 function(s): banner, bannerAbort, error, getName, getRegistry, getVersion, info, log, nextSteps, printHelp, and 3 more.
What does messages.ts depend on?
messages.ts imports 5 module(s): ./shell.js, cli-kit, node:child_process, node:util, utils.
Where is messages.ts in the architecture?
messages.ts is located at packages/create-astro/src/messages.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/create-astro/src).

Analyze Your Own Codebase

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

Try Supermodel Free