import { ProjectGraph, ProjectsConfigurations } from '@nx/devkit';
import { Variant } from '@storm-software/config/types';
import { CommitEnumItemProps } from 'conventional-changelog-storm-software/types/commit-types';
import { RuleConfigSeverity } from 'conventional-changelog-storm-software/types/commitlint';
import { NxReleaseConfig } from 'nx/src/command-line/release/config/config';
import { NxReleaseDockerConfiguration, NxReleaseVersionConfiguration, NxReleaseChangelogConfiguration, NxReleaseVersionPlansConfiguration, NxReleaseConfiguration } from 'nx/src/config/nx-json';

type DeepPartial<T> = T extends object ? {
    [P in keyof T]?: DeepPartial<T[P]>;
} : T;
interface CommitLintCLIOptions {
    config?: string;
    message?: string;
    file?: string;
}
type CommitScopeProps = CommitEnumItemProps & {
    projectRoot: string;
};
type CommitScopesEnum = Record<string, CommitScopeProps>;
type CommitQuestionTypeProp = "input" | "select" | "confirm";
type CommitQuestionProps = {
    type?: CommitQuestionTypeProp;
    title: string;
    description: string;
    enum?: Record<string, CommitEnumItemProps>;
    defaultValue?: string | boolean;
    maxLength?: number;
    minLength?: number;
    when?: (answers: Record<string, string>) => boolean;
};
declare const DEFAULT_COMMIT_PROMPT_MESSAGES: {
    readonly skip: "press enter to skip";
    readonly max: "must be %d chars at most";
    readonly min: "must be %d chars at least";
    readonly emptyWarning: "can not be empty";
    readonly upperLimitWarning: "%s is %d characters longer than the upper limit";
    readonly lowerLimitWarning: "%s is %d characters less than the lower limit";
    readonly closedIssueMessage: "Closes: ";
};
type DefaultCommitPromptMessagesKeys = keyof typeof DEFAULT_COMMIT_PROMPT_MESSAGES;
type CommitPromptMessagesEnum<TCommitPromptMessagesKeys extends DefaultCommitPromptMessagesKeys = DefaultCommitPromptMessagesKeys> = Record<TCommitPromptMessagesKeys, string> & typeof DEFAULT_COMMIT_PROMPT_MESSAGES;
type CommitSettingsEnum = Record<string, any> & {
    scopeEnumSeparator?: string;
    enableMultipleScopes: boolean;
    disableEmoji: boolean;
    breakingChangePrefix?: string;
    closedIssuePrefix?: string;
    format: string;
};
type CommitState<TCommitAnswers extends Record<string, string | boolean> = Record<string, string | boolean>, TCommitConfig extends Record<string, any> = Record<string, any>> = {
    variant: Variant;
    answers: TCommitAnswers;
    config: TCommitConfig;
    root: string;
};
interface CommitLintRuleOutcome {
    /** If the commit is considered valid for the rule */
    valid: boolean;
    /** The "severity" of the rule (1 = warning, 2 = error) */
    level: RuleConfigSeverity;
    /** The name of the rule */
    name: string;
    /** The message returned from the rule, if invalid */
    message: string;
}
interface CommitLintOutcome {
    /** The linted commit, as string */
    input: string;
    /** If the linted commit is considered valid */
    valid: boolean;
    /** All errors, per rule, for the commit */
    errors: CommitLintRuleOutcome[];
    /** All warnings, per rule, for the commit */
    warnings: CommitLintRuleOutcome[];
}
type ReleaseOptions = any & {
    npm: boolean;
    github: boolean;
    githubOptions?: Record<string, unknown>;
    buildTarget?: string;
    changelog?: boolean;
    changelogFile?: string;
    outputPath?: string;
    commitMessage?: string;
    gitAssets?: string[];
    packageJsonDir?: string;
    parserOpts?: Record<string, unknown>;
    writerOpts?: Record<string, unknown>;
    linkCompare?: boolean;
    linkReferences?: boolean;
    releaseRules?: string | {
        release: string | boolean;
        [key: string]: unknown;
    }[];
    preset?: string;
    presetConfig?: Record<string, unknown>;
    plugins?: any[];
    tagFormat?: string;
    git: boolean;
    branches: string[];
};
type ReleaseContext = ReleaseConfig & {
    projectName: string;
    workspaceDir: string;
    projectGraph: ProjectGraph;
    projectConfigs: ProjectsConfigurations;
};
interface ReadMeOptions {
    templates: string;
    project?: string;
    workspace?: boolean;
    output?: string;
    clean: boolean;
    prettier: boolean;
}
interface ReleaseGroupConfig {
    /**
     * Whether to version and release projects within the group independently, or together in lock step ("fixed").
     * If not set on the group, this will be informed by the projectsRelationship config at the top level.
     */
    projectsRelationship?: "fixed" | "independent";
    /**
     * Required list of one or more projects to include in the release group. Any single project can
     * only be used in a maximum of one release group.
     */
    projects: string[] | string;
    /**
     * Configure options to handle versioning docker projects for this group.
     * Set to `true` to enable with default settings, or provide a configuration object for custom settings.
     */
    docker?: (NxReleaseDockerConfiguration & {
        /**
         * A command to run after validation of nx release configuration, but before docker versioning begins.
         * Used for preparing docker build artifacts. If --dry-run is passed, the command is still executed, but
         * with the NX_DRY_RUN environment variable set to 'true'.
         * It will run in addition to the global `preVersionCommand`
         */
        groupPreVersionCommand?: string;
    }) | true;
    /**
     * Optionally override version configuration for this group.
     *
     * NOTE: git configuration is not supported at the group level, only the root/command level
     */
    version?: NxReleaseVersionConfiguration & {
        /**
         * A command to run after validation of nx release configuration, but before versioning begins.
         * Used for preparing build artifacts. If --dry-run is passed, the command is still executed, but
         * with the NX_DRY_RUN environment variable set to 'true'.
         * It will run in addition to the global `preVersionCommand`
         */
        groupPreVersionCommand?: string;
    };
    /**
     * Project changelogs are disabled by default.
     *
     * Here you can optionally override project changelog configuration for this group.
     * Notes about boolean values:
     *
     * - true = enable project level changelogs using default configuration
     * - false = explicitly disable project level changelogs
     *
     * NOTE: git configuration is not supported at the group level, only the root/command level
     */
    changelog?: NxReleaseChangelogConfiguration | boolean;
    /**
     * Configuration for release tag generation and matching.
     */
    releaseTag?: {
        /**
         * The pattern to use for release tags. Supports interpolating {version}, {projectName}, and {releaseGroupName}.
         */
        pattern?: string;
        /**
         * By default, we will try and resolve the latest match for the releaseTagPattern from the current branch,
         * falling back to all branches if no match is found on the current branch.
         *
         * - Setting this to true will cause us to ALWAYS check all branches for the latest match.
         * - Setting it to false will cause us to ONLY check the current branch for the latest match.
         * - Setting it to an array of strings will cause us to check all branches WHEN the current branch matches one of the strings in the array. Glob patterns are supported.
         */
        checkAllBranchesWhen?: boolean | string[];
        /**
         * By default, we will use semver when searching through the tags to find the latest matching tag.
         *
         * - Setting this to true will cause us to use semver to match the version
         * - Setting this to false will cause us to not use semver to match the version allowing for non-semver versions
         */
        requireSemver?: boolean;
        /**
         * Controls how docker versions are used relative to semver versions when creating git tags and changelog entries.
         *
         * - true: Use only the docker version
         * - false: Use only the semver version
         * - 'both': Create tags and changelog entries for both docker and semver versions
         *
         * By default, this is set to true when docker configuration is present, and false otherwise.
         */
        preferDockerVersion?: boolean | "both";
        /**
         * When set to true and multiple tags match your configured pattern, the git tag matching logic will strictly prefer the tag which contain a semver preid which matches the one
         * given to the nx release invocation.
         *
         * For example, let's say your pattern is "{projectName}@{version}" and you have the following tags for project "my-lib", which uses semver:
         * - my-lib@1.2.4-beta.1
         * - my-lib@1.2.4-alpha.1
         * - my-lib@1.2.3
         *
         * If "strictPreid" is set to true and you run:
         * - `nx release --preid beta`, the git tag "my-lib@1.2.4-beta.1" will be resolved.
         * - `nx release --preid alpha`, the git tag "my-lib@1.2.4-alpha.1" will be resolved.
         * - `nx release` (no preid), the git tag "my-lib@1.2.3" will be resolved.
         *
         * If "strictPreid" is set to false, the git tag "my-lib@1.2.4-beta.1" will always be resolved as the latest tag that matches the pattern,
         * regardless of any preid which gets passed to nx release.
         *
         * NOTE: This feature was added in a minor version and is therefore set to false by default, but this may change in a future major version.
         */
        strictPreid?: boolean;
    };
    /**
     * Enables using version plans as a specifier source for versioning and
     * to determine changes for changelog generation.
     */
    versionPlans?: NxReleaseVersionPlansConfiguration | boolean;
}
type ReleaseConfig = Omit<NxReleaseConfiguration, "groups" | "conventionalCommits"> & Required<Pick<NxReleaseConfig, "conventionalCommits">> & {
    groups: Record<string, ReleaseGroupConfig>;
};
type NxReleaseRequiredGitConfig = Required<{
    commit?: boolean | undefined;
    commitMessage?: string | undefined;
    commitArgs?: string | undefined;
    stageChanges?: boolean | undefined;
    tag?: boolean | undefined;
    tagMessage?: string | undefined;
    tagArgs?: string | undefined;
}>;

export { type CommitLintCLIOptions, type CommitLintOutcome, type CommitLintRuleOutcome, type CommitPromptMessagesEnum, type CommitQuestionProps, type CommitScopeProps, type CommitScopesEnum, type CommitSettingsEnum, type CommitState, DEFAULT_COMMIT_PROMPT_MESSAGES, type DeepPartial, type DefaultCommitPromptMessagesKeys, type NxReleaseRequiredGitConfig, type ReadMeOptions, type ReleaseConfig, type ReleaseContext, type ReleaseGroupConfig, type ReleaseOptions };
