Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Monynha-Softwares
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
default_install_hook_types: [pre-commit, pre-push]
default_stages: [commit, push]
repos:
- repo: local
hooks:
Expand All @@ -13,14 +11,8 @@ repos:
entry: shellcheck -x
language: system
files: \.sh$
- id: editorconfig-checker
name: editorconfig-checker
entry: ec
language: system
pass_filenames: false
- id: bats
name: bats
entry: make test
language: system
pass_filenames: false
stages: [push]
4 changes: 4 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Code of Conduct

This project follows the [Contributor Covenant](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). All contributors are expected to uphold these standards.

9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributing

Thank you for helping improve MonaRepo.

- Run `make install-dev` once to set up tools.
- Use `make fmt` and `make lint` before committing.
- Validate with `make test`.

See [docs/contributing.md](docs/contributing.md) for full guidelines.
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
SHELL := /bin/bash

.PHONY: install-dev fmt lint test ci
.PHONY: install-dev fmt lint test

install-dev:
sudo apt-get update -y
sudo apt-get install -y shellcheck shfmt bats curl
pip install --upgrade pre-commit editorconfig-checker
pip install --upgrade pre-commit
pre-commit install --install-hooks
pre-commit install --hook-type pre-push --install-hooks

fmt:
shfmt -w bin modules recipes tests
Expand All @@ -18,5 +17,3 @@ lint:

test:
bats -r tests

ci: lint test
113 changes: 36 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,59 @@
# MonaRepo — Monynha Softwares
# MonaRepo TUI

