Ejemplo n.º 1
0
        bool HasPackageYaml(PackageInfo info)
        {
            var fullPath   = PrjPathVars.Expand(info.FullPath);
            var configPath = Path.Combine(fullPath, ProjenyEditorUtil.PackageConfigFileName);

            return(File.Exists(configPath));
        }
Ejemplo n.º 2
0
        void OnContextMenuOpenPackageFolderForSelected()
        {
            var selected = GetSelectedItems();

            Assert.IsEqual(selected.Count, 1);

            var info = selected.Single();

            var expandedPath = PrjPathVars.Expand(info.FullPath);

            Assert.That(Directory.Exists(expandedPath), "Expected to find directory at '{0}'", expandedPath);

            System.Diagnostics.Process.Start(expandedPath);
        }
Ejemplo n.º 3
0
        void OnContextMenuEditPackageYamlSelected()
        {
            var selected = GetSelectedItems();

            Assert.IsEqual(selected.Count, 1);

            var info = selected.Single();

            var fullPath   = PrjPathVars.Expand(info.FullPath);
            var configPath = Path.Combine(fullPath, ProjenyEditorUtil.PackageConfigFileName);

            Assert.That(File.Exists(configPath));

            InternalEditorUtility.OpenFileAtLineExternal(configPath, 1);
        }
Ejemplo n.º 4
0
        public IEnumerator DeletePackages(List <PackageInfo> packages)
        {
            var choice = _view.PromptForUserChoice(
                "<color=yellow>Are you sure you want to delete the following packages?</color>\n\n{0}\n\n<color=yellow>Please note the following:</color>\n\n- This change is not undoable\n- Any changes that you've made since installing will be lost\n- Any projects or other packages that still depend on this package may be put in an invalid state by deleting it".Fmt(packages.Select(x => "- " + x.Name).Join("\n")),
                new[] { "Delete", "Cancel" }, null, "DeleteSelectedPopupTextStyle", 0, 1);

            yield return(choice);

            if (choice.Current == 0)
            {
                foreach (var package in packages)
                {
                    var expandedPath = PrjPathVars.Expand(package.FullPath);
                    Log.Debug("Deleting package directory at '{0}'", expandedPath);
                    Directory.Delete(expandedPath, true);
                }

                yield return(RefreshPackagesAsync());
            }
        }
Ejemplo n.º 5
0
        IEnumerator CreateNewPackageAsync()
        {
            var userInput = _view.PromptForInput("Enter new package name:", "Untitled");

            yield return(userInput);

            if (userInput.Current == null)
            {
                // User Cancelled
                yield break;
            }

            var packageName = userInput.Current;
            var packageDir  = PrjPathVars.Expand(Path.Combine(_model.GetCurrentPackageFolderPath(), packageName));

            Log.Debug("Creating new package directory at '{0}'", packageDir);
            Directory.CreateDirectory(packageDir);

            yield return(_packageHandler.RefreshPackagesAsync());
        }
Ejemplo n.º 6
0
        void OnContextMenuOpenUnityPackagesFolderInExplorer()
        {
            var packageRootPath = _model.TryGetCurrentPackageFolderPath();

            if (packageRootPath == null)
            {
                Log.Error("Could not find current package folder path to open in explorer");
            }
            else
            {
                var fullPath = PrjPathVars.Expand(packageRootPath);

                if (Directory.Exists(fullPath))
                {
                    System.Diagnostics.Process.Start(fullPath);
                }
                else
                {
                    Log.Error("Could not find directory at path '{0}'", fullPath);
                }
            }
        }
Ejemplo n.º 7
0
        IEnumerator RenamePackageAsync(PackageInfo info)
        {
            var newPackageName = _view.PromptForInput("Enter package name:", info.Name);

            yield return(newPackageName);

            if (newPackageName.Current == null)
            {
                // User Cancelled
                yield break;
            }

            if (newPackageName.Current == info.Name)
            {
                yield break;
            }

            var fullPath = PrjPathVars.Expand(info.FullPath);

            Assert.That(Directory.Exists(fullPath), "Expected path to exist: {0}", fullPath);

            var dirInfo = new DirectoryInfo(fullPath);

            Assert.That(dirInfo.Name == info.Name);

            var newPath = Path.Combine(dirInfo.Parent.FullName, newPackageName.Current);

            Assert.That(!Directory.Exists(newPath), "Package with name '{0}' already exists.  Rename aborted.", newPackageName.Current);

            dirInfo.MoveTo(newPath);

            yield return(_packageHandler.RefreshPackagesAsync());

            _view.ClearSelected();
            _view.GetList(DragListTypes.Package).Values
            .Where(x => ((PackageInfo)x.Model).Name == newPackageName.Current).Single().IsSelected = true;
        }