Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
*.log
*.log
*.iml
.idea
37 changes: 20 additions & 17 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
'use strict';

var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var npmCheck = require('npm-check');
var path = require('path');
var yosay = require('yosay');
var yeoman = require('yeoman-generator'),
chalk = require('chalk'),
npmCheck = require('npm-check'),
path = require('path'),
yosay = require('yosay'),
l = require('lodash');

module.exports = yeoman.generators.Base.extend({
constructor: function() {
constructor: function () {
yeoman.generators.Base.apply(this, arguments);
// add option to skip install
this.option('skip-install');
this.argument('appname', {
type: String,
required: false
});
this.appname = this.appname || path.basename(process.cwd());
var appName = this.appname || path.basename(process.cwd());
this.appname = l.kebabCase(appName);
this.modulename = l.snakeCase(appName);
this.classname = l.capitalize(l.camelCase(appName));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are nice 👍. I wasn't aware of kebabCase & snakeCase.

},

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

writing: {
app: function() {
this.basicTemplate = 'src/' + this._.slugify(this.appname);
app: function () {
this.basicTemplate = 'src/' + l.kebabCase(this.appname);

this.copy('_package.json', 'package.json');
this.copy('_gulpfile.js', 'gulpfile.js');
this.copy('_readme.md', 'readme.md');
this.copy('_editorconfig', '.editorconfig');
this.copy('_gitignore', '.gitignore');

this.mkdir('src');
this.copy('src/_index.js', 'src/index.js');
this.copy('src/_index.html', 'src/index.html');
this.copy('src/_basic-template.html', this.basicTemplate + '.html');
this.copy('src/_basic-template.js', this.basicTemplate + '.js');
}
},

install: function() {
install: function () {
this.installDependencies({
skipInstall: this.options['skip-install'],
bower: false,
callback: function() {
callback: function () {
this.emit('dependenciesInstalled');
}.bind(this)
});

this.on('dependenciesInstalled', function() {
this.on('dependenciesInstalled', function () {
npmCheck({
global: true
}).then(function(globalPackages) {
}).then(function (globalPackages) {
if (!globalPackages.gulp) {
return './node_modules/.bin/gulp';
}
return 'gulp';
}).then(function(gulpCommand) {
this.spawnCommand(gulpCommand).on('close', function() {
}).then(function (gulpCommand) {
this.spawnCommand(gulpCommand).on('close', function () {
this.log('');
this.log('');
this.log('Setup complete, run ' +
Expand Down
58 changes: 29 additions & 29 deletions app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var shell = require('gulp-shell');
var traceur = require('gulp-traceur');
var webserver = require('gulp-webserver');
var gulp = require('gulp'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
traceur = require('gulp-traceur'),
webserver = require('gulp-webserver');

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

// serve the build dir
gulp.task('serve', function() {
gulp.task('serve', function () {
gulp.src('build')
.pipe(webserver({
open: true
}));
});

// watch for changes and run the relevant task
gulp.task('watch', function() {
gulp.task('watch', function () {
gulp.watch('src/**/*.js', ['js']);
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/**/*.css', ['css']);
});

// move dependencies into build dir
gulp.task('dependencies', function() {
gulp.task('dependencies', function () {
return gulp.src([
'node_modules/angular2/node_modules/rx/dist/rx.all.js',
'node_modules/angular2/node_modules/traceur/bin/traceur.js',
'node_modules/angular2/node_modules/traceur/bin/traceur-runtime.js',
'node_modules/angular2/node_modules/zone.js/zone.js',
'node_modules/es6-module-loader/dist/es6-module-loader.js',
'node_modules/es6-module-loader/dist/es6-module-loader.js.map',
'node_modules/systemjs/dist/system.js',
'node_modules/systemjs/dist/system.js.map'
])
'node_modules/angular2/node_modules/rx/dist/rx.all.js',
'node_modules/angular2/node_modules/traceur/bin/traceur.js',
'node_modules/angular2/node_modules/traceur/bin/traceur-runtime.js',
'node_modules/angular2/node_modules/zone.js/zone.js',
'node_modules/es6-module-loader/dist/es6-module-loader.js',
'node_modules/es6-module-loader/dist/es6-module-loader.js.map',
'node_modules/systemjs/dist/system.js',
'node_modules/systemjs/dist/system.js.map'
])
.pipe(gulp.dest('build/lib'));
});

// tanspile, concat & move angular
gulp.task('angular2', function() {
gulp.task('angular2', function () {
return gulp.src([
traceur.RUNTIME_PATH,
'node_modules/angular2/es6/prod/*.es6',
'node_modules/angular2/es6/prod/src/**/*.es6'
], {
base: 'node_modules/angular2/es6/prod'
})
.pipe(rename(function(path) {
traceur.RUNTIME_PATH,
'node_modules/angular2/es6/prod/*.es6',
'node_modules/angular2/es6/prod/src/**/*.es6'
], {
base: 'node_modules/angular2/es6/prod'
})
.pipe(rename(function (path) {
path.dirname = 'angular2/' + path.dirname;
path.extname = '';
}))
Expand All @@ -63,7 +63,7 @@ gulp.task('angular2', function() {
});

// transpile & move js
gulp.task('js', function() {
gulp.task('js', function () {
return gulp.src('src/**/*.js')
.pipe(rename({
extname: ''
Expand All @@ -81,13 +81,13 @@ gulp.task('js', function() {
});

// move html
gulp.task('html', function() {
gulp.task('html', function () {
return gulp.src('src/**/*.html')
.pipe(gulp.dest('build'))
});

// move css
gulp.task('css', function() {
gulp.task('css', function () {
return gulp.src('src/**/*.css')
.pipe(gulp.dest('build'))
});
20 changes: 10 additions & 10 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "<%= _.slugify(appname) %>",
"name": "<%= appname %>",
"version": "0.0.0",
"dependencies": {
"angular2": "^2.0.0-alpha.18",
"es6-module-loader": "~0.11.0",
"systemjs": "~0.11.0"
"angular2": "2.0.0-alpha.21",
"es6-module-loader": "0.16.6",
"systemjs": "0.16.10"
},
"devDependencies": {
"gulp": "^3.8.11",
"gulp-concat": "^2.5.2",
"gulp-rename": "^1.2.0",
"gulp-shell": "^0.4.0",
"gulp-traceur": "^0.17.0",
"gulp-webserver": "^0.9.0"
"gulp": "3.8.11",
"gulp-concat": "2.5.2",
"gulp-rename": "1.2.2",
"gulp-shell": "0.4.1",
"gulp-traceur": "0.17.1",
"gulp-webserver": "0.9.0"
}
}
2 changes: 1 addition & 1 deletion app/templates/_readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# <%= _.capitalize(_.humanize(appname)) %>
# <%= appname %>
2 changes: 1 addition & 1 deletion app/templates/src/_basic-template.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1><%= _.capitalize(_.humanize(appname)) %></h1>
<h1><%= appname %></h1>
8 changes: 4 additions & 4 deletions app/templates/src/_basic-template.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {Component, View} from 'angular2/angular2';

@Component({
selector: '<%= _.slugify(appname) %>'
selector: '<%= appname %>'
})

@View({
templateUrl: '<%= _.slugify(appname) %>.html'
templateUrl: '<%= appname %>.html'
})

export class <%= _.classify(appname) %> {
export class <%= classname %> {

constructor() {
console.info('<%= _.classify(appname) %> Component Mounted Successfully');
console.info('<%= classname %> Component Mounted Successfully');
}

}
3 changes: 2 additions & 1 deletion app/templates/src/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= _.capitalize(_.humanize(appname)) %></title>
<title><%= appname %></title>
</head>
<body>

Expand All @@ -17,6 +17,7 @@
System.config({
paths: {
'angular2/*': 'lib/angular2.js',
'traceur-runtime': 'lib/traceur-runtime.js',
'rx/dist/rx.all': 'lib/rx.all.js',
'index': 'index.js'
}
Expand Down
6 changes: 3 additions & 3 deletions app/templates/src/_index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Component, View, bootstrap} from 'angular2/angular2';
import {<%= _.classify(appname) %>} from '<%= _.slugify(appname) %>';
import {<%= classname %>} from '<%= appname %>';

@Component({
selector: 'main'
})

@View({
directives: [<%= _.classify(appname) %>],
directives: [<%= classname %>],
template: `
<<%= _.slugify(appname) %>></<%= _.slugify(appname) %>>
<<%= appname %>></<%= appname %>>
`
})

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
],
"preferGlobal": true,
"dependencies": {
"chalk": "^1.0.0",
"npm-check": "^3.2.10",
"yeoman-generator": "^0.18.9",
"yosay": "^1.0.2"
"chalk": "1.0.0",
"lodash": "3.7.0",
"npm-check": "3.2.10",
"yeoman-generator": "0.19.2",
"yosay": "1.0.2"
},
"devDependencies": {
"mocha": "*"
"mocha": "2.2.4"
}
}
Loading