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

@pagopa/danger-plugin

v2.0.2

Published

Shared rules for DangerJS, used in the PagoPA projects

Downloads

12

Readme

Custom DangerJS rules plugin

npm Azure DevOps builds Azure DevOps builds npm type definitions

This module provides custom rules over Danger CI automation.

Features

  • Cross-link with Jira stories, based on PR title
  • Warn when a PR has no description
  • Update the PR title with the right changelog configuration and scope
  • Update the generated changelog, adding the link to the related Jira ticket
  • Warn if npm-related files are added (as we use yarn)

Usage

To use you must already have danger-js set up in your repo. If you haven't configured it yet:

yarn add danger --dev

Install

yarn add @pagopa/danger-plugin --dev

At a glance

Create a new file Dangerfile.ts in your root working dir. It is mandatory to define a Configuration that allows you to make a mapping between a ticket projectid or ticket tag with a scope that is mainly a string that allows you to better describe it.

// Dangerfile.ts
import customRules from "@pagopa/danger-plugin";
import { Configuration } from "@pagopa/danger-plugin/dist/types";

const configuration: Configuration = {
  projectToScope: {
    IAC: "Bonus Pagamenti Digitali",
    IOACGN: "Carta Giovani Nazionale",
    IAGP: "EU Covid Certificate",
  },
  tagToScope: {
    android: "Android",
    ios: "iOS",
    messages: "Messages",
    payments: "Payments",
    services: "Services",
  },

  // minimum length of the PR description below which a warning is generated
  minLenPrDescription: 10,

  // To add a label to the PR containing the name of the project linked to the task on Jira.
  updateLabel: true,

  // To change the title of the PR according to whether the task on Jira is a feat (Story) / fix (Bug) / chore (Sub-task) / epic.
  updateTitle: false,
};

customRules(configuration);

Look at the Dangerfile.ts file to better understand how to structure it.

Creating a GitHub bot account for Danger

In order to get the most out of Danger, we recommend giving it the ability to post comments in your Pull Requests. This is a regular GitHub account, but depending on whether you are working on a private or public project, you will want to give different levels of access to this bot.

Environment variables

A token related to github bot account is required to enable the reading of the repo and comment the PR on github to be set in the environment variable:

DANGER_GITHUB_API_TOKEN="....."

Furthermore, to access the Jira API it is necessary to create a token relating to a service account and set the following environment variables:

[email protected]
JIRA_PASSWORD=token...

DevOps pipeline

example of a pipeline stage for the code review

stages:
  - stage: Static_analysis
    dependsOn: []
    jobs:
      - job: danger
        condition: and(
          succeeded(),
          and(
          eq(variables['Build.Reason'], 'PullRequest'),
          ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip')
          )
          )
        steps:
          - template: templates/node-job-setup/template.yaml@pagopaCommons
          - bash: |
              yarn danger ci
            env:
              DANGER_GITHUB_API_TOKEN: "$(DANGER_GITHUB_API_TOKEN)"
              JIRA_USERNAME: "$(JIRA_USERNAME)"
              JIRA_PASSWORD: "$(JIRA_PASSWORD)"
            displayName: "Danger CI"