Skip to content

Commit f0eba84

Browse files
author
Peter Foerger
committed
Initial commit
0 parents  commit f0eba84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+8942
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
test/temp
3+

.jshintrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"node" : true,
3+
"es5" : true,
4+
"esnext" : true,
5+
"bitwise" : false,
6+
"curly" : false,
7+
"eqeqeq" : true,
8+
"eqnull" : true,
9+
"immed" : true,
10+
"latedef" : true,
11+
"newcap" : true,
12+
"noarg" : true,
13+
"undef" : true,
14+
"strict" : false,
15+
"trailing" : true,
16+
"smarttabs" : true,
17+
"quotmark" : "single",
18+
"indent" : 2,
19+
"white" : true
20+
}

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'
4+
- '0.8'

app/index.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var util = require('util');
2+
var path = require('path');
3+
var yeoman = require('yeoman-generator');
4+
5+
var Generator = module.exports = function Generator(args, options, config) {
6+
yeoman.generators.Base.apply(this, arguments);
7+
8+
this.testFramework = this.options['test-framework'] || 'mocha';
9+
this.hookFor(this.testFramework, { as: 'app' });
10+
11+
this.on('end', function () {
12+
this.installDependencies({ skipInstall: options['skip-install'] });
13+
});
14+
};
15+
16+
util.inherits(Generator, yeoman.generators.Base);
17+
18+
Generator.prototype.setupEnv = function setupEnv() {
19+
// Copies the contents of the generator `templates`
20+
// directory into your users new application path
21+
this.sourceRoot(path.join(__dirname, 'templates'));
22+
23+
// Copies the contents of the generator `templates/app`
24+
// directory into your users new application path
25+
this.directory('app', 'app', true);
26+
};
27+
28+
Generator.prototype.bower = function bower() {
29+
this.copy('bowerrc', '.bowerrc');
30+
this.copy('_bower.json', 'bower.json');
31+
};
32+
33+
Generator.prototype.git = function git() {
34+
this.copy('gitignore', '.gitignore');
35+
this.copy('gitattributes', '.gitattributes');
36+
};
37+
38+
Generator.prototype.jshint = function jshint() {
39+
this.copy('jshintrc', '.jshintrc');
40+
};
41+
42+
Generator.prototype.editorConfig = function editorConfig() {
43+
this.copy('editorconfig', '.editorconfig');
44+
};
45+
46+
Generator.prototype.gruntfile = function gruntfile() {
47+
this.template('Gruntfile.js');
48+
};
49+
50+
Generator.prototype.packageJSON = function packageJSON() {
51+
this.template('_package.json', 'package.json');
52+
};

app/templates/Gruntfile.js

