Skip to content

Latest commit

 

History

History
161 lines (112 loc) · 3.62 KB

slides.md

File metadata and controls

161 lines (112 loc) · 3.62 KB

title: Getting started with open source output: index.html theme: theme controls: false

-- intro

Getting started with open source


Topics

  • Git & Github
  • Branches, Pull Request
  • What is NodeJS
  • NPM packages and package.json
  • Creating a node project
  • A NodeJS webserver
  • Testing
  • Continuous Integration (CI)

--

Git

A distributed version control system

Git

--

GitHub

A platform for collaborating on source code.

Codercat Mountietocat

--

Branches, Pull Request

Git branches

--

What is NodeJS

A JavaScript runtime to build scalable network applications

NodeJS logo

--

  • currently hosts ~ 1m modules
  • easy to use (npm install <package>)
  • easy to publish (npm publish)
  • use it with anything (folders, tarballs, git repositories)
  • Attempt for JavaScript API standardization

CommonJS modules

Provides global module, exports and require() to define this files API

// module1.js
exports.hello = 'World';
// or
module.exports = {
  hello: 'World'
}

Using the module

// main.js
var mod1 = require('./module1');

console.log(mod1.hello); // -> World

--

package.json

CommonJS specification for describing JavaScript packages

{
  "name": "nodeschool",
  "version": "0.1.0",
  "author": "Nodeschool <people@nodeschool.com>",
  "description": "NodeJS FTW!",
  "scripts": {
    "test": "mocha test",
    "start": "node lib/start.js"
  },
  "main": "./lib/main.js",
  "repository": {
    "type": "git", "url": "https://github.com/yycjs/node-up"
  },
  "dependencies": { "somePackage": "^1.0.0" },
  "devDependencies": { "some-dev-only-package":  "^0.2.0" },
  "license": "MIT"
}

--

A NodeJS webserver

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

--

Testing

Split functionality into contained units. Ideally each function should perform one unit of work.

--

Continuous Integration (CI)

  • Use source control management system (SCM) for builds
  • Run reports, tests, deploy or other tools on each SCM change
  • Popular open source CI servers:
    • Jenkins: Probably most popular CI server, formerly Hudson
    • CruiseControl: CI framework initially by Thoughtworks
  • Hosted CI services