<?php

function ignoreWith($ignoredFiles)
{
  return fn($file) => !in_array($file, $ignoredFiles);
}

function isChild($file)
{
  return $file !== '.' && $file !== '..';
}


if (is_file('./salkantay-api.zip')) {
  unlink('./salkantay-api.zip');
}

$ignore = explode("\n", file_get_contents('./.buildignore'));
$files = scandir('.');

$noIgnored = array_filter(array_filter($files, ignoreWith($ignore)), 'isChild');
$noIgnored = implode(' ', $noIgnored);


shell_exec("powershell.exe \"& 'C:\Program Files\WinRAR\WinRAR.exe' a -r ./salkantay-api.zip $noIgnored\"");
// shell_exec("powershell.exe \"& 'C:\Program Files (x86)\WinRAR\WinRAR.exe' a -r ./salkantay-api.zip .editorconfig .env.example .gitattributes .gitignore\"");
