/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { Package } from "@fluidframework/build-tools"; import type { PackageSelectionDefault, filterFlags, selectionFlags } from "./flags.js"; import type { Context } from "./library/index.js"; import { type ReleaseGroup } from "./releaseGroups.js"; /** * The criteria that should be used for selecting package-like objects from a collection. */ export interface PackageSelectionCriteria { /** * True if independent packages are selected; false otherwise. */ independentPackages: boolean; /** * An array of release groups whose packages are selected. */ releaseGroups: ReleaseGroup[]; /** * An array of release groups whose root packages are selected. */ releaseGroupRoots: ReleaseGroup[]; /** * Selects a package rooted in a directory. */ directory?: string[]; /** * If set, only selects packages that have changes when compared with the branch of this name. */ changedSinceBranch?: string; } /** * A pre-defined PackageSelectionCriteria that selects all packages. */ export declare const AllPackagesSelectionCriteria: PackageSelectionCriteria; /** * The criteria that should be used for filtering package-like objects from a collection. */ export interface PackageFilterOptions { /** * If set, filters IN packages whose scope matches the strings provided. */ scope?: string[]; /** * If set, filters OUT packages whose scope matches the strings provided. */ skipScope?: string[]; /** * If set, filters private packages in/out. */ private: boolean | undefined; } /** * Parses {@link selectionFlags} into a typed object that is more ergonomic than working with the flag values directly. * * @param flags - The parsed command flags. * @param defaultSelection - Controls what packages are selected when all flags are set to their default values. With * the default value of undefined, no packages will be selected. Setting this to `all` will select all packages by * default. Setting it to `dir` will select the package in the current directory. */ export declare const parsePackageSelectionFlags: (flags: selectionFlags, defaultSelection: PackageSelectionDefault) => PackageSelectionCriteria; /** * Parses {@link filterFlags} into a typed object that is more ergonomic than working with the flag values directly. * * @param flags - The parsed command flags. */ export declare const parsePackageFilterFlags: (flags: filterFlags) => PackageFilterOptions; /** * A type indicating the kind of package that is being processed. This enables subcommands to vary behavior based on the * type of package. */ export type PackageKind = /** * Package is an independent package. */ "independentPackage" /** * Package is part of a release group, but is _not_ the root. */ | "releaseGroupChildPackage" /** * Package is the root package of a release group. */ | "releaseGroupRootPackage" /** * Package is being loaded from a directory. The package may be one of the other three kinds. This kind is only used * when running on a package directly using its directory. */ | "packageFromDirectory"; /** * A convenience type mapping a package to its PackageKind. */ export type PackageWithKind = Package & { kind: PackageKind; }; /** * Selects packages from the context based on the selection. * * @param context - The context. * @param selection - The selection criteria to use to select packages. * @returns An array containing the selected packages. */ export declare function selectPackagesFromContext(context: Context, selection: PackageSelectionCriteria): Promise; /** * Selects packages from the context based on the selection. The selected packages will be filtered by the filter * criteria if provided. * * @param context - The context. * @param selection - The selection criteria to use to select packages. * @param filter - An optional filter criteria to filter selected packages by. * @returns An object containing the selected packages and the filtered packages. */ export declare function selectAndFilterPackages(context: Context, selection: PackageSelectionCriteria, filter?: PackageFilterOptions): Promise<{ selected: PackageWithKind[]; filtered: PackageWithKind[]; }>; /** * Convenience type that extracts only the properties of a package that are needed for filtering. */ type FilterablePackage = Pick; /** * Filters a list of packages by the filter criteria. * * @param packages - An array of packages to be filtered. * @param filters - The filter criteria to filter the packages by. * @typeParam T - The type of the package-like objects being filtered. * @returns An array containing only the filtered items. */ export declare function filterPackages(packages: T[], filters: PackageFilterOptions): Promise; export {}; //# sourceMappingURL=filter.d.ts.map