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.
- π 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
npm install package-version-info --save-dev
# or
yarn add package-version-info --dev# 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.tsFull 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: "dominik.hladik@seznam.cz",
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",
};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}`);
}| 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 |
Add to your package.json:
{
"scripts": {
"prebuild": "package-version-info",
"build": "your-build-command"
}
}{
"scripts": {
"version-info": "package-version-info --output src/version-info.ts",
"prebuild": "npm run version-info",
"build": "tsc"
}
}This project is written in Zig. To build from source:
- Zig >= 0.15.2
# 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- 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
None - This is a standalone binary with zero runtime dependencies.
Contributions are welcome! Please feel free to submit a Pull Request.
Copyright Β© 2025 Dominik Hladik
All contents are licensed under the MIT license.