-
Notifications
You must be signed in to change notification settings - Fork 0
1. Getting Started
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.
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.
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 directoryyour-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 setupgit
, the version management tool, in your package.gh-packages
usesgit
to perform the custom commands without modifying your working code. That's why it is necessary to have it setup in your project before usinggh-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.
For more information about the different installation options, please read the Installation page.
For more information about the different options offered by gh-packages
, like publishing a minor
update or using a custom command, please read the Options page.
For practical examples, please read the Examples page.