Rust

packager

Module

Package managers: Packager, the built-in Npm, Pnpm and Yarn, and the PackagerDetector that finds one from file names.

Contents

use utopia_detector::Npm;
Rust
pub struct Npm

npm: package.json or package-lock.json.

use utopia_detector::PackagerDetector;
Rust
pub struct PackagerDetector

Finds the packager of a project from its file names: the first option, in the order they were added, with one of its files among the inputs.

Rust
use utopia_detector::{Npm, PackagerDetector, Pnpm, Yarn};

let mut detector = PackagerDetector::new();
detector.add_option(Pnpm).add_option(Yarn).add_option(Npm);
detector.add_input("package.json").add_input("yarn.lock");

assert_eq!(detector.detect().map(|p| p.name()), Some("yarn"));
Also implements Debug.
use utopia_detector::Pnpm;
Rust
pub struct Pnpm

pnpm: pnpm-lock.yaml.

use utopia_detector::Yarn;
Rust
pub struct Yarn

Yarn: yarn.lock.

use utopia_detector::Packager;
Rust
pub trait Packager: Send + Sync

A package manager, recognised by the files it leaves in a project.

Implemented byNpmPnpmYarn