-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* @Author : HanskiJay | ||
* @Date : 2023-02-15 18:49:38 | ||
* @LastEditors : HanskiJay | ||
* @LastEditTime : 2023-02-15 19:04:39 | ||
* @LastEditTime : 2023-02-20 05:46:56 | ||
* @E-Mail : [email protected] | ||
* @Telegram : https://t.me/HanskiJay | ||
* @GitHub : https://github.com/Tommy131 | ||
|
@@ -22,7 +22,6 @@ | |
|
||
|
||
use owoframe\console\CommandBase; | ||
use owoframe\System; | ||
|
||
class AppGeneratorCommand extends CommandBase | ||
{ | ||
|
@@ -34,7 +33,7 @@ public function execute(array $params) : bool | |
} | ||
$appName = strtolower($appName); | ||
$upAppName = ucfirst($appName); | ||
$appPath = \owo\application_path($appName); | ||
$appPath = \owo\application_path($appName, true); | ||
$ctlPath = $appPath . 'controller' . DIRECTORY_SEPARATOR; | ||
$viewPath = $appPath . 'view' . DIRECTORY_SEPARATOR; | ||
$staticPath = $viewPath . 'static' . DIRECTORY_SEPARATOR; | ||
|
@@ -49,12 +48,14 @@ public function execute(array $params) : bool | |
if(!is_dir($staticPath)) mkdir($staticPath, 755, true); | ||
|
||
// Make application main info class file | ||
file_put_contents($appPath . $upAppName . 'App.php', str_replace(['{appName_s}', '{appName_u}'], [$appName, $upAppName], base64_decode('PD9waHAKCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKCSBfX19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6IHN0cmluZwoJewoJCXJldHVybiAne2FwcE5hbWVfc30nOwoJfQoKCXB1YmxpYyBzdGF0aWMgZnVuY3Rpb24gYXV0b1RvNDA0UGFnZSgpIDogYm9vbAoJewoJCXJldHVybiB0cnVlOwoJfQoKCXB1YmxpYyBzdGF0aWMgZnVuY3Rpb24gaXNDTElPbmx5KCkgOiBib29sCgl7CgkJcmV0dXJuIGZhbHNlOwoJfQoKCXB1YmxpYyBzdGF0aWMgZnVuY3Rpb24gZ2V0QXV0aG9yKCkgOiBzdHJpbmcKCXsKCQlyZXR1cm4gJyc7Cgl9CgoJcHVibGljIHN0YXRpYyBmdW5jdGlvbiBnZXREZXNjcmlwdGlvbigpIDogc3RyaW5nCgl7CgkJcmV0dXJuICcnOwoJfQp9Cj8+'))); | ||
$appFile = $appPath . $upAppName . 'App.php'; | ||
file_put_contents($appFile, str_replace(['applicationName', 'className'], [$appName, $upAppName . 'App'], file_get_contents(\owo\s_template_path('DefaultAppTemplate.php')))); | ||
|
||
// Make application default controller file | ||
file_put_contents($ctlPath . $upAppName . '.php', str_replace(['{appName_s}', '{appName_u}'], [$appName, $upAppName], base64_decode('PD9waHAKCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKCSBfX19fXyAgIF8gICAgICAgICAgX18gIF9fX19fICAgX19fX18gICBfICAgICAgIF9fX19fICAgX19fX18KCS8gIF8gIFwgfCB8ICAgICAgICAvIC8gLyAgXyAgXCB8ICBfICBcIHwgfCAgICAgLyAgXyAgXCAvICBfX198Cgl8IHwgfCB8IHwgfCAgX18gICAvIC8gIHwgfCB8IHwgfCB8X3wgfCB8IHwgICAgIHwgfCB8IHwgfCB8Cgl8IHwgfCB8IHwgfCAvICB8IC8gLyAgIHwgfCB8IHwgfCAgXyAgeyB8IHwgICAgIHwgfCB8IHwgfCB8ICBfCgl8IHxffCB8IHwgfC8gICB8LyAvICAgIHwgfF98IHwgfCB8X3wgfCB8IHxfX18gIHwgfF98IHwgfCB8X3wgfAoJXF9fX19fLyB8X19fL3xfX18vICAgICBcX19fX18vIHxfX19fXy8gfF9fX19ffCBcX19fX18vIFxfX19fXy8KCgkqIENvcHlyaWdodCAoYykgMjAxNS0yMDIxIE93T0Jsb2ctREdNVC4KCSogRGV2ZWxvcGVyOiBIYW5za2lKYXkoVG9tbXkxMzEpCgkqIFRlbGVncmFtOiAgaHR0cHM6Ly90Lm1lL0hhbnNraUpheQoJKiBFLU1haWw6ICAgIHN1cHBvcnRAb3dvYmxvZy5jb20KCSogR2l0SHViOiAgICBodHRwczovL2dpdGh1Yi5jb20vVG9tbXkxMzEKCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgpkZWNsYXJlKHN0cmljdF90eXBlcz0xKTsKbmFtZXNwYWNlIGFwcGxpY2F0aW9uXHthcHBOYW1lX3N9XGNvbnRyb2xsZXI7CgpjbGFzcyB7YXBwTmFtZV91fSBleHRlbmRzIFxvd29mcmFtZVxhcHBsaWNhdGlvblxDb250cm9sbGVyQmFzZQp7CglwdWJsaWMgZnVuY3Rpb24ge2FwcE5hbWVfdX0oKQoJewoJCXJldHVybiAnSGVsbG8gd29ybGQhIFRoaXMgYXBwbGljYXRpb24gd2FzIGdlbmVyYXRlZCBieSBPd09GcmFtZTo6UXVpY2tBcHBGcmFtR2VuZXJhdG9yLCB3ZWxjb21lIHRvIHVzZSBpdCA6KSc7Cgl9Cn0KPz4='))); | ||
$controllerFile = $ctlPath . $upAppName . '.php'; | ||
file_put_contents($controllerFile, str_replace(['applicationName', 'className'], [$appName, $upAppName], file_get_contents(\owo\s_template_path('DefaultControllerTemplate.php')))); | ||
|
||
if(System::getApplication($appName)) { | ||
if(is_dir($appPath) && is_file($appFile) && is_file($controllerFile)) { | ||
$this->getLogger()->success("Generated empty AppFrame '{$upAppName}' successfully. Please check the app path '{$appPath}' to develop it."); | ||
return true; | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* @Author : HanskiJay | ||
* @Date : 2023-02-15 18:49:38 | ||
* @LastEditors : HanskiJay | ||
* @LastEditTime : 2023-02-15 19:29:40 | ||
* @LastEditTime : 2023-02-20 05:56:08 | ||
* @E-Mail : [email protected] | ||
* @Telegram : https://t.me/HanskiJay | ||
* @GitHub : https://github.com/Tommy131 | ||
|
@@ -22,6 +22,7 @@ | |
|
||
|
||
use owoframe\console\CommandBase; | ||
use owoframe\object\Pipe; | ||
use owoframe\System; | ||
|
||
class RemoveAppCommand extends CommandBase | ||
|
@@ -39,15 +40,19 @@ public function execute(array $params) : bool | |
return true; | ||
} | ||
|
||
$answer = (string) \owo\ask('ARE YOU SURE THAT YOU WANT TO DELETE/REMOVE THIS APPLICATION? THIS OPERATION IS IRREVERSIBLE! [Y/N]', 'N', '[WARNING] '); | ||
if(strtolower($answer) === 'y') { | ||
$this->getLogger()->warning('Now will remove this application forever...'); | ||
if(\owo\remove_dir(\owo\application_path(strtolower($appName)))) { | ||
$this->getLogger()->success("Removed Application '{$appName}' successfully."); | ||
\owo\pipe_ask('ARE YOU SURE THAT YOU WANT TO DELETE/REMOVE THIS APPLICATION? THIS OPERATION IS IRREVERSIBLE! [Y/N]', ['y', 'Y', 'yes', 'YES']) | ||
->do(function(Pipe $object) use ($appName) { | ||
if($object->isContinue()) { | ||
$this->getLogger()->warning('Now will remove this application forever...'); | ||
if(\owo\remove_dir(\owo\application_path(strtolower($appName)))) { | ||
$this->getLogger()->success("Removed Application '{$appName}' successfully."); | ||
} else { | ||
$this->getLogger()->error('Somewhere was wrong that cannot remove this application!'); | ||
} | ||
} else { | ||
$this->getLogger()->error('Somewhere was wrong that cannot remove this application!'); | ||
$this->getLogger()->info('Cancelled.'); | ||
} | ||
} | ||
}); | ||
return true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* @Author : HanskiJay | ||
* @Date : 2023-02-20 03:05:15 | ||
* @LastEditors : HanskiJay | ||
* @LastEditTime : 2023-02-20 04:19:27 | ||
* @LastEditTime : 2023-02-20 06:18:41 | ||
* @E-Mail : [email protected] | ||
* @Telegram : https://t.me/HanskiJay | ||
* @GitHub : https://github.com/Tommy131 | ||
|
@@ -106,6 +106,17 @@ public function then() : Pipe | |
return $this; | ||
} | ||
|
||
/** | ||
* 立刻执行此操作, 不检测 | ||
* | ||
* @return Pipe | ||
*/ | ||
public function do(callable $callback) : Pipe | ||
{ | ||
$this->lastResult = $callback($this); | ||
return $this; | ||
} | ||
|
||
/** | ||
* 最终执行方法 | ||
* | ||
|
@@ -114,7 +125,11 @@ public function then() : Pipe | |
*/ | ||
public function finally(callable $callback) : Pipe | ||
{ | ||
$this->finalResult = $callback($this); | ||
if($this->isContinue()) { | ||
$this->finalResult = $callback($this); | ||
} else { | ||
$this->lastResult = null; | ||
} | ||
return $this; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/* | ||
* _____ _ __ _____ _____ _ _____ _____ | ||
* / _ \ | | / / / _ \ | _ \ | | / _ \ / ___| | ||
* | | | | | | __ / / | | | | | |_| | | | | | | | | | | ||
* | | | | | | / | / / | | | | | _ { | | | | | | | | _ | ||
* | |_| | | |/ |/ / | |_| | | |_| | | |___ | |_| | | |_| | | ||
* \_____/ |___/|___/ \_____/ |_____/ |_____| \_____/ \_____/ | ||
* | ||
* Copyright (c) 2023 by OwOTeam-DGMT (OwOBlog). | ||
* @Author : HanskiJay | ||
* @Date : 2023-02-20 05:32:54 | ||
* @LastEditors : HanskiJay | ||
* @LastEditTime : 2023-02-20 05:32:54 | ||
* @E-Mail : [email protected] | ||
* @Telegram : https://t.me/HanskiJay | ||
* @GitHub : https://github.com/Tommy131 | ||
*/ | ||
declare(strict_types=1); | ||
namespace application\applicationName; | ||
|
||
|
||
|
||
use owoframe\application\Application; | ||
|
||
class className extends Application | ||
{ | ||
/** | ||
* 应用程序配置文件 | ||
* | ||
* @var array | ||
*/ | ||
protected static $config = | ||
[ | ||
# 应用程序名称ID | ||
'name' => 'applicationName', | ||
# 基本信息 | ||
'author' => 'OwOTeam', | ||
'version' => '1.0.0', | ||
'description' => 'default description', | ||
# 允许应用程序在PHP模式下加载 (CGI, CLI) | ||
'loadMode' => ['cgi', 'cli'] | ||
]; | ||
|
||
|
||
public function initialize() : void | ||
{ | ||
} | ||
} | ||
?> |
33 changes: 33 additions & 0 deletions
33
src/owoframe/template/default/DefaultControllerTemplate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/* | ||
* _____ _ __ _____ _____ _ _____ _____ | ||
* / _ \ | | / / / _ \ | _ \ | | / _ \ / ___| | ||
* | | | | | | __ / / | | | | | |_| | | | | | | | | | | ||
* | | | | | | / | / / | | | | | _ { | | | | | | | | _ | ||
* | |_| | | |/ |/ / | |_| | | |_| | | |___ | |_| | | |_| | | ||
* \_____/ |___/|___/ \_____/ |_____/ |_____| \_____/ \_____/ | ||
* | ||
* Copyright (c) 2023 by OwOTeam-DGMT (OwOBlog). | ||
* @Author : HanskiJay | ||
* @Date : 2023-02-20 05:37:55 | ||
* @LastEditors : HanskiJay | ||
* @LastEditTime : 2023-02-20 05:38:10 | ||
* @E-Mail : [email protected] | ||
* @Telegram : https://t.me/HanskiJay | ||
* @GitHub : https://github.com/Tommy131 | ||
*/ | ||
declare(strict_types=1); | ||
namespace application\applicationName\controller; | ||
|
||
|
||
|
||
use owoframe\application\Controller; | ||
|
||
class className extends Controller | ||
{ | ||
public function className() | ||
{ | ||
return 'Hello world! This application generated by OwOFrame::QuickAppFrameGenerator, welcome to use it :)'; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* @Author : HanskiJay | ||
* @Date : 2023-02-01 20:34:03 | ||
* @LastEditors : HanskiJay | ||
* @LastEditTime : 2023-02-20 04:04:18 | ||
* @LastEditTime : 2023-02-20 06:13:56 | ||
* @E-Mail : [email protected] | ||
* @Telegram : https://t.me/HanskiJay | ||
* @GitHub : https://github.com/Tommy131 | ||
|
@@ -581,11 +581,17 @@ function pipe_ask(string $question, $expect) : Pipe | |
if(!is_array($expect)) { | ||
return (is_string($expect) && is_string($result) && str_is_regex($expect) && preg_match_all($expect, $result)) ? true : ($result === $expect) || (is_string($expect) && (strtolower($expect) === $allowAll)); | ||
} else { | ||
return isset($expect[array_search($result, $expect)]); | ||
return in_array($result, $expect); | ||
} | ||
}); | ||
} | ||
$object->setExpectingResults($expect)->then($question); | ||
|
||
if(is_array($expect)) { | ||
$object->setExpectingResults($expect); | ||
} else { | ||
$object->setExpectingResult($expect); | ||
} | ||
$object->then($question); | ||
return $object; | ||
} | ||
|
||
|