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

@xonovex/core

v0.1.12

Published

Core library for Xonovex TypeScript scripts (Node.js)

Readme

@xonovex/tool-lib

Core library functions for Xonovex TypeScript scripts running with Node.js.

Overview

This package provides common utilities used across all TypeScript scripts in the Xonovex platform:

  • Colors: ANSI color codes for terminal output
  • Logging: Structured logging with color-coded levels
  • Platform Detection: OS detection and platform-specific commands
  • Error Handling: Graceful error handling and validation
  • Path Utilities: File system navigation and platform root detection

Installation

This package is designed to be imported directly by other script packages in the monorepo workspace.

Usage

import {
  die,
  getPlatformRoot,
  logDebug,
  logError,
  logInfo,
  logSuccess,
  logWarning,
  printSection,
  requireCommand,
} from "@xonovex/tool-lib";

// Logging
logInfo("Starting operation...");
logSuccess("Operation completed!");
logWarning("This is a warning");
logError("An error occurred");
logDebug("Debug information"); // Only shown if DEBUG env var is set

// Sections
printSection("Configuration", "Loading platform configuration...");

// Platform detection
const root = await getPlatformRoot();
logInfo("Platform root:", root);

// Error handling
await requireCommand("git", "git");
die("Fatal error occurred", 1);

API Reference

Logging Functions

  • logInfo(...args) - Log info message (blue)
  • logSuccess(...args) - Log success message (green)
  • logWarning(...args) - Log warning message (yellow)
  • logError(...args) - Log error message (red)
  • logDebug(...args) - Log debug message (purple, only if DEBUG is set)
  • printSection(title, content?) - Print formatted section header
  • printSubsection(title) - Print subsection header
  • checkResult(name, status, details?) - Print check result with color

Platform Detection

  • isMacOS() - Check if running on macOS
  • isLinux() - Check if running on Linux
  • isWindows() - Check if running on Windows
  • getPlatformCommand(macCmd, linuxCmd, winCmd?) - Get OS-specific command
  • getOS() - Get current OS name

Error Handling

  • die(message, exitCode?) - Exit with error message
  • requireCommand(cmd, package?) - Verify command exists
  • requireFile(path, description?) - Verify file exists
  • requireDirectory(path, description?) - Verify directory exists
  • validateInArray(value, array) - Check if value is in array
  • validateBoolean(value, varName) - Validate boolean value
  • validateRepository(repo, platformRoot?) - Validate git repository

Path Utilities

  • getScriptDir(importMeta) - Get script directory path
  • getPlatformRoot(startDir?) - Find platform root directory
  • getGitRoot() - Get git repository root
  • fileExists(path) - Check if file exists
  • dirExists(path) - Check if directory exists
  • getFileMtime(path) - Get file modification time
  • formatTimestamp(date) - Format date for display
  • findClusterDirectory(platformRoot?) - Find cluster directory
  • findInfrastructureDirectory(platformRoot?) - Find infrastructure directory
  • detectAvailableEnvironments(infraDir?) - List available environments

Colors

import {Colors} from "@xonovex/tool-lib";

console.log(`${Colors.GREEN}Success!${Colors.NC}`);
console.log(`${Colors.RED}Error!${Colors.NC}`);

Available colors:

  • RED, GREEN, YELLOW, BLUE, CYAN, PURPLE, NC (no color)

Environment Variables

  • DEBUG - Enable debug logging
  • PLATFORM_ROOT - Override platform root detection

Examples

Simple Script

#!/usr/bin/env node
import {getPlatformRoot, logInfo, logSuccess} from "@xonovex/tool-lib";

async function main() {
  const root = await getPlatformRoot();
  logInfo("Working in:", root);

  // Do something...

  logSuccess("Done!");
}

main();

Script with Error Handling

#!/usr/bin/env node
import {
  die,
  logError,
  logInfo,
  requireCommand,
  requireDirectory,
} from "@xonovex/tool-lib";

async function main() {
  try {
    await requireCommand("git");
    await requireDirectory("./cluster", "cluster directory");

    logInfo("All checks passed!");
  } catch (error) {
    logError("Validation failed:", error);
    die("Cannot continue", 1);
  }
}

main();

Development

# Build
npm run build

# Type check
npm run check

# Format
npm run fmt

# Lint
npm run lint

# Test
npm test