Exemple #1
0
        public void FlattensTopLevelScalarNodes()
        {
            // Given
            IDocument document = Substitute.For<IDocument>();
            IEnumerable<KeyValuePair<string, object>> items = null;
            document
                .When(x => x.Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>()))
                .Do(x => items = x.Arg<IEnumerable<KeyValuePair<string, object>>>());
            document.Content.Returns(@"
A: 1
B: true
C: Yes
");
            Yaml yaml = new Yaml();

            // When
            yaml.Execute(new[] { document }, null).ToList();  // Make sure to materialize the result list

            // Then
            document.Received(1).Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>());
            Assert.AreEqual(3, items.Count());
            Assert.AreEqual("1", items.First(x => x.Key == "A").Value);
            Assert.AreEqual("true", items.First(x => x.Key == "B").Value);
            Assert.AreEqual("Yes", items.First(x => x.Key == "C").Value);
        }
Exemple #2
0
        public void GeneratesDynamicObject()
        {
            // Given
            IDocument document = Substitute.For<IDocument>();
            IEnumerable<KeyValuePair<string, object>> items = null;
            document
                .When(x => x.Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>()))
                .Do(x => items = x.Arg<IEnumerable<KeyValuePair<string, object>>>());
            document.Content.Returns(@"
A: 1
B: true
C: Yes
");
            Yaml yaml = new Yaml("MyYaml");

            // When
            yaml.Execute(new[] { document }, null).ToList();  // Make sure to materialize the result list

            // Then
            document.Received(1).Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>());
            Assert.AreEqual(1, items.Count());
            Assert.IsInstanceOf<DynamicYaml>(items.First().Value);
            Assert.AreEqual(1, (int)((dynamic)items.First().Value).A);
            Assert.AreEqual(true, (bool)((dynamic)items.First().Value).B);
            Assert.AreEqual("Yes", (string)((dynamic)items.First().Value).C);
        }
Exemple #3
0
        public void CanParseFile()
        {
            var yaml = new Yaml();
            var parsed = yaml.ParseFile(@"Resources\Sample.yaml");

            Assert.That(parsed[0].ToString(), Is.EqualTo("hello"));
            Assert.That(parsed[1].ToString(), Is.EqualTo("there"));
        }
Exemple #4
0
        public void SetsMetadataKey()
        {
            // Given
            IDocument document = Substitute.For<IDocument>();
            document.Content.Returns(@"A: 1");
            Yaml yaml = new Yaml("MyYaml");

            // When
            yaml.Execute(new [] { document }, null).ToList();  // Make sure to materialize the result list

            // Then
            document.Received(1).Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>());
            document.Received().Clone(Arg.Is<IEnumerable<KeyValuePair<string, object>>>(x => x.First().Key == "MyYaml"));
        }
Exemple #5
0
        public void CanParseText()
        {
            var content = string.Join(Environment.NewLine, new[]
            {
                "- hello",
                "- there"
            });

            var yaml = new Yaml();
            var parsed = yaml.ParseText(content);

            Assert.That(parsed[0].ToString(), Is.EqualTo("hello"));
            Assert.That(parsed[1].ToString(), Is.EqualTo("there"));
        }
Exemple #6
0
        public void CanParseMoreComplexFile()
        {
            var yaml = new Yaml();
            var parsed = yaml.ParseFile(@"Resources\NestedSample.yaml");

            ValidatePersonYaml(parsed[0] as YamlMapping, "James", "23", new[]
            {
                "01234 432123",
                "01234 455674"
            });
            ValidatePersonYaml(parsed[1] as YamlMapping, "Sara", "23", new[]
            {
                "03323 412314",
                "03432 885443"
            });
        }
 public void VerifyTokensOnExample7()
 {
     AssertSequenceOfEventsFrom(Yaml.ParserForResource("07-scalar-styles.yaml"),
                                StreamStart,
                                DocumentStart(Explicit),
                                PlainScalar(string.Empty),
                                DocumentEnd(Implicit),
                                DocumentStart(Explicit),
                                PlainScalar("a plain scalar"),
                                DocumentEnd(Implicit),
                                DocumentStart(Explicit),
                                SingleQuotedScalar("a single-quoted scalar"),
                                DocumentEnd(Implicit),
                                DocumentStart(Explicit),
                                DoubleQuotedScalar("a double-quoted scalar"),
                                DocumentEnd(Implicit),
                                DocumentStart(Explicit),
                                LiteralScalar("a literal scalar"),
                                DocumentEnd(Implicit),
                                DocumentStart(Explicit),
                                FoldedScalar("a folded scalar"),
                                DocumentEnd(Implicit),
                                StreamEnd);
 }
Exemple #8
0
        public async Task <Extensionsv1beta1Ingress> CreateExtensionsv1beta1IngressAsync(
            string extensionsv1beta1IngressContent,
            string namespaceParameter           = null,
            CancellationToken cancellationToken = default
            )
        {
            try {
                Log.Verbose("Loading k8s Ingress definition ...");
                var extensionsv1beta1IngressDefinition = Yaml
                                                         .LoadFromString <Extensionsv1beta1Ingress>(
                    extensionsv1beta1IngressContent
                    );

                if (null != namespaceParameter)
                {
                    extensionsv1beta1IngressDefinition.Metadata.NamespaceProperty = namespaceParameter;
                }

                Log.Verbose($"Creating k8s Ingress: " +
                            $"{extensionsv1beta1IngressDefinition.Metadata.Name} ...");
                var extensionsv1beta1Ingress = await _k8sClient
                                               .CreateNamespacedIngressAsync(
                    extensionsv1beta1IngressDefinition,
                    extensionsv1beta1IngressDefinition.Metadata.NamespaceProperty,
                    cancellationToken : cancellationToken
                    );

                Log.Verbose($"Created k8s Ingress: {extensionsv1beta1Ingress.Metadata.Name}");

                return(extensionsv1beta1Ingress);
            }
            catch (Exception ex) {
                Log.Error(ex, $"Failed to create k8s Ingress");
                throw;
            }
        }
        public void LoadPropertyNamedReadOnlyFromString()
        {
            var content = @"apiVersion: v1
kind: Pod
metadata:
  namespace: bar
  name: foo
spec:
  containers:
    - image: nginx
      volumeMounts:
      - name: vm1
        mountPath: /vm1
        readOnly: true
      - name: vm2
        mountPath: /vm2
        readOnly: false
";

            var obj = Yaml.LoadFromString <V1Pod>(content);

            Assert.True(obj.Spec.Containers[0].VolumeMounts[0].ReadOnlyProperty);
            Assert.False(obj.Spec.Containers[0].VolumeMounts[1].ReadOnlyProperty);
        }
