diff options
| -rw-r--r-- | bin/install_fullcalendar.php | 42 | ||||
| -rw-r--r-- | composer.json | 4 |
2 files changed, 42 insertions, 4 deletions
diff --git a/bin/install_fullcalendar.php b/bin/install_fullcalendar.php index aafce77..1a2839e 100644 --- a/bin/install_fullcalendar.php +++ b/bin/install_fullcalendar.php | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // bin/install_fullcalendar.php | 2 | // bin/install_fullcalendar.php |
| 3 | |||
| 3 | function installFullCalendar(): void | 4 | function installFullCalendar(): void |
| 4 | { | 5 | { |
| 5 | $path = 'public/js/fullcalendar'; | 6 | $path = 'public/js/fullcalendar'; |
| @@ -18,7 +19,9 @@ function installFullCalendar(): void | |||
| 18 | if(!is_dir($path)){ | 19 | if(!is_dir($path)){ |
| 19 | mkdir($path, 0755, true); | 20 | mkdir($path, 0755, true); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | $old_version = getVersion($path . '/' . $key); // peut être null | ||
| 24 | |||
| 22 | $file = @fopen($path . '/' . $key, 'w+'); // @masque l'erreur pour la traiter soi-même | 25 | $file = @fopen($path . '/' . $key, 'w+'); // @masque l'erreur pour la traiter soi-même |
| 23 | if(!$file){ // erreur écriture fichier | 26 | if(!$file){ // erreur écriture fichier |
| 24 | echo "Erreur : Impossible d'ouvrir le fichier $path pour l'écriture.\n"; | 27 | echo "Erreur : Impossible d'ouvrir le fichier $path pour l'écriture.\n"; |
| @@ -36,6 +39,41 @@ function installFullCalendar(): void | |||
| 36 | 39 | ||
| 37 | fclose($file); | 40 | fclose($file); |
| 38 | curl_close($curl); | 41 | curl_close($curl); |
| 39 | } | 42 | |
| 43 | $new_version = getVersion($path . '/' . $key); | ||
| 44 | |||
| 45 | if(!$old_version){ | ||
| 46 | echo $key . " installé " . $new_version . "\n"; | ||
| 47 | } | ||
| 48 | elseif($old_version === $new_version){ | ||
| 49 | echo $key . " réinstallé " . $new_version . "\n"; | ||
| 50 | } | ||
| 51 | else{ | ||
| 52 | echo $key . " mis à jour de " . $old_version . " vers " . $new_version . "\n"; | ||
| 53 | } | ||
| 54 | } | ||
| 40 | } | 55 | } |
| 56 | |||
| 57 | function getVersion(string $path): ?string | ||
| 58 | { | ||
| 59 | if(!is_file($path)){ | ||
| 60 | return null; | ||
| 61 | } | ||
| 62 | |||
| 63 | $file = fopen($path, 'r'); | ||
| 64 | if(!$file){ | ||
| 65 | return null; | ||
| 66 | } | ||
| 67 | |||
| 68 | for($i = 0; $i < 5 && ($line = fgets($file)) !== false; $i++){ | ||
| 69 | if(preg_match('/FullCalendar .*? (v[0-9.]+)/', $line, $matches)){ | ||
| 70 | fclose($file); | ||
| 71 | return $matches[1]; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | fclose($file); | ||
| 76 | return null; | ||
| 77 | } | ||
| 78 | |||
| 41 | installFullCalendar(); | 79 | installFullCalendar(); |
diff --git a/composer.json b/composer.json index b8ddaa2..6378d12 100644 --- a/composer.json +++ b/composer.json | |||
| @@ -19,14 +19,14 @@ | |||
| 19 | "post-install-cmd": [ | 19 | "post-install-cmd": [ |
| 20 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/tinymce/tinymce public/js/tinymce", | 20 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/tinymce/tinymce public/js/tinymce", |
| 21 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/mklkj/tinymce-i18n/langs public/js/tinymce-langs", | 21 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/mklkj/tinymce-i18n/langs public/js/tinymce-langs", |
| 22 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_fullcalendar.php", | ||
| 23 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/twbs/bootstrap-icons/icons public/icons" | 22 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/twbs/bootstrap-icons/icons public/icons" |
| 23 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_fullcalendar.php", | ||
| 24 | ], | 24 | ], |
| 25 | "post-update-cmd": [ | 25 | "post-update-cmd": [ |
| 26 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/tinymce/tinymce public/js/tinymce", | 26 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/tinymce/tinymce public/js/tinymce", |
| 27 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/mklkj/tinymce-i18n/langs public/js/tinymce-langs", | 27 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/mklkj/tinymce-i18n/langs public/js/tinymce-langs", |
| 28 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_fullcalendar.php", | ||
| 29 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/twbs/bootstrap-icons/icons public/icons" | 28 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/twbs/bootstrap-icons/icons public/icons" |
| 29 | "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_fullcalendar.php", | ||
| 30 | ] | 30 | ] |
| 31 | }, | 31 | }, |
| 32 | "authors": [ | 32 | "authors": [ |
