package delivery import ( "strings" ) // A mesh package is a Go module of a repository of the mesh's forge (ForgeModulePrefix): mesh-sdk's Go module, and an // owner module's package (novox/hq ADR 0593 §1). The indexer alone reads which packages a module imports, their content // digests and their latest published versions, and writes them in its state (PublishedPackages, ADR 0593 §2); a build // writes the version it is asked into its own go.mod and go.sum (StepAsk.Packages). // ForgeModulePrefix is the module path prefix of the Go modules the mesh's forge serves: a Go module whose path starts // with it is a mesh package, git.novox.be/novox/[/]. const ForgeModulePrefix = "git.novox.be/novox/" // PackageRepository is the repository (/) a mesh package is published from and the package's directory in // it ("" for its root); false for a path that is not a forge module's. func PackageRepository(pkg string) (repository, dir string, ok bool) { rest, found := strings.CutPrefix(pkg, ForgeModulePrefix) if !found || rest == "" { return "", "", false } name, dir, _ := strings.Cut(rest, "/") if name == "" { return "", "", false } return "novox/" + name, dir, true }