Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add devtools updates #673

Merged
merged 3 commits into from
Oct 28, 2024
Merged
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
42 changes: 42 additions & 0 deletions apps/svelte.dev/src/routes/devtools/updates.json/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { error, json } from '@sveltejs/kit';
import type { ServerlessConfig } from '@sveltejs/adapter-vercel';

export const config: ServerlessConfig = {
isr: {
expiration: 300
}
};

// We manage FF extension by ourselves through GH releases and this acts as `update_url`
// for our users to automatically update their extension when a new version is released
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#update_url
export async function GET({ fetch }) {
const response = await fetch('https://api.github.com/repos/sveltejs/svelte-devtools/tags');

if (!response.ok) {
error(response.status);
}

const gh: Array<{ name: string }> = await response.json();

// v2.2.0 is the first version that has the Firefox extension
const tags = gh.reverse().slice(gh.findIndex((t) => t.name === 'v2.2.0'));
const base = 'https://github.com/sveltejs/svelte-devtools/releases/download';
return json({
addons: {
'[email protected]': {
updates: tags.map(({ name: tag }) => {
return {
version: tag,
update_link: `${base}/${tag}/svelte-devtools.xpi`,
applications: requirements[tag] && { gecko: requirements[tag] }
};
})
}
}
});
}

const requirements: Record<string, any> = {
'v2.2.2': { strict_min_version: '121.0' }
};
Loading