fix(build): skip redundant AsyncAPI examples fetching when cached - #2285
fix(build): skip redundant AsyncAPI examples fetching when cached#2285RohithPariki wants to merge 1 commit into
Conversation
|
There was a problem hiding this comment.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
|



Problem
During the build process (
npm run build),scripts/fetch-asyncapi-example.jsunconditionally downloaded the examples ZIP file from GitHub, extracted it, and parsed every spec file to generateassets/examples/examples.json.This network operation ran on every single build, causing:
Root Cause
scripts/fetch-asyncapi-example.jsexecuted immediately without verifying whetherassets/examples/examples.jsonand the example YAML specs already existed in the local filesystem.Solution
shouldSkipFetching()check to verify ifassets/examples/examples.jsonexists, is non-empty, and example YAML files are present in the directory.--force,-f, orFORCE_FETCH_EXAMPLES=trueenvironment variable so developers and CI can force re-fetching when needed.test/unit/scripts/fetch-asyncapi-example.test.tscovering all caching conditions, empty files, missing files, and forced overrides.Testing
test/unit/scripts/fetch-asyncapi-example.test.ts(6 passing tests).node scripts/fetch-asyncapi-example.jsskips when examples are present.node scripts/fetch-asyncapi-example.js --forcedownloads fresh examples.npm run buildandnpm run lint.Risk
None. If
examples.jsondoes not exist or is invalid, the script falls back to downloading as before.Checklist
Fixes #2015