mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 10:32:48 +08:00
完成打包和最小化格式化
This commit is contained in:
@@ -74,7 +74,6 @@ if (!function_exists('xdebug')) {
|
||||
function xdebug($data, $type = 'xdebug', $suffix = null, $force = false, $file = null)
|
||||
{
|
||||
// 调试
|
||||
__DIR__;
|
||||
!is_dir(runtime_path() . 'xdebug/') && mkdir(runtime_path() . 'xdebug/');
|
||||
if (is_null($file)) {
|
||||
$file = is_null($suffix) ? runtime_path() . 'xdebug/' . date('Ymd') . '.txt' : runtime_path() . 'xdebug/' . date('Ymd') . "_{$suffix}" . '.txt';
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace app\common\command\build;
|
||||
|
||||
use app\common\tools\PathTools;
|
||||
use app\common\tools\phpparser\MinifyPrinterTools;
|
||||
use app\common\tools\phpparser\NodeVisitorTools;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
use League\Flysystem\Filesystem;
|
||||
@@ -158,9 +159,9 @@ class Dist extends Command
|
||||
PathTools::intiDir($lib_php_path);
|
||||
|
||||
$this->buildIncludeIndexFile([
|
||||
$lib_function_file,
|
||||
$lib_dir_const_file,
|
||||
$lib_php_file,
|
||||
$lib_function_file,
|
||||
]);
|
||||
|
||||
|
||||
@@ -206,18 +207,13 @@ class Dist extends Command
|
||||
));
|
||||
}
|
||||
|
||||
$prettyPrinter = new Standard();
|
||||
$prettyPrinter = new MinifyPrinterTools();
|
||||
|
||||
$dir_const_code = $prettyPrinter->prettyPrintFile($dir_const_stmts);
|
||||
|
||||
file_put_contents($lib_dir_const_path, $dir_const_code);
|
||||
}
|
||||
|
||||
public function buildDirConstCode($stmt)
|
||||
{
|
||||
# code...
|
||||
}
|
||||
|
||||
public function buildFunctionFile($lib_function_path)
|
||||
{
|
||||
$function_path = Config::get('dist.function_path', []);
|
||||
@@ -257,22 +253,22 @@ class Dist extends Command
|
||||
return new ConstFetch(new Name($const_key));
|
||||
}
|
||||
|
||||
if($node instanceof Comment){
|
||||
return NodeTraverser::REMOVE_NODE;
|
||||
if ($node->hasAttribute('comments')) {
|
||||
$node->setAttribute('comments', []);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
|
||||
|
||||
foreach ($stmts as $stmt_item) {
|
||||
$function_stmts[] = $stmt_item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$prettyPrinter = new Standard();
|
||||
$prettyPrinter = new MinifyPrinterTools();
|
||||
|
||||
$function_code = $prettyPrinter->prettyPrintFile($function_stmts);
|
||||
|
||||
@@ -303,7 +299,7 @@ class Dist extends Command
|
||||
foreach ($files as $file_name) {
|
||||
$file_stmts[] = new Expression(new Include_(new Concat(new Dir, new String_($file_name)), Include_::TYPE_REQUIRE_ONCE));
|
||||
}
|
||||
$prettyPrinter = new Standard();
|
||||
$prettyPrinter = new MinifyPrinterTools();
|
||||
|
||||
|
||||
$newCode = $prettyPrinter->prettyPrintFile($file_stmts);
|
||||
|
||||
47
app/common/tools/phpparser/MinifyPrinterTools.php
Normal file
47
app/common/tools/phpparser/MinifyPrinterTools.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\tools\phpparser;
|
||||
|
||||
|
||||
class MinifyPrinterTools extends PrettyPrinterTools
|
||||
{
|
||||
/**
|
||||
* Reset pretty printing state.
|
||||
*/
|
||||
protected function resetState()
|
||||
{
|
||||
$this->indentLevel = 0;
|
||||
$this->nl = "";
|
||||
$this->origTokens = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indentation level
|
||||
*
|
||||
* @param int $level Level in number of spaces
|
||||
*/
|
||||
protected function setIndentLevel(int $level)
|
||||
{
|
||||
$this->indentLevel = $level;
|
||||
$this->nl = "" . \str_repeat('', $level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase indentation level.
|
||||
*/
|
||||
protected function indent()
|
||||
{
|
||||
$this->indentLevel += 4;
|
||||
$this->nl .= '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease indentation level.
|
||||
*/
|
||||
protected function outdent()
|
||||
{
|
||||
assert($this->indentLevel >= 4);
|
||||
$this->indentLevel -= 4;
|
||||
$this->nl = "" . str_repeat('', $this->indentLevel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user