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

gl-code-quality-openapi-validator

v1.0.4

Published

GitLab Code Quality generator for IBM's OpenAPI Validator.

Downloads

7,581

Readme

gl-code-quality-openapi-validator

Build npm version Conventional Commits License: Unlicense NPM Downloads

Intro

gl-code-quality-openapi-validator converts the JSON file output of IBM's OpenAPI Validator to a GitLab Code Quality report JSON file. This file can then be exposed from a GitLab CI/CD job as an artifact and used to display code quality changes directly on the merge request.

Contents

Installation

To install this project you will need to have Node.js (>=16.0.0) installed. gl-code-quality-openapi-validator has been tested on the current LTS versions, 16.0.X and 18.0.X.

To install gl-code-quality-openapi-validator using npm execute:

npm install -g gl-code-quality-openapi-validator

The -g option installs gl-code-quality-openapi-validator globally so that it can be run from anywhere in the file system.

To execute gl-code-quality-openapi-validator after installing globally run:

gl-code-quality-openapi-validator

gl-code-quality-openapi-validator is designed to work with the JSON file output of IBM's OpenAPI Validator. Instructions for installation and usage can be found here.

The following command runs lint-openapi against openapi-spec.yml and redirects the JSON output to openapi-validator-report.json. gl-code-quality-openapi-validator is then able to convert this file into a GitLab Code Quality report.

lint-openapi --json openapi-spec.yml >> openapi-validator-report.json
gl-code-quality-openapi-validator -s openapi-spec.yml 

Options

gl-code-quality-openapi-validator has a handful of options. These options can be used to override the defaults that have been provided. For example:

gl-code-quality-openapi-validator -s ./specification/openapi-specification.yml -i /reporting/openapi-validator-report.json -o ./code-quality/gl-code-quality-report.json

Command Line Options

The following command line options are available for configuration:

| Option | Default | Description | |--------------------------------------|---------------------------------|------------------------------------------------------| | -V, --version | 1.0.0 | Output the version number | | -s, --specification <specification> | ./openapi-specification.yml | Filepath for the OpenAPI specification | | -i, --input <input> | ./openapi-validator-report.json | Filepath for the OpenAPI Validator JSON report input | | -o, --output <output> | ./gl-code-quality-report.json | Filepath for the GitLab Code Quality report output | | -h, --help | | display help for command |

GitLab

gl-code-quality-openapi-validator is intended to be used as part of a GitLab CI/CD pipeline job. The following code snippet provides an example job declaration.

openapi-validation:
  stage: code-quality
  image: node:latest
  script:
    - npm install -g ibm-openapi-validator @ibm-cloud/openapi-ruleset gl-code-quality-openapi-validator
    - lint-openapi --json ./openapi-specification.yml >> openapi-validator-report.json
    - gl-code-quality-openapi-validator -s ./openapi-specification.yml
  artifacts:
    reports:
      codequality: gl-code-quality-report.json

Local Development

Prerequisites

To install, run and modify this project you will need to have:

Installation

To start, please fork and clone the repository to your local machine. You are able to run the service directly on the command line or with your IDE of choice.

Running

Command Line

To run the service from the command line first you need to install the dependencies, install the project locally, and then execute gl-code-quality-openapi-validator.

npm install
npm install --global
gl-code-quality-openapi-validator

Testing

All tests have been written using Jest. To run the tests execute:

npm test

Code coverage is also measured by Jest and set to a minimum of 95%. To run tests with coverage execute:

npm run test:coverage

Code coverage reports can be found in the /coverage/ directory.

Conventional Commits

This project uses the Conventional Commits specification for commit messages. The specification provides a simple rule set for creating commit messages, documenting features, fixes, and breaking changes in commit messages.

A pre-commit configuration file has been provided to automate commit linting. Ensure that pre-commit has been installed and execute...

pre-commit install

...to add a commit Git hook to your local machine.

An automated pipeline job has been configured to lint commit messages on a push.

GitHub Actions

CI/CD pipelines has been created using GitHub Actions to automated tasks such as linting, testing, and releasing.

Build Workflow

The build workflow handles integration tasks. This workflow consists of two jobs, Git and Node, that run in parallel. This workflow is triggered on a push to a branch.

Git

This job automates tasks relating to repository linting and enforcing best practices.

Node

This job automates Node.js specific tasks.

Release Workflow

The release workflow handles release tasks. This workflow consists of one job, npm. This workflow is triggered manually from the GitHub Actions UI.

npm

This job automates tasks relating to updating changelog, and publishing to npm.