1.1.1 • Published 9 months ago

code-collector v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Code Collector

A handy command-line tool to collect local JavaScript and TypeScript code files into a formatted output. This tool recursively resolves all local imports from the chosen source file (excluding node_modules dependencies) and collects each resolved file into a structured format.  This helps to identify a bug's root cause in the chosen application area, review its business logic, and prepare documentation or code snippets for LLMs.

Features

  • Supports .js, .jsx, .ts, and .tsx files (files like styles, images, fonts will be skipped).
  • Recursively resolves local imports in your codebase.
  • Excludes external node_modules dependencies imports (only local code will be returned).
  • Collects code into a clean, formatted output.
  • CLI interface for easy usage.

Installation

You can install the package globally using npm:

npm install -g code-collector

Usage

npx code-collector <entryFile> [options]

Options

  • <entryFile>: Required. The entry file, base for building the dependency tree.
  • -o, --output <outputFile>: Optional. Specify the output file. Defaults to standard output (your terminal window 👀).

Example usage

code-collector src/components/MainComponent.tsx -o output.txt

This command collects the code starting from src/components/MainComponent.tsx and writes the formatted output to output.txt (in the directory where you executed the tool).

Output format

The collected output will list each file's path (relative to the root of the repository) and its content in a code block with appropriate syntax highlighting marker.

<path_to_the_file>
```typescript
<content_of_the_file>
```

License

This project is licensed under the ISC License.

1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago