Skip to content
Permalink
Browse files

feat(stfsy-node): add generator

  • Loading branch information...
stfsy committed Sep 4, 2016
1 parent 5315719 commit e9190d8706d456259d7b2f8ecfb018923c359dae
@@ -0,0 +1,102 @@
'use strict'

const generators = require('yeoman-generator')
const yosay = require('yosay')
const slugify = require('underscore.string').slugify

module.exports = generators.Base.extend({

initializing: function () {
this.log(yosay('Welcome to stfsy\'s node gen. You may pass.'))
this.year = new Date().getFullYear()

this.appname = slugify(this.appname)
},
prompting: function () {
return this.prompt([
{
type: 'input',
name: 'app',
message: 'Your project name:',
validate: (input) => {
return input && input.length > 0
},
default: this.appname // Default to current folder name
}, {
type: 'input',
name: 'description',
validate: (input) => {
return input && input.length > 0
},
message: 'Your projects description:'
}, {
type: 'input',
name: 'author',
required: true,
validate: (input) => {
return input && input.length > 0
},
default: this.author,
message: 'Your name:'
}, {
type: 'input',
name: 'alias',
validate: (input) => {
return input && input.length > 0
},
default: this.user.git.name(),
message: 'Your github alias:'
}]).then((answers) => {

for (let key in answers) {
this[key] = answers[key]
}
})
},
configuring: {
path: function () {
this.mkdir("lib")
this.mkdir("test")
this.mkdir("test/spec")
},
packagejson: function () {
this.fs.copyTpl(this.templatePath('package.json'),
this.destinationPath('package.json'), this)
},
jsdocjson: function () {
this.fs.copyTpl(this.templatePath('.jsdoc.json'),
this.destinationPath('.jsdoc.json'), this)
},
readme: function () {
this.fs.copyTpl(this.templatePath('README.md'),
this.destinationPath('README.md'), this)
},
license: function () {
this.fs.copyTpl(this.templatePath('LICENSE'),
this.destinationPath('LICENSE'), this)
},
travis: function () {
this.fs.copyTpl(this.templatePath('.travis.yml'),
this.destinationPath('.travis.yml'), this)
},
gitignore: function () {
this.fs.copyTpl(this.templatePath('.gitignore'),
this.destinationPath('.gitignore'), this)
},
indexjs: function () {
this.fs.copyTpl(this.templatePath('lib/index.js'),
this.destinationPath('lib/index.js'))
},
indexspec: function () {
this.fs.copyTpl(this.templatePath('lib/index.spec.js'),
this.destinationPath('test/spec/index.js'))
}
},
install: function () {
this.installDependencies({
bower: false,
npm: true
})
}
})

@@ -0,0 +1,5 @@
node_modules/
coverage/
docs/
npm-debug.log
.tmp
@@ -0,0 +1,11 @@
{
"templates": {
"default": {
"includeDate": false
}
},
"opts": {
"template": "node_modules/minami",
"private": false
}
}
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "6"
- "5"
- "4"
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) <%= year %> <%= author %>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,30 @@
# <%= app %>

[![Build Status](https://travis-ci.org/stfsy/<%= app %>.svg)](https://travis-ci.org/stfsy/<%= app %>)
[![Dependency Status](https://img.shields.io/david/stfsy/<%= app %>.svg)](https://github.com/<%= alias %>/<%= app %>/blob/master/package.json)
[![DevDependency Status](https://img.shields.io/david/dev/stfsy/<%= app %>.svg)](https://github.com/<%= alias %>/<%= app %>/blob/master/package.json)
[![Npm downloads](https://img.shields.io/npm/dm/<%= app %>.svg)](https://www.npmjs.com/package/<%= app %>)
[![Npm Version](https://img.shields.io/npm/v/<%= app %>.svg)](https://www.npmjs.com/package/<%= app %>)
[![Git tag](https://img.shields.io/github/tag/stfsy/<%= app %>.svg)](https://github.com/<%= alias %>/<%= app %>/releases)
[![Github issues](https://img.shields.io/github/issues/stfsy/<%= app %>.svg)](https://github.com/<%= alias %>/<%= app %>/issues)
[![License](https://img.shields.io/npm/l/<%= app %>.svg)](https://github.com/<%= alias %>/<%= app %>/blob/master/LICENSE)

<%= description %>

## Example

```js
```

## Installation

```
npm install <%= app %> --save
```

## Documentation

## License

This project is distributed under the MIT license.
@@ -0,0 +1,3 @@
'use strict'

module.exports = ''
@@ -0,0 +1,13 @@
'use strict'

const Module = require('../../lib/index')

const expect = require('chai').expect

describe('Module', () => {

it('should be defined', () => {

expect(typeof Module).to.equal('string')
})
})
@@ -0,0 +1,40 @@
{
"name": "<%= app %>",
"version": "0.0.0",
"description": "<%= description %>",
"main": "lib/index.js",
"scripts": {
"setup": "npm run release-patch",
"test-watch": "mocha test/spec --watch --check-leaks",
"test": "mocha test/spec --check-leaks",
"coverage": "istanbul cover node_modules/mocha/bin/_mocha -- test/spec --check-leaks",
"docs": "jsdoc lib --destination docs --configure .jsdoc.json --readme README.md ",
"preversion": "npm run test",
"version": "npm run changelog && git add -A CHANGELOG.md",
"postversion": "git push && git push --tags",
"release-major": "npm version major -m \"chore(release): v%s\"",
"release-minor": "npm version minor -m \"chore(release): v%s\"",
"release-patch": "npm version patch -m \"chore(release): v%s\"",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r"
},
"bugs": {
"url": "https://github.com/<%= alias %>/<%= app %>/issues"
},
"homepage": "https://github.com/<%= alias %>/<%= app %>#readme",
"repository": {
"type": "git",
"url": "https://github.com/<%= alias %>/<%= app %>"
},
"keywords": [],
"author": "<%= author %>",
"license": "MIT",
"devDependencies": {
"chai": "^3.5.0",
"chai-spies": "^0.7.1",
"conventional-changelog-cli": "^1.2.0",
"istanbul": "^0.4.4",
"jsdoc": "^3.4.0",
"minami": "^1.1.1",
"mocha": "^2.5.3"
}
}

0 comments on commit e9190d8

Please sign in to comment.
You can’t perform that action at this time.