|
@@ -9,6 +9,8 @@
|
|
* @license MIT, https://acollington.mit-license.org/
|
|
* @license MIT, https://acollington.mit-license.org/
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+$options = getopt('l', ['local-js']);
|
|
|
|
+$makeJsLocal = (isset($options['l']) || isset($options['local-js']));
|
|
$parentPath = dirname(__DIR__);
|
|
$parentPath = dirname(__DIR__);
|
|
|
|
|
|
if (!file_exists($parentPath . '/node_modules')) {
|
|
if (!file_exists($parentPath . '/node_modules')) {
|
|
@@ -25,12 +27,26 @@ echo "🚀 Creating single build file\n";
|
|
$template = trim(file_get_contents(__DIR__ . '/template.phps'));
|
|
$template = trim(file_get_contents(__DIR__ . '/template.phps'));
|
|
$jsOutput = trim(file_get_contents(__DIR__ . '/interface.js'));
|
|
$jsOutput = trim(file_get_contents(__DIR__ . '/interface.js'));
|
|
$cssOutput = trim(file_get_contents(__DIR__ . '/interface.css'));
|
|
$cssOutput = trim(file_get_contents(__DIR__ . '/interface.css'));
|
|
-$phpOutput = trim(join('', array_slice(file($parentPath . '/src/Opcache/Service.php'), 3)));
|
|
|
|
|
|
+$phpOutput = trim(implode('', array_slice(file($parentPath . '/src/Opcache/Service.php'), 3)));
|
|
$output = str_replace(
|
|
$output = str_replace(
|
|
['{{JS_OUTPUT}}', '{{CSS_OUTPUT}}', '{{PHP_OUTPUT}}'],
|
|
['{{JS_OUTPUT}}', '{{CSS_OUTPUT}}', '{{PHP_OUTPUT}}'],
|
|
[$jsOutput, $cssOutput, $phpOutput],
|
|
[$jsOutput, $cssOutput, $phpOutput],
|
|
$template
|
|
$template
|
|
);
|
|
);
|
|
|
|
+if ($makeJsLocal) {
|
|
|
|
+ echo "🔗 Making js links local\n";
|
|
|
|
+ $jsTags = [];
|
|
|
|
+ $matched = preg_match_all('!<script src="([^"]*)"></script>!', $output, $jsTags);
|
|
|
|
+ if ($matched) {
|
|
|
|
+ foreach ($jsTags[1] as $jsUrl) {
|
|
|
|
+ $jsFile = basename($jsUrl);
|
|
|
|
+ $jsFilePath = $parentPath . '/' . $jsFile;
|
|
|
|
+ file_put_contents($jsFilePath, file_get_contents('https:' . $jsUrl));
|
|
|
|
+ $output = str_replace($jsUrl, $jsFile, $output);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
file_put_contents($parentPath . '/index.php', $output);
|
|
file_put_contents($parentPath . '/index.php', $output);
|
|
|
|
|
|
echo "💯 Done!\n";
|
|
echo "💯 Done!\n";
|