mirror of https://gitee.com/karson/fastadmin.git
完善插件本地安装
parent
af21c68626
commit
4bd4d15788
|
|
@ -15,6 +15,7 @@ use think\exception\PDOException;
|
||||||
|
|
||||||
class Addon extends Command
|
class Addon extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
|
|
@ -25,6 +26,7 @@ class Addon extends Command
|
||||||
->addOption('release', 'r', Option::VALUE_OPTIONAL, 'addon release version', null)
|
->addOption('release', 'r', Option::VALUE_OPTIONAL, 'addon release version', null)
|
||||||
->addOption('uid', 'u', Option::VALUE_OPTIONAL, 'fastadmin uid', null)
|
->addOption('uid', 'u', Option::VALUE_OPTIONAL, 'fastadmin uid', null)
|
||||||
->addOption('token', 't', Option::VALUE_OPTIONAL, 'fastadmin token', null)
|
->addOption('token', 't', Option::VALUE_OPTIONAL, 'fastadmin token', null)
|
||||||
|
->addOption('local', 'l', Option::VALUE_OPTIONAL, 'local package', null)
|
||||||
->setDescription('Addon manager');
|
->setDescription('Addon manager');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,6 +81,7 @@ class Addon extends Command
|
||||||
$createTableSql = $result[0]['Create Table'];
|
$createTableSql = $result[0]['Create Table'];
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
|
@ -138,8 +141,10 @@ class Addon extends Command
|
||||||
if (is_dir($addonDir)) {
|
if (is_dir($addonDir)) {
|
||||||
rmdirs($addonDir);
|
rmdirs($addonDir);
|
||||||
}
|
}
|
||||||
|
// 获取本地路径
|
||||||
|
$local = $input->getOption('local');
|
||||||
try {
|
try {
|
||||||
Service::install($name, 0, ['version' => $release]);
|
Service::install($name, 0, ['version' => $release], $local);
|
||||||
} catch (AddonException $e) {
|
} catch (AddonException $e) {
|
||||||
if ($e->getCode() != -3) {
|
if ($e->getCode() != -3) {
|
||||||
throw new Exception($e->getMessage());
|
throw new Exception($e->getMessage());
|
||||||
|
|
@ -156,7 +161,7 @@ class Addon extends Command
|
||||||
throw new Exception("Operation is aborted!");
|
throw new Exception("Operation is aborted!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Service::install($name, 1, ['version' => $release, 'uid' => $uid, 'token' => $token]);
|
Service::install($name, 1, ['version' => $release, 'uid' => $uid, 'token' => $token], $local);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new Exception($e->getMessage());
|
throw new Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
@ -233,8 +238,7 @@ class Addon extends Command
|
||||||
$zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
$zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||||
|
|
||||||
$files = new \RecursiveIteratorIterator(
|
$files = new \RecursiveIteratorIterator(
|
||||||
new \RecursiveDirectoryIterator($addonDir),
|
new \RecursiveDirectoryIterator($addonDir), \RecursiveIteratorIterator::LEAVES_ONLY
|
||||||
\RecursiveIteratorIterator::LEAVES_ONLY
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($files as $name => $file) {
|
foreach ($files as $name => $file) {
|
||||||
|
|
@ -250,7 +254,7 @@ class Addon extends Command
|
||||||
$output->info("Package Successed!");
|
$output->info("Package Successed!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -314,4 +318,5 @@ class Addon extends Command
|
||||||
{
|
{
|
||||||
return __DIR__ . '/Addon/stubs/' . $name . '.stub';
|
return __DIR__ . '/Addon/stubs/' . $name . '.stub';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue