Skip to content

Commit 238a7c2

Browse files
authored
Merge pull request #4 from py-universe/patch/feedback
Patch/feedback
2 parents 36c7d07 + 8c60b08 commit 238a7c2

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

django_rest_cli/engine/commands/start_project.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from django_rest_cli.engine.cli.mixins import ProjectConfigMixin
55
from django_rest_cli.engine.utils import (
6+
display_project_setup_instructions,
67
init_git_repo,
78
install_dependencies,
89
rename_file,
@@ -13,7 +14,9 @@
1314

1415
class StartProject(ProjectConfigMixin, Base):
1516
@staticmethod
16-
def __follow_up_start_project(name: str, directory: Optional[str] = None) -> None:
17+
def __follow_up_start_project(
18+
name: str, template_type: str, directory: Optional[str] = None
19+
) -> None:
1720
if directory is None:
1821
manage_dir: pathlib.Path = pathlib.Path(".") / name
1922
else:
@@ -35,6 +38,7 @@ def __follow_up_start_project(name: str, directory: Optional[str] = None) -> Non
3538

3639
init_git_repo(manage_dir)
3740
install_dependencies(manage_dir)
41+
display_project_setup_instructions(template_type)
3842

3943
@classmethod
4044
async def __start(
@@ -48,7 +52,7 @@ async def __start(
4852
template: str = f"{what.name}_TEMPLATE_URL_{template_type.upper()}"
4953

5054
await Base.run_cmd_command(directive, name, directory, template)
51-
cls.__follow_up_start_project(name)
55+
cls.__follow_up_start_project(name, template_type)
5256

5357
@classmethod
5458
async def start_project(

django_rest_cli/engine/enums.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from enum import Enum
2+
3+
4+
class Templates(Enum):
5+
BASIC = "Basic"
6+
MEDIOR = "Medior"
7+
ADV = "Advanced"

django_rest_cli/engine/utils.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import inflect
88
from termcolor import cprint
99

10+
from .enums import Templates
11+
1012

1113
def raise_error_message(error_text: str, exception: Exception):
1214
raise exception(error_text)
@@ -97,3 +99,41 @@ def pluralize(string):
9799
"""
98100
pluralizer = inflect.engine()
99101
return pluralizer.plural(string)
102+
103+
104+
def display_project_setup_instructions(
105+
template_type: str,
106+
) -> None:
107+
if Templates.BASIC.value in template_type:
108+
print_info_message(
109+
"Project Run Steps:Run the following commands\n\n"
110+
"""pip install -r requirements.txt
111+
NB: Skip the above command if dr-cli already installed dependencies \n"""
112+
"python manage.py migrate \n"
113+
"python manage.py runserver \n"
114+
"point your browser to `http://localhost:8000/api/v1/docs to view docs \n"
115+
)
116+
117+
if Templates.MEDIOR.value in template_type:
118+
print_info_message(
119+
"Project Run Steps: Run the following commands:\n\n"
120+
"""pip install -r requirements.txt
121+
Then runpip install -r requirements-dev.txt
122+
NB: Skip the above commands if dr-cli already installed dependencies \n"""
123+
"pre-commit install \n"
124+
"python manage.py makemigrations users \n"
125+
"python manage.py migrate \n"
126+
"python manage.py runserver \n"
127+
"Point your browser to http://localhost:8000/api/v1/docs to view docs \n"
128+
)
129+
130+
if Templates.ADV.value in template_type:
131+
print_info_message(
132+
"Project Run Steps: Run the following commands\n\n"
133+
"pre-commit install \n"
134+
"docker-compose up --build \n"
135+
"Navigate to your project directory in a new terminal and run:\n\n"
136+
"docker-compose exec web python manage.py makemigrations users \n"
137+
"docker-compose exec web python manage.py migrate \n"
138+
"Point your browser to http://localhost:8000/api/v1/docs to view docs \n"
139+
)

0 commit comments

Comments
 (0)