**Version:** v0.1.0
[![CI](https://github.com/Monynha-Softwares/MonaRepoTui/actions/workflows/lint_test.yml/badge.svg)](https://github.com/Monynha-Softwares/MonaRepoTui/actions/workflows/lint_test.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

A base monorepo (Bash-first) to automate VM/server bootstrap with an optional TUI powered by [`bashsimplecurses`](https://github.com/metal3d/bashsimplecurses).
Use this as the starting point for Codex/agents to extend modules and recipes.
TL;DR: Bash-based toolkit with optional TUI to bootstrap servers the Monynha Way.

## Features
- Single entrypoint: `bin/mona` — interactive TUI (↑/↓, Enter, Q) with a heart header ❤
- Flows: Quick Start, Distro Upgrade, Network (Netplan), Users & SSH, Hostname/hosts, Run Recipe
- Dry-run mode (`--dry-run`) to preview actions
- CI ready (ShellCheck + BATS), Makefile targets
- Cloud-init template for first-boot provisioning

## Getting Started
- Single entrypoint `bin/mona`
- Dry-run support
- Modules & recipes for common tasks

## Install
```bash
# clone
git clone <your-repo> monarepo && cd monarepo

# install development dependencies and git hooks
git clone https://github.com/Monynha-Softwares/MonaRepoTui.git
cd MonaRepoTui
make install-dev

# run full test suite
make test

# run TUI (recommended with sudo/root)
sudo ./bin/mona
```

### Local hooks

This repository uses [pre-commit](https://pre-commit.com/) hooks. Formatting
(`shfmt`) and linting (`shellcheck`, `editorconfig-checker`) run on every
commit. The BATS tests run automatically on `git push`. Hooks are installed by
`make install-dev`. You can manually trigger them for all files with:

## Quickstart
```bash
pre-commit run --all-files
bin/mona --help
```

### Run CI tasks locally
## Usage
```bash
$ bin/mona --help
MonaRepo v0.4.0

The same checks used in GitHub Actions can be executed locally:
Usage: mona [--dry-run] [--help] [--version]

```bash
make lint
make test
Flags:
--dry-run Show actions without applying
--help Print help and exit
--version Print version and exit
Env:
MONA_NONINTERACTIVE=1 Single-shot non-interactive mode for CI
```

### Non-interactive/CI flags
- `--version` : prints version and exits
- `--help` : prints help and exits
- `--dry-run` : prints actions instead of applying
- `MONA_NONINTERACTIVE=1` : single-shot non-interactive mode (no curses, no actions)
## Development
- `make fmt`
- `make lint`
- `make test`

### Directory Layout

```
bin/ # entrypoints
lib/ # shared helpers (future work for agents)
modules/ # idempotent modules (base, docker, ...)
recipes/ # orchestration of modules per "role"
templates/ # cloud-init and systemd
tests/ # bats tests
ui/ # optional bashsimplecurses submodule (or runtime fetch)
.github/workflows/ci.yml
## Testing
Run the full suite:
```bash
make test
```

## Cloud-init quick start
Use `templates/cloud-init/user-data.yaml` as user-data for new VMs. It clones your repo into `/opt/monarepo` and runs a recipe.

## Contributing
- Lint Shell: `make lint` (ShellCheck)
- Tests: `make test` (BATS)
- Keep modules idempotent: **probe → apply → verify**
- Prefer `apply` helper (respects `--dry-run`).
See [CONTRIBUTING.md](CONTRIBUTING.md).

## License
MIT — see [LICENSE](LICENSE).


## Included Recipes (examples)
- `recipes/coolify-node.sh` — base + docker + coolify bootstrap (network/dirs)
- `recipes/monitoring-node.sh` — base + docker + node_exporter + cAdvisor
- `recipes/supabase-node.sh` — base + docker (hook para Supabase)
## Security
See [SECURITY.md](SECURITY.md).

## Project Installer (Wizard)
Use the TUI option **“Instalar/Configurar Projeto (GitHub/Docker)”** to:
- List or select a GitHub repo (Monynha-Softwares by default) and clone it
- Or pull/run a Docker image quickly
- Then MonaRepo detects common post‑clone actions (e.g., copy `.env.example`, `docker compose up -d`, `npm/pnpm/yarn install`, `make setup`, `supabase start`) and lets you run them step‑by‑step while logging output.

Logs are stored in `~/.mona/logs` (or `$MONA_LOG_DIR`). `--dry-run` prints commands without executing.
## License
MIT © Monynha Softwares

### Installer extras (v0.4.0)
- **GitHub PAT**: set `GITHUB_TOKEN` to avoid rate limits and access private repos.
- **Interactive `.env`**: when a project has `.env.example`, choose “Criar .env interativo” to fill values key-by-key.
- **Docker Compose advanced**: auto-detects `docker compose` (plugin) or `docker-compose`; offers `pull`, `up -d --remove-orphans`, `ps`, `logs -f`.
- **TUI README viewer** (experimental): set `MONA_USE_TUI_READER=1` to view README inside the TUI; otherwise falls back to `less`.
> The Monynha Way: inclusive, accessible, DX-first.
59 changes: 59 additions & 0 deletions README.pt-BR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# MonaRepo TUI

[![CI](https://github.com/Monynha-Softwares/MonaRepoTui/actions/workflows/lint_test.yml/badge.svg)](https://github.com/Monynha-Softwares/MonaRepoTui/actions/workflows/lint_test.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

TL;DR: toolkit em Bash com TUI opcional para iniciar servidores no estilo Monynha.

## Funcionalidades
- Ponto de entrada único `bin/mona`
- Suporte a dry-run
- Módulos e receitas para tarefas comuns

## Instalação
```bash
git clone https://github.com/Monynha-Softwares/MonaRepoTui.git
cd MonaRepoTui
make install-dev
```

## Início Rápido
```bash
bin/mona --help
```

## Uso
```bash
$ bin/mona --help
MonaRepo v0.4.0

Uso: mona [--dry-run] [--help] [--version]

Flags:
--dry-run Mostra ações sem aplicar
--help Exibe ajuda e sai
--version Exibe versão e sai
Env:
MONA_NONINTERACTIVE=1 Modo não interativo (CI)
```

## Desenvolvimento
- `make fmt`
- `make lint`
- `make test`

## Testes
Execute toda a suíte:
```bash
make test
```

## Contribuindo
Veja [CONTRIBUTING.md](CONTRIBUTING.md).

## Segurança
Veja [SECURITY.md](SECURITY.md).

## Licença
MIT © Monynha Softwares

> O Jeito Monynha: inclusivo, acessível e focado em DX.
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Security Policy

If you discover a security issue, please report it responsibly.

- Email: security@monynha-softwares.example
- Do not disclose publicly until we provide a fix.

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.0
43 changes: 33 additions & 10 deletions bin/mona
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# MonaRepo — Interactive TUI bootstrapper
set -euo pipefail
set -Eeuo pipefail
IFS=$'\n\t'

# Determine repo root early so other scripts can source helpers safely
export MONA_BIN_PATH="$(readlink -f "$0")"
Expand All @@ -9,14 +10,14 @@ export MONA_DIR="$(cd "$(dirname "$MONA_BIN_PATH")/.." && pwd)"
# shellcheck source=../lib/common.sh
. "$MONA_DIR/lib/common.sh"

VERSION="0.4.0"
VERSION="$(cat "$MONA_DIR/VERSION")"

# ------------------------------ Globals ------------------------------------
export MONA_DRY_RUN="${MONA_DRY_RUN:-false}"
export MONA_NONINTERACTIVE="${MONA_NONINTERACTIVE:-0}"

# Arg parsing
show_help() {
usage() {
cat <<EOF
MonaRepo v$VERSION

Expand All @@ -31,20 +32,42 @@ Env:
EOF
}

for a in "$@"; do
case "$a" in
--help)
show_help
while getopts ':h-:v' opt; do
case "$opt" in
h)
usage
exit 0
;;
--version)
v)
echo "$VERSION"
exit 0
;;
--dry-run) MONA_DRY_RUN=true ;;
*) ;;
-)
case "$OPTARG" in
help)
usage
exit 0
;;
version)
echo "$VERSION"
exit 0
;;
dry-run) MONA_DRY_RUN=true ;;
*)
log_error "Unknown option --$OPTARG"
usage >&2
exit 1
;;
esac
;;
\?)
log_error "Unknown option -$OPTARG"
usage >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))

MONA_TMP_DIR="${TMPDIR:-/tmp}/mona"
mkdir -p "$MONA_TMP_DIR"
Expand Down
7 changes: 7 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Architecture

```
bin/ # entrypoints
modules/ # bash modules
tests/ # bats tests
```
9 changes: 9 additions & 0 deletions docs/cli-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CLI Usage

Common commands:

```bash
bin/mona --help
bin/mona --version
bin/mona --dry-run
```
8 changes: 8 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributing Guide

1. Run `make install-dev` to set up tools.
2. Use `make fmt` to format scripts.
3. Run `make lint` and `make test` before pushing.
4. Follow Conventional Commits.

See [../CONTRIBUTING.md](../CONTRIBUTING.md) for summary.
Loading