Skip to content

Commit

Permalink
Merge pull request #32 from dekuan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
liuqixing authored Oct 14, 2016
2 parents b9bf0bd + 4903b50 commit 798f6c4
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/tools/ladep
/tools/ladep.phar
/ladep.d

composer.lock
box.json
Expand All @@ -17,7 +18,7 @@ ladep.phar.pubkey
xsdepdata

.DS_Store
src/ladep/.DS_Store
/src/ladep/.DS_Store



Expand Down
Binary file modified ladep.phar
Binary file not shown.
6 changes: 6 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,11 @@
"sha1" : "ba4602ed77981ab26868409fc165c3697d862086",
"url" : "https://github.com/dekuan/ladep/raw/1.0.11/ladep.phar",
"version" : "1.0.11"
},
{
"name" : "ladep.phar",
"sha1" : "538cd05b976e471ec22ebc5f9e45033ad8bab32c",
"url" : "https://github.com/dekuan/ladep/raw/1.0.12/ladep.phar",
"version" : "1.0.12"
}
]
24 changes: 19 additions & 5 deletions src/ladep/libs/Lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@

namespace dekuan\ladep\libs;

use dekuan\delib\CLib;


class Lib
{
protected static $g_arrStaticRequiredFile = [];


static function PrintByCallback( callable $pfnCbFunc, $sType, $sMsg )
{
if ( ! is_callable( $pfnCbFunc ) ||
! CLib::IsExistingString( $sType ) ||
! CLib::IsExistingString( $sMsg ) )
{
return false;
}

$pfnCbFunc( $sType, $sMsg );
}

static function IsValidUrl( $sUrl )
{
return ( is_string( $sUrl ) &&
Expand Down Expand Up @@ -162,7 +176,7 @@ static function GetFullPath( $sSubPath )
// ...
return sprintf
(
"%s/%s/",
"%s/%s",
self::RTrimPath( self::GetPharRootDir() ),
self::TrimPath( $sSubPath )
);
Expand Down Expand Up @@ -269,7 +283,7 @@ static function REnumerateDir( $sDir, $nLevel = 0 )
$oDir = null;
}
}
catch ( Exception $e )
catch ( \Exception $e )
{
throw $e;
}
Expand Down Expand Up @@ -334,7 +348,7 @@ static function RRmDir( $sDir, $bRetainRoot = false, $nLevel = 0 )
$bRet = @ rmdir( $sDir );
}
}
catch ( Exception $e )
catch ( \Exception $e )
{
throw $e;
}
Expand Down Expand Up @@ -405,7 +419,7 @@ static function RRmDirByName( $sDir, $bRetainRoot = false, $sDirName = '', $nLev
// $bRet = @ rmdir( $sDir );
// }
}
catch ( Exception $e )
catch ( \Exception $e )
{
throw $e;
}
Expand Down Expand Up @@ -477,7 +491,7 @@ static function RRmFileByName( $sDir, $bRetainRoot = false, $sFileName = '', $nL
// }

}
catch ( Exception $e )
catch ( \Exception $e )
{
throw $e;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ladep/models/classes/CComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function _CleanUpComposer( $sReleaseDir, callable $pfnCbFunc = null )
}
}
}
catch ( Exception $e )
catch ( \Exception $e )
{
// throw
if ( is_callable( $pfnCbFunc ) )
Expand Down
16 changes: 11 additions & 5 deletions src/ladep/models/classes/CCompressAndInject.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public function CompressAllViews( $sProjectName, $sVer, $arrOptions, callable $p
}
if ( ! is_string( $sProjectName ) || 0 == strlen( $sProjectName ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "# invalid parameter sProjectName : " . __FUNCTION__ );
return false;
}
if ( ! is_string( $sVer ) || 0 == strlen( $sVer ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "# invalid parameter sVer : " . __FUNCTION__ );
return false;
}

Expand Down Expand Up @@ -84,12 +86,12 @@ public function CompressAllViews( $sProjectName, $sVer, $arrOptions, callable $p
}
else
{
$pfnCbFunc( 'comment', "# invalid web public dir" );
libs\Lib::PrintByCallback( $pfnCbFunc, 'comment', "# invalid web public dir" );
}
}
else
{
$pfnCbFunc( 'comment', "# invalid web view dir" );
libs\Lib::PrintByCallback( $pfnCbFunc, 'comment', "# invalid web view dir" );
}

