diff --git a/package.json b/package.json index aa56108b5f7..ffe96ca7e44 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "crowdin:sync": "docusaurus write-translations && crowdin upload && crowdin download", "deploy": "docusaurus deploy", "docusaurus": "docusaurus", - "generate-markdown": "node scripts/native.mjs && concurrently \"node scripts/cli.mjs\" \"node scripts/release-notes.mjs\"", + "generate-markdown": "node scripts/native.mjs && node scripts/cli.mjs && node scripts/release-notes.mjs", "lint": "npm run prettier -- --write", "serve": "docusaurus serve", "playground:new": "hygen playground new", diff --git a/scripts/cli.mjs b/scripts/cli.mjs index 6fdebc8d971..6ccd3efa232 100644 --- a/scripts/cli.mjs +++ b/scripts/cli.mjs @@ -15,6 +15,7 @@ const commandToKebab = (str) => const { commands } = cliJSON; commands.map(writePage); + console.log(`📟 CLI Commands Generated`); })(); function writePage(page) { diff --git a/scripts/native.mjs b/scripts/native.mjs index 631f32c0f19..801bedb430d 100644 --- a/scripts/native.mjs +++ b/scripts/native.mjs @@ -97,7 +97,7 @@ async function getPkgJsonData(pluginId) { async function main() { await Promise.all(pluginApis.map(buildPluginApiDocs)); - console.log(`Plugin API Files Updated 🎸`); + console.log(`🔌 Capacitor Plugins Generated`); } function toTitleCase(str) { diff --git a/scripts/release-notes.mjs b/scripts/release-notes.mjs index a4e82310881..d43468eae29 100644 --- a/scripts/release-notes.mjs +++ b/scripts/release-notes.mjs @@ -15,22 +15,15 @@ const OUTPUT_PATH = resolve(__dirname, '../src/components/page/reference/Release // task: async () => outputJson(OUTPUT_PATH, await getReleases(), { spaces: 2 }) // }; -// Get the GitHub Releases from Ionic +// Get the GitHub Releases from Ionic Framework // ------------------------------------------------------------------------------- -// This requires an environment GITHUB_TOKEN otherwise it may fail -// -// To add a GITHUB_TOKEN, follow the steps to create a personal access token: -// https://docs.github.com/en/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token -// and then authorize it to work with SSO: -// https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on +// Fetches from the public GitHub API. Unauthenticated requests have a 60 req/hour limit. +// To increase the rate limit, set a GITHUB_TOKEN environment variable. const getReleases = async () => { try { - const request = await fetch(new URL('repos/ionic-team/ionic/releases', 'https://api.github.com'), { - headers: { - Authorization: process.env.GITHUB_TOKEN !== undefined ? `token ${process.env.GITHUB_TOKEN}` : '', - }, - }); - + const url = new URL('repos/ionic-team/ionic-framework/releases', 'https://api.github.com'); + const headers = process.env.GITHUB_TOKEN ? { Authorization: `token ${process.env.GITHUB_TOKEN}` } : {}; + const request = await fetch(url, { headers }); const releases = await request.json(); // Check that the response is an array in case it was @@ -97,8 +90,29 @@ function getVersionType(version) { } async function run() { - const { outputJson } = pkg; - outputJson(OUTPUT_PATH, await getReleases(), { spaces: 2 }); + const { outputJson, readJson } = pkg; + const newReleases = await getReleases(); + + // Successfully fetched new releases, save them + if (newReleases.length > 0) { + outputJson(OUTPUT_PATH, newReleases, { spaces: 2 }); + console.log(`🚀 Release Notes Generated`); + return; + } + + // If the fetch failed but we have existing data, keep it + try { + const existingData = await readJson(OUTPUT_PATH); + if (Array.isArray(existingData) && existingData.length > 0) { + console.log(`🚀 Release Notes Preserved`); + return; + } + } catch (error) { + console.warn(`⚠️ Could not read existing release notes: ${error.message}`); + } + + // If we have no new data and no cached data, error + throw new Error('Failed to fetch release notes from GitHub and no cached data available'); } run(); diff --git a/src/components/page/reference/ReleaseNotes/index.tsx b/src/components/page/reference/ReleaseNotes/index.tsx index c1402d63d1c..491dc8ebf71 100644 --- a/src/components/page/reference/ReleaseNotes/index.tsx +++ b/src/components/page/reference/ReleaseNotes/index.tsx @@ -26,7 +26,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating return [

Unable to load Releases. Please see all releases{' '} - + on GitHub . @@ -38,7 +38,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating

A complete release history for Ionic Framework is available{' '} - + on GitHub . Documentation for recent releases can also be found below. @@ -53,7 +53,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating

- +

{release.version}

@@ -79,7 +79,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating
To see more releases, visit{' '} - + GitHub .