From 508979d7b257099f4696669322ecacaacd5c0a50 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 29 May 2019 11:53:30 +0300 Subject: [PATCH 01/42] add lane for manually update code signing --- xcode/commonFastfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 040c3ab..73e596c 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -196,6 +196,34 @@ private_lane :openKeychain do |options| end end +lane :ManuallyUpdateCodeSigning do |options| + # based on this article https://medium.com/@jonathancardoso/using-fastlane-match-with-existing-certificates-without-revoking-them-a325be69dac6 + require 'fastlane_core' + require 'match' + + conf = FastlaneCore::Configuration.create(Match::Options.available_options, {}) + conf.load_configuration_file("Matchfile") + + git_url = conf.config_file_options[:git_url] + shallow_clone = false + branch = 'fastlane_certificates' + storage = Match::Storage.for_mode('git', { git_url: git_url, shallow_clone: shallow_clone, git_branch: branch, clone_branch_directly: false}) + storage.download + encryption = Match::Encryption.for_storage_mode('git', { git_url: git_url, working_directory: storage.working_directory}) + encryption.decrypt_files + + 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 = Dir[File.join(storage.working_directory, "**", "*.{cer,p12,mobileprovision}")] + storage.save_changes!(files_to_commit: files_to_commit) +end + def get_keychain_options(options) keychain_name = options[:keychain_name] keychain_password = options[:keychain_password] From 90e98175038088eaacd6b827c3ba8ef2e2ae4baa Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 19 Jul 2019 14:24:47 +0300 Subject: [PATCH 02/42] exclude build folder --- gradle/commonStaticAnalysis.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/commonStaticAnalysis.gradle b/gradle/commonStaticAnalysis.gradle index 8432daa..adbdbc9 100644 --- a/gradle/commonStaticAnalysis.gradle +++ b/gradle/commonStaticAnalysis.gradle @@ -33,7 +33,7 @@ detekt { config = files("$buildScriptsDir/kotlin/detekt-config.yml") // TODO add excludes from rootProject.extensions.findByName("staticAnalysisExcludes") - filters = ".*src/test.*,.*/resources/.*,.*/tmp/.*" + filters = ".*src/test.*,.*/resources/.*,.*/tmp/.*,.*/build/.*" reports { html { From a5bb4ad0cc8bed04f63210b6fd5495a1d70d7a4e Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 19 Jul 2019 14:44:17 +0300 Subject: [PATCH 03/42] ignore bad permissions for chrome os support --- lint/lint.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/lint/lint.xml b/lint/lint.xml index 4e33195..3709269 100644 --- a/lint/lint.xml +++ b/lint/lint.xml @@ -267,5 +267,6 @@ + From 4d583007da00a9db6fb97eee94d3a125329d7b80 Mon Sep 17 00:00:00 2001 From: Maxim Bachinsky Date: Mon, 22 Jul 2019 16:04:11 +0300 Subject: [PATCH 04/42] update detekt config to new version (after RC 15) --- gradle/commonStaticAnalysis.gradle | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gradle/commonStaticAnalysis.gradle b/gradle/commonStaticAnalysis.gradle index adbdbc9..f4c4a3c 100644 --- a/gradle/commonStaticAnalysis.gradle +++ b/gradle/commonStaticAnalysis.gradle @@ -29,11 +29,8 @@ cpd { } detekt { - input = files("${rootDir}") config = files("$buildScriptsDir/kotlin/detekt-config.yml") - - // TODO add excludes from rootProject.extensions.findByName("staticAnalysisExcludes") - filters = ".*src/test.*,.*/resources/.*,.*/tmp/.*,.*/build/.*" + parallel = true reports { html { @@ -45,6 +42,7 @@ detekt { destination = file("${project.buildDir}/reports/kotlin-detekt.xml") } } + } import org.apache.tools.ant.taskdefs.condition.Os @@ -351,7 +349,10 @@ getCheckstyleTask = { sources -> return task.name } -getKotlinDetektTask = { "detekt" } +getKotlinDetektTask = { + // TODO add excludes from rootProject.extensions.findByName("staticAnalysisExcludes") + "detekt" +} task optimizePng { doFirst { From f2692e162cd91fdd5f88a8e26470f74cf7381d83 Mon Sep 17 00:00:00 2001 From: Elena Bobkova Date: Tue, 23 Jul 2019 17:36:21 +0300 Subject: [PATCH 05/42] api-generator version update --- gradle/apiGeneratorKotlinServer.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/apiGeneratorKotlinServer.gradle b/gradle/apiGeneratorKotlinServer.gradle index 2b980aa..c2e8732 100644 --- a/gradle/apiGeneratorKotlinServer.gradle +++ b/gradle/apiGeneratorKotlinServer.gradle @@ -7,7 +7,7 @@ configurations { } dependencies { - apigeneratorKotlinServer 'ru.touchin:api-generator:1.3.2' + apigeneratorKotlinServer 'ru.touchin:api-generator:1.3.4' } task generateApiModelsKotlinServer doLast { From c4be015c0ff77da08a3f870b783c49458f407891 Mon Sep 17 00:00:00 2001 From: Sergey Kopytov Date: Wed, 31 Jul 2019 03:09:02 +0300 Subject: [PATCH 06/42] add removing functionality for ManuallyUpdateCodeSigning lane --- xcode/commonFastfile | 49 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 73e596c..91ccc2f 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -207,10 +207,26 @@ lane :ManuallyUpdateCodeSigning do |options| git_url = conf.config_file_options[:git_url] shallow_clone = false branch = 'fastlane_certificates' - storage = Match::Storage.for_mode('git', { git_url: git_url, shallow_clone: shallow_clone, git_branch: branch, clone_branch_directly: false}) - storage.download - encryption = Match::Encryption.for_storage_mode('git', { git_url: git_url, working_directory: storage.working_directory}) - encryption.decrypt_files + + storage_conf = lambda do + new_storage = Match::Storage.for_mode('git', { git_url: git_url, shallow_clone: shallow_clone, git_branch: branch, clone_branch_directly: false}) + new_storage.download + return new_storage + end + + encryption_conf = lambda do |stor| + new_encryption = Match::Encryption.for_storage_mode('git', { git_url: git_url, working_directory: stor.working_directory}) + new_encryption.decrypt_files + return new_encryption + end + + get_all_files = lambda do |stor| + return Dir[File.join(stor.working_directory, "**", "*.{cer,p12,mobileprovision}")] + end + + storage = storage_conf.call + encryption = encryption_conf.call(storage) + old_files = get_all_files.call(storage) sh("open #{storage.working_directory}") @@ -220,10 +236,33 @@ lane :ManuallyUpdateCodeSigning do |options| encryption.encrypt_files - files_to_commit = Dir[File.join(storage.working_directory, "**", "*.{cer,p12,mobileprovision}")] + 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 + + if files_diff.length > 0 + storage = storage_conf.call + encryption = encryption_conf.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 get_keychain_options(options) keychain_name = options[:keychain_name] keychain_password = options[:keychain_password] From 373792222e3d0fe344514da4101ae62a679b1e77 Mon Sep 17 00:00:00 2001 From: Sergey Kopytov Date: Wed, 31 Jul 2019 12:43:32 +0300 Subject: [PATCH 07/42] refactor --- xcode/commonFastfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 91ccc2f..36ece68 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -214,18 +214,18 @@ lane :ManuallyUpdateCodeSigning do |options| return new_storage end - encryption_conf = lambda do |stor| + encryption_conf_for_storage = lambda do |stor| new_encryption = Match::Encryption.for_storage_mode('git', { git_url: git_url, working_directory: stor.working_directory}) new_encryption.decrypt_files return new_encryption end get_all_files = lambda do |stor| - return Dir[File.join(stor.working_directory, "**", "*.{cer,p12,mobileprovision}")] + Dir[File.join(stor.working_directory, "**", "*.{cer,p12,mobileprovision}")] end storage = storage_conf.call - encryption = encryption_conf.call(storage) + encryption = encryption_conf_for_storage.call(storage) old_files = get_all_files.call(storage) sh("open #{storage.working_directory}") @@ -246,7 +246,7 @@ lane :ManuallyUpdateCodeSigning do |options| if files_diff.length > 0 storage = storage_conf.call - encryption = encryption_conf.call(storage) + encryption = encryption_conf_for_storage.call(storage) files_to_delete = files_diff.map do |file| old_file = file From 59b15d7db62f22874101e6e08c419697c5cd8532 Mon Sep 17 00:00:00 2001 From: Sergey Kopytov Date: Wed, 31 Jul 2019 14:29:48 +0300 Subject: [PATCH 08/42] add comment --- xcode/commonFastfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 36ece68..fe6cd0a 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -244,6 +244,9 @@ lane :ManuallyUpdateCodeSigning do |options| # 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_conf.call encryption = encryption_conf_for_storage.call(storage) From 7a5ddf62434941b801965514b6267058cb57a90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Thu, 1 Aug 2019 23:52:19 +0300 Subject: [PATCH 09/42] Add nesseccery scripts --- xcode/UnusedConfig.txt | 5 + xcode/build_phases/Unused.rb | 192 +++++++++++++++++++++++++++++++++++ xcode/build_phases/unused.sh | 1 + 3 files changed, 198 insertions(+) create mode 100644 xcode/UnusedConfig.txt create mode 100644 xcode/build_phases/Unused.rb create mode 100644 xcode/build_phases/unused.sh diff --git a/xcode/UnusedConfig.txt b/xcode/UnusedConfig.txt new file mode 100644 index 0000000..3dd1ffa --- /dev/null +++ b/xcode/UnusedConfig.txt @@ -0,0 +1,5 @@ +--ignored-resources: +Generated/ +Resources/Localization +Carthage/ +Pods/ \ No newline at end of file diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb new file mode 100644 index 0000000..dacf7ae --- /dev/null +++ b/xcode/build_phases/Unused.rb @@ -0,0 +1,192 @@ +#!/usr/bin/ruby +#encoding: utf-8 +Encoding.default_external = Encoding::UTF_8 +Encoding.default_internal = Encoding::UTF_8 + +$config_argv_key = "--config" +$ignored_argv_key = "--ignored" +$ignored_resources_key = "--ignored-resources:" +$log_file_name = "UnusedLog.txt" + +class Item + def initialize(file, line, at) + @file = file + @line = line + @at = at + 1 + if match = line.match(/(func|let|var|class|enum|struct|protocol)\s+(\w+)/) + @type = match.captures[0] + @name = match.captures[1] + end + end + + def modifiers + return @modifiers if @modifiers + @modifiers = [] + if match = @line.match(/(.*?)#{@type}/) + @modifiers = match.captures[0].split(" ") + end + return @modifiers + end + + def name + @name + end + + def file + @file + end + + def to_s + serialize + end + def to_str + serialize + end + + def full_file_path + Dir.pwd + '/' + @file + end + + def serialize + "#{@type.to_s} #{@name.to_s} from: #{@file}:#{@at} is unused" + end + + def to_xcode + "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" + end + + +end +class Unused + def find + items = [] + unused_warnings = [] + + regexps = parse_arguments + + all_files = Dir.glob("**/*.swift").reject do |path| + File.directory?(path) + end + + all_files.each { |my_text_file| + file_items = grab_items(my_text_file) + file_items = filter_items(file_items) + + non_private_items, private_items = file_items.partition { |f| !f.modifiers.include?("private") && !f.modifiers.include?("fileprivate") } + items += non_private_items + + # Usage within the file + if private_items.length > 0 + unused_warnings += find_usages_in_files([my_text_file], [], private_items, regexps) + end + + } + + xibs = Dir.glob("**/*.xib") + storyboards = Dir.glob("**/*.storyboard") + + unused_warnings += find_usages_in_files(all_files, xibs + storyboards, items, regexps) + + if unused_warnings.length > 0 + # show warning + puts "#{unused_warnings.map { |e| e.to_xcode }.join("\n")}" + # write log + File.open($log_file_name, "w") do |file| + file.write("Unused code warnings count: #{unused_warnings.length}\n\n") + file.write("#{unused_warnings.map { |e| e.serialize }.join("\n")}") + end + end + end + + def parse_arguments() + resources = [] + + arguments = ARGV.clone + + until arguments.empty? + item = arguments.shift + + # find --config file + if item == $config_argv_key + fileName = arguments.shift + + # add --ignored-resources to array + File.readlines(fileName).each do |line| + if !line.include? $ignored_resources_key + resources += [line.chomp] + end + end + end + + # add --ignored files to array + if item == $ignored_argv_key + resources += [arguments.shift] + end + end + + # create and return Regexp + resources.map { |r| Regexp.new(r) } + end + + # remove files, that maches ignored Regexps array + def ignore_files_with_regexps(files, regexps) + files.select { |f| regexps.all? { |r| r.match(f.file).nil? } } + end + + def find_usages_in_files(files, xibs, items_in, regexps) + items = items_in + usages = items.map { |f| 0 } + files.each { |file| + lines = File.readlines(file).map {|line| line.gsub(/^[^\/]*\/\/.*/, "") } + words = lines.join("\n").split(/\W+/) + words_arrray = words.group_by { |w| w }.map { |w, ws| [w, ws.length] }.flatten + + wf = Hash[*words_arrray] + + items.each_with_index { |f, i| + usages[i] += (wf[f.name] || 0) + } + # Remove all items which has usage 2+ + indexes = usages.each_with_index.select { |u, i| u >= 2 }.map { |f, i| i } + + # reduce usage array if we found some functions already + indexes.reverse.each { |i| usages.delete_at(i) && items.delete_at(i) } + } + + xibs.each { |xib| + lines = File.readlines(xib).map {|line| line.gsub(/^\s*\/\/.*/, "") } + full_xml = lines.join(" ") + classes = full_xml.scan(/(class|customClass)="([^"]+)"/).map { |cd| cd[1] } + classes_array = classes.group_by { |w| w }.map { |w, ws| [w, ws.length] }.flatten + + wf = Hash[*classes_array] + + items.each_with_index { |f, i| + usages[i] += (wf[f.name] || 0) + } + # Remove all items which has usage 2+ + indexes = usages.each_with_index.select { |u, i| u >= 2 }.map { |f, i| i } + + # reduce usage array if we found some functions already + indexes.reverse.each { |i| usages.delete_at(i) && items.delete_at(i) } + + } + + items = ignore_files_with_regexps(items, regexps) + end + + def grab_items(file) + lines = File.readlines(file).map {|line| line.gsub(/^\s*\/\/.*/, "") } + items = lines.each_with_index.select { |line, i| line[/(func|let|var|class|enum|struct|protocol)\s+\w+/] }.map { |line, i| Item.new(file, line, i)} + end + + def filter_items(items) + items.select { |f| + !f.name.start_with?("test") && !f.modifiers.include?("@IBAction") && !f.modifiers.include?("override") && !f.modifiers.include?("@objc") && !f.modifiers.include?("@IBInspectable") + } + end + +end + + +Unused.new.find diff --git a/xcode/build_phases/unused.sh b/xcode/build_phases/unused.sh new file mode 100644 index 0000000..3301156 --- /dev/null +++ b/xcode/build_phases/unused.sh @@ -0,0 +1 @@ +ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.txt From 2c91968fdc441d0406b216713e9f7a59e37a93b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 16:53:13 +0300 Subject: [PATCH 10/42] Make config file .yml. Add OptionParser --- xcode/UnusedConfig.txt | 5 - xcode/UnusedConfig.yml | 5 + xcode/build_phases/Unused.rb | 271 +++++++++++++++++------------------ xcode/build_phases/unused.sh | 2 +- 4 files changed, 140 insertions(+), 143 deletions(-) delete mode 100644 xcode/UnusedConfig.txt create mode 100644 xcode/UnusedConfig.yml diff --git a/xcode/UnusedConfig.txt b/xcode/UnusedConfig.txt deleted file mode 100644 index 3dd1ffa..0000000 --- a/xcode/UnusedConfig.txt +++ /dev/null @@ -1,5 +0,0 @@ ---ignored-resources: -Generated/ -Resources/Localization -Carthage/ -Pods/ \ No newline at end of file diff --git a/xcode/UnusedConfig.yml b/xcode/UnusedConfig.yml new file mode 100644 index 0000000..8ac9173 --- /dev/null +++ b/xcode/UnusedConfig.yml @@ -0,0 +1,5 @@ +--ignored-resources: + - Generated/ + - Resources/Localization + - Carthage/ + - Pods/ \ No newline at end of file diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index dacf7ae..416b47e 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -1,190 +1,187 @@ #!/usr/bin/ruby #encoding: utf-8 +require 'yaml' +require 'optparse' + Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 -$config_argv_key = "--config" -$ignored_argv_key = "--ignored" -$ignored_resources_key = "--ignored-resources:" -$log_file_name = "UnusedLog.txt" - class Item - def initialize(file, line, at) - @file = file - @line = line - @at = at + 1 - if match = line.match(/(func|let|var|class|enum|struct|protocol)\s+(\w+)/) - @type = match.captures[0] - @name = match.captures[1] + def initialize(file, line, at) + @file = file + @line = line + @at = at + 1 + if match = line.match(/(func|let|var|class|enum|struct|protocol)\s+(\w+)/) + @type = match.captures[0] + @name = match.captures[1] + end end - end - def modifiers - return @modifiers if @modifiers - @modifiers = [] - if match = @line.match(/(.*?)#{@type}/) - @modifiers = match.captures[0].split(" ") + def modifiers + return @modifiers if @modifiers + @modifiers = [] + if match = @line.match(/(.*?)#{@type}/) + @modifiers = match.captures[0].split(" ") + end + return @modifiers end - return @modifiers - end - def name - @name - end + def name + @name + end - def file - @file - end + def file + @file + end - def to_s - serialize - end - def to_str - serialize - end + def to_s + serialize + end + def to_str + serialize + end - def full_file_path - Dir.pwd + '/' + @file - end + def full_file_path + Dir.pwd + '/' + @file + end - def serialize - "#{@type.to_s} #{@name.to_s} from: #{@file}:#{@at} is unused" - end + def serialize + "#{@type.to_s} #{@name.to_s} from: #{@file}:#{@at} is unused" + end - def to_xcode - "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" - end + def to_xcode + "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" + end end class Unused - def find - items = [] - unused_warnings = [] + def find + items = [] + unused_warnings = [] - regexps = parse_arguments + regexps = parse_arguments - all_files = Dir.glob("**/*.swift").reject do |path| - File.directory?(path) - end + all_files = Dir.glob("**/*.swift").reject do |path| + File.directory?(path) + end - all_files.each { |my_text_file| - file_items = grab_items(my_text_file) - file_items = filter_items(file_items) + all_files.each { |my_text_file| + file_items = grab_items(my_text_file) + file_items = filter_items(file_items) - non_private_items, private_items = file_items.partition { |f| !f.modifiers.include?("private") && !f.modifiers.include?("fileprivate") } - items += non_private_items + non_private_items, private_items = file_items.partition { |f| !f.modifiers.include?("private") && !f.modifiers.include?("fileprivate") } + items += non_private_items - # Usage within the file - if private_items.length > 0 - unused_warnings += find_usages_in_files([my_text_file], [], private_items, regexps) - end + # Usage within the file + if private_items.length > 0 + unused_warnings += find_usages_in_files([my_text_file], [], private_items, regexps) + end - } + } - xibs = Dir.glob("**/*.xib") - storyboards = Dir.glob("**/*.storyboard") + xibs = Dir.glob("**/*.xib") + storyboards = Dir.glob("**/*.storyboard") - unused_warnings += find_usages_in_files(all_files, xibs + storyboards, items, regexps) + unused_warnings += find_usages_in_files(all_files, xibs + storyboards, items, regexps) - if unused_warnings.length > 0 - # show warning - puts "#{unused_warnings.map { |e| e.to_xcode }.join("\n")}" - # write log - File.open($log_file_name, "w") do |file| - file.write("Unused code warnings count: #{unused_warnings.length}\n\n") - file.write("#{unused_warnings.map { |e| e.serialize }.join("\n")}") + if unused_warnings.length > 0 + # show warning + puts "#{unused_warnings.map { |e| e.to_xcode }.join("\n")}" + # write log + File.open("UnusedLog.txt", "w") do |file| + file.write("Unused code warnings count: #{unused_warnings.length}\n\n") + file.write("#{unused_warnings.map { |e| e.serialize }.join("\n")}") + end end end - end - def parse_arguments() - resources = [] + def parse_arguments() + resources = [] - arguments = ARGV.clone + options = {} + OptionParser.new do |opts| + options[:ignore] = [] - until arguments.empty? - item = arguments.shift + opts.on("-c", "--config=FileName") { |c| options[:config] = c } + opts.on("-i", "--ignore=a, b, c", Array) { |i| options[:ignore] += i } - # find --config file - if item == $config_argv_key - fileName = arguments.shift + end.parse! - # add --ignored-resources to array - File.readlines(fileName).each do |line| - if !line.include? $ignored_resources_key - resources += [line.chomp] - end - end - end + # find --config file + if !options[:config].nil? + fileName = options[:config] + resources += YAML.load_file(fileName).fetch("--ignored-resources") + elsif + puts "---------\n Warning: Config file is now provided \n---------" + end - # add --ignored files to array - if item == $ignored_argv_key - resources += [arguments.shift] - end - end + # find --ignored files + if !options[:ignore].nil? + resources += options[:ignore] + end - # create and return Regexp - resources.map { |r| Regexp.new(r) } - end + # create and return Regexp + resources.map { |r| Regexp.new(r) } + end - # remove files, that maches ignored Regexps array - def ignore_files_with_regexps(files, regexps) - files.select { |f| regexps.all? { |r| r.match(f.file).nil? } } - end + # remove files, that maches ignored Regexps array + def ignore_files_with_regexps(files, regexps) + files.select { |f| regexps.all? { |r| r.match(f.file).nil? } } + end - def find_usages_in_files(files, xibs, items_in, regexps) - items = items_in - usages = items.map { |f| 0 } - files.each { |file| - lines = File.readlines(file).map {|line| line.gsub(/^[^\/]*\/\/.*/, "") } - words = lines.join("\n").split(/\W+/) - words_arrray = words.group_by { |w| w }.map { |w, ws| [w, ws.length] }.flatten + def find_usages_in_files(files, xibs, items_in, regexps) + items = items_in + usages = items.map { |f| 0 } + files.each { |file| + lines = File.readlines(file).map {|line| line.gsub(/^[^\/]*\/\/.*/, "") } + words = lines.join("\n").split(/\W+/) + words_arrray = words.group_by { |w| w }.map { |w, ws| [w, ws.length] }.flatten - wf = Hash[*words_arrray] + wf = Hash[*words_arrray] - items.each_with_index { |f, i| - usages[i] += (wf[f.name] || 0) - } - # Remove all items which has usage 2+ - indexes = usages.each_with_index.select { |u, i| u >= 2 }.map { |f, i| i } + items.each_with_index { |f, i| + usages[i] += (wf[f.name] || 0) + } + # Remove all items which has usage 2+ + indexes = usages.each_with_index.select { |u, i| u >= 2 }.map { |f, i| i } - # reduce usage array if we found some functions already - indexes.reverse.each { |i| usages.delete_at(i) && items.delete_at(i) } - } + # reduce usage array if we found some functions already + indexes.reverse.each { |i| usages.delete_at(i) && items.delete_at(i) } + } - xibs.each { |xib| - lines = File.readlines(xib).map {|line| line.gsub(/^\s*\/\/.*/, "") } - full_xml = lines.join(" ") - classes = full_xml.scan(/(class|customClass)="([^"]+)"/).map { |cd| cd[1] } - classes_array = classes.group_by { |w| w }.map { |w, ws| [w, ws.length] }.flatten + xibs.each { |xib| + lines = File.readlines(xib).map {|line| line.gsub(/^\s*\/\/.*/, "") } + full_xml = lines.join(" ") + classes = full_xml.scan(/(class|customClass)="([^"]+)"/).map { |cd| cd[1] } + classes_array = classes.group_by { |w| w }.map { |w, ws| [w, ws.length] }.flatten - wf = Hash[*classes_array] + wf = Hash[*classes_array] - items.each_with_index { |f, i| - usages[i] += (wf[f.name] || 0) - } - # Remove all items which has usage 2+ - indexes = usages.each_with_index.select { |u, i| u >= 2 }.map { |f, i| i } + items.each_with_index { |f, i| + usages[i] += (wf[f.name] || 0) + } + # Remove all items which has usage 2+ + indexes = usages.each_with_index.select { |u, i| u >= 2 }.map { |f, i| i } - # reduce usage array if we found some functions already - indexes.reverse.each { |i| usages.delete_at(i) && items.delete_at(i) } + # reduce usage array if we found some functions already + indexes.reverse.each { |i| usages.delete_at(i) && items.delete_at(i) } - } + } - items = ignore_files_with_regexps(items, regexps) - end + items = ignore_files_with_regexps(items, regexps) + end - def grab_items(file) - lines = File.readlines(file).map {|line| line.gsub(/^\s*\/\/.*/, "") } - items = lines.each_with_index.select { |line, i| line[/(func|let|var|class|enum|struct|protocol)\s+\w+/] }.map { |line, i| Item.new(file, line, i)} - end + def grab_items(file) + lines = File.readlines(file).map {|line| line.gsub(/^\s*\/\/.*/, "") } + items = lines.each_with_index.select { |line, i| line[/(func|let|var|class|enum|struct|protocol)\s+\w+/] }.map { |line, i| Item.new(file, line, i)} + end - def filter_items(items) - items.select { |f| - !f.name.start_with?("test") && !f.modifiers.include?("@IBAction") && !f.modifiers.include?("override") && !f.modifiers.include?("@objc") && !f.modifiers.include?("@IBInspectable") - } - end + def filter_items(items) + items.select { |f| + !f.name.start_with?("test") && !f.modifiers.include?("@IBAction") && !f.modifiers.include?("override") && !f.modifiers.include?("@objc") && !f.modifiers.include?("@IBInspectable") + } + end end diff --git a/xcode/build_phases/unused.sh b/xcode/build_phases/unused.sh index 3301156..01fe69d 100644 --- a/xcode/build_phases/unused.sh +++ b/xcode/build_phases/unused.sh @@ -1 +1 @@ -ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.txt +ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.yml From 453284d37b7d8be427307acbecb0bd7eb4a01514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 17:13:50 +0300 Subject: [PATCH 11/42] Add arguments parsing in .sh file --- xcode/build_phases/unused.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xcode/build_phases/unused.sh b/xcode/build_phases/unused.sh index 01fe69d..2c12160 100644 --- a/xcode/build_phases/unused.sh +++ b/xcode/build_phases/unused.sh @@ -1 +1,4 @@ -ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.yml +arguments=("$@") +ignored_files=$(IFS=, ; echo "${arguments[*]}") + +ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.yml --ignore ${ignored_files} From c6b0b0d7bf5a0c713102dcb43d833493bebb4e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 17:26:51 +0300 Subject: [PATCH 12/42] Genetare one huge warning --- xcode/build_phases/Unused.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index 416b47e..2f88d64 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -49,8 +49,8 @@ class Item "#{@type.to_s} #{@name.to_s} from: #{@file}:#{@at} is unused" end - def to_xcode - "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" + def to_xcode(count) + "Unused Code Warning! Total Count #{count}: warning: #{serialize} is unused" end @@ -87,7 +87,7 @@ class Unused if unused_warnings.length > 0 # show warning - puts "#{unused_warnings.map { |e| e.to_xcode }.join("\n")}" + puts "#{unused_warnings.map { |e| e.to_xcode unused_warnings.length }.join("\n")}" # write log File.open("UnusedLog.txt", "w") do |file| file.write("Unused code warnings count: #{unused_warnings.length}\n\n") From 66d2c4a885fa0529345419dcfb489ad66eb60ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 17:30:42 +0300 Subject: [PATCH 13/42] Refactor code a bit --- xcode/build_phases/Unused.rb | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index 2f88d64..b85cfb9 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -96,7 +96,7 @@ class Unused end end - def parse_arguments() + def parse_arguments resources = [] options = {} @@ -125,6 +125,17 @@ class Unused resources.map { |r| Regexp.new(r) } end + def grab_items(file) + lines = File.readlines(file).map {|line| line.gsub(/^\s*\/\/.*/, "") } + items = lines.each_with_index.select { |line, i| line[/(func|let|var|class|enum|struct|protocol)\s+\w+/] }.map { |line, i| Item.new(file, line, i)} + end + + def filter_items(items) + items.select { |f| + !f.name.start_with?("test") && !f.modifiers.include?("@IBAction") && !f.modifiers.include?("override") && !f.modifiers.include?("@objc") && !f.modifiers.include?("@IBInspectable") + } + end + # remove files, that maches ignored Regexps array def ignore_files_with_regexps(files, regexps) files.select { |f| regexps.all? { |r| r.match(f.file).nil? } } @@ -171,18 +182,6 @@ class Unused items = ignore_files_with_regexps(items, regexps) end - - def grab_items(file) - lines = File.readlines(file).map {|line| line.gsub(/^\s*\/\/.*/, "") } - items = lines.each_with_index.select { |line, i| line[/(func|let|var|class|enum|struct|protocol)\s+\w+/] }.map { |line, i| Item.new(file, line, i)} - end - - def filter_items(items) - items.select { |f| - !f.name.start_with?("test") && !f.modifiers.include?("@IBAction") && !f.modifiers.include?("override") && !f.modifiers.include?("@objc") && !f.modifiers.include?("@IBInspectable") - } - end - end From b5d26d3d2b780024a80fe907230d04b0f96324f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 17:47:25 +0300 Subject: [PATCH 14/42] Fix typos --- xcode/UnusedConfig.yml | 2 +- xcode/build_phases/Unused.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xcode/UnusedConfig.yml b/xcode/UnusedConfig.yml index 8ac9173..ba35344 100644 --- a/xcode/UnusedConfig.yml +++ b/xcode/UnusedConfig.yml @@ -1,4 +1,4 @@ ---ignored-resources: +ignored-resources: - Generated/ - Resources/Localization - Carthage/ diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index b85cfb9..02e6dde 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -111,9 +111,9 @@ class Unused # find --config file if !options[:config].nil? fileName = options[:config] - resources += YAML.load_file(fileName).fetch("--ignored-resources") + resources += YAML.load_file(fileName).fetch("ignored-resources") elsif - puts "---------\n Warning: Config file is now provided \n---------" + puts "---------\n Warning: Config file is not provided \n---------" end # find --ignored files From 3d61e3db82ef5fb2aeb95a1e3885d05cb8c67349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 18:30:43 +0300 Subject: [PATCH 15/42] Make --ignore argiment optional --- xcode/build_phases/Unused.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index b85cfb9..48a3ffd 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -104,7 +104,7 @@ class Unused options[:ignore] = [] opts.on("-c", "--config=FileName") { |c| options[:config] = c } - opts.on("-i", "--ignore=a, b, c", Array) { |i| options[:ignore] += i } + opts.on("-i", "--ignore [a, b, c]", Array) { |i| options[:ignore] += i if !i.nil? } end.parse! From 463eda96ecc7a72db7f71f8f1c633a0354e1e55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 19:30:51 +0300 Subject: [PATCH 16/42] Refactor warnings appearence. Add script source link --- xcode/build_phases/Unused.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index 48a3ffd..230c30c 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -1,3 +1,4 @@ +# source: https://github.com/PaulTaykalo/swift-scripts/blob/master/unused.rb #!/usr/bin/ruby #encoding: utf-8 require 'yaml' @@ -46,11 +47,10 @@ class Item end def serialize - "#{@type.to_s} #{@name.to_s} from: #{@file}:#{@at} is unused" + "#{@full_file_path}:#{@at} #{@type.to_s} #{@name.to_s} is unused" end - - def to_xcode(count) - "Unused Code Warning! Total Count #{count}: warning: #{serialize} is unused" + def to_xcode + "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" end @@ -87,7 +87,8 @@ class Unused if unused_warnings.length > 0 # show warning - puts "#{unused_warnings.map { |e| e.to_xcode unused_warnings.length }.join("\n")}" + puts "Unused Code Warning!: warning: Total Count #{unused_warnings.length}" + puts "#{unused_warnings.map { |e| e.to_xcode}.join("\n")}" # write log File.open("UnusedLog.txt", "w") do |file| file.write("Unused code warnings count: #{unused_warnings.length}\n\n") From 9fe44e481e2b2358a69756feb232128e728d07ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 19:38:14 +0300 Subject: [PATCH 17/42] Fix file output string --- xcode/build_phases/Unused.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index c84321f..0c25e07 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -47,7 +47,7 @@ class Item end def serialize - "#{@full_file_path}:#{@at} #{@type.to_s} #{@name.to_s} is unused" + "#{@file}:#{@at} #{@type.to_s} #{@name.to_s} is unused" end def to_xcode "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" From 7e6a55d72f7af4a6a73627276787674fab6ad88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Fri, 2 Aug 2019 19:48:14 +0300 Subject: [PATCH 18/42] Change output log format --- xcode/build_phases/Unused.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index 0c25e07..66ff067 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -47,7 +47,7 @@ class Item end def serialize - "#{@file}:#{@at} #{@type.to_s} #{@name.to_s} is unused" + "#{@file} has unused \"#{@type.to_s} #{@name.to_s}\"" end def to_xcode "#{full_file_path}:#{@at}:0: warning: #{@type.to_s} #{@name.to_s} is unused" From 82ca5cbbc095403f20508c8388d49288c7d96a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B8=CC=86=20=D0=A1=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Mon, 5 Aug 2019 13:15:05 +0300 Subject: [PATCH 19/42] Rename ignore to exclude --- xcode/UnusedConfig.yml | 5 +++-- xcode/build_phases/Unused.rb | 14 +++++++------- xcode/build_phases/unused.sh | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xcode/UnusedConfig.yml b/xcode/UnusedConfig.yml index ba35344..619dd71 100644 --- a/xcode/UnusedConfig.yml +++ b/xcode/UnusedConfig.yml @@ -1,5 +1,6 @@ -ignored-resources: +excluded-resources: - Generated/ - Resources/Localization - Carthage/ - - Pods/ \ No newline at end of file + - Pods/ + - FormattingService.swift \ No newline at end of file diff --git a/xcode/build_phases/Unused.rb b/xcode/build_phases/Unused.rb index 66ff067..478a8d2 100644 --- a/xcode/build_phases/Unused.rb +++ b/xcode/build_phases/Unused.rb @@ -102,24 +102,24 @@ class Unused options = {} OptionParser.new do |opts| - options[:ignore] = [] + options[:exclude] = [] opts.on("-c", "--config=FileName") { |c| options[:config] = c } - opts.on("-i", "--ignore [a, b, c]", Array) { |i| options[:ignore] += i if !i.nil? } + opts.on("-i", "--exclude [a, b, c]", Array) { |i| options[:exclude] += i if !i.nil? } end.parse! # find --config file if !options[:config].nil? fileName = options[:config] - resources += YAML.load_file(fileName).fetch("ignored-resources") + resources += YAML.load_file(fileName).fetch("excluded-resources") elsif puts "---------\n Warning: Config file is not provided \n---------" end - # find --ignored files - if !options[:ignore].nil? - resources += options[:ignore] + # find --exclude files + if !options[:exclude].nil? + resources += options[:exclude] end # create and return Regexp @@ -137,7 +137,7 @@ class Unused } end - # remove files, that maches ignored Regexps array + # remove files, that maches excluded Regexps array def ignore_files_with_regexps(files, regexps) files.select { |f| regexps.all? { |r| r.match(f.file).nil? } } end diff --git a/xcode/build_phases/unused.sh b/xcode/build_phases/unused.sh index 2c12160..5a0a906 100644 --- a/xcode/build_phases/unused.sh +++ b/xcode/build_phases/unused.sh @@ -1,4 +1,4 @@ arguments=("$@") ignored_files=$(IFS=, ; echo "${arguments[*]}") -ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.yml --ignore ${ignored_files} +ruby ${PROJECT_DIR}/build-scripts/xcode/build_phases/Unused.rb --config ${PROJECT_DIR}/build-scripts/xcode/UnusedConfig.yml --exclude ${ignored_files} From f3999f601f5192f882e2f969205a38e117ea5b69 Mon Sep 17 00:00:00 2001 From: DashaGitHub Date: Fri, 9 Aug 2019 16:48:21 +0300 Subject: [PATCH 20/42] Turn on repo update command --- xcode/commonFastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index fe6cd0a..ad49254 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -20,7 +20,7 @@ private_lane :installDependencies do |options| end cocoapods( - repo_update: false + repo_update: true ) end From 93e5f5a84cdc0306f021abfb2585b6f750db82a4 Mon Sep 17 00:00:00 2001 From: stanislav Date: Fri, 13 Sep 2019 12:00:29 +0300 Subject: [PATCH 21/42] added appsflyer proguard --- proguard/common.pro | 1 + proguard/rules/appsflyer.pro | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 proguard/rules/appsflyer.pro diff --git a/proguard/common.pro b/proguard/common.pro index 937bc37..52715c2 100644 --- a/proguard/common.pro +++ b/proguard/common.pro @@ -6,3 +6,4 @@ -include rules/crashlytics.pro -include rules/glide.pro -include rules/kaspersky.pro +-include rules/appsflyer.pro diff --git a/proguard/rules/appsflyer.pro b/proguard/rules/appsflyer.pro new file mode 100644 index 0000000..6494fc5 --- /dev/null +++ b/proguard/rules/appsflyer.pro @@ -0,0 +1,5 @@ +-dontwarn com.google.android.gms.iid.** +-keep class com.appsflyer.** { *; } +-dontwarn android.app.job.JobParameters +-dontwarn com.android.installreferrer.** +-dontwarn com.appsflyer.** From f21d8ec5944f833baf80ab8882ec9b935d70ee1d Mon Sep 17 00:00:00 2001 From: Stanislav Date: Mon, 16 Sep 2019 19:07:43 +0300 Subject: [PATCH 22/42] api generator updated to 1.4.0-alpha1 --- gradle/apiGenerator.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/apiGenerator.gradle b/gradle/apiGenerator.gradle index c8680e4..2efcf09 100644 --- a/gradle/apiGenerator.gradle +++ b/gradle/apiGenerator.gradle @@ -7,7 +7,7 @@ configurations { } dependencies { - apigenerator 'ru.touchin:api-generator:1.2.9' + apigenerator 'ru.touchin:api-generator:1.4.0-alpha1' } android.applicationVariants.all { variant -> From e31a200c41ec27a9ac9887624139797ac91aaa4b Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Mon, 30 Sep 2019 13:23:42 +0300 Subject: [PATCH 23/42] install ruby dependencies from Gemfile --- xcode/commonFastfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index ad49254..6e8b230 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -9,6 +9,10 @@ private_lane :installDependencies do |options| sh("rm -rf #{podsReposPath}") end + if File.exists? "../Gemfile" + bundle_install(path: "../.gem") + end + if File.exists? "../Cartfile" begin carthage(command: "bootstrap", platform: "iOS") From 1d04958271220d0c0708d6cb373a5752ddaba662 Mon Sep 17 00:00:00 2001 From: Victor Shabanov Date: Thu, 17 Oct 2019 15:42:36 +0300 Subject: [PATCH 24/42] Change api generation and localization scripts to work with swift modules --- xcode/aux_scripts/import_strings.php | 4 ++-- xcode/build_phases/api_generator.sh | 2 +- xcode/build_phases/localization.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xcode/aux_scripts/import_strings.php b/xcode/aux_scripts/import_strings.php index 911e989..814928a 100644 --- a/xcode/aux_scripts/import_strings.php +++ b/xcode/aux_scripts/import_strings.php @@ -1,5 +1,5 @@ Date: Thu, 17 Oct 2019 15:50:28 +0300 Subject: [PATCH 25/42] Fix localization NSLocalizedString static values visibility --- xcode/aux_scripts/import_strings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/aux_scripts/import_strings.php b/xcode/aux_scripts/import_strings.php index 814928a..3f13353 100644 --- a/xcode/aux_scripts/import_strings.php +++ b/xcode/aux_scripts/import_strings.php @@ -41,7 +41,7 @@ 'extension String {'.PHP_EOL; foreach ($json as $key=>$value) { $value_without_linefeed = preg_replace("/\r|\n/", " ", $value); - $ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = NSLocalizedString("'.$key.'", comment: "")'."\n".PHP_EOL; + $ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'public static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = NSLocalizedString("'.$key.'", comment: "")'."\n".PHP_EOL; } $ios_swift_strings .= '}'.PHP_EOL; file_put_contents($localization.'String+Localization.swift', $ios_swift_strings); From 6ed301663c206e9da65498d2eec0bcd647e6cbb0 Mon Sep 17 00:00:00 2001 From: Victor Shabanov Date: Thu, 17 Oct 2019 18:54:39 +0300 Subject: [PATCH 26/42] Fix strings import script --- xcode/aux_scripts/import_strings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcode/aux_scripts/import_strings.php b/xcode/aux_scripts/import_strings.php index 3f13353..52f79d6 100644 --- a/xcode/aux_scripts/import_strings.php +++ b/xcode/aux_scripts/import_strings.php @@ -38,10 +38,10 @@ '// swiftlint:disable line_length'.PHP_EOL. '// swiftlint:disable file_length'.PHP_EOL. '// swiftlint:disable identifier_name'.PHP_EOL.PHP_EOL. - 'extension String {'.PHP_EOL; + 'public extension String {'.PHP_EOL; foreach ($json as $key=>$value) { $value_without_linefeed = preg_replace("/\r|\n/", " ", $value); - $ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'public static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = NSLocalizedString("'.$key.'", comment: "")'."\n".PHP_EOL; + $ios_swift_strings .= "\t/// ".$value_without_linefeed."\n\t".'static let '.preg_replace_callback('/_(.?)/', function ($m) { return strtoupper($m[1]); }, $key).' = NSLocalizedString("'.$key.'", comment: "")'."\n".PHP_EOL; } $ios_swift_strings .= '}'.PHP_EOL; file_put_contents($localization.'String+Localization.swift', $ios_swift_strings); From df8e8f1efc2bb8ef71bb9b0a679f307d8c9d903f Mon Sep 17 00:00:00 2001 From: TonCherAmi Date: Mon, 21 Oct 2019 18:15:19 +0300 Subject: [PATCH 27/42] up kotlin server api generator version --- gradle/apiGeneratorKotlinServer.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/apiGeneratorKotlinServer.gradle b/gradle/apiGeneratorKotlinServer.gradle index c2e8732..2f98ab0 100644 --- a/gradle/apiGeneratorKotlinServer.gradle +++ b/gradle/apiGeneratorKotlinServer.gradle @@ -7,7 +7,7 @@ configurations { } dependencies { - apigeneratorKotlinServer 'ru.touchin:api-generator:1.3.4' + apigeneratorKotlinServer 'ru.touchin:api-generator:1.4.0-alpha1' } task generateApiModelsKotlinServer doLast { From 12f908a01bdb26184a413d6d293ccd14d462645e Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Tue, 5 Nov 2019 18:21:53 +0300 Subject: [PATCH 28/42] Api generator version updated to 1.4.0-beta1 (#150) --- gradle/apiGenerator.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/apiGenerator.gradle b/gradle/apiGenerator.gradle index 2efcf09..e8f08af 100644 --- a/gradle/apiGenerator.gradle +++ b/gradle/apiGenerator.gradle @@ -7,7 +7,7 @@ configurations { } dependencies { - apigenerator 'ru.touchin:api-generator:1.4.0-alpha1' + apigenerator 'ru.touchin:api-generator:1.4.0-beta1' } android.applicationVariants.all { variant -> From 94c179f6662c521458f00f35db94867ea3b4776d Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Wed, 15 Jan 2020 13:52:43 +0300 Subject: [PATCH 29/42] added folder and file to delete capabilities for download_file.sh --- xcode/aux_scripts/download_file.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xcode/aux_scripts/download_file.sh b/xcode/aux_scripts/download_file.sh index 9bfcbc7..52bdce7 100755 --- a/xcode/aux_scripts/download_file.sh +++ b/xcode/aux_scripts/download_file.sh @@ -1,9 +1,21 @@ file_name=$1 file_link=$2 +folder_to_delete=$3 +file_to_delete=$4 folder="Downloads" file_path="./${folder}/${file_name}" +# remove folder and all files it +if [ -e ${folder_to_delete} ]; then + rm -rf ${folder_to_delete} +fi + +# remove some file +if [ -e ${file_to_delete} ]; then + rm ${file_to_delete} +fi + # make folder if not exist if ! [ -e ${folder} ]; then mkdir ${folder} From 1205e6c5bb468e581f9ea5a92467b8cf7d80e3a5 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Wed, 15 Jan 2020 16:27:02 +0300 Subject: [PATCH 30/42] added folder and file to delete capabilities for download_file.sh --- xcode/aux_scripts/download_file.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xcode/aux_scripts/download_file.sh b/xcode/aux_scripts/download_file.sh index 52bdce7..d3822a4 100755 --- a/xcode/aux_scripts/download_file.sh +++ b/xcode/aux_scripts/download_file.sh @@ -1,19 +1,19 @@ file_name=$1 file_link=$2 -folder_to_delete=$3 -file_to_delete=$4 +folder=$3 +flag_of_delete=$4 -folder="Downloads" -file_path="./${folder}/${file_name}" +key_of_delete="--remove-cached" +default_folder="Downloads" -# remove folder and all files it -if [ -e ${folder_to_delete} ]; then - rm -rf ${folder_to_delete} +if ! [ -n "$folder" ]; then + folder="${default_folder}" fi -# remove some file -if [ -e ${file_to_delete} ]; then - rm ${file_to_delete} +file_path="./${folder}/${file_name}" + +if [[ ${flag_of_delete} = ${key_of_delete} ]]; then + rm ${file_path} fi # make folder if not exist From 618547c0806a6bff58cdca791f8ef3983c1a26b7 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Wed, 15 Jan 2020 16:42:58 +0300 Subject: [PATCH 31/42] added folder and file to delete capabilities for download_file.sh --- xcode/aux_scripts/download_file.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/xcode/aux_scripts/download_file.sh b/xcode/aux_scripts/download_file.sh index d3822a4..5f6f2c7 100755 --- a/xcode/aux_scripts/download_file.sh +++ b/xcode/aux_scripts/download_file.sh @@ -1,15 +1,8 @@ file_name=$1 file_link=$2 -folder=$3 +readonly folder=${3:-"Downloads"} flag_of_delete=$4 - -key_of_delete="--remove-cached" -default_folder="Downloads" - -if ! [ -n "$folder" ]; then - folder="${default_folder}" -fi - +readonly key_of_delete="--remove-cached" file_path="./${folder}/${file_name}" if [[ ${flag_of_delete} = ${key_of_delete} ]]; then @@ -18,7 +11,7 @@ fi # make folder if not exist if ! [ -e ${folder} ]; then - mkdir ${folder} + mkdir -p ${folder} fi # download file if not downloaded From 566e165d3f89e5cbe1f9c02e3565445ce45e52e9 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Wed, 15 Jan 2020 17:02:56 +0300 Subject: [PATCH 32/42] added folder and file to delete capabilities for download_file.sh --- xcode/aux_scripts/download_file.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xcode/aux_scripts/download_file.sh b/xcode/aux_scripts/download_file.sh index 5f6f2c7..d6bc935 100755 --- a/xcode/aux_scripts/download_file.sh +++ b/xcode/aux_scripts/download_file.sh @@ -1,8 +1,20 @@ file_name=$1 file_link=$2 -readonly folder=${3:-"Downloads"} +folder=$3 flag_of_delete=$4 + readonly key_of_delete="--remove-cached" +readonly default_folder="Downloads" + +if [[ ${folder} = ${key_of_delete} ]]; then + folder="${default_folder}" + flag_of_delete="${key_of_delete}" +fi + +if ! [ -n "$folder" ]; then + folder="${default_folder}" +fi + file_path="./${folder}/${file_name}" if [[ ${flag_of_delete} = ${key_of_delete} ]]; then From 75bda07282e6a2409d2bfa033365d96a9f3f0886 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Wed, 15 Jan 2020 17:11:24 +0300 Subject: [PATCH 33/42] added folder and file to delete capabilities for download_file.sh --- xcode/aux_scripts/download_file.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcode/aux_scripts/download_file.sh b/xcode/aux_scripts/download_file.sh index d6bc935..55d74ba 100755 --- a/xcode/aux_scripts/download_file.sh +++ b/xcode/aux_scripts/download_file.sh @@ -4,7 +4,7 @@ folder=$3 flag_of_delete=$4 readonly key_of_delete="--remove-cached" -readonly default_folder="Downloads" +readonly default_folder="./Downloads" if [[ ${folder} = ${key_of_delete} ]]; then folder="${default_folder}" @@ -15,7 +15,7 @@ if ! [ -n "$folder" ]; then folder="${default_folder}" fi -file_path="./${folder}/${file_name}" +file_path="${folder}/${file_name}" if [[ ${flag_of_delete} = ${key_of_delete} ]]; then rm ${file_path} From 2b3852a21a9669ca185945e1a2a11a3b45c436bc Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 20 Jan 2020 15:51:44 +0300 Subject: [PATCH 34/42] Swiftlint correction --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 3e81483..c61fd5e 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -3,7 +3,6 @@ opt_in_rules: # performance - first_where - - last_where - empty_string - empty_count @@ -60,6 +59,7 @@ excluded: - Carthage - Pods - Generated + - Localization line_length: 128 From de4b8102c6cef3dcf45ca413dfbf5b887420d328 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 20 Jan 2020 17:22:42 +0300 Subject: [PATCH 35/42] Return last_where --- xcode/.swiftlint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index c61fd5e..b731824 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -3,6 +3,7 @@ opt_in_rules: # performance - first_where + - last_where - empty_string - empty_count From 6c1b2cb7a5d16c0b4124c7eff4d5074de0508157 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jan 2020 12:37:53 +0300 Subject: [PATCH 36/42] Added android_hooks folder and gradle task to copy build scripts hooks to project hooks --- gradle/installGitHooks.gradle | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 gradle/installGitHooks.gradle diff --git a/gradle/installGitHooks.gradle b/gradle/installGitHooks.gradle new file mode 100644 index 0000000..8f1ebc4 --- /dev/null +++ b/gradle/installGitHooks.gradle @@ -0,0 +1,7 @@ +task installGitHooks(type: Copy) { + from new File(buildScriptsDir, 'android_hooks') + into { new File(rootProject.rootDir, '.git/hooks') } + fileMode 0777 +} + +tasks.getByPath(':app:preBuild').dependsOn installGitHooks From 4206cba09953f8ddc50a1b08317c873505c7264a Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jan 2020 12:39:51 +0300 Subject: [PATCH 37/42] added pre-push hook --- android_hooks/pre-push | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 android_hooks/pre-push diff --git a/android_hooks/pre-push b/android_hooks/pre-push new file mode 100755 index 0000000..fc221d2 --- /dev/null +++ b/android_hooks/pre-push @@ -0,0 +1,21 @@ +#!/bin/sh + +echo "Pre push static analysis" + +output=$(./gradlew staticAnalysis --daemon 2>&1) + + +status=$? + +if [ "$status" = 0 ] ; then + exit 0 +else + build_date=$(date +'%Y-%m-%d_%T') + file_name="build_$build_date" + folder_name="./build_log/" + file_path="${folder_name}${file_name}" + mkdir -p "$folder_name" + echo "$output" >> "$file_path" + echo "Pre push static failed. Full log path: ${file_path}" + exit 1 +fi From 86d0c8c661cc8eddde96c589dbe7f045d328af09 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jan 2020 12:41:41 +0300 Subject: [PATCH 38/42] superfluous line removed --- android_hooks/pre-push | 1 - 1 file changed, 1 deletion(-) diff --git a/android_hooks/pre-push b/android_hooks/pre-push index fc221d2..cc5cdce 100755 --- a/android_hooks/pre-push +++ b/android_hooks/pre-push @@ -4,7 +4,6 @@ echo "Pre push static analysis" output=$(./gradlew staticAnalysis --daemon 2>&1) - status=$? if [ "$status" = 0 ] ; then From 45f17869d163edcc767ff354b51f2ac77b15c088 Mon Sep 17 00:00:00 2001 From: Daniil Borisovskii Date: Tue, 4 Feb 2020 14:36:42 +0300 Subject: [PATCH 39/42] Add buildscript for naming application bundle according to mask "${applicationId}-${versionName}-${versionCode}-${buildName}" --- gradle/applicationBundleNaming.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 gradle/applicationBundleNaming.gradle diff --git a/gradle/applicationBundleNaming.gradle b/gradle/applicationBundleNaming.gradle new file mode 100644 index 0000000..7e992e9 --- /dev/null +++ b/gradle/applicationBundleNaming.gradle @@ -0,0 +1,10 @@ +android { + defaultConfig { + setProperty( + "archivesBaseName", + "${project.android.defaultConfig.applicationId}" + + "-" + + "${project.android.defaultConfig.versionName}" + ) + } +} From 787af83f073a45b308787ade2f9f212e65c56e09 Mon Sep 17 00:00:00 2001 From: Daniil Borisovskii Date: Tue, 4 Feb 2020 16:15:57 +0300 Subject: [PATCH 40/42] Rename buildscript name from `applicationBundleNaming` to `applicationNaming.gradle` --- .../{applicationBundleNaming.gradle => applicationNaming.gradle} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename gradle/{applicationBundleNaming.gradle => applicationNaming.gradle} (100%) diff --git a/gradle/applicationBundleNaming.gradle b/gradle/applicationNaming.gradle similarity index 100% rename from gradle/applicationBundleNaming.gradle rename to gradle/applicationNaming.gradle From 4b601c981ad46c12b59dce1c5a3224ff214b977a Mon Sep 17 00:00:00 2001 From: Daniil Borisovskii Date: Tue, 4 Feb 2020 16:19:09 +0300 Subject: [PATCH 41/42] Rename buildscript from `applicationNaming` to `applicationFileNaming` --- gradle/{applicationNaming.gradle => applicationFileNaming.gradle} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename gradle/{applicationNaming.gradle => applicationFileNaming.gradle} (100%) diff --git a/gradle/applicationNaming.gradle b/gradle/applicationFileNaming.gradle similarity index 100% rename from gradle/applicationNaming.gradle rename to gradle/applicationFileNaming.gradle From 35be55201186208789eb8f6e16dcfd5b09405e2b Mon Sep 17 00:00:00 2001 From: Daniil Borisovskii Date: Tue, 4 Feb 2020 16:47:33 +0300 Subject: [PATCH 42/42] Add separate part for `versionCode` in application file naming mask --- gradle/applicationFileNaming.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle/applicationFileNaming.gradle b/gradle/applicationFileNaming.gradle index 7e992e9..6c2e7e2 100644 --- a/gradle/applicationFileNaming.gradle +++ b/gradle/applicationFileNaming.gradle @@ -4,7 +4,9 @@ android { "archivesBaseName", "${project.android.defaultConfig.applicationId}" + "-" + - "${project.android.defaultConfig.versionName}" + "${project.android.defaultConfig.versionName}" + + "-" + + "${project.android.defaultConfig.versionCode}" ) } }