zrb 0.0.85__py3-none-any.whl → 0.0.87__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/__init__.py +4 -2
- zrb/action/runner.py +7 -3
- zrb/builtin/__init__.py +8 -22
- zrb/builtin/base64.py +1 -1
- zrb/builtin/devtool/__init__.py +20 -0
- zrb/builtin/devtool/devtool_install.py +45 -2
- zrb/builtin/devtool/docker/install.sh +8 -0
- zrb/builtin/devtool/gcloud/install.sh +8 -0
- zrb/builtin/devtool/helix/install.sh +20 -0
- zrb/builtin/devtool/helix/resource/config.toml +10 -0
- zrb/builtin/devtool/helix/resource/themes/gruvbox_transparent.toml +2 -0
- zrb/builtin/devtool/tmux/install.sh +8 -0
- zrb/builtin/devtool/zsh/install.sh +9 -0
- zrb/builtin/devtool/zsh/resource/config.sh +2 -0
- zrb/builtin/env.py +6 -3
- zrb/builtin/explain.py +129 -0
- zrb/builtin/generator/__init__.py +27 -0
- zrb/builtin/generator/app_generator/add.py +81 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/add.py +182 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +38 -0
- zrb/builtin/generator/{fastapp/template/_automate/snake_zrb_app_name/cmd/prepare-load-test.sh → app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/app-activate-venv.sh} +0 -6
- zrb/builtin/generator/{simple_python_app/template/_automate/snake_zrb_app_name/cmd/start.sh → app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/app-start.sh} +0 -9
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/pulumi-destroy.sh +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/pulumi-init-stack.sh +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/pulumi-up.sh +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +148 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +108 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +68 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +54 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/.gitignore +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/.gitignore +2 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/Pulumi.yaml +6 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +79 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/requirements.txt +3 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/state/.gitkeep +0 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/docker-compose.env +3 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/docker-compose.yml +20 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/.dockerignore +3 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/.gitignore +3 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/Dockerfile +7 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/main.py +20 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/requirements.txt +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/template.env +4 -0
- zrb/builtin/generator/cmd_task/add.py +14 -14
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/common/__init__.py +0 -0
- zrb/builtin/generator/common/helper.py +57 -0
- zrb/builtin/generator/common/task_factory.py +82 -0
- zrb/builtin/generator/{_common/input.py → common/task_input.py} +46 -1
- zrb/builtin/generator/docker_compose_task/add.py +16 -15
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/fastapp/add.py +105 -101
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_common.py +2 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/activate-venv.sh +7 -0
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/{load-test.sh → app-load-test.sh} +0 -3
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-prepare-backend.sh +2 -0
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-prepare-load-test.sh +3 -0
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-start.sh +3 -0
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/pulumi-destroy.sh +0 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/pulumi-init-stack.sh +1 -0
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/pulumi-up.sh +0 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/deployment.py +9 -3
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +3 -3
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/load_test.py +11 -4
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +13 -4
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local_microservices.py +4 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/requirements.txt +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/loadtest/requirements.txt +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/requirements.txt +3 -3
- zrb/builtin/generator/fastapp_crud/add.py +13 -126
- zrb/builtin/generator/fastapp_crud/helper.py +115 -0
- zrb/builtin/generator/fastapp_crud/task_factory.py +34 -0
- zrb/builtin/generator/fastapp_field/add.py +10 -282
- zrb/builtin/generator/fastapp_field/helper.py +283 -0
- zrb/builtin/generator/fastapp_module/add.py +22 -331
- zrb/builtin/generator/fastapp_module/helper.py +326 -0
- zrb/builtin/generator/pip_package/__init__.py +0 -0
- zrb/builtin/generator/pip_package/add.py +84 -0
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/cmd/build.sh +12 -0
- zrb/builtin/generator/{fastapp/template/_automate/snake_zrb_app_name/cmd/start.sh → pip_package/template/_automate/snake_zrb_package_name/cmd/install-symlink.sh} +2 -2
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/cmd/publish.sh +6 -0
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +60 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/.gitignore +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/README.md +79 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/pyproject.toml +36 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/requirements.txt +4 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__init__.py +2 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__main__.py +2 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/util.py +2 -0
- zrb/builtin/generator/project/create.py +12 -8
- zrb/builtin/generator/project_task/task_factory.py +167 -83
- zrb/builtin/generator/project_task/template/_automate/_project/build_project_images.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/deploy_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/destroy_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/push_project_images.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/remove_project_containers.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/start_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/start_project_containers.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/stop_project_containers.py +1 -1
- zrb/builtin/generator/python_task/add.py +14 -16
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/simple_python_app/add.py +95 -99
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/cmd/app-activate-venv.sh +7 -0
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/cmd/app-start.sh +6 -0
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/cmd/pulumi-destroy.sh +0 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/cmd/pulumi-init-stack.sh +1 -0
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/cmd/pulumi-up.sh +0 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/deployment.py +9 -3
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/local.py +5 -2
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/deployment/requirements.txt +2 -2
- zrb/builtin/git.py +1 -1
- zrb/builtin/{_group.py → group.py} +2 -5
- zrb/builtin/md5.py +1 -1
- zrb/builtin/project.py +1 -1
- zrb/builtin/ubuntu.py +1 -1
- zrb/config/config.py +8 -6
- zrb/helper/accessories/color.py +5 -1
- zrb/helper/accessories/icon.py +2 -0
- zrb/helper/accessories/name.py +2 -0
- zrb/helper/advertisement.py +1 -0
- zrb/helper/cli.py +5 -1
- zrb/helper/codemod/add_argument_to_function.py +3 -0
- zrb/helper/codemod/add_argument_to_function_call.py +3 -0
- zrb/helper/codemod/add_assert_resource.py +2 -0
- zrb/helper/codemod/add_function_call.py +2 -0
- zrb/helper/codemod/add_import_module.py +3 -0
- zrb/helper/codemod/add_key_value_to_dict.py +2 -0
- zrb/helper/codemod/add_property_to_class.py +3 -0
- zrb/helper/codemod/add_upstream_to_task.py +3 -0
- zrb/helper/codemod/append_code_to_function.py +3 -0
- zrb/helper/codemod/format_code.py +2 -0
- zrb/helper/default_env.py +2 -0
- zrb/helper/docker_compose/fetch_external_env.py +3 -0
- zrb/helper/docker_compose/file.py +4 -0
- zrb/helper/env_map/fetch.py +7 -0
- zrb/helper/file/text.py +6 -0
- zrb/helper/git/detect_changes.py +4 -0
- zrb/helper/loader/load_module.py +2 -0
- zrb/helper/map/conversion.py +2 -0
- zrb/helper/string/conversion.py +5 -0
- zrb/helper/string/double_quote.py +6 -2
- zrb/helper/string/jinja.py +2 -0
- zrb/helper/string/parse_replacement.py +2 -0
- zrb/helper/util.py +13 -0
- zrb/task/any_task.py +2 -2
- zrb/task/base_task.py +16 -16
- zrb/task/base_task_composite.py +12 -9
- zrb/task/cmd_task.py +23 -12
- zrb/task/decorator.py +2 -2
- zrb/task/docker_compose_task.py +5 -5
- zrb/task/flow_task.py +5 -5
- zrb/task/http_checker.py +2 -2
- zrb/task/path_checker.py +2 -2
- zrb/task/port_checker.py +2 -2
- zrb/task/resource_maker.py +3 -5
- zrb/task_input/any_input.py +23 -0
- zrb/task_input/base_input.py +46 -43
- zrb/task_input/float_input.py +0 -1
- {zrb-0.0.85.dist-info → zrb-0.0.87.dist-info}/METADATA +16 -17
- {zrb-0.0.85.dist-info → zrb-0.0.87.dist-info}/RECORD +175 -122
- zrb/builtin/generator/_common/helper.py +0 -79
- zrb/builtin/generator/fastapp_crud/add_navigation.py +0 -32
- zrb/builtin/principle.py +0 -66
- /zrb/builtin/generator/{_common → app_generator}/__init__.py +0 -0
- /zrb/{config.toml → builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/__init__.py} +0 -0
- /zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/{build-frontend.sh → app-build-frontend.sh} +0 -0
- /zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/{test.sh → app-test.sh} +0 -0
- /zrb/builtin/generator/{fastapp/template/_automate/snake_zrb_app_name/cmd/prepare-backend.sh → pip_package/template/_automate/snake_zrb_package_name/cmd/prepare-venv.sh} +0 -0
- /zrb/task_input/{_constant.py → constant.py} +0 -0
- /zrb/task_input/{input.py → task_input.py} +0 -0
- {zrb-0.0.85.dist-info → zrb-0.0.87.dist-info}/LICENSE +0 -0
- {zrb-0.0.85.dist-info → zrb-0.0.87.dist-info}/WHEEL +0 -0
- {zrb-0.0.85.dist-info → zrb-0.0.87.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -9,7 +9,8 @@ from .task.port_checker import PortChecker
|
|
9
9
|
from .task.path_checker import PathChecker
|
10
10
|
from .task.resource_maker import ResourceMaker, Replacement, ReplacementMutator
|
11
11
|
from .task.flow_task import FlowTask, FlowNode
|
12
|
-
from .task_input.
|
12
|
+
from .task_input.any_input import AnyInput
|
13
|
+
from .task_input.task_input import Input
|
13
14
|
from .task_input.bool_input import BoolInput
|
14
15
|
from .task_input.choice_input import ChoiceInput
|
15
16
|
from .task_input.float_input import FloatInput
|
@@ -19,7 +20,7 @@ from .task_input.str_input import StrInput
|
|
19
20
|
from .task_env.env import Env
|
20
21
|
from .task_env.env_file import EnvFile
|
21
22
|
from .task_group.group import Group
|
22
|
-
from .builtin import
|
23
|
+
from .builtin import group as builtin_group
|
23
24
|
from .helper.default_env import inject_default_env
|
24
25
|
|
25
26
|
|
@@ -38,6 +39,7 @@ assert FlowTask
|
|
38
39
|
assert FlowNode
|
39
40
|
assert Replacement
|
40
41
|
assert ReplacementMutator
|
42
|
+
assert AnyInput
|
41
43
|
assert Input
|
42
44
|
assert BoolInput
|
43
45
|
assert ChoiceInput
|
zrb/action/runner.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import Any, Callable, Iterable, List, Mapping, Union
|
2
|
+
from typeguard import typechecked
|
2
3
|
from ..task_group.group import Group as TaskGroup
|
3
4
|
from ..task.any_task import AnyTask
|
4
5
|
import click
|
@@ -7,6 +8,7 @@ import sys
|
|
7
8
|
CliSubcommand = Union[click.Group, click.Command]
|
8
9
|
|
9
10
|
|
11
|
+
@typechecked
|
10
12
|
class Runner():
|
11
13
|
'''
|
12
14
|
Runner class.
|
@@ -32,7 +34,9 @@ class Runner():
|
|
32
34
|
cli.add_command(subcommand)
|
33
35
|
return cli
|
34
36
|
|
35
|
-
def _create_cli_subcommand(
|
37
|
+
def _create_cli_subcommand(
|
38
|
+
self, task: AnyTask
|
39
|
+
) -> Union[click.Group, click.Command]:
|
36
40
|
subcommand: CliSubcommand = self._create_cli_command(task)
|
37
41
|
task_group = task._group
|
38
42
|
while task_group is not None:
|
@@ -82,9 +86,9 @@ class Runner():
|
|
82
86
|
# if there are inputs with the same name, choose the first.
|
83
87
|
registered_input: Mapping[str, bool] = {}
|
84
88
|
for task_input in task_inputs:
|
85
|
-
if task_input.
|
89
|
+
if task_input.get_name() in registered_input:
|
86
90
|
continue
|
87
|
-
registered_input[task_input.
|
91
|
+
registered_input[task_input.get_name()] = True
|
88
92
|
param_decl = task_input.get_param_decl()
|
89
93
|
options = task_input.get_options()
|
90
94
|
command.params.append(click.Option(param_decl, **options))
|
zrb/builtin/__init__.py
CHANGED
@@ -1,41 +1,27 @@
|
|
1
|
+
from . import group
|
1
2
|
from . import base64
|
2
3
|
from . import env
|
3
4
|
from . import eval
|
4
5
|
from . import git
|
5
6
|
from . import md5
|
6
|
-
from . import
|
7
|
+
from . import explain
|
7
8
|
from . import project
|
8
9
|
from . import ubuntu
|
9
10
|
from . import update
|
10
11
|
from . import version
|
11
|
-
from .
|
12
|
-
from .
|
13
|
-
from .generator.cmd_task import add as generate_cmd_task
|
14
|
-
from .generator.docker_compose_task import add as generate_docker_compose_task
|
15
|
-
from .generator.python_task import add as generate_python_task
|
16
|
-
from .generator.simple_python_app import add as generate_simple_python_app
|
17
|
-
from .generator.fastapp import add as generate_fastapp
|
18
|
-
from .generator.fastapp_module import add as generate_fastapp_module
|
19
|
-
from .generator.fastapp_crud import add as generate_fastapp_crud
|
20
|
-
from .generator.fastapp_field import add as generate_fastapp_field
|
12
|
+
from . import devtool
|
13
|
+
from . import generator
|
21
14
|
|
15
|
+
assert group
|
22
16
|
assert base64
|
23
17
|
assert env
|
24
18
|
assert eval
|
25
19
|
assert git
|
26
20
|
assert md5
|
27
|
-
assert
|
21
|
+
assert explain
|
28
22
|
assert project
|
29
23
|
assert ubuntu
|
30
24
|
assert update
|
31
25
|
assert version
|
32
|
-
assert
|
33
|
-
assert
|
34
|
-
assert generate_cmd_task
|
35
|
-
assert generate_docker_compose_task
|
36
|
-
assert generate_python_task
|
37
|
-
assert generate_simple_python_app
|
38
|
-
assert generate_fastapp
|
39
|
-
assert generate_fastapp_module
|
40
|
-
assert generate_fastapp_crud
|
41
|
-
assert generate_fastapp_field
|
26
|
+
assert devtool
|
27
|
+
assert generator
|
zrb/builtin/base64.py
CHANGED
zrb/builtin/devtool/__init__.py
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
from .devtool_install import (
|
2
|
+
install_gvm, install_pyenv, install_nvm, install_sdkman, install_pulumi,
|
3
|
+
install_aws, install_gcloud, install_tmux, install_zsh, install_kubectl,
|
4
|
+
install_helm, install_docker, install_terraform, install_helix
|
5
|
+
)
|
6
|
+
|
7
|
+
assert install_gvm
|
8
|
+
assert install_pyenv
|
9
|
+
assert install_nvm
|
10
|
+
assert install_sdkman
|
11
|
+
assert install_pulumi
|
12
|
+
assert install_aws
|
13
|
+
assert install_gcloud
|
14
|
+
assert install_tmux
|
15
|
+
assert install_zsh
|
16
|
+
assert install_kubectl
|
17
|
+
assert install_helm
|
18
|
+
assert install_docker
|
19
|
+
assert install_terraform
|
20
|
+
assert install_helix
|
@@ -1,12 +1,13 @@
|
|
1
1
|
from typing import Any, Callable
|
2
|
+
from typeguard import typechecked
|
2
3
|
from ...config.config import get_current_shell
|
3
|
-
from .._group import dev_tool_install_group
|
4
4
|
from ...task.task import Task
|
5
5
|
from ...task.flow_task import FlowTask, FlowNode
|
6
6
|
from ...task_input.str_input import StrInput
|
7
7
|
from ...task_input.bool_input import BoolInput
|
8
8
|
from ...runner import runner
|
9
9
|
from ...helper.file.text import read_text_file_async, write_text_file_async
|
10
|
+
from ..group import dev_tool_install_group
|
10
11
|
import os
|
11
12
|
|
12
13
|
dir_path = os.path.dirname(__file__)
|
@@ -28,6 +29,7 @@ terminal_config_file_input = StrInput(
|
|
28
29
|
###############################################################################
|
29
30
|
|
30
31
|
|
32
|
+
@typechecked
|
31
33
|
def write_config(
|
32
34
|
template_file: str, config_file: str, remove_old_config: bool = False
|
33
35
|
) -> Callable[..., Any]:
|
@@ -39,7 +41,8 @@ def write_config(
|
|
39
41
|
rendered_template_file = os.path.expandvars(os.path.expanduser(
|
40
42
|
task.render_str(template_file)
|
41
43
|
))
|
42
|
-
if remove_old_config:
|
44
|
+
if remove_old_config and os.path.exists(rendered_config_file):
|
45
|
+
task.print_out(f'Removing {rendered_config_file}')
|
43
46
|
os.remove(rendered_config_file)
|
44
47
|
additional_content = await read_text_file_async(
|
45
48
|
rendered_template_file
|
@@ -48,6 +51,7 @@ def write_config(
|
|
48
51
|
if os.path.exists(rendered_config_file):
|
49
52
|
content = await read_text_file_async(rendered_config_file) + '\n'
|
50
53
|
new_content = content + additional_content
|
54
|
+
task.print_out(f'Writing content to {rendered_config_file}')
|
51
55
|
await write_text_file_async(rendered_config_file, new_content)
|
52
56
|
return set_config
|
53
57
|
|
@@ -409,3 +413,42 @@ install_terraform = FlowTask(
|
|
409
413
|
retry=0
|
410
414
|
)
|
411
415
|
runner.register(install_terraform)
|
416
|
+
|
417
|
+
install_helix = FlowTask(
|
418
|
+
name='helix',
|
419
|
+
group=dev_tool_install_group,
|
420
|
+
description='Post modern text editor',
|
421
|
+
nodes=[
|
422
|
+
FlowNode(
|
423
|
+
name='install-helix',
|
424
|
+
cmd_path=os.path.join(dir_path, 'helix', 'install.sh'),
|
425
|
+
preexec_fn=None
|
426
|
+
),
|
427
|
+
[
|
428
|
+
FlowNode(
|
429
|
+
name='create-helix-theme',
|
430
|
+
run=write_config(
|
431
|
+
template_file=os.path.join(
|
432
|
+
dir_path, 'helix', 'resource', 'themes', 'gruvbox_transparent.toml' # noqa
|
433
|
+
),
|
434
|
+
config_file='~/.config/helix/themes/gruvbox_transparent.toml', # noqa
|
435
|
+
remove_old_config=True
|
436
|
+
),
|
437
|
+
preexec_fn=None
|
438
|
+
),
|
439
|
+
FlowNode(
|
440
|
+
name='configure-helix',
|
441
|
+
run=write_config(
|
442
|
+
template_file=os.path.join(
|
443
|
+
dir_path, 'helix', 'resource', 'config.toml'
|
444
|
+
),
|
445
|
+
config_file='~/.config/helix/config.toml',
|
446
|
+
remove_old_config=True
|
447
|
+
),
|
448
|
+
preexec_fn=None
|
449
|
+
),
|
450
|
+
],
|
451
|
+
],
|
452
|
+
retry=0
|
453
|
+
)
|
454
|
+
runner.register(install_helix)
|
@@ -1,4 +1,12 @@
|
|
1
|
+
set +e
|
2
|
+
apt --version
|
3
|
+
if [ "$?" != 0 ]
|
4
|
+
then
|
5
|
+
>&2 echo "apt not found"
|
6
|
+
exit 1
|
7
|
+
fi
|
1
8
|
set -e
|
9
|
+
|
2
10
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
3
11
|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
4
12
|
sudo apt-get update
|
@@ -1,4 +1,12 @@
|
|
1
|
+
set +e
|
2
|
+
apt --version
|
3
|
+
if [ "$?" != 0 ]
|
4
|
+
then
|
5
|
+
>&2 echo "apt not found"
|
6
|
+
exit 1
|
7
|
+
fi
|
1
8
|
set -e
|
9
|
+
|
2
10
|
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
|
3
11
|
sudo apt-get install apt-transport-https ca-certificates gnupg
|
4
12
|
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
|
@@ -0,0 +1,20 @@
|
|
1
|
+
set -e
|
2
|
+
if [ "{{ platform.system() }}" = "Darwin" ]
|
3
|
+
then
|
4
|
+
sudo brew install helix
|
5
|
+
elif [ "{{ platform.system() }}" = "Linux" ]
|
6
|
+
then
|
7
|
+
set +e
|
8
|
+
apt --version
|
9
|
+
if [ "$?" != 0 ]
|
10
|
+
then
|
11
|
+
>&2 echo "apt not found"
|
12
|
+
exit 1
|
13
|
+
fi
|
14
|
+
set -e
|
15
|
+
sudo add-apt-repository ppa:maveonair/helix-editor -y
|
16
|
+
sudo apt update
|
17
|
+
sudo apt install helix
|
18
|
+
else
|
19
|
+
echo "Cannot determine how to install zsh, assuming it has been installed"
|
20
|
+
fi
|
@@ -4,6 +4,14 @@ then
|
|
4
4
|
sudo brew install tmux
|
5
5
|
elif [ "{{ platform.system() }}" = "Linux" ]
|
6
6
|
then
|
7
|
+
set +e
|
8
|
+
apt --version
|
9
|
+
if [ "$?" != 0 ]
|
10
|
+
then
|
11
|
+
>&2 echo "apt not found"
|
12
|
+
exit 1
|
13
|
+
fi
|
14
|
+
set -e
|
7
15
|
sudo apt install tmux
|
8
16
|
else
|
9
17
|
echo "Cannot determine how to install tmux, assuming it has been installed"
|
@@ -1,8 +1,17 @@
|
|
1
|
+
set -e
|
1
2
|
if [ "{{ platform.system() }}" = "Darwin" ]
|
2
3
|
then
|
3
4
|
sudo brew install zsh
|
4
5
|
elif [ "{{ platform.system() }}" = "Linux" ]
|
5
6
|
then
|
7
|
+
set +e
|
8
|
+
apt --version
|
9
|
+
if [ "$?" != 0 ]
|
10
|
+
then
|
11
|
+
>&2 echo "apt not found"
|
12
|
+
exit 1
|
13
|
+
fi
|
14
|
+
set -e
|
6
15
|
sudo apt install zsh
|
7
16
|
else
|
8
17
|
echo "Cannot determine how to install zsh, assuming it has been installed"
|
zrb/builtin/env.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
from typing import Any,
|
2
|
-
from .
|
1
|
+
from typing import Any, List
|
2
|
+
from .group import env_group
|
3
3
|
from ..helper.accessories.color import colored
|
4
4
|
from ..task.decorator import python_task
|
5
5
|
from ..task.task import Task
|
@@ -22,9 +22,12 @@ async def get(*args: Any, **kwargs: Any):
|
|
22
22
|
names = list(env_map.keys())
|
23
23
|
names.sort()
|
24
24
|
colored_equal = colored('=', color='grey', attrs=['dark'])
|
25
|
+
env_lines: List[str] = []
|
25
26
|
for name in names:
|
26
27
|
value = env_map[name]
|
27
28
|
colored_name = colored(name, color='green', attrs=['bold'])
|
28
29
|
colored_value = colored(value, attrs=['bold'])
|
29
|
-
|
30
|
+
env_lines.append(f'{colored_name}{colored_equal}{colored_value}')
|
31
|
+
line_separator = '\n '
|
32
|
+
task.print_out(line_separator + line_separator.join(env_lines))
|
30
33
|
return env_map
|
zrb/builtin/explain.py
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from typeguard import typechecked
|
3
|
+
from .group import explain_group
|
4
|
+
from ..task.decorator import python_task
|
5
|
+
from ..task.task import Task
|
6
|
+
from ..runner import runner
|
7
|
+
|
8
|
+
|
9
|
+
@typechecked
|
10
|
+
def show_lines(task: Task, *lines: str):
|
11
|
+
separator = '\n '
|
12
|
+
task.print_out(
|
13
|
+
'\n' + separator + separator.join(lines) + '\n', trim_message=False
|
14
|
+
)
|
15
|
+
|
16
|
+
|
17
|
+
###############################################################################
|
18
|
+
# Task Definitions
|
19
|
+
###############################################################################
|
20
|
+
|
21
|
+
|
22
|
+
@python_task(
|
23
|
+
name='solid',
|
24
|
+
group=explain_group,
|
25
|
+
description='Explain SOLID principle',
|
26
|
+
runner=runner
|
27
|
+
)
|
28
|
+
async def explain_solid(*args: Any, **kwargs: Any):
|
29
|
+
show_lines(
|
30
|
+
kwargs['_task'],
|
31
|
+
'S - Single Responsibility Principle',
|
32
|
+
'O - Open/Closed Principle',
|
33
|
+
'L - Liskov’s Substitution Principle',
|
34
|
+
'I - Interface Segregation Principle',
|
35
|
+
'D - Dependency Inversion Principle',
|
36
|
+
'',
|
37
|
+
'In software development, Object-Oriented Design plays a crucial role when it comes to writing flexible, scalable, maintainable, and reusable code. There are so many benefits of using OOD but every developer should also have the knowledge of the SOLID principle for good object-oriented design in programming. The SOLID principle was introduced by Robert C. Martin, also known as Uncle Bob and it is a coding standard in programming.', # noqa
|
38
|
+
'',
|
39
|
+
'The SOLID principle helps in reducing tight coupling. Tight coupling means a group of classes are highly dependent on one another which you should avoid in your code. Opposite of tight coupling is loose coupling and your code is considered as a good code when it has loosely-coupled classes. Loosely coupled classes minimize changes in your code, helps in making code more reusable, maintainable, flexible and stable.', # noqa
|
40
|
+
)
|
41
|
+
|
42
|
+
|
43
|
+
@python_task(
|
44
|
+
name='yagni',
|
45
|
+
group=explain_group,
|
46
|
+
description='Explain YAGNI principle',
|
47
|
+
runner=runner
|
48
|
+
)
|
49
|
+
async def explain_yagni(*args: Any, **kwargs: Any):
|
50
|
+
show_lines(
|
51
|
+
kwargs['_task'],
|
52
|
+
'Y - You',
|
53
|
+
'A - Aren\'t',
|
54
|
+
'G - Gonna',
|
55
|
+
'N - Need',
|
56
|
+
'I - It',
|
57
|
+
'',
|
58
|
+
'YAGNI principle ("You Aren\'t Gonna Need It") is a practice in software development which states that features should only be added when required.', # noqa
|
59
|
+
'',
|
60
|
+
'As a part of the extreme programming (XP) philosophy, YAGNI trims away excess and inefficiency in development to facilitate the desired increased frequency of releases.', # noqa
|
61
|
+
)
|
62
|
+
|
63
|
+
|
64
|
+
@python_task(
|
65
|
+
name='dry',
|
66
|
+
group=explain_group,
|
67
|
+
description='Explain DRY principle',
|
68
|
+
runner=runner
|
69
|
+
)
|
70
|
+
async def explain_dry(*args: Any, **kwargs: Any):
|
71
|
+
show_lines(
|
72
|
+
kwargs['_task'],
|
73
|
+
'D - Don\'t',
|
74
|
+
'R - Repeat',
|
75
|
+
'Y - Yourself',
|
76
|
+
'',
|
77
|
+
'"Don\'t repeat yourself" (DRY) is a principle of software development aimed at reducing repetition of information which is likely to change, replacing it with abstractions that are less likely to change, or using data normalization which avoids redundancy in the first place.', # noqa
|
78
|
+
'',
|
79
|
+
'The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system". The principle has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer.', # noqa
|
80
|
+
)
|
81
|
+
|
82
|
+
|
83
|
+
@python_task(
|
84
|
+
name='kiss',
|
85
|
+
group=explain_group,
|
86
|
+
description='Explain KISS principle',
|
87
|
+
runner=runner
|
88
|
+
)
|
89
|
+
async def explain_kiss(*args: Any, **kwargs: Any):
|
90
|
+
show_lines(
|
91
|
+
kwargs['_task'],
|
92
|
+
'K - Keep',
|
93
|
+
'I - It',
|
94
|
+
'S - Simple',
|
95
|
+
'S - Stupid',
|
96
|
+
'',
|
97
|
+
'KISS, an acronym for "Keep it simple, stupid!", is a design principle noted by the U.S. Navy in 1960. First seen partly in American English by at least 1938, the KISS principle states that most systems work best if they are kept simple rather than made complicated; therefore, simplicity should be a key goal in design, and unnecessary complexity should be avoided.' # noqa
|
98
|
+
)
|
99
|
+
|
100
|
+
|
101
|
+
@python_task(
|
102
|
+
name='zen-of-python',
|
103
|
+
group=explain_group,
|
104
|
+
description='Explain Zen of Python',
|
105
|
+
runner=runner
|
106
|
+
)
|
107
|
+
async def explain_zen_of_python(*args: Any, **kwargs: Any):
|
108
|
+
show_lines(
|
109
|
+
kwargs['_task'],
|
110
|
+
'Beautiful is better than ugly.',
|
111
|
+
'Explicit is better than implicit.',
|
112
|
+
'Simple is better than complex.',
|
113
|
+
'Complex is better than complicated.',
|
114
|
+
'Flat is better than nested.',
|
115
|
+
'Sparse is better than dense.',
|
116
|
+
'Readability counts.',
|
117
|
+
'Special cases aren\'t special enough to break the rules.',
|
118
|
+
'Although practicality beats purity.',
|
119
|
+
'Errors should never pass silently.',
|
120
|
+
'Unless explicitly silenced.',
|
121
|
+
'In the face of ambiguity, refuse the temptation to guess.',
|
122
|
+
'There should be one-- and preferably only one --obvious way to do it.', # noqa
|
123
|
+
'Although that way may not be obvious at first unless you\'re Dutch.',
|
124
|
+
'Now is better than never.',
|
125
|
+
'Although never is often better than *right* now.',
|
126
|
+
'If the implementation is hard to explain, it\'s a bad idea.',
|
127
|
+
'If the implementation is easy to explain, it may be a good idea.',
|
128
|
+
'Namespaces are one honking great idea -- let\'s do more of those!',
|
129
|
+
)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
from . import common
|
2
|
+
from . import project_task
|
3
|
+
from .project.create import create_project
|
4
|
+
from .cmd_task.add import add_cmd_task
|
5
|
+
from .docker_compose_task.add import add_docker_compose_task
|
6
|
+
from .python_task.add import add_python_task
|
7
|
+
from .simple_python_app import add as add_simple_python_app
|
8
|
+
from .fastapp import add as add_fastapp
|
9
|
+
from .fastapp_module import add as add_fastapp_module
|
10
|
+
from .fastapp_crud import add as add_fastapp_crud
|
11
|
+
from .fastapp_field import add as add_fastapp_field
|
12
|
+
from .pip_package import add as add_pip_package
|
13
|
+
from .app_generator import add as add_app_generator
|
14
|
+
|
15
|
+
assert common
|
16
|
+
assert project_task
|
17
|
+
assert create_project
|
18
|
+
assert add_cmd_task
|
19
|
+
assert add_docker_compose_task
|
20
|
+
assert add_python_task
|
21
|
+
assert add_simple_python_app
|
22
|
+
assert add_fastapp
|
23
|
+
assert add_fastapp_module
|
24
|
+
assert add_fastapp_crud
|
25
|
+
assert add_fastapp_field
|
26
|
+
assert add_pip_package
|
27
|
+
assert add_app_generator
|
@@ -0,0 +1,81 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from ..common.task_input import project_dir_input
|
3
|
+
from ..common.helper import (
|
4
|
+
validate_existing_project_dir, validate_inexisting_automation
|
5
|
+
)
|
6
|
+
from ..common.task_factory import create_register_module
|
7
|
+
from ...group import project_add_group
|
8
|
+
from ....task.decorator import python_task
|
9
|
+
from ....task.task import Task
|
10
|
+
from ....task.resource_maker import ResourceMaker
|
11
|
+
from ....task_input.str_input import StrInput
|
12
|
+
from ....helper.accessories.name import get_random_name
|
13
|
+
from ....runner import runner
|
14
|
+
|
15
|
+
import os
|
16
|
+
|
17
|
+
CURRENT_DIR = os.path.dirname(__file__)
|
18
|
+
|
19
|
+
|
20
|
+
template_name_input = StrInput(
|
21
|
+
name='template-name',
|
22
|
+
shortcut='t',
|
23
|
+
description='Template name',
|
24
|
+
prompt='Template name',
|
25
|
+
default=get_random_name()
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
###############################################################################
|
30
|
+
# Task Definitions
|
31
|
+
###############################################################################
|
32
|
+
|
33
|
+
|
34
|
+
@python_task(
|
35
|
+
name='validate',
|
36
|
+
inputs=[
|
37
|
+
project_dir_input,
|
38
|
+
template_name_input
|
39
|
+
]
|
40
|
+
)
|
41
|
+
async def validate(*args: Any, **kwargs: Any):
|
42
|
+
project_dir = kwargs.get('project_dir')
|
43
|
+
validate_existing_project_dir(project_dir)
|
44
|
+
template_name = kwargs.get('template_name')
|
45
|
+
validate_inexisting_automation(project_dir, template_name)
|
46
|
+
|
47
|
+
|
48
|
+
copy_resource = ResourceMaker(
|
49
|
+
name='copy-resource',
|
50
|
+
inputs=[
|
51
|
+
project_dir_input,
|
52
|
+
template_name_input,
|
53
|
+
],
|
54
|
+
upstreams=[validate],
|
55
|
+
replacements={
|
56
|
+
'zrbMetaTemplateName': '{{input.template_name}}',
|
57
|
+
},
|
58
|
+
template_path=os.path.join(CURRENT_DIR, 'template'),
|
59
|
+
destination_path='{{ input.project_dir }}',
|
60
|
+
excludes=[
|
61
|
+
'*/__pycache__',
|
62
|
+
]
|
63
|
+
)
|
64
|
+
|
65
|
+
register_module = create_register_module(
|
66
|
+
module_path='_automate.{{util.to_snake_case(input.template_name)}}.add',
|
67
|
+
alias='{{util.to_snake_case(input.template_name)}}_add',
|
68
|
+
inputs=[template_name_input],
|
69
|
+
upstreams=[copy_resource]
|
70
|
+
)
|
71
|
+
|
72
|
+
|
73
|
+
@python_task(
|
74
|
+
name='app-generator',
|
75
|
+
group=project_add_group,
|
76
|
+
upstreams=[register_module],
|
77
|
+
runner=runner
|
78
|
+
)
|
79
|
+
async def add_python_task(*args: Any, **kwargs: Any):
|
80
|
+
task: Task = kwargs.get('_task')
|
81
|
+
task.print_out('Success')
|