diff --git a/app/admin/controller/api/Update.php b/app/admin/controller/api/Update.php index 7bd3c7a94..2d444ce06 100644 --- a/app/admin/controller/api/Update.php +++ b/app/admin/controller/api/Update.php @@ -17,6 +17,7 @@ namespace app\admin\controller\api; use think\admin\Controller; use think\admin\extend\PlugsExtend; +use think\admin\install\ExtendInstall; /** * 系统更新接口 @@ -30,7 +31,7 @@ class Update extends Controller */ public function tree() { - $extend = PlugsExtend::instance($this->app); + $extend = ExtendInstall::instance($this->app); $this->rules = unserialize($this->request->post('rules', 'a:0:{}', '')); $this->ignore = unserialize($this->request->post('ignore', 'a:0:{}', '')); $this->success('获取当前文件列表成功!', $extend->buildFileList($this->rules, $this->ignore)); diff --git a/composer.lock b/composer.lock index 8e35c61bf..3764ce554 100644 --- a/composer.lock +++ b/composer.lock @@ -783,12 +783,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "246980334faacab77128f653365478c7c5086451" + "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/246980334faacab77128f653365478c7c5086451", - "reference": "246980334faacab77128f653365478c7c5086451", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b48c8d60ba7463049de08c403df5e326d4b5002c", + "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c", "shasum": "", "mirrors": [ { @@ -832,7 +832,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2019-11-01T11:22:17+00:00" + "time": "2019-11-02T07:13:53+00:00" } ], "packages-dev": [], diff --git a/vendor/autoload.php b/vendor/autoload.php index fd8e37e00..1efc9d82d 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645::getLoader(); +return ComposerAutoloaderInitf141db0785048027c24f92d1492ab3c5::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 9b3e760f4..a829f2ae0 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -150,7 +150,6 @@ return array( 'think\\admin\\extend\\ExpressExtend' => $vendorDir . '/zoujingli/think-library/src/extend/ExpressExtend.php', 'think\\admin\\extend\\HttpExtend' => $vendorDir . '/zoujingli/think-library/src/extend/HttpExtend.php', 'think\\admin\\extend\\NodeExtend' => $vendorDir . '/zoujingli/think-library/src/extend/NodeExtend.php', - 'think\\admin\\extend\\PlugsExtend' => $vendorDir . '/zoujingli/think-library/src/extend/PlugsExtend.php', 'think\\admin\\extend\\ProcessExtend' => $vendorDir . '/zoujingli/think-library/src/extend/ProcessExtend.php', 'think\\admin\\extend\\TokenExtend' => $vendorDir . '/zoujingli/think-library/src/extend/TokenExtend.php', 'think\\admin\\helper\\DeleteHelper' => $vendorDir . '/zoujingli/think-library/src/helper/DeleteHelper.php', @@ -160,9 +159,8 @@ return array( 'think\\admin\\helper\\QueryHelper' => $vendorDir . '/zoujingli/think-library/src/helper/QueryHelper.php', 'think\\admin\\helper\\SaveHelper' => $vendorDir . '/zoujingli/think-library/src/helper/SaveHelper.php', 'think\\admin\\helper\\TokenHelper' => $vendorDir . '/zoujingli/think-library/src/helper/TokenHelper.php', - 'think\\admin\\plugs\\AdminPlugs' => $vendorDir . '/zoujingli/think-library/src/plugs/AdminPlugs.php', - 'think\\admin\\plugs\\Plugs' => $vendorDir . '/zoujingli/think-library/src/plugs/Plugs.php', - 'think\\admin\\plugs\\StaticPlugs' => $vendorDir . '/zoujingli/think-library/src/plugs/StaticPlugs.php', + 'think\\admin\\install\\CommandInstall' => $vendorDir . '/zoujingli/think-library/src/install/CommandInstall.php', + 'think\\admin\\install\\ExtendInstall' => $vendorDir . '/zoujingli/think-library/src/install/ExtendInstall.php', 'think\\admin\\queue\\ListenQueue' => $vendorDir . '/zoujingli/think-library/src/queue/ListenQueue.php', 'think\\admin\\queue\\QueryQueue' => $vendorDir . '/zoujingli/think-library/src/queue/QueryQueue.php', 'think\\admin\\queue\\StartQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StartQueue.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 248971ecc..fb88ddf1c 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645 +class ComposerAutoloaderInitf141db0785048027c24f92d1492ab3c5 { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf141db0785048027c24f92d1492ab3c5', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf141db0785048027c24f92d1492ab3c5', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInita51eb218b1f5b76290775d4f6b984645::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitf141db0785048027c24f92d1492ab3c5::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequirea51eb218b1f5b76290775d4f6b984645($fileIdentifier, $file); + composerRequiref141db0785048027c24f92d1492ab3c5($fileIdentifier, $file); } return $loader; } } -function composerRequirea51eb218b1f5b76290775d4f6b984645($fileIdentifier, $file) +function composerRequiref141db0785048027c24f92d1492ab3c5($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 955b70866..375bb2d1d 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInita51eb218b1f5b76290775d4f6b984645 +class ComposerStaticInitf141db0785048027c24f92d1492ab3c5 { public static $files = array ( '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', @@ -241,7 +241,6 @@ class ComposerStaticInita51eb218b1f5b76290775d4f6b984645 'think\\admin\\extend\\ExpressExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/ExpressExtend.php', 'think\\admin\\extend\\HttpExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/HttpExtend.php', 'think\\admin\\extend\\NodeExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/NodeExtend.php', - 'think\\admin\\extend\\PlugsExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/PlugsExtend.php', 'think\\admin\\extend\\ProcessExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/ProcessExtend.php', 'think\\admin\\extend\\TokenExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/TokenExtend.php', 'think\\admin\\helper\\DeleteHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/DeleteHelper.php', @@ -251,9 +250,8 @@ class ComposerStaticInita51eb218b1f5b76290775d4f6b984645 'think\\admin\\helper\\QueryHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/QueryHelper.php', 'think\\admin\\helper\\SaveHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/SaveHelper.php', 'think\\admin\\helper\\TokenHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/TokenHelper.php', - 'think\\admin\\plugs\\AdminPlugs' => __DIR__ . '/..' . '/zoujingli/think-library/src/plugs/AdminPlugs.php', - 'think\\admin\\plugs\\Plugs' => __DIR__ . '/..' . '/zoujingli/think-library/src/plugs/Plugs.php', - 'think\\admin\\plugs\\StaticPlugs' => __DIR__ . '/..' . '/zoujingli/think-library/src/plugs/StaticPlugs.php', + 'think\\admin\\install\\CommandInstall' => __DIR__ . '/..' . '/zoujingli/think-library/src/install/CommandInstall.php', + 'think\\admin\\install\\ExtendInstall' => __DIR__ . '/..' . '/zoujingli/think-library/src/install/ExtendInstall.php', 'think\\admin\\queue\\ListenQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/ListenQueue.php', 'think\\admin\\queue\\QueryQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/QueryQueue.php', 'think\\admin\\queue\\StartQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StartQueue.php', @@ -470,9 +468,9 @@ class ComposerStaticInita51eb218b1f5b76290775d4f6b984645 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 07ac1f210..f12c7e059 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -805,12 +805,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "246980334faacab77128f653365478c7c5086451" + "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/246980334faacab77128f653365478c7c5086451", - "reference": "246980334faacab77128f653365478c7c5086451", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b48c8d60ba7463049de08c403df5e326d4b5002c", + "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c", "shasum": "", "mirrors": [ { @@ -826,7 +826,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2019-11-01T11:22:17+00:00", + "time": "2019-11-02T07:13:53+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 29c94cf81..e3da4671f 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/ThinkLibrary.php b/vendor/zoujingli/think-library/src/ThinkLibrary.php index 9c5d483e5..9773dc66c 100644 --- a/vendor/zoujingli/think-library/src/ThinkLibrary.php +++ b/vendor/zoujingli/think-library/src/ThinkLibrary.php @@ -66,8 +66,7 @@ class ThinkLibrary extends Service 'think\admin\queue\StartQueue', 'think\admin\queue\QueryQueue', 'think\admin\queue\ListenQueue', - 'think\admin\plugs\AdminPlugs', - 'think\admin\plugs\StaticPlugs', + 'think\admin\plugs\CommandInstall', ]); } diff --git a/vendor/zoujingli/think-library/src/extend/CaptchaExtend.php b/vendor/zoujingli/think-library/src/extend/CaptchaExtend.php index 6c0bf8297..d644d2f5e 100644 --- a/vendor/zoujingli/think-library/src/extend/CaptchaExtend.php +++ b/vendor/zoujingli/think-library/src/extend/CaptchaExtend.php @@ -50,7 +50,7 @@ class CaptchaExtend $this->code .= $this->charset[mt_rand(0, $length)]; } // 设置字体文件路径 - $this->font = __DIR__ . '/font/icon.ttf'; + $this->font = __DIR__ . '/bin/font.ttf'; // 缓存验证码字符串 app()->cache->set($this->uniqid, $this->code, 360); } diff --git a/vendor/zoujingli/think-library/src/extend/font/icon.ttf b/vendor/zoujingli/think-library/src/extend/bin/font.ttf similarity index 100% rename from vendor/zoujingli/think-library/src/extend/font/icon.ttf rename to vendor/zoujingli/think-library/src/extend/bin/font.ttf diff --git a/vendor/zoujingli/think-library/src/install/CommandInstall.php b/vendor/zoujingli/think-library/src/install/CommandInstall.php new file mode 100644 index 000000000..04cde0494 --- /dev/null +++ b/vendor/zoujingli/think-library/src/install/CommandInstall.php @@ -0,0 +1,123 @@ + [ + 'rules' => ['think', 'app/admin'], + 'ignore' => [], + ], + 'static' => [ + 'rules' => ['public/static'], + 'ignore' => ['public/static/self'], + ], + ]; + + protected function configure() + { + $this->setName('xtask:plugs'); + $this->addArgument('name', Argument::OPTIONAL, '模块名称'); + $this->setDescription('[同步]在线安装指定功能模块'); + } + + /** + * @param Input $input + * @param Output $output + */ + protected function execute(Input $input, Output $output) + { + $this->name = trim($input->getArgument('name')); + if (empty($this->name)) { + $this->output->error('=== 在线安装模块名称不能为空'); + } else { + $this->extend = ExtendInstall::instance($this->app); + if (isset($this->bind[$this->name])) { + $this->rules = empty($this->bind[$this->name]['rules']) ? [] : $this->bind[$this->name]['rules']; + $this->ignore = empty($this->bind[$this->name]['ignore']) ? [] : $this->bind[$this->name]['ignore']; + $this->output->comment("=== 准备下载安装{$this->name}模块{$this->extend->getVersion()} ==="); + $this->installFile(); + $this->output->comment("=== 下载安装{$this->name}模块{$this->extend->getVersion()}完成 ==="); + $this->installDatabase(); + } else { + $this->output->error("指定模块 {$this->name} 未配置安装规则"); + } + } + } + + protected function installFile() + { + $data = $this->extend->grenerateDifference($this->rules, $this->ignore); + if (empty($data)) $this->output->info('--- 本地文件与线上文件一致,无需更新文件'); + else foreach ($data as $file) { + list($state, $mode, $name) = $this->extend->fileSynchronization($file); + if ($state) { + if ($mode === 'add') $this->output->info("--- 下载 {$name} 添加成功"); + if ($mode === 'mod') $this->output->info("--- 下载 {$name} 更新成功"); + if ($mode === 'del') $this->output->info("--- 删除 {$name} 文件成功"); + } else { + if ($mode === 'add') $this->output->error("--- 下载 {$name} 添加失败"); + if ($mode === 'mod') $this->output->error("--- 下载 {$name} 更新失败"); + if ($mode === 'del') $this->output->error("--- 删除 {$name} 文件失败"); + } + } + } + + protected function installDatabase() + { + + } + +} \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/extend/PlugsExtend.php b/vendor/zoujingli/think-library/src/install/ExtendInstall.php similarity index 89% rename from vendor/zoujingli/think-library/src/extend/PlugsExtend.php rename to vendor/zoujingli/think-library/src/install/ExtendInstall.php index 0620731c4..f613f0a8d 100644 --- a/vendor/zoujingli/think-library/src/extend/PlugsExtend.php +++ b/vendor/zoujingli/think-library/src/install/ExtendInstall.php @@ -13,16 +13,17 @@ // | github 仓库地址 :https://github.com/zoujingli/ThinkLibrary // +---------------------------------------------------------------------- -namespace think\admin\extend; +namespace think\admin\install; +use think\admin\extend\HttpExtend; use think\App; -use think\console\Output; /** - * Class PlugsExtend - * @package think\admin\extend + * 模块安装服务扩展 + * Class ExtendInstall + * @package think\admin\install */ -class PlugsExtend +class ExtendInstall { /** * 当前应用 @@ -48,12 +49,6 @@ class PlugsExtend */ protected $version; - /** - * 输出对象 - * @var Output - */ - protected $output; - /** * 文件规则 * @var array @@ -92,8 +87,7 @@ class PlugsExtend public function __construct(App $app) { $this->app = $app; - $this->output = new Output(); - // 应用框架版本号 + // 应用框架版本 $this->version = $this->app->config->get('app.thinkadmin_ver'); if (empty($this->version)) $this->version = 'v4'; // 线上应用代码 @@ -112,24 +106,25 @@ class PlugsExtend } /** - * 同步指定文件 + * 同步更新文件 * @param array $file + * @return array */ public function fileSynchronization($file) { if (in_array($file['type'], ['add', 'mod'])) { if ($this->downloadFile(encode($file['name']))) { - $this->output->writeln("--- 下载 {$file['name']} 更新成功"); + return [true, $file['type'], $file['name']]; } else { - $this->output->writeln("--- 下载 {$file['name']} 更新失败"); + return [false, $file['type'], $file['name']]; } } elseif (in_array($file['type'], ['del'])) { $real = $this->path . $file['name']; if (is_file($real) && unlink($real)) { $this->removeEmptyDirectory(dirname($real)); - $this->output->writeln("--- 删除 {$file['name']} 文件成功"); + return [true, $file['type'], $file['name']]; } else { - $this->output->error("--- 删除 {$file['name']} 文件失败"); + return [false, $file['type'], $file['name']]; } } } @@ -220,11 +215,12 @@ class PlugsExtend { // 扫描规则文件 foreach ($rules as $key => $rule) { - $data = array_merge($data, $this->scanFileList(strtr("{$this->path}{$rule}", '\\', '/'))); + $name = strtr(trim($rule, '\\/'), '\\', '/'); + $data = array_merge($data, $this->scanFileList("{$this->path}{$name}")); } // 清除忽略文件 - foreach ($data as $key => $map) foreach ($ignore as $ingore) { - if (stripos($map['name'], $ingore) === 0) unset($data[$key]); + foreach ($data as $key => $item) foreach ($ignore as $ingore) { + if (stripos($item['name'], $ingore) === 0) unset($data[$key]); } return ['rules' => $rules, 'ignore' => $ignore, 'list' => $data]; } diff --git a/vendor/zoujingli/think-library/src/plugs/AdminPlugs.php b/vendor/zoujingli/think-library/src/plugs/AdminPlugs.php deleted file mode 100644 index 2a7b3a2c0..000000000 --- a/vendor/zoujingli/think-library/src/plugs/AdminPlugs.php +++ /dev/null @@ -1,35 +0,0 @@ -setName('xplugs:admin')->setDescription('[同步]覆盖本地Admin模块代码'); - } - -} \ 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 deleted file mode 100644 index 061d8071f..000000000 --- a/vendor/zoujingli/think-library/src/plugs/Plugs.php +++ /dev/null @@ -1,62 +0,0 @@ -app); - $output->comment("=== 准备从代码仓库下载更新{$extend->getVersion()}版本文件 ==="); - $data = $extend->grenerateDifference($this->rules, $this->ignore); - if (empty($data)) $output->info('--- 本地文件与线上文件一致,无需更新文件'); - else foreach ($data as $file) $extend->fileSynchronization($file); - $output->comment("=== 从代码仓库下载{$extend->getVersion()}版本同步更新成功 ==="); - $this->install(); - } - - protected function install() - { - - } - -} \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/plugs/StaticPlugs.php b/vendor/zoujingli/think-library/src/plugs/StaticPlugs.php deleted file mode 100644 index df6c292c5..000000000 --- a/vendor/zoujingli/think-library/src/plugs/StaticPlugs.php +++ /dev/null @@ -1,31 +0,0 @@ -setName('xplugs:static')->setDescription('[同步]覆盖本地Static插件代码'); - } -} \ No newline at end of file