Skip to content

Commit

Permalink
Merge pull request #58 from minos-framework/0.1.0
Browse files Browse the repository at this point in the history
0.1.0
  • Loading branch information
Sergio García Prado authored Feb 3, 2022
2 parents 3d6ddfc + 9163f9e commit 4b6f11f
Show file tree
Hide file tree
Showing 71 changed files with 2,706 additions and 1,074 deletions.
14 changes: 14 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@

* Implement basic `minos microservice new` and `minos microservice init` commands.
* First version on pypi.


## 0.1.0 (2022-02-03)

* Add `minos set broker` command.
* Add `minos set database` command.
* Add `minos set discovery` command.
* Add `minos set api-gateway` command.
* Add `minos deploy project` command.
* Add `minos deploy microservice` command.
* Refactor `minos project new` command as `minos new project`.
* Refactor `minos project init` command as `minos init project`.
* Refactor `minos microservice new` command as `minos new microservice`.
* Refactor `minos microservice init` command as `minos init microservice`.
90 changes: 47 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,70 @@
# Minos CLI
<p align="center">
<a href="http://minos.run" target="_blank"><img src="https://raw.githubusercontent.com/minos-framework/.github/main/images/logo.png" alt="Minos logo"></a>
</p>

[![codecov](https://codecov.io/gh/Clariteia/minos_cli/branch/main/graph/badge.svg)](https://codecov.io/gh/Clariteia/minos_cli)
![Tests](https://github.com/Clariteia/minos_cli/actions/workflows/python-tests.yml/badge.svg)
# Minos CLI: Minos' microservices up and running

Minos is a framework which helps you create [reactive](https://www.reactivemanifesto.org/) microservices in Python.
Internally, it leverages Event Sourcing, CQRS and a message driven architecture to fulfil the commitments of an
asynchronous environment.
[![PyPI Latest Release](https://img.shields.io/pypi/v/minos-cli.svg?label=minos-cli)](https://pypi.org/project/minos-microservice-aggregate/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/minos-framework/minos-python/pages%20build%20and%20deployment?label=docs)](https://minos-framework.github.io/minos-cli)
[![License](https://img.shields.io/github/license/minos-framework/minos-python.svg)](https://github.com/minos-framework/minos-python/blob/main/LICENSE)
[![Coverage](https://codecov.io/github/minos-framework/minos-cli/coverage.svg?branch=main)](https://codecov.io/gh/minos-framework/minos-cli)
[![Stack Overflow](https://img.shields.io/badge/Stack%20Overflow-Ask%20a%20question-green)](https://stackoverflow.com/questions/tagged/minos)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/minos-framework/community)

## Documentation
## Summary

The official documentation as well as the API you can find it under https://clariteia.github.io/minos_cli/.
Please, submit any issue regarding documentation as well!
Minos CLI is a command line tool that helps you create and deploy Minos' microservices. Through its simple command
structure, you'll get your microservices up and running as fast as you've coded your business logic.

## Set up a development environment
## Quickstart

Minos uses `poetry` as its default package manager. Please refer to the
[Poetry installation guide](https://python-poetry.org/docs/#installation) for instructions on how to install it.
First, we need to create a project to host our microservices

Now you con install all the dependencies by running
```bash
make install
```shell
minos new project sample_project
cd sample_project/
```

In order to make the pre-commits checks available to git, run
```bash
pre-commit install
We need to set some services that our project needs

```shell
minos set database postgres
minos set broker kafka
minos set apigateway minos
minos set discovery minos
```

Make yourself sure you are able to run the tests. Refer to the appropriate section in this guide.
Once we've gone through all of these steps, the project is ready to accept a new microservice!

## Run the tests
```shell
cd microservices/
minos new microservice foo
```

In order to run the tests, please make sure you have the [Docker Engine](https://docs.docker.com/engine/install/)
and [Docker Compose](https://docs.docker.com/compose/install/) installed.
Time to start coding! Yes, already!

Move into `tests/` directory
## Documentation

```bash
cd tests/
```
Run service dependencies:
Coming soon...

```bash
docker-compose up -d
```
## Source Code

Install library dependencies:
The source code of this project is hosted at [GitHub](https://github.com/minos-framework/minos-cli).

```bash
make install
```
## Getting Help

Run tests:
For usage questions, the best place to go to is [StackOverflow](https://stackoverflow.com/questions/tagged/minos).

```bash
make test
```
## Discussion and Development

Most development discussions take place over the [GitHub Issues](https://github.com/minos-framework/minos-python/issues)
. In addition, a [Gitter channel](https://gitter.im/minos-framework/community) is available for development-related
questions.

## How to contribute

Minos being an open-source project, we are looking forward to having your contributions. No matter whether it is a pull
request with new features, or the creation of an issue related to a bug you have found.
We are looking forward to having your contributions. No matter whether it is a pull request with new features, or the
creation of an issue related to a bug you have found.

Please consider these guidelines before you submit any modification.

Expand All @@ -78,7 +82,7 @@ Please consider these guidelines before you submit any modification.
4. Run the tests!
5. Submit a pull request from your fork's branch.

## Credits

This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [Minos Package](https://github.com/Clariteia/minos-pypackage) project template.
## License

This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE)
license.
33 changes: 23 additions & 10 deletions minos/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
__author__ = """Clariteia Devs"""
__email__ = "[email protected]"
__version__ = "0.0.1"
__author__ = "Minos Framework Devs"
__email__ = "[email protected]"
__version__ = "0.1.0"

from .constants import (
MICROSERVICE_TEMPLATE_PATH,
)
from .generators import (
MicroserviceGenerator,
)
from .main import (
from .api import (
app,
main,
)
from .consoles import (
console,
error_console,
)
from .importlib import (
FunctionLoader,
)
from .pathlib import (
get_microservice_target_directory,
get_project_target_directory,
)
from .templating import (
TemplateFetcher,
TemplateProcessor,
)
from .wizards import (
Form,
Question,
)
2 changes: 1 addition & 1 deletion minos/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .main import (
from .api import (
main,
)

Expand Down
34 changes: 34 additions & 0 deletions minos/cli/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import typer

from ..consoles import (
console,
)
from .deploy import app as deploy_app
from .init import app as init_app
from .new import app as new_app
from .set import app as set_app
from .utils import app as utils_app

app = typer.Typer(add_completion=False)
app.add_typer(init_app, name="init")
app.add_typer(new_app, name="new")
app.add_typer(deploy_app, name="deploy")
app.add_typer(utils_app, name="utils")
app.add_typer(set_app, name="set")


@app.callback()
def callback():
"""Minos CLI."""


def main(): # pragma: no cover
"""CLI's main function."""
console.rule("Welcome to the Minos CLI :robot:")
console.print()

try:
app()
finally:
console.rule("See you later! :call_me_hand:")
console.print()
42 changes: 42 additions & 0 deletions minos/cli/api/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from pathlib import (
Path,
)
from typing import (
Optional,
)

import typer

from ..consoles import (
console,
)
from ..deploying import (
MicroserviceDeployer,
ProjectDeployer,
)

app = typer.Typer(add_completion=False)


@app.command("microservice")
def deploy_microservice(name: Optional[str] = typer.Argument(None), path: Path = typer.Option(Path.cwd())) -> None:
"""Deploy a Microservice."""

console.print(":wrench: Deploying the microservice...\n")
deployer = MicroserviceDeployer(path, name)
deployer.deploy()


@app.command("project")
def deploy_project(path: Path = typer.Option(Path.cwd())) -> None:
"""Deploy a Project."""

console.print(":wrench: Deploying the Project...\n")

deployer = ProjectDeployer(path)
deployer.deploy()


@app.callback()
def callback():
"""Deploys the project"""
40 changes: 40 additions & 0 deletions minos/cli/api/init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pathlib import (
Path,
)

import typer

from ..consoles import (
console,
)
from ..templating import (
TemplateFetcher,
TemplateProcessor,
)

app = typer.Typer(add_completion=False)


@app.command("project")
def init_project() -> None:
"""Initialize a project on the current working directory."""

console.print(":wrench: Initializing new Project...\n")
fetcher = TemplateFetcher.from_name("project-init")
processor = TemplateProcessor.from_fetcher(fetcher, Path.cwd(), defaults={"project_name": Path.cwd().name})
processor.render()


@app.command("microservice")
def init_microservice() -> None:
"""Initialize a microservice on the current working directory."""

console.print(":wrench: Initializing new Microservice...\n")
fetcher = TemplateFetcher.from_name("microservice-init")
processor = TemplateProcessor.from_fetcher(fetcher, Path.cwd(), defaults={"name": Path.cwd().name})
processor.render()


@app.callback()
def callback():
"""Initializes a new project or microservice in the current path"""
42 changes: 42 additions & 0 deletions minos/cli/api/new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from pathlib import (
Path,
)

import typer

from ..consoles import (
console,
)
from ..templating import (
TemplateFetcher,
TemplateProcessor,
)

app = typer.Typer(add_completion=False)


@app.command("project")
def new_project(path: Path) -> None:
"""Initialize a project on the given directory."""

console.print(":wrench: Creating new Project...\n")

fetcher = TemplateFetcher.from_name("project-init")
processor = TemplateProcessor.from_fetcher(fetcher, path.absolute(), defaults={"project_name": path.name})
processor.render()


@app.command("microservice")
def new_microservice(path: Path) -> None:
"""Initialize a microservice on the given directory."""

console.print(":wrench: Creating new Microservice...\n")

fetcher = TemplateFetcher.from_name("microservice-init")
processor = TemplateProcessor.from_fetcher(fetcher, path.absolute(), defaults={"name": path.name})
processor.render()


@app.callback()
def callback():
"""Creates a new project or microservice in a given path"""
Loading

0 comments on commit 4b6f11f

Please sign in to comment.