import type { ITerminal } from '@rushstack/terminal';
import type { RushConfigurationProject } from './RushConfigurationProject';
import type { IPhase } from './CommandLineConfiguration';
/**
 * Describes the file structure for the `<project root>/config/rush-project.json` config file.
 * @internal
 */
export interface IRushProjectJson {
    /**
     * The incremental analyzer can skip Rush commands for projects whose input files have
     * not changed since the last build. Normally, every Git-tracked file under the project
     * folder is assumed to be an input. Set incrementalBuildIgnoredGlobs to ignore specific
     * files, specified as globs relative to the project folder. The list of file globs will
     * be interpreted the same way your .gitignore file is.
     */
    incrementalBuildIgnoredGlobs?: string[];
    /**
     * Disable caching for this project. The project will never be restored from cache.
     * This may be useful if this project affects state outside of its folder.
     *
     * This option is only used when the build cache is enabled for the repo. You can set
     * disableBuildCacheForProject=true to disable caching for a specific project. This is a useful workaround
     * if that project's build scripts violate the assumptions of the cache, for example by writing
     * files outside the project folder. Where possible, a better solution is to improve the build scripts
     * to be compatible with caching.
     */
    disableBuildCacheForProject?: boolean;
    operationSettings?: IOperationSettings[];
}
/** @alpha */
export interface IRushPhaseSharding {
    /**
     * The number of shards to create.
     */
    count: number;
    /**
     * The format of the argument to pass to the command to indicate the shard index and count.
     *
     * @defaultValue `--shard={shardIndex}/{shardCount}`
     */
    shardArgumentFormat?: string;
    /**
     * An optional argument to pass to the command to indicate the output folder for the shard.
     *  It must end with `{shardIndex}`.
     *
     * @defaultValue `--shard-output-folder=.rush/operations/{phaseName}/shards/{shardIndex}`.
     */
    outputFolderArgumentFormat?: string;
    /**
     * @deprecated Create a separate operation settings object for the shard operation settings with the name `{operationName}:shard`.
     */
    shardOperationSettings?: unknown;
}
/**
 * The granularity at which the Node.js version is included in the build cache hash.
 *
 * - `"major"` - includes only the major version (e.g. `18`)
 * - `"minor"` - includes the major and minor version (e.g. `18.17`)
 * - `"patch"` - includes the full version (e.g. `18.17.1`)
 *
 * @alpha
 */
export type NodeVersionGranularity = 'major' | 'minor' | 'patch';
/**
 * @alpha
 */
export interface IOperationSettings {
    /**
     * The name of the operation. This should be a key in the `package.json`'s `scripts` object.
     */
    operationName: string;
    /**
     * Specify the folders where this operation writes its output files. If enabled, the Rush build
     * cache will restore these folders from the cache. The strings are folder names under the project
     * root folder.
     *
     * These folders should not be tracked by Git. They must not contain symlinks.
     */
    outputFolderNames?: string[];
    /**
     * Disable caching for this operation. The operation will never be restored from cache.
     * This may be useful if this operation affects state outside of its folder.
     *
     * This option is only used when the build cache is enabled for the repo. You can set
     * disableBuildCacheForOperation=true to disable caching for a specific project operation.
     * This is a useful workaround if that project's build scripts violate the assumptions of the cache,
     * for example by writing files outside the project folder. Where possible, a better solution is to improve
     * the build scripts to be compatible with caching.
     */
    disableBuildCacheForOperation?: boolean;
    /**
     * An optional list of environment variables that can affect this operation. The values of
     * these environment variables will become part of the hash when reading and writing the build cache.
     *
     * Note: generally speaking, all environment variables available to Rush are also available to any
     * operations performed -- Rush assumes that environment variables do not affect build outputs unless
     * you list them here.
     */
    dependsOnEnvVars?: string[];
    /**
     * Specifies whether and at what granularity the Node.js version should be included in the hash
     * used for the build cache. When enabled, changing the Node.js version at the specified granularity
     * will invalidate cached outputs and cause the operation to be re-executed. This is useful for
     * projects that produce Node.js-version-specific outputs, such as native module builds.
     *
     * Allowed values:
     * - `true` - alias for `"patch"`, includes the full version (e.g. `18.17.1`)
     * - `"major"` - includes only the major version (e.g. `18`)
     * - `"minor"` - includes the major and minor version (e.g. `18.17`)
     * - `"patch"` - includes the full version (e.g. `18.17.1`)
     */
    dependsOnNodeVersion?: boolean | NodeVersionGranularity;
    /**
     * An optional list of glob (minimatch) patterns pointing to files that can affect this operation.
     * The hash values of the contents of these files will become part of the final hash when reading
     * and writing the build cache.
     *
     * Note: if a particular file will be matched by patterns provided by both `incrementalBuildIgnoredGlobs` and
     * `dependsOnAdditionalFiles` options - `dependsOnAdditionalFiles` will win and the file will be included
     * calculating final hash value when reading and writing the build cache
     */
    dependsOnAdditionalFiles?: string[];
    /**
     * An optional config object for sharding the operation. If specified, the operation will be sharded
     * into multiple invocations. The `count` property specifies the number of shards to create. The
     * `shardArgumentFormat` property specifies the format of the argument to pass to the command to
     * indicate the shard index and count. The default value is `--shard={shardIndex}/{shardCount}`.
     */
    sharding?: IRushPhaseSharding;
    /**
     * How many concurrency units this operation should take up during execution. The maximum concurrent units is
     *  determined by the -p flag.
     */
    weight?: number | `${number}%`;
    /**
     * If true, this operation can use cobuilds for orchestration without restoring build cache entries.
     */
    allowCobuildWithoutCache?: boolean;
    /**
     * If true, this operation will never be skipped by the `--changed-projects-only` flag.
     */
    ignoreChangedProjectsOnlyFlag?: boolean;
    /**
     * An optional list of custom command-line parameter names (their `parameterLongName` values from
     * command-line.json) that should be ignored when invoking the command for this operation.
     * This allows a project to opt out of parameters that don't affect its operation, preventing
     * unnecessary cache invalidation for this operation and its consumers.
     */
    parameterNamesToIgnore?: string[];
}
/**
 * Use this class to load the "config/rush-project.json" config file.
 *
 * This file provides project-specific configuration options.
 * @alpha
 */
