Home / File/ verify.ts — astro Source File

verify.ts — astro Source File

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

File typescript CoreAstro CoreMiddleware 9 imports 12 functions

Entity Profile

Dependency Diagram

graph LR
  bf354028_170b_aac5_1cb8_bcd8677afe9a["verify.ts"]
  73414401_e2bb_915f_9b7e_7876ce05c609["./messages.js"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> 73414401_e2bb_915f_9b7e_7876ce05c609
  a92de0dc_dbd8_66cd_eaac_504972b46b30["./actions/context.js"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> a92de0dc_dbd8_66cd_eaac_504972b46b30
  d75457f1_c905_87d9_5df9_ce5ad96e7abd["promises"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> d75457f1_c905_87d9_5df9_ce5ad96e7abd
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  5d6d1861_a18d_b246_cd94_08889ab7e74c["promises"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> 5d6d1861_a18d_b246_cd94_08889ab7e74c
  44da03af_fba3_824c_9c9c_2685d1d33d31["cli-kit"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> 44da03af_fba3_824c_9c9c_2685d1d33d31
  67038837_ac1f_0c49_bbbb_c0fd71688426["coerce.js"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> 67038837_ac1f_0c49_bbbb_c0fd71688426
  89179d86_4de7_4995_84d3_ea2a10a7a510["diff.js"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> 89179d86_4de7_4995_84d3_ea2a10a7a510
  dd10d914_20ca_9b72_39cd_bd28a6089ece["parse.js"]
  bf354028_170b_aac5_1cb8_bcd8677afe9a --> dd10d914_20ca_9b72_39cd_bd28a6089ece
  style bf354028_170b_aac5_1cb8_bcd8677afe9a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import dns from 'node:dns/promises';
import { existsSync } from 'node:fs';
import { readFile } from 'node:fs/promises';
import { color } from '@astrojs/cli-kit';
import semverCoerce from 'semver/functions/coerce.js';
import semverDiff from 'semver/functions/diff.js';
import semverParse from 'semver/functions/parse.js';
import { bannerAbort, error, getRegistry, info, newline } from '../messages.js';
import type { Context, PackageInfo } from './context.js';

export async function verify(
	ctx: Pick<Context, 'version' | 'packages' | 'cwd' | 'dryRun' | 'exit'>,
) {
	const registry = await getRegistry();

	if (!ctx.dryRun) {
		const online = await isOnline(registry);
		if (!online) {
			bannerAbort();
			newline();
			error('error', `Unable to connect to the internet.`);
			ctx.exit(1);
		}
	}

	const isAstroProject = await verifyAstroProject(ctx);
	if (!isAstroProject) {
		bannerAbort();
		newline();
		error('error', `Astro installation not found in the current directory.`);
		ctx.exit(1);
	}

	const ok = await verifyVersions(ctx, registry);
	if (!ok) {
		bannerAbort();
		newline();
		error('error', `Version ${color.reset(ctx.version)} ${color.dim('could not be found!')}`);
		await info('check', 'https://github.com/withastro/astro/releases');
		ctx.exit(1);
	}
}

function isOnline(registry: string): Promise<boolean> {
	const { hostname } = new URL(registry);
	return dns.lookup(hostname).then(
		() => true,
		() => false,
	);
}

function safeJSONParse(value: string) {
	try {
		return JSON.parse(value);
	} catch {}
	return {};
}

async function verifyAstroProject(ctx: Pick<Context, 'cwd' | 'version' | 'packages'>) {
	const packageJson = new URL('./package.json', ctx.cwd);
// ... (143 more lines)

Domain

Subdomains

Dependencies

  • ./actions/context.js
  • ./messages.js
  • cli-kit
  • coerce.js
  • diff.js
  • node:fs
  • parse.js
  • promises
  • promises

Frequently Asked Questions

What does verify.ts do?
verify.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in verify.ts?
verify.ts defines 12 function(s): collectPackageInfo, extractChangelogURLFromRepository, isAllowedPackage, isAstroPackage, isOnline, isSupportedPackage, isValidVersion, resolveTargetVersion, safeJSONParse, verify, and 2 more.
What does verify.ts depend on?
verify.ts imports 9 module(s): ./actions/context.js, ./messages.js, cli-kit, coerce.js, diff.js, node:fs, parse.js, promises, and 1 more.
Where is verify.ts in the architecture?
verify.ts is located at packages/upgrade/src/actions/verify.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/upgrade/src/actions).

Analyze Your Own Codebase

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

Try Supermodel Free