From 9133b7d6309de551a1025ed6b346cc98c6242264 Mon Sep 17 00:00:00 2001 From: Markus Heck Date: Mon, 16 Dec 2024 04:02:49 +0100 Subject: [PATCH] remove plugins.json from project, add sample plugins.json, improve error handling if file does not exist and update README.md --- README.md | 10 +++++++++- classes/playbook.php | 5 ++++- files/plugins.json | 22 ---------------------- files/plugins.json.sample | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 24 deletions(-) delete mode 100644 files/plugins.json create mode 100644 files/plugins.json.sample diff --git a/README.md b/README.md index 973ce5a..c8b8765 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,12 @@ The following roles are available: The following environment variables are used: - DECLARATIVE_SETUP_MANAGER_PASSWORD: Password for the manager user -- DECLARATIVE_SETUP_STUDENT_PASSWORD: Password for the student user \ No newline at end of file +- DECLARATIVE_SETUP_STUDENT_PASSWORD: Password for the student user + +## files/plugins.json +This file is required if `moodle_dev_env` role is not used. Get the current version from +[ProjektAdLer/MoodleAdlerLMS/files/plugin.json](https://github.com/ProjektAdLer/MoodleAdlerLMS/blob/main/plugins.json). +See plugins.json.sample for an example. + +If this plugin is used in the [AdLer LMS Moodle image](https://github.com/ProjektAdLer/MoodleAdlerLMS), the plugin.json +file is automatically copied to the `files` directory. \ No newline at end of file diff --git a/classes/playbook.php b/classes/playbook.php index 78020f1..efc3d06 100644 --- a/classes/playbook.php +++ b/classes/playbook.php @@ -145,12 +145,15 @@ protected function playbook_implementation(): void { } /** - * @throws invalid_parameter_exception + * @throws moodle_exception * @returns install_plugins_model[] */ private function load_plugins_to_install(): array { $filePath = __DIR__ . '/../files/plugins.json'; $jsonContent = file_get_contents($filePath); + if ($jsonContent === false) { + throw new moodle_exception('Failed to read files/plugins.json. Does it exist?'); + } $pluginsArray = json_decode($jsonContent, true); return array_map(function ($plugin) { diff --git a/files/plugins.json b/files/plugins.json deleted file mode 100644 index a50bce1..0000000 --- a/files/plugins.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "git_project": "ProjektAdLer/MoodlePluginLocal", - "version": "5.0.0", - "name": "local_adler" - }, - { - "git_project": "ProjektAdler/MoodlePluginAvailability", - "version": "4.0.1", - "name": "availability_adler" - }, - { - "git_project": "ProjektAdLer/MoodlePluginModAdleradaptivity", - "version": "3.0.0", - "name": "mod_adleradaptivity" - }, - { - "git_project": "ProjektAdLer/MoodlePluginLocalLogging", - "version": "1.0.0", - "name": "local_logging" - } -] diff --git a/files/plugins.json.sample b/files/plugins.json.sample new file mode 100644 index 0000000..dd976c4 --- /dev/null +++ b/files/plugins.json.sample @@ -0,0 +1,32 @@ +[ + { + "package_repo": "https://packages.projekt-adler.eu/packages/moodle/", + "version": "0.1.0", + "name": "local_declarativesetup" + }, + { + "package_repo": "https://packages.projekt-adler.eu/packages/moodle/", + "version": "0.1.0", + "name": "playbook_adler" + }, + { + "package_repo": "https://packages.projekt-adler.eu/packages/moodle/", + "version": "5.0.0", + "name": "local_adler" + }, + { + "package_repo": "https://packages.projekt-adler.eu/packages/moodle/", + "version": "4.0.1", + "name": "availability_adler" + }, + { + "package_repo": "https://packages.projekt-adler.eu/packages/moodle/", + "version": "3.0.0", + "name": "mod_adleradaptivity" + }, + { + "package_repo": "https://packages.projekt-adler.eu/packages/moodle/", + "version": "1.0.0", + "name": "local_logging" + } +]