toolModule
uses tcmts.loader.packages.shippedPackage, which uses node:module
What a tool tcm provides is installed as in the codebase's cache (npm:vitest@5), or undefined when it's the one
tcm ships (shippedPackage), unless the codebase settled on a range that one isn't in (chosen with tcm upgrade <tool>@<range>, or the one its tests import Vitest at): at that range, else the newest release's. For installing
several at once (provideTool installs one).
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { toolRange } from "#codebase/tcmts/cli/lint"; import { compatRange, satisfies as satisfies_ } from "#codebase/tcmts/core/semver"; import { newestVersion, shippedPackage } from "#codebase/tcmts/loader/packages"; export function toolModule(cb: Codebase, name: string): string | undefined { const settled = toolRange(cb, name); const own = shippedPackage(name); if (own && (!settled || satisfies_(own.version, settled))) return undefined; const range = settled ?? compatRange(newestVersion(name) ?? ""); if (!range) throw new Error(`can't find ${name} on the registry`); return `npm:${name}@${range}`; }
uses
- tcmts.cli.codebase.Codebase
- tcmts.cli.lint.toolRange
- tcmts.core.semver.compatRange
- tcmts.core.semver.satisfies
- tcmts.loader.packages.newestVersion
- tcmts.loader.packages.shippedPackage