Compare commits

...

5 commits

Author SHA1 Message Date
2d8c6320dc
init,main
All checks were successful
/ job (push) Successful in 7m22s
2024-06-09 23:15:19 +02:00
71f2370dad
frame 2024-06-09 21:00:01 +02:00
736e4fccb9
strings 2024-06-09 20:55:32 +02:00
371d66cb61
linting 2024-06-09 20:28:09 +02:00
3b66390840
linting 2024-06-09 20:04:29 +02:00
4 changed files with 26 additions and 15 deletions

View file

@ -1,3 +1,5 @@
"""Continuous Deployment."""
import os import os
from pathlib import Path from pathlib import Path
@ -71,19 +73,19 @@ def browse(root: str) -> None:
absolute_path = Path(directory) / file absolute_path = Path(directory) / file
relative_path = os.path.relpath(absolute_path, start=root) relative_path = os.path.relpath(absolute_path, start=root)
paths.append(relative_path) paths.append(relative_path)
open(root) frame(root)
for path in sorted(paths): for path in sorted(paths):
print(path) print(path)
shut(root) shut(root)
def cat(file: str) -> None: def cat(file: str) -> None:
open(file) frame(file)
print(fs.read_file_text(file).rstrip()) print(fs.read_file_text(file).rstrip())
shut(file) shut(file)
def install_commands(path) -> None: def install_commands(path: str) -> None:
step("Install commands") step("Install commands")
user = Path("/usr/local/bin") user = Path("/usr/local/bin")
for command in [ for command in [
@ -94,10 +96,10 @@ def install_commands(path) -> None:
"synchronize", "synchronize",
]: ]:
print(command) print(command)
os.symlink(path, user / f"{COMMANDS_PREFIX}{command}") (user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
def set_ssh(*arguments) -> None: def set_ssh(*arguments: str) -> None:
step("Set SSH") step("Set SSH")
# #
ssh_key, ssh_hosts = arguments ssh_key, ssh_hosts = arguments
@ -124,12 +126,12 @@ def set_ssh(*arguments) -> None:
cat(known) cat(known)
def open(*arguments) -> None: def frame(*arguments: str) -> None:
print(env.CD_OPEN, end="") print(env.CD_OPEN, end="")
print(*arguments, flush=True) print(*arguments, flush=True)
def shut(*arguments) -> None: def shut(*arguments: str) -> None:
print(env.CD_SHUT, end="") print(env.CD_SHUT, end="")
print(*arguments, flush=True) print(*arguments, flush=True)
@ -138,7 +140,7 @@ def split() -> None:
print(env.CD_SPLT, flush=True) print(env.CD_SPLT, flush=True)
def step(*arguments) -> None: def step(*arguments: str) -> None:
env.CD_STEP += 1 env.CD_STEP += 1
print(env.CD_DOWN) print(env.CD_DOWN)
print(env.CD_VERT, env.CD_STEP, *arguments) print(env.CD_VERT, env.CD_STEP, *arguments)

View file

@ -1,17 +1,18 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
"""Entry point to either bootstrap or command."""
import sys import sys
from pathlib import Path from pathlib import Path
import cd import cd
if __name__ == "__main__": if __name__ == "__main__":
command, *arguments = sys.argv path, *arguments = sys.argv
command = Path(command).name name = Path(path).name
if command == "__main__.py": if name == "__main__.py":
cd.set_ssh(*arguments) cd.set_ssh(*arguments)
cd.install_commands(__file__) cd.install_commands(__file__)
else: else:
command = command.replace("-", "_") function = getattr(cd, name.replace("-", "_"))
function = getattr(cd, command)
function(*arguments) function(*arguments)

View file

@ -1,4 +1,10 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from cd.projects import Projects
BRANCH = [ BRANCH = [
"GITHUB_REF_NAME", "GITHUB_REF_NAME",
@ -15,7 +21,7 @@ ROOT = [
class Project: class Project:
def __init__(self, projects) -> None: def __init__(self: Project, projects: Projects) -> None:
self.projects = projects self.projects = projects
# branch # branch
for variable in BRANCH: for variable in BRANCH:

View file

@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
GROUP_AND_NAME = [ GROUP_AND_NAME = [
@ -11,7 +13,7 @@ SERVER_URL = [
class Projects: class Projects:
def __init__(self, environment) -> None: def __init__(self: Projects, environment) -> None:
self.environment = environment self.environment = environment
# group, name # group, name
for variable in GROUP_AND_NAME: for variable in GROUP_AND_NAME: