@cantez/onyx
v1.0.5
Published
A blazingly-fast package manager for JavaScript.
Downloads
6
Readme
Onyx is a Node.js package manager built with Go (yes, ironically) and the Cobra CLI framework. It allows you to manage your Node.js dependencies without relying on traditional package managers like npm
, yarn
or even pnpm
. The tool provides features for installing, removing, and running scripts from package.json
, with additional support for handling devDependencies
.
Features
- Install a Single Package: Install individual Node.js packages directly from the npm registry.
- Install All Dependencies: Install all dependencies listed in
package.json
. - Install as DevDependencies: Install a package as a devDependency using a flag.
- Remove a Package: Remove a package from
node_modules
andpackage.json
. - Run Custom Scripts: Run custom npm scripts defined in the
scripts
section ofpackage.json
. - Install Global Packages: Install packages globally with permissions management.
- Graceful Error Handling: Handles missing or incomplete package metadata gracefully and skips problematic packages.
Prerequisites
Installation
Clone the repository:
git clone https://github.com/alperencantez/onyx.git
Change to the project directory:
cd onyx
Build the CLI tool:
go build -o .
Move the binary to your
$PATH
for global usage:sudo mv onyx /usr/local/bin/
Now you can use onyx
from any directory!
Usage
1. Install a Single Package
To install a package:
onyx get next 14.1.3
To install a package as a devDependency:
onyx get lodash --dev
2. Install All Dependencies from package.json
If you already have a package.json
file, you can install all dependencies listed:
onyx deps
This command installs all dependencies and devDependencies listed in the package.json
file.
3. Remove a Package
To remove a package from node_modules
and package.json
:
onyx remove lodash
This will delete the lodash
package from your node_modules
and remove its entry from the package.json
file.
4. Run a Custom Script
You can run custom scripts defined in the scripts
section of your package.json
:
onyx r build
This will execute the build
script defined in your package.json
.
5. Install Global Packages
To install a package globally:
sudo onyx get lodash -g
This command installs lodash
globally in your system.
Error Handling
The tool provides graceful error handling for cases such as:
- Missing
package.json
. - Missing
node_modules
. - Packages with incomplete metadata in the npm registry.
- Invalid or malformed versions (e.g.,
^
and~
symbols).
Logs and Warnings
In cases where a package cannot be installed due to missing metadata or other issues, warnings will be logged, but the process will continue for other packages:
Warning: 'dist' field is missing for package 'gsap'. Skipping installation.
Development
Running Locally
Clone the repository:
git clone https://github.com/alperencantez/onyx.git
Make your changes.
Run the project locally:
go run main.go
Contributing
If you’d like to contribute, please fork the repository and use a feature branch. Pull requests are welcome!
Fork the repo and create your branch:
git checkout -b feature/my-feature
Make changes and commit them:
git commit -m "Add new feature"
Push to the branch:
git push origin feature/my-feature
Create a PR.
License
This project is licensed under the MIT License. See the LICENSE file for details.