Ejemplo n.º 1
0
        private void bmptestBump(object sender, RoutedEventArgs e)
        {
            json = getTools.openJSON((Projects.SelectedItem as User).Name);
            help = getTools.getjsonVersion(json);

            int choice = (int)options.EnumProperty;

            if (choice == 0)
            {
                System.Windows.MessageBox.Show("Trivial Bump");
            }
            else if (choice == 1)
            {
                System.Windows.MessageBox.Show("Minor Bump");
            }
            else if (choice == 2)
            {
                System.Windows.MessageBox.Show("Major Bump");
            }
            else if (choice == 3)
            {
                System.Windows.MessageBox.Show("Rewrite Bump");
            }
            help.toArray();
            help.bumpTrivial();
            help.toString();
            List <string> test = getTools.GetDirectories(selected);

            try { help2 = getTools.bumpChildrenTrivial((Projects.SelectedItem as User).Name); } catch (System.IO.DirectoryNotFoundException) { Console.WriteLine(); }
            getTools.writejsonVersion(help);
            getTools.writechildVersion(help2);
            getTools.writeOtherDep(json, selected);
            //}
            // getTools.verify((Projects.SelectedItem as User).Name);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the version of a child by parsing the assembly info file
        /// </summary>
        /// <param name="file">A myFile of a child</param>
        /// <returns>Returns a version object containing version number and name of the child</returns>
        public Version getchildVersion(myFile file)
        {
            Version ver = new Version();

            string temp    = "";
            string pattern = "\"[^\"]+\"";

            foreach (string line in file.getData())
            {
                if (line.Contains("[assembly: AssemblyVersion(") && !line.Contains("//"))
                {
                    ver = new Version();
                    ver.setType("Child");
                    ver.setName(file.getFilename());
                    var match = Regex.Match(line, pattern);
                    temp = (match.Value);
                    temp = temp.Substring(1);
                    temp = temp.TrimEnd('\"');
                    ver.setVersion(temp);

                    return(ver);
                }
            }


            return(ver);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Searches through other directories inside the main project and rewrites the manifest.json file with the updated version
        /// </summary>
        /// <param name="json">The main json file used to write the dependents</param>
        /// <param name="dir">Directory of the main project</param>
        /// <returns></returns>
        public bool writeOtherDep(myFile json, string dir)
        {
            Version       ver    = getjsonVersion(json);
            List <string> direcs = GetDirectories(dir);
            string        tempstr;
            string        pattern = "[:][' ']\"[^\"]+\"";

            foreach (string location in direcs)
            {
                int last = json.getFilename().LastIndexOf('\\');
                tempstr = json.getFilename().Substring(last + 1);
                try
                {
                    string[] temp = File.ReadAllLines(location + "\\manifest.json");
                    for (int i = 0; i < temp.Count() - 1; i++)
                    {
                        if (temp[i].Contains(tempstr))
                        {
                            temp[i + 1] = Regex.Replace(temp[i + 1], pattern, ": \"" + ver.getVersion() + '"');
                        }
                    }
                    File.WriteAllLines(location + "\\manifest.json", temp);
                }
                catch (FileNotFoundException e) { Console.WriteLine(e); }
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses manifest.json file to get the version of it
        /// </summary>
        /// <param name="json">A myFile that contains the contents of a manifest.json file and the path to the file</param>
        /// <returns>Returns a version object that contains the version and the name of the parent</returns>
        public Version getjsonVersion(myFile json)
        {
            Version ver   = new Version();
            int     count = 0;

            ver.setName(json.getFilename());

            string temp    = "";
            string pattern = "[:][' ']\"[^\"]+\"";

            foreach (string line in json.getData())
            {
                if (line.Contains("version") && count < 2)
                {
                    ver = new Version();
                    ver.setType("Parent");
                    var match = Regex.Match(line, pattern);
                    temp = (match.Value);
                    temp = temp.Substring(3);
                    temp = temp.TrimEnd('\"');
                    ver.setVersion(temp);
                    return(ver);
                }
                else
                {
                    count++;
                }
            }
            return(ver);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Verifies that all versions in the main directory match.
        /// </summary>
        /// <param name="json">Original file which contains a path and its version</param>
        /// <param name="dir">The main directory</param>
        /// <returns>Returns false and throws exception if not matching</returns>
        public bool verify(myFile json, string dir)
        {
            bool    matches     = true;
            Version jsonversion = getjsonVersion(json);
            Dictionary <string, string> kids = getAllChildrenVersions(json.getFilename());
            List <myFile> direcs             = openAllJson(dir);

            foreach (KeyValuePair <string, string> entry in kids)
            {
                if (entry.Value != jsonversion.getVersion())
                {
                    matches = false;
                    Exception MismatchedVersion = new Exception(); throw MismatchedVersion;
                }
            }

            if (verifyAllJson(json, direcs) != true)
            {
                matches = false; Exception MismatchedVersion = new Exception(); throw MismatchedVersion;
            }
            ;


            return(matches);
        }
Ejemplo n.º 6
0
        private void allkidsBump(object sender, RoutedEventArgs e)
        {
            json = getTools.openJSON((Projects.SelectedItem as User).Name);
            help = getTools.getjsonVersion(json);
            help.bumpTrivial();

            obj.Name = help.getVersion();
        }
Ejemplo n.º 7
0
        private void Projects_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var myitem = (e.OriginalSource as FrameworkElement).DataContext as User;

            try { json = getTools.openJSON(myitem.Name); }
            catch (NullReferenceException) { }
            Version welp = getTools.getjsonVersion(json);

            obj.Name = welp.getVersion();
        }
Ejemplo n.º 8
0
        private void jsonverBump(object sender, RoutedEventArgs e)
        {
            json = getTools.openJSON((Projects.SelectedItem as User).Name);
            help = getTools.getjsonVersion(json);

            bool matches;

            try {
                matches = (getTools.verify(json, selected));
                System.Windows.MessageBox.Show("Everything went okay", "Verify");
            }
            catch (Exception MismatchedVersion) { System.Windows.MessageBox.Show("There was an error", "Error"); }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Bumps all of the children contained in a parent directory.  Does not write anything to file.
        /// </summary>
        /// <param name="filename">Path to the main directory</param>
        /// <returns>Returns a dictionary containing the paths to the children and their corresponding bumped versions.</returns>
        public Dictionary <string, string> bumpChildrenRewrite(string filename)
        {
            Dictionary <string, string> kids = new Dictionary <string, string>();
            List <string> files = GetDirectories(filename);
            myFile        file  = new myFile();

            foreach (string child in files)
            {
                file = openAssemblyInfo(child);
                Version little = getchildVersion(file);
                little.bumpRewrite();
                kids.Add(little.getName(), little.getVersion());
            }

            return(kids);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Opens an assembly info file and puts it into a myFile
        /// </summary>
        /// <param name="filename">Path to a folder containing an assembly info file</param>
        /// <returns>Returns a myFile with the contents of the assembly info file</returns>
        public myFile openAssemblyInfo(string filename)
        {
            myFile info = new myFile();

            info.setFilename(filename);
            string path = filename + "\\properties\\AssemblyInfo.cs";

            if (File.Exists(path))
            {
                foreach (string line in File.ReadLines(filename + "\\properties\\AssemblyInfo.cs", Encoding.UTF8))
                {
                    info.add(line);
                }
            }
            return(info);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Opens a json file and puts the contents into a myFile
        /// </summary>
        /// <param name="filename">A path that contains a manifest.json file</param>
        /// <returns>Returns a myFile that contains the contents and the corresponding path</returns>
        public myFile openJSON(string filename)
        {
            myFile json = new myFile();

            json.setFilename(filename);
            try
            {
                foreach (string line in File.ReadLines(filename + "\\manifest.json", Encoding.UTF8))
                {
                    json.add(line);
                }
            }
            catch (System.IO.FileNotFoundException) { Console.WriteLine(); }


            return(json);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Opens multiple json files
        /// </summary>
        /// <param name="dir">Main parent directory</param>
        /// <returns>Returns a list contaning myFiles of each manifest.json file.</returns>
        public List <myFile> openAllJson(string dir)
        {
            List <myFile> dic    = new List <myFile>();
            List <string> direcs = GetDirectories(dir);

            foreach (string location in direcs)
            {
                string[] temp = File.ReadAllLines(location + "\\manifest.json");
                myFile   json = new myFile(temp);
                json.setFilename(location);
                dic.Add(json);
            }



            return(dic);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Takes an original file and compares the version of it against the rest of the files that have it as a dependency
        /// </summary>
        /// <param name="json">Original File</param>
        /// <param name="list">List of all directories to check against</param>
        public bool verifyAllJson(myFile json, List <myFile> list)
        {
            bool    exists = false;
            string  tempstr;
            Version ver = getjsonVersion(json);

            foreach (myFile item in list)
            {
                int last = item.getFilename().LastIndexOf('\\');
                tempstr = item.getFilename().Substring(last + 1);
                for (int i = 0; i < item.data.Count - 1; i++)
                {
                    if (item.data[i].Contains(tempstr) && item.data[i + 1].Contains(ver.getVersion()))
                    {
                        exists = true;
                    }
                }
            }
            return(exists);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Takes a path and creates a dictionary containing the name of each child and the corresponding version of the child.
        /// </summary>
        /// <param name="filename">The path to the parent</param>
        /// <returns></returns>
        public Dictionary <string, string> getAllChildrenVersions(string filename)
        {
            Dictionary <string, string> kids = new Dictionary <string, string>();
            List <string> filesdirec         = GetDirectories(filename);
            myFile        file = new myFile();

            foreach (string child in filesdirec)
            {
                file = openAssemblyInfo(child);
                {
                    if (file.getCount() != 0)
                    {
                        Version little = getchildVersion(file);
                        kids.Add(little.getName(), little.getVersion());
                    }
                }
            }

            return(kids);
        }
Ejemplo n.º 15
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int choice = (int)options.EnumProperty;

            json = getTools.openJSON((Projects.SelectedItem as User).Name);
            help = getTools.getjsonVersion(json);
            List <string> direcs  = getTools.GetDirectories(selected);
            StringBuilder message = new StringBuilder(@"Are you sure you would like to bump ");

            message.Append((Projects.SelectedItem as User).Name);
            message.Append(" to version ");


            if (choice == 0)
            {
                help.bumpTrivial(); obj.Name = help.getVersion();
            }
            else if (choice == 1)
            {
                help.bumpMinor(); obj.Name = help.getVersion();
            }
            else if (choice == 2)
            {
                help.bumpMajor(); obj.Name = help.getVersion();
            }
            else if (choice == 3)
            {
                help.bumpRewrite(); obj.Name = help.getVersion();
            }

            message.Append(help.getVersion() + "?");
            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(message.ToString(), "Bump Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
            }
            else
            {
                help = getTools.getjsonVersion(json); obj.Name = help.getVersion();
            }
        }