Commit da5e8c42 authored by joe-narvaez's avatar joe-narvaez
Browse files

using minio instead of files

parent 735fcfed
Pipeline #573101265 failed with stage
in 38 seconds
No preview for this file type
......@@ -12,8 +12,8 @@ disable=
import-error,
attribute-defined-outside-init,
logging-fstring-interpolation,
no-self-use
print-statement
; no-self-use
; print-statement
......
......@@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"
[requires]
python_version = "3.9"
python_version = "3.10"
[packages]
pydantic = "*"
......@@ -14,6 +14,8 @@ sway = {editable = true, path = "."}
questionary = "*"
pyyaml = "*"
email-validator = "*"
psutil = "*"
aiohttp = "*"
[dev-packages]
pytest = "*"
......@@ -22,15 +24,15 @@ bandit = "*"
pylint = "*"
mypy = "*"
black = "*"
json2python-models = "*"
pytest-cov = "*"
sentry-sdk = "*"
datamodel-code-generator = "*"
[scripts]
preflight = "bash -c 'gitlab-ci-lint --token $GITLAB_TOKEN && semantic-release -d'"
typecheck = "mypy --install-types --non-interactive sway tests"
format = "black sway tests"
gen-types = "bash -c 'wget -O /tmp/schema.json https://minio.sway.cx/data/schema.json && datamodel-codegen --input /tmp/schema.json --input-file-type jsonschema --output sway/schema.py'"
lint = "bash -c 'pylint sway tests && bandit -r sway'"
cover = "pytest --cov --cov-fail-under=80"
checks = "bash -c 'pipenv run typecheck && pipenv run format && pipenv run lint && pipenv check -i 42559 -i 40291 -i 43313 -i 38464'"
checks = "bash -c 'pipenv run typecheck && pipenv run format && pipenv run lint && pipenv check -i 42559 -i 40291 -i 43313 -i 38464 -i 49150 -i 48542'"
commit = "bash -c 'pipenv run preflight && pipenv run checks && pipenv run cover && git add -A && cz --name cz_commitizen_emoji commit && git push'"
This diff is collapsed.
This diff is collapsed.
type: checkbox
message: " Dev Services:"
qmark: "☁️"
name: services
choices:
- separator: "👪 Team Services"
- name: "Gitlab: Alternative to Github and Github Actions (3.5k⭐)"
- name: "Matrix: Alternative to Slack (1.9k⭐)"
- separator: "🚀 App Services"
- name: "Dokku: Alternative to Heroku, AWS ECS/Copilot (1.9k⭐)"
- name: "Kong: Alternative to API Gateway (1.9k⭐)"
- name: "Keycloak: Alternative to AWS Cognito or Okta (1.9k⭐)"
- name: "Minio: Alternative to S3 (1.9k⭐)"
- name: "Hasura: GraphQL as a Service. Alternative to AppSync (1.9k⭐)"
- separator: " Messaging"
- name: "Kafka: Alternative to AWS Kinesis/MSK (1.9k⭐)"
- name: "EMQX: MQTT/IoT broker. Alternative to AWS IoT (1.9k⭐)"
- name: "Postal: Email Services. Alternative to AWS SES (1.9k⭐)"
- name: "Textbelt: SMS Services. (1.9k⭐)"
- name: "Gorush: Push notification Services. (1.9k⭐)"
- separator: "🔍 Monitoring and Logging"
- name: "Loki: Logging and monitoring. (1.9k⭐)"
- name: "Sentry: Error monitoring (1.9k⭐)"
- name: "Garie: Web Performance Monitoring (1.9k⭐)"
- separator: "🏗 Infrastructure"
- name: "Bitwarden: Manage passwords, secrets and tokens (3.7k⭐)"
disabled: "required"
- name: "Traefik: Routes HTTPS requests to container running all the services above (1.9k⭐)"
......@@ -2,7 +2,7 @@ message: |
During this wizard you will be prompted for:
✅ Services you wish to install
✅ The personal domain you purchased from namecheap
✅ The domain you purchased from namecheap
✅ Namecheap username and API key
✅ An email address to notify (these can all be turned off) when:
- auto renewal fails on your encryption certs
......
......@@ -17,11 +17,11 @@ choices:
- separator: "💬 Social Media"
- name: "Weechat: Manage slack, gitter, discord, irc, matrix chats (1.9k⭐)"
- name: "Mastodon: Federated Twitter (29.3k⭐)"
- name: "Fluent-Reader: An RSS Reader (2.8k⭐)\n Dependencies: syncthing"
- name: "FreshRSS: An RSS Reader (2.8k⭐)\n Dependencies: syncthing"
- separator: "🥗 Miscellaneous"
- name: "Bitwarden: Manage passwords, secrets and tokens (3.7k⭐)"
disabled: "required"
checked: true
- name: "Bitcore: Manage crypto. Compatible with bitpay debit card (3.6k⭐)\n Dependencies: mongodb bitcoind. Optional: cpuminer ethereum"
# - name: "Bitwarden: Manage passwords, secrets and tokens (3.7k⭐)"
# disabled: "required"
# checked: true
- name: "Bitcore: Manage crypto. Compatible with bitpay debit card (3.6k⭐)\n Dependencies: mongodb bitcoind. Optional: cpuminer ethereum"
- name: "Mycroft: Personal assistant. Easily add your own module (6.8k⭐)\n Dependencies: redis postgres"
- name: "wger: Alternative to google/apple fit (414⭐).\n Dependencies: redis postgres"
\ No newline at end of file
- name: personal_email
- name: email
type: text
message: "What's the email used to manage personal services (protonmail recommended)?"
message: "What's the email used to manage services (protonmail recommended)?"
qmark: ' '
- name: personal_domain
- name: domain
type: text
message: "What's the personal domain you got from namecheap?"
message: "What's the domain you got from namecheap?"
qmark: 🌎
- name: namecheap_username
type: text
......@@ -13,7 +13,6 @@
- name: namecheap_api_key
type: password
qmark: 🔑
message: "What's your namecheap API key?"
- name: master_password
type: password
......
{
"$id": "https://minio.sway.cx/shared/data/schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"title": "Resource",
"required": [
"name",
"description",
"category",
"repo-data"
],
"properties": {
"options": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/$defs/web-client"
},
{
"$ref": "#/$defs/personal-service"
},
{
"$ref": "#/$defs/daemon"
}
]
}
},
"dependencies": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/$defs/personal-service"
},
{
"$ref": "#/$defs/database"
},
{
"$ref": "#/$defs/daemon"
}
]
}
},
"name": {
"oneOf": [
{
"$ref": "#/$defs/personal-service"
},
{
"$ref": "#/$defs/dev-service"
},
{
"$ref": "#/$defs/android-client"
},
{
"$ref": "#/$defs/terminal-client"
},
{
"$ref": "#/$defs/web-client"
},
{
"$ref": "#/$defs/operating-system"
},
{
"$ref": "#/$defs/daemon"
},
{
"$ref": "#/$defs/database"
}
]
},
"description": {
"type": "string"
},
"category": {
"type": "string",
"enum": [
"personal-services",
"dev-services",
"android-clients",
"web-clients",
"operating-systems",
"terminal-clients",
"daemons",
"databases"
]
},
"repo-data": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "object",
"required": [
"url",
"title"
],
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"title": {
"type": "string"
},
"rating": {
"type": "integer"
}
}
}
}
},
"$defs": {
"personal-service": {
"type": "string",
"enum": [
"audiobookshelf",
"bitcore",
"calibre-web",
"collabora",
"fluent-reader",
"funkwhale",
"home-assistant",
"hydroxide",
"jellyfin",
"joplin",
"mastodon",
"mycroft",
"nextcloud",
"paperless",
"librephotos",
"syncthing",
"weechat",
"wger"
]
},
"dev-service": {
"type": "string",
"enum": [
"bitwarden",
"dokku",
"emqx",
"garie",
"gitlab",
"gorush",
"hasura",
"kafka",
"keycloak",
"kong",
"loki",
"matrix",
"minio",
"postal",
"sentry",
"textbelt",
"traefik"
]
},
"web-client": {
"type": "string",
"enum": [
"glowing-bear"
]
},
"terminal-client": {
"type": "string",
"enum": [
"castero",
"cava",
"emacs",
"epr",
"feh",
"khal",
"khard",
"mpv",
"ncmpcpp",
"neomutt",
"newsboat",
"ranger"
]
},
"android-client": {
"type": "string",
"enum": [
"antennapod",
"bitpay",
"geometric-weather",
"k9-mail",
"librera",
"microg",
"orgzly",
"simple-calendar",
"simple-contacts",
"simple-gallery",
"termux",
"tusky",
"weechat-android"
]
},
"operating-system": {
"type": "string",
"enum": [
"arch-linux",
"asteroidos",
"debian",
"lineageos"
]
},
"daemon": {
"type": "string",
"enum": [
"docker",
"restic",
"bitcoind",
"openethereum",
"cpuminer",
"litecoind"
]
},
"database": {
"type": "string",
"enum": [
"mariadb",
"mongodb",
"postgres",
"redis"
]
}
}
}
File added
import screens.personal
import screens.install
......@@ -3,9 +3,9 @@ import click
def intro(title: str) -> None:
click.echo(
"\n======================= Welcome to"
"\n==================== Welcome to"
+ click.style(" S W A Y ", bold=True, fg="bright_cyan")
+ f"{title} =======================\n"
+ f"{title} ====================\n"
)
......
......@@ -3,6 +3,7 @@ import sentry_sdk
import screens
from config import config, setup_logger
from utils import run
@click.version_option()
......@@ -19,7 +20,7 @@ def dev() -> None:
@dev.command("install")
def dev_install() -> None:
click.echo("Initializing dev install!")
screens.install.main("dev")
@dev.command("uninstall")
......@@ -34,7 +35,7 @@ def personal() -> None:
@personal.command("install")
def personal_install() -> None:
screens.personal.install()
screens.install.main("personal")
@personal.command("uninstall")
......@@ -68,6 +69,20 @@ def update() -> None:
click.echo("updates")
@cli.command()
@cli.group()
def autocomplete() -> None:
click.echo("autocomplete")
pass
@autocomplete.command()
def zsh() -> None:
run("_SWAY_COMPLETE=zsh_source sway > ~/.sway-complete.zsh")
run("echo '. ~/.sway-complete.zsh' >> ~/.zshrc")
click.echo("zsh autocomplete installed. please restart zsh")
@autocomplete.command()
def bash() -> None:
run("_SWAY_COMPLETE=bash_source sway > ~/.sway-complete.bash")
run("echo '. ~/.sway-complete.bash' >> ~/.bashrc")
click.echo("bash autocomplete installed. please restart bash")
......@@ -34,9 +34,13 @@ class CheckboxQuestion(Question):
choices: Choices
class VariablesQuestion(Question):
qmark: str
class Variables(BaseModel):
personal_email: EmailStr
personal_domain: str = Field(..., regex=DOMAIN_REGEX)
email: EmailStr
domain: str = Field(..., regex=DOMAIN_REGEX)
namecheap_username: str
namecheap_api_key: str
master_password: str
......@@ -47,3 +51,6 @@ class Spec(BaseModel):
services: List[Union[PersonalService, DevService]]
databases: List[Database]
daemons: List[Daemon]
ServiceType = Literal["personal", "dev"]
import asyncio
from typing import List, cast
from aiohttp import ClientSession
from schema import Resource
async def get_data(session: ClientSession) -> List[Resource]:
async with session.get("https://minio.sway.cx/data/data.json") as response:
blobs = await response.json()
return [Resource(**blob) for blob in blobs]
async def main() -> None:
session = ClientSession()
resources = await get_data(session)
await session.close()
asyncio.run(main())
# generated by datamodel-codegen:
# filename: schema.json
# timestamp: 2022-05-28T18:45:15+00:00
# timestamp: 2022-06-26T02:21:01+00:00
from __future__ import annotations
from enum import Enum
from typing import List, Optional, Union
from typing import List, Optional, Union, Literal
from pydantic import AnyUrl, BaseModel, Field
class Subcategory(Enum):
Databases_And_Storage = "Databases And Storage"
App_Services = "App Services"
BaaS = "BaaS"
Team_Services = "Team Services"
Messaging = "Messaging"
Metrics = "Metrics"
Media = "Media"
Groupware = "Groupware"
Social_Media = "Social Media"
Miscellaneous = "Miscellaneous"
class Category(Enum):
personal_services = "personal-services"
dev_services = "dev-services"
......@@ -21,15 +34,17 @@ class Category(Enum):
databases = "databases"
class RepoDatum(BaseModel):
class Repo(BaseModel):
url: AnyUrl
title: str
rating: Optional[int] = None
class AndroidClient(Enum):
class AndroidClients(Enum):
antennapod = "antennapod"
bitpay = "bitpay"
fluent_reader = "fluent-reader"
davx5 = "davx5"
geometric_weather = "geometric-weather"
k9_mail = "k9-mail"
librera = "librera"
......@@ -49,7 +64,6 @@ class Daemon(Enum):
bitcoind = "bitcoind"
openethereum = "openethereum"
cpuminer = "cpuminer"
litecoind = "litecoind"
class Database(Enum):
......@@ -60,16 +74,18 @@ class Database(Enum):
class DevService(Enum):
appwrite = "appwrite"
bitwarden = "bitwarden"
community = "community"
dokku = "dokku"
emqx = "emqx"
garie = "garie"
gitlab = "gitlab"
gorush = "gorush"
grafana = "grafana"
hasura = "hasura"
kafka = "kafka"
keycloak = "keycloak"
kong = "kong"
loki = "loki"
matrix = "matrix"
minio = "minio"
......@@ -79,7 +95,7 @@ class DevService(Enum):
traefik = "traefik"
class OperatingSystem(Enum):
class OperatingSystems(Enum):
arch_linux = "arch-linux"
asteroidos = "asteroidos"
debian = "debian"
......@@ -91,23 +107,25 @@ class PersonalService(Enum):
bitcore = "bitcore"
calibre_web = "calibre-web"
collabora = "collabora"
fluent_reader = "fluent-reader"
freshrss = "freshrss"
funkwhale = "funkwhale"
home_assistant = "home-assistant"
hydroxide = "hydroxide"
jellyfin = "jellyfin"
joplin = "joplin"
mastodon = "mastodon"
mopidy = "mopidy"
mycroft = "mycroft"
nextcloud = "nextcloud"
paperless = "paperless"
librephotos = "librephotos"
snapcast = "snapcast"
syncthing = "syncthing"
weechat = "weechat"
wger = "wger"
class TerminalClient(Enum):
class TerminalClients(Enum):
castero = "castero"
cava = "cava"
emacs = "emacs"
......@@ -122,25 +140,24 @@ class TerminalClient(Enum):
ranger = "ranger"
class WebClient(Enum):
class WebClients(Enum):
glowing_bear = "glowing-bear"
class Resource(BaseModel):
options: Optional[List[Union[WebClient, PersonalService, Daemon]]] = None
subcategory: Optional[Subcategory] = None
options: Optional[List[Union[WebClients, PersonalService, Daemon]]] = None
dependencies: Optional[List[Union[PersonalService, Database, Daemon]]] = None
name: Union[
PersonalService,
DevService,
AndroidClient,
TerminalClient,
WebClient,
OperatingSystem,
AndroidClients,
TerminalClients,
WebClients,