. /** * Build script to properly create a distribution zip * @package local_treestudyplan * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('CLI_SCRIPT', true); require_once("../../config.php"); $plugin = new stdClass; require_once('version.php'); $a = explode("_", $plugin->component, 2); $plugin->type = $a[0]; $plugin->name = $a[1]; $excludepaths = [ "build", // Dir for build zip files. "build/*", "build.*", "vuemode.sh", ".git", ".git/*", ".gitignore", "*.zip", ]; // Determine some paths. $wd = realpath(dirname(__FILE__)); $parent = dirname($wd); $plugindirname = basename($wd); $builddir = $wd."/"."build"; $zipname = $builddir."/"."{$plugin->name}-{$plugin->version}.zip"; // Create the exclude line. $exclude = "-x "; foreach ($excludepaths as $x) { $exclude .= "'{$plugindirname}/{$x}' "; } if (!is_dir($builddir)) { mkdir($builddir); if (!is_dir($builddir)) { print("Cannot access dir '{$builddir}' to store zip files\n"); exit(1); } } if (file_exists($zipfile)) { print("Zip file '{$zipfile}' already exists. Exiting...\n"); exit(1); } $cwd = getcwd(); chdir($parent); $cmd = "zip -r '{$zipname}' '{$plugindirname}' {$exclude}"; system($cmd); chdir($cwd);