コード例 #1
0
ファイル: WwwInstaller.cs プロジェクト: GrowSense/Index
 public WwwInstaller(CLIContext context)
 {
     Context   = context;
     Starter   = new ProcessStarter(context.IndexDirectory);
     Verifier  = new WwwVerifier(context);
     SystemCtl = new SystemCtlHelper(context);
 }
コード例 #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");
        }
コード例 #3
0
 public MqttBridgeInstaller(CLIContext context)
 {
     Context  = context;
     Starter  = new ProcessStarter(context.IndexDirectory);
     Docker   = new DockerHelper(context);
     Verifier = new MqttBridgeVerifier(context);
     Services = new MqttBridgeServiceManager(context);
 }
コード例 #4
0
 public UIControllerInstaller(CLIContext context)
 {
     Context  = context;
     Starter  = new ProcessStarter(context.IndexDirectory);
     Docker   = new DockerHelper(context);
     Verifier = new UIControllerVerifier(context);
     Services = new UIControllerServiceManager(context);
 }
コード例 #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);
 }
コード例 #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();
        }
コード例 #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);
        }
コード例 #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();
            }
        }
コード例 #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);
        }
コード例 #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();
            }
        }
コード例 #11
0
        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();
        }
コード例 #12
0
ファイル: PostInstaller.cs プロジェクト: GrowSense/Index
        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);
        }
コード例 #13
0
ファイル: Verifier.cs プロジェクト: GrowSense/Index
        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");
        }
コード例 #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.");
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #17
0
        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);
        }
コード例 #18
0
ファイル: MockDockerHelper.cs プロジェクト: GrowSense/Index
 public MockDockerHelper(CLIContext context) : base(context)
 {
 }
コード例 #19
0
ファイル: BaseVerifier.cs プロジェクト: GrowSense/Index
 public BaseVerifier(CLIContext context)
 {
     Context   = context;
     Starter   = new ProcessStarter(context.IndexDirectory);
     SystemCtl = new SystemCtlHelper(context);
 }
コード例 #20
0
 public DockerHelper(CLIContext context)
 {
     Context = context;
     Starter = new ProcessStarter(context.IndexDirectory);
 }
コード例 #21
0
ファイル: SystemCtlHelper.cs プロジェクト: GrowSense/Index
 public SystemCtlHelper(CLIContext context)
 {
     Context = context;
     Starter = new ProcessStarter(Context.IndexDirectory);
 }
コード例 #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);
        }
コード例 #23
0
 public ArduinoPlugAndPlayVerifier(CLIContext context) : base(context)
 {
     SystemCtl = new SystemCtlHelper(context);
 }
コード例 #24
0
 public MqttBridgeServiceManager(CLIContext context)
 {
     Context   = context;
     SystemCtl = new SystemCtlHelper(context);
     Verifier  = new MqttBridgeServiceVerifier(context);
 }
コード例 #25
0
 public ArduinoPlugAndPlayInstaller(CLIContext context)
 {
     Context  = context;
     Starter  = new ProcessStarter(context.IndexDirectory);
     Verifier = new ArduinoPlugAndPlayVerifier(context);
 }
コード例 #26
0
ファイル: DockerInstaller.cs プロジェクト: GrowSense/Index
        public DockerInstaller(CLIContext context)
        {
            Context = context;

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