Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flatten script #1262

Merged
merged 3 commits into from
Feb 11, 2025
Merged

feat: flatten script #1262

merged 3 commits into from
Feb 11, 2025

Conversation

drptbl
Copy link
Collaborator

@drptbl drptbl commented Feb 11, 2025

Add flatten script

This PR introduces a script for consolidating project files into a single output directory, making it easier to review and analyze the codebase (especially with AI).

Changes

Added

  • New flatten.cjs script that:
    • Recursively processes .js, .ts, .json, and .md files
    • Respects .gitignore patterns when scanning directories
    • Splits output into multiple files if exceeding line limit
    • Provides statistics about total lines and characters processed
    • Maintains file origin information in output files

Implementation Details

  • Uses native Node.js modules (fs, path) without external dependencies
  • Implements custom .gitignore pattern matching
  • Handles large codebases by splitting output into manageable chunks
  • Provides detailed statistics after processing

Notes

  • Output files are generated with .txt extension for consistency
  • Each file in the output includes a reference to its original location
  • The script automatically creates the output directory if it doesn't exist

This script processes project files, ignoring .gitignore patterns, and creates consolidated output files with file contents and metadata.

Signed-off-by: drptbl <[email protected]>
Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
synpress ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 10:42pm

@drptbl drptbl changed the title Flatten script feat: flatten script Feb 11, 2025
Signed-off-by: drptbl <[email protected]>
@drptbl drptbl merged commit 45f80c8 into dev Feb 11, 2025
4 checks passed
@drptbl drptbl deleted the flatten-script branch February 11, 2025 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant