Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Crontab/src/Command/CrontabMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

use Hyperf\Command\Command as Base;
use Hyperf\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\NullOutput;

class CrontabMigrateCommand extends Base
Expand All @@ -36,7 +38,7 @@ public function __invoke()
$migrator = $this->migrator;
$migrator->setConnection($connection);
$this->migrator
->setOutput(new NullOutput())
->setOutput(new NullOutput(new ArrayInput([]), new ConsoleOutput()))
->run(dirname(__DIR__, 2) . '/Database/Migrations');
}

Expand Down
8 changes: 5 additions & 3 deletions src/app-store/src/Command/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ class DownloadCommand extends Base

public function __invoke()
{
$name = $this->input->getOption('name');
$identifier = $this->input->getOption('identifier');
$version = $this->input->getOption('version');
$appStoreService = ApplicationContext::getContainer()->get(AppStoreService::class);
$appStoreService->download($name);
$appStoreService->download($identifier, $version);
$this->output->success('Plugin Downloaded Successfully');
}

protected function configure()
{
$this->addOption('name', 'n', InputOption::VALUE_REQUIRED, 'Plug-in Name');
$this->addOption('identifier', 'n', InputOption::VALUE_REQUIRED, '必选,应用唯一标识符');
$this->addOption('version', null, InputOption::VALUE_OPTIONAL, '应用版本号,默认latest', 'latest');
}
}
2 changes: 1 addition & 1 deletion src/app-store/src/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __invoke()
$params['title'] = $title;
}
$appStoreService = ApplicationContext::getContainer()->get(AppStoreService::class);
$result = $appStoreService->list($params);
$result = $appStoreService->list($params)['data']['list'] ?? [];
$headers = [
'extensionName', 'description', 'author', 'homePage', 'status',
];
Expand Down
2 changes: 1 addition & 1 deletion src/app-store/src/Service/AppStoreService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function request(string $uri, array $data = []): array;
/**
* Download the specified plug-in to a local directory.
*/
public function download(string $identifier): bool;
public function download(string $identifier, string $version): bool;

/**
* Get the details of the specified plugin.
Expand Down
22 changes: 19 additions & 3 deletions src/app-store/src/Service/Impl/AppStoreServiceImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\RequestOptions;
use Hyperf\Collection\Collection;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Guzzle\ClientFactory;
use Xmo\AppStore\Plugin;
Expand Down Expand Up @@ -81,12 +82,27 @@ public function view(string $identifier): array
/**
* Download the specified plug-in to a local directory.
*/
public function download(string $identifier): bool
public function download(string $identifier, string $version): bool
{
$downloadToken = $this->request(__FUNCTION__, compact('identifier'))[0] ?? '';
$downloadResponse = Collection::make($this->request(__FUNCTION__, compact('identifier', 'version')));
if (! $downloadResponse->get('success')) {
throw new \RuntimeException('服务端返回错误' . $downloadResponse->get('message'));
}
$file_token = $downloadResponse->get('data.token');
if (empty($file_token)) {
throw new \RuntimeException('Failed to get download token');
}
$downLoadFileResponse = Collection::make($this->request('download_file', compact('file_token')));
if (! $downLoadFileResponse->get('success')) {
throw new \RuntimeException('服务端返回错误' . $downLoadFileResponse->get('message'));
}
$file_url = $downLoadFileResponse->get('data.url');
if (empty($file_url)) {
throw new \RuntimeException('Failed to get download url');
}
$tmpFile = sys_get_temp_dir() . '/' . uniqid('mine', true) . '.zip';
$tmpFileResource = fopen(sys_get_temp_dir() . '/' . uniqid('mine', true) . '.zip', 'wb+');
$response = $this->client->get('download_file?token=' . $downloadToken, [
$response = $this->client->get($file_url, [
RequestOptions::SINK => $tmpFileResource,
]);
if ($response->getStatusCode() !== 200) {
Expand Down
3 changes: 2 additions & 1 deletion src/mine-generator/src/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\NullOutput;

use function Hyperf\Support\env;
Expand Down Expand Up @@ -96,7 +97,7 @@ public function generator(): void
}

$input = new ArrayInput($command);
$output = new NullOutput();
$output = new NullOutput(new ArrayInput([]), new BufferedOutput());

/** @var Application $application */
$application = $this->container->get(ApplicationInterface::class);
Expand Down