Browse Source

添加模块配置信息

elviss 2 years ago
parent
commit
b06a7daf33
1 changed files with 14 additions and 13 deletions
  1. 14 13
      src/PackageClass.php

+ 14 - 13
src/PackageClass.php

@@ -59,6 +59,7 @@ class PackageClass
 	}
 	private static function createModuleIni($vendorDir,$vendorPkgs)
 	{
+		//[MODULE]节点内容
 		$content = '[MODULE]' . PHP_EOL;
 		foreach($vendorPkgs as $i=>$pkg){
 			if( in_array($pkg->getName(),['util/distribute-helper']) )
@@ -72,6 +73,16 @@ class PackageClass
 			}
 			$content .= $moduleName . '=' . $pkg->getName() . ',' . $pkg->getPrettyVersion() . PHP_EOL;
 		}
+		//[CONFIG]节点内容
+		//获取包信息
+		$repoDir = dirname($vendorDir);
+		$packageInfo = self::getPackageInfo($vendorDir,$repoDir,$pkg);
+		$moduleConfig = $packageInfo['helper']['module-config'] ? : array();
+		$content = '[CONFIG]' . PHP_EOL;
+		foreach($moduleConfig as $i=>$cfg){
+			$content .= $cfg['name'] . '=' . $cfg['value'] . PHP_EOL;
+		}
+		//保存文件
 		file_put_contents(MODULEINI_PATH,$content);
 		return true;
 	}
@@ -232,11 +243,7 @@ class PackageClass
 		$moduleDir = $packageInfo['moduleDir'];
 		$ossHost = $packageInfo['ossHost'];
 		
-		$moduleFiles = $packageInfo['helper']['module-files'];
-		if(! $moduleFiles){
-			return;
-		}
-		
+		$moduleFiles = $packageInfo['helper']['module-files'] ? : array();	
 		foreach($moduleFiles as $fileInfo){
 			$fileName = $fileInfo['name'];
 
@@ -268,10 +275,7 @@ class PackageClass
 		$version  = $packageInfo['version'];
 		$commonDir = $packageInfo['commonDir'];
 		$ossHost = $packageInfo['ossHost'];
-		$commonFiles = $packageInfo['helper']['common-files'];
-		if(! $commonFiles){
-			return;
-		}
+		$commonFiles = $packageInfo['helper']['common-files']? : array();
 		foreach($commonFiles as $fileInfo){
 			$fileName = $fileInfo['name'];
 			$target = $fileInfo['target'];
@@ -303,10 +307,7 @@ class PackageClass
 		$version = $packageInfo['version'];
 		$configDir = $packageInfo['configDir'];
 		$moduleDir = $packageInfo['moduleDir'];
-		$configFiles = $packageInfo['helper']['config-files'];
-		if(! $configFiles){
-			return;
-		}
+		$configFiles = $packageInfo['helper']['config-files'] ? : array();
 		foreach($configFiles as $fileInfo){
 			$fileName = $fileInfo['name'];
 			$targetName = $fileInfo['target'];