package-version-info 0.1.0 β 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/README.md +126 -99
- package/bin/version_info +0 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,121 +1,152 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
3
|
+
# π¦ Package Version Info
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
**Generate a TypeScript build-info constant from `package.json` and Git in milliseconds.**
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/package-version-info)
|
|
8
|
+
[](https://github.com/Celtian/package-version-info/actions/workflows/pull-request.yml)
|
|
9
|
+
[](https://ziglang.org/)
|
|
10
|
+
[](LICENSE)
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
+
</div>
|
|
19
19
|
|
|
20
|
-
|
|
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
|
-
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```bash
|
|
25
44
|
yarn add package-version-info --dev
|
|
26
45
|
```
|
|
27
46
|
|
|
28
|
-
###
|
|
47
|
+
### 2. Generate the file
|
|
29
48
|
|
|
30
49
|
```bash
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
npx package-version-info --output src/version-info.ts
|
|
51
|
+
```
|
|
33
52
|
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
```text
|
|
54
|
+
β
Generated src/version-info.ts (v1.0.0, 2ms)
|
|
55
|
+
```
|
|
36
56
|
|
|
37
|
-
|
|
38
|
-
npx package-version-info --input package.json --output src/version-info.ts --git ../.git
|
|
57
|
+
### 3. Import it
|
|
39
58
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
59
|
+
```typescript
|
|
60
|
+
import { VERSION_INFO } from "./version-info";
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
console.log(`Version ${VERSION_INFO.version}`);
|
|
63
|
+
console.log(`Built at ${VERSION_INFO.date}`);
|
|
64
|
+
```
|
|
45
65
|
|
|
46
|
-
|
|
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: "
|
|
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: "
|
|
59
|
-
commit: "
|
|
60
|
-
}
|
|
83
|
+
branch: "main",
|
|
84
|
+
commit: "8be6ca60256cc90e0a41d40b9ee222165f239444"
|
|
85
|
+
}
|
|
61
86
|
};
|
|
62
87
|
```
|
|
63
88
|
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
100
|
+
### Options
|
|
74
101
|
|
|
75
|
-
|
|
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
|
-
|
|
78
|
-
import { VERSION_INFO } from "./version-info";
|
|
111
|
+
### Common examples
|
|
79
112
|
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
```bash
|
|
114
|
+
# Generate with default paths
|
|
115
|
+
npx package-version-info
|
|
82
116
|
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
+
Compact mode is designed for normal builds:
|
|
104
136
|
|
|
105
|
-
|
|
137
|
+
```text
|
|
138
|
+
β
Generated src/version-info.ts (v1.0.0, 2ms)
|
|
139
|
+
```
|
|
106
140
|
|
|
107
|
-
|
|
141
|
+
Use verbose mode when diagnosing package, author, timestamp, Git, or output-path behavior:
|
|
108
142
|
|
|
109
|
-
```
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
164
|
+
## ποΈ Development
|
|
135
165
|
|
|
136
|
-
|
|
166
|
+
Requirements:
|
|
137
167
|
|
|
138
|
-
|
|
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
|
|
176
|
+
# Run the CLI
|
|
145
177
|
zig build run
|
|
146
178
|
|
|
147
|
-
# Run
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
190
|
+
```bash
|
|
191
|
+
zig build
|
|
192
|
+
docker run --rm -v "$PWD:/vhs" ghcr.io/charmbracelet/vhs docs/terminal-demo.tape
|
|
193
|
+
```
|
|
167
194
|
|
|
168
|
-
|
|
195
|
+
</details>
|
|
169
196
|
|
|
170
|
-
Contributions are welcome
|
|
197
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.
|
|
171
198
|
|
|
172
|
-
##
|
|
199
|
+
## π License
|
|
173
200
|
|
|
174
|
-
Copyright © 2025
|
|
201
|
+
Copyright © 2025β2026 [Dominik HladΓk](https://github.com/Celtian).
|
|
175
202
|
|
|
176
|
-
|
|
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.
|
|
3
|
+
"version": "0.2.0",
|
|
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
|
}
|