Пример #1
0
        private void DependencyStateBlock(
            DependencyDefinition definition,
            PackageRepo bestMatch,
            PackageRepo latest,
            InstalledPackage installed
            )
        {
            EditorGUILayout.LabelField(definition.Name + ":", EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Requirement: " + definition.Requirement.ToString());
            if (installed != null)
            {
                EditorGUILayout.LabelField("Installed version: " + installed.Version);

                if (VersionParser.GreaterThan(bestMatch.Package.PackageVersion, installed.Version))
                {
                    EditorGUILayout.HelpBox(
                        string.Format(
                            "Package is outdated. You can update it to {0} (from {1})",
                            bestMatch.Package.PackageVersion,
                            bestMatch.Repository.ToString()
                            ),
                        MessageType.Info
                        );
                    if (GUILayout.Button("Update to version " + bestMatch.Package.PackageVersion))
                    {
                        UpliftManager.Instance().UpdatePackage(bestMatch, updateLockfile: true);
                        Init();
                        Repaint();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Package is up to date!", MessageType.Info);
                }

                if (!definition.Requirement.IsMetBy(installed.Version))
                {
                    EditorGUILayout.HelpBox(
                        "The version of the package currently installed does not match the requirements of your project!",
                        installed.Version != bestMatch.Package.PackageVersion ? MessageType.Warning : MessageType.Error
                        );
                }
            }
            else
            {
                EditorGUILayout.LabelField("Not yet installed");
            }

            if (latest.Package.PackageVersion != bestMatch.Package.PackageVersion)
            {
                EditorGUILayout.HelpBox(
                    string.Format(
                        "Note: there is a more recent version of the package ({0} from {1}), but it doesn't match your requirement",
                        latest.Package.PackageVersion,
                        bestMatch.Repository.ToString()
                        ),
                    MessageType.Info
                    );
            }
        }
Пример #2
0
        protected void Given()
        {
            UpliftManagerExposer.ClearAllInstances();

            pwd = Directory.GetCurrentDirectory();
            Helper.InitializeRunDirectory();

            try
            {
                Directory.SetCurrentDirectory(Helper.testRunDirectoryName);

                // Upfile Setup
                upfile_path = Helper.GetLocalFilePath("..", "TestData", "PackageUpdating", "Upfile.xml");

                try
                {
                    UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                }
                upfile  = Upfile.Instance();
                manager = UpliftManager.Instance();

                upfile.Dependencies[0].Version = "1.0.0";
                manager.InstallDependencies();
                upfile.Dependencies[0].Version = "1.0.1";
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
            }
        }
        protected void Init()
        {
            UpliftManagerExposer.ClearAllInstances();

            manager = UpliftManager.Instance();
            pwd     = Directory.GetCurrentDirectory();
        }
Пример #4
0
        public static void UpdatePackage()
        {
            string packageName = LastArgument();

            PackageRepo pr = PackageList.Instance().GetLatestPackage(packageName);

            UpliftManager.Instance().UpdatePackage(pr);
        }
Пример #5
0
        public void WhenUpfileModifiedNoSkip()
        {
            // Upfile Setup
            upfile_path = Helper.GetLocalFilePath("..", "TestData", "CustomizedFileLocation", "Upfile_Modified_NoSkip.xml");

            try
            {
                UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                Assert.IsTrue(false, "The test could not run correctly. See console message.");
            }
            Upfile.Instance();
            manager = UpliftManager.Instance();

            manager.InstallDependencies();

            // Directories existence
            Assert.IsTrue(Directory.Exists("UPackages"), "Directory UPackages does not exist");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5"), "Package directory does not exist under UPackages");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5/Media"), "Media directory does not exist under UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5/Example"), "Example directory does not exist under UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("UPackages/package_c~1.3.5/Example/Adv"), "Example advanced directory does not exist under UPackages/package_c~1.3.5");
            Assert.IsTrue(Directory.Exists("Assets"), "Directory Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages"), "Directory UPackages under Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_c~1.3.5"), "Package directory does not exist under Assets/UPackages");
            Assert.IsTrue(Directory.Exists("Assets/Media"), "Media directory does not exist under Assets");
            Assert.IsTrue(Directory.Exists("Assets/Media/package_c~1.3.5"), "Package directory does not exist under Assets/Media");
            Assert.IsTrue(Directory.Exists("Examples"), "Examples directory does not exist");
            Assert.IsTrue(Directory.Exists("Examples/package_c~1.3.5"), "Package directory does not exist under Examples");
            Assert.IsTrue(Directory.Exists("Examples/package_c~1.3.5/Adv"), "Advanced directory does not exist under Examples/package_c~1.3.5");

            // Files under Assets
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/C1.cs"), "File C1 did not get copied to Assets/UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_c~1.3.5/C2.cs"), "File C2 did not get copied to Assets/UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Assets/Media/package_c~1.3.5/M1.txt"), "File M1 did not get copied to Assets/Media/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Assets/Media/package_c~1.3.5/M2.txt"), "File M2 did not get copied to Assets/Media/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Examples/package_c~1.3.5/E1.txt"), "File E1 did not get copied to Examples/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Examples/package_c~1.3.5/E2.txt"), "File E2 did not get copied to Examples/package_c~1.3.5");
            Assert.IsTrue(File.Exists("Examples/package_c~1.3.5/Adv/E3.txt"), "File E2 did not get copied to Examples/package_c~1.3.5/Adv");

            // Files under UPackages
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/C1.cs"), "File C1 did not get copied to UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/C2.cs"), "File C2 did not get copied to UPackages/package_c~1.3.5");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Media/M1.txt"), "File M1 did not get copied to UPackages/package_c~1.3.5/Media");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Media/M2.txt"), "File M2 did not get copied to UPackages/package_c~1.3.5/Media");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Example/E1.txt"), "File E1 did not get copied to UPackages/package_c~1.3.5/Example");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Example/E2.txt"), "File E2 did not get copied to UPackages/package_c~1.3.5/Example");
            Assert.IsTrue(File.Exists("UPackages/package_c~1.3.5/Example/Adv/E3.txt"), "File E2 did not get copied to UPackages/package_c~1.3.5/Example/Adv");
        }
