Exemple #1
0
 public WwwInstaller(CLIContext context)
 {
     Context   = context;
     Starter   = new ProcessStarter(context.IndexDirectory);
     Verifier  = new WwwVerifier(context);
     SystemCtl = new SystemCtlHelper(context);
 }
Exemple #2
0
        public void Test_Install()
        {
            MoveToTemporaryDirectory();

            var random = new Random();

            var settings = new CLISettings();

            settings.SmtpServer      = "smtp.myserver" + random.Next(1000, 9000) + ".com";
            settings.SmtpUsername    = "******" + random.Next(1000, 9000);
            settings.SmtpPassword    = "******" + random.Next(1000, 9000);
            settings.Email           = "me@mydomain" + random.Next(1000, 9000) + ".com";
            settings.IsMockSystemCtl = true;

            var context = new CLIContext(Environment.CurrentDirectory, settings);

            var installer = new ArduinoPlugAndPlayInstaller(context);

            installer.Verifier.SystemCtl = new MockSystemCtlHelper(context);

            installer.EnsureInstallDirectoryExists();

            var installPath = installer.GetInstallPath();

            //File.WriteAllText(Path.Combine(installPath, "is-mock-systemctl.txt"), "true");

            installer.Install();

            //var starter = new ProcessStarter();

            //starter.StartBash("sudo systemctl disable arduino-plug-and-play.service");
            //starter.StartBash("sudo systemctl stop arduino-plug-and-play.service");
        }
 public MqttBridgeInstaller(CLIContext context)
 {
     Context  = context;
     Starter  = new ProcessStarter(context.IndexDirectory);
     Docker   = new DockerHelper(context);
     Verifier = new MqttBridgeVerifier(context);
     Services = new MqttBridgeServiceManager(context);
 }
 public UIControllerInstaller(CLIContext context)
 {
     Context  = context;
     Starter  = new ProcessStarter(context.IndexDirectory);
     Docker   = new DockerHelper(context);
     Verifier = new UIControllerVerifier(context);
     Services = new UIControllerServiceManager(context);
 }
Exemple #5
0
 public MosquittoInstaller(CLIContext context)
 {
     Context   = context;
     Starter   = new ProcessStarter(context.IndexDirectory);
     Docker    = new DockerHelper(context);
     Verifier  = new MosquittoVerifier(context);
     SystemCtl = new SystemCtlHelper(context);
 }
Exemple #6
0
        public void Test_Install()
        {
            MoveToTemporaryDirectory();

            var context = new CLIContext(Environment.CurrentDirectory, new CLISettings());

            var installer = new DockerInstaller(context);

            installer.Verifier.SystemCtl = new MockSystemCtlHelper(context);
            installer.Install();
        }
Exemple #7
0
        private void saveSetting(CLIContext context)
        {
            var filePath = Path.Combine(context.DataDirectoryFullPath, settingFileName);

            if (!File.Exists(filePath))
            {
                throw new Exception($"file not found({filePath}).");
            }
            var json = JsonConvert.SerializeObject(setting);

            File.WriteAllText(filePath, json);
        }
Exemple #8
0
        static void Main(string[] args)
        {
            var context          = new CLIContext(Environment.CurrentDirectory);
            var commandContainer = new CLICommandsContainer
            {
                { new CLICommandConfig("my command"), new MyCommand() },
                { new CLICommandConfig("with initialize"), new MyCommandWithInitialize() }
            };

            using (var driver = new Driver(commandContainer, context)) {
                driver.Run();
            }
        }
Exemple #9
0
        public void Initialize(CLIContext context)
        {
            this.context = context;

            CLIConsole.WriteLine($"({GetType().Name})Loading setting file...");
            var filePath = Path.Combine(this.context.DataDirectoryFullPath, settingFileName);

            if (!File.Exists(filePath))
            {
                File.Create(filePath).Close();
                saveSetting(context);
            }
            setting = loadSetting(filePath);
        }
Exemple #10
0
        static void Main(string[] args)
        {
            CLIConsole.WriteLine("Welcome to ClArc");
            CLIConsole.WriteLine();
            var commands = new CLICommandsContainer
            {
                { new CLICommandConfig("GenerateDefaultWebProject"), new CreateDefaultWebProjectCommand() },
                { new CLICommandConfig("UseCase"), new CreateUseCaseCommand() },
            };
            var context = new CLIContext(Environment.CurrentDirectory);

            using (var driver = new Driver(commands, context))
            {
                driver.Run();
            }
        }
        public void Test_Install()
        {
            MoveToTemporaryDirectory();

            PullDirectoryFromProject("/");

            File.WriteAllText(Path.GetFullPath("is-mock-systemctl.txt"), "true");

            var settings = new CLISettings();

            var context   = new CLIContext(Environment.CurrentDirectory, settings);
            var installer = new SupervisorInstaller(context);

            installer.Verifier.SystemCtl = new MockSystemCtlHelper(context);

            installer.Install();
        }
