File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
apps/svelte.dev/src/routes/devtools/updates.json Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ import { error , json } from '@sveltejs/kit' ;
2+ import type { ServerlessConfig } from '@sveltejs/adapter-vercel' ;
3+
4+ export const config : ServerlessConfig = {
5+ isr : {
6+ expiration : 300
7+ }
8+ } ;
9+
10+ // We manage FF extension by ourselves through GH releases and this acts as `update_url`
11+ // for our users to automatically update their extension when a new version is released
12+ // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#update_url
13+ export async function GET ( { fetch } ) {
14+ const response = await fetch ( 'https://api.github.com/repos/sveltejs/svelte-devtools/tags' ) ;
15+
16+ if ( ! response . ok ) {
17+ error ( response . status ) ;
18+ }
19+
20+ const gh : Array < { name : string } > = await response . json ( ) ;
21+
22+ // v2.2.0 is the first version that has the Firefox extension
23+ const tags = gh . reverse ( ) . slice ( gh . findIndex ( ( t ) => t . name === 'v2.2.0' ) ) ;
24+ const base = 'https://github.com/sveltejs/svelte-devtools/releases/download' ;
25+ return json ( {
26+ addons : {
27+ 28+ updates : tags . map ( ( { name : tag } ) => {
29+ return {
30+ version : tag ,
31+ update_link : `${ base } /${ tag } /svelte-devtools.xpi` ,
32+ applications : requirements [ tag ] && { gecko : requirements [ tag ] }
33+ } ;
34+ } )
35+ }
36+ }
37+ } ) ;
38+ }
39+
40+ const requirements : Record < string , any > = {
41+ 'v2.2.2' : { strict_min_version : '121.0' }
42+ } ;
You can’t perform that action at this time.
0 commit comments