diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1c6314a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..902b37a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends" : ["airbnb-base", "prettier"], + "env": { + "node": true, + "es6": true + }, + "plugins": ["prettier"], + "rules": { + "prettier/prettier": 1, + "no-unused-expressions": [ + "error", + { + "allowShortCircuit": true, + "allowTernary": true + } + ] + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..89f25e5 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# 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, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, 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 lucas.tostee@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 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..e69f13d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,23 @@ +--- +name: Bug report +about: Create a report to help us improve +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional information's** +Use a label and assign this issue to someone to get your issue done quickly --> diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..0ffdd76 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,16 @@ +--- +name: Feature request +about: Suggest an idea for this project +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional information's** +Use a label and assign this issue to someone to get your issue done quickly --> diff --git a/.github/LICENSE b/.github/LICENSE new file mode 100644 index 0000000..0bb58f1 --- /dev/null +++ b/.github/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 lucas tostée + +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/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..a605b22 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,3 @@ +## Test Plan + +(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!). diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bac3d54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +# 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 (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ +package-lock.json + +# 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 + +# next.js build output +.next + +# vscode settings +.vscode diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..5aea179 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +./lib/build/ diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..0813724 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "semicolons": true, + "arrowFunctionsParentheses": "avoid", + "bracketSetting": true, + "printWidth": 90 +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7d534dc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: node_js + +node_js: +- "lts/*" + +os: +- linux +- osx + +cache: + directories: + - node_modules + +before_install: + - npm i -g npm@latest + +install: +- npm install + +script: +- npm test +- npm run lint +- npm run style diff --git a/README.md b/README.md new file mode 100644 index 0000000..91b8e2d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# repo-template +[![Build Status](https://travis-ci.com/luctst/repo-template.svg?branch=master)](https://travis-ci.com/luctst/repo-template) +[![Dependencies](https://img.shields.io/david/luctst/repo-template.svg?style=popout-square)](https://david-dm.org/luctst/repo-template) +[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![Twitter](https://img.shields.io/twitter/follow/luctstt.svg?label=Follow&style=social)](https://twitter.com/luctstt) + +Created for being reused. diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..e69de29 diff --git a/lib/scripts/init.js b/lib/scripts/init.js new file mode 100644 index 0000000..2c5ff11 --- /dev/null +++ b/lib/scripts/init.js @@ -0,0 +1,95 @@ +const readline = require("readline"); +const replace = require("replace-in-file"); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + prompt: "-> " +}); +const initProcess = { + steps: 0, + questions: [ + "What is the name of your project ? Don't add space in the name. \n", + "Enter a description. \n", + "Enter the version of NodeJs that your project must use. \n", + "Enter the URL of your repo. \n" + ], + answers: { + name: "", + description: "", + node: "", + url: "" + } +}; + +const replaceContent = (property, input) => { + const newAnswers = { ...initProcess.answers }; + newAnswers[property] = input; + initProcess.answers = { ...newAnswers }; + + if (initProcess.steps !== initProcess.questions.length) { + initProcess.steps += 1; + return; + } + console.log("\x1b[35m%s\x1b[0m", "Your package.json file was configurated"); + + replace.sync({ + files: "./package.json", + from: [/NAME/g, /DESCRIPTION/g, /VERSION/g, /REPO/g], + to: [ + initProcess.answers.name, + initProcess.answers.description, + initProcess.answers.node, + initProcess.answers.url + ], + countMatches: true, + allowEmptyPaths: true, + dry: true + }); + + process.exit(0); +}; + +console.log( + "\x1b[33m%s\x1b[0m", + "Before starting we need some informations to configurate your project. \n" +); +console.log("Press enter to start"); + +rl.on("line", input => { + if (input === "" && initProcess.steps !== 0) { + console.log("\x1b[35m%s\x1b[0m", "You should enter data !"); + rl.prompt(); + } else { + if (initProcess.steps !== initProcess.questions.length) { + console.log(`${initProcess.steps} - ${initProcess.questions[initProcess.steps]}`); + rl.prompt(); + } + + switch (initProcess.steps) { + case 0: + initProcess.steps += 1; + break; + case 1: + replaceContent("name", input); + break; + case 2: + replaceContent("description", input); + break; + case 3: + replaceContent("node", input); + break; + case 4: + replaceContent("url", input); + break; + default: + break; + } + } +}).on("close", () => { + initProcess.steps !== initProcess.questions.length && + console.log( + "\x1b[33m%s\x1b[0m", + "You closed the program too earlier your package.json file is not completed" + ); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..fe24bab --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "repo-template", + "version": "1.0.0", + "description": "Project boilerplate for easily create and share your new cool modules. ♻️ ♻️", + "main": "lib/index.js", + "files": [ + "lib/" + ], + "engines": { + "node": ">= 10.0.0" + }, + "eslintIgnore": [ + "./lib/build/" + ], + "scripts": { + "test": "ava --verbose ./test/*.js", + "test:watch": "ava --watch --verbose ./test/*.js", + "lint": "npx eslint --cache './lib/**/*.js'", + "lint:watch": "esw -w --clear --color --cache './lib/**/*.js'", + "lint:fix": "npx eslint --fix './lib/**/*.js'", + "style": "prettier -c './lib/**/*.js'", + "style:fix": "prettier --c --write './lib/**/*.js'" + }, + "repository": { + "type": "git", + "url": "https://www.github.com/luctst/repo-template" + }, + "keywords": [], + "author": "Tostée Lucas (https://www.lucas-tostee.com)", + "license": "MIT", + "bugs": { + "url": "https://www.github.com/luctst/repo-template/issues" + }, + "homepage": "https://www.github.com/luctst/repo-template", + "devDependencies": { + "ava": "^2.1.0", + "eslint": "^6.0.1", + "eslint-config-airbnb-base": "^13.2.0", + "eslint-config-prettier": "^6.0.0", + "eslint-plugin-import": "^2.18.0", + "eslint-plugin-prettier": "^3.1.0", + "eslint-watch": "^5.1.2", + "prettier": "^1.18.2" + }, + "dependencies": { + "replace-in-file": "^4.1.0" + } +} diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..65b7239 --- /dev/null +++ b/test/test.js @@ -0,0 +1,5 @@ +import test from "ava"; + +test("Repo-template fake test :)", t => { + t.pass(); +});