Skip to content

1. Getting Started

RilDev edited this page Dec 1, 2020 · 11 revisions

Setting Up Your Environment

In order to use gh-packages you will need Node.js and Git.

To test if you have Node.js, run this command line:

node -v

You should see something like this, your version might be diffrent:

user@computer:~$ node -v
v10.20.1

If you see this output, then you have Node.js installed.

If you see an error, then you should download Node.js here: Download Node.js.

To test if you have Git, run this command:

git --version

You should see something like this, your version might be diffrent:

user@computer:~$ git --version
git version 2.25.1

If you see this output, then you have Git installed.

If you see an error, then you should download Git here: Download Git.

Install gh-packages

To install gh-packages, you should run the following command:

npm i -g gh-packages

The -g flag stands for "Global", it means that gh-packages will be accessible in all your projects without having to reinstall it.

Publish Your Package

In order to publish a package, you first need to set it up:

npm login #optional
mkdir your-package
cd your-package
npm init
git init

Here is what this code does:

  • (Optional) if you are not yet logged in to npmjs.com, then run npm login to do so. You will be prompt with a few questions to connect your computer to your NPM account.
  • The mkdir command creates a new directory.
  • cd stands for change directory, it will put us inside the directory your-package.
  • The command npm init will start an interactive tool that will help you setup your package information. That information will be used by npmjs.com to create your package.
  • The git init command will setup git, the version management tool, in your package. gh-packages uses git to perform the custom commands without modifying your working code. That's why it is necessary to have it setup in your project before using gh-packages.

Note: You don't need to have a git online repository for gh-packages to work, just make sure you run git init in your project's directory.

To publish your package to NPM simply run gh-packages inside your package's directory:

cd your-package
gh-packages

This command will patch your version number in your package.json and commit it. It will then publish your package to NPM.

Note: If you don't have an NPM account yet, you can create one here: create NPM account.

Clone this wiki locally