Skip to content
GitHub

CLI Commands

Unentropy provides a command-line interface for local development and testing. Use these commands to initialize configuration, validate setup, and preview reports before pushing to CI.

Generate configuration file with sensible defaults for your project type.

bunx unentropy init [options]
  1. Detects project type from marker files
  2. Creates unentropy.json with appropriate metrics
  3. Displays GitHub Actions workflow examples
  4. Suggests next steps

Force specific project type.

bunx unentropy init --type php

Values: javascript, php, go, python

Use this when:

  • Auto-detection picks the wrong type
  • You have a multi-language project
  • Marker files are in subdirectories

Select storage backend.

bunx unentropy init --storage s3

Values: artifact (default), s3, local

  • artifact: GitHub Actions artifacts (90-day retention)
  • s3: S3-compatible storage (unlimited retention)
  • local: Local file (development only)

Overwrite existing configuration.

bunx unentropy init --force

Warning: This replaces your existing unentropy.json. Back up custom changes first.

Preview configuration without writing files.

bunx unentropy init --dry-run

Displays what would be created without modifying anything.

Unentropy detects your project type from these files:

TypeDetection Files
JavaScriptpackage.json, tsconfig.json, bun.lockb, pnpm-lock.yaml, yarn.lock, package-lock.json
PHPcomposer.json, composer.lock
Gogo.mod, go.sum
Pythonpyproject.toml, setup.py, requirements.txt, Pipfile, setup.cfg

Priority order when multiple types detected: JavaScript > PHP > Go > Python

Detected project type: javascript (found: package.json, tsconfig.json)

✓ Created unentropy.json with 3 metrics:
  - lines-of-code (Lines of Code)
  - test-coverage (Test Coverage)
  - bundle (Bundle Size)

Next steps:
  1. Run 'bunx unentropy test' to verify metric collection
  2. Add the workflows below to your repository

TRACK METRICS (main branch):
.github/workflows/metrics.yml:

name: Track Metrics
on:
  push:
    branches: [main]
jobs:
  track-metrics:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run tests with coverage
        run: bun test --coverage
      - name: Track metrics
        uses: unentropy/track-metrics-action@v1

QUALITY GATE (pull requests):
.github/workflows/quality-gate.yml:

name: Quality Gate
on:
  pull_request:
jobs:
  quality-gate:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - name: Run tests with coverage
        run: bun test --coverage
      - name: Quality Gate Check
        uses: unentropy/quality-gate-action@v1
  • 0: Success
  • 1: Configuration already exists (use --force to overwrite)
  • 1: Project type cannot be detected (use --type to specify)
  • 1: Invalid --type value

Validate configuration and run metric collection locally without persisting data.

bunx unentropy test [options]
  1. Validates unentropy.json schema
  2. Runs metric collection commands sequentially
  3. Displays results with values, units, and timing
  4. Exits with appropriate code based on results

Specify alternate configuration file.

bunx unentropy test --config custom-config.json

Default: unentropy.json

Override per-metric timeout in milliseconds.

bunx unentropy test --timeout 60000

Default: 30000ms (30 seconds)

Per-metric timeouts in config take precedence when not specified.

Success:

✓ Config schema valid

Collecting metrics:

  ✓ lines-of-code (integer)    4,521         0.8s
  ✓ test-coverage (percent)    87.3%         2.1s
  ✓ bundle (bytes)             240 KB        0.2s

All 3 metrics collected successfully.

Failure:

✓ Config schema valid

Collecting metrics:

  ✓ lines-of-code (integer)    4,521         0.8s
  ✗ test-coverage (percent)    Failed        2.1s
    Error: coverage/lcov.info not found
  ✓ bundle (bytes)             240 KB        0.2s

2 of 3 metrics collected successfully.
  • 0: All metrics collected successfully
  • 1: Configuration validation failed
  • 2: One or more metrics failed to collect

Generate HTML report with empty/placeholder data to preview report structure.

bunx unentropy preview [options]
  1. Validates unentropy.json schema
  2. Generates HTML report with all configured metrics
  3. Shows metrics with no data (empty state)
  4. Opens report in default browser

Specify alternate configuration file.

bunx unentropy preview --config custom-config.json

Default: unentropy.json

Specify output directory.

bunx unentropy preview --output ./reports/preview

Default: unentropy-preview

Creates directory if it doesn’t exist. Report is written to <output>/index.html.

Don’t open browser automatically.

bunx unentropy preview --no-open

Report is generated but browser doesn’t launch. Useful in headless/CI environments.

Overwrite existing non-empty output directory.

bunx unentropy preview --force

Warning: This deletes existing content in the output directory.

✓ Config schema valid
✓ Generated report: unentropy-preview/index.html
✓ Opening in browser...
  • 0: Report generated successfully
  • 1: Configuration validation failed
  • 1: Output directory exists and is not empty (use --force)
  • 1: Report generation failed
  • 1: Configuration file not found

Validate configuration file schema and structure.

bunx unentropy verify [config]
  • config (optional): Path to configuration file. Defaults to unentropy.json.

Validates:

  • JSON syntax
  • Required fields present
  • Valid metric definitions
  • Storage configuration correct
  • Threshold syntax valid

Success:

✓ Configuration is valid

Failure:

✗ Configuration validation failed:

Error: Invalid storage type "invalid-type"
  Expected: sqlite-local, sqlite-artifact, sqlite-s3
  Location: storage.type

Error: Missing required field "command" for metric "coverage"
  Location: metrics.coverage
  • 0: Configuration is valid
  • 1: Validation failed

These options work with all commands:

Show help for a command.

bunx unentropy --help
bunx unentropy init --help
bunx unentropy test --help

Show Unentropy version.

bunx unentropy --version
# Generate configuration
bunx unentropy init

# Verify it works
bunx unentropy test

# Preview report structure
bunx unentropy preview

# Add workflows to repository (copy from init output)
# Commit and push
# Validate changes
bunx unentropy verify

# Test metric collection
bunx unentropy test

# Preview report
bunx unentropy preview --force
# Test metric collection
bunx unentropy test

# Increase timeout for slow metrics
bunx unentropy test --timeout 60000
# Project 1 (JavaScript)
cd project1
bunx unentropy init --type javascript

# Project 2 (PHP)
cd ../project2
bunx unentropy init --type php