Exemple #10
0
        public static List <BuildScriptWithBuildData> PrepareBuildScriptsFromYaml(Dep dep)
        {
            var buildSections = Yaml.BuildParser(dep.Name).Get(dep.Configuration);

            var result = new List <BuildScriptWithBuildData>();

            foreach (var buildSection in buildSections)
            {
                if (buildSection.Target.IsFakeTarget())
                {
                    result.Add(null);
                }
                else
                {
                    var script       = buildSection.Tool.Name == "msbuild" ? BuildMsbuildScript(buildSection, dep.Name) : BuildShellScript(buildSection);
                    var scriptIfFail = buildSection.Tool.Name == "msbuild" ? BuildMsbuildScript(buildSection, dep.Name) : BuildShellScript(buildSection);
                    result.Add(new BuildScriptWithBuildData(
                                   script,
                                   scriptIfFail,
                                   buildSection));
                }
            }
            return(result);
        }
Exemple #11
0
 public void CommentsAreOmittedUnlessRequested()
 {
     AssertSequenceOfEventsFrom(Yaml.ParserForText(@"
             # Top comment
             - first # Comment on first item
             - second
             - # a mapping
                ? key # my key
                : value # my value
             # Bottom comment
         "),
                                StreamStart,
                                DocumentStart(Implicit),
                                BlockSequenceStart,
                                PlainScalar("first"),
                                PlainScalar("second"),
                                BlockMappingStart,
                                PlainScalar("key"),
                                PlainScalar("value"),
                                MappingEnd,
                                SequenceEnd,
                                DocumentEnd(Implicit),
                                StreamEnd);
 }
Exemple #12
0
        public void ScannerIsSerializable()
        {
            var sut = Yaml.ScannerForText(@"
                - one
                - two
                - three
            ");

            AssertPartialSequenceOfTokensFrom(sut,
                                              StreamStart,
                                              BlockSequenceStart,
                                              BlockEntry,
                                              PlainScalar("one"),
                                              BlockEntry,
                                              PlainScalar("two"));

            var buffer    = new MemoryStream();
            var formatter = new BinaryFormatter();

            formatter.Serialize(buffer, sut);

            AssertSequenceOfTokensFrom(sut,
                                       BlockEntry,
                                       PlainScalar("three"),
                                       BlockEnd,
                                       StreamEnd);

            buffer.Position = 0;
            sut             = (Scanner)formatter.Deserialize(buffer);

            AssertSequenceOfTokensFrom(sut,
                                       BlockEntry,
                                       PlainScalar("three"),
                                       BlockEnd,
                                       StreamEnd);
        }
Exemple #13
0
 public void VerifyTokensOnExample12()
 {
     AssertSequenceOfEventsFrom(Yaml.ParserForResource("12-compact-sequence.yaml"),
                                StreamStart,
                                DocumentStart(Implicit),
                                BlockSequenceStart,
                                BlockSequenceStart,
                                PlainScalar("item 1"),
                                PlainScalar("item 2"),
                                SequenceEnd,
                                BlockMappingStart,
                                PlainScalar("key 1"),
                                PlainScalar("value 1"),
                                PlainScalar("key 2"),
                                PlainScalar("value 2"),
                                MappingEnd,
                                BlockMappingStart,
                                PlainScalar("complex key"),
                                PlainScalar("complex value"),
                                MappingEnd,
                                SequenceEnd,
                                DocumentEnd(Implicit),
                                StreamEnd);
 }
Exemple #14
0
 private Scanner ScannerFor(string name)
 {
     return(new Scanner(Yaml.StreamFrom(name)));
 }
        public void GenericDictionaryThatDoesNotImplementIDictionaryCanBeDeserialized()
        {
            var sut          = new Deserializer();
            var deserialized = sut.Deserialize <GenericTestDictionary <string, string> >(Yaml.ReaderForText(@"
                a: 1
                b: 2
            "));

            Assert.Equal("1", deserialized["a"]);
            Assert.Equal("2", deserialized["b"]);
        }
Exemple #16
0
        internal async Task <int> Main()
        {
            Console.WriteLine("This utility will walk you through setting up a brand new FiveM server with NFive installed.");
            Console.WriteLine();
            Console.WriteLine("If you already have FiveM server installed you should cancel and use `nfpm init`.");
            Console.WriteLine();
            Console.WriteLine("Press ^C at any time to quit.");
            Console.WriteLine();

            var config = new ConfigGenerator();

            config.Hostname = ParseSimple("server name", "NFive");
            var serverMaxPlayers = ParseSimple("server max players", "32");

            config.Tags       = ParseSimple("server tags (separate with space)", "nfive").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            config.LicenseKey = ParseSimple("server license key (https://keymaster.fivem.net/)", "<skip>");

            Console.WriteLine();

            Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "resources", "nfive"));

            var definition = new Definition
            {
                Name    = "local/nfive-install",
                Version = "1.0.0"
            };

            using (var client = new WebClient())
            {
                Console.WriteLine("Finding latest FiveM Windows server version...");

                var yml = await client.DownloadStringTaskAsync("https://nfive.io/fivem/server-versions-windows.yml");

                var versions = Yaml.Deserialize <List <string> >(yml);
                var latest   = versions.First();

                Console.WriteLine($"Downloading FiveM server v{latest.Split(new[] { '-' }, 2)[0]}...");

                var data = await client.DownloadDataTaskAsync($"https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/{latest}/server.zip");

                Console.WriteLine("Installing FiveM server...");

                using (var stream = new MemoryStream(data))
                    using (var zip = ZipFile.Read(stream))
                    {
                        zip.ExtractAll(Environment.CurrentDirectory, ExtractExistingFileAction.OverwriteSilently);
                    }

                Console.WriteLine();
                Console.WriteLine("Downloading NFive...");

                data = await client.DownloadDataTaskAsync("https://ci.appveyor.com/api/projects/NFive/nfive/artifacts/nfive.zip");

                Console.WriteLine("Installing NFive...");

                using (var stream = new MemoryStream(data))
                    using (var zip = ZipFile.Read(stream))
                    {
                        zip.ExtractAll(Path.Combine(Environment.CurrentDirectory, "resources", "nfive"), ExtractExistingFileAction.OverwriteSilently);
                    }
            }

            config.Serialize().Save(Path.Combine(Environment.CurrentDirectory, "server.cfg"));
            File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "resources", "nfive", "nfive.yml"), Yaml.Serialize(definition));

            Console.WriteLine();
            Console.WriteLine("Installation is complete, you can now start the server with `nfpm start`!");

            return(await Task.FromResult(0));
        }
