diff --git a/build-pipeline.js b/build-pipeline.js index f6e0975..154bab5 100644 --- a/build-pipeline.js +++ b/build-pipeline.js @@ -18,20 +18,23 @@ const REPO_CONFIG = { 'stream-api': { name: 'stream-api', branch: 'main' }, }; +const clonedRepos = new Set(); + function clonePrivateRepo(repoConfig, targetDir) { + if (fs.existsSync(targetDir)) { + console.log(`[DEV] ${repoConfig.name} already exists locally. Skipping clone to use local changes.`); + return; + } + const token = process.env.GITLAB_TOKEN || process.env.VYLA_GITLAB_TOKEN; const auth = token ? `oauth2:${token}@` : ''; const repoUrl = `https://${auth}gitlab.com/${GITLAB_GROUP}/${repoConfig.name}.git`; try { - if (fs.existsSync(targetDir)) { - fs.rmSync(targetDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); - } - execSync(`git clone --depth 1 --branch ${repoConfig.branch} ${repoUrl} ${targetDir}`, { stdio: 'inherit' }); - + clonedRepos.add(repoConfig.name); } catch (error) { throw new Error(`Failed to clone ${repoConfig.name}: ${error.message}`); } @@ -332,9 +335,11 @@ async function build() { fs.writeFileSync(path.join(__dirname, 'manifest.json'), JSON.stringify(manifest, null, 2), 'utf8'); for (const repo of REPOS) { - const repoPath = path.join(__dirname, repo); - if (fs.existsSync(repoPath)) { - fs.rmSync(repoPath, { recursive: true, force: true }); + if (clonedRepos.has(repo)) { + const repoPath = path.join(__dirname, repo); + if (fs.existsSync(repoPath)) { + fs.rmSync(repoPath, { recursive: true, force: true }); + } } } diff --git a/main.js b/main.js index 96a29cb..feb63e4 100644 --- a/main.js +++ b/main.js @@ -203,10 +203,34 @@ async function start() { try { sendToTauri('status', { message: 'Inspecting local workspace and installed files...' }); - const isFirstRun = !patcher.verifyExtraction(); - const localVersion = patcher.getCurrentVersion(); - const localSha = patcher.getCurrentSha(); - debugLog(`Is First Run: ${isFirstRun}, Local Version: ${localVersion}`); + let isFirstRun = !patcher.verifyExtraction(); + let localVersion = patcher.getCurrentVersion(); + let localSha = patcher.getCurrentSha(); + debugLog(`Is First Run: ${isFirstRun}, Local Version: ${localVersion}, Local SHA: ${localSha}`); + + const localZipPath = path.join(__dirname, 'update-payload.zip'); + const localManifestPath = path.join(__dirname, 'manifest.json'); + let localZipManifest = null; + + if (fs.existsSync(localZipPath) && fs.existsSync(localManifestPath)) { + try { localZipManifest = JSON.parse(fs.readFileSync(localManifestPath, 'utf8')); } catch (e) { } + } + + if (localZipManifest && (isFirstRun || localZipManifest.sha256 !== localSha)) { + debugLog("New local payload detected! Applying local build..."); + sendToTauri('status', { message: 'Extracting local development payload...' }); + patcher.purgeOldCode(); + patcher.extractZipPayload(localZipPath); + patcher.applyPatches(getReplacementsConfig()); + patcher.bridgeCredentials(serviceManager.credentialManager); + patcher.saveCurrentVersion(localZipManifest.version, localZipManifest.sha256); + serviceManager.envConfig = getEnvConfig(); + + isFirstRun = false; + localVersion = localZipManifest.version; + localSha = localZipManifest.sha256; + debugLog("Local payload applied successfully."); + } sendToTauri('status', { message: 'Connecting to update servers...' }); let release = null; @@ -277,7 +301,14 @@ async function start() { patcher.extractZipPayload(localZip); patcher.applyPatches(getReplacementsConfig()); patcher.bridgeCredentials(serviceManager.credentialManager); - patcher.saveCurrentVersion("1.0.0"); + + let ver = "1.0.0"; + try { + const man = JSON.parse(fs.readFileSync(path.join(__dirname, 'manifest.json'), 'utf8')); + ver = man.version || ver; + } catch (e) { } + + patcher.saveCurrentVersion(ver); serviceManager.envConfig = getEnvConfig(); debugLog("Local payload extracted successfully."); } else { diff --git a/package.json b/package.json index 2d3a52f..845b018 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vyla-home", - "version": "1.1.12", + "version": "1.1.13", "description": "Vyla Home Desktop App Launcher", "main": "main.js", "scripts": { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index aeb91ec..4989640 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4222,7 +4222,7 @@ dependencies = [ [[package]] name = "vyla-home" -version = "1.1.12" +version = "1.1.13" dependencies = [ "base64 0.22.1", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 27a2d27..1da2b15 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vyla-home" -version = "1.1.12" +version = "1.1.13" description = "Vyla Home Desktop App Launcher" edition = "2021" diff --git a/src-tauri/build.rs b/src-tauri/build.rs index ffca4c5..a4cbc29 100644 --- a/src-tauri/build.rs +++ b/src-tauri/build.rs @@ -1,5 +1,20 @@ fn main() { println!("cargo:rerun-if-changed=src/main.rs"); println!("cargo:rerun-if-changed=tauri.conf.json"); + + if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" { + if let (Ok(manifest_dir), Ok(out_dir)) = (std::env::var("CARGO_MANIFEST_DIR"), std::env::var("OUT_DIR")) { + let mut target_dir = std::path::PathBuf::from(out_dir); + target_dir.pop(); + target_dir.pop(); + target_dir.pop(); + let dll_src = std::path::Path::new(&manifest_dir).join("WebView2Loader.dll"); + let dll_dest = target_dir.join("WebView2Loader.dll"); + if dll_src.exists() { + let _ = std::fs::copy(dll_src, dll_dest); + } + } + } + tauri_build::build(); } \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 85ff0c4..978bb9c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -570,6 +570,41 @@ fn main() { let app_data = app.path().app_data_dir().unwrap_or_default(); let app_data_str = clean_path(&app_data); + let vyla_files = if let Ok(appdata_env) = std::env::var("APPDATA") { + std::path::PathBuf::from(appdata_env).join("vyla-home").join("vyla-home-files") + } else { + app_data.join("vyla-home-files") + }; + + let version_file = vyla_files.join("version.json"); + let current_app_version = app.package_info().version.to_string(); + let mut version_mismatch = false; + + if version_file.exists() { + if let Ok(content) = std::fs::read_to_string(&version_file) { + if let Ok(json) = serde_json::from_str::(&content) { + if let Some(version) = json.get("version").and_then(|v| v.as_str()) { + if version != current_app_version { + version_mismatch = true; + } + } else { + version_mismatch = true; + } + } else { + version_mismatch = true; + } + } + } + + if version_mismatch { + debug_log(&format!("App version updated to {}. Cleaning old files.", current_app_version)); + let dirs_to_remove = ["frontend", "player", "stream-api", "auth-proxy", "config"]; + for d in dirs_to_remove { + let _ = std::fs::remove_dir_all(vyla_files.join(d)); + } + let _ = std::fs::remove_file(&version_file); + } + let window = WebviewWindowBuilder::new(app, "main", WebviewUrl::App("index.html".into())) .title("Vyla Home") .inner_size(1280.0, 800.0) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index fae1f20..794f5dc 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Vyla Home", - "version": "1.1.12", + "version": "1.1.13", "identifier": "com.vyla.home", "build": { "frontendDist": "../ui"