Skip to content

Commit 60334a8

Browse files
committed
feat(server): implement server-side ES6 via babel
1 parent d084fab commit 60334a8

File tree

5 files changed

+25
-66
lines changed

5 files changed

+25
-66
lines changed

Diff for: app/templates/Gruntfile.js

+9-20
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ module.exports = function (grunt) {
3939
},
4040
dev: {
4141
options: {
42-
script: 'server/app.js',
42+
script: 'server',
4343
debug: true
4444
}
4545
},
4646
prod: {
4747
options: {
48-
script: 'dist/server/app.js'
48+
script: 'dist/server'
4949
}
5050
}
5151
},
@@ -61,7 +61,7 @@ module.exports = function (grunt) {
6161
'!<%%= yeoman.client %>/{app,components}/**/*.spec.js',
6262
'!<%%= yeoman.client %>/{app,components}/**/*.mock.js',
6363
'!<%%= yeoman.client %>/app/app.js'],
64-
tasks: ['injector:scripts']
64+
tasks: [<% if(filters.babel) { %>'newer:babel:client', <% } %>'injector:scripts']
6565
},
6666
injectCss: {
6767
files: [
@@ -128,13 +128,6 @@ module.exports = function (grunt) {
128128
'<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}'
129129
],
130130
tasks: ['karma']
131-
},<% } %><% if(filters.babel) { %>
132-
babel: {
133-
files: [
134-
'<%%= yeoman.client %>/{app,components}/**/*.js',
135-
'!<%%= yeoman.client %>/{app,components}/**/*.spec.js'
136-
],
137-
tasks: ['babel']
138131
},<% } %>
139132
gruntfile: {
140133
files: ['Gruntfile.js']
@@ -143,11 +136,7 @@ module.exports = function (grunt) {
143136
files: [
144137
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.css',
145138
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.html',
146-
<% if(filters.babel) { %>
147-
'.tmp/{app,components}/**/*.js',
148-
<% } else { %>
149139
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.js',
150-
<% } %>
151140
'!{.tmp,<%%= yeoman.client %>}{app,components}/**/*.spec.js',
152141
'!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.mock.js',
153142
'<%%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
@@ -261,7 +250,7 @@ module.exports = function (grunt) {
261250
// Use nodemon to run server in debug mode with an initial breakpoint
262251
nodemon: {
263252
debug: {
264-
script: 'server/app.js',
253+
script: 'server',
265254
options: {
266255
nodeArgs: ['--debug-brk'],
267256
env: {
@@ -470,15 +459,15 @@ module.exports = function (grunt) {
470459
concurrent: {
471460
server: [<% if(filters.coffee) { %>
472461
'coffee',<% } %><% if(filters.babel) { %>
473-
'babel',<% } %><% if(filters.jade) { %>
462+
'newer:babel:client',<% } %><% if(filters.jade) { %>
474463
'jade',<% } %><% if(filters.stylus) { %>
475464
'stylus',<% } %><% if(filters.sass) { %>
476465
'sass',<% } %><% if(filters.less) { %>
477466
'less',<% } %>
478467
],
479468
test: [<% if(filters.coffee) { %>
480469
'coffee',<% } %><% if(filters.babel) { %>
481-
'babel',<% } %><% if(filters.jade) { %>
470+
'newer:babel:client',<% } %><% if(filters.jade) { %>
482471
'jade',<% } %><% if(filters.stylus) { %>
483472
'stylus',<% } %><% if(filters.sass) { %>
484473
'sass',<% } %><% if(filters.less) { %>
@@ -495,7 +484,7 @@ module.exports = function (grunt) {
495484
},
496485
dist: [<% if(filters.coffee) { %>
497486
'coffee',<% } %><% if(filters.babel) { %>
498-
'babel',<% } %><% if(filters.jade) { %>
487+
'newer:babel:client',<% } %><% if(filters.jade) { %>
499488
'jade',<% } %><% if(filters.stylus) { %>
500489
'stylus',<% } %><% if(filters.sass) { %>
501490
'sass',<% } %><% if(filters.less) { %>
@@ -639,10 +628,10 @@ module.exports = function (grunt) {
639628
options: {
640629
sourceMap: true
641630
},
642-
server: {
631+
client: {
643632
files: [{
644633
expand: true,
645-
cwd: 'client',
634+
cwd: '<%%= yeoman.client %>',
646635
src: [
647636
'{app,components}/**/*.js',
648637
'!{app,components}/**/*.spec.js'

Diff for: app/templates/_package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"express-session": "~1.0.2",
1313
"errorhandler": "~1.0.0",
1414
"compression": "~1.0.1",
15-
"lodash": "~2.4.1",<% if (filters.jade) { %>
15+
"lodash": "~2.4.1",<% if(filters.babel) { %>
16+
"babel-core": "^5.6.4",<% } %><% if (filters.jade) { %>
1617
"jade": "~1.2.0",<% } %><% if (filters.html) { %>
1718
"ejs": "~0.8.4",<% } %><% if (filters.mongoose) { %>
1819
"mongoose": "~3.8.8",
@@ -106,7 +107,7 @@
106107
"node": ">=0.10.0"
107108
},
108109
"scripts": {
109-
"start": "node server/app.js",
110+
"start": "node server",
110111
"test": "grunt test",
111112
"update-webdriver": "node node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update"
112113
},

Diff for: app/templates/mocha.conf.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
'use strict';
1+
'use strict';<% if(filters.babel) { %>
2+
3+
// Register the Babel require hook
4+
require('babel-core/register');<% } %>
25

36
var chai = require('chai');
47

Diff for: app/templates/server/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';<% if (filters.babel) { %>
2+
3+
// Register the Babel require hook
4+
require('babel-core/register');<% } %>
5+
6+
// Export the application
7+
exports = module.exports = require('./app');

Diff for: test/test-file-creation.js

+2-43
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var recursiveReadDir = require('recursive-readdir');
1111
describe('angular-fullstack generator', function () {
1212
var gen, defaultOptions = {
1313
script: 'js',
14+
babel: true,
1415
markup: 'html',
1516
stylesheet: 'sass',
1617
router: 'uirouter',
@@ -176,6 +177,7 @@ describe('angular-fullstack generator', function () {
176177
'server/.jshintrc',
177178
'server/.jshintrc-spec',
178179
'server/app.js',
180+
'server/index.js',
179181
'server/routes.js',
180182
'server/api/thing/index.js',
181183
'server/api/thing/index.spec.js',
@@ -476,49 +478,6 @@ describe('angular-fullstack generator', function () {
476478
}
477479
});
478480

479-
describe('with Babel ES6 preprocessor', function() {
480-
beforeEach(function() {
481-
helpers.mockPrompt(gen, {
482-
script: 'js',
483-
babel: true,
484-
markup: 'jade',
485-
stylesheet: 'less',
486-
router: 'uirouter'
487-
});
488-
});
489-
490-
it('should run client tests successfully', function(done) {
491-
this.timeout(60000);
492-
gen.run({}, function () {
493-
exec('grunt test:client', function (error, stdout, stderr) {
494-
expect(stdout, 'Client tests failed \n' + stdout ).to.contain('Executed 1 of 1 SUCCESS');
495-
done();
496-
});
497-
});
498-
});
499-
500-
it('should pass jshint', function(done) {
501-
this.timeout(60000);
502-
gen.run({}, function () {
503-
exec('grunt jshint', function (error, stdout, stderr) {
504-
expect(stdout).to.contain('Done, without errors.');
505-
done();
506-
});
507-
});
508-
});
509-
510-
it('should run server tests successfully', function(done) {
511-
this.timeout(60000);
512-
gen.run({}, function () {
513-
exec('grunt test:server', function (error, stdout, stderr) {
514-
expect(stdout, 'Server tests failed (do you have mongoDB running?) \n' + stdout).to.contain('Done, without errors.');
515-
done();
516-
});
517-
});
518-
});
519-
});
520-
521-
522481
describe('with other preprocessors and oauth', function() {
523482
var testOptions = {
524483
script: 'coffee',

0 commit comments

Comments
 (0)