package-version-info 0.0.2 β 0.0.4
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 +165 -5
- package/bin/version_info +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,173 @@
|
|
|
1
|
-
|
|
1
|
+
# Package Version Info
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/package-version-info)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
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.
|
|
7
|
+
|
|
8
|
+
## β¨ Features
|
|
9
|
+
|
|
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
|
|
17
|
+
|
|
18
|
+
## π Quick Start
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install package-version-info --save-dev
|
|
24
|
+
# or
|
|
25
|
+
yarn add package-version-info --dev
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Usage
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Generate version-info.ts from package.json
|
|
32
|
+
npx package-version-info
|
|
33
|
+
|
|
34
|
+
# Show version
|
|
35
|
+
npx package-version-info --version
|
|
36
|
+
|
|
37
|
+
# Custom paths
|
|
38
|
+
npx package-version-info --input package.json --output src/version-info.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Output Example
|
|
42
|
+
|
|
43
|
+
**Full Output (with author and git):**
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
export const VERSION_INFO = {
|
|
47
|
+
version: "1.0.0",
|
|
48
|
+
date: "2025-12-26T16:00:00.000Z",
|
|
49
|
+
author: {
|
|
50
|
+
name: "Dominik HladΓk",
|
|
51
|
+
email: "dominik.hladik@seznam.cz",
|
|
52
|
+
url: "https://github.com/Celtian",
|
|
53
|
+
},
|
|
54
|
+
git: {
|
|
55
|
+
branch: "master",
|
|
56
|
+
commit: "324822ac3893dd6159ab8cb4477d45edeacf11f6",
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Minimal Output (without author and git):**
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
export const VERSION_INFO = {
|
|
65
|
+
version: "1.0.0",
|
|
66
|
+
date: "2025-12-26T16:00:00.000Z",
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## π Usage in Your Application
|
|
71
|
+
|
|
72
|
+
Once generated, import and use the version info in your application:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { VERSION_INFO } from "./version-info";
|
|
76
|
+
|
|
77
|
+
console.log(`Version: ${VERSION_INFO.version}`);
|
|
78
|
+
console.log(`Build Date: ${VERSION_INFO.date}`);
|
|
79
|
+
|
|
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
|
+
}
|
|
85
|
+
|
|
86
|
+
if (VERSION_INFO.git) {
|
|
87
|
+
console.log(`Branch: ${VERSION_INFO.git.branch}`);
|
|
88
|
+
console.log(`Commit: ${VERSION_INFO.git.commit}`);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## π§ CLI Options
|
|
93
|
+
|
|
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 |
|
|
99
|
+
|
|
100
|
+
## π οΈ Integration with Build Tools
|
|
101
|
+
|
|
102
|
+
### NPM Scripts
|
|
103
|
+
|
|
104
|
+
Add to your `package.json`:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"scripts": {
|
|
109
|
+
"prebuild": "package-version-info",
|
|
110
|
+
"build": "your-build-command"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### With TypeScript Projects
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"scripts": {
|
|
120
|
+
"version-info": "package-version-info --output src/version-info.ts",
|
|
121
|
+
"prebuild": "npm run version-info",
|
|
122
|
+
"build": "tsc"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## ποΈ Development
|
|
128
|
+
|
|
129
|
+
This project is written in Zig. To build from source:
|
|
130
|
+
|
|
131
|
+
### Prerequisites
|
|
132
|
+
|
|
133
|
+
- [Zig](https://ziglang.org/) >= 0.15.2
|
|
134
|
+
|
|
135
|
+
### Build Commands
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Build the executable
|
|
139
|
+
zig build
|
|
140
|
+
|
|
141
|
+
# Run the executable
|
|
142
|
+
zig build run
|
|
143
|
+
|
|
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
|
|
152
|
+
```
|
|
153
|
+
|
|
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
|
|
2
160
|
|
|
3
161
|
## π¦ Dependencies
|
|
4
162
|
|
|
5
|
-
_None_
|
|
163
|
+
_None_ - This is a standalone binary with zero runtime dependencies.
|
|
164
|
+
|
|
165
|
+
## π€ Contributing
|
|
166
|
+
|
|
167
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
6
168
|
|
|
7
169
|
## πͺͺ License
|
|
8
170
|
|
|
9
171
|
Copyright © 2025 [Dominik Hladik](https://github.com/Celtian)
|
|
10
172
|
|
|
11
|
-
All contents are licensed under the [MIT license].
|
|
12
|
-
|
|
13
|
-
[mit license]: LICENSE
|
|
173
|
+
All contents are licensed under the [MIT license](LICENSE).
|
package/bin/version_info
CHANGED
|
Binary file
|