package-version-info 0.1.0 β†’ 0.2.1

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/README.md CHANGED
@@ -1,121 +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
50
+ npx package-version-info --output src/version-info.ts
51
+ ```
33
52
 
34
- # Show version
35
- npx package-version-info --version
53
+ ```text
54
+ βœ… Generated src/version-info.ts (v1.0.0, 2.00ms)
55
+ ```
36
56
 
37
- # Custom paths (.git is the default Git directory)
38
- npx package-version-info --input package.json --output src/version-info.ts --git ../.git
57
+ ### 3. Import it
39
58
 
40
- # Short options
41
- npx package-version-info -i package.json -o src/version-info.ts -g ../.git
42
- ```
59
+ ```typescript
60
+ import { VERSION_INFO } from "./version-info";
43
61
 
44
- ### Output Example
62
+ console.log(`Version ${VERSION_INFO.version}`);
63
+ console.log(`Built at ${VERSION_INFO.date}`);
64
+ ```
45
65
 
46
- **Full Output (with author and git):**
66
+ ## πŸ“ Generated output
47
67
 
48
68
  ```typescript
69
+ /**
70
+ * Generated by script 🍺
71
+ * Do not edit manually.
72
+ */
73
+
49
74
  export const VERSION_INFO = {
50
75
  version: "1.0.0",
51
- date: "2025-12-26T16:00:00.000Z",
76
+ date: "2026-07-16T18:53:01.908Z",
52
77
  author: {
53
78
  name: "Dominik HladΓ­k",
54
79
  email: "dominik.hladik@seznam.cz",
55
- url: "https://github.com/Celtian",
80
+ url: "https://github.com/Celtian"
56
81
  },
57
82
  git: {
58
- branch: "master",
59
- commit: "324822ac3893dd6159ab8cb4477d45edeacf11f6",
60
- },
83
+ branch: "main",
84
+ commit: "8be6ca60256cc90e0a41d40b9ee222165f239444"
85
+ }
61
86
  };
62
87
  ```
63
88
 
64
- **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.
65
91
 
66
- ```typescript
67
- export const VERSION_INFO = {
68
- version: "1.0.0",
69
- date: "2025-12-26T16:00:00.000Z",
70
- };
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
71
98
  ```
72
99
 
73
- ## πŸ“– Usage in Your Application
100
+ ### Options
74
101
 
75
- 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. |
76
110
 
77
- ```typescript
78
- import { VERSION_INFO } from "./version-info";
111
+ ### Common examples
79
112
 
80
- console.log(`Version: ${VERSION_INFO.version}`);
81
- console.log(`Build Date: ${VERSION_INFO.date}`);
113
+ ```bash
114
+ # Generate with default paths
115
+ npx package-version-info
82
116
 
83
- if (VERSION_INFO.author) {
84
- console.log(`Author: ${VERSION_INFO.author.name}`);
85
- console.log(`Email: ${VERSION_INFO.author.email}`);
86
- console.log(`URL: ${VERSION_INFO.author.url}`);
87
- }
117
+ # Show detailed progress
118
+ npx package-version-info --verbose
88
119
 
89
- if (VERSION_INFO.git) {
90
- console.log(`Branch: ${VERSION_INFO.git.branch}`);
91
- console.log(`Commit: ${VERSION_INFO.git.commit}`);
92
- }
93
- ```
120
+ # Use custom paths
121
+ npx package-version-info \
122
+ --input package.json \
123
+ --output src/generated/version-info.ts \
124
+ --git .git
94
125
 
95
- ## πŸ”§ 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
+ ```
96
132
 
97
- | Option | Alias | Default | Description |
98
- | ----------- | ----- | ----------------- | ------------------------------ |
99
- | `--version` | `-v` | - | Display version information |
100
- | `--input` | `-i` | `package.json` | Path to package.json file |
101
- | `--output` | `-o` | `version-info.ts` | Path to output TypeScript file |
133
+ ## 🎨 Compact and verbose logging
102
134
 
103
- ## πŸ› οΈ Integration with Build Tools
135
+ Compact mode is designed for normal builds:
104
136
 
105
- ### NPM Scripts
137
+ ```text
138
+ βœ… Generated src/version-info.ts (v1.0.0, 2.00ms)
139
+ ```
106
140
 
107
- Add to your `package.json`:
141
+ Use verbose mode when diagnosing package, author, timestamp, Git, or output-path behavior:
108
142
 
109
- ```json
110
- {
111
- "scripts": {
112
- "prebuild": "package-version-info",
113
- "build": "your-build-command"
114
- }
115
- }
143
+ ```bash
144
+ npx package-version-info --verbose
116
145
  ```
117
146
 
118
- ### With TypeScript Projects
147
+ ## πŸ› οΈ Build-tool integration
148
+
149
+ Generate version information automatically before your application build:
119
150
 
120
151
  ```json
121
152
  {
@@ -127,50 +158,46 @@ Add to your `package.json`:
127
158
  }
128
159
  ```
129
160
 
130
- ## πŸ—οΈ Development
131
-
132
- 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.
133
163
 
134
- ### Prerequisites
164
+ ## πŸ—οΈ Development
135
165
 
136
- - [Zig](https://ziglang.org/) >= 0.15.2
166
+ Requirements:
137
167
 
138
- ### Build Commands
168
+ - [Zig 0.16.0](https://ziglang.org/download/)
169
+ - Node.js 24
170
+ - Yarn 1.22.22
139
171
 
140
172
  ```bash
141
173
  # Build the executable
142
174
  zig build
143
175
 
144
- # Run the executable
176
+ # Run the CLI
145
177
  zig build run
146
178
 
147
- # Run with arguments
148
- zig build run -- --input package.json --output version-info.ts --git .git
149
-
150
- # Run tests
151
- zig build test
152
-
153
- # Clean build artifacts
154
- rm -rf zig-cache zig-out
179
+ # Run all formatting, build, and test checks
180
+ yarn validate
155
181
  ```
156
182
 
157
- ## 🎯 Why Zig?
158
-
159
- - **Performance**: Compiled binary with minimal overhead
160
- - **Size**: Small executable footprint
161
- - **Cross-platform**: Easy to build for multiple platforms
162
- - **Memory Safety**: No runtime exceptions or undefined behavior
183
+ <details>
184
+ <summary><strong>Regenerate the terminal demo</strong></summary>
163
185
 
164
- ## πŸ“¦ 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:
165
189
 
166
- _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
+ ```
167
194
 
168
- ## 🀝 Contributing
195
+ </details>
169
196
 
170
- 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.
171
198
 
172
- ## πŸͺͺ License
199
+ ## πŸ“„ License
173
200
 
174
- Copyright &copy; 2025 - 2026 [Dominik Hladik](https://github.com/Celtian)
201
+ Copyright &copy; 2025–2026 [Dominik HladΓ­k](https://github.com/Celtian).
175
202
 
176
- 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.1.0",
3
+ "version": "0.2.1",
4
4
  "author": {
5
5
  "name": "Dominik HladΓ­k",
6
6
  "email": "dominik.hladik@seznam.cz",
@@ -36,5 +36,6 @@
36
36
  ],
37
37
  "publishConfig": {
38
38
  "registry": "https://registry.npmjs.org"
39
- }
39
+ },
40
+ "dependencies": {}
40
41
  }