Skip to content

Commit

Permalink
package.json cleanup, Phase 4
Browse files Browse the repository at this point in the history
- @cantremember/node-mocks-http
- config efficiency
- ci integration
- travis-ci.org
- coveralls.io
- #!/bin/bash
- massive dependency upgrade
- httpMocks.createRequest({ query })
- supertest#expect(302) for all redirects
- mock and retrieve from request#query Object hash
- throw an Error in supertest#expect filters
  • Loading branch information
cantremember committed May 14, 2015
1 parent 42035f8 commit 0c226f2
Show file tree
Hide file tree
Showing 29 changed files with 173 additions and 91 deletions.
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: node_js
node_js:
- "0.12"
- "0.10"
- stable

before_install:
- "npm install -g npm@^2.7.x"
script: "npm run ci"

branches:
only:
- master
- develop
# - edge

# http://docs.travis-ci.com/user/build-configuration/
# services: []
# env: []
# before_script: []
# after_failure: []
# after_script: []
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,24 @@

A Node.js app to replace legacy Perl CGI scripts for [sleepbot.com](http://sleepbot.com)

[![Build status][travis-img]][travis-url]
[![Test coverage][coveralls-img]][coveralls-url]
[![Dependency status][david-img]][david-url]
[![License][license-img]][license-url]

Provided as a code example, since no one in their right might has any need for this besides me.


## License

[WTFPL][license-url]


[travis-img]: https://img.shields.io/travis/cantremember/node-sleepbot-cgi.svg?style=flat-square
[travis-url]: https://travis-ci.org/cantremember/node-sleepbot-cgi
[coveralls-img]: https://img.shields.io/coveralls/cantremember/node-sleepbot-cgi.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/cantremember/node-sleepbot-cgi
[david-img]: https://img.shields.io/david/cantremember/node-sleepbot-cgi.svg?style=flat-square
[david-url]: https://david-dm.org/cantremember/node-sleepbot-cgi
[license-img]: https://img.shields.io/badge/license-WTFPL-blue.svg?style=flat-square
[license-url]: LICENSE
4 changes: 2 additions & 2 deletions app/lookitImgFoley.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ var theLib = require('../lib/index');
module.exports = function handler(req, res, cb) {
return Promise.resolve()
.then(function() {
var title = req.param('title') || '(image)';
var image = req.param('image');
var title = req.query.title || '(image)';
var image = req.query.image;
image = (image
? ('/lookit/images/dfoley/' + image)
: '/images/shim_clear.gif'
Expand Down
2 changes: 1 addition & 1 deletion app/morganLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = function handler(req, res, cb) {

// parameters
// 1..10 cards, assume 3
var cardCount = req.param('cards');
var cardCount = req.query.cards;

cardCount = ((cardCount === undefined || cardCount === null)
? 3
Expand Down
2 changes: 1 addition & 1 deletion app/sebPlaylist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// TODO:
// support req.params('format'), M3U, etc.
// support req.params.format, M3U, etc.
// is M3U just a single line with a URL?

var theLib = require('../lib/index');
Expand Down
5 changes: 2 additions & 3 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ var path = require('path');

module.exports = {
httpPort: 3000,
wwwRoot: '/Volumes/GrandMasterKashik/archive/http',
wwwRoot: '/mnt/ec2-http/sleepbot.com',
baseURL: 'http://www.sleepbot.com',
// baseURL: 'http://sleepbot.localhost:8080',
// baseURL: 'http://localhost:3000',
caching: false,

viewsRoot: path.resolve(
path.join(__dirname, '../views') // relative to *me*
Expand Down
4 changes: 2 additions & 2 deletions config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


module.exports = {
// overrides
wwwRoot: '/Volumes/GrandMasterKashik/archive/http',
caching: false,

baseURL: 'http://localhost:3000',
// baseURL: 'http://localhost:3000',
};
4 changes: 0 additions & 4 deletions config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@


module.exports = {
// overrides
wwwRoot: '/mnt/ec2-http/sleepbot.com',
caching: true,

baseURL: 'http://www.sleepbot.com',
};
4 changes: 1 addition & 3 deletions config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@


module.exports = {
// overrides
wwwRoot: '/mock-fs',

baseURL: 'http://localhost:3000',
// baseURL: 'http://sleepbot.localhost:8080',
caching: false,

viewsRoot: '/mock-fs',

Expand Down
45 changes: 27 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,64 @@
{
"name": "node-sleepbot-cgi",
"version": "0.0.2",
"version": "0.1.0",
"description": "A Node.js app to replace legacy Perl CGI scripts for sleepbot.com",
"author": "Daniel M Foley",
"author": "Daniel M Foley <webmaster@sleepbot.com>",
"repository": {
"type": "git",
"url": "ssh://git@sink.cantremember.com/opt/git-repo/node-sleepbot-cgi.git"
},
"license": "WTFPL",
"homepage": "http://sleepbot.com",
"email": "webmaster@sleepbot.com",
"keywords": [
"sleepbot"
],
"main": "index.js",
"directories": {
"app": "./app",
"lib": "./lib"
},
"files": [],
"readmeFilename": "README.md",
"scripts": {
"postinstall": "./run/post-install",
"test": "BLUEBIRD_DEBUG=1 NODE_ENV=test ./node_modules/.bin/mocha test",
"test-debug": "BLUEBIRD_DEBUG=1 NODE_ENV=test ./node_modules/.bin/mocha debug test",
"ci": "./run/ci",
"lint": "./run/lint",
"style": "./run/style",
"coverage": "./run/coverage",
"doc": "./run/doc",
"dev": "BLUEBIRD_DEBUG=1 NODE_ENV=test node app.js"
"dev": "BLUEBIRD_DEBUG=1 NODE_ENV=dev node app.js"
},
"repository": {
"type": "git",
"url": "ssh://git@sink.cantremember.com/opt/git-repo/node-sleepbot-cgi.git"
"engines": {
"node": ">= 0.10.0"
},
"readmeFilename": "README.md",
"dependencies": {
"bluebird": "~2.3.2",
"bluebird": "^2.9.0",
"cookie-parser": "~1.3.2",
"csv": "0.4.x",
"ejs": "~1.0.0",
"express": "~4.8.7",
"forever": "~0.11.1",
"glob": "~4.0.5",
"csv": "^0.4.0",
"ejs": "^2.3.0",
"express": "^4.12.0",
"forever": "~0.14.0",
"glob": "^5.0.0",
"lodash": "^3.8.0",
"marked-engine": "~0.1.0",
"minimist": "~1.1.0",
"nconf": "~0.7.1",
"request": "~2.40.0"
"request": "^2.55.0"
},
"devDependencies": {
"istanbul": "~0.2.7",
"@cantremember/node-mocks-http": "^1.5.0",
"coveralls": "^2.11.2",
"istanbul": "~0.3.14",
"jscs": "^1.12.0",
"jsdoc": "3.3.0-beta1",
"jshint": "^2.6.3",
"mocha": "^1.21.4",
"mocha": "^2.2.0",
"mock-fs": "^2.6.0",
"node-mocks-http": "git+ssh://git@github.com:cantremember/node-mocks-http.git#master",
"proxyquire": "^1.4.0",
"sinon": "^1.10.3",
"supertest": "~0.13.0"
"supertest": "~1.0.0"
}
}
22 changes: 22 additions & 0 deletions run/ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

source `dirname $0`/common

# https://github.com/cainus/node-coveralls

pushd . > /dev/null
cd $ROOT

OUTPUT=./coverage/lcov.info
rm -f $OUTPUT

NODE_ENV=test $NODE_BIN/istanbul cover $NODE_BIN/_mocha test -- --reporter dot
if [[ "$?" != "0" ]]; then
FAIL "Test Suite failed"
fi

cat $OUTPUT | $NODE_BIN/coveralls

popd > /dev/null

SUCCEED "CI passed!"
19 changes: 10 additions & 9 deletions run/common
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# paths
# walk up to find package.json @ ROOT
Expand All @@ -13,26 +13,27 @@ NODE_BIN=$ROOT/node_modules/.bin
JS_DIRS="app/ app.js config/ index.js lib/ run/ test/ views/"

# colors
C_INFO="\033[97;40m"
C_OK="\033[97;42m"
C_ERR="\033[97;41m"
C_WARN="\033[97;43m"
# http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
C_INFO="\033[1;37;40m"
C_OK="\033[1;30;42m"
C_ERR="\033[1;30;41m"
C_WARN="\033[1;30;43m"
C_CLOSE="\033[0m"

# logging and resolution
function INFO () {
echo "$C_INFO INFO $C_CLOSE $1"
echo -e "$C_INFO INFO $C_CLOSE $1"
}
function WARN () {
echo "$C_WARN WARN $C_CLOSE $1"
echo -e "$C_WARN WARN $C_CLOSE $1"
}
function FAIL () {
echo "$C_ERR FAIL $C_CLOSE $1"
echo -e "$C_ERR FAIL $C_CLOSE $1"
cd $PWD
exit 1
}
function SUCCEED () {
echo "$C_OK OK $C_CLOSE $1"
echo -e "$C_OK OK $C_CLOSE $1"
cd $PWD
exit 0
}
Expand Down
2 changes: 1 addition & 1 deletion run/coverage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source `dirname $0`/common

Expand Down
2 changes: 1 addition & 1 deletion run/doc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source `dirname $0`/common

Expand Down
2 changes: 1 addition & 1 deletion run/lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source `dirname $0`/common

Expand Down
2 changes: 1 addition & 1 deletion run/post-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source `dirname $0`/common

Expand Down
6 changes: 3 additions & 3 deletions run/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source `dirname $0`/common

Expand Down Expand Up @@ -31,7 +31,7 @@ fi
#

INFO "linting"
npm run-script lint
npm run lint
if [[ "$?" != "0" ]]; then # there were failures
exit 1 # already reported itself
fi
Expand All @@ -41,7 +41,7 @@ fi
#

INFO "styling"
npm run-script style
npm run style
if [[ "$?" != "0" ]]; then # there were failures
exit 1 # already reported itself
fi
Expand Down
2 changes: 1 addition & 1 deletion run/style
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

source `dirname $0`/common

Expand Down
Loading

0 comments on commit 0c226f2

Please sign in to comment.