These are my notes based on the phenomenal tutorial by Kent C. Dodds hosted by egghead.io both of which are my go to sources when I want to learn something new. I highly suggest you sign up for the pro subscription.
Part 1 : The Setup
These are my notes based on the phenomenal tutorial by Kent C. Dodds hosted by egghead.io both of which are my go to sources when I want to learn something new. I highly suggest you sign up for the pro subscription. They are focused on a ‘code first’ delivery so you start learning right away. I made these notes to dig a little deeper on some of the topics, but I would not have known where to get started without these two wonderful resources!
I will be using the following icons to denote certain sections.
= Time Saving Idea
= Pro Tip
= Code Update
= A Closer Look
- Create the git repo
- Create the library
- Publish to npm
- Create test suites
- Set up continuous Integration
- Add ES6/ES2015
- web pack
Create the GitHub Repo
First head over to github.com to create your account if you don’t already have one. Next create a new repo. You can skip creating the README.md as we will be making our own in the next few moments. Take note of the url for the repo as we are going to add it in as the origin in the following steps.
$ echo “# Project name” >> README.md $ git init $ git add README.md $ git commit -m "Initial Commit" $ git remote add origin <git url> //i.e. https://github.com/jmichelin/something.git $ git push -u origin master
Setting up NPM
To verify that you have node installed run:
$ npm -v
Head to https://docs.npmjs.com/ and read about init-author.name, init-author-email, init-author-url, init-license and save-exact. These set up defaults making future projects even easier. The save-exact true makes your project configured with an exact version rather than using npm’s default semver range operator. There are more but these are some of the more common ones that tend not to change between projects.
Run the following commands:
$ npm set init-author-name 'Name' $ npm set init-author-email '<your_email>' $ npm set init-author -url '<your_website>' $ npm set init-license 'MIT' $ npm set save-exact true //makes sure you use exact versioning
let’s look at npmrc:
$ cat ~/.npmrc
You will see all of the defaults you set above saved there in case you ever want to edit them.
Create npmjs.com account by heading over to npmjs.com and click on sign up.
Then back in your console:
$ npm adduser
enter npmjs account name, password and Email, add user creates an auth token that you should keep private.
$ npm init
Accept default name, version, enter a brief description, entry point is the file that will be looked at when you require(‘module-name’); change the entry point to read src/index.js accept default for test, for github repo, enter some keywords, accept default license, and create package.json.
Next…Creating a Library
start thinking about what you might want to make and keep it simple.