docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility tool that helps developers select and list packages in a pnpm workspace based on various filtering criteria.
Build a package selector utility that can filter and identify packages in a pnpm workspace monorepo. The tool should support filtering by package name patterns and dependency relationships.
The utility should accept a workspace configuration and a set of filter criteria, then return the matching package names.
The selector must support the following filter patterns:
@scope/*)app, lib, utils, filtering by name app returns ["app"] @test@scope/pkg-a, @scope/pkg-b, other, filtering by glob pattern @scope/* returns ["@scope/pkg-a", "@scope/pkg-b"] @testapp depends on lib and utils, filtering by app with dependency inclusion returns ["app", "lib", "utils"] @testapp and service both depend on lib, filtering by lib with dependent inclusion returns ["app", "lib", "service"] @testapp, lib, utils, filtering by * with exclusion of lib returns ["app", "utils"] @test/**
* Represents a package in the workspace
*/
export interface WorkspacePackage {
name: string;
location: string;
dependencies: string[];
}
/**
* Filter criteria for package selection
*/
export interface FilterCriteria {
/** Package name or glob pattern to include */
includeNames?: string[];
/** Include dependencies of matched packages */
includeDependencies?: boolean;
/** Include dependents of matched packages */
includeDependents?: boolean;
/** Package names to exclude */
exclude?: string[];
}
/**
* Selects packages from a workspace based on filter criteria
*
* @param workspace - Array of workspace packages
* @param filter - Filter criteria to apply
* @returns Sorted array of matching package names
*/
export function selectPackages(
workspace: WorkspacePackage[],
filter: FilterCriteria
): string[];Provides package management capabilities for understanding workspace filtering patterns and behavior.