Documentation
¶
Overview ¶
Package gdshpkg installs gdsh command packages into a command root (<root>/packages/<name>) from a reviewed index: godot-gdsh-lib-manifest. Each entry pins a tag and the commit it was reviewed at; installs download that commit, so a moved tag can't change what is served.
Index ¶
- Constants
- func CompareVersions(a, b string) int
- func Dependents(installed []Installed, name string, m *Manifest) []string
- func Extract(data []byte, dir string) error
- func PackagesDir(root string) string
- func Remove(root, name string) error
- func SplitRequire(spec string) (repo, tag string)
- type Action
- type Cfg
- type Client
- func (c *Client) Archive(ctx context.Context, repo, commit string) ([]byte, error)
- func (c *Client) FetchIndex(ctx context.Context, refresh bool) (*Index, error)
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) IndexURL() string
- func (c *Client) Install(ctx context.Context, root string, steps []Step, report func(string)) error
- type Index
- type Installed
- type Manifest
- type Package
- type ProjectOnlyError
- type Step
- type Update
Constants ¶
const DefaultManifestURL = "https://raw.githubusercontent.com/brohd11/godot-gdsh-lib-manifest/main/manifest.json"
DefaultManifestURL is the published index.
const GdshRepo = "brohd11/godot-gdsh"
GdshRepo is gdsh itself. Hosts bring their own copy, so it is never installed.
const IndexEnv = "GDSH_PACKAGE_INDEX"
IndexEnv overrides the index location: a URL, or a local manifest.json (read as is, not cached), for trying an index before publishing it.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions orders "v1.2.3"-style versions: -1, 0 or 1. A leading v is ignored, numeric parts compare as numbers, and a missing part counts as 0.
func Dependents ¶
Dependents returns the installed packages that require name. Requires are matched by repo through the index when it is given, else by the repo's last path part.
func Extract ¶
Extract unpacks a repo zip into dir: the single wrapper folder GitHub adds is dropped, and so are dot files/folders and export_ignore folders at any depth. Links and paths escaping dir are refused.
func PackagesDir ¶
PackagesDir is where a root keeps its packages.
func SplitRequire ¶
SplitRequire splits "owner/repo@tag" (a github.com/ prefix or .git suffix is allowed).
Types ¶
type Cfg ¶
type Cfg struct {
Name string
Version string
Path string // project path, e.g. addons/_lib/gdsh_lib/level; its basename is the install name
Require []string // "owner/repo@tag"
}
Cfg is the [package] section of a package's package.cfg.
func ParseCfg ¶
ParseCfg reads the [package] section of a Godot ConfigFile: quoted strings and string arrays, which may span lines. Other sections and value types are ignored.
func (Cfg) InstallName ¶
InstallName is the folder a package installs to: the basename of its path. Packages find their dependencies as sibling folders by this name.
type Client ¶
type Client struct {
HTTP *http.Client
ManifestURL string
// ArchiveURL is a zip of repo at commit; default GitHub's codeload archive.
ArchiveURL func(repo, commit string) string
// CacheDir holds manifest.json; default <user cache>/gdsh.
CacheDir string
TTL time.Duration
}
Client fetches the index and package archives. The zero value uses the published index and GitHub, caching the index under the user cache folder for a day.
func (*Client) FetchIndex ¶
FetchIndex returns the index: the cached copy while it is younger than TTL (unless refresh), else a fresh download, else the cached copy marked Stale. A local file is always read fresh.
func (*Client) HTTPClient ¶
HTTPClient is the client requests go through.
func (*Client) IndexURL ¶
IndexURL is where the index comes from: ManifestURL, else $GDSH_PACKAGE_INDEX, else the published one.
type Index ¶
Index is a fetched manifest. Stale is set when the network failed and the cached copy was used.
type Installed ¶
Installed is a package found in a root.
func ListInstalled ¶
ListInstalled returns the packages in root, by name: folders under packages/ that have a package.cfg. A root without packages/ has none.
type Manifest ¶
Manifest is the index: packages approved for install.
func LoadManifest ¶
LoadManifest reads an index file.
func ParseManifest ¶
ParseManifest decodes and sanity-checks an index.
func (*Manifest) Marshal ¶
Marshal is the canonical file form: two-space indent and a trailing newline.
func (*Manifest) Outdated ¶
Outdated compares installed versions with the index pins. Packages not in the index are skipped.
type Package ¶
type Package struct {
Name string `json:"name"`
Repo string `json:"repo"`
Summary string `json:"summary"`
Tags []string `json:"tags,omitempty"`
Tag string `json:"tag"`
Commit string `json:"commit"`
// Gdsh is the lowest gdsh version the package requires.
Gdsh string `json:"gdsh,omitempty"`
// Requires are other indexed gdsh packages (repos), installed as siblings.
Requires []string `json:"requires"`
// ProjectOnly are requires a command root can't hold (non-gdsh code such as util_r): the
// package has to be installed into the project instead, with gdaddon.
ProjectOnly []string `json:"project_only,omitempty"`
}
Package is one entry. Name, Repo, Summary, Tags and the Tag/Commit pin are written by hand; Gdsh, Requires and ProjectOnly are derived from package.cfg at Commit by gdsh-manifest.
type ProjectOnlyError ¶
type ProjectOnlyError struct{ Pkg Package }
ProjectOnlyError is a package a command root can't hold.
func (ProjectOnlyError) Error ¶
func (e ProjectOnlyError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gdsh-manifest
command
gdsh-manifest maintains godot-gdsh-lib-manifest's manifest.json.
|
gdsh-manifest maintains godot-gdsh-lib-manifest's manifest.json. |
|
Package maint keeps godot-gdsh-lib-manifest honest: it derives each entry's gdsh, requires and project_only from package.cfg at the pinned commit, checks the pin and the package shape, moves pins (Pin) and lists newer tags for review (Propose).
|
Package maint keeps godot-gdsh-lib-manifest honest: it derives each entry's gdsh, requires and project_only from package.cfg at the pinned commit, checks the pin and the package shape, moves pins (Pin) and lists newer tags for review (Propose). |