codereg
v1.4.0
Published
A CLI tool for copying and managing source code directly from GitHub repositories, perfect for modern React UI libraries and custom code management.
Maintainers
Readme
CodeReg
A powerful command-line tool for copying and managing source code directly from GitHub repositories. Instead of installing libraries as dependencies, CodeReg allows you to copy specific source code files into your project, giving you full control over the code and making it easier to customize.
Key Features
- Copy source code directly from GitHub repositories instead of installing packages
- Perfect for modern React UI libraries that share source code rather than bundled packages
- Interactive GUI-like CLI interface for easy code registration
- Registry-based configuration system for managing multiple code sources
- Support for copying any public files from GitHub repositories
- Easy customization of copied code since it's directly in your project
- Branch and path-specific code copying
- Progress indicators and interactive prompts
Why CodeReg?
In modern web development, especially with React UI libraries, there's a growing trend of sharing source code instead of bundled packages. This approach offers several advantages:
- Full control over the code in your project
- Easy customization and modification
- No need to deal with complex bundling configurations
- Direct access to source code for debugging and learning
- Ability to modify and adapt code to your specific needs
CodeReg makes this workflow seamless by providing a simple way to copy and manage source code from GitHub repositories.
Installation
Global Installation
You can install CodeReg globally using pnpm:
pnpm add -g coderegLocal Project Installation
To install CodeReg as a development dependency in your project:
pnpm add -D coderegAfter local installation, you can use it in your project's scripts in package.json:
{
"scripts": {
"register": "codereg"
}
}Then run it using:
pnpm registerOr use it directly with npx:
npx coderegUsage
Basic Commands
Initialize Project
Initialize a new CodeReg project in your current directory:
npx codereg initThis will create a default configuration file .codereg.config.json in your project root.
Example configuration:
{
"$schema": "https://cdn.jsdelivr.net/npm/codereg/dist/config.schema.json",
"registry": [
{
"name": "ui", // name your entry
"url": "https://github.com/xxx/ui",
"branch": "main", // optional
"path": "/packages/ui/src", // optional
"dirname": "./components"
}
]
}Add Registration
Add a new code registration using the interactive CLI:
codereg addThe interactive prompt will guide you through:
- Selecting the registry
- Choosing the branch
- Specifying the source path
- Selecting files to copy
- Setting the destination directory
Command Options
Add Command with options
codereg add -r ui -b main -p /packages/ui/src -f button.tsxCommon Flags
-r, --registry: Specify the registry name to add (e.g., 'ui')-b, --branch: Specify the branch name (e.g., 'main')-p, --path: Specify the source path in the registry (e.g., '/packages/ui/src')-f, --file: Specify the file to register (e.g., 'button.tsx')--helpor-h: Show help information--versionor-V: Show version information
Use Cases
React UI Libraries
CodeReg is particularly useful for modern React UI libraries that share source code. Instead of installing the entire package, you can copy only the components you need and customize them directly in your project.
Custom Code Management
- Copy utility functions from public repositories
- Share code between projects
- Maintain a local registry of commonly used code snippets
- Version control your custom code modifications
Learning and Experimentation
- Study and learn from open-source code
- Experiment with different implementations
- Create your own modified versions of existing code
Development
Prerequisites
- Node.js (Latest LTS version recommended)
- pnpm
Setup
- Clone the repository:
git clone https://github.com/onepercman/codereg.git
cd codereg- Install dependencies:
pnpm installAvailable Scripts
pnpm build- Build the projectpnpm dev- Start development mode with watchpnpm start- Run the built projectpnpm test- Run tests
Building
To build the project:
pnpm buildThis will create the distribution files in the dist directory.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Author
- onepercman
Support
If you encounter any issues or have questions, please open an issue on GitHub.
