fix: add vendor ids for additional devices

fix: use proper semver parsing for device versions

Fixes #2
This commit is contained in:
2023-11-03 18:24:32 +01:00
parent 88429412b9
commit d2fd84a6b5
4 changed files with 49 additions and 7 deletions

27
src/lib/serial/sem-ver.ts Normal file
View File

@@ -0,0 +1,27 @@
export class SemVer {
major: number
minor: number
patch: number
preRelease?: string
meta?: string
constructor(versionString: string) {
const [, major, minor, patch, preRelease, meta] =
/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+))?$/.exec(
versionString,
)!
this.major = Number.parseInt(major)
this.minor = Number.parseInt(minor)
this.patch = Number.parseInt(patch)
if (preRelease) this.preRelease = preRelease
if (meta) this.meta = meta
}
toString() {
return (
`${this.major}.${this.minor}.${this.patch}` +
(this.preRelease ? `-${this.preRelease}` : "") +
(this.meta ? `+${this.meta}` : "")
)
}
}