feat(desktop,launcher): default to ~/.waggle-community (P1.3c)
The Tauri shell's bundled npm environment and its first-launch flag, the server installer's --data-dir default and the NSIS installer config fell back to ~/.waggle. Use ~/.waggle-community (ADR-0011). The Rust shell keeps the name in DEFAULT_DATA_DIR_NAME in lib.rs and the launcher, which uses only Node built-ins, in DATA_DIR_NAME. packages/shared/tests/data-dir.test.ts fails when either copy, or the marketplace's, differs from @waggle/shared.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Brief: briefs/2026-04-30-cc-sesija-A-waggle-apps-web-integration.md §2.3 Task A10
|
||||
//
|
||||
// Persists a flag file at `~/.waggle/first-launch.flag` so the onboarding wizard
|
||||
// Persists a flag file at `~/.waggle-community/first-launch.flag` so the onboarding wizard
|
||||
// state survives across app reinstalls (browser localStorage doesn't, since
|
||||
// Tauri builds may use a fresh WebView profile per install). The web `npm run
|
||||
// dev` path continues to use localStorage via useOnboarding — these commands
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
const FLAG_DIR: &str = ".waggle";
|
||||
use crate::DEFAULT_DATA_DIR_NAME;
|
||||
|
||||
const FLAG_FILE: &str = "first-launch.flag";
|
||||
|
||||
fn home_dir() -> Option<PathBuf> {
|
||||
@@ -23,10 +24,10 @@ fn home_dir() -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
/// Resolve the flag location: `WAGGLE_DATA_DIR` (when set and non-empty) else
|
||||
/// `~/.waggle` — the SAME resolution order the sidecar's resolveDataDir uses
|
||||
/// `~/.waggle-community` — the SAME resolution order the sidecar's resolveDataDir uses
|
||||
/// (UX-Refactor P4/D11). Without this, a custom-data-dir install reads/writes
|
||||
/// the flag in `~/.waggle` while the server's completion stamp lives in the
|
||||
/// data dir — and a stale `~/.waggle` flag from a prior default install would
|
||||
/// the flag in the default directory while the server's completion stamp lives in the
|
||||
/// data dir — and a stale default-directory flag from a prior default install would
|
||||
/// auto-skip onboarding against a brand-new data dir (P4 review, 5 findings).
|
||||
fn flag_path() -> Result<PathBuf, String> {
|
||||
if let Some(dir) = std::env::var_os("WAGGLE_DATA_DIR") {
|
||||
@@ -37,7 +38,7 @@ fn flag_path() -> Result<PathBuf, String> {
|
||||
let home = home_dir().ok_or_else(|| {
|
||||
"could not resolve user home directory (USERPROFILE/HOME unset)".to_string()
|
||||
})?;
|
||||
Ok(home.join(FLAG_DIR).join(FLAG_FILE))
|
||||
Ok(home.join(DEFAULT_DATA_DIR_NAME).join(FLAG_FILE))
|
||||
}
|
||||
|
||||
/// Returns true if the user has not yet completed onboarding.
|
||||
@@ -54,7 +55,7 @@ pub async fn is_first_launch() -> Result<bool, String> {
|
||||
}
|
||||
|
||||
/// Marks onboarding as complete by creating the flag file. Idempotent.
|
||||
/// Creates the parent `~/.waggle/` directory if needed.
|
||||
/// Creates the parent data directory if needed.
|
||||
#[tauri::command]
|
||||
pub async fn mark_first_launch_complete() -> Result<(), String> {
|
||||
let path = flag_path()?;
|
||||
@@ -91,12 +92,12 @@ mod tests {
|
||||
std::env::set_var("USERPROFILE", &tmp);
|
||||
std::env::set_var("HOME", &tmp);
|
||||
|
||||
// Default: ~/.waggle.
|
||||
// Default: ~/.waggle-community, never the commercial edition's ~/.waggle.
|
||||
std::env::remove_var("WAGGLE_DATA_DIR");
|
||||
let path = flag_path().expect("flag_path resolves with USERPROFILE/HOME set");
|
||||
assert!(
|
||||
path.ends_with(".waggle/first-launch.flag")
|
||||
|| path.ends_with(".waggle\\first-launch.flag")
|
||||
assert_eq!(
|
||||
path,
|
||||
tmp.join(".waggle-community").join("first-launch.flag")
|
||||
);
|
||||
|
||||
// P4/D11: a custom data dir keeps the flag NEXT TO the server's stamp.
|
||||
@@ -110,9 +111,9 @@ mod tests {
|
||||
// Empty env value falls through to the home default (matches resolveDataDir).
|
||||
std::env::set_var("WAGGLE_DATA_DIR", "");
|
||||
let fallback = flag_path().expect("flag_path resolves with empty WAGGLE_DATA_DIR");
|
||||
assert!(
|
||||
fallback.ends_with(".waggle/first-launch.flag")
|
||||
|| fallback.ends_with(".waggle\\first-launch.flag")
|
||||
assert_eq!(
|
||||
fallback,
|
||||
tmp.join(".waggle-community").join("first-launch.flag")
|
||||
);
|
||||
|
||||
std::env::remove_var("WAGGLE_DATA_DIR");
|
||||
|
||||
Reference in New Issue
Block a user