Restructure build system

This commit is contained in:
Dennis Eichhorn 2017-03-11 14:12:38 +01:00
parent 8e8ca6fee6
commit d9aafdfa43
14 changed files with 105 additions and 577 deletions

View File

@ -1,36 +1,34 @@
# General
The Orange Management software is a modular web application for small to mid sized companies that need CRM, ERP, Intranet and/or CMS features. The Orange Management modules can be split into the following different categories:
The Orange Management build system is a collection of scripts to create builds. Builds that can get created are:
* General
* Business
* Education
* Health Care
* Public release builds
* Public developer release builds
There is no limitation on how to combine modules. The modules are structured in a way that there is a minimum amount of dependencies between modules. Often modules provide additional functionality for other modules or modules request features from existing modules. Only in a few cases modules require another module for it's functionality, this is usually only the case for core modules or modules that have a strong relation to an other module.
On top of the release builds the build system can also perform automated code inspections. This allows to run all tests and inspections without interaction and generates a report for developers at the end.
Thanks to the modular structure it's easy to have full control over the costs and keep the functionality to the exact amount that is needed. There is no fear of having too many functions that reduce the usability if they are not needed. This also results in a fast environment not just because only the necessary parts get installed but also because the core is built for a good experience in terms of performance.
The last feature is the backend and documentation generation based on the DocBlock documentation.
## Development Status
# Setup
Currently Orange Management is still fully developing the first Alpha version. As soon as we have a running Beta version we are allowing external testers to use our software and a selected amount of inhouse developed modules.
* Clone the repository somewhere save
* Modify the `config.sh` file to your needs
* Run `setup.sh`
## Developers
# Usage
We are always looking for people that are interested in joining this project. We are looking for:
* Run `build_dev.sh`
* Run `build_public.sh`
* Run `inspection.sh`
* PHP developer
* JavaScript developer
* Frontend developer
* Designer
## Inspections
Are you interested in joining us? Feel free to contact us at spl1nes.com@gmail.com.
The following inspections are performed:
## Overview
* Linting
* Security
* Unit tests
* Metrics (loc, dependencies)
* Code quality (crap, code coverage, code style)
* Project: Orange Management
* Group: Orange Management
* Developers: 1
* Languages: PHP, JS, Java, HTML, CSS
* Dependencies: d3.js, THREE.js, tcpdf, PhpExcel
* Website: [http://orange-management.de/Website](http://orange-management.de/Website)
In order to perform these inspections the build system relies on third party tools as well as custom scripts.

View File

@ -24,3 +24,5 @@ find ${ROOT_PATH}/${RELEASE_PATH}/${VERSION_HASH}/Dev -name "*.css" -type f -del
find ${ROOT_PATH}/${RELEASE_PATH}/${VERSION_HASH}/Dev -name "*.min.js" -type f -delete
find ${ROOT_PATH}/${RELEASE_PATH}/${VERSION_HASH}/Dev -name "private.php" -type f -delete
find ${ROOT_PATH}/${RELEASE_PATH}/${VERSION_HASH}/Dev -name "private.sh" -type f -delete
# Documentation

View File

@ -1 +0,0 @@
#!/bin/bash

44
config.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# Paths
BASE_PATH="/var/www/html"
ROOT_PATH="/var/www/html/Orange-Management"
TOOLS_PATH="/var/www/html/Tools"
RELEASE_PATH="/var/www/html/Release"
INSPECTION_PATH="/var/www/html/Inspection"
TEST_PATH="/var/www/html/Orange-Management/Tests"
# Web
WEB_URL="http://orange-management.de"
MAIL_ADDR=""
# Authentications
DB_USER="root"
DB_PASSWORD="123456"
# Git variables
GITHUB_URL[0]="https://github.com/Orange-Management/Orange-Management.git"
GITHUB_URL[1]="https://github.com/Orange-Management/Console.git"
GITHUB_URL[2]="https://github.com/Orange-Management/cssOMS.git"
GITHUB_URL[3]="https://github.com/Orange-Management/Demo.git"
GITHUB_URL[4]="https://github.com/Orange-Management/Docs.git"
GITHUB_URL[5]="https://github.com/Orange-Management/Documentation.git"
GITHUB_URL[6]="https://github.com/Orange-Management/Install.git"
GITHUB_URL[7]="https://github.com/Orange-Management/jsOMS.git"
GITHUB_URL[8]="https://github.com/Orange-Management/Model.git"
GITHUB_URL[9]="https://github.com/Orange-Management/Modules.git"
GITHUB_URL[10]="https://github.com/Orange-Management/phpOMS.git"
GITHUB_URL[11]="https://github.com/Orange-Management/Release.git"
GITHUB_URL[12]="https://github.com/Orange-Management/Resources.git"
GITHUB_URL[13]="https://github.com/Orange-Management/Socket.git"
GITHUB_URL[14]="https://github.com/Orange-Management/Tests.git"
GITHUB_URL[15]="https://github.com/Orange-Management/Web.git"
GITHUB_URL[16]="https://github.com/Orange-Management/Website.git"
GITHUB_URL[17]="https://github.com/Orange-Management/GitDashboard.git"
GITHUB_URL[18]="https://github.com/Orange-Management/Documentor.git"
GIT_BRANCH="develop"
DATE=$(date +%Y-%m-%d)
VERSION_HASH=${DATE}

View File

@ -1,77 +1,24 @@
#!/bin/bash
# Include
. var.sh
. config.sh
# Executing unit tests
php ${ROOT_PATH}/phpunit.phar --configuration ${ROOT_PATH}/${TEST_PATH}/PHPUnit/phpunit_default.xml > ${ROOT_PATH}/${BUILD_PATH}/logs/phpunit.log
#phpdbg -qrr phpunit.phar --configuration Tests/PHPUnit/phpunit_default.xml
#php Documentor/src/index.php -s C:\Users\coyle\Desktop\Orange-Management\phpOMS -d C:\Users\coyle\Desktop\outtest -c C:\Users\coyle\Desktop\Orange-Management\Build\log\coverage.xml -u C:\Users\coyle\Desktop\Orange-Management\Build\log\test.xml -g C:\Users\coyle\Desktop\Orange-Management\Developer-Guide
#phpdbg -qrr phpunit.phar Tests/PHPUnit/Framework/Math/Matrix/MatrixTest.php --bootstrap Tests/PHPUnit/Bootstrap.php
. Inspection/Php/tests.sh
# Stats & metrics
php ${ROOT_PATH}/phploc.phar ${ROOT_PATH}/phpOMS/ > ${ROOT_PATH}/${BUILD_PATH}/Framework/phploc.log
php ${ROOT_PATH}/phploc.phar ${ROOT_PATH}/Modules/ > ${ROOT_PATH}/${BUILD_PATH}/Modules/phploc.log
php ${ROOT_PATH}/phpmetrics.phar --report-html=${ROOT_PATH}/${BUILD_PATH}/Framework/metrics/metrics.html ${ROOT_PATH}/phpOMS/ >> ${ROOT_PATH}/${BUILD_PATH}/Framework/build.log
php ${ROOT_PATH}/phpmetrics.phar --report-html=${ROOT_PATH}/${BUILD_PATH}/Modules/metrics/metrics.html ${ROOT_PATH}/Modules/ >> ${ROOT_PATH}/${BUILD_PATH}/Modules/build.log
php ${ROOT_PATH}/pdepend.phar --summary-xml=${ROOT_PATH}/${BUILD_PATH}/Framework/pdepend/pdepend.xml --jdepend-chart=${ROOT_PATH}/${BUILD_PATH}/Framework/pdepend/chart.svg --overview-pyramid=${ROOT_PATH}/${BUILD_PATH}/Framework/pdepend/pyramid.svg ${ROOT_PATH}/phpOMS
php ${ROOT_PATH}/pdepend.phar --summary-xml=${ROOT_PATH}/${BUILD_PATH}/Modules/pdepend/pdepend.xml --jdepend-chart=${ROOT_PATH}/${BUILD_PATH}/Modules/pdepend/chart.svg --overview-pyramid=${ROOT_PATH}/${BUILD_PATH}/Modules/pdepend/pyramid.svg ${ROOT_PATH}/Modules
# Documentation
php ${ROOT_PATH}/phpDocumentor.phar -d ${ROOT_PATH} --ignore "*/phpOMS/Localization/*" -t ${ROOT_PATH}/${BUILD_PATH}/docs
. Inspection/Php/stats.sh
# Local inspection
php phpcs.phar --report-file=${ROOT_PATH}/${BUILD_PATH}/Framework/phpcs/phpcs.log --ignore=${ROOT_PATH}/phpOMS/Localization --standard=${ROOT_PATH}/${BUILD_PATH}/phpcs.xml ${ROOT_PATH}/phpOMS
php phpcs.phar --report-file=${ROOT_PATH}/${BUILD_PATH}/Modules/phpcs/phpcs.log --standard=${ROOT_PATH}/${BUILD_PATH}/phpcs.xml ${ROOT_PATH}/Modules
#php phpmd.phar ${ROOT_PATH}/phpOMS xml ${ROOT_PATH}/${BUILD_PATH}/phpmd.xml --reportfile ${ROOT_PATH}/${BUILD_PATH}/logs/phpmdFramework.log -- bzip missing
#php phpmd.phar ${ROOT_PATH}/Modules xml ${ROOT_PATH}/${BUILD_PATH}/phpmd.xml --reportfile ${ROOT_PATH}/${BUILD_PATH}/logs/phpmdModules.log -- bzip missing
php phpcpd.phar ${ROOT_PATH}/phpOMS --exclude Localization --no-interaction > ${ROOT_PATH}/${BUILD_PATH}/Framework/phpcpd/phpcpd.log
php phpcpd.phar ${ROOT_PATH}/Modules --no-interaction > ${ROOT_PATH}/${BUILD_PATH}/Modules/phpcpd/phpcpd.log
. Inspection/Php/tools.sh
# Linting
find ${ROOT_PATH}/phpOMS -name "*.php" | xargs -L1 php -l > ${ROOT_PATH}/${BUILD_PATH}/logs/temp.log
sed '/^No syntax.*/ d' < ${ROOT_PATH}/${BUILD_PATH}/logs/temp.log > ${ROOT_PATH}/${BUILD_PATH}/Framework/linting/linting_php.log
find ${ROOT_PATH}/Modules -name "*.php" | xargs -L1 php -l > ${ROOT_PATH}/${BUILD_PATH}/logs/temp.log
sed '/^No syntax.*/ d' < ${ROOT_PATH}/${BUILD_PATH}/logs/temp.log > ${ROOT_PATH}/${BUILD_PATH}/Modules/linting/linting_php.log
rm ${ROOT_PATH}/${BUILD_PATH}/logs/temp.log
find ${ROOT_PATH} -name "*.json" | xargs -L1 jsonlint -q > ${ROOT_PATH}/${BUILD_PATH}/Modules/linting/linting_json.log
. Inspection/Php/linting.sh
. Inspection/Json/linting.sh
# External inspection and build
#curl -H "Content-Type: application/json" -X POST -d '{"branch":"$GIT_BRANCH","access_token":"$SCRUTINIZER_TOKEN"}' https://scrutinizer-ci.com/api/repositories/g/spl1nes/oms/inspections?access_token=${SCRUTINIZER_TOKEN}
#curl --get --data api_token=$CODECLIMATE_TOKEN https://codeclimate.com/api/repos/oms/branches/$GIT_BRANCH/refresh -- Coming in the future... right now not available for free
#curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $TRAVIS_TOKEN" -d '{"request": {"branch":"$GIT_BRANCH"}}' https://api.travis-ci.org/repo/spl1nes%2FOrange-Management/requests
# Custom html inspections
. Inspection/Html/tags.sh
. Inspection/Html/attributes.sh
# Html tag inspection
TAG[0]="<\/html>"
TAG[1]="<\/body>"
TAG[2]="<\/head>"
TAG[3]="<\/thead>"
TAG[4]="<\/tbody>"
TAG[5]="<\/tfoot>"
TAG[6]="<\/tr>"
TAG[7]="<\/th>"
TAG[8]="<\/td>"
TAG[9]="<\/option>"
TAG[10]="<\/li>"
TAG[11]="<br\s*\/>"
TAG[12]="<meta.*\/>"
TAG[13]="<input.*\/>"
TAG[14]="<hr.*\/>"
TAG[15]="<img.*\/>"
TAG[16]="<link.*\/>"
TAG[17]="<source.*\/>"
TAG[18]="<embed.*\/>"
for i in "${TAG[@]}"
do
grep -rln "$i" --include \*.tpl.php ${ROOT_PATH}/phpOMS >> ${ROOT_PATH}/${BUILD_PATH}/Framework/html/inspection.log
grep -rln "$i" --include \*.tpl.php ${ROOT_PATH}/Modules >> ${ROOT_PATH}/${BUILD_PATH}/Modules/html/inspection.log
done
# Find empty attributes
grep -rln "=\"\"" --include \*.tpl.php ${ROOT_PATH} > ${ROOT_PATH}/${BUILD_PATH}/Modules/html/attributes_empty.log
# Html tag inspection
. ${ROOT_PATH}/${BUILD_PATH}/security.sh
# Custom php inspections
. Inspection/Php/security.sh

View File

@ -1,19 +0,0 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$fh = fopen('GeoIPCountryWhois.csv', 'r');
$fo = fopen('output.csv', 'w');
function ip2int(string $ip) : float {
$split = explode('.', $ip);
return $split[0] * (256 ** 3) + $split[1] * (256 ** 2) + $split[2] * (256 ** 1) + $split[3];
}
while (($data = fgetcsv($fh, 150, ",")) !== FALSE) {
fputcsv($fo, [ip2int($data[0]), ip2int($data[1]), $data[4]]);
}
fclose($fo);
fclose($fh);

102
phpcs.xml
View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="oms-rulesets">
<description>Orange Management ruleset! www.orange-management.de
</description>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="10"/>
<property name="absoluteComplexity" value="20"/>
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="5"/>
<property name="absoluteNestingLevel" value="10"/>
</properties>
</rule>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
<rule ref="MySource.PHP.EvalObjectFactory"/>
<rule ref="MySource.PHP.GetRequestData"/>
<rule ref="PEAR.Classes.ClassDeclaration"/>
<rule ref="PEAR.Commenting.ClassComment"/>
<rule ref="PEAR.Commenting.FileComment"/>
<rule ref="PEAR.Commenting.FunctionComment"/>
<rule ref="PEAR.Commenting.InlineComment"/>
<rule ref="PEAR.ControlStructures.ControlSignature"/>
<rule ref="PEAR.Functions.FunctionCallSignature"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="PEAR.NamingConventions.ValidClassName"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
<rule ref="PEAR.WhiteSpace.ScopeIndent"/>
<rule ref="PSR1.Classes.ClassDeclaration"/>
<rule ref="PSR1.Files.SideEffects"/>
<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="PSR2.Namespaces.UseDeclaration"/>
<rule ref="Squiz.PHP.CommentedOutCode">
<properties>
<property name="maxPercentage" value="30"/>
</properties>
</rule>
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.ForbiddenFunctions"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.PHP.Heredoc"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.Scope.StaticThisUsage"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.PropertyLabelSpacing"/>
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Zend.Files.ClosingTag"/>
</ruleset>

100
phpmd.xml
View File

@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="oms-rulesets"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Orange Management ruleset! www.orange-management.de
</description>
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="10"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="200"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="minimum" value="100"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassLength">
<properties>
<property name="minimum" value="1000"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
<properties>
<property name="minimum" value="10"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessivePublicCount">
<properties>
<property name="minimum" value="45"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/TooManyFields">
<properties>
<property name="maxfields" value="15"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="10"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
<properties>
<property name="maximum" value="50"/>
</properties>
</rule>
<rule ref="rulesets/controversial.xml/Superglobals"/>
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
<rule ref="rulesets/controversial.xml/CamelCaseParameterName"/>
<rule ref="rulesets/controversial.xml/CamelCaseVariableName"/>
<rule ref="rulesets/design.xml/ExitExpression"/>
<rule ref="rulesets/design.xml/EvalExpression"/>
<rule ref="rulesets/design.xml/GotoStatement"/>
<rule ref="rulesets/design.xml/NumberOfChildren">
<properties>
<property name="minimum" value="15"/>
</properties>
</rule>
<rule ref="rulesets/design.xml/DepthOfInheritance">
<properties>
<property name="minimum" value="6"/>
</properties>
</rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties>
<property name="minimum" value="13"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="minimum" value="3"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<property name="maximum" value="20"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortMethodName">
<properties>
<property name="minimum" value="3"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass"/>
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
</ruleset>

View File

@ -1,13 +0,0 @@
#!/bin/bash
git diff --cached --name-only | while read FILE; do
if [[ "$FILE" =~ ^.+(php)$ ]]; then
if [[ -f ${FILE} ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo -e "\e[1;31m\tAborting commit due to files with syntax errors.\e[0m" >&2
exit 1
fi
fi
fi
done || exit $?

View File

@ -1,39 +0,0 @@
#!/bin/bash
. var.sh
# PHP code inspection
CODE[0]="file_get_content"
CODE[1]="fopen"
CODE[2]="include"
CODE[3]="require"
CODE[4]="file_put_content"
CODE[5]="fread"
CODE[6]="fwrite"
CODE[7]="fget"
CODE[8]="fput"
CODE[9]="chmod"
CODE[10]="eval"
CODE[11]="delete"
CODE[12]="mkdir"
CODE[13]="move_uploaded_file"
CODE[14]="mkdir"
CODE[15]="copy"
CODE[16]="chown"
CODE[17]="touch"
CODE[18]="exec"
CODE[19]="_GET"
CODE[20]="_POST"
CODE[21]="_SESSION"
CODE[22]="_REQUEST"
CODE[23]="_SERVER"
CODE[24]="_COOKIE"
CODE[25]="_FILES"
CODE[26]="unlink"
CODE[27]="action=\""
for i in "${CODE[@]}"
do
grep -rln "$i" --include \*.php ${ROOT_PATH}/phpOMS >> ${ROOT_PATH}/${BUILD_PATH}/Framework/critical_php.log
grep -rln "$i" --include \*.php ${ROOT_PATH}/Modules >> ${ROOT_PATH}/${BUILD_PATH}/Modules/citical_php.log
done

View File

@ -1,11 +1,20 @@
#!/bin/bash
. var.sh
. config.sh
# Previous cleanup
rm -r -f ${ROOT_PATH}
mkdir -p ${ROOT_PATH}
rm -r -f ${INSPECTION_PATH}
mkdir -p ${INSPECTION_PATH}
rm -r -f ${TOOLS_PATH}
mkdir -p ${TOOLS_PATH}
rm -r -f ${BUILD_PATH}
mkdir -p ${BUILD_PATH}
# Handling git
c=0;
for i in "${GITHUB_URL[@]}"
@ -25,21 +34,21 @@ do
done
# Creating directories
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/logs
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/logs
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/metrics
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/pdepend
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/phpcs
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/phpcpd
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/linting
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Framework/html
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/logs
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/metrics
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/pdepend
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/phpcs
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/phpcpd
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/linting
mkdir -p ${ROOT_PATH}/${BUILD_PATH}/Modules/html
mkdir -p ${INSPECTION_PATH}/logs
mkdir -p ${INSPECTION_PATH}/Framework/logs
mkdir -p ${INSPECTION_PATH}/Framework/metrics
mkdir -p ${INSPECTION_PATH}/Framework/pdepend
mkdir -p ${INSPECTION_PATH}/Framework/phpcs
mkdir -p ${INSPECTION_PATH}/Framework/phpcpd
mkdir -p ${INSPECTION_PATH}/Framework/linting
mkdir -p ${INSPECTION_PATH}/Framework/html
mkdir -p ${INSPECTION_PATH}/Modules/logs
mkdir -p ${INSPECTION_PATH}/Modules/metrics
mkdir -p ${INSPECTION_PATH}/Modules/pdepend
mkdir -p ${INSPECTION_PATH}/Modules/phpcs
mkdir -p ${INSPECTION_PATH}/Modules/phpcpd
mkdir -p ${INSPECTION_PATH}/Modules/linting
mkdir -p ${INSPECTION_PATH}/Modules/html
# Permission handling
chmod -R 777 ${ROOT_PATH}
@ -52,6 +61,8 @@ mysql -e 'create database oms;' -u ${DB_USER} -p${DB_PASSWORD}
cd ${ROOT_PATH}
touch private.php
cd ${TOOLS_PATH}
# Downloading tools
wget -nc https://getcomposer.org/composer.phar
wget -nc https://phar.phpunit.de/phploc.phar

View File

@ -1,143 +0,0 @@
<?php
function endsWith($haystack, $needle)
{
return $needle === '' || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);
}
function listFolderFiles($dir, $extension)
{
$files = [];
$ffs = scandir($dir);
foreach ($ffs as $ff) {
if ($ff !== '.' && $ff !== '..') {
if (is_dir($dir . '/' . $ff)) {
$files = array_merge($files, listFolderFiles($dir . '/' . $ff, $extension));
} else {
if (endsWith($ff, $extension)) {
$files[] = $dir . '/' . $ff;
}
}
}
}
return $files;
}
// PHP tests
$base = __DIR__ . '/../phpOMS';
$files = listFolderFiles($base, '.php');
$testBase = __DIR__ . '/../Tests/PHPUnit/Framework';
foreach ($files as $file) {
$file = str_replace($base, '', $file);
$subdir = trim($file, '/');
$split = explode('.', $file);
$testPath = $testBase . '/' . $split[0] . 'Test.' . $split[1];
if (stripos($subdir, 'Status.php') === false
&& stripos($subdir, 'Type.php') === false
&& stripos($subdir, 'Layout.php') === false
&& stripos($subdir, 'Level.php') === false
&& stripos($subdir, 'Status') === false
&& stripos($subdir, 'Enum') === false
&& stripos($subdir, 'Null') === false
&& stripos($subdir, 'Interface') === false
&& stripos($subdir, 'Trait') === false
&& stripos($subdir, 'Abstract') === false
) {
if (!file_exists($testPath)) {
$namespace = str_replace('/', '\\', $split[0]);
$namespace = explode('\\', $namespace);
$classnameSrc = $namespace[count($namespace) - 1];
$classname = $classnameSrc . 'Test';
unset($namespace[count($namespace) - 1]);
$use = trim('phpOMS\\' . trim(implode('\\', $namespace), '\\') . '\\' . $classnameSrc, '\\');
$namespace = trim('Tests\PHPUnit\Framework\\' . trim(implode('\\', $namespace), '\\'), '\\');
$autoloader = str_repeat('/..', count(explode('\\', $namespace)));
if(!file_exists(dirname($testPAth))) {
mkdir(dirname($testPath), 0777, true);
}
file_put_contents($testPath,
'<?php' . PHP_EOL
. '/**' . PHP_EOL
. ' * Orange Management' . PHP_EOL
. ' *' . PHP_EOL
. ' * PHP Version 7.1' . PHP_EOL
. ' *' . PHP_EOL
. ' * @category TBD' . PHP_EOL
. ' * @package TBD' . PHP_EOL
. ' * @author OMS Development Team <dev@oms.com>' . PHP_EOL
. ' * @author Dennis Eichhorn <d.eichhorn@oms.com>' . PHP_EOL
. ' * @copyright Dennis Eichhorn' . PHP_EOL
. ' * @license OMS License 1.0' . PHP_EOL
. ' * @version 1.0.0' . PHP_EOL
. ' * @link http://orange-management.com' . PHP_EOL
. ' */' . PHP_EOL
. '' . PHP_EOL
. 'namespace ' . $namespace . ';' . PHP_EOL
. '' . PHP_EOL
. 'require_once __DIR__ . \'' . $autoloader . '/phpOMS/Autoloader.php\';' . PHP_EOL
. '' . PHP_EOL
. 'use ' . $use . ';' . PHP_EOL
. '' . PHP_EOL
. 'class ' . $classname . ' extends \PHPUnit_Framework_TestCase' . PHP_EOL
. '{' . PHP_EOL
. ' public function testPlaceholder()' . PHP_EOL
. ' {' . PHP_EOL
. ' self::markTestIncomplete();' . PHP_EOL
. ' }' . PHP_EOL
. '}' . PHP_EOL
);
}
}
}
// JS tests
$base = __DIR__ . '/../jsOMS';
$files = listFolderFiles($base, '.js');
$testBase = __DIR__ . '/../Tests/JS/Framework';
foreach ($files as $file) {
$file = str_replace($base, '', $file);
$subdir = trim($file, '/');
$split = explode('.', $file);
$testPath = $testBase . '/' . $split[0] . 'Test.' . $split[1];
if (stripos($subdir, 'Status.php') === false
&& stripos($subdir, 'Type.php') === false
&& stripos($subdir, 'Layout.php') === false
&& stripos($subdir, 'Level.php') === false
&& stripos($subdir, 'Status') === false
&& stripos($subdir, 'Enum') === false
&& stripos($subdir, 'Null') === false
&& stripos($subdir, 'Interface') === false
&& stripos($subdir, 'Trait') === false
&& stripos($subdir, 'Abstract') === false
) {
if (!file_exists($testPath)) {
$name = explode('/', $split[0]);
if(!file_exists(dirname($testPath))) {
mkdir(dirname($testPath), 0777, true);
}
file_put_contents($testPath,
'describe(\'' . $name[count($name) - 1] . 'Test\', function ()' . PHP_EOL
. '{' . PHP_EOL
. ' "use strict";' . PHP_EOL
. '' . PHP_EOL
. ' beforeEach(function ()' . PHP_EOL
. ' {' . PHP_EOL
. ' });' . PHP_EOL
. '' . PHP_EOL
. ' afterEach(function ()' . PHP_EOL
. ' {' . PHP_EOL
. ' });' . PHP_EOL
. '}' . PHP_EOL
);
}
}
}

39
var.sh
View File

@ -1,39 +0,0 @@
#!/bin/bash
# Defining paths & basics
BASE_PATH="/var/www/html"
ROOT_PATH="${BASE_PATH}/Orange-Management"
BUILD_PATH="Build"
RELEASE_PATH="Release"
TEST_PATH="Tests"
WEB_URL="http://orange-management.de"
MAIL_ADDR=""
DB_USER="root"
DB_PASSWORD="123456"
# Git variables
GITHUB_URL[0]="https://github.com/Orange-Management/Orange-Management.git"
GITHUB_URL[1]="https://github.com/Orange-Management/Build.git"
GITHUB_URL[2]="https://github.com/Orange-Management/Console.git"
GITHUB_URL[3]="https://github.com/Orange-Management/cssOMS.git"
GITHUB_URL[4]="https://github.com/Orange-Management/Demo.git"
GITHUB_URL[5]="https://github.com/Orange-Management/Docs.git"
GITHUB_URL[6]="https://github.com/Orange-Management/Documentation.git"
GITHUB_URL[7]="https://github.com/Orange-Management/Install.git"
GITHUB_URL[8]="https://github.com/Orange-Management/jsOMS.git"
GITHUB_URL[9]="https://github.com/Orange-Management/Model.git"
GITHUB_URL[10]="https://github.com/Orange-Management/Modules.git"
GITHUB_URL[11]="https://github.com/Orange-Management/phpOMS.git"
GITHUB_URL[12]="https://github.com/Orange-Management/Release.git"
GITHUB_URL[13]="https://github.com/Orange-Management/Resources.git"
GITHUB_URL[14]="https://github.com/Orange-Management/Socket.git"
GITHUB_URL[15]="https://github.com/Orange-Management/Tests.git"
GITHUB_URL[16]="https://github.com/Orange-Management/Web.git"
GITHUB_URL[17]="https://github.com/Orange-Management/Website.git"
GITHUB_URL[18]="https://github.com/Orange-Management/GitDashboard.git"
GITHUB_URL[19]="https://github.com/Orange-Management/Documentor.git"
GIT_BRANCH="develop"
DATE=$(date +%Y-%m-%d)
VERSION_HASH=DATE

View File

@ -1,18 +0,0 @@
#!/bin/bash
DIRECTORY_TO_OBSERVE="cssOMS jsOMS"
function watcher {
inotifywait -r -e modify,move,create,delete \
--exclude ".*(\.css|\.php|\.json|\.md|\.sh|\.txt|\.log|\.min\.js)" \
${DIRECTORY_TO_OBSERVE}
}
BUILD_SCRIPT=build_frontend.sh
function build {
bash ${BUILD_SCRIPT}
}
build
while watcher; do
build
done