Skip to content

Commit

Permalink
Drop gulp-coveralls and use the api directly
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jan 28, 2017
1 parent 8097483 commit 83d7917
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 182 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
coverage
npm-debug.log
node_modules
temp
coverage
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_js:
- node
cache:
yarn: true
after_script: 'cat ./coverage/lcov.info | coveralls'
15 changes: 12 additions & 3 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var parseAuthor = require('parse-author');
var githubUsername = require('github-username');
var path = require('path');
var askName = require('inquirer-npm-name');
var pkgJson = require('../../package.json');

module.exports = Generator.extend({
constructor: function () {
Expand Down Expand Up @@ -223,9 +224,14 @@ module.exports = Generator.extend({
this.options.projectRoot,
'index.js'
).replace(/\\/g, '/'),
keywords: []
keywords: [],
devDependencies: {}
}, currentPkg);

if (this.props.includeCoveralls) {
pkg.devDependencies.coveralls = pkgJson.devDependencies.coveralls;
}

// Combine the keywords
if (this.props.keywords) {
pkg.keywords = _.uniq(this.props.keywords.concat(pkg.keywords));
Expand All @@ -237,7 +243,11 @@ module.exports = Generator.extend({

default: function () {
if (this.options.travis) {
this.composeWith(require.resolve('generator-travis/generators/app'));
let options = {config: {}};
if (this.props.includeCoveralls) {
options.config.after_script = 'cat ./coverage/lcov.info | coveralls'; // eslint-disable-line camelcase
}
this.composeWith(require.resolve('generator-travis/generators/app'), options);
}

this.composeWith(require.resolve('../editorconfig'));
Expand All @@ -254,7 +264,6 @@ module.exports = Generator.extend({

if (this.options.gulp) {
this.composeWith(require.resolve('../gulp'), {
coveralls: this.props.includeCoveralls,
babel: this.props.babel,
projectRoot: this.options.projectRoot,
cli: this.options.cli
Expand Down
15 changes: 0 additions & 15 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ module.exports = Generator.extend({
desc: 'Relocate the location of the generated files.'
});

this.option('coveralls', {
type: Boolean,
required: false,
desc: 'Send coverage reports to coveralls'
});

this.option('babel', {
type: Boolean,
required: false,
Expand Down Expand Up @@ -60,10 +54,6 @@ module.exports = Generator.extend({
}
});

if (this.options.coveralls) {
pkg.devDependencies['gulp-coveralls'] = '^0.1.0';
}

if (this.options.babel) {
pkg.devDependencies['gulp-babel'] = '^6.1.2';
pkg.devDependencies.del = '^2.0.2';
Expand All @@ -84,10 +74,6 @@ module.exports = Generator.extend({
var tasks = ['test'];
var prepublishTasks = [];

if (this.options.coveralls) {
tasks.push('coveralls');
}

if (this.options.cli) {
prepublishTasks.push('line-ending-corrector');
}
Expand All @@ -100,7 +86,6 @@ module.exports = Generator.extend({
this.templatePath('gulpfile.js'),
this.destinationPath(this.options.generateInto, 'gulpfile.js'),
{
includeCoveralls: this.options.coveralls,
cli: this.options.cli,
babel: this.options.babel,
tasks: stringifyArray(tasks),
Expand Down
15 changes: 1 addition & 14 deletions generators/gulp/templates/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var plumber = require('gulp-plumber');
<% if (includeCoveralls) { -%>
var coveralls = require('gulp-coveralls');
<% } -%>
<% if (cli) { -%>
var lec = require('gulp-line-ending-corrector');
<% } -%>
Expand Down Expand Up @@ -51,18 +48,8 @@ gulp.task('test', ['pre-test'], function (cb) {
gulp.task('watch', function () {
gulp.watch(['<%- projectRoot %>', 'test/**'], ['test']);
});
<% if (includeCoveralls) { -%>

gulp.task('coveralls', ['test'], function () {
if (!process.env.CI) {
return;
}

return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
.pipe(coveralls());
});
<% } -%>
<% if (cli) { -%>

gulp.task('line-ending-corrector', function () {
return gulp.src('<%- projectRoot.replace("**/*.js", "cli.js") %>')
.pipe(excludeGitignore())
Expand Down
48 changes: 25 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
{
"name": "generator-node",
"version": "1.12.1",
"main": "index.js",
"description": "Create a Node.js module",
"homepage": "https://github.com/yeoman/generator-node",
"author": "Yeoman team",
"files": [
"index.js",
"generators"
],
"main": "index.js",
"keywords": [
"yeoman-generator",
"scaffold",
"node",
"module",
"cli"
],
"author": "Yeoman team",
"repository": "yeoman/generator-node",
"scripts": {
"pretest": "eslint **/*.js --fix",
"test": "gulp",
"prepublish": "nsp check"
},
"dependencies": {
"generator-license": "^4.0.0",
"generator-travis": "^1.1.3",
"git-remote-origin-url": "^2.0.0",
"github-username": "^3.0.0",
"inquirer-npm-name": "^2.0.0",
"lodash": "^4.17.3",
"parse-author": "^1.0.0",
"yeoman-generator": "^1.0.1"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"coveralls": "^2.11.15",
"eslint": "^3.8.1",
"eslint-config-xo": "^0.17.0",
"eslint-config-xo-space": "^0.15.0",
Expand All @@ -44,17 +33,30 @@
"nsp": "^2.6.2",
"pinkie-promise": "^2.0.1",
"yeoman-assert": "^2.2.1",
"yeoman-test": "^1.5.1"
"yeoman-test": "^1.5.1",
"gulp-line-ending-corrector": "^1.0.1"
},
"repository": "yeoman/generator-node",
"scripts": {
"pretest": "eslint **/*.js --fix",
"test": "gulp",
"prepublish": "nsp check"
},
"dependencies": {
"generator-license": "^4.0.0",
"generator-travis": "^1.1.3",
"git-remote-origin-url": "^2.0.0",
"github-username": "^3.0.0",
"inquirer-npm-name": "^2.0.0",
"lodash": "^4.17.3",
"parse-author": "^1.0.0",
"yeoman-generator": "^1.0.1"
},
"eslintConfig": {
"extends": "xo-space",
"env": {
"mocha": true
}
},
"files": [
"index.js",
"generators"
],
"license": "MIT"
}
7 changes: 6 additions & 1 deletion test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe('node:app', function () {
authorEmail: 'hi@yeoman.io',
authorUrl: 'http://yeoman.io',
keywords: ['foo', 'bar'],
babel: true
babel: true,
includeCoveralls: true
};
return helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts(this.answers);
Expand Down Expand Up @@ -88,6 +89,10 @@ describe('node:app', function () {
assert.fileContent('README.md', '[travis-image]: https://travis-ci.org/yeoman/generator-node.svg?branch=master');
assert.fileContent('README.md', 'coveralls');
});

it('creates proper Travis config', function () {
assert.fileContent('.travis.yml', '| coveralls');
});
});

describe('running on existing project', function () {
Expand Down
123 changes: 0 additions & 123 deletions test/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,6 @@ var assert = require('yeoman-assert');
var helpers = require('yeoman-test');

describe('node:gulp', function () {
describe('including coveralls', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.withOptions({
coveralls: true,
projectRoot: 'lib'
});
});

it('creates files and configuration', function () {
assert.file([
'gulpfile.js',
'package.json'
]);

assert.fileContent('gulpfile.js', 'gulp.task(\'coveralls\'');
assert.fileContent('gulpfile.js', 'gulp.task(\'test\'');

assert.fileContent('package.json', 'gulp');
assert.fileContent('package.json', 'gulp-coveralls');
assert.fileContent('package.json', '"test": "gulp"');
assert.fileContent('package.json', '"prepublish": "gulp prepublish"');
});

it('does not include babel configurations', function () {
assert.noFileContent('gulpfile.js', 'gulp.task(\'babel\'');
assert.noFileContent('package.json', 'gulp-babel');
});
});

describe('excluding coveralls', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.withOptions({
coveralls: false,
projectRoot: 'lib'
});
});

it('does not include coveralls configurations', function () {
assert.noFileContent('gulpfile.js', 'gulp.task(\'coveralls\'');
assert.noFileContent('package.json', 'gulp-coveralls');
});
});

describe('--no-coveralls', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.withOptions({
coveralls: false,
projectRoot: 'lib'
});
});

it('does not include coveralls configurations', function () {
assert.noFileContent('gulpfile.js', 'gulp.task(\'coveralls\'');
assert.noFileContent('package.json', 'gulp-coveralls');
});
});

describe('--babel', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
Expand Down Expand Up @@ -97,69 +37,6 @@ describe('node:gulp', function () {
});

describe('node:gulp', function () {
describe('including coveralls with generate-into option', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.withOptions({
coveralls: true,
projectRoot: 'lib',
generateInto: 'other/'
});
});

it('creates files and configuration', function () {
assert.file([
'other/gulpfile.js',
'other/package.json'
]);

assert.fileContent('other/gulpfile.js', 'gulp.task(\'coveralls\'');
assert.fileContent('other/gulpfile.js', 'gulp.task(\'test\'');

assert.fileContent('other/package.json', 'gulp');
assert.fileContent('other/package.json', 'gulp-coveralls');
assert.fileContent('other/package.json', '"test": "gulp"');
assert.fileContent('other/package.json', '"prepublish": "gulp prepublish"');
});

it('does not include babel configurations', function () {
assert.noFileContent('other/gulpfile.js', 'gulp.task(\'babel\'');
assert.noFileContent('other/package.json', 'gulp-babel');
});
});

describe('excluding coveralls with generate-into option', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.withOptions({
coveralls: false,
projectRoot: 'lib',
generateInto: 'other/'
});
});

it('does not include coveralls configurations', function () {
assert.noFileContent('other/gulpfile.js', 'gulp.task(\'coveralls\'');
assert.noFileContent('other/package.json', 'gulp-coveralls');
});
});

describe('--no-coveralls and --generate-into', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
.withOptions({
coveralls: false,
projectRoot: 'lib',
generateInto: 'other/'
});
});

it('does not include coveralls configurations', function () {
assert.noFileContent('other/gulpfile.js', 'gulp.task(\'coveralls\'');
assert.noFileContent('other/package.json', 'gulp-coveralls');
});
});

describe('--babel and --generate-into', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/gulp'))
Expand Down

0 comments on commit 83d7917

Please sign in to comment.