Skip to content
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