Add iOS build phase scripts
This commit is contained in:
parent
31e9eb4ac0
commit
57c54a1a3f
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
foreach (simplexml_load_file('cpd-output.xml')->duplication as $duplication) {
|
||||
$files = $duplication->xpath('file');
|
||||
foreach ($files as $file) {
|
||||
echo $file['path'].':'.$file['line'].':1: warning: '.$duplication['lines'].' copy-pasted lines from: '
|
||||
.implode(', ', array_map(function ($otherFile) { return $otherFile['path'].':'.$otherFile['line']; },
|
||||
array_filter($files, function ($f) use (&$file) { return $f != $file; }))).PHP_EOL;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
file_name=$1
|
||||
file_link=$2
|
||||
|
||||
folder="Downloads"
|
||||
file_path="./${folder}/${file_name}"
|
||||
|
||||
# make folder if not exist
|
||||
if ! [ -e ${folder} ]; then
|
||||
mkdir ${folder}
|
||||
fi
|
||||
|
||||
# download file if not downloaded
|
||||
if ! [ -e ${file_path} ]; then
|
||||
curl -L ${file_link} -o ${file_path}
|
||||
fi
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
$PROJECT_NAME = $argv[1];
|
||||
$COMMON_STRINGS_PATH = $argv[2];
|
||||
|
||||
function createFolder($path) {
|
||||
if (!file_exists($path)) {
|
||||
mkdir($path, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
$localization = './'.$PROJECT_NAME.'/Resources/Localization/';
|
||||
|
||||
foreach (glob($COMMON_STRINGS_PATH.'/*.json') as $file) {
|
||||
$languageName = array_pop(explode('_', basename($file, '.json')));
|
||||
$isBase = strpos($file, 'default') !== false;
|
||||
|
||||
$jsonFile = file_get_contents($file);
|
||||
$json = json_decode($jsonFile);
|
||||
|
||||
$ios_strings = "";
|
||||
foreach ($json as $key=>$value) {
|
||||
$ios_strings.='"'.$key.'" = "'.str_replace('%s', '%@', str_replace('"','\"', str_replace("\n", '\n', $value))).'";'.PHP_EOL;
|
||||
}
|
||||
$ios_strings = preg_replace('/(\\\\)(u)(\d{4})/', '$1U$3', $ios_strings);
|
||||
|
||||
$lproj = $localization.$languageName.'.lproj/';
|
||||
createFolder($lproj);
|
||||
file_put_contents($lproj.'Localizable.strings', $ios_strings);
|
||||
|
||||
if($isBase) {
|
||||
createFolder($localization.'Base.lproj/');
|
||||
file_put_contents($localization.'Base.lproj/Localizable.strings', $ios_strings);
|
||||
$ios_swift_strings = 'import Foundation'.PHP_EOL.
|
||||
'import LeadKit'.PHP_EOL.PHP_EOL.
|
||||
'// swiftlint:disable superfluous_disable_command'.PHP_EOL.
|
||||
'// swiftlint:disable line_length'.PHP_EOL.
|
||||
'// swiftlint:disable file_length'.PHP_EOL.
|
||||
'// swiftlint:disable identifier_name'.PHP_EOL.PHP_EOL.
|
||||
'extension String {'.PHP_EOL;
|
||||
foreach ($json as $key=>$value) {
|
||||
$value_without_linefeed = preg_replace("/\r|\n/", " ", $value);
|
||||
$ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = "'.$key.'".localized()'."\n".PHP_EOL;
|
||||
}
|
||||
$ios_swift_strings .= '}'.PHP_EOL;
|
||||
file_put_contents($localization.'String+Localization.swift', $ios_swift_strings);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
VERSION=$1
|
||||
FILE_NAME="api-generator-${VERSION}.jar"
|
||||
|
||||
# download api generator
|
||||
link="https://dl.bintray.com/touchin/touchin-tools/ru/touchin/api-generator/${VERSION}/${FILE_NAME}"
|
||||
. build-scripts/xcode/aux_scripts/download_file.sh ${FILE_NAME} ${link}
|
||||
|
||||
# execute api generator
|
||||
java -jar "Downloads/${FILE_NAME}" -s common/api -o ${PROJECT_NAME}/Generated -t api-generator-templates/Swift -a generate-client-code
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# running CPD
|
||||
echo ${EXECUTABLE_NAME}
|
||||
pmd cpd --files ${EXECUTABLE_NAME} --exclude ${EXECUTABLE_NAME}/Generated --minimum-tokens 50 --language swift --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer > cpd-output.xml --failOnViolation true
|
||||
|
||||
# running script
|
||||
php ./build-scripts/xcode/aux_scripts/cpd_script.php -cpd-xml cpd-output.xml
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
LOCALIZATION_PATH="${PROJECT_NAME}/Resources/Localization"
|
||||
STRINGS_FOLDER="common/strings"
|
||||
|
||||
if ! [ -e ${LOCALIZATION_PATH} ]; then
|
||||
echo "${PROJECT_DIR}/${LOCALIZATION_PATH} path does not exist. Add these folders and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -e "${PROJECT_DIR}/${STRINGS_FOLDER}" ]; then
|
||||
echo "${PROJECT_DIR}/${STRINGS_FOLDER} path does not exist. Submodule with strings should be named common and contain strings folder."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
php build-scripts/xcode/aux_scripts/import_strings.php ${PROJECT_NAME} ${STRINGS_FOLDER}
|
||||
Loading…
Reference in New Issue