Exemple #17
0
 public void Save(string path = Program.LockFile)
 {
     File.WriteAllText(path, Yaml.Serialize(this));
 }
Exemple #18
0
 private static TokensList ModuleConfigs(string moduleName)
 {
     return(TokensList.Create(
                Yaml.ConfigurationParser(moduleName).GetConfigurations()));
 }
Exemple #19
0
 /// <summary>
 /// Serialize this instance and saves the file to the specified path.
 /// </summary>
 /// <param name="path">The path to save the file at.</param>
 public void Save(string path = ConfigurationManager.LockFile)
 {
     File.WriteAllText(path, Yaml.Serialize(this));
 }
Exemple #20
0
        public static Server ParseShadowsocksServer(YamlMappingNode proxy)
        {
            int port;

            if (!Int32.TryParse(Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "port", "0"), out port))
            {
                return(null);
            }

            var server = new ShadowsocksServer()
            {
                Port     = port,
                Name     = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "name"),
                Host     = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "server"),
                Password = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "password"),
                Method   = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "cipher"),
                UDPRelay = Yaml.GetTruthFromYamlChildrenNode(proxy, "udp"),
            };

            YamlNode pluginOptionsNode;

            // refer to offical clash to parse plugin options
            // https://github.com/Dreamacro/clash/blob/34338e7107c1868124f8aab2446f6b71c9b0640f/adapters/outbound/shadowsocks.go#L135
            if (proxy.Children.TryGetValue("plugin-opts", out pluginOptionsNode) && pluginOptionsNode.NodeType == YamlNodeType.Mapping)
            {
                switch (Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "plugin"))
                {
                case "obfs":
                    server.PluginType    = PluginType.SimpleObfs;
                    server.PluginOptions = new SimpleObfsPluginOptions()
                    {
                        Mode = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "mode"),
                        Host = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "host"),
                    };
                    break;

                case "v2ray-plugin":
                    // also refer to official v2ray-plugin to parse v2ray-plugin options
                    // https://github.com/shadowsocks/v2ray-plugin/blob/c7017f45bb1e12cf1e4b739bcb8f42f3eb8b22cd/main.go#L126
                    var options = new V2RayPluginOptions();
                    server.PluginType    = PluginType.V2Ray;
                    server.PluginOptions = options;

                    options.Host                 = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "host");
                    options.Mode                 = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "mode");
                    options.Path                 = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "path");
                    options.EnableTLS            = Yaml.GetTruthFromYamlChildrenNode(pluginOptionsNode, "tls");
                    options.SkipCertVerification = Yaml.GetTruthFromYamlChildrenNode(pluginOptionsNode, "skip-cert-verify");
                    options.Headers              = new Dictionary <string, string>();

                    YamlNode headersNode;
                    if (!(pluginOptionsNode as YamlMappingNode).Children.TryGetValue("headers", out headersNode))
                    {
                        break;
                    }
                    if (headersNode.NodeType != YamlNodeType.Mapping)
                    {
                        break;
                    }

                    foreach (var header in (headersNode as YamlMappingNode))
                    {
                        if (header.Value.NodeType != YamlNodeType.Scalar)
                        {
                            continue;
                        }
                        options.Headers.Add((header.Key as YamlScalarNode).Value, (header.Value as YamlScalarNode).Value);
                    }
                    break;
                }
            }


            if (server.PluginType == PluginType.None)
            {
                var obfs     = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "obfs");
                var obfsHost = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "obfs-host");

                if (!String.IsNullOrEmpty(obfs))
                {
                    server.PluginType    = PluginType.SimpleObfs;
                    server.PluginOptions = new SimpleObfsPluginOptions()
                    {
                        Mode = obfs,
                        Host = obfsHost
                    };
                }
            }

            return(server);
        }
Exemple #21
0
 /// <summary>
 /// Serialize this instance and saves the to the specified path.
 /// </summary>
 /// <param name="path">The path to save the file at.</param>
 public void Save(string path)
 {
     File.WriteAllText(path, Yaml.Serialize(this));
 }
Exemple #22
0
        public void AllAliasesMustBeResolved()
        {
            var original = new YamlStream();

            Assert.Throws <AnchorNotFoundException>(() => original.Load(Yaml.ReaderFrom("invalid-reference.yaml")));
        }
Exemple #23
0
 private static bool IsContentModuel(Dep dep)
 {
     return(Yaml.SettingsParser(dep.Name).Get().IsContentModule || Yaml.BuildParser(dep.Name).Get(dep.Configuration)
            .All(t => t.Target == "None"));
 }
Exemple #24
0
 public static TOptions Parse <TOptions>(string configFile, string sectionName = "") where TOptions : class, new()
 {
     return(Yaml.FromFile(configFile, sectionName).ApplyTo <TOptions>());
 }
