Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions scripts/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const commandToKebab = (str) =>
const { commands } = cliJSON;

commands.map(writePage);
console.log(`📟 CLI Commands Generated`);
})();

function writePage(page) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/native.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
44 changes: 29 additions & 15 deletions scripts/release-notes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
8 changes: 4 additions & 4 deletions src/components/page/reference/ReleaseNotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating
return [
<p>
Unable to load Releases. Please see all releases{' '}
<a href="https://github.com/ionic-team/ionic/releases" target="_blank">
<a href="https://github.com/ionic-team/ionic-framework/releases" target="_blank">
on GitHub
</a>
.
Expand All @@ -38,7 +38,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating
<article>
<p className={styles.intro}>
A complete release history for Ionic Framework is available{' '}
<a href="https://github.com/ionic-team/ionic/releases" target="_blank">
<a href="https://github.com/ionic-team/ionic-framework/releases" target="_blank">
on GitHub
</a>
. Documentation for recent releases can also be found below.
Expand All @@ -53,7 +53,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating
<section className={clsx(styles['release-note'], styles[`release-note-${release.type}`])}>
<div className={styles['release-info']}>
<div className={styles['release-header']}>
<a href={`https://github.com/ionic-team/ionic/releases/v${release.version}`}>
<a href={`https://github.com/ionic-team/ionic-framework/releases/v${release.version}`}>
<h2>
<span className={styles['release-version']}>{release.version}</span>
</h2>
Expand All @@ -79,7 +79,7 @@ https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating
</div>
<blockquote>
To see more releases, visit{' '}
<a href="https://github.com/ionic-team/ionic/releases/" target="_blank">
<a href="https://github.com/ionic-team/ionic-framework/releases/" target="_blank">
GitHub
</a>
.
Expand Down
Loading