Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

Commit

Permalink
fix(gen): consolidate template files
Browse files Browse the repository at this point in the history
All template files are now in /templates. This makes it easier to find
things, reference things and keeps the project tidier overall. The
templates/common folder is also more indicative of what a generated
project will look like.
  • Loading branch information
eddiemonge committed May 6, 2014
1 parent 8dfd3fb commit 22f2f2c
Show file tree
Hide file tree
Showing 25 changed files with 27 additions and 20 deletions.
22 changes: 11 additions & 11 deletions app/index.js
Expand Up @@ -97,6 +97,7 @@ var Generator = module.exports = function Generator(args, options) {
});

this.pkg = require('../package.json');
this.sourceRoot(path.join(__dirname, '../templates/common'));
};

util.inherits(Generator, yeoman.generators.Base);
Expand Down Expand Up @@ -219,21 +220,21 @@ Generator.prototype.askForModules = function askForModules() {

Generator.prototype.readIndex = function readIndex() {
this.ngRoute = this.env.options.ngRoute;
this.indexFile = this.engine(this.read('../../templates/common/index.html'), this);
this.indexFile = this.engine(this.read('app/index.html'), this);
};

Generator.prototype.bootstrapFiles = function bootstrapFiles() {
var sass = this.compass;
var mainFile = 'main.' + (sass ? 's' : '') + 'css';

if (this.bootstrap && !sass) {
this.copy('fonts/glyphicons-halflings-regular.eot', 'app/fonts/glyphicons-halflings-regular.eot');
this.copy('fonts/glyphicons-halflings-regular.ttf', 'app/fonts/glyphicons-halflings-regular.ttf');
this.copy('fonts/glyphicons-halflings-regular.svg', 'app/fonts/glyphicons-halflings-regular.svg');
this.copy('fonts/glyphicons-halflings-regular.woff', 'app/fonts/glyphicons-halflings-regular.woff');
this.copy('app/fonts/glyphicons-halflings-regular.eot');
this.copy('app/fonts/glyphicons-halflings-regular.ttf');
this.copy('app/fonts/glyphicons-halflings-regular.svg');
this.copy('app/fonts/glyphicons-halflings-regular.woff');
}

this.copy('styles/' + mainFile, 'app/styles/' + mainFile);
this.copy('app/styles/' + mainFile);
};

Generator.prototype.appJs = function appJs() {
Expand All @@ -253,14 +254,13 @@ Generator.prototype.createIndexHtml = function createIndexHtml() {

Generator.prototype.packageFiles = function () {
this.coffee = this.env.options.coffee;
this.template('../../templates/common/_bower.json', 'bower.json');
this.template('../../templates/common/_package.json', 'package.json');
this.template('../../templates/common/Gruntfile.js', 'Gruntfile.js');
this.template('root/_bower.json', 'bower.json');
this.template('root/_package.json', 'package.json');
this.template('root/_Gruntfile.js', 'Gruntfile.js');
};

Generator.prototype.imageFiles = function () {
this.sourceRoot(path.join(__dirname, 'templates'));
this.directory('images', 'app/images', true);
this.directory('app/images');
};

Generator.prototype._injectDependencies = function _injectDependencies() {
Expand Down
16 changes: 12 additions & 4 deletions common/index.js
Expand Up @@ -11,9 +11,17 @@ var Generator = module.exports = function Generator() {
util.inherits(Generator, yeoman.generators.Base);

Generator.prototype.setupEnv = function setupEnv() {
// Copies the contents of the generator `templates`
// directory into your users new application path
this.sourceRoot(path.join(__dirname, '../templates/common'));
this.directory('root', '.', true);
this.sourceRoot(path.join(__dirname, '../templates/common/root'));
this.copy('.bowerrc', '.bowerrc');
this.copy('.editorconfig', '.editorconfig');
this.copy('.gitattributes', '.gitattributes');
this.copy('.jshintrc', '.jshintrc');
this.copy('gitignore', '.gitignore');
this.directory('../test', 'test', true);
this.copy('../app/.buildignore', 'app/.buildignore');
this.copy('../app/.htaccess', 'app/.htaccess');
this.copy('../app/404.html', 'app/404.html');
this.copy('../app/favicon.ico', 'app/favicon.ico');
this.copy('../app/robots.txt', 'app/robots.txt');
this.copy('../app/views/main.html', 'app/views/main.html');
};
5 changes: 2 additions & 3 deletions main/index.js
@@ -1,9 +1,8 @@
'use strict';
var util = require('util');
var path = require('path');
var ScriptBase = require('../script-base.js');
var util = require('util');
var yeoman = require('yeoman-generator');

var ScriptBase = require('../script-base.js');

var Generator = module.exports = function Generator() {
ScriptBase.apply(this, arguments);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions view/index.js
Expand Up @@ -6,7 +6,7 @@ var yeoman = require('yeoman-generator');

var Generator = module.exports = function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));
this.sourceRoot(path.join(__dirname, '../templates/common'));

if (typeof this.env.options.appPath === 'undefined') {
try {
Expand All @@ -20,7 +20,7 @@ util.inherits(Generator, yeoman.generators.NamedBase);

Generator.prototype.createViewFiles = function createViewFiles() {
this.template(
'common/view.html',
'app/views/view.html',
path.join(
this.env.options.appPath,
'views',
Expand Down

0 comments on commit 22f2f2c

Please sign in to comment.