diff --git a/app/admin/controller/api/Update.php b/app/admin/controller/api/Update.php index 1464bb95a..3cde0b171 100644 --- a/app/admin/controller/api/Update.php +++ b/app/admin/controller/api/Update.php @@ -30,11 +30,13 @@ class Update extends Controller */ public function tree() { - $this->success('获取当前文件列表成功!', PlugsExtend::instance($this->app)->buildFileList([ + $modules = PlugsExtend::instance($this->app)->buildFileList([ 'think', 'app/admin', 'public/static', - ], [ + ]); + dump($modules); + $this->success('获取当前文件列表成功!', $modules, [ 'public/static/self' - ])); + ]); } /** diff --git a/vendor/zoujingli/think-library/src/extend/PlugsExtend.php b/vendor/zoujingli/think-library/src/extend/PlugsExtend.php index 19baf9ec4..42aa43bfc 100644 --- a/vendor/zoujingli/think-library/src/extend/PlugsExtend.php +++ b/vendor/zoujingli/think-library/src/extend/PlugsExtend.php @@ -147,13 +147,22 @@ class PlugsExtend * 获取文件差异数据 * @return array */ - public function grenerateDifference($modules = []) + public function grenerateDifference($modules = [], $data = []) { $this->modules = $modules; $result = json_decode(HttpExtend::get("{$this->uri}?s=/admin/api.update/tree"), true); if (empty($result['code'])) return []; $new = $this->buildFileList($result['data']['paths'], $result['data']['ignores']); - return $this->grenerateDifferenceContrast($result['data']['list'], $new['list']); + foreach ($this->grenerateDifferenceContrast($result['data']['list'], $new['list']) as $file) { + if (in_array($file['type'], ['add', 'del', 'mod'])) { + foreach ($this->modules as $module) { + if (stripos($file['name'], $module) === 0) { + $data[] = $file; + } + } + } + } + return $data; } /** @@ -194,7 +203,7 @@ class PlugsExtend { // 扫描规则文件 foreach ($paths as $key => $path) { - $data = array_merge($data, $this->getFileList("{$this->path}{$path}")); + $data = array_merge($data, $this->scanFileList(strtr("{$this->path}{$path}", '\\', '/'))); } // 清除忽略文件 foreach ($data as $key => $map) foreach ($ignores as $ingore) { @@ -209,11 +218,11 @@ class PlugsExtend * @param array $data 扫描结果 * @return array */ - private function getFileList($path, $data = []) + private function scanFileList($path, $data = []) { if (file_exists($path)) if (is_dir($path)) foreach (scandir($path) as $sub) { if (strpos($sub, '.') !== 0) if (is_dir($temp = "{$path}/{$sub}")) { - $data = array_merge($data, $this->getFileList($temp)); + $data = array_merge($data, $this->scanFileList($temp)); } else { array_push($data, $this->getFileInfo($temp)); } @@ -231,8 +240,8 @@ class PlugsExtend private function getFileInfo($filename) { return [ + 'name' => str_replace($this->path, '', $filename), 'hash' => md5(preg_replace('/\s+/', '', file_get_contents($filename))), - 'name' => strtr(strtr(realpath($filename), '\\', '/'), $this->path, ''), ]; } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/plugs/Plugs.php b/vendor/zoujingli/think-library/src/plugs/Plugs.php index d95f12912..b8c6fa1cc 100644 --- a/vendor/zoujingli/think-library/src/plugs/Plugs.php +++ b/vendor/zoujingli/think-library/src/plugs/Plugs.php @@ -33,6 +33,7 @@ class Plugs extends Command } } } + dump($data); if (empty($data)) { $output->info('--- 本地文件与线上文件一致,无需更新文件'); } else {