From c8e3d6ecacd0037c5670d5fa1ebef842e0756a90 Mon Sep 17 00:00:00 2001 From: "M. Peter" Date: Thu, 17 Dec 2015 10:13:48 +0100 Subject: [PATCH] Updated to yeoman 1.5 and made some fixes --- README.md | 1 + app/index.js | 20 +++++++++++--------- app/templates/Gruntfile.coffee | 4 ++-- app/templates/README.md | 4 ---- app/templates/_travis.yml | 11 ++++++++++- package.json | 12 ++++++++---- test/test-app.js | 10 ++++++---- 7 files changed, 38 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 28a388c..f4dd746 100644 --- a/README.md +++ b/README.md @@ -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| diff --git a/app/index.js b/app/index.js index 102f3c7..2737919 100644 --- a/app/index.js +++ b/app/index.js @@ -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'); }, @@ -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; @@ -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"); } } diff --git a/app/templates/Gruntfile.coffee b/app/templates/Gruntfile.coffee index 86a6c4d..ba750df 100644 --- a/app/templates/Gruntfile.coffee +++ b/app/templates/Gruntfile.coffee @@ -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: '' @@ -32,7 +32,7 @@ module.exports = (grunt) -> pckg: options: globals: - version: "<%= pkg.version %>" + version: '<%%= pkg.version %>' prefix: "@@" suffix: '' diff --git a/app/templates/README.md b/app/templates/README.md index 420809b..35bd690 100644 --- a/app/templates/README.md +++ b/app/templates/README.md @@ -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 ``` diff --git a/app/templates/_travis.yml b/app/templates/_travis.yml index 94fc200..f4c655b 100644 --- a/app/templates/_travis.yml +++ b/app/templates/_travis.yml @@ -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" diff --git a/package.json b/package.json index 679c895..6d4d0d4 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": "*" diff --git a/test/test-app.js b/test/test-app.js index 48be933..231231d 100644 --- a/test/test-app.js +++ b/test/test-app.js @@ -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 () { @@ -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); @@ -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, @@ -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 ); });