Skip to content

Commit e477d2b

Browse files
author
Chris Wheatley
committed
Merge pull request #24 from mrzepinski/master
NPM updates, some clean code fixes
2 parents a698461 + 2ac3df8 commit e477d2b

File tree

11 files changed

+110
-103
lines changed

11 files changed

+110
-103
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
2-
*.log
2+
*.log
3+
*.iml
4+
.idea

app/index.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
'use strict';
22

3-
var yeoman = require('yeoman-generator');
4-
var chalk = require('chalk');
5-
var npmCheck = require('npm-check');
6-
var path = require('path');
7-
var yosay = require('yosay');
3+
var yeoman = require('yeoman-generator'),
4+
chalk = require('chalk'),
5+
npmCheck = require('npm-check'),
6+
path = require('path'),
7+
yosay = require('yosay'),
8+
l = require('lodash');
89

910
module.exports = yeoman.generators.Base.extend({
10-
constructor: function() {
11+
constructor: function () {
1112
yeoman.generators.Base.apply(this, arguments);
1213
// add option to skip install
1314
this.option('skip-install');
1415
this.argument('appname', {
1516
type: String,
1617
required: false
1718
});
18-
this.appname = this.appname || path.basename(process.cwd());
19+
var appName = this.appname || path.basename(process.cwd());
20+
this.appname = l.kebabCase(appName);
21+
this.modulename = l.snakeCase(appName);
22+
this.classname = l.capitalize(l.camelCase(appName));
1923
},
2024

21-
prompting: function() {
25+
prompting: function () {
2226
// Yeoman greeting
2327
this.log(yosay(
2428
'Yo! I\'m here to help build your ' +
@@ -28,42 +32,41 @@ module.exports = yeoman.generators.Base.extend({
2832
},
2933

3034
writing: {
31-
app: function() {
32-
this.basicTemplate = 'src/' + this._.slugify(this.appname);
35+
app: function () {
36+
this.basicTemplate = 'src/' + l.kebabCase(this.appname);
3337

3438
this.copy('_package.json', 'package.json');
3539
this.copy('_gulpfile.js', 'gulpfile.js');
3640
this.copy('_readme.md', 'readme.md');
3741
this.copy('_editorconfig', '.editorconfig');
3842
this.copy('_gitignore', '.gitignore');
3943

40-
this.mkdir('src');
4144
this.copy('src/_index.js', 'src/index.js');
4245
this.copy('src/_index.html', 'src/index.html');
4346
this.copy('src/_basic-template.html', this.basicTemplate + '.html');
4447
this.copy('src/_basic-template.js', this.basicTemplate + '.js');
4548
}
4649
},
4750

48-
install: function() {
51+
install: function () {
4952
this.installDependencies({
5053
skipInstall: this.options['skip-install'],
5154
bower: false,
52-
callback: function() {
55+
callback: function () {
5356
this.emit('dependenciesInstalled');
5457
}.bind(this)
5558
});
5659

57-
this.on('dependenciesInstalled', function() {
60+
this.on('dependenciesInstalled', function () {
5861
npmCheck({
5962
global: true
60-
}).then(function(globalPackages) {
63+
}).then(function (globalPackages) {
6164
if (!globalPackages.gulp) {
6265
return './node_modules/.bin/gulp';
6366
}
6467
return 'gulp';
65-
}).then(function(gulpCommand) {
66-
this.spawnCommand(gulpCommand).on('close', function() {
68+
}).then(function (gulpCommand) {
69+
this.spawnCommand(gulpCommand).on('close', function () {
6770
this.log('');
6871
this.log('');
6972
this.log('Setup complete, run ' +

app/templates/_gulpfile.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var gulp = require('gulp');
2-
var concat = require('gulp-concat');
3-
var rename = require('gulp-rename');
4-
var shell = require('gulp-shell');
5-
var traceur = require('gulp-traceur');
6-
var webserver = require('gulp-webserver');
1+
var gulp = require('gulp'),
2+
concat = require('gulp-concat'),
3+
rename = require('gulp-rename'),
4+
shell = require('gulp-shell'),
5+
traceur = require('gulp-traceur'),
6+
webserver = require('gulp-webserver');
77

88
// run init tasks
99
gulp.task('default', ['dependencies', 'angular2', 'js', 'html', 'css']);
@@ -12,45 +12,45 @@ gulp.task('default', ['dependencies', 'angular2', 'js', 'html', 'css']);
1212
gulp.task('dev', ['watch', 'serve']);
1313

1414
// serve the build dir
15-
gulp.task('serve', function() {
15+
gulp.task('serve', function () {
1616
gulp.src('build')
1717
.pipe(webserver({
1818
open: true
1919
}));
2020
});
2121

2222
// watch for changes and run the relevant task
23-
gulp.task('watch', function() {
23+
gulp.task('watch', function () {
2424
gulp.watch('src/**/*.js', ['js']);
2525
gulp.watch('src/**/*.html', ['html']);
2626
gulp.watch('src/**/*.css', ['css']);
2727
});
2828

2929
// move dependencies into build dir
30-
gulp.task('dependencies', function() {
30+
gulp.task('dependencies', function () {
3131
return gulp.src([
32-
'node_modules/angular2/node_modules/rx/dist/rx.all.js',
33-
'node_modules/angular2/node_modules/traceur/bin/traceur.js',
34-
'node_modules/angular2/node_modules/traceur/bin/traceur-runtime.js',
35-
'node_modules/angular2/node_modules/zone.js/zone.js',
36-
'node_modules/es6-module-loader/dist/es6-module-loader.js',
37-
'node_modules/es6-module-loader/dist/es6-module-loader.js.map',
38-
'node_modules/systemjs/dist/system.js',
39-
'node_modules/systemjs/dist/system.js.map'
40-
])
32+
'node_modules/angular2/node_modules/rx/dist/rx.all.js',
33+
'node_modules/angular2/node_modules/traceur/bin/traceur.js',
34+
'node_modules/angular2/node_modules/traceur/bin/traceur-runtime.js',
35+
'node_modules/angular2/node_modules/zone.js/zone.js',
36+
'node_modules/es6-module-loader/dist/es6-module-loader.js',
37+
'node_modules/es6-module-loader/dist/es6-module-loader.js.map',
38+
'node_modules/systemjs/dist/system.js',
39+
'node_modules/systemjs/dist/system.js.map'
40+
])
4141
.pipe(gulp.dest('build/lib'));
4242
});
4343

4444
// tanspile, concat & move angular
45-
gulp.task('angular2', function() {
45+
gulp.task('angular2', function () {
4646
return gulp.src([
47-
traceur.RUNTIME_PATH,
48-
'node_modules/angular2/es6/prod/*.es6',
49-
'node_modules/angular2/es6/prod/src/**/*.es6'
50-
], {
51-
base: 'node_modules/angular2/es6/prod'
52-
})
53-
.pipe(rename(function(path) {
47+
traceur.RUNTIME_PATH,
48+
'node_modules/angular2/es6/prod/*.es6',
49+
'node_modules/angular2/es6/prod/src/**/*.es6'
50+
], {
51+
base: 'node_modules/angular2/es6/prod'
52+
})
53+
.pipe(rename(function (path) {
5454
path.dirname = 'angular2/' + path.dirname;
5555
path.extname = '';
5656
}))
@@ -63,7 +63,7 @@ gulp.task('angular2', function() {
6363
});
6464

6565
// transpile & move js
66-
gulp.task('js', function() {
66+
gulp.task('js', function () {
6767
return gulp.src('src/**/*.js')
6868
.pipe(rename({
6969
extname: ''
@@ -81,13 +81,13 @@ gulp.task('js', function() {
8181
});
8282

8383
// move html
84-
gulp.task('html', function() {
84+
gulp.task('html', function () {
8585
return gulp.src('src/**/*.html')
8686
.pipe(gulp.dest('build'))
8787
});
8888

8989
// move css
90-
gulp.task('css', function() {
90+
gulp.task('css', function () {
9191
return gulp.src('src/**/*.css')
9292
.pipe(gulp.dest('build'))
9393
});

app/templates/_package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"name": "<%= _.slugify(appname) %>",
2+
"name": "<%= appname %>",
33
"version": "0.0.0",
44
"dependencies": {
5-
"angular2": "^2.0.0-alpha.18",
6-
"es6-module-loader": "~0.11.0",
7-
"systemjs": "~0.11.0"
5+
"angular2": "2.0.0-alpha.21",
6+
"es6-module-loader": "0.16.6",
7+
"systemjs": "0.16.10"
88
},
99
"devDependencies": {
10-
"gulp": "^3.8.11",
11-
"gulp-concat": "^2.5.2",
12-
"gulp-rename": "^1.2.0",
13-
"gulp-shell": "^0.4.0",
14-
"gulp-traceur": "^0.17.0",
15-
"gulp-webserver": "^0.9.0"
10+
"gulp": "3.8.11",
11+
"gulp-concat": "2.5.2",
12+
"gulp-rename": "1.2.2",
13+
"gulp-shell": "0.4.1",
14+
"gulp-traceur": "0.17.1",
15+
"gulp-webserver": "0.9.0"
1616
}
1717
}

app/templates/_readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# <%= _.capitalize(_.humanize(appname)) %>
1+
# <%= appname %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<h1><%= _.capitalize(_.humanize(appname)) %></h1>
1+
<h1><%= appname %></h1>

app/templates/src/_basic-template.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {Component, View} from 'angular2/angular2';
22

33
@Component({
4-
selector: '<%= _.slugify(appname) %>'
4+
selector: '<%= appname %>'
55
})
66

77
@View({
8-
templateUrl: '<%= _.slugify(appname) %>.html'
8+
templateUrl: '<%= appname %>.html'
99
})
1010

11-
export class <%= _.classify(appname) %> {
11+
export class <%= classname %> {
1212

1313
constructor() {
14-
console.info('<%= _.classify(appname) %> Component Mounted Successfully');
14+
console.info('<%= classname %> Component Mounted Successfully');
1515
}
1616

1717
}

app/templates/src/_index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1">
7-
<title><%= _.capitalize(_.humanize(appname)) %></title>
7+
<title><%= appname %></title>
88
</head>
99
<body>
1010

@@ -17,6 +17,7 @@
1717
System.config({
1818
paths: {
1919
'angular2/*': 'lib/angular2.js',
20+
'traceur-runtime': 'lib/traceur-runtime.js',
2021
'rx/dist/rx.all': 'lib/rx.all.js',
2122
'index': 'index.js'
2223
}

app/templates/src/_index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {Component, View, bootstrap} from 'angular2/angular2';
2-
import {<%= _.classify(appname) %>} from '<%= _.slugify(appname) %>';
2+
import {<%= classname %>} from '<%= appname %>';
33

44
@Component({
55
selector: 'main'
66
})
77

88
@View({
9-
directives: [<%= _.classify(appname) %>],
9+
directives: [<%= classname %>],
1010
template: `
11-
<<%= _.slugify(appname) %>></<%= _.slugify(appname) %>>
11+
<<%= appname %>></<%= appname %>>
1212
`
1313
})
1414

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
],
3232
"preferGlobal": true,
3333
"dependencies": {
34-
"chalk": "^1.0.0",
35-
"npm-check": "^3.2.10",
36-
"yeoman-generator": "^0.18.9",
37-
"yosay": "^1.0.2"
34+
"chalk": "1.0.0",
35+
"lodash": "3.7.0",
36+
"npm-check": "3.2.10",
37+
"yeoman-generator": "0.19.2",
38+
"yosay": "1.0.2"
3839
},
3940
"devDependencies": {
40-
"mocha": "*"
41+
"mocha": "2.2.4"
4142
}
4243
}

0 commit comments

Comments
 (0)