mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
增加数据库迁移打包
This commit is contained in:
@@ -149,6 +149,7 @@ class Dist extends Command
|
||||
$lib_function_path = $this->distPath . '/lib' . $lib_function_file;
|
||||
$this->buildFunctionFile($lib_function_path);
|
||||
|
||||
$this->buildMigrateFile();
|
||||
|
||||
$lib_dir_const_file = '/lib.' . uniqid() . '.php';
|
||||
$lib_dir_const_path = $this->distPath . '/lib' . $lib_dir_const_file;
|
||||
@@ -166,9 +167,68 @@ class Dist extends Command
|
||||
|
||||
|
||||
$this->buildAllAppDir();
|
||||
|
||||
|
||||
$output->info('打包完成');
|
||||
}
|
||||
|
||||
public function buildMigrateFile()
|
||||
{
|
||||
$database_dir = 'database';
|
||||
|
||||
$list_files = $this->appFilesystem->listContents($database_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', []);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$file_stmts = $traverser->traverse($file_stmts);
|
||||
|
||||
$function_code = $prettyPrinter->prettyPrintFile($file_stmts);
|
||||
|
||||
$this->distFilesystem->put($item_file['path'], $function_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打包标准类文件(核心)
|
||||
|
||||
@@ -40,7 +40,7 @@ class DebugMysql implements LogHandlerInterface
|
||||
$dirname = dirname($log_path);
|
||||
|
||||
if (!is_dir($dirname)) {
|
||||
mkdir($log_path, 0777, true);
|
||||
mkdir($dirname, 0777, true);
|
||||
}
|
||||
|
||||
$first_line = false;
|
||||
|
||||
Reference in New Issue
Block a user