Skip to content
Snippets Groups Projects

feat: remove compilation command

Closed Bartek Jaskulski requested to merge v0.10 into main

Files

+ 45
7
@@ -2,16 +2,54 @@
@@ -2,16 +2,54 @@
<?php
<?php
use WPDesk\Init\Util\PhpFileDumper;
use WPDesk\Init\Util\PhpFileDumper;
 
use WPDesk\Init\Plugin\DefaultHeaderParser;
include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
$autoloadPath = $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
 
if (!file_exists($autoloadPath)) {
 
echo "\033[31mError: Autoloader not found. Please run composer install.\033[0m\n";
 
exit(1);
 
}
 
require_once $autoloadPath;
$filename = $argv[1] ?? null;
function displayHelp() {
 
echo "Usage: " . basename(__FILE__) . " <plugin_file> <cache_dir>\n";
 
echo "Initialize a WordPress plugin by parsing the input file and generating output.\n";
 
echo "\n";
 
echo "Arguments:\n";
 
echo " <plugin_file> Path to the input file to parse\n";
 
echo " <cache_dir> Path to the output file to generate\n";
 
}
$parser = new \WPDesk\Init\Plugin\DefaultHeaderParser();
if (in_array('--help', $argv) || in_array('-h', $argv)) {
 
displayHelp();
 
exit(0);
 
}
$data = $parser->parse( $filename );
if ($argc < 3 || in_array('--help', $argv) || in_array('-h', $argv)) {
 
echo "\033[31mError: Missing required arguments.\033[0m\n";
 
displayHelp();
 
exit(1);
 
}
$dumper = new PhpFileDumper();
$inputFile = $argv[1];
$dumper->dump( $parser->parse( $filename ), $argv[2] );
$outputDir = rtrim($argv[2], '/\\') . '/';
//echo "Compile static plugin resources.";
// Check if input file exists
 
if (!file_exists($inputFile)) {
 
echo "\033[31mError: Input file '$inputFile' does not exist.\033[0m\n";
 
exit(1);
 
}
 
 
try {
 
$parser = new DefaultHeaderParser();
 
$data = $parser->parse($inputFile);
 
 
$dumper = new PhpFileDumper();
 
$dumper->dump($data, $outputDir . 'plugin.php');
 
 
echo "\033[32mSuccess: Plugin data generated.\033[0m\n";
 
exit(0);
 
} catch (Exception $e) {
 
echo "\033[31mError: " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\033[0m\n";
 
exit(1);
 
}
Loading