Skip to content

Commit 22f2f2c

Browse files
committed
fix(gen): consolidate template files
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.
1 parent 8dfd3fb commit 22f2f2c

25 files changed

+27
-20
lines changed

app/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ var Generator = module.exports = function Generator(args, options) {
9797
});
9898

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

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

220221
Generator.prototype.readIndex = function readIndex() {
221222
this.ngRoute = this.env.options.ngRoute;
222-
this.indexFile = this.engine(this.read('../../templates/common/index.html'), this);
223+
this.indexFile = this.engine(this.read('app/index.html'), this);
223224
};
224225

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

229230
if (this.bootstrap && !sass) {
230-
this.copy('fonts/glyphicons-halflings-regular.eot', 'app/fonts/glyphicons-halflings-regular.eot');
231-
this.copy('fonts/glyphicons-halflings-regular.ttf', 'app/fonts/glyphicons-halflings-regular.ttf');
232-
this.copy('fonts/glyphicons-halflings-regular.svg', 'app/fonts/glyphicons-halflings-regular.svg');
233-
this.copy('fonts/glyphicons-halflings-regular.woff', 'app/fonts/glyphicons-halflings-regular.woff');
231+
this.copy('app/fonts/glyphicons-halflings-regular.eot');
232+
this.copy('app/fonts/glyphicons-halflings-regular.ttf');
233+
this.copy('app/fonts/glyphicons-halflings-regular.svg');
234+
this.copy('app/fonts/glyphicons-halflings-regular.woff');
234235
}
235236

236-
this.copy('styles/' + mainFile, 'app/styles/' + mainFile);
237+
this.copy('app/styles/' + mainFile);
237238
};
238239

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

254255
Generator.prototype.packageFiles = function () {
255256
this.coffee = this.env.options.coffee;
256-
this.template('../../templates/common/_bower.json', 'bower.json');
257-
this.template('../../templates/common/_package.json', 'package.json');
258-
this.template('../../templates/common/Gruntfile.js', 'Gruntfile.js');
257+
this.template('root/_bower.json', 'bower.json');
258+
this.template('root/_package.json', 'package.json');
259+
this.template('root/_Gruntfile.js', 'Gruntfile.js');
259260
};
260261

261262
Generator.prototype.imageFiles = function () {
262-
this.sourceRoot(path.join(__dirname, 'templates'));
263-
this.directory('images', 'app/images', true);
263+
this.directory('app/images');
264264
};
265265

266266
Generator.prototype._injectDependencies = function _injectDependencies() {

common/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ var Generator = module.exports = function Generator() {
1111
util.inherits(Generator, yeoman.generators.Base);
1212

1313
Generator.prototype.setupEnv = function setupEnv() {
14-
// Copies the contents of the generator `templates`
15-
// directory into your users new application path
16-
this.sourceRoot(path.join(__dirname, '../templates/common'));
17-
this.directory('root', '.', true);
14+
this.sourceRoot(path.join(__dirname, '../templates/common/root'));
15+
this.copy('.bowerrc', '.bowerrc');
16+
this.copy('.editorconfig', '.editorconfig');
17+
this.copy('.gitattributes', '.gitattributes');
18+
this.copy('.jshintrc', '.jshintrc');
1819
this.copy('gitignore', '.gitignore');
20+
this.directory('../test', 'test', true);
21+
this.copy('../app/.buildignore', 'app/.buildignore');
22+
this.copy('../app/.htaccess', 'app/.htaccess');
23+
this.copy('../app/404.html', 'app/404.html');
24+
this.copy('../app/favicon.ico', 'app/favicon.ico');
25+
this.copy('../app/robots.txt', 'app/robots.txt');
26+
this.copy('../app/views/main.html', 'app/views/main.html');
1927
};

main/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use strict';
2-
var util = require('util');
32
var path = require('path');
4-
var ScriptBase = require('../script-base.js');
3+
var util = require('util');
54
var yeoman = require('yeoman-generator');
6-
5+
var ScriptBase = require('../script-base.js');
76

87
var Generator = module.exports = function Generator() {
98
ScriptBase.apply(this, arguments);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)