/** @ignore **/
export type ReposConfigurationWithDefaultsApplied = ReposConfiguration & {
  path: string,
  repos: {
    [repoName: string]: GitConfigWithDefaultsApplied
  },
  defaultTemplate: {
    enabled: boolean,
    allRepositoriesPageTitle: string,
    colors: {
      languageGraph: Array<any>,
    }
  }
}

/** @ignore **/
export type GitConfigWithDefaultsApplied = GitConfig & {
  defaultBranch: string,
  branches: Array<any>,
  tags: Array<any>,
  languageExtensions: Object,
  defaultTemplate: {
    homepageButtons: Array<any>
  }
}

/**
 The ReposConfiguration object contains information about your local repositories,
 like their name and location on your local filesystem. Add repositories to this
 configuration object to make a static site for them.
 
 You will also need to set the {@link ReposConfiguration.baseUrl} to the URL of your
 live website.
 @example
 const config: ReposConfiguration = {
   baseUrl: "https://repos.tuckerm.us",
   repos: {
     "My Git Project": {
       defaultBranch: 'main',
       branches: ['main', 'develop']
     },
   },
 }
 */
export type ReposConfiguration = {
  repos: {
    /**
     *An object containing the configuration for your repositories.
     *Each key in this object is a repository name, and the value has several
     *config options for that repository. The required config options describe
     *the path to the repository and which branches should be pulled. See the specific
     *definition of {@link GitConfig} for more details
     *about what goes in these configuration objects.
     */
    [repoName: string]: GitConfig
  },
  /**
   * The root URL where this website will be. E.g.: https://blog.example.com/repos.
   * This URL will be used when a clone or pull command is being shown on your site.
   * Unlike on a regular Build Awesome site, this needs to be explicitly defined,
   * since the `git clone` URL cannot be a relative link; Repo Viewer needs to know
   * your domain name in order to know what the `git clone` URL should be.
   * @example baseUrl: "https://repos.tuckerm.us"
   */
  baseUrl: string,
  /**
   * The path to put the cloned repositories in. Repositories will be cloned from
   * their source `location` to the `path` folder inside of your site's output folder.
   * For example, `_site/repos/my-git-repo.git`.
   * @default path: "/repos"
   * @example path: "/repos"
   */
  path?: string,
  /**
   * Some configuration options for the default template included with this plugin.
   */
  defaultTemplate?: {
    /**
     Whether or not the default template should be used. If `true`, will generate
     the type of HTML pages seen at https://tuckerm.us/repos.
     @default true
    */
    enabled?: boolean,
    allRepositoriesPageTitle?: string,
    colors?: {
      languageGraph?: Array<{light: string, dark?: string}>,
    },
  },
}

export type GitConfig = {
  /* The absolute path to the repository.
   * @example location: "/home/alice/projects/git_repo"
   */
  location: string,
  description?: string,
  /**
   The default branch for the repository. If this field is not set,
   Repo Viewer will automatically try `main`, `master`, and `develop`, in
   that order. Set a `defaultBranch` value if your default branch is not one
   of those.
   @default 'main', 'master', or 'develop', determined by looking for one of those branches
   @example defaultBranch: 'main'
  */
  defaultBranch?: string,
  /**
   The list of branches to pull from the source repo, making them available
   in the public repo. If you have some branches in your source repo (that is,
   the one specified in `location`,) and you don't want those branches to have
   a snapshot of their current files available, then do not list those branches
   in this field. Glob patterns can be used here. By default, pulls all available
   branches from the source repo.
   @example branches: [
     'main',
     'release-candidate',
     {
       pattern: 'develop/*',
       max: 50,
       compareTo: 'release-candidate'
     },
     'features/**'
   ]
   @default branches: ['**']
  */
  branches?: Array<string | {pattern: string, max?: number, compareTo?: string, description?: string}>,
  /**
   The list of tags to fetch from the source repo, making them available
   in the public repo. If you have some tags in your source repo (that is,
   the one specified in `location`,) and you don't want those tags to have
   a snapshot of their files available, then do not list those tags
   in this field. Glob patterns can be used here. By default, pulls all available
   tags from the source repo.

   You may give either an exact name of the tag, a glob pattern (like `releases/**`),
   or an object. If you want to limit the number of tags that are shown (e.g. to
   avoid generating HTML pages for very old releases), use the object. The object
   contains two keys: `pattern` and `max`, where `pattern` is a glob pattern for
   matching a tag name, and `max` is how many tags should be fetched matching
   that name. Older tags beyond the max number will be ignored.
   @type Array<string>
   @example tags: ['v1.*', 'v2.*', {pattern: 'releases/**', max: 100}]
   @default tags: ['**']
  */
  tags?: Array<string | {pattern: string, max: number}>,
  languageExtensions?: {
    [fileExtension: string]: string
  },
  buildSteps?: {
    command: string,
    copyFrom: string,
    copyTo: string,
  }[],
  defaultTemplate?: {
    homepageButtons: Array<{
      url: string,
      text: string,
      newTab?: boolean,
    }>
  },
}