Exemple #25
0
        public bool CheckDeployments(IKubernetes client, IDeserializer deserializer, string path, string key, out string value)
        {
            value = null;
            string curr;
            bool   match = true;

            foreach (string file in Directory.EnumerateFiles(path))
            {
                var fileContent = System.IO.File.ReadAllText(file);

                var deployment = Yaml.LoadFromString <V1Deployment>(fileContent);

                if (deployment == null)
                {
                    match = false;
                    break;
                }

                // Check if Deployment has label - if no labels return false

                if (deployment.Metadata.Labels != null)
                {
                    deployment.Metadata.Labels.TryGetValue(key, out curr);
                }

                else
                {
                    match = false;
                    break;
                }


                // Matches first Deployment with label, assigns label value to labName

                if (value == null)
                {
                    value = curr;
                }

                // If there is no match at this stage, there is a mismatch

                else if (value != curr)
                {
                    match = false;
                    break;
                }

                // Checking selectors - all deployments must select based on at least the lab name and that name must match on every template

                // Checking MatchLabels


                if (deployment.Spec.Selector.MatchLabels != null)
                {
                    deployment.Spec.Selector.MatchLabels.TryGetValue(key, out curr);

                    if (value != curr)
                    {
                        match = false;
                        break;
                    }
                }



                // Checking MatchExpressions
                else
                {
                    var expressions = deployment.Spec.Selector.MatchExpressions;

                    if (expressions != null)
                    {
                        foreach (var expression in expressions)
                        {
                            if (expression.Key == key && expression.OperatorProperty == "In" && expression.Values.Contains(value))
                            {
                                match = true;
                                break;
                            }
                            else
                            {
                                match = false;
                                break;
                            }
                        }
                    }
                }

                // Checking Pod Spec - label should be present and correct
                if (deployment.Spec.Template.Metadata.Labels == null)
                {
                    match = false;
                    break;
                }

                deployment.Spec.Template.Metadata.Labels.TryGetValue(key, out curr);

                if (value != curr)
                {
                    match = false;
                    break;
                }
            }
            return(match);
        }
Exemple #26
0
 public static T FromYaml <T>(this string yaml)
 {
     return(Yaml.From <T>(yaml));
 }
Exemple #27
0
        public void SetsMetadataKey()
        {
            // Given
            IDocument document = Substitute.For<IDocument>();
            IEnumerable<KeyValuePair<string, object>> items = null;
            document
                .When(x => x.Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>()))
                .Do(x => items = x.Arg<IEnumerable<KeyValuePair<string, object>>>());
            document.Content.Returns(@"A: 1");
            Yaml yaml = new Yaml("MyYaml");

            // When
            yaml.Execute(new [] { document }, null).ToList();  // Make sure to materialize the result list

            // Then
            document.Received().Clone(Arg.Any<IEnumerable<KeyValuePair<string, object>>>());
            Assert.AreEqual(1, items.Count());
            Assert.AreEqual("MyYaml", items.First().Key);
        }
Exemple #28
0
        public async System.Threading.Tasks.Task <IActionResult> Index(int id)
        {
            userName = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var k8SClientConfig = KubernetesClientConfiguration.BuildDefaultConfig();
            var client          = new Kubernetes(k8SClientConfig);


            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsBuilder.UseSqlServer("ApplicationDbContext");
            p = _context.Template.Find(id).Path;

            HttpContext.Session.SetInt32("TemplateId", id);


            var    pDeployments = "/etc/athena/Templates/" + p + "/Deployment";
            var    pServices    = "/etc/athena/Templates/" + p + "/Service";
            var    pIngress     = "/etc/athena/Templates/" + p + "/Ingress";
            string pNetPol      = "/etc/athena/Templates/" + p + "/NetworkPolicy";

            try
            {
                foreach (string file in Directory.EnumerateFiles(pServices))
                {
                    var fileContent = System.IO.File.ReadAllText(file);

                    var service = Yaml.LoadFromString <V1Service>(fileContent);


                    var result = client.CreateNamespacedService(service, userName);
                }

                foreach (string file in Directory.EnumerateFiles(pDeployments))
                {
                    var fileContent = System.IO.File.ReadAllText(file);

                    var deployment = Yaml.LoadFromString <V1Deployment>(fileContent);

                    var result = client.CreateNamespacedDeployment(deployment, userName);
                }

                foreach (string file in Directory.EnumerateFiles(pIngress))
                {
                    var fileContent = System.IO.File.ReadAllText(file);

                    var ingress = Yaml.LoadFromString <Networkingv1beta1Ingress>(fileContent);

                    AddIngress(client, ingress, userName);
                }

                foreach (string file in Directory.EnumerateFiles(pNetPol))
                {
                    V1NetworkPolicy netPol      = null;
                    var             fileContent = System.IO.File.ReadAllText(file);

                    netPol = Yaml.LoadFromString <V1NetworkPolicy>(fileContent);


                    var result = client.CreateNamespacedNetworkPolicy(netPol, userName);
                }


                return(View());
            }
            catch {
                return(View());
            }
        }
