diff --git a/src/manifest/package.json b/src/manifest/package.json index 1fdeb485..eb511daa 100644 --- a/src/manifest/package.json +++ b/src/manifest/package.json @@ -1,7 +1,7 @@ { "name": "@neon-rs/manifest", "private": false, - "version": "0.1.2", + "version": "0.1.3", "description": "Library for working with Neon package configuration.", "exports": { ".": { diff --git a/src/manifest/src/platform.cts b/src/manifest/src/platform.cts index 7f31f9d0..ab0ff1ea 100644 --- a/src/manifest/src/platform.cts +++ b/src/manifest/src/platform.cts @@ -34,6 +34,14 @@ export function isPlatformPreset(x: unknown): x is PlatformPreset { return (typeof x === 'string') && (x in PRESET); } +export type PlatformName = NodePlatform | PlatformPreset; + +export function assertIsPlatformName(x: unknown): asserts x is PlatformName { + if (!isPlatformPreset(x) && !isNodePlatform(x)) { + throw new RangeError(`invalid platform name: ${x}`); + } +} + export function assertIsPlatformPreset(x: unknown): asserts x is PlatformPreset { if (!isPlatformPreset(x)) { throw new RangeError(`invalid platform family preset: ${x}`); @@ -55,13 +63,13 @@ export function assertIsPlatformMap(json: unknown, path: string): asserts json i export function assertIsPlatformFamily(json: unknown, path: string): asserts json is PlatformFamily { if (typeof json === 'string') { - assertIsPlatformPreset(json); + assertIsPlatformName(json); return; } if (Array.isArray(json)) { for (const elt of json) { - assertIsPlatformPreset(elt); + assertIsPlatformName(elt); } return; } @@ -71,7 +79,6 @@ export function assertIsPlatformFamily(json: unknown, path: string): asserts jso export type TargetPair = { node: NodePlatform, rust: RustTarget }; export type PlatformMap = { [key in NodePlatform]?: RustTarget }; -export type PlatformName = NodePlatform | PlatformPreset; export type PlatformFamily = PlatformName