return $bRet;
Expand All @@ -98,24 +100,28 @@ public function CompressAllViews( $sProjectName, $sVer, $arrOptions, callable $p

private function _CreateCompressedView( $sProjectName, $sVer, $sViewFullFilename, $sWebRootDir, $arrOptions, callable $pfnCbFunc )
{
if ( ! is_string( $sProjectName ) || 0 == strlen( $sProjectName ) )
if ( ! is_callable( $pfnCbFunc ) )
{
return false;
}
if ( ! is_string( $sVer ) || 0 == strlen( $sVer ) )
if ( ! is_string( $sProjectName ) || 0 == strlen( $sProjectName ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, 'comment', "# invalid parameter sProjectName" );
return false;
}
if ( ! is_callable( $pfnCbFunc ) )
if ( ! is_string( $sVer ) || 0 == strlen( $sVer ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, 'comment', "# invalid parameter sVer" );
return false;
}
if ( ! is_string( $sViewFullFilename ) || ! is_file( $sViewFullFilename ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, 'comment', "# invalid parameter sViewFullFilename" );
return false;
}
if ( ! is_string( $sWebRootDir ) || ! is_dir( $sWebRootDir ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, 'comment', "# invalid parameter sWebRootDir" );
return false;
}

Expand Down
8 changes: 8 additions & 0 deletions src/ladep/models/classes/CEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ private function _SetupRandomAppKey( $sSrcFullFilename, $sDstFullFilename, $sRan
{
if ( ! is_string( $sSrcFullFilename ) || 0 == strlen( $sSrcFullFilename ) || ! is_file( $sSrcFullFilename ) )
{
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "info", "Source file[$sSrcFullFilename] is invalid." );
}
return false;
}
if ( ! is_string( $sDstFullFilename ) || 0 == strlen( $sDstFullFilename ) )
{
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "info", "destination file is invalid." );
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ladep/models/classes/CProjectFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private function _ScanAllProjectFiles( $sDir, $arrExtName = [ 'ladep' ] )
$oDir = null;
}
}
catch ( Exception $e )
catch ( \Exception $e )
{
throw $e;
}
Expand Down
12 changes: 8 additions & 4 deletions src/ladep/models/classes/CSSHCmdPullLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace dekuan\ladep\models\classes;

use Illuminate\Support\Facades\Config;
//use Illuminate\Support\Facades\Config;
use Symfony\Component\Process;

use dekuan\ladep\libs;
Expand Down Expand Up @@ -38,12 +38,16 @@ private function _PullLogs( $arrSrvList, $sTargetDir, callable $pfnCbFunc )
// pfnCbFunc - [in] callable
// RETURN - true / false
//

if ( ! is_array( $arrSrvList ) || 0 == count( $arrSrvList ) || ! is_callable( $pfnCbFunc ) )
if ( ! is_array( $arrSrvList ) || 0 == count( $arrSrvList ) )
{
$pfnCbFunc( 'error', "Invalid server list." );
libs\Lib::PrintByCallback( $pfnCbFunc, 'error', "Invalid server list." );
return false;
}
if ( ! is_callable( $pfnCbFunc ) )
{
return false;
}


