ソースを参照

refactor: generate:installed-sixshop 复用独立脚本

runphp 1 ヶ月 前
コミット
d8d7cfc085
1 ファイル変更2 行追加20 行削除
  1. 2 20
      src/Command/GenerateInstalledSixShopCommand.php

+ 2 - 20
src/Command/GenerateInstalledSixShopCommand.php

@@ -4,8 +4,6 @@ declare(strict_types=1);
 
 namespace SixShop\Core\Command;
 
-use Composer\InstalledVersions;
-use SixShop\Core\Plugin;
 use think\console\Command;
 
 class GenerateInstalledSixShopCommand extends Command
@@ -18,23 +16,7 @@ class GenerateInstalledSixShopCommand extends Command
 
     public function handle(): void
     {
-        $installedSixShopExtensions = [
-            'root' => [],
-            'versions' => []
-        ];
-        $referenceMap = [];
-        foreach (InstalledVersions::getAllRawData() as $installed) {
-            foreach ($installed['versions'] as $name => $package) {
-                if (isset($package['type']) && $package['type'] === Plugin::EXTENSION_TYPE) {
-                    $installedSixShopExtensions['versions'][$name] = $package;
-                    $referenceMap[$name] = $package['reference'];
-                }
-            }
-        }
-        $installedSixShopExtensions['root']['reference'] = hash('md5', json_encode($referenceMap));
-
-        $filePath = dirname(InstalledVersions::getInstallPath('composer/composer'), 2) . '/installedSixShop.php';
-        file_put_contents($filePath, '<?php return ' . var_export($installedSixShopExtensions, true) . ';');
-        $this->output->writeln("Generated: $filePath");
+        require $this->app->getRootPath() . 'scripts/generate-installed-sixshop.php';
+        $this->output->writeln('Generated: ' . $this->app->getRootPath() . 'vendor/composer/installedSixShop.php');
     }
 }