Skip to content

mattpjohnson/typescript-library-boilerplate

Repository files navigation

typescript-library-boilerplate

Travis CI Build Status CircleCI Build Status GitLab CI Build Status Codecov Coverage Status SonarQube Technical Debt code style: prettier

A boilerplate with some sane defaults for building TypeScript libraries to be consumed by both browsers and Node.js projects.

Table of Contents

What's Included

This project includes tooling for

With easy integrations for

Setting Up Your Development Environment

It is recommended that you install the following extensions for your editor:

If you're using VSCode all the recommended extensions are included in this extension pack.

Setting Up CircleCI

Login to CircleCI and select "Add Projects" in the left-hand sidebar.
Scroll down until you find your project and click "Set Up Project".
For Operating System choose Linux and then click the "Start Building" button located at the bottom of the page.

If you aren't using SonarQube you'll want to remove && ./sonarqube.sh from the run command in .circleci/config.yml.
If you would like to use SonarQube make sure you setup SonarQube following the instructions below.

If you don't setup or disable SonarQube then CircleCI will fail with the message
You're only authorized to execute a local (preview) SonarQube
analysis without pushing the results to the SonarQube server.
Please contact your SonarQube administrator.

Setting Up Travis CI

Login to https://travis-ci.org/ and click the "+" next to "My Repositories".
Click the toggle next to your project.
And that's it! Your project will build next time you push to your repository.

Setting Up GitLab CI

If your code is hosted on GitLab:

  • From within your GitLab repository, click on "CI/CD" in the left-hand sidebar and click "Run Pipeline" then "Create Pipeline".

If your code is hosted on GitHub:

  • From https://gitlab.com/ click "New project" and select "CI/CD for external repo".
    Click "GitHub" and then click "Connect" next to your project.

Setting Up Codecov

Login to https://codecov.io/gh and give them access to your git hosting account.
Copy your Upload Token and add it with the key CODECOV_TOKEN as an environment variable to the CI service of your choice.

Here are some links to docs for setting up environment variables with the CI services this project supports:

  • CircleCI - Setting an Environment Variable in a Project
  • Travis CI - Defining Variables in Repository Settings
  • GitLab CI - Variables

Congrats! After your next CI run you will see coverage reports.

Reminder: Don't forget to update the badge in README.md to point to your project in codecov

Setting Up SonarQube

Login to https://sonarcloud.io/ and click "Create new project".
Select your repository and click "Create".
Enter a name for your token and click "Generate".
Copy the token that was generated and add it as an environment variable with the key SONAR_LOGIN to your CI project.

If you're not using CircleCI then update your CI run script to call ./sonarqube.sh after build.

After your next CI run you will see code quality analysis in SonarQube.

License

MIT

About

Boilerplate for creating TypeScript libraries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published