Skip to content

Commit 6dcc349

Browse files
committed
Fix import for startunicorn. Ask for GitHub star and some ascii art.
1 parent e7e3c73 commit 6dcc349

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

django_unicorn/management/commands/startunicorn.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from pathlib import Path
2+
from webbrowser import open
23

34
from django.core.management.base import BaseCommand, CommandError
45

5-
from ...components import convert_to_pascal_case, convert_to_snake_case
6+
from django_unicorn.components.unicorn_view import (
7+
convert_to_pascal_case,
8+
convert_to_snake_case,
9+
)
610

711

812
COMPONENT_FILE = """from django_unicorn.components import UnicornView
@@ -28,9 +32,17 @@ def handle(self, *args, **options):
2832
if not Path("manage.py").exists():
2933
raise CommandError("Can't find manage.py in current path.")
3034

35+
first_component = False
36+
3137
if not Path("unicorn").exists():
3238
Path("unicorn").mkdir()
33-
self.stdout.write(self.style.SUCCESS("Create unicorn directory ✨"))
39+
self.stdout.write(
40+
self.style.SUCCESS(
41+
"Create unicorn directory for your first component! ✨"
42+
)
43+
)
44+
45+
first_component = True
3446

3547
for component_name in options["component_names"]:
3648
snake_case_component_name = convert_to_snake_case(component_name)
@@ -59,8 +71,41 @@ def handle(self, *args, **options):
5971
template_path.write_text(TEMPLATE_FILE)
6072
self.stdout.write(self.style.SUCCESS(f"Created {template_path}."))
6173

74+
if first_component:
75+
input_value = input(
76+
"\nStarring the GitHub repo helps other Django users find Unicorn. Can you star it for me? [y/N] "
77+
)
78+
79+
if input_value.strip().lower() in ("y", "yes"):
80+
self.stdout.write(
81+
"""
82+
,/
83+
//
84+
,//
85+
__ /| |//
86+
`__/\\_ --(/|___/-/
87+
\\|\\_-\\___ __-_`- /-/ \\.
88+
|\\_-___,-\\_____--/_)' ) \\
89+
\\ -_ / __ \\( `( __`\\|
90+
`\\__| |\\) (/|
91+
',--//-| \\ | ' /
92+
/,---| \\ /
93+
`_/ _,' | |
94+
__/'/ | |
95+
___/ \\ ( ) /
96+
\\____/\\
97+
\\
98+
"""
99+
)
100+
self.stdout.write(
101+
self.style.SUCCESS(
102+
"Thank you for helping spread the word about Unicorn!"
103+
)
104+
)
105+
open("https://github.com/adamghill/django-unicorn", new=2)
106+
62107
self.stdout.write(
63-
self.style.SUCCESS(
64-
f"\nMake sure to add '\"unicorn\",' to your INSTALLED_APPS array in your settings file if necessary."
108+
self.style.WARNING(
109+
"\nMake sure to add '\"unicorn\",' to your INSTALLED_APPS list in your settings file if necessary."
65110
)
66111
)

0 commit comments

Comments
 (0)