1616
1717
1818conf_module_dir = module_dir (scaffolding )
19- root_scaffold_template_path = os .path .join (conf_module_dir , "new_template" )
20- init_template_json = os .path .join (root_scaffold_template_path , "setup.json " )
19+ new_template_template_path = os .path .join (conf_module_dir , "new_template" )
20+ new_manage_template_template_path = os .path .join (conf_module_dir , "new_manage_template " )
2121
2222
2323class NewTemplateScaffold (FileTemplateScaffold ):
2424 unwanted_chars = "" .join (["-" , ";" , "!" , "*" , ":" , " " ])
2525
26- def __init__ (self , project_name : str = None , ** kwargs : t .Any ) -> None :
26+ def __init__ (
27+ self , project_name : str = None , pyproject_enabled : bool = True , ** kwargs : t .Any
28+ ) -> None :
2729 super (NewTemplateScaffold , self ).__init__ (
2830 working_project_name = project_name , ** kwargs
2931 )
3032 self ._project_name = project_name
33+ self ._pyproject_enabled = pyproject_enabled
3134
3235 def create_file (self , base_path : str , file_name : str , content : t .Any ) -> None :
3336 _path = os .path .join (base_path , file_name .replace (".ellar" , ".py" ))
@@ -42,8 +45,12 @@ def create_file(self, base_path: str, file_name: str, content: t.Any) -> None:
4245 fw .writelines (refined_content )
4346
4447 def on_scaffold_completed (self ) -> None :
48+ args = ["ellar" , "create-project" , self .get_project_name ()]
49+ if self ._pyproject_enabled :
50+ args .append ("--plain" )
51+
4552 popen_res = subprocess .run (
46- [ "ellar" , "create-project" , self . get_project_name ()] ,
53+ args ,
4754 cwd = self .get_project_cwd (),
4855 stdout = subprocess .PIPE ,
4956 stderr = subprocess .PIPE ,
@@ -64,9 +71,13 @@ def on_scaffold_completed(self) -> None:
6471 f"{ log_1 } "
6572 )
6673 print ("To start your server, run the command below" )
67- print (
68- f"- ellar --project { project_working_project_name } runserver --reload\n Happy coding!"
69- )
74+ if self ._pyproject_enabled :
75+ print ("- python manage.py runserver --reload\n Happy coding!" )
76+ else :
77+ print (
78+ f"- ellar --project { project_working_project_name } runserver --reload\n Happy coding!"
79+ )
80+
7081 else : # pragma: no cover
7182 print (popen_res .stderr .decode ("utf8" ))
7283
@@ -128,14 +139,28 @@ def get_project_cwd(self) -> str:
128139 required = False ,
129140 help = "The name of a new directory to scaffold the project into. Scaffolding into an existing directory is only allowed if the directory is empty" ,
130141)
131- def new_command (project_name : str , directory : t .Optional [str ]):
142+ @eClick .option (
143+ "--plain" ,
144+ is_flag = True ,
145+ default = False ,
146+ help = "Create a new without including `pyproject.toml`." ,
147+ )
148+ def new_command (project_name : str , directory : t .Optional [str ], plain : bool ):
132149 """- Runs a complete Ellar project scaffold and creates all files required for managing you application -"""
150+ root_scaffold_template_path = new_template_template_path
151+ init_template_json = os .path .join (root_scaffold_template_path , "setup.json" )
152+
153+ if plain :
154+ root_scaffold_template_path = new_manage_template_template_path
155+ init_template_json = os .path .join (root_scaffold_template_path , "setup.json" )
156+
133157 schema = EllarScaffoldSchema .parse_file (init_template_json )
134158 init_template_scaffold = NewTemplateScaffold (
135159 schema = schema ,
136160 working_directory = os .getcwd (),
137161 scaffold_ellar_template_root_path = root_scaffold_template_path ,
138162 project_name = project_name ,
139163 specified_directory = directory ,
164+ pyproject_enabled = plain ,
140165 )
141166 init_template_scaffold .scaffold ()
0 commit comments