// What's the difference between Nuke and Uninstall? // Nuke doesn't care for dependencies (if present) public void NukePackage(string packageName) { Upbring upbring = Upbring.Instance(); InstalledPackage package = upbring.GetInstalledPackage(packageName); package.Nuke(); upbring.RemovePackage(package); upbring.SaveFile(); }
// What's the difference between Nuke and Uninstall? // Nuke doesn't care for dependencies (if present) public void NukePackage(string packageName) { Upbring upbring = Upbring.Instance(); InstalledPackage package = upbring.GetInstalledPackage(packageName); package.Nuke(); upbring.RemovePackage(package); upbring.SaveFile(); UnityHacks.BuildSettingsEnforcer.EnforceAssetSave(); }
public void UpdatePackage(Upset package, TemporaryDirectory td) { Upbring upbring = Upbring.Instance(); // Nuking previous version InstalledPackage installedPackage = upbring.GetInstalledPackage(package.PackageName); installedPackage.Nuke(); DependencyDefinition definition = Upfile.Instance().Dependencies.First(dep => dep.Name == package.PackageName); InstallPackage(package, td, definition); }
public void GetInstalledPackageTest() { InstalledPackage package_A = new InstalledPackage() { Name = "packageA" }; InstalledPackage package_B = new InstalledPackage() { Name = "packageB" }; upbring.InstalledPackage = new InstalledPackage[] { package_A, package_B }; Assert.AreEqual(upbring.GetInstalledPackage("packageA"), package_A); }
private static void CheckDependencies() { Upbring upbring = Upbring.Instance(); Upfile upfile = Upfile.Instance(); PackageList packageList = PackageList.Instance(); PackageRepo[] packageRepos = packageList.GetAllPackages(); bool any_installed = upbring.InstalledPackage != null && upbring.InstalledPackage.Length != 0; foreach (DependencyDefinition dependency in upfile.Dependencies) { string name = dependency.Name; bool installed = any_installed && upbring.InstalledPackage.Any(ip => ip.Name == name); bool installable = packageRepos.Any(pr => pr.Package.PackageName == name); string latest = installable ? packageList.GetLatestPackage(name).Package.PackageVersion : ""; string string_latest = string.IsNullOrEmpty(latest) ? "No version available in any repository" : "Latest version is " + latest; if (installed) { string installed_version = upbring.GetInstalledPackage(name).Version; if (installed_version != latest) { Debug.Log(string.Format("Package {0} is outdated: installed version is {1}, latest is {2}", name, installed_version, string_latest)); } else { Debug.Log(string.Format("Package {0} is up-to-date ({1})", name, installed_version)); } } else { Debug.Log(string.Format("Package {0} is not installed ({1})", name, string_latest)); } } }
protected void OnGUI() { titleContent.text = "Update Utility"; UpliftManager manager = UpliftManager.Instance(); Upbring upbring = Upbring.Instance(); Upfile upfile = Upfile.Instance(); PackageList packageList = PackageList.Instance(); PackageRepo[] packageRepos = packageList.GetAllPackages(); DependencyDefinition[] dependencies = upfile.Dependencies; bool any_installed = upbring.InstalledPackage != null && upbring.InstalledPackage.Length != 0; if (dependencies.Length == 0) { EditorGUILayout.HelpBox("It seems that you didn't specify any dependency in the Upfile. Try refreshing it if you did.", MessageType.Warning); } else { foreach (DependencyDefinition dependency in dependencies) { string name = dependency.Name; EditorGUILayout.LabelField(name + ":", EditorStyles.boldLabel); bool installable = packageRepos.Any(pr => pr.Package.PackageName == name); bool installed = any_installed && upbring.InstalledPackage.Any(ip => ip.Name == name); string installed_version = installed ? upbring.GetInstalledPackage(name).Version : ""; if (installed) { EditorGUILayout.LabelField("- Installed version is " + installed_version); } else { EditorGUILayout.LabelField("- Not yet installed"); } if (!installable) { EditorGUILayout.HelpBox("No repository contains this package. Try specifying one whith this package in.", MessageType.Warning); } else { PackageRepo latestPackageRepo = packageList.GetLatestPackage(name); string latest_version = latestPackageRepo.Package.PackageVersion; EditorGUILayout.LabelField(string.Format("- Latest version is: {0} (from {1})", latest_version, latestPackageRepo.Repository.ToString())); GUI.enabled = installed && installed_version != latest_version; if (GUILayout.Button("Update to " + latest_version)) { Debug.Log(string.Format("Updating package {0} (to {1})", name, latest_version)); manager.UpdatePackage(latestPackageRepo); AssetDatabase.Refresh(); Repaint(); } GUI.enabled = true; } EditorGUILayout.Space(); } if (GUILayout.Button("Install all dependencies")) { manager.InstallDependencies(); AssetDatabase.Refresh(); Repaint(); } GUI.enabled = any_installed; if (GUILayout.Button("Update all installed packages")) { foreach (InstalledPackage package in upbring.InstalledPackage) { PackageRepo latestPackageRepo = packageList.GetLatestPackage(package.Name); if (package.Version != latestPackageRepo.Package.PackageVersion) { Debug.Log(string.Format("Updating package {0} (to {1})", package.Name, latestPackageRepo.Package.PackageVersion)); manager.UpdatePackage(latestPackageRepo); } } AssetDatabase.Refresh(); Repaint(); } GUI.enabled = true; if (GUILayout.Button("Refresh Upfile")) { Upfile.Instance(); Repaint(); } } }