From 64552135a39688e81b97d695bb060556cfd3facf Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 24 Sep 2025 23:39:18 -0400 Subject: [PATCH 1/4] fix: Enhance package sync with archived status and UI improvements Adds support for tracking and displaying repository archived status throughout the sync and package generation process. Updates the UI to show an 'Archived' badge, limits displayed releases to the latest 5 per repository, and provides a link to view additional releases. Also ensures only v-prefixed releases are processed and improves metadata handling in the workflow. --- .github/scripts/generate-packages.js | 19 ++++++-- .github/scripts/sync-assets.js | 11 ++++- .github/workflows/sync-release-assets.yml | 18 +++++++- gh-pages-template/assets/js/app.js | 54 +++++++++++++++-------- 4 files changed, 77 insertions(+), 25 deletions(-) diff --git a/.github/scripts/generate-packages.js b/.github/scripts/generate-packages.js index 8cb31fa8..23e764fd 100644 --- a/.github/scripts/generate-packages.js +++ b/.github/scripts/generate-packages.js @@ -4,13 +4,20 @@ const path = require('path'); /** * Generate packages.json file by scanning the dist directory structure * @param {string} distPath - Path to the dist directory + * @param {Array} repositoryMetadata - Repository metadata from sync process with archived status * @returns {Object} Generated packages data */ -function generatePackagesJson(distPath = '.') { +function generatePackagesJson(distPath = '.', repositoryMetadata = []) { console.log(`Scanning dist directory: ${distPath}`); const repositories = []; + // Create a map of repository metadata for quick lookup + const repoMetadataMap = new Map(); + repositoryMetadata.forEach(repo => { + repoMetadataMap.set(repo.name, repo); + }); + try { // Read the dist directory const distDir = fs.readdirSync(distPath, { withFileTypes: true }); @@ -21,6 +28,12 @@ function generatePackagesJson(distPath = '.') { console.log(`Processing repository: ${dirent.name}`); const repoData = scanRepositoryDirectory(path.join(distPath, dirent.name)); if (repoData) { + // Update archived status from metadata if available + const metadata = repoMetadataMap.get(dirent.name); + if (metadata) { + repoData.archived = metadata.archived; + } + repositories.push(repoData); console.log(` Found ${repoData.releases.length} releases`); } else { @@ -79,7 +92,7 @@ function scanRepositoryDirectory(repoPath) { const repoDirContents = fs.readdirSync(repoPath, { withFileTypes: true }); for (const dirent of repoDirContents) { - if (dirent.isDirectory()) { + if (dirent.isDirectory() && dirent.name.startsWith('v')) { // Only process v-prefixed releases const releaseData = scanReleaseDirectory(path.join(repoPath, dirent.name)); if (releaseData) { releases.push(releaseData); @@ -93,7 +106,7 @@ function scanRepositoryDirectory(repoPath) { if (releases.length > 0) { return { name: repoName, - archived: false, // Default to false, will be updated by sync process + archived: false, // This will be updated by the sync process with actual GitHub data releases: releases }; } diff --git a/.github/scripts/sync-assets.js b/.github/scripts/sync-assets.js index 96137905..98357ab8 100644 --- a/.github/scripts/sync-assets.js +++ b/.github/scripts/sync-assets.js @@ -24,8 +24,12 @@ async function processRepository(github, context, repo, repositoryData, totalAss per_page: 100 }); - // Filter out draft and prerelease - const publishedReleases = releases.filter(release => !release.draft && !release.prerelease); + // Filter out draft and prerelease, and only include releases with v-prefixed tags + const publishedReleases = releases.filter(release => + !release.draft && + !release.prerelease && + release.tag_name.startsWith('v') + ); if (publishedReleases.length === 0) { console.log(`No published releases found for ${repo.name}`); @@ -273,6 +277,9 @@ async function syncReleaseAssets(github, context, isPullRequest = false, maxNewA } else { console.log(`Downloaded ${newAssetsDownloaded} new assets`); } + + // Return repository data with archived status + return repositoryData; } module.exports = { diff --git a/.github/workflows/sync-release-assets.yml b/.github/workflows/sync-release-assets.yml index f2768468..c280ea4d 100644 --- a/.github/workflows/sync-release-assets.yml +++ b/.github/workflows/sync-release-assets.yml @@ -65,7 +65,11 @@ jobs: // Run the asset synchronization with PR limit and asset limit // Change working directory to dist for file operations process.chdir('./dist'); - await syncReleaseAssets(github, context, isPullRequest, maxNewAssets); + const repositoryData = await syncReleaseAssets(github, context, isPullRequest, maxNewAssets); + + // Store repository data for use in next step + const fs = require('fs'); + fs.writeFileSync('repo-metadata.json', JSON.stringify(repositoryData, null, 2)); - name: Generate packages.json uses: actions/github-script@v8 @@ -80,8 +84,18 @@ jobs: // Change to dist directory process.chdir('./dist'); + // Read repository metadata from previous step + const fs = require('fs'); + let repositoryMetadata = []; + try { + const metadataContent = fs.readFileSync('repo-metadata.json', 'utf8'); + repositoryMetadata = JSON.parse(metadataContent); + } catch (error) { + console.log('No repository metadata found, continuing without archived status'); + } + // Generate the packages data - const packagesData = generatePackagesJson('.'); + const packagesData = generatePackagesJson('.', repositoryMetadata); // Write the packages.json file writePackagesJson(packagesData, './packages.json'); diff --git a/gh-pages-template/assets/js/app.js b/gh-pages-template/assets/js/app.js index 218849ad..bbad4bc6 100644 --- a/gh-pages-template/assets/js/app.js +++ b/gh-pages-template/assets/js/app.js @@ -115,26 +115,44 @@ class UIManager { return; } - this.repositoryGrid.innerHTML = repos.map(repo => ` -