Example #1
0
        private static void AddPackage(string package, bool activate)
        {
            string action = activate
                                ? ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION
                                : ActionRunner.ADD_PACKAGE_ACTION;

            ActionRunner.AddActionToStartup($"{action} {package}");
        }
Example #2
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;
            Runner r = new Runner();

            r._AddCommand(
                new SetDataCommand(
                    strings => Adds = strings,
                    new[] { "--add", "-a" },
                    "Adds a Plugin package"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Removes = strings,
                    new[] { "--remove", "-r" },
                    "Removes a Plugin package"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );
            r._AddCommand(new DefaultHelpCommand(true));

            r._RunCommands(args);

            FLData.InitializePluginSystemOnly(true);

            foreach (string remove in Removes)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.REMOVE_PACKAGE_ACTION} {remove}");
            }

            foreach (string adds in Adds)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {adds}");
            }

            Debug.OnConfigCreate -= ProjectDebugConfig_OnConfigCreate;
        }
Example #3
0
 private static void PluginManagerOnOnInitialized()
 {
     if (FLScriptEditor.Settings.PluginInit != null)
     {
         loaderForm.Log("Running Initialization", Color.OrangeRed);
         foreach (string s in FLScriptEditor.Settings.InitFiles)
         {
             if (Directory.Exists(Path.GetFullPath(s)))
             {
                 string[] plugins = Directory.GetFiles(
                     Path.GetFullPath(s),
                     "*",
                     SearchOption.AllDirectories
                     );
                 foreach (string plugin in plugins)
                 {
                     ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {plugin}");
                 }
             }
         }
     }
 }
Example #4
0
        private void ToggleLoadState(object sender, EventArgs e)
        {
            if (lbPlugins.SelectedIndex != -1)
            {
                if (lbPlugins.SelectedItem is IPlugin plugin)
                {
                }
                else
                {
                    bool isActive         = lbPluginHosts.SelectedItem.ToString() != "[Inactive Packages]";
                    BasePluginPointer ptr = new BasePluginPointer(lbPlugins.SelectedItem.ToString());
                    if (!isActive)
                    {
                        ActionRunner.AddActionToStartup($"{ActionRunner.ACTIVATE_PACKAGE_ACTION} {ptr.PluginName}");
                    }
                    else
                    {
                        ActionRunner.AddActionToStartup($"{ActionRunner.DEACTIVATE_PACKAGE_ACTION} {ptr.PluginName}");
                    }

                    lbPlugins.Items.Remove(lbPlugins.SelectedItem);
                }
            }
        }
