Exemplo n.º 1
0
        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);
                }
            });
        }
Exemplo n.º 2
0
        public static void InstallCustomPackage(string name, string url, string version = null)
        {
            // TODO: verify this version exists
            // TODO: verify not already installed

            var relativeInstallDirectory = Settings.RelativePackagesDirectoryPath + name;
            var absoluteInstallDirectory = Settings.AbsolutePackagesDirectoryPath + name;
            var args = new InstallPackageArgs(name, url, version);

            Dispatcher.Dispatch(ActionTypes.PACKAGE_INSTALLATION_STARTED, args);

            var operation = new AsyncOperation();

            operation.Add(new AddSubmoduleTask(url, relativeInstallDirectory));

            if (!string.IsNullOrEmpty(version))
            {
                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);
                }
            });
        }
Exemplo n.º 3
0
        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));
                }
            });
        }