Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950// tests/fixtures/npm-cli.json, what real npm 11.7.0 did for each command over the cli// registry (`npm-oracle.mjs cli`), shared by the Node-side and browser specs.import { readFileSync } from "node:fs";import type { FakePackages } from "./npm-registry";// @ts-expect-error: an untyped .mjs scriptimport { cliPackageText } from "../scripts/npm-oracle.mjs";
export interface CliCase { description: string; args: string[]; package?: Record<string, unknown>; seed?: Record<string, unknown>; indent?: string | number; newline?: string; npm: { status: number; stdout: string; stderr: string; seedLock?: string; packageJson: string | null; lockfile: string | null; modules: string[] };}
/** What npm printed and how it exited. */export interface Output { status: number; stdout: string; stderr: string;}
/** A script, `npm exec` or npx case: `files` written into the project, run as `bin`. */export interface ScriptCase { description: string; args: string[]; bin?: "npm" | "npx"; package?: Record<string, unknown>; seed?: Record<string, unknown>; files: Record<string, string>; /** Run twice; the second run's output and registry requests are `npm.again`. */ again?: boolean; npm: Output & { /** The npx cache by hash: its package.json and package-lock.json. */ npx: Record<string, { packageJson: string | null; lockfile: string | null }> | null; again?: Output & { requests: string[] }; };}
export const cli = JSON.parse(readFileSync("tests/fixtures/npm-cli.json", "utf8")) as { registry: FakePackages; cases: Record<string, CliCase>; scripts: Record<string, ScriptCase>;};
/** package.json as npm found it when the command ran: the case's own, else the seed's. */export const startingPackage = (c: CliCase): string | undefined => (c.package ?? c.seed) && (cliPackageText(c, c.package ?? c.seed) as string);