Skip to content

Commit

Permalink
Remove babel support
Browse files Browse the repository at this point in the history
This is temporary. Babel support through gulp was adding an incredible
amount of complexity to every part of the generated system. We'll
probably add babel support back eventually, but for now we prefer to
skip it than providing less than ideal project configuration.
  • Loading branch information
SBoudrias committed Jan 28, 2017
1 parent 83d7917 commit 602e250
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 263 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ That'll generate a project with all the common tools setup. This includes:

- Filled `package.json` file
- [gulp](http://gulpjs.com/) task runner
- [Babel](https://babeljs.io/) ES2015 transpiler
- [mocha](http://mochajs.org/) unit test
- [ESLint](http://eslint.org/) linting and code style checking
- [nsp](https://nodesecurity.io/) known vulnerability check
Expand Down Expand Up @@ -81,7 +80,6 @@ module.exports = Generator.extend({
Here's a list of our supported options:

- `boilerplate` (Boolean, default true) include or not the boilerplate files (`lib/index.js`, `test/index.js`).
- `babel` (Boolean, default true) include or not a `.babelrc` file.
- `cli` (Boolean, default false) include or not a `lib/cli.js` file.
- `editorconfig` (Boolean, default true) include or not a `.editorconfig` file.
- `git` (Boolean, default true) include or not the git files (`.gitattributes`, `.gitignore`).
Expand All @@ -99,7 +97,6 @@ If you don't need all the features provided by the main generator, you can still
Remember you can see the options of each sub generators by running `yo node:sub --help`.

- `node:boilerplate`
- `node:babel`
- `node:cli`
- `node:editorconfig`
- `node:eslint`
Expand Down
35 changes: 6 additions & 29 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ module.exports = Generator.extend({
desc: 'Include boilerplate files'
});

this.option('babel', {
type: Boolean,
required: false,
desc: 'Compile ES2015 using Babel'
});

this.option('cli', {
type: Boolean,
required: false,
Expand Down Expand Up @@ -93,8 +87,7 @@ module.exports = Generator.extend({
name: this.pkg.name,
description: this.pkg.description,
version: this.pkg.version,
homepage: this.pkg.homepage,
babel: Boolean(this.options.babel)
homepage: this.pkg.homepage
};

if (_.isObject(this.pkg.author)) {
Expand Down Expand Up @@ -162,11 +155,6 @@ module.exports = Generator.extend({
filter: function (words) {
return words.split(/\s*,\s*/g);
}
}, {
name: 'babel',
type: 'confirm',
message: 'Use es2015 (precompiled with Babel)',
when: this.options.babel === undefined
}, {
name: 'includeCoveralls',
type: 'confirm',
Expand Down Expand Up @@ -217,13 +205,8 @@ module.exports = Generator.extend({
email: this.props.authorEmail,
url: this.props.authorUrl
},
files: [
this.props.babel ? 'dist' : this.options.projectRoot
],
main: this.props.babel ? 'dist/index.js' : path.join(
this.options.projectRoot,
'index.js'
).replace(/\\/g, '/'),
files: [this.options.projectRoot],
main: path.join(this.options.projectRoot, 'index.js').replace(/\\/g, '/'),
keywords: [],
devDependencies: {}
}, currentPkg);
Expand Down Expand Up @@ -253,9 +236,7 @@ module.exports = Generator.extend({
this.composeWith(require.resolve('../editorconfig'));
this.composeWith(require.resolve('../nsp'));

this.composeWith(require.resolve('../eslint'), {
es2015: this.props.babel
});
this.composeWith(require.resolve('../eslint'));

this.composeWith(require.resolve('../git'), {
name: this.props.name,
Expand All @@ -264,23 +245,19 @@ module.exports = Generator.extend({

if (this.options.gulp) {
this.composeWith(require.resolve('../gulp'), {
babel: this.props.babel,
projectRoot: this.options.projectRoot,
cli: this.options.cli
});
}

if (this.options.boilerplate) {
this.composeWith(require.resolve('../boilerplate'), {
name: this.props.name,
babel: this.props.babel
name: this.props.name
});
}

if (this.options.cli) {
this.composeWith(require.resolve('../cli'), {
babel: this.props.babel
});
this.composeWith(require.resolve('../cli'));
}

if (this.options.license && !this.pkg.license) {
Expand Down
13 changes: 2 additions & 11 deletions generators/boilerplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,19 @@ module.exports = Generator.extend({
required: true,
desc: 'The new module name.'
});

this.option('babel', {
required: false,
default: false,
desc: 'Compile ES2015 using Babel'
});
},

writing: function () {
this.fs.copyTpl(
this.templatePath('index.js'),
this.destinationPath(this.options.generateInto, 'lib/index.js'), {
babel: this.options.babel
}
this.destinationPath(this.options.generateInto, 'lib/index.js')
);

this.fs.copyTpl(
this.templatePath('test.js'),
this.destinationPath(this.options.generateInto, 'test/index.js'), {
pkgName: this.options.name,
pkgSafeName: _.camelCase(this.options.name),
babel: this.options.babel
pkgSafeName: _.camelCase(this.options.name)
}
);
}
Expand Down
4 changes: 0 additions & 4 deletions generators/boilerplate/templates/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<% if (babel) { -%>
export default {};
<% } else { -%>
'use strict';

module.exports = {};
<% } -%>
5 changes: 0 additions & 5 deletions generators/boilerplate/templates/test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<% if (babel) { -%>
import assert from 'assert';
import <%= pkgSafeName %> from '../lib';
<% } else { -%>
'use strict';

var assert = require('assert');
var <%= pkgSafeName %> = require('../lib');
<% } -%>

describe('<%= pkgName %>', function () {
it('should have unit test!', function () {
Expand Down
12 changes: 2 additions & 10 deletions generators/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ module.exports = Generator.extend({
defaults: '',
desc: 'Relocate the location of the generated files.'
});

this.option('babel', {
type: Boolean,
required: false,
defaults: false,
desc: 'pre-compile with Babel'
});
},

writing: {
package: function () {
var pkg = this.fs.readJSON(this.destinationPath(this.options.generateInto, 'package.json'), {});

extend(pkg, {
bin: this.options.babel ? 'dist/cli.js' : 'lib/cli.js',
bin: 'lib/cli.js',
dependencies: {
meow: '^3.7.0'
}
Expand All @@ -42,8 +35,7 @@ module.exports = Generator.extend({
this.templatePath('cli.js'),
this.destinationPath(this.options.generateInto, 'lib/cli.js'), {
pkgName: pkg.name,
pkgSafeName: _.camelCase(pkg.name),
babel: this.options.babel
pkgSafeName: _.camelCase(pkg.name)
}
);
}
Expand Down
5 changes: 0 additions & 5 deletions generators/cli/templates/cli.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/usr/bin/env node
'use strict';
<% if (babel) { -%>
import meow from 'meow';
import <%= pkgSafeName %> from './';
<% } else { -%>
var meow = require('meow');
var <%= pkgSafeName %> = require('./');
<% } -%>

var cli = meow([
'Usage',
Expand Down
11 changes: 0 additions & 11 deletions generators/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ module.exports = class extends Generator {
default: '',
desc: 'Relocate the location of the generated files.'
});

this.option('es2015', {
required: false,
default: false,
desc: 'Allow ES2015 syntax'
});
}

writing() {
Expand All @@ -37,11 +31,6 @@ module.exports = class extends Generator {
}
};

if (this.options.es2015) {
pkgJson.devDependencies['babel-eslint'] = rootPkg.devDependencies['babel-eslint'];
pkgJson.devDependencies['eslint-plugin-babel'] = rootPkg.devDependencies['eslint-plugin-babel'];
}

this.fs.extendJSON(
this.destinationPath(this.options.generateInto, 'package.json'),
pkgJson
Expand Down
43 changes: 0 additions & 43 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ module.exports = Generator.extend({
desc: 'Relocate the location of the generated files.'
});

this.option('babel', {
type: Boolean,
required: false,
defaults: false,
desc: 'Compile ES2015 using Babel'
});

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

if (this.options.babel) {
pkg.devDependencies['gulp-babel'] = '^6.1.2';
pkg.devDependencies.del = '^2.0.2';
pkg.devDependencies['babel-core'] = '^6.11.4';
pkg.devDependencies['babel-register'] = '^6.9.0';
pkg.devDependencies['babel-preset-es2015'] = '6.9.0';
pkg.devDependencies.isparta = '^4.0.0';
}

if (this.options.cli) {
pkg.devDependencies['gulp-line-ending-corrector'] = '^1.0.1';
}
Expand All @@ -78,43 +62,16 @@ module.exports = Generator.extend({
prepublishTasks.push('line-ending-corrector');
}

if (this.options.babel) {
prepublishTasks.push('babel');
}

this.fs.copyTpl(
this.templatePath('gulpfile.js'),
this.destinationPath(this.options.generateInto, 'gulpfile.js'),
{
cli: this.options.cli,
babel: this.options.babel,
tasks: stringifyArray(tasks),
prepublishTasks: stringifyArray(prepublishTasks),
projectRoot: path.join(this.options.projectRoot, '**/*.js').replace(/\\/g, '/')
}
);
},

babel: function () {
if (!this.options.babel) {
return;
}

this.fs.copy(
this.templatePath('babelrc'),
this.destinationPath(this.options.generateInto, '.babelrc')
);

// Add dist/ to the .gitignore file
var gitignore = this.fs.read(
this.destinationPath(this.options.generateInto, '.gitignore'),
{defaults: ''}
).split('\n').filter(Boolean);
gitignore.push('dist');
this.fs.write(
this.destinationPath(this.options.generateInto, '.gitignore'),
gitignore.join('\n') + '\n'
);
}
}
});
Expand Down
3 changes: 0 additions & 3 deletions generators/gulp/templates/babelrc

This file was deleted.

26 changes: 1 addition & 25 deletions generators/gulp/templates/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<% if (!babel) { -%>
'use strict';
<% } -%>
var path = require('path');
var gulp = require('gulp');
var excludeGitignore = require('gulp-exclude-gitignore');
Expand All @@ -10,22 +8,12 @@ var plumber = require('gulp-plumber');
<% if (cli) { -%>
var lec = require('gulp-line-ending-corrector');
<% } -%>
<% if (babel) { -%>
var babel = require('gulp-babel');
var del = require('del');
var isparta = require('isparta');

// Initialize the babel transpiler so ES2015 files gets compiled
// when they're loaded
require('babel-register');
<% } -%>

gulp.task('pre-test', function () {
return gulp.src('<%- projectRoot %>')
.pipe(excludeGitignore())
.pipe(istanbul({
includeUntested: true<% if (babel) { %>,
instrumenter: isparta.Instrumenter<% } %>
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});
Expand Down Expand Up @@ -57,18 +45,6 @@ gulp.task('line-ending-corrector', function () {
.pipe(gulp.dest('.'));
});
<% } -%>
<% if (babel) { -%>

gulp.task('babel', ['clean'], function () {
return gulp.src('<%- projectRoot %>')
.pipe(babel())
.pipe(gulp.dest('dist'));
});

gulp.task('clean', function () {
return del('dist');
});
<% } -%>

gulp.task('prepublish', <%- prepublishTasks %>);
gulp.task('default', <%- tasks %>);
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
"cli"
],
"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",
"eslint-plugin-babel": "^4.0.0",
"gulp": "^3.9.1",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^1.1.1",
Expand Down

0 comments on commit 602e250

Please sign in to comment.