@@ -11,82 +11,48 @@ import terminalLink from "terminal-link"
1111
1212interface Template {
1313 name: string
14+ alias: string
1415 description: string
1516 path: string
1617}
1718
18- interface GitHubContent {
19- name: string
20- type: string
21- download_url ? : string
22- }
23-
24- interface GitHubFile {
25- content : string
26- }
27-
2819interface NpmPackageData {
2920 version : string
3021}
3122
32- type PackageJson = Awaited < ReturnType < typeof readPackage >>
33-
3423async function fetchTemplates ( ) : Promise < Template [ ] > {
3524 const s = spinner ( )
3625 s . start ( "Discovering templates..." )
3726
3827 try {
3928 // Fetch examples directory contents
40- const response = await fetch (
41- "https://api.github.com/repos/noxify/vorsteh-queue/contents/examples" ,
42- )
43- if ( ! response . ok ) throw new Error ( `HTTP ${ response . status } ` )
29+ const response = await fetch ( "https://vorsteh-queue.dev/templates.json" )
4430
45- const contents = ( await response . json ( ) ) as GitHubContent [ ]
46- const templates : Template [ ] = [ ]
47-
48- // Process each directory in examples/
49- for ( const item of contents ) {
50- if ( item . type === "dir" ) {
51- try {
52- // Fetch package.json for each example
53- const pkgResponse = await fetch (
54- `https://api.github.com/repos/noxify/vorsteh-queue/contents/examples/${ item . name } /package.json` ,
55- )
56- if ( pkgResponse . ok ) {
57- const pkgData = ( await pkgResponse . json ( ) ) as GitHubFile
58- const pkgContent = JSON . parse ( atob ( pkgData . content ) ) as Partial < PackageJson >
59-
60- templates . push ( {
61- name : pkgContent . name ?? item . name ,
62- description : pkgContent . description ?? `${ item . name } example` ,
63- path : `examples/${ item . name } ` ,
64- } )
65- }
66- } catch ( error ) {
67- // Skip directories without valid package.json
68- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
69- console . warn ( pc . yellow ( `⚠️ Skipping ${ item . name } : ${ error } ` ) )
70- }
71- }
31+ if ( ! response . ok ) {
32+ throw new Error ( `HTTP ${ response . status } ` )
7233 }
7334
74- s . stop ( `Found ${ templates . length } templates` )
75- return templates
76- // eslint-disable-next-line @typescript-eslint/no-unused-vars
77- } catch ( error ) {
78- s . stop ( "Failed to fetch templates" )
35+ const responseBody = ( await response . json ( ) ) as { templates : Template [ ] }
36+
37+ s . stop ( `Found ${ responseBody . templates . length } templates` )
38+ return responseBody . templates
39+ } catch ( error : unknown ) {
40+ s . stop (
41+ `Failed to fetch templates - ${ error instanceof Error ? error . toString ( ) : String ( error ) } ` ,
42+ )
7943 // Fallback to hardcoded templates
8044
8145 console . warn ( pc . yellow ( "⚠️ Using fallback templates" ) )
8246 return [
8347 {
84- name : "drizzle-postgres" ,
48+ name : "drizzle-postgres-example" ,
49+ alias : "drizzle-postgres" ,
8550 description : "Drizzle ORM + postgres.js" ,
8651 path : "examples/drizzle-postgres" ,
8752 } ,
8853 {
89- name : "drizzle-pglite" ,
54+ name : "drizzle-pglite-example" ,
55+ alias : "drizzle-pglite" ,
9056 description : "Drizzle ORM + PGlite (Embedded)" ,
9157 path : "examples/drizzle-pglite" ,
9258 } ,
0 commit comments