npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

danger-plugin-gitlab

v0.0.3

Published

Some simple but useful DangerJS plugins for Gitlab

Downloads

6

Readme

Danger Plugins For GitLab

Some simple but useful DangerJS plugins for Gitlab

Install

npm install -D danger-plugin-gitlab

Plugins

addLabel

Add labels according to the changed files.

import { addLabel } from "danger-plugin-gitlab";

addLabel([
  { match: /packages\/server\/.*/, name: "server" },
  { match: /packages\/webapp\/.*/, name: "webapp" },
]);

checkAutomatedTest

Check if source files have been modified, but not test files.

import { checkAutomatedTest } from "danger-plugin-gitlab";

checkAutomatedTest({
  logType: "fail",
  logMessage:
    "Source files have been modified, but no test files have been added or modified.",
  sourceFileMath: /src\/.*.(?<!test.)(js|ts|jsx|tsx)$/,
  testFileMath: /src\/.*test.*(js|ts|jsx|tsx)$/,
  enableCheck: false,
  checkMessage: "Automated tests added/updated",
});

If enableCheck is set true, you can also add below content into your merge request description to control the behaviour.

<!-- merge request description -->

# Checklist

- [ ] Automated tests added/updated

checkChangelog

Make sure every change is recorded in the CHANGELOG.

import { checkChangelog } from "danger-plugin-gitlab";

checkChangelog({
  logFile: "changelog.md",
  logType: "warn",
  logMessage: "Please add a changelog entry for your changes.",
  enableSkip: false,
  skipMessage: "Skip CHANGELOG check",
});

If enableSkip is set true, you can also add below content into your merge request description to control the behaviour.

<!-- merge request description -->

# Skip

- [ ] Skip CHANGELOG check

checkDescription

Make sure each merge request has a detailed description.

import { checkDescription } from "danger-plugin-gitlab";

checkDescription({
  logType: "message",
  minLength: 50,
  logMessage: "Please provide a summary in the merge request description.",
});

checkIssueTicket

Check if an ISSUE ticket exists in the title or description of merge request description. Or add NO-ISSUE to indicate no issue ticket is required.

import { checkIssueTicket } from "danger-plugin-gitlab";

checkIssueTicket({
  logType: "warn",
  key: "JIRA",
  location: "title",
  logMessage: "Please include a ticket (like \`XXX-DDDD\` or \`NO-ISSUE\` if there is no ticket) at the beginning of the MR title";
});

checkLockfile

  • Make sure the package-lock.json (or yarn.lock) is up to date when changes were made to package.json.
  • Check if only package-lock.json (or yarn.lock) was modified with package.json no changed.
import { checkLockfile } from "danger-plugin-gitlab";

checkLockfile({
  lockType: "warn",
  lockfile: "package-lock.json",
});

// or custom log type, path, lockfile and logMessage
checkLockfile({
  lockType: "fail",
  lockfile: "yarn.lock",
  path: "packages/webapp/",
  logMessage: (isPkgLockMissing: boolean) =>
    isPkgLockMissing
      ? `Dependencies (\`packages/webapp/package.json\`) may have changed, but lockfile (\`packages/webapp/yarn.lock\`) has not been updated.`
      : `Lockfile (\`packages/webapp/yarn.lock\`) has been updated, but no dependencies (\`packages/webapp/package.json\`) have changed.`,
});

checkManuallyTested

Check if author has manually tested their changes when source files have been modified

import { checkManuallyTested } from "danger-plugin-gitlab";

checkManuallyTested({
  logType: "fail",
  logMessage:
    "`Manually tested in a web browser` is unchecked in the MR description when source files have been modified.",
  checkMessage: "Manually tested in a web browser",
  sourceFileMath: /src\/.*.(?<!test.)(js|ts|jsx|tsx)$/,
});

Make use below content is inserted into the merge request description.

<!-- merge request description -->

# Checklist

- [ ] Manually tested in a web browser

checkMutexUpdate

Check if changes have been made to both the server and client code.

import { checkMutexUpdate } from "danger-plugin-gitlab";

const SKIP_SERVER_CLIENT_MUTEX_CHECK =
  "I am familiar with the danger of releasing webapp and server changes simultaneously";

checkMutexUpdate({
  logType: "fail",
  logMessage: `The reviewer must check the \`${SKIP_SERVER_CLIENT_MUTEX_CHECK}\` toggle, or the pull request should be split.`,
  mutexItems: [
    {
      match: /packages\/server\/(?!app\/tests\/).*/,
      name: "server",
    },
    {
      match: /packages\/client\/.*/,
      name: "webapp",
    },
  ],
  enableSkip: true,
  skipMessage: SKIP_SERVER_CLIENT_MUTEX_CHECK,
});

If enableSkip is set true, you can also add below content into your merge request description to control the behaviour.

<!-- merge request description -->

# Skip

- [ ] I am familiar with the danger of releasing webapp and server changes simultaneously

checkSelfReview

Check if author has reviewed their code.

import { checkSelfReview } from "danger-plugin-gitlab";

checkSelfReview({
  logType: "warn",
  logMessage:
    "`Code has been reviewed by the author` is unchecked in the MR description.",
  checkMessage: "Code has been reviewed by the author",
});

Make use below content or custom check message is inserted into the merge request description.

<!-- merge request description -->

# Checklist

- [ ] Code has been reviewed by the author

checkSize

Encourage smaller merge request.

import { checkSize } from "danger-plugin-gitlab";

checkSize({
  logType: "fail",
  maxSize: 20,
  logMessage: ({ createdFiles, modifiedFiles }) =>
    `This MR contains ${[...createdFiles, ...modifiedFiles].length} files (${
      createdFiles.length
    } new, ${
      modifiedFiles.length
    } modified). Consider splitting it into multiple MRs.`,
  enableSkip: false,
  skipMessage: "Skip MR size check",
});

If enableSkip is set true, you can also add below content into your merge request description to control the behaviour.

<!-- merge request description -->

# Skip

- [ ] Skip MR size check