Exemple #29
0
        public static void Execute(Arguments arguments)
        {
            FileInfo manifestFile            = arguments.TemplateManifest;
            FileInfo functionalTemplatesFile = arguments.TemplateDefinitions;

            // Read in all template manifests
            var manifests = Yaml.Deserialize <TemplateManifest[]>(manifestFile);

            // Read current template definitions and convert to dictionary
            var arrayOfFunctionalTemplates   = Json.Deserialize <FunctionalTemplate[]>(functionalTemplatesFile);
            var dictionaryOfCurrentTemplates = DataProcessing.ConvertArrayOfFunctionalTemplatesToDictionary(arrayOfFunctionalTemplates);

            // init a new template list for output.
            var newTemplateList = new List <FunctionalTemplate>();

            // cycle through all the manifests
            foreach (var manifest in manifests)
            {
                var name = manifest.Name;
                if (!dictionaryOfCurrentTemplates.ContainsKey(name))
                {
                    // the current manifest is not an existing template - therefore make it.
                    var newTemplate = new FunctionalTemplate(manifest)
                    {
                        Template       = TemplateManifest.CreateTemplateDefinition(manifest),
                        MostRecentEdit = DateTime.Now,
                    };
                    newTemplateList.Add(newTemplate);
                    continue;
                }

                if (manifest.EditStatus == EditStatus.Edit)
                {
                    // This option edits an existing functional template in the json file. The template definition is (re)calculated.
                    // Effectively the same as creating a new template.
                    var newTemplate = new FunctionalTemplate(manifest)
                    {
                        Template       = TemplateManifest.CreateTemplateDefinition(manifest),
                        MostRecentEdit = DateTime.Now,
                    };
                    newTemplateList.Add(newTemplate);
                    continue;
                }

                if (manifest.EditStatus == EditStatus.Copy)
                {
                    // This option keeps an existing functional template unchanged.
                    var existingTemplate = dictionaryOfCurrentTemplates[name];
                    newTemplateList.Add(existingTemplate);
                    continue;
                }

                if (manifest.EditStatus == EditStatus.Ignore)
                {
                    // Do not output this template to the list of functional templates.
                    continue;
                }
            }

            var functionalTemplatesFileName = functionalTemplatesFile.Name;
            var functionalTemplatesFilePath = Path.Combine(manifestFile.DirectoryName ?? throw new InvalidOperationException(), functionalTemplatesFileName);

            // Save the previous templates file
            string backupPath = Path.Combine(manifestFile.DirectoryName, functionalTemplatesFileName + ".Backup.json");

            if (File.Exists(backupPath))
            {
                File.Delete(backupPath);
            }

            //Now copy the file first
            File.Copy(functionalTemplatesFilePath, backupPath, true);

            //Now Rename the File
            //File.Move(NewFilePath, Path.Combine(NewFileLocation, "File.txt"));

            // No need to move the backup because serializing over-writes the current templates file.
            var opTemplatesFile = new FileInfo(functionalTemplatesFilePath);

            Json.Serialise(opTemplatesFile, newTemplateList.ToArray());

            if (arguments.ListOfTestIndexFiles != null)
            {
                TestTemplates(arguments.ListOfTestIndexFiles, opTemplatesFile, arguments.ImageOfLdfcSpectrogram);
            }
        }
Exemple #30
0
        protected override int Execute()
        {
            var currentModuleDirectory = Helper.GetModuleDirectory(Directory.GetCurrentDirectory());
            var currentModule          = Path.GetFileName(currentModuleDirectory);

            if (!File.Exists(project))
            {
                var all   = Yaml.GetCsprojsList(currentModule);
                var maybe = all.FirstOrDefault(f =>
                                               string.Equals(Path.GetFileName(f), project, StringComparison.CurrentCultureIgnoreCase));
                if (maybe != null)
                {
                    project = maybe;
                }
            }

            if (!File.Exists(project))
            {
                ConsoleWriter.WriteError($"Project file '{project}' does not exist.");
                return(-1);
            }

            var moduleToInsert = Helper.TryFixModuleCase(dep.Name);

            dep = new Dep(moduleToInsert, dep.Treeish, dep.Configuration);
            var configuration = dep.Configuration;

            if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, moduleToInsert)) ||
                !Helper.HasModule(moduleToInsert))
            {
                ConsoleWriter.WriteError($"Can't find module '{moduleToInsert}'");
                return(-1);
            }

            Log.Debug(
                $"{moduleToInsert + (configuration == null ? "" : Helper.ConfigurationDelimiter + configuration)} -> {project}");

            CheckBranch();

            Log.Info("Getting install data for " + moduleToInsert + Helper.ConfigurationDelimiter + configuration);
            var installData = InstallParser.Get(moduleToInsert, configuration);

            if (!installData.BuildFiles.Any())
            {
                ConsoleWriter.WriteWarning($"No install files found in '{moduleToInsert}'");
                return(0);
            }

            AddModuleToCsproj(installData);
            if (testReplaces)
            {
                return(hasReplaces ? -1 : 0);
            }

            if (!File.Exists(Path.Combine(currentModuleDirectory, Helper.YamlSpecFile)))
            {
                throw new CementException(
                          "No module.yaml file. You should patch deps file manually or convert old spec to module.yaml (cm convert-spec)");
            }
            DepsPatcherProject.PatchDepsForProject(currentModuleDirectory, dep, project);
            return(0);
        }
        /// <summary>
        /// Reads a config file. Supports both "dynamic" and "static" config files.
        /// Additionally dumps config files into the log as JSON on first read for experimental provenance.
        /// Additionally caches the contents of config file on read based on the fully-qualified path.
        /// All configs returned are clones of the cached copy (even the first config).
        /// </summary>
        /// <remarks>
        /// Support exists for processing recursive config file (where a <see cref="Config"/> objected is nested in another
        /// <see cref="Config"/>.
        /// </remarks>
        /// <typeparam name="T">The type to deserialize.</typeparam>
        /// <param name="path">
        /// The path to the config file to read (will be expanded with <see cref="Path.GetFullPath"/>.
        /// </param>
        /// <param name="factory">
        /// A factory used to create a new config if <typeparamref name="T"/> is exactly the type <see cref="Config"/>.
        /// </param>
        /// <returns>The config object, or a cached copy after the first call.</returns>
        private static T LoadAndCache <T>(string path, Func <T> factory)
            where T : IConfig
        {
            Contract.RequiresNotNull(path, nameof(path));
            path = Path.GetFullPath(path);

            lock (CachedProperties)
            {
                // "cache" path skips this
                if (!CachedProperties.TryGetValue(path, out var cachedConfig))
                {
                    // not cached, load, log, and cache
                    T      loadedConfig;
                    object generic;

                    // if is exactly the Config type (no sub types)
                    if (typeof(T) == typeof(Config))
                    {
                        // "untyped" config
                        Log.Trace($"Reading untyped config file `{path}`");
                        using (var file = File.OpenText(path))
                        {
                            generic = Yaml.Deserialize <object>(file);
                        }

                        loadedConfig = factory();
                    }
                    else
                    {
                        // deserialize typed config
                        Log.Trace($"Reading typed config file `{path}`");
                        (generic, loadedConfig) = Yaml.LoadAndDeserialize <T>(path);
                    }

                    // if implements Config in any subtype (more specific than IConfig)
                    if (loadedConfig is Config config)
                    {
                        config.GenericConfig = generic;
                        Contract.EnsuresNotNull(config.GenericConfig);
                    }

                    loadedConfig.ConfigPath = path;
                    Contract.EnsuresNotNull(loadedConfig.ConfigPath);

                    // dump the config in the log
                    configJsonSerializerSettings = new JsonSerializerSettings();
                    var configDump = Json.SerializeToString(loadedConfig, false, configJsonSerializerSettings);
                    NoConsole.Log.Info($"Config file `{path}` loaded:{Environment.NewLine}{configDump}");

                    // this has the potential to be recursive here if a config file loads another config file.
                    ((IConfig)loadedConfig).InvokeLoaded();

                    // cache the config (with possible nested configs)
                    CachedProperties.AddOrUpdate(path, loadedConfig, (key, existing) => loadedConfig);

                    cachedConfig = loadedConfig;
                }

                // always need to clone a copy to protect from cross-thread mutability
                return(((T)cachedConfig).DeepClone());
            }
        }
