pnpm_config/pnpm_elements.rs
1use super::*;
2
3/// When a user installs your package, warnings are emitted if packages specified in "peerDependencies" are not already installed. The "peerDependenciesMeta" field serves to provide more information on how your peer dependencies are utilized. Most commonly, it allows peer dependencies to be marked as optional. Metadata for this field is specified with a simple hash of the package name to a metadata object.
4#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
5#[cfg_attr(feature = "schemars", derive(JsonSchema))]
6#[serde(default)]
7pub struct PeerDependencyMeta {
8 /// Specifies that this peer dependency is optional and should not be installed automatically.
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub optional: Option<bool>,
11
12 #[serde(flatten, skip_serializing_if = "BTreeMap::is_empty")]
13 pub extras: JsonValueBTreeMap,
14}
15
16/// Determines how pnpm resolves dependencies. See more: https://pnpm.io/settings#resolutionmode
17#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
18#[cfg_attr(feature = "schemars", derive(JsonSchema))]
19pub enum ResolutionMode {
20 /// Dependencies will be resolved to their highest versions.
21 #[serde(rename = "highest")]
22 Highest,
23
24 /// Direct dependencies will be resolved to their lowest versions.
25 #[serde(rename = "lowest-direct")]
26 LowestDirect,
27
28 /// When resolutionMode is set to time-based, dependencies will be resolved the following way:
29 /// Direct dependencies will be resolved to their lowest versions. So if there is foo@^1.1.0 in the dependencies, then 1.1.0 will be installed.
30 /// Subdependencies will be resolved from versions that were published before the last direct dependency was published.
31 #[serde(rename = "time-based")]
32 TimeBased,
33}
34
35/// Configure how versions of packages installed to a package.json file get prefixed. See more: https://pnpm.io/settings#saveprefix
36#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
37#[cfg_attr(feature = "schemars", derive(JsonSchema))]
38pub enum SavePrefix {
39 /// Do not allow upgrades.
40 #[serde(rename = "")]
41 Exact,
42 /// Allows patch upgrades.
43 #[serde(rename = "~")]
44 Patch,
45 /// Allows minor upgrades.
46 #[serde(rename = "^")]
47 Minor,
48}
49
50/// This setting controls how dependencies that are linked from the workspace are added to package.json. See more: https://pnpm.io/settings#saveworkspaceprotocol
51#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
52#[cfg_attr(feature = "schemars", derive(JsonSchema))]
53pub enum SaveWorkspaceProtocol {
54 Rolling,
55 #[serde(untagged)]
56 Bool(bool),
57}
58
59/// If this is enabled, locally available packages are linked to node_modules instead of being downloaded from the registry. See more: https://pnpm.io/settings#linkworkspacepackages
60#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
61#[cfg_attr(feature = "schemars", derive(JsonSchema))]
62pub enum LinkWorkspacePackages {
63 Deep,
64 #[serde(untagged)]
65 Bool(bool),
66}
67
68/// This setting allows the checking of the state of dependencies before running scripts. See more: https://pnpm.io/settings#verifydepsbeforerun
69#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
70#[cfg_attr(feature = "schemars", derive(JsonSchema))]
71pub enum VerifyDepsBeforeRun {
72 /// Automatically runs install if node_modules is not up to date.
73 Install,
74 /// Prints a warning if node_modules is not up to date.
75 Warn,
76 /// Throws an error if node_modules is not up to date.
77 Error,
78 /// Prompts the user for permission to run install if node_modules is not up to date.
79 Prompt,
80 #[serde(untagged)]
81 Bool(bool),
82}
83
84/// Controls colors in the output. See more: https://pnpm.io/settings#no-color
85#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
86#[cfg_attr(feature = "schemars", derive(JsonSchema))]
87#[serde(rename_all = "camelCase")]
88pub enum Color {
89 /// Ignore the difference between terminals and pipes.
90 Always,
91 /// Output uses colors when the standard output is a terminal or TTY
92 Auto,
93 /// Turns off colors. This is the setting used by --no-color.
94 Never,
95}
96
97/// Any logs at or higher than the given level will be shown. See more: https://pnpm.io/settings#loglevel
98#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
99#[cfg_attr(feature = "schemars", derive(JsonSchema))]
100#[serde(rename_all = "camelCase")]
101pub enum LogLevel {
102 Debug,
103 Info,
104 Warn,
105 Error,
106}
107
108/// Controls the way packages are imported from the store (if you want to disable symlinks inside node_modules, then you need to change the nodeLinker setting, not this one). See more: https://pnpm.io/settings#packageimportmethod
109#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
110#[cfg_attr(feature = "schemars", derive(JsonSchema))]
111#[serde(rename_all = "camelCase")]
112pub enum PackageImportMethod {
113 /// Try to clone packages from the store. If cloning is not supported then hardlink packages from the store. If neither cloning nor linking is possible, fall back to copying.
114 Auto,
115 /// Hard link packages from the store.
116 Hardlink,
117 /// Clone (AKA copy-on-write or reference link) packages from the store.
118 Clone,
119 /// Try to clone packages from the store. If cloning is not supported then fall back to copying.
120 #[serde(rename = "clone-or-copy")]
121 CloneOrCopy,
122 /// Copy packages from the store.
123 Copy,
124}
125
126/// Defines what linker should be used for installing Node packages. See more: https://pnpm.io/settings#nodelinker
127#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
128#[cfg_attr(feature = "schemars", derive(JsonSchema))]
129#[serde(rename_all = "camelCase")]
130pub enum NodeLinker {
131 /// Dependencies are symlinked from a virtual store at node_modules/.pnpm
132 Isolated,
133 /// A flat node_modules without symlinks is created.
134 Hoisted,
135 /// No node_modules. Plug'n'Play is an innovative strategy for Node that is used by Yarn Berry. It is recommended to also set symlink setting to false when using pnp as your linker.
136 Pnp,
137}
138
139/// Instructions for the runtime, such as the node version to use. See more: https://pnpm.io/settings#executionenvnodeversion
140#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
141#[cfg_attr(feature = "schemars", derive(JsonSchema))]
142#[serde(rename_all = "camelCase")]
143#[serde(deny_unknown_fields)]
144pub struct ExecutionEnv {
145 /// Specifies which exact Node.js version should be used for the project's runtime.
146 #[serde(alias = "node_version")]
147 pub node_version: Option<String>,
148}
149
150/// Specifies architectures for which you'd like to install optional dependencies, even if they don't match the architecture of the system running the install. See more: https://pnpm.io/settings#supportedarchitectures
151#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
152#[cfg_attr(feature = "schemars", derive(JsonSchema))]
153#[serde(rename_all = "camelCase")]
154#[serde(default)]
155#[serde(deny_unknown_fields)]
156pub struct SupportedArchitectures {
157 #[serde(alias = "cpu")]
158 #[serde(skip_serializing_if = "Option::is_none")]
159 pub cpu: Option<BTreeSet<String>>,
160
161 #[serde(alias = "libc")]
162 #[serde(skip_serializing_if = "Option::is_none")]
163 pub libc: Option<BTreeSet<String>>,
164
165 #[serde(alias = "os")]
166 #[serde(skip_serializing_if = "Option::is_none")]
167 pub os: Option<BTreeSet<String>>,
168}
169
170/// Settings for the `pnpm audit` command. See more: https://pnpm.io/settings#auditconfig
171#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
172#[cfg_attr(feature = "schemars", derive(JsonSchema))]
173#[serde(rename_all = "camelCase")]
174#[serde(default)]
175#[serde(deny_unknown_fields)]
176pub struct AuditConfig {
177 /// A list of CVE IDs that will be ignored by `pnpm audit`.
178 #[serde(alias = "ignore_cves")]
179 #[serde(skip_serializing_if = "Option::is_none")]
180 pub ignore_cves: Option<BTreeSet<String>>,
181
182 /// A list of GHSA Codes that will be ignored by `pnpm audit`.
183 #[serde(alias = "ignore_ghas")]
184 #[serde(skip_serializing_if = "Option::is_none")]
185 pub ignore_ghas: Option<BTreeSet<String>>,
186}
187
188/// Configuration for package updates. See more: https://pnpm.io/settings#updateconfig
189#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
190#[cfg_attr(feature = "schemars", derive(JsonSchema))]
191#[serde(rename_all = "camelCase")]
192#[serde(deny_unknown_fields)]
193pub struct UpdateConfig {
194 /// A list of packages that should be ignored when running `pnpm outdated` or `pnpm update --latest`.
195 #[serde(alias = "ignore_dependencies")]
196 #[serde(skip_serializing_if = "Option::is_none")]
197 pub ignore_dependencies: Option<BTreeSet<String>>,
198}
199
200/// Rules for peer dependencies. See more: https://pnpm.io/settings#peerdependencyrules
201#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
202#[cfg_attr(feature = "schemars", derive(JsonSchema))]
203#[serde(rename_all = "camelCase")]
204#[serde(default)]
205#[serde(deny_unknown_fields)]
206pub struct PeerDependencyRules {
207 /// Unmet peer dependency warnings will not be printed for peer dependencies of the specified range.
208 #[serde(alias = "allowed_versions")]
209 #[serde(skip_serializing_if = "Option::is_none")]
210 pub allowed_versions: Option<StringBTreeMap>,
211
212 /// A list of package name patterns, any peer dependency matching the pattern will be resolved from any version, regardless of the range specified in peerDependencies.
213 #[serde(alias = "allow_any")]
214 #[serde(skip_serializing_if = "Option::is_none")]
215 pub allow_any: Option<BTreeSet<String>>,
216
217 /// pnpm will not print warnings about missing peer dependencies from this list.
218 #[serde(alias = "ignore_missing")]
219 #[serde(skip_serializing_if = "Option::is_none")]
220 pub ignore_missing: Option<BTreeSet<String>>,
221}
222
223/// Package extensions offer a way to extend the existing package definitions with additional information. For example, if react-redux should have react-dom in its peerDependencies but it has not, it is possible to patch react-redux using packageExtensions. See more: https://pnpm.io/settings#packageextensions
224#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
225#[cfg_attr(feature = "schemars", derive(JsonSchema))]
226#[serde(rename_all = "camelCase")]
227#[serde(default)]
228#[serde(deny_unknown_fields)]
229pub struct PackageExtension {
230 /// Dependencies are specified with a simple hash of package name to version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
231 #[serde(skip_serializing_if = "Option::is_none")]
232 pub dependencies: Option<StringBTreeMap>,
233
234 /// Specifies dependencies that are required for the development and testing of the project. These dependencies are not needed in the production environment.
235 #[serde(alias = "dev_dependencies")]
236 #[serde(skip_serializing_if = "Option::is_none")]
237 pub dev_dependencies: Option<StringBTreeMap>,
238
239 /// Specifies dependencies that are optional for your project. These dependencies are attempted to be installed during the npm install process, but if they fail to install, the installation process will not fail.
240 #[serde(alias = "optional_dependencies")]
241 #[serde(skip_serializing_if = "Option::is_none")]
242 pub optional_dependencies: Option<StringBTreeMap>,
243
244 /// Specifies dependencies that are required by the package but are expected to be provided by the consumer of the package.
245 #[serde(alias = "peer_dependencies")]
246 #[serde(skip_serializing_if = "Option::is_none")]
247 pub peer_dependencies: Option<StringBTreeMap>,
248
249 /// When a user installs your package, warnings are emitted if packages specified in "peerDependencies" are not already installed. The "peerDependenciesMeta" field serves to provide more information on how your peer dependencies are utilized. Most commonly, it allows peer dependencies to be marked as optional. Metadata for this field is specified with a simple hash of the package name to a metadata object.
250 #[serde(alias = "peer_dependencies_meta")]
251 #[serde(skip_serializing_if = "Option::is_none")]
252 pub peer_dependencies_meta: Option<BTreeMap<String, PeerDependencyMeta>>,
253}
254
255/// Controlls if and how dependencies are added to the default catalog, when running pnpm add. See more: https://pnpm.io/settings#catalogmode
256#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Copy, Eq)]
257#[cfg_attr(feature = "schemars", derive(JsonSchema))]
258pub enum CatalogMode {
259 /// (default) - does not automatically add dependencies to the catalog.
260 Manual,
261 /// Only allows dependency versions from the catalog. Adding a dependency outside the catalog's version range will cause an error.
262 Strict,
263 /// Prefers catalog versions, but will fall back to direct dependencies if no compatible version is found.
264 Prefer,
265}