diff --git a/src/config/common.php b/src/config/common.php
index 8ae17b8..dabcb78 100644
--- a/src/config/common.php
+++ b/src/config/common.php
@@ -17,8 +17,9 @@
'controllerNamespace' => 'hiqdev\assetpackagist\controllers',
'bootstrap' => ['log'],
'aliases' => [
- '@bower' => '@vendor/bower-asset',
- '@npm' => '@vendor/npm-asset',
+ 'storage' => dirname(dirname(__DIR__)) . '/web',
+ 'npm' => '@vendor/npm-asset',
+ 'bower' => '@vendor/bower-asset',
],
'components' => [
'log' => [
diff --git a/src/config/console.php b/src/config/console.php
index d5c7a8b..478e43f 100644
--- a/src/config/console.php
+++ b/src/config/console.php
@@ -11,6 +11,6 @@
return [
'aliases' => [
- '@web' => '@prjdir/web',
+ 'storage' => dirname(dirname(__DIR__)) . '/web',
],
];
diff --git a/src/console/AssetPackageController.php b/src/console/AssetPackageController.php
index 6df74b3..b852e04 100644
--- a/src/console/AssetPackageController.php
+++ b/src/console/AssetPackageController.php
@@ -12,7 +12,6 @@
namespace hiqdev\assetpackagist\console;
use hiqdev\assetpackagist\models\AssetPackage;
-
use Yii;
class AssetPackageController extends \yii\console\Controller
diff --git a/src/controllers/SiteController.php b/src/controllers/SiteController.php
index e503356..99b2154 100644
--- a/src/controllers/SiteController.php
+++ b/src/controllers/SiteController.php
@@ -11,6 +11,9 @@
namespace hiqdev\assetpackagist\controllers;
+use hiqdev\assetpackagist\models\AssetPackage;
+use Yii;
+
class SiteController extends \yii\web\Controller
{
public function actionIndex()
@@ -27,4 +30,17 @@ public function actionContact()
{
return $this->render('contact');
}
+
+ public function actionSearch()
+ {
+ $q = Yii::$app->request->get('query') ?: Yii::$app->request->post('query');
+ list($temp, $name) = explode('/', $q);
+ list($type, $temp) = explode('-', $temp);
+ $package = new AssetPackage($type, $name);
+ $binpath = Yii::getAlias('@vendor/bin/hidev');
+ system("$binpath asset-package/update $type $name");
+ $package->load();
+
+ return $this->render('search', compact('package'));
+ }
}
diff --git a/src/models/AssetPackage.php b/src/models/AssetPackage.php
index ff629a0..fa71cb5 100644
--- a/src/models/AssetPackage.php
+++ b/src/models/AssetPackage.php
@@ -2,9 +2,10 @@
namespace hiqdev\assetpackagist\models;
-use hiqdev\assetpackagist\registry\RegistryFactory;
+use Exception;
use Composer\Factory;
use Composer\IO\NullIO;
+use hiqdev\assetpackagist\registry\RegistryFactory;
class AssetPackage
{
@@ -22,10 +23,26 @@ class AssetPackage
public function __construct($type, $name)
{
+ if (!$this->checkType($type)) {
+ throw new Exception('wrong type');
+ }
+ if (!$this->checkName($name)) {
+ throw new Exception('wrong name');
+ }
$this->_type = $type;
$this->_name = $name;
}
+ public function checkType($type)
+ {
+ return $type === 'bower' || $type === 'npm';
+ }
+
+ public function checkName($name)
+ {
+ return strlen($name)>1;
+ }
+
public function getFullName()
{
return static::buildFullName($this->_type, $this->_name);
@@ -55,6 +72,8 @@ static public function getCommonComposer()
{
if (static::$_commonComposer === null) {
static::$_commonComposer = Factory::create(new NullIO());
+ #$factory = new Factory();
+ #static::$_commonComposer = $factory->createComposer(new NullIO(), null, false, null, false);
}
return static::$_commonComposer;
diff --git a/src/models/Storage.php b/src/models/Storage.php
index 6408b80..0f3d3b2 100644
--- a/src/models/Storage.php
+++ b/src/models/Storage.php
@@ -16,7 +16,7 @@ class Storage
protected function __construct()
{
- $this->_path = Yii::getAlias('@web');
+ $this->_path = Yii::getAlias('@storage');
}
static public function getInstance()
diff --git a/src/views/layouts/_search.php b/src/views/layouts/_search.php
index 5a13e1b..c7881c7 100644
--- a/src/views/layouts/_search.php
+++ b/src/views/layouts/_search.php
@@ -3,7 +3,7 @@
+ getReleases() ?> +
= $version ?> | += $release['source']['reference'] ?: $release['dist']['reference'] ?> |
+
---|