Main entry point.
()
| 554 | |
| 555 | |
| 556 | def main(): |
| 557 | """Main entry point.""" |
| 558 | args = parse_args() |
| 559 | |
| 560 | output_file = None |
| 561 | if args.output: |
| 562 | output_dir = Path(args.output).parent |
| 563 | output_dir.mkdir(parents=True, exist_ok=True) |
| 564 | output_file = open(args.output, 'w', encoding='utf-8') |
| 565 | print(f"Writing output to: {args.output}", file=sys.stderr) |
| 566 | |
| 567 | try: |
| 568 | # Directory tree |
| 569 | print_section( |
| 570 | f"DIRECTORY TREE (max depth {TREE_MAX_DEPTH}, source files only)", |
| 571 | get_directory_tree(), |
| 572 | output_file |
| 573 | ) |
| 574 | |
| 575 | # Stack detection |
| 576 | manifests = find_manifest_files() |
| 577 | if manifests: |
| 578 | manifest_content = [""] |
| 579 | for manifest in manifests: |
| 580 | manifest_path = Path(manifest) |
| 581 | manifest_content.append(f"--- {manifest} ---") |
| 582 | if manifest == "bun.lockb": |
| 583 | manifest_content.append("[Binary lockfile — see package.json for dependency details.]") |
| 584 | else: |
| 585 | manifest_content.append(read_file_preview(manifest_path)) |
| 586 | print_section("STACK DETECTION (manifest files)", manifest_content, output_file) |
| 587 | else: |
| 588 | print_section("STACK DETECTION (manifest files)", ["No recognized manifest files found in project root."], output_file) |
| 589 | |
| 590 | # Entry points |
| 591 | entries = find_entry_points() |
| 592 | if entries: |
| 593 | entry_content = [f"Found: {e}" for e in entries] |
| 594 | print_section("ENTRY POINTS", entry_content, output_file) |
| 595 | else: |
| 596 | print_section("ENTRY POINTS", ["No common entry points found. Check 'main' or 'scripts.start' in manifest files above."], output_file) |
| 597 | |
| 598 | # Linting config |
| 599 | lint = find_lint_config() |
| 600 | if lint: |
| 601 | lint_content = [f"Found: {l}" for l in lint] |
| 602 | print_section("LINTING AND FORMATTING CONFIG", lint_content, output_file) |
| 603 | else: |
| 604 | print_section("LINTING AND FORMATTING CONFIG", ["No linting or formatting config files found in project root."], output_file) |
| 605 | |
| 606 | # Environment templates |
| 607 | envs = find_env_templates() |
| 608 | if envs: |
| 609 | env_content = [] |
| 610 | for filename, filepath in envs: |
| 611 | env_content.append(f"--- {filename} ---") |
| 612 | env_content.append(read_file_preview(filepath)) |
| 613 | print_section("ENVIRONMENT VARIABLE TEMPLATES", env_content, output_file) |
no test coverage detected