ComposerUpdate

This commit is contained in:
Anyon 2019-11-02 15:18:28 +08:00
parent aa34703591
commit f16ff6c921
16 changed files with 169 additions and 182 deletions

View File

@ -17,6 +17,7 @@ namespace app\admin\controller\api;
use think\admin\Controller; use think\admin\Controller;
use think\admin\extend\PlugsExtend; use think\admin\extend\PlugsExtend;
use think\admin\install\ExtendInstall;
/** /**
* 系统更新接口 * 系统更新接口
@ -30,7 +31,7 @@ class Update extends Controller
*/ */
public function tree() public function tree()
{ {
$extend = PlugsExtend::instance($this->app); $extend = ExtendInstall::instance($this->app);
$this->rules = unserialize($this->request->post('rules', 'a:0:{}', '')); $this->rules = unserialize($this->request->post('rules', 'a:0:{}', ''));
$this->ignore = unserialize($this->request->post('ignore', 'a:0:{}', '')); $this->ignore = unserialize($this->request->post('ignore', 'a:0:{}', ''));
$this->success('获取当前文件列表成功!', $extend->buildFileList($this->rules, $this->ignore)); $this->success('获取当前文件列表成功!', $extend->buildFileList($this->rules, $this->ignore));

8
composer.lock generated
View File

@ -783,12 +783,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "246980334faacab77128f653365478c7c5086451" "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/246980334faacab77128f653365478c7c5086451", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b48c8d60ba7463049de08c403df5e326d4b5002c",
"reference": "246980334faacab77128f653365478c7c5086451", "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -832,7 +832,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top", "homepage": "http://framework.thinkadmin.top",
"time": "2019-11-01T11:22:17+00:00" "time": "2019-11-02T07:13:53+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645::getLoader(); return ComposerAutoloaderInitf141db0785048027c24f92d1492ab3c5::getLoader();

View File

@ -150,7 +150,6 @@ return array(
'think\\admin\\extend\\ExpressExtend' => $vendorDir . '/zoujingli/think-library/src/extend/ExpressExtend.php', '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\\HttpExtend' => $vendorDir . '/zoujingli/think-library/src/extend/HttpExtend.php',
'think\\admin\\extend\\NodeExtend' => $vendorDir . '/zoujingli/think-library/src/extend/NodeExtend.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\\ProcessExtend' => $vendorDir . '/zoujingli/think-library/src/extend/ProcessExtend.php',
'think\\admin\\extend\\TokenExtend' => $vendorDir . '/zoujingli/think-library/src/extend/TokenExtend.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', '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\\QueryHelper' => $vendorDir . '/zoujingli/think-library/src/helper/QueryHelper.php',
'think\\admin\\helper\\SaveHelper' => $vendorDir . '/zoujingli/think-library/src/helper/SaveHelper.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\\helper\\TokenHelper' => $vendorDir . '/zoujingli/think-library/src/helper/TokenHelper.php',
'think\\admin\\plugs\\AdminPlugs' => $vendorDir . '/zoujingli/think-library/src/plugs/AdminPlugs.php', 'think\\admin\\install\\CommandInstall' => $vendorDir . '/zoujingli/think-library/src/install/CommandInstall.php',
'think\\admin\\plugs\\Plugs' => $vendorDir . '/zoujingli/think-library/src/plugs/Plugs.php', 'think\\admin\\install\\ExtendInstall' => $vendorDir . '/zoujingli/think-library/src/install/ExtendInstall.php',
'think\\admin\\plugs\\StaticPlugs' => $vendorDir . '/zoujingli/think-library/src/plugs/StaticPlugs.php',
'think\\admin\\queue\\ListenQueue' => $vendorDir . '/zoujingli/think-library/src/queue/ListenQueue.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\\QueryQueue' => $vendorDir . '/zoujingli/think-library/src/queue/QueryQueue.php',
'think\\admin\\queue\\StartQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StartQueue.php', 'think\\admin\\queue\\StartQueue' => $vendorDir . '/zoujingli/think-library/src/queue/StartQueue.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645 class ComposerAutoloaderInitf141db0785048027c24f92d1492ab3c5
{ {
private static $loader; private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645
return self::$loader; 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(); 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()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInita51eb218b1f5b76290775d4f6b984645::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInitf141db0785048027c24f92d1492ab3c5::getInitializer($loader));
} else { } else {
$map = require __DIR__ . '/autoload_namespaces.php'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInita51eb218b1f5b76290775d4f6b984645
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$files; $includeFiles = Composer\Autoload\ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirea51eb218b1f5b76290775d4f6b984645($fileIdentifier, $file); composerRequiref141db0785048027c24f92d1492ab3c5($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequirea51eb218b1f5b76290775d4f6b984645($fileIdentifier, $file) function composerRequiref141db0785048027c24f92d1492ab3c5($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInita51eb218b1f5b76290775d4f6b984645 class ComposerStaticInitf141db0785048027c24f92d1492ab3c5
{ {
public static $files = array ( public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', '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\\ExpressExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/ExpressExtend.php',
'think\\admin\\extend\\HttpExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/HttpExtend.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\\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\\ProcessExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/ProcessExtend.php',
'think\\admin\\extend\\TokenExtend' => __DIR__ . '/..' . '/zoujingli/think-library/src/extend/TokenExtend.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', '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\\QueryHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/QueryHelper.php',
'think\\admin\\helper\\SaveHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/SaveHelper.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\\helper\\TokenHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/TokenHelper.php',
'think\\admin\\plugs\\AdminPlugs' => __DIR__ . '/..' . '/zoujingli/think-library/src/plugs/AdminPlugs.php', 'think\\admin\\install\\CommandInstall' => __DIR__ . '/..' . '/zoujingli/think-library/src/install/CommandInstall.php',
'think\\admin\\plugs\\Plugs' => __DIR__ . '/..' . '/zoujingli/think-library/src/plugs/Plugs.php', 'think\\admin\\install\\ExtendInstall' => __DIR__ . '/..' . '/zoujingli/think-library/src/install/ExtendInstall.php',
'think\\admin\\plugs\\StaticPlugs' => __DIR__ . '/..' . '/zoujingli/think-library/src/plugs/StaticPlugs.php',
'think\\admin\\queue\\ListenQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/ListenQueue.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\\QueryQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/QueryQueue.php',
'think\\admin\\queue\\StartQueue' => __DIR__ . '/..' . '/zoujingli/think-library/src/queue/StartQueue.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) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita51eb218b1f5b76290775d4f6b984645::$classMap; $loader->classMap = ComposerStaticInitf141db0785048027c24f92d1492ab3c5::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -805,12 +805,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "246980334faacab77128f653365478c7c5086451" "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/246980334faacab77128f653365478c7c5086451", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b48c8d60ba7463049de08c403df5e326d4b5002c",
"reference": "246980334faacab77128f653365478c7c5086451", "reference": "b48c8d60ba7463049de08c403df5e326d4b5002c",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -826,7 +826,7 @@
"ext-json": "*", "ext-json": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2019-11-01T11:22:17+00:00", "time": "2019-11-02T07:13:53+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2019-11-01 19:25:53 // This file is automatically generated at:2019-11-02 15:17:49
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

View File

@ -66,8 +66,7 @@ class ThinkLibrary extends Service
'think\admin\queue\StartQueue', 'think\admin\queue\StartQueue',
'think\admin\queue\QueryQueue', 'think\admin\queue\QueryQueue',
'think\admin\queue\ListenQueue', 'think\admin\queue\ListenQueue',
'think\admin\plugs\AdminPlugs', 'think\admin\plugs\CommandInstall',
'think\admin\plugs\StaticPlugs',
]); ]);
} }

View File

@ -50,7 +50,7 @@ class CaptchaExtend
$this->code .= $this->charset[mt_rand(0, $length)]; $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); app()->cache->set($this->uniqid, $this->code, 360);
} }

