Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Aug 3, 2015
0 parents commit 4ed9991
Show file tree
Hide file tree
Showing 24 changed files with 506 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"browser": true
},
"rules": {
// Legacy
"max-len": [2, 80, 2]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OS Specific
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE Specific
nbproject
.~lock.*
.buildpath
.idea
.project
.settings
composer.lock
*.sublime-workspace

# NPM Specific
node_modules
npm-debug.log
15 changes: 15 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# OS Specific
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE Specific
nbproject
.~lock.*
.buildpath
.idea
.project
.settings
composer.lock
*.sublime-workspace
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2015, Ry Racherbaumer <ry@rygine.com>

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.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ES2015 Module Generator

Initial version of ES2015 Module Generator using Babel and Tape.

## Install
`npm install -g generator-es2015-module`

## Run
`yo es2015-module`

__Optionally__, you can skip the installation of npm packages by passing in `--skip-install`.
`yo es2015-module --skip-install`

## Sub-generator for single module
`yo es2015-module:module`
133 changes: 133 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
'use strict';
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var mkdirp = require('mkdirp');
var _ = require('underscore.string');

var ES2015ModuleGenerator = yeoman.generators.Base.extend({

init: function () {
this.pkg = this.fs.readJSON(path.join(__dirname, '../package.json'));
},

prompting: function () {
var done = this.async();

this.log(yosay(
'Welcome to the ' + chalk.red('ES2015 Module') + ' generator!'
));

this.module = path.basename(process.cwd());

var prompts = [
{
name: 'module',
message: 'What would you like to call your module?',
default: this.module
},
{
name: 'author',
message: 'What is your name?'
},
{
name: 'email',
message: 'What is your email?'
},
{
name: 'githubUser',
message: 'What is your github user name?'
},
{
name: 'license',
message: 'What license would you like to use?',
default: 'MIT'
}
];

this.prompt(prompts, function(props) {
this.props = props;
this.props.module = _.slugify(props.module || this.module);
this.props.year = new Date().getFullYear();
this.appRoot = path.basename(process.cwd()) === this.props.module ?
this.destinationRoot() :
path.join(this.destinationRoot(), this.props.module);
if (process.cwd() !== this.appRoot) {
mkdirp(this.appRoot);
process.chdir(this.appRoot);
}
done();
}.bind(this));
},

writing: {

app: function() {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'),
this.props
);
},

projectfiles: function() {
this.fs.copy(
this.templatePath('editorconfig'),
this.destinationPath('.editorconfig')
);
this.fs.copy(
this.templatePath('eslintrc'),
this.destinationPath('.eslintrc')
);
this.fs.copy(
this.templatePath('babelrc'),
this.destinationPath('.babelrc')
);
this.fs.copy(
this.templatePath('gitignore'),
this.destinationPath('.gitignore')
);
this.fs.copy(
this.templatePath('npmignore'),
this.destinationPath('.npmignore')
);
this.fs.copy(
this.templatePath('LICENSE'),
this.destinationPath('LICENSE')
);
this.fs.copy(
this.templatePath('README.md'),
this.destinationPath('README.md')
);
this.fs.copy(
this.templatePath('CHANGELOG.md'),
this.destinationPath('CHANGELOG.md')
);
this.fs.copyTpl(
this.templatePath('src/index.js'),
this.destinationPath('src/' + this.props.module + '.js'),
this.props
);
this.fs.copy(
this.templatePath('test/harness.js'),
this.destinationPath('test/harness.js')
);
this.fs.copyTpl(
this.templatePath('test/test.js'),
this.destinationPath('test/' + this.props.module + '-test.js'),
this.props
);
}

},

install: function() {
if (!this.options['skip-install']) {
this.installDependencies();
}
}

});

module.exports = ES2015ModuleGenerator;
Empty file.
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "<%= module %>",
"description": "",
"version": "0.1.0",
"author": {
"name": "<%= author %>",
"email": "<%= email %>",
"url": "https://github.com/<%= githubUser %>"
},
"license": "<%= license %>",
"repository": {
"type": "git",
"url": "git://github.com/<%= githubUser %>/<%= module %>.git"
},
"bugs": "https://github.com/<%= githubUser %>/<%= module %>/issues",
"dependencies": {
"babel-runtime": "^5.8.20"
},
"devDependencies": {
"tape": "^4.0.2",
"babel": "^5.8.20",
"glob": "^5.0.14",
"eslint": "^1.0.0",
"babel-eslint": "^4.0.5"
},
"scripts": {
"prepublish": "npm run compile",
"test": "babel-node --stage 1 test/harness.js test/**/*.js",
"compile": "npm run lint && babel src -s -d dist",
"lint": "eslint src/**.js"
},
"main": "./dist/<%= module %>.js"
}
7 changes: 7 additions & 0 deletions generators/app/templates/babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"stage": 1,
"optional": [
"runtime"
],
"modules": "common"
}
13 changes: 13 additions & 0 deletions generators/app/templates/editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
25 changes: 25 additions & 0 deletions generators/app/templates/eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "eslint:recommended",
"parser": "babel-eslint",
"env": {
"node": true,
"browser": true,
"es6": true
},
"ecmaFeatures": {
"modules": true
},
"rules": {
// ECMAScript 2015
"generator-star-spacing": [2, "before"],
"no-class-assign": 2,
"no-const-assign": 2,
"no-var": 2,
"object-shorthand": [2, "always"],
"arrow-parens": 2,
"arrow-spacing": [2, {"before": true, "after": true}],
"prefer-const": 2,
// Legacy
"max-len": [2, 80, 2]
}
}
22 changes: 22 additions & 0 deletions generators/app/templates/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OS Specific
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE Specific
nbproject
.~lock.*
.buildpath
.idea
.project
.settings
composer.lock
*.sublime-workspace

# NPM Specific
node_modules
npm-debug.log
15 changes: 15 additions & 0 deletions generators/app/templates/npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# OS Specific
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE Specific
nbproject
.~lock.*
.buildpath
.idea
.project
.settings
composer.lock
*.sublime-workspace
7 changes: 7 additions & 0 deletions generators/app/templates/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Copyright (c) <%= year %>, <%= author %> <<%= email %>>
*/

export default {

}
10 changes: 10 additions & 0 deletions generators/app/templates/test/harness.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Glob from 'glob';
import Path from 'path';

setImmediate(() => {
process.argv.slice(2).forEach(arg => {
Glob.sync(arg).forEach(file => {
require(Path.resolve(process.cwd(), file));
});
});
});
11 changes: 11 additions & 0 deletions generators/app/templates/test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import tape from 'tape';
import * as <%= module %> from '../src/<%= module %>';

tape('test', (t) => {

t.test('true is truthy', (t) => {
t.plan(1);
t.ok(true);
});

});

0 comments on commit 4ed9991

Please sign in to comment.