mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 18:42:49 +08:00
完成基本的语法合并
This commit is contained in:
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\common\command\build;
|
||||
|
||||
use app\common\class\phpparser\NodeVisitor;
|
||||
use app\common\exception\DirFindedException;
|
||||
use app\common\tools\PathTools;
|
||||
use app\common\tools\phpparser\NodeVisitorTools;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
use League\Flysystem\Filesystem;
|
||||
use PhpParser\Node;
|
||||
@@ -23,6 +23,7 @@ use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use think\facade\App;
|
||||
use think\facade\View;
|
||||
|
||||
class Dist extends Command
|
||||
{
|
||||
@@ -104,8 +105,10 @@ class Dist extends Command
|
||||
|
||||
|
||||
|
||||
$lib_php_file = 'lib/index.' . uniqid() . '.php';
|
||||
$lib_php_path = $this->distPath . '/' . $lib_php_file;
|
||||
|
||||
|
||||
$lib_php_path = $this->distPath . '/lib/index.' . uniqid() . '.php';
|
||||
PathTools::intiDir($lib_php_path);
|
||||
|
||||
$prettyPrinter = new Standard();
|
||||
@@ -115,6 +118,18 @@ class Dist extends Command
|
||||
|
||||
file_put_contents($lib_php_path, $newCode);
|
||||
|
||||
$index_code = file_get_contents(__DIR__ . '/tpl/index.php.temp');
|
||||
|
||||
$index_code = str_replace('{$lib_php_file}', $lib_php_file, $index_code);
|
||||
|
||||
$dist_filesystem->put('public/index.php', $index_code);
|
||||
|
||||
$think_code = file_get_contents(__DIR__ . '/tpl/think.temp');
|
||||
|
||||
$think_code = str_replace('{$lib_php_file}', $lib_php_file, $think_code);
|
||||
|
||||
$dist_filesystem->put('think', $think_code);
|
||||
|
||||
$output->info('打包完成');
|
||||
}
|
||||
|
||||
@@ -135,8 +150,6 @@ class Dist extends Command
|
||||
|
||||
$stmts = $this->parseStmts($stmts, $name);
|
||||
|
||||
|
||||
|
||||
$this->packList = array_merge($this->packList, $stmts);
|
||||
|
||||
return null;
|
||||
@@ -156,7 +169,7 @@ class Dist extends Command
|
||||
|
||||
$traverser = new NodeTraverser();
|
||||
|
||||
$node_visitor = new NodeVisitor($this, $name);
|
||||
$node_visitor = new NodeVisitorTools($this, $name);
|
||||
|
||||
$traverser->addVisitor($node_visitor);
|
||||
|
||||
|
||||
21
app/common/command/build/tpl/index.php.temp
Normal file
21
app/common/command/build/tpl/index.php.temp
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// [ 应用入口文件 ]
|
||||
namespace think;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
require __DIR__ . '../{$lib_php_file}';
|
||||
|
||||
// 声明全局变量
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('ROOT_PATH', __DIR__ . DS . '..' . DS);
|
||||
define('REUQEST_UID', uniqid());
|
||||
// 执行HTTP应用并响应
|
||||
$http = (new App())->http;
|
||||
|
||||
$response = $http->run();
|
||||
|
||||
$response->send();
|
||||
|
||||
$http->end($response);
|
||||
17
app/common/command/build/tpl/think.temp
Normal file
17
app/common/command/build/tpl/think.temp
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
namespace think;
|
||||
|
||||
// 命令行入口文件
|
||||
// 加载基础文件
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
|
||||
define('REUQEST_UID', uniqid());
|
||||
|
||||
// 应用初始化
|
||||
$app = (new App());
|
||||
|
||||
require __DIR__ . '/{$lib_php_file}';
|
||||
|
||||
$app->console->run();
|
||||
Reference in New Issue
Block a user