File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,45 @@ def compile(ctx):
305
305
ctx .invoke (legacy_alias , legacy_args = ["collectstatic" , "--noinput" ])
306
306
307
307
308
+ @bolt_cli .command ()
309
+ @click .argument ("package_name" )
310
+ def create (package_name ):
311
+ """Create a new local package"""
312
+ package_dir = bolt .runtime .APP_PATH / package_name
313
+ package_dir .mkdir (exist_ok = True )
314
+
315
+ empty_dirs = (
316
+ f"templates/{ package_name } " ,
317
+ "migrations" ,
318
+ )
319
+ for d in empty_dirs :
320
+ (package_dir / d ).mkdir (parents = True , exist_ok = True )
321
+
322
+ empty_files = (
323
+ "__init__.py" ,
324
+ "migrations/__init__.py" ,
325
+ "models.py" ,
326
+ "views.py" ,
327
+ )
328
+ for f in empty_files :
329
+ (package_dir / f ).touch (exist_ok = True )
330
+
331
+ # Create a urls.py file with a default namespace
332
+ if not (package_dir / "urls.py" ).exists ():
333
+ (package_dir / "urls.py" ).write_text (
334
+ f"""from bolt.urls import path
335
+
336
+ default_namespace = f"{ package_name } "
337
+
338
+ urlpatterns = [
339
+ # path("", views.IndexView, name="index"),
340
+ ]
341
+ """
342
+ )
343
+
344
+ click .secho (f"Created { package_dir .relative_to (Path .cwd ())} " , fg = "green" )
345
+
346
+
308
347
class AppCLIGroup (click .Group ):
309
348
"""
310
349
Loads app.cli if it exists as `bolt app`
You can’t perform that action at this time.
0 commit comments