public static void InstallPackage(AvailablePackage package, string version) { // TODO: verify this version exists // TODO: verify not already installed var relativeInstallDirectory = Settings.RelativePackagesDirectoryPath + package.Name; var absoluteInstallDirectory = Settings.AbsolutePackagesDirectoryPath + package.Name; var args = new InstallPackageArgs(package, version); var operation = new AsyncOperation(); operation.AddSync(() => { Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_STARTED, args); }); operation.Add(new AddSubmoduleTask(package.GitUrl, relativeInstallDirectory)); operation.Add(new CheckoutSubmoduleTask(absoluteInstallDirectory, version)); operation.Execute(result => { if (result.IsError) { Debug.LogError("Error installing package"); Debug.LogError(result.Error.Message); Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_FAILED); } else { Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_COMPLETE, args); } }); }
public static void SwitchVersion(AvailablePackage package, string version) { // TODO: Verify that this package is actually installed var absoluteInstallDirectory = Settings.AbsolutePackagesDirectoryPath + package.Name; Dispatcher.Dispatch(ActionTypes.SWITCH_PACKAGE_VERSION_STARTED); var operation = new AsyncOperation(); operation.Add(new GitTask("fetch") { WorkingDirectory = absoluteInstallDirectory }); operation.Add(new CheckoutSubmoduleTask(absoluteInstallDirectory, version)); operation.Execute(result => { if (result.IsError) { Debug.LogError("Failed to switch package version: " + package.Name + "@" + version); Debug.LogError(result.Error.Message); Dispatcher.Dispatch(ActionTypes.SWITCH_PACKAGE_VERSION_FAILED); } else { Debug.Log("Switched package: " + package.Name + " to version: " + version); Dispatcher.Dispatch(ActionTypes.SWITCH_PACKAGE_VERSION_COMPLETE, new SwitchPackageArgs(package, version)); } }); }
public PackageView(AvailablePackage package) { this.package = package; style.height = 32; style.flexDirection = FlexDirection.Row; style.marginBottom = style.marginTop = style.marginLeft = style.marginRight = 4; style.alignItems = Align.Center; style.borderRadius = 4; packageName = new Label(package.Name); packageName.style.fontSize = FontSizes.packageRow; packageName.style.flex = 1; packageName.style.textColor = Colors.packageRowText; versionSelector = new PopupField <string>(package.Versions.ToList(), package.Versions.Last()); versionSelector.style.width = 100; versionSelector.style.height = 24; versionSelector.style.paddingRight = 12; versionSelector.style.textAlignment = TextAnchor.MiddleCenter; versionSelector.style.fontSize = FontSizes.packageRow; versionSelector.OnValueChanged(HandleVersionSelectorValueChanged); infoButton = new Button(HandleInfoClicked); infoButton.style.width = 40; infoButton.text = "Info"; installButton = new Button(HandleInstallClicked); installButton.style.width = 60; installButton.text = "Install"; switchVersionButton = new Button(HandleSwitchVersionClicked); switchVersionButton.style.width = 60; switchVersionButton.text = "Install"; installedLabel = new Label("Installed"); installedLabel.style.width = 60; installedLabel.style.fontSize = FontSizes.packageRow; installedLabel.style.textColor = Colors.packageRowText; removeButton = new Button(HandleRemoveClicked); removeButton.style.width = 30; removeButton.text = "X"; style.backgroundColor = Colors.packageRowBackground; isPackageInstalled = BindToDerivedState(packages.InstalledPackages, installedPackages => installedPackages.Packages.Any(p => p.Name == package.Name)); Init(); }
public static void RemovePackage(AvailablePackage package) { var installDirectory = Settings.RelativePackagesDirectoryPath + package.Name; Dispatcher.Dispatch(ActionTypes.REMOVE_PACKAGE_STARTED, package); var task = ActionEpics.RemoveSubmodule(installDirectory); task.Execute(result => { if (result.IsError) { Debug.LogError("Failed to removed submodule: " + installDirectory); Debug.LogError(result.Error.Message); Dispatcher.Dispatch(ActionTypes.REMOVE_PACKAGE_FAILED); } else { Debug.Log("Successfully removed submodule: " + installDirectory); Dispatcher.Dispatch(ActionTypes.REMOVE_PACKAGE_COMPLETE, package); } }); }
public SwitchPackageArgs(AvailablePackage package, string version) { Package = package; Version = version; }
public InstallPackageArgs(AvailablePackage package, string version) { PackageName = package.Name; GitUrl = package.GitUrl; Version = version; }