diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..a5aa84c --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,17 @@ +#!/bin/bash + +#/** +# * TangoMan pre-commit git hook +# * +# * @license MIT +# * @author "Matthias Morin" +# * @version 0.1.0 +# */ + +set -efu -o pipefail + +BASEDIR="$(git rev-parse --show-toplevel)" + +cd "${BASEDIR}" || exit 1 + +make diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c36f449 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Call script with parameters ... +2. Type ... +3. Wait for ... seconds +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. + +**Desktop (please complete the following information):** + - OS: [e.g. MacOS] + - make version (make --version) + - Script version + - copy/paste output + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**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 context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml new file mode 100644 index 0000000..f4b4611 --- /dev/null +++ b/.github/workflows/make.yml @@ -0,0 +1,34 @@ +name: Make CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + ubuntu: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: install Ubuntu dependencies with sudo apt install -y + run: sudo apt install -y gawk make + + - name: Check for basic execution + run: make && make generate + + macos: + runs-on: macos-latest + if: "contains(toJSON(github.event.commits.*.message), '[macos]')" + + steps: + - uses: actions/checkout@v2 + + - name: install MacOS dependencies with brew install + run: brew install gawk make + + - name: Check for basic execution + run: make && make generate diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2028ec9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build +config.yaml +makefiles/_* +makefiles/vars/_* +makefiles/header/_* diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..26804cd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +Change Log +========== + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] +- WIP + +## [0.1.0](https://github.com/TangoMan75/makefile-generator/releases/tag/0.1.0) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..b480fb3 --- /dev/null +++ b/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 mat@tangoman.io. 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/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..06c246c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,242 @@ +# Contributing + +## How do I... + +* [Use This Guide](#introduction)? +* Ask or Say Something? 🤔🐛😱 + * [Request Support](#request-support) + * [Report an Error or Bug](#report-an-error-or-bug) + * [Request a Feature](#request-a-feature) +* Make Something? 🤓👩🏽‍💻📜🍳 + * [Project Setup](#project-setup) + * [Contribute Documentation](#contribute-documentation) + * [Contribute Code](#contribute-code) +* Manage Something ✅🙆🏼💃👔 + * [Provide Support on Issues](#provide-support-on-issues) + * [Label Issues](#label-issues) + * [Clean Up Issues and PRs](#clean-up-issues-and-prs) + * [Review Pull Requests](#review-pull-requests) + * [Merge Pull Requests](#merge-pull-requests) + * [Tag a Release](#tag-a-release) + * [Join the Project Team](#join-the-project-team) +* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻 + +## Introduction + +Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝 + +Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚 + +## Request Support + +If you have a question about this project, how to use it, or just need clarification about something: + +* Open an Issue at https://github.com/TangoMan75/makefile-generator/issues +* Provide as much context as you can about what you're running into. +* Provide project and platform versions (bash, basher, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* Someone will try to have a response soon. +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). + If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. + +## Report an Error or Bug + +If you run into an error or bug with the project: + +* Open an Issue at https://github.com/TangoMan75/makefile-generator/issues +* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own. +* Provide project and platform versions (OS, bash, basher, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code). +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. +* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline. + +## Request a Feature + +If the project doesn't do something you need or want it to do: + +* Open an Issue at https://github.com/TangoMan75/makefile-generator/issues +* Provide as much context as you can about what you're running into. +* Please be clear about why existing features and alternatives would not work for you. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward. +* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code). + +Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no. + +## Project Setup + +So you want to contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before. + +If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code). + +If you want to go the usual route and run the project locally, though: + +* [Fork the project](https://guides.github.com/activities/forking/#fork) + +Then in your terminal: +* `cd path/to/your/clone` + +And you should be ready to go! + +## Contribute Documentation + +Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance. + +Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! + +To contribute documentation: + +* [Set up the project](#project-setup). +* Edit or add any relevant documentation. +* Make sure your changes are formatted correctly and consistently with the rest of the documentation. +* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `. +* Go to https://github.com/TangoMan75/makefile-generator/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Contribute Code + +We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others. + +Code contributions of just about any size are acceptable! + +The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution. + +To contribute code: + +* [Set up the project](#project-setup). +* Make any necessary changes to the source code. +* Include any [additional documentation](#contribute-documentation) the changes might need. +* Write tests that verify that your contribution works as expected. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). +* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion. +* Go to https://github.com/TangoMan75/makefile-generator/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc). +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Provide Support on Issues + +Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug. + +Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it. + +In order to help other folks out with their questions: + +* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/TangoMan75/makefile-generator/issues?q=is%3Aopen+is%3Aissue+label%3Asupport). +* Read through the list until you find something that you're familiar enough with to give an answer to. +* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on. +* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you. + +Some notes on picking up support issues: + +* Avoid responding to issues you don't know you can answer accurately. +* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format. +* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict). + +## Label Issues + +One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily. + +In order to label issues, [open up the list of unlabeled issues](https://github.com/TangoMan75/makefile-generator/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself! + +Label | Apply When | Notes +--- | --- | --- +`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label. +`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. | +`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`. +`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`) +`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. | +`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling. +`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete. +`performance` | This issue or PR is directly related to improving performance. | +`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. | +`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority. +`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes. +`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests) +`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not. + +## Clean Up Issues and PRs + +Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon. + +In these cases, they should be closed until they're brought up again or the interaction starts over. + +To clean up issues and PRs: + +* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today. +* Go through each issue *from oldest to newest*, and close them if **all of the following are true**: + * not opened by a maintainer + * not marked as `critical` + * not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available) + * no explicit messages in the comments asking for it to be left open + * does not belong to a milestone +* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/TangoMan75/makefile-generator/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details." + +## Review Pull Requests + +While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions. + +PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration. + +Some notes: + +* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments". +* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers. +* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own. +* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it? + +## Merge Pull Requests + +Project Team will merge pull requests after review. + +## Tag A Release + +Project Team will bump tags/version with [setver](https://github.com/pforret/setver) as a patch or minor versionupdate. +Releases are done manually for important changes. + + +## Join the Project Team + +### Ways to Join + +There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do. + +All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like. + +You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names. + +Permission | Description +--- | --- +Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker. +Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team. +Admin/Owner | Granted to people ultimately responsible for the project, its community, etc. + +## Attribution + +This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)! + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d691851 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Matthias Morin + +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/Makefile b/Makefile new file mode 100755 index 0000000..331b3cf --- /dev/null +++ b/Makefile @@ -0,0 +1,377 @@ +#/** +# * TangoMan Makefile Generator +# * +# * Run `make` to print help. +# * Add help for a rule by prexixing a comment with two pound signs on the previous line. +# * Optionally use three signs to group rules by categories. +# * +# * @version 0.1.0 +# * @author "Matthias Morin" +# * @license MIT +# * @link https://github.com/TangoMan75/makefile-generator +# */ + +.PHONY: help generate makefile phony readme license changelog code contrib ci-cd init clean + +#-------------------------------------------------- +# Colors +#-------------------------------------------------- + +PRIMARY = \033[97m +SECONDARY = \033[94m +SUCCESS = \033[32m +DANGER = \033[31m +WARNING = \033[33m +INFO = \033[95m +LIGHT = \033[47;90m +DARK = \033[40;37m +DEFAULT = \033[0m +EOL = \033[0m\n + +ALERT_PRIMARY = \033[1;104;97m +ALERT_SECONDARY = \033[1;45;97m +ALERT_SUCCESS = \033[1;42;97m +ALERT_DANGER = \033[1;41;97m +ALERT_WARNING = \033[1;43;97m +ALERT_INFO = \033[1;44;97m +ALERT_LIGHT = \033[1;47;90m +ALERT_DARK = \033[1;40;37m + +#-------------------------------------------------- +# Color Functions +#-------------------------------------------------- + +define echo_primary + @printf "${PRIMARY}%b${EOL}" $(1) +endef +define echo_secondary + @printf "${SECONDARY}%b${EOL}" $(1) +endef +define echo_success + @printf "${SUCCESS}%b${EOL}" $(1) +endef +define echo_danger + @printf "${DANGER}%b${EOL}" $(1) +endef +define echo_warning + @printf "${WARNING}%b${EOL}" $(1) +endef +define echo_info + @printf "${INFO}%b${EOL}" $(1) +endef +define echo_light + @printf "${LIGHT}%b${EOL}" $(1) +endef +define echo_dark + @printf "${DARK}%b${EOL}" $(1) +endef + +define echo_label + @printf "${SUCCESS}%b ${DEFAULT}" $(1) +endef +define echo_error + @printf "${DANGER}error: %b${EOL}" $(1) +endef + +define alert_primary + @printf "${EOL}${ALERT_PRIMARY}%64s${EOL}${ALERT_PRIMARY} %-63s${EOL}${ALERT_PRIMARY}%64s${EOL}\n" "" $(1) "" +endef +define alert_secondary + @printf "${EOL}${ALERT_SECONDARY}%64s${EOL}${ALERT_SECONDARY} %-63s${EOL}${ALERT_SECONDARY}%64s${EOL}\n" "" $(1) "" +endef +define alert_success + @printf "${EOL}${ALERT_SUCCESS}%64s${EOL}${ALERT_SUCCESS} %-63s${EOL}${ALERT_SUCCESS}%64s${EOL}\n" "" $(1) "" +endef +define alert_danger + @printf "${EOL}${ALERT_DANGER}%64s${EOL}${ALERT_DANGER} %-63s${EOL}${ALERT_DANGER}%64s${EOL}\n" "" $(1) "" +endef +define alert_warning + @printf "${EOL}${ALERT_WARNING}%64s${EOL}${ALERT_WARNING} %-63s${EOL}${ALERT_WARNING}%64s${EOL}\n" "" $(1) "" +endef +define alert_info + @printf "${EOL}${ALERT_INFO}%64s${EOL}${ALERT_INFO} %-63s${EOL}${ALERT_INFO}%64s${EOL}\n" "" $(1) "" +endef +define alert_light + @printf "${EOL}${ALERT_LIGHT}%64s${EOL}${ALERT_LIGHT} %-63s${EOL}${ALERT_LIGHT}%64s${EOL}\n" "" $(1) "" +endef +define alert_dark + @printf "${EOL}${ALERT_DARK}%64s${EOL}${ALERT_DARK} %-63s${EOL}${ALERT_DARK}%64s${EOL}\n" "" $(1) "" +endef + +#-------------------------------------------------- +# Makefile Generator +#-------------------------------------------------- + +# get parameters from config.yaml +# NOTE: "$(1)" in make "define" functions refers to the first given parameter +define get_param + cat ./config.yaml | sed -nE 's/^(\s+)?$(1)://p' | sed -E 's/^\s+//g' +endef + +# get phony from file +# NOTE: "eval" allows to set variables in global scope +# NOTE: ":=" allows to set variable as value +define get_phony + $(eval phony:=$(shell awk -F ':' '/^[a-zA-Z0-9_-]+:/{printf "%s ", $$1}' $(1))) +endef + +# get usage from file +define get_usage + $(eval usage:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf "%s=[%s]\n", $$1, $$1}' $(1)|sort|uniq|tr '\n' ' ')) +endef + +# render template (phony and usage are generated - can't edit) +define render + @sed -i s/'{{ AUTHOR }}'/"$(author)"/g $(1) + @sed -i s/'{{ DESCRIPTION }}'/"$(description)"/g $(1) + @sed -i s/'{{ EMAIL }}'/"$(email)"/g $(1) + @sed -i s/'{{ FILENAME }}'/"$(filename)"/g $(1) + @sed -i s/'{{ GIT_SERVER }}'/"$(git_server)"/g $(1) + @sed -i s/'{{ GIT_USER }}'/"$(git_user)"/g $(1) + @sed -i s/'{{ LICENSE }}'/"$(license)"/g $(1) + @sed -i s/'{{ PADDING }}'/"$(padding)"/g $(1) + @sed -i s/'{{ PHONY }}'/"$(phony)"/g $(1) + @sed -i s/'{{ PROJECT }}'/"$(project)"/g $(1) + @sed -i s/'{{ REPOSITORY }}'/"$(repository)"/g $(1) + @sed -i s/'{{ USAGE }}'/"$(usage)"/g $(1) + @sed -i s/'{{ VERSION }}'/"$(version)"/g $(1) + @sed -i s/'{{ YEAR }}'/"$(year)"/g $(1) +endef + +# parameters (usage parameter=value) +ifeq ($(shell test ! -f ./config.yaml && echo true),true) + # set default config (from this actual file header) + author?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @author /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '\".+\"' | tr -d '"'` + description?=`awk '/^\# \* @/ {i=2} /^\#\/\*\*$$/,/^\# \*\/$$/{i+=1; if (i>3) printf "%s ", substr($$0, 5)}' ${MAKEFILE_LIST} 2>/dev/null` + email?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @author /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '<.+>' | tr -d '<' | tr -d '>'` + filename?=Makefile + git_server?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '(bitbucket.org|github.com|gitlab.com)'` + git_user?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -E '(bitbucket.org|github.com|gitlab.com)' | cut -d/ -f4` + license?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @license /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '(Apache|GPL2|GPL3|MIT)'` + padding?=12 + project?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{i+=1; if (i==2) print substr($$0, 5)}' ${MAKEFILE_LIST} 2>/dev/null` + repository?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -E '(bitbucket.org|github.com|gitlab.com)' | cut -d/ -f5` + version?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @version /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oP '\d+\.\d+\.\d+'` + year?=`date +%Y` +else + # get config from config.yaml + author?=`$(call get_param,author)` + description?=`$(call get_param,description)` + email?=`$(call get_param,email)` + filename?=`$(call get_param,filename)` + git_server?=`$(call get_param,git_server)` + git_user?=`$(call get_param,git_user)` + license?=`$(call get_param,license)` + padding?=`$(call get_param,padding)` + project?=`$(call get_param,project)` + repository?=`$(call get_param,repository)` + version?=`$(call get_param,version)` + year?=`$(call get_param,year)` +endif + +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + $(call alert_primary, 'TangoMan Makefile Generator') + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} Generate Makefiles with one single command${EOL}" + @printf "${PRIMARY} Prefix \"*.make\" files from \"./makefiles\" with underscore to concatenate${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + +################################################## +### Generator +################################################## + +## Generate all +generate: + -@make --no-print-directory makefile + -@make --no-print-directory phony + -@make --no-print-directory readme + -@make --no-print-directory license + -@make --no-print-directory changelog + -@make --no-print-directory code + -@make --no-print-directory contrib + -@make --no-print-directory ci-cd + +## Generate "Makefile" +makefile: init +ifeq ($(shell test ! -d ./makefiles && echo true),true) + $(call echo_danger, 'error: "./makefiles" source folder not found') + @exit 1 +endif + + $(call echo_secondary, 'print header block') +ifeq ($(shell test -f ./makefiles/header/_header*.make && echo true),true) + $(call echo_info, "cp ./makefiles/header/_header*.make ./build/${filename}") + @cp ./makefiles/header/_header*.make ./build/${filename} +else + $(call echo_info, "cp ./makefiles/header/header_default.make ./build/${filename}") + @cp ./makefiles/header/header_default.make ./build/${filename} +endif + + $(call echo_secondary, 'print colors') +ifeq ($(shell test -f ./makefiles/colors/_colors*.make && echo true),true) + $(call echo_info, "cat ./makefiles/colors/_colors*.make >> ./build/${filename}") + @cat ./makefiles/colors/_colors*.make >> ./build/${filename} +else + $(call echo_info, "cat ./makefiles/colors/colors_default.make >> ./build/${filename}") + @cat ./makefiles/colors/colors_default.make >> ./build/${filename} +endif + + $(call echo_secondary, 'print vars block') +ifeq ($(shell ! test -f ./makefiles/vars/_*.make && echo true),true) + $(call echo_warning, 'no templates found in "./makefiles/vars"') +else + $(call echo_info, "cat ./makefiles/vars/_*.make >> ./build/${filename}") + -@cat ./makefiles/vars/_*.make >> ./build/${filename} +endif + + $(call echo_secondary, 'print help block') +ifeq ($(shell test -f ./makefiles/header/_help*.make && echo true),true) + $(call echo_info, "cat ./makefiles/header/_help*.make >> ./build/${filename}") + -@cat ./makefiles/header/_help*.make >> ./build/${filename} +else + $(call echo_info, "cat ./makefiles/header/help_default.make >> ./build/${filename}") + -@cat ./makefiles/header/help_default.make >> ./build/${filename} +endif + + $(call echo_secondary, 'print makefile rules block') +ifeq ($(shell ! test -f ./makefile/_*.make && echo true),true) + $(call echo_warning, 'no templates found in "./makefiles"') +else + $(call echo_info, "cat ./makefiles/_*.make >> ./build/${filename}") + -@cat ./makefiles/_*.make >> ./build/${filename} +endif + @# can't read from file while writing in the same rule apparently + @$(eval phony:=".PHONY:") + + $(call render,./build/${filename}) + $(call echo_success, "${filename} generated.") + +## Update ".PHONY:" rule +phony: + $(call echo_secondary, 'update phony rule') + $(call get_phony,./build/${filename}) + @$(eval phony:=.PHONY: ${phony}) + $(call echo_secondary, '${phony}') + @sed -i s/"^\.PHONY:.*"/"${phony}"/g ./build/${filename} + +## Generate "README.md" +readme: init + $(call echo_info, 'cp ./templates/README.md ./build/README.md') + @cp ./templates/README.md ./build/README.md + $(call echo_info, 'cp ./templates/README_FR.md ./build/README_FR.md') + @cp ./templates/README_FR.md ./build/README_FR.md + +ifeq ($(shell test -f ./build/${filename} && echo true),true) + $(call echo_info, 'get phony') + $(call get_phony,./build/${filename}) + $(call echo_info, '$(phony)') + + $(call echo_info, 'get usage') + $(call get_usage,./build/${filename}) + $(call echo_info, '$(usage)') + + $(call echo_info, 'get markdown') + $(call echo_info, "$(shell awk '/^### /{printf"### %s\\n",substr($$0, 5)}/^[a-zA-Z0-9_-]+:/{if(match(PREV,/^## /)) HELP=substr(PREV,4);else HELP="";RULE=substr($$1,0,index($$1,":")-1);printf"#### ⚡ %s\\n\\`\\`\\`bash\\n$$ make %s\\n\\`\\`\\`\\n\\n",HELP,RULE}{PREV=$$0}' ./build/${filename} | tr '/' '-')") + @sed -i s/'{{ MARKDOWN }}'/"$(shell awk '/^### /{printf"### %s\\n",substr($$0, 5)}/^[a-zA-Z0-9_-]+:/{if(match(PREV,/^## /)) HELP=substr(PREV,4);else HELP="";RULE=substr($$1,0,index($$1,":")-1);printf"#### ⚡ %s\\n\\`\\`\\`bash\\n$$ make %s\\n\\`\\`\\`\\n\\n",HELP,RULE}{PREV=$$0}' ./build/${filename} | tr '/' '-')"/g ./build/README.md +endif + $(call render,./build/README.md) + $(call echo_success, 'README.md generated.') + $(call render,./build/README_FR.md) + $(call echo_success, 'README_FR.md generated.') + +## Generate "LICENSE" +license: init +ifeq ($(shell echo ${license}),Apache) + $(call echo_info, 'cp ./templates/APACHE.txt ./build/LICENSE') + @cp ./templates/APACHE.txt ./build/LICENSE +endif +ifeq ($(shell echo ${license}),GPL2) + $(call echo_info, 'cp ./templates/GPL2.txt ./build/LICENSE') + @cp ./templates/GPL2.txt ./build/LICENSE +endif +ifeq ($(shell echo ${license}),GPL3) + $(call echo_info, 'cp ./templates/GPL3.txt ./build/LICENSE') + @cp ./templates/GPL3.txt ./build/LICENSE +endif +ifeq ($(shell echo ${license}),MIT) + $(call echo_info, 'cp ./templates/MIT.txt ./build/LICENSE') + @cp ./templates/MIT.txt ./build/LICENSE +endif + $(call render,./build/LICENSE) + $(call echo_success, 'LICENSE generated.') + +## Generate "CHANGELOG.md" +changelog: init + $(call echo_info, 'cp ./templates/CHANGELOG.md ./build/CHANGELOG.md') + @cp ./templates/CHANGELOG.md ./build/CHANGELOG.md + $(call render,./build/CHANGELOG.md) + $(call echo_success, 'CHANGELOG.md generated.') + +## Generate "CODE_OF_CONDUCT.md" +code: init + $(call echo_info, 'cp ./templates/CODE_OF_CONDUCT.md ./build/CODE_OF_CONDUCT.md') + @cp ./templates/CODE_OF_CONDUCT.md ./build/CODE_OF_CONDUCT.md + $(call render,./build/CODE_OF_CONDUCT.md) + $(call echo_success, 'CODE_OF_CONDUCT.md generated.') + +## Generate "CONTRIBUTING.md" +contrib: init + $(call echo_info, 'cp ./templates/CONTRIBUTING.md ./build/CONTRIBUTING.md') + @cp ./templates/CONTRIBUTING.md ./build/CONTRIBUTING.md + $(call render,./build/CONTRIBUTING.md) + $(call echo_success, 'CONTRIBUTING.md generated.') + +## Copy CI/CD tools +ci-cd: init + $(call echo_info, 'cp -r ./templates/.github ./build/') + @cp -r ./templates/.github ./build/ + $(call echo_success, '.github copied.') + $(call echo_info, 'cp ./templates/entrypoint.sh ./build/') + @cp ./templates/entrypoint.sh ./build/ + $(call echo_success, 'entrypoint.sh copied.') + +## Create "config.yaml" and "./build" folder +init: +ifeq ($(shell test ! -d ./build && echo true),true) + $(call echo_info, 'mkdir ./build') + @mkdir ./build +endif +ifeq ($(shell test ! -f ./config.yaml && echo true),true) + @if [ -f ./config.yaml.dist ]; then \ + printf "${INFO}cp ./config.yaml.dist ./config.yaml${EOL}"; \ + cp ./config.yaml.dist ./config.yaml; \ + fi + $(call render,./config.yaml) +endif + +## Remove "config.yml" "./build" and all "template/_*.make" files +clean: + $(call echo_info, 'rm config.yaml') + -@rm config.yaml + $(call echo_info, 'rm -rf ./build') + -@rm -rf ./build + $(call echo_info, 'rm ./makefiles/_*.make') + -@rm ./makefiles/_*.make + $(call echo_info, 'rm ./makefiles/header/_*.make') + -@rm ./makefiles/header/_*.make + $(call echo_info, 'rm ./makefiles/vars/_*.make') + -@rm ./makefiles/vars/_*.make + diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d869cb --- /dev/null +++ b/README.md @@ -0,0 +1,255 @@ +![GH language](https://img.shields.io/github/languages/top/TangoMan75/makefile-generator) +[![GH release](https://img.shields.io/github/v/release/TangoMan75/makefile-generator)](https://github.com/TangoMan75/makefile-generator/releases) +[![GH license](https://img.shields.io/github/license/TangoMan75/makefile-generator)]((https://github.com/TangoMan75/makefile-generator/blob/main/LICENSE)) +[![GH stars](https://img.shields.io/github/stars/TangoMan75/makefile-generator)](https://github.com/TangoMan75/makefile-generator/stargazers) +[![Make CI](https://github.com/TangoMan75/makefile-generator/workflows/Make%20CI/badge.svg)](https://github.com/TangoMan75/makefile-generator/actions/workflows/make.yml) +![visitors](https://visitor-badge.glitch.me/badge?page_id=TangoMan75.makefile-generator) + +TangoMan Makefile Generator +=========================== + +Awesome **TangoMan Makefile Generator** is a fast and handy tool to generate self documenting makefiles and provides neat makefiles templates. + +![TangoMan Makefile Generator](./assets/screenshot.png) + +🎯 Features +----------- + +**TangoMan Makefile Generator** generates Makefile, README.md, LICENSE (Apache, MIT, GPL2, GPL3) from templates with one single command. + +Template values are configurable with `config.yaml`. + +**TangoMan Makefile Generator** will generate `.PHONY` rule, and detailed help from available rules and parameters for your makefile. + +### 💡 Self documentation + +Generated Makefiles will print self documentation, with the `help` command and Awk. + +If you want to add a help message for your rule, just add : `## Foo bar`, on the previous line. + +Use : `### Foobar` to group rules by categories. + +💻 Dependencies +--------------- + +**TangoMan Makefile Generator** requires the following dependencies: + +- Make +- GAWK +- SED + +which should be available by default on most linux distributions. + +--- + +### 🛠 Gawk + +#### 🐧 Install Gawk (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes gawk +``` + +#### 🏁 Install Gawk (Windows) + +On windows machine you will need to install [cygwin](http://www.cygwin.com/) or Gawk for Windows](http://gnuwin32.sourceforge.net/packages/gawk.htm) first to execute script. + +#### 🍎 Install Gawk (OSX) + +Gawk should be available by default on OSX system, but you can upgrade Gawk version with following command + +```bash +$ brew install gawk +``` + +--- + +### 🛠 Make + +#### 🐧 Install Make (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes make +``` + +#### 🏁 Install Make (Windows) + +On windows machine you will need to install [cygwin](http://www.cygwin.com/) or [GnuWin make](http://gnuwin32.sourceforge.net/packages/make.htm) first to execute make script. + +#### 🍎 Install Make (OS X) + +Make exists by default on OS X, if you want to update to a newer version use: + +```bash +$ brew install make +``` + +--- + +### 🛠 Sed + +#### 🐧 Install Sed (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes sed +``` + +#### 🏁 Install Sed (Windows) + +On windows machine you will need to install [cygwin](http://www.cygwin.com/) or [Sed for Windows](http://gnuwin32.sourceforge.net/packages/sed.htm) first to execute script. + +#### 🍎 Install Sed (OSX) + +Sed should be available by default on OSX system, but you can upgrade Sed version with following command + +```bash +$ brew install sed +``` + +--- + +🔥 Usage +-------- + +Prefix template files with underscore in the `makefiles`, `vars` and `header` directories to be concatenated. + +Tags delimited with double curly braces (eg: `{{ PLACEHODER }}`) will be replaced with values from `config.yaml` file. + +Valid tags are: + +- `{{ FILENAME }}`: Filename of generated Makefile (default is current datetime, eg: 20210101090000.make). +- `{{ PROJECT }}`: Project name. +- `{{ VERSION }}`: Project version number. +- `{{ DESCRIPTION }}`: Project description. +- `{{ PADDING }}`: Padding spaces in the `help` command. +- `{{ AUTHOR }}`: Project author. +- `{{ EMAIL }}`: Author email. +- `{{ YEAR }}`: License year. +- `{{ LICENSE }}`: License type (valid types: mit, apache, gpl2, gpl3). +- `{{ GIT_SERVER }}`: Project repository server. +- `{{ GIT_USER }}`: Project repository username. +- `{{ REPOSITORY }}`: Project repository name. + +### 📝 Note 1 + +`{{ PHONY }}` and `{{ MARKDOWN }}` values are generated on the fly and are not configurable. + +- `{{ PHONY }}`: Generated `.PHONY:` rule. +- `{{ MARKDOWN }}`: Generated markdown documentation. + +### 📝 Note 2 + +Do not use **backticks** inside `{{ DESCRIPTION }}` block, help rules or categories.. + +### ✅ Parameters + +Run `make` to print help + +```bash +$ make [command] author=[author] description=[description] email=[email] filename=[filename] git_server=[git_server] git_user=[git_user] license=[license] padding=[padding] project=[project] repository=[repository] version=[version] year=[year] +``` + +Available commands are: `help generate makefile phony readme license changelog code contrib ci-cd init clean ` + +🤖 Commands +----------- + +#### ⚡ Print this help +```bash +$ make help +``` + +### Generator +#### ⚡ Generate all +```bash +$ make generate +``` + +#### ⚡ Generate Makefile +```bash +$ make makefile +``` + +#### ⚡ Update .PHONY: rule +```bash +$ make phony +``` + +#### ⚡ Generate README.md +```bash +$ make readme +``` + +#### ⚡ Generate LICENSE +```bash +$ make license +``` + +#### ⚡ Generate CHANGELOG.md +```bash +$ make changelog +``` + +#### ⚡ Generate CODE_OF_CONDUCT.md +```bash +$ make code +``` + +#### ⚡ Generate CONTRIBUTING.md +```bash +$ make contrib +``` + +#### ⚡ Copy CI-CD tools +```bash +$ make ci-cd +``` + +#### ⚡ Create config.yaml and .-build folder +```bash +$ make init +``` + +#### ⚡ Remove config.yml .-build and all \_template.make files +```bash +$ make clean +``` + +📝 Notes +-------- + +You can find emojis for semantic enhancement here: + +- [gist.github.com/parmentf](https://gist.github.com/parmentf/035de27d6ed1dce0b36a) +- [webfx.com/tools/emoji-cheat-sheet](https://www.webfx.com/tools/emoji-cheat-sheet) + +🤝 Contributing +--------------- + +Thank you for your interest in contributing to **TangoMan Makefile Generator**. + +Please review the [code of conduct](./CODE_OF_CONDUCT.md) and [contribution guidelines](./CONTRIBUTING.md) before starting to work on any features. + +If you want to open an issue, please check first if it was not [reported already](https://github.com/TangoMan75/makefile-generator/issues/) before creating a new one. + +📜 License +---------- + +Copyrights (c) 2023 "Matthias Morin" <mat@tangoman.io> + +[![License](https://img.shields.io/badge/Licence-MIT-green.svg)](LICENSE) +Distributed under the MIT license. + +If you like **TangoMan Makefile Generator** please star, follow or tweet about it: + +[![GitHub stars](https://img.shields.io/github/stars/TangoMan75/makefile-generator?style=social)](https://github.com/TangoMan75/makefile-generator/stargazers) +[![GitHub followers](https://img.shields.io/github/followers/TangoMan75?style=social)](https://github.com/TangoMan75) +[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2FTangoMan75%2Fmakefile-generator)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2FTangoMan75%2Fmakefile-generator) + +... And check my other cool projects. diff --git a/assets/screenshot.png b/assets/screenshot.png new file mode 100644 index 0000000..9a62a06 Binary files /dev/null and b/assets/screenshot.png differ diff --git a/config.yaml.dist b/config.yaml.dist new file mode 100644 index 0000000..2915787 --- /dev/null +++ b/config.yaml.dist @@ -0,0 +1,13 @@ +config: + filename: {{ FILENAME }} + project: {{ PROJECT }} + version: {{ VERSION }} + description: {{ DESCRIPTION }} + padding: {{ PADDING }} + author: {{ AUTHOR }} + email: {{ EMAIL }} + year: {{ YEAR }} + license: {{ LICENSE }} + git_server: {{ GIT_SERVER }} + git_user: {{ GIT_USER }} + repository: {{ REPOSITORY }} diff --git a/makefiles/ansible_install_node.make b/makefiles/ansible_install_node.make new file mode 100644 index 0000000..efcd1e2 --- /dev/null +++ b/makefiles/ansible_install_node.make @@ -0,0 +1,52 @@ +################################################## +### ansible install node +################################################## + +## Install ansible locally +ansible-install: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo apt-get update${EOL}" + -@sudo apt-get update + @printf "${INFO}sudo apt-get install -y ansible${EOL}" + @sudo apt-get install -y ansible +endif + +## Install virtualenv and sshpass +ansible-init: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo apt-get update${EOL}" + -@sudo apt-get update + @printf "${INFO}sudo apt-get install -y python-virtualenv${EOL}" + @sudo apt-get install -y python-virtualenv + @printf "${INFO}sudo apt-get install -y sshpass${EOL}" + @sudo apt-get install -y sshpass +endif + +## Create ansible user +ansible-adduser: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}adduser user-ansible${EOL}" + @adduser user-ansible + @printf "${INFO}sudo usermod -a -G docker ${USER}${EOL}" + @sudo usermod -a -G docker ${USER} +endif + +## Create ansible virtualenv +ansible-create-virtualenv: + @printf "${INFO}virtualenv ansible2.7.10${EOL}" + @virtualenv ansible2.7.10 + @printf "${INFO}source ansible2.7.10/bin/activate${EOL}" + @source ansible2.7.10/bin/activate + +## Install ansible in virtualenv +ansible-install-virtualenv: + @printf "${INFO}pip install ansible==2.7.10${EOL}" + @pip install ansible==2.7.10 + @printf "${INFO}ansible --version${EOL}" + @ansible --version + +## List ansible config +ansible-config: + @printf "${INFO}ansible-config list${EOL}" + @ansible-config list + diff --git a/makefiles/api-platform_react_client_generator.make b/makefiles/api-platform_react_client_generator.make new file mode 100644 index 0000000..2b2539b --- /dev/null +++ b/makefiles/api-platform_react_client_generator.make @@ -0,0 +1,23 @@ +################################################## +### Api Platform React Client Generator Local Env +################################################## + +## Install developpement dependencies for react.js +install-env: + @printf "${INFO}npx create-react-app .${EOL}" + @npx create-react-app . + @printf "${INFO}yarn add redux react-redux redux-thunk redux-form react-router-dom connected-react-router prop-types lodash${EOL}" + @yarn add redux react-redux redux-thunk redux-form react-router-dom connected-react-router prop-types lodash + @printf "${INFO}yarn add bootstrap font-awesome${EOL}" + @yarn add bootstrap font-awesome + +## Open documentation in default browser +doc: + @printf "${INFO}nohup xdg-open https://api-platform.com/docs/client-generator/react >/dev/null 2>&1${EOL}" + @nohup xdg-open https://api-platform.com/docs/client-generator/react >/dev/null 2>&1 + +## Generate code for a exposed resource from Hydra-enabled API entrypoint +generate: + @printf "${INFO}npx @api-platform/client-generator http://symfony.localhost/api src/${EOL}" + @npx @api-platform/client-generator http://symfony.localhost/api src/ + diff --git a/makefiles/api-platform_schema_generator.make b/makefiles/api-platform_schema_generator.make new file mode 100644 index 0000000..9e77f46 --- /dev/null +++ b/makefiles/api-platform_schema_generator.make @@ -0,0 +1,18 @@ +############################################## +### Schema Generator +############################################## + +## Install Schema Generator binary +sg-install: + @printf "${INFO}composer require --dev api-platform/schema-generator${EOL}" + @composer require --dev api-platform/schema-generator + @if [ ! -f "./config/schema.yaml" ]; then \ + printf "${INFO}touch ./config/schema.yaml${EOL}"; \ + touch ./config/schema.yaml; \ + fi; + +## Generate schema from ./config/schema.yaml +sg-generate: + @printf "${INFO}php -d memory-limit=-1 vendor/bin/schema generate-types ./src/ ./config/schema.yaml${EOL}" + @php -d memory-limit=-1 vendor/bin/schema generate-types ./src/ ./config/schema.yaml + diff --git a/makefiles/api-platform_vue_client_generator.make b/makefiles/api-platform_vue_client_generator.make new file mode 100644 index 0000000..e1e55f9 --- /dev/null +++ b/makefiles/api-platform_vue_client_generator.make @@ -0,0 +1,22 @@ +################################################## +### Api Platform Vue Client Generator Local Env +################################################## + +## Install developpement dependencies for vue.js +install-env: + @printf "${INFO}vue init webpack-simple .${EOL}" + @vue init webpack-simple . + @printf "${INFO}yarn add vue-router vuex vuex-map-fields babel-plugin-transform-builtin-extend babel-preset-es2015 babel-preset-stage-2 lodash${EOL}" + @yarn add vue-router vuex vuex-map-fields babel-plugin-transform-builtin-extend babel-preset-es2015 babel-preset-stage-2 lodash + @printf "${INFO}yarn add bootstrap font-awesome${EOL}" + @yarn add bootstrap font-awesome + +## Open documentation in default browser +doc: + @printf "${INFO}nohup xdg-open https://api-platform.com/docs/client-generator/vuejs >/dev/null 2>&1${EOL}" + @nohup xdg-open https://api-platform.com/docs/client-generator/vuejs >/dev/null 2>&1 + +## Generate code for a exposed resource from Hydra-enabled API entrypoint +generate: + @printf "${INFO}npx @api-platform/client-generator http://symfony.localhost/api src/ --generator vue --resource tag${EOL}" + @npx @api-platform/client-generator http://symfony.localhost/api src/ --generator vue --resource tag diff --git a/makefiles/chef.make b/makefiles/chef.make new file mode 100644 index 0000000..4b3d2ac --- /dev/null +++ b/makefiles/chef.make @@ -0,0 +1,24 @@ +################################################## +### Chef +################################################## + +## Clean chef recipes folder +clean-chef: + @printf "${INFO}rm -rf ./{{ REPOSITORY }}/* ./{{ REPOSITORY }}/.git* ./{{ REPOSITORY }}/.kitchen.yml${EOL}" + rm -rf ./{{ REPOSITORY }}/* ./{{ REPOSITORY }}/.git* ./{{ REPOSITORY }}/.kitchen.yml + +## Clone {{ REPOSITORY }} git project +git-clone: clean-chef + @printf "${INFO}git clone git@{{ GIT_SERVER }}:{{ GIT_USER }}/{{ REPOSITORY }}.git ./{{ REPOSITORY }}${EOL}" + git clone git@{{ GIT_SERVER }}:{{ GIT_USER }}/{{ REPOSITORY }}.git ./{{ REPOSITORY }} + +## Build chef cookbooks +build-cookbooks: + @printf "${INFO}cd {{ REPOSITORY }} && berks vendor cookbooks${EOL}" + cd {{ REPOSITORY }} && berks vendor cookbooks + +## Untar default chef (when you can't build the cookbooks on your machine) +untar-{{ REPOSITORY }}: + @printf "${INFO}tar -xvzf {{ REPOSITORY }}.tar.gz${EOL}" + tar -xvzf {{ REPOSITORY }}.tar.gz + diff --git a/makefiles/colors/colors_default.make b/makefiles/colors/colors_default.make new file mode 100644 index 0000000..ff8b845 --- /dev/null +++ b/makefiles/colors/colors_default.make @@ -0,0 +1,43 @@ +#-------------------------------------------------- +# Colors +#-------------------------------------------------- + +PRIMARY = \033[97m +SECONDARY = \033[94m +SUCCESS = \033[32m +DANGER = \033[31m +WARNING = \033[33m +INFO = \033[95m +LIGHT = \033[47;90m +DARK = \033[40;37m +DEFAULT = \033[0m +EOL = \033[0m\n + +#-------------------------------------------------- +# Color Functions +#-------------------------------------------------- + +define echo_primary + @printf "${PRIMARY}%b${EOL}" $(1) +endef +define echo_secondary + @printf "${SECONDARY}%b${EOL}" $(1) +endef +define echo_success + @printf "${SUCCESS}%b${EOL}" $(1) +endef +define echo_danger + @printf "${DANGER}%b${EOL}" $(1) +endef +define echo_warning + @printf "${WARNING}%b${EOL}" $(1) +endef +define echo_info + @printf "${INFO}%b${EOL}" $(1) +endef +define echo_light + @printf "${LIGHT}%b${EOL}" $(1) +endef +define echo_dark + @printf "${DARK}%b${EOL}" $(1) +endef diff --git a/makefiles/colors/colors_extended.make b/makefiles/colors/colors_extended.make new file mode 100644 index 0000000..de3c1bb --- /dev/null +++ b/makefiles/colors/colors_extended.make @@ -0,0 +1,84 @@ +#-------------------------------------------------- +# Colors +#-------------------------------------------------- + +PRIMARY = \033[97m +SECONDARY = \033[94m +SUCCESS = \033[32m +DANGER = \033[31m +WARNING = \033[33m +INFO = \033[95m +LIGHT = \033[47;90m +DARK = \033[40;37m +DEFAULT = \033[0m +EOL = \033[0m\n + +ALERT_PRIMARY = \033[1;104;97m +ALERT_SECONDARY = \033[1;45;97m +ALERT_SUCCESS = \033[1;42;97m +ALERT_DANGER = \033[1;41;97m +ALERT_WARNING = \033[1;43;97m +ALERT_INFO = \033[1;44;97m +ALERT_LIGHT = \033[1;47;90m +ALERT_DARK = \033[1;40;37m + +#-------------------------------------------------- +# Color Functions +#-------------------------------------------------- + +define echo_primary + @printf "${PRIMARY}%b${EOL}" $(1) +endef +define echo_secondary + @printf "${SECONDARY}%b${EOL}" $(1) +endef +define echo_success + @printf "${SUCCESS}%b${EOL}" $(1) +endef +define echo_danger + @printf "${DANGER}%b${EOL}" $(1) +endef +define echo_warning + @printf "${WARNING}%b${EOL}" $(1) +endef +define echo_info + @printf "${INFO}%b${EOL}" $(1) +endef +define echo_light + @printf "${LIGHT}%b${EOL}" $(1) +endef +define echo_dark + @printf "${DARK}%b${EOL}" $(1) +endef + +define echo_label + @printf "${SUCCESS}%b ${DEFAULT}" $(1) +endef +define echo_error + @printf "${DANGER}error: %b${EOL}" $(1) +endef + +define alert_primary + @printf "${EOL}${ALERT_PRIMARY}%64s${EOL}${ALERT_PRIMARY} %-63s${EOL}${ALERT_PRIMARY}%64s${EOL}\n" "" $(1) "" +endef +define alert_secondary + @printf "${EOL}${ALERT_SECONDARY}%64s${EOL}${ALERT_SECONDARY} %-63s${EOL}${ALERT_SECONDARY}%64s${EOL}\n" "" $(1) "" +endef +define alert_success + @printf "${EOL}${ALERT_SUCCESS}%64s${EOL}${ALERT_SUCCESS} %-63s${EOL}${ALERT_SUCCESS}%64s${EOL}\n" "" $(1) "" +endef +define alert_danger + @printf "${EOL}${ALERT_DANGER}%64s${EOL}${ALERT_DANGER} %-63s${EOL}${ALERT_DANGER}%64s${EOL}\n" "" $(1) "" +endef +define alert_warning + @printf "${EOL}${ALERT_WARNING}%64s${EOL}${ALERT_WARNING} %-63s${EOL}${ALERT_WARNING}%64s${EOL}\n" "" $(1) "" +endef +define alert_info + @printf "${EOL}${ALERT_INFO}%64s${EOL}${ALERT_INFO} %-63s${EOL}${ALERT_INFO}%64s${EOL}\n" "" $(1) "" +endef +define alert_light + @printf "${EOL}${ALERT_LIGHT}%64s${EOL}${ALERT_LIGHT} %-63s${EOL}${ALERT_LIGHT}%64s${EOL}\n" "" $(1) "" +endef +define alert_dark + @printf "${EOL}${ALERT_DARK}%64s${EOL}${ALERT_DARK} %-63s${EOL}${ALERT_DARK}%64s${EOL}\n" "" $(1) "" +endef diff --git a/makefiles/docker-compose_container.make b/makefiles/docker-compose_container.make new file mode 100644 index 0000000..1d74f00 --- /dev/null +++ b/makefiles/docker-compose_container.make @@ -0,0 +1,26 @@ +################################################## +### Docker Compose Container +################################################## + +## Build docker stack +dc-build: + @printf "${INFO}docker-compose build${EOL}" + @docker-compose build + +## Start docker stack +dc-start: + @printf "${INFO}docker-compose up --detach --remove-orphans${EOL}" + @docker-compose up --detach --remove-orphans + +## Stop docker stack +dc-stop: + @printf "${INFO}docker-compose stop${EOL}" + @docker-compose stop + +## Stack status +dc-status: + @printf "${INFO}docker-compose ps${EOL}" + @docker-compose ps + +## Restart container +dc-restart: dc-stop dc-build dc-start diff --git a/makefiles/docker-compose_extra.make b/makefiles/docker-compose_extra.make new file mode 100644 index 0000000..46967c4 --- /dev/null +++ b/makefiles/docker-compose_extra.make @@ -0,0 +1,24 @@ +################################################## +### docker-compose extra +################################################## + +## Show stack logs +dc-logs: + @printf "${INFO}docker-compose logs -f --tail 5${EOL}" + @docker-compose logs -f --tail 5 + +## Kill docker stack +dc-kill: + @printf "${INFO}docker-compose kill${EOL}" + @docker-compose kill + +## Stop and remove containers, networks, volumes, and images +dc-clean: + @printf "${INFO}docker-compose down --remove-orphans${EOL}" + @docker-compose down --remove-orphans + +## Check docker-compose.yaml syntax validity +dc-valid: + @printf "${INFO}docker-compose config${EOL}" + @docker-compose config + diff --git a/makefiles/docker-compose_install_env.make b/makefiles/docker-compose_install_env.make new file mode 100644 index 0000000..c40c9f7 --- /dev/null +++ b/makefiles/docker-compose_install_env.make @@ -0,0 +1,14 @@ +################################################## +### Docker Compose Install Local Env +################################################## + +## Install docker-compose locally +dc-install: +ifeq (${SYSTEM}, Linux) + @#curl -L => follow redirects + @printf "${INFO}sudo curl -L \"https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m`\" -o /usr/bin/docker-compose${EOL}" + @sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m`" -o /usr/bin/docker-compose + @printf "${INFO}sudo chmod +x /usr/bin/docker-compose${EOL}" + @sudo chmod +x /usr/bin/docker-compose +endif + diff --git a/makefiles/docker_adminer.make b/makefiles/docker_adminer.make new file mode 100644 index 0000000..0b48791 --- /dev/null +++ b/makefiles/docker_adminer.make @@ -0,0 +1,41 @@ +################################################## +### Docker Adminer +################################################## + +## Connect to database with adminer +adminer: adminer-start adminer-info adminer-open + +## Start adminer +adminer-start: + @printf "${INFO}docker run --detach --name adminer --link ${container}:${container} -P adminer${EOL}" + @docker run --detach --name adminer --link ${container}:${container} -P adminer + +## Open adminer in browser +adminer-open: +ifneq ($(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container}),) + @printf "${INFO}nohup xdg-open http://`docker inspect -f '{{ .NetworkSettings.IPAddress }}' adminer`:8080/?pgsql=`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`\&username=root\&db=${container} >/dev/null 2>&1${EOL}" + -@nohup xdg-open http://`docker inspect -f '{{ .NetworkSettings.IPAddress }}' adminer`:8080/?pgsql=`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`\&username=root\&db=${container} >/dev/null 2>&1 +else + @printf "${DANGER}error: image not ready${EOL}" +endif + +## Print adminer infos +adminer-info: +ifneq ($(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container}),) + @printf "${SUCCESS}server: ${INFO}%s${EOL}" "`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`" + @printf "${SUCCESS}username: ${INFO}%s${EOL}" "root" + @printf "${SUCCESS}database: ${INFO}%s${EOL}" ${container} + @printf "${SUCCESS}password: ${INFO}%s${EOL}" "toor" + @printf "${SUCCESS}local url: ${INFO}http://%s:8080${EOL}" "`docker inspect -f '{{ .NetworkSettings.IPAddress }}' adminer`" +else + @printf "${SUCCESS}ip address: ${DANGER}error: image not ready${EOL}" + @printf "${SUCCESS}open ports: ${DANGER}error: image not ready${EOL}" +endif + +## Stop adminer +adminer-stop: + @printf "${INFO}docker kill adminer${EOL}" + @docker kill adminer + @printf "${INFO}docker rm adminer${EOL}" + @docker rm adminer + diff --git a/makefiles/docker_container.make b/makefiles/docker_container.make new file mode 100644 index 0000000..b81852f --- /dev/null +++ b/makefiles/docker_container.make @@ -0,0 +1,99 @@ +################################################## +### Docker Container (deprecated) +################################################## + +## Build container +build: +ifeq ($(shell test -f ./${image} && echo true),true) + @printf "${INFO}docker build . -f ${image} -t ${container}${EOL}" + @docker build . -f ${image} -t ${container} +else + @printf "${WARNING}Dockerfile not found, skipping${EOL}" +endif + +## Start container and bind host CWD with given guest path +start: +ifeq (${workdir},) + @printf "${INFO}docker run --detach --name ${container} --network ${network} --rm -P ${container}${EOL}" + @docker run --detach --name ${container} --network ${network} --rm -P ${container} +else + @printf "${INFO}docker run --volume \"$(PWD)\":${workdir} --detach --name ${container} --network ${network} --rm -P ${container}${EOL}" + @docker run --volume "$(PWD)":${workdir} --detach --name ${container} --network ${network} --rm -P ${container} +endif + +## Open in default browser +open: +ifeq ($(shell docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null),) + @printf "${INFO}nohup xdg-open http://localhost${app_route} >/dev/null 2>&1${EOL}" + @nohup xdg-open http://localhost${app_route} >/dev/null 2>&1 +else + @printf "${INFO}nohup xdg-open http://`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`${app_route} >/dev/null 2>&1${EOL}" + @nohup xdg-open http://`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`${app_route} >/dev/null 2>&1 +endif + +## Open shell as root into running container +shell: + @printf "${INFO}docker exec -u 0 -it ${container} /bin/bash${EOL}" + @docker exec -u 0 -it ${container} /bin/bash + +## Print image status +status: + @printf "${SUCCESS}image: ${INFO}%s${EOL}" "`docker inspect --format '{{ .Config.Image }}' ${container} 2>/dev/null`" + @printf "${SUCCESS}hostname: ${INFO}%s${EOL}" "`docker inspect --format '{{ .Config.Hostname }}' ${container} 2>/dev/null`" +ifneq ($(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null),) + @printf "${SUCCESS}ip address: ${INFO}%s${EOL}" "`docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null`" + @printf "${SUCCESS}open ports: ${INFO}%s${EOL}" "`docker port ${container} 2>/dev/null`" + @printf "${SUCCESS}local url: ${INFO}http://%s${EOL}" "`docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null`" +else + @if [ ${network} != 'host' ]; then \ + printf "${SUCCESS}ip address: ${DANGER}error${EOL}"; \ + printf "${SUCCESS}open ports: ${DANGER}error${EOL}"; \ + else \ + printf "${SUCCESS}ip address: ${INFO}127.0.0.1${EOL}"; \ + printf "${SUCCESS}local url: ${INFO}http://localhost${EOL}"; \ + fi +endif + +## Stop container +stop: + @printf "${INFO}docker stop ${container}${EOL}" + @docker stop ${container} + +## Kill container +kill: + @printf "${INFO}docker kill ${container}${EOL}" + @docker kill ${container} + @printf "${INFO}docker rm ${container} 2>/dev/null${EOL}" + @docker rm ${container} 2>/dev/null + +## Stop and remove image +remove: + -@make --no-print-directory kill + @printf "${INFO}docker image rm ${container}${EOL}" + @docker image rm ${container} + +## Start container with given command binding host CWD with given guest path +cmd: +ifeq (${workdir},) + @printf "${INFO}docker run --detach --name ${container} --network ${network} --rm -P ${container} ${command}${EOL}" + @docker run --detach --name ${container} --network ${network} --rm -P ${container} ${command} +else + @printf "${INFO}docker run --volume \"$(PWD)\":${workdir} --detach --name ${container} --network ${network} --rm -P ${container} ${command}${EOL}" + @docker run --volume "$(PWD)":${workdir} --detach --name ${container} --network ${network} --rm -P ${container} ${command} +endif + +## Print container volumes +volumes: +ifeq ($(shell test -x `which python 2>/dev/null` && echo true),true) + @printf "${INFO}docker inspect --format='{{ json .Mounts }}' ${container} ${EOL}" + @docker inspect --format='{{ json .Mounts }}' ${container} 2>/dev/null | python -m json.tool +else + @printf "${INFO}docker inspect --format='{{ json .Mounts }}' ${container} ${EOL}" + @docker inspect --format='{{ json .Mounts }}' ${container} 2>/dev/null +endif + +## Print container logs +logs: + @printf "${INFO}docker logs ${container} --tail 5${EOL}" + @docker logs ${container} --tail 5 + diff --git a/makefiles/docker_image.make b/makefiles/docker_image.make new file mode 100644 index 0000000..fe6e75a --- /dev/null +++ b/makefiles/docker_image.make @@ -0,0 +1,16 @@ +################################################## +### Docker Image (deprecated) +################################################## + +## Start and open in default browser (build start status open) +up: build start status open + +## Start in production mode (build and start) +prod: build start + +## Start in dev mode (build start status shell) +dev: build start status shell + +## Start in cli mode (build cmd status shell) +cli: build cmd status shell + diff --git a/makefiles/docker_install_env.make b/makefiles/docker_install_env.make new file mode 100644 index 0000000..1d0e7d6 --- /dev/null +++ b/makefiles/docker_install_env.make @@ -0,0 +1,24 @@ +################################################## +### Docker Install Local Env +################################################## + +## Install docker locally +docker-install: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo apt-get update${EOL}" + -@sudo apt-get update + @printf "${INFO}sudo apt-get install -y docker.io${EOL}" + @sudo apt-get install -y docker.io + @printf "${INFO}sudo usermod -a -G docker ${USER}${EOL}" + @sudo usermod -a -G docker ${USER} + @printf "${INFO}sudo su ${USER}${EOL}" + @sudo su ${USER} +endif + +## Remove docker +docker-remove: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo apt-get remove -y docker.io${EOL}" + @sudo apt-get remove -y docker.io +endif + diff --git a/makefiles/docker_manager.make b/makefiles/docker_manager.make new file mode 100644 index 0000000..4730bd5 --- /dev/null +++ b/makefiles/docker_manager.make @@ -0,0 +1,47 @@ +################################################## +### Docker Manager +################################################## + +## List images, volumes and network information +top: + @printf "${INFO}docker ps --all${EOL}" + @docker ps --all + @printf "${INFO}docker images --all${EOL}" + @docker images --all + @printf "${INFO}docker volume ls${EOL}" + @docker volume ls + @printf "${INFO}docker network ls${EOL}" + @docker network ls + @printf "${INFO}docker inspect --format '{{ .Name }}: {{ .NetworkSettings.IPAddress }}' `docker ps --quiet | tr '\n' ' '` 2>/dev/null${EOL}" + @docker inspect --format '{{ .Name }}: {{ .NetworkSettings.IPAddress }}' `docker ps --quiet | tr '\n' ' '` 2>/dev/null + +## Stop all running containers +stop-all: + @printf "${INFO}docker stop `docker ps --quiet`${EOL}" + @docker stop `docker ps --quiet` + +## Kill all running containers +kill-all: + @printf "${INFO}docker kill `docker ps --quiet | tr '\n' ' '` 2>/dev/null${EOL}" + @docker kill `docker ps --quiet | tr '\n' ' '` 2>/dev/null + @printf "${INFO}docker rm `docker ps --all --quiet | tr '\n' ' '` 2>/dev/null${EOL}" + @docker rm `docker ps --all --quiet | tr '\n' ' '` 2>/dev/null + +## Remove all unused system, images, containers, volumes and networks +clean: + @printf "${INFO}docker system prune --force${EOL}" + @docker system prune --force + @printf "${INFO}docker image prune --all --force${EOL}" + @docker image prune --all --force + @printf "${INFO}docker container prune --force${EOL}" + @docker container prune --force + @printf "${INFO}docker volume prune --force${EOL}" + @docker volume prune --force + @printf "${INFO}docker network prune --force${EOL}" + @docker network prune --force + +## Kill and remove all system, images, containers, volumes and networks +remove-all: + -@make --no-print-directory -s kill-all + -@make --no-print-directory -s clean + diff --git a/makefiles/docker_network.make b/makefiles/docker_network.make new file mode 100644 index 0000000..6fb3bd5 --- /dev/null +++ b/makefiles/docker_network.make @@ -0,0 +1,37 @@ +################################################## +### Docker Network +################################################## + +## Create "tango" network +network: + @printf "${INFO}docker network create tango${EOL}" + -@docker network create tango + +## Remove "tango" network +remove-network: + @printf "${INFO}docker network rm tango${EOL}" + @docker network rm tango + +# print network information +network-info: + @printf "${INFO}docker network inspect ${network}${EOL}" + @docker network inspect ${network} + +## Enable bridge and port forwarding on host +bridge: + @if [ -z "$(shell brctl --version 2>/dev/null)" ]; then \ + printf "${INFO}sudo apt-get update${EOL}"; \ + sudo apt-get update; \ + printf "${INFO}sudo apt-get install -y bridge-utils${EOL}"; \ + sudo apt-get install -y bridge-utils; \ + fi + @printf "${INFO}sysctl net.ipv4.conf.all.forwarding=1${EOL}" + @sysctl net.ipv4.conf.all.forwarding=1 + @printf "${INFO}iptables -P FORWARD ACCEPT${EOL}" + @iptables -P FORWARD ACCEPT + +## Create macvlan on guest +macvlan: + @printf "${INFO}docker network create -d macvlan --subnet=192.168.1.1/24 --gateway=192.168.1.254 -o parent=${adapter} macvlan${EOL}" + @docker network create -d macvlan --subnet=192.168.1.1/24 --gateway=192.168.1.254 -o parent=${adapter} macvlan + diff --git a/makefiles/docker_postgresql.make b/makefiles/docker_postgresql.make new file mode 100644 index 0000000..5bd2c19 --- /dev/null +++ b/makefiles/docker_postgresql.make @@ -0,0 +1,14 @@ +#################################### +### Docker PostgreSQL +#################################### + +## Start database server from host +docker-psql-start: + @printf "${INFO}docker exec -u 0 ${container} service postgresql start${EOL}" + @docker exec -u 0 ${container} service postgresql start + +## Stop database server from host +docker-psql-stop: + @printf "${INFO}docker exec -u 0 ${container} service postgresql stop${EOL}" + @docker exec -u 0 ${container} service postgresql stop + diff --git a/makefiles/git.make b/makefiles/git.make new file mode 100644 index 0000000..aa22243 --- /dev/null +++ b/makefiles/git.make @@ -0,0 +1,11 @@ +################################################## +### Git +################################################## + +## Initialise git submodules +submodules: + @if [ -f ./.gitmodules ]; then \ + printf "${INFO}git submodule update --init --recursive${EOL}"; \ + git submodule update --init --recursive; \ + fi + diff --git a/makefiles/header/header_default.make b/makefiles/header/header_default.make new file mode 100644 index 0000000..3566257 --- /dev/null +++ b/makefiles/header/header_default.make @@ -0,0 +1,16 @@ +#/** +# * This file was generated with TangoMan Makefile Generator +# * https://github.com/TangoMan75/makefile-generator +# * +# * {{ PROJECT }} +# * +# * {{ DESCRIPTION }} +# * +# * @version {{ VERSION }} +# * @author "{{ AUTHOR }}" <{{ EMAIL }}> +# * @license {{ LICENSE }} +# * @link https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }} +# */ + +{{ PHONY }} + diff --git a/makefiles/header/help_default.make b/makefiles/header/help_default.make new file mode 100644 index 0000000..c6c3d34 --- /dev/null +++ b/makefiles/header/help_default.make @@ -0,0 +1,29 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} $(shell basename ${CURDIR}) ${EOL}\n" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "login" "$(shell whoami)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "system" "$(shell uname -s)" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_docker.make b/makefiles/header/help_docker.make new file mode 100644 index 0000000..e54738f --- /dev/null +++ b/makefiles/header/help_docker.make @@ -0,0 +1,31 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} ${container} ${EOL}" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "image" "${image}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "container" "${container}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "ethernet" "${default_ethernet}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "wifi" "${default_wifi}" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_makefile_generator.make b/makefiles/header/help_makefile_generator.make new file mode 100644 index 0000000..698a035 --- /dev/null +++ b/makefiles/header/help_makefile_generator.make @@ -0,0 +1,25 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} TangoMan Makefile Generator ${EOL}\n" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} Generate Makefiles with one single command${EOL}" + @printf "${PRIMARY} Prefix \"*.make\" files from \"./makefiles\" with underscore to concatenate${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_python.make b/makefiles/header/help_python.make new file mode 100644 index 0000000..cda3529 --- /dev/null +++ b/makefiles/header/help_python.make @@ -0,0 +1,31 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} $(shell basename ${CURDIR}) ${EOL}\n" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "filename" "${filename}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "virtualenv" "${virtualenv}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "arguments" "${arguments}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "port" "${port}" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_react.make b/makefiles/header/help_react.make new file mode 100644 index 0000000..668b5a9 --- /dev/null +++ b/makefiles/header/help_react.make @@ -0,0 +1,32 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} $(shell basename ${CURDIR}) ${EOL}\n" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "system" "$(shell uname -s)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "node" "$(shell node --version)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "npm" "$(shell npm --version)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "yarn" "$(shell yarn --version)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "port" "${port}" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_symfony-docker.make b/makefiles/header/help_symfony-docker.make new file mode 100644 index 0000000..e98d6b8 --- /dev/null +++ b/makefiles/header/help_symfony-docker.make @@ -0,0 +1,31 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} $(shell basename ${CURDIR}) ${EOL}\n" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "container" "${container}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "port" "${port}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "php" "${PHP_VERSION}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "symfony" "${VERSION}" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_symfony.make b/makefiles/header/help_symfony.make new file mode 100644 index 0000000..8ec4e6a --- /dev/null +++ b/makefiles/header/help_symfony.make @@ -0,0 +1,33 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} $(shell basename ${CURDIR}) ${EOL}\n" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "login" "$(shell whoami)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "system" "$(shell uname -s)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "httpduser" "${HTTPDUSER}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "port" "${port}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "php" "${PHP_VERSION}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "Symfony" "${VERSION}" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_vue.make b/makefiles/header/help_vue.make new file mode 100644 index 0000000..668b5a9 --- /dev/null +++ b/makefiles/header/help_vue.make @@ -0,0 +1,32 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "${LIGHT} {{ PROJECT }} $(shell basename ${CURDIR}) ${EOL}\n" + + @printf "${WARNING}Infos${EOL}" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "system" "$(shell uname -s)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "node" "$(shell node --version)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "npm" "$(shell npm --version)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "yarn" "$(shell yarn --version)" + @printf "${SUCCESS} %-{{ PADDING }}s${INFO} %s${EOL}" "port" "${port}" + @printf "${EOL}" + + @printf "${WARNING}Description${EOL}" + @printf "${PRIMARY} {{ DESCRIPTION }}${EOL}\n" + + @printf "${WARNING}Usage${EOL}" + @printf "${PRIMARY} make [command] `awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"%s=[%s]\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq|tr '\n' ' '`${EOL}\n" + + @printf "${WARNING}Config${EOL}" + $(eval CONFIG:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf"$${SECONDARY} %-12s$${DEFAULT} $${INFO}$${%s}$${EOL}\n",$$1,$$1}' ${MAKEFILE_LIST}|sort|uniq)) + @printf " ${CONFIG}\n" + + @printf "${WARNING}Commands${EOL}" + @awk '/^### /{printf"\n${WARNING}%s${EOL}",substr($$0,5)} \ + /^[a-zA-Z0-9_-]+:/{HELP="";if( match(PREV,/^## /))HELP=substr(PREV, 4); \ + printf "${SUCCESS} %-12s ${PRIMARY}%s${EOL}",substr($$1,0,index($$1,":")-1),HELP \ + }{PREV=$$0}' ${MAKEFILE_LIST} + diff --git a/makefiles/header/help_xs.make b/makefiles/header/help_xs.make new file mode 100644 index 0000000..0283b0f --- /dev/null +++ b/makefiles/header/help_xs.make @@ -0,0 +1,14 @@ +#-------------------------------------------------- +# Help +#-------------------------------------------------- + +## Print this help +help: + @printf "\033[1;41m TangoMan $(shell basename ${CURDIR}) \033[0\n" + + @printf "\033[1;44m Description\033[0\n" + @printf "\033[33m {{ DESCRIPTION }}\033[0\n" + + @printf "\033[1;44m Commands\033[0\n" + @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' + diff --git a/makefiles/makefile_generator.make b/makefiles/makefile_generator.make new file mode 100644 index 0000000..7ee1abf --- /dev/null +++ b/makefiles/makefile_generator.make @@ -0,0 +1,176 @@ +################################################## +### Generator +################################################## + +## Generate all +generate: + -@make --no-print-directory makefile + -@make --no-print-directory phony + -@make --no-print-directory readme + -@make --no-print-directory license + -@make --no-print-directory changelog + -@make --no-print-directory code + -@make --no-print-directory contrib + -@make --no-print-directory ci-cd + +## Generate "Makefile" +makefile: init +ifeq ($(shell test ! -d ./makefiles && echo true),true) + @printf "${DANGER}error: \"./makefiles\" source folder not found${EOL}" + @exit 1 +endif + + @printf "${PRIMARY}print header block${EOL}" +ifeq ($(shell test -f ./makefiles/header/_header*.make && echo true),true) + @printf "${INFO}cp ./makefiles/header/_header*.make ./build/${filename}${EOL}" + @cp ./makefiles/header/_header*.make ./build/${filename} +else + @printf "${INFO}cp ./makefiles/header/header_default.make ./build/${filename}${EOL}" + @cp ./makefiles/header/header_default.make ./build/${filename} +endif + + @printf "${PRIMARY}print colors${EOL}" +ifeq ($(shell test ! -f ./makefiles/vars/_colors.make && echo true),true) + @printf "${INFO}cat ./makefiles/vars/colors_default.make >> ./build/${filename}${EOL}" + -@cat ./makefiles/vars/colors_default.make >> ./build/${filename} +endif + + @printf "${PRIMARY}print vars block${EOL}" +ifeq ($(shell ! test -f ./makefiles/vars/_*.make && echo true),true) + @printf "${WARNING}no templates found in \"./makefiles/vars\"${EOL}" +else + @printf "${INFO}cat ./makefiles/vars/_*.make >> ./build/${filename}${EOL}" + -@cat ./makefiles/vars/_*.make >> ./build/${filename} +endif + + @printf "${PRIMARY}print help block${EOL}" +ifeq ($(shell test -f ./makefiles/header/_help*.make && echo true),true) + @printf "${INFO}cat ./makefiles/header/_help*.make >> ./build/${filename}${EOL}" + -@cat ./makefiles/header/_help*.make >> ./build/${filename} +else + @printf "${INFO}cat ./makefiles/header/help_default.make >> ./build/${filename}${EOL}" + -@cat ./makefiles/header/help_default.make >> ./build/${filename} +endif + + @printf "${PRIMARY}print makefile rules block${EOL}" +ifeq ($(shell test -f ./makefile/_*.make && echo true),true) + @printf "${WARNING}no templates found in \"./makefiles\"${EOL}" +else + @printf "${INFO}cat ./makefiles/_*.make >> ./build/${filename}${EOL}" + -@cat ./makefiles/_*.make >> ./build/${filename} +endif + #@ can't read from file while writing in the same rule apparently + @$(eval phony:=".PHONY:") + + @$(call render,./build/${filename}) + @printf "${SUCCESS}${filename} generated.${EOL}" + +## Update ".PHONY:" rule +phony: + @printf "${PRIMARY}update phony rule${EOL}" + @$(call get_phony,./build/${filename}) + @$(eval phony:=.PHONY: ${phony}) + @printf "${PRIMARY}${phony}${EOL}" + @sed -i s/"^\.PHONY:.*"/"${phony}"/g ./build/${filename} + +## Generate "README.md" +readme: init + @printf "${INFO}cp ./templates/README.md ./build/README.md${EOL}" + @cp ./templates/README.md ./build/README.md +ifeq ($(shell test -f ./build/${filename} && echo true),true) + @printf "${INFO}get phony${EOL}" + @$(call get_phony,./build/${filename}) + @printf "${INFO}$(phony)${EOL}" + + @printf "${INFO}get usage${EOL}" + @$(call get_usage,./build/${filename}) + @printf "${INFO}$(usage)${EOL}" + + @printf "${INFO}get markdown${EOL}" + @printf "${INFO}$(shell awk '/^### /{printf"### %s\\n",substr($$0, 5)}/^[a-zA-Z0-9_-]+:/{if(match(PREV,/^## /)) HELP=substr(PREV,4);else HELP="";RULE=substr($$1,0,index($$1,":")-1);printf"#### ⚡ %s\\n\\`\\`\\`bash\\n$$ make %s\\n\\`\\`\\`\\n\\n",HELP,RULE}{PREV=$$0}' ./build/${filename} | tr '/' '-')${EOL}" + @sed -i s/'{{ MARKDOWN }}'/"$(shell awk '/^### /{printf"### %s\\n",substr($$0, 5)}/^[a-zA-Z0-9_-]+:/{if(match(PREV,/^## /)) HELP=substr(PREV,4);else HELP="";RULE=substr($$1,0,index($$1,":")-1);printf"#### ⚡ %s\\n\\`\\`\\`bash\\n$$ make %s\\n\\`\\`\\`\\n\\n",HELP,RULE}{PREV=$$0}' ./build/${filename} | tr '/' '-')"/g ./build/README.md +endif + @$(call render,./build/README.md) + @printf "${SUCCESS}README.md generated.${EOL}" + +## Generate "LICENSE" +license: init +ifeq ($(shell echo ${license}),Apache) + @printf "${INFO}cp ./templates/APACHE.txt ./build/LICENSE${EOL}" + @cp ./templates/APACHE.txt ./build/LICENSE +endif +ifeq ($(shell echo ${license}),GPL2) + @printf "${INFO}cp ./templates/GPL2.txt ./build/LICENSE${EOL}" + @cp ./templates/GPL2.txt ./build/LICENSE +endif +ifeq ($(shell echo ${license}),GPL3) + @printf "${INFO}cp ./templates/GPL3.txt ./build/LICENSE${EOL}" + @cp ./templates/GPL3.txt ./build/LICENSE +endif +ifeq ($(shell echo ${license}),MIT) + @printf "${INFO}cp ./templates/MIT.txt ./build/LICENSE${EOL}" + @cp ./templates/MIT.txt ./build/LICENSE +endif + @$(call render,./build/LICENSE) + @printf "${SUCCESS}LICENSE generated.${EOL}" + +## Generate "CHANGELOG.md" +changelog: init + @printf "${INFO}cp ./templates/CHANGELOG.md ./build/CHANGELOG.md${EOL}" + @cp ./templates/CHANGELOG.md ./build/CHANGELOG.md + @$(call render,./build/CHANGELOG.md) + @printf "${SUCCESS}CHANGELOG.md generated.${EOL}" + +## Generate "CODE_OF_CONDUCT.md" +code: init + @printf "${INFO}cp ./templates/CODE_OF_CONDUCT.md ./build/CODE_OF_CONDUCT.md${EOL}" + @cp ./templates/CODE_OF_CONDUCT.md ./build/CODE_OF_CONDUCT.md + @$(call render,./build/CODE_OF_CONDUCT.md) + @printf "${SUCCESS}CODE_OF_CONDUCT.md generated.${EOL}" + +## Generate "CONTRIBUTING.md" +contrib: init + @printf "${INFO}cp ./templates/CONTRIBUTING.md ./build/CONTRIBUTING.md${EOL}" + @cp ./templates/CONTRIBUTING.md ./build/CONTRIBUTING.md + @$(call render,./build/CONTRIBUTING.md) + @printf "${SUCCESS}CONTRIBUTING.md generated.${EOL}" + +## Copy CI/CD tools +ci-cd: init + @printf "${INFO}cp -r ./templates/.github ./build/${EOL}" + @cp -r ./templates/.github ./build/ + @printf "${SUCCESS}.github copied.${EOL}" + @printf "${INFO}cp ./templates/run_linter.sh ./build/${EOL}" + @cp ./templates/run_linter.sh ./build/ + @printf "${SUCCESS}run_linter.sh copied.${EOL}" + @printf "${INFO}cp ./templates/run_tests.sh ./build/${EOL}" + @cp ./templates/run_tests.sh ./build/ + @printf "${SUCCESS}run_tests.sh copied.${EOL}" + +## Create "config.yaml" and "./build" folder +init: +ifeq ($(shell test ! -d ./build && echo true),true) + @printf "${INFO}mkdir ./build${EOL}" + @mkdir ./build +endif +ifeq ($(shell test ! -f ./config.yaml && echo true),true) + @if [ -f ./config.yaml.dist ]; then \ + printf "${INFO}cp ./config.yaml.dist ./config.yaml${EOL}"; \ + cp ./config.yaml.dist ./config.yaml; \ + fi + @$(call render,./config.yaml) +endif + +## Remove "config.yml" "./build" and all "_template.make" files +clean: + @printf "${INFO}rm config.yaml${EOL}" + -@rm config.yaml + @printf "${INFO}rm -rf ./build${EOL}" + -@rm -rf ./build + @printf "${INFO}rm ./makefiles/_*.make${EOL}" + -@rm ./makefiles/_*.make + @printf "${INFO}rm ./makefiles/header/_*.make${EOL}" + -@rm ./makefiles/header/_*.make + @printf "${INFO}rm ./makefiles/vars/_*.make${EOL}" + -@rm ./makefiles/vars/_*.make + diff --git a/makefiles/nginx_docker.make b/makefiles/nginx_docker.make new file mode 100644 index 0000000..56fa66f --- /dev/null +++ b/makefiles/nginx_docker.make @@ -0,0 +1,11 @@ +############################################## +### Nginx Docker +############################################## + +## Validate nginx configuration +validate: +# @printf "${INFO}docker-compose exec nginx sh -c \"nginx -c /etc/nginx/nginx.conf -t\"${EOL}" +# @docker-compose exec nginx sh -c "nginx -c /etc/nginx/nginx.conf -t" + @printf "${INFO}docker-compose exec nginx sh -c \"nginx -t\"${EOL}" + @docker-compose exec nginx sh -c "nginx -t" + diff --git a/makefiles/php_server.make b/makefiles/php_server.make new file mode 100644 index 0000000..0c4cde9 --- /dev/null +++ b/makefiles/php_server.make @@ -0,0 +1,16 @@ +############################################## +### PHP Server +############################################## + +## Run local server and open in browser +serve: +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}start \"http://localhost:${port}\"${EOL}" + -@start "http://localhost:${port}" +else + @printf "${INFO}nohup xdg-open http://localhost:${port} >/dev/null 2>&1${EOL}" + -@nohup xdg-open http://localhost:${port} >/dev/null 2>&1 +endif + @printf "${INFO}php -d memory-limit=-1 -S localhost:${port} -t ${PUBLIC}${EOL}" + @php -d memory-limit=-1 -S localhost:${port} -t ${PUBLIC} + diff --git a/makefiles/postgresql.make b/makefiles/postgresql.make new file mode 100644 index 0000000..4d3eaee --- /dev/null +++ b/makefiles/postgresql.make @@ -0,0 +1,14 @@ +#################################### +### PostgreSQL +#################################### + +## Start database server as postgres user +psql-start: + @printf "${INFO}/usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main -c config_file=/etc/postgresql/11/main/postgresql.conf${EOL}" + @/usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main -c config_file=/etc/postgresql/11/main/postgresql.conf + +## Stop database server +psql-stop: + @printf "${INFO}service postgresql stop${EOL}" + @service postgresql stop + diff --git a/makefiles/python_cache.make b/makefiles/python_cache.make new file mode 100644 index 0000000..0853537 --- /dev/null +++ b/makefiles/python_cache.make @@ -0,0 +1,11 @@ +################################################## +### Python3 Cache +################################################## + +## Clear python cache +cache: + @printf "${INFO}find . -type d -name __pycache__ | xargs rm -rf${EOL}" + @find . -type d -name __pycache__ | xargs rm -rf + @printf "${INFO}find . -type f -iname \"*.pyc\" -delete${EOL}" + @find . -type f -iname "*.pyc" -delete + diff --git a/makefiles/python_check_install.make b/makefiles/python_check_install.make new file mode 100644 index 0000000..7d8e9b0 --- /dev/null +++ b/makefiles/python_check_install.make @@ -0,0 +1,43 @@ +################################################## +### Check Python install +################################################## + +## Check correct python environment installation +check-install: + @if [ -n "$(shell pip --version 2>/dev/null)" ]; then \ + printf "${INFO}pip --version${EOL}"; \ + pip --version; \ + else \ + printf "${WARNING}pip is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell pip3 --version 2>/dev/null)" ]; then \ + printf "${INFO}pip3 --version${EOL}"; \ + pip3 --version; \ + else \ + printf "${WARNING}pip3 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell python --version 2>/dev/null)" ]; then \ + printf "${INFO}python --version${EOL}"; \ + python --version; \ + else \ + printf "${WARNING}python is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell python2 --version 2>/dev/null)" ]; then \ + printf "${INFO}python2 --version${EOL}"; \ + python2 --version; \ + else \ + printf "${WARNING}python2 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell python3 --version 2>/dev/null)" ]; then \ + printf "${INFO}python3 --version${EOL}"; \ + python3 --version; \ + else \ + printf "${WARNING}python3 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell virtualenv --version 2>/dev/null)" ]; then \ + printf "${INFO}virtualenv --version${EOL}"; \ + virtualenv --version; \ + else \ + printf "${WARNING}virtualenv is not installed on your system${EOL}"; \ + fi + diff --git a/makefiles/python_cli.make b/makefiles/python_cli.make new file mode 100644 index 0000000..1c834fb --- /dev/null +++ b/makefiles/python_cli.make @@ -0,0 +1,21 @@ +################################################## +### Python3 CLI +################################################## + +## Install +install: + @printf "${INFO}python3 -m pip install --upgrade pip${EOL}" + @python3 -m pip install --upgrade pip + @printf "${INFO}python3 -m pip install -r requirements.txt${EOL}" + @python3 -m pip install -r requirements.txt + +## Start app +run: + @printf "${INFO}python3 ${filename} ${arguments}${EOL}" + @python3 ${filename} ${arguments} + +## Generate requirements.txt +freeze: + @printf "${INFO}python3 -m pip freeze > requirements.txt${EOL}" + @python3 -m pip freeze > requirements.txt + diff --git a/makefiles/python_flask.make b/makefiles/python_flask.make new file mode 100644 index 0000000..15d8d51 --- /dev/null +++ b/makefiles/python_flask.make @@ -0,0 +1,24 @@ +################################################## +### Python Flask +################################################## + +## Deploy and start Flask app locally with one command +up: install serve + +## Open default browser Serve app with gunicorn at localhost +serve: +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}start \"http://localhost:${port}\"${EOL}" + -@start "http://localhost:${port}" +else + @printf "${INFO}nohup xdg-open http://localhost:${port} >/dev/null 2>&1${EOL}" + -@nohup xdg-open http://localhost:${port} >/dev/null 2>&1 +endif + @printf "${INFO}gunicorn --bind 0.0.0.0:${port} `basename ${filename} .py`:`basename ${filename} .py`${EOL}" + @gunicorn --bind 0.0.0.0:${port} `basename ${filename} .py`:`basename ${filename} .py` + +## Kill gunicorn server +stop: + @printf "${INFO}pkill gunicorn${EOL}" + -@pkill gunicorn + diff --git a/makefiles/python_install_env.make b/makefiles/python_install_env.make new file mode 100644 index 0000000..ae01cbb --- /dev/null +++ b/makefiles/python_install_env.make @@ -0,0 +1,24 @@ +################################################## +### Python3 Local Install +################################################## + +## Install development environment locally (python3, pip3 and virtualenv) +python-install: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo apt-get update${EOL}" + -@sudo apt-get update + @printf "${INFO}sudo apt-get install -y python3${EOL}" + @sudo apt-get install -y python3 + @printf "${INFO}sudo apt-get install -y python3-pip${EOL}" + @sudo apt-get install -y python3-pip + @printf "${INFO}python3 -m pip install --upgrade pip${EOL}" + @python3 -m pip install --upgrade pip + @printf "${INFO}sudo apt-get install -y python-virtualenv${EOL}" + @sudo apt-get install -y python-virtualenv +endif + +## Update all pip packages locally +pip-update: + @printf "${INFO}python3 -m pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 python3 -m pip install -U${EOL}" + @python3 -m pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 python3 -m pip install -U + diff --git a/makefiles/python_module_install.make b/makefiles/python_module_install.make new file mode 100644 index 0000000..f5a34b0 --- /dev/null +++ b/makefiles/python_module_install.make @@ -0,0 +1,20 @@ +################################################## +### Python3 Module +################################################## + +## Install module locally +install: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo python3 setup.py install${EOL}" + -@sudo python3 setup.py install +endif + +## Uninstall module +uninstall: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo pip3 uninstall -y $(shell basename ${CURDIR})${EOL}" + -@sudo pip3 uninstall -y $(shell basename ${CURDIR}) + @printf "${INFO}sudo rm -rf build dist *.egg-info${EOL}" + @sudo rm -rf build dist *.egg-info +endif + diff --git a/makefiles/python_server.make b/makefiles/python_server.make new file mode 100644 index 0000000..ea46d49 --- /dev/null +++ b/makefiles/python_server.make @@ -0,0 +1,16 @@ +############################################## +### Python Server +############################################## + +## Run server +serve: + @printf "${INFO}python2 -m SimpleHTTPServer ${port}${EOL}" + @python2 -m SimpleHTTPServer ${port} +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}start \"http://localhost:${port}\"${EOL}" + -@start "http://localhost:${port}" +else + @printf "${INFO}nohup xdg-open http://localhost:${port} >/dev/nul 2>&1${EOL}" + -@nohup xdg-open http://localhost:${port} >/dev/nul 2>&1 +endif + diff --git a/makefiles/python_unittest.make b/makefiles/python_unittest.make new file mode 100644 index 0000000..30cb7f3 --- /dev/null +++ b/makefiles/python_unittest.make @@ -0,0 +1,20 @@ +################################################## +### Python3 Unit Test +################################################## + +## Run unit tests +tests: + @printf "${INFO}python3 -m unittest -v tests/*.py${EOL}" + @python3 -m unittest -v tests/*.py + +## Check static typing with mypy +lint: + @# Check mypy module installed + @python3 -c 'import mypy' + @if [ $? == 0 ]; then \ + printf "${INFO}python3 -m mypy${EOL}" && \ + python3 -m mypy; \ + else \ + printf "${INFO}mypy module not found${EOL}"; \ + fi + diff --git a/makefiles/python_venv.make b/makefiles/python_venv.make new file mode 100644 index 0000000..b30c501 --- /dev/null +++ b/makefiles/python_venv.make @@ -0,0 +1,63 @@ +################################################## +### Python Virtualenv +################################################## + +## Start +venv-run: +ifeq ($(shell test -f ${virtualenv}/bin/python && echo true),true) + @printf "${INFO}venv/bin/python ${filename}${EOL}" + @venv/bin/python ${filename} +else + @printf "${DANGER}error: virtualenv not found${EOL}" + @exit 1 +endif + +## Create virtualenv +venv-create: venv-remove + @printf "${INFO}virtualenv -p python3 ${virtualenv}${EOL}" + @virtualenv -p python3 ${virtualenv} + -@make --no-print-directory venv-start + -@make --no-print-directory venv-install + +## Activate virtualenv +venv-start: +ifeq ($(shell test -f ${virtualenv}/bin/activate && echo true),true) + @printf "${INFO}source ${virtualenv}/bin/activate${EOL}" + @source ${virtualenv}/bin/activate +else + @printf "${DANGER}error: virtualenv not found${EOL}" + @exit 1 +endif + +## Deactivate virtualenv +venv-stop: + @printf "${INFO}bash -c \"source ${virtualenv}/bin/activate && deactivate\"${EOL}" + -@bash -c "source ${virtualenv}/bin/activate && deactivate" + +## Run tests from virtualenv +venv-tests: +ifeq ($(shell test -f ${virtualenv}/bin/python && echo true),true) + @printf "${INFO}venv/bin/python -m unittest -v tests/*.py${EOL}" + @venv/bin/python -m unittest -v tests/*.py +else + @printf "${DANGER}error: virtualenv not found${EOL}" + @exit 1 +endif + +## Install in virtualenv +venv-install: +ifeq ($(shell test -f ${virtualenv}/bin/pip && echo true),true) + @printf "${INFO}${virtualenv}/bin/pip install -r requirements.txt${EOL}" + @${virtualenv}/bin/pip install -r requirements.txt +else + @printf "${DANGER}error: virtualenv not found${EOL}" + @exit 1 +endif + +## Remove virtualenv +venv-remove: venv-stop + @printf "${INFO}rm -rf ${virtualenv}${EOL}" + @rm -rf ${virtualenv} + @printf "${INFO}rm -rf __pycache__${EOL}" + @rm -rf __pycache__ + diff --git a/makefiles/python_venv_flask.make b/makefiles/python_venv_flask.make new file mode 100644 index 0000000..01dc2e6 --- /dev/null +++ b/makefiles/python_venv_flask.make @@ -0,0 +1,24 @@ +################################################## +### Python Virtualenv Flask +################################################## + +## Deploy and start your Flask app in fresh virtualenv with one command +venv-up: venv-create + @printf "${INFO}sleep 1${EOL}" + @sleep 1 + -@make --no-print-directory venv-serve + +## Serve app with gunicorn from virtualenv +venv-serve: +ifeq ($(shell test -f ${virtualenv}/bin/gunicorn && echo true),true) + @printf "${INFO}app listening here: http://localhost:${port}${EOL}" + @printf "${INFO}${virtualenv}/bin/gunicorn --bind 0.0.0.0:${port} `basename ${filename} .py`:`basename ${filename} .py`${EOL}" + @${virtualenv}/bin/gunicorn --bind 0.0.0.0:${port} `basename ${filename} .py`:`basename ${filename} .py` +else + @printf "${DANGER}error: virtualenv not found${EOL}" + @exit 1 +endif + +## Kill gunicorn server and remove virtualenv +venv-kill: stop venv-remove + diff --git a/makefiles/react.make b/makefiles/react.make new file mode 100644 index 0000000..6b21fb4 --- /dev/null +++ b/makefiles/react.make @@ -0,0 +1,65 @@ +################################################## +### React +################################################## + +## Install and serve locally +up: install serve + +## Install dependencies +install: + @if [ ! -d node_modules ]; then \ + printf "${INFO}yarn install${EOL}"; \ + yarn install; \ + fi + +## Serve with hot reload at localhost +serve: + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn start${EOL}"; \ + yarn start; \ + fi + +## Run unit tests +tests: + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn run test:unit${EOL}"; \ + yarn run test:unit; \ + fi + +## Lint and fix files +lint: + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn run lint${EOL}"; \ + yarn run lint; \ + fi + +## Build for production with minification +build: + @printf "${INFO}rm -rf ./dist${EOL}" + @rm -rf ./dist + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn build${EOL}"; \ + yarn build; \ + fi + +## Deploy to gh-pages +deploy: build + ( \ + printf "${INFO}cd dist${EOL}"; \ + cd dist; \ + printf "${INFO}git init${EOL}"; \ + git init; \ + printf "${INFO}git add -A${EOL}"; \ + git add -A; \ + printf "${INFO}git commit -m "$(shell date '+%Y-%m-%d %H:%M:%S')"${EOL}"; \ + git commit -m "$(shell date '+%Y-%m-%d %H:%M:%S')"; \ + printf "${INFO}git push -f git@{{ GIT_SERVER }}:{{ GIT_USER }}/{{ REPOSITORY }}.git main:gh-pages${EOL}"; \ + git push -f git@{{ GIT_SERVER }}:{{ GIT_USER }}/{{ REPOSITORY }}.git main:gh-pages; \ + ) + +## Uninstall app +uninstall: + @printf "${INFO}sudo rm -rf node_modules${EOL}" + @sudo rm -rf node_modules + @printf "${INFO}sudo rm -rf dist${EOL}" + @sudo rm -rf dist diff --git a/makefiles/react_docker.make b/makefiles/react_docker.make new file mode 100644 index 0000000..28e737e --- /dev/null +++ b/makefiles/react_docker.make @@ -0,0 +1,16 @@ +################################################## +### React Docker +################################################## + +## Create network, build, start docker, yarn install and serve +up: network build start + +## Open a terminal in the node container +shell: + @printf "${INFO}docker-compose exec node sh${EOL}" + @docker-compose exec node sh + +## Open in default browser +open: + @printf "${INFO}nohup xdg-open `docker inspect startups-admin --format 'http://{{.NetworkSettings.Networks.tango.IPAddress}}:3000' 2>/dev/null` >/dev/null 2>&1${EOL}" + @nohup xdg-open `docker inspect startups-admin --format 'http://{{.NetworkSettings.Networks.tango.IPAddress}}:3000' 2>/dev/null` >/dev/null 2>&1 diff --git a/makefiles/sass.make b/makefiles/sass.make new file mode 100644 index 0000000..d5c14bf --- /dev/null +++ b/makefiles/sass.make @@ -0,0 +1,14 @@ +################################################## +### Sass +################################################## + +## Compile scss +sass: + @printf "${INFO}sass assets/scss/index.scss public/css/index.css${EOL}" + @sass assets/scss/index.scss public/css/index.css + +## Watch scss folder +watch: + @printf "${INFO}sass --watch assets/scss:public/css${EOL}" + @sass --watch assets/scss:public/css + diff --git a/makefiles/sass_install.make b/makefiles/sass_install.make new file mode 100644 index 0000000..a760d86 --- /dev/null +++ b/makefiles/sass_install.make @@ -0,0 +1,16 @@ +################################################## +### Sass +################################################## + +## Install standalone Sass globally +sass-install: + @if [ -x "`command -v yarn`" ]; then \ + printf "${INFO}sudo yarn global add sass${EOL}"; \ + sudo yarn global add sass; \ + elif [ -x "`command -v npm`" ]; then \ + printf "${INFO}sudo npm install -g sass${EOL}"; \ + sudo npm install -g sass; \ + else \ + printf "${DANGER}error: yarn and npm missing, skipping...${EOL}"; \ + fi; + diff --git a/makefiles/symfony_app.make b/makefiles/symfony_app.make new file mode 100644 index 0000000..2b51591 --- /dev/null +++ b/makefiles/symfony_app.make @@ -0,0 +1,27 @@ +################################################## +### Symfony App +################################################## + +## Install Symfony application locally +install: cp-install db-create + +## Remove .env, *.lock, var/data.db, vendor, var/cache, var/log, var/sessions +uninstall: + @printf "${INFO}sudo rm -f .env${EOL}" + @sudo rm -f .env + @printf "${INFO}sudo rm -f ./composer.lock${EOL}" + @sudo rm -f ./composer.lock + @printf "${INFO}sudo rm -f ./symfony.lock${EOL}" + @sudo rm -f ./symfony.lock + @printf "${INFO}sudo rm -f ./var/data.db${EOL}" + @sudo rm -f ./var/data.db + @printf "${INFO}sudo rm -f composer${EOL}" + @sudo rm -f composer + @printf "${INFO}sudo rm -f installer${EOL}" + @sudo rm -f installer + @printf "${INFO}sudo rm -f symfony${EOL}" + @sudo rm -f symfony + @printf "${INFO}sudo rm -rf ./vendor${EOL}" + @sudo rm -rf ./vendor + @make --no-print-directory cache + diff --git a/makefiles/symfony_bundle.make b/makefiles/symfony_bundle.make new file mode 100644 index 0000000..cc7a01f --- /dev/null +++ b/makefiles/symfony_bundle.make @@ -0,0 +1,41 @@ +################################################## +### Symfony Bundle +################################################## + +## Run tests +tests: + @if [ ! -d ./vendor ]; then \ + make --no-print-directory cp-install; \ + fi + @if [ -x ./bin/phpunit ]; then \ + php -d memory-limit=-1 ./bin/phpunit --stop-on-failure; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + bash ./vendor/bin/phpunit --stop-on-failure; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + php -d memory-limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure; \ + else \ + printf 'error: phpunit executable not found\n'; \ + exit 1; \ + fi + +## Dump coverage (requires XDebug) +coverage: + @if [ ! -d ./vendor ]; then \ + make --no-print-directory cp-install; \ + fi + @if [ -x ./bin/phpunit ]; then \ + php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage; \ + else \ + printf 'error: phpunit executable not found\n'; \ + exit 1; \ + fi +ifeq (${SYSTEM}, Windows_NT) + start "${PUBLIC}/coverage/index.html" +else + nohup xdg-open "${PUBLIC}/coverage/index.html" >/dev/null 2>&1 +endif + diff --git a/makefiles/symfony_check.make b/makefiles/symfony_check.make new file mode 100644 index 0000000..115d62a --- /dev/null +++ b/makefiles/symfony_check.make @@ -0,0 +1,104 @@ +#################################### +### Symfony Check +#################################### + +## Check correct environment installation +check: + @printf "${INFO}whoami${EOL}" + @whoami + @if [ -n "$(shell lsb_release -a 2>/dev/null)" ]; then \ + printf "${INFO}lsb_release -a${EOL}"; \ + lsb_release -a; \ + fi + @if [ -n "$(shell uname -a 2>/dev/null)" ]; then \ + printf "${INFO}uname -a${EOL}"; \ + uname -a; \ + fi + @if [ -n "$(shell docker --version 2>/dev/null)" ]; then \ + printf "${INFO}docker --version${EOL}"; \ + docker --version; \ + else \ + printf "${WARNING}docker is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell docker-compose --version 2>/dev/null)" ]; then \ + printf "${INFO}docker-compose --version${EOL}"; \ + docker-compose --version; \ + else \ + printf "${WARNING}docker-compose is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell psql --version 2>/dev/null)" ]; then \ + printf "${INFO}psql --version${EOL}"; \ + psql --version; \ + printf "${INFO}service postgresql status${EOL}"; \ + service postgresql status; \ + else \ + printf "${WARNING}PostgreSQL is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell mysql --version 2>/dev/null)" ]; then \ + printf "${INFO}mysql --version${EOL}"; \ + mysql --version; \ + else \ + printf "${WARNING}MySQL is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell php --version 2>/dev/null)" ]; then \ + printf "${INFO}php --version${EOL}"; \ + php --version; \ + else \ + printf "${WARNING}PHP is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell php-fpm --version 2>/dev/null)" ]; then \ + printf "${INFO}php-fpm --version${EOL}"; \ + php-fpm --version; \ + else \ + printf "${WARNING}PHP-fpm is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell php --version 2>/dev/null)" ]; then \ + if [ -x "$(shell which composer 2>/dev/null)" ]; then \ + printf "${INFO}$(shell which composer) --version${EOL}"; \ + $(shell which composer) --version; \ + else \ + printf "${WARNING}composer is not installed on your system${EOL}"; \ + fi; \ + else \ + printf "${WARNING}unable to show composer version, php not installed${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep curl 2>/dev/null)" ]; then \ + printf "${SUCCESS}php curl module is installed${EOL}"; \ + else \ + printf "${DANGER}php curl module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep gd 2>/dev/null)" ]; then \ + printf "${SUCCESS}php gd module is installed${EOL}"; \ + else \ + printf "${DANGER}php gd module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep intl 2>/dev/null)" ]; then \ + printf "${SUCCESS}php intl module is installed${EOL}"; \ + else \ + printf "${DANGER}php intl module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep mbstring 2>/dev/null)" ]; then \ + printf "${SUCCESS}php mbstring module is installed${EOL}"; \ + else \ + printf "${DANGER}php mbstring module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep mysql 2>/dev/null)" ]; then \ + printf "${SUCCESS}php mysql module is installed${EOL}"; \ + else \ + printf "${WARNING}php mysql module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep pgsql 2>/dev/null)" ]; then \ + printf "${SUCCESS}php pgsql module is installed${EOL}"; \ + else \ + printf "${WARNING}php pgsql module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep sqlite3 2>/dev/null)" ]; then \ + printf "${SUCCESS}php sqlite3 module is installed${EOL}"; \ + else \ + printf "${WARNING}php sqlite3 module is missing${EOL}"; \ + fi + @if [ -n "$(shell php -m | grep xml 2>/dev/null)" ]; then \ + printf "${SUCCESS}php xml module is installed${EOL}"; \ + else \ + printf "${DANGER}php xml module is missing${EOL}"; \ + fi diff --git a/makefiles/symfony_cli_docker_container.make b/makefiles/symfony_cli_docker_container.make new file mode 100644 index 0000000..b55d548 --- /dev/null +++ b/makefiles/symfony_cli_docker_container.make @@ -0,0 +1,69 @@ +################################################## +### Symfony CLI Docker Container (deprecated) +################################################## + +## Build container +build: +ifeq ($(shell test -f ./${image} && echo true),true) + @printf "${INFO}docker build . -f ${image} -t ${container}${EOL}" + @docker build . -f ${image} -t ${container} +else + @printf "${WARNING}Dockerfile not found, skipping${EOL}" +endif + +## Start container and bind host CWD with given guest path +start: +ifeq (${workdir},) + @printf "${INFO}docker run --detach --name ${container} --network ${network} --rm -P ${container}${EOL}" + @docker run --detach --name ${container} --network ${network} --rm -P ${container} +else + @printf "${INFO}docker run --volume \"$(PWD)\":${workdir} --detach --name ${container} --network ${network} --rm -P ${container}${EOL}" + @docker run --volume "$(PWD)":${workdir} --detach --name ${container} --network ${network} --rm -P ${container} +endif + +## Open shell as root into running container +shell: + @printf "${INFO}docker exec -u 0 -it ${container} /bin/bash${EOL}" + @docker exec -u 0 -it ${container} /bin/bash + +## Run local server and open in browser +serve: + @printf "${INFO}sleep 1${EOL}" + @sleep 1 + @make --no-print-directory open + @printf "${INFO}docker exec -u 0 -it ${container} php -S 0.0.0.0:${port} -t ${PUBLIC}${EOL}" + @docker exec -u 0 -it ${container} php -S 0.0.0.0:${port} -t ${PUBLIC} + +## Open in default browser +open: +ifeq ($(shell docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null),) + @printf "${INFO}nohup xdg-open http://localhost${app_route} >/dev/null 2>&1${EOL}" + @nohup xdg-open http://localhost${app_route} >/dev/null 2>&1 +else + @printf "${INFO}nohup xdg-open http://`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`${app_route} >/dev/null 2>&1${EOL}" + @nohup xdg-open http://`docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${container}`${app_route} >/dev/null 2>&1 +endif + +## Print image status +status: + @printf "${SUCCESS}image: ${INFO}%s${EOL}" "`docker inspect --format '{{ .Config.Image }}' ${container} 2>/dev/null`" + @printf "${SUCCESS}hostname: ${INFO}%s${EOL}" "`docker inspect --format '{{ .Config.Hostname }}' ${container} 2>/dev/null`" +ifneq ($(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null),) + @printf "${SUCCESS}ip address: ${INFO}%s${EOL}" "`docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null`" + @printf "${SUCCESS}open ports: ${INFO}%s${EOL}" "`docker port ${container} 2>/dev/null`" + @printf "${SUCCESS}local url: ${INFO}http://%s${EOL}" "`docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${container} 2>/dev/null`" +else + @if [ ${network} != 'host' ]; then \ + printf "${SUCCESS}ip address: ${DANGER}error${EOL}"; \ + printf "${SUCCESS}open ports: ${DANGER}error${EOL}"; \ + else \ + printf "${SUCCESS}ip address: ${INFO}127.0.0.1${EOL}"; \ + printf "${SUCCESS}local url: ${INFO}http://localhost${EOL}"; \ + fi +endif + +## Stop container +stop: + @printf "${INFO}docker stop ${container}${EOL}" + @docker stop ${container} + diff --git a/makefiles/symfony_composer.make b/makefiles/symfony_composer.make new file mode 100644 index 0000000..5e5bbba --- /dev/null +++ b/makefiles/symfony_composer.make @@ -0,0 +1,24 @@ +############################################## +### Composer +############################################## + +## Composer install project +cp-install: +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}composer install${EOL}" + @composer install +else + @printf "${INFO}php -d memory-limit=-1 $(shell which composer) install${EOL}" + @php -d memory-limit=-1 $(shell which composer) install +endif + +## Composer update project +cp-update: +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}composer update${EOL}" + @composer update +else + @printf "${INFO}php -d memory-limit=-1 $(shell which composer) update${EOL}" + @php -d memory-limit=-1 $(shell which composer) update +endif + diff --git a/makefiles/symfony_debug.make b/makefiles/symfony_debug.make new file mode 100644 index 0000000..b890525 --- /dev/null +++ b/makefiles/symfony_debug.make @@ -0,0 +1,34 @@ +############################################## +### Symfony Debug +############################################## + +## Inspect autowiring +autowiring: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} debug:autowiring${EOL}" + @php -d memory-limit=-1 ${CONSOLE} debug:autowiring + +## Inspect config +config: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} debug:config${EOL}" + @php -d memory-limit=-1 ${CONSOLE} debug:config + +## Inspect container +container: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} debug:container${EOL}" + @php -d memory-limit=-1 ${CONSOLE} debug:container + +## Inspect event-dispatcher +dispatcher: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} debug:event-dispatcher${EOL}" + @php -d memory-limit=-1 ${CONSOLE} debug:event-dispatcher + +## Inspect router +router: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} debug:router${EOL}" + @php -d memory-limit=-1 ${CONSOLE} debug:router + +## Inspect twig +twig: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} debug:twig${EOL}" + @php -d memory-limit=-1 ${CONSOLE} debug:twig + diff --git a/makefiles/symfony_docker.make b/makefiles/symfony_docker.make new file mode 100644 index 0000000..d356b7c --- /dev/null +++ b/makefiles/symfony_docker.make @@ -0,0 +1,23 @@ +################################################## +### Symfony (Docker) +################################################## + +## Build, start docker, composer install, create database, import data, and serve +up: network build start install import + +## Open a terminal in the php container +shell: + @printf "${INFO}docker-compose exec php sh${EOL}" + @docker-compose exec php sh + +## Open in default browser +open: + @printf "${INFO}nohup xdg-open `docker inspect $(shell basename ${CURDIR}) --format 'http://{{.NetworkSettings.Networks.tango.IPAddress}}/api/docs' 2>/dev/null` >/dev/null 2>&1${EOL}" + @nohup xdg-open `docker inspect $(shell basename ${CURDIR}) --format 'http://{{.NetworkSettings.Networks.tango.IPAddress}}/api/docs' 2>/dev/null` >/dev/null 2>&1 + +## Restart app and clear cache +restart: stop start cache + +## Drop database, clear cache and re-import data +reset: database import cache + diff --git a/makefiles/symfony_docker_app.make b/makefiles/symfony_docker_app.make new file mode 100644 index 0000000..c6aff90 --- /dev/null +++ b/makefiles/symfony_docker_app.make @@ -0,0 +1,72 @@ +################################################## +### Symfony App (Docker) +################################################## + +## Install Symfony application in docker +install: + @make --no-print-directory composer + @make --no-print-directory database +ifeq ($(env),dev) + @printf "${INFO}make --no-print-directory own${EOL}" + @make --no-print-directory own +endif + +## Uninstall app completely +uninstall: stop + @printf "${INFO}sudo rm -f ./.env.local${EOL}" + @sudo rm -f ./.env.local + + @printf "${INFO}sudo rm -f ./composer.lock${EOL}" + @sudo rm -f ./composer.lock + + @printf "${INFO}sudo rm -f ./symfony.lock${EOL}" + @sudo rm -f ./symfony.lock + + @printf "${INFO}sudo rm -f ./var/data.db${EOL}" + @sudo rm -f ./var/data.db + + @printf "${INFO}sudo rm -f ./var/dev.db${EOL}" + @sudo rm -f ./var/dev.db + + @printf "${INFO}sudo rm -f ./var/test.db${EOL}" + @sudo rm -f ./var/test.db + + @printf "${INFO}sudo rm -rf ./public/bundles${EOL}" + @sudo rm -rf ./public/bundles + + @printf "${INFO}sudo rm -rf ./bin/.phpunit${EOL}" + @sudo rm -rf ./bin/.phpunit + + @printf "${INFO}sudo rm -rf ./vendor${EOL}" + @sudo rm -rf ./vendor + @make --no-print-directory nuke + +## Composer install Symfony project +composer: +ifeq ($(env),dev) + @printf "${INFO}cp .env.dev .env.local${EOL}" + @cp .env.dev .env.local + + @printf "${INFO}cp .env.dev .env.dev.local${EOL}" + @cp .env.dev .env.dev.local + + @printf "${INFO}cp .env.dev .env.prod.local${EOL}" + @cp .env.dev .env.prod.local +endif + @printf "${INFO}docker-compose exec php sh -c \"composer install --no-interaction --optimize-autoloader --prefer-dist --working-dir=/www\"${EOL}" + @docker-compose exec php sh -c "composer install --no-interaction --optimize-autoloader --prefer-dist --working-dir=/www" + +## Create database and schema +database: + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} doctrine:database:drop --force --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} doctrine:database:drop --force --env=${env}" + + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} doctrine:database:create --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} doctrine:database:create --env=${env}" + + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} doctrine:schema:create --dump-sql --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} doctrine:schema:create --dump-sql --env=${env}" + + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} doctrine:schema:create --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} doctrine:schema:create --env=${env}" + diff --git a/makefiles/symfony_docker_cache.make b/makefiles/symfony_docker_cache.make new file mode 100644 index 0000000..6c40191 --- /dev/null +++ b/makefiles/symfony_docker_cache.make @@ -0,0 +1,64 @@ +############################################## +### Symfony Cache (Docker) +############################################## + +## Clean cache +cache: + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} cache:clear --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} cache:clear --env=${env}" + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} cache:warmup --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} cache:warmup --env=${env}" +ifeq ($(env),dev) + @make --no-print-directory own +endif + +## Force delete cache +nuke: + @printf "${INFO}sudo rm -rf ./var/cache${EOL}" + -@sudo rm -rf ./var/cache + @printf "${INFO}mkdir ./var/cache${EOL}" + @mkdir -p ./var/cache + + @printf "${INFO}sudo rm -rf ./var/log${EOL}" + -@sudo rm -rf ./var/log + @printf "${INFO}mkdir ./var/log${EOL}" + @mkdir -p ./var/log + + @printf "${INFO}sudo rm -rf /var/cache/symfony/$(shell basename ${CURDIR})${EOL}" + @sudo rm -rf /var/cache/symfony/$(shell basename ${CURDIR}) + + @printf "${INFO}sudo rm -rf /var/log/symfony/$(shell basename ${CURDIR})${EOL}" + @sudo rm -rf /var/log/symfony/$(shell basename ${CURDIR}) + + @printf "${INFO}sudo rm -rf /var/log/nginx/$(shell basename ${CURDIR})${EOL}" + @sudo rm -rf /var/log/nginx/$(shell basename ${CURDIR}) + +## Own ./var +own: +ifeq ($(env),prod) + $(eval OWNER=$(shell whoami)) + $(eval GROUP=$(shell whoami)) +else + $(eval OWNER=nobody) + $(eval GROUP=nogroup) +endif + @printf "${INFO}sudo chown -R ${OWNER}:${GROUP} ./var${EOL}" + -@sudo chown -R ${OWNER}:${GROUP} ./var + @printf "${INFO}sudo chmod 777 -R ./var${EOL}" + -@sudo chmod 777 -R ./var + + @printf "${INFO}sudo chown ${OWNER}:${GROUP} ./var/data.db${EOL}" + -@sudo chown ${OWNER}:${GROUP} ./var/data.db + @printf "${INFO}sudo chmod 664 ./var/data.db${EOL}" + -@sudo chmod 664 ./var/data.db + + @printf "${INFO}sudo chown ${OWNER}:${GROUP} ./var/dev.db${EOL}" + -@sudo chown ${OWNER}:${GROUP} ./var/dev.db + @printf "${INFO}sudo chmod 664 ./var/dev.db${EOL}" + -@sudo chmod 664 ./var/dev.db + + @printf "${INFO}sudo chown ${OWNER}:${GROUP} ./var/test.db${EOL}" + -@sudo chown ${OWNER}:${GROUP} ./var/test.db + @printf "${INFO}sudo chmod 664 ./var/test.db${EOL}" + -@sudo chmod 664 ./var/test.db + diff --git a/makefiles/symfony_docker_phpunit.make b/makefiles/symfony_docker_phpunit.make new file mode 100644 index 0000000..ae8cea0 --- /dev/null +++ b/makefiles/symfony_docker_phpunit.make @@ -0,0 +1,62 @@ +############################################## +### PHPUnit (Docker) +############################################## + +## Load fixtures +fixtures: + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} doctrine:fixtures:load --no-interaction --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} doctrine:fixtures:load --no-interaction --env=${env}" + +## Load Alice fixtures +alice: + @printf "${INFO}docker-compose exec php sh -c \"${CONSOLE} hautelook:fixtures:load --no-interaction --env=${env}\"${EOL}" + @docker-compose exec php sh -c "${CONSOLE} hautelook:fixtures:load --no-interaction --env=${env}" + +## Run tests +tests: +## Run tests +tests: +ifeq ($(shell test ! -f ./var/test.db && echo true),true) + @make --no-print-directory database env=test + @make --no-print-directory own env=test +endif + @make --no-print-directory fixtures env=test +ifeq ($(shell test -x ./vendor/bin/simple-phpunit && echo true),true) + $(eval PHP_UNIT="./vendor/bin/simple-phpunit") +else ifeq ($(shell test -x ./bin/phpunit && echo true),true) + $(eval PHP_UNIT="./bin/phpunit") +else + @printf "${DANGER}error: phpunit executable not found${EOL}" + exit 1 +endif + @printf "${INFO}docker-compose exec php sh -c \"php -d memory-limit=-1 ${PHP_UNIT} tests/Unit --stop-on-failure\"${EOL}" + @docker-compose exec php sh -c "php -d memory-limit=-1 ${PHP_UNIT} tests/Unit --stop-on-failure" + @printf "${INFO}docker-compose exec php sh -c \"php -d memory-limit=-1 ${PHP_UNIT} tests/Functional --stop-on-failure\"${EOL}" + @docker-compose exec php sh -c "php -d memory-limit=-1 ${PHP_UNIT} tests/Functional --stop-on-failure" + +## Dump coverage (requires XDebug) +coverage: + @if [ -x ./bin/phpunit ]; then \ + printf "${INFO}docker-compose exec php sh -c \"php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage\"${EOL}"; \ + docker-compose exec php sh -c "php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage"; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + printf "${INFO}docker-compose exec php sh -c \"bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage\"${EOL}"; \ + docker-compose exec php sh -c "bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage"; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + printf "${INFO}docker-compose exec php sh -c \"php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage\"${EOL}"; \ + docker-compose exec php sh -c "php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage"; \ + else \ + printf "${DANGER}error: phpunit executable not found${EOL}"; \ + exit 1; \ + fi + @printf "${INFO}docker-compose exec php sh -c \"php -d memory-limit=-1 ${PHP_UNIT} --coverage-html ${PUBLIC}/coverage\"${EOL}" + @docker-compose exec php sh -c "php -d memory-limit=-1 ${PHP_UNIT} --coverage-html ${PUBLIC}/coverage" + +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}start \"${PUBLIC}/coverage/index.html\"${EOL}" + @start "${PUBLIC}/coverage/index.html" +else + @printf "${INFO}nohup xdg-open \"${PUBLIC}/coverage/index.html\" >/dev/null 2>&1${EOL}" + @nohup xdg-open "${PUBLIC}/coverage/index.html" >/dev/null 2>&1 +endif + diff --git a/makefiles/symfony_doctrine.make b/makefiles/symfony_doctrine.make new file mode 100644 index 0000000..0c93efe --- /dev/null +++ b/makefiles/symfony_doctrine.make @@ -0,0 +1,27 @@ +############################################## +### Symfony Doctrine +############################################## + +## Create database and schema +db-create: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} doctrine:database:create${EOL}" + @php -d memory-limit=-1 ${CONSOLE} doctrine:database:create + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} doctrine:schema:create${EOL}" + @php -d memory-limit=-1 ${CONSOLE} doctrine:schema:create + +## Reset database +db-reset: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} doctrine:database:drop --force${EOL}" + @php -d memory-limit=-1 ${CONSOLE} doctrine:database:drop --force + @make --no-print-directory db-create + +## Load fixtures +db-fixtures: + @printf "${INFO}php ${CONSOLE} doctrine:fixtures:load -n${EOL}" + @php ${CONSOLE} doctrine:fixtures:load -n + +## Update schema +db-update: + @printf "${INFO}php -d memory-limit=-1 ${CONSOLE} doctrine:schema:update${EOL}" + @php -d memory-limit=-1 ${CONSOLE} doctrine:schema:update + diff --git a/makefiles/symfony_encore.make b/makefiles/symfony_encore.make new file mode 100644 index 0000000..54f17a0 --- /dev/null +++ b/makefiles/symfony_encore.make @@ -0,0 +1,9 @@ +############################################## +### Webpack Encore +############################################## + +## Build assets for production +encore: + @printf "${INFO}node yarn build${EOL}" + @node yarn build + diff --git a/makefiles/symfony_front.make b/makefiles/symfony_front.make new file mode 100644 index 0000000..75b23a5 --- /dev/null +++ b/makefiles/symfony_front.make @@ -0,0 +1,24 @@ +################################################## +### Front +################################################## + +## Build js and css +build-front: sass concat + +## Concat javascript +concat: + @printf "${INFO}mkdir -p public/js${EOL}" + @mkdir -p public/js + @printf "${INFO}cat assets/js/_*.js > public/js/main.js${EOL}" + @cat assets/js/_*.js > public/js/main.js + +## Compile scss +sass: + @printf "${INFO}sass assets/scss/styles.scss public/css/styles.css${EOL}" + @sass assets/scss/styles.scss public/css/styles.css + +## Watch scss folder +watch: + @printf "${INFO}sass --watch assets/scss:public/css${EOL}" + @sass --watch assets/scss:public/css + diff --git a/makefiles/symfony_install_env.make b/makefiles/symfony_install_env.make new file mode 100644 index 0000000..c06e7d4 --- /dev/null +++ b/makefiles/symfony_install_env.make @@ -0,0 +1,96 @@ +############################################## +### Symfony Install Local Env +############################################## + +## Download and install composer +install-composer: + @printf "${PRIMARY}download composer-installer${EOL}" + @printf "${INFO}wget -q -O composer.phar https://getcomposer.org/composer-stable.phar${EOL}" + @wget -q -O composer.phar https://getcomposer.org/composer-stable.phar + @printf "${PRIMARY}install composer globally${EOL}" + @printf "${INFO}sudo mv composer.phar /usr/local/bin/composer${EOL}" + @sudo mv composer.phar /usr/local/bin/composer + @printf "${PRIMARY}fix permissions${EOL}" + @printf "${INFO}sudo chmod +x /usr/local/bin/composer${EOL}" + @sudo chmod +x /usr/local/bin/composer + @printf "${INFO}composer self-update --stable${EOL}" + @composer self-update --stable + +## Install latest php locally +install-php: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION} + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-fpm${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-fpm + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-gd${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-gd + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-curl${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-curl + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-xml${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-xml + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-intl${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-intl + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-mysql${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-mysql + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-pgsql${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-pgsql + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-sqlite3${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-sqlite3 + @printf "${INFO}sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-mbstring${EOL}" + @sudo apt-get install -y --no-install-recommends php${PHP_VERSION}-mbstring +endif + +## PHP settings for development environment +php-dev-settings: +ifeq (${SYSTEM}, Linux) + @printf "${PRIMARY}unlimited execution time (default: 30)${EOL}" + @printf "${INFO}sudo sed -i -E s/\"^;?max_execution_time\s?=\s?\-?\d+$$\"/\"max_execution_time = -1\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?max_execution_time\s?=\s?\-?\d+$$"/"max_execution_time = -1"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${PRIMARY}allow maximum memory usage (default: 128)${EOL}" + @printf "${INFO}sudo sed -i -E s/\"^;?memory_limit\s?=\s?\-?[\d\w]+$$\"/\"memory_limit = -1\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?memory_limit\s?=\s?\-?[\d\w]+$$"/"memory_limit = -1"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${PRIMARY}unlimited upload file size (default: 2M)${EOL}" + @printf "${INFO}sudo sed -i -E s/\"^;?upload_max_filesize\s?=\s?\-?[\d\w]+$$\"/\"upload_max_filesize = -1\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?upload_max_filesize\s?=\s?\-?[\d\w]+$$"/"upload_max_filesize = -1"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${PRIMARY}enable logging (default: On)${EOL}" + @printf "${INFO}sudo sed -i -E s/\"^;?log_errors\s?=\s?\w+$$\"/\"log_errors = On\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?log_errors\s?=\s?\w+$$"/"log_errors = On"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${PRIMARY}show the presence of php (default: On)${EOL}" + @printf "${INFO}sudo sed -i -E s/\"^;?expose_php\s?=\s?\w+$$\"/\"expose_php = On\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?expose_php\s?=\s?\w+$$"/"expose_php = On"/g /etc/php/${PHP_VERSION}/cli/php.ini +endif + +## PHP optimisation tasks for production +php-optimize: disable-xdebug +ifeq (${SYSTEM}, Linux) + @printf "${INFO}$(shell which composer) dump-autoload --optimize --no-dev --classmap-authoritative${EOL}" + @$(shell which composer) dump-autoload --optimize --no-dev --classmap-authoritative + @printf "${INFO}sudo sed -i -E s/\"^;?opcache.enable=\d$$\"/\"opcache.enable=1\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?opcache.enable=\d$$"/"opcache.enable=1"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${INFO}sudo sed -i -E s/\"^;?opcache.memory_consumption=\d+$$\"/\"opcache.memory_consumption=256\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?opcache.memory_consumption=\d+$$"/"opcache.memory_consumption=256"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${INFO}sudo sed -i -E s/\"^;?opcache.max_accelerated_files=\d+$$\"/\"opcache.max_accelerated_files=20000\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?opcache.max_accelerated_files=\d+$$"/"opcache.max_accelerated_files=20000"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${INFO}sudo sed -i -E s/\"^;?opcache.validate_timestamps=\d$$\"/\"opcache.validate_timestamps=0\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^;?opcache.validate_timestamps=\d$$"/"opcache.validate_timestamps=0"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${INFO}sudo sed -i -E s/\"^realpath_cache_size=\d$$\"/\"realpath_cache_size=4096k\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^realpath_cache_size=\d$$"/"realpath_cache_size=4096k"/g /etc/php/${PHP_VERSION}/cli/php.ini + @printf "${INFO}sudo sed -i -E s/\"^realpath_cache_ttl=\d$$\"/\"realpath_cache_ttl=600\"/g /etc/php/${PHP_VERSION}/cli/php.ini${EOL}" + @sudo sed -i -E s/"^realpath_cache_ttl=\d$$"/"realpath_cache_ttl=600"/g /etc/php/${PHP_VERSION}/cli/php.ini +endif + +## Disable xdebug +disable-xdebug: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo sed -i -E s/\"^;?zend_extension=xdebug.so$$\"/\";zend_extension=xdebug.so\"/g $(shell php -i | grep xdebug.ini | tr -d ',')${EOL}" + @sudo sed -i -E s/"^;?zend_extension=xdebug.so$$"/";zend_extension=xdebug.so"/g $(shell php -i | grep xdebug.ini | tr -d ',') +endif + +## Enable xdebug +enable-xdebug: +ifeq (${SYSTEM}, Linux) + @printf "${INFO}sudo sed -i -E s/\"^;?zend_extension=xdebug.so$$\"/\"zend_extension=xdebug.so\"/g $(shell php -i | grep xdebug.ini | tr -d ',')${EOL}";" + sudo sed -i -E s/"^;?zend_extension=xdebug.so$$"/"zend_extension=xdebug.so"/g $(shell php -i | grep xdebug.ini | tr -d ',') +endif + diff --git a/makefiles/symfony_jwt_ssl.make b/makefiles/symfony_jwt_ssl.make new file mode 100644 index 0000000..9ea21c0 --- /dev/null +++ b/makefiles/symfony_jwt_ssl.make @@ -0,0 +1,18 @@ +############################################## +### JWT +############################################## + +## Generate JWT key +generate-keys: + @printf "${INFO}sudo rm -rf ./config/jwt${EOL}" + -@sudo rm -rf ./config/jwt + + @printf "${INFO}mkdir -p ./config/jwt${EOL}" + -@mkdir -p ./config/jwt + + @printf "${INFO}echo \"$(shell grep ^JWT_PASSPHRASE .env | cut -f 2 -d=)\" | openssl genpkey -out ./config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096${EOL}" + @echo "$(shell grep ^JWT_PASSPHRASE .env | cut -f 2 -d=)" | openssl genpkey -out ./config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096 + + @printf "${INFO}echo \"$(shell grep ^JWT_PASSPHRASE .env | cut -f 2 -d=)\" | openssl pkey -in ./config/jwt/private.pem -passin stdin -out ./config/jwt/public.pem -pubout${EOL}" + @echo "$(shell grep ^JWT_PASSPHRASE .env | cut -f 2 -d=)" | openssl pkey -in ./config/jwt/private.pem -passin stdin -out ./config/jwt/public.pem -pubout + diff --git a/makefiles/symfony_phpunit.make b/makefiles/symfony_phpunit.make new file mode 100644 index 0000000..5729f5c --- /dev/null +++ b/makefiles/symfony_phpunit.make @@ -0,0 +1,42 @@ +############################################## +### PHPUnit +############################################## + +## Load fixtures +fixtures: + @printf "${INFO}php ${CONSOLE} doctrine:fixtures:load --no-interaction --env=test${EOL}" + @php ${CONSOLE} doctrine:fixtures:load --no-interaction --env=test + +## Run tests +tests: fixtures + @if [ -x ./bin/phpunit ]; then \ + php -d memory-limit=-1 ./bin/phpunit --stop-on-failure; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + bash ./vendor/bin/phpunit --stop-on-failure; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + php -d memory-limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure; \ + else \ + printf "${DANGER}error: phpunit executable not found${EOL}"; \ + exit 1; \ + fi + +## Dump coverage (requires XDebug) +coverage: + @if [ -x ./bin/phpunit ]; then \ + php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage; \ + elif [ -x ./vendor/bin/phpunit ]; then \ + bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage; \ + elif [ -x ./vendor/bin/simple-phpunit ]; then \ + php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage; \ + else \ + printf "${DANGER}error: phpunit executable not found${EOL}"; \ + exit 1; \ + fi +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}start \"${PUBLIC}/coverage/index.html\"${EOL}" + @start "${PUBLIC}/coverage/index.html" +else + @printf "${INFO}nohup xdg-open \"${PUBLIC}/coverage/index.html\" >/dev/null 2>&1${EOL}" + @nohup xdg-open "${PUBLIC}/coverage/index.html" >/dev/null 2>&1 +endif + diff --git a/makefiles/symfony_requirements_checker.make b/makefiles/symfony_requirements_checker.make new file mode 100644 index 0000000..b272572 --- /dev/null +++ b/makefiles/symfony_requirements_checker.make @@ -0,0 +1,18 @@ +############################################## +### Requirements +############################################## + +## Checking requirements automatically +requirements-checker: +# composer require symfony/requirements-checker + @printf "${PRIMARY} open:${DEFAULT}${INFO} http://localhost:${port}/check.php ${PRIMARY}in your browser${EOL}" +ifeq (${SYSTEM}, Windows_NT) + @printf "${INFO}start \"http://localhost:${port}/check.php\"${EOL}" + -@start "http://localhost:${port}/check.php" +else + @printf "${INFO}nohup xdg-open http://localhost:${port}/check.php >/dev/null 2>&1${EOL}" + -@nohup xdg-open http://localhost:${port}/check.php >/dev/null 2>&1 +endif + @printf "${INFO}php -S localhost:${port} -t ./public${EOL}" + @php -S localhost:${port} -t ./public + diff --git a/makefiles/system_check_install.make b/makefiles/system_check_install.make new file mode 100644 index 0000000..ba12493 --- /dev/null +++ b/makefiles/system_check_install.make @@ -0,0 +1,217 @@ +################################################## +### Check install +################################################## + +## Check correct environment installation +check: + @if [ -n "$(shell ansible --version 2>/dev/null)" ]; then \ + printf "${INFO}ansible --version${EOL}"; \ + ansible --version; \ + else \ + printf "${WARNING}ansible is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell apache2 --version 2>/dev/null)" ]; then \ + printf "${INFO}apache2 --version${EOL}"; \ + apache2 --version; \ + else \ + printf "${WARNING}apache2 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell aws --version 2>/dev/null)" ]; then \ + printf "${INFO}aws --version${EOL}"; \ + aws --version; \ + else \ + printf "${WARNING}aws is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell bundle --version 2>/dev/null)" ]; then \ + printf "${INFO}bundle --version${EOL}"; \ + bundle --version; \ + else \ + printf "${WARNING}bundle is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell chef --version 2>/dev/null)" ]; then \ + printf "${INFO}chef --version${EOL}"; \ + chef --version; \ + else \ + printf "${WARNING}chef is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell php --version 2>/dev/null)" ]; then \ + if [ -x "$(shell which composer 2>/dev/null)" ]; then \ + printf "${INFO}$(shell which composer) --version${EOL}"; \ + $(shell which composer) --version; \ + else \ + printf "${WARNING}composer is not installed on your system${EOL}"; \ + fi; \ + else \ + printf "${WARNING}unable to show composer version, php not installed${EOL}"; \ + fi + @if [ -n "$(shell curl --version 2>/dev/null)" ]; then \ + printf "${INFO}curl --version$ | head -n1${EOL}"; \ + curl --version | head -n1; \ + else \ + printf "${WARNING}curl is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell docker --version 2>/dev/null)" ]; then \ + printf "${INFO}docker --version${EOL}"; \ + docker --version; \ + else \ + printf "${WARNING}docker is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell docker-compose --version 2>/dev/null)" ]; then \ + printf "${INFO}docker-compose --version${EOL}"; \ + docker-compose --version; \ + else \ + printf "${WARNING}docker-compose is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell gem --version 2>/dev/null)" ]; then \ + printf "${INFO}gem --version${EOL}"; \ + gem --version; \ + else \ + printf "${WARNING}gem is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell git --version 2>/dev/null)" ]; then \ + printf "${INFO}git --version${EOL}"; \ + git --version; \ + else \ + printf "${WARNING}git is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell ip -V 2>/dev/null)" ]; then \ + printf "${INFO}ip -V${EOL}"; \ + ip -V; \ + else \ + printf "${WARNING}ip is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell iptables --version 2>/dev/null)" ]; then \ + printf "${INFO}iptables --version${EOL}"; \ + iptables --version; \ + else \ + printf "${WARNING}iptables is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell mysql --version 2>/dev/null)" ]; then \ + printf "${INFO}mysql --version${EOL}"; \ + mysql --version; \ + else \ + printf "${WARNING}mysql is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell nginx --version 2>/dev/null)" ]; then \ + printf "${INFO}nginx --version${EOL}"; \ + nginx --version; \ + else \ + printf "${WARNING}nginx is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell nodejs --version 2>/dev/null)" ]; then \ + printf "${INFO}nodejs --version${EOL}"; \ + nodejs --version; \ + else \ + printf "${WARNING}nodejs is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell npm --version 2>/dev/null)" ]; then \ + printf "${INFO}npm --version${EOL}"; \ + npm --version; \ + else \ + printf "${WARNING}npm is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell openssl version 2>/dev/null)" ]; then \ + printf "${INFO}openssl version${EOL}"; \ + openssl version; \ + else \ + printf "${WARNING}openssl is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell php --version 2>/dev/null)" ]; then \ + printf "${INFO}php --version${EOL}"; \ + php --version; \ + printf "${INFO}php -m${EOL}"; \ + php -m; \ + else \ + printf "${WARNING}php is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell pip --version 2>/dev/null)" ]; then \ + printf "${INFO}pip --version${EOL}"; \ + pip --version; \ + else \ + printf "${WARNING}pip is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell pip3 --version 2>/dev/null)" ]; then \ + printf "${INFO}pip3 --version${EOL}"; \ + pip3 --version; \ + else \ + printf "${WARNING}pip3 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell psql --version 2>/dev/null)" ]; then \ + printf "${INFO}psql --version${EOL}"; \ + psql --version; \ + else \ + printf "${WARNING}postgresql is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell python --version 2>/dev/null)" ]; then \ + printf "${INFO}python --version${EOL}"; \ + python --version; \ + else \ + printf "${WARNING}python is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell python2 --version 2>/dev/null)" ]; then \ + printf "${INFO}python2 --version${EOL}"; \ + python2 --version; \ + else \ + printf "${WARNING}python2 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell python3 --version 2>/dev/null)" ]; then \ + printf "${INFO}python3 --version${EOL}"; \ + python3 --version; \ + else \ + printf "${WARNING}python3 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell ruby --version 2>/dev/null)" ]; then \ + printf "${INFO}ruby --version${EOL}"; \ + ruby --version; \ + else \ + printf "${WARNING}ruby is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell rvm --version 2>/dev/null)" ]; then \ + printf "${INFO}rvm --version${EOL}"; \ + rvm --version; \ + else \ + printf "${WARNING}rvm is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell sqlite3 --version 2>/dev/null)" ]; then \ + printf "${INFO}sqlite3 --version${EOL}"; \ + sqlite3 --version; \ + else \ + printf "${WARNING}sqlite3 is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell ufw --version 2>/dev/null)" ]; then \ + printf "${INFO}ufw --version${EOL}"; \ + ufw --version; \ + else \ + printf "${WARNING}ufw is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell vagrant --version 2>/dev/null)" ]; then \ + printf "${INFO}vagrant --version${EOL}"; \ + vagrant --version; \ + else \ + printf "${WARNING}vagrant is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell vboxmanage --version 2>/dev/null)" ]; then \ + printf "${INFO}vboxmanage --version${EOL}"; \ + vboxmanage --version; \ + else \ + printf "${WARNING}vboxmanage is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell virtualenv --version 2>/dev/null)" ]; then \ + printf "${INFO}virtualenv --version${EOL}"; \ + virtualenv --version; \ + else \ + printf "${WARNING}virtualenv is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell wget --version 2>/dev/null)" ]; then \ + printf "${INFO}wget --version | head -n1${EOL}"; \ + wget --version | head -n1; \ + else \ + printf "${WARNING}wget is not installed on your system${EOL}"; \ + fi + @if [ -n "$(shell which yarn 2>/dev/null)" ]; then \ + printf "${INFO}yarn --version${EOL}"; \ + yarn --version; \ + else \ + printf "${WARNING}yarn is not installed on your system${EOL}"; \ + fi + diff --git a/makefiles/system_info.make b/makefiles/system_info.make new file mode 100644 index 0000000..4ed8ec3 --- /dev/null +++ b/makefiles/system_info.make @@ -0,0 +1,77 @@ +################################################## +### System Info +################################################## + +## Print system information +sysinfo: + @printf "${INFO}whoami${EOL}" + @whoami + @printf "${INFO}id --user${EOL}" + @id --user + @printf "${INFO}id --groups --name${EOL}" + @id --groups --name + @printf "${INFO}id --groups${EOL}" + @id --groups + @if [ -n "$(shell lsb_release -a 2>/dev/null)" ]; then \ + printf "${INFO}lsb_release -a${EOL}"; \ + lsb_release -a; \ + else \ + printf "${WARNING}\"lsb_release\" not available${EOL}"; \ + fi + @if [ -n "$(shell uname -a 2>/dev/null)" ]; then \ + printf "${INFO}uname -a${EOL}"; \ + uname -a; \ + else \ + printf "${WARNING}\"uname\" not available${EOL}"; \ + fi + @if [ -n "$(shell hostname 2>/dev/null)" ]; then \ + printf "${INFO}hostname -i${EOL}"; \ + hostname -i; \ + printf "${INFO}hostname -I${EOL}"; \ + hostname -I; \ + else \ + printf "${WARNING}\"hostname\" not available${EOL}"; \ + fi + @if [ -n "$(shell ip -V 2>/dev/null)" ]; then \ + printf "${INFO}ip addr${EOL}"; \ + ip addr; \ + else \ + printf "${WARNING}\"ip\" not available${EOL}"; \ + fi + @if [ -n "$(shell ifconfig 2>/dev/null)" ]; then \ + printf "${INFO}ifconfig${EOL}"; \ + ifconfig; \ + else \ + printf "${WARNING}\"ifconfig\" not available${EOL}"; \ + fi + @if [ -n "$(shell netstat 2>/dev/null)" ]; then \ + printf "${INFO}netstat -tulpn${EOL}"; \ + netstat -tulpn; \ + else \ + printf "${WARNING}\"netstat\" not available${EOL}"; \ + fi + @if [ -n "$(shell lshw 2>/dev/null)" ]; then \ + printf "${INFO}lshw -short${EOL}"; \ + lshw -short; \ + else \ + printf "${WARNING}\"lshw\" not available${EOL}"; \ + fi + @if [ -n "$(shell df 2>/dev/null)" ]; then \ + printf "${INFO}df -h | grep -vP \"/dev/loop\d+\"${EOL}"; \ + df -h | grep -vP "/dev/loop\d+"; \ + else \ + printf "${WARNING}\"df\" not available${EOL}"; \ + fi + @if [ -n "$(shell service 2>/dev/null)" ]; then \ + printf "${INFO}service --status-all${EOL}"; \ + service --status-all; \ + else \ + printf "${WARNING}\"service\" not available${EOL}"; \ + fi + @if [ -n "$(shell systemctl 2>/dev/null)" ]; then \ + printf "${INFO}systemctl | grep running | sed -E 's/\s+/ /g' | sed 's/ loaded active running /\t/'${EOL}"; \ + systemctl | grep running | sed -E 's/\s+/ /g' | sed 's/ loaded active running /\t/'; \ + else \ + printf "${WARNING}\"systemctl\" not available${EOL}"; \ + fi + diff --git a/makefiles/traefik.make b/makefiles/traefik.make new file mode 100644 index 0000000..8036d17 --- /dev/null +++ b/makefiles/traefik.make @@ -0,0 +1,12 @@ +################################################## +### Traefik Let's Encrypt +################################################## + +## Create acme.json file +acme: + @printf "${INFO}touch ./config/acme.json${EOL}" + @touch ./config/acme.json + + @printf "${INFO}chmod 600 ./config/acme.json${EOL}" + @chmod 600 ./config/acme.json + diff --git a/makefiles/vagrant.make b/makefiles/vagrant.make new file mode 100644 index 0000000..78a9055 --- /dev/null +++ b/makefiles/vagrant.make @@ -0,0 +1,41 @@ +#################################################### +### Vagrant +#################################################### + +## Start vagrant +start: + @bash ./bin/host/start_vagrant.sh + +## Stop vagrant +stop: + @printf "${INFO}vagrant halt${EOL}" + @vagrant halt + +## Open bash shell into guest +shell: + @bash ./bin/host/start_vagrant.sh + @printf "${INFO}vagrant ssh${EOL}" + @vagrant ssh + +## Restart vagrant +restart: + @printf "${INFO}vagrant halt${EOL}" + @vagrant halt + @sleep 2 + @bash ./bin/host/start_vagrant.sh + +## Validate Vagrantfile syntax +validate: + @printf "${INFO}vagrant validate${EOL}" + @vagrant validate + +## List running vagrant boxes +status: + @printf "${INFO}vagrant global-status${EOL}" + @vagrant global-status + +## Remove stale vagrant boxes +clean: + @printf "${INFO}vagrant global-status --prune${EOL}" + @vagrant global-status --prune + diff --git a/makefiles/vagrant_guest.make b/makefiles/vagrant_guest.make new file mode 100644 index 0000000..07b1086 --- /dev/null +++ b/makefiles/vagrant_guest.make @@ -0,0 +1,43 @@ +#################################################### +### Vagrant Guest +#################################################### + +## Start and ssh into vagrant guest +up: + @bash ./bin/host/start_vagrant.sh + @printf "${INFO}vagrant ssh${EOL}" + @vagrant ssh + +## Create vagrant guest +init: config + -@bash ./bin/host/create_vagrant_guest.sh + +## Init configuration +config: + @bash ./bin/host/init_vagrant_config.sh + @bash ./bin/host/set_hosts.sh + +## Set hosts +hosts: + @bash ./bin/host/set_hosts.sh + +## Rebuild vagrant guest forcing provisioners +reset: destroy + @sleep 2 + @printf "${INFO}vagrant up --provision --destroy-on-error${EOL}" + @vagrant up --provision --destroy-on-error + +## Update guest provisioners +update: + @printf "${INFO}vagrant halt${EOL}" + @vagrant halt + @sleep 2 + @bash ./bin/host/set_hosts.sh + @printf "${INFO}vagrant up --provision --destroy-on-error${EOL}" + @vagrant up --provision --destroy-on-error + +## Destroy guest +destroy: + @bash ./bin/host/destroy_vagrant.sh + @bash ./bin/host/restart_nfs.sh + diff --git a/makefiles/vagrant_host.make b/makefiles/vagrant_host.make new file mode 100644 index 0000000..4df8c37 --- /dev/null +++ b/makefiles/vagrant_host.make @@ -0,0 +1,30 @@ +#################################################### +### Vagrant Host +#################################################### + +## Install vagrant host (Ansible, VirtualBox & Vagrant) +install: + @bash ./bin/host/install_ansible.sh + @bash ./bin/host/install_nfs.sh + @bash ./bin/host/install_vagrant.sh + @bash ./bin/host/install_vagrant_plugins.sh + @bash ./bin/host/install_virtualbox-6.0.sh + @bash ./bin/tools/check_install.sh + +## Install vagrant host (Ansible, VirtualBox & Vagrant) from sh files +install-bin: + @bash ./bin/host/install_ansible.sh + @bash ./bin/host/install_nfs.sh + @bash ./bin/host/install_vagrant.sh + @bash ./bin/host/install_vagrant_plugins.sh + @bash ./bin/host/install_virtualbox-6.0.sh + @bash ./bin/tools/check_install.sh + +## Uninstall all +uninstall: + @bash ./bin/host/uninstall_all.sh + +## Check installation +check: + @bash ./bin/tools/check_install.sh + diff --git a/makefiles/vagrant_images.make b/makefiles/vagrant_images.make new file mode 100644 index 0000000..e01849d --- /dev/null +++ b/makefiles/vagrant_images.make @@ -0,0 +1,30 @@ +#################################################### +### Vagrant Images +#################################################### + +## Download Windows7 image from microsoft +download-win7: + @printf "${INFO}wget https://az792536.vo.msecnd.net/vms/VMBuild_20150916/Vagrant/IE8/IE8.Win7.Vagrant.zip${EOL}" + @wget https://az792536.vo.msecnd.net/vms/VMBuild_20150916/Vagrant/IE8/IE8.Win7.Vagrant.zip + -@make --no-print-directory add-win7 + +## Extract and add downloaded Windows7 image from microsoft +add-win7: + @printf "${INFO}7z e IE8.Win7.Vagrant.zip${EOL}" + @7z e IE8.Win7.Vagrant.zip + @printf "${INFO}rm IE8.Win7.Vagrant.zip${EOL}" + @rm IE8.Win7.Vagrant.zip + @printf "${INFO}vagrant box add win7 "./IE8 - Win7.box"${EOL}" + @vagrant box add win7 "./IE8 - Win7.box" + +## Download Mac OSX image from Vagrant +download-osx: + @printf "${INFO}wget https://vagrant-osx.nyc3.digitaloceanspaces.com/osx-sierra-0.3.1.box${EOL}" + @wget https://vagrant-osx.nyc3.digitaloceanspaces.com/osx-sierra-0.3.1.box + -@make --no-print-directory add-osx + +## Extract and add downloaded Windows7 image from microsoft +add-osx: + @printf "${INFO}vagrant box add osx ./osx-sierra-0.3.1.box${EOL}" + @vagrant box add osx ./osx-sierra-0.3.1.box + diff --git a/makefiles/vars/docker.make b/makefiles/vars/docker.make new file mode 100644 index 0000000..2ceafc1 --- /dev/null +++ b/makefiles/vars/docker.make @@ -0,0 +1,63 @@ +#-------------------------------------------------- +# Docker (deprecated) +#-------------------------------------------------- + +# https://hub.docker.com/search +# +# | ubuntu | debian | alpine | archlinux | kalilinux | +# |---------------|-----------------------------|--------|-----------|-------------------| +# | 20.04, focal | bullseye | edge | 20191205 | kali | +# | 19.10, eoan | 10.3, buster, buster-slim | 3.11 | 20191105 | kali-rolling | +# | 19.04, disco | 9.11, stretch, stretch-slim | 3.10 | 20191006 | kali-linux-docker | +# | 18.04, bionic | 8.11, jessie, jessie-slim | 3.9 | | | +# | 16.04, xenial | | 3.8 | | | +# | 14.04, trusty | | | | | + +image?= +container?= + +# when no container name given and Dockerfile present and git repository present +ifeq ($(shell test -z "${image}" && test -z "${container}" && test -f ./Dockerfile && test -n `git rev-parse --show-toplevel 2>/dev/null` && echo true),true) + # set default container name from git repository name + container="$(shell basename `git rev-parse --show-toplevel 2>/dev/null | tr '[:upper:]' '[:lower:]'` 2>/dev/null)" +endif + +# when no container name given and Dockerfile present and no git repository found +ifeq ($(shell test -z "${image}" && test -z "${container}" && test -f ./Dockerfile && echo true),true) + # set default container name from current folder name (removing spaces, replacing ".", ":" and "/" by "-", to lowercase) + container="$(shell basename ${CURDIR} | tr :/ - | tr -d ' ' | tr '[:upper:]' '[:lower:]')" +endif + +# when no image name given and Dockerfile present +ifeq ($(shell test -z "${image}" && test -f ./Dockerfile && echo true),true) + # default image is debian:buster-slim + image=Dockerfile +endif + +# when no image name given and no Dockerfile present +ifeq ($(shell test -z "${image}" && test ! -f ./Dockerfile && echo true),true) + # default image is debian:buster-slim + image=debian:buster-slim +endif + +# when no container name found +ifeq (${container},) + # set default container name from image (removing spaces, replacing ".", ":" and "/" by "-", to lowercase) + container=$(shell echo "${image}" | tr ":/." - | tr -d ' ' | tr '[:upper:]' '[:lower:]') +endif + +# guest working directory e.g: `/usr/src/app` (for bindind and hotreload) +workdir?=/usr/src/app +# app path (will append to container's ip e.g: `http://172.17.0.2/index.php`) +app_route?=/index.php +# command to execute on container startup +command?=tail -f /dev/null + +# Host network config +default_ethernet="$(shell ip token | cut -d\ -f4 | grep -E '^e' | head -n1)" +default_wifi="$(shell ip token | cut -d\ -f4 | grep -E '^w' | head -n1)" + +adapter?=${default_ethernet} +# valid parameter = bridge, host, macvlan or none (https://docs.docker.com/network) +network?=bridge + diff --git a/makefiles/vars/git.make b/makefiles/vars/git.make new file mode 100644 index 0000000..aecef35 --- /dev/null +++ b/makefiles/vars/git.make @@ -0,0 +1,17 @@ +#-------------------------------------------------- +# Git +#-------------------------------------------------- + +# get version from git tag +version?=`git tag --list 2>/dev/null | tail -1` + +# get lastest tag from git repository +version?=`git describe --exact-match --abbrev=0 2>/dev/null` + +# get repository name from git +repository?=$(shell basename `git rev-parse --show-toplevel 2>/dev/null` 2>/dev/null) +ifeq (${repository},) + # get default repository name from current folder name + repository="$(shell basename ${CURDIR})" +endif + diff --git a/makefiles/vars/git_bashdoc.make b/makefiles/vars/git_bashdoc.make new file mode 100644 index 0000000..8e51e84 --- /dev/null +++ b/makefiles/vars/git_bashdoc.make @@ -0,0 +1,9 @@ +#-------------------------------------------------- +# Git BashDoc +#-------------------------------------------------- + +# get values from `@link` TangoMan BashDoc +git_server?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '(bitbucket.org|github.com|gitlab.com)'` +git_user?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -E '(bitbucket.org|github.com|gitlab.com)' | cut -d/ -f4` +repository?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -E '(bitbucket.org|github.com|gitlab.com)' | cut -d/ -f5` + diff --git a/makefiles/vars/makefile_generator.make b/makefiles/vars/makefile_generator.make new file mode 100644 index 0000000..564a3b3 --- /dev/null +++ b/makefiles/vars/makefile_generator.make @@ -0,0 +1,69 @@ +#-------------------------------------------------- +# Makefile Generator +#-------------------------------------------------- + +# get parameters from config.yaml +define get_param + cat ./config.yaml | sed -nE 's/^(\s+)?$(1)://p' | sed -E 's/^\s+//g' +endef + +# get phony from file +define update_phony + $(eval phony:=$(shell awk -F ':' '/^[a-zA-Z0-9_-]+:/{printf "%s ", $$1}' $(1))) +endef + +# get usage from file +define update_usage + $(eval usage:=$(shell awk -F '?' '/^[ \t]+?[a-zA-Z0-9_-]+[ \t]+?\?=/{gsub(/[ \t]+/,"");printf "%s=[%s]\n", $$1, $$1}' $(1)|sort|uniq|tr '\n' ' ')) +endef + +# render template (phony and usage are generated - can't edit) +define render + sed -i s/'{{ AUTHOR }}'/"${author}"/g $(1) + sed -i s/'{{ DESCRIPTION }}'/"${description}"/g $(1) + sed -i s/'{{ EMAIL }}'/"${email}"/g $(1) + sed -i s/'{{ FILENAME }}'/"${filename}"/g $(1) + sed -i s/'{{ GIT_SERVER }}'/"${git_server}"/g $(1) + sed -i s/'{{ GIT_USER }}'/"${git_user}"/g $(1) + sed -i s/'{{ LICENSE }}'/"${license}"/g $(1) + sed -i s/'{{ PADDING }}'/"${padding}"/g $(1) + sed -i s/'{{ PHONY }}'/"${phony}"/g $(1) + sed -i s/'{{ PROJECT }}'/"${project}"/g $(1) + sed -i s/'{{ REPOSITORY }}'/"${repository}"/g $(1) + sed -i s/'{{ USAGE }}'/"${usage}"/g $(1) + sed -i s/'{{ VERSION }}'/"${version}"/g $(1) + sed -i s/'{{ YEAR }}'/"${year}"/g $(1) +endef + +# parameters (usage parameter=value) +ifeq ($(shell test ! -f ./config.yaml && echo true),true) + # set default config (from this actual file header) + author?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @author /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '\".+\"' | tr -d '"'` + description?=`awk '/^\# \* @/ {i=2} /^\#\/\*\*$$/,/^\# \*\/$$/{i+=1; if (i>3) printf "%s ", substr($$0, 5)}' ${MAKEFILE_LIST} 2>/dev/null` + email?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @author /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '<.+>' | tr -d '<' | tr -d '>'` + filename?=`date +%Y%m%d%H%M%S`.make + git_server?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '(bitbucket.org|github.com|gitlab.com)'` + git_user?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -E '(bitbucket.org|github.com|gitlab.com)' | cut -d/ -f4` + license?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @license /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oE '(Apache|GPL2|GPL3|MIT)'` + padding?=12 + project?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{i+=1; if (i==2) print substr($$0, 5)}' ${MAKEFILE_LIST} 2>/dev/null` + repository?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @link /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -E '(bitbucket.org|github.com|gitlab.com)' | cut -d/ -f5` + version?=`awk '/^\#\/\*\*$$/,/^\# \*\/$$/{}/^\# \* @version /{print}' ${MAKEFILE_LIST} 2>/dev/null | grep -m1 -oP '\d+\.\d+\.\d+'` + year?=`date +%Y` +else + # get config from config.yaml + author?=`$(call get_param,author)` + description?=`$(call get_param,description)` + email?=`$(call get_param,email)` + filename?=`$(call get_param,filename)` + git_server?=`$(call get_param,git_server)` + git_user?=`$(call get_param,git_user)` + license?=`$(call get_param,license)` + padding?=`$(call get_param,padding)` + project?=`$(call get_param,project)` + repository?=`$(call get_param,repository)` + version?=`$(call get_param,version)` + year?=`$(call get_param,year)` +endif + + diff --git a/makefiles/vars/network.make b/makefiles/vars/network.make new file mode 100644 index 0000000..6b8d1b9 --- /dev/null +++ b/makefiles/vars/network.make @@ -0,0 +1,8 @@ +#-------------------------------------------------- +# Network +#-------------------------------------------------- + +# Host network config +default_ethernet="$(shell ip token | cut -d\ -f4 | grep -E '^e' | head -n1)" +default_wifi="$(shell ip token | cut -d\ -f4 | grep -E '^w' | head -n1)" + diff --git a/makefiles/vars/python.make b/makefiles/vars/python.make new file mode 100644 index 0000000..a8ab437 --- /dev/null +++ b/makefiles/vars/python.make @@ -0,0 +1,16 @@ +#-------------------------------------------------- +# Python +#-------------------------------------------------- + +# file name +filename?=app.py + +# virtualenv name +virtualenv?=venv + +# default app arguments +arguments?=--file app.py + +# app port +port?=8080 + diff --git a/makefiles/vars/react.make b/makefiles/vars/react.make new file mode 100644 index 0000000..09c8c1c --- /dev/null +++ b/makefiles/vars/react.make @@ -0,0 +1,7 @@ +#-------------------------------------------------- +# React +#-------------------------------------------------- + +# app port +port?=3000 + diff --git a/makefiles/vars/symfony-cli.make b/makefiles/vars/symfony-cli.make new file mode 100644 index 0000000..ca5758a --- /dev/null +++ b/makefiles/vars/symfony-cli.make @@ -0,0 +1,13 @@ +#-------------------------------------------------- +# Symfony CLI +#-------------------------------------------------- + +# get correct console executable +CONSOLE=$(shell if [ -f ./app/console ]; then echo './app/console'; elif [ -f ./bin/console ]; then echo './bin/console'; fi) +# get correct public folder +PUBLIC=$(shell if [ -d ./web ]; then echo './web'; elif [ -d ./public ]; then echo './public'; else echo './'; fi) +# get current php version +PHP_VERSION=$(shell php -v | grep -oP 'PHP\s\d+\.\d+' | sed s/'PHP '//) +# symfony version +VERSION=$(shell ${CONSOLE} --version) + diff --git a/makefiles/vars/symfony.make b/makefiles/vars/symfony.make new file mode 100644 index 0000000..3f294e9 --- /dev/null +++ b/makefiles/vars/symfony.make @@ -0,0 +1,19 @@ +#-------------------------------------------------- +# Symfony +#-------------------------------------------------- + +# get correct console executable +CONSOLE=$(shell if [ -f ./app/console ]; then echo './app/console'; elif [ -f ./bin/console ]; then echo './bin/console'; fi) +# get correct public folder +PUBLIC=$(shell if [ -d ./web ]; then echo './web'; elif [ -d ./public ]; then echo './public'; else echo './'; fi) +# get current php version +PHP_VERSION=$(shell php -v | grep -oP 'PHP\s\d+\.\d+' | sed s/'PHP '//) +# symfony version +SYMFONY_VERSION=$(shell if [ -f ./vendor/autoload.php ]; then ${CONSOLE} --version; else echo 'Symfony not installed'; fi) +# get current httpd user +HTTPDUSER=$(shell ps aux | grep -E 'apache|httpd|_www|www-data|nginx' | grep -v root | head -1 | cut -d\ -f1) +# app port +port?=8080 +# app environment +env?=prod + diff --git a/makefiles/vars/symfony_docker.make b/makefiles/vars/symfony_docker.make new file mode 100644 index 0000000..ffdca89 --- /dev/null +++ b/makefiles/vars/symfony_docker.make @@ -0,0 +1,18 @@ +#-------------------------------------------------- +# Symfony Docker (depecated) +#-------------------------------------------------- + +image?=Dockerfile +# set default container name from current folder name (removing spaces, replacing ".", ":" and "/" by "-", to lowercase) +container?="$(shell basename ${CURDIR} | tr :/ - | tr -d ' ' | tr '[:upper:]' '[:lower:]')" +# guest working directory e.g: `/usr/src/app` (for bindind and hotreload) +workdir?=/www +# app path (will append to container's ip e.g: `http://172.17.0.2/index.php`) +app_route?=/index.php +# app port +port?=80 +# command to execute on container startup +command?=php -S 0.0.0.0:${port} ${PUBLIC} +# valid parameter = bridge, host, macvlan or none (https://docs.docker.com/network) +network?=bridge + diff --git a/makefiles/vars/system_platform.make b/makefiles/vars/system_platform.make new file mode 100644 index 0000000..7a6a08c --- /dev/null +++ b/makefiles/vars/system_platform.make @@ -0,0 +1,11 @@ +#-------------------------------------------------- +# Local OS +#-------------------------------------------------- + +# Local operating system (Windows_NT, Darwin, Linux) +ifeq ($(OS),Windows_NT) + SYSTEM=$(OS) +else + SYSTEM=$(shell uname -s) +endif + diff --git a/makefiles/vars/time.make b/makefiles/vars/time.make new file mode 100644 index 0000000..7b83be8 --- /dev/null +++ b/makefiles/vars/time.make @@ -0,0 +1,14 @@ +#-------------------------------------------------- +# Time +#-------------------------------------------------- + +# Date / Time +DATE=$(shell date -I) +DATETIME=$(shell date '+%Y-%m-%d %H:%M:%S') +TIME=$(shell date -Ins) +ISO-8601=$(shell date -Ins) +TIMESTAMP=$(shell date +%Y%m%d%H%M%S) +LONG_TIMESTAMP=$(shell date +%Y-%m-%d_%H-%M-%S) +EPOCH=$(shell date +%s) +DAY=$(shell LANG=C date +%A) + diff --git a/makefiles/vars/vue.make b/makefiles/vars/vue.make new file mode 100644 index 0000000..4d62f61 --- /dev/null +++ b/makefiles/vars/vue.make @@ -0,0 +1,7 @@ +#-------------------------------------------------- +# Vue +#-------------------------------------------------- + +# app port +port?=8080 + diff --git a/makefiles/vue-sass.make b/makefiles/vue-sass.make new file mode 100644 index 0000000..bd7501c --- /dev/null +++ b/makefiles/vue-sass.make @@ -0,0 +1,16 @@ +################################################## +### Sass Vue local +################################################## + +## Install Sass into project dependencies +sass-dev: + @if [ -x "`command -v yarn`" ]; then \ + printf "${INFO}sudo yarn add --dev sass${EOL}"; \ + sudo yarn add --dev sass; \ + elif [ -x "`command -v npm`" ]; then \ + printf "${INFO}sudo npm install --save-dev sass${EOL}"; \ + sudo npm install --save-dev sass; \ + else \ + printf "${DANGER}error: yarn and npm missing, skipping...${EOL}"; \ + fi; + diff --git a/makefiles/vue.make b/makefiles/vue.make new file mode 100644 index 0000000..bc0f963 --- /dev/null +++ b/makefiles/vue.make @@ -0,0 +1,82 @@ +################################################## +### Vue +################################################## + +## Install and serve locally +up: yarn-install vue-cli-install install serve + +## Install dependencies +install: + @if [ ! -d node_modules ] && [ -f yarn.lock ]; then \ + printf "${INFO}yarn install${EOL}"; \ + yarn install; \ + elif [ ! -d node_modules ]; then \ + printf "${INFO}npm install${EOL}"; \ + npm install; \ + fi + +## Serve with hot reload at localhost +serve: + @printf "${INFO}nohup xdg-open http://localhost:${port} >/dev/null 2>&1${EOL}" + @nohup xdg-open http://localhost:${port} >/dev/null 2>&1 + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn serve${EOL}"; \ + yarn serve; \ + else \ + printf "${INFO}npm run serve${EOL}"; \ + npm run serve; \ + fi + +## Run unit tests +tests: + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn run test:unit${EOL}"; \ + yarn run test:unit; \ + else \ + printf "${INFO}npm run test:unit${EOL}"; \ + npm run test:unit; \ + fi + +## Lint and fix files +lint: + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn run lint${EOL}"; \ + yarn run lint; \ + else \ + printf "${INFO}npm run lint${EOL}"; \ + npm run lint; \ + fi + +## Build for production with minification +build: + @printf "${INFO}rm -rf ./dist${EOL}" + @rm -rf ./dist + @if [ -f yarn.lock ]; then \ + printf "${INFO}yarn build${EOL}"; \ + yarn build; \ + else \ + printf "${INFO}npm run build${EOL}"; \ + npm run build; \ + fi + +## Deploy to gh-pages +deploy: build + ( \ + printf "${INFO}cd dist${EOL}"; \ + cd dist; \ + printf "${INFO}git init${EOL}"; \ + git init; \ + printf "${INFO}git add -A${EOL}"; \ + git add -A; \ + printf "${INFO}git commit -m "$(shell date '+%Y-%m-%d %H:%M:%S')"${EOL}"; \ + git commit -m "$(shell date '+%Y-%m-%d %H:%M:%S')"; \ + printf "${INFO}git push -f git@{{ GIT_SERVER }}:{{ GIT_USER }}/{{ REPOSITORY }}.git main:gh-pages${EOL}"; \ + git push -f git@{{ GIT_SERVER }}:{{ GIT_USER }}/{{ REPOSITORY }}.git main:gh-pages; \ + ) + +## Uninstall app +uninstall: + @printf "${INFO}sudo rm -rf node_modules${EOL}" + @sudo rm -rf node_modules + @printf "${INFO}sudo rm -rf dist${EOL}" + @sudo rm -rf dist diff --git a/makefiles/vue_install_env.make b/makefiles/vue_install_env.make new file mode 100644 index 0000000..344c445 --- /dev/null +++ b/makefiles/vue_install_env.make @@ -0,0 +1,32 @@ +################################################## +### Yarn Install Local Env +################################################## + +## Install yarn +yarn-install: +ifeq (${SYSTEM}, Linux) + @if [ -z "$(shell yarn --version 2>/dev/null)" ]; then \ + printf "${INFO}curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -${EOL}"; \ + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -; \ + printf "${INFO}echo 'deb https://dl.yarnpkg.com/debian/ stable main' | sudo tee /etc/apt/sources.list.d/yarn.list${EOL}"; \ + echo 'deb https://dl.yarnpkg.com/debian/ stable main' | sudo tee /etc/apt/sources.list.d/yarn.list; \ + printf "${INFO}sudo apt-get update${EOL}"; \ + sudo apt-get update; \ + printf "${INFO}sudo apt-get install -y yarn${EOL}"; \ + sudo apt-get install -y yarn; \ + else \ + printf "${WARNING}yarn already installed, skipping...${EOL}"; \ + fi +endif + +## Install vue-cli +vue-cli-install: +ifeq (${SYSTEM}, Linux) + @if [ -z "$(shell vue --version 2>/dev/null)" ]; then \ + printf "${INFO}sudo yarn global add @vue/cli${EOL}"; \ + sudo yarn global add @vue/cli; \ + else \ + printf "${WARNING}vue-cli already installed, skipping...${EOL}"; \ + fi +endif + diff --git a/templates/.github/ISSUE_TEMPLATE/bug_report.md b/templates/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c36f449 --- /dev/null +++ b/templates/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Call script with parameters ... +2. Type ... +3. Wait for ... seconds +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. + +**Desktop (please complete the following information):** + - OS: [e.g. MacOS] + - make version (make --version) + - Script version + - copy/paste output + +**Additional context** +Add any other context about the problem here. diff --git a/templates/.github/ISSUE_TEMPLATE/feature_request.md b/templates/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/templates/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**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 context** +Add any other context or screenshots about the feature request here. diff --git a/templates/.github/workflows/bash_unit.yml b/templates/.github/workflows/bash_unit.yml new file mode 100644 index 0000000..f2ba729 --- /dev/null +++ b/templates/.github/workflows/bash_unit.yml @@ -0,0 +1,34 @@ +name: bash_unit CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + ubuntu: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: install Ubuntu dependencies with sudo apt install -y + run: sudo apt install -y gawk + + - name: Unit testing with bash_unit + run: ./entrypoint.sh tests + + macos: + runs-on: macos-latest + if: "contains(toJSON(github.event.commits.*.message), '[macos]')" + + steps: + - uses: actions/checkout@v2 + + - name: install MacOS dependencies with brew install + run: brew install gawk + + - name: Unit testing with bash_unit + run: ./entrypoint.sh tests diff --git a/templates/.github/workflows/make.yml b/templates/.github/workflows/make.yml new file mode 100644 index 0000000..c9a5e1b --- /dev/null +++ b/templates/.github/workflows/make.yml @@ -0,0 +1,34 @@ +name: Make CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + ubuntu: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: install Ubuntu dependencies with sudo apt install -y + run: sudo apt install -y gawk make + + - name: Check for basic execution + run: make generate + + macos: + runs-on: macos-latest + if: "contains(toJSON(github.event.commits.*.message), '[macos]')" + + steps: + - uses: actions/checkout@v2 + + - name: install MacOS dependencies with brew install + run: brew install gawk make + + - name: Check for basic execution + run: make generate diff --git a/templates/.github/workflows/node.yml b/templates/.github/workflows/node.yml new file mode 100644 index 0000000..9ac5c12 --- /dev/null +++ b/templates/.github/workflows/node.yml @@ -0,0 +1,23 @@ +name: Node CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + node: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@main + + - name: Install App + run: yarn install + + - name: Run unit tests + run: yarn tests diff --git a/templates/.github/workflows/php-composer.yaml b/templates/.github/workflows/php-composer.yaml new file mode 100644 index 0000000..0b6e069 --- /dev/null +++ b/templates/.github/workflows/php-composer.yaml @@ -0,0 +1,59 @@ +name: PHP CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + php: + name: PHP project (PHP ${{ matrix.php-versions }}) + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php-versions: ['7.1', '7.3', '7.4', '8.0'] + + steps: + # Setup Github actions + # https://github.com/actions/checkout (official) + - name: Checkout + uses: actions/checkout@v2 + + # Setup PHP + # https://github.com/shivammathur/setup-php (community) + - name: Setup PHP, extensions and composer with shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + env: + update: true + + - name: Check PHP Version + run: php -v + + # Install Composer + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Project + run: make install + + - name: Check for code quality errors + run: make lint + + - name: Run Unit tests + run: make tests diff --git a/templates/.github/workflows/php.yaml b/templates/.github/workflows/php.yaml new file mode 100644 index 0000000..46b2c6c --- /dev/null +++ b/templates/.github/workflows/php.yaml @@ -0,0 +1,45 @@ +name: PHP CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + php: + name: PHP project (PHP ${{ matrix.php-versions }}) + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + php-versions: ['7.3', '7.4', '8.0'] + + steps: + # Setup Github actions + # https://github.com/actions/checkout (official) + - name: Checkout + uses: actions/checkout@v2 + + # Setup PHP + # https://github.com/shivammathur/setup-php (community) + - name: Setup PHP, extensions and composer with shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: composer + + - name: Check PHP Version + run: php -v + + - name: Install Project + run: make install + + - name: Check for code quality errors + run: make lint + + - name: Run Unit tests + run: make tests diff --git a/templates/.github/workflows/sass.yml b/templates/.github/workflows/sass.yml new file mode 100644 index 0000000..249d5f1 --- /dev/null +++ b/templates/.github/workflows/sass.yml @@ -0,0 +1,23 @@ +name: Sass CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + sass: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@main + + - name: Install Sass + run: yarn global add sass + + - name: Compile Sass + run: sass ./scss/index.scss ./css/index.css diff --git a/templates/.github/workflows/shellcheck.yml b/templates/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..ac93b55 --- /dev/null +++ b/templates/.github/workflows/shellcheck.yml @@ -0,0 +1,18 @@ +name: ShellCheck CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + shellcheck: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Check for code quality errors + run: ./entrypoint.sh lint diff --git a/templates/.github/workflows/symfony.yml b/templates/.github/workflows/symfony.yml new file mode 100644 index 0000000..97cb07e --- /dev/null +++ b/templates/.github/workflows/symfony.yml @@ -0,0 +1,63 @@ +name: Symfony CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + symfony: + name: Symfony 5.2 (PHP 8.0) + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + + steps: + # Setup Github actions + # https://github.com/actions/checkout (official) + - name: Checkout + uses: actions/checkout@v2 + + # Setup PHP + # https://github.com/shivammathur/setup-php (community) + - name: Setup PHP, extensions and composer with shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + extensions: ctype, dom, filter, gd, iconv, intl, json, mbstring, pdo, pdo_mysql, xml + env: + update: true + + - name: Check PHP Version + run: php -v + + # Install Composer + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Project + run: ./entrypoint.sh install env=prod + + - name: Check for code quality errors + run: ./entrypoint.sh lint_sniff + + - name: Run Unit tests + run: ./entrypoint.sh unit_tests + + - name: Run Integration tests + run: ./entrypoint.sh integration_tests diff --git a/templates/APACHE.txt b/templates/APACHE.txt new file mode 100644 index 0000000..74bc722 --- /dev/null +++ b/templates/APACHE.txt @@ -0,0 +1,207 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, and + distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the + copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other + entities that control, are controlled by, or are under common control with + that entity. For the purposes of this definition, "control" means (i) the + power, direct or indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (ii) ownership of + fifty percent (50%) or more of the outstanding shares, or (iii) beneficial + ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising + permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation source, + and configuration files. + + "Object" form shall mean any form resulting from mechanical transformation + or translation of a Source form, including but not limited to compiled + object code, generated documentation, and conversions to + other media types. + + "Work" shall mean the work of authorship, whether in Source or Object + form, made available under the License, as indicated by a copyright notice + that is included in or attached to the work (an example is provided in the + Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object form, + that is based on (or derived from) the Work and for which the editorial + revisions, annotations, elaborations, or other modifications represent, + as a whole, an original work of authorship. For the purposes of this + License, Derivative Works shall not include works that remain separable + from, or merely link (or bind by name) to the interfaces of, the Work and + Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including the original + version of the Work and any modifications or additions to that Work or + Derivative Works thereof, that is intentionally submitted to Licensor for + inclusion in the Work by the copyright owner or by an individual or + Legal Entity authorized to submit on behalf of the copyright owner. + For the purposes of this definition, "submitted" means any form of + electronic, verbal, or written communication sent to the Licensor or its + representatives, including but not limited to communication on electronic + mailing lists, source code control systems, and issue tracking systems + that are managed by, or on behalf of, the Licensor for the purpose of + discussing and improving the Work, but excluding communication that is + conspicuously marked or otherwise designated in writing by the copyright + owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on + behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. + + Subject to the terms and conditions of this License, each Contributor + hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable copyright license to reproduce, prepare + Derivative Works of, publicly display, publicly perform, sublicense, + and distribute the Work and such Derivative Works in + Source or Object form. + +3. Grant of Patent License. + + Subject to the terms and conditions of this License, each Contributor + hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable (except as stated in this section) patent + license to make, have made, use, offer to sell, sell, import, and + otherwise transfer the Work, where such license applies only to those + patent claims licensable by such Contributor that are necessarily + infringed by their Contribution(s) alone or by combination of their + Contribution(s) with the Work to which such Contribution(s) was submitted. + If You institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work or a + Contribution incorporated within the Work constitutes direct or + contributory patent infringement, then any patent licenses granted to + You under this License for that Work shall terminate as of the date such + litigation is filed. + +4. Redistribution. + + You may reproduce and distribute copies of the Work or Derivative Works + thereof in any medium, with or without modifications, and in Source or + Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a + copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from + the Source form of the Work, excluding those notices that do not pertain + to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable copy + of the attribution notices contained within such NOTICE file, excluding + those notices that do not pertain to any part of the Derivative Works, + in at least one of the following places: within a NOTICE text file + distributed as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, within a + display generated by the Derivative Works, if and wherever such + third-party notices normally appear. The contents of the NOTICE file are + for informational purposes only and do not modify the License. + You may add Your own attribution notices within Derivative Works that You + distribute, alongside or as an addendum to the NOTICE text from the Work, + provided that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and may + provide additional or different license terms and conditions for use, + reproduction, or distribution of Your modifications, or for any such + Derivative Works as a whole, provided Your use, reproduction, and + distribution of the Work otherwise complies with the conditions + stated in this License. + +5. Submission of Contributions. + + Unless You explicitly state otherwise, any Contribution intentionally + submitted for inclusion in the Work by You to the Licensor shall be under + the terms and conditions of this License, without any additional + terms or conditions. Notwithstanding the above, nothing herein shall + supersede or modify the terms of any separate license agreement you may + have executed with Licensor regarding such Contributions. + +6. Trademarks. + + This License does not grant permission to use the trade names, trademarks, + service marks, or product names of the Licensor, except as required for + reasonable and customary use in describing the origin of the Work and + reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + + Unless required by applicable law or agreed to in writing, Licensor + provides the Work (and each Contributor provides its Contributions) + on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied, including, without limitation, any warranties + or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS + FOR A PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any risks + associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + + In no event and under no legal theory, whether in tort + (including negligence), contract, or otherwise, unless required by + applicable law (such as deliberate and grossly negligent acts) or agreed + to in writing, shall any Contributor be liable to You for damages, + including any direct, indirect, special, incidental, or consequential + damages of any character arising as a result of this License or out of + the use or inability to use the Work (including but not limited to damages + for loss of goodwill, work stoppage, computer failure or malfunction, + or any and all other commercial damages or losses), even if such + Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + + While redistributing the Work or Derivative Works thereof, You may choose + to offer, and charge a fee for, acceptance of support, warranty, + indemnity, or other liability obligations and/or rights consistent with + this License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf of any + other Contributor, and only if You agree to indemnify, defend, and hold + each Contributor harmless for any liability incurred by, or claims + asserted against, such Contributor by reason of your accepting any such + warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + + To apply the Apache License to your work, attach the following boilerplate + notice, with the fields enclosed by brackets "[]" replaced with your own + identifying information. (Don't include the brackets!) The text should be + enclosed in the appropriate comment syntax for the file format. We also + recommend that a file or class name and description of purpose be included + on the same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {{ YEAR }} {{ AUTHOR }} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the License for the specific language governing + permissions and limitations under the License. \ No newline at end of file diff --git a/templates/CHANGELOG.md b/templates/CHANGELOG.md new file mode 100644 index 0000000..59c58a9 --- /dev/null +++ b/templates/CHANGELOG.md @@ -0,0 +1,22 @@ +Change Log +========== + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] +- WIP + +## [{{ VERSION }}](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/releases/tag/{{ VERSION }}) +### Added +- Install / uninstall script +- doc with screenshot +- CHANGELOG.md +- CODE_OF_CONDUCT.md +- CONTRIBUTING.md +- ISSUE_TEMPLATE/bug_report.md +- ISSUE_TEMPLATE/feature_request.md +- Github: workflows/bash_unit.yml +- Github: workflows/shellcheck.yml diff --git a/templates/CODE_OF_CONDUCT.md b/templates/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..07f4a0c --- /dev/null +++ b/templates/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 {{ 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 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/templates/CONTRIBUTING.md b/templates/CONTRIBUTING.md new file mode 100644 index 0000000..6866f72 --- /dev/null +++ b/templates/CONTRIBUTING.md @@ -0,0 +1,242 @@ +# Contributing + +## How do I... + +* [Use This Guide](#introduction)? +* Ask or Say Something? 🤔🐛😱 + * [Request Support](#request-support) + * [Report an Error or Bug](#report-an-error-or-bug) + * [Request a Feature](#request-a-feature) +* Make Something? 🤓👩🏽‍💻📜🍳 + * [Project Setup](#project-setup) + * [Contribute Documentation](#contribute-documentation) + * [Contribute Code](#contribute-code) +* Manage Something ✅🙆🏼💃👔 + * [Provide Support on Issues](#provide-support-on-issues) + * [Label Issues](#label-issues) + * [Clean Up Issues and PRs](#clean-up-issues-and-prs) + * [Review Pull Requests](#review-pull-requests) + * [Merge Pull Requests](#merge-pull-requests) + * [Tag a Release](#tag-a-release) + * [Join the Project Team](#join-the-project-team) +* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻 + +## Introduction + +Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝 + +Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚 + +## Request Support + +If you have a question about this project, how to use it, or just need clarification about something: + +* Open an Issue at https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues +* Provide as much context as you can about what you're running into. +* Provide project and platform versions (bash, basher, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* Someone will try to have a response soon. +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). + If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. + +## Report an Error or Bug + +If you run into an error or bug with the project: + +* Open an Issue at https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues +* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own. +* Provide project and platform versions (OS, bash, basher, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code). +* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made. +* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline. + +## Request a Feature + +If the project doesn't do something you need or want it to do: + +* Open an Issue at https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues +* Provide as much context as you can about what you're running into. +* Please be clear about why existing features and alternatives would not work for you. + +Once it's filed: + +* The project team will [label the issue](#label-issues). +* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward. +* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code). + +Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no. + +## Project Setup + +So you want to contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before. + +If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code). + +If you want to go the usual route and run the project locally, though: + +* [Fork the project](https://guides.github.com/activities/forking/#fork) + +Then in your terminal: +* `cd path/to/your/clone` + +And you should be ready to go! + +## Contribute Documentation + +Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance. + +Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake! + +To contribute documentation: + +* [Set up the project](#project-setup). +* Edit or add any relevant documentation. +* Make sure your changes are formatted correctly and consistently with the rest of the documentation. +* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `. +* Go to https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Contribute Code + +We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others. + +Code contributions of just about any size are acceptable! + +The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution. + +To contribute code: + +* [Set up the project](#project-setup). +* Make any necessary changes to the source code. +* Include any [additional documentation](#contribute-documentation) the changes might need. +* Write tests that verify that your contribution works as expected. +* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). +* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion. +* Go to https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/pulls and open a new pull request with your changes. +* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing. + +Once you've filed the PR: + +* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc). +* One or more maintainers will use GitHub's review feature to review your PR. +* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review. +* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚 +* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release) + +## Provide Support on Issues + +Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug. + +Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it. + +In order to help other folks out with their questions: + +* Go to the issue tracker and [filter open issues by the `support` label](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues?q=is%3Aopen+is%3Aissue+label%3Asupport). +* Read through the list until you find something that you're familiar enough with to give an answer to. +* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on. +* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you. + +Some notes on picking up support issues: + +* Avoid responding to issues you don't know you can answer accurately. +* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format. +* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict). + +## Label Issues + +One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily. + +In order to label issues, [open up the list of unlabeled issues](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself! + +Label | Apply When | Notes +--- | --- | --- +`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label. +`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. | +`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`. +`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`) +`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. | +`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling. +`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete. +`performance` | This issue or PR is directly related to improving performance. | +`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. | +`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority. +`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes. +`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests) +`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not. + +## Clean Up Issues and PRs + +Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon. + +In these cases, they should be closed until they're brought up again or the interaction starts over. + +To clean up issues and PRs: + +* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today. +* Go through each issue *from oldest to newest*, and close them if **all of the following are true**: + * not opened by a maintainer + * not marked as `critical` + * not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available) + * no explicit messages in the comments asking for it to be left open + * does not belong to a milestone +* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details." + +## Review Pull Requests + +While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions. + +PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration. + +Some notes: + +* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments". +* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers. +* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own. +* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it? + +## Merge Pull Requests + +Project Team will merge pull requests after review. + +## Tag A Release + +Project Team will bump tags/version with [setver](https://github.com/pforret/setver) as a patch or minor versionupdate. +Releases are done manually for important changes. + + +## Join the Project Team + +### Ways to Join + +There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do. + +All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like. + +You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names. + +Permission | Description +--- | --- +Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker. +Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team. +Admin/Owner | Granted to people ultimately responsible for the project, its community, etc. + +## Attribution + +This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)! + diff --git a/templates/GPL2.txt b/templates/GPL2.txt new file mode 100644 index 0000000..313715b --- /dev/null +++ b/templates/GPL2.txt @@ -0,0 +1,325 @@ +The GNU General Public License (GPL-2.0) +Version 2, June 1991 +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply +it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. +Our General Public Licenses are designed to make sure that you have the +freedom to distribute copies of free software (and charge for this service +if you wish), that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free programs; +and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or +for a fee, you must give the recipients all the rights that you have. +You must make sure that they, too, receive or can get the source code. +And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. +If the software is modified by someone else and passed on, we want its +recipients to know that what they have is not the original, so that any +problems introduced by others will not reflect on the +original authors' reputations. + +Finally, any free program is threatened constantly by software patents. +We wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program proprietary. +To prevent this, we have made it clear that any patent must be licensed for +everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution +and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such +program or work, and a "work based on the Program" means either the Program +or any derivative work under copyright law: that is to say, a work containing +the Program or a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is included +without limitation in the term "modification".) +Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program +is not restricted, and the output from the Program is covered only if its +contents constitute a work based on the Program (independent of having been +made by running the Program). Whether that is true depends on +what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code +as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +License and to the absence of any warranty; and give any other recipients +of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that you +also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating + that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole + or in part contains or is derived from the Program or any part thereof, + to be licensed as a whole at no charge to all third parties under + the terms of this License. + + c) If the modified program normally reads commands interactively when run, + you must cause it, when started running for such interactive use in the + most ordinary way, to print or display an announcement including an + appropriate copyright notice and a notice that there is no warranty + (or else, saying that you provide a warranty) and that users may + redistribute the program under these conditions, and telling the user how + to view a copy of this License. (Exception: if the Program itself is + interactive but does not normally print such an announcement, your work + based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part +regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective +works based on the Program. + +In addition, mere aggregation of another work not based on the Program with +the Program (or with a work based on the Program) on a volume of a storage +or distribution medium does not bring the other work under +the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source + code, which must be distributed under the terms of Sections 1 and 2 above + on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to + give any third party, for a charge no more than your cost of physically + performing source distribution, a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Sections 1 and 2 above on a medium customarily used + for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed only + for noncommercial distribution and only if you received the program in + object code or executable form with such an offer, in accord + with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and +installation of the executable. However, as a special exception, the source +code distributed need not include anything that is normally distributed +(in either source or binary form) with the major components (compiler, kernel, +and so on) of the operating system on which the executable runs, unless that +component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source +along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Program +(or any work based on the Program), you indicate your acceptance of this +License to do so, and all its terms and conditions for copying, distributing +or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor +to copy, distribute or modify the Program subject to these terms +and conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or otherwise) +that contradict the conditions of this License, they do not excuse you from +the conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly +through you, then the only way you could satisfy both it and this License +would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system, which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of +that system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee +cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. +In such case, this License incorporates the limitation as if written +in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar +in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and conditions +either of that version or of any later version published by the +Free Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published +by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of +all derivatives of our free software and of promoting the sharing +and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + Copyright (C) {{ YEAR }} {{ AUTHOR }} + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when +it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision + comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is + free software, and you are welcome to redistribute it under certain + conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Library General +Public License instead of this License. \ No newline at end of file diff --git a/templates/GPL3.txt b/templates/GPL3.txt new file mode 100644 index 0000000..30d7af7 --- /dev/null +++ b/templates/GPL3.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {{ PROJECT }} Copyright (C) {{ YEAR }} {{ AUTHOR }} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/templates/MIT.txt b/templates/MIT.txt new file mode 100644 index 0000000..710af72 --- /dev/null +++ b/templates/MIT.txt @@ -0,0 +1,21 @@ +MIT License + +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. diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 0000000..c408798 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,476 @@ +![GH language](https://img.shields.io/github/languages/top/{{ GIT_USER }}/{{ REPOSITORY }}) +[![GH tag](https://img.shields.io/github/v/tag/{{ GIT_USER }}/{{ REPOSITORY }})](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/tags) +[![GH release](https://img.shields.io/github/v/release/{{ GIT_USER }}/{{ REPOSITORY }})](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/releases) +[![GH license](https://img.shields.io/github/license/{{ GIT_USER }}/{{ REPOSITORY }})]((https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/blob/main/LICENSE)) +[![GH stars](https://img.shields.io/github/stars/{{ GIT_USER }}/{{ REPOSITORY }})](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/stargazers) +[![Bash CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/bash_unit%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/bash_unit.yml) +[![Make CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/Make%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/make.yml) +[![Node CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/Node%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/node.yml) +[![PHP CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/PHP%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/php.yml) +[![ShellCheck CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/ShellCheck%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/shellcheck.yml) +[![Symfony CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/Symfony%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/symfony.yml) +![visitors](https://visitor-badge.glitch.me/badge?page_id={{ GIT_USER }}.{{ REPOSITORY }}) + +{{ PROJECT }} +=== + +{{ DESCRIPTION }} + +⏳ TL;DR +-------- + +[place here a short description of how to install and use your project] + +📑 Documentation +---------------- + +Documentation available here: [./docs/{{ REPOSITORY }}.md](./docs/{{ REPOSITORY }}.md) + +🎯 Features +----------- + +**{{ PROJECT }}** provides the following features: + +- ⚡ Feature 1 +- ⚡ Feature 2 +- ⚡ Feature 3 +- ⚡ Feature 4 + +🚀 Installation +--------------- + +### ⚡ Step 1: Simply enter following command in your terminal + +```bash +$ make [command] +``` + +🔥 Usage +-------- + +Run `make` to print help + +```bash +$ make [command] {{ USAGE }} +``` + +Available commands are: `{{ PHONY }}` + +🤖 Commands +----------- + +{{ MARKDOWN }} + +💻 Dependencies +--------------- + +**{{ PROJECT }}** requires the following dependencies: + +- bash_unit +- Composer +- Docker +- Docker-compose +- Gawk +- git +- Make +- Node.js +- npm +- PHP +- Python3 +- Python3-pip +- Sass +- Sed +- Yarn + +--- + +### 🔎 bash_unit + +#### 🐧 Install bash_unit (Linux) + +```bash +# download binary with wget +wget -qO "./tests/bash_unit" https://raw.githubusercontent.com/pgrange/bash_unit/master/bash_unit +# download binary with curl +curl -sSL -o "./tests/bash_unit" https://raw.githubusercontent.com/pgrange/bash_unit/master/bash_unit +# download binary with git +git clone https://github.com/pgrange/bash_unit +``` + +--- + +### 📦 Composer + +Learn how to install Composer from official documentation [here](https://getcomposer.org/download/) + +#### 🐧 Install Composer (Linux) + +On linux machine install composer globally with the following commands (requires php): + +```bash +# download binary +$ php -r "copy('https://getcomposer.org/composer-stable.phar', 'composer.phar');" +# install composer globally +$ sudo mv composer.phar /usr/local/bin/composer +# fix permissions +$ sudo chmod uga+x /usr/local/bin/composer +$ sync +# install symfony flex globally to speed up download of composer packages (parallelized prefetching) +$ composer global require 'symfony/flex' --prefer-dist --no-progress --no-suggest --classmap-authoritative +$ composer clear-cache +``` + +--- + +### 🐋 Docker + +#### 🐧 Install Docker (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes docker.io +``` + +#### 🔧 Configure Docker (Linux) + +Add current user to docker group + +```bash +$ sudo usermod -a -G docker ${USER} +``` + +> You will need to log out and log back in current user to use docker + +> If your group membership is not properly re-evaluated, enter following command + +```bash +$ newgrp docker +``` + +#### 🏁 Install Docker (Windows) + +Download docker community edition installer from docker hub: + +- [https://hub.docker.com/editions/community/docker-ce-desktop-windows](https://hub.docker.com/editions/community/docker-ce-desktop-windows) + +#### 🍎 Install Docker (OSX) + +Download docker community edition installer from docker hub: + +- [https://hub.docker.com/editions/community/docker-ce-desktop-mac](https://hub.docker.com/editions/community/docker-ce-desktop-mac) + +--- + +### 🐳 Docker Compose + +#### 🐧 Install Docker Compose (Linux) + +On linux machine you will need curl to install docker-compose with the following commands + +```bash +$ sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m`" -o /usr/bin/docker-compose +$ sudo chmod uga+x /usr/bin/docker-compose +$ sync +``` + +--- + +### 🔖 git + +#### 🐧 Install git (Linux) + +```bash +$ sudo apt-get install --assume-yes git +``` + +#### 🏁 Install git (Windows) + +Download and install latest version from here [git-scm.com](https://git-scm.com/download/win) + +#### 🍎 Install git (OSX) + +```bash +$ brew install git +``` + +#### 🔧 git configuration + +Push current branch only if upstream exists + +```bash +$ git config --global push.default simple +``` + +Set vim as git default editor + +```bash +$ git config --global core.editor 'vim' +``` + +### ⚡ Initialize git submodules + +In order to download project submodules, enter the following command + +```bash +$ git submodule update --init --recursive +``` + +--- + +### 🛠 Gawk + +#### 🐧 Install Gawk (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes gawk +``` + +#### 🏁 Install Gawk (Windows) + +On windows machine you will need to install [cygwin](http://www.cygwin.com/) or Gawk for Windows](http://gnuwin32.sourceforge.net/packages/gawk.htm) first to execute script. + +#### 🍎 Install Gawk (OSX) + +Gawk should be available by default on OSX system, but you can upgrade Gawk version with following command + +```bash +$ brew install gawk +``` + +--- + +### 🛠 Make + +#### 🐧 Install Make (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes make +``` + +#### 🏁 Install Make (Windows) + +On windows machine you will need to install [cygwin](http://www.cygwin.com/) or [GnuWin make](http://gnuwin32.sourceforge.net/packages/make.htm) first to execute make script. + +#### 🍎 Install Make (OSX) + +Make should be available by default on OSX system, but you can upgrade make version with following command + +```bash +$ brew install make +``` + +--- + +### 🦖 Node.js + +#### 🐧 Install Node.js (Linux) + +On linux machine install node globally with the following commands (requires curl): + +```bash +$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - +$ sudo apt-get install --assume-yes nodejs +``` + +#### 🏁 Install Node.js (Windows) + +Download and install recommended LTS version from here: [Node.js](https://nodejs.org/en/download) + +#### 🍎 Install Node.js (OSX) + +Download and install recommended LTS version from here: [Node.js](https://nodejs.org/en/download) + +--- + +### 🐘 PHP + +Learn how to install PHP from official documentation [here](https://www.php.net/manual/en/install.php) + +#### 🐧 Install PHP (Linux) + +On linux machine enter following commands + +```bash +$ sudo add-apt-repository --assume-yes ppa:ondrej/php +$ sudo apt-get update +$ sudo apt-get install --assume-yes php7.2 +``` + +--- + +### 🐍 Python3 + +#### 🐧 Install Python3 (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes python3 +``` + +#### 🏁 Install Python3 (Windows) + +Download and install latest version from here [python.org](https://python.org) + +#### 🍎 Install Python3 (OSX) + +You can install python through the Homebrew package manager. Homebrew will install python-pip as well. + +```bash +$ brew install python +``` + +--- + +### 🐍 Python3-pip + +#### 🐧 Install Python3-pip (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes python3-pip +``` + +--- + +### 🦄 Sass + +#### 🐧 Install Sass (Linux) + +On linux machine install sass globally with the following commands. + +With yarn: +```bash +$ sudo yarn global add sass +``` + +With npm: +```bash +$ sudo npm install sass -g +``` + +--- + +### 🛠 Sed + +#### 🐧 Install Sed (Linux) + +On linux machine enter following command + +```bash +$ sudo apt-get install --assume-yes sed +``` + +#### 🏁 Install Sed (Windows) + +On windows machine you will need to install [cygwin](http://www.cygwin.com/) or [Sed for Windows](http://gnuwin32.sourceforge.net/packages/sed.htm) first to execute script. + +#### 🍎 Install Sed (OSX) + +Sed should be available by default on OSX system, but you can upgrade Sed version with following command + +```bash +$ brew install sed +``` + +--- + +### 🧶 Yarn + +#### 🐧 Install Yarn (Linux) + +On linux machine install yarn globally with the following commands (requires curl): + +```bash +$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +$ sudo apt-get update +$ sudo apt-get install --assume-yes yarn +``` + +#### 🏁 Install Yarn (Windows) + +Download and install latest version from here: [yarnpkg.com](https://classic.yarnpkg.com/en/docs/install/#windows-stable) + +#### 🍎 Install Yarn (OSX) + +You can install Yarn through the Homebrew package manager. This will also install Node.js if it is not already installed. + +```bash +$ brew install yarn +``` + +--- + +### 🕶 Vue-Cli + +#### 🧶 Install With Yarn + +```bash +$ sudo yarn global add @vue/cli +``` + +#### 📦 Install With npm + +```bash +$ sudo npm install -g @vue/cli-service-global +``` + +--- + +📝 Notes +-------- + +- Note 1 +- Note 2 +- Note 3 +- Note 4 + +🗓 Todo +------- + +- Task 1 +- Task 2 +- Task 3 +- Task 4 + +🔮 Roadmap +---------- + +- Release 0.1.0 + +🤝 Contributing +--------------- + +Thank you for your interest in contributing to **{{ PROJECT }}**. + +Please review the [code of conduct](./CODE_OF_CONDUCT.md) and [contribution guidelines](./CONTRIBUTING.md) before starting to work on any features. + +If you want to open an issue, please check first if it was not [reported already](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues) before creating a new one. + +📜 License +---------- + +Copyrights (c) {{ YEAR }} "{{ AUTHOR }}" <{{ EMAIL }}> + +[![License](https://img.shields.io/badge/Licence-{{ LICENSE }}-green.svg)](LICENSE) +Distributed under the {{ LICENSE }} license. + +If you like **{{ PROJECT }}** please star, follow or tweet about it: + +[![GitHub stars](https://img.shields.io/github/stars/{{ GIT_USER }}/{{ REPOSITORY }}?style=social)](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/stargazers) +[![GitHub followers](https://img.shields.io/github/followers/{{ GIT_USER }}?style=social)](https://{{ GIT_SERVER }}/{{ GIT_USER }}) +[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2F{{ GIT_SERVER }}%2F{{ GIT_USER }}%2F{{ REPOSITORY }})](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2F{{ GIT_SERVER }}%2F{{ GIT_USER }}%2F{{ REPOSITORY }}) + +... And check my other cool projects. + +🙏 Acknowledgements +------------------- + +Script created with [makefile-generator](https://github.com/TangoMan75/makefile-generator) diff --git a/templates/README_FR.md b/templates/README_FR.md new file mode 100644 index 0000000..84f3806 --- /dev/null +++ b/templates/README_FR.md @@ -0,0 +1,476 @@ +![GH language](https://img.shields.io/github/languages/top/{{ GIT_USER }}/{{ REPOSITORY }}) +[![GH tag](https://img.shields.io/github/v/tag/{{ GIT_USER }}/{{ REPOSITORY }})](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/tags) +[![GH release](https://img.shields.io/github/v/release/{{ GIT_USER }}/{{ REPOSITORY }})](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/releases) +[![GH license](https://img.shields.io/github/license/{{ GIT_USER }}/{{ REPOSITORY }})]((https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/blob/main/LICENSE)) +[![GH stars](https://img.shields.io/github/stars/{{ GIT_USER }}/{{ REPOSITORY }})](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/stargazers) +[![Bash CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/bash_unit%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/bash_unit.yml) +[![Make CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/Make%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/make.yml) +[![Node CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/Node%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/node.yml) +[![PHP CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/PHP%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/php.yml) +[![ShellCheck CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/ShellCheck%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/shellcheck.yml) +[![Symfony CI](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/workflows/Symfony%20CI/badge.svg)](https://github.com/{{ GIT_USER }}/{{ REPOSITORY }}/actions/workflows/symfony.yml) +![visiteurs](https://visitor-badge.glitch.me/badge?page_id={{ GIT_USER }}.{{ REPOSITORY }}) + +{{ PROJECT }} +=== + +{{ DESCRIPTION }} + +⏳ TL;DR +-------- + +[décrivez brièvement ici comment installer et utiliser votre projet] + +📑 Documentation +---------------- + +La documentation de ce projet est disponible ici : [./docs/{{ REPOSITORY }}.md](./docs/{{ REPOSITORY }}.md) + +🎯 Fonctionalités +----------------- + +**{{ PROJECT }}** permet d'utiliser ces fonctionalités : + +- ⚡ Fonctionalité 1 +- ⚡ Fonctionalité 2 +- ⚡ Fonctionalité 3 +- ⚡ Fonctionalité 4 + +🚀 Installation +--------------- + +### ⚡ Étape 1: Entrez simplement la commande suivante dans votre terminal + +```bash +$ make [command] +``` + +🔥 Usage +-------- + +Run `make` to print help + +```bash +$ make [command] {{ USAGE }} +``` + +Available commands are: `{{ PHONY }}` + +🤖 Commandes +------------ + +{{ MARKDOWN }} + +💻 Dépendances +-------------- + +**{{ PROJECT }}** repose sur les dépendances suivantes : + +- bash_unit +- Composer +- Docker +- Docker-compose +- Gawk +- git +- Make +- Node.js +- npm +- PHP +- Python3 +- Python3-pip +- Sass +- Sed +- Yarn + +--- + +### 🔎 bash_unit + +#### 🐧 Installer bash_unit (Linux) + +```bash +# download binary with wget +wget -qO "./tests/bash_unit" https://raw.githubusercontent.com/pgrange/bash_unit/master/bash_unit +# download binary with curl +curl -sSL -o "./tests/bash_unit" https://raw.githubusercontent.com/pgrange/bash_unit/master/bash_unit +# download binary with git +git clone https://github.com/pgrange/bash_unit +``` + +--- + +### 📦 Composer + +#### 🐧 Installer Composer (Linux) + +Sur une machine Linux, installez _composer_ globalement avec les commandes suivantes (nécessite php): + +```bash +# download binary +$ php -r "copy('https://getcomposer.org/composer-stable.phar', 'composer.phar');" +# install composer globally +$ sudo mv composer.phar /usr/local/bin/composer +# fix permissions +$ sudo chmod uga+x /usr/local/bin/composer +$ sync +# install symfony flex globally to speed up download of composer packages (parallelized prefetching) +$ composer global require 'symfony/flex' --prefer-dist --no-progress --no-suggest --classmap-authoritative +$ composer clear-cache +``` + +--- + +### 🐋 Docker + +#### 🐧 Installer Docker (Linux) + +Sur une machine sous Linux, entrez la commande suivante + +```bash +$ sudo apt-get install --assume-yes docker.io +``` + +#### 🔧 Configurer Docker (Linux) + +Ajouter l'utilisateur courant au groupe _"Docker"_ + +```bash +$ sudo usermod -a -G docker ${USER} +``` + +> Vous devrez vous déconnecter et vous reconnecter à l'utilisateur courant pour utiliser docker + +> Si vous n'avez pas été correctement inclu dans le groupe, entrez la commande suivante + +```bash +$ newgrp docker +``` + +#### 🏁 Installer Docker (Windows) + +Téléchargez le programme d'installation de _Docker Community Edition_ à partir de _Docker Hub_ : + +- [https://hub.docker.com/editions/community/docker-ce-desktop-windows](https://hub.docker.com/editions/community/docker-ce-desktop-windows) + +#### 🍎 Installer Docker (OSX) + +Téléchargez le programme d'installation de _Docker Community Edition_ à partir de _Docker Hub_ : + +- [https://hub.docker.com/editions/community/docker-ce-desktop-mac](https://hub.docker.com/editions/community/docker-ce-desktop-mac) + +--- + +### 🐳 Docker Compose + +#### 🐧 Installer Docker Compose (Linux) + +Sur une machine sous Linux, vous aurez besoin de _curl_ pour installer _docker-compose_ avec les commandes suivantes + +```bash +$ sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m`" -o /usr/bin/docker-compose +$ sudo chmod uga+x /usr/bin/docker-compose +$ sync +``` + +--- + +### 🔖 git + +#### 🐧 Installer git (Linux) + +```bash +$ sudo apt-get install --assume-yes git +``` + +#### 🏁 Installer git (Windows) + +Téléchargez et installez la dernière version à partir de [git-scm.com](https://git-scm.com/download/win) + +#### 🍎 Installer git (OSX) + +```bash +$ brew install git +``` + +#### 🔧 Configuration de git + +Pousser la branche actuelle uniquement si l'amont existe + +```bash +$ git config --global push.default simple +``` + +Définir vim comme éditeur par défaut de git + +```bash +$ git config --global core.editor 'vim' +``` + +### ⚡ Initialiser les sous-modules + +Afin de télécharger des sous-modules de projet, entrez la commande suivante + +```bash +$ git submodule update --init --recursive +``` + +--- + +### 🛠 Gawk + +#### 🐧 Installer Gawk (Linux) + +Sur une machine sous Linux, entrez la commande suivante + +```bash +$ sudo apt-get install --assume-yes gawk +``` + +#### 🏁 Installer Gawk (Windows) + +Sur Windows, vous devrez d'abord installer [cygwin](http://www.cygwin.com/) ou [Gawk for Windows](http://gnuwin32.sourceforge.net/packages/gawk.htm) pour exécuter le script. + +#### 🍎 Install Gawk (OSX) + +Gawk devrait être disponible par défaut sur OSX, mais vous pouvez le mettre à jour avec la commande suivante + +```bash +$ brew install gawk +``` + +--- + +### 🛠 Make + +#### 🐧 Installer Make (Linux) + +Sur une machine sous Linux, entrez la commande suivante + +```bash +$ sudo apt-get install --assume-yes make +``` + +#### 🏁 Installer Make (Windows) + +Sur Windows, vous devrez d'abord installer [cygwin](http://www.cygwin.com/) ou [GnuWin make](http://gnuwin32.sourceforge.net/packages/make.htm) pour exécuter le script. + +#### 🍎 Install Make (OSX) + +Make devrait être disponible par défaut sur OSX, mais vous pouvez le mettre à jour avec la commande suivante + +```bash +$ brew install make +``` + +--- + +### 🦖 Node.js + +#### 🐧 Installer Node.js (Linux) + +Sur une machine sous Linux, installez _Node_ globalement avec les commandes suivantes (nécessite _curl_): + +```bash +$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - +$ sudo apt-get install --assume-yes nodejs +``` + +#### 🏁 Installer Node.js (Windows) + +Téléchargez et installez la version LTS à partir de [Node.js](https://nodejs.org/en/download) + +#### 🍎 Installer Node.js (OSX) + +Téléchargez et installez la version LTS à partir de [Node.js](https://nodejs.org/en/download) + +--- + +### 🐘 PHP + +#### 🐧 Installer PHP (Linux) + +Sur une machine sous Linux, entrez les commandes suivante + +```bash +$ sudo add-apt-repository --assume-yes ppa:ondrej/php +$ sudo apt-get update +$ sudo apt-get install --assume-yes php7.2 +``` + +--- + +### 🐍 Python3 + +#### 🐧 Installer Python3 (Linux) + +Sur une machine sous Linux, entrez la commande suivante + +```bash +$ sudo apt-get install --assume-yes python3 +``` + +#### 🏁 Installer Python3 (Windows) + +Téléchargez et installez la dernière version à partir de [python.org](https://python.org) + +#### 🍎 Installer Python3 (OSX) + +Vous pouvez installer _python_ via le gestionnaire de paquets _"Homebrew"_. _"Homebrew"_ installera également _python-pip_. + +```bash +$ brew install python +``` + +--- + +### 🐍 Python3-pip + +#### 🐧 Installer Python3-pip (Linux) + +Sur une machine sous Linux, entrez la commande suivante + +```bash +$ sudo apt-get install --assume-yes python3-pip +``` + +--- + +### 🦄 Sass + +#### 🐧 Installer Sass (Linux) + +Sur une machine sous Linux, installez _sass_ globalement avec les commandes suivantes + +With yarn: +```bash +$ sudo yarn global add sass +``` + +With npm: +```bash +$ sudo npm install sass -g +``` + +--- + +### 🛠 Sed + +#### 🐧 Installer Sed (Linux) + +Sur une machine sous Linux, entrez la commande suivante + +```bash +$ sudo apt-get install --assume-yes sed +``` + +#### 🏁 Installer Sed (Windows) + +Sur Windows, vous devrez d'abord installer [cygwin](http://www.cygwin.com/) ou [Sed for Windows](http://gnuwin32.sourceforge.net/packages/sed.htm) pour exécuter le script. + +#### 🍎 Install Sed (OSX) + +Sed devrait être disponible par défaut sur OSX, mais vous pouvez le mettre à jour avec la commande suivante + +```bash +$ brew install sed +``` + +--- + +### 🧶 Yarn + +#### 🐧 Installer Yarn (Linux) + +Sur une machine sous Linux, installez _yarn_ globalement avec les commandes suivantes (nécessite _curl_): + +```bash +$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +$ sudo apt-get update +$ sudo apt-get install --assume-yes yarn +``` + +#### 🏁 Installer Yarn (Windows) + +Téléchargez et installez la dernière version à partir de: [yarnpkg.com](https://classic.yarnpkg.com/en/docs/install/#windows-stable) + +#### 🍎 Installer Yarn (OSX) + +Vous pouvez installer Yarn via le gestionnaire de paquets _"Homebrew"_. Cela installera également Node.js s'il n'est pas déjà installé. + +```bash +$ brew install yarn +``` + +--- + +### 🕶 Vue-Cli + +#### 🧶 Installer avec Yarn + +Installez _vue-cli_ globalement avec la commande suivante + +```bash +$ sudo yarn global add @vue/cli +``` + +#### 📦 Installer avec npm + +Installez _vue-cli_ globalement avec la commande suivante + +```bash +$ sudo npm install -g @vue/cli-service-global +``` + +--- + +📝 Notes +-------- + +- Note 1 +- Note 2 +- Note 3 +- Note 4 + +🗓 À faire +---------- + +- Tâche 1 +- Tâche 2 +- Tâche 3 +- Tâche 4 + +🔮 Feuille de route +------------------- + +- Release 0.1.0 + +🤝 Contribuer +------------- + +Merci pour votre intérêt à apporter votre contribution à **{{ PROJECT }}**. + +Veuillez consulter le [code de conduite](./CODE_OF_CONDUCT.md) et les [directives de contribution](./CONTRIBUTING.md) avant de commencer à travailler sur des fonctionnalités. + +Si vous souhaitez ouvrir un rapport de bug, veuillez d'abord vérifier qu'il n'a pas [déjà été signalé](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/issues) avant d'en créer un nouveau. + +📜 License +---------- + +Copyrights (c) {{ YEAR }} "{{ AUTHOR }}" <{{ EMAIL }}> + +[![License](https://img.shields.io/badge/Licence-{{ LICENSE }}-green.svg)](LICENSE) +Distribué sous la licence {{ LICENSE }}. + +Si vous aimez **{{ PROJECT }}**, mettez une étoile, suivez-moi ou publiez un tweet. + +[![GitHub stars](https://img.shields.io/github/stars/{{ GIT_USER }}/{{ REPOSITORY }}?style=social)](https://{{ GIT_SERVER }}/{{ GIT_USER }}/{{ REPOSITORY }}/stargazers) +[![GitHub followers](https://img.shields.io/github/followers/{{ GIT_USER }}?style=social)](https://{{ GIT_SERVER }}/{{ GIT_USER }}) +[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2F{{ GIT_SERVER }}%2F{{ GIT_USER }}%2F{{ REPOSITORY }})](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2F{{ GIT_SERVER }}%2F{{ GIT_USER }}%2F{{ REPOSITORY }}) + +... Et jetez un oeil à mes autres projets. + +🙏 Remerciements +---------------- + +Ce script a été généré avec [makefile-generator](https://github.com/TangoMan75/makefile-generator) diff --git a/templates/entrypoint.sh b/templates/entrypoint.sh new file mode 100755 index 0000000..346d120 --- /dev/null +++ b/templates/entrypoint.sh @@ -0,0 +1,326 @@ +#!/bin/sh +set -e + +#/* +# * This script is based on TangoMan Shoe Shell Microframework version 0.10.1-xxs +# * +# * This file is distributed under to the MIT license. +# * +# * Copyright (c) 2023 "Matthias Morin" +# * +# * 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. +# * +# * Source code is available here: https://github.com/TangoMan75/shoe +# */ + +#/** +# * TangoMan Entrypoint +# * +# * @author "Matthias Morin" +# * @version 0.10.1-xxs +# * @link https://github.com/TangoMan75/shoe +# */ + +#-------------------------------------------------- +# Place your functions after this line +#-------------------------------------------------- + +## Return staged bash files +get_staged_bash_files() { + if [ ! -x "$(command -v git)" ]; then + echo_error "\"$(basename "${0}")\" requires git, try: 'sudo apt-get install -y git'\n" + exit 1 + fi + + if git rev-parse --verify HEAD >/dev/null 2>&1; then + against=HEAD + else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) + fi + + # --diff-filter + # A Added + # C Copied + # M Modified + # R Renamed + git diff-index --cached --name-only --diff-filter=ACMR "${against}" | grep \ + -e '\.bashrc' \ + -e '\.zshrc' \ + -e '\.bash_profile' \ + -e '\.sh$' || true +} + +## Return staged php files +get_staged_php_files() { + if [ ! -x "$(command -v git)" ]; then + echo_error "\"$(basename "${0}")\" requires git, try: 'sudo apt-get install -y git'\n" + exit 1 + fi + + if git rev-parse --verify HEAD >/dev/null 2>&1; then + against=HEAD + else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) + fi + + # --diff-filter + # A Added + # C Copied + # M Modified + # R Renamed + git diff-index --cached --name-only --diff-filter=ACMR "${against}" | grep -e '\.php$' +} + +## Install git hooks +hooks() { + echo_info 'rm -fr .git/hooks\n' + rm -fr .git/hooks + + echo_info 'cp -r .githooks .git/hooks\n' + cp -r .githooks .git/hooks + + echo_info 'chmod +x .git/hooks/*\n' + chmod +x .git/hooks/* +} + +## Install bash_unit framework +install() { + if [ ! -d ./tests ]; then + mkdir -p ./tests + + cat > "./tests/test_sample.sh" <\n' + echo_label 10 ' version'; echo_primary '0.10.1-xxs\n' + echo_label 10 ' link'; echo_primary 'https://github.com/TangoMan75/shoe\n\n' + echo_warning 'Description:\n' + echo_primary ' This is the main entrypoint for continuous integration and deployment.\n\n' | fold -w 64 -s + echo_warning 'Usage:\n' + printf "%b sh $(basename "${0}") [%bcommand%b]\n\n" "${INFO}" "${SUCCESS}" "${INFO}" + _print_commands 10 +} + +#-------------------------------------------------- + +_print_commands() { + # $1 = padding + if [ -z "$1" ]; then set -- 12; fi + printf "%bCommands:%b\n" "${WARNING}" "${DEFAULT}" + awk "/^### /{printf\"\n${WARNING}%s:${EOL}\",substr(\$0,5)} + /^(function )? *[a-zA-Z0-9_]+ *\(\) *\{/ { + sub(\"^function \",\"\"); gsub(\"[ ()]\",\"\"); + FUNCTION = substr(\$0, 1, index(\$0, \"{\")); + sub(\"{\$\", \"\", FUNCTION); + if (substr(PREV, 1, 3) == \"## \" && substr(\$0, 1, 1) != \"_\") + printf \"${SUCCESS} %-$1s ${DEFAULT}%s\n\", FUNCTION, substr(PREV, 4) + } { PREV = \$0 }" "$0" + printf '\n' +} + +#-------------------------------------------------- +# Reflexion +#-------------------------------------------------- + +_get_functions_names() { + if [ -z "$1" ]; then echo_error 'some mandatory parameter is missing.\n'; return 1; fi + # this regular expression matches functions with either bash or sh syntax + awk '/^(function )? *[a-zA-Z0-9_]+ *\(\) *\{/ { + sub("^function ",""); gsub("[ ()]",""); # remove leading "function ", round brackets and extra spaces + FUNCTION = substr($0, 1, index($0, "{")); # truncate string after opening curly brace + sub("{$", "", FUNCTION); # remove trailing curly brace + if (substr(PREV, 1, 3) == "## " && substr($0, 1, 1) != "_") print FUNCTION + } { PREV = $0 }' "$1" +} + +#-------------------------------------------------- +# Main loop +#-------------------------------------------------- + +_main() { + if [ $# -lt 1 ]; then + help + exit 0 + fi + + _execute='' + for _argument in "$@"; do + _is_valid=false + for _function in $(_get_functions_names "$0"); do + # get shorthand character + _shorthand="$(printf '%s' "${_function}" | awk '{$0=substr($0, 1, 1); print}')" + if [ "${_argument}" = "${_function}" ] || [ "${_argument}" = "${_shorthand}" ]; then + # append argument to the execute stack + _execute="${_execute} ${_function}" + _is_valid=true + break + fi + done + # unknown parameters will raise errors + if [ "${_is_valid}" = false ]; then + printf "${DANGER}error: \"%s\" is not a valid command${EOL}" "${_argument}" + exit 1 + fi + done + + for _function in ${_execute}; do + eval "${_function}" + done +} + +_main "$@"