Skip to content

Commit

Permalink
Big update of the README file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guigui14460 committed Jul 4, 2020
1 parent b328ed4 commit 2fe71df
Show file tree
Hide file tree
Showing 6 changed files with 409 additions and 683 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GITHUB_USER=''
GITHUB_PASS=''
GITHUB_OAUTH_ACCESS_TOKEN=''
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
# .env
.venv
env/
venv/
Expand Down
875 changes: 201 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

204 changes: 199 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,212 @@
# Autonation of project creation for developers.
This project allows developers to create all kinds of projects (to be included in the executable of course) in a single command line via this CLI.

## Table of contents
1. [Usage of the application](#usage)
1. [How to use the CLI ?](#how-to-use-the-cli)
2. [Simple use](#simple-use)
3. [Executable creation](#compilation)
4. [Env file](#env-file)
5. [General usage](#general-usage)
6. [Licenses options](#licenses-options)
7. [Examples](#examples)
8. [Contribute](#contribute)

## Usage
## How to use the CLI ?
You need to download this Github repo via this command `git clone https://github.com/Guigui14460/project_automation.git` or `git clone [email protected]:Guigui14460/project_automation.git`.

For Windows :
After that, you need to use `pipenv` command to create the Python virtual environment. You can also use `virtualenv` command.

If you use `pipenv`, just launch:
```shell
$ pyinstaller cli.py --exclude-module=autopep8 --hidden-import=pkg_resources.py2_warn --name automate_projects --onefile
$ pipenv shell
```
If you use `virtualenv`, launch:
```shell
$ python -m venv env # replace python by python3 on Unix-like systems
$ . env/bin/activate # For Unix-like systems
$ env\Scripts\activate.bat # For Windows system
$ pip install -r requirements.txt
```
**Now, you are ready to begin with !**

## Simple use
Just launch:
```shell
$ python cli.py -h
```
You will have the same results at [general usage section](#general-usage).

**Warning !** If you want to create a project in Python and there are packages to install, the packages will install in the virtual environment of that project and not the desired project.
To avoid this, we advise you to [compile the application](#compilation).

For Unix-like systems :
**Warning !** If you want to create a repository on Github, you need to put your login credentials in a `.env` file ([see this section for more informations](#env-file)).

## Compilation
For Windows and Unix-like systems :
```shell
$ pyinstaller cli.py --exclude-module=autopep8 --hidden-import=pkg_resources.py2_warn --name automate_projects --onefile
```

## Env file
For personal use, we advise you to put your identifiers in the `.env` file at the root of the project.
Here is an example of how to write this :
```env
GITHUB_USER=<username>
GITHUB_PASS=<userpass>
GITHUB_OAUTH_ACCESS_TOKEN=<very_long_access_token>
```
You must not use simple or double quotation marks
**Warning !** If you have enabled dual authentication, you are required to use an access token. Here is the [official Github documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). After, you can only specify the `GITHUB_OAUTH_ACCESS_TOKEN`.

If you want to produce your own version to distribute this CLI, or you use a compiled version, you need to place the `.env` file at the same place from your executable file.

## General usage
After [compiling](#compilation), you can use your executable. You can launch it via the `help` command :
```shell
$ automate_projects -h
```
You will have this result :
```
usage: automate_projects [-h] [-i] [--github] [--public] [--license LICENSE]
{c,cpp,deno,flutter,go,haskell,java,nodejs,php,python,website}
...
positional arguments:
{c,cpp,deno,flutter,go,haskell,java,nodejs,php,python,website}
Use one of the available sub-command
optional arguments:
-h, --help show this help message and exit
-i, --allow-install allows to install used commands/packages (False by
default)
Github options:
--github use the github versioning
--public make the github repo with "Public Status"
--license LICENSE license type to add for the repo
```

To use subcommands, you can test the `python` subcommand :
```shell
$ automate_projects python -h
```
You will have this result :
```
usage: automate_projects.exe python [-h] [-t {classic,cython}] [--no-env]
[--env {pipenv,venv}]
[-p PACKAGES [PACKAGES ...]]
path project_name
sub-command to generate Python type project
positional arguments:
path path of the parent root for create the project
structure
project_name name of the project
optional arguments:
-h, --help show this help message and exit
-t {classic,cython}, --type {classic,cython}
create some specific python project (classic by
default)
--no-env no use the python virtual environment (False by
default)
--env {pipenv,venv} choice a python virtual environment (pipenv by
default)
-p PACKAGES [PACKAGES ...], --packages PACKAGES [PACKAGES ...]
package to install for this specific project
```
Each sub-command has its uniqueness, it's up to you to see what you do.

For more information, see [this section](#examples) showing some examples of use ;)

## Licenses options
By default, if you not use Github, the CLI will not add any `LICENSE` file. If you use Github and you not specify any license type, the CLI will add the `unlicense`.

Here is a list of licenses you can use:
```
apache : Apache License 2.0
bsd3 : BSD 3-Clause "New" or "Revised" License
bsd2 : BSD 2-Clause "Simplified" License
CC : Creative Commons Zero v1.0 Universal
eclipse : Eclipse Public License 2.0
gnu3 : GNU General Public License v3.0
gnu2 : GNU General Public License v2.0
gnuAffero3 : GNU Affero General Public License v3.0
gnuLess3 : GNU Lesser General Public License v3.0
gnuLess2.1 : GNU Lesser General Public License v2.1
mit : MIT License
mozilla : Mozilla Public License 2.0
unlicense : Unlicense
```


## Examples
Here are a few examples representing the majority of use cases.

---
### C++ example without Github
```shell
$ automate_projects -i cpp <your_path> <your_project_name>
```
Creation of a simple C++ project. Allow automatic installation of the required programs and packages.

---
### Cython example with Github (public repo)
```shell
$ automate_projects --github --public --license gnu3 -i python <your_path> <your_project_name> -t cython --env pipenv -p numpy matplotlib scipy sympy
```
Here, you choose to create a Python project and install automatically the required programs and packages. We create a public repository on Github licensed under GNU General Public License v3.0. We use use the Pipenv virtual environment. The Python project type is a [Cython](https://cython.readthedocs.io/en/latest/) project and we install [numpy](https://numpy.org/), [matplotlib](https://matplotlib.org/), [scipy](https://www.scipy.org/) and [sympy](https://www.sympy.org/en/index.html) python packages.

---
### Maven example with Github (private repo)
```shell
$ automate_projects --github java <your_path> <your_project_name> <project_package_name> -t mvn -c <compagny_name>
```
Here, you choose to create a Java project and not install the required programs and packages. We create a private repository on Github licensed under Unlicense. The Java project type is a [Maven](https://maven.apache.org/index.html) project.

---
### Webpack example without Github
```shell
$ automate_projects -i nodejs <your_path> <your_project_name> -t webpack
```
Here, you choose to create a [NodeJS project](https://nodejs.org/en/) and install automatically the required programs and packages. The NodeJS project type is a [WebpackJS](https://webpack.js.org/) project. For WebpackJS, some inputs are required to help the CLI to generate all the files and install all the packages.

## Contribute
You can contribute to the project in different ways:

---
### Add commands :
Adding commands is simple:
- create a file similar to the other files in the `project_automation.commands` directory;
- add it to the `__init__.py` file in the `project_automation.commands` module.

That's it!

---
### Add files
Adding files is simple:
- create a file similar to the other files in the `project_automation.files` folder;
- add it to the `__init__.py` file in the `project_automation.files` module.

That's it!

---
### Add projects
To add projects:
- create a file similar to the other files in the `project_automation.projects` folder;
- add it to the `__init__.py` file in the `project_automation.projects` module.
- add it to the argument parser, otherwise the project cannot be created.

If you decide to create a project on a language/framework not yet implemented, start by creating the commands and associated files. Then, simply create a module similar to the others in the `project_automation.projects` directory and repeat the above steps.

To choose the languages and framework used in the project, they are linked to the `gitignore` files available [here](https://github.com/github/gitignore).

If they are not there, just put the name of the language/framework used.

---
### Add licenses
To add license templates:
- create a file similar to the other files in the `project_automation.licenses` folder;
- add it to the `__init__.py` file in the `project_automation.licenses` module.
- add it to the `project_automation.settings` module in the `LICENSE_MODE` constant (to get the full name of the license type), then in `LICENSE_MODE_SHORTCUT` (to use it on the command line).
2 changes: 1 addition & 1 deletion project_automation/projects/java/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, subparser: argparse._SubParsersAction) -> NoReturn:
self.parser.add_argument('-c', '--company-name', default='nobody',
help='name of the compagny for the name of the package (nobody by default)')
self.parser.add_argument('-s', '--no-scripts', default=True, action='store_false',
help='generate some scripts to simplify usage (no scripts by default)')
help='generate some scripts to simplify usage for "classic" and "ant" only (no scripts by default)')

def modify_project_settings(self, result: argparse.Namespace, project_settings: dict) -> dict:
"""
Expand Down
6 changes: 4 additions & 2 deletions project_automation/projects/java/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MavenProject(JavaProject):
},
}

def __init__(self, path: str, name: str, package_name: str, company_name: str, github_settings: dict = {}, **kwargs: Any) -> NoReturn:
def __init__(self, path: str, name: str, package_name: str, company_name: str, executing_scripts: bool = False, github_settings: dict = {}, **kwargs: Any) -> NoReturn:
"""
Constructor and initializer.
Expand All @@ -58,6 +58,8 @@ def __init__(self, path: str, name: str, package_name: str, company_name: str, g
name of the package to put at the head of the Java files
company_name : str
name of the company (for the name of the package and maven)
executing_scripts : bool
allows us to create scripts to simplify the usage
github_settings : dict
some github informations
"""
Expand All @@ -76,7 +78,7 @@ def create(self) -> NoReturn:
self.verify_installation()
os.chdir(os.path.join(self.path, '..'))
execute_command2(
f"mvn archetype:generate -DgroupId=com.{self.company_name.lower()}.{self.package_name} -DartifactId={self.package_name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false")
f"mvn archetype:generate -DgroupId={self.company_name.lower()}.{self.package_name} -DartifactId={self.package_name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false")
super().create()

def verify_installation(self) -> NoReturn:
Expand Down

0 comments on commit 2fe71df

Please sign in to comment.