Ejemplo n.º 1
0
        private static void LoadAndVerifyConfig()
        {
            if (!File.Exists(@".\config.json"))
            {
                throw new ApplicationException("There is no config.json file. Run SqlCi.Console -i to get started.");
            }

            _configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(@".\config.json"));
            _configuration.Verify();
        }
Ejemplo n.º 2
0
        private static void Initialize()
        {
            // if there is already a config file we should just exit
            if (File.Exists("config.json"))
            {
                throw new ApplicationException("config.json already exists.");
            }

            // create a configuration with defaults
            var configuration = new Configuration
            {
                ScriptsFolder      = ".\\Scripts",
                ResetScriptsFolder = ".\\ResetScripts",
                ScriptTable        = "ScriptTable",
                Version            = "1.0.0",
            };

            configuration.Environments.Add(new EnvironmentConfiguration
            {
                Name          = "local",
                ResetDatabase = true
            });

            // create the config.json file
            File.WriteAllText("config.json", JsonConvert.SerializeObject(configuration, Formatting.Indented));

            ShowStatusUpdate(new StatusUpdateEvent("Created config.json", StatusLevelEnum.Success));

            // ensure that the default Scripts folder exists
            if (!Directory.Exists("Scripts"))
            {
                Directory.CreateDirectory("Scripts");
                ShowStatusUpdate(new StatusUpdateEvent("Created Scripts directory", StatusLevelEnum.Success));
            }

            // ensure that hte default ResetScripts folder exists
            if (!Directory.Exists("ResetScripts"))
            {
                Directory.CreateDirectory("ResetScripts");
                ShowStatusUpdate(new StatusUpdateEvent("Created ResetScripts directory", StatusLevelEnum.Success));
            }

            // load up this default configuration
            _configuration = configuration;

            // create the first baseline script
            GenerateScript("all", "baseline");
            ShowStatusUpdate(new StatusUpdateEvent("Created baseline script in Scripts directory", StatusLevelEnum.Success));
        }