export declare class RushProjectConfiguration {
    private static readonly _configCache;
    readonly project: RushConfigurationProject;
    /**
     * {@inheritdoc _IRushProjectJson.incrementalBuildIgnoredGlobs}
     */
    readonly incrementalBuildIgnoredGlobs: ReadonlyArray<string>;
    /**
     * {@inheritdoc _IRushProjectJson.disableBuildCacheForProject}
     */
    readonly disableBuildCacheForProject: boolean;
    readonly operationSettingsByOperationName: ReadonlyMap<string, Readonly<IOperationSettings>>;
    private readonly _validationCache;
    private constructor();
    /**
     * Validates that the requested phases are compatible.
     * Deferral of this logic to its own method means that Rush no longer eagerly validates
     * all defined commands in command-line.json. As such, while validation will be run for a given
     * command upon invoking that command, defining overlapping phases in "rush custom-command"
     * that are not used by "rush build" will not cause "rush build" to exit with an error.
     */
    validatePhaseConfiguration(phases: Iterable<IPhase>, terminal: ITerminal): void;
    /**
     * Examines the list of source files for the project and the target phase and returns a reason
     * why the project cannot enable the build cache for that phase, or undefined if it is safe to so do.
     */
    getCacheDisabledReason(trackedFileNames: Iterable<string>, phaseName: string, isNoOp: boolean): string | undefined;
    /**
     * Source of truth for whether a project is unable to use the build cache for a given phase.
     * As some operations may not have a rush-project.json file defined at all, but may be no-op operations
     *  we'll want to ignore those completely.
     */
    static getCacheDisabledReasonForProject(options: {
        projectConfiguration: RushProjectConfiguration | undefined;
        trackedFileNames: Iterable<string>;
        phaseName: string;
        isNoOp: boolean;
    }): string | undefined;
    /**
     * Loads the rush-project.json data for the specified project.
     */
    static tryLoadForProjectAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<RushProjectConfiguration | undefined>;
    /**
     * Load only the `incrementalBuildIgnoredGlobs` property from the rush-project.json file, skipping
     * validation of other parts of the config file.
     *
     * @remarks
     * This function exists to allow the ProjectChangeAnalyzer to load just the ignore globs without
     * having to validate the rest of the `rush-project.json` file against the repo's command-line configuration.
     */
    static tryLoadIgnoreGlobsForProjectAsync(project: RushConfigurationProject, terminal: ITerminal): Promise<ReadonlyArray<string> | undefined>;
    /**
     * Load the rush-project.json data for all selected projects.
     * Validate compatibility of output folders across all selected phases.
     */
    static tryLoadForProjectsAsync(projects: Iterable<RushConfigurationProject>, terminal: ITerminal): Promise<ReadonlyMap<RushConfigurationProject, RushProjectConfiguration>>;
    private static _tryLoadJsonForProjectAsync;
    private static _getRushProjectConfiguration;
}
//# sourceMappingURL=RushProjectConfiguration.d.ts.map