mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-05 19:41:44 +08:00
[更新]CompoesrUpdate
This commit is contained in:
parent
d228360496
commit
e20fc39ca7
@ -21,5 +21,5 @@ return [
|
||||
// URL参数方式 0 按名称成对解析 1 按顺序解析
|
||||
'url_param_type' => 1,
|
||||
// 当前 ThinkAdmin 版本号
|
||||
'thinkadmin_ver' => 'v5',
|
||||
'thinkadmin_ver' => 'demo',
|
||||
];
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit4709a80ce52b64d052d71eeb78f881e1::getLoader();
|
||||
return ComposerAutoloaderInit5c48a3348c717dd438f5f9e83747c5f0::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit4709a80ce52b64d052d71eeb78f881e1
|
||||
class ComposerAutoloaderInit5c48a3348c717dd438f5f9e83747c5f0
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -19,15 +19,15 @@ class ComposerAutoloaderInit4709a80ce52b64d052d71eeb78f881e1
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit4709a80ce52b64d052d71eeb78f881e1', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5c48a3348c717dd438f5f9e83747c5f0', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit4709a80ce52b64d052d71eeb78f881e1', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5c48a3348c717dd438f5f9e83747c5f0', '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\ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit5c48a3348c717dd438f5f9e83747c5f0::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
@ -48,19 +48,19 @@ class ComposerAutoloaderInit4709a80ce52b64d052d71eeb78f881e1
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit5c48a3348c717dd438f5f9e83747c5f0::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire4709a80ce52b64d052d71eeb78f881e1($fileIdentifier, $file);
|
||||
composerRequire5c48a3348c717dd438f5f9e83747c5f0($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire4709a80ce52b64d052d71eeb78f881e1($fileIdentifier, $file)
|
||||
function composerRequire5c48a3348c717dd438f5f9e83747c5f0($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1
|
||||
class ComposerStaticInit5c48a3348c717dd438f5f9e83747c5f0
|
||||
{
|
||||
public static $files = array (
|
||||
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
|
||||
@ -347,9 +347,9 @@ class ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit4709a80ce52b64d052d71eeb78f881e1::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5c48a3348c717dd438f5f9e83747c5f0::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5c48a3348c717dd438f5f9e83747c5f0::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5c48a3348c717dd438f5f9e83747c5f0::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -502,12 +502,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "e6acc10660ea0185992c2e8c2f73c97ed6d5162c"
|
||||
"reference": "5fae7920d5b8ea47cfc4ed114dc36c4dcc4e8b28"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e6acc10660ea0185992c2e8c2f73c97ed6d5162c",
|
||||
"reference": "e6acc10660ea0185992c2e8c2f73c97ed6d5162c",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/5fae7920d5b8ea47cfc4ed114dc36c4dcc4e8b28",
|
||||
"reference": "5fae7920d5b8ea47cfc4ed114dc36c4dcc4e8b28",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -526,7 +526,7 @@
|
||||
"qiniu/php-sdk": "^7.2",
|
||||
"topthink/framework": "5.1.*"
|
||||
},
|
||||
"time": "2019-07-17T03:08:08+00:00",
|
||||
"time": "2019-07-18T03:17:34+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -245,7 +245,7 @@ class Controller extends \stdClass
|
||||
|
||||
/**
|
||||
* 快捷输入逻辑器
|
||||
* @param array $data 验证数据
|
||||
* @param array|string $data 验证数据
|
||||
* @param array $rule 验证规则
|
||||
* @param array $info 验证消息
|
||||
* @return array
|
||||
|
@ -27,6 +27,18 @@ use think\console\Output;
|
||||
class Sync extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* 当前Admin版本号
|
||||
* @var string
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* 基础URL地址
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUri;
|
||||
|
||||
/**
|
||||
* 指定更新模块
|
||||
* @var array
|
||||
@ -34,10 +46,16 @@ class Sync extends Command
|
||||
protected $modules = [];
|
||||
|
||||
/**
|
||||
* 基础URL地址
|
||||
* @var string
|
||||
* Sync constructor.
|
||||
* @param null $name
|
||||
*/
|
||||
protected static $baseUri = 'https://framework.thinkadmin.top';
|
||||
public function __construct($name = null)
|
||||
{
|
||||
$this->version = config('app.thinkadmin_ver');
|
||||
if (empty($this->version)) $this->version = 'v4';
|
||||
$this->baseUri = "https://{$this->version}.thinkadmin.top";
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行指令
|
||||
@ -47,7 +65,7 @@ class Sync extends Command
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$output->comment('start updating difference files');
|
||||
foreach (self::diff() as $file) foreach ($this->modules as $module) {
|
||||
foreach ($this->diff() as $file) foreach ($this->modules as $module) {
|
||||
if (stripos($file['name'], $module) === 0) {
|
||||
$this->syncFile($file, $output);
|
||||
break;
|
||||
@ -59,10 +77,10 @@ class Sync extends Command
|
||||
/**
|
||||
* 同步所有差异文件
|
||||
*/
|
||||
public static function sync()
|
||||
public function sync()
|
||||
{
|
||||
foreach (self::diff() as $file) {
|
||||
self::syncFile($file, new Output());
|
||||
foreach ($this->diff() as $file) {
|
||||
$this->syncFile($file, new Output());
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,10 +89,10 @@ class Sync extends Command
|
||||
* @param array $file
|
||||
* @param Output $output
|
||||
*/
|
||||
private static function syncFile($file, $output)
|
||||
private function syncFile($file, $output)
|
||||
{
|
||||
if (in_array($file['type'], ['add', 'mod'])) {
|
||||
if (self::down(encode($file['name']))) {
|
||||
if ($this->down(encode($file['name']))) {
|
||||
$output->writeln("{$file['name']} updated successfully.");
|
||||
} else {
|
||||
$output->error("{$file['name']} update failed.");
|
||||
@ -82,7 +100,7 @@ class Sync extends Command
|
||||
} elseif (in_array($file['type'], ['del'])) {
|
||||
$realfile = realpath(env('root_path') . $file['name']);
|
||||
if (is_file($realfile) && unlink($realfile)) {
|
||||
self::removeEmptyDir(dirname($realfile));
|
||||
$this->removeEmptyDir(dirname($realfile));
|
||||
$output->writeln("{$file['name']} remove successfully.");
|
||||
} else {
|
||||
$output->error("{$file['name']} remove failed.");
|
||||
@ -94,10 +112,10 @@ class Sync extends Command
|
||||
* 清理指定的空目录
|
||||
* @param string $dir
|
||||
*/
|
||||
private static function removeEmptyDir($dir)
|
||||
private function removeEmptyDir($dir)
|
||||
{
|
||||
if (is_dir($dir) && count(scandir($dir)) === 2) {
|
||||
if (rmdir($dir)) self::removeEmptyDir(dirname($dir));
|
||||
if (rmdir($dir)) $this->removeEmptyDir(dirname($dir));
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,9 +123,9 @@ class Sync extends Command
|
||||
* 获取当前系统文件列表
|
||||
* @return array
|
||||
*/
|
||||
public static function build()
|
||||
public function build()
|
||||
{
|
||||
return self::tree([
|
||||
return $this->tree([
|
||||
'think',
|
||||
'config/log.php',
|
||||
'config/cookie.php',
|
||||
@ -128,12 +146,12 @@ class Sync extends Command
|
||||
* @param array $maps 扫描结果列表
|
||||
* @return array
|
||||
*/
|
||||
public static function tree(array $paths, array $ignores = [], array $maps = [])
|
||||
public function tree(array $paths, array $ignores = [], array $maps = [])
|
||||
{
|
||||
$root = str_replace('\\', '/', env('root_path'));
|
||||
foreach ($paths as $key => $dir) {
|
||||
$paths[$key] = str_replace('\\', '/', $dir);
|
||||
$maps = array_merge($maps, self::scanDir("{$root}{$paths[$key]}", $root));
|
||||
$maps = array_merge($maps, $this->scanDir("{$root}{$paths[$key]}", $root));
|
||||
}
|
||||
// 清除忽略文件
|
||||
foreach ($maps as $key => $map) foreach ($ignores as $ingore) {
|
||||
@ -148,7 +166,7 @@ class Sync extends Command
|
||||
* @param array $local 本地文件列表信息
|
||||
* @return array
|
||||
*/
|
||||
public static function contrast(array $serve = [], array $local = [])
|
||||
public function contrast(array $serve = [], array $local = [])
|
||||
{
|
||||
// 数据扁平化
|
||||
list($_serve, $_local, $_new) = [[], [], []];
|
||||
@ -174,9 +192,9 @@ class Sync extends Command
|
||||
* @param string $encode
|
||||
* @return boolean|integer
|
||||
*/
|
||||
public static function down($encode)
|
||||
public function down($encode)
|
||||
{
|
||||
$result = json_decode(http_get(self::$baseUri . "?s=admin/api.update/read/{$encode}"), true);
|
||||
$result = json_decode(http_get("{$this->baseUri}?s=admin/api.update/read/{$encode}"), true);
|
||||
if (empty($result['code'])) return false;
|
||||
$pathname = env('root_path') . decode($encode);
|
||||
file_exists(dirname($pathname)) || mkdir(dirname($pathname), 0755, true);
|
||||
@ -187,12 +205,12 @@ class Sync extends Command
|
||||
* 获取文件差异数据
|
||||
* @return array
|
||||
*/
|
||||
public static function diff()
|
||||
public function diff()
|
||||
{
|
||||
$result = json_decode(http_get(self::$baseUri . "?s=/admin/api.update/tree"), true);
|
||||
$result = json_decode(http_get("{$this->baseUri}?s=/admin/api.update/tree"), true);
|
||||
if (empty($result['code'])) return [];
|
||||
$new = self::tree($result['data']['paths'], $result['data']['ignores']);
|
||||
return self::contrast($result['data']['list'], $new['list']);
|
||||
$new = $this->tree($result['data']['paths'], $result['data']['ignores']);
|
||||
return $this->contrast($result['data']['list'], $new['list']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,15 +220,15 @@ class Sync extends Command
|
||||
* @param array $data 扫描结果
|
||||
* @return array
|
||||
*/
|
||||
private static function scanDir($dir, $root = '', $data = [])
|
||||
private function scanDir($dir, $root = '', $data = [])
|
||||
{
|
||||
if (file_exists($dir) && is_file($dir)) {
|
||||
return [self::getFileInfo($dir, $root)];
|
||||
return [$this->getFileInfo($dir, $root)];
|
||||
}
|
||||
if (file_exists($dir)) foreach (scandir($dir) as $sub) if (strpos($sub, '.') !== 0) {
|
||||
if (is_dir($temp = "{$dir}/{$sub}")) {
|
||||
$data = array_merge($data, self::scanDir($temp, $root));
|
||||
} else array_push($data, self::getFileInfo($temp, $root));
|
||||
$data = array_merge($data, $this->scanDir($temp, $root));
|
||||
} else array_push($data, $this->getFileInfo($temp, $root));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@ -221,7 +239,7 @@ class Sync extends Command
|
||||
* @param string $root
|
||||
* @return array
|
||||
*/
|
||||
private static function getFileInfo($file, $root)
|
||||
private function getFileInfo($file, $root)
|
||||
{
|
||||
$hash = md5(preg_replace('/\s{1,}/', '', file_get_contents($file)));
|
||||
$name = str_replace($root, '', str_replace('\\', '/', realpath($file)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user