Skip to content
Snippets Groups Projects
Select Git revision
  • 915ab742d92abd1d5c34198fad8bf5d901475a20
  • master default protected
  • gh-pages
  • dependabot/npm_and_yarn/neostandard-0.12.2
  • dependabot/npm_and_yarn/eslint-plugin-prettier-5.5.1
  • dependabot/npm_and_yarn/eslint-9.30.1
  • dependabot/npm_and_yarn/cypress-14.5.1
  • dependabot/npm_and_yarn/eslint-plugin-import-2.32.0
  • dependabot/npm_and_yarn/eslint-plugin-jsdoc-51.3.4
  • dependabot/npm_and_yarn/mocha-11.7.1
  • dependabot/npm_and_yarn/typescript-eslint/parser-8.36.0
  • dependabot/npm_and_yarn/nock-14.0.5
  • dependabot/npm_and_yarn/react-19.1.0
  • dependabot/npm_and_yarn/react-dom-19.1.0
  • server-2025-02-01-6100669a
  • server-2024-11-01-87cba042
  • server-2024-10-01-6875b7c8
  • dependabot/npm_and_yarn/path-to-regexp-8.2.0
  • server-2024-09-01-3d52575c
  • daily-tests-gha2
  • daily-tests-gha
  • server-2025-07-01
  • 5.0.2
  • 5.0.1
  • 5.0.0
  • server-2025-06-01
  • server-2025-05-01
  • server-2025-04-03
  • server-2025-03-02
  • server-2025-03-01
  • server-2025-02-02
  • server-2025-01-01
  • server-2024-12-01
  • server-2024-11-02
  • 4.1.0
  • server-2024-09-25
  • server-2024-09-02
  • server-2024-08-01
  • server-2024-07-01
  • 4.0.0
  • server-2024-06-01
41 results

load-simple-icons.spec.js

