Skip to content

Commit

Permalink
Updated to yeoman 1.5 and made some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Peter committed Dec 17, 2015
1 parent 55948a7 commit c8e3d6e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ If you'd like to get to know Yeoman better and meet some of his friends, [Grunt]
## Release History
|Version|Date|Description|
|:--:|:--:|:--|
|0.1.0|2015-12-17|Updated to yeoman 1.5 and made some fixes|
|0.0.11|2015-02-09|Added node 0.12 and iojs to travis.yml|
|0.0.10|2015-01-29|removed prepublish script [npm#3059](https://github.com/npm/npm/issues/3059) and fixed travis.yml|
|0.0.9|2015-01-29|Default modulename by current folder; bugfixes|
Expand Down
20 changes: 11 additions & 9 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';
var util = require('util');
var _ = require('lodash');
var path = require('path');
var mkdirp = require( 'mkdirp' );
var yeoman = require('yeoman-generator');

var yosay = require('yosay');

var GeneratorNodemoduleGenerator = yeoman.generators.Base.extend({
var GeneratorNodemoduleGenerator = require('yeoman-generator').Base.extend({
initializing: function () {
this.pkg = require('../package.json');
},
Expand Down Expand Up @@ -57,12 +60,11 @@ var GeneratorNodemoduleGenerator = yeoman.generators.Base.extend({
message: 'Add docker code doc generator?',
default: true
}];

this.prompt(prompts, function (props) {
this.githubuser = props.githubuser;
this.fullname = props.fullname.length ? props.fullname : props.githubuser;
this.modulename = props.modulename;
this.classname = this._.classify( this.modulename );
this.classname = _.capitalize(_.camelCase( this.modulename ));
this.moduledesc = props.moduledesc;
this.moduleversion = props.moduleversion;
this.minnodeversion = props.minnodeversion;
Expand All @@ -86,21 +88,21 @@ var GeneratorNodemoduleGenerator = yeoman.generators.Base.extend({
},

configfiles: function () {
this.src.copy('_gitignore', '.gitignore');
this.src.copy('_npmignore', '.npmignore');
this.src.copy('_editorconfig', '.editorconfig');
this.template('_gitignore', '.gitignore');
this.template('_npmignore', '.npmignore');
this.template('_editorconfig', '.editorconfig');
},

app: function() {
this.dest.mkdir('_src');
this.dest.mkdir('_src/lib');
mkdirp('_src');
mkdirp('_src/lib');
this.template('_src/index.coffee', "_src/index.coffee");
this.template('_src/lib/main.coffee', "_src/lib/main.coffee");
if (this.useredis) {
this.template('_src/lib/redisconnector.coffee', "_src/lib/redisconnector.coffee");
}
if (this.addtests) {
this.dest.mkdir('_src/test');
mkdirp('_src/test');
this.template('_src/test/main.coffee', "_src/test/main.coffee");
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (grunt) ->
changed:
expand: true
cwd: '_src'
src: [ '<<% print("%") %> print( _.first( ((typeof grunt !== "undefined" && grunt !== null ? (_ref = grunt.regarde) != null ? _ref.changed : void 0 : void 0) || ["_src/nothing"]) ).slice( "_src/".length ) ) <% print("%") %>>' ]
src: [ '<%% print( _.first( ((typeof grunt !== "undefined" && grunt !== null ? (_ref = grunt.regarde) != null ? _ref.changed : void 0 : void 0) || ["_src/nothing"]) ).slice( "_src/".length ) ) %>' ]
# template to cut off `_src/` and throw on error on non-regrade call
# CF: `_.first( grunt?.regarde?.changed or [ "_src/nothing" ] ).slice( "_src/".length )
dest: ''
Expand All @@ -32,7 +32,7 @@ module.exports = (grunt) ->
pckg:
options:
globals:
version: "<%= pkg.version %>"
version: '<%%= pkg.version %>'

prefix: "@@"
suffix: ''
Expand Down
4 changes: 0 additions & 4 deletions app/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

[![NPM](https://nodei.co/npm/<%= modulename %>.png?downloads=true&stars=true)](https://nodei.co/npm/<%= modulename %>/)

*Written in coffee-script*

**INFO: all examples are written in coffee-script**

## Install

```
Expand Down
11 changes: 10 additions & 1 deletion app/templates/_travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
os:
- linux
language: node_js
<% if( useredis ){ %>services:
- redis-server
<% } %>language: node_js
<% } %>
node_js:
- 0.10
- 0.12
- 4.0
- 4.1
- 4.2
- 5.0
- 5.1
- 5.2
- iojs
before_script:
- "npm install -g mocha grunt-cli"
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-mpnodemodule",
"version": "0.0.11",
"version": "0.1.0",
"description": "Yeoman generator to generate a node module",
"license": "MIT",
"main": "app/index.js",
Expand All @@ -23,9 +23,13 @@
"yeoman-generator"
],
"dependencies": {
"yeoman-generator": "^0.17.0",
"chalk": "^0.5.0",
"yosay": "^0.3.0"
"chalk": "^1.1.1",
"lodash": "^3.10.1",
"mkdirp": "^0.5.1",
"yeoman-assert": "^2.1.1",
"yeoman-generator": "^0.22.1",
"yeoman-test": "^1.0.0",
"yosay": "^1.1.0"
},
"devDependencies": {
"mocha": "*"
Expand Down
10 changes: 6 additions & 4 deletions test/test-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'use strict';

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

describe('generator-nodemodule:app', function () {
Expand All @@ -12,7 +12,7 @@ describe('generator-nodemodule:app', function () {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
.withPrompts({
modulename: "test-module"
})
.on('end', done);
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('generator-nodemodule:app', function () {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
.withPrompts({
modulename: "test-module2",
fullname: "Test U. User",
useredis: false,
Expand Down Expand Up @@ -73,6 +73,8 @@ describe('generator-nodemodule:app', function () {
it('file content', function () {
var rgx = new RegExp( "# TestModule2", "gi" );
assert.fileContent('_src/lib/main.coffee', rgx );

assert.fileContent('Gruntfile.coffee', "<%= pkg.version %>" );

assert.fileContent('LICENSE', /Test\sU\.\sUser/gi );
});
Expand Down

0 comments on commit c8e3d6e

Please sign in to comment.