4 releases (1 stable)

1.0.0 Mar 4, 2025
0.1.3 Jan 9, 2025
0.1.2 Dec 2, 2024
0.1.1 Dec 1, 2024
0.1.0 Nov 27, 2024

#135 in Build Utils

Download history 324/week @ 2024-11-27 69/week @ 2024-12-04 15/week @ 2024-12-11 137/week @ 2025-01-08 2/week @ 2025-01-15 6/week @ 2025-02-05 89/week @ 2025-02-26 64/week @ 2025-03-05 7/week @ 2025-03-12

160 downloads per month

MIT/Apache

83KB
2K SLoC

Cargonode

A simple build tool for Node.js projects.

Install

MacOS

brew install xosnrdev/cargonode/cargonode

Linux

curl -LsSf https://github.com/xosnrdev/cargonode/releases/download/0.1.3/cargonode-installer.sh | sh
iwr https://github.com/xosnrdev/cargonode/releases/download/0.1.3/cargonode-installer.ps1 | iex

Cargo

cargo install cargonode

Checkout releases page for more information.

Use

Usage: cargonode <COMMAND>

Commands:
  new    Create a new Node.js project at PATH
  init   Create a new Node.js project in an existing directory
  run    Run a specific tool
  check  Check files for errors
  build  Build the project
  test   Run tests
  help   Print this message

Options:
  -h, --help     Print help
  -V, --version  Print version

Configuration Protocol

Cargonode uses a simple protocol in your package.json to define build tools:

{
  "cargonode": {
    "tools": {
      "build": {
        "command": "tsc",                // Command to execute
        "args": ["--outDir", "dist"],    // Command arguments (optional)
        "env": {                         // Environment variables (optional)
          "NODE_ENV": "production"
        },
        "working_dir": "packages/core",  // Working directory (optional)
        "inputs": ["src/**/*.ts"],       // Input file patterns (required)
        "outputs": ["dist/**/*.js"]      // Output file patterns (optional)
      }
    }
  }
}

Protocol Fields

  • command: The executable to run (required)
  • args: List of command-line arguments (optional)
  • env: Environment variables to set (optional)
  • working_dir: Directory to run the command in (optional)
  • inputs: Glob patterns for input files (required)
  • outputs: Glob patterns for output files (optional)
    • Only specify for commands that generate files
    • Directories will be created automatically

Examples

{
  "cargonode": {
    "tools": {
      "dev": {
        "command": "ts-node-dev",
        "args": ["src/index.ts"],
        "inputs": ["src/**/*.ts"]
      },
      "test": {
        "command": "jest",
        "args": ["--coverage"],
        "inputs": ["src/**/*.ts", "test/**/*.ts"],
        "outputs": ["coverage/**/*"]
      }
    }
  }
}
cargonode run dev # Calls the dev protocol
cargonode test  # Calls the test protocol

Error Handling

Cargonode provides clear error messages and handles common scenarios:

  • Missing output directories are created automatically
  • Command failures include helpful suggestions
  • Use verbose mode (-v) to see detailed command output and progress

License

MIT or Apache-2.0

Dependencies

~4.5–6.5MB
~122K SLoC