minecraft-version-validator 1.0.0 → 1.0.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/CLAUDE.md +80 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Development Commands
|
|
6
|
+
|
|
7
|
+
### Essential Commands
|
|
8
|
+
- `npm run build` - Compile TypeScript to JavaScript in `dist/`
|
|
9
|
+
- `npm test` - Run all tests using Vitest
|
|
10
|
+
- `npm run dev` - Run tests in watch mode for development
|
|
11
|
+
- `npm run generate-versions` - Regenerate the version Set from Minecraft manifest data
|
|
12
|
+
- `npm run prepack` - Build before packaging (runs automatically)
|
|
13
|
+
|
|
14
|
+
### Testing
|
|
15
|
+
- Run all tests: `npm test`
|
|
16
|
+
- Watch mode: `npm run dev`
|
|
17
|
+
- Test specific patterns: `npm test -- --run "pattern"`
|
|
18
|
+
|
|
19
|
+
## Architecture Overview
|
|
20
|
+
|
|
21
|
+
This is a TypeScript library that validates Minecraft version strings using a **hybrid validation strategy**:
|
|
22
|
+
|
|
23
|
+
1. **Pre-computed Set Lookup** - O(1) validation for known versions stored in `src/version-set.ts`
|
|
24
|
+
2. **Regex Pattern Matching** - Future-proof validation for upcoming version formats
|
|
25
|
+
|
|
26
|
+
### Core Components
|
|
27
|
+
|
|
28
|
+
**`src/index.ts`** - Main entry point exposing `isValidMinecraftVersion(version: string): boolean`
|
|
29
|
+
- First checks if version exists in the pre-computed Set (fast path)
|
|
30
|
+
- Falls back to regex patterns for unknown versions
|
|
31
|
+
- Handles input validation and edge cases
|
|
32
|
+
|
|
33
|
+
**`src/version-set.ts`** - Auto-generated Set containing all known Minecraft versions
|
|
34
|
+
- Contains ~860 versions from classic (`c0.30_01c`) to modern (`1.21.11-pre5`)
|
|
35
|
+
- Generated from official Minecraft version manifest
|
|
36
|
+
- DO NOT edit manually - use `npm run generate-versions`
|
|
37
|
+
|
|
38
|
+
**`scripts/generate-version-set.ts`** - Utility to refresh version data
|
|
39
|
+
- Fetches from `test/version_manifest_copy.json`
|
|
40
|
+
- Creates TypeScript Set with all version IDs
|
|
41
|
+
- Updates timestamp in generated code
|
|
42
|
+
|
|
43
|
+
### Version Format Support
|
|
44
|
+
|
|
45
|
+
The library validates comprehensive Minecraft version formats:
|
|
46
|
+
- Modern releases: `1.21.10`, `1.21.9`
|
|
47
|
+
- Pre-releases: `1.21.11-pre5`, `1.21.9-pre4`
|
|
48
|
+
- Release candidates: `1.21.10-rc1`
|
|
49
|
+
- Snapshots: `25w46a`, `25w14craftmine`
|
|
50
|
+
- Legacy formats: `a1.2.6`, `b1.8.1`, `rd-20090515`
|
|
51
|
+
- Future year-based: `26.1`, `26.1-snapshot-1`, `26.1-pre-1`
|
|
52
|
+
|
|
53
|
+
### Key Patterns
|
|
54
|
+
|
|
55
|
+
**Future-proof regex**: `/^[2-5]\d\.\d{1,2}(?:\.\d{1,2})?(?:-(?:snapshot|pre|rc)-[1-9]\d{0,2})?$/`
|
|
56
|
+
- Supports year-based formats through 59xx
|
|
57
|
+
- Handles optional hotfix versions and pre-release suffixes
|
|
58
|
+
|
|
59
|
+
**Performance optimization**: Set lookup provides O(1) validation for known versions, ensuring fast validation for the common case.
|
|
60
|
+
|
|
61
|
+
## Build and CI/CD
|
|
62
|
+
|
|
63
|
+
**TypeScript Configuration**: Targets ES2022 with strict mode enabled, using modern module resolution.
|
|
64
|
+
|
|
65
|
+
**Testing**: Uses Vitest with comprehensive coverage including:
|
|
66
|
+
- All supported version formats with real examples
|
|
67
|
+
- 200+ invalid version formats for proper rejection
|
|
68
|
+
- Type safety validation for non-string inputs
|
|
69
|
+
|
|
70
|
+
**CI/CD**:
|
|
71
|
+
- Tests on Node.js 18.x, 20.x, 22.x, and 24.x
|
|
72
|
+
- Automated npm publishing with manual workflow trigger
|
|
73
|
+
- Version bumping and Git tagging in publish pipeline
|
|
74
|
+
|
|
75
|
+
## Development Notes
|
|
76
|
+
|
|
77
|
+
- The version Set is auto-generated - never edit `src/version-set.ts` manually
|
|
78
|
+
- When adding new version support, update the regex patterns in `src/index.ts`
|
|
79
|
+
- Test coverage is comprehensive - new formats should include both valid and invalid test cases
|
|
80
|
+
- The library has zero runtime dependencies for minimal bundle size
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAqBhE"}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,10 @@ export function isValidMinecraftVersion(version) {
|
|
|
16
16
|
}
|
|
17
17
|
// Fallback to patterns for future versions not in the manifest
|
|
18
18
|
const futurePatterns = [
|
|
19
|
-
//
|
|
19
|
+
// Standard semantic versioning format (future compatibility)
|
|
20
|
+
// Examples: 1.21.11, 1.22.0, 1.22.1, 1.21.11-pre1, 1.21.11-rc1
|
|
21
|
+
/^1\.\d{1,2}\.\d{1,2}(?:-(?:pre|rc)[1-9]\d{0,2})?$/,
|
|
22
|
+
// New year-based format (future compatibility that started in 2026)
|
|
20
23
|
// Examples: 26.1, 26.1.1, 26.1-snapshot-1, 26.1-pre-1, 26.1-rc-1
|
|
21
24
|
/^[2-5]\d\.\d{1,2}(?:\.\d{1,2})?(?:-(?:snapshot|pre|rc)-[1-9]\d{0,2})?$/
|
|
22
25
|
];
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2DAA2D;IAC3D,IAAI,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+DAA+D;IAC/D,MAAM,cAAc,GAAG;QACrB,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2DAA2D;IAC3D,IAAI,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+DAA+D;IAC/D,MAAM,cAAc,GAAG;QACrB,6DAA6D;QAC7D,+DAA+D;QAC/D,mDAAmD;QACnD,oEAAoE;QACpE,iEAAiE;QACjE,wEAAwE;KACzE,CAAC;IAEF,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecraft-version-validator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A TypeScript library to validate Minecraft version strings",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
"generate-versions": "npx tsx scripts/generate-version-set.ts",
|
|
12
12
|
"prepack": "npm run build"
|
|
13
13
|
},
|
|
14
|
-
"keywords": [
|
|
14
|
+
"keywords": [
|
|
15
|
+
"minecraft",
|
|
16
|
+
"version",
|
|
17
|
+
"validator",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
15
20
|
"author": "Kaf",
|
|
16
21
|
"license": "MIT",
|
|
17
22
|
"type": "module",
|