Documentation
¶
Overview ¶
Package repoformat is what an anfra repo is, as anything handling one outside the engine needs it: which files make up a repo (Publishable), which of them are Data Apps and what they are called (DataApp, AppLabel), and how a file's content is named (BlobID). anfra core owns it, as it owns the repo format; anfra-cloud imports it, so a server, the CLI and every host agree on them.
Index ¶
Constants ¶
const AppsDir = "apps"
AppsDir is where a repo's Data Apps are: published whole.
TODO: configurable, in the repo's config, rather than fixed.
Variables ¶
This section is empty.
Functions ¶
func AppLabel ¶ added in v0.12.0
AppLabel is what a host calls a Data App: its definition's <title>, with whitespace collapsed and entities decoded, or else its file name. p is the definition's slash-separated path, content its HTML.
func BlobID ¶
BlobID is content's git blob id: SHA-1 over "blob <size>\0" and the content, as git names it with no filters applied. It is what a publish names a file's content by, and what a server, storing it in git, answers for it.
func CheckOrigin ¶ added in v0.12.0
CheckOrigin reports whether s may be added to a Data App's content policy: https://<host>[:<port>] and nothing after it, written as a browser writes an origin (lowercase, no default port), so it cannot widen a directive (a scheme, a wildcard) or end one (a space, a ";"). The SDK's checkOrigin is the same rule, in the browser.
func DataApp ¶ added in v0.12.0
DataApp reports whether a file is a Data App definition: an .html file under AppsDir that a publish carries. The other files there are what definitions refer to (an image, a script). path is as Publishable takes it.
func Publishable ¶
Publishable reports whether a file is part of an anfra repo, so a publish carries it: its AML (*.aml), and its Data Apps (everything under AppsDir). path is slash-separated and relative to the repo root.
A publish carries the repo, not the folder it is in: what the server uses, chosen by the repo's format, the same on every machine, with or without git. So a .env, build output, notes or scripts beside the repo are never sent, and nothing depends on .gitignore, which says what belongs in version control, a different question (PUBLISH.md §What gets published). Within the repo, never:
- a path with a part starting with ".": git's own files, the repo's config (.anfra/, whose data_sources.yml holds credentials), editors' and tools' state;
- a path through node_modules: a Data App's installed dependencies.
The CLI selects with it, and a server refuses what it does not allow, so neither a modified client nor a mistake in one can publish anything else.
Types ¶
type AppIssue ¶ added in v0.12.0
AppIssue is something in a Data App definition that will not work in a host: where it is, and what to do about it.
func CheckApp ¶ added in v0.12.0
CheckApp is what in a Data App definition will not work in a host, in document order:
- A reference to a local file (a relative or root-relative src, href, srcset, poster or CSS url()): a Data App is one HTML file, and a host serves nothing beside it.
- A script or stylesheet from another server without an integrity hash: the library runs beside the reader's query results, so a change to it at its CDN should stop it, not run it.
It never fails: a definition it cannot read has no issues it can name.