|
@@ -7,12 +7,19 @@ class PackageClass
|
|
|
{
|
|
|
//当所有包都安装完毕后
|
|
|
public static function index($vendorDir,$repoName){
|
|
|
+ //创建.distribute目录
|
|
|
+ $distributeDir = getDistributeDir($vendorDir);
|
|
|
+ if( !file_exists($distributeDir) ){
|
|
|
+ mkdir($distributeDir,0777,true);
|
|
|
+ }
|
|
|
+
|
|
|
//设置日志文件路径
|
|
|
if(! defined(LOG_PATH)){
|
|
|
- define('LOG_PATH',getLogPath($vendorDir))
|
|
|
+ define('LOG_PATH',getLogPath($distributeDir))
|
|
|
}
|
|
|
+
|
|
|
//获取配置信息
|
|
|
- $cfgPath = getConfigPath($vendorDir);
|
|
|
+ $cfgPath = getConfigPath($distributeDir);
|
|
|
$config = loadConfig($cfgPath);
|
|
|
if(!$config){
|
|
|
printf("Failed to load distribute config -- %s\n",$cfgPath);
|
|
@@ -21,6 +28,9 @@ class PackageClass
|
|
|
|
|
|
//获取当前包信息
|
|
|
$packageInfo = self::getPackageInfo($config,$vendorDir,$repoName);
|
|
|
+ if(!$packageInfo){
|
|
|
+ exit();
|
|
|
+ }
|
|
|
|
|
|
//获取当前包的module文件
|
|
|
self::fetchModuleFiles($packageInfo);
|
|
@@ -53,15 +63,24 @@ class PackageClass
|
|
|
//解析composer.json
|
|
|
$cfgPath = pathJoin($repoDir,'composer.json');
|
|
|
$data = json_decode(file_get_contents($cfgPath), true);
|
|
|
+ if(!$data["version"]){
|
|
|
+ logError('no version node exists',$cfgPath);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
$moduleName = $data["distribute-helper"]["module-name"];
|
|
|
+ if(!$moduleName){
|
|
|
+ logError('no distribute-helper/module-name node exists',$cfgPath);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
//获取安装目录
|
|
|
$commonDir = pathJoin($rootDir,'common');
|
|
|
$configDir = pathJoin($rootDir,'config',$moduleName);
|
|
|
- $moduleDir = pathJoin($rootDir,'module',$moduleName);
|
|
|
+ $moduleDir = pathJoin($rootDir,'module',$moduleName . '-' . $data["version"]);
|
|
|
|
|
|
//获取缓存目录
|
|
|
- $cacheDir = pathJoin($config['cache-dir'],$data["name"]);
|
|
|
+ $cacheName = str_replace('/','-',$data["name"]) . '-' . $data["version"];
|
|
|
+ $cacheDir = pathJoin($config['cache-dir'],$cacheName);
|
|
|
|
|
|
//返回包的相关信息
|
|
|
return array(
|