diff --git a/src/app/index.js b/src/app/index.js index e4272d5..03f13df 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -7,27 +7,27 @@ import yosay from 'yosay'; const QUESTIONS = [ { type: 'input', - name: 'module:name', + name: 'moduleName', message: 'Module name' }, { type: 'input', - name: 'module:description', + name: 'moduleDescription', message: 'Module description' }, { type: 'input', - name: 'module:author:nickname', + name: 'githubUsername', message: 'Your GitHub username' }, { type: 'input', - name: 'module:author:fullName', + name: 'fullName', message: 'Your full name' }, { 'type': 'list', - 'name': 'module:license', + 'name': 'license', 'message': 'Choose a license', 'default': 'MIT', 'choices': [ @@ -84,23 +84,23 @@ module.exports = class AppGenerator extends Base { writing() { this.directory('src', 'src'); this.directory('test', 'test'); - this.copy('babelrc', '.babelrc'); - this.copy('editorconfig', '.editorconfig'); - this.copy('gitignore', '.gitignore'); - this.copy('npmignore', '.npmignore'); - this.copy('package.json', 'package.json'); - this.copy('README.md', 'README.md'); - this.copy('travis.yml', '.travis.yml'); + this.fs.copy(this.templatePath('babelrc'), this.destinationPath('.babelrc')); + this.fs.copy(this.templatePath('editorconfig'), this.destinationPath('.editorconfig')); + this.fs.copy(this.templatePath('gitignore'), this.destinationPath('.gitignore')); + this.fs.copy(this.templatePath('npmignore'), this.destinationPath('.npmignore')); + this.fs.copyTpl(this.templatePath('package.json'), this.destinationPath('package.json'), this.answers); + this.fs.copyTpl(this.templatePath('README.md'), this.destinationPath('README.md'), this.answers); + this.fs.copy(this.templatePath('travis.yml'), this.destinationPath('.travis.yml')); let done = this.async(); this::fetchLicense( - this.answers['module:license'], + this.answers.license, tpl => { let content = tpl .replace(/-+[\d\D]*?-+\n\n/, '') .replace(/\[year\]/g, new Date().getFullYear()) - .replace(/\[fullname\]/g, this.answers['module:author:fullName']); - this.write('LICENSE', content); + .replace(/\[fullname\]/g, this.answers.fullName); + this.fs.write(this.destinationPath('LICENSE'), content); done(); } ); diff --git a/src/app/templates/README.md b/src/app/templates/README.md index 7eaf572..f6b4a25 100644 --- a/src/app/templates/README.md +++ b/src/app/templates/README.md @@ -1,30 +1,30 @@ -# <%= answers['module:name'] %> +# <%= moduleName %> -![Build Status](https://img.shields.io/travis/<%= answers['module:author:nickname'] %>/<%= answers['module:name'] %>.svg) -![Coverage](https://img.shields.io/coveralls/<%= answers['module:author:nickname'] %>/<%= answers['module:name'] %>.svg) -![Downloads](https://img.shields.io/npm/dm/<%= answers['module:name'] %>.svg) -![Downloads](https://img.shields.io/npm/dt/<%= answers['module:name'] %>.svg) -![npm version](https://img.shields.io/npm/v/<%= answers['module:name'] %>.svg) -![dependencies](https://img.shields.io/david/<%= answers['module:author:nickname'] %>/<%= answers['module:name'] %>.svg) -![dev dependencies](https://img.shields.io/david/dev/<%= answers['module:author:nickname'] %>/<%= answers['module:name'] %>.svg) -![License](https://img.shields.io/npm/l/<%= answers['module:name'] %>.svg) +![Build Status](https://img.shields.io/travis/<%= githubUsername %>/<%= moduleName %>.svg) +![Coverage](https://img.shields.io/coveralls/<%= githubUsername %>/<%= moduleName %>.svg) +![Downloads](https://img.shields.io/npm/dm/<%= moduleName %>.svg) +![Downloads](https://img.shields.io/npm/dt/<%= moduleName %>.svg) +![npm version](https://img.shields.io/npm/v/<%= moduleName %>.svg) +![dependencies](https://img.shields.io/david/<%= githubUsername %>/<%= moduleName %>.svg) +![dev dependencies](https://img.shields.io/david/dev/<%= githubUsername %>/<%= moduleName %>.svg) +![License](https://img.shields.io/npm/l/<%= moduleName %>.svg) -<%= answers['module:description'] %> +<%= moduleDescription %> ## Getting Started Install it via npm: ```shell -npm install <%= answers['module:name'] %> +npm install <%= moduleName %> ``` And include in your project: ```javascript -import <%= answers['module:name'] %> from '<%= answers['module:name'] %>'; +import <%= moduleName %> from '<%= moduleName %>'; ``` ## License -<%= answers['module:license'] %> +<%= license %> diff --git a/src/app/templates/package.json b/src/app/templates/package.json index 4fed613..d180f51 100644 --- a/src/app/templates/package.json +++ b/src/app/templates/package.json @@ -1,11 +1,11 @@ { - "name": "<%= answers['module:name'] %>", - "description": "<%= answers['module:description'] %>", + "name": "<%= moduleName %>", + "description": "<%= moduleDescription %>", "version": "0.1.0", "main": "lib/index.js", - "author": "<%= answers['module:author:nickname'] %>", - "repository": "<%= answers['module:author:nickname'] %>/<%= answers['module:name'] %>", - "license": "<%= answers['module:license'] %>", + "author": "<%= githubUsername %>", + "repository": "<%= githubUsername %>/<%= moduleName %>", + "license": "<%= license %>", "scripts": { "compile": "babel src --out-dir lib", "coveralls": "cat ./coverage/lcov.info | coveralls", diff --git a/test/unit/app.test.js b/test/unit/app.test.js index 6154a57..b11084d 100644 --- a/test/unit/app.test.js +++ b/test/unit/app.test.js @@ -8,7 +8,7 @@ describe('app', () => { before(done => { test .run(path.join(__dirname, '../../src/app')) - .withPrompts({'module:license': 'MIT'}) + .withPrompts({license: 'MIT'}) .on('end', done); });