voidzero-dev / voidzero-dev/vite-plus

Install in LocalAppData on Windows

Aperta
#1,592 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
pending triage
Lingua principale
Rust
Stelle
5.8k
Fork
262
Merge medio
23h 41m
PR unite (30g)
138

Descrizione

### Description

By default, Vite+ is installed in `%USERPROFILE%\.vite-plus`. This adds clutter to the user's profile folder, especially since the folder is not hidden (unlike on POSIX systems). This issue is related to #827.

### Suggested solution

Change the default installation location to either `%LOCALAPPDATA%\vite-plus` (which is equivalent to `$XDG_DATA_HOME`) or in `%LOCALAPPDATA%\Programs\vite-plus` (which is used by MSI installers as the default per-user install location).

Strictly speaking, the default per-user install location is a [known folder](https://learn.microsoft.com/en-us/windows/win32/shell/known-folders) with the ID [FOLDERID_UserProgramFiles](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid#:~:text=FOLDERID%5FUserProgramFiles). The default path is `%LOCALAPPDATA%\Programs`, but it can be overridden on an individual system. Therefore, the path to this folder should be retrieved by calling the `SHGetKnownFolderPath` function in `shell32.dll`. The following script uses P/Invoke within PowerShell to get the value (with no error checking):

```powershell
# Here be P/Invoke...
$Shell32 = ([System.Management.Automation.PSTypeName]'Win32.Shell32').Type;

if (-not $Shell32) {
# The PreserveSig = false setting automatically unmarshals the return value.
$signature = @'
[DllImport("shell32.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
public static extern string SHGetKnownFolderPath(
ref Guid rfid,
uint dwFlags,
IntPtr hToken
);
'@

$typeArgs = @{
MemberDefinition = $signature
Name = "Shell32"
Namespace = "Win32"
PassThru = $true
};
$Shell32 = Add-Type @typeArgs;
}

# GUID for FOLDERID_UserProgramFiles known folder: {5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}
# $guid = [System.Guid]::ParseExact("{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}", "B")
# $guid = [guid]"{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}"
$guid = [System.Guid]::new(0x5CD7AEE2, 0x2219, 0x4A67, 0xB8, 0x5D, 0x6C, 0x9C, 0xE1, 0x56, 0x60, 0xCB);
# The flag in the second argument tells Windows to create the folder if it doesn't exist
# The null pointer as the third argument means we get the known folder path for the current user
$path = $Shell32::SHGetKnownFolderPath([ref]$guid, 0x00008000, [IntPtr]::Zero);
return $path;
```

### Alternative

_No response_

### Additional context

_No response_

### Validations

- [x] Read the [Contributing Guidelines](https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md).
- [x] Confirm this request is for Vite+ itself and not for Vite, Vitest, tsdown, Rolldown, or Oxc.
- [x] Check that there isn't already an issue requesting the same feature.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Il payload non indica alcun file di implementazione o test. Inizia individuando la logica dei percorsi dell’installer Windows e ispeziona l’entry point SHGetKnownFolderPath proposto; il lavoro è completato quando le nuove installazioni di Windows usano la posizione per utente selezionata senza compromettere le installazioni esistenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
operating-systems, tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.