Exemple #32
0
        /// <summary>
        /// Gets the documents.
        /// </summary>
        /// <returns>The documents.</returns>
        internal IList <dynamic> GetDocuments()
        {
            var mt = _content.ToFrontMatterType();

            if (mt == Enums.FrontMatterType.Json)
            {
                var items = JsonConvert.DeserializeObject <List <dynamic> >(_content);

                foreach (var i in items)
                {
                    var f2 = i.ToObject <Dictionary <string, object> >();

                    if (f2.Count == 0)
                    {
                        throw new KotoriDocumentException(_identifier, "Data contains document with no meta fields.");
                    }
                }

                if (!items.Any())
                {
                    throw new KotoriDocumentException(_identifier, "Data contains no document.");
                }

                return(items.ToList());
            }

            if (mt == Enums.FrontMatterType.Yaml)
            {
                IDeserializer des = new Yaml();

                var items = _content.Split("---", StringSplitOptions.RemoveEmptyEntries).ToList();

                items.RemoveAll(x => string.IsNullOrEmpty(x.Trim()));

                if (items.Any(x => string.IsNullOrWhiteSpace(x.Replace("\r", "", StringComparison.OrdinalIgnoreCase).Replace("\n", "", StringComparison.OrdinalIgnoreCase).Replace(" ", "", StringComparison.OrdinalIgnoreCase))))
                {
                    throw new KotoriDocumentException(_identifier, "Data contains document with no meta fields.");
                }

                List <dynamic> items2 = new List <dynamic>();
                var            c      = 0;

                foreach (var i in items)
                {
                    try
                    {
                        var d = des.Deserialize(i);
                        items2.Add(d);
                    }
                    catch (Exception ex)
                    {
                        throw new KotoriDocumentException(_identifier, $"Deserialization of data document at index {c} failed with a message: {ex.Message}");
                    }

                    c++;
                }

                if (!items2.Any())
                {
                    throw new KotoriDocumentException(_identifier, "Data contains no document.");
                }

                return(items2);
            }

            throw new KotoriDocumentException(_identifier, "Data content has an unknown format.");
        }
Exemple #33
0
        protected override int Execute()
        {
            var moduleDirectory = Helper.GetModuleDirectory(Directory.GetCurrentDirectory());

            if (moduleSolutionName == null)
            {
                var possibleModuleSolutions = Yaml.GetSolutionList(moduleDirectory);
                if (possibleModuleSolutions.Count != 1)
                {
                    throw new BadArgumentException("Unable to resolve sln-file, please specify path to one");
                }
                moduleSolutionName = possibleModuleSolutions[0];
            }
            var moduleSolutionPath = Path.GetFullPath(moduleSolutionName);

            if (!moduleSolutionPath.EndsWith(".sln"))
            {
                throw new BadArgumentException(moduleSolutionPath + " is not sln-file");
            }
            if (!File.Exists(moduleSolutionPath))
            {
                throw new BadArgumentException(moduleSolutionPath + " is not exist");
            }

            var analyzerModuleName = Helper.TryFixModuleCase(analyzerModule.Name);

            analyzerModule = new Dep(analyzerModuleName, analyzerModule.Treeish, analyzerModule.Configuration);
            var configuration = analyzerModule.Configuration;

            if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, analyzerModuleName)) || !Helper.HasModule(analyzerModuleName))
            {
                throw new CementException($"Can't find module '{analyzerModuleName}'");
            }

            Log.Debug($"{analyzerModuleName + (configuration == null ? "" : Helper.ConfigurationDelimiter + configuration)} -> {moduleSolutionName}");

            CheckBranch();

            Log.Info("Getting install data for " + analyzerModuleName + Helper.ConfigurationDelimiter + configuration);
            var installData = InstallParser.Get(analyzerModuleName, configuration);

            if (!installData.BuildFiles.Any())
            {
                ConsoleWriter.WriteWarning($"No install files found in '{analyzerModuleName}'");
                return(0);
            }

            var csprojFiles           = GetCsprojFiles(moduleSolutionPath);
            var csprojAndRulesetPairs = csprojFiles
                                        .Select(projectFile => new
            {
                Csproj  = projectFile,
                Ruleset = new RulesetFile(Path.ChangeExtension(projectFile.FilePath, "ruleset"))
            })
                                        .ToList();

            foreach (var pair in csprojAndRulesetPairs)
            {
                foreach (var installItem in installData.BuildFiles)
                {
                    if (installItem.EndsWith(".ruleset"))
                    {
                        var analyzerModuleRulesetPath = Path.GetFullPath(Path.Combine(Helper.CurrentWorkspace, installItem));
                        pair.Ruleset.Include(analyzerModuleRulesetPath);
                    }
                }

                pair.Csproj.BindRuleset(pair.Ruleset);

                foreach (var installItem in installData.BuildFiles)
                {
                    if (installItem.EndsWith(".dll"))
                    {
                        var analyzerModuleDllPath = Path.GetFullPath(Path.Combine(Helper.CurrentWorkspace, installItem));
                        pair.Csproj.AddAnalyzer(analyzerModuleDllPath);
                    }
                }
            }

            if (!File.Exists(Path.Combine(moduleDirectory, Helper.YamlSpecFile)))
            {
                throw new CementException("No module.yaml file. You should patch deps file manually or convert old spec to module.yaml (cm convert-spec)");
            }
            DepsPatcherProject.PatchDepsForSolution(moduleDirectory, analyzerModule, moduleSolutionPath);

            foreach (var pair in csprojAndRulesetPairs)
            {
                pair.Csproj.Save();
                pair.Ruleset.Save();
            }

            ConsoleWriter.WriteOk($"Add {analyzerModuleName} to {Path.GetFileName(moduleSolutionPath)} successfully completed");
            return(0);
        }
