aboutsummaryrefslogtreecommitdiff
path: root/internal/manifest/manifest.go
blob: ffb73f8420fb3efedb99f05d9535994df55872d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2026 Arslaan Pathan
// This software is licensed under the ARPL. See LICENSE for details.

package manifest

import (
	"fmt"
	"encoding/json"
	"net/http"
	"log"
	"io"
	"errors"
	"github.com/BurntSushi/toml"
)

type KiiroToml struct {
	// package name
	Name string `toml:"pkgname"`
	// supported architectures
	Architectures string `toml:"archs"`
	// authors
	Authors []string `toml:"authors"`
	// maintainers of the Kiirofile/kiiro.toml
	Maintainers []string `toml:"maintainers"`
	// Dependencies on other Kiiro packages - you can refer to a package from a specific source by using <source-url>:<package-name>
	// If no source is provided (just a bare URL), we clone directly from git
	Depends []string `toml:"deps"`
	// Platforms it runs on: e.g. "Windows", "macOS", "Linux", "BSD"
	Platforms []string `toml:"platforms"`
}

func FetchKiiroToml(url string) (*KiiroToml, error) {
	fmt.Println("Fetching kiiro.toml...")

	res, err := http.Get(url)
	if err != nil {
		return nil, err
	}

	body, err := io.ReadAll(res.Body)
	res.Body.Close()

	if res.StatusCode > 299 {
		return nil, err
	}

	if err != nil {
		return nil, err
	}

	kiirotoml, err := ParseKiiroToml(body)
	if err != nil {
		return nil, err
	}

	fmt.Println("Fetched package listing!")
	return packageListing, nil
}

func ParseKiiroToml(kiirotomlTOML []byte) (*Kiirotoml, error) {
	var kiirotoml Kiirotoml 
	err := toml.Unmarshal(kiirotomlTOML, kiirotoml);
	if err != nil {
		return nil, err
	}
	return &kiirotoml, nil;
}