Blame
  • dependency-dashboard.ts 8.60 KiB
    import is from '@sindresorhus/is';
    import { nameFromLevel } from 'bunyan';
    import { getAdminConfig } from '../../config/admin';
    import type { RenovateConfig } from '../../config/types';
    import { getProblems, logger } from '../../logger';
    import { platform } from '../../platform';
    import { BranchConfig, BranchResult } from '../types';
    
    function getListItem(branch: BranchConfig, type: string): string {
      let item = ' - [ ] ';
      item += `<!-- ${type}-branch=${branch.branchName} -->`;
      if (branch.prNo) {
        item += `[${branch.prTitle}](../pull/${branch.prNo})`;
      } else {
        item += branch.prTitle;
      }
      const uniquePackages = [
        ...new Set(branch.upgrades.map((upgrade) => '`' + upgrade.depName + '`')),
      ];
      if (uniquePackages.length < 2) {
        return item + '\n';
      }
      return item + ' (' + uniquePackages.join(', ') + ')\n';
    }
    
    function appendRepoProblems(config: RenovateConfig, issueBody: string): string {
      let newIssueBody = issueBody;
      const repoProblems = new Set(
        getProblems()
          .filter(
            (problem) =>
              problem.repository === config.repository && !problem.artifactErrors
          )
          .map(
            (problem) =>
              `${nameFromLevel[problem.level].toUpperCase()}: ${problem.msg}`
          )
      );
      if (repoProblems.size) {
        newIssueBody += '## Repository problems\n\n';
        newIssueBody +=
          'These problems occurred while renovating this repository.\n\n';
        for (const repoProblem of repoProblems) {
          newIssueBody += ` - ${repoProblem}\n`;
        }
        newIssueBody += '\n';
      }
      return newIssueBody;
    }
    
    export async function ensureDependencyDashboard(
      config: RenovateConfig,
      branches: BranchConfig[]
    ): Promise<void> {
      // legacy/migrated issue
      const reuseTitle = 'Update Dependencies (Renovate Bot)';
      if (
        !(
          config.dependencyDashboard ||
          config.dependencyDashboardApproval ||
          config.packageRules?.some((rule) => rule.dependencyDashboardApproval) ||
          branches.some(
            (branch) =>
              branch.dependencyDashboardApproval ||
              branch.dependencyDashboardPrApproval
          )
        )
      ) {
        return;
      }
      // istanbul ignore if
      if (config.repoIsOnboarded === false) {
        logger.debug('Repo is onboarding - skipping dependency dashboard');
        return;
      }
      logger.debug('Ensuring Dependency Dashboard');
      const hasBranches =
        is.nonEmptyArray(branches) &&
        branches.some((branch) => branch.result !== BranchResult.Automerged);
      if (config.dependencyDashboardAutoclose && !hasBranches) {
        if (getAdminConfig().dryRun) {
          logger.info(
            'DRY-RUN: Would close Dependency Dashboard ' +
              config.dependencyDashboardTitle
          );
        } else {
          logger.debug('Closing Dependency Dashboard');
          await platform.ensureIssueClosing(config.dependencyDashboardTitle);
        }
        return;
      }
      let issueBody = '';
      if (config.dependencyDashboardHeader?.length) {
        issueBody += `${config.dependencyDashboardHeader}\n\n`;
      }
    
      issueBody = appendRepoProblems(config, issueBody);
    
      const pendingApprovals = branches.filter(
        (branch) => branch.result === BranchResult.NeedsApproval
      );
      if (pendingApprovals.length) {
        issueBody += '## Pending Approval\n\n';
        issueBody += `These branches will be created by Renovate only once you click their checkbox below.\n\n`;
        for (const branch of pendingApprovals) {
          issueBody += getListItem(branch, 'approve');
        }
        issueBody += '\n';
      }
      const awaitingSchedule = branches.filter(
        (branch) => branch.result === BranchResult.NotScheduled
      );
      if (awaitingSchedule.length) {
        issueBody += '## Awaiting Schedule\n\n';
        issueBody +=
          'These updates are awaiting their schedule. Click on a checkbox to ignore the schedule.\n';
        for (const branch of awaitingSchedule) {
          issueBody += getListItem(branch, 'unschedule');
        }
        issueBody += '\n';
      }
      const rateLimited = branches.filter(
        (branch) =>
          branch.result === BranchResult.BranchLimitReached ||
          branch.result === BranchResult.PrLimitReached ||
          branch.result === BranchResult.CommitLimitReached
      );
      if (rateLimited.length) {
        issueBody += '## Rate Limited\n\n';
        issueBody +=
          'These updates are currently rate limited. Click on a checkbox below to force their creation now.\n\n';
        for (const branch of rateLimited) {
          issueBody += getListItem(branch, 'unlimit');
        }
        issueBody += '\n';
      }
      const errorList = branches.filter(
        (branch) => branch.result === BranchResult.Error
      );
      if (errorList.length) {
        issueBody += '## Errored\n\n';
        issueBody +=
          'These updates encountered an error and will be retried. Click a checkbox below to force a retry now.\n\n';
        for (const branch of errorList) {
          issueBody += getListItem(branch, 'retry');
        }
        issueBody += '\n';
      }
      const awaitingPr = branches.filter(
        (branch) => branch.result === BranchResult.NeedsPrApproval
      );
      if (awaitingPr.length) {
        issueBody += '## PR Creation Approval Required\n\n';
        issueBody +=
          "These branches exist but PRs won't be created until you approve by ticking the checkbox.\n\n";
        for (const branch of awaitingPr) {
          issueBody += getListItem(branch, 'approvePr');
        }
        issueBody += '\n';
      }
      const prEdited = branches.filter(
        (branch) => branch.result === BranchResult.PrEdited
      );
      if (prEdited.length) {
        issueBody += '## Edited/Blocked\n\n';
        issueBody += `These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, check the box below.\n\n`;
        for (const branch of prEdited) {
          issueBody += getListItem(branch, 'rebase');
        }
        issueBody += '\n';
      }
      const prPending = branches.filter(
        (branch) => branch.result === BranchResult.Pending
      );
      if (prPending.length) {
        issueBody += '## Pending Status Checks\n\n';
        issueBody += `These updates await pending status checks. To force their creation now, check the box below.\n\n`;
        for (const branch of prPending) {
          issueBody += getListItem(branch, 'approvePr');
        }
        issueBody += '\n';
      }
      const otherRes = [
        BranchResult.Pending,
        BranchResult.NeedsApproval,
        BranchResult.NeedsPrApproval,
        BranchResult.NotScheduled,
        BranchResult.PrLimitReached,
        BranchResult.CommitLimitReached,
        BranchResult.BranchLimitReached,
        BranchResult.AlreadyExisted,
        BranchResult.Error,
        BranchResult.Automerged,
        BranchResult.PrEdited,
      ];
      let inProgress = branches.filter(
        (branch) => !otherRes.includes(branch.result)
      );
      const otherBranches = inProgress.filter(
        (branch) => branch.prBlockedBy || !branch.prNo
      );
      // istanbul ignore if
      if (otherBranches.length) {
        issueBody += '## Other Branches\n\n';
        issueBody += `These updates are pending. To force PRs open, check the box below.\n\n`;
        for (const branch of otherBranches) {
          logger.info(
            {
              prBlockedBy: branch.prBlockedBy,
              prNo: branch.prNo,
              result: branch.result,
            },
            'Blocked PR'
          );
          issueBody += getListItem(branch, 'other');
        }
        issueBody += '\n';
      }
      inProgress = inProgress.filter(
        (branch) => branch.prNo && !branch.prBlockedBy
      );
      if (inProgress.length) {
        issueBody += '## Open\n\n';
        issueBody +=
          'These updates have all been created already. Click a checkbox below to force a retry/rebase of any.\n\n';
        for (const branch of inProgress) {
          issueBody += getListItem(branch, 'rebase');
        }
        if (inProgress.length > 2) {
          issueBody += ' - [ ] ';
          issueBody += '<!-- rebase-all-open-prs -->';
          issueBody +=
            '**Check this option to rebase all the above open PRs at once**';
          issueBody += '\n';
        }
        issueBody += '\n';
      }
      const alreadyExisted = branches.filter(
        (branch) => branch.result === BranchResult.AlreadyExisted
      );
      if (alreadyExisted.length) {
        issueBody += '## Ignored or Blocked\n\n';
        issueBody +=
          'These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.\n\n';
        for (const branch of alreadyExisted) {
          issueBody += getListItem(branch, 'recreate');
        }
        issueBody += '\n';
      }
    
      if (!hasBranches) {
        issueBody +=
          'This repository currently has no open or pending branches.\n\n';
      }
    
      if (config.dependencyDashboardFooter?.length) {
        issueBody += `---\n${config.dependencyDashboardFooter}\n`;
      }
    
      if (getAdminConfig().dryRun) {
        logger.info(
          'DRY-RUN: Would ensure Dependency Dashboard ' +
            config.dependencyDashboardTitle
        );
      } else {
        await platform.ensureIssue({
          title: config.dependencyDashboardTitle,
          reuseTitle,
          body: issueBody,
        });
      }
    }