11//! Configuration and version resolution for the env command.
22//!
33//! This module provides:
4- //! - VITE_PLUS_HOME path resolution
4+ //! - VP_HOME path resolution
55//! - Version resolution with priority order
66//! - Config file management
77
@@ -27,7 +27,7 @@ pub enum ShimMode {
2727 SystemFirst ,
2828}
2929
30- /// User configuration stored in VITE_PLUS_HOME /config.json
30+ /// User configuration stored in VP_HOME /config.json
3131#[ derive( Serialize , Deserialize , Default , Debug ) ]
3232#[ serde( rename_all = "camelCase" ) ]
3333pub struct Config {
@@ -60,26 +60,26 @@ pub struct VersionResolution {
6060 pub is_range : bool ,
6161}
6262
63- /// Get the VITE_PLUS_HOME directory path.
63+ /// Get the VP_HOME directory path.
6464///
65- /// Uses `VITE_PLUS_HOME ` environment variable if set, otherwise defaults to `~/.vite-plus`.
66- pub fn get_vite_plus_home ( ) -> Result < AbsolutePathBuf , Error > {
67- Ok ( vite_shared:: get_vite_plus_home ( ) ?)
65+ /// Uses `VP_HOME ` environment variable if set, otherwise defaults to `~/.vite-plus`.
66+ pub fn get_vp_home ( ) -> Result < AbsolutePathBuf , Error > {
67+ Ok ( vite_shared:: get_vp_home ( ) ?)
6868}
6969
7070/// Get the bin directory path (~/.vite-plus/bin/).
7171pub fn get_bin_dir ( ) -> Result < AbsolutePathBuf , Error > {
72- Ok ( get_vite_plus_home ( ) ?. join ( "bin" ) )
72+ Ok ( get_vp_home ( ) ?. join ( "bin" ) )
7373}
7474
7575/// Get the packages directory path (~/.vite-plus/packages/).
7676pub fn get_packages_dir ( ) -> Result < AbsolutePathBuf , Error > {
77- Ok ( get_vite_plus_home ( ) ?. join ( "packages" ) )
77+ Ok ( get_vp_home ( ) ?. join ( "packages" ) )
7878}
7979
8080/// Get the tmp directory path for staging (~/.vite-plus/tmp/).
8181pub fn get_tmp_dir ( ) -> Result < AbsolutePathBuf , Error > {
82- Ok ( get_vite_plus_home ( ) ?. join ( "tmp" ) )
82+ Ok ( get_vp_home ( ) ?. join ( "tmp" ) )
8383}
8484
8585/// Get the node_modules directory path for a package.
@@ -116,7 +116,7 @@ pub fn get_node_modules_dir(prefix: &AbsolutePath, package_name: &str) -> Absolu
116116
117117/// Get the config file path.
118118pub fn get_config_path ( ) -> Result < AbsolutePathBuf , Error > {
119- Ok ( get_vite_plus_home ( ) ?. join ( CONFIG_FILE ) )
119+ Ok ( get_vp_home ( ) ?. join ( CONFIG_FILE ) )
120120}
121121
122122/// Load configuration from disk.
@@ -135,7 +135,7 @@ pub async fn load_config() -> Result<Config, Error> {
135135/// Save configuration to disk.
136136pub async fn save_config ( config : & Config ) -> Result < ( ) , Error > {
137137 let config_path = get_config_path ( ) ?;
138- let vite_plus_home = get_vite_plus_home ( ) ?;
138+ let vite_plus_home = get_vp_home ( ) ?;
139139
140140 // Ensure directory exists
141141 tokio:: fs:: create_dir_all ( & vite_plus_home) . await ?;
@@ -147,14 +147,14 @@ pub async fn save_config(config: &Config) -> Result<(), Error> {
147147
148148/// Environment variable for per-shell session Node.js version override.
149149/// Set by `vp env use` command.
150- pub const VERSION_ENV_VAR : & str = vite_shared:: env_vars:: VITE_PLUS_NODE_VERSION ;
150+ pub const VERSION_ENV_VAR : & str = vite_shared:: env_vars:: VP_NODE_VERSION ;
151151
152152/// Session version file name, written by `vp env use` so shims work without the shell eval wrapper.
153153pub const SESSION_VERSION_FILE : & str = ".session-node-version" ;
154154
155155/// Get the path to the session version file (~/.vite-plus/.session-node-version).
156156pub fn get_session_version_path ( ) -> Result < AbsolutePathBuf , Error > {
157- Ok ( get_vite_plus_home ( ) ?. join ( SESSION_VERSION_FILE ) )
157+ Ok ( get_vp_home ( ) ?. join ( SESSION_VERSION_FILE ) )
158158}
159159
160160/// Read the session version file. Returns `None` if the file is missing or empty.
@@ -197,7 +197,7 @@ pub async fn delete_session_version() -> Result<(), Error> {
197197/// Resolve Node.js version for a directory.
198198///
199199/// Resolution order:
200- /// 0. `VITE_PLUS_NODE_VERSION ` env var (session override from `vp env use`)
200+ /// 0. `VP_NODE_VERSION ` env var (session override from `vp env use`)
201201/// 1. `.session-node-version` file (session override written by `vp env use` for shell-wrapper-less environments)
202202/// 2. `.node-version` file in current or parent directories
203203/// 3. `package.json#engines.node` in current or parent directories
@@ -824,7 +824,7 @@ mod tests {
824824
825825 let resolution = resolve_version ( & temp_path) . await . unwrap ( ) ;
826826
827- // VITE_PLUS_NODE_VERSION should take priority over .node-version
827+ // VP_NODE_VERSION should take priority over .node-version
828828 assert_eq ! ( resolution. version, "22.0.0" ) ;
829829 assert_eq ! ( resolution. source, VERSION_ENV_VAR ) ;
830830 assert ! ( resolution. source_path. is_none( ) ) ;
0 commit comments