Compare commits
90 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
dd85251813 | |
|
|
069396ecb8 | |
|
|
fce05b99ec | |
|
|
efa00ff67b | |
|
|
565279ef75 | |
|
|
66f4df9425 | |
|
|
5a663334f0 | |
|
|
ccd4df9314 | |
|
|
d900c5b9ad | |
|
|
1160ea6320 | |
|
|
e732e16d21 | |
|
|
abe62fca64 | |
|
|
7f7d535ca5 | |
|
|
e54d505272 | |
|
|
70c2899bf0 | |
|
|
434c4f4e6a | |
|
|
e44811d1b7 | |
|
|
eaad4027c6 | |
|
|
5be3987ea3 | |
|
|
f8865b3232 | |
|
|
4dfed1b2a8 | |
|
|
c841e48516 | |
|
|
3e249eae3d | |
|
|
318e0ce021 | |
|
|
f1fe35d298 | |
|
|
39109c6e60 | |
|
|
7d3f2794bc | |
|
|
b843196f3c | |
|
|
96f4d38bab | |
|
|
e3b688639f | |
|
|
16b6523742 | |
|
|
bf2ee40721 | |
|
|
cd8e8c60e4 | |
|
|
69928bb749 | |
|
|
d6c818370f | |
|
|
b50ced768e | |
|
|
7c5352e6c9 | |
|
|
23fb4371b1 | |
|
|
211020a30d | |
|
|
4716bdb131 | |
|
|
98bd66290e | |
|
|
4cdf0b8982 | |
|
|
9fe5348a98 | |
|
|
ba7f792f96 | |
|
|
3321f3bdfd | |
|
|
082f618425 | |
|
|
d83a3628e4 | |
|
|
0400dbe36d | |
|
|
216c228898 | |
|
|
84db8a0e09 | |
|
|
a58de7d461 | |
|
|
c5b7947526 | |
|
|
4d7182fd67 | |
|
|
302530f3c2 | |
|
|
4b5ee64737 | |
|
|
f0bbbb9929 | |
|
|
ce23c714e5 | |
|
|
34dcae1d5c | |
|
|
45fbc84578 | |
|
|
55ab60b6ea | |
|
|
99281d2105 | |
|
|
c4b340ec44 | |
|
|
a54982e482 | |
|
|
18cf87ea18 | |
|
|
8050647847 | |
|
|
1b8d06cb0d | |
|
|
7c22f6e4fc | |
|
|
d924c2a995 | |
|
|
1af248ea15 | |
|
|
3dfdb3de1e | |
|
|
b350383ae7 | |
|
|
120551da8f | |
|
|
65a5af2e31 | |
|
|
f389e6d806 | |
|
|
8e13458c7f | |
|
|
3f7c655c8e | |
|
|
732df3171f | |
|
|
e082796930 | |
|
|
44a7fd7f48 | |
|
|
47a67edfff | |
|
|
021e4f410e | |
|
|
fa8322b142 | |
|
|
8f4e64bc86 | |
|
|
76ac52accf | |
|
|
b908265a3e | |
|
|
fe8f581c48 | |
|
|
2e08a7c062 | |
|
|
2753812843 | |
|
|
c985b62bf0 | |
|
|
5ad312828c |
25
README.md
25
README.md
|
|
@ -1 +1,26 @@
|
||||||
# BuildScripts
|
# BuildScripts
|
||||||
|
|
||||||
|
## Настройки форматирования
|
||||||
|
|
||||||
|
Позволяют настроить одинаковое форматирования кода в Android Studio у всех, кто работает на проекте.
|
||||||
|
Настройки соответствуют
|
||||||
|
[Правилам оформления Kotlin кода](https://styleguide.docs.touchin.ru/Coding/KotlinCodestyle.html)
|
||||||
|
|
||||||
|
Есть два варианта использования: подключить к проекту или импортировать схему в Android Studio.
|
||||||
|
|
||||||
|
### Как подключить к проекту:
|
||||||
|
|
||||||
|
1. Скопировать директорию [`codeStyles`](./codeStyles) в директорию проекта `.idea`
|
||||||
|
2. Добавить в файл `.gitignore` строку `!.idea/codeStyles`
|
||||||
|
3. Перезапустить Android Studio, чтобы настройки применились
|
||||||
|
|
||||||
|
При таком варианте настройки будут применены у всех, кто работает на проекте.
|
||||||
|
И только для одного конкретного проекта.
|
||||||
|
|
||||||
|
### Как импортировать схему в Android Studio:
|
||||||
|
|
||||||
|
1. Скачать схему [`codeStyles/Project.xml`](./codeStyles/Project.xml)
|
||||||
|
2. В Android Studio перейти в `File` > `Settings` > `Editor` > `Code Style`
|
||||||
|
3. Нажать на шестеренку справа от выпадающего списка схем и выбрать `Import Scheme`
|
||||||
|
4. В открывшемся окне указать путь до сохраненной схемы и нажать `ОК`
|
||||||
|
5. В открывшемся окне ввести название новой схемы и нажать `ОК`
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
<application>
|
|
||||||
<component name="CodeStyleSettingsManager">
|
|
||||||
<option name="PER_PROJECT_SETTINGS">
|
|
||||||
<value />
|
|
||||||
</option>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="TouchInstinct" />
|
|
||||||
</component>
|
|
||||||
</application>
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
<application>
|
|
||||||
<component name="CodeStyleSchemeSettings">
|
|
||||||
<option name="CURRENT_SCHEME_NAME" value="TouchInstinct" />
|
|
||||||
</component>
|
|
||||||
</application>
|
|
||||||
|
|
@ -0,0 +1,249 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<option name="RIGHT_MARGIN" value="120" />
|
||||||
|
<option name="SOFT_MARGINS" value="100" />
|
||||||
|
<AndroidXmlCodeStyleSettings>
|
||||||
|
<option name="LAYOUT_SETTINGS">
|
||||||
|
<value>
|
||||||
|
<option name="INSERT_LINE_BREAK_BEFORE_NAMESPACE_DECLARATION" value="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="MANIFEST_SETTINGS">
|
||||||
|
<value>
|
||||||
|
<option name="INSERT_LINE_BREAK_BEFORE_NAMESPACE_DECLARATION" value="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="OTHER_SETTINGS">
|
||||||
|
<value>
|
||||||
|
<option name="INSERT_LINE_BREAK_BEFORE_NAMESPACE_DECLARATION" value="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</AndroidXmlCodeStyleSettings>
|
||||||
|
<JavaCodeStyleSettings>
|
||||||
|
<option name="GENERATE_FINAL_LOCALS" value="true" />
|
||||||
|
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
|
||||||
|
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
|
||||||
|
<option name="ANNOTATION_PARAMETER_WRAP" value="1" />
|
||||||
|
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
|
||||||
|
<option name="IMPORT_LAYOUT_TABLE">
|
||||||
|
<value>
|
||||||
|
<package name="android" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="com" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="junit" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="net" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="org" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="java" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="javax" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" static="false" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" static="true" withSubpackages="true" />
|
||||||
|
<emptyLine />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="JD_P_AT_EMPTY_LINES" value="false" />
|
||||||
|
</JavaCodeStyleSettings>
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
|
<value />
|
||||||
|
</option>
|
||||||
|
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||||
|
<value>
|
||||||
|
<package name="" alias="false" withSubpackages="true" />
|
||||||
|
<package name="" alias="true" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
|
||||||
|
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
|
||||||
|
<option name="CONTINUATION_INDENT_IN_PARAMETER_LISTS" value="true" />
|
||||||
|
<option name="CONTINUATION_INDENT_IN_ARGUMENT_LISTS" value="true" />
|
||||||
|
<option name="CONTINUATION_INDENT_FOR_EXPRESSION_BODIES" value="true" />
|
||||||
|
<option name="CONTINUATION_INDENT_FOR_CHAINED_CALLS" value="true" />
|
||||||
|
<option name="CONTINUATION_INDENT_IN_ELVIS" value="true" />
|
||||||
|
<option name="ALLOW_TRAILING_COMMA" value="true" />
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<Objective-C-extensions>
|
||||||
|
<file>
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||||
|
</file>
|
||||||
|
<class>
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||||
|
</class>
|
||||||
|
<extensions>
|
||||||
|
<pair header="h" source="cpp" />
|
||||||
|
<pair header="h" source="c" />
|
||||||
|
</extensions>
|
||||||
|
</Objective-C-extensions>
|
||||||
|
<XML>
|
||||||
|
<option name="XML_KEEP_BLANK_LINES" value="1" />
|
||||||
|
</XML>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
|
||||||
|
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||||
|
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||||
|
<option name="RESOURCE_LIST_WRAP" value="1" />
|
||||||
|
<option name="EXTENDS_LIST_WRAP" value="1" />
|
||||||
|
<option name="THROWS_LIST_WRAP" value="1" />
|
||||||
|
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
|
||||||
|
<option name="THROWS_KEYWORD_WRAP" value="1" />
|
||||||
|
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||||
|
<option name="BINARY_OPERATION_WRAP" value="1" />
|
||||||
|
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
||||||
|
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||||
|
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
||||||
|
<option name="FOR_STATEMENT_WRAP" value="1" />
|
||||||
|
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||||
|
<option name="ASSIGNMENT_WRAP" value="1" />
|
||||||
|
<option name="PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE" value="true" />
|
||||||
|
<option name="IF_BRACE_FORCE" value="3" />
|
||||||
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
|
<option name="WRAP_LONG_LINES" value="true" />
|
||||||
|
<option name="PARAMETER_ANNOTATION_WRAP" value="1" />
|
||||||
|
<option name="VARIABLE_ANNOTATION_WRAP" value="1" />
|
||||||
|
<option name="ENUM_CONSTANTS_WRAP" value="5" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="kotlin">
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||||
|
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
|
||||||
|
<option name="ENUM_CONSTANTS_WRAP" value="5" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
|
|
@ -1,254 +0,0 @@
|
||||||
<code_scheme name="TouchInstinct">
|
|
||||||
<option name="GENERATE_FINAL_LOCALS" value="true" />
|
|
||||||
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
|
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
|
||||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
|
|
||||||
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
|
|
||||||
<value />
|
|
||||||
</option>
|
|
||||||
<option name="IMPORT_LAYOUT_TABLE">
|
|
||||||
<value>
|
|
||||||
<package name="android" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="com" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="junit" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="net" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="org" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="java" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="javax" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="" withSubpackages="true" static="false" />
|
|
||||||
<emptyLine />
|
|
||||||
<package name="" withSubpackages="true" static="true" />
|
|
||||||
<emptyLine />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="RIGHT_MARGIN" value="150" />
|
|
||||||
<option name="JD_P_AT_EMPTY_LINES" value="false" />
|
|
||||||
<AndroidXmlCodeStyleSettings>
|
|
||||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
|
||||||
</AndroidXmlCodeStyleSettings>
|
|
||||||
<JavaCodeStyleSettings>
|
|
||||||
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
|
|
||||||
<option name="ANNOTATION_PARAMETER_WRAP" value="1" />
|
|
||||||
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
|
|
||||||
</JavaCodeStyleSettings>
|
|
||||||
<Objective-C-extensions>
|
|
||||||
<file>
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
|
||||||
</file>
|
|
||||||
<class>
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
|
||||||
</class>
|
|
||||||
<extensions>
|
|
||||||
<pair source="cpp" header="h" />
|
|
||||||
<pair source="c" header="h" />
|
|
||||||
</extensions>
|
|
||||||
</Objective-C-extensions>
|
|
||||||
<XML>
|
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
|
||||||
</XML>
|
|
||||||
<codeStyleSettings language="JAVA">
|
|
||||||
<option name="RIGHT_MARGIN" value="150" />
|
|
||||||
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
|
|
||||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
|
||||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
|
||||||
<option name="RESOURCE_LIST_WRAP" value="1" />
|
|
||||||
<option name="EXTENDS_LIST_WRAP" value="1" />
|
|
||||||
<option name="THROWS_LIST_WRAP" value="1" />
|
|
||||||
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
|
|
||||||
<option name="THROWS_KEYWORD_WRAP" value="1" />
|
|
||||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
|
||||||
<option name="BINARY_OPERATION_WRAP" value="1" />
|
|
||||||
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
|
|
||||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
|
||||||
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
|
||||||
<option name="FOR_STATEMENT_WRAP" value="1" />
|
|
||||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
|
||||||
<option name="ASSIGNMENT_WRAP" value="1" />
|
|
||||||
<option name="PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE" value="true" />
|
|
||||||
<option name="IF_BRACE_FORCE" value="3" />
|
|
||||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
|
||||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
|
||||||
<option name="FOR_BRACE_FORCE" value="3" />
|
|
||||||
<option name="WRAP_LONG_LINES" value="true" />
|
|
||||||
<option name="PARAMETER_ANNOTATION_WRAP" value="1" />
|
|
||||||
<option name="VARIABLE_ANNOTATION_WRAP" value="1" />
|
|
||||||
<option name="ENUM_CONSTANTS_WRAP" value="2" />
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="XML">
|
|
||||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
|
||||||
<indentOptions>
|
|
||||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
|
||||||
</indentOptions>
|
|
||||||
<arrangement>
|
|
||||||
<rules>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:android</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>xmlns:.*</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:id</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:name</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>name</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>style</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_width</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_height</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:layout_.*</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:width</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*:height</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<rule>
|
|
||||||
<match>
|
|
||||||
<AND>
|
|
||||||
<NAME>.*</NAME>
|
|
||||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
|
||||||
</AND>
|
|
||||||
</match>
|
|
||||||
<order>BY_NAME</order>
|
|
||||||
</rule>
|
|
||||||
</section>
|
|
||||||
</rules>
|
|
||||||
</arrangement>
|
|
||||||
</codeStyleSettings>
|
|
||||||
</code_scheme>
|
|
||||||
|
|
@ -7,7 +7,7 @@ plugins {
|
||||||
|
|
||||||
// The kotlin-dsl plugin requires a repository to be declared
|
// The kotlin-dsl plugin requires a repository to be declared
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,6 +36,10 @@ gradlePlugin {
|
||||||
id = "api-generator-android"
|
id = "api-generator-android"
|
||||||
implementationClass = "apigen.ApiGeneratorAndroidPlugin"
|
implementationClass = "apigen.ApiGeneratorAndroidPlugin"
|
||||||
}
|
}
|
||||||
|
create("swagger-generator-android") {
|
||||||
|
id = "swagger-generator-android"
|
||||||
|
implementationClass = "apigen.SwaggerApiGeneratorAndroidPlugin"
|
||||||
|
}
|
||||||
create("api-generator-backend") {
|
create("api-generator-backend") {
|
||||||
id = "api-generator-backend"
|
id = "api-generator-backend"
|
||||||
implementationClass = "apigen.ApiGeneratorBackendPlugin"
|
implementationClass = "apigen.ApiGeneratorBackendPlugin"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package apigen
|
||||||
|
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.Task
|
||||||
|
import org.gradle.kotlin.dsl.create
|
||||||
|
import org.gradle.kotlin.dsl.dependencies
|
||||||
|
import org.gradle.kotlin.dsl.repositories
|
||||||
|
|
||||||
|
class SwaggerApiGeneratorAndroidPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val GENERATOR_CONFIG = "swaggerCodegen"
|
||||||
|
const val GENERATOR_VERSION = "3.0.34"
|
||||||
|
const val TI_GENERATOR_CONFIG = "TIKotlin-swagger-codegen"
|
||||||
|
const val TI_GENERATOR_VERSION = "1.0.0"
|
||||||
|
const val GENERATOR_EXT_NAME = "swaggerApiGenerator"
|
||||||
|
const val MAVEN_URL = "https://maven.dev.touchin.ru"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun apply(target: Project) {
|
||||||
|
with(target) {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = uri(MAVEN_URL)
|
||||||
|
metadataSources {
|
||||||
|
artifact()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.create(GENERATOR_CONFIG)
|
||||||
|
configurations.create(TI_GENERATOR_CONFIG)
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
add(TI_GENERATOR_CONFIG, "ru.touchin:TIKotlin-swagger-codegen:$TI_GENERATOR_VERSION")
|
||||||
|
add(GENERATOR_CONFIG, "io.swagger.codegen.v3:swagger-codegen-cli:$GENERATOR_VERSION")
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.create<SwaggerApiGeneratorExtension>(GENERATOR_EXT_NAME)
|
||||||
|
|
||||||
|
val apiGenTask = createSwaggerApiGeneratorTask()
|
||||||
|
|
||||||
|
gradle.projectsEvaluated {
|
||||||
|
tasks.getByName("preBuild").dependsOn(apiGenTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun Project.getExtension(): SwaggerApiGeneratorExtension = extensions.getByName(GENERATOR_EXT_NAME) as SwaggerApiGeneratorExtension
|
||||||
|
|
||||||
|
private fun Project.createSwaggerApiGeneratorTask(): Task = tasks.create(GENERATOR_CONFIG).doLast {
|
||||||
|
|
||||||
|
val extension = getExtension()
|
||||||
|
|
||||||
|
val taskWorkingDir = extension.taskWorkingDir ?: throw IllegalStateException("Configure taskWorkingDir for swagger generator plugin")
|
||||||
|
val apiSchemesFilePath = extension.apiSchemesFilePath ?: throw IllegalStateException("Configure sourceFilePath for swagger generator plugin")
|
||||||
|
val outputDir = extension.outputDir ?: throw IllegalStateException("Configure outputDir for swagger generator plugin")
|
||||||
|
val projectName = extension.projectName ?: throw IllegalStateException("Configure projectName for swagger generator plugin")
|
||||||
|
|
||||||
|
javaexec {
|
||||||
|
workingDir = file(taskWorkingDir)
|
||||||
|
classpath = files(configurations.getByName(GENERATOR_CONFIG).asPath,
|
||||||
|
configurations.getByName(TI_GENERATOR_CONFIG).asPath)
|
||||||
|
main = "io.swagger.codegen.v3.cli.SwaggerCodegen"
|
||||||
|
args = listOfNotNull(
|
||||||
|
"generate",
|
||||||
|
"-i",
|
||||||
|
apiSchemesFilePath,
|
||||||
|
"-l",
|
||||||
|
"TIKotlinCodegen",
|
||||||
|
"-o",
|
||||||
|
outputDir,
|
||||||
|
"--additional-properties",
|
||||||
|
"projectName=$projectName"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
open class SwaggerApiGeneratorExtension(
|
||||||
|
var taskWorkingDir: String? = null,
|
||||||
|
var apiSchemesFilePath: String? = null,
|
||||||
|
var outputDir: String? = null,
|
||||||
|
var projectName: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
fun Project.swaggerApiGenerator(configure: Action<SwaggerApiGeneratorExtension>): Unit =
|
||||||
|
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("swaggerApiGenerator", configure)
|
||||||
|
|
@ -3,6 +3,7 @@ package static_analysis.plugins
|
||||||
import com.android.build.gradle.AppExtension
|
import com.android.build.gradle.AppExtension
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.getByType
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
import static_analysis.linters.AndroidLinter
|
||||||
import static_analysis.linters.CpdLinter
|
import static_analysis.linters.CpdLinter
|
||||||
import static_analysis.linters.DetektLinter
|
import static_analysis.linters.DetektLinter
|
||||||
import static_analysis.linters.Linter
|
import static_analysis.linters.Linter
|
||||||
|
|
@ -34,8 +35,7 @@ class StaticAnalysisAndroidPlugin : StaticAnalysisPlugin() {
|
||||||
override fun createLinters(): List<Linter> = listOf(
|
override fun createLinters(): List<Linter> = listOf(
|
||||||
DetektLinter(),
|
DetektLinter(),
|
||||||
CpdLinter(),
|
CpdLinter(),
|
||||||
//TODO temporary disable Android Linter to avoid FileNotFoundException when generating report
|
AndroidLinter()
|
||||||
//AndroidLinter()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,16 @@
|
||||||
#
|
#
|
||||||
# Example of usage:
|
# Example of usage:
|
||||||
# export_src.sh TestProject ios android backend
|
# export_src.sh TestProject ios android backend
|
||||||
# GIT_BRANCH="develop"; ./export_src.sh TestProject ios web
|
# GIT_BRANCH="develop" ./export_src.sh TestProject ios web
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -z "${GIT_BRANCH}" ]; then
|
if [ -z "${GIT_BRANCH}" ]; then
|
||||||
GIT_BRANCH="master"
|
GIT_BRANCH="master"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LAST_COMMIT_DATE=""
|
||||||
PROJECT_NAME=$1
|
PROJECT_NAME=$1
|
||||||
SRC_FOLDER_NAME="${PROJECT_NAME}-src-$(date +%F)"
|
SRC_FOLDER_NAME="${PROJECT_NAME}-src"
|
||||||
SRC_DIR="./${SRC_FOLDER_NAME}"
|
SRC_DIR="./${SRC_FOLDER_NAME}"
|
||||||
|
|
||||||
COMMAND_LINE_ARGUMENTS=$@
|
COMMAND_LINE_ARGUMENTS=$@
|
||||||
|
|
@ -29,7 +30,18 @@ clone_platform() {
|
||||||
PROJECT_NAME=$1
|
PROJECT_NAME=$1
|
||||||
PLATFORM=$2
|
PLATFORM=$2
|
||||||
|
|
||||||
git clone --recurse-submodules -j8 "git@github.com:TouchInstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"
|
if git clone --recurse-submodules -j8 "ssh://git@git.ti:7999/touchinstinct/${PROJECT_NAME}-${PLATFORM}.git" --branch "${GIT_BRANCH}"; then
|
||||||
|
cd ${PROJECT_NAME}-${PLATFORM}
|
||||||
|
|
||||||
|
COMMIT_DATE=`git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d'`
|
||||||
|
if [[ $LAST_COMMIT_DATE < $COMMIT_DATE ]]; then
|
||||||
|
LAST_COMMIT_DATE="${COMMIT_DATE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p "${SRC_DIR}"
|
mkdir -p "${SRC_DIR}"
|
||||||
|
|
@ -43,7 +55,17 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
ERR_PATHS=$(find . -name "*[<>:\\|?*]*" | xargs -I %s echo "- %s")
|
||||||
|
if [ "$ERR_PATHS" ]; then
|
||||||
|
echo "Export aborted! Invalid characters found in file or directories name(s):\n$ERR_PATHS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${EXPORT_DATE}" ]; then
|
||||||
|
EXPORT_DATE="${LAST_COMMIT_DATE}"
|
||||||
|
fi
|
||||||
|
|
||||||
find . -name ".git*" -print0 | xargs -0 rm -rf
|
find . -name ".git*" -print0 | xargs -0 rm -rf
|
||||||
zip -r -q ${SRC_FOLDER_NAME}.zip .
|
zip -r -q "${SRC_FOLDER_NAME}-${EXPORT_DATE}".zip .
|
||||||
|
|
||||||
open .
|
open .
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ opt_in_rules:
|
||||||
|
|
||||||
# idiomatic
|
# idiomatic
|
||||||
|
|
||||||
- legacy_random
|
|
||||||
- legacy_multiple
|
- legacy_multiple
|
||||||
- pattern_matching_keywords
|
- pattern_matching_keywords
|
||||||
- redundant_nil_coalescing
|
- redundant_nil_coalescing
|
||||||
|
|
@ -32,8 +31,12 @@ opt_in_rules:
|
||||||
- fatal_error_message
|
- fatal_error_message
|
||||||
- extension_access_modifier
|
- extension_access_modifier
|
||||||
- explicit_init
|
- explicit_init
|
||||||
- prefer_zero_over_explicit_init
|
|
||||||
- fallthrough
|
- fallthrough
|
||||||
|
- unavailable_function
|
||||||
|
- prefer_zero_over_explicit_init
|
||||||
|
- discouraged_assert
|
||||||
|
- discouraged_none_name
|
||||||
|
- shorthand_optional_binding
|
||||||
|
|
||||||
# style
|
# style
|
||||||
|
|
||||||
|
|
@ -55,29 +58,46 @@ opt_in_rules:
|
||||||
- closure_spacing
|
- closure_spacing
|
||||||
- closure_end_indentation
|
- closure_end_indentation
|
||||||
- prefer_self_type_over_type_of_self
|
- prefer_self_type_over_type_of_self
|
||||||
|
- closure_parameter_position
|
||||||
|
- comma_inheritance
|
||||||
|
- self_binding
|
||||||
|
- prefer_self_in_static_references
|
||||||
|
- direct_return
|
||||||
|
- period_spacing
|
||||||
|
|
||||||
# lint
|
# lint
|
||||||
|
|
||||||
- private_action
|
- private_action
|
||||||
- private_outlet
|
- private_outlet
|
||||||
- prohibited_super_call
|
- prohibited_super_call
|
||||||
- unused_import
|
|
||||||
- unused_declaration
|
|
||||||
- identical_operands
|
- identical_operands
|
||||||
- overridden_super_call
|
- overridden_super_call
|
||||||
- unowned_variable_capture
|
- unowned_variable_capture
|
||||||
|
- strong_iboutlet
|
||||||
|
- lower_acl_than_parent
|
||||||
- comment_spacing
|
- comment_spacing
|
||||||
|
- ibinspectable_in_extension
|
||||||
|
- private_subject
|
||||||
|
- unhandled_throwing_task
|
||||||
|
|
||||||
# metrics
|
# metrics
|
||||||
|
|
||||||
- enum_case_associated_values_count
|
- enum_case_associated_values_count
|
||||||
|
|
||||||
|
analyzer_rules:
|
||||||
|
- capture_variable
|
||||||
|
- typesafe_array_init
|
||||||
|
- unused_declaration
|
||||||
|
- unused_import
|
||||||
|
|
||||||
excluded:
|
excluded:
|
||||||
- Carthage
|
- Carthage
|
||||||
- Pods
|
- Pods
|
||||||
- Generated
|
- Generated
|
||||||
- "**/Generated"
|
- "**/Generated"
|
||||||
- "**/Resources"
|
- "**/Resources"
|
||||||
|
- ".gem"
|
||||||
|
- "**/*.app"
|
||||||
|
|
||||||
line_length:
|
line_length:
|
||||||
warning: 128
|
warning: 128
|
||||||
|
|
@ -109,6 +129,7 @@ identifier_name:
|
||||||
- id
|
- id
|
||||||
- ok
|
- ok
|
||||||
- URL
|
- URL
|
||||||
|
- qr
|
||||||
- x
|
- x
|
||||||
- y
|
- y
|
||||||
- z
|
- z
|
||||||
|
|
@ -121,30 +142,17 @@ custom_rules:
|
||||||
|
|
||||||
# General
|
# General
|
||||||
|
|
||||||
uiwebview_disabled:
|
unsecure_logging:
|
||||||
included: ".*.swift"
|
name: "Unsecure logging"
|
||||||
name: "UIWebView Usage Disabled"
|
regex: '\s(print|debugPrint|NSLog)\('
|
||||||
regex: 'UIWebView'
|
message: "Please use os_log or remove this debug statement"
|
||||||
message: "Do not use UIWebView. Use WKWebView Instead. https://developer.apple.com/reference/uikit/uiwebview"
|
|
||||||
severity: error
|
|
||||||
|
|
||||||
native_print:
|
|
||||||
name: "print -> DDLog"
|
|
||||||
regex: '(print|NSLog)\('
|
|
||||||
message: "Please use CocoaLumberjack instead `print` and `NSlog`"
|
|
||||||
severity: error
|
|
||||||
|
|
||||||
uiedge_insets_zero:
|
|
||||||
name: "UIEdgeInsets .zero"
|
|
||||||
regex: '\(top: 0, left: 0, bottom: 0, right: 0\)'
|
|
||||||
message: "Please use short init `.zero`."
|
|
||||||
severity: error
|
|
||||||
|
|
||||||
let_variable:
|
|
||||||
name: "Let Variable"
|
|
||||||
regex: 'var\s\w*(:|(\s=))\sVariable'
|
|
||||||
message: "Please make variable using `let`."
|
|
||||||
severity: error
|
severity: error
|
||||||
|
excluded_match_kinds:
|
||||||
|
- comment
|
||||||
|
- comment.mark
|
||||||
|
- comment.url
|
||||||
|
- doccomment
|
||||||
|
- doccomment.field
|
||||||
|
|
||||||
marks_style:
|
marks_style:
|
||||||
name: "Marks"
|
name: "Marks"
|
||||||
|
|
@ -165,19 +173,12 @@ custom_rules:
|
||||||
message: "Type definition not needed"
|
message: "Type definition not needed"
|
||||||
severity: error
|
severity: error
|
||||||
|
|
||||||
unowned:
|
unsafe_unowned:
|
||||||
name: "Unowned"
|
name: "Unsafe unowned usage"
|
||||||
regex: 'unowned'
|
regex: 'unowned'
|
||||||
message: "Please use `weak` instead. "
|
message: "Please use `weak` instead."
|
||||||
severity: error
|
severity: error
|
||||||
|
|
||||||
continue_keyword:
|
|
||||||
name: "Continue"
|
|
||||||
regex: 'continue'
|
|
||||||
message: "Don't use continue instruction"
|
|
||||||
severity: error
|
|
||||||
match_kinds: keyword
|
|
||||||
|
|
||||||
cyrillic_strings:
|
cyrillic_strings:
|
||||||
name: "Cyrillic strings"
|
name: "Cyrillic strings"
|
||||||
regex: '[а-яА-Я]+'
|
regex: '[а-яА-Я]+'
|
||||||
|
|
@ -237,12 +238,6 @@ custom_rules:
|
||||||
message: "Use сontentView instead of self for addSubview or addSubviews methods in cell."
|
message: "Use сontentView instead of self for addSubview or addSubviews methods in cell."
|
||||||
severity: warning
|
severity: warning
|
||||||
|
|
||||||
redundant_type_annotation_bool:
|
|
||||||
name: "Redundant type annotation for Bool"
|
|
||||||
regex: '\s((var|let))\s{1,}\w+ *((: *Bool *=)|((\w| |<|>|:)*= *BehaviorRelay<Bool>\( *value *:)) *((true)|(false))'
|
|
||||||
message: "Using a type annotation for Bool is redundant."
|
|
||||||
severity: warning
|
|
||||||
|
|
||||||
parameter_repetition:
|
parameter_repetition:
|
||||||
name: "Parameter repetition"
|
name: "Parameter repetition"
|
||||||
regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<[^>]+>)? *\( *(?i)(\3|\4):'
|
regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<[^>]+>)? *\( *(?i)(\3|\4):'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Working environment
|
||||||
|
brew "rbenv" # ruby + bundler
|
||||||
|
brew "gettext"
|
||||||
|
|
||||||
|
# Code, configs and project generation
|
||||||
|
brew "php"
|
||||||
|
brew "python"
|
||||||
|
brew "xcodegen"
|
||||||
|
|
||||||
|
# code quality
|
||||||
|
brew "pmd"
|
||||||
|
|
||||||
|
# CI badge
|
||||||
|
# brew "imagemagick"
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
gem "cocoapods"
|
||||||
|
gem "fastlane"
|
||||||
|
gem 'mustache' # for config generator
|
||||||
|
gem 'xcode-install'
|
||||||
|
|
||||||
|
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
|
||||||
|
eval_gemfile(plugins_path) if File.exist?(plugins_path)
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
GREEN := $(shell tput -Txterm setaf 2)
|
||||||
|
YELLOW := $(shell tput -Txterm setaf 3)
|
||||||
|
WHITE := $(shell tput -Txterm setaf 7)
|
||||||
|
RESET := $(shell tput -Txterm sgr0)
|
||||||
|
|
||||||
|
RUBY_VERSION="2.7.6"
|
||||||
|
|
||||||
|
open_project=(open *.xcworkspace)
|
||||||
|
install_dev_certs=(bundle exec fastlane InstallDevelopmentSigningIdentities)
|
||||||
|
install_pods=(bundle exec pod install || bundle exec pod install --repo-update)
|
||||||
|
init_rbenv=(if command -v rbenv &> /dev/null; then eval "$$(rbenv init -)"; fi)
|
||||||
|
|
||||||
|
TARGET_MAX_CHAR_NUM=20
|
||||||
|
## Show help
|
||||||
|
help:
|
||||||
|
@echo ''
|
||||||
|
@echo 'Использование:'
|
||||||
|
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
|
||||||
|
@echo ''
|
||||||
|
@echo 'Команды:'
|
||||||
|
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
|
||||||
|
helpMessage = match(lastLine, /^## (.*)/); \
|
||||||
|
if (helpMessage) { \
|
||||||
|
helpCommand = substr($$1, 0, index($$1, ":")-1); \
|
||||||
|
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
|
||||||
|
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
{ lastLine = $$0 }' $(MAKEFILE_LIST)
|
||||||
|
|
||||||
|
## Инициализирует проект и устанавливает системные утилиты
|
||||||
|
init:
|
||||||
|
brew bundle
|
||||||
|
|
||||||
|
$(call init_rbenv)
|
||||||
|
|
||||||
|
rbenv install -s ${RUBY_VERSION}
|
||||||
|
rbenv global ${RUBY_VERSION}
|
||||||
|
|
||||||
|
if ! gem spec bundler > /dev/null 2>&1; then\
|
||||||
|
echo "bundler gem is not installed!";\
|
||||||
|
-sudo gem install bundler;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
bundle install
|
||||||
|
|
||||||
|
xcodegen
|
||||||
|
|
||||||
|
$(call install_pods)
|
||||||
|
|
||||||
|
bundle exec fastlane install_plugins
|
||||||
|
|
||||||
|
$(call install_dev_certs)
|
||||||
|
|
||||||
|
$(call open_project)
|
||||||
|
|
||||||
|
git config --local core.hooksPath .githooks
|
||||||
|
|
||||||
|
## Устанавливает поды
|
||||||
|
pod:
|
||||||
|
$(call install_pods)
|
||||||
|
|
||||||
|
## Запускает генерацию файла проекта
|
||||||
|
gen:
|
||||||
|
xcodegen
|
||||||
|
|
||||||
|
## Устанавливает сертификат и профили для запуска на девайсе
|
||||||
|
dev_certs:
|
||||||
|
$(call install_dev_certs)
|
||||||
|
|
||||||
|
## Открывает папку для ручного редактирования сертификатов и профайлов
|
||||||
|
update_certs:
|
||||||
|
bundle exec fastlane ManuallyUpdateCodeSigning
|
||||||
|
|
||||||
|
## Поднимает версию приложения (параметр "X.Y.Z")
|
||||||
|
bumpAppVersion:
|
||||||
|
ifeq ($(version),undefined)
|
||||||
|
@echo "Version parameter is missing (ex: x.y.z)" $(target)
|
||||||
|
else
|
||||||
|
bundle exec fastlane run increment_version_number version_number:$(version)
|
||||||
|
endif
|
||||||
|
|
||||||
|
## Позволяет быстро открыть workspace проекта
|
||||||
|
start:
|
||||||
|
$(call open_project)
|
||||||
|
|
||||||
|
## Очищает содержимое папки DerivedData
|
||||||
|
clean:
|
||||||
|
rm -rf ~/Library/Developer/Xcode/DerivedData/*
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Description:
|
||||||
|
# Runs full linting and copy-paste-detection for project
|
||||||
|
#
|
||||||
|
# Required environment variables:
|
||||||
|
# SRCROOT - project directory.
|
||||||
|
# SCRIPT_DIR - directory of current script.
|
||||||
|
#
|
||||||
|
# Optional environment variables:
|
||||||
|
# See swiftlint.sh and copy_paste_detection.sh for complete list of available variables
|
||||||
|
#
|
||||||
|
# Example of usage:
|
||||||
|
# ./full_code_lint.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -z "${SCRIPT_DIR}" ]; then
|
||||||
|
SCRIPT_DIR=${SRCROOT}/build-scripts/xcode/build_phases
|
||||||
|
fi
|
||||||
|
|
||||||
|
. ${SRCROOT}/build-scripts/xcode/aux_scripts/install_env.sh swiftlint
|
||||||
|
FORCE_LINT=true; . ${SCRIPT_DIR}/swiftlint.sh
|
||||||
|
|
||||||
|
. ${SRCROOT}/build-scripts/xcode/aux_scripts/install_env.sh cpd
|
||||||
|
. ${SCRIPT_DIR}/copy_paste_detection.sh Localization Generated Pods
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Description:
|
||||||
|
# Runs incremental linting for project
|
||||||
|
#
|
||||||
|
# Required environment variables:
|
||||||
|
# SRCROOT - project directory.
|
||||||
|
# SCRIPT_DIR - directory of current script.
|
||||||
|
#
|
||||||
|
# Optional environment variables:
|
||||||
|
# See swiftlint.sh for complete list of available variables
|
||||||
|
#
|
||||||
|
# Example of usage:
|
||||||
|
# ./incremetal_code_lint.sh
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -z "${SCRIPT_DIR}" ]; then
|
||||||
|
SCRIPT_DIR=${SRCROOT}/build-scripts/xcode/build_phases
|
||||||
|
fi
|
||||||
|
|
||||||
|
. ${SRCROOT}/build-scripts/xcode/aux_scripts/install_env.sh swiftlint
|
||||||
|
. ${SCRIPT_DIR}/swiftlint.sh
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
PROJECT_DIR="${DIR}/../../../"
|
||||||
|
|
||||||
|
make init -C ${PROJECT_DIR}
|
||||||
|
|
@ -24,39 +24,69 @@
|
||||||
readonly EXIT_SUCCESS=0
|
readonly EXIT_SUCCESS=0
|
||||||
readonly EXIT_FAILURE=1
|
readonly EXIT_FAILURE=1
|
||||||
|
|
||||||
readonly TRUE=0
|
readonly TRUE=1
|
||||||
readonly FALSE=1
|
readonly FALSE=0
|
||||||
|
|
||||||
readonly LOG_TAG="API-GENERATOR"
|
readonly LOG_TAG="API-GENERATOR"
|
||||||
|
|
||||||
notice()
|
notice()
|
||||||
{
|
{
|
||||||
echo "${LOG_TAG}:NOTICE: ${1}"
|
echo "${LOG_TAG}:NOTICE: ${1}" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
debug()
|
debug()
|
||||||
{
|
{
|
||||||
if [ ! -z "${VERBOSE}" ]; then
|
if [ ! -z "${VERBOSE}" ]; then
|
||||||
echo "${LOG_TAG}:DEBUG: ${1}"
|
echo "${LOG_TAG}:DEBUG: ${1}" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
exit_on_failure()
|
||||||
|
{
|
||||||
|
eval ${1}
|
||||||
|
|
||||||
|
local -r EXIT_CODE=$?
|
||||||
|
|
||||||
|
if [ ${EXIT_CODE} -ne 0 ]; then
|
||||||
|
echo "Recent command: \`${1}\` failed with code ${EXIT_CODE}"
|
||||||
|
|
||||||
|
exit ${EXIT_CODE}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
is_force_run()
|
is_force_run()
|
||||||
{
|
{
|
||||||
if [ -z "${FORCE_RUN}" ]; then
|
if [ -z "${FORCE_RUN}" ]; then
|
||||||
return ${FALSE}
|
echo ${FALSE}
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -r STR_MODE=`tr "[:upper:]" "[:lower:]" <<< ${FORCE_RUN}`
|
local -r STR_MODE=`tr "[:upper:]" "[:lower:]" <<< ${FORCE_RUN}`
|
||||||
|
|
||||||
if [ ${STR_MODE} == "yes" ] || [ ${STR_MODE} == "true" ] || [ ${STR_MODE} == "1" ]; then
|
if [ ${STR_MODE} == "yes" ] || [ ${STR_MODE} == "true" ] || [ ${STR_MODE} == "1" ]; then
|
||||||
return ${TRUE}
|
echo ${TRUE}
|
||||||
|
else
|
||||||
|
echo ${FALSE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return ${FALSE}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_current_commit()
|
is_single_file()
|
||||||
|
{
|
||||||
|
if [ -z "${SINGLE_FILE}" ]; then
|
||||||
|
echo "true"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local -r STR_MODE=`tr "[:upper:]" "[:lower:]" <<< ${SINGLE_FILE}`
|
||||||
|
|
||||||
|
if [ ${STR_MODE} == "no" ] || [ ${STR_MODE} == "false" ] || [ ${STR_MODE} == "0" ]; then
|
||||||
|
echo "false"
|
||||||
|
else
|
||||||
|
echo "true"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_api_spec_current_commit()
|
||||||
{
|
{
|
||||||
if [ -z "${API_SPEC_DIR}" ]; then
|
if [ -z "${API_SPEC_DIR}" ]; then
|
||||||
if [ ! -z "${1}" ]; then
|
if [ ! -z "${1}" ]; then
|
||||||
|
|
@ -69,11 +99,60 @@ get_current_commit()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_api_spec_status()
|
||||||
|
{
|
||||||
|
if [ -z "${API_SPEC_DIR}" ]; then
|
||||||
|
if [ ! -z "${1}" ]; then
|
||||||
|
echo `git -C ${1} status -s`
|
||||||
|
else
|
||||||
|
echo `git status -s`
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo `git -C ${API_SPEC_DIR} status -s`
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_api_spec_under_source_control()
|
||||||
|
{
|
||||||
|
local IS_UNDER_SOURCE_CONTROL_CHECK
|
||||||
|
|
||||||
|
if [ -z "${API_SPEC_DIR}" ]; then
|
||||||
|
if [ ! -z "${1}" ]; then
|
||||||
|
IS_UNDER_SOURCE_CONTROL_CHECK=`git -C ${1} rev-parse --is-inside-work-tree 2>/dev/null`
|
||||||
|
else
|
||||||
|
IS_UNDER_SOURCE_CONTROL_CHECK=`git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
IS_UNDER_SOURCE_CONTROL_CHECK=`git -C ${API_SPEC_DIR} rev-parse --is-inside-work-tree 2>/dev/null`
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${IS_UNDER_SOURCE_CONTROL_CHECK}" = "true" ]; then
|
||||||
|
echo ${TRUE}
|
||||||
|
else
|
||||||
|
echo ${FALSE}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
is_api_spec_has_uncommited_changes()
|
||||||
|
{
|
||||||
|
if [ `is_api_spec_under_source_control` -eq ${TRUE} ]; then
|
||||||
|
local -r API_SPEC_STATUS=`get_api_spec_status`
|
||||||
|
|
||||||
|
if [ -z "${API_SPEC_STATUS}" ]; then
|
||||||
|
echo ${FALSE}
|
||||||
|
else
|
||||||
|
echo ${TRUE}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo ${FALSE}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
is_nothing_changed_since_last_check()
|
is_nothing_changed_since_last_check()
|
||||||
{
|
{
|
||||||
if is_force_run; then
|
if [ `is_force_run` -eq ${TRUE} ]; then
|
||||||
notice "Force run detected. Skipping commits comparison."
|
notice "Force run detected. Skipping commits comparison."
|
||||||
return ${EXIT_FAILURE}
|
echo ${TRUE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${COMMIT_FILE_PATH}" ]; then
|
if [ -z "${COMMIT_FILE_PATH}" ]; then
|
||||||
|
|
@ -81,24 +160,33 @@ is_nothing_changed_since_last_check()
|
||||||
local -r COMMIT_FILE_PATH=${1}
|
local -r COMMIT_FILE_PATH=${1}
|
||||||
else
|
else
|
||||||
debug "COMMIT_FILE_PATH should be defined or passed as first argument!"
|
debug "COMMIT_FILE_PATH should be defined or passed as first argument!"
|
||||||
return ${EXIT_FAILURE}
|
echo ${FALSE}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -r CURRENT_COMMIT=`get_current_commit`
|
if [ `is_api_spec_under_source_control` -eq ${TRUE} ]; then
|
||||||
|
local -r CURRENT_COMMIT=`get_api_spec_current_commit`
|
||||||
|
|
||||||
local -r LAST_CHECKED_COMMIT=`cat ${COMMIT_FILE_PATH} 2> /dev/null || echo ""`
|
local -r LAST_CHECKED_COMMIT=`cat ${COMMIT_FILE_PATH} 2> /dev/null || echo ""`
|
||||||
|
|
||||||
if [ ${CURRENT_COMMIT} = "${LAST_CHECKED_COMMIT}" ]; then
|
if [ ${CURRENT_COMMIT} = "${LAST_CHECKED_COMMIT}" ]; then
|
||||||
return ${EXIT_SUCCESS}
|
if [ `is_api_spec_has_uncommited_changes` -eq ${TRUE} ]; then
|
||||||
|
notice "API spec has uncomitted changes."
|
||||||
|
echo ${FALSE}
|
||||||
else
|
else
|
||||||
return ${EXIT_FAILURE}
|
echo ${TRUE}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo ${FALSE}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo ${FALSE}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
record_current_commit()
|
record_current_commit()
|
||||||
{
|
{
|
||||||
if is_force_run; then
|
if [ `is_force_run` -eq ${TRUE} ]; then
|
||||||
notice "Force run detected. Commit won't be recorder."
|
notice "Force run detected. Commit won't be recorder."
|
||||||
exit ${EXIT_SUCCESS}
|
exit ${EXIT_SUCCESS}
|
||||||
fi
|
fi
|
||||||
|
|
@ -112,7 +200,7 @@ record_current_commit()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -r CURRENT_COMMIT=`get_current_commit`
|
local -r CURRENT_COMMIT=`get_api_spec_current_commit`
|
||||||
|
|
||||||
echo ${CURRENT_COMMIT} > ${COMMIT_FILE_PATH}
|
echo ${CURRENT_COMMIT} > ${COMMIT_FILE_PATH}
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +240,7 @@ openapi_codegen()
|
||||||
|
|
||||||
notice "OpenAPI spec generation for ${OPEN_API_SPEC_PATH}"
|
notice "OpenAPI spec generation for ${OPEN_API_SPEC_PATH}"
|
||||||
|
|
||||||
local -r CODEGEN_VERSION="3.0.33"
|
local -r CODEGEN_VERSION="3.0.34"
|
||||||
|
|
||||||
local -r CODEGEN_FILE_NAME="swagger-codegen-cli-${CODEGEN_VERSION}.jar"
|
local -r CODEGEN_FILE_NAME="swagger-codegen-cli-${CODEGEN_VERSION}.jar"
|
||||||
local -r CODEGEN_DOWNLOAD_URL="https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${CODEGEN_VERSION}/${CODEGEN_FILE_NAME}"
|
local -r CODEGEN_DOWNLOAD_URL="https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${CODEGEN_VERSION}/${CODEGEN_FILE_NAME}"
|
||||||
|
|
@ -167,7 +255,9 @@ openapi_codegen()
|
||||||
|
|
||||||
rm -rf ${OUTPUT_PATH}/${API_NAME} # remove previously generated API (if exists)
|
rm -rf ${OUTPUT_PATH}/${API_NAME} # remove previously generated API (if exists)
|
||||||
|
|
||||||
java -cp "Downloads/${CODEGEN_FILE_NAME}:Downloads/${TINETWORKING_CODEGEN_FILE_NAME}" io.swagger.codegen.v3.cli.SwaggerCodegen generate -l TINetworking -i ${OPEN_API_SPEC_PATH} -o ${OUTPUT_PATH} --additional-properties projectName=${API_NAME}
|
local -r OPENAPI_COMMAND="java -cp "Downloads/${CODEGEN_FILE_NAME}:Downloads/${TINETWORKING_CODEGEN_FILE_NAME}" io.swagger.codegen.v3.cli.SwaggerCodegen generate -l TINetworking -i ${OPEN_API_SPEC_PATH} -o ${OUTPUT_PATH} --additional-properties projectName=${API_NAME}"
|
||||||
|
|
||||||
|
exit_on_failure "${OPENAPI_COMMAND}"
|
||||||
|
|
||||||
# flatten folders hierarchy
|
# flatten folders hierarchy
|
||||||
|
|
||||||
|
|
@ -212,7 +302,9 @@ api_generator_codegen()
|
||||||
|
|
||||||
. build-scripts/xcode/aux_scripts/download_file.sh ${FILE_NAME} ${DOWNLOAD_URL}
|
. build-scripts/xcode/aux_scripts/download_file.sh ${FILE_NAME} ${DOWNLOAD_URL}
|
||||||
|
|
||||||
java -Xmx6g -jar "Downloads/${FILE_NAME}" generate-client-code --output-language SWIFT --specification-path ${API_SPEC_DIR} --output-path ${OUTPUT_PATH} --single-file true
|
local -r API_GENERATOR_COMMAND="java -Xmx12g -jar Downloads/${FILE_NAME} generate-client-code --output-language SWIFT --specification-path ${API_SPEC_DIR} --output-path ${OUTPUT_PATH} --single-file $(is_single_file)"
|
||||||
|
|
||||||
|
exit_on_failure "${API_GENERATOR_COMMAND}"
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly BUILD_PHASES_DIR=${SRCROOT}/build_phases
|
readonly BUILD_PHASES_DIR=${SRCROOT}/build_phases
|
||||||
|
|
@ -221,8 +313,8 @@ mkdir -p ${BUILD_PHASES_DIR}
|
||||||
|
|
||||||
readonly COMMIT_FILE_PATH=${BUILD_PHASES_DIR}/api-generator-commit
|
readonly COMMIT_FILE_PATH=${BUILD_PHASES_DIR}/api-generator-commit
|
||||||
|
|
||||||
if is_nothing_changed_since_last_check; then
|
if [ `is_nothing_changed_since_last_check` -eq ${TRUE} ]; then
|
||||||
notice "Nothing was changed api generation skipped."
|
notice "Nothing was changed. API generation skipped."
|
||||||
exit ${EXIT_SUCCESS}
|
exit ${EXIT_SUCCESS}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,17 +61,13 @@ if has_input_files && \
|
||||||
SCRIPT_INPUT_FILE_VARIABLE_NAME="SCRIPT_INPUT_FILE_${i}"
|
SCRIPT_INPUT_FILE_VARIABLE_NAME="SCRIPT_INPUT_FILE_${i}"
|
||||||
SHELL_VARIABLE="\${${SCRIPT_INPUT_FILE_VARIABLE_NAME}}"
|
SHELL_VARIABLE="\${${SCRIPT_INPUT_FILE_VARIABLE_NAME}}"
|
||||||
RESOLVED_FILE_NAME=`envsubst <<< ${SHELL_VARIABLE}`
|
RESOLVED_FILE_NAME=`envsubst <<< ${SHELL_VARIABLE}`
|
||||||
|
|
||||||
|
if [ ! -z ${INPUT_FILE_NAMES} ]; then
|
||||||
|
INPUT_FILE_NAMES=${INPUT_FILE_NAMES}${FILE_NAMES_SEPARATOR}
|
||||||
|
else
|
||||||
INPUT_FILE_NAMES=${INPUT_FILE_NAMES}${FILE_NAMES_SEPARATOR}${RESOLVED_FILE_NAME}
|
INPUT_FILE_NAMES=${INPUT_FILE_NAMES}${FILE_NAMES_SEPARATOR}${RESOLVED_FILE_NAME}
|
||||||
done
|
|
||||||
|
|
||||||
FILE_NAMES_SEPARATOR_LENGTH=`awk '{ print length; }' <<< "${FILE_NAMES_SEPARATOR}"`
|
|
||||||
|
|
||||||
if [ ${FILE_NAMES_SEPARATOR_LENGTH} -gt 0 ] && \
|
|
||||||
[ ! -z "${INPUT_FILE_NAMES}" ]; then
|
|
||||||
|
|
||||||
# remove separator prefix
|
|
||||||
INPUT_FILE_NAMES=`cut -c${FILE_NAMES_SEPARATOR_LENGTH}- <<< ${INPUT_FILE_NAMES}`
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
elif has_input_file_lists; then
|
elif has_input_file_lists; then
|
||||||
for i in `seq 0 $((${SCRIPT_INPUT_FILE_LIST_COUNT}-1))`
|
for i in `seq 0 $((${SCRIPT_INPUT_FILE_LIST_COUNT}-1))`
|
||||||
do
|
do
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# $1 $2 $3 $n - folders to exclude from code checking.
|
# $1 $2 $3 $n - folders to exclude from code checking.
|
||||||
#
|
#
|
||||||
# Required environment variables:
|
# Required environment variables:
|
||||||
# PROJECT_DIR - project directory.
|
# SRCROOT - project directory.
|
||||||
# SCRIPT_DIR - directory of current script.
|
# SCRIPT_DIR - directory of current script.
|
||||||
#
|
#
|
||||||
# Optional environment variables:
|
# Optional environment variables:
|
||||||
|
|
@ -15,43 +15,47 @@
|
||||||
# SCRIPT_INPUT_FILE_{N} - file path to directory that should be checked.
|
# SCRIPT_INPUT_FILE_{N} - file path to directory that should be checked.
|
||||||
#
|
#
|
||||||
# Modified files:
|
# Modified files:
|
||||||
# ${PROJECT_DIR}/code-quality-reports/CPDLog.txt - check report.
|
# ${SRCROOT}/code-quality-reports/CPDLog.txt - check report.
|
||||||
#
|
#
|
||||||
# Example of usage:
|
# Example of usage:
|
||||||
# runner.sh copy_paste_detection.sh Generated Localization Pods
|
# copy_paste_detection.sh Generated Localization Pods
|
||||||
#
|
#
|
||||||
|
|
||||||
readonly EXIT_SUCCESS=0
|
EXIT_SUCCESS=0
|
||||||
readonly EXIT_FAILURE=1
|
EXIT_FAILURE=1
|
||||||
|
|
||||||
. ${SCRIPT_DIR}/../aux_scripts/install_env.sh pmd
|
|
||||||
|
|
||||||
if which pmd >/dev/null; then
|
if which pmd >/dev/null; then
|
||||||
readonly REPORTS_DIR="${PROJECT_DIR}/code-quality-reports"
|
REPORTS_DIR="${SRCROOT}/code-quality-reports"
|
||||||
|
|
||||||
readonly SOURCES_DIRS=`. ${SCRIPT_DIR}/common/read_input_file_names.sh " " ${PROJECT_DIR}`
|
SOURCES_DIRS=`. ${SCRIPT_DIR}/common/read_input_file_names.sh " " ${SRCROOT}`
|
||||||
|
|
||||||
readonly COMMAND_LINE_ARGUMENTS=$@
|
COMMAND_LINE_ARGUMENTS=$@
|
||||||
|
|
||||||
FOLDERS_TO_EXLUDE=""
|
FOLDERS_TO_EXCLUDE=""
|
||||||
|
|
||||||
for argument in ${COMMAND_LINE_ARGUMENTS}
|
for argument in ${COMMAND_LINE_ARGUMENTS}
|
||||||
do
|
do
|
||||||
FOLDERS_TO_EXLUDE=${FOLDERS_TO_EXLUDE}"-or -name ${argument} "
|
FOLDERS_TO_EXCLUDE=${FOLDERS_TO_EXCLUDE}"-or -name ${argument} "
|
||||||
done
|
done
|
||||||
|
|
||||||
FOLDERS_TO_EXLUDE=`echo ${FOLDERS_TO_EXLUDE} | cut -c5-` # remove first "-or"
|
FOLDERS_TO_EXCLUDE=`echo ${FOLDERS_TO_EXCLUDE} | cut -c5-` # remove first "-or"
|
||||||
|
|
||||||
readonly FILES_TO_EXCLUDE=`find ${PROJECT_DIR} -type d ${FOLDERS_TO_EXLUDE} | paste -sd " " -`
|
FILES_TO_EXCLUDE=`find ${SRCROOT} -type d ${FOLDERS_TO_EXCLUDE} | paste -sd " " -`
|
||||||
|
|
||||||
mkdir -p ${REPORTS_DIR}
|
mkdir -p ${REPORTS_DIR}
|
||||||
|
|
||||||
pmd cpd --files ${SOURCES_DIRS} --exclude ${FILES_TO_EXCLUDE} --minimum-tokens 50 --language swift --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer --failOnViolation true > ${REPORTS_DIR}/cpd-output.xml
|
DIRS_ARGUMENTS=""
|
||||||
|
|
||||||
|
for SOURCE_DIR in ${SOURCES_DIRS}; do
|
||||||
|
DIRS_ARGUMENTS=${DIRS_ARGUMENTS}" --dir "${SOURCE_DIR}
|
||||||
|
done
|
||||||
|
|
||||||
|
pmd cpd ${DIRS_ARGUMENTS} --exclude ${FILES_TO_EXCLUDE} --minimum-tokens 50 --language swift --encoding UTF-8 --format net.sourceforge.pmd.cpd.XMLRenderer --skip-lexical-errors true > ${REPORTS_DIR}/cpd-output.xml
|
||||||
|
|
||||||
php ${SCRIPT_DIR}/../aux_scripts/cpd_script.php ${REPORTS_DIR}/cpd-output.xml | tee ${REPORTS_DIR}/CPDLog.txt
|
php ${SCRIPT_DIR}/../aux_scripts/cpd_script.php ${REPORTS_DIR}/cpd-output.xml | tee ${REPORTS_DIR}/CPDLog.txt
|
||||||
|
|
||||||
# Make paths relative to PROJECT_DIR, so different developers won't rewrite entire file
|
# Make paths relative to SRCROOT, so different developers won't rewrite entire file
|
||||||
readonly SED_REPLACEMENT_STRING=$(echo ${PROJECT_DIR} | sed "s/\//\\\\\//g")
|
SED_REPLACEMENT_STRING=$(echo ${SRCROOT} | sed "s/\//\\\\\//g")
|
||||||
|
|
||||||
sed -i '' "s/${SED_REPLACEMENT_STRING}//g" "${REPORTS_DIR}/CPDLog.txt"
|
sed -i '' "s/${SED_REPLACEMENT_STRING}//g" "${REPORTS_DIR}/CPDLog.txt"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
# Description:
|
# Description:
|
||||||
# Runs swiftlint with selected or default config file.
|
# Runs swiftlint with selected or default config file.
|
||||||
|
# By default it runs only for modified files.
|
||||||
#
|
#
|
||||||
# Parameters:
|
# Parameters:
|
||||||
# $1 - path to swiftlint executable.
|
# $1 - path to swiftlint executable.
|
||||||
|
|
@ -10,14 +11,15 @@
|
||||||
# Required environment variables:
|
# Required environment variables:
|
||||||
# SCRIPT_DIR - directory of current script.
|
# SCRIPT_DIR - directory of current script.
|
||||||
# SRCROOT - project directory.
|
# SRCROOT - project directory.
|
||||||
# PODS_ROOT - cocoapods installation directory (eg. ${SRCROOT}/Pods).
|
|
||||||
#
|
#
|
||||||
# Optional environment variables:
|
# Optional environment variables:
|
||||||
# SWIFTLINT_EXECUTABLE - path to swiftlint executable.
|
# SWIFTLINT_EXECUTABLE - path to swiftlint executable.
|
||||||
# SWIFTLINT_CONFIG_PATH - path to swiftlint config.
|
# SWIFTLINT_CONFIG_PATH - path to swiftlint config.
|
||||||
|
# PODS_ROOT - cocoapods installation directory (eg. ${SRCROOT}/Pods) if SWIFTLINT_EXECUTABLE or ${1} is missing
|
||||||
# SCRIPT_INPUT_FILE_COUNT - number of files listed in "Input files" of build phase.
|
# SCRIPT_INPUT_FILE_COUNT - number of files listed in "Input files" of build phase.
|
||||||
# SCRIPT_INPUT_FILE_{N} - file path to directory that should be checked.
|
# SCRIPT_INPUT_FILE_{N} - file path to directory that should be checked.
|
||||||
# FORCE_LINT - lint all project.
|
# FORCE_LINT - don't exclude not modified files.
|
||||||
|
# AUTOCORRECT - format and fix code before lint.
|
||||||
#
|
#
|
||||||
# Example of usage:
|
# Example of usage:
|
||||||
# swiftlint.sh
|
# swiftlint.sh
|
||||||
|
|
@ -30,8 +32,10 @@ readonly SOURCES_DIRS=`. ${SCRIPT_DIR}/common/read_input_file_names.sh "\n" ${SR
|
||||||
if [ -z "${SWIFTLINT_EXECUTABLE}" ]; then
|
if [ -z "${SWIFTLINT_EXECUTABLE}" ]; then
|
||||||
if [ ! -z "${1}" ]; then
|
if [ ! -z "${1}" ]; then
|
||||||
readonly SWIFTLINT_EXECUTABLE=${1}
|
readonly SWIFTLINT_EXECUTABLE=${1}
|
||||||
else
|
elif [ ! -z "${PODS_ROOT}" ]; then
|
||||||
readonly SWIFTLINT_EXECUTABLE=${PODS_ROOT}/SwiftLint/swiftlint
|
readonly SWIFTLINT_EXECUTABLE=${PODS_ROOT}/SwiftLint/swiftlint
|
||||||
|
else
|
||||||
|
readonly SWIFTLINT_EXECUTABLE=${SRCROOT}/Pods/SwiftLint/swiftlint
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -46,8 +50,11 @@ fi
|
||||||
if [ ! -z "${FORCE_LINT}" ]; then
|
if [ ! -z "${FORCE_LINT}" ]; then
|
||||||
# Если задана переменная FORCE_LINT, то проверяем все файлы проекта
|
# Если задана переменная FORCE_LINT, то проверяем все файлы проекта
|
||||||
for SOURCE_DIR in ${SOURCES_DIRS}; do
|
for SOURCE_DIR in ${SOURCES_DIRS}; do
|
||||||
${SWIFTLINT_EXECUTABLE} autocorrect --path ${SOURCE_DIR} --config ${SWIFTLINT_CONFIG_PATH}
|
if [ ! -z "${AUTOCORRECT}" ]; then
|
||||||
${SWIFTLINT_EXECUTABLE} --path ${SOURCE_DIR} --config ${SWIFTLINT_CONFIG_PATH}
|
${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format "${SRCROOT}/${SOURCE_DIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} "${SRCROOT}/${SOURCE_DIR}"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
# Xcode упадет, если будем использовать большое количество Script Input Files,
|
# Xcode упадет, если будем использовать большое количество Script Input Files,
|
||||||
|
|
@ -56,19 +63,21 @@ else
|
||||||
# Создадим временный файл swiftlint_files с префиксом @ и в нем уже определим список файлов
|
# Создадим временный файл swiftlint_files с префиксом @ и в нем уже определим список файлов
|
||||||
# необходимых для линтовки :)
|
# необходимых для линтовки :)
|
||||||
|
|
||||||
lint_files_path="${SRCROOT}/build_phases/swiftlint_files"
|
lint_files_path=`mktemp`
|
||||||
|
|
||||||
# Если файл существует, то просто его очистим, если нет - создадим
|
|
||||||
> ${lint_files_path}
|
|
||||||
|
|
||||||
# Проходимся по папкам, которые требуют линтовки
|
# Проходимся по папкам, которые требуют линтовки
|
||||||
for SOURCE_DIR in ${SOURCES_DIRS}; do
|
for SOURCE_DIR in ${SOURCES_DIRS}; do
|
||||||
# Путь к папке репозитория
|
LINE_PREFIX="${SRCROOT}/"
|
||||||
path_prefix="`git rev-parse --show-toplevel`/"
|
|
||||||
|
pushd .
|
||||||
|
|
||||||
|
cd ${SRCROOT} # in case of runing script outside project folder (SPM)
|
||||||
|
|
||||||
# Отбираем файлы, которые были изменены или созданы
|
# Отбираем файлы, которые были изменены или созданы
|
||||||
source_unstaged_files=$(git diff --diff-filter=d --name-only --line-prefix=${path_prefix} ${SOURCE_DIR} | grep "\.swift$")
|
source_unstaged_files=$(git diff --diff-filter=d --name-only --line-prefix=${LINE_PREFIX} ${SOURCE_DIR} | grep "\.swift$")
|
||||||
source_staged_files=$(git diff --diff-filter=d --name-only --line-prefix=${path_prefix} --cached ${SOURCE_DIR} | grep "\.swift$")
|
source_staged_files=$(git diff --diff-filter=d --name-only --line-prefix=${LINE_PREFIX} --cached ${SOURCE_DIR} | grep "\.swift$")
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
if [ ! -z "${source_unstaged_files}" ]; then
|
if [ ! -z "${source_unstaged_files}" ]; then
|
||||||
echo "${source_unstaged_files}" >> ${lint_files_path}
|
echo "${source_unstaged_files}" >> ${lint_files_path}
|
||||||
|
|
@ -81,6 +90,9 @@ else
|
||||||
|
|
||||||
swiftlint_files_path="@${lint_files_path}"
|
swiftlint_files_path="@${lint_files_path}"
|
||||||
|
|
||||||
${SWIFTLINT_EXECUTABLE} autocorrect --path ${swiftlint_files_path} --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding
|
if [ ! -z "${AUTOCORRECT}" ]; then
|
||||||
${SWIFTLINT_EXECUTABLE} --path ${swiftlint_files_path} --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding
|
${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --fix --format --force-exclude --use-alternative-excluding ${swiftlint_files_path}
|
||||||
|
fi
|
||||||
|
|
||||||
|
${SWIFTLINT_EXECUTABLE} lint --config ${SWIFTLINT_CONFIG_PATH} --force-exclude --use-alternative-excluding ${swiftlint_files_path}
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
$appName = File.basename(Dir['../*.xcworkspace'].first, '.*')
|
$appName = File.basename(Dir['../*.xcworkspace'].first, '.*')
|
||||||
|
|
||||||
require_relative 'fastlane/touchlane/lib/touchlane'
|
require_relative 'fastlane/touchlane/lib/touchlane'
|
||||||
require_relative 'managers/managers'
|
|
||||||
|
|
||||||
# ugly hack to add support for custom storage
|
|
||||||
|
|
||||||
Match.module_eval do
|
|
||||||
def self.storage_modes
|
|
||||||
return %w(git google_cloud s3 local)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private_lane :installDependencies do |options|
|
private_lane :installDependencies do |options|
|
||||||
podsReposPath = File.expand_path "~/.cocoapods/repos/master/"
|
podsReposPath = File.expand_path "~/.cocoapods/repos/master/"
|
||||||
|
|
@ -21,7 +13,7 @@ private_lane :installDependencies do |options|
|
||||||
end
|
end
|
||||||
|
|
||||||
cocoapods(
|
cocoapods(
|
||||||
repo_update: true
|
try_repo_update_on_error: true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -54,18 +46,20 @@ private_lane :uploadToFirebase do |options|
|
||||||
release_notes_file: releaseNotesFile
|
release_notes_file: releaseNotesFile
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
upload_symbols_to_crashlytics(
|
|
||||||
gsp_path: get_google_services_plist_path(app_target_folder_name, configuration_type)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_to_app_store_using_options(options)
|
def upload_to_app_store_using_options(options, submit_for_review = false)
|
||||||
upload_to_app_store(
|
upload_to_app_store(
|
||||||
username: options[:username] || options[:apple_id],
|
username: options[:username] || options[:apple_id],
|
||||||
api_key_path: options[:api_key_path],
|
api_key_path: options[:api_key_path],
|
||||||
|
api_key: options[:api_key],
|
||||||
ipa: options[:ipa_path],
|
ipa: options[:ipa_path],
|
||||||
|
build_number: options[:ipa_path].nil? ? options[:buildNumber] : nil,
|
||||||
|
skip_binary_upload: options[:ipa_path].nil?,
|
||||||
|
skip_screenshots: true,
|
||||||
force: true, # skip metainfo prompt
|
force: true, # skip metainfo prompt
|
||||||
|
submit_for_review: submit_for_review,
|
||||||
|
submission_information: options[:submission_information],
|
||||||
skip_metadata: true,
|
skip_metadata: true,
|
||||||
team_id: options[:itc_team_id],
|
team_id: options[:itc_team_id],
|
||||||
dev_portal_team_id: options[:team_id],
|
dev_portal_team_id: options[:team_id],
|
||||||
|
|
@ -108,7 +102,7 @@ private_lane :buildConfiguration do |options|
|
||||||
options[:workspace] = options[:workspace] || File.expand_path("../#{options[:appName]}.xcworkspace")
|
options[:workspace] = options[:workspace] || File.expand_path("../#{options[:appName]}.xcworkspace")
|
||||||
|
|
||||||
configuration_type = Touchlane::ConfigurationType.from_lane_name(lane_name)
|
configuration_type = Touchlane::ConfigurationType.from_lane_name(lane_name)
|
||||||
options = fill_up_options_using_configuration_type(options, configuration_type)
|
options = fill_up_options_using_configuration_type(options, configuration_type, true)
|
||||||
|
|
||||||
generate_xcodeproj_if_needed(options)
|
generate_xcodeproj_if_needed(options)
|
||||||
|
|
||||||
|
|
@ -123,33 +117,33 @@ private_lane :buildConfiguration do |options|
|
||||||
installDependencies(options)
|
installDependencies(options)
|
||||||
|
|
||||||
run_code_generation_phase_if_needed(options)
|
run_code_generation_phase_if_needed(options)
|
||||||
generate_enabled_features_extension_if_needed(options)
|
|
||||||
|
|
||||||
if !(options[:uploadToFabric] || options[:uploadToAppStore])
|
if !(options[:uploadToFabric] || options[:uploadToAppStore])
|
||||||
options[:skip_package_ipa] = true
|
options[:skip_package_ipa] = true
|
||||||
|
|
||||||
sync_code_signing_using_options(options)
|
install_signing_identities(options)
|
||||||
|
|
||||||
buildArchive(options) # check build failures and static analysis
|
buildArchive(options) # check build failures and static analysis
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:uploadToFabric]
|
if options[:uploadToFabric]
|
||||||
sync_code_signing_using_options(options)
|
install_signing_identities(options)
|
||||||
addShield(options)
|
addShield(options)
|
||||||
buildArchive(options)
|
buildArchive(options)
|
||||||
|
|
||||||
uploadToFirebase(options)
|
uploadToFirebase(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:uploadToAppStore]
|
if options[:uploadToAppStore]
|
||||||
options[:compileBitcode] = options[:compileBitcode].nil? ? true : options[:compileBitcode]
|
|
||||||
options[:include_symbols] = options[:include_symbols].nil? ? true : options[:include_symbols]
|
options[:include_symbols] = options[:include_symbols].nil? ? true : options[:include_symbols]
|
||||||
|
|
||||||
sync_code_signing_using_options(options)
|
install_signing_identities(options)
|
||||||
|
|
||||||
buildArchive(options)
|
buildArchive(options)
|
||||||
upload_to_app_store_using_options(options)
|
upload_to_app_store_using_options(options, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
upload_symbols_to_crashlytics(
|
||||||
|
gsp_path: get_google_services_plist_path(options[:appName], configuration_type)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
private_lane :buildArchive do |options|
|
private_lane :buildArchive do |options|
|
||||||
|
|
@ -158,103 +152,72 @@ private_lane :buildArchive do |options|
|
||||||
|
|
||||||
icloudEnvironment = options[:iCloudContainerEnvironment] || ""
|
icloudEnvironment = options[:iCloudContainerEnvironment] || ""
|
||||||
exportOptions = icloudEnvironment.to_s.empty? ? {} : {iCloudContainerEnvironment: icloudEnvironment}
|
exportOptions = icloudEnvironment.to_s.empty? ? {} : {iCloudContainerEnvironment: icloudEnvironment}
|
||||||
exportOptions[:compileBitcode] = options[:compileBitcode] || false
|
|
||||||
|
|
||||||
lane_name = options[:lane_name]
|
lane_name = options[:lane_name]
|
||||||
configuration = options[:configuration]
|
configuration = options[:configuration]
|
||||||
xcodeproj_path = options[:xcodeproj_path]
|
xcodeproj_path = options[:xcodeproj_path]
|
||||||
xcode_version = options[:xcodeVersion]
|
|
||||||
|
|
||||||
cmd = 'system_profiler -json SPDeveloperToolsDataType'
|
xcodes(select_for_current_build_only: true)
|
||||||
cmd_result = `#{cmd}`
|
|
||||||
spdeveloperToolsDataType = JSON.parse(cmd_result)['SPDeveloperToolsDataType']
|
|
||||||
sortedSPDeveloperToolsDataType = spdeveloperToolsDataType.sort_by { |hash| hash['spdevtools_version'].split(' ').first.to_i } # sort by increasing the version of xcode
|
|
||||||
default_xcode_version = sortedSPDeveloperToolsDataType.last['spdevtools_version'] # take the largest version in format: "13.0 (13A5212g)"
|
|
||||||
default_xcode_version_number = default_xcode_version.split(' ').first # take version number
|
|
||||||
|
|
||||||
if configuration != "AppStore" # AppStore uses xcconfig choosen in Xcode
|
if configuration != "AppStore" # AppStore uses xcconfig choosen in Xcode
|
||||||
set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path)
|
set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
if xcode_version.nil?
|
|
||||||
xcversion(version: default_xcode_version_number)
|
|
||||||
else
|
|
||||||
xcversion(version: xcode_version)
|
|
||||||
end
|
|
||||||
|
|
||||||
gym(
|
gym(
|
||||||
clean: true,
|
clean: true,
|
||||||
workspace: options[:workspace],
|
workspace: options[:workspace],
|
||||||
scheme: options[:scheme],
|
scheme: options[:scheme],
|
||||||
archive_path: "./",
|
archive_path: "./#{$appName}.xcarchive",
|
||||||
output_directory: "./",
|
buildlog_path: "./",
|
||||||
output_name: options[:output_name],
|
output_name: options[:output_name],
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
export_method: options[:export_method],
|
export_method: options[:export_method],
|
||||||
export_options: exportOptions,
|
export_options: exportOptions,
|
||||||
skip_package_ipa: options[:skip_package_ipa],
|
skip_package_ipa: options[:skip_package_ipa],
|
||||||
include_symbols: options[:include_symbols] || false,
|
include_symbols: options[:include_symbols] || false
|
||||||
include_bitcode: options[:compileBitcode] || false,
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
lane :CreatePushCertificate do |options|
|
lane :SubmitForReview do |options|
|
||||||
configuration = get_configuration_for_type(options[:type] || "development")
|
configuration_type = Touchlane::ConfigurationType.from_type("appstore")
|
||||||
options = configuration.to_options.merge(options)
|
options = fill_up_options_using_configuration_type(options, configuration_type, false)
|
||||||
|
|
||||||
certificates_path = File.expand_path "../Certificates"
|
upload_to_app_store_using_options(options, true)
|
||||||
Dir.mkdir(certificates_path) unless File.directory?(certificates_path)
|
|
||||||
|
|
||||||
app_identifier = options[:app_identifier]
|
|
||||||
|
|
||||||
get_push_certificate(
|
|
||||||
development: options[:development].nil? ? true : options[:development],
|
|
||||||
generate_p12: true,
|
|
||||||
active_days_limit: 30, # create new certificate if old one will expire in 30 days
|
|
||||||
save_private_key: false,
|
|
||||||
app_identifier: (app_identifier.is_a? Array) ? app_identifier.first : app_identifier,
|
|
||||||
username: options[:username] || options[:apple_id],
|
|
||||||
team_id: options[:team_id],
|
|
||||||
p12_password: "123", # empty password won't work with Pusher
|
|
||||||
output_path: certificates_path
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
lane :SyncCodeSigning do |options|
|
lane :InstallDevelopmentSigningIdentities do |options|
|
||||||
configuration_type = Touchlane::ConfigurationType.from_type(options[:type])
|
configuration_type = Touchlane::ConfigurationType.from_type("development")
|
||||||
options = fill_up_options_using_configuration_type(options, configuration_type)
|
options = fill_up_options_using_configuration_type(options, configuration_type)
|
||||||
|
|
||||||
sync_code_signing_using_options(options)
|
install_signing_identities(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
lane :SyncSymbols do |options|
|
lane :RefreshProfiles do |options|
|
||||||
configuration = get_configuration_for_type(options[:type])
|
type = options[:type] || "development"
|
||||||
options = configuration.to_options.merge(options)
|
|
||||||
|
|
||||||
appName = options[:appName] || $appName
|
configuration_type = Touchlane::ConfigurationType.from_type(type)
|
||||||
|
options = fill_up_options_using_configuration_type(options, configuration_type)
|
||||||
|
|
||||||
xcodeproj_path = File.expand_path "../#{appName}.xcodeproj"
|
refresh_profiles(options)
|
||||||
|
end
|
||||||
|
|
||||||
version_number = options[:version] || "latest"
|
lane :ReplaceDevelopmentCertificate do |options|
|
||||||
build_number = options[:build_number]
|
configuration_type = Touchlane::ConfigurationType.from_type("development")
|
||||||
|
options = fill_up_options_using_configuration_type(options, configuration_type, true)
|
||||||
|
|
||||||
if configuration.type.is_app_store
|
replace_development_certificate(options)
|
||||||
download_dsyms(
|
end
|
||||||
username: options[:username],
|
|
||||||
app_identifier: options[:app_identifier].first,
|
|
||||||
team_id: options[:itc_team_id],
|
|
||||||
version: version_number,
|
|
||||||
build_number: build_number
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
app_target_folder_name = appName
|
lane :SyncAppStoreIdentities do |options|
|
||||||
|
configuration_type = Touchlane::ConfigurationType.from_type("appstore")
|
||||||
|
options = fill_up_options_using_configuration_type(options, configuration_type, true)
|
||||||
|
|
||||||
upload_symbols_to_crashlytics(
|
options[:readonly] = false
|
||||||
gsp_path: get_google_services_plist_path(app_target_folder_name, configuration.type)
|
sync_signing_identities(options)
|
||||||
)
|
end
|
||||||
|
|
||||||
clean_build_artifacts
|
lane :ManuallyUpdateCodeSigning do |options|
|
||||||
|
manually_update_code_signing(get_default_options.merge(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
private_lane :openKeychain do |options|
|
private_lane :openKeychain do |options|
|
||||||
|
|
@ -279,122 +242,78 @@ private_lane :openKeychain do |options|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
lane :ManuallyUpdateCodeSigning do |options|
|
def get_default_options
|
||||||
register_local_storage_for_match()
|
{
|
||||||
|
:git_url => get_signing_identities_path(),
|
||||||
require 'match'
|
:signing_identities_path => get_signing_identities_path(),
|
||||||
|
:storage_mode => Touchlane::LocalStorage::STORAGE_TYPE
|
||||||
storage_factory = lambda do
|
}
|
||||||
new_storage = Match::Storage.for_mode('local', { git_url: get_signing_identities_path() })
|
|
||||||
new_storage.download
|
|
||||||
return new_storage
|
|
||||||
end
|
|
||||||
|
|
||||||
encryption_factory = lambda do |stor|
|
|
||||||
new_encryption = Match::Encryption.for_storage_mode('local', { working_directory: stor.working_directory })
|
|
||||||
new_encryption.decrypt_files
|
|
||||||
return new_encryption
|
|
||||||
end
|
|
||||||
|
|
||||||
get_all_files = lambda do |stor|
|
|
||||||
Dir[File.join(stor.working_directory, "**", "*.{cer,p12,mobileprovision}")]
|
|
||||||
end
|
|
||||||
|
|
||||||
storage = storage_factory.call
|
|
||||||
encryption = encryption_factory.call(storage)
|
|
||||||
old_files = get_all_files.call(storage)
|
|
||||||
|
|
||||||
sh("open #{storage.working_directory}")
|
|
||||||
|
|
||||||
# we are not using prompt() since it requires non-empty input which is not a case for Enter (\n)
|
|
||||||
puts "Enter any key when you're done"
|
|
||||||
STDIN.gets
|
|
||||||
|
|
||||||
encryption.encrypt_files
|
|
||||||
|
|
||||||
files_to_commit = get_all_files.call(storage)
|
|
||||||
old_directory = storage.working_directory
|
|
||||||
storage.save_changes!(files_to_commit: files_to_commit)
|
|
||||||
|
|
||||||
|
|
||||||
# need to check, because saving changes with delete is another function (update repo if needed)
|
|
||||||
files_diff = old_files - files_to_commit
|
|
||||||
|
|
||||||
# match can not work with both save/delete functionality `You can't provide both files_to_delete and files_to_commit right now`
|
|
||||||
# to avoid this we use storage twice if needed
|
|
||||||
|
|
||||||
if files_diff.length > 0
|
|
||||||
storage = storage_factory.call
|
|
||||||
encryption = encryption_factory.call(storage)
|
|
||||||
|
|
||||||
files_to_delete = files_diff.map do |file|
|
|
||||||
old_file = file
|
|
||||||
old_file.slice! old_directory
|
|
||||||
new_file = File.join(storage.working_directory, old_file)
|
|
||||||
File.delete(new_file) if File.exist?(new_file)
|
|
||||||
file = new_file
|
|
||||||
end
|
|
||||||
|
|
||||||
encryption.encrypt_files
|
|
||||||
storage.save_changes!(files_to_delete: files_to_delete)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def sync_code_signing_using_options(options)
|
|
||||||
register_local_storage_for_match()
|
|
||||||
|
|
||||||
match(
|
|
||||||
app_identifier: options[:app_identifier],
|
|
||||||
username: options[:username] || options[:apple_id],
|
|
||||||
api_key_path: options[:api_key_path],
|
|
||||||
team_id: options[:team_id],
|
|
||||||
type: options[:type],
|
|
||||||
readonly: options[:readonly].nil? ? true : options[:readonly],
|
|
||||||
storage_mode: "local",
|
|
||||||
# we can't pass signing_identities_path as parameter name since params is hardcoded in match/runner.rb
|
|
||||||
git_url: get_signing_identities_path(),
|
|
||||||
skip_docs: true,
|
|
||||||
keychain_name: options[:keychain_name],
|
|
||||||
keychain_password: options[:keychain_password]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def register_local_storage_for_match
|
|
||||||
Match::Storage.register_backend(type: 'local', storage_class: Touchlane::LocalStorage)
|
|
||||||
Match::Encryption.register_backend(type: 'local', encryption_class: Match::Encryption::OpenSSL)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_signing_identities_path
|
def get_signing_identities_path
|
||||||
File.expand_path "../EncryptedSigningIdentities"
|
File.expand_path "../EncryptedSigningIdentities"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fill_up_options_using_configuration_type(options, configuration_type)
|
def fill_up_options_using_configuration_type(options, configuration_type, keychain_password_required = false)
|
||||||
configuration = get_configuration_for_type(configuration_type.type)
|
configuration = get_configuration_for_type(configuration_type.type)
|
||||||
|
|
||||||
if configuration_type.is_app_store || configuration_type.is_development
|
api_key_path = File.expand_path "../fastlane/#{configuration_type.prefix}_api_key.json"
|
||||||
api_key_path = "fastlane/#{configuration_type.prefix}_api_key.json"
|
is_api_key_file_exists = File.exists?(api_key_path)
|
||||||
else
|
|
||||||
api_key_path = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
default_options = {:api_key_path => api_key_path}
|
# default_options required to be empty due to the possibility of skipping the configuration type check below
|
||||||
|
|
||||||
|
default_options = get_default_options
|
||||||
|
|
||||||
|
# Check whether configuration type is required to configure one of api key parameters or not
|
||||||
|
|
||||||
|
if configuration_type.is_app_store || configuration_type.is_development
|
||||||
|
|
||||||
|
# Check whether API key JSON file exists or not
|
||||||
|
|
||||||
|
if is_api_key_file_exists
|
||||||
|
|
||||||
|
# If exists then fill in all required information through api_key_path parameter
|
||||||
|
# and set a value to an options` parameter respectively
|
||||||
|
|
||||||
|
default_options[:api_key_path] = api_key_path
|
||||||
|
else
|
||||||
|
|
||||||
|
# If doesn't exist then build api_key parameter through app_store_connect_api_key action
|
||||||
|
# and set a value to an options` parameter respectively also
|
||||||
|
|
||||||
|
default_options[:api_key] = get_app_store_connect_api_key()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
default_options
|
default_options
|
||||||
.merge(configuration.to_options)
|
.merge(configuration.to_options)
|
||||||
.merge(get_keychain_options(options))
|
.merge(get_keychain_options(options, keychain_password_required))
|
||||||
.merge(options)
|
.merge(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_keychain_options(options)
|
def get_app_store_connect_api_key()
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
api_key_parameters = JSON.parse(ENV['API_KEY_JSON'])
|
||||||
|
|
||||||
|
return app_store_connect_api_key(
|
||||||
|
key_id: api_key_parameters['key_id'],
|
||||||
|
issuer_id: api_key_parameters['issuer_id'],
|
||||||
|
key_content: api_key_parameters['key'],
|
||||||
|
duration: api_key_parameters['duration'],
|
||||||
|
in_house: api_key_parameters['in_house']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_keychain_options(options, keychain_password_required = false)
|
||||||
keychain_name = options[:keychain_name]
|
keychain_name = options[:keychain_name]
|
||||||
keychain_password = options[:keychain_password]
|
keychain_password = options[:keychain_password]
|
||||||
|
|
||||||
if is_ci?
|
if is_ci?
|
||||||
keychain_name = keychain_name || "ci.keychain"
|
keychain_name = keychain_name || "ci.keychain"
|
||||||
keychain_password = keychain_password || ""
|
keychain_password = keychain_password || ""
|
||||||
else
|
elsif keychain_password_required && keychain_password.nil?
|
||||||
keychain_password = keychain_password || prompt(
|
keychain_password = prompt(
|
||||||
text: "Please enter your keychain password (account password): ",
|
text: "Please enter your keychain password (account password): ",
|
||||||
secure_text: true
|
secure_text: true
|
||||||
)
|
)
|
||||||
|
|
@ -413,34 +332,6 @@ def get_google_services_plist_path(app_target_folder_name, configuration_type)
|
||||||
File.expand_path "../#{app_target_folder_name}/Resources/GoogleService-Info.plist"
|
File.expand_path "../#{app_target_folder_name}/Resources/GoogleService-Info.plist"
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_enabled_features_extension_if_needed(options)
|
|
||||||
app_target_folder_name = options[:appName] || $appName
|
|
||||||
|
|
||||||
project_enabled_features_file_path = File.expand_path "../#{app_target_folder_name}/Resources/Features/Enabled.swift"
|
|
||||||
build_settings_file_path = File.expand_path "../common/build_settings.yaml"
|
|
||||||
|
|
||||||
unless is_feature_extension_needed?(options, project_enabled_features_file_path)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if options[:features].nil?
|
|
||||||
builder_features_list = [] # If Enabled.swift exists and features option is nil we need to create empty extension to avoid unexpected features
|
|
||||||
else
|
|
||||||
builder_features_list = options[:features]
|
|
||||||
.split(",").map { |feature_name| feature_name.strip } # [ "Feature1", "Feature2", "Feature3" ]
|
|
||||||
end
|
|
||||||
|
|
||||||
build_settings_features_list = Managers::FileManager.load_from_file_YAML(build_settings_file_path)["features"]
|
|
||||||
|
|
||||||
enabled_features_extension = Touchlane::Features.generate_enabled_features_extension(builder_features_list, build_settings_features_list)
|
|
||||||
|
|
||||||
Managers::FileManager.save_data_to_file(project_enabled_features_file_path, enabled_features_extension)
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_feature_extension_needed?(options, project_enabled_features_file_path)
|
|
||||||
!options[:features].nil? || File.exists?(project_enabled_features_file_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path)
|
def set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path)
|
||||||
require 'xcodeproj'
|
require 'xcodeproj'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3f81529c1425a74f43fe84fe8befffd81a442cc7
|
Subproject commit a8f072f216684bd7f5563c0211f71d6637a5f92d
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
require 'json'
|
||||||
|
require 'mustache'
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
require_relative '../fastlane/touchlane/lib/touchlane/configuration_type'
|
||||||
|
|
||||||
|
class String
|
||||||
|
def in_current_dir
|
||||||
|
"#{__dir__}/#{self}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ConfigRenderer
|
||||||
|
class XCConfigKeys
|
||||||
|
DEVELOPMENT_TEAM = "DEVELOPMENT_TEAM"
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "PRODUCT_BUNDLE_IDENTIFIER"
|
||||||
|
CODE_SIGN_STYLE = "CODE_SIGN_STYLE"
|
||||||
|
end
|
||||||
|
|
||||||
|
INHERITED_PREFIX = "$(inherited)"
|
||||||
|
|
||||||
|
private_constant :INHERITED_PREFIX
|
||||||
|
|
||||||
|
def initialize(configurations_file_path, build_parameters_path, configs_folder_name)
|
||||||
|
@configurations_file_path = configurations_file_path
|
||||||
|
@build_parameters_path = build_parameters_path
|
||||||
|
@configs_folder_name = configs_folder_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_xconfigs
|
||||||
|
temp_configs_data_file_path = "configs_data.json".in_current_dir
|
||||||
|
generator_path = "build_options_helper/helper.py".in_current_dir
|
||||||
|
template_path = "target_xcconfig.mustache".in_current_dir
|
||||||
|
|
||||||
|
# Create config directory if needed
|
||||||
|
Dir.mkdir(@configs_folder_name) unless Dir.exist?(@configs_folder_name)
|
||||||
|
|
||||||
|
# Call python script and generate configs to config file
|
||||||
|
system("python #{generator_path} -bp #{@build_parameters_path} -o #{__dir__} -r ios_build_settings -p ios")
|
||||||
|
|
||||||
|
# Open settings, configurations and template files
|
||||||
|
target_xcconfig_tempate = File.read(template_path)
|
||||||
|
$configurations = YAML.load(File.open(@configurations_file_path))
|
||||||
|
$config_types = $configurations["types"]
|
||||||
|
|
||||||
|
targets = $configurations["targets"]
|
||||||
|
|
||||||
|
# Run through all target in project
|
||||||
|
targets.each do |target_name, target|
|
||||||
|
|
||||||
|
# Need open everytime, because script make some changes only for this target
|
||||||
|
configs = JSON.load(File.open(temp_configs_data_file_path))
|
||||||
|
|
||||||
|
# Run through all configs
|
||||||
|
configs.each do |config|
|
||||||
|
|
||||||
|
# Take default values
|
||||||
|
distribution_type = Touchlane::ConfigurationType.from_account_type(config["account_type"]).type
|
||||||
|
properties = target[distribution_type]
|
||||||
|
|
||||||
|
# Add properties from settings file
|
||||||
|
properties.each do |key, value|
|
||||||
|
if config["xcconfig_options"].any? { |option| key == option["key"] }
|
||||||
|
config["xcconfig_options"].map! { |option| key == option["key"] ? merge_config_data(key, option["value"], value) : option }
|
||||||
|
else
|
||||||
|
config["xcconfig_options"].append(config_option(key, value))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add missing properties if needed
|
||||||
|
config["xcconfig_options"].concat(generate_missing_properties(target_name, properties, distribution_type))
|
||||||
|
|
||||||
|
# Create settings pack
|
||||||
|
config_data = {
|
||||||
|
"target_name": target_name,
|
||||||
|
"abstract_targets_prefix": target["abstract_targets_prefix"],
|
||||||
|
"configuration": config
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create file for every setting in loop
|
||||||
|
File.open(@configs_folder_name + "/" + target_name + config["name"] + ".xcconfig", 'w') { |file|
|
||||||
|
file.puts(Mustache.render(target_xcconfig_tempate, config_data))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove config file, it's trash
|
||||||
|
File.delete(temp_configs_data_file_path) if File.exist?(temp_configs_data_file_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Make tuple of key and value become mustache template element
|
||||||
|
def config_option(key, value)
|
||||||
|
return { "key" => key, "value" => value }
|
||||||
|
end
|
||||||
|
|
||||||
|
def merge_config_data(key, config_value, settings_value)
|
||||||
|
if settings_value.start_with?(INHERITED_PREFIX)
|
||||||
|
new_value = settings_value.split(INHERITED_PREFIX).last
|
||||||
|
return config_option(key, config_value + new_value)
|
||||||
|
else
|
||||||
|
return config_option(key, settings_value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fetch development team from build configuration
|
||||||
|
def fetch_development_team(development_team_key, distribution_type)
|
||||||
|
current_config = $config_types[distribution_type]
|
||||||
|
team_value = current_config["team_id"]
|
||||||
|
return config_option(development_team_key, team_value)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Generate missing properties if needed
|
||||||
|
def generate_missing_properties(target_name, properties, distribution_type)
|
||||||
|
result = []
|
||||||
|
|
||||||
|
# Bundle_id_key should be among the properties (required by fastlane)
|
||||||
|
unless properties.key?(XCConfigKeys::PRODUCT_BUNDLE_IDENTIFIER)
|
||||||
|
raise "#{target_name}: Could not find #{XCConfigKeys::PRODUCT_BUNDLE_IDENTIFIER} for #{distribution_type}"
|
||||||
|
end
|
||||||
|
|
||||||
|
unless properties.key?(XCConfigKeys::DEVELOPMENT_TEAM)
|
||||||
|
result.append(fetch_development_team(XCConfigKeys::DEVELOPMENT_TEAM, distribution_type))
|
||||||
|
end
|
||||||
|
|
||||||
|
unless properties.key?(XCConfigKeys::CODE_SIGN_STYLE)
|
||||||
|
result.append(config_option(XCConfigKeys::CODE_SIGN_STYLE, "Manual"))
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -5,10 +5,12 @@ targets:
|
||||||
PRODUCT_BUNDLE_IDENTIFIER: "ru.touchin.testproject"
|
PRODUCT_BUNDLE_IDENTIFIER: "ru.touchin.testproject"
|
||||||
PROVISIONING_PROFILE_SPECIFIER: "TestProjectDev"
|
PROVISIONING_PROFILE_SPECIFIER: "TestProjectDev"
|
||||||
CODE_SIGN_ENTITLEMENTS: "TestProject/Standard.entitlements"
|
CODE_SIGN_ENTITLEMENTS: "TestProject/Standard.entitlements"
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS: "$(inherited) DEBUG_MENU"
|
||||||
enterprise:
|
enterprise:
|
||||||
PRODUCT_BUNDLE_IDENTIFIER: "com.touchin.testproject"
|
PRODUCT_BUNDLE_IDENTIFIER: "com.touchin.testproject"
|
||||||
PROVISIONING_PROFILE_SPECIFIER: "TestProjectEnterprise"
|
PROVISIONING_PROFILE_SPECIFIER: "TestProjectEnterprise"
|
||||||
CODE_SIGN_ENTITLEMENTS: "TestProject/Enterprise.entitlements"
|
CODE_SIGN_ENTITLEMENTS: "TestProject/Enterprise.entitlements"
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS: "$(inherited) DEBUG_MENU"
|
||||||
appstore:
|
appstore:
|
||||||
PRODUCT_BUNDLE_IDENTIFIER: "ru.customer.domain"
|
PRODUCT_BUNDLE_IDENTIFIER: "ru.customer.domain"
|
||||||
PROVISIONING_PROFILE_SPECIFIER: "TestProjectAppStore"
|
PROVISIONING_PROFILE_SPECIFIER: "TestProjectAppStore"
|
||||||
|
|
@ -16,13 +18,13 @@ targets:
|
||||||
|
|
||||||
types:
|
types:
|
||||||
development:
|
development:
|
||||||
apple_id: "apple@touchin.ru"
|
apple_id: "iosdev@touchin.ru"
|
||||||
team_id: "**********"
|
team_id: "**********"
|
||||||
itc_team_id: "**********"
|
itc_team_id: "**********"
|
||||||
enterprise:
|
enterprise:
|
||||||
apple_id: "enterpriseapple@touchin.ru"
|
apple_id: "enterpriseapple@touchin.ru"
|
||||||
team_id: "**********"
|
team_id: "**********"
|
||||||
appstore:
|
appstore:
|
||||||
apple_id: "apple@touchin.ru"
|
apple_id: "iosdev@touchin.ru"
|
||||||
team_id: "**********"
|
team_id: "**********"
|
||||||
itc_team_id: "**********"
|
itc_team_id: "**********"
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
require 'json'
|
require_relative "config_renderer"
|
||||||
require 'mustache'
|
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Usage: render_xcconfigs.rb <configurations.yaml> <build_parameters.yaml> [<ouptut folder>]
|
# Usage: render_xcconfigs.rb <configurations.yaml> <build_parameters.yaml> [<ouptut folder>]
|
||||||
#
|
#
|
||||||
|
|
@ -10,122 +7,9 @@ require 'yaml'
|
||||||
# It is recommended to remove old .xcconfig files before running this script.
|
# It is recommended to remove old .xcconfig files before running this script.
|
||||||
#
|
#
|
||||||
|
|
||||||
class String
|
|
||||||
def in_current_dir
|
|
||||||
"#{__dir__}/#{self}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Input files paths
|
# Input files paths
|
||||||
configurations_file_path = ARGV[0]
|
configurations_file_path = ARGV[0]
|
||||||
temp_configs_data_file_path = "configs_data.json".in_current_dir
|
|
||||||
generator_path = "build_options_helper/helper.py".in_current_dir
|
|
||||||
template_path = "target_xcconfig.mustache".in_current_dir
|
|
||||||
build_parameters_path = ARGV[1]
|
build_parameters_path = ARGV[1]
|
||||||
configs_folder_name = ARGV[2] || "TargetConfigurations"
|
configs_folder_name = ARGV[2] || "TargetConfigurations"
|
||||||
|
|
||||||
# Create config directory if needed
|
ConfigRenderer.new(configurations_file_path, build_parameters_path, configs_folder_name).render_xconfigs()
|
||||||
Dir.mkdir(configs_folder_name) unless Dir.exist?(configs_folder_name)
|
|
||||||
|
|
||||||
# Call python script and generate configs to config file
|
|
||||||
system("python #{generator_path} -bp #{build_parameters_path} -o #{__dir__} -r ios_build_settings -p ios")
|
|
||||||
|
|
||||||
# Open settings, configurations and template files
|
|
||||||
target_xcconfig_tempate = File.read(template_path)
|
|
||||||
$configurations = YAML.load(File.open(configurations_file_path))
|
|
||||||
$config_types = $configurations["types"]
|
|
||||||
|
|
||||||
# Set global property
|
|
||||||
targets = $configurations["targets"]
|
|
||||||
|
|
||||||
# Make tuple of key and value become mustache template element
|
|
||||||
def config_option(key, value)
|
|
||||||
return { "key" => key, "value" => value }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Maps lane prefix to distribution type
|
|
||||||
def distribution_type_of(account_type)
|
|
||||||
case account_type
|
|
||||||
when "Standard"
|
|
||||||
"development"
|
|
||||||
when "Enterprise"
|
|
||||||
"enterprise"
|
|
||||||
when "AppStore"
|
|
||||||
"appstore"
|
|
||||||
else
|
|
||||||
raise "Error: Unsupported distribution type #{account_type}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Fetch development team from build configuration
|
|
||||||
def fetch_development_team(development_team_key, distribution_type)
|
|
||||||
current_config = $config_types[distribution_type]
|
|
||||||
team_value = current_config["team_id"]
|
|
||||||
return config_option(development_team_key, team_value)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Generate missing properties if needed
|
|
||||||
def generate_missing_properties(target_name, properties, distribution_type)
|
|
||||||
result = []
|
|
||||||
development_team_key = "DEVELOPMENT_TEAM"
|
|
||||||
bundle_id_key = "PRODUCT_BUNDLE_IDENTIFIER"
|
|
||||||
code_sign_style_key = "CODE_SIGN_STYLE"
|
|
||||||
|
|
||||||
# Bundle_id_key should be among the properties (required by fastlane)
|
|
||||||
unless properties.key?(bundle_id_key)
|
|
||||||
raise "#{target_name}: Could not find #{bundle_id_key} for #{distribution_type}"
|
|
||||||
end
|
|
||||||
|
|
||||||
unless properties.key?(development_team_key)
|
|
||||||
result.append(fetch_development_team(development_team_key, distribution_type))
|
|
||||||
end
|
|
||||||
|
|
||||||
unless properties.key?(code_sign_style_key)
|
|
||||||
result.append(config_option(code_sign_style_key, "Manual"))
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
# Run through all target in project
|
|
||||||
targets.each do |target_name, target|
|
|
||||||
|
|
||||||
# Need open everytime, because script make some changes only for this target
|
|
||||||
configs = JSON.load(File.open(temp_configs_data_file_path))
|
|
||||||
|
|
||||||
# Run through all configs
|
|
||||||
configs.each do |config|
|
|
||||||
|
|
||||||
# Take default values
|
|
||||||
distribution_type = distribution_type_of(config["account_type"])
|
|
||||||
properties = target[distribution_type]
|
|
||||||
|
|
||||||
# Add properties from settings file
|
|
||||||
properties.each do |key, value|
|
|
||||||
if config["xcconfig_options"].any? { |option| key == option["key"] }
|
|
||||||
config["xcconfig_options"].map! { |option| key == option["key"] ? config_option(key, value) : option }
|
|
||||||
else
|
|
||||||
config["xcconfig_options"].append(config_option(key, value))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add missing properties if needed
|
|
||||||
config["xcconfig_options"].concat(generate_missing_properties(target_name, properties, distribution_type))
|
|
||||||
|
|
||||||
# Create settings pack
|
|
||||||
config_data = {
|
|
||||||
"target_name": target_name,
|
|
||||||
"abstract_targets_prefix": target["abstract_targets_prefix"],
|
|
||||||
"configuration": config
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create file for every setting in loop
|
|
||||||
File.open(configs_folder_name + "/" + target_name + config["name"] + ".xcconfig", 'w') { |file|
|
|
||||||
file.puts(Mustache.render(target_xcconfig_tempate, config_data))
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Remove config file, it's trash
|
|
||||||
File.delete(temp_configs_data_file_path) if File.exist?(temp_configs_data_file_path)
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ module Touchlane
|
||||||
class LocalStorage < Match::Storage::Interface
|
class LocalStorage < Match::Storage::Interface
|
||||||
attr_accessor :signing_identities_path
|
attr_accessor :signing_identities_path
|
||||||
|
|
||||||
|
STORAGE_TYPE = "local"
|
||||||
|
|
||||||
def self.configure(params)
|
def self.configure(params)
|
||||||
return self.new(
|
return self.new(
|
||||||
# we can't pass signing_identities_path since params is hardcoded in match/runner.rb
|
# we can't pass signing_identities_path since params is hardcoded in match/runner.rb
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
require 'match'
|
||||||
|
|
||||||
|
# ugly hack to add support for custom storage
|
||||||
|
|
||||||
|
Match.module_eval do
|
||||||
|
def self.storage_modes
|
||||||
|
return ['git', 'google_cloud' 's3', Touchlane::LocalStorage::STORAGE_TYPE]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_local_storage_for_match
|
||||||
|
storage_type = Touchlane::LocalStorage::STORAGE_TYPE
|
||||||
|
|
||||||
|
Match::Storage.register_backend(type: storage_type, storage_class: Touchlane::LocalStorage)
|
||||||
|
Match::Encryption.register_backend(type: storage_type, encryption_class: Match::Encryption::OpenSSL)
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
module Touchlane
|
module Touchlane
|
||||||
require_relative "touchlane/configuration_type"
|
require_relative "touchlane/configuration_type"
|
||||||
require_relative "touchlane/configuration"
|
require_relative "touchlane/configuration"
|
||||||
require_relative "touchlane/features"
|
require_relative "match/storage/local_storage_register"
|
||||||
require_relative "match/storage/local_storage"
|
require_relative "touchlane/actions/sync_signing_identities"
|
||||||
|
require_relative "touchlane/actions/refresh_profiles"
|
||||||
|
require_relative "touchlane/actions/replace_development_certificate"
|
||||||
|
require_relative "touchlane/actions/manually_update_code_signing"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
require 'match'
|
||||||
|
require_relative '../../match/storage/local_storage'
|
||||||
|
|
||||||
|
def manually_update_code_signing(options)
|
||||||
|
register_local_storage_for_match()
|
||||||
|
|
||||||
|
storage_factory = lambda do
|
||||||
|
new_storage = Match::Storage.from_params(options)
|
||||||
|
new_storage.download
|
||||||
|
return new_storage
|
||||||
|
end
|
||||||
|
|
||||||
|
encryption_factory = lambda do |stor|
|
||||||
|
new_encryption = Match::Encryption.for_storage_mode(options[:storage_mode], { working_directory: stor.working_directory })
|
||||||
|
new_encryption.decrypt_files
|
||||||
|
return new_encryption
|
||||||
|
end
|
||||||
|
|
||||||
|
get_all_files = lambda do |stor|
|
||||||
|
Dir[File.join(stor.working_directory, "**", "*.{cer,p12,mobileprovision}")]
|
||||||
|
end
|
||||||
|
|
||||||
|
storage = storage_factory.call
|
||||||
|
encryption = encryption_factory.call(storage)
|
||||||
|
old_files = get_all_files.call(storage)
|
||||||
|
|
||||||
|
sh("open #{storage.working_directory}")
|
||||||
|
|
||||||
|
# we are not using prompt() since it requires non-empty input which is not a case for Enter (\n)
|
||||||
|
puts "Enter any key when you're done"
|
||||||
|
STDIN.gets
|
||||||
|
|
||||||
|
encryption.encrypt_files
|
||||||
|
|
||||||
|
files_to_commit = get_all_files.call(storage)
|
||||||
|
old_directory = storage.working_directory
|
||||||
|
storage.save_changes!(files_to_commit: files_to_commit)
|
||||||
|
|
||||||
|
|
||||||
|
# need to check, because saving changes with delete is another function (update repo if needed)
|
||||||
|
files_diff = old_files - files_to_commit
|
||||||
|
|
||||||
|
# match can not work with both save/delete functionality `You can't provide both files_to_delete and files_to_commit right now`
|
||||||
|
# to avoid this we use storage twice if needed
|
||||||
|
|
||||||
|
if files_diff.length > 0
|
||||||
|
storage = storage_factory.call
|
||||||
|
encryption = encryption_factory.call(storage)
|
||||||
|
|
||||||
|
files_to_delete = files_diff.map do |file|
|
||||||
|
old_file = file
|
||||||
|
old_file.slice! old_directory
|
||||||
|
new_file = File.join(storage.working_directory, old_file)
|
||||||
|
File.delete(new_file) if File.exist?(new_file)
|
||||||
|
file = new_file
|
||||||
|
end
|
||||||
|
|
||||||
|
encryption.encrypt_files
|
||||||
|
storage.save_changes!(files_to_delete: files_to_delete)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
require 'match'
|
||||||
|
require 'fastlane_core'
|
||||||
|
require 'Spaceship'
|
||||||
|
|
||||||
|
def refresh_profiles(options)
|
||||||
|
register_local_storage_for_match()
|
||||||
|
|
||||||
|
profiles_tmp_dir = Dir.mktmpdir
|
||||||
|
|
||||||
|
unless options[:cert_id]
|
||||||
|
cert_type = Match.cert_type_sym(options[:type])
|
||||||
|
|
||||||
|
storage = Match::Storage.from_params(options)
|
||||||
|
storage.download
|
||||||
|
|
||||||
|
output_dir_certs = File.join(storage.prefixed_working_directory, "certs", cert_type.to_s)
|
||||||
|
|
||||||
|
matched_certs = Dir.glob("*.cer", base: output_dir_certs)
|
||||||
|
|
||||||
|
if matched_certs.empty?
|
||||||
|
FastlaneCore::UI.error("Unable to locate certificate to upate profiles")
|
||||||
|
raise "No certificates found at #{output_dir_certs}"
|
||||||
|
end
|
||||||
|
|
||||||
|
if matched_certs.length > 1
|
||||||
|
options[:cert_id] = File.basename(FastlaneCore::UI.select("Please select the certificate", matched_certs), ".cer")
|
||||||
|
else
|
||||||
|
options[:cert_id] = File.basename(matched_certs.first, ".cer")
|
||||||
|
end
|
||||||
|
|
||||||
|
if options[:cert_path].nil? && options[:p12_path].nil?
|
||||||
|
encryption = Match::Encryption.for_storage_mode(options[:storage_mode], { working_directory: storage.working_directory })
|
||||||
|
encryption.decrypt_files
|
||||||
|
|
||||||
|
tmp_certs_dir = Dir.mktmpdir
|
||||||
|
|
||||||
|
cer_file_name = "#{options[:cert_id]}.cer"
|
||||||
|
cert_path = File.join(output_dir_certs, cer_file_name)
|
||||||
|
options[:cert_path] = File.join(tmp_certs_dir, cer_file_name)
|
||||||
|
|
||||||
|
p12_file_name = "#{options[:cert_id]}.p12"
|
||||||
|
p12_path = File.join(output_dir_certs, p12_file_name)
|
||||||
|
options[:p12_path] = File.join(tmp_certs_dir, p12_file_name)
|
||||||
|
|
||||||
|
IO.copy_stream(cert_path, options[:cert_path])
|
||||||
|
IO.copy_stream(p12_path, options[:p12_path])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
app_identifier = options[:app_identifier]
|
||||||
|
|
||||||
|
Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.from_json_file(options[:api_key_path])
|
||||||
|
|
||||||
|
if app_identifier.is_a? Array
|
||||||
|
app_identifier.each { |app_id| refresh_profile_for_app(options, app_id, profiles_tmp_dir) }
|
||||||
|
else
|
||||||
|
refresh_profile_for_app(options, app_identifier, profiles_tmp_dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def refresh_profile_for_app(options, app_id, profiles_tmp_dir)
|
||||||
|
provisioning_name = Fastlane::Actions.lane_context[Touchlane::SharedValues::TOUCH_BUNDLE_ID_PROFILE_NAME_MAPPING][app_id]
|
||||||
|
|
||||||
|
profiles = Spaceship::ConnectAPI::Profile.all(filter: { name: provisioning_name })
|
||||||
|
|
||||||
|
if profiles.empty?
|
||||||
|
sigh_for_app(options, app_id, provisioning_name, profiles_tmp_dir)
|
||||||
|
else
|
||||||
|
FastlaneCore::UI.important("Did find existing profile #{provisioning_name}. Removing it from dev portal.")
|
||||||
|
|
||||||
|
profiles.each { |profile| profile.delete! if profile.name == provisioning_name }
|
||||||
|
sigh_for_app(options, app_id, provisioning_name, profiles_tmp_dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
Match::Importer.new.import_cert(
|
||||||
|
options,
|
||||||
|
cert_path: options[:cert_path],
|
||||||
|
p12_path: options[:p12_path],
|
||||||
|
profile_path: lane_context[Fastlane::Actions::SharedValues::SIGH_PROFILE_PATH]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sigh_for_app(options, app_id, provisioning_name, profiles_tmp_dir)
|
||||||
|
sigh(
|
||||||
|
app_identifier: app_id,
|
||||||
|
development: options[:development],
|
||||||
|
username: options[:username] || options[:apple_id],
|
||||||
|
api_key_path: options[:api_key_path],
|
||||||
|
api_key: options[:api_key],
|
||||||
|
team_id: options[:team_id],
|
||||||
|
provisioning_name: provisioning_name,
|
||||||
|
output_path: profiles_tmp_dir,
|
||||||
|
cert_id: options[:cert_id],
|
||||||
|
force: true # will also add all available devices to this profile
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
def replace_development_certificate(options)
|
||||||
|
register_local_storage_for_match()
|
||||||
|
|
||||||
|
certs_path_tmp_dir = Dir.mktmpdir
|
||||||
|
|
||||||
|
cert(
|
||||||
|
development: true,
|
||||||
|
username: options[:username] || options[:apple_id],
|
||||||
|
api_key_path: options[:api_key_path],
|
||||||
|
api_key: options[:api_key],
|
||||||
|
team_id: options[:team_id],
|
||||||
|
output_path: certs_path_tmp_dir,
|
||||||
|
keychain_password: options[:keychain_password]
|
||||||
|
)
|
||||||
|
|
||||||
|
options[:cert_id] = lane_context[Fastlane::Actions::SharedValues::CERT_CERTIFICATE_ID]
|
||||||
|
options[:cert_path] = lane_context[Fastlane::Actions::SharedValues::CERT_FILE_PATH]
|
||||||
|
options[:p12_path] = File.join(File.dirname(options[:cert_path]), "#{options[:cert_id]}.p12")
|
||||||
|
options[:readonly] = false
|
||||||
|
|
||||||
|
refresh_profiles(options)
|
||||||
|
|
||||||
|
sh("open #{certs_path_tmp_dir}")
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
def install_signing_identities(options)
|
||||||
|
readonly_options = options
|
||||||
|
readonly_options[:readonly] = true
|
||||||
|
|
||||||
|
sync_signing_identities(readonly_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sync_signing_identities(options)
|
||||||
|
register_local_storage_for_match()
|
||||||
|
|
||||||
|
match(
|
||||||
|
app_identifier: options[:app_identifier],
|
||||||
|
username: options[:username] || options[:apple_id],
|
||||||
|
api_key_path: options[:api_key_path],
|
||||||
|
api_key: options[:api_key],
|
||||||
|
team_id: options[:team_id],
|
||||||
|
type: options[:type],
|
||||||
|
readonly: options[:readonly].nil? ? true : options[:readonly],
|
||||||
|
storage_mode: options[:storage_mode],
|
||||||
|
# we can't pass signing_identities_path as parameter name since params is hardcoded in match/runner.rb
|
||||||
|
git_url: options[:signing_identities_path] || options[:git_url],
|
||||||
|
skip_docs: true,
|
||||||
|
keychain_name: options[:keychain_name],
|
||||||
|
keychain_password: options[:keychain_password]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
require "yaml"
|
require "yaml"
|
||||||
|
|
||||||
module Touchlane
|
module Touchlane
|
||||||
|
module SharedValues
|
||||||
|
TOUCH_BUNDLE_ID_PROFILE_NAME_MAPPING = :TOUCH_BUNDLE_ID_PROFILE_NAME_MAPPING
|
||||||
|
end
|
||||||
|
|
||||||
class Configuration
|
class Configuration
|
||||||
def initialize(type, app_identifier, apple_id, team_id, itc_team_id)
|
def initialize(type, app_identifier, apple_id, team_id, itc_team_id)
|
||||||
@type = type
|
@type = type
|
||||||
|
|
@ -13,6 +17,8 @@ module Touchlane
|
||||||
attr_reader :type, :app_identifier, :apple_id, :team_id, :itc_team_id
|
attr_reader :type, :app_identifier, :apple_id, :team_id, :itc_team_id
|
||||||
|
|
||||||
def self.from_file(path, type)
|
def self.from_file(path, type)
|
||||||
|
Fastlane::Actions.lane_context[SharedValues::TOUCH_BUNDLE_ID_PROFILE_NAME_MAPPING] = {}
|
||||||
|
|
||||||
configuration_hash = load_configuration_from_file(path)
|
configuration_hash = load_configuration_from_file(path)
|
||||||
attrs_hash = configuration_hash["types"][type]
|
attrs_hash = configuration_hash["types"][type]
|
||||||
identifiers = get_app_identifiers_from_configuration_hash(configuration_hash, type)
|
identifiers = get_app_identifiers_from_configuration_hash(configuration_hash, type)
|
||||||
|
|
@ -35,8 +41,15 @@ module Touchlane
|
||||||
|
|
||||||
def self.get_app_identifiers_from_configuration_hash(configuration_hash, type)
|
def self.get_app_identifiers_from_configuration_hash(configuration_hash, type)
|
||||||
identifier_key = "PRODUCT_BUNDLE_IDENTIFIER"
|
identifier_key = "PRODUCT_BUNDLE_IDENTIFIER"
|
||||||
|
profile_name_key = "PROVISIONING_PROFILE_SPECIFIER"
|
||||||
|
|
||||||
configuration_hash["targets"].collect do |target, types|
|
configuration_hash["targets"].collect do |target, types|
|
||||||
types[type][identifier_key] or raise "#{target}: There is no #{identifier_key} field in #{type}"
|
bundle_id = types[type][identifier_key]
|
||||||
|
profile_name = types[type][profile_name_key]
|
||||||
|
|
||||||
|
Fastlane::Actions.lane_context[SharedValues::TOUCH_BUNDLE_ID_PROFILE_NAME_MAPPING][bundle_id] = profile_name
|
||||||
|
|
||||||
|
bundle_id or raise "#{target}: There is no #{identifier_key} field in #{type}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@ module Touchlane
|
||||||
DEVELOPMENT = "development"
|
DEVELOPMENT = "development"
|
||||||
ENTERPRISE = "enterprise"
|
ENTERPRISE = "enterprise"
|
||||||
APP_STORE = "appstore"
|
APP_STORE = "appstore"
|
||||||
|
ADHOC = "adhoc"
|
||||||
|
|
||||||
DEVELOPMENT_PREFIX = "Standard"
|
DEVELOPMENT_PREFIX = "Standard"
|
||||||
ENTERPRISE_PREFIX = "Enterprise"
|
ENTERPRISE_PREFIX = "Enterprise"
|
||||||
APP_STORE_PREFIX = "AppStore"
|
APP_STORE_PREFIX = "AppStore"
|
||||||
|
ADHOC_PREFIX = "AdHoc"
|
||||||
|
|
||||||
private_constant :DEVELOPMENT, :ENTERPRISE, :APP_STORE
|
private_constant :DEVELOPMENT, :ENTERPRISE, :APP_STORE, :ADHOC_PREFIX
|
||||||
private_constant :DEVELOPMENT_PREFIX, :ENTERPRISE_PREFIX, :APP_STORE_PREFIX
|
private_constant :DEVELOPMENT_PREFIX, :ENTERPRISE_PREFIX, :APP_STORE_PREFIX, :ADHOC_PREFIX
|
||||||
|
|
||||||
def initialize(type)
|
def initialize(type)
|
||||||
@type = type
|
@type = type
|
||||||
|
|
@ -30,6 +32,10 @@ module Touchlane
|
||||||
@export_method = "app-store"
|
@export_method = "app-store"
|
||||||
@configuration = "AppStore"
|
@configuration = "AppStore"
|
||||||
@prefix = APP_STORE_PREFIX
|
@prefix = APP_STORE_PREFIX
|
||||||
|
when ADHOC
|
||||||
|
@export_method = type
|
||||||
|
@export_method = "ad-hoc"
|
||||||
|
@prefix = ADHOC_PREFIX
|
||||||
else
|
else
|
||||||
raise "Unknown type passed #{type}"
|
raise "Unknown type passed #{type}"
|
||||||
end
|
end
|
||||||
|
|
@ -47,9 +53,11 @@ module Touchlane
|
||||||
from_type(APP_STORE)
|
from_type(APP_STORE)
|
||||||
when lane_name.start_with?(DEVELOPMENT_PREFIX)
|
when lane_name.start_with?(DEVELOPMENT_PREFIX)
|
||||||
from_type(DEVELOPMENT)
|
from_type(DEVELOPMENT)
|
||||||
|
when lane_name.start_with?(ADHOC_PREFIX)
|
||||||
|
from_type(ADHOC)
|
||||||
else
|
else
|
||||||
raise "Unable to map #{lane_name} to #{ConfigurationType.class}."
|
raise "Unable to map #{lane_name} to #{ConfigurationType.class}."
|
||||||
+ "Available prefixes: #{DEVELOPMENT_PREFIX}, #{ENTERPRISE_PREFIX}, #{APP_STORE_PREFIX}"
|
+ "Available prefixes: #{DEVELOPMENT_PREFIX}, #{ENTERPRISE_PREFIX}, #{APP_STORE_PREFIX}, #{ADHOC_PREFIX}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -57,9 +65,26 @@ module Touchlane
|
||||||
new(type)
|
new(type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.from_account_type(account_type)
|
||||||
|
case account_type
|
||||||
|
when DEVELOPMENT_PREFIX
|
||||||
|
from_type(DEVELOPMENT)
|
||||||
|
when ENTERPRISE_PREFIX
|
||||||
|
from_type(ENTERPRISE)
|
||||||
|
when APP_STORE_PREFIX
|
||||||
|
from_type(APP_STORE)
|
||||||
|
when ADHOC_PREFIX
|
||||||
|
from_type(ADHOC)
|
||||||
|
else
|
||||||
|
raise "Unable to map #{account_type} to #{ConfigurationType.class}."
|
||||||
|
+ "Available account types: #{DEVELOPMENT_PREFIX}, #{ENTERPRISE_PREFIX}, #{APP_STORE_PREFIX}, #{ADHOC_PREFIX}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def to_options
|
def to_options
|
||||||
{
|
{
|
||||||
:type => @type,
|
:type => @type,
|
||||||
|
:development => @is_development,
|
||||||
:export_method => @export_method,
|
:export_method => @export_method,
|
||||||
:configuration => @configuration
|
:configuration => @configuration
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
require_relative '../../../../managers/managers'
|
|
||||||
require_relative '../../../../templates/templates'
|
|
||||||
|
|
||||||
module Touchlane
|
|
||||||
class Features
|
|
||||||
|
|
||||||
def self.generate_enabled_features_extension(builder_features_list, build_settings_features_list)
|
|
||||||
|
|
||||||
# Check is entered features contains in configuration file
|
|
||||||
features_diff = builder_features_list - build_settings_features_list
|
|
||||||
|
|
||||||
unless features_diff.empty?
|
|
||||||
raise "Unexpected features: " + features_diff.join(', ')
|
|
||||||
end
|
|
||||||
|
|
||||||
# Generate enabled features extension from feature names
|
|
||||||
enabled_features_extension_template = Templates::FeatureTemplates.enabled_features_extension
|
|
||||||
utils = Managers::TemplateManager.new(builder_features_list)
|
|
||||||
|
|
||||||
utils.render(enabled_features_extension_template).strip
|
|
||||||
end
|
|
||||||
|
|
||||||
private_class_method :new
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
require 'yaml'
|
|
||||||
require 'json'
|
|
||||||
|
|
||||||
module Managers
|
|
||||||
class FileManager
|
|
||||||
|
|
||||||
def self.save_data_to_file(path, data)
|
|
||||||
unless File.exists? path
|
|
||||||
raise "Unable to save data to file at #{path}"
|
|
||||||
else
|
|
||||||
File.open(path, "w") do |f|
|
|
||||||
f.write(data)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.load_from_file_YAML(path)
|
|
||||||
unless File.exists? path
|
|
||||||
raise "Unable to load data from file at #{path}"
|
|
||||||
else
|
|
||||||
YAML.load_file(path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.save_data_to_file_in_json(path, data)
|
|
||||||
json_data = JSON.pretty_generate(data)
|
|
||||||
save_data_to_file(path, json_data)
|
|
||||||
end
|
|
||||||
|
|
||||||
private_class_method :new
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
require 'erb'
|
|
||||||
|
|
||||||
module Managers
|
|
||||||
class TemplateManager
|
|
||||||
|
|
||||||
include ERB::Util
|
|
||||||
|
|
||||||
attr_accessor :items
|
|
||||||
|
|
||||||
def initialize(items)
|
|
||||||
@items = items
|
|
||||||
end
|
|
||||||
|
|
||||||
def render(template)
|
|
||||||
ERB.new(template).result(binding)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
module Managers
|
|
||||||
require_relative "lib/file_manager"
|
|
||||||
require_relative "lib/template_manager"
|
|
||||||
end
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
module Templates
|
|
||||||
require_relative "templates/features_templates"
|
|
||||||
end
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
module Templates
|
|
||||||
module FeatureTemplates
|
|
||||||
|
|
||||||
def self.features_enum
|
|
||||||
"
|
|
||||||
// MARK: - Generated feature toggles
|
|
||||||
|
|
||||||
public enum Feature: String, Codable, RawRepresentable, CaseIterable {
|
|
||||||
<% for @item in @items %>
|
|
||||||
case <%= @item %>
|
|
||||||
<% end %>
|
|
||||||
}
|
|
||||||
"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.enabled_features_extension
|
|
||||||
"
|
|
||||||
// MARK: - Generated enabled features
|
|
||||||
|
|
||||||
public extension Feature {
|
|
||||||
|
|
||||||
static var enabled: [Feature] {
|
|
||||||
[
|
|
||||||
<% for @item in @items %>
|
|
||||||
\.<%= @item %>,
|
|
||||||
<% end %>
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
Reference in New Issue