Example #5
0
        public void Run(string[] args)
        {
            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;

            Runner r = new Runner();

            r._AddCommand(new DefaultHelpCommand());
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageAdds = strings,
                    new[] { "--add", "-a" },
                    "Adds a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageAdds = strings,
                    new[] { "--add-activate", "-aa" },
                    "Adds and activates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageRemoves = strings,
                    new[] { "--remove", "-r" },
                    "Removes a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageActivates = strings,
                    new[] { "--activate", "-active" },
                    "Activates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => PackageDeactivates = strings,
                    new[] { "--deactivate", "-d" },
                    "Deactivates a Plugin package by name"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => OriginRemoves = strings,
                    new[] { "--remove-origin", "-ro" },
                    "Removes an Origin Url from the Origins File"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => OriginAdds = strings,
                    new[] { "--add-origin", "-ao" },
                    "Adds an Origin Url to the Origins File"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => DefaultOrigin = true,
                    new[] { "--default-origin", "-default" },
                    "Writes the Default Origin File to Disk, overwriting the current origin file"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => InstallAll = true,
                    new[] { "--all", "-all" },
                    "Installs and activates All packages from all repositories"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => ListPackages = true,
                    new[] { "--list-packages", "-list" },
                    "Lists All packages from all repositories"
                    )
                );
            r._AddCommand(
                new SetDataCommand(
                    strings => Verbosity = int.Parse(strings.First()),
                    new[] { "--verbosity", "-v" },
                    "The Verbosity Level (lower = less logs)"
                    )
                );


            FLData.InitializePluginSystemOnly(true);


            r._RunCommands(args);

            if (DefaultOrigin)
            {
                string file = RepositoryPlugin.GetOriginFilePath(GetDefaultRepoPluginPointer());
                Directory.CreateDirectory(Path.GetDirectoryName(file));
                WriteDefaultOrigin(file);
            }
            else
            {
                CheckOriginsExists(GetDefaultRepoPluginPointer());
            }

            RepositoryPlugin repo = GetPlugin();

            List <Repository> repos = repo.GetPlugins();
            IEnumerable <BasePluginPointer> global =
                ListHelper.LoadList(PluginPaths.GlobalPluginListFile).Select(x => new BasePluginPointer(x));
            IEnumerable <BasePluginPointer> active =
                ListHelper.LoadList(PluginPaths.PluginListFile).Select(x => new BasePluginPointer(x));

            if (ListPackages)
            {
                Console.WriteLine("Available Packages: ");
                foreach (Repository repository in repos)
                {
                    Console.WriteLine($"\tRepository: {repository.RepositoryOrigin}");
                    foreach (BasePluginPointer basePluginPointer in repository.Plugins)
                    {
                        BasePluginPointer installedPtr =
                            global.FirstOrDefault(x => x.PluginOrigin == basePluginPointer.PluginOrigin);
                        bool   contained = installedPtr != null;
                        bool   installed = contained && active.Any(x => x.PluginOrigin == basePluginPointer.PluginOrigin);
                        string tag       = installed ? "[ACTIVE]" : contained ? "[INSTALLED]" : "[NOT INSTALLED]";
                        Console.WriteLine($"\t\t{tag} {basePluginPointer.PluginName}");
                        Console.WriteLine($"\t\t\tVersion(Origin): {basePluginPointer.PluginVersion}");
                        Console.WriteLine(
                            $"\t\t\tVersion(Installed): {installedPtr?.PluginVersion?.ToString() ?? "NOT INSTALLED"}"
                            );
                    }
                }
            }

            if (InstallAll)
            {
                PackageAddsActivates = repos.SelectMany(x => x.Plugins.Select(y => y.PluginName)).ToArray();
            }

            foreach (string originRemove in OriginRemoves)
            {
                repo.RemoveOrigin(originRemove);
            }

            foreach (string originAdd in OriginAdds)
            {
                repo.AddOrigin(originAdd);
            }

            foreach (string packageDeactivate in PackageDeactivates)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.DEACTIVATE_PACKAGE_ACTION} {packageDeactivate}");
            }

            foreach (string packageRemove in PackageRemoves)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.REMOVE_PACKAGE_ACTION} {packageRemove}");
            }

            foreach (string packageAdd in PackageAdds)
            {
                string package = GetPackage(repos, packageAdd);
                if (package == null)
                {
                    PluginManager.SendLog("Can not Add Package. Url does not exist.");
                    continue;
                }

                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_PACKAGE_ACTION} {package}");
            }

            foreach (string packageAddActivate in PackageAddsActivates)
            {
                string package = GetPackage(repos, packageAddActivate);

                if (package == null)
                {
                    PluginManager.SendLog("Can not Add Package. Url does not exist.");
                    continue;
                }

                ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {package}");
            }

            foreach (string packageActivate in PackageActivates)
            {
                ActionRunner.AddActionToStartup($"{ActionRunner.ACTIVATE_PACKAGE_ACTION} {packageActivate}");
            }


            Debug.OnConfigCreate += ProjectDebugConfig_OnConfigCreate;
        }
Example #6
0
 private void btnInstallPackage_Click(object sender, EventArgs e)
 {
     ActionRunner.AddActionToStartup($"{ActionRunner.ADD_ACTIVATE_PACKAGE_ACTION} {tbPackageOrigin.Text}");
     MessageBox.Show("Package will be added on the next restart");
 }