Skip to content

JetCrabCollab/cpm

CPM - Crab Package Manager

License: MIT Rust Node.js

The package manager for JetCrab - npm/yarn equivalent for the JetCrab ecosystem

CPM (Crab Package Manager) is the package manager for JetCrab projects. Like npm and yarn for Node.js, CPM manages dependencies, scripts, and project lifecycle for JavaScript and Rust projects in the JetCrab stack.

Why CPM?

CPM aims for parity with npm/yarn for the JetCrab ecosystem:

npm/yarn CPM
npm init cpm init
npm install cpm install
npm install pkg cpm add pkg
npm run script cpm run script
yarn add / remove cpm add / remove

Plus: native Rust/WASM support via Cargo integration.

πŸš€ 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 add <package> [-D]

Add a package (delegates to npm install). Use -D for devDependencies.

cpm add lodash
cpm add -D eslint

cpm remove <package>

Remove a package (delegates to npm uninstall).

cpm remove lodash

cpm install

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

cpm install

cpm lock

Update lockfiles (package-lock.json, Cargo.lock).

cpm lock

cpm workspace

List workspace packages.

cpm workspace

cpm build

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

cpm build

cpm dev [-w|--watch]

Start development server (JetCrab first, then Node.js). Use --watch for hot reload with nodemon.

cpm dev
cpm dev --watch

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

cpm publish

Publish package to npm registry (delegates to npm publish).

cpm publish

πŸ—οΈ 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 add lodash      # Add dependencies
cpm install         # Install all 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

 
 
 

Contributors