Move code platform definition to config#97
Conversation
Add functions to define API URLs and ribbon values based on config-defined platform
There was a problem hiding this comment.
Pull request overview
Adds a PLATFORM configuration key (currently only github accepted) and centralizes platform-specific API URLs and ribbon display data into two new modules (src/defineApiUrls.js, src/defineRibbonVals.js). The hard-coded GitHub URLs in main.js, scripts/fetch-releases.js, and scripts/export-tags.js are routed through these helpers, and the index.html ribbon is parameterized to swap icon/name/link based on the selected platform. This is foundational work toward Codeberg/GitLab support (issue #96), with those branches stubbed out as commented-out entries.
Changes:
- Introduce
PLATFORMconfig key with validation, README docs, and config.yaml default. - Add
getPlatformApiUrlsandgetPlatformDisplayhelpers and wire them intomain.js, both scripts, and the ribbon markup. - Generalize GitHub-specific UI text, IDs, and comments to platform-agnostic equivalents.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/defineApiUrls.js | New helper returning org/repo URLs per platform |
| src/defineRibbonVals.js | New helper returning ribbon SVG path / name / color per platform |
| src/validateConfig.js | Validate presence and allowlist of PLATFORM |
| tests/validateConfig.test.js | New tests for missing/unrecognized PLATFORM |
| main.js | Use platform helpers; rename GitHub ribbon → repo ribbon; assign module-scope URLs |
| scripts/fetch-releases.js | Replace hard-coded URLs with getPlatformApiUrls |
| scripts/export-tags.js | Same, plus log messages parameterized (incorrect import path) |
| index.html | Generalize ribbon element IDs and inject icon/name at runtime |
| public/config.yaml | Add PLATFORM: github with explanatory comments |
| README.md | Document the new PLATFORM config key |
Comments suppressed due to low confidence (1)
main.js:718
getPlatformApiUrls(PLATFORM, ORGANIZATION_NAME)is invoked twice in successive lines, each time rebuilding the platform-URLs object. Call it once and destructure (e.g.,const { org, repo } = getPlatformApiUrls(...)) for clarity and a small efficiency gain — also matches the destructuring pattern used inscripts/fetch-releases.jsandscripts/export-tags.js.
ORG_API_URL = getPlatformApiUrls(PLATFORM, ORGANIZATION_NAME).org;
REPO_API_URL = getPlatformApiUrls(PLATFORM, ORGANIZATION_NAME).repo;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Paginate through all public repos (Platform determines API max returns per page) | ||
| let allRepos = []; | ||
| let nextUrl = `https://api.github.com/orgs/${ORGANIZATION_NAME}/repos?type=public&per_page=100`; | ||
| let nextUrl = `${ORG_API_URL}`; |
|
@EmersonFras, I removed the redundant tests and reformatted the |
Tested it out everything LGTM! |
Add functions to define API URLs and ribbon values based on config-defined platform.
This is a first step toward #96. The support for other platforms is being added because this is a re-usable template. Once the configs are set, they won't be changed for that implementation. As such, it's easiest for downstream users if we keep required changes in a single file. We don't want to introduce more if statements than necessary because there will be a fixed implementation each time it's used.