Exemple #12
0
        public PostInstaller(CLIContext context)
        {
            Context = context;

            Python             = new PythonInstaller();
            Docker             = new DockerInstaller(context);
            PlatformIO         = new PlatformIOInstaller();
            Mqtt               = new MosquittoInstaller(context);
            MqttBridge         = new MqttBridgeInstaller(context);
            UIController       = new UIControllerInstaller(context);
            ArduinoPlugAndPlay = new ArduinoPlugAndPlayInstaller(context);

            Supervisor = new SupervisorInstaller(context);
            WWW        = new WwwInstaller(context);

            SettingsManager = new SettingsManager(context.IndexDirectory);

            Verifier = new Verifier(context);
        }
Exemple #13
0
        public Verifier(CLIContext context) : base(context)
        {
            Context = context;
            Docker  = new DockerVerifier(context);

            ArduinoPlugAndPlay = new ArduinoPlugAndPlayVerifier(context);

            Mosquitto    = new MosquittoVerifier(context);
            MqttBridge   = new MqttBridgeVerifier(context);
            UIController = new UIControllerVerifier(context);

            Settings = new SettingsVerifier(context);

            Supervisor = new SupervisorVerifier(context);
            WWW        = new WwwVerifier(context);

            Version = new VersionVerifier(context);

            Console.WriteLine("GrowSense installation verified");
        }
Exemple #14
0
        public void Test_Initialize_IndexPath()
        {
            MoveToTemporaryDirectory();

            var startingDirectory = Environment.CurrentDirectory;

            var settings = new CLISettings();

            var context = new CLIContext(startingDirectory, settings);
            var paths   = new PathHelper(context);

            paths.Initialize(startingDirectory);

            var expectedParentPath = Path.GetFullPath(Environment.CurrentDirectory + "/../../").TrimEnd('/');

            Assert.AreEqual(expectedParentPath, context.ParentDirectory, "Parent path is not set correctly.");

            var expectedIndexDirectory = Environment.CurrentDirectory;

            Assert.AreEqual(expectedIndexDirectory, context.IndexDirectory, "Index directory is not set correctly.");
        }
Exemple #15
0
        public void Test_Install()
        {
            MoveToTemporaryDirectory();

            PullDirectoryFromProject("scripts/apps/Serial1602ShieldSystemUIController/");

            var random = new Random();

            var settings = new CLISettings();

            settings.MqttUsername = "******" + random.Next(1000, 9000);
            settings.MqttPassword = "******" + random.Next(1000, 9000);
            settings.MqttHost     = "10.0.0." + random.Next(0, 240);

            settings.SmtpServer   = "smtp.myserver" + random.Next(1000, 9000) + ".com";
            settings.SmtpUsername = "******" + random.Next(1000, 9000);
            settings.SmtpPassword = "******" + random.Next(1000, 9000);
            settings.Email        = "me@mydomain" + random.Next(1000, 9000) + ".com";

            var context = new CLIContext(Environment.CurrentDirectory, settings);
            var uiControllerInstaller = new UIControllerInstaller(context);

            uiControllerInstaller.Install();
        }
Exemple #16
0
        public void Test_Install()
        {
            MoveToTemporaryDirectory();

            PullDirectoryFromProject("scripts/apps/BridgeArduinoSerialToMqttSplitCsv/");

            var random = new Random();

            var settings = new CLISettings();

            settings.MqttUsername = "******" + random.Next(1000, 9000);
            settings.MqttPassword = "******" + random.Next(1000, 9000);
            settings.MqttHost     = "10.0.0." + random.Next(0, 240);

            settings.SmtpServer   = "smtp.myserver" + random.Next(1000, 9000) + ".com";
            settings.SmtpUsername = "******" + random.Next(1000, 9000);
            settings.SmtpPassword = "******" + random.Next(1000, 9000);
            settings.Email        = "me@mydomain" + random.Next(1000, 9000) + ".com";

            var context             = new CLIContext(Environment.CurrentDirectory, settings);
            var mqttBridgeInstaller = new MqttBridgeInstaller(context);

            mqttBridgeInstaller.Install();
        }
        public void Test_Install()
        {
            MoveToTemporaryDirectory();

            PullFileFromProject("scripts/docker/mosquitto/data/mosquitto.conf");

            var random = new Random();

            var settings = new CLISettings();

            settings.MqttUsername = "******" + random.Next(1000, 9000);
            settings.MqttPassword = "******" + random.Next(1000, 9000);

            var context            = new CLIContext(Environment.CurrentDirectory, settings);
            var mosquittoInstaller = new MosquittoInstaller(context);

            mosquittoInstaller.Docker          = new MockDockerHelper(context);
            mosquittoInstaller.Verifier.Docker = mosquittoInstaller.Docker;
            mosquittoInstaller.SystemCtl       = new MockSystemCtlHelper(context);

            mosquittoInstaller.Install();

            mosquittoInstaller.Docker.Remove("mosquitto", true);
        }
