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

package-version-info

v0.0.6

Published

Generate version info from package.json for TypeScript projects

Downloads

836

Readme

Package Version Info

npm version License: MIT

A blazingly fast CLI tool written in Zig that generates TypeScript version information files from your package.json. Perfect for embedding version, build date, and git information into your applications.

✨ Features

  • 🚀 Fast: Written in Zig for maximum performance
  • 📦 Zero Dependencies: No runtime dependencies required
  • 👤 Author Information: Extracts author details from package.json
  • 🌿 Git Integration: Automatically extracts branch and commit information
  • TypeScript Output: Generates type-safe TypeScript constants
  • 🎯 Graceful Degradation: Works with or without a git repository or author info
  • 🔧 Configurable: Customize input and output paths

🚀 Quick Start

Installation

npm install package-version-info --save-dev
# or
yarn add package-version-info --dev

Usage

# Generate version-info.ts from package.json
npx package-version-info

# Show version
npx package-version-info --version

# Custom paths
npx package-version-info --input package.json --output src/version-info.ts

Output Example

Full Output (with author and git):

export const VERSION_INFO = {
  version: "1.0.0",
  date: "2025-12-26T16:00:00.000Z",
  author: {
    name: "Dominik Hladík",
    email: "[email protected]",
    url: "https://github.com/Celtian",
  },
  git: {
    branch: "master",
    commit: "324822ac3893dd6159ab8cb4477d45edeacf11f6",
  },
};

Minimal Output (without author and git):

export const VERSION_INFO = {
  version: "1.0.0",
  date: "2025-12-26T16:00:00.000Z",
};

📖 Usage in Your Application

Once generated, import and use the version info in your application:

import { VERSION_INFO } from "./version-info";

console.log(`Version: ${VERSION_INFO.version}`);
console.log(`Build Date: ${VERSION_INFO.date}`);

if (VERSION_INFO.author) {
  console.log(`Author: ${VERSION_INFO.author.name}`);
  console.log(`Email: ${VERSION_INFO.author.email}`);
  console.log(`URL: ${VERSION_INFO.author.url}`);
}

if (VERSION_INFO.git) {
  console.log(`Branch: ${VERSION_INFO.git.branch}`);
  console.log(`Commit: ${VERSION_INFO.git.commit}`);
}

🔧 CLI Options

| Option | Alias | Default | Description | | ----------- | ----- | ----------------- | ------------------------------ | | --version | -v | - | Display version information | | --input | -i | package.json | Path to package.json file | | --output | -o | version-info.ts | Path to output TypeScript file |

🛠️ Integration with Build Tools

NPM Scripts

Add to your package.json:

{
  "scripts": {
    "prebuild": "package-version-info",
    "build": "your-build-command"
  }
}

With TypeScript Projects

{
  "scripts": {
    "version-info": "package-version-info --output src/version-info.ts",
    "prebuild": "npm run version-info",
    "build": "tsc"
  }
}

🏗️ Development

This project is written in Zig. To build from source:

Prerequisites

Build Commands

# Build the executable
zig build

# Run the executable
zig build run

# Run with arguments
zig build run -- --input package.json --output version-info.ts

# Run tests
zig build test

# Clean build artifacts
rm -rf zig-cache zig-out

🎯 Why Zig?

  • Performance: Compiled binary with minimal overhead
  • Size: Small executable footprint
  • Cross-platform: Easy to build for multiple platforms
  • Memory Safety: No runtime exceptions or undefined behavior

📦 Dependencies

None - This is a standalone binary with zero runtime dependencies.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

🪪 License

Copyright © 2025 Dominik Hladik

All contents are licensed under the MIT license.