UNPKG

@roots/bud

Version:

Configurable, extensible build tools for modern single and multi-page web applications

49 lines (48 loc) 2.2 kB
import { jsxs as _jsxs, jsx as _jsx } from "@roots/bud-support/jsx-runtime"; import { LabelBox } from '@roots/bud/cli/components/LabelBox'; import { BudError, render as renderError } from '@roots/bud-support/errors'; import figures from '@roots/bud-support/figures'; import { Box, Text } from '@roots/bud-support/ink'; export const Versions = ({ packages, }) => { if (!packages) return null; return (_jsx(LabelBox, { label: "Version compatibility", children: packages.map((result, i) => { if (typeof result === `string`) { return (_jsxs(Text, { dimColor: true, children: [figures.ellipsis, " ", result] }, i)); } if (result.error) { renderError(BudError.normalize(`${result.signifier} is not installed at the same version as @roots/bud (required: ${result.requiredVersion}, installed: ${result.packageVersion}). Your installation may be corrupted or your package manager may have cached an outdated module; consider reinstalling with the \`--force\` flag.`)); return null; } return (_jsx(Box, { children: _jsx(Package, { ...result }) }, i)); }) })); }; export const criticalPackages = [ `@roots/bud-api`, `@roots/bud-build`, `@roots/bud-cache`, `@roots/bud-dashboard`, `@roots/bud-extensions`, `@roots/bud-framework`, `@roots/bud-hooks`, `@roots/bud-server`, `@roots/bud-support`, ]; export const getPackageResults = async function (signifier) { const manifest = await this.module.getManifestPath(signifier); if (!manifest) return null; const result = await this.fs.read(manifest); if (!result?.version) return null; return { error: result.version !== this.context.bud.version, packageVersion: result.version, requiredVersion: this.context.bud.version, signifier, }; }; const Package = (result) => { return (_jsxs(Text, { children: [_jsxs(Text, { color: "green", children: [figures.tick, " ", result.signifier, " meets requirements"] }), ` `, "(required:", ` `, result.requiredVersion, ", installed: ", result.packageVersion, ")"] })); };