Skip to content

build(aircraft): validate the configs before publishing them - #16

Draft
nabeelio wants to merge 1 commit into
mainfrom
feat/validate-aircraft-configs
Draft

build(aircraft): validate the configs before publishing them#16
nabeelio wants to merge 1 commit into
mainfrom
feat/validate-aircraft-configs

Conversation

@nabeelio

Copy link
Copy Markdown
Member

Aircraft configs used to be TypeScript classes, so the compiler caught a typo'd feature name or a missing field. As JSON they have nothing in front of them, and a broken document publishes to every VA and then fails quietly - the client skips a feature key it doesn't recognise and logs a warning nobody reads.

  • The check lives in the bundle task rather than behind a test runner. This repo has none, and adding vitest plus config to validate 36 JSON files is a lot of machinery for something the build already walks. CI runs npm run build, so a bad document now fails there instead of shipping.
  • Validates meta's required fields, that sim is one the client understands, that meta.id is unique across documents, that match is an array, and that every features/disabled key exists in this repo's AircraftFeature enum. Problems are collected rather than thrown one at a time, so one build reports all of them.
  • The vocabulary is parsed out of defs.ts instead of imported, because the gulpfile runs before any TypeScript is compiled and defs.js is a build artifact that can lag its source. Parsing zero members throws rather than returning an empty set, which would quietly turn every check into a no-op.
  • Restores coverage that moving the library here removed. The plugin's corpus.test.ts used to validate all 35 documents against the engine on every CI run; it now guards the four examples that stayed behind, and nothing was checking these.

Verified against the real corpus: a clean build passes all 36, and each failure mode was injected and confirmed to fail the build with the offending file named - typo'd feature key, unknown sim, missing meta.author, duplicate meta.id, non-array match, non-object disabled.

These documents used to be TypeScript classes, so the compiler caught a
typo'd feature name or a missing field. As JSON they have nothing in
front of them, and this repo has no test runner, so a broken document
would publish to every VA and then fail quietly: the client skips a
feature key it does not recognise and logs a warning nobody reads.

The bundle task already parses all 36 documents and CI already runs the
build, so the check goes there rather than behind a new test runner and
its dependencies. A bad document now fails the build instead of shipping.

Checks meta's required fields, that sim is one the client understands,
that ids are unique, that match is an array, and that every features and
disabled key exists in this repo's AircraftFeature enum. Problems are
collected so one build reports all of them.

The vocabulary is parsed out of defs.ts rather than imported, because the
gulpfile runs before any TypeScript is compiled and defs.js is an
artifact that can lag its source. Parsing zero members throws instead of
returning an empty set, which would turn every check into a no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant