├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md └── workflows │ └── integrate.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── PKGBUILD ├── README.md ├── assets ├── python_dir.PNG └── python_init.PNG ├── go.mod ├── go.sum ├── hydra ├── HEAD ├── config ├── description ├── hooks │ ├── applypatch-msg.sample │ ├── commit-msg.sample │ ├── fsmonitor-watchman.sample │ ├── post-update.sample │ ├── pre-applypatch.sample │ ├── pre-commit.sample │ ├── pre-merge-commit.sample │ ├── pre-push.sample │ ├── pre-rebase.sample │ ├── pre-receive.sample │ ├── prepare-commit-msg.sample │ ├── push-to-checkout.sample │ └── update.sample ├── info │ └── exclude ├── objects │ └── pack │ │ ├── pack-9130140b25475cf9f2e06660ca95f5d8ee000ef6.idx │ │ └── pack-9130140b25475cf9f2e06660ca95f5d8ee000ef6.pack └── packed-refs ├── linux_install.sh ├── macos_install.sh ├── pkg └── hydra-git │ ├── .BUILDINFO │ ├── .MTREE │ └── .PKGINFO ├── src ├── boilerplates │ ├── cssReset │ ├── flask │ ├── gemspec │ ├── html │ └── setupContent ├── build.sh ├── config.go ├── config_test.go ├── gitignores │ ├── c.gitignore │ ├── cpp.gitignore │ ├── go.gitignore │ ├── python.gitignore │ ├── ruby.gitignore │ └── web.gitignore ├── hydra.go ├── init.go ├── init_test.go ├── licenses │ ├── APACHE │ ├── BSD │ ├── EPL │ ├── GPL │ ├── MIT │ ├── MPL │ └── UNI ├── list.go ├── static.go ├── templates │ ├── go.json │ └── python.json ├── update.go └── utils.go ├── structures.md └── windows_install.ps1 /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. Windows, macOS] 28 | - Version of hydra you are using [e.g. v1.0.0] 29 | 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | You can add the code you're using. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/integrate.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: 4 | push: 5 | branches: [ main, 3.x ] 6 | pull_request: 7 | branches: [ main, 3.x ] 8 | 9 | jobs: 10 | 11 | windows: 12 | runs-on: windows-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Set up Go 17 | uses: actions/setup-go@v2 18 | with: 19 | go-version: 1.16 20 | 21 | - name: Build 22 | run: go build -v -o hydra.exe ./... 23 | 24 | - name: Test 25 | run: go test -v ./... 26 | 27 | 28 | macos: 29 | runs-on: macos-latest 30 | steps: 31 | - uses: actions/checkout@v2 32 | 33 | - name: Set up Go 34 | uses: actions/setup-go@v2 35 | with: 36 | go-version: 1.16 37 | 38 | - name: Build 39 | run: go build -v -o hydra ./... 40 | 41 | - name: Test 42 | run: go test -v ./... 43 | 44 | linux: 45 | runs-on: ubuntu-latest 46 | steps: 47 | - uses: actions/checkout@v2 48 | 49 | - name: Set up Go 50 | uses: actions/setup-go@v2 51 | with: 52 | go-version: 1.16 53 | 54 | - name: Build 55 | run: go build -v -o hydra ./... 56 | 57 | - name: Test 58 | run: go test -v ./... -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | bin/ 3 | *.exe 4 | *.exe~ 5 | *.dll 6 | *.so 7 | *.dylib 8 | 9 | # Test binary, built with `go test -c` 10 | *.test 11 | 12 | # Output of the go coverage tool, specifically when used with LiteIDE 13 | *.out 14 | 15 | # Visual Studio Code 16 | .vscode/ 17 | tempCodeRunnerFile.go 18 | 19 | # JetBrains IDEs 20 | .idea/ 21 | 22 | # Dependency directories (remove the comment below to include it) 23 | # vendor/ 24 | 25 | # Test Coverage 26 | coverage.html -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## v1.0.0 (31/3/2021) 4 | - First release 5 | 6 |
7 | 8 | ## v2.0.0 (8/4/2021) 9 | - Added the `list` command 10 | - Added the `config` command 11 | - Added support for gitignores and licenses 12 | 13 |
14 | 15 | ## v2.0.1 (15/4/2021) 16 | - Made a separate 'list.go' file for the `list` command 17 | - CI build bug fix (redefined embed paths for licenses and gitignores) 18 | 19 | ## v2.1.0 (28/4/2021) 20 | - Added support for web as a language type for project initialisation 21 | 22 | ## v2.2.0 (9/5/2021) 23 | - Added flask (python web framework), C, C++, and ruby as language types for project initialisation 24 | - Improved web initialisation 25 | - Added support for Unilicense 26 | - Changed the hydra config directory -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to hydra 2 | 3 | 👍🎉 First off, thanks for taking the time to contribute! 🎉👍 4 | 5 | The following is a set of guidelines for contributing to *hydra*, which is hosted on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. 6 | 7 | 8 | ## Project Structure 9 | ``` 10 | ├── .github 11 | | ├── ISSUE_TEMPLATE # issue templates 12 | | | ├── bug_report.md 13 | | | ├── custom.md 14 | | | └── feature_request.md 15 | | └── workflows # ci workflow 16 | | └── go.yml 17 | ├── .gitignore 18 | ├── CHANGELOG.md 19 | ├── CONTRIBUTING.md 20 | ├── LICENSE 21 | ├── README.md 22 | ├── assets # media assets for readme 23 | | ├── python_dir.PNG 24 | | └── python_init.PNG 25 | ├── config.go # config command code 26 | ├── gitignores # all gitignores 27 | | ├── go.gitignore 28 | | └── python.gitignore 29 | | └── ruby.gitignore 30 | | └── c.gitignore 31 | | └── c++.gitignore 32 | ├── go.mod 33 | ├── go.sum 34 | ├── hydra.go # main code for the cli 35 | ├── hydra_test.go # unittests for hydra 36 | ├── init.go # init command code 37 | ├── list.go # list command code 38 | └── licenses # all licenses 39 | ├── APACHE 40 | ├── BSD 41 | ├── EPL 42 | ├── GPL 43 | ├── MIT 44 | └── MPL 45 | └── UNI 46 | ``` 47 | 48 | ## Setup Development Environment 49 | This section shows how you can setup your development environment to contribute to hydra. 50 | 51 | - Fork the repository. 52 | - Clone it using Git (`git clone https://github.com/hydra.git`). 53 | - Create a new git branch (`git checkout -b "BRANCH NAME"`). 54 | - Install the `commando` module using the command `go get github.com/thatisuday/commando`. 55 | - Make changes. 56 | - Stage and commit (`git add .` and `git commit -m "COMMIT MESSAGE"`). 57 | - Push it your remote repository (`git push`). 58 | - Open a pull request by clicking [here](https://github.com/shravanasati/hydra/compare). 59 | 60 | 61 | ## Reporting Issues 62 | If you know a bug in the code or you want to file a feature request, open an issue. 63 | Choose the correct issue template from [here](https://github.com/shravanasati/hydra/issues/new/choose). -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-Present Shravan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PKGBUILD: -------------------------------------------------------------------------------- 1 | Maintainer: Shravan Asati 2 | pkgname=hydra-go 3 | pkgver=2.2.0 4 | pkgrel=1 5 | epoch= 6 | pkgdesc="hydra is a command line utility for generating language-specific project structures." 7 | arch=(x86_64 i686) 8 | url="https://github.com/shravanasati/hydra.git" 9 | license=('MIT') 10 | groups=() 11 | depends=() 12 | makedepends=(git curl) 13 | checkdepends=() 14 | optdepends=() 15 | provides=() 16 | conflicts=() 17 | replaces=() 18 | backup=() 19 | options=() 20 | install= 21 | changelog= 22 | source=("git+$url") 23 | noextract=() 24 | md5sums=("SKIP") 25 | validpgpkeys=() 26 | 27 | prepare() { 28 | cd "${_pkgname}" 29 | printf "2.2.r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 30 | } 31 | 32 | build() { 33 | cd hydra 34 | bash linux_install.sh 35 | 36 | } 37 | 38 | # check() { 39 | # cd "$pkgname-$pkgver" 40 | # make -k check 41 | # } 42 | 43 | package() { 44 | echo "hydra installation is sucessful" 45 | } 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hydra 2 | 3 | [![Continuous Integration](https://github.com/shravanasati/hydra/actions/workflows/integrate.yml/badge.svg)](https://github.com/shravanasati/hydra/actions/workflows/integrate.yml) 4 | 5 | *hydra* is a command line utility for generating language-specific project structures. 6 | 7 | ![python-init](assets/python_init.PNG) 8 | 9 | ⏬ 10 | 11 | ![python-dir](assets/python_dir.PNG) 12 | 13 |
14 | 15 | ## ✨ Features 16 | 17 | - Build project templates with just one command 18 | - Support for seven different licenses 19 | - Language-specific `.gitignore` file 20 | - Configure default language and default license to work with 21 | - Fast and reliable 22 | 23 |
24 | 25 | ## ⚡️ Installation 26 | 27 | **For Linux users:** 28 | 29 | If you use an Arch based distro, 30 | ``` 31 | yay -S hydra-go 32 | ``` 33 | Or any other AUR helper would work. 34 | 35 | Otherwise, 36 | 37 | Execute the following command in bash: 38 | 39 | ```bash 40 | curl https://raw.githubusercontent.com/shravanasati/hydra/main/linux_install.sh > hydra_install.sh 41 | 42 | chmod +x ./hydra_install.sh 43 | 44 | bash ./hydra_install.sh 45 | ``` 46 | 47 | 48 | **For MacOS users:** 49 | 50 | Execute the following command in bash: 51 | 52 | ```bash 53 | curl https://raw.githubusercontent.com/shravanasati/hydra/main/macos_install.sh > hydra_install.sh 54 | 55 | chmod +x ./hydra_install.sh 56 | 57 | bash ./hydra_install.sh 58 | ``` 59 | 60 | **For Windows users:** 61 | 62 | Open Powershell **as Admin** and execute the following command: 63 | ```powershell 64 | Set-ExecutionPolicy Bypass -Scope Process -Force; (Invoke-WebRequest -Uri https://raw.githubusercontent.com/shravanasati/hydra/main/windows_install.ps1 -UseBasicParsing).Content | powershell - 65 | ``` 66 | 67 | To verify the installation of *hydra*, open a new shell and execute `hydra -v`. You should see output like this: 68 | ``` 69 | hydra 2.2.0 70 | 71 | Version: 2.2.0 72 | ``` 73 | If the output isn't something like this, you need to repeat the above steps carefully. 74 | 75 | 76 | 77 |
78 | 79 | ## 💡 Usage 80 | This section shows how you can use *hydra*. 81 | 82 | ### config 83 | The `config` command is used to set or alter the hydra user configurations. 84 | 85 | `$ hydra config {flags}` 86 | 87 | The valid flags for config command are: 88 | - `name` --> The name of the user. 89 | It is used as the name of the copyright holder in the LICENSE file. 90 | 91 | - `github-username` --> The Github username of the user. 92 | It is used to initiate the modules in go. 93 | 94 | - `default-lang` --> The default language for project initialisation. It is used in case the `lang` argument is not provided in the `init` command. Valid options for the `default-lang` flag are: 95 | * go 96 | * python 97 | * web 98 | * flask 99 | * c 100 | * c++ 101 | * ruby 102 | 103 | - `default-license` --> The default license for project creation. Valid values are: 104 | * MIT 105 | * GPL 106 | * BSD 107 | * APACHE 108 | * EPL 109 | * MPL 110 | * UNI 111 | 112 | Once hydra is installed, it is advised to run the following command to complete the configuration. 113 | 114 | `$ hydra config --name "YOUR NAME" --github-username "YOUR GITHUB USERNAME"` 115 | 116 | 117 | ### list 118 | The `list` command is used to list supported languages, licenses and the hydra user configurations. 119 | 120 | `$ hydra list ` 121 | 122 | Valid options for the `item` argument are: 123 | - langs --> Languages supported by hydra 124 | - licenses --> Licenses supported by hydra 125 | - configs --> The hydra user configurations 126 | 127 | Example: `hydra list langs` 128 | 129 | ### init 130 | To create a new project structure using *hydra*, 131 | execute: 132 | 133 | `$ hydra init [lang]` 134 | 135 | The `init` command initialises the project. 136 | 137 | 138 | Valid options for the language argument are: 139 | - python 140 | - go 141 | - web 142 | - flask 143 | - c 144 | - c++ 145 | - ruby 146 | 147 | Example: `hydra init myProject python` 148 | 149 | In case the `lang` argument is not provided, hydra falls back to the `default-lang` configuration. 150 | 151 | You can view the [structures.md](structures.md) file to see the project structure hydra creates for every language it supports. 152 | 153 | 154 | ### version 155 | `$ hydra version` 156 | 157 | The version command shows the version of *hydra* installed. 158 | 159 | ### help 160 | `$ hydra help` 161 | 162 | Renders assistance for *hydra* on a terminal, briefly showing its usage. 163 | 164 |
165 | 166 | ## ⏩ Change Log 167 | The changes made in the latest version of hydra, *v2.2.0* are: 168 | 169 | - Added flask (python web framework), C, C++, and ruby as language types for project initialisation 170 | - Improved web initialisation 171 | - Added support for Unilicense 172 | - Changed the hydra config directory 173 | 174 | View [CHANGELOG.md](CHANGELOG.md) for more information. 175 | 176 |
177 | 178 | ## 🔖 Versioning 179 | *hydra* releases follow semantic versioning, every release is in the *x.y.z* form, where: 180 | - *x* is the MAJOR version and is incremented when a backwards incompatible change to hydra is made. 181 | - *y* is the MINOR version and is incremented when a backwards compatible change to hydra is made, like changing dependencies or adding a new function, method, struct field, or type. 182 | - *z* is the PATCH version and is incremented after making minor changes that don't affect hydra's public API or dependencies, like fixing a bug. 183 | 184 |
185 | 186 | ## 📄 License 187 | License 188 | © 2021-Present Shravan Asati 189 | 190 | This repository is licensed under the MIT license. See [LICENSE](LICENSE) for details. 191 | 192 |
193 | 194 | ## 👥 Contribution 195 | Pull requests are more than welcome. For more information on how to contribute to *hydra*, refer [CONTRIBUTING.md](CONTRIBUTING.md). 196 | -------------------------------------------------------------------------------- /assets/python_dir.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shravanasati/hydra/1082d2ed50d2be53589e92df5cb8874c36b6a53a/assets/python_dir.PNG -------------------------------------------------------------------------------- /assets/python_init.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shravanasati/hydra/1082d2ed50d2be53589e92df5cb8874c36b6a53a/assets/python_init.PNG -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/shravanasati/hydra 2 | 3 | go 1.16 4 | 5 | require github.com/thatisuday/commando v1.0.4 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/thatisuday/clapper v1.0.10 h1:1EkqE/nb4npp8DuTKnpvVzO/Mcac9lOPND34uUKF+bU= 2 | github.com/thatisuday/clapper v1.0.10/go.mod h1:FQGIg8q2uzeI+3SUS82YKF4E3KexkHStbiK4qTfDknM= 3 | github.com/thatisuday/commando v1.0.4 h1:aNdH9tvmx2EPG6rT3NTQOV/qFYPf4Ap4Spo+q+n9Ois= 4 | github.com/thatisuday/commando v1.0.4/go.mod h1:ODGz6jwJs4QqhLJtCjRRs8xIrmLLMdatYYddP+v1b4E= 5 | -------------------------------------------------------------------------------- /hydra/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/main 2 | -------------------------------------------------------------------------------- /hydra/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = true 5 | [remote "origin"] 6 | url = https://github.com/shravanasati/hydra.git 7 | fetch = +refs/*:refs/* 8 | mirror = true 9 | -------------------------------------------------------------------------------- /hydra/description: -------------------------------------------------------------------------------- 1 | Unnamed repository; edit this file 'description' to name the repository. 2 | -------------------------------------------------------------------------------- /hydra/hooks/applypatch-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to check the commit log message taken by 4 | # applypatch from an e-mail message. 5 | # 6 | # The hook should exit with non-zero status after issuing an 7 | # appropriate message if it wants to stop the commit. The hook is 8 | # allowed to edit the commit message file. 9 | # 10 | # To enable this hook, rename this file to "applypatch-msg". 11 | 12 | . git-sh-setup 13 | commitmsg="$(git rev-parse --git-path hooks/commit-msg)" 14 | test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} 15 | : 16 | -------------------------------------------------------------------------------- /hydra/hooks/commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to check the commit log message. 4 | # Called by "git commit" with one argument, the name of the file 5 | # that has the commit message. The hook should exit with non-zero 6 | # status after issuing an appropriate message if it wants to stop the 7 | # commit. The hook is allowed to edit the commit message file. 8 | # 9 | # To enable this hook, rename this file to "commit-msg". 10 | 11 | # Uncomment the below to add a Signed-off-by line to the message. 12 | # Doing this in a hook is a bad idea in general, but the prepare-commit-msg 13 | # hook is more suited to it. 14 | # 15 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') 16 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" 17 | 18 | # This example catches duplicate Signed-off-by lines. 19 | 20 | test "" = "$(grep '^Signed-off-by: ' "$1" | 21 | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { 22 | echo >&2 Duplicate Signed-off-by lines. 23 | exit 1 24 | } 25 | -------------------------------------------------------------------------------- /hydra/hooks/fsmonitor-watchman.sample: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use IPC::Open2; 6 | 7 | # An example hook script to integrate Watchman 8 | # (https://facebook.github.io/watchman/) with git to speed up detecting 9 | # new and modified files. 10 | # 11 | # The hook is passed a version (currently 2) and last update token 12 | # formatted as a string and outputs to stdout a new update token and 13 | # all files that have been modified since the update token. Paths must 14 | # be relative to the root of the working tree and separated by a single NUL. 15 | # 16 | # To enable this hook, rename this file to "query-watchman" and set 17 | # 'git config core.fsmonitor .git/hooks/query-watchman' 18 | # 19 | my ($version, $last_update_token) = @ARGV; 20 | 21 | # Uncomment for debugging 22 | # print STDERR "$0 $version $last_update_token\n"; 23 | 24 | # Check the hook interface version 25 | if ($version ne 2) { 26 | die "Unsupported query-fsmonitor hook version '$version'.\n" . 27 | "Falling back to scanning...\n"; 28 | } 29 | 30 | my $git_work_tree = get_working_dir(); 31 | 32 | my $retry = 1; 33 | 34 | my $json_pkg; 35 | eval { 36 | require JSON::XS; 37 | $json_pkg = "JSON::XS"; 38 | 1; 39 | } or do { 40 | require JSON::PP; 41 | $json_pkg = "JSON::PP"; 42 | }; 43 | 44 | launch_watchman(); 45 | 46 | sub launch_watchman { 47 | my $o = watchman_query(); 48 | if (is_work_tree_watched($o)) { 49 | output_result($o->{clock}, @{$o->{files}}); 50 | } 51 | } 52 | 53 | sub output_result { 54 | my ($clockid, @files) = @_; 55 | 56 | # Uncomment for debugging watchman output 57 | # open (my $fh, ">", ".git/watchman-output.out"); 58 | # binmode $fh, ":utf8"; 59 | # print $fh "$clockid\n@files\n"; 60 | # close $fh; 61 | 62 | binmode STDOUT, ":utf8"; 63 | print $clockid; 64 | print "\0"; 65 | local $, = "\0"; 66 | print @files; 67 | } 68 | 69 | sub watchman_clock { 70 | my $response = qx/watchman clock "$git_work_tree"/; 71 | die "Failed to get clock id on '$git_work_tree'.\n" . 72 | "Falling back to scanning...\n" if $? != 0; 73 | 74 | return $json_pkg->new->utf8->decode($response); 75 | } 76 | 77 | sub watchman_query { 78 | my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') 79 | or die "open2() failed: $!\n" . 80 | "Falling back to scanning...\n"; 81 | 82 | # In the query expression below we're asking for names of files that 83 | # changed since $last_update_token but not from the .git folder. 84 | # 85 | # To accomplish this, we're using the "since" generator to use the 86 | # recency index to select candidate nodes and "fields" to limit the 87 | # output to file names only. Then we're using the "expression" term to 88 | # further constrain the results. 89 | if (substr($last_update_token, 0, 1) eq "c") { 90 | $last_update_token = "\"$last_update_token\""; 91 | } 92 | my $query = <<" END"; 93 | ["query", "$git_work_tree", { 94 | "since": $last_update_token, 95 | "fields": ["name"], 96 | "expression": ["not", ["dirname", ".git"]] 97 | }] 98 | END 99 | 100 | # Uncomment for debugging the watchman query 101 | # open (my $fh, ">", ".git/watchman-query.json"); 102 | # print $fh $query; 103 | # close $fh; 104 | 105 | print CHLD_IN $query; 106 | close CHLD_IN; 107 | my $response = do {local $/; }; 108 | 109 | # Uncomment for debugging the watch response 110 | # open ($fh, ">", ".git/watchman-response.json"); 111 | # print $fh $response; 112 | # close $fh; 113 | 114 | die "Watchman: command returned no output.\n" . 115 | "Falling back to scanning...\n" if $response eq ""; 116 | die "Watchman: command returned invalid output: $response\n" . 117 | "Falling back to scanning...\n" unless $response =~ /^\{/; 118 | 119 | return $json_pkg->new->utf8->decode($response); 120 | } 121 | 122 | sub is_work_tree_watched { 123 | my ($output) = @_; 124 | my $error = $output->{error}; 125 | if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { 126 | $retry--; 127 | my $response = qx/watchman watch "$git_work_tree"/; 128 | die "Failed to make watchman watch '$git_work_tree'.\n" . 129 | "Falling back to scanning...\n" if $? != 0; 130 | $output = $json_pkg->new->utf8->decode($response); 131 | $error = $output->{error}; 132 | die "Watchman: $error.\n" . 133 | "Falling back to scanning...\n" if $error; 134 | 135 | # Uncomment for debugging watchman output 136 | # open (my $fh, ">", ".git/watchman-output.out"); 137 | # close $fh; 138 | 139 | # Watchman will always return all files on the first query so 140 | # return the fast "everything is dirty" flag to git and do the 141 | # Watchman query just to get it over with now so we won't pay 142 | # the cost in git to look up each individual file. 143 | my $o = watchman_clock(); 144 | $error = $output->{error}; 145 | 146 | die "Watchman: $error.\n" . 147 | "Falling back to scanning...\n" if $error; 148 | 149 | output_result($o->{clock}, ("/")); 150 | $last_update_token = $o->{clock}; 151 | 152 | eval { launch_watchman() }; 153 | return 0; 154 | } 155 | 156 | die "Watchman: $error.\n" . 157 | "Falling back to scanning...\n" if $error; 158 | 159 | return 1; 160 | } 161 | 162 | sub get_working_dir { 163 | my $working_dir; 164 | if ($^O =~ 'msys' || $^O =~ 'cygwin') { 165 | $working_dir = Win32::GetCwd(); 166 | $working_dir =~ tr/\\/\//; 167 | } else { 168 | require Cwd; 169 | $working_dir = Cwd::cwd(); 170 | } 171 | 172 | return $working_dir; 173 | } 174 | -------------------------------------------------------------------------------- /hydra/hooks/post-update.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to prepare a packed repository for use over 4 | # dumb transports. 5 | # 6 | # To enable this hook, rename this file to "post-update". 7 | 8 | exec git update-server-info 9 | -------------------------------------------------------------------------------- /hydra/hooks/pre-applypatch.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed 4 | # by applypatch from an e-mail message. 5 | # 6 | # The hook should exit with non-zero status after issuing an 7 | # appropriate message if it wants to stop the commit. 8 | # 9 | # To enable this hook, rename this file to "pre-applypatch". 10 | 11 | . git-sh-setup 12 | precommit="$(git rev-parse --git-path hooks/pre-commit)" 13 | test -x "$precommit" && exec "$precommit" ${1+"$@"} 14 | : 15 | -------------------------------------------------------------------------------- /hydra/hooks/pre-commit.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | # 8 | # To enable this hook, rename this file to "pre-commit". 9 | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 11 | then 12 | against=HEAD 13 | else 14 | # Initial commit: diff against an empty tree object 15 | against=$(git hash-object -t tree /dev/null) 16 | fi 17 | 18 | # If you want to allow non-ASCII filenames set this variable to true. 19 | allownonascii=$(git config --type=bool hooks.allownonascii) 20 | 21 | # Redirect output to stderr. 22 | exec 1>&2 23 | 24 | # Cross platform projects tend to avoid non-ASCII filenames; prevent 25 | # them from being added to the repository. We exploit the fact that the 26 | # printable range starts at the space character and ends with tilde. 27 | if [ "$allownonascii" != "true" ] && 28 | # Note that the use of brackets around a tr range is ok here, (it's 29 | # even required, for portability to Solaris 10's /usr/bin/tr), since 30 | # the square bracket bytes happen to fall in the designated range. 31 | test $(git diff --cached --name-only --diff-filter=A -z $against | 32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 33 | then 34 | cat <<\EOF 35 | Error: Attempt to add a non-ASCII file name. 36 | 37 | This can cause problems if you want to work with people on other platforms. 38 | 39 | To be portable it is advisable to rename the file. 40 | 41 | If you know what you are doing you can disable this check using: 42 | 43 | git config hooks.allownonascii true 44 | EOF 45 | exit 1 46 | fi 47 | 48 | # If there are whitespace errors, print the offending file names and fail. 49 | exec git diff-index --check --cached $against -- 50 | -------------------------------------------------------------------------------- /hydra/hooks/pre-merge-commit.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git merge" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message to 6 | # stderr if it wants to stop the merge commit. 7 | # 8 | # To enable this hook, rename this file to "pre-merge-commit". 9 | 10 | . git-sh-setup 11 | test -x "$GIT_DIR/hooks/pre-commit" && 12 | exec "$GIT_DIR/hooks/pre-commit" 13 | : 14 | -------------------------------------------------------------------------------- /hydra/hooks/pre-push.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # An example hook script to verify what is about to be pushed. Called by "git 4 | # push" after it has checked the remote status, but before anything has been 5 | # pushed. If this script exits with a non-zero status nothing will be pushed. 6 | # 7 | # This hook is called with the following parameters: 8 | # 9 | # $1 -- Name of the remote to which the push is being done 10 | # $2 -- URL to which the push is being done 11 | # 12 | # If pushing without using a named remote those arguments will be equal. 13 | # 14 | # Information about the commits which are being pushed is supplied as lines to 15 | # the standard input in the form: 16 | # 17 | # 18 | # 19 | # This sample shows how to prevent push of commits where the log message starts 20 | # with "WIP" (work in progress). 21 | 22 | remote="$1" 23 | url="$2" 24 | 25 | zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing" 48 | exit 1 49 | fi 50 | fi 51 | done 52 | 53 | exit 0 54 | -------------------------------------------------------------------------------- /hydra/hooks/pre-rebase.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2006, 2008 Junio C Hamano 4 | # 5 | # The "pre-rebase" hook is run just before "git rebase" starts doing 6 | # its job, and can prevent the command from running by exiting with 7 | # non-zero status. 8 | # 9 | # The hook is called with the following parameters: 10 | # 11 | # $1 -- the upstream the series was forked from. 12 | # $2 -- the branch being rebased (or empty when rebasing the current branch). 13 | # 14 | # This sample shows how to prevent topic branches that are already 15 | # merged to 'next' branch from getting rebased, because allowing it 16 | # would result in rebasing already published history. 17 | 18 | publish=next 19 | basebranch="$1" 20 | if test "$#" = 2 21 | then 22 | topic="refs/heads/$2" 23 | else 24 | topic=`git symbolic-ref HEAD` || 25 | exit 0 ;# we do not interrupt rebasing detached HEAD 26 | fi 27 | 28 | case "$topic" in 29 | refs/heads/??/*) 30 | ;; 31 | *) 32 | exit 0 ;# we do not interrupt others. 33 | ;; 34 | esac 35 | 36 | # Now we are dealing with a topic branch being rebased 37 | # on top of master. Is it OK to rebase it? 38 | 39 | # Does the topic really exist? 40 | git show-ref -q "$topic" || { 41 | echo >&2 "No such branch $topic" 42 | exit 1 43 | } 44 | 45 | # Is topic fully merged to master? 46 | not_in_master=`git rev-list --pretty=oneline ^master "$topic"` 47 | if test -z "$not_in_master" 48 | then 49 | echo >&2 "$topic is fully merged to master; better remove it." 50 | exit 1 ;# we could allow it, but there is no point. 51 | fi 52 | 53 | # Is topic ever merged to next? If so you should not be rebasing it. 54 | only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` 55 | only_next_2=`git rev-list ^master ${publish} | sort` 56 | if test "$only_next_1" = "$only_next_2" 57 | then 58 | not_in_topic=`git rev-list "^$topic" master` 59 | if test -z "$not_in_topic" 60 | then 61 | echo >&2 "$topic is already up to date with master" 62 | exit 1 ;# we could allow it, but there is no point. 63 | else 64 | exit 0 65 | fi 66 | else 67 | not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` 68 | /usr/bin/perl -e ' 69 | my $topic = $ARGV[0]; 70 | my $msg = "* $topic has commits already merged to public branch:\n"; 71 | my (%not_in_next) = map { 72 | /^([0-9a-f]+) /; 73 | ($1 => 1); 74 | } split(/\n/, $ARGV[1]); 75 | for my $elem (map { 76 | /^([0-9a-f]+) (.*)$/; 77 | [$1 => $2]; 78 | } split(/\n/, $ARGV[2])) { 79 | if (!exists $not_in_next{$elem->[0]}) { 80 | if ($msg) { 81 | print STDERR $msg; 82 | undef $msg; 83 | } 84 | print STDERR " $elem->[1]\n"; 85 | } 86 | } 87 | ' "$topic" "$not_in_next" "$not_in_master" 88 | exit 1 89 | fi 90 | 91 | <<\DOC_END 92 | 93 | This sample hook safeguards topic branches that have been 94 | published from being rewound. 95 | 96 | The workflow assumed here is: 97 | 98 | * Once a topic branch forks from "master", "master" is never 99 | merged into it again (either directly or indirectly). 100 | 101 | * Once a topic branch is fully cooked and merged into "master", 102 | it is deleted. If you need to build on top of it to correct 103 | earlier mistakes, a new topic branch is created by forking at 104 | the tip of the "master". This is not strictly necessary, but 105 | it makes it easier to keep your history simple. 106 | 107 | * Whenever you need to test or publish your changes to topic 108 | branches, merge them into "next" branch. 109 | 110 | The script, being an example, hardcodes the publish branch name 111 | to be "next", but it is trivial to make it configurable via 112 | $GIT_DIR/config mechanism. 113 | 114 | With this workflow, you would want to know: 115 | 116 | (1) ... if a topic branch has ever been merged to "next". Young 117 | topic branches can have stupid mistakes you would rather 118 | clean up before publishing, and things that have not been 119 | merged into other branches can be easily rebased without 120 | affecting other people. But once it is published, you would 121 | not want to rewind it. 122 | 123 | (2) ... if a topic branch has been fully merged to "master". 124 | Then you can delete it. More importantly, you should not 125 | build on top of it -- other people may already want to 126 | change things related to the topic as patches against your 127 | "master", so if you need further changes, it is better to 128 | fork the topic (perhaps with the same name) afresh from the 129 | tip of "master". 130 | 131 | Let's look at this example: 132 | 133 | o---o---o---o---o---o---o---o---o---o "next" 134 | / / / / 135 | / a---a---b A / / 136 | / / / / 137 | / / c---c---c---c B / 138 | / / / \ / 139 | / / / b---b C \ / 140 | / / / / \ / 141 | ---o---o---o---o---o---o---o---o---o---o---o "master" 142 | 143 | 144 | A, B and C are topic branches. 145 | 146 | * A has one fix since it was merged up to "next". 147 | 148 | * B has finished. It has been fully merged up to "master" and "next", 149 | and is ready to be deleted. 150 | 151 | * C has not merged to "next" at all. 152 | 153 | We would want to allow C to be rebased, refuse A, and encourage 154 | B to be deleted. 155 | 156 | To compute (1): 157 | 158 | git rev-list ^master ^topic next 159 | git rev-list ^master next 160 | 161 | if these match, topic has not merged in next at all. 162 | 163 | To compute (2): 164 | 165 | git rev-list master..topic 166 | 167 | if this is empty, it is fully merged to "master". 168 | 169 | DOC_END 170 | -------------------------------------------------------------------------------- /hydra/hooks/pre-receive.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to make use of push options. 4 | # The example simply echoes all push options that start with 'echoback=' 5 | # and rejects all pushes when the "reject" push option is used. 6 | # 7 | # To enable this hook, rename this file to "pre-receive". 8 | 9 | if test -n "$GIT_PUSH_OPTION_COUNT" 10 | then 11 | i=0 12 | while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" 13 | do 14 | eval "value=\$GIT_PUSH_OPTION_$i" 15 | case "$value" in 16 | echoback=*) 17 | echo "echo from the pre-receive-hook: ${value#*=}" >&2 18 | ;; 19 | reject) 20 | exit 1 21 | esac 22 | i=$((i + 1)) 23 | done 24 | fi 25 | -------------------------------------------------------------------------------- /hydra/hooks/prepare-commit-msg.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to prepare the commit log message. 4 | # Called by "git commit" with the name of the file that has the 5 | # commit message, followed by the description of the commit 6 | # message's source. The hook's purpose is to edit the commit 7 | # message file. If the hook fails with a non-zero status, 8 | # the commit is aborted. 9 | # 10 | # To enable this hook, rename this file to "prepare-commit-msg". 11 | 12 | # This hook includes three examples. The first one removes the 13 | # "# Please enter the commit message..." help message. 14 | # 15 | # The second includes the output of "git diff --name-status -r" 16 | # into the message, just before the "git status" output. It is 17 | # commented because it doesn't cope with --amend or with squashed 18 | # commits. 19 | # 20 | # The third example adds a Signed-off-by line to the message, that can 21 | # still be edited. This is rarely a good idea. 22 | 23 | COMMIT_MSG_FILE=$1 24 | COMMIT_SOURCE=$2 25 | SHA1=$3 26 | 27 | /usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" 28 | 29 | # case "$COMMIT_SOURCE,$SHA1" in 30 | # ,|template,) 31 | # /usr/bin/perl -i.bak -pe ' 32 | # print "\n" . `git diff --cached --name-status -r` 33 | # if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; 34 | # *) ;; 35 | # esac 36 | 37 | # SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') 38 | # git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" 39 | # if test -z "$COMMIT_SOURCE" 40 | # then 41 | # /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" 42 | # fi 43 | -------------------------------------------------------------------------------- /hydra/hooks/push-to-checkout.sample: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # An example hook script to update a checked-out tree on a git push. 4 | # 5 | # This hook is invoked by git-receive-pack(1) when it reacts to git 6 | # push and updates reference(s) in its repository, and when the push 7 | # tries to update the branch that is currently checked out and the 8 | # receive.denyCurrentBranch configuration variable is set to 9 | # updateInstead. 10 | # 11 | # By default, such a push is refused if the working tree and the index 12 | # of the remote repository has any difference from the currently 13 | # checked out commit; when both the working tree and the index match 14 | # the current commit, they are updated to match the newly pushed tip 15 | # of the branch. This hook is to be used to override the default 16 | # behaviour; however the code below reimplements the default behaviour 17 | # as a starting point for convenient modification. 18 | # 19 | # The hook receives the commit with which the tip of the current 20 | # branch is going to be updated: 21 | commit=$1 22 | 23 | # It can exit with a non-zero status to refuse the push (when it does 24 | # so, it must not modify the index or the working tree). 25 | die () { 26 | echo >&2 "$*" 27 | exit 1 28 | } 29 | 30 | # Or it can make any necessary changes to the working tree and to the 31 | # index to bring them to the desired state when the tip of the current 32 | # branch is updated to the new commit, and exit with a zero status. 33 | # 34 | # For example, the hook can simply run git read-tree -u -m HEAD "$1" 35 | # in order to emulate git fetch that is run in the reverse direction 36 | # with git push, as the two-tree form of git read-tree -u -m is 37 | # essentially the same as git switch or git checkout that switches 38 | # branches while keeping the local changes in the working tree that do 39 | # not interfere with the difference between the branches. 40 | 41 | # The below is a more-or-less exact translation to shell of the C code 42 | # for the default behaviour for git's push-to-checkout hook defined in 43 | # the push_to_deploy() function in builtin/receive-pack.c. 44 | # 45 | # Note that the hook will be executed from the repository directory, 46 | # not from the working tree, so if you want to perform operations on 47 | # the working tree, you will have to adapt your code accordingly, e.g. 48 | # by adding "cd .." or using relative paths. 49 | 50 | if ! git update-index -q --ignore-submodules --refresh 51 | then 52 | die "Up-to-date check failed" 53 | fi 54 | 55 | if ! git diff-files --quiet --ignore-submodules -- 56 | then 57 | die "Working directory has unstaged changes" 58 | fi 59 | 60 | # This is a rough translation of: 61 | # 62 | # head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX 63 | if git cat-file -e HEAD 2>/dev/null 64 | then 65 | head=HEAD 66 | else 67 | head=$(git hash-object -t tree --stdin &2 35 | echo " (if you want, you could supply GIT_DIR then run" >&2 36 | echo " $0 )" >&2 37 | exit 1 38 | fi 39 | 40 | if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then 41 | echo "usage: $0 " >&2 42 | exit 1 43 | fi 44 | 45 | # --- Config 46 | allowunannotated=$(git config --type=bool hooks.allowunannotated) 47 | allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) 48 | denycreatebranch=$(git config --type=bool hooks.denycreatebranch) 49 | allowdeletetag=$(git config --type=bool hooks.allowdeletetag) 50 | allowmodifytag=$(git config --type=bool hooks.allowmodifytag) 51 | 52 | # check for no description 53 | projectdesc=$(sed -e '1q' "$GIT_DIR/description") 54 | case "$projectdesc" in 55 | "Unnamed repository"* | "") 56 | echo "*** Project description file hasn't been set" >&2 57 | exit 1 58 | ;; 59 | esac 60 | 61 | # --- Check types 62 | # if $newrev is 0000...0000, it's a commit to delete a ref. 63 | zero=$(git hash-object --stdin &2 76 | echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 77 | exit 1 78 | fi 79 | ;; 80 | refs/tags/*,delete) 81 | # delete tag 82 | if [ "$allowdeletetag" != "true" ]; then 83 | echo "*** Deleting a tag is not allowed in this repository" >&2 84 | exit 1 85 | fi 86 | ;; 87 | refs/tags/*,tag) 88 | # annotated tag 89 | if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 90 | then 91 | echo "*** Tag '$refname' already exists." >&2 92 | echo "*** Modifying a tag is not allowed in this repository." >&2 93 | exit 1 94 | fi 95 | ;; 96 | refs/heads/*,commit) 97 | # branch 98 | if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then 99 | echo "*** Creating a branch is not allowed in this repository" >&2 100 | exit 1 101 | fi 102 | ;; 103 | refs/heads/*,delete) 104 | # delete branch 105 | if [ "$allowdeletebranch" != "true" ]; then 106 | echo "*** Deleting a branch is not allowed in this repository" >&2 107 | exit 1 108 | fi 109 | ;; 110 | refs/remotes/*,commit) 111 | # tracking branch 112 | ;; 113 | refs/remotes/*,delete) 114 | # delete tracking branch 115 | if [ "$allowdeletebranch" != "true" ]; then 116 | echo "*** Deleting a tracking branch is not allowed in this repository" >&2 117 | exit 1 118 | fi 119 | ;; 120 | *) 121 | # Anything else (is there anything else?) 122 | echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 123 | exit 1 124 | ;; 125 | esac 126 | 127 | # --- Finished 128 | exit 0 129 | -------------------------------------------------------------------------------- /hydra/info/exclude: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | # *.[oa] 6 | # *~ 7 | -------------------------------------------------------------------------------- /hydra/objects/pack/pack-9130140b25475cf9f2e06660ca95f5d8ee000ef6.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shravanasati/hydra/1082d2ed50d2be53589e92df5cb8874c36b6a53a/hydra/objects/pack/pack-9130140b25475cf9f2e06660ca95f5d8ee000ef6.idx -------------------------------------------------------------------------------- /hydra/objects/pack/pack-9130140b25475cf9f2e06660ca95f5d8ee000ef6.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shravanasati/hydra/1082d2ed50d2be53589e92df5cb8874c36b6a53a/hydra/objects/pack/pack-9130140b25475cf9f2e06660ca95f5d8ee000ef6.pack -------------------------------------------------------------------------------- /hydra/packed-refs: -------------------------------------------------------------------------------- 1 | # pack-refs with: peeled fully-peeled sorted 2 | 0eecf3157df775b415b96daee0c07dbf9aa28141 refs/heads/3.x 3 | bfb723d4764d1db19e492aee1177d6d2b6532e6c refs/heads/main 4 | b78c1bb0c7ba8ac120ed9974f110f9b299408ca7 refs/pull/6/head 5 | 5115f4ce197fed3166a389cbd0204c533eb68687 refs/pull/6/merge 6 | 5fcc1d6743e2f29014a83970d61c1185f1cb79cc refs/pull/7/head 7 | b89e37bd1bbda15dae75c4b91c19326588314606 refs/tags/v1.0.0 8 | 9e06f6a2b3bcd9b3c3c6388a00c91556afdd9893 refs/tags/v2.0.0 9 | d27cf4f11edf3bf306f97cf68aad9e6bbd8786a4 refs/tags/v2.0.1 10 | 2a023de76a5e4030d673de493418c274a110dca7 refs/tags/v2.1.0 11 | ff3a1283624ba0f988d6a32755a01804500fb3a8 refs/tags/v2.2.0 12 | -------------------------------------------------------------------------------- /linux_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Downloading hydra..." 4 | curl -L "https://github.com/shravanasati/hydra/releases/latest/download/hydra-linux-amd64" -o hydra 5 | 6 | echo "Adding hydra into PATH..." 7 | 8 | mkdir -p ~/.hydra 9 | 10 | chmod u+x ./hydra 11 | 12 | mv ./hydra ~/.hydra 13 | echo "export PATH=$PATH:~/.hydra" >> ~/.bashrc 14 | set -U fish_user_paths ~/.hydra/ $fish_user_paths 15 | echo "export PATH=$PATH:~/.hydra" >> ~/.zshrc 16 | 17 | echo "hydra installation is completed!" 18 | echo "You need to restart the shell to use hydra." 19 | -------------------------------------------------------------------------------- /macos_install.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash 3 | 4 | echo "Downloading hydra..." 5 | curl -L "https://github.com/shravanasati/hydra/releases/latest/download/hydra-darwin-amd64" -o hydra 6 | 7 | echo "Adding hydra into PATH..." 8 | 9 | mkdir -p ~/.hydra; 10 | mv ./hydra ~/.hydra 11 | echo "export PATH=$PATH:~/.hydra" >> ~/.bashrc 12 | 13 | echo "hydra installation is completed!" 14 | echo "You need to restart the shell to use hydra." 15 | -------------------------------------------------------------------------------- /pkg/hydra-git/.MTREE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shravanasati/hydra/1082d2ed50d2be53589e92df5cb8874c36b6a53a/pkg/hydra-git/.MTREE -------------------------------------------------------------------------------- /pkg/hydra-git/.PKGINFO: -------------------------------------------------------------------------------- 1 | # Generated by makepkg 6.0.0 2 | # using fakeroot version 1.25.3 3 | pkgname = hydra-git 4 | pkgbase = hydra-git 5 | pkgver = 2.2-1 6 | pkgdesc = hydra is a command line utility for generating language-specific project structures. 7 | url = https://github.com/Shravan-1908/hydra.git 8 | builddate = 1628744761 9 | packager = Unknown Packager 10 | size = 0 11 | arch = x86_64 12 | license = MIT 13 | makedepend = git 14 | makedepend = curl 15 | -------------------------------------------------------------------------------- /src/boilerplates/cssReset: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0px; 3 | padding: 0px; 4 | box-sizing: border-box; 5 | border: 0; 6 | } -------------------------------------------------------------------------------- /src/boilerplates/flask: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route("/") 6 | def home(): 7 | return render_template('index.html') 8 | 9 | if __name__ == "__main__": 10 | app.run(debug=True) -------------------------------------------------------------------------------- /src/boilerplates/gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.name = ":PROJECT_NAME:" 3 | s.version = '1.0.0' 4 | s.license = ":LICENSE:" 5 | s.summary = "Project summary here" 6 | s.description = "Much longer explanation of the project." 7 | s.authors = [":AUTHOR_NAME:"] 8 | s.email = 'Your email here.' 9 | s.files = ["lib/:PROJECT_NAME:.rb"] 10 | s.homepage = 'https://rubygems.org/gems/:PROJECT_NAME:' 11 | s.metadata = { "source_code_uri" => "https://github.com/:GITHUB:/:PROJECT_NAME:" } 12 | end -------------------------------------------------------------------------------- /src/boilerplates/html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | :PROJECT_NAME: 8 | :CSS_LINK: 9 | 10 | 11 | 12 |