Пример #6
0
        protected void Given()
        {
            UpliftManagerExposer.ClearAllInstances();

            pwd = Directory.GetCurrentDirectory();
            Helper.InitializeRunDirectory();

            try
            {
                Directory.SetCurrentDirectory(Helper.testRunDirectoryName);

                // Upfile Setup for filler package
                upfile_path = Helper.GetLocalFilePath("..", "TestData", "PackageNuking", "Init_Upfile.xml");

                try
                {
                    UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                    Assert.Fail("The test could not run correctly. See console message.");
                }
                UpfileExposer.TestingInstance();
                manager = UpliftManager.Instance();

                // Creating original state
                Directory.CreateDirectory("Assets");
                Directory.CreateDirectory("Assets/Media");

                File.Create("Assets/scriptA.cs").Dispose();
                File.Create("Assets/scriptB.cs").Dispose();
                File.Create("Assets/Media/mediaA.txt").Dispose();
                File.Create("Assets/Media/mediaB.txt").Dispose();

                // Install Filler Package
                manager.InstallDependencies();

                // Save the snapshot
                original_snapshot = GetSnapshot();

                // Proper Upfile Setup
                UpliftManagerExposer.ClearAllInstances();
                UpfileExposer.ClearInstance();
                upfile_path = Helper.GetLocalFilePath("..", "TestData", "PackageNuking", "Upfile.xml");

                try
                {
                    UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Make sure you are running the test from UpliftTesting/TestResults. The Upfile.xml uses the current path to register the repositories.");
                    Assert.IsTrue(false, "The test could not run correctly. See console message.");
                }
                Upfile.Instance();
                manager = UpliftManager.Instance();
            }
            finally
            {
                Directory.SetCurrentDirectory(pwd);
            }
        }
