From 6a0c8643e448734aabc6e1a1a33c3552715a6a94 Mon Sep 17 00:00:00 2001 From: Lufty Wiranda Date: Mon, 14 Aug 2017 18:08:23 +0700 Subject: [PATCH] chore: initial commit --- .all-contributorsrc | 22 ++ .editorconfig | 12 ++ .eslintignore | 2 + .gitattributes | 2 + .github/issue_template.md | 39 ++++ .github/pull_request_template.md | 38 ++++ .gitignore | 61 ++++++ .travis.yml | 12 ++ app/index.js | 126 +++++++++++ app/templates/_babelrc | 10 + app/templates/_editorconfig | 12 ++ app/templates/_eslintignore | 2 + app/templates/_eslintrc.json | 6 + app/templates/_gitattributes | 2 + app/templates/_github/issue_template.md | 38 ++++ .../_github/pull_request_template.md | 38 ++++ app/templates/_gitignore | 61 ++++++ app/templates/_package.json | 58 +++++ app/templates/_test.js | 8 + app/templates/_travis.yml | 13 ++ app/templates/contributing.md | 29 +++ app/templates/index.js | 5 + app/templates/license | 9 + app/templates/other/code_of_conduct.md | 74 +++++++ app/templates/other/examples.md | 3 + app/templates/other/roadmap.md | 11 + app/templates/readme.md | 34 +++ contributing.md | 47 +++++ license | 9 + other/code_of_conduct.md | 74 +++++++ other/examples.md | 3 + other/roadmap.md | 11 + package.json | 78 +++++++ readme.md | 51 +++++ test.js | 198 ++++++++++++++++++ 35 files changed, 1198 insertions(+) create mode 100644 .all-contributorsrc create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .gitattributes create mode 100644 .github/issue_template.md create mode 100644 .github/pull_request_template.md create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 app/index.js create mode 100644 app/templates/_babelrc create mode 100644 app/templates/_editorconfig create mode 100644 app/templates/_eslintignore create mode 100644 app/templates/_eslintrc.json create mode 100644 app/templates/_gitattributes create mode 100644 app/templates/_github/issue_template.md create mode 100644 app/templates/_github/pull_request_template.md create mode 100644 app/templates/_gitignore create mode 100644 app/templates/_package.json create mode 100644 app/templates/_test.js create mode 100644 app/templates/_travis.yml create mode 100644 app/templates/contributing.md create mode 100644 app/templates/index.js create mode 100644 app/templates/license create mode 100644 app/templates/other/code_of_conduct.md create mode 100644 app/templates/other/examples.md create mode 100644 app/templates/other/roadmap.md create mode 100644 app/templates/readme.md create mode 100644 contributing.md create mode 100644 license create mode 100644 other/code_of_conduct.md create mode 100644 other/examples.md create mode 100644 other/roadmap.md create mode 100644 package.json create mode 100644 readme.md create mode 100644 test.js diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 0000000..56b60e7 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,22 @@ +{ + "projectName": "generator-node-oss", + "projectOwner": "luftywiranda13", + "files": [ + "readme.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [ + { + "login": "luftywiranda13", + "name": "Lufty Wiranda", + "avatar_url": "https://avatars0.githubusercontent.com/u/22868432?v=4", + "profile": "http://instagram.com/luftywiranda13", + "contributions": [ + "code", + "doc", + "infra" + ] + } + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4a7ea30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +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 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..1a7864a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +app/templates/** +coverage diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..391f0a4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.js text eol=lf diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000..1ddf88f --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,39 @@ + + +## I'm submitting a… + +- [ ] Regression (a behavior that used to work and stopped working in a new release) +- [ ] Bug report +- [ ] Feature request +- [ ] Documentation issue or request +- [ ] Support request + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + +## Environment + +- generator-node-oss version: +- yo version: +- Node version: +- NPM version: +- Yarn version (if you use Yarn): +- Operating system: +- Link to your project: diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..ae879d7 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,38 @@ + + +## PR Type + + +- [ ] Bugfix +- [ ] Feature +- [ ] Code style update (whitespace, formatting, missing semicolons, etc.) +- [ ] Refactoring (no functional changes, no api changes) +- [ ] Build related changes +- [ ] CI related changes +- [ ] Documentation content changes +- [ ] Other… Please describe: + +## Description + + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Does this PR introduce a breaking change? + + +- [ ] Yes +- [ ] No + +## Checklist: + + +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the [`contributing.md`](https://github.com/luftywiranda13/generator-node-oss/blob/master/contributing.md). diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2434c59 --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# temporary directory +/temp diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..90ff641 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: node_js +notifications: + email: false +node_js: + - 'node' + - '6' + - '4' +after_script: + - npm install -g codecov + - codecov +branches: + only: master diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..d390294 --- /dev/null +++ b/app/index.js @@ -0,0 +1,126 @@ +'use strict'; + +const path = require('path'); + +const Generator = require('yeoman-generator'); +const camelCase = require('lodash.camelcase'); +const kebabCase = require('lodash.kebabcase'); +const findUp = require('find-up'); +const mkdirp = require('mkdirp'); + +module.exports = class extends Generator { + initializing() { + this.props = {}; + } + + prompting() { + return this.prompt([ + { + name: 'projectName', + message: 'Project name', + default: this.appname, + }, + { + name: 'description', + message: 'Description', + default: 'as cute as bunny', + store: true, + }, + { + name: 'esnext', + message: 'Need ES2015+', + type: 'confirm', + default: false, + }, + { + name: 'coverage', + message: 'Need code coverage', + type: 'confirm', + default: false, + }, + { + name: 'name', + message: "Author's name", + default: this.user.git.name(), + store: true, + }, + { + name: 'email', + message: "Author's email", + default: this.user.git.email(), + store: true, + }, + { + name: 'website', + message: "Author's website", + store: true, + }, + { + name: 'githubUsername', + message: 'GitHub username', + store: true, + }, + ]).then(answers => { + this.props = { + projectName: kebabCase(answers.projectName), + camelProject: camelCase(answers.projectName), + description: answers.description, + esnext: answers.esnext, + coverage: answers.coverage, + name: answers.name, + email: answers.email, + website: answers.website, + githubUsername: answers.githubUsername, + }; + }); + } + + configuring() { + if (path.basename(this.destinationPath()) !== this.props.projectName) { + mkdirp(this.props.projectName); + this.destinationRoot(this.destinationPath(this.props.projectName)); + } + } + + default() { + this.spawnCommandSync('git', ['init'], { stdio: false }); + } + + writing() { + this.fs.copyTpl( + [`${this.templatePath()}/**`, '!**/_babelrc'], + this.destinationPath(), + this.props + ); + + const mv = (from, to) => { + this.fs.move(this.destinationPath(from), this.destinationPath(to)); + }; + + mv('_editorconfig', '.editorconfig'); + mv('_eslintignore', '.eslintignore'); + mv('_eslintrc.json', '.eslintrc.json'); + mv('_gitattributes', '.gitattributes'); + mv('_github/issue_template.md', '.github/issue_template.md'); + mv('_github/pull_request_template.md', '.github/pull_request_template.md'); + mv('_gitignore', '.gitignore'); + mv('_package.json', 'package.json'); + mv('_test.js', 'test.js'); + mv('_travis.yml', '.travis.yml'); + + if (this.props.esnext) { + mv('index.js', 'src/index.js'); + mv('test.js', 'src/__tests__/index.test.js'); + this.fs.copy( + this.templatePath('_babelrc'), + this.destinationPath('.babelrc') + ); + } + } + install() { + this.installDependencies({ bower: false }); + } + end() { + this.fs.delete(findUp.sync('.yo-rc.json')); + } +}; diff --git a/app/templates/_babelrc b/app/templates/_babelrc new file mode 100644 index 0000000..c8f470c --- /dev/null +++ b/app/templates/_babelrc @@ -0,0 +1,10 @@ +{ + "presets": [ + ["env", { + "targets": { "node": 4 } + }] + ], + "plugins": [ + "add-module-exports" + ] +} diff --git a/app/templates/_editorconfig b/app/templates/_editorconfig new file mode 100644 index 0000000..4a7ea30 --- /dev/null +++ b/app/templates/_editorconfig @@ -0,0 +1,12 @@ +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 diff --git a/app/templates/_eslintignore b/app/templates/_eslintignore new file mode 100644 index 0000000..65877df --- /dev/null +++ b/app/templates/_eslintignore @@ -0,0 +1,2 @@ +coverage<% if (esnext) { %> +dist<% } %> diff --git a/app/templates/_eslintrc.json b/app/templates/_eslintrc.json new file mode 100644 index 0000000..55b11dc --- /dev/null +++ b/app/templates/_eslintrc.json @@ -0,0 +1,6 @@ +{ + "extends": [ + "bunny", + "bunny/recommended" + ] +} diff --git a/app/templates/_gitattributes b/app/templates/_gitattributes new file mode 100644 index 0000000..391f0a4 --- /dev/null +++ b/app/templates/_gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.js text eol=lf diff --git a/app/templates/_github/issue_template.md b/app/templates/_github/issue_template.md new file mode 100644 index 0000000..7d6a3dc --- /dev/null +++ b/app/templates/_github/issue_template.md @@ -0,0 +1,38 @@ + + +## I'm submitting a… + +- [ ] Regression (a behavior that used to work and stopped working in a new release) +- [ ] Bug report +- [ ] Feature request +- [ ] Documentation issue or request +- [ ] Support request + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + +## Environment + +- <%= projectName %> version: +- Node version: +- NPM version: +- Yarn version (if you use Yarn): +- Operating system: +- Link to your project: diff --git a/app/templates/_github/pull_request_template.md b/app/templates/_github/pull_request_template.md new file mode 100644 index 0000000..6ec528f --- /dev/null +++ b/app/templates/_github/pull_request_template.md @@ -0,0 +1,38 @@ + + +## PR Type + + +- [ ] Bugfix +- [ ] Feature +- [ ] Code style update (whitespace, formatting, missing semicolons, etc.) +- [ ] Refactoring (no functional changes, no api changes) +- [ ] Build related changes +- [ ] CI related changes +- [ ] Documentation content changes +- [ ] Other… Please describe: + +## Description + + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Does this PR introduce a breaking change? + + +- [ ] Yes +- [ ] No + +## Checklist: + + +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the [`contributing.md`](https://github.com/<%= githubUsername %>/<%= projectName %>/blob/master/contributing.md). diff --git a/app/templates/_gitignore b/app/templates/_gitignore new file mode 100644 index 0000000..f343faa --- /dev/null +++ b/app/templates/_gitignore @@ -0,0 +1,61 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env<% if (esnext) { %> + +# compiled +dist<% } %> diff --git a/app/templates/_package.json b/app/templates/_package.json new file mode 100644 index 0000000..a8ab6fa --- /dev/null +++ b/app/templates/_package.json @@ -0,0 +1,58 @@ +{ + "name": "<%= projectName %>", + "version": "0.0.0", + "description": "<%= description %>", + "license": "MIT", + "repository": "https://github.com/<%= githubUsername %>/<%= projectName %>.git", + "author": { + "name": "<%= name %>", + "email": "<%= email %>", + "url": "<%= website %>" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "precommit": "remove-lockfiles && lint-staged",<% if (esnext) { %> + "prebuild": "rimraf dist", + "build": "babel --copy-files --out-dir dist --ignore *.test.js src",<% } %> + "pretest": "eslint .", + "test": "jest" + },<% if (esnext) { %> + "main": "dist/index.js", + "files": [ + "dist" + ],<% } else { %> + "files": [ + "index.js" + ],<% } %> + "dependencies": {}, + "devDependencies": {<% if (esnext) { %> + "babel-cli": "^6.24.1", + "babel-plugin-add-module-exports": "^0.2.1", + "babel-preset-env": "^1.6.0",<% } %> + "eslint": "^4.4.1", + "eslint-config-bunny": "^4.1.0", + "husky": "^0.14.3", + "jest": "^20.0.4", + "lint-staged": "^4.0.3", + "prettier": "^1.5.3", + "remove-lockfiles": "^1.0.0"<% if (esnext) { %>, + "rimraf": "^2.6.1"<% } %> + }, + "jest": { + "testEnvironment": "node"<% if (coverage) { %>, + "collectCoverage": true<% } %><% if (esnext) { %>, + "collectCoverageFrom": [ + "src/**/*.js" + ]<% } %> + }, + "lint-staged": { + "*.js": [ + "prettier --trailing-comma es5 --single-quote --write", + "eslint --fix", + "git add" + ] + }, + "keywords": [] +} diff --git a/app/templates/_test.js b/app/templates/_test.js new file mode 100644 index 0000000..1e36260 --- /dev/null +++ b/app/templates/_test.js @@ -0,0 +1,8 @@ +<% if (esnext) { %>import <%= camelProject %> from '../';<% } else { %>'use strict'; + +const <%= camelProject %> = require('./');<% } %> + +test('output', () => { + expect(<%= camelProject %>('🐰')).toEqual('👉 🐰 👈'); + expect(<%= camelProject %>()).toEqual('No args passed!'); +}); diff --git a/app/templates/_travis.yml b/app/templates/_travis.yml new file mode 100644 index 0000000..e0fa7fd --- /dev/null +++ b/app/templates/_travis.yml @@ -0,0 +1,13 @@ +language: node_js +notifications: + email: false +node_js: + - 'node' + - '6' + - '4'<% if (esnext) { %> +before_script: npm run build<% } %><% if (coverage) { %> +after_script: + - npm install -g codecov + - codecov<% } %> +branches: + only: master diff --git a/app/templates/contributing.md b/app/templates/contributing.md new file mode 100644 index 0000000..7a459fa --- /dev/null +++ b/app/templates/contributing.md @@ -0,0 +1,29 @@ +# Contributing + +Thanks for being willing to contribute! + +**Working on your first Pull Request?** You can learn how from this *free* series +[How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) + +## Project setup + +1. Fork and clone the repo +2. `npm install` to install dependencies +3. `npm test` to validate you‘ve got it working +4. Create a branch for your PR + +> Tip: Keep your `master` branch pointing at the original repository and make pull requests from branches on your fork. To do this, run: +> +> ``` +> git remote add upstream https://github.com/<%= githubUsername %>/<%= projectName %>.git +> git fetch upstream +> git branch --set-upstream-to=upstream/master master +> ``` +> +> This will add the original repository as a “remote” called “upstream”, Then fetch the git information from that remote, then set your local `master` branch to use the upstream master branch whenever you run `git pull`. Then you can make all of your pull request branches based on this `master` branch. Whenever you want to update your version of `master`, do a regular `git pull`. + +## Help needed + +Please checkout the [`roadmap.md`](./other/roadmap.md) and the open issues. + +Also, please watch the repo and respond to questions/bug reports/feature requests, Thanks! diff --git a/app/templates/index.js b/app/templates/index.js new file mode 100644 index 0000000..13408e7 --- /dev/null +++ b/app/templates/index.js @@ -0,0 +1,5 @@ +<% if (esnext) { %>export default function <%= camelProject %>(input) { + return input ? `👉 ${input} 👈` : 'No args passed!'; +}<% } else { %>'use strict'; + +module.exports = input => (input ? `👉 ${input} 👈` : 'No args passed!');<% } %> diff --git a/app/templates/license b/app/templates/license new file mode 100644 index 0000000..7cb292a --- /dev/null +++ b/app/templates/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) <%= name %> <<%= email %>> + +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. diff --git a/app/templates/other/code_of_conduct.md b/app/templates/other/code_of_conduct.md new file mode 100644 index 0000000..8b16e92 --- /dev/null +++ b/app/templates/other/code_of_conduct.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others‘ private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at <%= email %>. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project‘s leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/app/templates/other/examples.md b/app/templates/other/examples.md new file mode 100644 index 0000000..810b5bc --- /dev/null +++ b/app/templates/other/examples.md @@ -0,0 +1,3 @@ +# Examples + +There aren‘t any examples yet! Want to add one? See [`contributing.md`](../contributing.md) diff --git a/app/templates/other/roadmap.md b/app/templates/other/roadmap.md new file mode 100644 index 0000000..538d7d8 --- /dev/null +++ b/app/templates/other/roadmap.md @@ -0,0 +1,11 @@ +# Project Roadmap + +This is where we‘ll define a few things about the library‘s goals. + +We haven‘t filled this out yet though. Care to help? See [`contributing.md`](../contributing.md) + +## Want to do + +## Might do + +## Won‘t do diff --git a/app/templates/readme.md b/app/templates/readme.md new file mode 100644 index 0000000..6f0ef50 --- /dev/null +++ b/app/templates/readme.md @@ -0,0 +1,34 @@ +# <%= projectName %> + +[![npm](https://img.shields.io/npm/v/<%= projectName %>.svg?style=flat-square)](https://www.npmjs.com/package/<%= projectName %>) +[![Travis branch](https://img.shields.io/travis/<%= githubUsername %>/<%= projectName %>/master.svg?style=flat-square)](https://travis-ci.org/<%= githubUsername %>/<%= projectName %>)<% if (coverage) { %> +[![Codecov branch](https://img.shields.io/codecov/c/github/<%= githubUsername %>/<%= projectName %>/master.svg?style=flat-square)](https://codecov.io/gh/<%= githubUsername %>/<%= projectName %>)<% } %> +[![npm](https://img.shields.io/npm/dm/<%= projectName %>.svg?style=flat-square)](https://npm-stat.com/charts.html?package=<%= projectName %>&from=2016-04-01) + +<%= description %> + +## Why? + +// TODO + +## Installation + +```sh +npm install --save <%= projectName %> +``` + +## Usage + +```js +<% if (esnext) { %>import <%= camelProject %> from '<%= projectName %>'; %><% } else { %>const <%= camelProject %> = require('<%= projectName %>');<% } %> + +<%= camelProject %>('some text'); //=> some text +``` + +## Related + +// TODO + +## License + +MIT © [<%= name %>](<%= website %>) diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..2198792 --- /dev/null +++ b/contributing.md @@ -0,0 +1,47 @@ +# Contributing + +Thanks for being willing to contribute! + +**Working on your first Pull Request?** You can learn how from this *free* series +[How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) + +## Project setup + +1. Fork and clone the repo +2. `npm install` to install dependencies +3. `npm test` to validate you‘ve got it working +4. Create a branch for your PR + +> Tip: Keep your `master` branch pointing at the original repository and make pull requests from branches on your fork. To do this, run: +> +> ``` +> git remote add upstream https://github.com/luftywiranda13/generator-node-oss.git +> git fetch upstream +> git branch --set-upstream-to=upstream/master master +> ``` +> +> This will add the original repository as a “remote” called “upstream”, Then fetch the git information from that remote, then set your local `master` branch to use the upstream master branch whenever you run `git pull`. Then you can make all of your pull request branches based on this `master` branch. Whenever you want to update your version of `master`, do a regular `git pull`. + +## Add yourself as a contributor + +This project follows the [all contributors](https://github.com/kentcdodds/all-contributors) specification. To add yourself to the table of +contributors on the [`readme.md`](./readme.md), please use the automated script as part of your PR: + +```sh +npm run contributors:add +``` + +Follow the prompt. If you‘ve already added yourself to the list and are making a +new type of contribution, you can run it again and select the added contribution +type. + +## Committing and Pushing changes + +This project uses [semantic-release](https://npmjs.com/package/semantic-release) to do automatic releases and generate a changelog based on the +commit history. So we follow [a convention](https://github.com/conventional-changelog/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md) for commit messages. You don‘t have to follow this convention if you don‘t like to. Just know that when we merge your commit, we‘ll probably use “Squash and Merge” so we can change the commit message. + +## Help needed + +Please checkout the [`roadmap.md`](./other/roadmap.md) and the open issues. + +Also, please watch the repo and respond to questions/bug reports/feature requests, Thanks! diff --git a/license b/license new file mode 100644 index 0000000..f3baeff --- /dev/null +++ b/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Lufty Wiranda + +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. diff --git a/other/code_of_conduct.md b/other/code_of_conduct.md new file mode 100644 index 0000000..6d81d96 --- /dev/null +++ b/other/code_of_conduct.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others‘ private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at lufty.wiranda@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project‘s leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/other/examples.md b/other/examples.md new file mode 100644 index 0000000..810b5bc --- /dev/null +++ b/other/examples.md @@ -0,0 +1,3 @@ +# Examples + +There aren‘t any examples yet! Want to add one? See [`contributing.md`](../contributing.md) diff --git a/other/roadmap.md b/other/roadmap.md new file mode 100644 index 0000000..538d7d8 --- /dev/null +++ b/other/roadmap.md @@ -0,0 +1,11 @@ +# Project Roadmap + +This is where we‘ll define a few things about the library‘s goals. + +We haven‘t filled this out yet though. Care to help? See [`contributing.md`](../contributing.md) + +## Want to do + +## Might do + +## Won‘t do diff --git a/package.json b/package.json new file mode 100644 index 0000000..8059944 --- /dev/null +++ b/package.json @@ -0,0 +1,78 @@ +{ + "name": "generator-node-oss", + "version": "0.0.0", + "description": "Create a Node.js project with ease", + "license": "MIT", + "repository": "https://github.com/luftywiranda13/generator-node-oss", + "author": { + "name": "Lufty Wiranda", + "email": "lufty.wiranda@gmail.com", + "url": "https://www.instagram.com/luftywiranda13" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "contributors:add": "all-contributors add", + "contributors:generate": "all-contributors generate", + "precommit": "remove-lockfiles && lint-staged", + "pretest": "eslint .", + "test": "jest" + }, + "files": [ + "app" + ], + "dependencies": { + "find-up": "^2.1.0", + "lodash.camelcase": "^4.3.0", + "lodash.kebabcase": "^4.1.1", + "mkdirp": "^0.5.1", + "yeoman-generator": "^1.1.1" + }, + "devDependencies": { + "all-contributors-cli": "^4.4.0", + "eslint": "^4.4.1", + "eslint-config-bunny": "^4.1.0", + "husky": "^0.14.3", + "jest": "^20.0.4", + "lint-staged": "^4.0.3", + "pify": "^3.0.0", + "remove-lockfiles": "^1.0.0", + "yeoman-assert": "^3.0.0", + "yeoman-test": "^1.7.0" + }, + "eslintConfig": { + "extends": [ + "bunny", + "bunny/recommended" + ] + }, + "jest": { + "testEnvironment": "node", + "collectCoverage": true, + "testPathIgnorePatterns": [ + "templates", + "temp" + ] + }, + "lint-staged": { + "*.js": [ + "eslint --fix", + "git add" + ] + }, + "keywords": [ + "yeoman-generator", + "yeoman", + "generator", + "boilerplate", + "template", + "scaffold", + "node", + "nodejs", + "module", + "node_module", + "node-module", + "open-source" + ] +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..f3045b8 --- /dev/null +++ b/readme.md @@ -0,0 +1,51 @@ +# generator-node-oss + +[![npm](https://img.shields.io/npm/v/generator-node-oss.svg?style=flat-square)](https://www.npmjs.com/package/generator-node-oss) +[![Travis branch](https://img.shields.io/travis/luftywiranda13/generator-node-oss/master.svg?style=flat-square)](https://travis-ci.org/luftywiranda13/generator-node-oss) +[![Codecov branch](https://img.shields.io/codecov/c/github/luftywiranda13/generator-node-oss/master.svg?style=flat-square)](https://codecov.io/gh/luftywiranda13/generator-node-oss) +[![npm](https://img.shields.io/npm/dm/generator-node-oss.svg?style=flat-square)](https://npm-stat.com/charts.html?package=generator-node-oss&from=2016-04-01) + +This [Yeoman](http://yeoman.io) generator helps you to create a Node.js project with ease. + +## Why? + +- Generates a *ready-to-start* project structure +- Shows repo quality through helpful badges +- [GitHub templates](https://github.com/blog/2111-issue-and-pull-request-templates) (Issue, Pull Request, Contributing guidelines) +- Pre-installed useful development tools ([Jest](https://facebook.github.io/jest), [ESLint](http://eslint.org), [Prettier](https://github.com/prettier/prettier), etc.) +- Pre-configured dotfiles (`.gitignore`, `.gitattributes`, [`.editorconfig`](http://editorconfig.org), etc.) +- [Travis CI](https://travis-ci.org) configuration +- Supports for ES2015+ with [Babel](https://babeljs.io) (optional) + +## Installation + +```sh +npm install --global yo generator-node-oss +``` + +## Usage + +```sh +yo node-oss +``` + +## Related + +- [generator-kcd-oss](https://github.com/kentcdodds/generator-kcd-oss) - More features but many things left untouched +- [generator-bunny](https://github.com/luftywiranda13/generator-bunny) - Supports ES2015+ and [Flow](https://flow.org) by default +- [generator-nm](https://github.com/sindresorhus/generator-nm) - A simpler Yeoman generator + +## Contributors + +Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): + + +| [
Lufty Wiranda](http://instagram.com/luftywiranda13)
[💻](https://github.com/luftywiranda13/generator-node-oss/commits?author=luftywiranda13 "Code") [📖](https://github.com/luftywiranda13/generator-node-oss/commits?author=luftywiranda13 "Documentation") [🚇](#infra-luftywiranda13 "Infrastructure (Hosting, Build-Tools, etc)") | +| :---: | + + +This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! + +## License + +MIT © [Lufty Wiranda](https://www.instagram.com/luftywiranda13) diff --git a/test.js b/test.js new file mode 100644 index 0000000..3270b56 --- /dev/null +++ b/test.js @@ -0,0 +1,198 @@ +'use strict'; + +const path = require('path'); + +const assert = require('yeoman-assert'); +const helpers = require('yeoman-test'); +const findUp = require('find-up'); +const pify = require('pify'); + +let generator; + +beforeEach(async () => { + await pify(helpers.testDirectory)(path.join(__dirname, 'temp')); + generator = helpers.createGenerator('node-oss:app', ['../app'], null, { + skipInstall: true, + }); +}); + +it('creates and uses the folder for the project', async () => { + helpers.mockPrompt(generator, { + projectName: 'test', + }); + + await pify(generator.run.bind(generator))(); + + expect(generator.destinationRoot()).toBe(findUp.sync('test')); +}); + +it('generates default files', async () => { + helpers.mockPrompt(generator, {}); + + await pify(generator.run.bind(generator))(); + + assert.file([ + '.git', + '.github/issue_template.md', + '.github/pull_request_template.md', + '.editorconfig', + '.eslintignore', + '.eslintrc.json', + '.gitattributes', + '.gitignore', + '.travis.yml', + 'contributing.md', + 'index.js', + 'license', + 'other/code_of_conduct.md', + 'other/examples.md', + 'other/roadmap.md', + 'package.json', + 'readme.md', + 'test.js', + ]); + + assert.noFile(['.babelrc', 'src/index.js', 'src/__tests__/index.test.js']); + assert.noFile(findUp.sync('.yo-rc.json')); +}); + +it('generates files for esnext', async () => { + helpers.mockPrompt(generator, { + esnext: true, + }); + + await pify(generator.run.bind(generator))(); + + assert.file(['.babelrc', 'src/index.js', 'src/__tests__/index.test.js']); + assert.noFile(['index.js', 'test.js']); +}); + +describe('templating', () => { + test('projectName', async () => { + helpers.mockPrompt(generator, { + projectName: 'test', + githubUsername: 'tester', + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('package.json', /"name": "test"/); + assert.fileContent('package.json', 'https://github.com/tester/test.git'); + assert.fileContent('contributing.md', 'https://github.com/tester/test.git'); + assert.fileContent('readme.md', /# test/); + assert.fileContent( + 'readme.md', + '[![npm](https://img.shields.io/npm/v/test.svg?style=flat-square)](https://www.npmjs.com/package/test)\n[![Travis branch](https://img.shields.io/travis/tester/test/master.svg?style=flat-square)](https://travis-ci.org/tester/test)\n[![npm](https://img.shields.io/npm/dm/test.svg?style=flat-square)](https://npm-stat.com/charts.html?package=test&from=2016-04-01)' + ); + assert.fileContent('readme.md', /npm install --save test/); + assert.fileContent('readme.md', "const test = require('test');"); + assert.fileContent( + '.github/issue_template.md', + /test version: / + ); + assert.fileContent( + '.github/pull_request_template.md', + 'https://github.com/tester/test/blob/master/contributing.md' + ); + }); + + test('coverage', async () => { + helpers.mockPrompt(generator, { + coverage: true, + githubUsername: 'tester', + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('package.json', /"collectCoverage": true/); + assert.fileContent('.travis.yml', /after_script:/); + assert.fileContent('.travis.yml', /npm install -g codecov/); + assert.fileContent('.travis.yml', /codecov/); + assert.fileContent( + 'readme.md', + '[![Codecov branch](https://img.shields.io/codecov/c/github/tester/temp/master.svg?style=flat-square)](https://codecov.io/gh/tester/temp)' + ); + }); + + test('description', async () => { + helpers.mockPrompt(generator, { + description: 'foo', + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('package.json', /"description": "foo"/); + assert.fileContent('readme.md', /foo/); + }); + + test('esnext', async () => { + helpers.mockPrompt(generator, { + esnext: true, + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('.eslintignore', /dist/); + assert.fileContent('.gitignore', /dist/); + assert.JSONFileContent('package.json', { + scripts: { + prebuild: 'rimraf dist', + build: 'babel --copy-files --out-dir dist --ignore *.test.js src', + }, + main: 'dist/index.js', + files: ['dist'], + devDependencies: { + 'babel-cli': /./, + 'babel-plugin-add-module-exports': /./, + 'babel-preset-env': /./, + rimraf: /./, + }, + jest: { + testEnvironment: 'node', + collectCoverageFrom: ['src/**/*.js'], + }, + }); + assert.fileContent( + 'src/__tests__/index.test.js', + "import temp from '../';" + ); + assert.fileContent('.travis.yml', /before_script: npm run build/); + assert.fileContent('src/index.js', 'export default function temp(input)'); + assert.fileContent('readme.md', /import temp from 'temp';/); + }); + + test('name', async () => { + helpers.mockPrompt(generator, { + name: 'tester', + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('package.json', /"name": "tester"/); + assert.fileContent('license', /tester/); + assert.fileContent('readme.md', 'MIT © [tester]'); + }); + + test('email', async () => { + helpers.mockPrompt(generator, { + email: 'tester@bunny.com', + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('package.json', /"email": "tester@bunny.com"/); + assert.fileContent('license', /tester@bunny.com/); + assert.fileContent('other/code_of_conduct.md', /tester@bunny.com/); + }); + + test('website', async () => { + helpers.mockPrompt(generator, { + website: 'test.com', + }); + + await pify(generator.run.bind(generator))(); + + assert.fileContent('package.json', /"url": "test.com"/); + assert.fileContent('readme.md', 'test.com'); + }); +});