kitchentemplate
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

npm-template

npm package MIT last commit downloads week downloads total size dependencies

Npm publish Build status Quality Gate Bugs Coverage Code Smells Duplicated Lines (%) Maintainability Rating Reliability Rating Security Rating Technical Debt Vulnerabilities

npm-template

About

A template for creating npm packages

How to setup your project

  1. Clone this repo or "use as template" and upload it to GitHub
  2. Setup GitHub Secrets
  3. Get your Sonar credentials
  4. Configure and run the setup script
  5. Configure Quality Gate in Sonar

2. GitHub Secrets

If not done by your organisation you will need to define the following secrets for your repository or your organisation:

  • GITHUB_TOKEN
  • NPM_TOKEN

(Note: You will also need to add a secret for Sonar in step 3.)

3. Sonar

Sonar Cloud will be used to analyse our project in terms of code-quality: https://en.wikipedia.org/wiki/Software_quality Therefore we need to get credentials for our project. Create a Sonar-Account if you dont have one (it is free).

  • Visit: https://sonarcloud.io/
  • Select your profile or organisation.
  • Select the GitHub project: https://sonarcloud.io/projects/create
  • Configure "With GitHub Actions"
  • Follow Step 1: Add the secret to your repository
  • "Skip" step 2
  • Copy and paste the values of "sonar.projectKey" and "sonar.FireboltCasters" into the setup.json

4. Setup Script

For the correct upload to npm and sonar and keep everything working correctly, the package.json file needs to be setup correctly. This can be tedious, so that you only need to configure the setup.json file to match your project:

{
  "package": {
    "name": "<kitchentemplate>",
    "description": "<packageDescription>",
    "keywords": [
      "npm-template"
    ],
    "repositoryURL": "https://github.com/FireboltCasters/npm-template.git",
    "author": "Steffen Droppelmann",
    "contributors": [
      {
        "name": "Nils Baumgartner",
        "email": "nilsbaumgartner1994@gmail.com",
        "url": "https://github.com/FireboltCasters"
      },
      {
        "name": "Steffen Droppelmann",
        "email": "steffen.droppelmann@gmail.com",
        "url": "https://github.com/FireboltCasters"
      }
    ],
    "license": "MIT"
  },
  "sonar": {
    "projectKey": "ExampleKey",
    "FireboltCasters": "ExampleOrganization"
  }
}

Then, run the following command: (Note: After running this command, the setup files will be deleted)

npm run setup

5. Configure Quality Gate

Push your current project to GitHub. After that you should see on GitHub under "Actions" that some GitHub-Actions are being executed. The Sonar-Action will firstly fail with:

ERROR: QUALITY GATE STATUS: FAILED

This is because we haven't told Sonarcloud how it should measure the Quality Gate.

  • Visit your project at: https://sonarcloud.io/projects/
  • Select: "Set New Code definition"
  • Select the code definition for your match. We recommend: "Previous version"
  • Re-Upload your some minor change in your GitRepo to the master

Contributors

The FireboltCasters

Contributors

Package Sidebar

Install

npm i kitchentemplate

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

713 kB

Total Files

209

Last publish

Collaborators

  • nilsbaumgartner1994