6060 command
6161 . env
6262 . insert ( "PATH" . to_string ( ) , vp_shared:: format_path_prepended ( manager. get_bin_prefix ( ) ) ) ;
63- if manager. client == PackageManagerType :: Pnpm {
64- // Vite+ manages pnpm, so its self-update notification is not useful here.
65- command. env . insert ( "PNPM_CONFIG_UPDATE_NOTIFIER" . to_string ( ) , "false" . to_string ( ) ) ;
63+ match manager. client {
64+ PackageManagerType :: Pnpm => {
65+ // Vite+ manages pnpm, so its self-update notification is not useful here.
66+ command. env . insert ( "PNPM_CONFIG_UPDATE_NOTIFIER" . to_string ( ) , "false" . to_string ( ) ) ;
67+ }
68+ PackageManagerType :: Yarn if command. program == "yarn" => {
69+ match parse_version ( manager) ?. major {
70+ 0 | 1 => {
71+ command. env . insert (
72+ "YARN_DISABLE_SELF_UPDATE_CHECK" . to_string ( ) ,
73+ "true" . to_string ( ) ,
74+ ) ;
75+ }
76+ 4 .. => {
77+ // Yarn 4 includes version notices in its daily tips.
78+ command. env . insert ( "YARN_ENABLE_TIPS" . to_string ( ) , "false" . to_string ( ) ) ;
79+ }
80+ // Yarn 2 and 3 reject these settings and have no version notices.
81+ _ => { }
82+ }
83+ }
84+ _ => { }
6685 }
6786 }
6887
@@ -80,7 +99,7 @@ fn parse_version(manager: &PackageManager) -> Result<Version, Error> {
8099#[ cfg( test) ]
81100mod tests {
82101 use super :: * ;
83- use crate :: resolution:: { ApproveBuildsArgs , InstallArgs } ;
102+ use crate :: resolution:: { ApproveBuildsArgs , DlxArgs , InstallArgs } ;
84103
85104 fn package_manager ( client : PackageManagerType , version : & str ) -> PackageManager {
86105 let workspace_root = vt_path:: current_dir ( ) . unwrap ( ) ;
@@ -127,6 +146,59 @@ mod tests {
127146 ) ) ;
128147 }
129148
149+ #[ test]
150+ fn yarn_update_settings_match_the_major_version ( ) {
151+ for ( client, version, classic, tips) in [
152+ ( PackageManagerType :: Yarn , "1.22.22" , Some ( "true" ) , None ) ,
153+ ( PackageManagerType :: Yarn , "2.4.2" , None , None ) ,
154+ ( PackageManagerType :: Yarn , "3.8.7" , None , None ) ,
155+ ( PackageManagerType :: Yarn , "4.0.0" , None , Some ( "false" ) ) ,
156+ ( PackageManagerType :: Yarn , "4.12.0" , None , Some ( "false" ) ) ,
157+ ( PackageManagerType :: Npm , "11.13.0" , None , None ) ,
158+ ( PackageManagerType :: Pnpm , "12.3.4" , None , None ) ,
159+ ( PackageManagerType :: Bun , "1.0.0" , None , None ) ,
160+ ] {
161+ let manager = package_manager ( client, version) ;
162+ let resolution = resolve_for_manager ( & manager, InstallArgs :: default ( ) ) . unwrap ( ) ;
163+ let CommandResolution :: Run ( command) = resolution. outcome else {
164+ panic ! ( "expected install command" ) ;
165+ } ;
166+
167+ assert_eq ! (
168+ command. env. get( "YARN_DISABLE_SELF_UPDATE_CHECK" ) . map( String :: as_str) ,
169+ classic,
170+ "{client}@{version}"
171+ ) ;
172+ assert_eq ! (
173+ command. env. get( "YARN_ENABLE_TIPS" ) . map( String :: as_str) ,
174+ tips,
175+ "{client}@{version}"
176+ ) ;
177+ assert ! ( !command. env. contains_key( "YARN_ENABLE_TELEMETRY" ) ) ;
178+ }
179+ }
180+
181+ #[ test]
182+ fn yarn_classic_npx_fallback_uses_only_npm_update_settings ( ) {
183+ let manager = package_manager ( PackageManagerType :: Yarn , "1.22.22" ) ;
184+ let resolution = resolve_for_manager (
185+ & manager,
186+ DlxArgs { args : vec ! [ "create-vue" . to_string( ) ] , ..Default :: default ( ) } ,
187+ )
188+ . unwrap ( ) ;
189+ let CommandResolution :: Run ( command) = resolution. outcome else {
190+ panic ! ( "expected npx command" ) ;
191+ } ;
192+
193+ assert_eq ! ( command. program, "npx" ) ;
194+ assert_eq ! (
195+ command. env. get( "npm_config_update_notifier" ) . map( String :: as_str) ,
196+ Some ( "false" )
197+ ) ;
198+ assert ! ( !command. env. contains_key( "YARN_DISABLE_SELF_UPDATE_CHECK" ) ) ;
199+ assert ! ( !command. env. contains_key( "YARN_ENABLE_TIPS" ) ) ;
200+ }
201+
130202 #[ test]
131203 fn only_npm_installs_disable_npm_update_notifications ( ) {
132204 for ( client, version, expected) in [
0 commit comments