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

create-github-package

v1.0.3

Published

boiler plate for a npm package hosted in github using typescript and other tools for better CI/CD

Downloads

2

Readme

CREATE GITHUB PACKAGE

This package will help you to create a boiler plate for creating a new npm package and be hosted into github, with some utils added and CI/CD using github workflows

Utils included and configured:

  • Github Workflows:
    • (unit testing on PR into develop and master branch)
    • Auto publishing your package when merging into master
  • Typescript
  • Jest
  • Husky
  • Prettier
  • ESLint
  • Standard-version

Usage

Start by creating a new repository and add a repository secret (under the repository settings) with the name of GH_PACKAGE_TOKEN the token that you put there needs to have access to read/write packages. (if you don't have a token yet, you can create one on https://github.com/settings/tokens )

once your repo is ready clone it into your local computer. then in the root of your empty project run:

npx create-github-package

this will start a wizard of 2 questions it'll ask you for your username or your organization name. It needs to be the same where your repo is hosted.

your package name needs to be all lower case (if you need spaces use dash), if you have upper cases you might encounter errors when publishing.

The script will then install some dependencies, this can take some minutes depending on your internet connection.

once is done, you can start codding!

Conventional commits

In order for standard release work the best, you need to use conventional commits. I recommend to use Commitizen, but this is up to you.

Your first release

for your first release you can work on the master branch, and when you are ready run

npm run release -- --first-release

then push your branch as follow:

git push --follow-tags origin master

this should trigger an automated publishing of your package!

After your first release

You need to create a develop branch from master and push it.

And branch-out develop for every new change you want to do. and create PR into develop when creating the PR to develop, github actions will run unit test. you should not merge it to develop unless all test have passed.

(tip you can lock the branch until this happen, under the repository settings / branches )

ready for next release

for the next steps you can keep working on develop or create a release branch and merge develop into release.

Before you deploy you need to run

npm run release

This will bump your package.json package.lock.json and create a git tag and if you have conventional commits it will create a changelog for you.

once that's done you need to push it with --follow-tags for example:

git push --follow-tags origin develop

or

git push --follow-tags origin release

After this create a PR to master. this will again trigger unit testing once is ready, you can merge into master and this will create a new version of your package.

Using your package in an external project

the new project needs to have a .npmrc file in the root folder with:


@<<your-user-name>>:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:\_authToken=<<READ_ONLY_TOKEN>>
registry=https://registry.npmjs.com

replace <<your-user-name>> with your user name or your organization and <<READ_ONLY_TOKEN>> with a new token with read-only for packages (if you don't want to store this in the repo, you can use environment variables)