Пример #7
0
        public void WhenInstalling()
        {
            upfile_path = Helper.GetLocalFilePath("..", "TestData", "BasicPackageInstallation", "Upfile.xml");

            try
            {
                UpfileExposer.SetInstance(UpfileExposer.LoadTestXml(upfile_path));
            }
            catch (FileNotFoundException)
            {
                UnityEngine.Debug.LogError("The Upfile.xml uses the current path to register the repositories.");
            }
            Upfile.Instance();
            manager = UpliftManager.Instance();

            manager.InstallDependencies();

            // Directories existence
            Assert.IsTrue(Directory.Exists("UPackages"), "Directory UPackages does not exist");
            Assert.IsTrue(Directory.Exists("UPackages/package_a~1.0.0"), "Package directory does not exist under UPackages");
            Assert.IsTrue(Directory.Exists("Assets"), "Directory Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages"), "Directory UPackages under Assets does not exist");
            Assert.IsTrue(Directory.Exists("Assets/UPackages/package_a~1.0.0"), "Package directory does not exist under Assets/UPackages");

            // Files under Assets/UPackages
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/A1.cs"), "File A1 did not get copied to Assets/UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/A2.cs"), "File A2 did not get copied to Assets/UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/A3.cs"), "File A3 did not get copied to Assets/UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("Assets/UPackages/package_a~1.0.0/Upset.xml"), "Upset file did not get copied to Assets/UPackages/package_a~1.0.0");

            // Files under UPackages
            Assert.IsTrue(File.Exists("UPackages/Upbring.xml"), "Upbring file has not been created");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/A1.cs"), "File A1 did not get copied to UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/A2.cs"), "File A2 did not get copied to UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/A3.cs"), "File A3 did not get copied to UPackages/package_a~1.0.0");
            Assert.IsTrue(File.Exists("UPackages/package_a~1.0.0/Upset.xml"), "Upset file did not get copied to UPackages/package_a~1.0.0");

            // Upbring validity
            Upbring upbring = Upbring.Instance();

            Assert.IsNotEmpty(upbring.InstalledPackage, "Upbring file did not registered the installation");
            Assert.That(upbring.InstalledPackage.Any(p =>
                                                     p.Name == "package_a" &&
                                                     p.Version == "1.0.0"
                                                     ), "Upbring did not register an installation with the proper package Name and Version");
            Assert.IsNotEmpty(upbring.InstalledPackage[0].Install, "Upbring file did not register file dependencies");

            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "UPackages/package_a~1.0.0" &&
                                                                i.Type == InstallSpecType.Root
                                                                ), "Root installation did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/A1.cs" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of A1.cs did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/A2.cs" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of A2.cs did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/A3.cs" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of A3.cs did not get registered");
            Assert.That(upbring.InstalledPackage[0].Install.Any(i =>
                                                                i is InstallSpecPath &&
                                                                (i as InstallSpecPath).Path == "Assets/UPackages/package_a~1.0.0/Upset.xml" &&
                                                                i.Type == InstallSpecType.Base
                                                                ), "Base installation of Upset.xml did not get registered");
        }
