|
@@ -18,6 +18,9 @@ class PackageClass
|
|
|
//依赖库都已下载,默认先给个进度
|
|
|
self::setProgressStep1(100);
|
|
|
|
|
|
+ //生成module.ini文件
|
|
|
+ self::createModuleIni($vendorDir,$vendorPkgs);
|
|
|
+
|
|
|
//逐个依赖仓库操作
|
|
|
self::postUpdateVendorPkgs($vendorDir,$vendorPkgs);
|
|
|
|
|
@@ -28,7 +31,24 @@ class PackageClass
|
|
|
self::setProgressOK(true);
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+ private static function createModuleIni($vendorDir,$vendorPkgs)
|
|
|
+ {
|
|
|
+ $content = '[MODULE]' . PHP_EOL;
|
|
|
+ foreach($vendorPkgs as $i=>$pkg){
|
|
|
+ if( in_array($pkg->getName(),['util/distribute-helper']) )
|
|
|
+ continue;
|
|
|
+ $cfgPath = pathJoin($vendorDir,$pkg->getName(),'composer.json');
|
|
|
+ $data = json_decode(file_get_contents($cfgPath), true);
|
|
|
+ $moduleName = $data["distribute-helper"]["module-name"];
|
|
|
+ if(!$moduleName){
|
|
|
+ logError('bad format. no module-name node exists.',$cfgPath);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $content .= $moduleName . '=' . $pkg->getName() . ',' . $pkg->getPrettyVersion() . PHP_EOL;
|
|
|
+ }
|
|
|
+ file_put_contents(MODULEINI_PATH,$content);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
private static function postUpdateVendorPkgs($vendorDir,$vendorPkgs)
|
|
|
{
|
|
|
$count = count($vendorPkgs);
|
|
@@ -80,22 +100,34 @@ class PackageClass
|
|
|
createDirectory($distributeDir);
|
|
|
}
|
|
|
|
|
|
- //创建module目录
|
|
|
- $moduleDir = pathJoin(dirname($vendorDir),'module');
|
|
|
- if( !file_exists($moduleDir) ){
|
|
|
- createDirectory($moduleDir);
|
|
|
- }
|
|
|
-
|
|
|
//设置日志文件路径
|
|
|
if(! defined(LOG_PATH)){
|
|
|
$logPath = pathJoin($distributeDir,'log.txt');
|
|
|
define('LOG_PATH',$logPath);
|
|
|
+ if(file_exists($logPath))
|
|
|
+ unlink($logPath);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//设置进度文件路径
|
|
|
if(! defined(PROGRESS_PATH)){
|
|
|
$progressPath = pathJoin($distributeDir,'progress.txt');
|
|
|
define('PROGRESS_PATH',$progressPath);
|
|
|
+ if(file_exists($progressPath))
|
|
|
+ unlink($progressPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建module目录
|
|
|
+ $moduleDir = pathJoin(dirname($vendorDir),'module');
|
|
|
+ if( !file_exists($moduleDir) ){
|
|
|
+ createDirectory($moduleDir);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置 module.ini 路径
|
|
|
+ if(! defined(MODULEINI_PATH)){
|
|
|
+ $moduleiniPath = pathJoin($moduleDir,'module.ini');
|
|
|
+ define('MODULEINI_PATH',$moduleiniPath);
|
|
|
+ if(file_exists($moduleiniPath))
|
|
|
+ unlink($moduleiniPath);
|
|
|
}
|
|
|
|
|
|
//获取部署配置信息
|
|
@@ -109,6 +141,7 @@ class PackageClass
|
|
|
logError("Failed to load distribute config",$cfgPath);
|
|
|
return false;
|
|
|
}
|
|
|
+ logInfo("succeeded to decode config file -- .distribute/config.json");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -141,8 +174,6 @@ class PackageClass
|
|
|
{
|
|
|
$config = self::$config;
|
|
|
$version = $pkg->getPrettyVersion();
|
|
|
- if($version == 'dev-master')
|
|
|
- $version = 'master';
|
|
|
|
|
|
$cfgPath = pathJoin($repoDir,'composer.json');
|
|
|
$data = json_decode(file_get_contents($cfgPath), true);
|
|
@@ -153,11 +184,10 @@ class PackageClass
|
|
|
$rootDir = dirname($vendorDir);
|
|
|
$commonDir = pathJoin($rootDir,'siscom');
|
|
|
$configDir = pathJoin($rootDir,'config',$moduleName);
|
|
|
- $moduleDir = pathJoin($rootDir,'module',$moduleName . '-' . $version);
|
|
|
+ $moduleDir = pathJoin($rootDir,'module',$moduleName);
|
|
|
|
|
|
//获取缓存目录
|
|
|
- $cacheName = str_replace('/','-',$pkg->getName()) . '-' . $version;
|
|
|
- $cacheDir = pathJoin($config['cache-dir'],$cacheName);
|
|
|
+ $cacheDir = pathJoin($config['cache-dir'],str_replace('/','-',$pkg->getName()),$version);
|
|
|
|
|
|
//返回包的相关信息
|
|
|
return array(
|
|
@@ -198,7 +228,7 @@ class PackageClass
|
|
|
logError($repoName,"fetch module file failed",$fileName);
|
|
|
return false;
|
|
|
}
|
|
|
- logInfo($repoName,"module file fetched-- ",$fileName);
|
|
|
+ logInfo("succeeded to fetch module file --",$repoName,$fileName);
|
|
|
|
|
|
// 解压文件
|
|
|
if( isZipFile($fileName) ){
|
|
@@ -232,7 +262,7 @@ class PackageClass
|
|
|
logError($repoName,"fetch common file failed",$fileName);
|
|
|
return false;
|
|
|
}
|
|
|
- logInfo($repoName,"common file fetched -- ",$fileName);
|
|
|
+ llogInfo("succeeded to fetch common file --",$repoName,$fileName);
|
|
|
|
|
|
// 解压文件
|
|
|
if( isZipFile($fileName) ){
|