+298
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
'use strict';
2+
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
3+
var mountFolder = function (connect, dir) {
4+
return connect.static(require('path').resolve(dir));
5+
};
6+
7+
// # Globbing
8+
// for performance reasons we're only matching one level down:
9+
// 'test/spec/{,*/}*.js'
10+
// use this if you want to match all subfolders:
11+
// 'test/spec/**/*.js'
12+
13+
module.exports = function (grunt) {
14+
// load all grunt tasks
15+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
16+
17+
// configurable paths
18+
var yeomanConfig = {
19+
app: 'app',
20+
dist: 'dist'
21+
};
22+
23+
grunt.initConfig({
24+
yeoman: yeomanConfig,
25+
watch: {
26+
coffee: {
27+
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
28+
tasks: ['coffee:dist']
29+
},
30+
coffeeTest: {
31+
files: ['test/spec/{,*/}*.coffee'],
32+
tasks: ['coffee:test']
33+
},
34+
compass: {
35+
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
36+
tasks: ['compass']
37+
},
38+
livereload: {
39+
files: [
40+
'<%= yeoman.app %>/*.html',
41+
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
42+
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
43+
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}'
44+
],
45+
tasks: ['livereload']
46+
}
47+
},
48+
connect: {
49+
options: {
50+
port: 9000,
51+
// change this to '0.0.0.0' to access the server from outside
52+
hostname: 'localhost'
53+
},
54+
livereload: {
55+
options: {
56+
middleware: function (connect) {
57+
return [
58+
lrSnippet,
59+
mountFolder(connect, '.tmp'),
60+
mountFolder(connect, 'app')
61+
];
62+
}
63+
}
64+
},
65+
test: {
66+
options: {
67+
middleware: function (connect) {
68+
return [
69+
mountFolder(connect, '.tmp'),
70+
mountFolder(connect, 'test')
71+
];
72+
}
73+
}
74+
},
75+
dist: {
76+
options: {
77+
middleware: function (connect) {
78+
return [
79+
mountFolder(connect, 'dist')
80+
];
81+
}
82+
}
83+
}
84+
},
85+
open: {
86+
server: {
87+
path: 'http://localhost:<%= connect.options.port %>'
88+
}
89+
},
90+
clean: {
91+
dist: ['.tmp', '<%= yeoman.dist %>/*'],
92+
server: '.tmp'
93+
},
94+
jshint: {
95+
options: {
96+
jshintrc: '.jshintrc'
97+
},
98+
all: [
99+
'Gruntfile.js',
100+
'<%= yeoman.app %>/scripts/{,*/}*.js',
101+
'!<%= yeoman.app %>/scripts/vendor/*',
102+
'!<%= yeoman.app %>/scripts/libs/*',
103+
'!<%= yeoman.app %>/scripts/plugins/*',
104+
'test/spec/{,*/}*.js'
105+
]
106+
},
107+
mocha: {
108+
all: {
109+
options: {
110+
run: true,
111+
urls: ['http://localhost:<%= connect.options.port %>/index.html']
112+
}
113+
}
114+
},
115+
coffee: {
116+
dist: {
117+
files: [{
118+
// rather than compiling multiple files here you should
119+
// require them into your main .coffee file
120+
expand: true,
121+
cwd: '<%= yeoman.app %>/scripts',
122+
src: '*.coffee',
123+
dest: '.tmp/scripts',
124+
ext: '.js'
125+
}]
126+
},
127+
test: {
128+
files: [{
129+
expand: true,
130+
cwd: '.tmp/spec',
131+
src: '*.coffee',
132+
dest: 'test/spec'
133+
}]
134+
}
135+
},
136+
compass: {
137+
options: {
138+
cssDir: '.tmp/styles',
139+
sassDir: '<%= yeoman.app %>/styles',
140+
imagesDir: '<%= yeoman.app %>/images',
141+
javascriptsDir: '.tmp/scripts',
142+
loadAll: '<%= yeoman.app %>/styles/extensions',
143+
relativeAssets: true,
144+
force: true
145+
},
146+
dist: {},
147+
server: {
148+
options: {
149+
debugInfo: true
150+
}
151+
}
152+
},
153+
// not used since Uglify task does concat,
154+
// but still available if needed
155+
/*concat: {
156+
dist: {}
157+
},*/
158+
requirejs: {
159+
dist: {
160+
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
161+
options: {
162+
// `name` and `out` is set by grunt-usemin
163+
baseUrl: 'app/scripts',
164+
optimize: 'none',
165+
// TODO: Figure out how to make sourcemaps work with grunt-usemin
166+
// https://github.com/yeoman/grunt-usemin/issues/30
167+
//generateSourceMaps: true,
168+
// required to support SourceMaps
169+
// http://requirejs.org/docs/errors.html#sourcemapcomments
170+
preserveLicenseComments: false,
171+
useStrict: true,
172+
wrap: true,
173+
//uglify2: {} // https://github.com/mishoo/UglifyJS2
174+
}
175+
}
176+
},
177+
useminPrepare: {
178+
html: '<%= yeoman.app %>/index.html',
179+
options: {
180+
dest: '<%= yeoman.dist %>'
181+
}
182+
},
183+
usemin: {
184+
html: ['<%= yeoman.dist %>/{,*/}*.html'],
185+
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
186+
options: {
187+
dirs: ['<%= yeoman.dist %>']
188+
}
189+
},
190+
imagemin: {
191+
dist: {
192+
files: [{
193+
expand: true,
194+
cwd: '<%= yeoman.app %>/images',
195+
src: '{,*/}*.{png,jpg,jpeg}',
196+
dest: '<%= yeoman.dist %>/images'
197+
}]
198+
}
199+
},
200+
cssmin: {
201+
dist: {
202+
files: {
203+
'<%= yeoman.dist %>/styles/gumby.css': [
204+
'.tmp/styles/{,*/}*.css',
205+
'<%= yeoman.app %>/styles/{,*/}*.css'
206+
]
207+
}
208+
}
209+
},
210+
htmlmin: {
211+
dist: {
212+
options: {
213+
/*removeCommentsFromCDATA: true,
214+
// https://github.com/yeoman/grunt-usemin/issues/44
215+
//collapseWhitespace: true,
216+
collapseBooleanAttributes: true,
217+
removeAttributeQuotes: true,
218+
removeRedundantAttributes: true,
219+
useShortDoctype: true,
220+
removeEmptyAttributes: true,
221+
removeOptionalTags: true*/
222+
},
223+
files: [{
224+
expand: true,
225+
cwd: '<%= yeoman.app %>',
226+
src: '*.html',
227+
dest: '<%= yeoman.dist %>'
228+
}]
229+
}
230+
},
231+
copy: {
232+
dist: {
233+
files: [{
234+
expand: true,
235+
dot: true,
236+
cwd: '<%= yeoman.app %>',
237+
dest: '<%= yeoman.dist %>',
238+
src: [
239+
'*.{ico,txt}',
240+
'.htaccess',
241+
'images/{,*/}*.{webp,gif}'
242+
]
243+
}]
244+
}
245+
},
246+
bower: {
247+
all: {
248+
rjsConfig: '<%= yeoman.app %>/scripts/main.js'
249+
}
250+
}
251+
});
252+
253+
grunt.renameTask('regarde', 'watch');
254+
255+
grunt.registerTask('server', function (target) {
256+
if (target === 'dist') {
257+
return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
258+
}
259+
260+
grunt.task.run([
261+
'clean:server',
262+
'coffee:dist',
263+
'compass:server',
264+
'livereload-start',
265+
'connect:livereload',
266+
'open',
267+
'watch'
268+
]);
269+
});
270+
271+
grunt.registerTask('test', [
272+
'clean:server',
273+
'coffee',
274+
'compass',
275+
'connect:test',
276+
'mocha'
277+
]);
278+
279+
grunt.registerTask('build', [
280+
'clean:dist',
281+
'coffee',
282+
'compass:dist',
283+
'useminPrepare',
284+
'requirejs',
285+
'imagemin',
286+
'htmlmin',
287+
'concat',
288+
'cssmin',
289+
'uglify',
290+
'copy',
291+
'usemin'
292+
]);
293+
294+
grunt.registerTask('default', [
295+
'test',
296+
'build'
297+
]);
298+
};

0 commit comments

Comments
 (0)