/** * A parsed `bundle.packages.embed` entry: a package name — or a name * pattern with `*` wildcards — with an optional exact version pin * (`name` or `name@version`), optionally prefixed with `!` to make it an * exclusion. */ export interface EmbeddedPackageSpec { /** The raw config entry, `!` prefix included, kept for error messages. */ raw: string; /** * The package name, e.g. `@acme/private-utils` — or, when * {@link wildcard} is set, the raw name pattern, e.g. `@acme/*`. */ name: string; /** The exact pinned version, if the entry included one. */ version?: string; /** * True when the name contains `*` wildcards and matches as a pattern * rather than by exact comparison. Each single `*` matches any run of * characters except `/`, so it never crosses the scope separator * (`@acme/*` matches only packages in that scope; a bare `*` matches * only unscoped names). A run of two or more stars (`**`) matches any * run of characters *including* `/`: `**` alone matches every package, * and `**-foo` matches scoped and unscoped names alike. Directly before * a `/`, a `**` may also match nothing together with that `/` — the * glob habit, so `'**' + '/utils'` (one string; split here only because * `*` followed by `/` would end this comment) matches both `utils` and * `@acme/utils`. */ wildcard: boolean; /** * True when the entry was prefixed with `!`: instead of selecting * packages, it removes the ones it matches from what the entries before * it selected. */ exclude: boolean; } /** The parts of a lockfile entry a spec is matched against. */ export interface PackageRef { name: string; /** * Absent on entries the lockfile records without one, e.g. git, file and * URL resolutions and workspace links. */ version?: string; } /** * Whether a spec selects the given package name: exact comparison for * plain specs, pattern match for wildcard specs. */ export declare function specMatchesPackageName(spec: PackageNamePattern, packageName: string): boolean; /** * Whether an ordered pattern list selects the given name: a matching * plain entry selects it, a matching `!` exclusion deselects it, and the * last matching entry wins. This is the canonical definition of the * order-sensitive exclusion rule both `bundle.packages` options share * (`['@acme/*', '!@acme/keep']` selects the scope except `@acme/keep`, * while the reverse order selects the whole scope because the exclusion * ran before anything was selected); the embed materializer applies the * same rule per spec so it can attribute diagnostics to entries. */ export declare function patternsSelectName(patterns: PackageNamePattern[], name: string): boolean; /** * Whether a spec selects the given package: the name must match, and so * must an exact version pin. An entry the lockfile records without a * version never satisfies a pin. */ export declare function specMatchesPackage(spec: EmbeddedPackageSpec, entry: PackageRef): boolean; /** * As {@link specMatchesPackage}, except that a version-less entry matches * any pin. Used where such an entry is still worth reporting against a * pinned spec: a git resolution or a workspace link may well be the package * the user meant, recorded in a form that has no version to compare. */ export declare function specLooselyMatchesPackage(spec: EmbeddedPackageSpec, entry: PackageRef): boolean; export declare class InvalidEmbeddedPackageSpecError extends Error { /** The failure alone, without the `Invalid embedded package '':` prefix. */ readonly reason: string; constructor(spec: string, reason: string); } /** * Parses a `bundle.packages.embed` entry into a package name, an optional * exact version pin and whether the entry excludes rather than selects. * * Accepts `name` (embed every lockfile version of the package) and * `name@version` with an exact semver version. The name may contain `*` * and `**` wildcards (`@acme/*`, `acme-*`, `**-foo`), matching as * described on {@link EmbeddedPackageSpec.wildcard}. A `!` * prefix (`!@acme/legacy`, `!@acme/*`, * `!legacy@2.1.0`) marks the entry as an exclusion, subtracting from what * the entries before it selected. Version ranges are rejected: the * embedded tarball must be the exact artifact the lockfile resolved, so a * range has nothing meaningful to select against. A leading `v` is * stripped, but the version is otherwise kept as written (including any * build metadata) so it compares exactly against lockfile versions. */ export declare function parseEmbeddedPackageSpec(raw: string): EmbeddedPackageSpec; /** * A parsed package name pattern: a plain package name, or a name pattern * with `*` wildcards, optionally prefixed with `!` to make it an * exclusion — the name-matching subset of {@link EmbeddedPackageSpec}, * without the version pin. See the spec's field docs for the wildcard * and exclusion semantics. */ export type PackageNamePattern = Pick; export declare class InvalidPackageNamePatternError extends Error { constructor(raw: string, reason: string); } /** * Parses a package name pattern: a package name that may contain `*` * and `**` wildcards (`@acme/*`, `acme-*`, `**-foo`), matching as * described on {@link EmbeddedPackageSpec.wildcard}. A `!` prefix * marks the entry as an exclusion, subtracting from what the entries * before it selected, exactly as in `bundle.packages.embed`. Unlike * {@link parseEmbeddedPackageSpec} there are no `name@version` pins; * they are rejected with a pointed message so an embed-style pin fails * loudly instead of silently matching nothing. */ export declare function parsePackageNamePattern(raw: string): PackageNamePattern;