Exemple #34
0
 public void EmptyDocument()
 {
     AssertSequenceOfEventsFrom(Yaml.ParserForEmptyContent(),
                                StreamStart,
                                StreamEnd);
 }
        public Server ParseShadowsocksServer(YamlMappingNode proxy)
        {
            string portString = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "port", "0");
            int    port;

            if (!int.TryParse(portString, out port))
            {
                this.logger.LogError($"Invalid port: {port}.");
                return(null);
            }

            var server = new ShadowsocksServer()
            {
                Port     = port,
                Name     = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "name"),
                Host     = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "server"),
                Password = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "password"),
                Method   = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "cipher"),
                UDPRelay = Yaml.GetTruthFromYamlChildrenNode(proxy, "udp"),
            };

            YamlNode pluginOptionsNode;

            // refer to offical clash to parse plugin options
            // https://github.com/Dreamacro/clash/blob/34338e7107c1868124f8aab2446f6b71c9b0640f/adapters/outbound/shadowsocks.go#L135
            if (proxy.Children.TryGetValue("plugin-opts", out pluginOptionsNode) && pluginOptionsNode.NodeType == YamlNodeType.Mapping)
            {
                switch (Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "plugin").ToLower())
                {
                case "obfs":
                    var simpleObfsModeString = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "mode");
                    var simpleObfsOptions    = new SimpleObfsPluginOptions();

                    if (SimpleObfsPluginOptions.TryParseMode(simpleObfsModeString, out SimpleObfsPluginMode simpleObfsMode))
                    {
                        simpleObfsOptions.Mode = simpleObfsMode;
                    }
                    else if (!string.IsNullOrWhiteSpace(simpleObfsModeString))
                    {
                        this.logger.LogError($"Unsupported simple-obfs mode: {simpleObfsModeString}. This server will be ignored.");
                        return(null);
                    }
                    simpleObfsOptions.Host = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "host");

                    server.PluginOptions = simpleObfsOptions;
                    break;

                case "v2ray-plugin":
                    // also refer to official v2ray-plugin to parse v2ray-plugin options
                    // https://github.com/shadowsocks/v2ray-plugin/blob/c7017f45bb1e12cf1e4b739bcb8f42f3eb8b22cd/main.go#L126
                    var v2rayModeString = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "mode");
                    var options         = new V2RayPluginOptions();
                    server.PluginOptions = options;

                    if (V2RayPluginOptions.TryParseMode(v2rayModeString, out V2RayPluginMode v2rayMode))
                    {
                        options.Mode = v2rayMode;
                    }
                    else
                    {
                        this.logger.LogError($"Unsupported v2ray-plugin mode: {v2rayModeString}. This server will be ignored.");
                        return(null);
                    }

                    options.Host                 = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "host");
                    options.Path                 = Yaml.GetStringOrDefaultFromYamlChildrenNode(pluginOptionsNode, "path");
                    options.EnableTLS            = Yaml.GetTruthFromYamlChildrenNode(pluginOptionsNode, "tls");
                    options.SkipCertVerification = Yaml.GetTruthFromYamlChildrenNode(pluginOptionsNode, "skip-cert-verify");
                    options.Headers              = new Dictionary <string, string>();

                    YamlNode headersNode;
                    if (!(pluginOptionsNode as YamlMappingNode).Children.TryGetValue("headers", out headersNode))
                    {
                        break;
                    }
                    if (headersNode.NodeType != YamlNodeType.Mapping)
                    {
                        break;
                    }

                    foreach (var header in (headersNode as YamlMappingNode))
                    {
                        if (header.Value.NodeType != YamlNodeType.Scalar)
                        {
                            continue;
                        }
                        options.Headers.Add((header.Key as YamlScalarNode).Value, (header.Value as YamlScalarNode).Value);
                    }
                    break;
                }
            }

            if (server.PluginOptions == null)
            {
                var simpleObfsModeString = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "obfs");

                if (SimpleObfsPluginOptions.TryParseMode(simpleObfsModeString, out SimpleObfsPluginMode simpleObfsMode))
                {
                    server.PluginOptions = new SimpleObfsPluginOptions()
                    {
                        Mode = simpleObfsMode,
                        Host = Yaml.GetStringOrDefaultFromYamlChildrenNode(proxy, "obfs-host")
                    };
                }
                else if (!string.IsNullOrWhiteSpace(simpleObfsModeString))
                {
                    this.logger.LogError($"Unsupported simple-obfs mode: {simpleObfsModeString}");
                    return(null);
                }
            }

            return(server);
        }
Exemple #36
0
 public static BymlFileData FromYaml(this string String)
 {
     return(Yaml.FromYaml(String));
 }
