|
32 | 32 | from codeflash.code_utils.github_utils import get_github_secrets_page_url |
33 | 33 | from codeflash.code_utils.shell_utils import get_shell_rc_path, save_api_key_to_rc |
34 | 34 | from codeflash.either import is_successful |
| 35 | +from codeflash.lsp.helpers import is_LSP_enabled |
35 | 36 | from codeflash.telemetry.posthog_cf import ph |
36 | 37 | from codeflash.version import __version__ as version |
37 | 38 |
|
@@ -648,41 +649,41 @@ def check_for_toml_or_setup_file() -> str | None: |
648 | 649 | apologize_and_exit() |
649 | 650 | create_toml = toml_answers["create_toml"] |
650 | 651 | if create_toml: |
651 | | - ph("cli-create-pyproject-toml") |
652 | | - # Define a minimal pyproject.toml content |
653 | | - new_pyproject_toml = tomlkit.document() |
654 | | - new_pyproject_toml["tool"] = {"codeflash": {}} |
655 | | - try: |
656 | | - pyproject_toml_path.write_text(tomlkit.dumps(new_pyproject_toml), encoding="utf8") |
657 | | - |
658 | | - # Check if the pyproject.toml file was created |
659 | | - if pyproject_toml_path.exists(): |
660 | | - success_panel = Panel( |
661 | | - Text( |
662 | | - f"✅ Created a pyproject.toml file at {pyproject_toml_path}\n\n" |
663 | | - "Your project is now ready for Codeflash configuration!", |
664 | | - style="green", |
665 | | - justify="center", |
666 | | - ), |
667 | | - title="🎉 Success!", |
668 | | - border_style="bright_green", |
669 | | - ) |
670 | | - console.print(success_panel) |
671 | | - console.print("\n📍 Press any key to continue...") |
672 | | - console.input() |
673 | | - ph("cli-created-pyproject-toml") |
674 | | - except OSError: |
675 | | - click.echo( |
676 | | - "❌ Failed to create pyproject.toml. Please check your disk permissions and available space." |
677 | | - ) |
678 | | - apologize_and_exit() |
679 | | - else: |
680 | | - click.echo("⏩️ Skipping pyproject.toml creation.") |
681 | | - apologize_and_exit() |
| 652 | + create_empty_pyproject_toml(pyproject_toml_path) |
682 | 653 | click.echo() |
683 | 654 | return cast("str", project_name) |
684 | 655 |
|
685 | 656 |
|
| 657 | +def create_empty_pyproject_toml(pyproject_toml_path: Path) -> None: |
| 658 | + ph("cli-create-pyproject-toml") |
| 659 | + lsp_mode = is_LSP_enabled() |
| 660 | + # Define a minimal pyproject.toml content |
| 661 | + new_pyproject_toml = tomlkit.document() |
| 662 | + new_pyproject_toml["tool"] = {"codeflash": {}} |
| 663 | + try: |
| 664 | + pyproject_toml_path.write_text(tomlkit.dumps(new_pyproject_toml), encoding="utf8") |
| 665 | + |
| 666 | + # Check if the pyproject.toml file was created |
| 667 | + if pyproject_toml_path.exists() and not lsp_mode: |
| 668 | + success_panel = Panel( |
| 669 | + Text( |
| 670 | + f"✅ Created a pyproject.toml file at {pyproject_toml_path}\n\n" |
| 671 | + "Your project is now ready for Codeflash configuration!", |
| 672 | + style="green", |
| 673 | + justify="center", |
| 674 | + ), |
| 675 | + title="🎉 Success!", |
| 676 | + border_style="bright_green", |
| 677 | + ) |
| 678 | + console.print(success_panel) |
| 679 | + console.print("\n📍 Press any key to continue...") |
| 680 | + console.input() |
| 681 | + ph("cli-created-pyproject-toml") |
| 682 | + except OSError: |
| 683 | + click.echo("❌ Failed to create pyproject.toml. Please check your disk permissions and available space.") |
| 684 | + apologize_and_exit() |
| 685 | + |
| 686 | + |
686 | 687 | def install_github_actions(override_formatter_check: bool = False) -> None: # noqa: FBT001, FBT002 |
687 | 688 | try: |
688 | 689 | config, _config_file_path = parse_config_file(override_formatter_check=override_formatter_check) |
|
0 commit comments