|
|
|
|
@ -8,8 +8,8 @@ declare(strict_types=1); |
|
|
|
|
* @license https://mit-license.org/ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
$show_authors = true; |
|
|
|
|
$debugging_AKA_non_production_mode = false; |
|
|
|
|
|
|
|
|
|
if ($debugging_AKA_non_production_mode) { |
|
|
|
|
$print_new_line = true; |
|
|
|
|
$show_filename_comments = true; |
|
|
|
|
@ -17,10 +17,42 @@ if ($debugging_AKA_non_production_mode) { |
|
|
|
|
$skip_extras_folder = false; |
|
|
|
|
} else { |
|
|
|
|
$print_new_line = false; |
|
|
|
|
$show_filename_comments = false; |
|
|
|
|
$show_filename_comments = true; |
|
|
|
|
$skip_mocking_data_arrays = true; |
|
|
|
|
$skip_extras_folder = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach($argv as $arg) { |
|
|
|
|
if ($arg === "/?") { |
|
|
|
|
?> |
|
|
|
|
-prod break up mocking array data file and extras folder into separate files |
|
|
|
|
-dev build one big file (non-minimized) |
|
|
|
|
-authors (Removes all comment blocks, including the author/(c)) |
|
|
|
|
/? this help |
|
|
|
|
<?php |
|
|
|
|
exit(0); |
|
|
|
|
} |
|
|
|
|
if ($arg === "-prod" || $arg === "--prod") { |
|
|
|
|
$debugging_AKA_non_production_mode = false; |
|
|
|
|
$print_new_line = false; |
|
|
|
|
$skip_mocking_data_arrays = true; |
|
|
|
|
$skip_extras_folder = true; |
|
|
|
|
echo "Prod mode on"; |
|
|
|
|
} |
|
|
|
|
if ($arg === "-dev" || $arg === "--dev") { |
|
|
|
|
$debugging_AKA_non_production_mode = true; |
|
|
|
|
$print_new_line = true; |
|
|
|
|
$skip_mocking_data_arrays = false; |
|
|
|
|
$skip_extras_folder = false; |
|
|
|
|
echo "Dev mode on"; |
|
|
|
|
} |
|
|
|
|
if ($arg === "-authors" || $arg === "--authors") { |
|
|
|
|
$show_authors = false; |
|
|
|
|
$show_filename_comments = false; |
|
|
|
|
echo "Skipping Comments/Authors..."; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$make_one_file = true; |
|
|
|
|
|
|
|
|
|
if ($make_one_file) { |
|
|
|
|
@ -29,6 +61,9 @@ if ($make_one_file) { |
|
|
|
|
multi_files(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Default and best mode |
|
|
|
|
*/ |
|
|
|
|
function single_file(): void { |
|
|
|
|
$bootstap_files = glob("bootstrap/*.php"); |
|
|
|
|
|
|
|
|
|
@ -51,6 +86,9 @@ function single_file(): void { |
|
|
|
|
get_classes($rsearch['extras'], "tts_extras"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Left in here in case you wanted to play with loading this way |
|
|
|
|
*/ |
|
|
|
|
function multi_files(): void { |
|
|
|
|
$bootstap_files = glob("bootstrap/*.php"); |
|
|
|
|
|
|
|
|
|
@ -177,15 +215,22 @@ function rsearch(array & $file_list, string $folder, string $pattern): array { |
|
|
|
|
return ['extras' => $extras, 'arrays' => $arrays]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function remove_comments(string & $str): void { |
|
|
|
|
function remove_comments(string & $str): array { |
|
|
|
|
$authors = []; |
|
|
|
|
foreach (token_get_all($str) as $token ) { |
|
|
|
|
if ($token[0] != \T_COMMENT && |
|
|
|
|
$token[0] != \T_DOC_COMMENT |
|
|
|
|
) { |
|
|
|
|
continue; // Do nothing on NON-Comments! |
|
|
|
|
} |
|
|
|
|
if (str_contains($token[1], "@author") || str_contains($token[1], "@copyright")) { |
|
|
|
|
if (! str_contains($token[1], "Robert Strutts")) { |
|
|
|
|
$authors[] = $token[1]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$str = str_replace($token[1], '', $str); // Replace comment |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $authors; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function is_folder(string $dir): bool { |
|
|
|
|
@ -206,7 +251,8 @@ function compile( |
|
|
|
|
bool $append = false, |
|
|
|
|
?string $prefix = "", |
|
|
|
|
?string $postfix = "" |
|
|
|
|
): void { |
|
|
|
|
): void { |
|
|
|
|
$show_authors = $GLOBALS['show_authors'] ?? true; |
|
|
|
|
$root_path = __DIR__ . '/'; |
|
|
|
|
is_folder($root_path); |
|
|
|
|
|
|
|
|
|
@ -226,11 +272,14 @@ function compile( |
|
|
|
|
} |
|
|
|
|
if (! $append) { |
|
|
|
|
fwrite($fl_handle, "<?php \r\n declare(strict_types=1);\r\n");
|
|
|
|
|
fwrite($fl_handle, "\t /** \r\n \t * @link https://git.mysnippetsofcode.com/tts/tts_framework \r\n \t * @author Robert Strutts <Robert@TryingToScale.com> \r\n \t * @copyright Copyright (c) 2022, Robert Strutts. \r\n \t * @license MIT \r\n \t */ \r\n"); |
|
|
|
|
if ($show_authors) { |
|
|
|
|
fwrite($fl_handle, "\t /** \r\n \t * @link https://git.mysnippetsofcode.com/tts/tts_framework \r\n \t * @author Robert Strutts <Robert@TryingToScale.com> \r\n \t * @copyright Copyright (c) 2022, Robert Strutts. \r\n \t * @license MIT \r\n \t */ \r\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($prefix !== null && ! empty($prefix)) { |
|
|
|
|
fwrite($fl_handle, $prefix); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($files as $file) { |
|
|
|
|
$file_with_path = $root_path . $file; |
|
|
|
|
|
|
|
|
|
@ -238,8 +287,8 @@ function compile( |
|
|
|
|
if ($content === false) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
remove_comments($content); |
|
|
|
|
|
|
|
|
|
$authors = remove_comments($content); |
|
|
|
|
|
|
|
|
|
$a = explode(PHP_EOL, $content); |
|
|
|
|
unset($content); |
|
|
|
|
@ -249,9 +298,15 @@ function compile( |
|
|
|
|
if ($is_php_start_block) { |
|
|
|
|
$is_php_start_block = false; |
|
|
|
|
if ($GLOBALS['show_filename_comments']) { |
|
|
|
|
$line = PHP_EOL . "/* Contents of : {$file} */"; |
|
|
|
|
$line = PHP_EOL . "/* Contents of : {$file} */" . PHP_EOL; |
|
|
|
|
fwrite($fl_handle, $line); |
|
|
|
|
} |
|
|
|
|
if ($show_authors) { |
|
|
|
|
foreach($authors as $author) { |
|
|
|
|
fwrite($fl_handle, PHP_EOL); |
|
|
|
|
fwrite($fl_handle, "/*" . str_replace(['/*','*/','*'], ['','',''], $author) . "*/" . PHP_EOL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -281,13 +336,19 @@ function compile( |
|
|
|
|
'\\tts\\contacts\\', |
|
|
|
|
'\\tts\\traits\\database\\', |
|
|
|
|
'\\tts\\traits\\security\\', |
|
|
|
|
'\\tts\\services\\sessions\\']; |
|
|
|
|
'\\tts\\services\\sessions\\', |
|
|
|
|
'\\tts\\exceptions\\', |
|
|
|
|
'\\tts\\extras\\', |
|
|
|
|
]; |
|
|
|
|
$replace = ['tts', 'tts', |
|
|
|
|
'\\tts\\', |
|
|
|
|
'\\tts\\', |
|
|
|
|
'\\tts\\', |
|
|
|
|
'\\tts\\', |
|
|
|
|
'\\tts\\']; |
|
|
|
|
'\\tts\\', |
|
|
|
|
'\\tts\\', |
|
|
|
|
'\\tts\\', |
|
|
|
|
]; |
|
|
|
|
$out = str_replace($search, $replace, $line); |
|
|
|
|
fwrite($fl_handle, $out); |
|
|
|
|
} |
|
|
|
|
|