/** The `workspaces` field of a root package.json: the array form or Yarn v1's object form. */ export type WorkspacesDeclaration = string[] | { packages?: string[]; } | undefined; /** * Every workspace package.json path (relative to the monorepo root, sorted) that Bun would link * for the given root package.json `workspaces` declaration. Canonicalizes the declared patterns * (see getMeaningfulDeclaredWorkspacePatterns), drops patterns escaping the repository (see * isInRepositoryWorkspacePattern), and resolves the rest with Bun's sequential semantics (see * resolveWorkspacePackageJsonPaths). */ export declare function resolveBunWorkspacePackageJsonPaths(workspaces: WorkspacesDeclaration, rootDirPath: string): string[]; /** * Resolves workspace patterns to package.json paths mimicking Bun's SEQUENTIAL evaluation, * derived empirically with Bun 1.3.14 (fixture repos observed via `bun install --lockfile-only`; * WillBooster/shared#1004 / WillBooster/shared#1005): * 1. Patterns are evaluated in declaration order into an accumulating set: a positive glob * pattern adds every package.json it matches; a negation deletes its matches from the set * accumulated SO FAR, so a later positive re-adds them (`["!apps/excluded", "apps/*"]` links * apps/excluded, while `["apps/*", "!apps/excluded"]` does not). * 2. A negation whose normalized body has EXACTLY two segments, whose last segment is a star-run * (`*`, `**`, `***`, …), and whose first segment is NOT itself a star-run first seeds the * implicit baseline into the set, then deletes its own matches: a `**` last segment seeds * `**` (packages at any depth), any other star-run seeds `*\/*` (depth 2 only). Seeding * happens even alongside positive patterns (`["apps/*", "!other/*"]` links every depth-2 * package outside other/). No other negation shape seeds: `!*`, `!**`, `!*\/*`, `!*\/**`, * `!**\/*`, `!a/b/*`, `!a/b/**`, `!dir`, and `!dir/*x` each link nothing on their own. * `?`, brace, and character-class last segments behave ERRATICALLY (`["!other/?"]` links * packages/a yet not the equally baseline-shaped other/yy, `["!other/??"]` links nothing, and * `["!?/?"]` links the very other/x it matches), so no consistent rule can model them; they * are deliberately treated as not seeding — see hasImplicitWorkspaceBaseline and #1005. * 3. A non-glob positive pattern PINS its directory: it stays a workspace regardless of where a * matching negation appears (`["other/x", "!other/x"]` and `["!other/x", "other/x"]` both * link other/x). * 4. `**` matches zero or more path segments (`["apps/**"]` links the package at apps itself, and * `!apps/**` deletes it), matching fast-glob's file-glob semantics. * Do not apply globIgnore here: workspace membership is defined solely by the declared patterns, * and source-scanning ignores such as `build` or `dist` would hide legitimately named workspace * directories. */ export declare function resolveWorkspacePackageJsonPaths(workspacePatterns: string[], rootDirPath: string): string[]; /** * Whether the declaration seeds Bun's implicit workspace baseline: it contains at least one * negation of the seeding shape (see resolveWorkspacePackageJsonPaths rule 2). Measured with Bun * 1.3.14, seeding is per-negation and happens even alongside positive patterns; concrete or * mixed-literal last segments (`!apps/excluded`, `!apps/*d`) never seed, and `?`, brace, and * character-class last segments behaved inconsistently across fixtures (sometimes dropping even * unrelated sibling workspaces), so they are conservatively treated as not seeding; see * WillBooster/shared#1005. */ export declare function hasImplicitWorkspaceBaseline(workspaces: WorkspacesDeclaration): boolean; /** * Declared workspace patterns without Bun's no-op ones (`""`, a lone `"!"`, and `"."`), which Bun * ignores entirely — a lone `"!"` must not activate the negative-only implicit baseline, and `""` * must not make the repository root itself a discovered workspace. Declaration order and * duplicates are preserved — Bun evaluates the patterns sequentially, so position matters. */ export declare function getMeaningfulDeclaredWorkspacePatterns(workspaces: WorkspacesDeclaration): string[]; /** * Collapses `//`, resolves `./`, and strips trailing slashes, mirroring Bun's path handling. * A pure star-run segment of three or more stars behaves like `*` under Bun (`!other/***` * matches other/x) but not under fast-glob, so canonicalize it to `*`. */ export declare function normalizeWorkspacePatternBody(patternBody: string): string; /** The implicit baseline glob a negation seeds under Bun's rule 2 above, or undefined if none. */ export declare function getSeededBaselineGlob(negationBody: string): string | undefined; /** Workspace patterns from either the array form or Yarn v1's `{ packages: […] }` object form. */ export declare function getDeclaredWorkspacePatterns(workspaces: WorkspacesDeclaration): string[]; /** * Whether a declared workspace pattern (negative ones included) stays inside the repository: * absolute or `..`-traversing patterns would make consumers such as node_modules cleanup operate * on another repository's files. */ export declare function isInRepositoryWorkspacePattern(workspacePattern: string): boolean;