예제 #1
0
        public void Run(bool firstRun)
        {
            Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);

            var initEnvironmentTask = new ActionTask <NPath>(CancellationToken,
                                                             (_, path) => InitializeEnvironment(path))
            {
                Affinity = TaskAffinity.UI
            };

            isBusy = true;

            var octorunInstaller = new OctorunInstaller(Environment, TaskManager);
            var setupTask        = octorunInstaller
                                   .SetupOctorunIfNeeded()
                                   .Then((s, octorunPath) =>
            {
                Environment.OctorunScriptPath = octorunPath;
            });

            var initializeGitTask = new FuncTask <NPath>(CancellationToken, () =>
            {
                var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
                if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists())     // we have a git path
                {
                    Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
                    return(gitExecutablePath.Value);
                }
                return(NPath.Default);
            });

            initializeGitTask.OnEnd += (t, path, _, __) =>
            {
                if (path.IsInitialized)
                {
                    return;
                }

                Logger.Trace("Using portable git");

                var gitInstaller = new GitInstaller(Environment, ProcessManager, TaskManager);

                var task = gitInstaller.SetupGitIfNeeded();
                task.Progress(progressReporter.UpdateProgress);
                task.OnEnd += (thisTask, result, success, exception) =>
                {
                    thisTask.GetEndOfChain().Then(initEnvironmentTask, taskIsTopOfChain: true);
                };

                // append installer task to top chain
                t.Then(task, taskIsTopOfChain: true);
            };

            setupTask.Then(initializeGitTask).Start();
        }
예제 #2
0
        public void Run(bool firstRun)
        {
            Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);

            var octorunScriptPath = Environment.UserCachePath.Combine("octorun", "src", "bin", "app.js");

            Logger.Trace("Using octorunScriptPath: {0}", octorunScriptPath);

            var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();

            if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path
            {
                Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
                InitializeEnvironment(gitExecutablePath.Value, octorunScriptPath);
            }
            else // we need to go find git
            {
                Logger.Trace("No git path found in settings");

                var initEnvironmentTask = new ActionTask <NPath>(CancellationToken, (_, path) => InitializeEnvironment(path, octorunScriptPath))
                {
                    Affinity = TaskAffinity.UI
                };
                var findExecTask = new FindExecTask("git", CancellationToken)
                                   .FinallyInUI((b, ex, path) => {
                    if (b && path.IsInitialized)
                    {
                        Logger.Trace("FindExecTask Success: {0}", path);
                        InitializeEnvironment(path, octorunScriptPath);
                    }
                    else
                    {
                        Logger.Warning("FindExecTask Failure");
                        Logger.Error("Git not found");
                    }
                });

                var installDetails = new GitInstallDetails(Environment.UserCachePath, true);
                var gitInstaller   = new GitInstaller(Environment, CancellationToken, installDetails);

                // if successful, continue with environment initialization, otherwise try to find an existing git installation
                gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask);
            }
        }
예제 #3
0
        public void Run(bool firstRun)
        {
            Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);

            var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();

            if (gitExecutablePath != null && gitExecutablePath.FileExists()) // we have a git path
            {
                Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
                InitializeEnvironment(gitExecutablePath);
            }
            else // we need to go find git
            {
                Logger.Trace("No git path found in settings");

                var initEnvironmentTask = new ActionTask <NPath>(CancellationToken, (b, path) => InitializeEnvironment(path))
                {
                    Affinity = TaskAffinity.UI
                };
                var findExecTask = new FindExecTask("git", CancellationToken)
                                   .FinallyInUI((b, ex, path) => {
                    if (b && path != null)
                    {
                        Logger.Trace("FindExecTask Success: {0}", path);
                        InitializeEnvironment(gitExecutablePath);
                    }
                    else
                    {
                        Logger.Warning("FindExecTask Failure");
                        Logger.Error("Git not found");
                    }
                });

                var applicationDataPath = Environment.GetSpecialFolder(System.Environment.SpecialFolder.LocalApplicationData).ToNPath();
                var installDetails      = new GitInstallDetails(applicationDataPath, true);
                var gitInstaller        = new GitInstaller(Environment, CancellationToken, installDetails);

                // if successful, continue with environment initialization, otherwise try to find an existing git installation
                gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask);
            }
        }
