mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 03:22:51 +08:00
完成路由文件的打包压缩
This commit is contained in:
@@ -150,6 +150,7 @@ class Dist extends Command
|
|||||||
$this->buildFunctionFile($lib_function_path);
|
$this->buildFunctionFile($lib_function_path);
|
||||||
|
|
||||||
$this->buildMigrateFile();
|
$this->buildMigrateFile();
|
||||||
|
$this->buildRouteFile();
|
||||||
|
|
||||||
$lib_dir_const_file = '/lib.' . uniqid() . '.php';
|
$lib_dir_const_file = '/lib.' . uniqid() . '.php';
|
||||||
$lib_dir_const_path = $this->distPath . '/lib' . $lib_dir_const_file;
|
$lib_dir_const_path = $this->distPath . '/lib' . $lib_dir_const_file;
|
||||||
@@ -172,6 +173,69 @@ class Dist extends Command
|
|||||||
$output->info('打包完成');
|
$output->info('打包完成');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打包路由文件
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function buildRouteFile()
|
||||||
|
{
|
||||||
|
$route_dir = 'route';
|
||||||
|
|
||||||
|
$list_files = $this->appFilesystem->listContents($route_dir, true);
|
||||||
|
|
||||||
|
$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
|
||||||
|
|
||||||
|
$prettyPrinter = new MinifyPrinterTools();
|
||||||
|
|
||||||
|
foreach ($list_files as $item_file) {
|
||||||
|
if ($item_file['type'] == 'dir') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_content = $this->appFilesystem->read($item_file['path']);
|
||||||
|
|
||||||
|
$file_stmts = $parser->parse($file_content);
|
||||||
|
|
||||||
|
$traverser = new NodeTraverser();
|
||||||
|
$traverser->addVisitor(new class($item_file['path'], $this) extends NodeVisitorAbstract
|
||||||
|
{
|
||||||
|
protected $name;
|
||||||
|
protected $mainClass;
|
||||||
|
public function __construct($name, $main_class)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
$this->mainClass = $main_class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function leaveNode(Node $node)
|
||||||
|
{
|
||||||
|
$name = $this->name;
|
||||||
|
if ($node instanceof Dir) {
|
||||||
|
// Clean out the function body
|
||||||
|
$const_key = 'dirconst' . uniqid();
|
||||||
|
|
||||||
|
$this->mainClass->constDirList[$const_key] = dirname($name);
|
||||||
|
return new ConstFetch(new Name($const_key));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($node->hasAttribute('comments')) {
|
||||||
|
$node->setAttribute('comments', []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$function_code = $prettyPrinter->prettyPrintFile($file_stmts);
|
||||||
|
|
||||||
|
$this->distFilesystem->put($item_file['path'], $function_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理数据库迁移代码
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function buildMigrateFile()
|
public function buildMigrateFile()
|
||||||
{
|
{
|
||||||
$database_dir = 'database';
|
$database_dir = 'database';
|
||||||
@@ -629,7 +693,11 @@ class Dist extends Command
|
|||||||
public function isSkip($path)
|
public function isSkip($path)
|
||||||
{
|
{
|
||||||
|
|
||||||
$system_skip_path = ['/app\/common.php/'];
|
$system_skip_path = [
|
||||||
|
'/app\/common.php/',
|
||||||
|
'/^database\/*/',
|
||||||
|
'/^route\/*/',
|
||||||
|
];
|
||||||
|
|
||||||
$skip_path = Config::get('dist.skip_path', []);
|
$skip_path = Config::get('dist.skip_path', []);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ return [
|
|||||||
'/^vendor/',
|
'/^vendor/',
|
||||||
'/^config/',
|
'/^config/',
|
||||||
'/^lib\//',
|
'/^lib\//',
|
||||||
'/^database\/*/',
|
|
||||||
'/event\.php/',
|
'/event\.php/',
|
||||||
'/middleware\.php/',
|
'/middleware\.php/',
|
||||||
'/provider\.php/',
|
'/provider\.php/',
|
||||||
@@ -30,7 +30,7 @@ return [
|
|||||||
'/config.php/',
|
'/config.php/',
|
||||||
'/^public\/index\.php/',
|
'/^public\/index\.php/',
|
||||||
'/^public\/router\.php/',
|
'/^public\/router\.php/',
|
||||||
'/^route\/*/',
|
|
||||||
'/^app\/admin\/service\/initAdminData\/*/',
|
'/^app\/admin\/service\/initAdminData\/*/',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user