作者 Karson
@@ -15,6 +15,7 @@ use think\exception\PDOException; @@ -15,6 +15,7 @@ use think\exception\PDOException;
15 15
16 class Addon extends Command 16 class Addon extends Command
17 { 17 {
  18 +
18 protected function configure() 19 protected function configure()
19 { 20 {
20 $this 21 $this
@@ -25,6 +26,7 @@ class Addon extends Command @@ -25,6 +26,7 @@ class Addon extends Command
25 ->addOption('release', 'r', Option::VALUE_OPTIONAL, 'addon release version', null) 26 ->addOption('release', 'r', Option::VALUE_OPTIONAL, 'addon release version', null)
26 ->addOption('uid', 'u', Option::VALUE_OPTIONAL, 'fastadmin uid', null) 27 ->addOption('uid', 'u', Option::VALUE_OPTIONAL, 'fastadmin uid', null)
27 ->addOption('token', 't', Option::VALUE_OPTIONAL, 'fastadmin token', null) 28 ->addOption('token', 't', Option::VALUE_OPTIONAL, 'fastadmin token', null)
  29 + ->addOption('local', 'l', Option::VALUE_OPTIONAL, 'local package', null)
28 ->setDescription('Addon manager'); 30 ->setDescription('Addon manager');
29 } 31 }
30 32
@@ -79,6 +81,7 @@ class Addon extends Command @@ -79,6 +81,7 @@ class Addon extends Command
79 $createTableSql = $result[0]['Create Table']; 81 $createTableSql = $result[0]['Create Table'];
80 } 82 }
81 } catch (PDOException $e) { 83 } catch (PDOException $e) {
  84 +
82 } 85 }
83 86
84 $data = [ 87 $data = [
@@ -138,8 +141,10 @@ class Addon extends Command @@ -138,8 +141,10 @@ class Addon extends Command
138 if (is_dir($addonDir)) { 141 if (is_dir($addonDir)) {
139 rmdirs($addonDir); 142 rmdirs($addonDir);
140 } 143 }
  144 + // 获取本地路径
  145 + $local = $input->getOption('local');
141 try { 146 try {
142 - Service::install($name, 0, ['version' => $release]); 147 + Service::install($name, 0, ['version' => $release], $local);
143 } catch (AddonException $e) { 148 } catch (AddonException $e) {
144 if ($e->getCode() != -3) { 149 if ($e->getCode() != -3) {
145 throw new Exception($e->getMessage()); 150 throw new Exception($e->getMessage());
@@ -156,7 +161,7 @@ class Addon extends Command @@ -156,7 +161,7 @@ class Addon extends Command
156 throw new Exception("Operation is aborted!"); 161 throw new Exception("Operation is aborted!");
157 } 162 }
158 } 163 }
159 - Service::install($name, 1, ['version' => $release, 'uid' => $uid, 'token' => $token]); 164 + Service::install($name, 1, ['version' => $release, 'uid' => $uid, 'token' => $token], $local);
160 } catch (Exception $e) { 165 } catch (Exception $e) {
161 throw new Exception($e->getMessage()); 166 throw new Exception($e->getMessage());
162 } 167 }
@@ -233,8 +238,7 @@ class Addon extends Command @@ -233,8 +238,7 @@ class Addon extends Command
233 $zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); 238 $zip->open($addonFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
234 239
235 $files = new \RecursiveIteratorIterator( 240 $files = new \RecursiveIteratorIterator(
236 - new \RecursiveDirectoryIterator($addonDir),  
237 - \RecursiveIteratorIterator::LEAVES_ONLY 241 + new \RecursiveDirectoryIterator($addonDir), \RecursiveIteratorIterator::LEAVES_ONLY
238 ); 242 );
239 243
240 foreach ($files as $name => $file) { 244 foreach ($files as $name => $file) {
@@ -250,7 +254,7 @@ class Addon extends Command @@ -250,7 +254,7 @@ class Addon extends Command
250 $output->info("Package Successed!"); 254 $output->info("Package Successed!");
251 break; 255 break;
252 256
253 - default: 257 + default :
254 break; 258 break;
255 } 259 }
256 } 260 }
@@ -314,4 +318,5 @@ class Addon extends Command @@ -314,4 +318,5 @@ class Addon extends Command
314 { 318 {
315 return __DIR__ . '/Addon/stubs/' . $name . '.stub'; 319 return __DIR__ . '/Addon/stubs/' . $name . '.stub';
316 } 320 }
  321 +
317 } 322 }