update-check.ts — astro Source File
Architecture documentation for update-check.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b91228c7_974e_a490_80d5_1ddf98044159["update-check.ts"] 5f310fba_45ef_87f3_baa6_5e93f993468e["../../cli/install-package.js"] b91228c7_974e_a490_80d5_1ddf98044159 --> 5f310fba_45ef_87f3_baa6_5e93f993468e a170ca6a_e9d2_0356_ff6d_60b52ee58679["../preferences/index.js"] b91228c7_974e_a490_80d5_1ddf98044159 --> a170ca6a_e9d2_0356_ff6d_60b52ee58679 65300f14_7198_278b_9340_6e56b02fc2ea["ci-info"] b91228c7_974e_a490_80d5_1ddf98044159 --> 65300f14_7198_278b_9340_6e56b02fc2ea style b91228c7_974e_a490_80d5_1ddf98044159 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import ci from 'ci-info';
import { fetchPackageJson } from '../../cli/install-package.js';
import type { AstroPreferences } from '../../preferences/index.js';
export const MAX_PATCH_DISTANCE = 5; // If the patch distance is less than this, don't bother the user
const CHECK_MS_INTERVAL = 1_036_800_000; // 12 days, give or take
let _latestVersion: string | undefined = undefined;
export async function fetchLatestAstroVersion(
preferences: AstroPreferences | undefined,
): Promise<string> {
if (_latestVersion) {
return _latestVersion;
}
const packageJson = await fetchPackageJson(undefined, 'astro', 'latest');
if (packageJson instanceof Error) {
throw packageJson;
}
const version = packageJson?.version;
if (!version) {
throw new Error('Failed to fetch latest Astro version');
}
if (preferences) {
await preferences.set('_variables.lastUpdateCheck', Date.now(), { reloadServer: false });
}
_latestVersion = version;
return version;
}
export async function shouldCheckForUpdates(preferences: AstroPreferences): Promise<boolean> {
if (ci.isCI) {
return false;
}
const timeSinceLastCheck = Date.now() - (await preferences.get('_variables.lastUpdateCheck'));
const hasCheckUpdatesEnabled = await preferences.get('checkUpdates.enabled');
return (
timeSinceLastCheck > CHECK_MS_INTERVAL &&
process.env.ASTRO_DISABLE_UPDATE_CHECK !== 'true' &&
hasCheckUpdatesEnabled
);
}
Domain
Subdomains
Dependencies
- ../../cli/install-package.js
- ../preferences/index.js
- ci-info
Source
Frequently Asked Questions
What does update-check.ts do?
update-check.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 update-check.ts?
update-check.ts defines 2 function(s): fetchLatestAstroVersion, shouldCheckForUpdates.
What does update-check.ts depend on?
update-check.ts imports 3 module(s): ../../cli/install-package.js, ../preferences/index.js, ci-info.
Where is update-check.ts in the architecture?
update-check.ts is located at packages/astro/src/core/dev/update-check.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/astro/src/core/dev).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free