package-version-info 0.0.6 β†’ 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Celtian
3
+ Copyright (c) 2025 - 2026 Celtian
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,118 +1,152 @@
1
- # Package Version Info
1
+ <div align="center">
2
2
 
3
- [![npm version](https://badge.fury.io/js/package-version-info.svg)](https://badge.fury.io/js/package-version-info)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ # πŸ“¦ Package Version Info
5
4
 
6
- 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.
5
+ **Generate a TypeScript build-info constant from `package.json` and Git in milliseconds.**
7
6
 
8
- ## ✨ Features
7
+ [![npm version](https://badge.fury.io/js/package-version-info.svg)](https://www.npmjs.com/package/package-version-info)
8
+ [![Test PR](https://github.com/Celtian/package-version-info/actions/workflows/pull-request.yml/badge.svg)](https://github.com/Celtian/package-version-info/actions/workflows/pull-request.yml)
9
+ [![Zig 0.16.0](https://img.shields.io/badge/Zig-0.16.0-F7A41D?logo=zig&logoColor=white)](https://ziglang.org/)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
11
 
10
- - πŸš€ **Fast**: Written in Zig for maximum performance
11
- - πŸ“¦ **Zero Dependencies**: No runtime dependencies required
12
- - πŸ‘€ **Author Information**: Extracts author details from package.json
13
- - 🌿 **Git Integration**: Automatically extracts branch and commit information
14
- - ⚑ **TypeScript Output**: Generates type-safe TypeScript constants
15
- - 🎯 **Graceful Degradation**: Works with or without a git repository or author info
16
- - πŸ”§ **Configurable**: Customize input and output paths
12
+ <img
13
+ src="https://raw.githubusercontent.com/Celtian/package-version-info/master/docs/assets/terminal-demo.gif"
14
+ alt="Package Version Info terminal demo"
15
+ width="900"
16
+ />
17
17
 
18
- ## πŸš€ Quick Start
18
+ </div>
19
19
 
20
- ### Installation
20
+ `package-version-info` is a fast native CLI for embedding your package version, build date,
21
+ author, Git branch, and commit into TypeScript applications. It has no runtime dependencies and
22
+ gracefully omits optional metadata when it is unavailable.
23
+
24
+ ## ✨ Why use it?
25
+
26
+ | Feature | Details |
27
+ | --- | --- |
28
+ | ⚑ **Fast native executable** | Built with Zig and starts without a JavaScript runtime. |
29
+ | πŸ“¦ **Zero runtime dependencies** | Installs as a standalone executable for your platform. |
30
+ | 🧩 **TypeScript-ready output** | Generates a directly importable `VERSION_INFO` constant. |
31
+ | 🌿 **Optional Git metadata** | Reads loose refs, packed refs, and detached HEAD states. |
32
+ | πŸ‘€ **Package author metadata** | Includes author name, email, and URL when available. |
33
+ | 🧘 **Quiet by default** | Prints one compact result line, with `--verbose` when you need details. |
34
+
35
+ ## πŸš€ Quick start
36
+
37
+ ### 1. Install
21
38
 
22
39
  ```bash
23
40
  npm install package-version-info --save-dev
24
- # or
41
+ ```
42
+
43
+ ```bash
25
44
  yarn add package-version-info --dev
26
45
  ```
27
46
 
28
- ### Usage
47
+ ### 2. Generate the file
29
48
 
30
49
  ```bash
31
- # Generate version-info.ts from package.json
32
- npx package-version-info
33
-
34
- # Show version
35
- npx package-version-info --version
50
+ npx package-version-info --output src/version-info.ts
51
+ ```
36
52
 
37
- # Custom paths
38
- npx package-version-info --input package.json --output src/version-info.ts
53
+ ```text
54
+ βœ… Generated src/version-info.ts (v1.0.0, 2ms)
39
55
  ```
40
56
 
41
- ### Output Example
57
+ ### 3. Import it
58
+
59
+ ```typescript
60
+ import { VERSION_INFO } from "./version-info";
61
+
62
+ console.log(`Version ${VERSION_INFO.version}`);
63
+ console.log(`Built at ${VERSION_INFO.date}`);
64
+ ```
42
65
 
43
- **Full Output (with author and git):**
66
+ ## πŸ“ Generated output
44
67
 
45
68
  ```typescript
69
+ /**
70
+ * Generated by script 🍺
71
+ * Do not edit manually.
72
+ */
73
+
46
74
  export const VERSION_INFO = {
47
75
  version: "1.0.0",
48
- date: "2025-12-26T16:00:00.000Z",
76
+ date: "2026-07-16T18:53:01.908Z",
49
77
  author: {
50
78
  name: "Dominik HladΓ­k",
51
79
  email: "dominik.hladik@seznam.cz",
52
- url: "https://github.com/Celtian",
80
+ url: "https://github.com/Celtian"
53
81
  },
54
82
  git: {
55
- branch: "master",
56
- commit: "324822ac3893dd6159ab8cb4477d45edeacf11f6",
57
- },
83
+ branch: "main",
84
+ commit: "8be6ca60256cc90e0a41d40b9ee222165f239444"
85
+ }
58
86
  };
59
87
  ```
60
88
 
61
- **Minimal Output (without author and git):**
89
+ The `author` property is omitted when `package.json` has no object-style author metadata. The
90
+ `git` property is omitted when the configured Git directory or ref cannot be resolved.
62
91
 
63
- ```typescript
64
- export const VERSION_INFO = {
65
- version: "1.0.0",
66
- date: "2025-12-26T16:00:00.000Z",
67
- };
92
+ ## 🧭 CLI reference
93
+
94
+ Running the CLI without arguments generates `version-info.ts` from `package.json`:
95
+
96
+ ```bash
97
+ npx package-version-info
68
98
  ```
69
99
 
70
- ## πŸ“– Usage in Your Application
100
+ ### Options
71
101
 
72
- Once generated, import and use the version info in your application:
102
+ | Option | Alias | Default | Description |
103
+ | --- | --- | --- | --- |
104
+ | `--help` | `-h` | β€” | Display usage information. |
105
+ | `--version` | `-v` | β€” | Display the installed package version. |
106
+ | `--verbose` | β€” | Disabled | Display detailed generation progress. |
107
+ | `--input <path>` | `-i` | `package.json` | Input package file. |
108
+ | `--output <path>` | `-o` | `version-info.ts` | Generated TypeScript file. |
109
+ | `--git <path>` | `-g` | `.git` | Git directory used for branch and commit metadata. |
73
110
 
74
- ```typescript
75
- import { VERSION_INFO } from "./version-info";
111
+ ### Common examples
76
112
 
77
- console.log(`Version: ${VERSION_INFO.version}`);
78
- console.log(`Build Date: ${VERSION_INFO.date}`);
113
+ ```bash
114
+ # Generate with default paths
115
+ npx package-version-info
79
116
 
80
- if (VERSION_INFO.author) {
81
- console.log(`Author: ${VERSION_INFO.author.name}`);
82
- console.log(`Email: ${VERSION_INFO.author.email}`);
83
- console.log(`URL: ${VERSION_INFO.author.url}`);
84
- }
117
+ # Show detailed progress
118
+ npx package-version-info --verbose
85
119
 
86
- if (VERSION_INFO.git) {
87
- console.log(`Branch: ${VERSION_INFO.git.branch}`);
88
- console.log(`Commit: ${VERSION_INFO.git.commit}`);
89
- }
90
- ```
120
+ # Use custom paths
121
+ npx package-version-info \
122
+ --input package.json \
123
+ --output src/generated/version-info.ts \
124
+ --git .git
91
125
 
92
- ## πŸ”§ CLI Options
126
+ # Short aliases
127
+ npx package-version-info \
128
+ -i package.json \
129
+ -o src/generated/version-info.ts \
130
+ -g .git
131
+ ```
93
132
 
94
- | Option | Alias | Default | Description |
95
- | ----------- | ----- | ----------------- | ------------------------------ |
96
- | `--version` | `-v` | - | Display version information |
97
- | `--input` | `-i` | `package.json` | Path to package.json file |
98
- | `--output` | `-o` | `version-info.ts` | Path to output TypeScript file |
133
+ ## 🎨 Compact and verbose logging
99
134
 
100
- ## πŸ› οΈ Integration with Build Tools
135
+ Compact mode is designed for normal builds:
101
136
 
102
- ### NPM Scripts
137
+ ```text
138
+ βœ… Generated src/version-info.ts (v1.0.0, 2ms)
139
+ ```
103
140
 
104
- Add to your `package.json`:
141
+ Use verbose mode when diagnosing package, author, timestamp, Git, or output-path behavior:
105
142
 
106
- ```json
107
- {
108
- "scripts": {
109
- "prebuild": "package-version-info",
110
- "build": "your-build-command"
111
- }
112
- }
143
+ ```bash
144
+ npx package-version-info --verbose
113
145
  ```
114
146
 
115
- ### With TypeScript Projects
147
+ ## πŸ› οΈ Build-tool integration
148
+
149
+ Generate version information automatically before your application build:
116
150
 
117
151
  ```json
118
152
  {
@@ -124,50 +158,46 @@ Add to your `package.json`:
124
158
  }
125
159
  ```
126
160
 
127
- ## πŸ—οΈ Development
128
-
129
- This project is written in Zig. To build from source:
161
+ The generated file is regular TypeScript, so the same approach works with Angular, React, Vue,
162
+ Vite, Node.js, and other TypeScript-based build systems.
130
163
 
131
- ### Prerequisites
164
+ ## πŸ—οΈ Development
132
165
 
133
- - [Zig](https://ziglang.org/) >= 0.15.2
166
+ Requirements:
134
167
 
135
- ### Build Commands
168
+ - [Zig 0.16.0](https://ziglang.org/download/)
169
+ - Node.js 24
170
+ - Yarn 1.22.22
136
171
 
137
172
  ```bash
138
173
  # Build the executable
139
174
  zig build
140
175
 
141
- # Run the executable
176
+ # Run the CLI
142
177
  zig build run
143
178
 
144
- # Run with arguments
145
- zig build run -- --input package.json --output version-info.ts
146
-
147
- # Run tests
148
- zig build test
149
-
150
- # Clean build artifacts
151
- rm -rf zig-cache zig-out
179
+ # Run all formatting, build, and test checks
180
+ yarn validate
152
181
  ```
153
182
 
154
- ## 🎯 Why Zig?
155
-
156
- - **Performance**: Compiled binary with minimal overhead
157
- - **Size**: Small executable footprint
158
- - **Cross-platform**: Easy to build for multiple platforms
159
- - **Memory Safety**: No runtime exceptions or undefined behavior
183
+ <details>
184
+ <summary><strong>Regenerate the terminal demo</strong></summary>
160
185
 
161
- ## πŸ“¦ Dependencies
186
+ The animation is defined in [`docs/terminal-demo.tape`](docs/terminal-demo.tape) and rendered with
187
+ [VHS](https://github.com/charmbracelet/vhs). The official Docker image includes VHS and its media
188
+ dependencies:
162
189
 
163
- _None_ - This is a standalone binary with zero runtime dependencies.
190
+ ```bash
191
+ zig build
192
+ docker run --rm -v "$PWD:/vhs" ghcr.io/charmbracelet/vhs docs/terminal-demo.tape
193
+ ```
164
194
 
165
- ## 🀝 Contributing
195
+ </details>
166
196
 
167
- Contributions are welcome! Please feel free to submit a Pull Request.
197
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.
168
198
 
169
- ## πŸͺͺ License
199
+ ## πŸ“„ License
170
200
 
171
- Copyright &copy; 2025 [Dominik Hladik](https://github.com/Celtian)
201
+ Copyright &copy; 2025–2026 [Dominik HladΓ­k](https://github.com/Celtian).
172
202
 
173
- All contents are licensed under the [MIT license](LICENSE).
203
+ Licensed under the [MIT License](LICENSE).
package/bin/version_info CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "package-version-info",
3
- "version": "0.0.6",
3
+ "version": "0.2.0",
4
4
  "author": {
5
5
  "name": "Dominik HladΓ­k",
6
6
  "email": "dominik.hladik@seznam.cz",
@@ -20,6 +20,13 @@
20
20
  "bugs": {
21
21
  "url": "https://github.com/Celtian/package-version-info/issues"
22
22
  },
23
+ "auto-changelog": {
24
+ "remote": "none",
25
+ "commitUrl": "https://github.com/Celtian/package-version-info/commit/{id}",
26
+ "issueUrl": "https://github.com/Celtian/package-version-info/issues/{id}",
27
+ "mergeUrl": "https://github.com/Celtian/package-version-info/pull/{id}",
28
+ "compareUrl": "https://github.com/Celtian/package-version-info/compare/{from}...{to}"
29
+ },
23
30
  "keywords": [
24
31
  "version",
25
32
  "info",
@@ -29,5 +36,6 @@
29
36
  ],
30
37
  "publishConfig": {
31
38
  "registry": "https://registry.npmjs.org"
32
- }
39
+ },
40
+ "dependencies": {}
33
41
  }