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 +1 -1
- package/README.md +127 -97
- package/bin/version_info +0 -0
- package/package.json +10 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,118 +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
|
-
|
|
33
|
-
|
|
34
|
-
# Show version
|
|
35
|
-
npx package-version-info --version
|
|
50
|
+
npx package-version-info --output src/version-info.ts
|
|
51
|
+
```
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
```text
|
|
54
|
+
β
Generated src/version-info.ts (v1.0.0, 2ms)
|
|
39
55
|
```
|
|
40
56
|
|
|
41
|
-
###
|
|
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
|
-
|
|
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: "
|
|
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: "
|
|
56
|
-
commit: "
|
|
57
|
-
}
|
|
83
|
+
branch: "main",
|
|
84
|
+
commit: "8be6ca60256cc90e0a41d40b9ee222165f239444"
|
|
85
|
+
}
|
|
58
86
|
};
|
|
59
87
|
```
|
|
60
88
|
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
100
|
+
### Options
|
|
71
101
|
|
|
72
|
-
|
|
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
|
-
|
|
75
|
-
import { VERSION_INFO } from "./version-info";
|
|
111
|
+
### Common examples
|
|
76
112
|
|
|
77
|
-
|
|
78
|
-
|
|
113
|
+
```bash
|
|
114
|
+
# Generate with default paths
|
|
115
|
+
npx package-version-info
|
|
79
116
|
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
+
Compact mode is designed for normal builds:
|
|
101
136
|
|
|
102
|
-
|
|
137
|
+
```text
|
|
138
|
+
β
Generated src/version-info.ts (v1.0.0, 2ms)
|
|
139
|
+
```
|
|
103
140
|
|
|
104
|
-
|
|
141
|
+
Use verbose mode when diagnosing package, author, timestamp, Git, or output-path behavior:
|
|
105
142
|
|
|
106
|
-
```
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
164
|
+
## ποΈ Development
|
|
132
165
|
|
|
133
|
-
|
|
166
|
+
Requirements:
|
|
134
167
|
|
|
135
|
-
|
|
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
|
|
176
|
+
# Run the CLI
|
|
142
177
|
zig build run
|
|
143
178
|
|
|
144
|
-
# Run
|
|
145
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
190
|
+
```bash
|
|
191
|
+
zig build
|
|
192
|
+
docker run --rm -v "$PWD:/vhs" ghcr.io/charmbracelet/vhs docs/terminal-demo.tape
|
|
193
|
+
```
|
|
164
194
|
|
|
165
|
-
|
|
195
|
+
</details>
|
|
166
196
|
|
|
167
|
-
Contributions are welcome
|
|
197
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.
|
|
168
198
|
|
|
169
|
-
##
|
|
199
|
+
## π License
|
|
170
200
|
|
|
171
|
-
Copyright © 2025 [Dominik
|
|
201
|
+
Copyright © 2025β2026 [Dominik HladΓk](https://github.com/Celtian).
|
|
172
202
|
|
|
173
|
-
|
|
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
|
|
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
|
}
|