zrb 0.0.86__py3-none-any.whl → 0.0.88__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 +3 -1
- zrb/action/runner.py +7 -3
- zrb/builtin/__init__.py +1 -1
- zrb/builtin/base64.py +1 -1
- zrb/builtin/devtool/devtool_install.py +13 -4
- zrb/builtin/devtool/helix/install-language-server.sh +33 -0
- zrb/builtin/env.py +6 -3
- zrb/builtin/explain.py +3 -1
- zrb/builtin/generator/__init__.py +4 -8
- zrb/builtin/generator/app_generator/add.py +15 -6
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/add.py +62 -52
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/app-start.sh +1 -6
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +2 -2
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +4 -2
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/.gitignore +2 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/Dockerfile +10 -5
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/go.work +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/main.go +28 -0
- zrb/builtin/generator/cmd_task/add.py +6 -6
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/{_common → common}/helper.py +6 -0
- zrb/builtin/generator/{_common → common}/task_factory.py +9 -5
- zrb/builtin/generator/docker_compose_task/add.py +8 -8
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/fastapp/add.py +24 -24
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_common.py +2 -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 +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +1 -1
- 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 +3 -2
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +2 -4
- zrb/builtin/generator/fastapp_crud/add.py +8 -121
- zrb/builtin/generator/fastapp_crud/helper.py +115 -0
- zrb/builtin/generator/fastapp_crud/{add_navigation.py → task_factory.py} +5 -3
- zrb/builtin/generator/fastapp_field/add.py +8 -280
- zrb/builtin/generator/fastapp_field/helper.py +283 -0
- zrb/builtin/generator/fastapp_module/add.py +19 -328
- zrb/builtin/generator/fastapp_module/helper.py +326 -0
- zrb/builtin/generator/pip_package/add.py +8 -8
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +1 -1
- zrb/builtin/generator/project/create.py +10 -3
- zrb/builtin/generator/project/template/template.env +1 -1
- zrb/builtin/generator/project_task/task_factory.py +33 -21
- 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 +6 -6
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/simple_python_app/add.py +28 -30
- 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 +1 -1
- 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 +1 -1
- zrb/builtin/git.py +1 -1
- zrb/builtin/md5.py +1 -1
- zrb/builtin/project.py +1 -1
- zrb/builtin/ubuntu.py +3 -3
- 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 +4 -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 +15 -15
- zrb/task/base_task_composite.py +3 -3
- zrb/task/cmd_task.py +2 -2
- zrb/task/decorator.py +2 -2
- zrb/task/docker_compose_task.py +2 -2
- 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.86.dist-info → zrb-0.0.88.dist-info}/METADATA +1 -1
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/RECORD +118 -114
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/main.py +0 -20
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/requirements.txt +0 -1
- zrb/config.toml +0 -0
- /zrb/builtin/generator/{_common → common}/__init__.py +0 -0
- /zrb/builtin/generator/{_common → common}/task_input.py +0 -0
- /zrb/builtin/{_group.py → group.py} +0 -0
- /zrb/task_input/{_constant.py → constant.py} +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/LICENSE +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/WHEEL +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import Optional
|
2
|
+
from typeguard import typechecked
|
2
3
|
from ....helper.codemod.add_assert_resource import add_assert_resource
|
3
4
|
from ....helper.codemod.add_import_module import add_import_module
|
4
5
|
from ....helper.file.text import read_text_file_async, write_text_file_async
|
@@ -6,16 +7,19 @@ from ....helper import util
|
|
6
7
|
import os
|
7
8
|
|
8
9
|
|
10
|
+
@typechecked
|
9
11
|
def validate_existing_project_dir(project_dir: str):
|
10
12
|
if not os.path.isfile(os.path.join(project_dir, 'zrb_init.py')):
|
11
13
|
raise Exception(f'Not a project: {project_dir}')
|
12
14
|
|
13
15
|
|
16
|
+
@typechecked
|
14
17
|
def validate_inexisting_automation(project_dir: str, automation_name: str):
|
15
18
|
validate_inexisting_automation_package(project_dir, automation_name)
|
16
19
|
validate_inexisting_automation_module(project_dir, automation_name)
|
17
20
|
|
18
21
|
|
22
|
+
@typechecked
|
19
23
|
def validate_inexisting_automation_package(
|
20
24
|
project_dir: str, package_name: str
|
21
25
|
):
|
@@ -26,6 +30,7 @@ def validate_inexisting_automation_package(
|
|
26
30
|
raise Exception(f'Automation package already exists: {package_dir}')
|
27
31
|
|
28
32
|
|
33
|
+
@typechecked
|
29
34
|
def validate_inexisting_automation_module(project_dir: str, module_name: str):
|
30
35
|
module_file = os.path.join(
|
31
36
|
project_dir, '_automate', f'{util.to_snake_case(module_name)}.py'
|
@@ -34,6 +39,7 @@ def validate_inexisting_automation_module(project_dir: str, module_name: str):
|
|
34
39
|
raise Exception(f'Automation module already exists: {module_file}')
|
35
40
|
|
36
41
|
|
42
|
+
@typechecked
|
37
43
|
async def register_module_to_project(
|
38
44
|
project_dir: str, module_path: str, alias: Optional[str] = None
|
39
45
|
):
|
@@ -1,19 +1,22 @@
|
|
1
1
|
from typing import Any, List, Optional
|
2
|
+
from typeguard import typechecked
|
2
3
|
from .task_input import project_dir_input
|
3
4
|
from .helper import validate_existing_project_dir, register_module_to_project
|
4
5
|
from ....task.decorator import python_task
|
6
|
+
from ....task.any_task import AnyTask
|
5
7
|
from ....task.task import Task
|
6
|
-
from ....task_input.
|
8
|
+
from ....task_input.any_input import AnyInput
|
7
9
|
from ....helper.file.text import read_text_file_async, write_text_file_async
|
8
10
|
from ....helper.codemod.add_import_module import add_import_module
|
9
11
|
from ....helper.codemod.add_upstream_to_task import add_upstream_to_task
|
10
12
|
import os
|
11
13
|
|
12
14
|
|
15
|
+
@typechecked
|
13
16
|
def create_register_module(
|
14
17
|
module_path: str,
|
15
|
-
inputs: Optional[List[
|
16
|
-
upstreams: Optional[List[
|
18
|
+
inputs: Optional[List[AnyInput]] = None,
|
19
|
+
upstreams: Optional[List[AnyTask]] = None,
|
17
20
|
alias: Optional[str] = None
|
18
21
|
) -> Task:
|
19
22
|
@python_task(
|
@@ -41,13 +44,14 @@ def create_register_module(
|
|
41
44
|
return register_module
|
42
45
|
|
43
46
|
|
47
|
+
@typechecked
|
44
48
|
def create_add_upstream(
|
45
49
|
task_file_name: str,
|
46
50
|
task_name: str,
|
47
51
|
upstream_module: str,
|
48
52
|
upstream_task_var: str,
|
49
|
-
inputs: Optional[List[
|
50
|
-
upstreams: Optional[List[
|
53
|
+
inputs: Optional[List[AnyInput]] = None,
|
54
|
+
upstreams: Optional[List[AnyTask]] = None
|
51
55
|
) -> Task:
|
52
56
|
@python_task(
|
53
57
|
name='register-upstream',
|
@@ -1,17 +1,17 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
2
|
+
from ..common.task_input import (
|
3
|
+
project_dir_input, task_name_input, http_port_input, env_prefix_input
|
4
|
+
)
|
5
|
+
from ..common.helper import (
|
6
|
+
validate_existing_project_dir, validate_inexisting_automation
|
7
|
+
)
|
8
|
+
from ..common.task_factory import create_register_module
|
9
|
+
from ...group import project_add_group
|
3
10
|
from ....task.task import Task
|
4
11
|
from ....task.decorator import python_task
|
5
12
|
from ....task_input.str_input import StrInput
|
6
13
|
from ....task.resource_maker import ResourceMaker
|
7
14
|
from ....runner import runner
|
8
|
-
from .._common.task_input import (
|
9
|
-
project_dir_input, task_name_input, http_port_input, env_prefix_input
|
10
|
-
)
|
11
|
-
from .._common.helper import (
|
12
|
-
validate_existing_project_dir, validate_inexisting_automation
|
13
|
-
)
|
14
|
-
from .._common.task_factory import create_register_module
|
15
15
|
from ....helper import util
|
16
16
|
|
17
17
|
import os
|
@@ -1,17 +1,12 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
3
|
-
from ....task.task import Task
|
4
|
-
from ....task.decorator import python_task
|
5
|
-
from ....task.resource_maker import ResourceMaker
|
6
|
-
from ....runner import runner
|
7
|
-
from .._common.task_input import (
|
2
|
+
from ..common.task_input import (
|
8
3
|
project_dir_input, app_name_input, app_image_name_input, http_port_input,
|
9
4
|
env_prefix_input
|
10
5
|
)
|
11
|
-
from ..
|
6
|
+
from ..common.helper import (
|
12
7
|
validate_existing_project_dir, validate_inexisting_automation
|
13
8
|
)
|
14
|
-
from ..
|
9
|
+
from ..common.task_factory import create_register_module
|
15
10
|
from ..project_task.task_factory import (
|
16
11
|
create_ensure_project_tasks, create_add_build_images_upstream,
|
17
12
|
create_add_deploy_upstream, create_add_destroy_upstream,
|
@@ -19,6 +14,11 @@ from ..project_task.task_factory import (
|
|
19
14
|
create_add_start_containers_upstream, create_add_start_upstream,
|
20
15
|
create_add_stop_containers_upstream
|
21
16
|
)
|
17
|
+
from ...group import project_add_group
|
18
|
+
from ....task.task import Task
|
19
|
+
from ....task.decorator import python_task
|
20
|
+
from ....task.resource_maker import ResourceMaker
|
21
|
+
from ....runner import runner
|
22
22
|
from ....helper import util
|
23
23
|
|
24
24
|
import os
|
@@ -123,56 +123,56 @@ ensure_project_tasks = create_ensure_project_tasks(
|
|
123
123
|
upstreams=[copy_resource]
|
124
124
|
)
|
125
125
|
|
126
|
-
|
126
|
+
add_start_upstream = create_add_start_upstream(
|
127
127
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.local',
|
128
128
|
upstream_task_var=f'start_{SNAKE_APP_NAME_TPL}',
|
129
129
|
upstreams=[ensure_project_tasks],
|
130
130
|
inputs=[app_name_input]
|
131
131
|
)
|
132
132
|
|
133
|
-
|
133
|
+
add_start_container_upstream = create_add_start_containers_upstream(
|
134
134
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
135
135
|
upstream_task_var=f'start_{SNAKE_APP_NAME_TPL}_container',
|
136
136
|
upstreams=[ensure_project_tasks],
|
137
137
|
inputs=[app_name_input]
|
138
138
|
)
|
139
139
|
|
140
|
-
|
140
|
+
add_stop_container_upstream = create_add_stop_containers_upstream(
|
141
141
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
142
142
|
upstream_task_var=f'stop_{SNAKE_APP_NAME_TPL}_container',
|
143
143
|
upstreams=[ensure_project_tasks],
|
144
144
|
inputs=[app_name_input]
|
145
145
|
)
|
146
146
|
|
147
|
-
|
147
|
+
add_remove_container_upstream = create_add_remove_containers_upstream(
|
148
148
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.container',
|
149
149
|
upstream_task_var=f'remove_{SNAKE_APP_NAME_TPL}_container',
|
150
150
|
upstreams=[ensure_project_tasks],
|
151
151
|
inputs=[app_name_input]
|
152
152
|
)
|
153
153
|
|
154
|
-
|
154
|
+
add_build_image_upstream = create_add_build_images_upstream(
|
155
155
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.image',
|
156
156
|
upstream_task_var=f'build_{SNAKE_APP_NAME_TPL}_image',
|
157
157
|
upstreams=[ensure_project_tasks],
|
158
158
|
inputs=[app_name_input]
|
159
159
|
)
|
160
160
|
|
161
|
-
|
161
|
+
add_push_image_upstream = create_add_push_images_upstream(
|
162
162
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.image',
|
163
163
|
upstream_task_var=f'push_{SNAKE_APP_NAME_TPL}_image',
|
164
164
|
upstreams=[ensure_project_tasks],
|
165
165
|
inputs=[app_name_input]
|
166
166
|
)
|
167
167
|
|
168
|
-
|
168
|
+
add_deploy_upstream = create_add_deploy_upstream(
|
169
169
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.deployment',
|
170
170
|
upstream_task_var=f'deploy_{SNAKE_APP_NAME_TPL}',
|
171
171
|
upstreams=[ensure_project_tasks],
|
172
172
|
inputs=[app_name_input]
|
173
173
|
)
|
174
174
|
|
175
|
-
|
175
|
+
add_destroy_upstream = create_add_destroy_upstream(
|
176
176
|
upstream_module=f'_automate.{SNAKE_APP_NAME_TPL}.deployment',
|
177
177
|
upstream_task_var=f'destroy_{SNAKE_APP_NAME_TPL}',
|
178
178
|
upstreams=[ensure_project_tasks],
|
@@ -190,14 +190,14 @@ add_destroy = create_add_destroy_upstream(
|
|
190
190
|
register_deployment_module,
|
191
191
|
register_test_module,
|
192
192
|
register_load_test_module,
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
193
|
+
add_start_upstream,
|
194
|
+
add_start_container_upstream,
|
195
|
+
add_stop_container_upstream,
|
196
|
+
add_remove_container_upstream,
|
197
|
+
add_build_image_upstream,
|
198
|
+
add_push_image_upstream,
|
199
|
+
add_deploy_upstream,
|
200
|
+
add_destroy_upstream
|
201
201
|
],
|
202
202
|
runner=runner
|
203
203
|
)
|
@@ -33,7 +33,8 @@ MODULES = jsons.loads(MODULE_JSON_STR)
|
|
33
33
|
def skip_local_microservices_execution(*args: Any, **kwargs: Any) -> bool:
|
34
34
|
if not kwargs.get('local_snake_zrb_app_name', True):
|
35
35
|
return True
|
36
|
-
|
36
|
+
run_mode = kwargs.get('snake_zrb_app_name_run_mode', 'monolith')
|
37
|
+
return run_mode != 'microservices'
|
37
38
|
|
38
39
|
|
39
40
|
###############################################################################
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import Mapping, Any, List
|
2
2
|
from zrb import DockerComposeTask, Env, ServiceConfig, EnvFile, runner, Task
|
3
3
|
from zrb.helper.util import to_kebab_case
|
4
|
-
from zrb.builtin.
|
4
|
+
from zrb.builtin.group import project_group
|
5
5
|
from ._common import (
|
6
6
|
APP_TEMPLATE_ENV_FILE_NAME, RESOURCE_DIR, MODULES, app_container_checker,
|
7
7
|
rabbitmq_checker, rabbitmq_management_checker, redpanda_console_checker,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from zrb import CmdTask, Env, EnvFile, StrInput, ChoiceInput, runner
|
2
|
-
from zrb.builtin.
|
2
|
+
from zrb.builtin.group import project_group
|
3
3
|
from .image import push_snake_zrb_app_name_image
|
4
4
|
from ._common import (
|
5
5
|
CURRENT_DIR, DEPLOYMENT_DIR, APP_TEMPLATE_ENV_FILE_NAME,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from zrb import DockerComposeTask, Env, StrInput, runner
|
2
|
-
from zrb.builtin.
|
2
|
+
from zrb.builtin.group import project_group
|
3
3
|
from ._common import RESOURCE_DIR, local_input
|
4
4
|
|
5
5
|
###############################################################################
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from zrb import CmdTask, EnvFile, BoolInput, StrInput, IntInput, runner
|
2
|
-
from zrb.builtin.
|
2
|
+
from zrb.builtin.group import project_group
|
3
3
|
from ._common import CURRENT_DIR, RESOURCE_DIR
|
4
4
|
import os
|
5
5
|
|
@@ -54,7 +54,8 @@ url_input = StrInput(
|
|
54
54
|
###############################################################################
|
55
55
|
|
56
56
|
load_test_env_file = EnvFile(
|
57
|
-
env_file=LOAD_TEST_TEMPLATE_ENV_FILE_NAME,
|
57
|
+
env_file=LOAD_TEST_TEMPLATE_ENV_FILE_NAME,
|
58
|
+
prefix='LOAD_TEST_ZRB_ENV_PREFIX'
|
58
59
|
)
|
59
60
|
|
60
61
|
###############################################################################
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Any, List
|
2
2
|
from zrb import CmdTask, DockerComposeTask, Task, Env, EnvFile, runner
|
3
|
-
from zrb.builtin.
|
3
|
+
from zrb.builtin.group import project_group
|
4
4
|
from ._common import (
|
5
5
|
CURRENT_DIR, APP_DIR, APP_TEMPLATE_ENV_FILE_NAME, RESOURCE_DIR,
|
6
6
|
skip_local_microservices_execution, rabbitmq_checker,
|
@@ -1,8 +1,6 @@
|
|
1
1
|
from zrb import CmdTask, StrInput, Env, EnvFile, runner, python_task
|
2
|
-
from zrb.builtin.
|
3
|
-
from ._common import
|
4
|
-
CURRENT_DIR, RESOURCE_DIR, APP_TEMPLATE_ENV_FILE_NAME,
|
5
|
-
)
|
2
|
+
from zrb.builtin.group import project_group
|
3
|
+
from ._common import CURRENT_DIR, RESOURCE_DIR, APP_TEMPLATE_ENV_FILE_NAME
|
6
4
|
from .frontend import build_snake_zrb_app_name_frontend_once
|
7
5
|
from .local import prepare_snake_zrb_app_name_backend
|
8
6
|
import os
|
@@ -1,20 +1,18 @@
|
|
1
1
|
from typing import Any
|
2
|
-
from
|
2
|
+
from .task_factory import create_add_navigation_task
|
3
|
+
from .helper import register_api, register_permission, register_rpc
|
4
|
+
from ..common.task_input import (
|
5
|
+
project_dir_input, app_name_input, module_name_input, entity_name_input,
|
6
|
+
plural_entity_name_input, main_column_name_input
|
7
|
+
)
|
8
|
+
from ..common.helper import validate_existing_project_dir
|
9
|
+
from ...group import project_add_group
|
3
10
|
from ....task.task import Task
|
4
11
|
from ....task.decorator import python_task
|
5
12
|
from ....task.cmd_task import CmdTask
|
6
13
|
from ....task.resource_maker import ResourceMaker
|
7
14
|
from ....runner import runner
|
8
15
|
from ....helper import util
|
9
|
-
from ....helper.codemod.add_import_module import add_import_module
|
10
|
-
from ....helper.codemod.append_code_to_function import append_code_to_function
|
11
|
-
from ....helper.file.text import read_text_file_async, write_text_file_async
|
12
|
-
from .._common.task_input import (
|
13
|
-
project_dir_input, app_name_input, module_name_input, entity_name_input,
|
14
|
-
plural_entity_name_input, main_column_name_input
|
15
|
-
)
|
16
|
-
from .._common.helper import validate_existing_project_dir
|
17
|
-
from .add_navigation import create_add_navigation_task
|
18
16
|
|
19
17
|
import asyncio
|
20
18
|
import os
|
@@ -155,114 +153,3 @@ add_navigation = create_add_navigation_task(
|
|
155
153
|
async def add_fastapp_crud(*args: Any, **kwargs: Any):
|
156
154
|
task: Task = kwargs.get('_task')
|
157
155
|
task.print_out('Success')
|
158
|
-
|
159
|
-
|
160
|
-
###############################################################################
|
161
|
-
# Helper Definitions
|
162
|
-
###############################################################################
|
163
|
-
|
164
|
-
|
165
|
-
async def register_api(
|
166
|
-
task: Task,
|
167
|
-
project_dir: str,
|
168
|
-
kebab_app_name: str,
|
169
|
-
snake_module_name: str,
|
170
|
-
snake_entity_name: str
|
171
|
-
):
|
172
|
-
module_api_file_path = os.path.join(
|
173
|
-
project_dir, 'src', kebab_app_name, 'src', 'module', snake_module_name,
|
174
|
-
'api.py'
|
175
|
-
)
|
176
|
-
register_function_path = '.'.join([
|
177
|
-
'module', snake_module_name, 'entity', snake_entity_name, 'api'
|
178
|
-
])
|
179
|
-
register_function = f'register_{snake_entity_name}_api'
|
180
|
-
task.print_out(f'Read code from: {module_api_file_path}')
|
181
|
-
code = await read_text_file_async(module_api_file_path)
|
182
|
-
task.print_out(
|
183
|
-
f'Add import "register_api" as "{register_function}" ' +
|
184
|
-
f'from "{register_function_path}" to the code'
|
185
|
-
)
|
186
|
-
code = add_import_module(
|
187
|
-
code=code,
|
188
|
-
module_path=register_function_path,
|
189
|
-
resource='register_api',
|
190
|
-
alias=register_function
|
191
|
-
)
|
192
|
-
task.print_out(f'Add "{register_function}" call to the code')
|
193
|
-
code = append_code_to_function(
|
194
|
-
code=code,
|
195
|
-
function_name='register_api',
|
196
|
-
new_code=f'{register_function}(logger, app, authorizer, rpc_caller, publisher)' # noqa
|
197
|
-
)
|
198
|
-
task.print_out(f'Write modified code to: {module_api_file_path}')
|
199
|
-
await write_text_file_async(module_api_file_path, code)
|
200
|
-
|
201
|
-
|
202
|
-
async def register_rpc(
|
203
|
-
task: Task,
|
204
|
-
project_dir: str,
|
205
|
-
kebab_app_name: str,
|
206
|
-
snake_module_name: str,
|
207
|
-
snake_entity_name: str
|
208
|
-
):
|
209
|
-
module_rpc_file_path = os.path.join(
|
210
|
-
project_dir, 'src', kebab_app_name, 'src', 'module', snake_module_name,
|
211
|
-
'rpc.py'
|
212
|
-
)
|
213
|
-
register_function_path = '.'.join([
|
214
|
-
'module', snake_module_name, 'entity', snake_entity_name, 'rpc'
|
215
|
-
])
|
216
|
-
register_function = f'register_{snake_entity_name}_rpc'
|
217
|
-
task.print_out(f'Read code from: {module_rpc_file_path}')
|
218
|
-
code = await read_text_file_async(module_rpc_file_path)
|
219
|
-
task.print_out(
|
220
|
-
f'Add import "register_rpc" as "{register_function}" ' +
|
221
|
-
f'from "{register_function_path}" to the code'
|
222
|
-
)
|
223
|
-
code = add_import_module(
|
224
|
-
code=code,
|
225
|
-
module_path=register_function_path,
|
226
|
-
resource='register_rpc',
|
227
|
-
alias=register_function
|
228
|
-
)
|
229
|
-
task.print_out(f'Add "{register_function}" call to the code')
|
230
|
-
code = append_code_to_function(
|
231
|
-
code=code,
|
232
|
-
function_name='register_rpc',
|
233
|
-
new_code=f'{register_function}(logger, rpc_server, rpc_caller, publisher)' # noqa
|
234
|
-
)
|
235
|
-
task.print_out(f'Write modified code to: {module_rpc_file_path}')
|
236
|
-
await write_text_file_async(module_rpc_file_path, code)
|
237
|
-
|
238
|
-
|
239
|
-
async def register_permission(
|
240
|
-
task: Task,
|
241
|
-
project_dir: str,
|
242
|
-
kebab_app_name: str,
|
243
|
-
snake_module_name: str,
|
244
|
-
snake_entity_name: str
|
245
|
-
):
|
246
|
-
module_register_permission_file_path = os.path.join(
|
247
|
-
project_dir, 'src', kebab_app_name, 'src', 'module', 'auth',
|
248
|
-
'register_permission.py'
|
249
|
-
)
|
250
|
-
task.print_out(f'Read code from: {module_register_permission_file_path}')
|
251
|
-
code = await read_text_file_async(module_register_permission_file_path)
|
252
|
-
code = append_code_to_function(
|
253
|
-
code=code,
|
254
|
-
function_name='register_permission',
|
255
|
-
new_code='\n'.join([
|
256
|
-
'await ensure_entity_permission(',
|
257
|
-
f" module_name='{snake_module_name}', entity_name='{snake_entity_name}'", # noqa
|
258
|
-
')'
|
259
|
-
])
|
260
|
-
)
|
261
|
-
task.print_out(
|
262
|
-
f'Add "ensure_entity_permission" call for {snake_entity_name} ' +
|
263
|
-
'to the code'
|
264
|
-
)
|
265
|
-
task.print_out(
|
266
|
-
f'Write modified code to: {module_register_permission_file_path}'
|
267
|
-
)
|
268
|
-
await write_text_file_async(module_register_permission_file_path, code)
|
@@ -0,0 +1,115 @@
|
|
1
|
+
from typeguard import typechecked
|
2
|
+
from ....task.task import Task
|
3
|
+
from ....helper.codemod.add_import_module import add_import_module
|
4
|
+
from ....helper.codemod.append_code_to_function import append_code_to_function
|
5
|
+
from ....helper.file.text import read_text_file_async, write_text_file_async
|
6
|
+
import os
|
7
|
+
|
8
|
+
|
9
|
+
@typechecked
|
10
|
+
async def register_api(
|
11
|
+
task: Task,
|
12
|
+
project_dir: str,
|
13
|
+
kebab_app_name: str,
|
14
|
+
snake_module_name: str,
|
15
|
+
snake_entity_name: str
|
16
|
+
):
|
17
|
+
module_api_file_path = os.path.join(
|
18
|
+
project_dir, 'src', kebab_app_name, 'src', 'module', snake_module_name,
|
19
|
+
'api.py'
|
20
|
+
)
|
21
|
+
register_function_path = '.'.join([
|
22
|
+
'module', snake_module_name, 'entity', snake_entity_name, 'api'
|
23
|
+
])
|
24
|
+
register_function = f'register_{snake_entity_name}_api'
|
25
|
+
task.print_out(f'Read code from: {module_api_file_path}')
|
26
|
+
code = await read_text_file_async(module_api_file_path)
|
27
|
+
task.print_out(
|
28
|
+
f'Add import "register_api" as "{register_function}" ' +
|
29
|
+
f'from "{register_function_path}" to the code'
|
30
|
+
)
|
31
|
+
code = add_import_module(
|
32
|
+
code=code,
|
33
|
+
module_path=register_function_path,
|
34
|
+
resource='register_api',
|
35
|
+
alias=register_function
|
36
|
+
)
|
37
|
+
task.print_out(f'Add "{register_function}" call to the code')
|
38
|
+
code = append_code_to_function(
|
39
|
+
code=code,
|
40
|
+
function_name='register_api',
|
41
|
+
new_code=f'{register_function}(logger, app, authorizer, rpc_caller, publisher)' # noqa
|
42
|
+
)
|
43
|
+
task.print_out(f'Write modified code to: {module_api_file_path}')
|
44
|
+
await write_text_file_async(module_api_file_path, code)
|
45
|
+
|
46
|
+
|
47
|
+
@typechecked
|
48
|
+
async def register_rpc(
|
49
|
+
task: Task,
|
50
|
+
project_dir: str,
|
51
|
+
kebab_app_name: str,
|
52
|
+
snake_module_name: str,
|
53
|
+
snake_entity_name: str
|
54
|
+
):
|
55
|
+
module_rpc_file_path = os.path.join(
|
56
|
+
project_dir, 'src', kebab_app_name, 'src', 'module', snake_module_name,
|
57
|
+
'rpc.py'
|
58
|
+
)
|
59
|
+
register_function_path = '.'.join([
|
60
|
+
'module', snake_module_name, 'entity', snake_entity_name, 'rpc'
|
61
|
+
])
|
62
|
+
register_function = f'register_{snake_entity_name}_rpc'
|
63
|
+
task.print_out(f'Read code from: {module_rpc_file_path}')
|
64
|
+
code = await read_text_file_async(module_rpc_file_path)
|
65
|
+
task.print_out(
|
66
|
+
f'Add import "register_rpc" as "{register_function}" ' +
|
67
|
+
f'from "{register_function_path}" to the code'
|
68
|
+
)
|
69
|
+
code = add_import_module(
|
70
|
+
code=code,
|
71
|
+
module_path=register_function_path,
|
72
|
+
resource='register_rpc',
|
73
|
+
alias=register_function
|
74
|
+
)
|
75
|
+
task.print_out(f'Add "{register_function}" call to the code')
|
76
|
+
code = append_code_to_function(
|
77
|
+
code=code,
|
78
|
+
function_name='register_rpc',
|
79
|
+
new_code=f'{register_function}(logger, rpc_server, rpc_caller, publisher)' # noqa
|
80
|
+
)
|
81
|
+
task.print_out(f'Write modified code to: {module_rpc_file_path}')
|
82
|
+
await write_text_file_async(module_rpc_file_path, code)
|
83
|
+
|
84
|
+
|
85
|
+
@typechecked
|
86
|
+
async def register_permission(
|
87
|
+
task: Task,
|
88
|
+
project_dir: str,
|
89
|
+
kebab_app_name: str,
|
90
|
+
snake_module_name: str,
|
91
|
+
snake_entity_name: str
|
92
|
+
):
|
93
|
+
module_register_permission_file_path = os.path.join(
|
94
|
+
project_dir, 'src', kebab_app_name, 'src', 'module', 'auth',
|
95
|
+
'register_permission.py'
|
96
|
+
)
|
97
|
+
task.print_out(f'Read code from: {module_register_permission_file_path}')
|
98
|
+
code = await read_text_file_async(module_register_permission_file_path)
|
99
|
+
code = append_code_to_function(
|
100
|
+
code=code,
|
101
|
+
function_name='register_permission',
|
102
|
+
new_code='\n'.join([
|
103
|
+
'await ensure_entity_permission(',
|
104
|
+
f" module_name='{snake_module_name}', entity_name='{snake_entity_name}'", # noqa
|
105
|
+
')'
|
106
|
+
])
|
107
|
+
)
|
108
|
+
task.print_out(
|
109
|
+
f'Add "ensure_entity_permission" call for {snake_entity_name} ' +
|
110
|
+
'to the code'
|
111
|
+
)
|
112
|
+
task.print_out(
|
113
|
+
f'Write modified code to: {module_register_permission_file_path}'
|
114
|
+
)
|
115
|
+
await write_text_file_async(module_register_permission_file_path, code)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
from typing import List
|
2
|
-
from
|
2
|
+
from typeguard import typechecked
|
3
|
+
from ....task.any_task import AnyTask
|
3
4
|
from ....task.cmd_task import CmdTask
|
4
|
-
from ..
|
5
|
+
from ..common.task_input import (
|
5
6
|
project_dir_input, app_name_input, module_name_input, entity_name_input,
|
6
7
|
)
|
7
8
|
|
@@ -17,7 +18,8 @@ NAV_URL = '/{{util.to_kebab_case(input.module_name)}}/{{util.to_kebab_case(input
|
|
17
18
|
NAV_PERMISSION = '{{util.to_snake_case(input.module_name)}}:{{util.to_snake_case(input.entity_name)}}:get' # noqa
|
18
19
|
|
19
20
|
|
20
|
-
|
21
|
+
@typechecked
|
22
|
+
def create_add_navigation_task(upstreams: List[AnyTask]) -> AnyTask:
|
21
23
|
return CmdTask(
|
22
24
|
name='add-navigation',
|
23
25
|
inputs=[
|