예제 #4
0
        private async Task <NPath> DetermineGitExecutablePath(ProgressReport progress = null)
        {
            var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();

            if (gitExecutablePath != null && gitExecutablePath.FileExists())
            {
                Logger.Trace("Using git install path from settings");
                return(gitExecutablePath);
            }

            var gitInstaller = new GitInstaller(Environment, CancellationToken);
            var setupDone    = await gitInstaller.SetupIfNeeded(progress?.Percentage, progress?.Remaining);

            if (setupDone)
            {
                Logger.Trace("Setup performed using new path");
                return(gitInstaller.GitExecutablePath);
            }

            Logger.Trace("Finding git install path");
            return(await GitClient.FindGitInstallation().SafeAwait());
        }
예제 #5
0
        public void Run(bool firstRun)
        {
            Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);
            isBusy = true;

            var endTask = new ActionTask <GitInstaller.GitInstallationState>(CancellationToken,
                                                                             (_, state) => InitializeEnvironment(state))
            {
                Affinity = TaskAffinity.UI
            };

            ITask <string> setExistingEnvironmentPath;

            if (Environment.IsMac)
            {
                setExistingEnvironmentPath = new SimpleProcessTask(CancellationToken, "bash".ToNPath(), "-c \"/usr/libexec/path_helper\"")
                                             .Configure(ProcessManager, dontSetupGit: true)
                                             .Catch(e => true) // make sure this doesn't throw if the task fails
                                             .Then((success, path) => success ? path?.Split(new[] { "\"" }, StringSplitOptions.None)[1] : null);
            }
            else
            {
                setExistingEnvironmentPath = new FuncTask <string>(CancellationToken, () => null);
            }

            setExistingEnvironmentPath.OnEnd += (t, path, success, ex) =>
            {
                if (path != null)
                {
                    Logger.Trace("Existing Environment Path Original:{0} Updated:{1}", Environment.Path, path);
                    Environment.Path = path;
                }
            };

            var setupOctorun          = new OctorunInstaller(Environment, TaskManager).SetupOctorunIfNeeded();
            var setOctorunEnvironment = new ActionTask <NPath>(CancellationToken,
                                                               (s, octorunPath) => Environment.OctorunScriptPath = octorunPath);

            var getGitFromSettings = new FuncTask <NPath>(CancellationToken, () =>
            {
                var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
                if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path
                {
                    Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
                    return(gitExecutablePath.Value);
                }
                return(NPath.Default);
            });

            getGitFromSettings.OnEnd += (t, path, _, __) =>
            {
                if (path.IsInitialized)
                {
                    var state = new GitInstaller.GitInstallationState {
                        GitExecutablePath = path,
                        GitIsValid        = true
                    };
                    endTask.PreviousResult = state;
                    endTask.Start();
                    return;
                }
                Logger.Trace("Using portable git");

                var setupGit = new GitInstaller(Environment, ProcessManager, TaskManager).SetupGitIfNeeded();
                t.Then(setupGit);
                setupGit.Finally((s, state) =>
                {
                    endTask.PreviousResult = state;
                    endTask.Start();
                });
                setupGit.Progress(progressReporter.UpdateProgress);
                // append installer task to top chain
            };

            var setupChain = setExistingEnvironmentPath.Then(setupOctorun);

            setupChain.OnEnd += (t, path, _, __) =>
            {
                t.GetEndOfChain().Then(setOctorunEnvironment).Then(getGitFromSettings);
            };

            setupChain.Start();
        }