elviss 2 yıl önce
ebeveyn
işleme
557a07a0bd
2 değiştirilmiş dosya ile 27 ekleme ve 15 silme
  1. 1 1
      src/PackageClass.php
  2. 26 14
      src/Utility.php

+ 1 - 1
src/PackageClass.php

@@ -9,7 +9,7 @@ class PackageClass
 	public static function index($vendorDir, $repoName)
 	{
 		//读取配置信息
-		$config = include "Config.php";
+		$config = parseDistributeConfig();
 		
 		//获取当前包信息
 		$packageInfo = self::getPackageInfo($config,$vendorDir, $repoName);

+ 26 - 14
src/Utility.php

@@ -34,9 +34,32 @@ function getGoPeedPath(){
 function get7ZipPath(){
 	return dirname(dirname(__FILE__)). "/bin/7z.exe";
 }
+//两个参数的路径拼接
+function twoPathJoin($base, $path) {
+	return rtrim( $base, '/' ) . '/' . ltrim( $path, '/' );
+}
+//不定参数路径拼接
+function pathJoin($base, $path) {
+	$newPath = twoPathJoin($base, $path);
+	$args = func_get_args();
+	$argc = func_num_args();
+	for($i=2;$i<$argc;$i++){
+		$newPath = twoPathJoin($newPath,$args[$i]);
+	}
+    return $newPath;
+}
+
+//获取部署配置文件
+function getDistributeConfigPath($vendorDir){
+	return pathJoin(dirname($vendorDir),'.distribute/config.json')
+}
+//解析部署配置文件
+function parseDistributeConfig(){
+	
+}
 
 //多线程下载文件
-function downloadToDir($ossUrl,$repoName,$fileName,$targetDir){
+function downloadToDir($ossHost,$repoName,$fileName,$targetDir){
 	if (!file_exists($targetDir))
 		mkdir($targetDir,0777,true);
 
@@ -46,7 +69,7 @@ function downloadToDir($ossUrl,$repoName,$fileName,$targetDir){
 	}
 	$gopeed = getGoPeedPath();
 	
-	$remoteUrl = pathJoin($ossUrl,$repoName,$fileName);
+	$remoteUrl = pathJoin($ossHost,$repoName,$fileName);
 	$cmd = $gopeed." -D=" . $targetDir . " " . $remoteUrl;
 	system($cmd, $ret);
 	if ($ret != 0) {
@@ -81,18 +104,7 @@ function unzipFile($zipFile, $targetDir){
 	}
 	return false;
 }
-function twoPathJoin($base, $path) {
-	return rtrim( $base, '/' ) . '/' . ltrim( $path, '/' );
-}
-function pathJoin($base, $path) {
-	$newPath = twoPathJoin($base, $path);
-	$args = func_get_args();
-	$argc = func_num_args();
-	for($i=2;$i<$argc;$i++){
-		$newPath = twoPathJoin($newPath,$args[$i]);
-	}
-    return $newPath;
-}
+
 //过滤得到一个最终文件列表
 function filterFiles($files){
 	if(!is_array($files) )