import type { CommandLineParameter } from '@rushstack/ts-command-line';
import type { ICommandLineJson, IGlobalCommandJson, IFlagParameterJson, IChoiceParameterJson, IStringParameterJson, IIntegerParameterJson, IStringListParameterJson, IIntegerListParameterJson, IChoiceListParameterJson, IPhasedCommandWithoutPhasesJson } from './CommandLineJson';
export interface IShellCommandTokenContext {
    packageFolder: string;
}
/**
 * The set of valid behaviors for a missing script in a project's package.json scripts for a given phase.
 * @alpha
 */
export type PhaseBehaviorForMissingScript = 'silent' | 'log' | 'error';
/**
 * Metadata about a phase.
 * @alpha
 */
export interface IPhase {
    /**
     * The name of this phase.
     */
    name: string;
    /**
     * If set to `true,` this this phase was generated from a bulk command, and
     * was not explicitly defined in the command-line.json file.
     */
    isSynthetic: boolean;
    /**
     * This property is used in the name of the filename for the logs generated by this
     * phase. This is a filesystem-safe version of the phase name. For example,
     * a phase with name `_phase:compile` has a `logFilenameIdentifier` of `_phase_compile`.
     */
    logFilenameIdentifier: string;
    /**
     * The set of custom command line parameters that are relevant to this phase.
     */
    associatedParameters: Set<CommandLineParameter>;
    /**
     * The resolved dependencies of the phase
     */
    dependencies: {
        self: Set<IPhase>;
        upstream: Set<IPhase>;
    };
    /**
     * By default, Rush returns a nonzero exit code if errors or warnings occur during a command. If this option is
     * set to `true`, Rush will return a zero exit code if warnings occur during the execution of this phase.
     */
    allowWarningsOnSuccess: boolean;
    /**
     * What should happen if the script is not defined in a project's package.json scripts field. Default is "error".
     */
    missingScriptBehavior: PhaseBehaviorForMissingScript;
    /**
     * (Optional) If the `shellCommand` field is set for a bulk command, Rush will invoke it for each
     * selected project; otherwise, Rush will invoke the package.json `"scripts"` entry matching Rush command/phase name.
     *
     * This string is the path to a script that will be invoked using the OS shell. The working directory will be
     * the folder that contains rush.json.  If custom parameters are associated with this command, their
     * values will be appended to the end of this string.
     */
    shellCommand?: string;
}
export interface ICommandWithParameters {
    associatedParameters: Set<IParameterJson>;
}
export interface IPhasedCommandConfig extends IPhasedCommandWithoutPhasesJson, ICommandWithParameters {
    /**
     * If set to `true`, then this phased command was generated from a bulk command, and
     * was not explicitly defined in the command-line.json file.
     */
    isSynthetic: boolean;
    disableBuildCache?: boolean;
    originalPhases: Set<IPhase>;
    /**
     * Include upstream and self phases.
     */
    phases: Set<IPhase>;
    /**
     * If set to `true`, this phased command will always run in watch mode, regardless of CLI flags.
     */
    alwaysWatch: boolean;
    /**
     * The set of phases to execute when running this phased command in watch mode.
     */
    watchPhases: Set<IPhase>;
    /**
     * How many milliseconds to wait after receiving a file system notification before executing in watch mode.
     */
    watchDebounceMs?: number;
    /**
     * If set to `true`, then this phased command will always perform an install before executing, regardless of CLI flags.
     * If set to `false`, then Rush will define a built-in "--install" CLI flag for this command.
     * If undefined, then Rush does not define a built-in "--install" CLI flag for this command and no installation is performed.
     */
    alwaysInstall: boolean | undefined;
}
export interface IGlobalCommandConfig extends IGlobalCommandJson, ICommandWithParameters {
    /**
     * If true, this command was declared with commandKind "globalPlugin" and its implementation
     * is provided by a Rush plugin via the `runGlobalCustomCommand` hook. There is no shell
     * command to execute.
     */
    providedByPlugin: boolean;
}
export type Command = IGlobalCommandConfig | IPhasedCommandConfig;
/**
 * Metadata about a custom parameter defined in command-line.json
 * @alpha
 */
export type IParameterJson = IFlagParameterJson | IChoiceParameterJson | IStringParameterJson | IIntegerParameterJson | IStringListParameterJson | IIntegerListParameterJson | IChoiceListParameterJson;
interface ICommandLineConfigurationOptions {
    /**
     * If true, do not include default build and rebuild commands.
     */
    doNotIncludeDefaultBuildCommands?: boolean;
}
/**
 * Custom Commands and Options for the Rush Command Line
 */
export declare class CommandLineConfiguration {
    private static _jsonSchema;
    readonly commands: Map<string, Command>;
    readonly phases: Map<string, IPhase>;
    readonly parameters: IParameterJson[];
    /**
     * shellCommand from plugin custom command line configuration needs to be expanded with tokens
     */
    shellCommandTokenContext: IShellCommandTokenContext | undefined;
    /**
     * These path will be prepended to the PATH environment variable
     */
    readonly additionalPathFolders: Readonly<string[]>;
    /**
     * A map of bulk command names to their corresponding synthetic phase identifiers
     */
    private readonly _syntheticPhasesByTranslatedBulkCommandName;
    /**
     * Use CommandLineConfiguration.loadFromFile()
     *
     * @internal
     */
    constructor(commandLineJson: ICommandLineJson | undefined, options?: ICommandLineConfigurationOptions);
    /**
     * Performs a depth-first search to detect cycles in the directed graph of phase "self" dependencies.
     *
     * @param phase The phase node currently being checked
     * @param phasesInPath The current path from the start node to `phase`
     * @param cycleFreePhases Phases that have already been fully walked and confirmed to not be in any cycles
     */
    private _checkForPhaseSelfCycles;
    private static _applyBuildCommandDefaults;
    /**
     * Load the command-line.json configuration file from the specified path. Note that this
     * does not include the default build settings. This option is intended to be used to load
     * command-line.json files from plugins. To load a common/config/rush/command-line.json file,
     * use {@see loadFromFileOrDefault} instead.
     *
     * If the file does not exist, this function returns `undefined`
     */
    static tryLoadFromFile(jsonFilePath: string): CommandLineConfiguration | undefined;
    /**
     * Loads the configuration from the specified file and applies any omitted default build
     * settings.  If the file does not exist, then a default instance is returned.
     * If the file contains errors, then an exception is thrown.
     */
    static loadFromFileOrDefault(jsonFilePath?: string, doNotIncludeDefaultBuildCommands?: boolean): CommandLineConfiguration;
    prependAdditionalPathFolder(pathFolder: string): void;
    private _translateBulkCommandToPhasedCommand;
}
export {};
//# sourceMappingURL=CommandLineConfiguration.d.ts.map