Last active
June 12, 2018 16:28
-
-
Save Grummfy/1bbd96945f676e6ae4d270e4e66823f0 to your computer and use it in GitHub Desktop.
exakat tips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# <name of project> <path to project> | |
PROJECT_NAME=$1 | |
PROJECT_BASE_PATH=$2 | |
EXAKAT_PROJECT_PATH=$(pwd) | |
echo 'get last version' | |
docker pull exakat/exakat | |
# we need to mount two directory, first is the one from exakat analysis and the second a path to project sources | |
EXAKAT_CMD="docker run -it -v $EXAKAT_PROJECT_PATH:/usr/src/exakat/projects -v $PROJECT_BASE_PATH:/tmp/projects/$PROJECT_NAME --rm exakat/exakat" | |
$EXAKAT_CMD version | |
if [ -f "$EXAKAT_PROJECT_PATH/$PROJECT_NAME/index.php" ]; then | |
echo 'update project' | |
$EXAKAT_CMD update -p $PROJECT_NAME | |
else | |
echo 'init project' | |
$EXAKAT_CMD init -p $PROJECT_NAME -symlink -R /tmp/projects/$PROJECT_NAME | |
fi | |
echo 'build it' | |
$EXAKAT_CMD project -p $PROJECT_NAME -v | |
echo 'and make reports about it' | |
FORMAT=( 'Ambassador' 'Clustergrammer' 'Codacy' 'Codesniffer' 'Devoops' 'FacetedJson' 'FileDependencies' 'FileDependenciesHtml' 'Inventories' 'Json' 'OnepageJson' 'PhpCompilation' 'PhpConfiguration' 'RadwellCode' 'Text' 'Uml' 'Xml' 'ZendFramework' ) | |
for REPORT in "${FORMAT[@]}" | |
do | |
echo "====[ $REPORT ]====" | |
$EXAKAT_CMD report -p $PROJECT_NAME -format $REPORT -file $REPORT | |
done | |
echo "===================" | |
echo "===================" | |
if [ ! -f "$EXAKAT_PROJECT_PATH/$PROJECT_NAME/index.php" ]; then | |
wget 'https://gist.githubusercontent.com/Grummfy/1bbd96945f676e6ae4d270e4e66823f0/raw/e01045dbf19e82b4034a6b6508ed8b130241a610/list-file.php' | |
# the docker don't allow to launch bash, so we need to sudo this ;( | |
sudo mv list-file.php "$EXAKAT_PROJECT_PATH/$PROJECT_NAME/index.php" | |
fi | |
php -S 127.0.0.1:8082 -t $EXAKAT_PROJECT_PATH/$PROJECT_NAME/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>List files</title></head> | |
<body> | |
<?php | |
// WARNING this script not secure at all | |
// but in this case, we don't care, it's for debug purpose | |
$path = (!empty($_GET['p']) ? ($_GET['p'] . '/') : '/'); | |
$list = [ | |
'dirs' => array(), | |
'files' => array(), | |
'parents' => array(), | |
]; | |
// list files | |
foreach (new FilesystemIterator(__DIR__ . $path, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS) as $fileInfo) | |
{ | |
if ($fileInfo->isDir()) | |
{ | |
$list['dirs'][] = $fileInfo->getFilename(); | |
} | |
else | |
{ | |
$list['files'][] = $fileInfo->getFilename(); | |
} | |
} | |
// get parents path | |
$parents = explode('/', trim($path, '/')); | |
$parent = array(); | |
do | |
{ | |
$full = implode('/', $parents); | |
$element = array_pop($parents); | |
$list['parents'][] = [$full, $element]; | |
} while (!empty($parents)); | |
asort($list['dirs']); | |
asort($list['files']); | |
$list['parents'] = array_reverse($list['parents']); | |
// display everything | |
echo '<ul><li>'; | |
array_walk($list['parents'], function($dir) | |
{ | |
echo '<a href="?p=/', $dir[0], '">', $dir[1], '</a>/'; | |
}); | |
echo '</li><li>--</li>'; | |
array_walk($list['dirs'], function($dir) use ($path) | |
{ | |
$dir = $path . $dir; | |
echo '<li><a href="', $dir, '/">', $dir, '/</a> (<a href="?p=', $dir, '">list</a>)</li>', PHP_EOL; | |
}); | |
echo '<li>--</li>'; | |
array_walk($list['files'], function($file) | |
{ | |
echo '<li><a href="', $file, '">', $file, '</a></li>', PHP_EOL; | |
}); | |
echo '</ul>'; | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment