Skip to content

Commit

Permalink
Added unit tests and setup coverage report via travis and coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
enenkel committed Feb 18, 2017
1 parent d60f7af commit 2714217
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 117 deletions.
220 changes: 220 additions & 0 deletions .eslintrc.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
.idea
temp
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "node"
- "6"
- "5"
- "4"
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Generator-NExT [![NPM version][npm-image]][npm-url]
# Generator-NExT
[![NPM version][npm-image]][npm-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Build Status][travis-image]][travis-url]
> Generator that provides a basic setup for a **N**ode project with **Ex**press and **T**ypescript.
![alt tag](assets/generator-next.gif)

## Installation

First, install [Yeoman](http://yeoman.io) and Generator-NExT using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).
Expand Down Expand Up @@ -55,15 +58,20 @@ Check here for available [releases](https://github.com/ommsolutions/generator-ne

## Roadmap

Version 0.3.x: Implement sub generator which adds [pug](https://github.com/pugjs/pug)
Version 0.4.x: Implement sub generator which adds [mongoose](https://github.com/Automattic/mongoose)
Version 1.x.x: Combine all sub generators on demand.
Version 0.3.x: Add test coverage for generator with travis and coveralls
Version 0.4.x: Implement sub generator which adds [typedoc](https://github.com/TypeStrong/typedoc)
Version 0.5.x: Implement sub generator which adds [rxjs](https://github.com/Reactive-Extensions/RxJS)
Version 0.6.x: Implement sub generator which adds [mongoose](https://github.com/Automattic/mongoose)
Version 0.5.x: Implement sub generator which adds [pug](https://github.com/pugjs/pug)
Version 1.x.x: Combine all sub generators combined depending on the user's responses.

## License

MIT

[npm-image]: https://badge.fury.io/js/generator-next.svg
[npm-url]: https://npmjs.org/package/generator-next
[coveralls-image]: https://coveralls.io/repos/enenkel/generator-next/badge.svg
[coveralls-url]: https://coveralls.io/r/enenkel/generator-next
[coveralls-image]:https://coveralls.io/repos/github/ommsolutions/generator-next/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/github/ommsolutions/generator-next?branch=master
[travis-image]:https://travis-ci.org/ommsolutions/generator-next.svg?branch=master
[travis-url]:https://travis-ci.org/ommsolutions/generator-next?branch=master
Binary file added assets/generator-next.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions generators/app/templates/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var typescript = require("gulp-typescript");
var nodemon = require("gulp-nodemon");
var tslint = require("gulp-tslint");
var runSequence = require("run-sequence");
var rimraf = require("rimraf");
var typedoc = require("gulp-typedoc");
var mocha = require("gulp-mocha");
var istanbul = require("gulp-istanbul");
var plumber = require("gulp-plumber");
var remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");
let gulp = require("gulp");
let sourcemaps = require("gulp-sourcemaps");
let typescript = require("gulp-typescript");
let nodemon = require("gulp-nodemon");
let tslint = require("gulp-tslint");
let runSequence = require("run-sequence");
let rimraf = require("rimraf");
let typedoc = require("gulp-typedoc");
let mocha = require("gulp-mocha");
let istanbul = require("gulp-istanbul");
let plumber = require("gulp-plumber");
let remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");

const CLEAN_BUILD = "clean:build";
const CLEAN_COVERAGE = "clean:coverage";
Expand Down Expand Up @@ -91,7 +91,7 @@ gulp.task(PRETEST, function() {

// Run the tests via mocha and generate a istanbul json report.
gulp.task(RUN_TESTS, function(callback) {
var mochaError;
let mochaError;
gulp.src(JS_TEST_GLOB)
.pipe(plumber())
.pipe(mocha({reporter: "spec"}))
Expand Down
61 changes: 31 additions & 30 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
'use strict';
var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');

gulp.task('static', function () {
return gulp.src('**/*.js')
"use strict";
let path = require("path");
let gulp = require("gulp");
let eslint = require("gulp-eslint");
let excludeGitignore = require("gulp-exclude-gitignore");
let mocha = require("gulp-mocha");
let istanbul = require("gulp-istanbul");
let nsp = require("gulp-nsp");
let plumber = require("gulp-plumber");
let coveralls = require("gulp-coveralls");

gulp.task("static", function () {
return gulp.src("**/*.js")
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint(".eslintrc.json"))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
nsp({package: path.resolve('package.json')}, cb);
gulp.task("nsp", function (cb) {
nsp({package: path.resolve("package.json")}, cb);
});

gulp.task('pre-test', function () {
return gulp.src('generators/**/*.js')
gulp.task("pre-test", function () {
return gulp.src(["generators/**/*.js", "!**/gulpfile.js"])
.pipe(excludeGitignore())
.pipe(istanbul({
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
var mochaErr;
gulp.task("test", ["pre-test"], function (cb) {
let mochaErr;

gulp.src('test/**/*.js')
gulp.src("test/**/*.js")
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.on('error', function (err) {
.pipe(mocha({reporter: "spec"}))
.on("error", function (err) {
mochaErr = err;
})
.pipe(istanbul.writeReports())
.on('end', function () {
.on("end", function () {
cb(mochaErr);
});
});

gulp.task('watch', function () {
gulp.watch(['generators/**/*.js', 'test/**'], ['test']);
gulp.task("watch", function () {
gulp.watch(["generators/**/*.js", "test/**"], ["test"]);
});

gulp.task('coveralls', ['test'], function () {
gulp.task("coveralls", ["test"], function () {
if (!process.env.CI) {
console.log("Not running on CI server -> skipped coveralls");
return;
}

return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
return gulp.src(path.join(__dirname, "coverage/lcov.info"))
.pipe(coveralls());
});

gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test', 'coveralls']);
gulp.task("prepublish", ["nsp"]);
gulp.task("default", ["static", "test", "coveralls"]);
96 changes: 46 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
{
"name": "generator-next",
"version": "0.2.1",
"description": "Generator that provides a basic setup for a Node project with Express and Typescript.",
"homepage": "https://github.com/ommsolutions/generator-next",
"author": {
"name": "Andreas Enenkel",
"email": "ae@omm-solutions.de"
},
"files": [
"generators"
],
"main": "generators/index.js",
"keywords": [
"Node",
"Express",
"Typescript",
"yeoman-generator"
],
"dependencies": {
"chalk": "^1.1.3",
"yeoman-generator": "^1.1.0",
"yosay": "^1.2.1"
},
"devDependencies": {
"eslint": "^3.15.0",
"eslint-config-xo-space": "^0.15.0",
"gulp": "^3.9.1",
"gulp-coveralls": "^0.1.4",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^1.1.1",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-mocha": "^3.0.1",
"gulp-nsp": "^2.4.2",
"gulp-plumber": "^1.1.0",
"yeoman-assert": "^2.2.3",
"yeoman-test": "^1.6.0"
},
"eslintConfig": {
"extends": "xo-space",
"env": {
"mocha": true
}
},
"repository": "https://github.com/ommsolutions/generator-next",
"scripts": {
"prepublish": "gulp prepublish",
"test": "gulp"
},
"license": "MIT"
"name": "generator-next",
"version": "0.3.0",
"description": "Generator that provides a basic setup for a Node project with Express and Typescript.",
"homepage": "https://github.com/ommsolutions/generator-next",
"author": {
"name": "Andreas Enenkel",
"email": "ae@omm-solutions.de"
},
"files": [
"generators"
],
"main": "generators/index.js",
"keywords": [
"Node",
"Express",
"Typescript",
"yeoman-generator"
],
"dependencies": {
"chalk": "^1.1.3",
"yeoman-generator": "^1.1.0",
"yosay": "^1.2.1"
},
"devDependencies": {
"eslint": "^3.15.0",
"eslint-config-xo-space": "^0.15.0",
"fs-extra": "2.0.0",
"gulp": "^3.9.1",
"gulp-coveralls": "^0.1.4",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^1.1.1",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-mocha": "^3.0.1",
"gulp-nsp": "^2.4.2",
"gulp-plumber": "^1.1.0",
"rimraf": "2.5.4",
"yeoman-assert": "^2.2.3",
"yeoman-test": "^1.6.0"
},
"repository": "https://github.com/ommsolutions/generator-next",
"scripts": {
"prepublish": "gulp prepublish",
"test": "gulp"
},
"license": "MIT"
}
18 changes: 0 additions & 18 deletions test/app.js

This file was deleted.

Loading

0 comments on commit 2714217

Please sign in to comment.