Monorepo management for opam overlays
at main 91 lines 2.9 kB view raw
1(** Package metadata and operations. 2 3 A package represents a single opam package discovered from the opam overlay 4 repository. It contains the package name, version, git remote URL, and 5 optional configuration overrides. *) 6 7(** {1 Types} *) 8 9type t 10(** A package discovered from the opam overlay. *) 11 12(** {1 Constructors} *) 13 14val create : 15 name:string -> 16 version:string -> 17 dev_repo:Uri.t -> 18 ?branch:string -> 19 ?depends:string list -> 20 ?synopsis:string -> 21 unit -> 22 t 23(** [create ~name ~version ~dev_repo ?branch ?depends ?synopsis ()] creates a 24 new package. 25 26 @param name The opam package name 27 @param version The package version (e.g., "dev") 28 @param dev_repo The git remote URL from the opam file's dev-repo field 29 @param branch Optional branch override; defaults to repository default 30 @param depends List of opam package names this package depends on 31 @param synopsis Short description of the package *) 32 33(** {1 Accessors} *) 34 35val name : t -> string 36(** [name t] returns the package name. *) 37 38val version : t -> string 39(** [version t] returns the package version string. *) 40 41val dev_repo : t -> Uri.t 42(** [dev_repo t] returns the git remote URI. *) 43 44val branch : t -> string option 45(** [branch t] returns the branch to track, if explicitly set. *) 46 47val depends : t -> string list 48(** [depends t] returns the list of opam package names this package depends on. 49*) 50 51val synopsis : t -> string option 52(** [synopsis t] returns the short description of the package, if any. *) 53 54val repo_name : t -> string 55(** [repo_name t] returns the repository name extracted from the dev-repo URL. 56 57 This is the basename of the URL path with any ".git" suffix removed. For 58 example, "https://github.com/foo/bar.git" returns "bar". *) 59 60(** {1 Derived Paths} *) 61 62val checkout_dir : checkouts_root:Fpath.t -> t -> Fpath.t 63(** [checkout_dir ~checkouts_root t] returns the expected path for this 64 package's git checkout, based on the repository name. 65 66 For a package with dev-repo "https://example.com/foo/bar.git" and 67 checkouts_root "/home/user/src", this returns "/home/user/src/bar". 68 69 Multiple packages from the same repository will share the same checkout. *) 70 71val subtree_prefix : t -> string 72(** [subtree_prefix t] returns the subdirectory name used in the monorepo. 73 74 This is the repository name (same as [repo_name t]), so multiple packages 75 from the same repository share the same subtree directory. *) 76 77(** {1 Comparison} *) 78 79val compare : t -> t -> int 80(** [compare a b] compares packages by name. *) 81 82val equal : t -> t -> bool 83(** [equal a b] returns true if packages have the same name. *) 84 85val same_repo : t -> t -> bool 86(** [same_repo a b] returns true if packages share the same dev-repo URL. *) 87 88(** {1 Pretty Printing} *) 89 90val pp : t Fmt.t 91(** [pp] is a formatter for packages. *)