File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 11import helloWorld from './modules/helloWorld'
2+ import { getTemplatesList } from './modules/repo'
23
3- console . log ( helloWorld ( 'typescript!' ) )
4+ console . log ( await getTemplatesList ( ) )
Original file line number Diff line number Diff line change 1+ import { fetch } from 'undici'
2+
3+ export interface TemplateMeta {
4+ name : string
5+ description : string
6+ author ?: string
7+ repository :
8+ | string
9+ | {
10+ url : string
11+ }
12+ }
13+
14+ type TemplatesJson = { templates : TemplateMeta [ ] }
15+
16+ export const getTemplatesList = async ( templatesFileUrl ?: string ) => {
17+ if ( ! templatesFileUrl ) {
18+ templatesFileUrl =
19+ 'https://raw.githubusercontent.com/pkgtoolsjs/pkgtools/refs/heads/main/templates.json'
20+ }
21+
22+ const res = await fetch ( templatesFileUrl )
23+ const json = res . json ( ) as unknown as TemplatesJson
24+
25+ return json
26+ }
You can’t perform that action at this time.
0 commit comments