Compare commits
No commits in common. "2d8c6320dc5c6e3ccb588d198dff887e34fbe3e6" and "4ebb93149061320291f1617ec8cbe85808d23ae0" have entirely different histories.
2d8c6320dc
...
4ebb931490
4 changed files with 15 additions and 26 deletions
|
@ -1,5 +1,3 @@
|
||||||
"""Continuous Deployment."""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -73,19 +71,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)
|
||||||
frame(root)
|
open(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:
|
||||||
frame(file)
|
open(file)
|
||||||
print(fs.read_file_text(file).rstrip())
|
print(fs.read_file_text(file).rstrip())
|
||||||
shut(file)
|
shut(file)
|
||||||
|
|
||||||
|
|
||||||
def install_commands(path: str) -> None:
|
def install_commands(path) -> None:
|
||||||
step("Install commands")
|
step("Install commands")
|
||||||
user = Path("/usr/local/bin")
|
user = Path("/usr/local/bin")
|
||||||
for command in [
|
for command in [
|
||||||
|
@ -96,10 +94,10 @@ def install_commands(path: str) -> None:
|
||||||
"synchronize",
|
"synchronize",
|
||||||
]:
|
]:
|
||||||
print(command)
|
print(command)
|
||||||
(user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
|
os.symlink(path, user / f"{COMMANDS_PREFIX}{command}")
|
||||||
|
|
||||||
|
|
||||||
def set_ssh(*arguments: str) -> None:
|
def set_ssh(*arguments) -> None:
|
||||||
step("Set SSH")
|
step("Set SSH")
|
||||||
#
|
#
|
||||||
ssh_key, ssh_hosts = arguments
|
ssh_key, ssh_hosts = arguments
|
||||||
|
@ -126,12 +124,12 @@ def set_ssh(*arguments: str) -> None:
|
||||||
cat(known)
|
cat(known)
|
||||||
|
|
||||||
|
|
||||||
def frame(*arguments: str) -> None:
|
def open(*arguments) -> None:
|
||||||
print(env.CD_OPEN, end="")
|
print(env.CD_OPEN, end="")
|
||||||
print(*arguments, flush=True)
|
print(*arguments, flush=True)
|
||||||
|
|
||||||
|
|
||||||
def shut(*arguments: str) -> None:
|
def shut(*arguments) -> None:
|
||||||
print(env.CD_SHUT, end="")
|
print(env.CD_SHUT, end="")
|
||||||
print(*arguments, flush=True)
|
print(*arguments, flush=True)
|
||||||
|
|
||||||
|
@ -140,7 +138,7 @@ def split() -> None:
|
||||||
print(env.CD_SPLT, flush=True)
|
print(env.CD_SPLT, flush=True)
|
||||||
|
|
||||||
|
|
||||||
def step(*arguments: str) -> None:
|
def step(*arguments) -> 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)
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
#! /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__":
|
||||||
path, *arguments = sys.argv
|
command, *arguments = sys.argv
|
||||||
name = Path(path).name
|
command = Path(command).name
|
||||||
if name == "__main__.py":
|
if command == "__main__.py":
|
||||||
cd.set_ssh(*arguments)
|
cd.set_ssh(*arguments)
|
||||||
cd.install_commands(__file__)
|
cd.install_commands(__file__)
|
||||||
else:
|
else:
|
||||||
function = getattr(cd, name.replace("-", "_"))
|
command = command.replace("-", "_")
|
||||||
|
function = getattr(cd, command)
|
||||||
function(*arguments)
|
function(*arguments)
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
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",
|
||||||
|
@ -21,7 +15,7 @@ ROOT = [
|
||||||
|
|
||||||
|
|
||||||
class Project:
|
class Project:
|
||||||
def __init__(self: Project, projects: Projects) -> None:
|
def __init__(self, projects) -> None:
|
||||||
self.projects = projects
|
self.projects = projects
|
||||||
# branch
|
# branch
|
||||||
for variable in BRANCH:
|
for variable in BRANCH:
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
GROUP_AND_NAME = [
|
GROUP_AND_NAME = [
|
||||||
|
@ -13,7 +11,7 @@ SERVER_URL = [
|
||||||
|
|
||||||
|
|
||||||
class Projects:
|
class Projects:
|
||||||
def __init__(self: Projects, environment) -> None:
|
def __init__(self, environment) -> None:
|
||||||
self.environment = environment
|
self.environment = environment
|
||||||
# group, name
|
# group, name
|
||||||
for variable in GROUP_AND_NAME:
|
for variable in GROUP_AND_NAME:
|
||||||
|
|
Loading…
Add table
Reference in a new issue