npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@unispechq/unispec-cli

v0.3.3

Published

UniSpec CLI (validate/normalize/diff/convert).

Downloads

2

Readme

UniSpec CLI

npm version License: MIT

A powerful and user-friendly command-line interface for UniSpec specifications. Validate, normalize, diff, and convert UniSpec files with ease.

Features

  • 🔍 Validate - Check UniSpec specifications against the official schema
  • 🔧 Normalize - Apply normalization rules to ensure consistency
  • 📊 Diff - Compare two specifications and see detailed differences
  • 🔄 Convert - Convert between JSON and YAML formats
  • 🎨 Beautiful Output - Colored, formatted output with emojis for better UX
  • Fast - Built on top of the performant @unispechq/unispec-core
  • 🧪 Well Tested - Comprehensive test suite ensuring reliability

Installation

Global Installation

npm install -g @unispechq/unispec-cli

Local Installation

npm install --save-dev @unispechq/unispec-cli

Using npx (no installation needed)

npx @unispechq/unispec-cli <command>

Quick Start

# Validate a specification
unispec validate api-spec.json

# Normalize a specification
unispec normalize api-spec.json --output normalized.json

# Compare two specifications
unispec diff old-spec.json new-spec.json

# Convert JSON to YAML
unispec convert api-spec.json --format yaml --output api-spec.yaml

Commands

Validate

Validate UniSpec specifications against the official schema.

unispec validate <file> [options]

Options:

  • -s, --schema - Validate schema only
  • -c, --config - Validate configuration only
  • -t, --tests - Validate tests only
  • -f, --format <format> - Output format: json, yaml, table (default: table)
  • --verbose - Enable verbose output

Examples:

# Basic validation
unispec validate api-spec.json

# JSON output for CI/CD
unispec validate api-spec.json --format json

# Validate with verbose output
unispec validate api-spec.json --verbose

Exit Codes:

  • 0 - Validation successful
  • 1 - Validation failed or error occurred

Normalize

Apply normalization rules to ensure consistency across specifications.

unispec normalize <file> [options]

Options:

  • -o, --output <path> - Output file path (default: overwrite input)
  • -f, --format <format> - Output format: json, yaml (default: json)
  • --backup - Create backup of original file
  • --indent <size> - JSON indentation size (default: 2)

Examples:

# Normalize in place
unispec normalize api-spec.json

# Normalize to new file with backup
unispec normalize api-spec.json --output normalized.json --backup

# Convert to YAML during normalization
unispec normalize api-spec.json --format yaml --output api-spec.yaml

Diff

Compare two UniSpec specifications and see detailed differences.

unispec diff <file1> <file2> [options]

Options:

  • -f, --format <format> - Output format: table, json, summary (default: table)
  • --enhanced - Use enhanced diff algorithm
  • --context <lines> - Number of context lines for enhanced diff (default: 3)
  • --ignore <fields> - Comma-separated list of fields to ignore

Examples:

# Basic comparison
unispec diff old-spec.json new-spec.json

# Summary view
unispec diff old-spec.json new-spec.json --format summary

# JSON output for automation
unispec diff old-spec.json new-spec.json --format json

# Ignore specific fields
unispec diff old-spec.json new-spec.json --ignore "info.version,service.name"

Exit Codes:

  • 0 - No differences found
  • 1 - Differences found or error occurred

Convert

Convert UniSpec specifications between JSON and YAML formats.

unispec convert <file> [options]

Options:

  • -o, --output <path> - Output file path
  • -f, --format <format> - Target format: json, yaml (default: json)
  • --indent <size> - JSON indentation size (default: 2)
  • --backup - Create backup of original file

Examples:

# Convert JSON to YAML
unispec convert api-spec.json --format yaml --output api-spec.yaml

# Convert YAML to JSON with custom indentation
unispec convert api-spec.yaml --format json --indent 4 --output api-spec.json

# Convert with backup
unispec convert api-spec.json --format yaml --backup

Global Options

These options are available for all commands:

  • --config <path> - Path to configuration file (default: unispec.config.json)
  • --verbose - Enable verbose output
  • --no-color - Disable colored output
  • -v, --version - Display version number
  • -h, --help - Display help for command

Configuration

You can create a unispec.config.json file in your project root to set default options:

{
  "validate": {
    "format": "json",
    "strict": true
  },
  "normalize": {
    "backup": true,
    "indent": 2
  },
  "diff": {
    "format": "summary",
    "ignore": ["info.version"]
  },
  "convert": {
    "format": "yaml",
    "backup": true
  }
}

Examples

CI/CD Integration

#!/bin/bash
# Validate all spec files in a directory
for file in specs/*.json; do
  if ! unispec validate "$file" --format json; then
    echo "Validation failed for $file"
    exit 1
  fi
done

# Compare specs before deployment
if unispec diff current-spec.json new-spec.json; then
  echo "No changes detected"
else
  echo "Changes detected, review required"
  exit 1
fi

Git Hook Example

#!/bin/sh
# .git/hooks/pre-commit
echo "Validating UniSpec files..."

for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.json$\|\.yaml$'); do
  if ! unispec validate "$file"; then
    echo "❌ Validation failed for $file"
    exit 1
  fi
done

echo "✅ All files validated successfully"

Development Workflow

# Normalize all specs
find specs -name "*.json" -exec unispec normalize {} --backup \;

# Convert all to YAML
for file in specs/*.json; do
  unispec convert "$file" --format yaml --output "${file%.json}.yaml"
done

# Check for changes
unispec diff specs/v1/api.json specs/v2/api.json --format summary

API Reference

Programmatic Usage

You can also use the CLI programmatically:

import { validateCommand, normalizeCommand, diffCommand, convertCommand } from '@unispechq/unispec-cli';

// Commands are Commander.js instances
// Use them in your own CLI tools

Error Handling

The CLI provides clear error messages and appropriate exit codes:

  • Validation Errors - Detailed schema violations with paths and line numbers
  • File System Errors - Clear messages for missing files or permission issues
  • Format Errors - Helpful messages for invalid JSON/YAML syntax

All errors include:

  • Clear description
  • File path (when applicable)
  • Line/column numbers (when available)
  • Suggestions for resolution

Contributing

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

Development Setup

# Clone the repository
git clone https://github.com/unispechq/unispec-platform.git
cd unispec-platform

# Install dependencies
npm install

# Run tests
npm test

# Build the project
npm run build

# Run in development mode
npm run dev -- validate test-spec.json

License

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

Support

Related Projects


Made with ❤️ by the UniSpec team