Exemple #37
0
        public override async Task <int> Main()
        {
            this.Location = Path.GetFullPath(this.Location);

            Console.WriteLine("This utility will walk you through setting up a new FiveM server with NFive installed.");
            Console.WriteLine();
            Console.WriteLine($"The server will be installed at {this.Location}");
            Console.WriteLine();
            Console.WriteLine("Press ", "Ctrl+C".Yellow(), " at any time to quit.");
            Console.WriteLine();

            if (this.FiveM.HasValue && this.FiveM.Value || !this.FiveM.HasValue && Input.Bool("Install FiveM server?", true))
            {
                if (!this.FiveM.HasValue)
                {
                    Console.WriteLine();
                }
                Console.WriteLine("FiveM server configuration...");

                var config = new ConfigGenerator
                {
                    Hostname   = string.IsNullOrWhiteSpace(this.ServerName) ? Input.String("server name", "NFive") : this.ServerName,
                    MaxPlayers = this.MaxPlayers ?? Convert.ToUInt16(Input.Int("server max players", 1, 128, 32)),
                    Locale     = string.IsNullOrWhiteSpace(this.Locale) ? Input.String("server locale", "en-US", s =>
                    {
                        if (Regex.IsMatch(s, @"[a-z]{2}-[A-Z]{2}"))
                        {
                            return(true);
                        }

                        Console.Write("Please enter a valid locale (xx-XX format): ");
                        return(false);
                    }) : this.Locale,
                    OneSync    = this.OneSync ?? Input.Bool("enable OneSync", true),
                    Tags       = (string.IsNullOrWhiteSpace(this.Tags) ? Input.String("server tags (separate with space)", "NFive") : this.Tags).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList(),
                    LicenseKey = string.IsNullOrWhiteSpace(this.LicenseKey) ? Input.String("server license key (https://keymaster.fivem.net/)", s =>
                    {
                        if (Regex.IsMatch(s, @"[\d\w]{32}"))
                        {
                            return(true);
                        }

                        Console.Write("Please enter a valid license key: ");
                        return(false);
                    }).ToLowerInvariant() : this.LicenseKey,
                    SteamKey = string.IsNullOrWhiteSpace(this.SteamKey) ? Regex.Replace(Input.String("Steam API license key (https://steamcommunity.com/dev/apikey)", "<disabled>", s =>
                    {
                        if (s == "<disabled>")
                        {
                            return(true);
                        }
                        if (s == "none")
                        {
                            return(true);
                        }
                        if (Regex.IsMatch(s, @"[0-9a-fA-F]{32}"))
                        {
                            return(true);
                        }

                        Console.Write("Please enter a valid Steam API license key: ");
                        return(false);
                    }), "^<disabled>$", "none") : this.SteamKey,
                    RconPassword = string.IsNullOrWhiteSpace(this.RconPassword) ? Regex.Replace(Input.Password("RCON password", "<disabled>"), "^<disabled>$", string.Empty) : this.RconPassword
                };

                Directory.CreateDirectory(RuntimeEnvironment.IsWindows ? this.Location : Path.Combine(this.Location, "alpine", "opt", "cfx-server"));

                config.Serialize(Path.Combine(this.Location, RuntimeEnvironment.IsWindows ? PathManager.ConfigFile : Path.Combine("alpine", "opt", "cfx-server", PathManager.ConfigFile)));

                if (!this.FiveM.HasValue)
                {
                    Console.WriteLine();
                }

                await InstallFiveM(this.Location, this.FiveMSource);

                if (!RuntimeEnvironment.IsWindows)
                {
                    this.Location = Path.Combine(this.Location, "alpine", "opt", "cfx-server");
                }
                this.Location = Path.Combine(this.Location, "resources", "nfive");
            }

            if (this.NFive.HasValue && this.NFive.Value || !this.NFive.HasValue && Input.Bool("Install NFive?", true))
            {
                if (!this.FiveM.HasValue)
                {
                    Console.WriteLine();
                }
                Console.WriteLine("NFive database configuration...");

                var dbHost = string.IsNullOrWhiteSpace(this.DatabaseHost) ? Input.String("database host", "localhost") : this.DatabaseHost;
                var dbPort = this.DatabasePort ?? Input.Int("database port", 1, ushort.MaxValue, 3306);
                var dbUser = string.IsNullOrWhiteSpace(this.DatabaseUser) ? Input.String("database user", "root") : this.DatabaseUser;
                var dbPass = string.IsNullOrWhiteSpace(this.DatabasePassword) ? Regex.Replace(Input.Password("database password", "<blank>"), "^<blank>$", string.Empty) : this.DatabasePassword;
                var dbName = string.IsNullOrWhiteSpace(this.DatabaseName) ? Input.String("database name", "fivem", s =>
                {
                    if (Regex.IsMatch(s, "^[^\\/?%*:|\"<>.]{1,64}$"))
                    {
                        return(true);
                    }

                    Console.Write("Please enter a valid database name: ");

                    return(false);
                }) : this.DatabaseName;

                if (!this.FiveM.HasValue)
                {
                    Console.WriteLine();
                }

                await InstallNFive(this.Location);

                File.WriteAllText(Path.Combine(this.Location, ConfigurationManager.DefinitionFile), Yaml.Serialize(new
                {
                    Name    = "local/nfive-install",
                    Version = new Version
                    {
                        Major = 1,
                        Minor = 0,
                        Patch = 0
                    }
                }));

                var dbYml = File.ReadAllText(Path.Combine(this.Location, "config", "database.yml"));                 // TODO: Handle as YAML?
                dbYml = Regex.Replace(dbYml, "(\\s*host\\: ).+", $"${{1}}{dbHost}");
                dbYml = Regex.Replace(dbYml, "(\\s*port\\: ).+", $"${{1}}{dbPort}");
                dbYml = Regex.Replace(dbYml, "(\\s*database\\: ).+", $"${{1}}{dbName}");
                dbYml = Regex.Replace(dbYml, "(\\s*user\\: ).+", $"${{1}}{dbUser}");
                dbYml = Regex.Replace(dbYml, "(\\s*password\\: ).+", $"${{1}}{dbPass}");
                File.WriteAllText(Path.Combine(this.Location, "config", "database.yml"), dbYml);

                // TODO: Ask to include stock plugins?
            }

            Console.WriteLine("Installation is complete, you can now start the server with `nfpm start`!");

            return(0);
        }