// ...
$bRet = false;
Expand Down
38 changes: 13 additions & 25 deletions src/ladep/models/classes/CSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,17 @@ private function _SetupFile( $sDestDirName, $sFilename, $sReleaseDir, CProject $
{
if ( ! is_string( $sFilename ) || 0 == strlen( $sFilename ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # Invalid filename : " . $sFilename );
return CConst::ERROR_PARAMETER;
}
if ( ! is_string( $sReleaseDir ) || ! is_dir( $sReleaseDir ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # Invalid Release Dir : " . $sReleaseDir );
return CConst::ERROR_PARAMETER;
}
if ( ! $cProject instanceof CProject )
{
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # Invalid instanceof of [cProject]" );
return CConst::ERROR_PARAMETER;
}

Expand Down Expand Up @@ -172,11 +175,13 @@ private function _SetupFile( $sDestDirName, $sFilename, $sReleaseDir, CProject $
else
{
$nRet = constants\CUConsts::CONST_ERROR_FAILED_COPY_FILE;
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # failed in copying file." );
}
}
else
{
$nRet = constants\CUConsts::CONST_ERROR_FILE_NOT_EXIST;
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # source file does not exists : " . $sSrc );
}
}
else if ( 0 == strcasecmp( 'ssh', $sType ) )
Expand All @@ -185,24 +190,19 @@ private function _SetupFile( $sDestDirName, $sFilename, $sReleaseDir, CProject $
// todo
// copy files via ssh
//
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # copying file via SSH is now not supported." );
}
}
else
{
$nRet = constants\CUConsts::CONST_ERROR_CONFIG;
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "comment", "\t\t # error in arrSrvConfig" );
}
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # error in arrSrvConfig" );
}
}
else
{
$nRet = constants\CUConsts::CONST_ERROR_CONFIG;
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "comment", "\t\t # error in name" );
}
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # error in name" );
}

return $nRet;
Expand All @@ -212,6 +212,7 @@ private function _SetupHttpErrorsPage( $sReleaseDir, callable $pfnCbFunc = null
{
if ( ! is_string( $sReleaseDir ) || ! is_dir( $sReleaseDir ) )
{
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "\t\t # invalid ReleaseDir : " . __FUNCTION__ );
return false;
}

Expand All @@ -233,10 +234,7 @@ private function _SetupHttpErrorsPage( $sReleaseDir, callable $pfnCbFunc = null
{
if ( copy( $sSrcFFN, $sDstFFN ) )
{
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "info", "Create error page successfully: " . $sDstSubFile );
}
libs\Lib::PrintByCallback( $pfnCbFunc, "info", "Create error page successfully: " . $sDstSubFile );
}
else
{
Expand All @@ -245,30 +243,20 @@ private function _SetupHttpErrorsPage( $sReleaseDir, callable $pfnCbFunc = null
//
$bRet = false;

if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "error", "Create error page unsuccessfully: " . $sDstSubFile );
}
libs\Lib::PrintByCallback( $pfnCbFunc, "error", "Create error page unsuccessfully: " . $sDstSubFile );
}
}
else
{
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "comment", "error page already exists : " . $sDstSubFile );
}
libs\Lib::PrintByCallback( $pfnCbFunc, "comment", "error page already exists : " . $sDstSubFile );
}
}
}
else
{
if ( is_callable( $pfnCbFunc ) )
{
$pfnCbFunc( "error", "Failed to load the list of http error pages." );
}
libs\Lib::PrintByCallback( $pfnCbFunc, "error", "Failed to load the list of http error pages." );
}

return $bRet;
}

}
13 changes: 7 additions & 6 deletions src/ladep/models/compressores/CCompressor.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,19 @@ public function GetCompressorFullFilenameByName( $sFilename )
$sRet = '';

// ...
$sWorkingRootDir = libs\Lib::GetLocalWorkingRootDir();
$sWorkingJarFFN = sprintf( "%s/%s", libs\Lib::RTrimPath( $sWorkingRootDir ), $sFilename );
if ( is_file( $sWorkingJarFFN ) )
//$sCompressorDir = libs\Lib::GetLocalWorkingRootDir();
$sCompressorDir = sys_get_temp_dir();
$sCompressorJarFFN = sprintf( "%s/%s", libs\Lib::RTrimPath( $sCompressorDir ), $sFilename );
if ( is_file( $sCompressorJarFFN ) )
{
$sRet = $sWorkingJarFFN;
$sRet = $sCompressorJarFFN;
}
else
{
$sPharFFN = libs\Lib::GetFullPath( "/tools/$sFilename" );
if ( false !== file_put_contents( $sWorkingJarFFN, @ file_get_contents( $sPharFFN ) ) )
if ( false !== file_put_contents( $sCompressorJarFFN, @ file_get_contents( $sPharFFN ) ) )
{
$sRet = $sWorkingJarFFN;
$sRet = $sCompressorJarFFN;
}
}

Expand Down

0 comments on commit 798f6c4

Please sign in to comment.