Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit b10d2f9

Browse files
author
Kahlil Lechelt
committed
Merge branch 'master' into feature-sub-generator-page
2 parents b74f0ef + 30818c0 commit b10d2f9

File tree

8 files changed

+230
-54
lines changed

8 files changed

+230
-54
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
22
temp/
3+
test/temp
4+
.idea

Gruntfile.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* generator-init
3+
* https://github.com/use-init/generator-init
4+
*
5+
*/
6+
7+
'use strict';
8+
9+
module.exports = function (grunt) {
10+
// Load all grunt tasks matching the `grunt-*` pattern.
11+
require('load-grunt-tasks')(grunt);
12+
13+
// Project configuration.
14+
grunt.initConfig({
15+
jshint: {
16+
all: [
17+
'Gruntfile.js',
18+
'app/index.js',
19+
'<%= mochaTest.test.src%>'
20+
],
21+
options: {
22+
jshintrc: '.jshintrc'
23+
}
24+
},
25+
26+
// Before generating any new files, remove any previously-created files.
27+
clean: {
28+
tests: ['tests/temp']
29+
},
30+
31+
// Unit tests.
32+
mochaTest: {
33+
test: {
34+
options: {
35+
reporter: 'spec'
36+
},
37+
src: ['test/*.js']
38+
}
39+
}
40+
41+
});
42+
43+
// Whenever the "test" task is run, first clean the "temp" dir, then run this
44+
// plugin's task(s), then test the result.
45+
grunt.registerTask('test', ['clean', 'mochaTest']);
46+
47+
// By default, lint and run all tests.
48+
grunt.registerTask('default', ['clean', 'jshint', 'mochaTest']);
49+
};

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ npm install -g yo
1111
npm install -g generator-init
1212
yo init
1313
```
14+
## Contributing
15+
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

app/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ var InitGenerator;
44
var initHelpers = require('../lib/initgenerator.js');
55
var util = require('util');
66
var path = require('path');
7-
var fs = require('fs');
87
var yeoman = require('yeoman-generator');
98

10-
InitGenerator = module.exports = function InitGenerator(args, options, cnf) {
9+
InitGenerator = module.exports = function InitGenerator(args, options) {
1110
var packageJsonPath;
1211
yeoman.generators.Base.apply(this, arguments);
1312

@@ -40,11 +39,11 @@ InitGenerator.prototype.askFor = function askFor() {
4039
},
4140
{
4241
name: 'email',
43-
message: 'What is your email address? (otpional)'
42+
message: 'What is your email address? (optional)'
4443
},
4544
{
4645
name: 'url',
47-
message: 'What is the url of your homepage? (otpional)'
46+
message: 'What is the url of your homepage? (optional)'
4847
},
4948
{
5049
name: 'role',

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
"yeoman-generator": "~0.14.0"
2626
},
2727
"devDependencies": {
28-
"mocha": "~1.14.0"
28+
"mocha": "~1.14.0",
29+
"grunt": "~0.4.2",
30+
"grunt-mocha-test": "~0.8.1",
31+
"grunt-contrib-clean": "~0.5.0",
32+
"grunt-contrib-jshint": "~0.7.2",
33+
"load-grunt-tasks": "~0.2.0"
2934
},
3035
"peerDependencies": {
3136
"yo": ">=1.0.0"

test/test-creation.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/test-load.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/test.js

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*global describe, beforeEach, it*/
2+
'use strict';
3+
4+
var path = require('path');
5+
var helpers = require('yeoman-generator').test;
6+
var assert = require('assert');
7+
8+
var expected = [
9+
10+
// Project files
11+
'.jshintrc',
12+
'.editorconfig',
13+
'.htaccess',
14+
15+
// Bower
16+
'.bowerrc',
17+
'bower.json',
18+
19+
// Pkg
20+
'package.json',
21+
22+
// Git
23+
'.gitattributes',
24+
'.gitignore',
25+
26+
// Travis
27+
'.travis.yml',
28+
29+
// Robots
30+
'robots.txt',
31+
32+
// HTML
33+
'templates/header.html',
34+
'templates/index.html',
35+
'templates/footer.html',
36+
'pages.json',
37+
38+
// Karma
39+
'karma.conf.js',
40+
41+
// Humans
42+
'humans.txt',
43+
44+
// Grunt
45+
'Gruntfile.js',
46+
'tasks/config.js',
47+
'tasks/options/clean.js',
48+
'tasks/options/concat.js',
49+
'tasks/options/connect.js',
50+
'tasks/options/copy.js',
51+
'tasks/options/imagemin.js',
52+
'tasks/options/jshint.js',
53+
'tasks/options/karma.js',
54+
'tasks/options/modernizr.js',
55+
'tasks/options/replace.js',
56+
'tasks/options/requirejs.js',
57+
'tasks/options/sass.js',
58+
'tasks/options/watch.js',
59+
60+
// Javascript
61+
'js/modules/module.js',
62+
'js/plugins/console.js',
63+
'js/config.js',
64+
'js/main.js',
65+
66+
// Authors
67+
'AUTHORS',
68+
69+
// Ico
70+
'apple-touch-icon-precomposed.png',
71+
'favicon.ico',
72+
73+
// Contribuiting
74+
'CONTRIBUTING.md',
75+
76+
// Cossdomain
77+
'crossdomain.xml',
78+
79+
// 404
80+
'404.html',
81+
82+
// Test
83+
'test/specs/example.spec.js',
84+
'test/spec.js',
85+
'test/test-main.js'
86+
87+
];
88+
89+
describe('init generator', function () {
90+
91+
beforeEach(function (done) {
92+
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
93+
if (err) {
94+
return done(err);
95+
}
96+
97+
this.app = helpers.createGenerator('init:app', [
98+
'../../app'
99+
]);
100+
done();
101+
}.bind(this));
102+
});
103+
104+
it('the generator can be required without throwing', function () {
105+
// not testing the actual run of generators yet
106+
var app = require('../app');
107+
assert(app !== undefined);
108+
});
109+
110+
it('creates expected files for SCSS preprocessor', function (done) {
111+
112+
helpers.mockPrompt(this.app, {
113+
'cssPreprocessor': 'Compass'
114+
});
115+
116+
var expectedSCSS = [
117+
'scss/main.scss',
118+
'scss/elements/_typography.scss',
119+
'scss/helpers/_helpers.scss',
120+
'scss/helpers/_variables.scss',
121+
'scss/media/_print.scss',
122+
'scss/modules/_box.scss',
123+
'scss/page/_base.scss',
124+
'scss/page/_footer.scss',
125+
'scss/page/_header.scss',
126+
'scss/page/_main.scss'
127+
];
128+
129+
expectedSCSS.concat(expectedSCSS, expected);
130+
131+
this.app.options['skip-install'] = true;
132+
this.app.run({}, function () {
133+
helpers.assertFiles(expectedSCSS);
134+
done();
135+
});
136+
137+
});
138+
139+
it('creates expected files for LESS preprocessor', function (done) {
140+
141+
helpers.mockPrompt(this.app, {
142+
'cssPreprocessor': 'LESS'
143+
});
144+
145+
var expectedLESS = [
146+
'less/main.less',
147+
'less/elements/_typography.less',
148+
'less/helpers/_helpers.less',
149+
'less/helpers/_variables.less',
150+
'less/media/_print.less',
151+
'less/modules/_box.less',
152+
'less/page/_base.less',
153+
'less/page/_footer.less',
154+
'less/page/_header.less',
155+
'less/page/_main.less'
156+
];
157+
158+
expectedLESS.concat(expectedLESS, expected);
159+
160+
this.app.options['skip-install'] = true;
161+
this.app.run({}, function () {
162+
helpers.assertFiles(expectedLESS);
163+
done();
164+
});
165+
166+
});
167+
168+
});

0 commit comments

Comments
 (0)