Skip to content

CPM (Crab Package Manager) is a lightweight package manager that acts as an intelligent wrapper around npm and cargo, providing a unified interface for JavaScript and Rust projects.

License

Notifications You must be signed in to change notification settings

JetCrabCollab/cpm

CPM - Crab Package Manager

License: MIT Rust Node.js

A simple and intelligent wrapper for npm and cargo

CPM (Crab Package Manager) is a lightweight package manager that acts as an intelligent wrapper around npm and cargo, providing a unified interface for JavaScript and Rust projects.

πŸ¦€ Why CPM?

  • Simple: No complex registries or cache management
  • Fast: Delegates to proven tools (npm, cargo)
  • Unified: Single interface for JS and Rust projects
  • Flexible: Add Rust to JS projects when needed
  • Lightweight: Minimal dependencies and overhead

πŸš€ Quick Start

Installation

Option 1: Cargo (Recommended)

# Install CPM
cargo install cpm

# Or build from source
git clone https://github.com/JetCrabCollab/cpm.git
cd cpm
cargo build --release

Option 2: Docker

# Build Docker image
docker build -t cpm:latest .

# Run CPM commands
docker run --rm cpm:latest --help
docker run --rm -v $(pwd):/workspace -w /workspace cpm:latest init my-project -y

Option 3: Pre-built Binaries

Download from Releases (coming soon)

Prerequisites

CPM requires the following tools to be installed:

Basic Usage

# Initialize a JavaScript project
cpm init my-project -y

# Add Rust to existing JS project
cpm add-rust

# Check Rust status
cpm rust-status

# Remove Rust from project
cpm remove-rust

πŸ“‹ Commands

cpm init [name] [-y]

Initialize a new JavaScript project with npm.

cpm init my-app -y

cpm install

Install dependencies for the current project (npm + cargo).

cpm install

cpm build

Build the project (cargo + wasm-pack if available).

cpm build

cpm dev

Start development server (JetCrab first, then Node.js).

cpm dev

cpm test

Run tests for the current project (npm + cargo).

cpm test

cpm npx <package> [args...]

Execute packages using npx.

cpm npx create-react-app my-app
cpm npx eslint --init

cpm add-rust [-y]

Add Rust to an existing JavaScript project.

cpm add-rust -y

cpm remove-rust [-y]

Remove Rust from a project.

cpm remove-rust -y

cpm rust-status

Check Rust status in the current project.

cpm rust-status

πŸ—οΈ Project Structure

JavaScript Project

my-project/
β”œβ”€β”€ package.json
β”œβ”€β”€ index.js
└── README.md

Hybrid Project (after cpm add-rust)

my-project/
β”œβ”€β”€ package.json
β”œβ”€β”€ Cargo.toml
β”œβ”€β”€ src/
β”‚   └── lib.rs
β”œβ”€β”€ pkg/           # Generated WASM
β”œβ”€β”€ index.js
└── README.md

πŸ”§ How It Works

CPM is designed to be simple and lightweight:

  1. JavaScript Projects: Uses npm for package management
  2. Rust Integration: Uses cargo for Rust dependencies
  3. WASM Compilation: Uses wasm-pack for WebAssembly
  4. Development: Uses jetcrab or node for running projects
  5. Package Execution: Uses npx for running packages
  6. Intelligent Detection: Automatically detects project type and uses appropriate tools
  7. Cross-Platform: Works on Windows, macOS, and Linux

πŸ“¦ Examples

Create a JavaScript Project

cpm init my-js-app -y
cd my-js-app
cpm install express  # Install dependencies
cpm dev             # Runs with jetcrab or node
cpm test            # Run tests
cpm build           # Build project

Add Rust to JavaScript Project

cpm add-rust -y
cpm install         # Install both JS and Rust dependencies
cpm build           # Compiles Rust to WASM
cpm dev             # Runs hybrid project
cpm test            # Run both JS and Rust tests

Using npx with CPM

cpm npx create-react-app my-react-app
cpm npx eslint --init
cpm npx jest --init

Check Project Status

cpm rust-status
# Output:
# πŸ“ Project Structure:
#    package.json: βœ…
#    Cargo.toml: βœ…
#    src/ directory: βœ…
#    src/lib.rs: βœ…
#    pkg/ directory: βœ…
# 
# πŸ¦€ Rust is fully integrated!

🎯 When to Use CPM

Use CPM when:

  • βœ… You want a simple package manager
  • βœ… You work with JavaScript projects
  • βœ… You need Rust performance occasionally
  • βœ… You want to avoid complex tooling

Don't use CPM when:

  • ❌ You need advanced package management features
  • ❌ You work exclusively with Rust
  • ❌ You need custom registries or caching

πŸ”„ Migration from Other Tools

From npm

# Your existing npm project works with CPM
cpm init . -y  # Adds CPM scripts to package.json

From cargo

# Cargo projects can be integrated with CPM
cpm add-rust -y  # Adds JavaScript support

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/JetCrabCollab/cpm.git
cd cpm
cargo build
cargo test

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • npm - JavaScript package manager
  • Cargo - Rust package manager
  • wasm-pack - WebAssembly packaging
  • JetCrab - JavaScript runtime

πŸ“ž Support


Part of the JetCrab ecosystem - jetcrab.dev

About

CPM (Crab Package Manager) is a lightweight package manager that acts as an intelligent wrapper around npm and cargo, providing a unified interface for JavaScript and Rust projects.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published