UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

20 lines (19 loc) 798 B
import path from "@reliverse/pathkit"; import { readPackageJSON } from "pkg-types"; export async function checkMissingDependencies(cwd, requiredContent, optionalContent) { const hasFilePackageJson = !!requiredContent.filePackageJson; const hasNodeModules = !!optionalContent.dirNodeModules; const hasMissingDeps = !hasNodeModules && hasFilePackageJson; let hasAnyDeps = false; if (hasFilePackageJson) { try { const pkgJson = await readPackageJSON(path.join(cwd, "package.json")); const depCount = Object.keys(pkgJson.dependencies || {}).length + Object.keys(pkgJson.devDependencies || {}).length; hasAnyDeps = depCount > 0; } catch { hasAnyDeps = false; } } const depsMissing = hasMissingDeps && hasAnyDeps; return { depsMissing, hasAnyDeps }; }