From ed20b06498795a88ee92f7f4aa38d82bb2e6c343 Mon Sep 17 00:00:00 2001 From: n0nag0n Date: Wed, 13 Dec 2023 10:20:14 -0700 Subject: [PATCH] added support for windows projects, updated libs --- composer.lock | 24 ++++++++++----------- controllers/Config_Check_Controller.php | 2 +- controllers/Controller_Controller.php | 10 ++++----- controllers/Devtools_Controller.php | 2 +- controllers/Index_Controller.php | 2 +- controllers/Init_Environment_Controller.php | 22 +++++++++---------- controllers/Manage_Composer_Controller.php | 21 +++++++++--------- controllers/Model_Controller.php | 6 +++--- controllers/Plugin_Controller.php | 2 +- controllers/Route_Controller.php | 4 ++-- templates/bootstrap.php | 2 +- templates/config.ini | 10 ++++----- templates/index.php | 4 ++-- templates/main_config.ini | 6 +++--- utils/ComposerInterfaceAdapter.php | 2 +- 15 files changed, 60 insertions(+), 59 deletions(-) diff --git a/composer.lock b/composer.lock index 77eb039..f7463ed 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "bcosca/fatfree-core", - "version": "3.8.1", + "version": "3.8.2", "source": { "type": "git", "url": "https://github.com/f3-factory/fatfree-core.git", - "reference": "f6ea45472f55a1ecabd4ced74cb56f0efd6af34e" + "reference": "774692ce7698904d3cb35bbd4f79376bb17eeddc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/f3-factory/fatfree-core/zipball/f6ea45472f55a1ecabd4ced74cb56f0efd6af34e", - "reference": "f6ea45472f55a1ecabd4ced74cb56f0efd6af34e", + "url": "https://api.github.com/repos/f3-factory/fatfree-core/zipball/774692ce7698904d3cb35bbd4f79376bb17eeddc", + "reference": "774692ce7698904d3cb35bbd4f79376bb17eeddc", "shasum": "" }, "require": { @@ -37,9 +37,9 @@ "homepage": "http://fatfreeframework.com/", "support": { "issues": "https://github.com/f3-factory/fatfree-core/issues", - "source": "https://github.com/f3-factory/fatfree-core/tree/3.8.1" + "source": "https://github.com/f3-factory/fatfree-core/tree/3.8.2" }, - "time": "2022-11-04T23:15:19+00:00" + "time": "2023-07-23T22:11:30+00:00" }, { "name": "ikkez/f3-flash", @@ -121,16 +121,16 @@ }, { "name": "net-tools/composer-interface", - "version": "1.0.15", + "version": "1.0.16", "source": { "type": "git", "url": "https://github.com/net-tools/composer-interface.git", - "reference": "079964b37399851763efbd3571205388829fd355" + "reference": "1640d38b4fff3ff31a53d49826381e25a148e6cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/net-tools/composer-interface/zipball/079964b37399851763efbd3571205388829fd355", - "reference": "079964b37399851763efbd3571205388829fd355", + "url": "https://api.github.com/repos/net-tools/composer-interface/zipball/1640d38b4fff3ff31a53d49826381e25a148e6cc", + "reference": "1640d38b4fff3ff31a53d49826381e25a148e6cc", "shasum": "" }, "require": { @@ -151,9 +151,9 @@ "description": "PHP shell interface to Composer when SSH is not available on your host ", "support": { "issues": "https://github.com/net-tools/composer-interface/issues", - "source": "https://github.com/net-tools/composer-interface/tree/1.0.15" + "source": "https://github.com/net-tools/composer-interface/tree/1.0.16" }, - "time": "2022-03-08T16:48:51+00:00" + "time": "2023-09-10T12:43:37+00:00" } ], "packages-dev": [], diff --git a/controllers/Config_Check_Controller.php b/controllers/Config_Check_Controller.php index 8624f8a..e34fbde 100644 --- a/controllers/Config_Check_Controller.php +++ b/controllers/Config_Check_Controller.php @@ -6,6 +6,6 @@ class Config_Check_Controller extends Base_Controller { public function indexAction(\Base $fw): void { - $this->renderHtml('config_check/index.htm'); + $this->renderHtml('config_check'.DIRECTORY_SEPARATOR.'index.htm'); } } diff --git a/controllers/Controller_Controller.php b/controllers/Controller_Controller.php index 6dc6c4d..d762808 100644 --- a/controllers/Controller_Controller.php +++ b/controllers/Controller_Controller.php @@ -9,11 +9,11 @@ class Controller_Controller extends Base_Controller { public function indexAction(\Base $fw): void { $controllers = $this->getControllers(); - $this->renderHtml('controllers/index.htm', [ 'controllers' => $controllers ]); + $this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'index.htm', [ 'controllers' => $controllers ]); } public function addAction(\Base $fw): void { - $this->renderHtml('controllers/add.htm'); + $this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'add.htm'); } public function create(\Base $fw, array $args = []): void { @@ -50,7 +50,7 @@ public function detailsAction(\Base $fw, array $args = []): void { $methods = $this->getControllerMethods($controller); $methods = $this->getControllerEndpointMethods($controller); - $this->renderHtml('controllers/details.htm', [ + $this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'details.htm', [ 'controller_name' => $controller, 'methods' => $methods ]); @@ -58,7 +58,7 @@ public function detailsAction(\Base $fw, array $args = []): void { public function addEndpointAction(\Base $fw, array $args = []): void { $controller = $args['controller']; - $this->renderHtml('controllers/add_endpoint.htm', [ + $this->renderHtml('controllers'.DIRECTORY_SEPARATOR.'add_endpoint.htm', [ 'controller_name' => $controller ]); } @@ -115,7 +115,7 @@ public function createControllerFile(string $controller_name): bool { throw new \Exception('The controller already exists'); } - $contents = $this->fw->read(__DIR__.'/../templates/Controller.php'); + $contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'Controller.php'); $contents = str_replace([ 'resolve($contents); $write_result = $this->fw->write($full_path, str_replace('#?php', 'config(__DIR__.'/../config/webtools_config.ini', true); + $fw->config(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'webtools_config.ini', true); $fw->set('DB', new \DB\Jig($fw->PROJECT_DATA_DIR, \DB\Jig::FORMAT_JSON )); $Project_Config = new Project_Config($fw->DB); diff --git a/controllers/Index_Controller.php b/controllers/Index_Controller.php index 6b004a2..fd09cde 100644 --- a/controllers/Index_Controller.php +++ b/controllers/Index_Controller.php @@ -13,7 +13,7 @@ public function index(\Base $fw): void { $fw->reroute('/init-environment'); } - $this->renderHtml('index/index.htm'); + $this->renderHtml('index'.DIRECTORY_SEPARATOR.'index.htm'); } } diff --git a/controllers/Init_Environment_Controller.php b/controllers/Init_Environment_Controller.php index c8ece4e..987bdf7 100644 --- a/controllers/Init_Environment_Controller.php +++ b/controllers/Init_Environment_Controller.php @@ -10,7 +10,7 @@ class Init_Environment_Controller extends Base_Controller { protected array $temp; public function indexAction(\Base $fw): void { - $this->renderHtml('init_environment/index.htm', [ 'PAGE_TITLE' => 'Initialize Environment' ]); + $this->renderHtml('init_environment'.DIRECTORY_SEPARATOR.'index.htm', [ 'PAGE_TITLE' => 'Initialize Environment' ]); } public function pageAction(\Base $fw, array $args = []): void { @@ -21,42 +21,42 @@ public function pageAction(\Base $fw, array $args = []): void { switch($page) { case 'title': - $page_ui = 'init_environment/title.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'title.htm'; $page_title = 'Title'; break; case 'directory-setup': - $page_ui = 'init_environment/directory_setup.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'directory_setup.htm'; $page_title = 'Directory Setup'; break; case 'basic-config': - $page_ui = 'init_environment/basic_config.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'basic_config.htm'; $page_title = 'Basic Config'; break; case 'choose-database': - $page_ui = 'init_environment/choose_database.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'choose_database.htm'; $page_title = 'Choose Database'; break; case 'jig': - $page_ui = 'init_environment/jig.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'jig.htm'; $page_title = 'Jig'; break; case 'sqlite': - $page_ui = 'init_environment/sqlite.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'sqlite.htm'; $page_title = 'SQLite'; break; case 'mysql': - $page_ui = 'init_environment/mysql.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'mysql.htm'; $page_title = 'MySQL'; break; case 'security': - $page_ui = 'init_environment/security.htm'; + $page_ui = 'init_environment'.DIRECTORY_SEPARATOR.'security.htm'; $page_title = 'Security'; break; @@ -155,7 +155,7 @@ protected function createProjectDir(string $relative_path): bool { protected function createProjectFile(string $relative_path, string $template_file_path): bool { $file_path = $this->fw->PROJECT_BASE_DIR.$relative_path; if(!empty($relative_path) && !file_exists($file_path)) { - $contents = $this->fw->read(__DIR__.'/../templates/'.$template_file_path); + $contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$template_file_path); $contents = str_replace('parse($contents); @@ -186,7 +186,7 @@ protected function createControllerFileOld(string $relative_path): bool { if(!file_exists($this->fw->PROJECT_BASE_DIR.$relative_path)) { $controller_filename = basename($this->fw->PROJECT_BASE_DIR.$relative_path); $controller_name = explode('.', $controller_filename)[0]; - $contents = $this->fw->read(__DIR__.'/../templates/Controller.php'); + $contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'Controller.php'); $contents = str_replace([ 'resolve($contents); $this->fw->write($this->fw->PROJECT_BASE_DIR.$relative_path, str_replace('#?php', 'PROJECT_BASE_DIR, '/'); + $root = rtrim($fw->PROJECT_BASE_DIR, DIRECTORY_SEPARATOR); $ret = ''; try { @@ -34,7 +34,8 @@ public function indexAction(\Base $fw): void { '/usr/bin/', '~/', $fw->PROJECT_BASE_DIR, - '.' + '.', + 'C:\ProgramData\ComposerSetup\bin' ]; $composer_bin_location = ''; foreach([ 'composer', 'composer.phar' ] as $composer_app_name) { @@ -84,8 +85,8 @@ public function indexAction(\Base $fw): void { error_reporting(E_ALL); - if(file_exists($root . '/composer.json')) { - $composer_file_contents = file_get_contents($root . '/composer.json'); + if(file_exists($root . DIRECTORY_SEPARATOR . 'composer.json')) { + $composer_file_contents = file_get_contents($root . DIRECTORY_SEPARATOR . 'composer.json'); } else { $composer_file_contents = "No composer.json file detected; you MUST install composer by hitting the SETUP link below.>"; } @@ -94,9 +95,9 @@ public function indexAction(\Base $fw): void { $params = [ 'command_return' => $ret, 'composer_file_contents' => $composer_file_contents, - 'composer_file_path' => $root.'/composer.json' + 'composer_file_path' => $root.DIRECTORY_SEPARATOR.'composer.json' ]; - $this->renderHtml('manage_composer/index.htm', $params); + $this->renderHtml('manage_composer'.DIRECTORY_SEPARATOR.'index.htm', $params); } } diff --git a/controllers/Model_Controller.php b/controllers/Model_Controller.php index e651ceb..82ec7cc 100644 --- a/controllers/Model_Controller.php +++ b/controllers/Model_Controller.php @@ -9,11 +9,11 @@ class Model_Controller extends Base_Controller { public function indexAction(\Base $fw): void { $models = $this->getModels(); - $this->renderHtml('models/index.htm', [ 'models' => $models ]); + $this->renderHtml('models'.DIRECTORY_SEPARATOR.'index.htm', [ 'models' => $models ]); } public function addAction(\Base $fw): void { - $this->renderHtml('models/add.htm'); + $this->renderHtml('models'.DIRECTORY_SEPARATOR.'add.htm'); } public function create(\Base $fw, array $args = []): void { @@ -54,7 +54,7 @@ public function createModelFile(string $model_name, string $table_name): bool { throw new \Exception('The model already exists'); } - $contents = $this->fw->read(__DIR__.'/../templates/Model.php'); + $contents = $this->fw->read(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'Model.php'); $contents = str_replace([ 'resolve($contents); $write_result = $this->fw->write($full_path, str_replace('#?php', 'renderHtml('plugins/index.htm', $projects); + $this->renderHtml('plugins'.DIRECTORY_SEPARATOR.'index.htm', $projects); } public static function hasPackageInstalled(string $package_name): bool { diff --git a/controllers/Route_Controller.php b/controllers/Route_Controller.php index b204044..6c1863d 100644 --- a/controllers/Route_Controller.php +++ b/controllers/Route_Controller.php @@ -16,7 +16,7 @@ public function __construct(\Base $fw) { public function indexAction(\Base $fw): void { $routes = $this->getRoutes(); - $this->renderHtml('routes/index.htm', [ 'routes' => $routes ]); + $this->renderHtml('routes'.DIRECTORY_SEPARATOR.'index.htm', [ 'routes' => $routes ]); } public function addAction(\Base $fw): void { @@ -25,7 +25,7 @@ public function addAction(\Base $fw): void { foreach($controllers as &$controller) { $controller['endpoints'] = $Controller_Controller->getControllerEndpointMethods($controller['base_name']); } - $this->renderHtml('routes/add.htm', [ + $this->renderHtml('routes'.DIRECTORY_SEPARATOR.'add.htm', [ 'controllers' => $controllers ]); } diff --git a/templates/bootstrap.php b/templates/bootstrap.php index fe2d8d8..4d05b9c 100644 --- a/templates/bootstrap.php +++ b/templates/bootstrap.php @@ -11,7 +11,7 @@ $fw = Base::instance(); // Define some constants you may need -define('PROJECT_DEVTOOLS_DATA_DIR', PROJECT_ROOT_DIR.'.fatfree-devtools/'); +define('PROJECT_DEVTOOLS_DATA_DIR', PROJECT_ROOT_DIR.'.fatfree-devtools'.DIRECTORY_SEPARATOR); // This will hold the config settings necessary for your routes, variables, connection settings, etc. $fw->config(PROJECT_ROOT_DIR.'{{ @cnf_config }}main_config.ini', true); diff --git a/templates/config.ini b/templates/config.ini index cd30f12..6ba8d50 100644 --- a/templates/config.ini +++ b/templates/config.ini @@ -1,17 +1,17 @@ [globals] ; Various config options -AUTOLOAD = "../{{ @cnf_controller }}; ../{{ @cnf_model }}; ../{{ @cnf_utils }}; ../{{ @cnf_task }}; {{ @cnf_autoload ? '../'.@cnf_autoload : '' }}" +AUTOLOAD = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_controller }}; ..{{ DIRECTORY_SEPARATOR }}{{ @cnf_model }}; ..{{ DIRECTORY_SEPARATOR }}{{ @cnf_utils }}; ..{{ DIRECTORY_SEPARATOR }}{{ @cnf_task }}; {{ @cnf_autoload ? '..'.DIRECTORY_SEPARATOR.@cnf_autoload : '' }}" CACHE = {{ @cnf_cache }} DEBUG = {{ @cnf_debug }} ENCODING = {{ @cnf_encoding }} ESCAPE = {{ @cnf_escape ? 'true' : 'false' }} HALT = {{ @cnf_halt ? 'true' : 'false' }} HIGHLIGHT = {{ @cnf_highlight ? 'true' : 'false' }} -UI = "../{{ @cnf_ui }}" -LOGS = "../{{ @cnf_log }}" -TEMP = "../{{ @cnf_temp }}" -UPLOADS = "../{{ @cnf_uploads }}" +UI = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_ui }}" +LOGS = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_log }}" +TEMP = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_temp }}" +UPLOADS = "..{{ DIRECTORY_SEPARATOR }}{{ @cnf_uploads }}" ; Removing the 'Fat-Free Framework' reference for security reasons PACKAGE = "" diff --git a/templates/index.php b/templates/index.php index fb97cbe..6ad2f71 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,6 +1,6 @@ run(); diff --git a/templates/main_config.ini b/templates/main_config.ini index abd60ae..bb7d1d0 100644 --- a/templates/main_config.ini +++ b/templates/main_config.ini @@ -3,10 +3,10 @@ ; Don't edit this file directly! Edit one of the files below! ; ; Main config for variables, connection information, etc. -../{{ @cnf_config }}{{ @cnf_general_config }} = false +..{{ DIRECTORY_SEPARATOR }}{{ @cnf_config }}{{ @cnf_general_config }} = false ; Routes for all your URL endpoints -../{{ @cnf_config }}{{ @cnf_routes }} = false +..{{ DIRECTORY_SEPARATOR }}{{ @cnf_config }}{{ @cnf_routes }} = false ; Routes for all your CLI scripts -../{{ @cnf_config }}{{ @cnf_cli_routes }} = false \ No newline at end of file +..{{ DIRECTORY_SEPARATOR }}{{ @cnf_config }}{{ @cnf_cli_routes }} = false \ No newline at end of file diff --git a/utils/ComposerInterfaceAdapter.php b/utils/ComposerInterfaceAdapter.php index 0180c4d..d87244e 100644 --- a/utils/ComposerInterfaceAdapter.php +++ b/utils/ComposerInterfaceAdapter.php @@ -11,7 +11,7 @@ public function php_shell($script) { // path to php binary $phpbin = $this->_config->composer_phpbin; - // path to composer home ; will be set in the shell environment. We recommand defining a home value + // path to composer home ; will be set in the shell environment. We recommend defining a home value // in the parent folder of the project, allowing sharing data between projects if ( $this->_config->composer_home ) { $home = $this->_config->composer_home;