Add Features class
This commit is contained in:
parent
dbfc6153ab
commit
aa00fe13ca
|
|
@ -106,24 +106,15 @@ private_lane :addShield do |options|
|
|||
end
|
||||
end
|
||||
|
||||
private_lane :uploadFeaturesToProject do |options|
|
||||
require 'json'
|
||||
|
||||
features_string = options[:features] # "DebitCardFeature,Sprint5Feature,CreditCardFeature"
|
||||
feature_names = features_string.split(",").map { |value| value.strip } # [ "DebitCardFeature", "Sprint5Feature", "CreditCardFeature" ]
|
||||
|
||||
# Generate JSON from feature names
|
||||
feature_bodies = feature_names.map { |feature_name| { :name => feature_name, :enabled => true} }
|
||||
features = { :features => features_body }
|
||||
features_json = JSON.pretty_generate(features)
|
||||
|
||||
# Put features JSON to project file
|
||||
private_lane lane :uploadFeaturesToProject do |options|
|
||||
app_target_folder_name = options[:appName] || $appName
|
||||
features_file_path = get_features_file_path(app_target_folder_name)
|
||||
|
||||
File.open(features_file_path, "w") do |f|
|
||||
f.write(features_json)
|
||||
end
|
||||
project_features_file_path = File.expand_path "../#{app_target_folder_name}/Resources/Features.json"
|
||||
common_features_file_path = File.expand_path "../common/build_options/Features.json"
|
||||
|
||||
builder_features_list = options[:features] # [ "Feature1", "Feature2", "Feature3" ]
|
||||
|
||||
Touchlane::Features.generate_features_file_in_project(builder_features_list, common_features_file_path, project_features_file_path)
|
||||
end
|
||||
|
||||
private_lane :buildConfiguration do |options|
|
||||
|
|
@ -421,10 +412,6 @@ def get_google_services_plist_path(app_target_folder_name, configuration_type)
|
|||
File.expand_path "../#{app_target_folder_name}/Resources/#{configuration_type.prefix}-GoogleService-Info.plist"
|
||||
end
|
||||
|
||||
def get_features_file_path(app_target_folder_name)
|
||||
File.expand_path "../#{app_target_folder_name}/Resources/Features.json"
|
||||
end
|
||||
|
||||
def set_xcconfig_for_configuration_of_project(lane_name, configuration, xcodeproj_path)
|
||||
require 'xcodeproj'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
module Touchlane
|
||||
require_relative "touchlane/configuration_type"
|
||||
require_relative "touchlane/configuration"
|
||||
require_relative "touchlane/features"
|
||||
require_relative "match/storage/local_storage"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
require 'json'
|
||||
require 'yaml'
|
||||
|
||||
module Touchlane
|
||||
class Features
|
||||
|
||||
def self.generate_features_file_in_project(builder_features_list, common_features_file_path, project_features_file_path)
|
||||
common_features_list = get_features_from_file(common_features_file_path)["features"]
|
||||
|
||||
# Check is entered features contains in configuration file
|
||||
features_diff = builder_features_list - common_features_list
|
||||
|
||||
if !features_diff.empty?
|
||||
raise "Unexpected features: " + features_diff.join(', ')
|
||||
end
|
||||
|
||||
# Generate JSON from feature names
|
||||
feature_bodies = builder_features_list.map { |feature_name| { :name => feature_name, :enabled => true} }
|
||||
features = { :features => features_body }
|
||||
features_json = JSON.pretty_generate(features)
|
||||
|
||||
unless File.exists? project_features_file_path
|
||||
raise "Unable to load features from file at #{path}"
|
||||
else
|
||||
File.open(project_features_file_path, "w") do |f|
|
||||
f.write(features_json)
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_features_from_file(path)
|
||||
unless File.exists? path
|
||||
raise "Unable to load features from file at #{path}"
|
||||
else
|
||||
YAML.load_file(path)["features"]
|
||||
end
|
||||
end
|
||||
|
||||
private_class_method :new, :get_features_from_file
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue