1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-10-31 21:33:00 +00:00
Pepperminty-Wiki/build.php
Starbeamrainbowlabs e93417f171
Start working on a new extra_data system, but it's not finished yet.
Warning: Everything's broken! If you want to use the latest master, please use the commit before this one.
2019-02-26 23:01:09 +00:00

67 lines
1.8 KiB
PHP

<?php
echo("*** Preparing environment ***\n");
$build_env = new stdClass();
$build_env->target = "build/index.php";
if(file_exists($build_env->target))
{
echo("Deleting old target...\n");
unlink($build_env->target);
}
//////////////////////////////////////////////////////////////////////
//////////////////////// Rebuild Module Index ////////////////////////
//////////////////////////////////////////////////////////////////////
echo("*** Rebuilding module index ***\n");
$modules = glob("modules/*.php");
$module_index = [];
// Defined just in case a module needs to reference them when we require() them
// to gain information
$env = $paths = new stdClass();
function register_module($settings)
{
global $module_index;
// If the optional flag isn't set, then we should set it to false.
if(!isset($settings["optional"]) || !is_bool($settings["optional"]))
$settings["optional"] = false;
$newmodule = [
"name" => $settings["name"],
"version" => $settings["version"],
"author" => $settings["author"],
"description" => $settings["description"],
"id" => $settings["id"],
"lastupdate" => filemtime("modules/" . $settings["id"] . ".php"),
"optional" => $settings["optional"],
"extra_data" => $settings["extra_data"] ?? []
];
$module_index[] = $newmodule;
}
$module_count = count($modules);
$i = 1;
foreach($modules as $filename)
{
echo("[$i / $module_count] Processing $filename \r");
require($filename);
$i++;
}
echo("\n*** Processing complete ***\n");
echo("Writing new module index to disk...");
file_put_contents("module_index.json", json_encode($module_index, JSON_PRETTY_PRINT));
echo("done\n");
//////////////////////////////////////////////////////////////////////
////////////////////////// Build New Target //////////////////////////
//////////////////////////////////////////////////////////////////////
require("pack.php");
?>