Exemple #18
0
 public MockDockerHelper(CLIContext context) : base(context)
 {
 }
Exemple #19
0
 public BaseVerifier(CLIContext context)
 {
     Context   = context;
     Starter   = new ProcessStarter(context.IndexDirectory);
     SystemCtl = new SystemCtlHelper(context);
 }
Exemple #20
0
 public DockerHelper(CLIContext context)
 {
     Context = context;
     Starter = new ProcessStarter(context.IndexDirectory);
 }
Exemple #21
0
 public SystemCtlHelper(CLIContext context)
 {
     Context = context;
     Starter = new ProcessStarter(Context.IndexDirectory);
 }
Exemple #22
0
        private bool CheckSetting(CLIContext context)
        {
            if (setting.IsSetuped)
            {
                if (ValidSolution(setting.SolutionFullPath) && ValidProject(setting.WebProjectDirectoryPath))
                {
                    CLIConsole.WriteLine("Current target solution is " + setting.SolutionFullPath);
                    var result = Prompt.ShowYesNoPrompt("Would you want to change project directory?", YesNoPrompt.Result.No);
                    switch (result)
                    {
                    case YesNoPrompt.Result.Yes:
                        setting.Clear();
                        break;

                    case YesNoPrompt.Result.No:
                        return(true);

                    default:
                        return(false);
                    }
                }
                else
                {
                    setting.Clear();
                }
            }

            if (!setting.IsSetuped)
            {
                while (!setting.IsSetupSolution)
                {
                    var(isQuit, input) = Prompt.ShowQuitable(@"Type your solution by full path.");
                    if (isQuit)
                    {
                        return(false);
                    }

                    if (ValidSolution(input))
                    {
                        CLIConsole.WriteLine("Solution file accepted");
                        setting.SaveSolutionFullPath(input);
                        saveSetting(context);
                    }
                    else
                    {
                        CLIConsole.WriteLine("The file is not solution file.");
                    }
                }

                while (!setting.IsSetupWebProject)
                {
                    var(isQuit, input) = Prompt.ShowQuitable(@"Type your web project directory by full path.");
                    if (isQuit)
                    {
                        return(false);
                    }

                    if (ValidProject(input))
                    {
                        CLIConsole.WriteLine("Project direcotry accepted");
                        setting.SaveWebProjectFullPath(input);
                        saveSetting(context);
                    }
                    else
                    {
                        CLIConsole.WriteLine("The file is not web project directory.");
                    }
                }
            }
            return(true);
        }
Exemple #23
0
 public ArduinoPlugAndPlayVerifier(CLIContext context) : base(context)
 {
     SystemCtl = new SystemCtlHelper(context);
 }
Exemple #24
0
 public MqttBridgeServiceManager(CLIContext context)
 {
     Context   = context;
     SystemCtl = new SystemCtlHelper(context);
     Verifier  = new MqttBridgeServiceVerifier(context);
 }
 public ArduinoPlugAndPlayInstaller(CLIContext context)
 {
     Context  = context;
     Starter  = new ProcessStarter(context.IndexDirectory);
     Verifier = new ArduinoPlugAndPlayVerifier(context);
 }
Exemple #26
0
        public DockerInstaller(CLIContext context)
        {
            Context = context;

            Verifier = new DockerVerifier(context);
        }
Exemple #27
0
 public UIControllerVerifier(CLIContext context) : base(context)
 {
 }
Exemple #28
0
 public MosquittoVerifier(CLIContext context)
 {
     Docker  = new DockerHelper(context);
     Context = context;
 }
Exemple #29
0
 public WwwVerifier(CLIContext context) : base(context)
 {
 }
 public UIControllerServiceManager(CLIContext context)
 {
     Context   = context;
     SystemCtl = new SystemCtlHelper(context);
     Verifier  = new UIControllerServiceVerifier(context);
 }