Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "pnpm-update-notifier",
"version": "1.0.0",
"private": true,
"packageManager": "pnpm@11.25.0",
"scripts": {
"postinstall": "node -e \"console.log('PNPM_CONFIG_UPDATE_NOTIFIER=' + process.env.PNPM_CONFIG_UPDATE_NOTIFIER)\""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
updateNotifier: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[case]]
name = "pnpm11_update_notifier"
vp = "global"
comment = "Managed pnpm 11 commands disable update notifications even when the project enables them."
steps = [
["vp", "pm", "config", "get", "updateNotifier"],
["vp", "install"],
]

[[case]]
name = "pnpm12_update_notifier"
vp = "global"
comment = "Managed pnpm 12 commands disable update notifications even when the project enables them."
steps = [
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "pnpm@12.3.4"], snapshot = false },
["vp", "pm", "config", "get", "updateNotifier"],
["vp", "install"],
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# pnpm11_update_notifier

Managed pnpm 11 commands disable update notifications even when the project enables them.

## `vp pm config get updateNotifier`

```
false
```

## `vp install`

```
VITE+ - The Unified Toolchain for the Web

Already up to date
. postinstall$ node -e "console.log('PNPM_CONFIG_UPDATE_NOTIFIER=' + process.env.PNPM_CONFIG_UPDATE_NOTIFIER)"
│ PNPM_CONFIG_UPDATE_NOTIFIER=false
└─ Done in <duration>

Done in <duration> using pnpm <version>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# pnpm12_update_notifier

Managed pnpm 12 commands disable update notifications even when the project enables them.

## `vpt json-edit package.json packageManager pnpm@12.3.4`


## `vp pm config get updateNotifier`

```
false
```

## `vp install`

```
VITE+ - The Unified Toolchain for the Web

. postinstall$ node -e "console.log('PNPM_CONFIG_UPDATE_NOTIFIER=' + process.env.PNPM_CONFIG_UPDATE_NOTIFIER)"
│ PNPM_CONFIG_UPDATE_NOTIFIER=false
└─ Done in <duration>
Already up to date

Done in <duration> using pnpm <version>
```
29 changes: 28 additions & 1 deletion crates/vp_pm_cli/src/resolution/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ where
command
.env
.insert("PATH".to_string(), vp_shared::format_path_prepended(manager.get_bin_prefix()));
if manager.client == PackageManagerType::Pnpm {
// Vite+ manages pnpm, so its self-update notification is not useful here.
command.env.insert("PNPM_CONFIG_UPDATE_NOTIFIER".to_string(), "false".to_string());
}
}

Ok(resolution)
Expand All @@ -76,7 +80,7 @@ fn parse_version(manager: &PackageManager) -> Result<Version, Error> {
#[cfg(test)]
mod tests {
use super::*;
use crate::resolution::ApproveBuildsArgs;
use crate::resolution::{ApproveBuildsArgs, InstallArgs};

fn package_manager(client: PackageManagerType, version: &str) -> PackageManager {
let workspace_root = vt_path::current_dir().unwrap();
Expand Down Expand Up @@ -122,4 +126,27 @@ mod tests {
} if version == "latest"
));
}

#[test]
fn only_pnpm_installs_disable_update_notifications() {
for (client, version, expected) in [
(PackageManagerType::Pnpm, "11.25.0", Some("false")),
(PackageManagerType::Pnpm, "12.3.4", Some("false")),
(PackageManagerType::Npm, "11.0.0", None),
(PackageManagerType::Yarn, "4.0.0", None),
(PackageManagerType::Bun, "1.0.0", None),
] {
let manager = package_manager(client, version);
let resolution = resolve_for_manager(&manager, InstallArgs::default()).unwrap();
let CommandResolution::Run(command) = resolution.outcome else {
panic!("expected install command");
};

assert_eq!(
command.env.get("PNPM_CONFIG_UPDATE_NOTIFIER").map(String::as_str),
expected,
"{client}@{version}"
);
}
}
}
Loading