Skip to content

Commit

Permalink
Added app name parameter and templating through hottowel for it. now …
Browse files Browse the repository at this point in the history
…at v0.0.6
  • Loading branch information
johnpapa committed Nov 29, 2014
1 parent 2e6cb3a commit c37827d
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 82 deletions.
12 changes: 11 additions & 1 deletion README.md
Expand Up @@ -38,8 +38,18 @@ Create an Angular application using the HotTowel style (via a [Yeoman](http://ye

3. Run the generator
```bash
yo hottowel
yo hottowel helloWorld
```

## HotTowel Options

### Application Name
- Pass in the app's name to avoid being prompted for it
```bash
yo hottowel [appName]
```
## Running HotTowel
### Linting
Expand Down
96 changes: 57 additions & 39 deletions app/index.js
Expand Up @@ -2,72 +2,90 @@
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var generators = yeoman.generators;
var yosay = require('yosay');
var chalk = require('chalk');

var HottowelGenerator = yeoman.generators.Base.extend({
prompting: function () {
var done = this.async();
var HottowelGenerator = generators.Base.extend({

// Have Yeoman greet the user.
constructor: function() {
// arguments and options should be
// defined in the constructor.
generators.Base.apply(this, arguments);

this.argument('appName', { type: String, required: false });
this.appName = this._.camelize(this._.slugify(this._.humanize(this.appName)));
},

welcome: function() {
this.log(yosay(
'Welcome to the HotTowel AngularJS generator!'
));
},

// var prompts = [{
// type: 'confirm',
// name: 'expressServer',
// message: 'Would you like to add an express server?',
// default: true
// }];

this.expressServer = true;
prompting: function () {
// If we passed in the app name, don't prompt the user for it
if(this.appName) {
return;
}

// this.prompt(prompts, function (props) {
// this.expressServer = props.expressServer;
//
var done = this.async();

var prompts = [{
type: 'input',
name: 'appName',
message: 'What would you like to name the app?',
default: this.appName || path.basename(process.cwd())
}];

this.prompt(prompts, function (answers) {
this.appName = answers.appName;
this.appName = this.appName || 'hottowel'; //path.basename(process.cwd());
done();
// }.bind(this));
}.bind(this));
},

displayName: function() {
this.log('Creating ' + this.appName + ' app based on HotTowel.');
},

scaffoldFolders: function () {
this.mkdir('src');
this.mkdir('src/client');
this.mkdir('src/client/app');
if (this.expressServer) {
this.mkdir('src/server');
}
this.mkdir('src/server');
},

app: function () {
this.src.copy('_package.json', 'package.json');
this.src.copy('_bower.json', 'bower.json');
this.src.copy('_gulpfile.js', 'gulpfile.js');
this.src.copy('_gulp.config.json', 'gulp.config.json');
this.src.copy('_karma.conf.js', 'karma.conf.js');
this.src.copy('_README.md', 'README.md');
packageFiles: function () {
var context = {
appName: this.appName
};

this.copy('_package.json', 'package.json');
this.template('_bower.json', 'bower.json');
this.template('_gulpfile.js', 'gulpfile.js');
this.template('_gulp.config.json', 'gulp.config.json');
this.template('_karma.conf.js', 'karma.conf.js');
this.template('_README.md', 'README.md');

},

appFiles: function () {
this.directory('src/client/app');
this.directory('src/client/content');
this.directory('src/client/test');

var context = {
site_name: this.appName
};
this.template('src/client/_index.html', 'src/client/index.html');

this.template('src/client/_index.html', 'src/client/index.html', context);

if (this.expressServer) {
this.template('src/server/_app.js', 'src/server/app.js', context);
this.copy('src/server/favicon.ico');
}
this.template('src/server/_app.js', 'src/server/app.js');
this.copy('src/server/favicon.ico');
},

projectfiles: function () {
this.src.copy('editorconfig', '.editorconfig');
this.src.copy('jshintrc', '.jshintrc');
this.src.copy('jscsrc', '.jscsrc');
this.src.copy('bowerrc', '.bowerrc');
this.copy('editorconfig', '.editorconfig');
this.copy('jshintrc', '.jshintrc');
this.copy('jscsrc', '.jscsrc');
this.copy('bowerrc', '.bowerrc');
},

runNpm: function () {
Expand Down
4 changes: 3 additions & 1 deletion app/templates/_README.md
@@ -1,4 +1,6 @@
# HotTowel Angular
# <%= appName %>

**Generated from HotTowel Angular**

>*Opinionated AngularJS style guide for teams by [@john_papa](//twitter.com/john_papa)*
Expand Down
19 changes: 8 additions & 11 deletions app/templates/_bower.json
@@ -1,12 +1,9 @@
{
"name": "hottowel-ng",
"version": "3.0.0",
"description": "HotTowel Angular",
"authors": [
"John Papa"
],
"name": "<%= appName %>",
"version": "0.0.1",
"description": "<%= appName %>",
"authors": [],
"license": "MIT",
"homepage": "https://github.com/johnpapa/hottowel-ng",
"ignore": [
"**/.*",
"node_modules",
Expand All @@ -15,18 +12,18 @@
"tests"
],
"devDependencies": {
"angular-mocks": "~1.3.2"
"angular-mocks": "~1.3.4"
},
"dependencies": {
"jquery": "~2.1.0",
"angular": "~1.3.2",
"angular-sanitize": "~1.3.2",
"angular": "~1.3.4",
"angular-sanitize": "~1.3.4",
"bootstrap": "~3.2.0",
"extras.angular.plus": "~0.9.2",
"font-awesome": "~4.2.0",
"moment": "~2.6.0",
"angular-ui-router": "~0.2.12",
"toastr": "~2.1.0",
"angular-animate": "~1.3.2"
"angular-animate": "~1.3.4"
}
}
10 changes: 5 additions & 5 deletions app/templates/_gulpfile.js
Expand Up @@ -415,11 +415,11 @@ function formatPercent(num, precision) {
function getHeader() {
var pkg = require('./package.json');
var template = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @authors <%= pkg.authors %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' * <%%= pkg.name %> - <%%= pkg.description %>',
' * @authors <%%= pkg.authors %>',
' * @version v<%%= pkg.version %>',
' * @link <%%= pkg.homepage %>',
' * @license <%%= pkg.license %>',
' */',
''].join('\n');
return plug.header(template, {pkg : pkg});
Expand Down
4 changes: 1 addition & 3 deletions app/templates/_karma.conf.js
@@ -1,6 +1,4 @@
// Karma configuration
// Generated on Sun Jul 13 2014 09:06:13 GMT-0400 (EDT)

module.exports = function (config) {
config.set({

Expand All @@ -13,7 +11,7 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'./src/client/test/bindPolyfill.js',
'./src/client/test/bind-polyfill.js',

'./bower_components/jquery/dist/jquery.js',
'./bower_components/angular/angular.js',
Expand Down
5 changes: 2 additions & 3 deletions app/templates/_package.json
@@ -1,7 +1,6 @@
{
"name": "HotTowel",
"description": "Project Generated from HotTowel Angular",
"repository": "TBD",
"name": "<%= appName %>",
"description": "<%= appName %> Project Generated from HotTowel Angular",
"version": "0.0.0",
"scripts": {
"init": "npm install",
Expand Down
2 changes: 1 addition & 1 deletion app/templates/editorconfig
Expand Up @@ -3,7 +3,7 @@ root = true

[*]
indent_style = space
indent_size = 2
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
4 changes: 2 additions & 2 deletions app/templates/src/client/_index.html
Expand Up @@ -6,7 +6,7 @@
/* Since Angular has this but needs to load, this gives us the class early. */
.ng-hide { display: none!important; }
</style>
<title ng-bind="title">Hot Towel Angular</title>
<title ng-bind="title"><%= appName %></title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
Expand All @@ -30,7 +30,7 @@
<div id="splash-page" ng-show="false">
<div class="page-splash">
<div class="page-splash-message">
Hot Towel Angular
<%= appName %>
</div>
<div class="progress progress-striped active page-progress-bar">
<div class="bar"></div>
Expand Down
11 changes: 1 addition & 10 deletions app/templates/src/client/app/app.module.js
@@ -1,18 +1,9 @@
(function () {
(function () {
'use strict';

angular.module('app', [
/*
* Order is not important. Angular makes a
* pass to register all of the modules listed
* and then when app.dashboard tries to use app.data,
* it's components are available.
*/
'app.core',
'app.widgets',
/*
* Feature areas
*/
'app.admin',
'app.dashboard',
'app.layout'
Expand Down
6 changes: 3 additions & 3 deletions app/templates/src/client/app/core/config.js
Expand Up @@ -12,8 +12,8 @@
}

var config = {
appErrorPrefix: '[HotTowel Error] ',
appTitle: 'HotTowel Angular Demo'
appErrorPrefix: '[<%= appName %> Error] ',
appTitle: '<%= appName %>'
};

core.value('config', config);
Expand All @@ -26,7 +26,7 @@
$logProvider.debugEnabled(true);
}
exceptionHandlerProvider.configure(config.appErrorPrefix);
routerHelperProvider.configure({docTitle: 'HotTowel: '});
routerHelperProvider.configure({docTitle: config.appTitle + ': '});
}

})();
@@ -1,4 +1,4 @@
(function () {
(function () {
'use strict';

angular
Expand All @@ -9,7 +9,7 @@
function DashboardController($q, dataservice, logger) {
var vm = this;
vm.news = {
title: 'Hot Towel Angular',
title: '<%= appName %>',
description: 'Hot Towel Angular is a SPA template for Angular developers.'
};
vm.messageCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "generator-hottowel",
"version": "0.0.5",
"version": "0.0.6",
"description": "Yeoman generator for HotTowel Angular",
"license": "MIT",
"main": "app/index.js",
Expand Down
2 changes: 2 additions & 0 deletions test/test-app.js
@@ -1,6 +1,8 @@
/*global describe, beforeEach, it*/
'use strict';

//TODO: create test suite

var path = require('path');
var assert = require('yeoman-generator').assert;
var helpers = require('yeoman-generator').test;
Expand Down

0 comments on commit c37827d

Please sign in to comment.