Slide 1

Slide 1 text

Let’s Build Some Shit Making your first NPM package. @rdegges

Slide 2

Slide 2 text

Hey, I’m Randall Developer Evangelist, Stormpath Open Source Dude <333 The Codez

Slide 3

Slide 3 text

(My Goal for You) I just shipped my first Node package to NPM!

Slide 4

Slide 4 text

What’s a Package, Anyway? $ npm install ipify // test.js var ipify = require('ipify'); ipify(function(err, ip) { console.log('My public IP address is:', ip); });

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

How do Packages Work? { "name": "package", "version": "1.0.0", "description": "A simple package.", "bin": "./index.js", "author": "Randall Degges", "license": "ISC" }

Slide 9

Slide 9 text

What do Packages Look Like?

Slide 10

Slide 10 text

Let’s Make a Package!

Slide 11

Slide 11 text

What We’ll Make https://thepiratebay.la/top/207

Slide 12

Slide 12 text

github.com/rdegges/tpb-top100

Slide 13

Slide 13 text

The Codez #!/usr/bin/env node 'use strict'; var cheerio = require('cheerio'); var request = require('request'); var TPB_URL = 'https://thepiratebay.la/top/207'; request(TPB_URL, function(err, resp, body) { if (err || resp.statusCode !== 200) { throw new Error("Couldn't reach thepiratebay... It might be down :("); } console.log('Top 100 Movies from The Pirate Bay'); console.log('----------------------------------\n'); var $ = cheerio.load(body); $('#content .detName a').each(function(index, element) { console.log(index, $(this).text()); }); }); index.js

Slide 14

Slide 14 text

MORE INFOZ! $('#content .detName a') $(this).text()

Slide 15

Slide 15 text

github.com/cheeriojs/cheerio github.com/request/request Fetch web pages really easily. Parse web pages really easily.

Slide 16

Slide 16 text

The NPM Package Info { "name": "tpb-top100", "version": "1.0.0", "description": "List the top 100 most popular movies on The Pirate Bay.", "bin": "./index.js", "dependencies": { "cheerio": "^0.19.0", "request": "^2.61.0" }, "repository": { "type": "git", "url": "git+https://github.com/rdegges/tpb-top100.git" }, "keywords": [ "thepiratebay" ], "author": "Randall Degges", "license": "UNLICENSE", "bugs": { "url": "https://github.com/rdegges/tpb-top100/issues" }, "homepage": "https://github.com/rdegges/tpb-top100#readme"

Slide 17

Slide 17 text

(sidenote) $ npm init $ npm publish Make a package.json. Deploy your package.

Slide 18

Slide 18 text

BONUS POINTS!!! README

Slide 19

Slide 19 text

Don’t Trust Me! Go Use It! $ npm install -g tpb-top100 $ tpb-top100

Slide 20

Slide 20 text

Now It’s Your Turn ● Build a command line tool. ○ Scrape a website. ○ Print off cool information. ○ Can’t be too simple! Duh! ○ Make it useful! <3 ● Package it up. ● Deploy it to NPM. ● First person to deploy a working package gets a t-shirt!

Slide 21

Slide 21 text

Ideas

Slide 22

Slide 22 text

Thanks! @rdegges http://www.rdegges.com [email protected]