From 80187c7056e5c38d1d4a29b346d1508dafcc9dd1 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Sat, 3 Jun 2023 16:05:27 +0200 Subject: [PATCH] added build script to easily create zip files --- .gitignore | 1 + build.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ build.sh | 3 +++ 3 files changed, 57 insertions(+) create mode 100644 build.php create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 7c6e0dc..91924d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.vs /node_modules /amd/build +/build diff --git a/build.php b/build.php new file mode 100644 index 0000000..10d5505 --- /dev/null +++ b/build.php @@ -0,0 +1,53 @@ +component,2); +$plugin->type = $a[0]; +$plugin->name = $a[1]; + +$exclude_paths = [ + "build", // dir for build zip files + "build/*", + "build.*", + "amd/src", + "amd/src/*", + ".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($exclude_paths 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(is_file($zipfile)){ + unlink($zipfile); +} + +$cwd = getcwd(); +chdir($parent); + +$cmd = "zip -r '{$zipname}' '{$plugindirname}' {$exclude}"; +system($cmd); + +chdir($cwd); + diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..058b5f0 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +php ${SCRIPT_DIR}/build.php $@