:PROJECT_NAME:

13 | 14 | :SCRIPT_LINK: 15 | 16 | -------------------------------------------------------------------------------- /src/boilerplates/setupContent: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages, setup 2 | 3 | VERSION = '1.0.0' 4 | with open("README.md") as f: 5 | README = f.read() 6 | 7 | setup( 8 | name = ":PROJECT_NAME:", 9 | version = VERSION, 10 | description = "Project summary here", 11 | long_description_content_type = "text/markdown", 12 | long_description = README, 13 | url = "https://github.com/:GITHUB:/:PROJECT_NAME:", 14 | author = ":AUTHOR_NAME:", 15 | author_email = "Your email here", 16 | packages = find_packages(), 17 | install_requires = [], 18 | license = ':LICENSE:', 19 | keywords = [], 20 | classifiers = [] 21 | ) -------------------------------------------------------------------------------- /src/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | platforms=("windows/amd64" "darwin/amd64" "linux/amd64") 4 | 5 | for platform in "${platforms[@]}" 6 | do 7 | platform_split=(${platform//\// }) 8 | GOOS=${platform_split[0]} 9 | GOARCH=${platform_split[1]} 10 | output_name="../bin/hydra-$GOOS-$GOARCH" 11 | if [ $GOOS = "windows" ]; then 12 | output_name+='.exe' 13 | fi 14 | 15 | echo "Building executable for $GOOS/$GOARCH..." 16 | 17 | env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name . 18 | if [ $? -ne 0 ]; then 19 | echo 'An error has occurred! Aborting the script execution...' 20 | exit 1 21 | fi 22 | done -------------------------------------------------------------------------------- /src/config.go: -------------------------------------------------------------------------------- 1 | /* 2 | The following code is responsible for the config command. 3 | 4 | Author: Shravan Asati 5 | Originally Written: 30 March 2021 6 | Last edited: 13 April 2021 7 | */ 8 | 9 | package main 10 | 11 | import ( 12 | "bufio" 13 | "encoding/json" 14 | "fmt" 15 | "os" 16 | "os/user" 17 | "path/filepath" 18 | ) 19 | 20 | type Configuration struct { 21 | FullName string `json:"FullName"` 22 | GithubUsername string `json:"GithubUsername"` 23 | DefaultLang string `json:"DefaultLang"` 24 | DefaultLicense string `json:"DefaultLicense"` 25 | } 26 | 27 | func jsonifyConfig(config *Configuration) string { 28 | byteArray, err := json.Marshal(config) 29 | if err != nil { 30 | panic(err) 31 | } 32 | return string(byteArray) 33 | } 34 | 35 | func readConfig(jsonString string) *Configuration { 36 | var result *Configuration 37 | err := json.Unmarshal([]byte(jsonString), &result) 38 | if err != nil { 39 | handleException(err) 40 | } 41 | return result 42 | } 43 | 44 | func getConfig(value string) string { 45 | // to make sure the config file exists 46 | config("default", "default", "default", "default") 47 | 48 | usr, _ := user.Current() 49 | configFile := (filepath.Join(usr.HomeDir, ".hydra/config.json")) 50 | file, ferr := os.Open(configFile) 51 | handleException(ferr) 52 | defer file.Close() 53 | wholeText := "" 54 | scanner := bufio.NewScanner(file) 55 | for scanner.Scan() { 56 | line := scanner.Text() 57 | wholeText = wholeText + line 58 | } 59 | 60 | config := readConfig(wholeText) 61 | switch value { 62 | case "fullName": 63 | return config.FullName 64 | case "githubUsername": 65 | return config.GithubUsername 66 | case "defaultLang": 67 | return config.DefaultLang 68 | case "defaultLicense": 69 | return config.DefaultLicense 70 | default: 71 | return fmt.Sprintf("Undefined value: %v.", value) 72 | } 73 | } 74 | 75 | func checkForCorrectConfig() bool { 76 | // to make sure the config file exists 77 | config("default", "default", "default", "default") 78 | 79 | usr, _ := user.Current() 80 | configFile := (filepath.Join(usr.HomeDir, ".hydra/config.json")) 81 | file, ferr := os.Open(configFile) 82 | handleException(ferr) 83 | wholeText := "" 84 | scanner := bufio.NewScanner(file) 85 | for scanner.Scan() { 86 | line := scanner.Text() 87 | wholeText = wholeText + line 88 | } 89 | file.Close() 90 | 91 | config := readConfig(wholeText) 92 | 93 | if config.FullName == "" || config.GithubUsername == "" { 94 | return false 95 | } else { 96 | return true 97 | } 98 | } 99 | 100 | func exists(path string) (bool, error) { 101 | _, err := os.Stat(path) 102 | if err == nil { 103 | return true, nil 104 | } 105 | if os.IsNotExist(err) { 106 | return false, nil 107 | } 108 | return false, err 109 | } 110 | 111 | func config(fullName, githubUsername, defaultLang, defaultLicense string) { 112 | // * defining path of hydra config file 113 | usr, _ := user.Current() 114 | hydraDir := filepath.Join(usr.HomeDir, ".hydra") 115 | 116 | if pathOk, _ := exists(hydraDir); !pathOk { 117 | os.Mkdir(hydraDir, os.ModePerm) 118 | } 119 | 120 | configFile := filepath.Join(hydraDir, "config.json") 121 | 122 | // * creating a file in case it doesnt exists 123 | if configOk, _ := exists(configFile); !configOk { 124 | f, err := os.Create(configFile) 125 | handleException(err) 126 | defaultConfig := Configuration{FullName: "", GithubUsername: "", DefaultLang: "", DefaultLicense: "MIT"} 127 | _, er := f.WriteString(jsonifyConfig(&defaultConfig)) 128 | handleException(er) 129 | f.Close() 130 | } 131 | 132 | // * reading data from the file 133 | file, ferr := os.Open(configFile) 134 | handleException(ferr) 135 | defer file.Close() 136 | wholeText := "" 137 | scanner := bufio.NewScanner(file) 138 | for scanner.Scan() { 139 | line := scanner.Text() 140 | wholeText = wholeText + line 141 | } 142 | 143 | // * writing new config to the file by first deleting it 144 | configStruct := readConfig(wholeText) 145 | if fullName != "default" { 146 | configStruct.FullName = fullName 147 | fmt.Printf("Successfully configured the full name to '%v'. \n", fullName) 148 | } 149 | 150 | if githubUsername != "default" { 151 | configStruct.GithubUsername = githubUsername 152 | fmt.Printf("Successfully configured the GitHub username to '%v'. \n", githubUsername) 153 | } 154 | 155 | if defaultLang != "default" { 156 | configStruct.DefaultLang = defaultLang 157 | fmt.Printf("Successfully configured the default language to '%v'. \n", defaultLang) 158 | } 159 | 160 | if defaultLicense != "default" { 161 | configStruct.DefaultLicense = defaultLicense 162 | fmt.Printf("Successfully configured the default license to '%v'. \n", defaultLicense) 163 | } 164 | 165 | os.Remove(configFile) 166 | f, err := os.Create(configFile) 167 | handleException(err) 168 | _, er := f.WriteString(jsonifyConfig(configStruct)) 169 | handleException(er) 170 | f.Close() 171 | } 172 | -------------------------------------------------------------------------------- /src/config_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func generateRandom(value string) string { 11 | letters := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 12 | rand.Seed(time.Now().UnixNano()) 13 | 14 | if value == "name" { 15 | // * generating random values for configurations 16 | 17 | var rname string 18 | // * generating random name 19 | for len(rname) <= 8 { 20 | rname += string(letters[rand.Intn(len(letters))]) 21 | } 22 | return rname 23 | 24 | } else if value == "githubUsername" { 25 | // * generating random github usename 26 | var rgithub string 27 | for len(rgithub) <= 10 { 28 | rgithub += string(letters[rand.Intn(len(letters))]) 29 | } 30 | return rgithub 31 | 32 | } else if value == "lang" { 33 | // * random choice of languages 34 | rlang := supportedLangs[rand.Intn(len(supportedLangs))] 35 | return rlang 36 | 37 | } else if value == "license" { 38 | // * random supported license 39 | licenses := []string{} 40 | for k := range supportedLicenses { 41 | licenses = append(licenses, k) 42 | } 43 | rlicense := licenses[rand.Intn(len(licenses))] 44 | return rlicense 45 | 46 | } else { 47 | panic(fmt.Sprintf("Invalid value for random generation: %v.", value)) 48 | } 49 | } 50 | 51 | func TestConfig(t *testing.T) { 52 | // * the below line is to ensure the `config.json` file exists 53 | config("default", "default", "default", "default") 54 | 55 | // * getting all initial values so that after the tests, the cleanup function can restore the configuration 56 | initialName := getConfig("fullName") 57 | initialGithubUsername := getConfig("githubUsername") 58 | initialLang := getConfig("defaultLang") 59 | initialLicense := getConfig("defaultLicense") 60 | 61 | // * storing random values 62 | rname := generateRandom("name") 63 | rgithub := generateRandom("githubUsername") 64 | rlang := generateRandom("lang") 65 | rlicense := generateRandom("license") 66 | 67 | // * setting configuration 68 | config(rname, rgithub, rlang, rlicense) 69 | 70 | // * checking fullname 71 | gotName := getConfig("fullName") 72 | if gotName != rname { 73 | t.Errorf("Got %v, expected %v", gotName, rname) 74 | } 75 | 76 | // * checking github username 77 | gotGithub := getConfig("githubUsername") 78 | if gotGithub != rgithub { 79 | t.Errorf("Got %v, expected %v", gotGithub, rgithub) 80 | } 81 | 82 | // * checking default language 83 | gotLang := getConfig("defaultLang") 84 | if gotLang != rlang { 85 | t.Errorf("Got %v, expected %v", gotLang, rlang) 86 | } 87 | 88 | // * checking default license 89 | gotLicense := getConfig("defaultLicense") 90 | if gotLicense != rlicense { 91 | t.Errorf("Got %v, expected %v", gotLicense, rlicense) 92 | } 93 | 94 | // * cleaning up 95 | t.Cleanup(func() { 96 | t.Log("\nCleaning up...\n") 97 | config(initialName, initialGithubUsername, initialLang, initialLicense) 98 | }) 99 | } 100 | -------------------------------------------------------------------------------- /src/gitignores/c.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf -------------------------------------------------------------------------------- /src/gitignores/cpp.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app -------------------------------------------------------------------------------- /src/gitignores/go.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ -------------------------------------------------------------------------------- /src/gitignores/python.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ -------------------------------------------------------------------------------- /src/gitignores/ruby.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /spec/examples.txt 9 | /test/tmp/ 10 | /test/version_tmp/ 11 | /tmp/ 12 | 13 | # Used by dotenv library to load environment variables. 14 | # .env 15 | 16 | # Ignore Byebug command history file. 17 | .byebug_history 18 | 19 | ## Specific to RubyMotion: 20 | .dat* 21 | .repl_history 22 | build/ 23 | *.bridgesupport 24 | build-iPhoneOS/ 25 | build-iPhoneSimulator/ 26 | 27 | ## Specific to RubyMotion (use of CocoaPods): 28 | # 29 | # We recommend against adding the Pods directory to your .gitignore. However 30 | # you should judge for yourself, the pros and cons are mentioned at: 31 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 32 | # 33 | # vendor/Pods/ 34 | 35 | ## Documentation cache and generated files: 36 | /.yardoc/ 37 | /_yardoc/ 38 | /doc/ 39 | /rdoc/ 40 | 41 | ## Environment normalization: 42 | /.bundle/ 43 | /vendor/bundle 44 | /lib/bundler/man/ 45 | 46 | # for a library or gem, you might want to ignore these files since the code is 47 | # intended to run in multiple environments; otherwise, check them in: 48 | # Gemfile.lock 49 | # .ruby-version 50 | # .ruby-gemset 51 | 52 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 53 | .rvmrc 54 | 55 | # Used by RuboCop. Remote config files pulled in from inherit_from directive. 56 | # .rubocop-https?--* -------------------------------------------------------------------------------- /src/gitignores/web.gitignore: -------------------------------------------------------------------------------- 1 | # ignore all files starting with . or ~ 2 | .* 3 | ~* 4 | 5 | # ignore node/grunt dependency directories 6 | node_modules/ 7 | 8 | # ignore composer vendor directory 9 | /vendor 10 | 11 | # ignore components loaded via Bower 12 | /bower_components 13 | 14 | # ignore jekyll build directory 15 | /_site 16 | 17 | # ignore OS generated files 18 | ehthumbs.db 19 | Thumbs.db 20 | 21 | # ignore Editor files 22 | *.sublime-project 23 | *.sublime-workspace 24 | *.komodoproject 25 | 26 | # ignore log files and databases 27 | *.log 28 | *.sql 29 | *.sqlite 30 | 31 | # ignore compiled files 32 | *.com 33 | *.class 34 | *.dll 35 | *.exe 36 | *.o 37 | *.so 38 | 39 | # ignore packaged files 40 | *.7z 41 | *.dmg 42 | *.gz 43 | *.iso 44 | *.jar 45 | *.rar 46 | *.tar 47 | *.zip 48 | 49 | # ignore private/secret files 50 | *.der 51 | *.key 52 | *.pem 53 | 54 | -------------------------------------------------------------------------------- /src/hydra.go: -------------------------------------------------------------------------------- 1 | /* 2 | Code responsible for the hydra CLI. 3 | 4 | Author: Shravan Asati 5 | Originally Written: 27 March 2021 6 | Last edited: 4 June 2021 7 | */ 8 | 9 | package main 10 | 11 | import ( 12 | "fmt" 13 | "github.com/thatisuday/commando" 14 | "regexp" 15 | "strings" 16 | ) 17 | 18 | const ( 19 | NAME string = "hydra" 20 | VERSION string = "2.2.0" 21 | ) 22 | 23 | var ( 24 | supportedLangs []string = []string{"go", "python", "web", "flask", "ruby", "c", "c++"} 25 | supportedLicenses map[string]string = map[string]string{ 26 | "APACHE": "Apache License", 27 | "BSD": "Berkeley Software Distribution 3-Clause", 28 | "EPL": "Eclipse Public License", 29 | "GPL": "GNU General Public License v3", 30 | "MIT": "Massachusetts Institute of Technology License", 31 | "MPL": "Mozilla Public License", 32 | "UNI": "The Unilicense"} 33 | ) 34 | 35 | func stringInSlice(s string, slice []string) bool { 36 | for _, v := range slice { 37 | if v == s { 38 | return true 39 | } 40 | } 41 | return false 42 | } 43 | 44 | func wrongProjectName(projectName string) bool { 45 | match, _ := regexp.MatchString(`\.|\?|\*|\:|\,|\'|\"|\||\|\|/<|>`, projectName) 46 | return match 47 | } 48 | 49 | func main() { 50 | fmt.Println(NAME, VERSION) 51 | 52 | // * basic configuration 53 | commando. 54 | SetExecutableName(NAME). 55 | SetVersion(VERSION). 56 | SetDescription("hydra is command line utility used to generate language-specific project structure. \nFor more detailed information and documentation, visit https://github.com/shravanasati/hydra . \n") 57 | 58 | commando. 59 | Register(nil). 60 | SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) { 61 | fmt.Println("\nExecute `hydra -h` for help.") 62 | }) 63 | 64 | // * the list command 65 | commando. 66 | Register("list"). 67 | SetShortDescription("Lists supported languages, licenses and user configurations."). 68 | SetDescription("Lists supported languages, licenses and user configurations."). 69 | AddArgument("item", "The item to list. Valid options are `langs`, `licenses` and `configs`.", ""). 70 | SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) { 71 | 72 | if args["item"].Value == "langs" { 73 | fmt.Println(list("langs")) 74 | } else if args["item"].Value == "licenses" { 75 | fmt.Println(list("licenses")) 76 | } else if args["item"].Value == "configs" { 77 | fmt.Println(list("configs")) 78 | } else { 79 | fmt.Println(list(args["item"].Value)) 80 | } 81 | }) 82 | 83 | commando. 84 | Register("config"). 85 | SetShortDescription("Alter or set the hydra user configuration."). 86 | SetDescription("Alter or set the hydra user configuration."). 87 | AddFlag("name", "The user's full name.", commando.String, "default"). 88 | AddFlag("github-username", "The user's GitHub username.", commando.String, "default"). 89 | AddFlag("default-lang", "The user's default language for project initialisation.", commando.String, "default"). 90 | AddFlag("default-license", "The user's default license for project initialisation.", commando.String, "default"). 91 | SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) { 92 | config( 93 | flags["name"].Value.(string), 94 | flags["github-username"].Value.(string), 95 | flags["default-lang"].Value.(string), 96 | strings.ToUpper(flags["default-license"].Value.(string))) 97 | }) 98 | 99 | // * the init command 100 | commando. 101 | Register("init"). 102 | SetShortDescription("Intialises the project structure."). 103 | SetDescription("Intialises the project structure.\n\nUsage: \n name : project name \n lang : programming language in which the project is being built."). 104 | AddArgument("name", "Name of the project", ""). 105 | AddArgument("lang", "Language/framework of the project. To view valid options for the this parameter, execute `hydra list langs`.", "default"). 106 | AddFlag("license", "The license to initialise the project with.", commando.String, "default"). 107 | SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) { 108 | 109 | // * checking if user has properly configured hydra (full name and github username) 110 | if !checkForCorrectConfig() { 111 | fmt.Println("Error: You've not set your hydra configuration. You cannot proceed without setting the necessary configuration.\nTo set configuration, execute `hydra config --name \"YOUR NAME\" --github-username \"YOUR GITHUB USERNAME\"` .\nFor further assistance regarding hydra configuration, type in `hydra config -h` .") 112 | return 113 | } 114 | 115 | // * checking for correct license 116 | license := strings.ToUpper(flags["license"].Value.(string)) 117 | if license == "DEFAULT" { 118 | license = getConfig("defaultLicense") 119 | } 120 | if !stringInSlice(license, []string{"MIT", "BSD", "MPL", "EPL", "GPL", "APACHE", "UNI"}) { 121 | fmt.Printf("Invalid value for flag license: '%v'.\n", license) 122 | fmt.Println("You've either provided invalid license flag in the init command, or you've set wrong license in your hydra configuration.\nTo see your hydra configuration, execute `hydra list configs`.") 123 | return 124 | } 125 | 126 | // * checking for correct project language 127 | projectLang := strings.ToLower(args["lang"].Value) 128 | if projectLang == "default" { 129 | projectLang = getConfig("defaultLang") 130 | } 131 | 132 | projectName := args["name"].Value 133 | 134 | // * checking the project name 135 | if wrongProjectName(projectName) { 136 | fmt.Printf(`Error: Invalid project name: '%v'. Characters like (, " | \ ? / : ; < >) are not allowed in filenames.`+"\n", projectName) 137 | return 138 | } 139 | 140 | init := Initializer{ 141 | projectName: projectName, 142 | license: license, 143 | lang: projectLang, 144 | } 145 | switch projectLang { 146 | case "python": 147 | init.pythonInit() 148 | case "go": 149 | init.goInit() 150 | case "web": 151 | init.webInit() 152 | case "flask": 153 | init.flaskInit() 154 | case "c": 155 | init.cInit() 156 | case "c++": 157 | init.cppInit() 158 | case "ruby": 159 | init.rubyInit() 160 | default: 161 | fmt.Printf("Unsupported language type: '%v'. Cannot initiate the project. \nHint: You've either a typo at the language name, or the hydra default language configuration is wrong.", projectLang) 162 | } 163 | }) 164 | 165 | commando. 166 | Register("update"). 167 | SetShortDescription("The update command updates hydra to the latest release."). 168 | SetDescription("The update command downloads and installs the latest hydra release."). 169 | SetAction(func(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) { 170 | update() 171 | }) 172 | 173 | commando.Parse(nil) 174 | deletePreviousInstallation() 175 | } 176 | -------------------------------------------------------------------------------- /src/init.go: -------------------------------------------------------------------------------- 1 | /* 2 | The following code is responsible for the init command. 3 | 4 | Author: Shravan Asati 5 | Originally Written: 28 March 2021 6 | Last edited: 8 June 2021 7 | */ 8 | 9 | package main 10 | 11 | import ( 12 | "fmt" 13 | "os" 14 | "os/exec" 15 | "strconv" 16 | "strings" 17 | "time" 18 | ) 19 | 20 | // year returns the current year, used for editing LICENSE file. 21 | func year() string { 22 | return strconv.Itoa(time.Now().Year()) 23 | } 24 | 25 | // handleException handles the exception by printing it and exiting the program. 26 | func handleException(err error) { 27 | if err != nil { 28 | fmt.Println("FATAL ERROR: Project initialisation failed! This should never happen. You may want to file an issue at the hydra repository: https://github.com/shravanasati/hydra/issues/new?assignees=&labels=&template=bug_report.md&title=") 29 | fmt.Println(err) 30 | os.Exit(-1) 31 | } 32 | } 33 | 34 | type Initializer struct { 35 | projectName string 36 | license string 37 | lang string 38 | } 39 | 40 | 41 | 42 | // makeDir creates a directory. 43 | func makeDir(dirname string) { 44 | err := os.Mkdir(dirname, os.ModePerm) 45 | handleException(err) 46 | cwd, _ := os.Getwd() 47 | fmt.Printf("\n - Created directory '%v' at %v.", dirname, cwd) 48 | } 49 | 50 | // execute executes a command in the shell. 51 | func execute(base string, command ...string) error { 52 | cmd := exec.Command(base, command...) 53 | _, err := cmd.Output() 54 | if err != nil { 55 | return err 56 | } 57 | return nil 58 | } 59 | 60 | // getGitignore returns the gitignore variable from static.go, corresponding to the provided language. 61 | func getGitignore(language string) string { 62 | switch language { 63 | case "python": 64 | return pythonGitignore 65 | case "go": 66 | return goGitignore 67 | case "c": 68 | return cGitignore 69 | case "c++": 70 | return cppGitignore 71 | case "ruby": 72 | return rubyGitignore 73 | default: 74 | return fmt.Sprintf("Unknown language: %v.", language) 75 | } 76 | } 77 | 78 | // manipulateLicense replaces the `:NAME:` and `:YEAR:` values of the license with actual values. 79 | func manipulateLicense(license string) string { 80 | licenseText := strings.Replace(license, ":YEAR:", year(), 1) 81 | licenseText = strings.Replace(licenseText, ":NAME:", getConfig("fullName"), 1) 82 | 83 | return licenseText 84 | } 85 | 86 | // getGitignore returns the license variable from static.go, corresponding to the provided license. 87 | func getLicense(license string) string { 88 | switch license { 89 | case "MIT": 90 | return manipulateLicense(MIT) 91 | case "BSD": 92 | return manipulateLicense(BSD) 93 | case "APACHE": 94 | return manipulateLicense(APACHE) 95 | case "EPL": 96 | return manipulateLicense(EPL) 97 | case "MPL": 98 | return manipulateLicense(MPL) 99 | case "GPL": 100 | return manipulateLicense(GPL) 101 | case "UNI": 102 | return manipulateLicense(UNI) 103 | default: 104 | return fmt.Sprintf("Undefined license: %v.", license) 105 | } 106 | } 107 | 108 | func (init *Initializer) initByJson(file string) { 109 | 110 | } 111 | 112 | // basicInit makes the README, LICENSE and gitignore files. 113 | func (init *Initializer) basicInit() string { 114 | fmt.Printf("Initialising project: '%v' in %v.\n", init.projectName, init.lang) 115 | 116 | makeDir(init.projectName) 117 | os.Chdir(fmt.Sprintf("./%v", init.projectName)) 118 | 119 | gwd, _ := os.Getwd() 120 | makeFile("LICENSE", getLicense(init.license)) 121 | makeFile("README.md", fmt.Sprintf("# %v", init.projectName)) 122 | makeFile(".gitignore", getGitignore(init.lang)) 123 | return gwd 124 | } 125 | 126 | // pythonInit is the python project initialisation function. 127 | func (init *Initializer) pythonInit() { 128 | gwd := init.basicInit() 129 | 130 | pythonSetup = strings.Replace(pythonSetup, ":PROJECT_NAME:", init.projectName, 2) 131 | pythonSetup = strings.Replace(pythonSetup, ":LICENSE:", init.license, 1) 132 | pythonSetup = strings.Replace(pythonSetup, ":GITHUB:", getConfig("githubUsername"), 1) 133 | pythonSetup = strings.Replace(pythonSetup, ":AUTHOR_NAME:", getConfig("fullName"), 1) 134 | makeFile("setup.py", pythonSetup) 135 | 136 | makeDir(init.projectName) 137 | os.Chdir(fmt.Sprintf("./%v", init.projectName)) 138 | makeFile("__init__.py", "") 139 | os.Chdir(gwd) 140 | 141 | makeDir("tests") 142 | os.Chdir("./tests") 143 | makeFile("__init__.py", "") 144 | makeFile(fmt.Sprintf("test_%v.py", init.projectName), "") 145 | os.Chdir(gwd) 146 | 147 | e := execute("git", "init") 148 | if e != nil { 149 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a git repository.") 150 | } else { 151 | fmt.Println("\n - Intialised a Git repository for your project.") 152 | } 153 | } 154 | 155 | // goInit is the go project initialisation function. 156 | func (init *Initializer) goInit() { 157 | gwd := init.basicInit() 158 | 159 | makeDir("src") 160 | os.Chdir("./src") 161 | makeFile("main.go", "package main") 162 | os.Chdir(gwd) 163 | 164 | makeDir("tests") 165 | os.Chdir("./tests") 166 | makeFile(fmt.Sprintf("%v_test.go", init.projectName), "package main") 167 | os.Chdir(gwd) 168 | 169 | e := execute("go", "mod", "init", fmt.Sprintf("github.com/%v/%v", getConfig("githubUsername"), init.projectName)) 170 | if e != nil { 171 | fmt.Println("\n ** Go isn't installed on your system. Cannot enable dependency tracking.") 172 | } else { 173 | fmt.Println("\n - Enabled dependency tracking for your Go application.") 174 | } 175 | e = execute("git", "init") 176 | if e != nil { 177 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a repository.") 178 | } else { 179 | fmt.Println(" - Intialised a Git repository for your project.") 180 | } 181 | } 182 | 183 | // webInit is the web-frontend project initialisation function. 184 | func (init *Initializer) webInit() { 185 | gwd := init.basicInit() 186 | 187 | indexContent := strings.Replace(HTMLBoilerplate, ":PROJECT_NAME:", init.projectName, 2) 188 | indexContent = strings.Replace(indexContent, ":CSS_LINK:", ``, 1) 189 | indexContent = strings.Replace(indexContent, ":SCRIPT_LINK:", ``, 1) 190 | makeFile("index.html", indexContent) 191 | makeFile("README.md", fmt.Sprintf("# %v", init.projectName)) 192 | 193 | makeDir("img") 194 | 195 | makeDir("css") 196 | os.Chdir("./css") 197 | makeFile("style.css", cssReset) 198 | os.Chdir(gwd) 199 | 200 | makeDir("js") 201 | os.Chdir("./js") 202 | makeFile("script.js", "") 203 | os.Chdir(gwd) 204 | 205 | e := execute("git", "init") 206 | if e != nil { 207 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a repository.") 208 | } else { 209 | fmt.Println(" - Intialised a Git repository for your project.") 210 | } 211 | } 212 | 213 | // flaskInit is the python-flask project initialisation function. 214 | func (init *Initializer) flaskInit() { 215 | gwd := init.basicInit() 216 | 217 | makeFile("app.py", flaskBoilerplate) 218 | 219 | // * making the static dir which contains images, styles and scripts dir 220 | makeDir("static") 221 | os.Chdir("./static") 222 | 223 | makeDir("images") 224 | 225 | makeDir("scripts") 226 | os.Chdir("./scripts") 227 | makeFile("script.js", "") 228 | os.Chdir("..") 229 | 230 | makeDir("styles") 231 | os.Chdir("./styles") 232 | makeFile("style.css", cssReset) 233 | os.Chdir(gwd) 234 | 235 | // * making the templates dir 236 | makeDir("templates") 237 | os.Chdir("./templates") 238 | indexContent := strings.Replace(HTMLBoilerplate, ":PROJECT_NAME:", init.projectName, 2) 239 | indexContent = strings.Replace(indexContent, ":CSS_LINK:", ``, 1) 240 | indexContent = strings.Replace(indexContent, ":SCRIPT_LINK:", ``, 1) 241 | makeFile("index.html", indexContent) 242 | os.Chdir(gwd) 243 | 244 | // * initialising git repository 245 | e := execute("git", "init") 246 | if e != nil { 247 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a git repository.") 248 | } else { 249 | fmt.Println("\n - Intialised a Git repository for your project.") 250 | } 251 | } 252 | 253 | // cInit is the C project initialisation function. 254 | func (init *Initializer) cInit() { 255 | gwd := init.basicInit() 256 | 257 | makeFile("Makefile.am", "") 258 | 259 | makeDir("src") 260 | os.Chdir("./src") 261 | makeFile("Makefile.am", "") 262 | makeFile("main.c", "") 263 | makeFile("main.h", "") 264 | os.Chdir(gwd) 265 | 266 | makeDir("tests") 267 | os.Chdir("./tests") 268 | makeFile("Makefile.am", "") 269 | makeFile(fmt.Sprintf("%v_test.c", init.projectName), "") 270 | os.Chdir(gwd) 271 | 272 | makeDir("libs") 273 | os.Chdir("../libs") 274 | makeFile("Makefile.am", "") 275 | 276 | e := execute("git", "init") 277 | if e != nil { 278 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a repository.") 279 | } else { 280 | fmt.Println(" - Intialised a Git repository for your project.") 281 | } 282 | } 283 | 284 | // cppInit is the C++ project initialisation function. 285 | func (init *Initializer) cppInit() { 286 | gwd := init.basicInit() 287 | makeFile("CMakeLists.txt", "") 288 | 289 | makeDir("src") 290 | os.Chdir("./src") 291 | makeFile("main.cpp", "") 292 | makeFile("main.h", "") 293 | os.Chdir(gwd) 294 | 295 | makeDir("include") 296 | os.Chdir("./include") 297 | makeDir(init.projectName) 298 | os.Chdir(fmt.Sprintf("./%v", init.projectName)) 299 | makeFile("header.h", "") 300 | os.Chdir(gwd) 301 | 302 | makeDir("tests") 303 | os.Chdir("./tests") 304 | makeFile(fmt.Sprintf("%v_test.cpp", init.projectName), "") 305 | os.Chdir(gwd) 306 | 307 | makeDir("libs") 308 | 309 | e := execute("git", "init") 310 | if e != nil { 311 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a repository.") 312 | } else { 313 | fmt.Println(" - Intialised a Git repository for your project.") 314 | } 315 | } 316 | 317 | // rubyInit is the ruby project initialisation function. 318 | func (init *Initializer) rubyInit() { 319 | gwd := init.basicInit() 320 | 321 | makeFile("Gemfile", "") 322 | makeFile("Rakefile", "") 323 | 324 | gemspecContent = strings.Replace(gemspecContent, ":PROJECT_NAME:", init.projectName, 4) 325 | gemspecContent = strings.Replace(gemspecContent, ":LICENSE:", init.license, 1) 326 | gemspecContent = strings.Replace(gemspecContent, ":GITHUB:", getConfig("githubUsername"), 1) 327 | gemspecContent = strings.Replace(gemspecContent, ":AUTHOR_NAME:", getConfig("fullName"), 1) 328 | makeFile(fmt.Sprintf("%v.gemspec", init.projectName), gemspecContent) 329 | 330 | makeDir("bin") 331 | 332 | makeDir("lib") 333 | os.Chdir("./lib") 334 | makeFile(fmt.Sprintf("%v.rb", init.projectName), "") 335 | os.Chdir(gwd) 336 | 337 | makeDir("tests") 338 | os.Chdir("./tests") 339 | makeFile(fmt.Sprintf("test_%v.rb", init.projectName), "") 340 | os.Chdir(gwd) 341 | 342 | e := execute("git", "init") 343 | if e != nil { 344 | fmt.Println("\n ** Git isn't installed on your system. Cannot initiate a git repository.") 345 | } else { 346 | fmt.Println("\n - Intialised a Git repository for your project.") 347 | } 348 | } 349 | -------------------------------------------------------------------------------- /src/init_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | The following code contains unittests for hydra continous integration. 3 | 4 | Author: Shravan Asati 5 | Originally Written: 21 April 2021 6 | Last Edited: 21 April 2021 7 | */ 8 | 9 | package main 10 | 11 | import ( 12 | "fmt" 13 | "io/ioutil" 14 | "os" 15 | "testing" 16 | ) 17 | 18 | func getFiles(dir string) []string { 19 | projectFiles, er := ioutil.ReadDir(dir) 20 | handleException(er) 21 | projectFileNames := []string{} 22 | for _, f := range projectFiles { 23 | projectFileNames = append(projectFileNames, f.Name()) 24 | } 25 | return projectFileNames 26 | } 27 | 28 | func TestPythonInit(t *testing.T) { 29 | gwd, e := os.Getwd() 30 | handleException(e) 31 | 32 | // * generating random project name and license for initialisation 33 | rlicense := generateRandom("license") 34 | rprojectName := generateRandom("name") 35 | 36 | init := Initializer{ 37 | projectName: rprojectName, 38 | license: rlicense, 39 | lang: "python", 40 | } 41 | init.pythonInit() 42 | 43 | // * getting all files present in the directory 44 | files, e := ioutil.ReadDir("./") 45 | handleException(e) 46 | 47 | // * converting into filenames 48 | filenames := []string{} 49 | for _, file := range files { 50 | filenames = append(filenames, file.Name()) 51 | } 52 | 53 | // * checking for presence 54 | if !stringInSlice(rprojectName, filenames) { 55 | t.Errorf("project %v not in the directory", rprojectName) 56 | } 57 | 58 | // * getting contents of the project initialised 59 | projectFiles, er := ioutil.ReadDir("./") 60 | handleException(er) 61 | projectFileNames := []string{} 62 | for _, f := range projectFiles { 63 | projectFileNames = append(projectFileNames, f.Name()) 64 | } 65 | 66 | // * checking for various files 67 | if !stringInSlice("LICENSE", projectFileNames) { 68 | t.Errorf("LICENSE file not present.") 69 | } 70 | if !stringInSlice("README.md", projectFileNames) { 71 | t.Errorf("README.md file not present.") 72 | } 73 | if !stringInSlice(".gitignore", projectFileNames) { 74 | t.Errorf(".gitignore file not present.") 75 | } 76 | if !stringInSlice("setup.py", projectFileNames) { 77 | t.Errorf("setup.py file not present.") 78 | } 79 | if !stringInSlice(rprojectName, projectFileNames) { 80 | t.Errorf("%v dir not present.", rprojectName) 81 | } 82 | if !stringInSlice("tests", projectFileNames) { 83 | t.Errorf("tests dir not present.") 84 | } 85 | 86 | t.Cleanup(func() { 87 | t.Log("Cleaning up...") 88 | os.Chdir(gwd) 89 | os.RemoveAll(rprojectName) 90 | }) 91 | } 92 | 93 | func TestGoInit(t *testing.T) { 94 | gwd, e := os.Getwd() 95 | handleException(e) 96 | 97 | // * generating random project name and license for initialisation 98 | rlicense := generateRandom("license") 99 | rprojectName := generateRandom("name") 100 | init := Initializer{ 101 | projectName: rprojectName, 102 | license: rlicense, 103 | lang: "go", 104 | } 105 | init.goInit() 106 | 107 | // * getting contents of the project initialised 108 | projectFiles, er := ioutil.ReadDir("./") 109 | handleException(er) 110 | projectFileNames := []string{} 111 | for _, f := range projectFiles { 112 | projectFileNames = append(projectFileNames, f.Name()) 113 | } 114 | 115 | // * checking for various files 116 | if !stringInSlice("LICENSE", projectFileNames) { 117 | t.Errorf("LICENSE file not present.") 118 | } 119 | if !stringInSlice("README.md", projectFileNames) { 120 | t.Errorf("README.md file not present.") 121 | } 122 | if !stringInSlice(".gitignore", projectFileNames) { 123 | t.Errorf(".gitignore file not present.") 124 | } 125 | if !stringInSlice("src", projectFileNames) { 126 | t.Errorf("src dir not present.") 127 | } 128 | if !stringInSlice("tests", projectFileNames) { 129 | t.Errorf("tests dir not present.") 130 | } 131 | 132 | t.Cleanup(func() { 133 | t.Log("Cleaning up...") 134 | os.Chdir(gwd) 135 | os.RemoveAll(rprojectName) 136 | }) 137 | } 138 | 139 | func TestWebInit(t *testing.T) { 140 | gwd, e := os.Getwd() 141 | handleException(e) 142 | 143 | // * generating random project name and license for initialisation 144 | rlicense := generateRandom("license") 145 | rprojectName := generateRandom("name") 146 | init := Initializer{ 147 | projectName: rprojectName, 148 | license: rlicense, 149 | lang: "web", 150 | } 151 | init.webInit() 152 | 153 | // * getting contents of the project initialised 154 | projectFileNames := getFiles("./") 155 | 156 | // * checking for various files 157 | fmt.Println(len(projectFileNames), projectFileNames) 158 | if len(projectFileNames) != 8 { 159 | t.Errorf("proper structure not made") 160 | } 161 | 162 | if !stringInSlice("LICENSE", projectFileNames) { 163 | t.Errorf("LICENSE file not present.") 164 | } 165 | if !stringInSlice("README.md", projectFileNames) { 166 | t.Errorf("README.md file not present.") 167 | } 168 | if !stringInSlice(".gitignore", projectFileNames) { 169 | t.Errorf(".gitignore file not present.") 170 | } 171 | if !stringInSlice("index.html", projectFileNames) { 172 | t.Errorf("index.html file not present.") 173 | } 174 | if !stringInSlice("css", projectFileNames) { 175 | t.Errorf("css dir not present.") 176 | } 177 | if !stringInSlice("js", projectFileNames) { 178 | t.Errorf("js dir not present.") 179 | } 180 | if !stringInSlice("img", projectFileNames) { 181 | t.Errorf("img dir not present.") 182 | } 183 | 184 | cssFiles := getFiles("./css") 185 | if !(stringInSlice("style.css", cssFiles)) { 186 | t.Errorf("style.css not present") 187 | } 188 | 189 | jsFiles := getFiles("./js") 190 | if !(stringInSlice("script.js", jsFiles)) { 191 | t.Errorf("script.js not present") 192 | } 193 | 194 | t.Cleanup(func() { 195 | t.Log("Cleaning up...") 196 | os.Chdir(gwd) 197 | os.RemoveAll(rprojectName) 198 | }) 199 | } 200 | -------------------------------------------------------------------------------- /src/licenses/APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright :YEAR: :NAME: 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /src/licenses/BSD: -------------------------------------------------------------------------------- 1 | Copyright :YEAR: :NAME: 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are 4 | permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of 7 | conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of 10 | conditions and the following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors may be used 14 | to endorse or promote products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 24 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/licenses/EPL: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 2.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ( 4 | “AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S 5 | ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | “Contribution” means: 9 | 10 | a) in the case of the initial Contributor, the initial content Distributed under this Agreement, and 11 | b) in the case of each subsequent Contributor: 12 | i) changes to the Program, and 13 | ii) additions to the Program; 14 | where such changes and/or additions to the Program originate from and are Distributed by 15 | that particular Contributor. A Contribution “originates” from a Contributor if it was added 16 | to the Program by such Contributor itself or anyone acting on such Contributor's behalf. 17 | Contributions do not include changes or additions to the Program that are not Modified 18 | Works. 19 | “Contributor” means any person or entity that Distributes the Program. 20 | 21 | “Licensed Patents” mean patent claims licensable by a Contributor which are necessarily 22 | infringed by the use or sale of its Contribution alone or when combined with the Program. 23 | 24 | “Program” means the Contributions Distributed in accordance with this Agreement. 25 | 26 | “Recipient” means anyone who receives the Program under this Agreement or any Secondary 27 | License (as applicable), including Contributors. 28 | 29 | “Derivative Works” shall mean any work, whether in Source Code or other form, that is based 30 | on (or derived from) the Program and for which the editorial revisions, annotations, 31 | elaborations, or other modifications represent, as a whole, an original work of authorship. 32 | 33 | “Modified Works” shall mean any work in Source Code or other form that results from an 34 | addition to, deletion from, or modification of the contents of the Program, including, for 35 | purposes of clarity any new file in Source Code form that contains any contents of the 36 | Program. Modified Works shall not include works that contain only declarations, interfaces, 37 | types, classes, structures, or files of the Program solely in each case in order to link 38 | to, bind by name, or subclass the Program or Modified Works thereof. 39 | 40 | “Distribute” means the acts of a) distributing or b) making available in any manner that 41 | enables the transfer of a copy. 42 | 43 | “Source Code” means the form of a Program preferred for making modifications, including but 44 | not limited to software source code, documentation source, and configuration files. 45 | 46 | “Secondary License” means either the GNU General Public License, Version 2.0, or any later 47 | versions of that license, including any exceptions or additional permissions as identified 48 | by the initial Contributor. 49 | 50 | 2. GRANT OF RIGHTS 51 | a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a 52 | non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare Derivative 53 | Works of, publicly display, publicly perform, Distribute and sublicense the Contribution of 54 | such Contributor, if any, and such Derivative Works. 55 | b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a 56 | non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, 57 | sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if 58 | any, in Source Code or other form. This patent license shall apply to the combination of 59 | the Contribution and the Program if, at the time the Contribution is added by the 60 | Contributor, such addition of the Contribution causes such combination to be covered by the 61 | Licensed Patents. The patent license shall not apply to any other combinations which 62 | include the Contribution. No hardware per se is licensed hereunder. 63 | c) Recipient understands that although each Contributor grants the licenses to its 64 | Contributions set forth herein, no assurances are provided by any Contributor that the 65 | Program does not infringe the patent or other intellectual property rights of any other 66 | entity. Each Contributor disclaims any liability to Recipient for claims brought by any 67 | other entity based on infringement of intellectual property rights or otherwise. As a 68 | condition to exercising the rights and licenses granted hereunder, each Recipient hereby 69 | assumes sole responsibility to secure any other intellectual property rights needed, if 70 | any. For example, if a third party patent license is required to allow Recipient to 71 | Distribute the Program, it is Recipient's responsibility to acquire that license before 72 | distributing the Program. 73 | d) Each Contributor represents that to its knowledge it has sufficient copyright rights in 74 | its Contribution, if any, to grant the copyright license set forth in this Agreement. 75 | e) Notwithstanding the terms of any Secondary License, no Contributor makes additional 76 | grants to any Recipient (other than those set forth in this Agreement) as a result of such 77 | Recipient's receipt of the Program under the terms of a Secondary License (if permitted 78 | under the terms of Section 3). 79 | 3. REQUIREMENTS 80 | 3.1 If a Contributor Distributes the Program in any form, then: 81 | 82 | a) the Program must also be made available as Source Code, in accordance with section 3.2, 83 | and the Contributor must accompany the Program with a statement that the Source Code for 84 | the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and 85 | b) the Contributor may Distribute the Program under a license different than this 86 | Agreement, provided that such license: 87 | i) effectively disclaims on behalf of all other Contributors all warranties and conditions, 88 | express and implied, including warranties or conditions of title and non-infringement, and 89 | implied warranties or conditions of merchantability and fitness for a particular purpose; 90 | ii) effectively excludes on behalf of all other Contributors all liability for damages, 91 | including direct, indirect, special, incidental and consequential damages, such as lost 92 | profits; 93 | iii) does not attempt to limit or alter the recipients' rights in the Source Code under 94 | section 3.2; and 95 | iv) requires any subsequent distribution of the Program by any party to be under a license 96 | that satisfies the requirements of this section 3. 97 | 3.2 When the Program is Distributed as Source Code: 98 | 99 | a) it must be made available under this Agreement, or if the Program (i) is combined with 100 | other material in a separate file or files made available under a Secondary License, and 101 | (ii) the initial Contributor attached to the Source Code the notice described in Exhibit A 102 | of this Agreement, then the Program may be made available under the terms of such Secondary 103 | Licenses, and 104 | b) a copy of this Agreement must be included with each copy of the Program. 105 | 3.3 Contributors may not remove or alter any copyright, patent, trademark, attribution 106 | notices, disclaimers of warranty, or limitations of liability (‘notices’) contained within 107 | the Program from any copy of the Program which they Distribute, provided that Contributors 108 | may add their own appropriate notices. 109 | 110 | 4. COMMERCIAL DISTRIBUTION 111 | Commercial distributors of software may accept certain responsibilities with respect to end 112 | users, business partners and the like. While this license is intended to facilitate the 113 | commercial use of the Program, the Contributor who includes the Program in a commercial 114 | product offering should do so in a manner which does not create potential liability for 115 | other Contributors. Therefore, if a Contributor includes the Program in a commercial 116 | product offering, such Contributor (“Commercial Contributor”) hereby agrees to defend and 117 | indemnify every other Contributor (“Indemnified Contributor”) against any losses, damages 118 | and costs (collectively “Losses”) arising from claims, lawsuits and other legal actions 119 | brought by a third party against the Indemnified Contributor to the extent caused by the 120 | acts or omissions of such Commercial Contributor in connection with its distribution of the 121 | Program in a commercial product offering. The obligations in this section do not apply to 122 | any claims or Losses relating to any actual or alleged intellectual property infringement. 123 | In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial 124 | Contributor in writing of such claim, and b) allow the Commercial Contributor to control, 125 | and cooperate with the Commercial Contributor in, the defense and any related settlement 126 | negotiations. The Indemnified Contributor may participate in any such claim at its own 127 | expense. 128 | 129 | For example, a Contributor might include the Program in a commercial product offering, 130 | Product X. That Contributor is then a Commercial Contributor. If that Commercial 131 | Contributor then makes performance claims, or offers warranties related to Product X, those 132 | performance claims and warranties are such Commercial Contributor's responsibility alone. 133 | Under this section, the Commercial Contributor would have to defend claims against the 134 | other Contributors related to those performance claims and warranties, and if a court 135 | requires any other Contributor to pay any damages as a result, the Commercial Contributor 136 | must pay those damages. 137 | 138 | 5. NO WARRANTY 139 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE 140 | LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 141 | KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS 142 | OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 143 | Recipient is solely responsible for determining the appropriateness of using and 144 | distributing the Program and assumes all risks associated with its exercise of rights under 145 | this Agreement, including but not limited to the risks and costs of program errors, 146 | compliance with applicable laws, damage to or loss of data, programs or equipment, and 147 | unavailability or interruption of operations. 148 | 149 | 6. DISCLAIMER OF LIABILITY 150 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY APPLICABLE 151 | LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, 152 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT 153 | LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 154 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 155 | OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 156 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | If any provision of this Agreement is invalid or unenforceable under applicable law, it 160 | shall not affect the validity or enforceability of the remainder of the terms of this 161 | Agreement, and without further action by the parties hereto, such provision shall be 162 | reformed to the minimum extent necessary to make such provision valid and enforceable. 163 | 164 | If Recipient institutes patent litigation against any entity (including a cross-claim or 165 | counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the 166 | Program with other software or hardware) infringes such Recipient's patent(s), then such 167 | Recipient's rights granted under Section 2(b) shall terminate as of the date such 168 | litigation is filed. 169 | 170 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any 171 | of the material terms or conditions of this Agreement and does not cure such failure in a 172 | reasonable period of time after becoming aware of such noncompliance. If all Recipient's 173 | rights under this Agreement terminate, Recipient agrees to cease use and distribution of 174 | the Program as soon as reasonably practicable. However, Recipient's obligations under this 175 | Agreement and any licenses granted by Recipient relating to the Program shall continue and 176 | survive. 177 | 178 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to 179 | avoid inconsistency the Agreement is copyrighted and may only be modified in the following 180 | manner. The Agreement Steward reserves the right to publish new versions (including 181 | revisions) of this Agreement from time to time. No one other than the Agreement Steward has 182 | the right to modify this Agreement. The Eclipse Foundation is the initial Agreement 183 | Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement 184 | Steward to a suitable separate entity. Each new version of the Agreement will be given a 185 | distinguishing version number. The Program (including Contributions) may always be 186 | Distributed subject to the version of the Agreement under which it was received. In 187 | addition, after a new version of the Agreement is published, Contributor may elect to 188 | Distribute the Program (including its Contributions) under the new version. 189 | 190 | 191 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 192 | licenses to the intellectual property of any Contributor under this Agreement, whether 193 | expressly, by implication, estoppel or otherwise. All rights in the Program not expressly 194 | granted under this Agreement are reserved. Nothing in this Agreement is intended to be 195 | enforceable by any entity that is not a Contributor or Recipient. No third-party 196 | beneficiary rights are created under this Agreement. 197 | 198 | Exhibit A – Form of Secondary Licenses Notice 199 | “This Source Code may also be made available under the following Secondary Licenses when 200 | the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are 201 | satisfied: {name license(s), version(s), and exceptions or additional permissions here}.” -------------------------------------------------------------------------------- /src/licenses/GPL: -------------------------------------------------------------------------------- 1 | Preamble 2 | 3 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 4 | 5 | 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. 6 | 7 | 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. 8 | 9 | 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. 10 | 11 | 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. 12 | 13 | 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. 14 | 15 | 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. 16 | 17 | 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. 18 | 19 | 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. 20 | 21 | The precise terms and conditions for copying, distribution and modification follow. 22 | 23 | TERMS AND CONDITIONS 24 | 0. Definitions. 25 | 26 | “This License” refers to version 3 of the GNU General Public License. 27 | 28 | “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 29 | 30 | “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. 31 | 32 | 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. 33 | 34 | A “covered work” means either the unmodified Program or a work based on the Program. 35 | 36 | 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. 37 | 38 | 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. 39 | 40 | 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. 41 | 42 | 1. Source Code. 43 | 44 | 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. 45 | 46 | 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. 47 | 48 | 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. 49 | 50 | 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. 51 | 52 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 53 | 54 | The Corresponding Source for a work in source code form is that same work. 55 | 56 | 2. Basic Permissions. 57 | 58 | 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. 59 | 60 | 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. 61 | 62 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 63 | 64 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 65 | 66 | 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. 67 | 68 | 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. 69 | 70 | 4. Conveying Verbatim Copies. 71 | 72 | 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. 73 | 74 | 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. 75 | 76 | 5. Conveying Modified Source Versions. 77 | 78 | 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: 79 | 80 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 81 | 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”. 82 | 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. 83 | 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. 84 | 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. 85 | 86 | 6. Conveying Non-Source Forms. 87 | 88 | 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: 89 | 90 | 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. 91 | 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. 92 | 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. 93 | 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. 94 | 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. 95 | 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. 96 | 97 | 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. 98 | 99 | “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. 100 | 101 | 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). 102 | 103 | 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. 104 | 105 | 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. 106 | 107 | 7. Additional Terms. 108 | 109 | “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. 110 | 111 | 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. 112 | 113 | 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: 114 | 115 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 116 | 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 117 | 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 118 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 119 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 120 | 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. 121 | 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. 122 | 123 | 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. 124 | 125 | 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. 126 | 127 | 8. Termination. 128 | 129 | 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). 130 | 131 | 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. 132 | 133 | 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. 134 | 135 | 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. 136 | 137 | 9. Acceptance Not Required for Having Copies. 138 | 139 | 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. 140 | 141 | 10. Automatic Licensing of Downstream Recipients. 142 | 143 | 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. 144 | 145 | 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. 146 | 147 | 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. 148 | 149 | 11. Patents. 150 | 151 | 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”. 152 | 153 | 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. 154 | 155 | 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. 156 | 157 | 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. 158 | 159 | 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. 160 | 161 | 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. 162 | 163 | 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. 164 | 165 | 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. 166 | 167 | 12. No Surrender of Others' Freedom. 168 | 169 | 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. 170 | 171 | 13. Use with the GNU Affero General Public License. 172 | 173 | 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. 174 | 175 | 14. Revised Versions of this License. 176 | 177 | 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. 178 | 179 | 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. 180 | 181 | 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. 182 | 183 | 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. 184 | 185 | 15. Disclaimer of Warranty. 186 | 187 | 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. 188 | 189 | 16. Limitation of Liability. 190 | 191 | 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. 192 | 193 | 17. Interpretation of Sections 15 and 16. 194 | 195 | 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. 196 | 197 | END OF TERMS AND CONDITIONS 198 | 199 | How to Apply These Terms to Your New Programs 200 | 201 | 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. 202 | 203 | 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. 204 | 205 | 206 | Copyright (C) :YEAR: :NAME: 207 | 208 | This program is free software: you can redistribute it and/or modify 209 | it under the terms of the GNU General Public License as published by 210 | the Free Software Foundation, either version 3 of the License, or 211 | (at your option) any later version. 212 | 213 | This program is distributed in the hope that it will be useful, 214 | but WITHOUT ANY WARRANTY; without even the implied warranty of 215 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 216 | GNU General Public License for more details. 217 | 218 | You should have received a copy of the GNU General Public License 219 | along with this program. If not, see . -------------------------------------------------------------------------------- /src/licenses/MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) :YEAR: :NAME: 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/licenses/MPL: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at https://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. -------------------------------------------------------------------------------- /src/licenses/UNI: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /src/list.go: -------------------------------------------------------------------------------- 1 | /* 2 | This file contains code which is responsible for the `list` command. 3 | 4 | Author: Shravan Asati 5 | Originally Written: 15 April 2021 6 | Last edited: 15 April 2021 7 | */ 8 | 9 | package main 10 | 11 | import "fmt" 12 | 13 | func list(item string) string { 14 | if item == "langs" { 15 | fmt.Printf("\n%v %v supports following languages for project initialisation: \n", NAME, VERSION) 16 | content := "" 17 | for i, v := range supportedLangs { 18 | content += fmt.Sprintf("%v. %v \n", i+1, v) 19 | } 20 | return content 21 | 22 | } else if item == "licenses" { 23 | fmt.Printf("\n%v %v supports following licenses for project initialisation: \n", NAME, VERSION) 24 | i := 1 25 | content := "" 26 | for k, v := range supportedLicenses { 27 | content += fmt.Sprintf("%v. %v - %v \n", i, k, v) 28 | i++ 29 | } 30 | return content 31 | 32 | } else if item == "configs" { 33 | config("default", "default", "default", "default") 34 | content := "\nThe hydra user configurations are: \n" 35 | content += fmt.Sprintf("Full Name: %v \n", getConfig("fullName")) 36 | content += fmt.Sprintf("GitHub Username: %v \n", getConfig("githubUsername")) 37 | content += fmt.Sprintf("Default Language: %v \n", getConfig("defaultLang")) 38 | content += fmt.Sprintf("Default License: %v \n", getConfig("defaultLicense")) 39 | content += fmt.Sprintln("\nTo know how to set the configuration, type in `hydra config -h`.") 40 | return content 41 | 42 | } else { 43 | return fmt.Sprintf("Invalid value for the 'item' argument: '%v'.\nSee `hydra list -h` for help.", item) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/static.go: -------------------------------------------------------------------------------- 1 | /* 2 | This file contains static data like variables (gitignores and licenses) which are to be 3 | embed and boilerplates for various programming languages. 4 | 5 | Author: Shravan Asati 6 | Originally Written: 8 May 2021 7 | Last edited: 4 June 2021 8 | */ 9 | 10 | package main 11 | 12 | import _ "embed" 13 | 14 | // * all licenses 15 | 16 | //go:embed licenses/APACHE 17 | var APACHE string 18 | 19 | //go:embed licenses/BSD 20 | var BSD string 21 | 22 | //go:embed licenses/EPL 23 | var EPL string 24 | 25 | //go:embed licenses/GPL 26 | var GPL string 27 | 28 | //go:embed licenses/MIT 29 | var MIT string 30 | 31 | //go:embed licenses/MPL 32 | var MPL string 33 | 34 | //go:embed licenses/UNI 35 | var UNI string 36 | 37 | // * all gitignores 38 | //go:embed gitignores/go.gitignore 39 | var goGitignore string 40 | 41 | //go:embed gitignores/python.gitignore 42 | var pythonGitignore string 43 | 44 | //go:embed gitignores/c.gitignore 45 | var cGitignore string 46 | 47 | //go:embed gitignores/cpp.gitignore 48 | var cppGitignore string 49 | 50 | //go:embed gitignores/ruby.gitignore 51 | var rubyGitignore string 52 | 53 | // * all boilerplates 54 | 55 | //go:embed boilerplates/html 56 | var HTMLBoilerplate string 57 | 58 | //go:embed boilerplates/cssReset 59 | var cssReset string 60 | 61 | //go:embed boilerplates/flask 62 | var flaskBoilerplate string 63 | 64 | //go:embed boilerplates/gemspec 65 | var gemspecContent string 66 | 67 | //go:embed boilerplates/setupContent 68 | var pythonSetup string -------------------------------------------------------------------------------- /src/templates/go.json: -------------------------------------------------------------------------------- 1 | { 2 | "file:LICENSE": "$license", 3 | "file:README.md": "# $projectName", 4 | "file:.gitignore": "$gitignore", 5 | 6 | "file:setup.py": "$pythonSetup", 7 | 8 | "dir:$projectName": { 9 | "file:__init__.py": "", 10 | "file:$projectName.py": "" 11 | }, 12 | 13 | "dir:tests": { 14 | "file:__init__.py": "", 15 | "file:test_$projectName.py": "" 16 | }, 17 | 18 | "commands": [ 19 | "git init" 20 | ] 21 | } -------------------------------------------------------------------------------- /src/templates/python.json: -------------------------------------------------------------------------------- 1 | { 2 | "file:LICENSE": "$license", 3 | "file:README.md": "# $projectName", 4 | "file:.gitignore": "$gitignore", 5 | 6 | "file:setup.py": "$pythonSetup", 7 | 8 | "dir:$projectName": { 9 | "file:__init__.py": "", 10 | "file:$projectName.py": "" 11 | }, 12 | 13 | "dir:tests": { 14 | "file:__init__.py": "", 15 | "file:test_$projectName.py": "" 16 | }, 17 | 18 | "commands": [ 19 | "git init" 20 | ] 21 | } -------------------------------------------------------------------------------- /src/update.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "io/ioutil" 7 | "net/http" 8 | "os" 9 | "runtime" 10 | "strings" 11 | ) 12 | 13 | func update() { 14 | fmt.Println("Updating hydra...") 15 | 16 | fmt.Println("Downloading the hydra executable...") 17 | // * determining the os-specific url 18 | url := "" 19 | switch runtime.GOOS { 20 | case "windows": 21 | url = "https://github.com/shravanasati/hydra/releases/latest/download/hydra-windows-amd64.exe" 22 | case "linux": 23 | url = "https://github.com/shravanasati/hydra/releases/latest/download/hydra-linux-amd64" 24 | case "darwin": 25 | url = "https://github.com/shravanasati/hydra/releases/latest/download/hydra-darwin-amd64" 26 | default: 27 | fmt.Println("Your OS isnt supported by hydra.") 28 | return 29 | } 30 | 31 | // * sending a request 32 | res, err := http.Get(url) 33 | 34 | if err != nil { 35 | fmt.Println("Error: Unable to download the executable. Check your internet connection.") 36 | fmt.Println(err) 37 | return 38 | } 39 | 40 | defer res.Body.Close() 41 | 42 | // * determining the executable path 43 | downloadPath, e := os.UserHomeDir() 44 | if e != nil { 45 | fmt.Println("Error: Unable to retrieve hydra path.") 46 | fmt.Println(e) 47 | return 48 | } 49 | downloadPath += "/.hydra/hydra" 50 | if runtime.GOOS == "windows" { 51 | downloadPath += ".exe" 52 | } 53 | 54 | os.Rename(downloadPath, downloadPath+"-old") 55 | 56 | exe, er := os.Create(downloadPath) 57 | if er != nil { 58 | fmt.Println("Error: Unable to access file permissions.") 59 | fmt.Println(er) 60 | return 61 | } 62 | defer exe.Close() 63 | 64 | // * writing the recieved content to the hydra executable 65 | _, errr := io.Copy(exe, res.Body) 66 | if errr != nil { 67 | fmt.Println("Error: Unable to write the executable.") 68 | fmt.Println(errr) 69 | return 70 | } 71 | 72 | // * performing an additional `chmod` utility for linux and mac 73 | if runtime.GOOS == "darwin" || runtime.GOOS == "linux" { 74 | execute("chmod", "u+x", downloadPath) 75 | } 76 | 77 | fmt.Println("Update completed!") 78 | } 79 | 80 | func deletePreviousInstallation() { 81 | hydraDir, _ := os.UserHomeDir() 82 | 83 | hydraDir += "/.hydra" 84 | 85 | files, _ := ioutil.ReadDir(hydraDir) 86 | for _, f := range files { 87 | if strings.HasSuffix(f.Name(), "-old") { 88 | // fmt.Println("found existsing installation") 89 | os.Remove(hydraDir + "/" + f.Name()) 90 | } 91 | // fmt.Println(f.Name()) 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/utils.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | // makeFile creates a file with the provided content. 9 | func makeFile(filename, content string) { 10 | f, e := os.Create(filename) 11 | handleException(e) 12 | _, er := f.WriteString(content) 13 | handleException(er) 14 | defer f.Close() 15 | cwd, _ := os.Getwd() 16 | fmt.Printf("\n - Created file '%v' at %v.", filename, cwd) 17 | } 18 | -------------------------------------------------------------------------------- /structures.md: -------------------------------------------------------------------------------- 1 | # Project Structures 2 | 3 | This file shows how the project structure for each language hydra supports, looks like. 4 | 5 | ### python 6 | 7 | ``` 8 | └── pythonDemo 9 | ├── .gitignore 10 | ├── LICENSE 11 | ├── README.md 12 | ├── pythonDemo 13 | | └── __init__.py 14 | ├── setup.py 15 | └── tests 16 | ├── __init__.py 17 | └── test_pythonDemo.py 18 | ``` 19 | 20 | 21 | ### go 22 | 23 | ``` 24 | └── goDemo 25 | ├── .gitignore 26 | ├── LICENSE 27 | ├── README.md 28 | ├── bin 29 | ├── go.mod 30 | ├── pkg 31 | ├── src 32 | | └── main.go 33 | └── tests 34 | └── goDemo_test.go 35 | ``` 36 | 37 | ### web 38 | 39 | ``` 40 | └── webDemo 41 | ├── .gitignore 42 | ├── LICENSE 43 | ├── README.md 44 | ├── css 45 | | └── style.css 46 | ├── img 47 | ├── index.html 48 | └── js 49 | └── script.js 50 | ``` 51 | 52 | ### flask 53 | 54 | ``` 55 | └── flaskDemo 56 | ├── .gitignore 57 | ├── LICENSE 58 | ├── README.md 59 | ├── app.py 60 | ├── static 61 | | ├── images 62 | | ├── scripts 63 | | | └── script.js 64 | | └── styles 65 | | └── style.css 66 | └── templates 67 | └── index.html 68 | ``` 69 | 70 | 71 | ### c 72 | 73 | ``` 74 | └── cDemo 75 | ├── .gitignore 76 | ├── LICENSE 77 | ├── Makefile.am 78 | ├── README.md 79 | ├── libs 80 | ├── src 81 | | ├── Makefile.am 82 | | ├── main.c 83 | | └── main.h 84 | └── tests 85 | ├── Makefile.am 86 | └── cDemo_test.c 87 | ``` 88 | 89 | 90 | ### c++ 91 | 92 | ``` 93 | └── cppDemo 94 | ├── .gitignore 95 | ├── CMakeLists.txt 96 | ├── LICENSE 97 | ├── README.md 98 | ├── include 99 | | └── cppDemo 100 | | └── header.h 101 | ├── libs 102 | ├── src 103 | | ├── main.cpp 104 | | └── main.h 105 | └── tests 106 | └── cppDemo_test.cpp 107 | ``` 108 | 109 | ### ruby 110 | 111 | ``` 112 | └── rubyDemo 113 | ├── .gitignore 114 | ├── Gemfile 115 | ├── LICENSE 116 | ├── README.md 117 | ├── Rakefile 118 | ├── bin 119 | ├── lib 120 | | └── rubyDemo.rb 121 | ├── rubyDemo.gemspec 122 | └── tests 123 | └── test_rubyDemo.rb 124 | ``` -------------------------------------------------------------------------------- /windows_install.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Downloading hydra..." 2 | 3 | $url = "https://github.com/shravanasati/hydra/releases/latest/download/hydra-windows-amd64.exe" 4 | 5 | $dir = $env:USERPROFILE + "\.hydra" 6 | $filepath = $env:USERPROFILE + "\.hydra\hydra.exe" 7 | 8 | [System.IO.Directory]::CreateDirectory($dir) 9 | (Invoke-WebRequest -Uri $url -OutFile $filepath) 10 | 11 | Write-Host "Adding hydra to PATH..." 12 | [Environment]::SetEnvironmentVariable( 13 | "Path", 14 | [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";"+$dir, 15 | [EnvironmentVariableTarget]::Machine) 16 | 17 | Write-Host 'hydra installation is successfull!' 18 | Write-Host "You need to restart your shell to use hydra." 19 | --------------------------------------------------------------------------------