Ejemplo n.º 1
0
        public string SetPackageJsonNpmVersion(Dependency dependency, CommitVersion commit, string folder)
        {
            var pathPackageJson = Path.Combine(folder, dependency.pathPackageSettings);

            var jsn = StringUtils.ReadAllText(pathPackageJson);

            var version = commit.ToString();

            var jobject = JsonConvert.DeserializeObject(jsn) as JObject;

            var dependenciesArray = jobject["dependencies"];

            var divisor = packageName.Split('_');

            var packageJson = $"@{divisor[0]}/{divisor[1]}";

            if (dependenciesArray != null && dependenciesArray.HasValues)
            {
                var packageExists = dependenciesArray.Any(s => ((JProperty)s).Name.Equals(packageJson));
                if (packageExists)
                {
                    var tkn = (JProperty)dependenciesArray.First(s => ((JProperty)s).Name.Equals(packageJson));
                    tkn.Value = $"^{version}";
                }
            }

            var devDependenciesArray = jobject["devDependencies"];

            if (devDependenciesArray != null && devDependenciesArray.HasValues)
            {
                var packageExists = devDependenciesArray.Any(s => ((JProperty)s).Name.Equals(packageJson));
                if (packageExists)
                {
                    var tkn = (JProperty)devDependenciesArray.First(s => ((JProperty)s).Name.Equals(packageJson));
                    tkn.Value = $"^{version}";
                }
            }

            var peerDependenciesArray = jobject["peerDependencies"];

            if (peerDependenciesArray != null && peerDependenciesArray.HasValues)
            {
                var packageExists = peerDependenciesArray.Any(s => ((JProperty)s).Name.Equals(packageJson));
                if (packageExists)
                {
                    var tkn = (JProperty)peerDependenciesArray.First(s => ((JProperty)s).Name.Equals(packageJson));
                    tkn.Value = $"^{version}";
                }
            }


            return(jobject.ToString());
        }
Ejemplo n.º 2
0
        public string SetCsProjNugetVersion(Dependency dependency, CommitVersion commit, string folder)
        {
            var pathCsproj = Path.Combine(folder, dependency.pathPackageSettings);

            var version = commit.ToString();
            var xmlDoc  = new XmlDocument();

            xmlDoc.Load(pathCsproj);

            for (int i = 0; i < xmlDoc.DocumentElement.ChildNodes.Count; i++)
            {
                var node = xmlDoc.DocumentElement.ChildNodes.Item(i);
                if (node.Name.Equals("ItemGroup"))
                {
                    var nodes = node.ChildNodes;
                    for (int x = 0; x < nodes.Count; x++)
                    {
                        var nodePackage = nodes.Item(x);
                        if (nodePackage.Name.Equals("PackageReference"))
                        {
                            var attributes = nodePackage.Attributes;

                            var attrInclude = attributes["Include"];

                            if (attrInclude != null && attrInclude.Value.Equals(packageName))
                            {
                                attributes["Version"].Value = $"{version}";
                            }
                        }
                    }
                }
            }


            return(ToXmlString(xmlDoc));
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public Commits FetchFrom(EventSourceKey eventSource, CommitVersion commitVersion)
 {
     return(GetCommits(QueryCommitsFor(_ => _.EventSourceId == eventSource.Id.Value && _.EventSourceArtifact == eventSource.Artifact.Value && _.CommitNumber >= commitVersion.Value),
                       $"Fetching commits on for event source { eventSource.Id.Value }  of artifact:{ eventSource.Artifact.Value} after {commitVersion.ToString()}"));
 }