View File

@ -0,0 +1,123 @@
<?php
// +----------------------------------------------------------------------
// | Library for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/zoujingli/ThinkLibrary
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
namespace think\admin\install;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
/**
* 插件基础指令类
* Class CommandInstall
* @package think\admin\install
*/
class CommandInstall extends Command
{
/**
* 查询规则
* @var array
*/
protected $rules = [];
/**
* 忽略规则
* @var array
*/
protected $ignore = [];
/**
* 插件工具实例
* @var ExtendInstall
*/
protected $extend;
/**
* 指定模块名称
* @var string
*/
protected $name;
/**
* 规则配置
* @var array
*/
protected $bind = [
'admin' => [
'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()
{
}
}

View File

@ -13,16 +13,17 @@
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary // | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace think\admin\extend; namespace think\admin\install;
use think\admin\extend\HttpExtend;
use think\App; 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; protected $version;
/**
* 输出对象
* @var Output
*/
protected $output;
/** /**
* 文件规则 * 文件规则
* @var array * @var array
@ -92,8 +87,7 @@ class PlugsExtend
public function __construct(App $app) public function __construct(App $app)
{ {
$this->app = $app; $this->app = $app;
$this->output = new Output(); // 应用框架版本
// 应用框架版本号
$this->version = $this->app->config->get('app.thinkadmin_ver'); $this->version = $this->app->config->get('app.thinkadmin_ver');
if (empty($this->version)) $this->version = 'v4'; if (empty($this->version)) $this->version = 'v4';
// 线上应用代码 // 线上应用代码
@ -112,24 +106,25 @@ class PlugsExtend
} }
/** /**
* 同步指定文件 * 同步更新文件
* @param array $file * @param array $file
* @return array
*/ */
public function fileSynchronization($file) public function fileSynchronization($file)
{ {
if (in_array($file['type'], ['add', 'mod'])) { if (in_array($file['type'], ['add', 'mod'])) {
if ($this->downloadFile(encode($file['name']))) { if ($this->downloadFile(encode($file['name']))) {
$this->output->writeln("--- 下载 {$file['name']} 更新成功"); return [true, $file['type'], $file['name']];
} else { } else {
$this->output->writeln("--- 下载 {$file['name']} 更新失败"); return [false, $file['type'], $file['name']];
} }
} elseif (in_array($file['type'], ['del'])) { } elseif (in_array($file['type'], ['del'])) {
$real = $this->path . $file['name']; $real = $this->path . $file['name'];
if (is_file($real) && unlink($real)) { if (is_file($real) && unlink($real)) {
$this->removeEmptyDirectory(dirname($real)); $this->removeEmptyDirectory(dirname($real));
$this->output->writeln("--- 删除 {$file['name']} 文件成功"); return [true, $file['type'], $file['name']];
} else { } else {
$this->output->error("--- 删除 {$file['name']} 文件失败"); return [false, $file['type'], $file['name']];
} }
} }
} }
@ -220,11 +215,12 @@ class PlugsExtend
{ {
// 扫描规则文件 // 扫描规则文件
foreach ($rules as $key => $rule) { 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) { foreach ($data as $key => $item) foreach ($ignore as $ingore) {
if (stripos($map['name'], $ingore) === 0) unset($data[$key]); if (stripos($item['name'], $ingore) === 0) unset($data[$key]);
} }
return ['rules' => $rules, 'ignore' => $ignore, 'list' => $data]; return ['rules' => $rules, 'ignore' => $ignore, 'list' => $data];
} }

View File

@ -1,35 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Library for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/zoujingli/ThinkLibrary
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
namespace think\admin\plugs;
/**
* Class AdminPlugs
* @package think\admin\plugs
*/
class AdminPlugs extends Plugs
{
/**
* 文件规则
* @var array
*/
protected $rules = ['think', 'app/admin'];
protected function configure()
{
$this->setName('xplugs:admin')->setDescription('[同步]覆盖本地Admin模块代码');
}
}

View File

@ -1,62 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Library for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/zoujingli/ThinkLibrary
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
namespace think\admin\plugs;
use think\admin\extend\PlugsExtend;
use think\console\Command;
use think\console\Input;
use think\console\Output;
/**
* 插件基础指令类
* Class Plugs
* @package think\admin\plugs
*/
class Plugs extends Command
{
/**
* 查询规则
* @var array
*/
protected $rules = [];
/**
* 忽略规则
* @var array
*/
protected $ignore = [];
/**
* @param Input $input
* @param Output $output
*/
protected function execute(Input $input, Output $output)
{
$extend = PlugsExtend::instance($this->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()
{
}
}

View File

@ -1,31 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Library for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/zoujingli/ThinkLibrary
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
namespace think\admin\plugs;
/**
* Class StaticPlugs
* @package think\admin\plugs
*/
class StaticPlugs extends Plugs
{
protected $rules = ['public/static'];
protected $ignore = ['public/static/self'];
protected function configure()
{
$this->setName('xplugs:static')->setDescription('[同步]覆盖本地Static插件代码');
}
}