Пример #8
0
        protected void OnGUI()
        {
            titleContent.text = "Update Utility";

            UpliftManager manager     = UpliftManager.Instance();
            Upbring       upbring     = Upbring.Instance();
            Upfile        upfile      = Upfile.Instance();
            PackageList   packageList = PackageList.Instance();

            PackageRepo[] packageRepos = packageList.GetAllPackages();

            DependencyDefinition[] dependencies = upfile.Dependencies;
            bool any_installed =
                upbring.InstalledPackage != null &&
                upbring.InstalledPackage.Length != 0;

            if (dependencies.Length == 0)
            {
                EditorGUILayout.HelpBox("It seems that you didn't specify any dependency in the Upfile. Try refreshing it if you did.", MessageType.Warning);
            }
            else
            {
                foreach (DependencyDefinition dependency in dependencies)
                {
                    string name = dependency.Name;
                    EditorGUILayout.LabelField(name + ":", EditorStyles.boldLabel);
                    bool installable = packageRepos.Any(pr => pr.Package.PackageName == name);
                    bool installed   =
                        any_installed &&
                        upbring.InstalledPackage.Any(ip => ip.Name == name);
                    string installed_version = installed ? upbring.GetInstalledPackage(name).Version : "";

                    if (installed)
                    {
                        EditorGUILayout.LabelField("- Installed version is " + installed_version);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("- Not yet installed");
                    }

                    if (!installable)
                    {
                        EditorGUILayout.HelpBox("No repository contains this package. Try specifying one whith this package in.", MessageType.Warning);
                    }
                    else
                    {
                        PackageRepo latestPackageRepo = packageList.GetLatestPackage(name);
                        string      latest_version    = latestPackageRepo.Package.PackageVersion;

                        EditorGUILayout.LabelField(string.Format("- Latest version is: {0} (from {1})", latest_version, latestPackageRepo.Repository.ToString()));

                        GUI.enabled = installed && installed_version != latest_version;
                        if (GUILayout.Button("Update to " + latest_version))
                        {
                            Debug.Log(string.Format("Updating package {0} (to {1})", name, latest_version));
                            manager.UpdatePackage(latestPackageRepo);

                            AssetDatabase.Refresh();

                            Repaint();
                        }
                        GUI.enabled = true;
                    }

                    EditorGUILayout.Space();
                }

                if (GUILayout.Button("Install all dependencies"))
                {
                    manager.InstallDependencies();

                    AssetDatabase.Refresh();

                    Repaint();
                }
                GUI.enabled = any_installed;
                if (GUILayout.Button("Update all installed packages"))
                {
                    foreach (InstalledPackage package in upbring.InstalledPackage)
                    {
                        PackageRepo latestPackageRepo = packageList.GetLatestPackage(package.Name);
                        if (package.Version != latestPackageRepo.Package.PackageVersion)
                        {
                            Debug.Log(string.Format("Updating package {0} (to {1})", package.Name, latestPackageRepo.Package.PackageVersion));
                            manager.UpdatePackage(latestPackageRepo);
                        }
                    }

                    AssetDatabase.Refresh();

                    Repaint();
                }
                GUI.enabled = true;
                if (GUILayout.Button("Refresh Upfile"))
                {
                    Upfile.Instance();

                    Repaint();
                }
            }
        }
Пример #9
0
 public void Init()
 {
     UpliftManager.ResetInstances();
     states = UpliftManager.Instance().GetDependenciesState();
     Repaint();
 }
Пример #10
0
 public static void NukeAllPackages()
 {
     UpliftManager.Instance().NukeAllPackages();
 }
Пример #11
0
        public static void NukePackage()
        {
            string packageName = LastArgument();

            UpliftManager.Instance().NukePackage(packageName);
        }
Пример #12
0
 public static void InstallLockfile()
 {
     UpliftManager.Instance().InstallDependencies(strategy: UpliftManager.InstallStrategy.ONLY_LOCKFILE);
 }
Пример #13
0
 public static void InstallDependencies()
 {
     UpliftManager.Instance().InstallDependencies(strategy: UpliftManager.InstallStrategy.INCOMPLETE_LOCKFILE);
 }
Пример #14
0
 public static void InstallDependencies()
 {
     UpliftManager.Instance().InstallDependencies();
 }
Пример #15
0
 public void Init()
 {
     states = UpliftManager.Instance().GetDependenciesState(true);
     Repaint();
 }