Skip to main content

ephemeris_release/adapters/
npm.rs

1//! npm package lookup and publication.
2
3mod publisher;
4mod registry;
5
6use std::io;
7
8pub(crate) use self::publisher::NpmPublisher;
9pub use self::registry::NpmRegistry;
10use crate::error::PackageFailure;
11
12/// An npm command or registry failure.
13#[derive(Debug, thiserror::Error)]
14pub(crate) enum NpmError {
15    /// A unit publishes but no npm registry is configured.
16    #[error("npm unit {unit:?} publishes but no npm registry is configured")]
17    MissingRegistry {
18        /// The release unit.
19        unit: String,
20    },
21    /// A resolved unit lacks its npm package name.
22    #[error("npm release unit {0:?} has no package name")]
23    MissingPackage(String),
24    /// The registry URL has no host to authenticate against.
25    #[error("npm registry URL {url:?} has no host")]
26    RegistryWithoutHost {
27        /// The configured URL.
28        url: String,
29    },
30    /// The publisher was built without a credential.
31    #[error("no credential was given to publish npm packages")]
32    MissingToken,
33    /// The temporary npm configuration cannot be written.
34    #[error("cannot write the temporary npm configuration")]
35    Npmrc(#[source] io::Error),
36    /// npm could not be started.
37    #[error("cannot run npm {arguments:?}")]
38    Spawn {
39        /// The npm arguments.
40        arguments: Vec<String>,
41        /// Why starting failed.
42        #[source]
43        source: io::Error,
44    },
45    /// npm exited unsuccessfully.
46    #[error("npm {arguments:?} exited unsuccessfully: {stderr}")]
47    Failed {
48        /// The npm arguments.
49        arguments: Vec<String>,
50        /// The trimmed standard error output.
51        stderr: String,
52    },
53    /// The registry could not say whether a version exists.
54    #[error("npm registry lookup failed")]
55    Registry(#[from] PackageFailure),
56}