Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
oleoneto committed Jan 18, 2024
1 parent e314d3e commit 6a7f079
Show file tree
Hide file tree
Showing 28 changed files with 126 additions and 389 deletions.
107 changes: 107 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,109 @@
# geny
An extendable file generator

![publish](https://github.com/oleoneto/geny/workflows/publish/badge.svg?branch=master)
![PyPI - Package](https://img.shields.io/pypi/v/geny)
![PyPI - Python](https://img.shields.io/pypi/pyversions/geny)
![PyPI - License](https://img.shields.io/pypi/l/geny)
![PyPI - Downloads](https://img.shields.io/pypi/dm/geny)


- [geny](#geny)
- [Installation](#installation)
- [Extending the CLI](#extending-the-cli)
- [Dependencies](#dependencies)
- [Interactive Docs](#interactive-docs)
- [To Do](#to-do)
- [Pull requests](#pull-requests)
- [LICENSE](#license)

## Installation
Install via [pip](https://pypi.org/project/geny):
```bash
pip install geny
```

After installation, the CLI will expose the binary with the name:
```
geny
```

## Extending the CLI

Currently, there are two main ways of extending the functionality of the CLI:
1. Adding your own commands/plugins
2. Overriding the provided resource templates

### Including your own commands

If you would like to extend the functionality of this CLI, you can include your own `plugins/commands` by
setting an environment variable: `GENY_PLUGINS`. Simply set this variable to the path where your plugins are.

Plugin commands are auto-discovered if they are placed under the plugins directory,
but please be sure to do the following for this to work:
1. **Name your package and click command the same**. That is, a package called `get`, for example, should define a `get` command.
2. **Place the command definition within the package's `main.py` module**. For example:
```python
# get/main.py
import click


@click.command()
@click.pass_context
def get(ctx):
pass
```
3. **Sub-commands should be added to the top-most command group in the package's `main.py` module.**
```python
# get/main.py
import click


@click.group() # <- group
@click.pass_context
def get(ctx):
pass


@click.command()
@click.pass_context
def foo(ctx):
pass


get.add_command(foo)
```
4. **Access your commands via your top-most command group.**
```
django-clite get foo
```

**NOTE:** If you would like to skip a plugin/command from being auto-discovered, simply rename the package by either
prepending or appending any number of underscores (`_`). Any code contained within the package will be ignored.

### Overriding the templates

The flag `--templates-dir` can be used to configure an additional path wherein the CLI can look for resource templates.
Alternatively, you can use the environment variable `GENY_TEMPLATES_DIR` for the same purpose.

## Development

### Install from source:
```
git clone https://github.com/oleoneto/geny.git
cd geny
pip install --editable .
```

### Dependencies
Check out [pyproject.toml](pyproject.toml) for all installation dependencies.

## To Do
[Check out our open issues](https://github.com/oleoneto/geny/issues).

## Pull requests
Found a bug? See a typo? Have an idea for new command?
Feel free to submit a pull request with your contributions. They are much welcome and appreciated.

## LICENSE
**geny** is [BSD Licensed](LICENSE).
9 changes: 1 addition & 8 deletions geny/commands/generate/dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ def dockerfile(ctx, docker_compose):
File(
name="docker-compose.yaml",
template="docker/docker-compose.tpl",
context={
"services": [
"celery",
"kafka",
"postgres",
"rabbitmq" "redis",
],
},
context={},
)
)

Expand Down
24 changes: 0 additions & 24 deletions geny/template_files/celery/celery.tpl

This file was deleted.

7 changes: 0 additions & 7 deletions geny/template_files/celery/celery_init.tpl

This file was deleted.

7 changes: 0 additions & 7 deletions geny/template_files/celery/celery_tasks.tpl

This file was deleted.

45 changes: 12 additions & 33 deletions geny/template_files/docker/docker-compose.tpl
Original file line number Diff line number Diff line change
@@ -1,79 +1,58 @@
# These settings are provided for development purposes only. Not suitable for production.

version: '3'

{% if 'database' in services %}
volumes:
database:
{% endif %}


services:
app:
container_name: "{{ project }}_web"
labels:
com.{{ project }}.web.description: "{{ project }}: Web Application"
build:
context: .
# command: "gunicorn {{ project }}.wsgi:application --bind 0.0.0.0:{{ port }} --workers {{ workers }}"
volumes:
- .:/app
env_file:
- .env
environment:
DJANGO_ENV: docker
entrypoint: /docker-entrypoint.sh
command: "gunicorn {{ project }}.wsgi:application --bind 0.0.0.0:{{ port }} --workers {{ workers }}"
ports:
- 8007:8000 # host:docker
{%- if services %}
depends_on:
{%- for service in services %}
- {{ service }}
{% endfor %}
{% endif %}
- database
- celery-worker


{%- if 'database' in services %}
database:
container_name: "{{ project }}_database"
image: postgres:12-alpine
labels:
com.database.description: "{{ project }}: Database service"
image: postgres:15-alpine
volumes:
- ./database:/var/lib/postgresql/data/
ports:
- 5437:5432 # host:docker
env_file:
- .env
healthcheck:
test: ["CMD-SHELL", "pg_ready -U postgres"]
interval: 10s
timeout: 83s
retries: 40
restart: always
{% endif %}
restart: unless-stopped

{%- if 'redis' in services %}
redis:
container_name: "{{ project }}_redis"
image: redis:latest
labels:
com.redis.description: "{{ project }}: Redis cache service"
ports:
- 6377:6379 # host:docker
restart: always
{% endif %}
restart: unless-stopped

{%- if 'celery' in services %}
celery_worker:
container_name: "{{ project }}_celery_worker"
labels:
com.celery.description: "{{ project }}: Celery Worker"
build:
context: .
command: celery worker --app {{ project }} --concurrency=20 -linfo -E
# command: celery worker --app {{ project }} --concurrency=20 -linfo -E
depends_on:
- redis
env_file:
- .env
restart: on-failure
stop_grace_period: 5s
{% endif %}


# These settings are provided for development purposes only. Not suitable for production.
12 changes: 0 additions & 12 deletions geny/template_files/docker/docker-entrypoint.tpl

This file was deleted.

7 changes: 0 additions & 7 deletions geny/template_files/dokku/app_json.tpl

This file was deleted.

2 changes: 0 additions & 2 deletions geny/template_files/dokku/dokku_checks.tpl

This file was deleted.

1 change: 0 additions & 1 deletion geny/template_files/dokku/dokku_scale.tpl

This file was deleted.

1 change: 0 additions & 1 deletion geny/template_files/dokku/procfile.tpl

This file was deleted.

19 changes: 6 additions & 13 deletions geny/template_files/env.tpl
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# Example variables that could be in an environment file.
# Commit only the .env-example file, not the .env file. Use the example file to illustrate
# what variables your environment uses, but be sure to not commit this file with any sensitive information.
# what variables need to be in your application environment, but be sure to not commit this file
# as it may contain sensitive information.

DEBUG=True
SERVER_EMAIL="[email protected]"
REDIS_URL="redis://[:password]@127.0.0.1:6379"
DATABASE_URL="postgres://username:password@localhost:5432/database"

ADMINS=# i.e (('Admin', '[email protected]'),)

SECRET_KEY=

SERVER_EMAIL=# i.e [email protected]
EMAIL_HOST=
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=

REDIS_URL=# i.e. redis://[:password]@127.0.0.1:6379

DATABASE_URL=postgres://u:p@service:5432/service
SECRET_KEY=""
13 changes: 0 additions & 13 deletions geny/template_files/fixture.tpl

This file was deleted.

8 changes: 0 additions & 8 deletions geny/template_files/form.tpl

This file was deleted.

Empty file removed geny/template_files/github/ci.tpl
Empty file.
30 changes: 0 additions & 30 deletions geny/template_files/github/github_ci.tpl

This file was deleted.

Empty file.
15 changes: 0 additions & 15 deletions geny/template_files/html/create.tpl

This file was deleted.

Loading

0 comments on commit 6a7f079

Please sign in to comment.