Compare commits
5 commits
4ebb931490
...
2d8c6320dc
Author | SHA1 | Date | |
---|---|---|---|
2d8c6320dc | |||
71f2370dad | |||
736e4fccb9 | |||
371d66cb61 | |||
3b66390840 |
4 changed files with 26 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
|||
"""Continuous Deployment."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -71,19 +73,19 @@ def browse(root: str) -> None:
|
|||
absolute_path = Path(directory) / file
|
||||
relative_path = os.path.relpath(absolute_path, start=root)
|
||||
paths.append(relative_path)
|
||||
open(root)
|
||||
frame(root)
|
||||
for path in sorted(paths):
|
||||
print(path)
|
||||
shut(root)
|
||||
|
||||
|
||||
def cat(file: str) -> None:
|
||||
open(file)
|
||||
frame(file)
|
||||
print(fs.read_file_text(file).rstrip())
|
||||
shut(file)
|
||||
|
||||
|
||||
def install_commands(path) -> None:
|
||||
def install_commands(path: str) -> None:
|
||||
step("Install commands")
|
||||
user = Path("/usr/local/bin")
|
||||
for command in [
|
||||
|
@ -94,10 +96,10 @@ def install_commands(path) -> None:
|
|||
"synchronize",
|
||||
]:
|
||||
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")
|
||||
#
|
||||
ssh_key, ssh_hosts = arguments
|
||||
|
@ -124,12 +126,12 @@ def set_ssh(*arguments) -> None:
|
|||
cat(known)
|
||||
|
||||
|
||||
def open(*arguments) -> None:
|
||||
def frame(*arguments: str) -> None:
|
||||
print(env.CD_OPEN, end="")
|
||||
print(*arguments, flush=True)
|
||||
|
||||
|
||||
def shut(*arguments) -> None:
|
||||
def shut(*arguments: str) -> None:
|
||||
print(env.CD_SHUT, end="")
|
||||
print(*arguments, flush=True)
|
||||
|
||||
|
@ -138,7 +140,7 @@ def split() -> None:
|
|||
print(env.CD_SPLT, flush=True)
|
||||
|
||||
|
||||
def step(*arguments) -> None:
|
||||
def step(*arguments: str) -> None:
|
||||
env.CD_STEP += 1
|
||||
print(env.CD_DOWN)
|
||||
print(env.CD_VERT, env.CD_STEP, *arguments)
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
"""Entry point to either bootstrap or command."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import cd
|
||||
|
||||
if __name__ == "__main__":
|
||||
command, *arguments = sys.argv
|
||||
command = Path(command).name
|
||||
if command == "__main__.py":
|
||||
path, *arguments = sys.argv
|
||||
name = Path(path).name
|
||||
if name == "__main__.py":
|
||||
cd.set_ssh(*arguments)
|
||||
cd.install_commands(__file__)
|
||||
else:
|
||||
command = command.replace("-", "_")
|
||||
function = getattr(cd, command)
|
||||
function = getattr(cd, name.replace("-", "_"))
|
||||
function(*arguments)
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from cd.projects import Projects
|
||||
|
||||
BRANCH = [
|
||||
"GITHUB_REF_NAME",
|
||||
|
@ -15,7 +21,7 @@ ROOT = [
|
|||
|
||||
|
||||
class Project:
|
||||
def __init__(self, projects) -> None:
|
||||
def __init__(self: Project, projects: Projects) -> None:
|
||||
self.projects = projects
|
||||
# branch
|
||||
for variable in BRANCH:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
GROUP_AND_NAME = [
|
||||
|
@ -11,7 +13,7 @@ SERVER_URL = [
|
|||
|
||||
|
||||
class Projects:
|
||||
def __init__(self, environment) -> None:
|
||||
def __init__(self: Projects, environment) -> None:
|
||||
self.environment = environment
|
||||
# group, name
|
||||
for variable in GROUP_AND_NAME:
|
||||
|
|
Loading…
Add table
Reference in a new issue