pub struct Project {
pub manifest: Manifest,
pub lock: Option<Lock>,
pub base: PathBuf,
pub scope: Scope,
pub cache: PathBuf,
pub state: PathBuf,
pub home: PathBuf,
/* private fields */
}Expand description
A chest.toml with its lock, and the folders its entries go to.
Fields§
§manifest: ManifestThe manifest.
lock: Option<Lock>Its lock, when there is one.
base: PathBufThe manifest’s folder, which its relative paths start from.
scope: ScopeWhether it is a project’s manifest or the user’s global one.
cache: PathBufWhere git clones are cached and work is staged: ~/.chest/cache
unless set otherwise.
state: PathBufWhere chest records what it placed on this machine, outside any
repository: ~/.chest/state unless set otherwise.
home: PathBufThe canonical home folder, which ~ names.
Implementations§
Source§impl Project
impl Project
Sourcepub fn open(path: &Path, scope: Scope) -> Result<Project, ChestError>
pub fn open(path: &Path, scope: Scope) -> Result<Project, ChestError>
The manifest at path and its lock, the file beside it named with
.lock for .toml: chest.dev.toml locks in chest.dev.lock.
The manifest’s folder is resolved to its canonical path once, so a
project opened through a link or another spelling of its path places,
records and removes the same paths. A manifest or lock that is itself
a link is refused, as refuse_link says.
Sourcepub fn global() -> Result<Project, ChestError>
pub fn global() -> Result<Project, ChestError>
The user’s global manifest, ~/.chest/chest.toml.
Sourcepub fn root(&self) -> PathBuf
pub fn root(&self) -> PathBuf
The folder chest never writes outside of: the project’s own for a project manifest, home for the global one.
Sourcepub fn store(&self) -> PathBuf
pub fn store(&self) -> PathBuf
The extension store: [folders] extensions, else .yapi/chest in a
project and ~/.chest/store for the global manifest.
Sourcepub fn too_wide(&self, folder: &Path, also: &[&Path]) -> bool
pub fn too_wide(&self, folder: &Path, also: &[&Path]) -> bool
Whether folder, an extension’s module root, holds far more than one
package, so the extension could load any file there: it is, or holds,
the home folder, the agent folder, the filesystem’s root, the
manifest’s folder, which is the project’s for a project manifest, the
store, which holds the other extensions, or a folder in also. A
held folder that does not exist yet counts by the path it will have.
Sourcepub fn placed(&self, section: Section, locked: &Locked) -> Vec<PathBuf>
pub fn placed(&self, section: Section, locked: &Locked) -> Vec<PathBuf>
The paths locked occupies: each of its items in each of its
section’s folders, or its store folder.
Sourcepub fn state(&self, section: Section, name: &str, entry: &Entry) -> &'static str
pub fn state(&self, section: Section, name: &str, entry: &Entry) -> &'static str
The state of entry name of section that yapi’s startup acts on,
as chest list shows it: under [patch], missing when a copy chest
placed is gone, edited when one changed since, else patched.
Otherwise, no source for a path entry whose source is gone, stale
when not locked or locked for another source, missing when not in
place, edited when a copy chest placed changed since, whatever lock
pinned it, outdated when in place as an older lock pinned it, else
installed. Startup hashes no copies, so it loads an edited entry
that the lock still pins, or that is patched, as it would unedited.
Sourcepub fn present(&self, section: Section, locked: &Locked) -> bool
pub fn present(&self, section: Section, locked: &Locked) -> bool
Whether everything locked occupies is there. A link in the first
folder, where the copy belongs, counts as missing, as after the
folders were reordered. An extension from a path loads where it is,
so it always is.
Sourcepub async fn sync(
&mut self,
mode: Mode,
npm: &mut Npm,
progress: &mut (dyn FnMut(&str) + Send),
) -> Result<Report, ChestError>
pub async fn sync( &mut self, mode: Mode, npm: &mut Npm, progress: &mut (dyn FnMut(&str) + Send), ) -> Result<Report, ChestError>
Brings the installed entries in line with the manifest and lock as
mode says, holding the lock file’s lock and the project’s record
lock throughout. Every entry is fetched and checked before anything
is put in place, so a failed download changes nothing. Nothing is
installed outside Project::root. Only chest’s cache and record,
under ~/.chest unless set otherwise, are written elsewhere.
progress hears a line for each entry fetched, and one while another
chest command holds a lock.
Sourcepub fn installed_root(&self, name: &str) -> Option<PathBuf>
pub fn installed_root(&self, name: &str) -> Option<PathBuf>
The folder installed extension name loads from: its [patch]
path, its store folder, the npm package inside it, or its path
source. None for an entry that is not an installed extension.
Sourcepub fn extension_roots(&self, name: &str) -> Option<(PathBuf, PathBuf)>
pub fn extension_roots(&self, name: &str) -> Option<(PathBuf, PathBuf)>
Where extension name loads from, as Project::installed_root
says whether or not it exists, and the folder that holds the package
and its own dependencies, which it may load modules from: the
[patch] or path source, or <store>/<name> for git and npm.
Sourcepub fn verify(&self) -> Result<Vec<String>, ChestError>
pub fn verify(&self) -> Result<Vec<String>, ChestError>
Checks every installed copy of a locked git or npm entry: canonical
copies, copy fallbacks and store folders by their hash, and links by
what they point to. Copies of path and [patch] entries are checked
by chest’s record of what it placed, and each path entry’s source
must be there. Returns one line per problem, so none means all match.
Sourcepub async fn outdated(&self, npm: &mut Npm) -> Result<Vec<Outdated>, ChestError>
pub async fn outdated(&self, npm: &mut Npm) -> Result<Vec<Outdated>, ChestError>
The newest revision each locked git or npm entry’s source offers:
the commit its rev names now, or the newest npm version in its
range with npm’s latest.
Sourcepub async fn fetch_package(
&self,
entry: &Entry,
npm: &mut Npm,
) -> Result<Fetched, ChestError>
pub async fn fetch_package( &self, entry: &Entry, npm: &mut Npm, ) -> Result<Fetched, ChestError>
Fetches the package entry names, without its dependencies, to read
what it provides and requests before it is added: a git source at the
commit its rev names, an npm source at the newest version in its
range, or a path source where it is.