Struct/platform keys - #126
Open
egrace479 wants to merge 6 commits into
Open
Conversation
Reduces platform-specific edits required to token-handling in scripts
fallback defined at UI render
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates code-platform-specific keys and API URL construction into a single utility (src/utils/definePlatformVals.js) to reduce duplication and prepare the codebase for future GitLab support, while updating the runtime app, scripts, and tests to use the new centralized definitions.
Changes:
- Added
getPlatformValsand expandedgetPlatformApiUrls(now includesreleaseSuffix) and updated call sites acrossmain.js, scripts, and API modules. - Refactored
fetchCodeReposto use platform-specific data keys (full name, fork, URL, stars) viagetPlatformVals. - Updated release-fetching logic to use the platform-specific release path suffix and adjusted tests accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/api/fetchCodeRepos.test.js | Updates tests to use centralized platform key/url utilities and validate updated fetchCodeRepos behavior. |
| src/utils/definePlatformVals.js | New consolidated utility for platform-specific repo keys and API URL definitions (plus release suffix). |
| src/utils/defineApiUrls.js | Removed in favor of definePlatformVals.js. |
| src/api/fetchStats.js | Adds releaseSuffix parameter to support platform-specific latest-release endpoints. |
| src/api/fetchCodeRepos.js | Uses getPlatformVals for platform-specific repo fields (stars, full name, fork, URL, profile repo). |
| scripts/fetch-releases.js | Uses centralized platform URL/key definitions and releaseSuffix when fetching latest releases. |
| scripts/export-tags.js | Uses centralized platform URL/key definitions for tag collection. |
| main.js | Switches to definePlatformVals URLs and threads releaseSuffix into fetchCatalogStats. |
Comments suppressed due to low confidence (1)
tests/api/fetchCodeRepos.test.js:110
- The expected
html_urlin this test is currently built fromrepoApiUrl(API base). Update the expectation to match the mocked browser URL value so the test reflects real platform responses.
expect(items[0].html_url).toBe(`${platformConfig.repoApiUrl}test-org/code-repo`);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #123.
Platform-specific, non-UI value fetching functions are now consolidated in
src/utils/definePlatformVals.js. I leftsrc/utils/defineRibbonVals.jsbecause the SVG import is incompatible with the release fetch. This PR preps for GitLab support with all needed keys added into thegetPlatformValsfunction (extracted fromfetchCodeRepos), though the GitLab option is commented out.This update should make it so that someone looking to run their own catalog on another code platform will only need to update the token handling in the scripts (and set the platform in the config).
I used Gemini for help updating the testing setup.