zrb 1.0.0a5__py3-none-any.whl → 1.0.0a10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zrb/__main__.py +6 -0
- zrb/builtin/__init__.py +14 -6
- zrb/builtin/git.py +16 -13
- zrb/builtin/git_subtree.py +19 -4
- zrb/builtin/group.py +5 -0
- zrb/builtin/setup/common_input.py +35 -0
- zrb/builtin/setup/dev/asdf.py +86 -0
- zrb/builtin/setup/dev/asdf_helper.py +44 -0
- zrb/builtin/setup/dev/tmux.py +50 -0
- zrb/builtin/setup/dev/tmux_config.sh +0 -0
- zrb/builtin/setup/dev/tmux_helper.py +13 -0
- zrb/builtin/setup/system/latex/ubuntu.py +18 -0
- zrb/builtin/setup/system/ubuntu.py +28 -0
- zrb/builtin/todo.py +5 -6
- zrb/config.py +4 -1
- zrb/runner/web_app.py +0 -6
- zrb/task/any_task.py +38 -2
- zrb/task/base_task.py +71 -4
- zrb/task/cmd_task.py +27 -3
- zrb/task/llm_task.py +24 -18
- zrb/task/rsync_task.py +8 -8
- zrb/util/cmd/command.py +33 -0
- zrb/util/codemod/add_parent_to_class.py +38 -0
- zrb/util/git.py +35 -17
- zrb/util/git_subtree.py +11 -10
- zrb/util/string/format.py +12 -2
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a10.dist-info}/METADATA +2 -1
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a10.dist-info}/RECORD +30 -20
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a10.dist-info}/WHEEL +1 -1
- {zrb-1.0.0a5.dist-info → zrb-1.0.0a10.dist-info}/entry_points.txt +0 -0
zrb/__main__.py
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
|
+
from zrb.config import INIT_MODULES, INIT_SCRIPTS
|
3
4
|
from zrb.runner.cli import cli
|
4
5
|
from zrb.util.cli.style import stylize_error, stylize_warning
|
5
6
|
from zrb.util.group import NodeNotFoundError
|
7
|
+
from zrb.util.load import load_file, load_module
|
6
8
|
|
7
9
|
|
8
10
|
def serve_cli():
|
9
11
|
try:
|
12
|
+
for init_module in INIT_MODULES:
|
13
|
+
load_module(init_module)
|
14
|
+
for init_script in INIT_SCRIPTS:
|
15
|
+
load_file(init_script, -1)
|
10
16
|
cli.run(sys.argv[1:])
|
11
17
|
except KeyboardInterrupt:
|
12
18
|
print(stylize_warning("\nStopped"), file=sys.stderr)
|
zrb/builtin/__init__.py
CHANGED
@@ -12,10 +12,14 @@ from zrb.builtin.md5 import hash_md5, sum_md5
|
|
12
12
|
from zrb.builtin.project.add.fastapp import add_fastapp_to_project
|
13
13
|
from zrb.builtin.project.create.create import create_project
|
14
14
|
from zrb.builtin.python import format_python_code
|
15
|
+
from zrb.builtin.setup.dev.asdf import setup_asdf
|
16
|
+
from zrb.builtin.setup.dev.tmux import setup_tmux
|
17
|
+
from zrb.builtin.setup.system.latex.ubuntu import setup_latex_on_ubuntu
|
18
|
+
from zrb.builtin.setup.system.ubuntu import setup_ubuntu
|
15
19
|
from zrb.builtin.shell.autocomplete.bash import make_bash_autocomplete
|
16
20
|
from zrb.builtin.shell.autocomplete.subcmd import get_shell_subcommands
|
17
21
|
from zrb.builtin.shell.autocomplete.zsh import make_zsh_autocomplete
|
18
|
-
from zrb.builtin.todo import
|
22
|
+
from zrb.builtin.todo import add_todo, complete_todo, edit_todo, list_todo, log_todo
|
19
23
|
|
20
24
|
assert create_project
|
21
25
|
assert add_fastapp_to_project
|
@@ -36,8 +40,12 @@ assert git_push
|
|
36
40
|
assert git_add_subtree
|
37
41
|
assert git_pull_subtree
|
38
42
|
assert git_push_subtree
|
39
|
-
assert
|
40
|
-
assert
|
41
|
-
assert
|
42
|
-
assert
|
43
|
-
assert
|
43
|
+
assert list_todo
|
44
|
+
assert add_todo
|
45
|
+
assert edit_todo
|
46
|
+
assert complete_todo
|
47
|
+
assert log_todo
|
48
|
+
assert setup_ubuntu
|
49
|
+
assert setup_latex_on_ubuntu
|
50
|
+
assert setup_asdf
|
51
|
+
assert setup_tmux
|
zrb/builtin/git.py
CHANGED
@@ -11,6 +11,7 @@ from zrb.util.git import (
|
|
11
11
|
get_branches,
|
12
12
|
get_current_branch,
|
13
13
|
get_diff,
|
14
|
+
get_repo_dir,
|
14
15
|
pull,
|
15
16
|
push,
|
16
17
|
)
|
@@ -55,7 +56,8 @@ from zrb.util.git import (
|
|
55
56
|
alias="diff",
|
56
57
|
)
|
57
58
|
def get_git_diff(ctx: AnyContext):
|
58
|
-
|
59
|
+
repo_dir = get_repo_dir()
|
60
|
+
diff = get_diff(repo_dir, ctx.input.source, ctx.input.current)
|
59
61
|
result = []
|
60
62
|
decorated = []
|
61
63
|
if ctx.input.created and diff.created:
|
@@ -82,14 +84,15 @@ def get_git_diff(ctx: AnyContext):
|
|
82
84
|
alias="prune",
|
83
85
|
)
|
84
86
|
def prune_local_branches(ctx: AnyContext):
|
85
|
-
|
86
|
-
|
87
|
+
repo_dir = get_repo_dir()
|
88
|
+
branches = get_branches(repo_dir)
|
89
|
+
current_branch = get_current_branch(repo_dir)
|
87
90
|
for branch in branches:
|
88
91
|
if branch == current_branch or branch == "main" or branch == "master":
|
89
92
|
continue
|
90
93
|
ctx.print(stylize_yellow(f"Removing local branch: {branch}"))
|
91
94
|
try:
|
92
|
-
delete_branch(branch)
|
95
|
+
delete_branch(repo_dir, branch)
|
93
96
|
except Exception as e:
|
94
97
|
ctx.log_error(e)
|
95
98
|
|
@@ -107,13 +110,11 @@ def prune_local_branches(ctx: AnyContext):
|
|
107
110
|
alias="commit",
|
108
111
|
)
|
109
112
|
def git_commit(ctx: AnyContext):
|
113
|
+
repo_dir = get_repo_dir()
|
110
114
|
ctx.print("Add changes to staging")
|
111
|
-
add()
|
115
|
+
add(repo_dir)
|
112
116
|
ctx.print("Commit changes")
|
113
|
-
|
114
|
-
commit(ctx.input.message)
|
115
|
-
except Exception as e:
|
116
|
-
ctx.log_error(e)
|
117
|
+
commit(repo_dir, ctx.input.message)
|
117
118
|
|
118
119
|
|
119
120
|
@make_task(
|
@@ -130,10 +131,11 @@ def git_commit(ctx: AnyContext):
|
|
130
131
|
alias="pull",
|
131
132
|
)
|
132
133
|
def git_pull(ctx: AnyContext):
|
134
|
+
repo_dir = get_repo_dir()
|
133
135
|
remote = ctx.input.remote
|
134
|
-
current_branch = get_current_branch()
|
136
|
+
current_branch = get_current_branch(repo_dir)
|
135
137
|
ctx.print(f"Pulling from {remote}/{current_branch}")
|
136
|
-
pull(remote, current_branch)
|
138
|
+
pull(repo_dir, remote, current_branch)
|
137
139
|
|
138
140
|
|
139
141
|
@make_task(
|
@@ -150,7 +152,8 @@ def git_pull(ctx: AnyContext):
|
|
150
152
|
alias="push",
|
151
153
|
)
|
152
154
|
def git_push(ctx: AnyContext):
|
155
|
+
repo_dir = get_repo_dir()
|
153
156
|
remote = ctx.input.remote
|
154
|
-
current_branch = get_current_branch()
|
157
|
+
current_branch = get_current_branch(repo_dir)
|
155
158
|
ctx.print(f"Pushing to {remote}/{current_branch}")
|
156
|
-
push(remote, current_branch)
|
159
|
+
push(repo_dir, remote, current_branch)
|
zrb/builtin/git_subtree.py
CHANGED
@@ -3,6 +3,7 @@ from zrb.builtin.group import git_subtree_group
|
|
3
3
|
from zrb.context.any_context import AnyContext
|
4
4
|
from zrb.input.str_input import StrInput
|
5
5
|
from zrb.task.make_task import make_task
|
6
|
+
from zrb.util.git import get_repo_dir
|
6
7
|
from zrb.util.git_subtree import add_subtree, load_config, pull_subtree, push_subtree
|
7
8
|
|
8
9
|
|
@@ -32,7 +33,9 @@ from zrb.util.git_subtree import add_subtree, load_config, pull_subtree, push_su
|
|
32
33
|
alias="add",
|
33
34
|
)
|
34
35
|
def git_add_subtree(ctx: AnyContext):
|
36
|
+
repo_dir = get_repo_dir()
|
35
37
|
add_subtree(
|
38
|
+
repo_dir=repo_dir,
|
36
39
|
name=ctx.input.name,
|
37
40
|
repo_url=ctx.input["repo-url"],
|
38
41
|
branch=ctx.input["repo-branch"],
|
@@ -48,14 +51,20 @@ def git_add_subtree(ctx: AnyContext):
|
|
48
51
|
alias="pull",
|
49
52
|
)
|
50
53
|
def git_pull_subtree(ctx: AnyContext):
|
51
|
-
|
54
|
+
repo_dir = get_repo_dir()
|
55
|
+
config = load_config(repo_dir)
|
52
56
|
if not config.data:
|
53
57
|
raise ValueError("No subtree config found")
|
54
58
|
first_err: Exception | None = None
|
55
59
|
for name, detail in config.data.items():
|
56
60
|
try:
|
57
61
|
ctx.print(f"Pull from subtree {name}")
|
58
|
-
pull_subtree(
|
62
|
+
pull_subtree(
|
63
|
+
repo_dir=repo_dir,
|
64
|
+
prefix=detail.prefix,
|
65
|
+
repo_url=detail.repo_url,
|
66
|
+
branch=detail.branch,
|
67
|
+
)
|
59
68
|
except Exception as e:
|
60
69
|
if first_err is None:
|
61
70
|
first_err = e
|
@@ -72,14 +81,20 @@ def git_pull_subtree(ctx: AnyContext):
|
|
72
81
|
alias="push",
|
73
82
|
)
|
74
83
|
def git_push_subtree(ctx: AnyContext):
|
75
|
-
|
84
|
+
repo_dir = get_repo_dir()
|
85
|
+
config = load_config(repo_dir)
|
76
86
|
if not config.data:
|
77
87
|
raise ValueError("No subtree config found")
|
78
88
|
first_err: Exception | None = None
|
79
89
|
for name, detail in config.data.items():
|
80
90
|
try:
|
81
91
|
ctx.print(f"Push to subtree {name}")
|
82
|
-
push_subtree(
|
92
|
+
push_subtree(
|
93
|
+
repo_dir=repo_dir,
|
94
|
+
prefix=detail.prefix,
|
95
|
+
repo_url=detail.repo_url,
|
96
|
+
branch=detail.branch,
|
97
|
+
)
|
83
98
|
except Exception as e:
|
84
99
|
if first_err is None:
|
85
100
|
first_err = e
|
zrb/builtin/group.py
CHANGED
@@ -32,3 +32,8 @@ add_to_project_group = project_group.add_group(
|
|
32
32
|
add_fastapp_to_project_group = add_to_project_group.add_group(
|
33
33
|
Group(name="fastapp", description="🚀 Add Fastapp resources")
|
34
34
|
)
|
35
|
+
|
36
|
+
setup_group = cli.add_group(Group(name="setup", description="🔧 Setup"))
|
37
|
+
setup_latex_group = setup_group.add_group(
|
38
|
+
Group(name="latex", description="✍️ Setup LaTeX")
|
39
|
+
)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from zrb.input.bool_input import BoolInput
|
2
|
+
from zrb.input.option_input import OptionInput
|
3
|
+
|
4
|
+
package_manager_input = OptionInput(
|
5
|
+
name="package-manager",
|
6
|
+
description="Your package manager",
|
7
|
+
prompt="Your package manager",
|
8
|
+
options=["apt", "dnf", "pacman", "zypper", "pkg", "brew", "spack"],
|
9
|
+
default_str="apt",
|
10
|
+
)
|
11
|
+
|
12
|
+
use_sudo_input = BoolInput(
|
13
|
+
name="use-sudo",
|
14
|
+
description="Use sudo or not",
|
15
|
+
prompt="Need sudo",
|
16
|
+
default_str="yes",
|
17
|
+
)
|
18
|
+
|
19
|
+
setup_bash_input = BoolInput(
|
20
|
+
name="setup-bash",
|
21
|
+
description="Setup bash",
|
22
|
+
prompt="Setup bash",
|
23
|
+
default_str="yes",
|
24
|
+
)
|
25
|
+
|
26
|
+
setup_zsh_input = BoolInput(
|
27
|
+
name="setup-zsh", description="Setup zsh", prompt="Setup zsh", default_str="yes"
|
28
|
+
)
|
29
|
+
|
30
|
+
setup_powershell_input = BoolInput(
|
31
|
+
name="setup-powershell",
|
32
|
+
description="Setup powershell",
|
33
|
+
prompt="Setup powershell",
|
34
|
+
default_str="no",
|
35
|
+
)
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.builtin.group import setup_group
|
4
|
+
from zrb.builtin.setup.common_input import (
|
5
|
+
package_manager_input,
|
6
|
+
setup_bash_input,
|
7
|
+
setup_powershell_input,
|
8
|
+
setup_zsh_input,
|
9
|
+
use_sudo_input,
|
10
|
+
)
|
11
|
+
from zrb.builtin.setup.dev.asdf_helper import (
|
12
|
+
check_inexist_asdf_dir,
|
13
|
+
get_install_prerequisites_cmd,
|
14
|
+
setup_asdf_ps_config,
|
15
|
+
setup_asdf_sh_config,
|
16
|
+
)
|
17
|
+
from zrb.context.any_context import AnyContext
|
18
|
+
from zrb.task.cmd_task import CmdTask
|
19
|
+
from zrb.task.make_task import make_task
|
20
|
+
|
21
|
+
install_asdf_prerequisites = CmdTask(
|
22
|
+
name="install-asdf-prerequisites",
|
23
|
+
input=[package_manager_input, use_sudo_input],
|
24
|
+
cmd=get_install_prerequisites_cmd,
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
download_asdf = CmdTask(
|
29
|
+
name="download-asdf",
|
30
|
+
cmd="git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1",
|
31
|
+
execute_condition=check_inexist_asdf_dir,
|
32
|
+
)
|
33
|
+
install_asdf_prerequisites >> download_asdf
|
34
|
+
|
35
|
+
|
36
|
+
@make_task(
|
37
|
+
name="setup-asdf-on-bash",
|
38
|
+
input=setup_bash_input,
|
39
|
+
execute_condition='{ctx.input["setup-bash"]}',
|
40
|
+
upstream=download_asdf,
|
41
|
+
)
|
42
|
+
def setup_asdf_on_bash(ctx: AnyContext):
|
43
|
+
ctx.print("Configure asdf for bash")
|
44
|
+
setup_asdf_sh_config(os.path.expanduser(os.path.join("~", ".bashrc")))
|
45
|
+
|
46
|
+
|
47
|
+
@make_task(
|
48
|
+
name="setup-asdf-on-zsh",
|
49
|
+
input=setup_zsh_input,
|
50
|
+
execute_condition='{ctx.input["setup-zsh"]}',
|
51
|
+
upstream=download_asdf,
|
52
|
+
)
|
53
|
+
def setup_asdf_on_zsh(ctx: AnyContext):
|
54
|
+
ctx.print("Configure asdf for zsh")
|
55
|
+
setup_asdf_sh_config(os.path.expanduser(os.path.join("~", ".zshrc")))
|
56
|
+
|
57
|
+
|
58
|
+
@make_task(
|
59
|
+
name="setup-asdf-on-powershell",
|
60
|
+
input=setup_powershell_input,
|
61
|
+
execute_condition='{ctx.input["setup-powershell"]}',
|
62
|
+
upstream=download_asdf,
|
63
|
+
)
|
64
|
+
def setup_asdf_on_powershell(ctx: AnyContext):
|
65
|
+
ctx.print("Configure asdf for powershell")
|
66
|
+
setup_asdf_ps_config(
|
67
|
+
os.path.expanduser(os.path.join("~", ".config", "powershell", "profile.ps1"))
|
68
|
+
)
|
69
|
+
|
70
|
+
|
71
|
+
@make_task(
|
72
|
+
name="setup-asdf",
|
73
|
+
description="🧰 Setup `asdf`.",
|
74
|
+
group=setup_group,
|
75
|
+
alias="asdf",
|
76
|
+
)
|
77
|
+
def setup_asdf(ctx: AnyContext):
|
78
|
+
ctx.print("Setup complete, restart your terminal to continue")
|
79
|
+
ctx.print("Some useful commands:")
|
80
|
+
ctx.print("- asdf plugin add python")
|
81
|
+
ctx.print("- asdf list all python")
|
82
|
+
ctx.print("- asdf install python 3.12.0")
|
83
|
+
ctx.print("- asdf global python 3.12.0")
|
84
|
+
|
85
|
+
|
86
|
+
setup_asdf << [setup_asdf_on_bash, setup_asdf_on_zsh, setup_asdf_on_powershell]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.context.any_context import AnyContext
|
4
|
+
|
5
|
+
|
6
|
+
def get_install_prerequisites_cmd(ctx: AnyContext) -> str:
|
7
|
+
package_manager: str = ctx.input["package-manager"]
|
8
|
+
if package_manager in ["brew", "spack"]:
|
9
|
+
cmd = f"{package_manager} install coreutils curl git"
|
10
|
+
elif package_manager == "pacman":
|
11
|
+
cmd = f"{package_manager} -S curl git"
|
12
|
+
else:
|
13
|
+
cmd = f"{package_manager} install curl git"
|
14
|
+
use_sudo: bool = ctx.input["use-sudo"]
|
15
|
+
if use_sudo:
|
16
|
+
return f"sudo {cmd}"
|
17
|
+
return cmd
|
18
|
+
|
19
|
+
|
20
|
+
def check_inexist_asdf_dir(_: AnyContext):
|
21
|
+
asdf_dir = os.path.expanduser(os.path.join("~", ".asdf"))
|
22
|
+
return not os.path.isdir(asdf_dir)
|
23
|
+
|
24
|
+
|
25
|
+
def setup_asdf_sh_config(file_path: str):
|
26
|
+
_setup_asdf_config(file_path, '. "$HOME/.asdf/asdf.sh"')
|
27
|
+
|
28
|
+
|
29
|
+
def setup_asdf_ps_config(file_path: str):
|
30
|
+
_setup_asdf_config(file_path, '. "$HOME/.asdf/asdf.ps1"')
|
31
|
+
|
32
|
+
|
33
|
+
def _setup_asdf_config(file_path: str, asdf_config: str):
|
34
|
+
dir_path = os.path.dirname(file_path)
|
35
|
+
os.makedirs(dir_path, exist_ok=True)
|
36
|
+
if not os.path.isfile(file_path):
|
37
|
+
with open(file_path, "w") as f:
|
38
|
+
f.write("")
|
39
|
+
with open(file_path, "r") as f:
|
40
|
+
content = f.read()
|
41
|
+
if asdf_config in content:
|
42
|
+
return
|
43
|
+
with open(file_path, "a") as f:
|
44
|
+
f.write(f"\n{asdf_config}\n")
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from zrb.builtin.group import setup_group
|
4
|
+
from zrb.builtin.setup.common_input import package_manager_input, use_sudo_input
|
5
|
+
from zrb.builtin.setup.dev.tmux_helper import get_install_tmux_cmd
|
6
|
+
from zrb.context.any_context import AnyContext
|
7
|
+
from zrb.input.str_input import StrInput
|
8
|
+
from zrb.task.cmd_task import CmdTask
|
9
|
+
from zrb.task.make_task import make_task
|
10
|
+
|
11
|
+
install_tmux = CmdTask(
|
12
|
+
name="install-tmux",
|
13
|
+
input=[package_manager_input, use_sudo_input],
|
14
|
+
cmd=get_install_tmux_cmd,
|
15
|
+
)
|
16
|
+
|
17
|
+
|
18
|
+
@make_task(
|
19
|
+
name="setup-tmux",
|
20
|
+
input=StrInput(
|
21
|
+
name="tmux-config",
|
22
|
+
description="Tmux config file",
|
23
|
+
prompt="Tmux config file",
|
24
|
+
default_str="~/.tmux.conf",
|
25
|
+
),
|
26
|
+
description="🖥️ Setup `tmux`.",
|
27
|
+
group=setup_group,
|
28
|
+
alias="tmux",
|
29
|
+
)
|
30
|
+
def setup_tmux(ctx: AnyContext):
|
31
|
+
with open(os.path.join(os.path.dirname(__file__), "tmux_config.sh"), "r") as f:
|
32
|
+
tmux_config_template = f.read()
|
33
|
+
tmux_config_file = os.path.expanduser(ctx.input["tmux-config"])
|
34
|
+
tmux_config_dir = os.path.dirname(tmux_config_file)
|
35
|
+
# Make sure config file exists
|
36
|
+
os.makedirs(tmux_config_dir, exist_ok=True)
|
37
|
+
if not os.path.isfile(tmux_config_file):
|
38
|
+
with open(tmux_config_file, "w") as f:
|
39
|
+
f.write("")
|
40
|
+
with open(tmux_config_file, "r") as f:
|
41
|
+
# config file already contain the config
|
42
|
+
if tmux_config_template in f.read():
|
43
|
+
return
|
44
|
+
# Write config
|
45
|
+
with open(tmux_config_file, "a") as f:
|
46
|
+
f.write(f"\n{tmux_config_template}\n")
|
47
|
+
ctx.print("Setup complete, restart your terminal to continue")
|
48
|
+
|
49
|
+
|
50
|
+
install_tmux >> setup_tmux
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from zrb.context.any_context import AnyContext
|
2
|
+
|
3
|
+
|
4
|
+
def get_install_tmux_cmd(ctx: AnyContext) -> str:
|
5
|
+
package_manager: str = ctx.input["package-manager"]
|
6
|
+
if package_manager == "pacman":
|
7
|
+
cmd = f"{package_manager} -S tmux"
|
8
|
+
else:
|
9
|
+
cmd = f"{package_manager} install tmux"
|
10
|
+
use_sudo: bool = ctx.input["use-sudo"]
|
11
|
+
if use_sudo:
|
12
|
+
return f"sudo {cmd}"
|
13
|
+
return cmd
|
@@ -0,0 +1,18 @@
|
|
1
|
+
from zrb.builtin.group import setup_latex_group
|
2
|
+
from zrb.builtin.setup.system.ubuntu import setup_ubuntu
|
3
|
+
from zrb.task.cmd_task import CmdTask
|
4
|
+
|
5
|
+
setup_latex_on_ubuntu = setup_latex_group.add_task(
|
6
|
+
CmdTask(
|
7
|
+
name="setup-latex-on-ubuntu",
|
8
|
+
description="🐧 Setup LaTeX on Ubuntu",
|
9
|
+
cmd=[
|
10
|
+
"sudo apt install -y \\",
|
11
|
+
"texlive-full texlive-latex-base texlive-fonts-recommended \\",
|
12
|
+
"texlive-fonts-extra texlive-latex-extra",
|
13
|
+
],
|
14
|
+
render_cmd=False,
|
15
|
+
),
|
16
|
+
alias="ubuntu",
|
17
|
+
)
|
18
|
+
setup_ubuntu >> setup_latex_on_ubuntu
|
@@ -0,0 +1,28 @@
|
|
1
|
+
from zrb.builtin.group import setup_group
|
2
|
+
from zrb.task.cmd_task import CmdTask
|
3
|
+
|
4
|
+
update_ubuntu = CmdTask(name="update-ubuntu", cmd="sudo apt update", render_cmd=False)
|
5
|
+
|
6
|
+
upgrade_todo = CmdTask(
|
7
|
+
name="upgrade-ubuntu", cmd="sudo apt upgrade -y", render_cmd=False
|
8
|
+
)
|
9
|
+
update_ubuntu >> upgrade_todo
|
10
|
+
|
11
|
+
setup_ubuntu = setup_group.add_task(
|
12
|
+
CmdTask(
|
13
|
+
name="setup-ubuntu",
|
14
|
+
description="🐧 Setup ubuntu",
|
15
|
+
cmd=[
|
16
|
+
"sudo apt install -y \\",
|
17
|
+
"build-essential python3-distutils libssl-dev zlib1g-dev \\"
|
18
|
+
"libbz2-dev libreadline-dev libsqlite3-dev libpq-dev python3-dev \\",
|
19
|
+
"llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev \\",
|
20
|
+
"liblzma-dev python3-openssl libblas-dev liblapack-dev rustc \\",
|
21
|
+
"golang gfortran fd-find ripgrep wget curl git ncat zip unzip \\",
|
22
|
+
"cmake make tree tmux zsh neovim xdotool xsel",
|
23
|
+
],
|
24
|
+
render_cmd=False,
|
25
|
+
),
|
26
|
+
alias="ubuntu",
|
27
|
+
)
|
28
|
+
upgrade_todo >> setup_ubuntu
|
zrb/builtin/todo.py
CHANGED
@@ -51,7 +51,7 @@ from zrb.util.todo import (
|
|
51
51
|
group=todo_group,
|
52
52
|
alias="add",
|
53
53
|
)
|
54
|
-
def
|
54
|
+
def add_todo(ctx: AnyContext):
|
55
55
|
todo_file_path = os.path.join(TODO_DIR, "todo.txt")
|
56
56
|
todo_list: list[TodoTaskModel] = []
|
57
57
|
if os.path.isfile(todo_file_path):
|
@@ -81,7 +81,7 @@ def todo_add(ctx: AnyContext):
|
|
81
81
|
|
82
82
|
|
83
83
|
@make_task(name="todo-list", description="📋 List todo", group=todo_group, alias="list")
|
84
|
-
def
|
84
|
+
def list_todo(ctx: AnyContext):
|
85
85
|
todo_file_path = os.path.join(TODO_DIR, "todo.txt")
|
86
86
|
todo_tasks: list[TodoTaskModel] = []
|
87
87
|
if os.path.isfile(todo_file_path):
|
@@ -96,7 +96,7 @@ def todo_list(ctx: AnyContext):
|
|
96
96
|
group=todo_group,
|
97
97
|
alias="complete",
|
98
98
|
)
|
99
|
-
def
|
99
|
+
def complete_todo(ctx: AnyContext):
|
100
100
|
todo_file_path = os.path.join(TODO_DIR, "todo.txt")
|
101
101
|
todo_list: list[TodoTaskModel] = []
|
102
102
|
if os.path.isfile(todo_file_path):
|
@@ -142,7 +142,7 @@ def todo_complete(ctx: AnyContext):
|
|
142
142
|
group=todo_group,
|
143
143
|
alias="log",
|
144
144
|
)
|
145
|
-
def
|
145
|
+
def log_todo(ctx: AnyContext):
|
146
146
|
todo_file_path = os.path.join(TODO_DIR, "todo.txt")
|
147
147
|
todo_list: list[TodoTaskModel] = []
|
148
148
|
if os.path.isfile(todo_file_path):
|
@@ -156,7 +156,6 @@ def todo_log(ctx: AnyContext):
|
|
156
156
|
todo_task = cascade_todo_task(todo_task)
|
157
157
|
current_duration = todo_task.keyval.get("duration", "0")
|
158
158
|
todo_task.keyval["duration"] = add_durations(current_duration, ctx.input.duration)
|
159
|
-
print(current_duration, todo_task.keyval)
|
160
159
|
# Save todo list
|
161
160
|
save_todo_list(todo_file_path, todo_list)
|
162
161
|
# Add log work
|
@@ -197,7 +196,7 @@ def _get_default_start() -> str:
|
|
197
196
|
group=todo_group,
|
198
197
|
alias="edit",
|
199
198
|
)
|
200
|
-
def
|
199
|
+
def edit_todo(ctx: AnyContext):
|
201
200
|
todo_list = [
|
202
201
|
cascade_todo_task(line_to_todo_task(line))
|
203
202
|
for line in ctx.input.text.split("\n")
|
zrb/config.py
CHANGED
@@ -49,6 +49,9 @@ LOGGING_LEVEL = _get_log_level(os.getenv("ZRB_LOGGING_LEVEL", "WARNING"))
|
|
49
49
|
LOAD_BUILTIN = to_boolean(os.getenv("ZRB_LOAD_BUILTIN", "1"))
|
50
50
|
ENV_PREFIX = os.getenv("ZRB_ENV", "")
|
51
51
|
SHOW_PROMPT = to_boolean(os.getenv("ZRB_SHOW_PROMPT", "1"))
|
52
|
+
WARN_UNRECOMMENDED_COMMAND = to_boolean(
|
53
|
+
os.getenv("ZRB_WARN_UNRECOMMENDED_COMMAND", "1")
|
54
|
+
)
|
52
55
|
SESSION_LOG_DIR = os.getenv(
|
53
56
|
"ZRB_SESSION_LOG_DIR", os.path.expanduser(os.path.join("~", ".zrb-session"))
|
54
57
|
)
|
@@ -77,7 +80,7 @@ BANNER = f"""
|
|
77
80
|
zzzzz rr bbbbbb {VERSION} Janggala
|
78
81
|
_ _ . . . _ . _ . . .
|
79
82
|
|
80
|
-
|
83
|
+
Your Automation Powerhouse
|
81
84
|
|
82
85
|
☕ Donate at: https://stalchmst.com/donation
|
83
86
|
🐙 Submit issues/PR at: https://github.com/state-alchemists/zrb
|
zrb/runner/web_app.py
CHANGED
@@ -142,9 +142,3 @@ def create_app(root_group: AnyGroup, port: int = WEB_HTTP_PORT):
|
|
142
142
|
raise HTTPException(status_code=500, detail=str(e))
|
143
143
|
|
144
144
|
return app
|
145
|
-
|
146
|
-
|
147
|
-
# async def run_web_server(app: FastAPI, port: int = WEB_HTTP_PORT):
|
148
|
-
# config = Config(app=app, host="0.0.0.0", port=port, loop="asyncio")
|
149
|
-
# server = Server(config)
|
150
|
-
# await server.serve()
|
zrb/task/any_task.py
CHANGED
@@ -74,6 +74,12 @@ class AnyTask(ABC):
|
|
74
74
|
"""Task fallbacks"""
|
75
75
|
pass
|
76
76
|
|
77
|
+
@property
|
78
|
+
@abstractmethod
|
79
|
+
def successors(self) -> list["AnyTask"]:
|
80
|
+
"""Task successors"""
|
81
|
+
pass
|
82
|
+
|
77
83
|
@property
|
78
84
|
@abstractmethod
|
79
85
|
def readiness_checks(self) -> list["AnyTask"]:
|
@@ -81,8 +87,38 @@ class AnyTask(ABC):
|
|
81
87
|
pass
|
82
88
|
|
83
89
|
@abstractmethod
|
84
|
-
def
|
85
|
-
"""
|
90
|
+
def append_fallback(self, fallbacks: "AnyTask" | list["AnyTask"]):
|
91
|
+
"""Add the fallback tasks.
|
92
|
+
|
93
|
+
Args:
|
94
|
+
fallbacks (AnyTask | list[AnyTask]): A single fallback task or
|
95
|
+
a list of fallback tasks.
|
96
|
+
"""
|
97
|
+
pass
|
98
|
+
|
99
|
+
@abstractmethod
|
100
|
+
def append_successor(self, successors: "AnyTask" | list["AnyTask"]):
|
101
|
+
"""Add the successor tasks.
|
102
|
+
|
103
|
+
Args:
|
104
|
+
successors (AnyTask | list[AnyTask]): A single successor task or
|
105
|
+
a list of successor tasks.
|
106
|
+
"""
|
107
|
+
pass
|
108
|
+
|
109
|
+
@abstractmethod
|
110
|
+
def append_readiness_check(self, readiness_checks: "AnyTask" | list["AnyTask"]):
|
111
|
+
"""Add the readiness_check tasks.
|
112
|
+
|
113
|
+
Args:
|
114
|
+
readiness_checks (AnyTask | list[AnyTask]): A single readiness_check task or
|
115
|
+
a list of readiness_check tasks.
|
116
|
+
"""
|
117
|
+
pass
|
118
|
+
|
119
|
+
@abstractmethod
|
120
|
+
def append_upstream(self, upstreams: "AnyTask" | list["AnyTask"]):
|
121
|
+
"""Add the upstream tasks that this task depends on.
|
86
122
|
|
87
123
|
Args:
|
88
124
|
upstreams (AnyTask | list[AnyTask]): A single upstream task or
|