|
3 | 3 |
|
4 | 4 | import importlib.resources
|
5 | 5 | import json
|
| 6 | +import sys |
6 | 7 | from pathlib import Path
|
7 | 8 | from typing import Annotated, Optional, cast
|
8 | 9 |
|
@@ -199,19 +200,32 @@ def create(
|
199 | 200 | TextColumn('[progress.description]{task.description}'),
|
200 | 201 | transient=True,
|
201 | 202 | ) as progress:
|
202 |
| - progress.add_task(description='Bootstrapping...', total=None) |
203 |
| - cookiecutter( |
204 |
| - template=str(template_directory), |
205 |
| - no_input=True, |
206 |
| - extra_context={ |
207 |
| - 'project_name': project_name, |
208 |
| - 'package_manager': package_manager, |
209 |
| - 'crawler_type': crawler_type, |
210 |
| - 'http_client': http_client, |
211 |
| - 'enable_apify_integration': enable_apify_integration, |
212 |
| - 'start_url': start_url, |
213 |
| - }, |
214 |
| - ) |
| 203 | + bootstrap_task = progress.add_task(description='Bootstrapping...', total=None) |
| 204 | + |
| 205 | + try: |
| 206 | + cookiecutter( |
| 207 | + template=str(template_directory), |
| 208 | + no_input=True, |
| 209 | + extra_context={ |
| 210 | + 'project_name': project_name, |
| 211 | + 'package_manager': package_manager, |
| 212 | + 'crawler_type': crawler_type, |
| 213 | + 'http_client': http_client, |
| 214 | + 'enable_apify_integration': enable_apify_integration, |
| 215 | + 'start_url': start_url, |
| 216 | + }, |
| 217 | + ) |
| 218 | + except Exception as exc: |
| 219 | + progress.update(bootstrap_task, visible=False) |
| 220 | + progress.refresh() |
| 221 | + |
| 222 | + # Print just the last line of the error message (the actual error without traceback) |
| 223 | + if 'Hook script failed' in str(exc): |
| 224 | + typer.echo('Project creation failed. Check the error message above.', err=True) |
| 225 | + else: |
| 226 | + typer.echo(f'Project creation failed: {exc!s}', err=True) |
| 227 | + |
| 228 | + sys.exit(1) |
215 | 229 |
|
216 | 230 | typer.echo(f'Your project "{project_name}" was created.')
|
217 | 231 |
|
|
0 commit comments