lib/flow/cli/cmd_manager.rb in flow-cli-0.0.1 vs lib/flow/cli/cmd_manager.rb in flow-cli-0.0.2
- old
+ new
@@ -13,13 +13,18 @@
end
desc "build_yaml_file", "build flow ci project yaml"
def build_yaml_file
config = ProjectAnalytics.new.config
+
+ # 用来交互
+ # TODO: 优化点,以后放到其他地方
+ config[:gym_config] = ask_gym_build_options if config[:flow_language] == "objc" && ENV["FLOW_CLI_TEST"] != "TRUE"
+
str = FlowYamlBuilder.new(config).build_yaml
- raise YamlError, "存在 flow.yml, 删除后才能重新生成" if File.file?("flow.yml")
- File.open("flow.yml", "wb") do |file|
+ raise YamlError, "存在 #{FLOW_YML_NAME}, 删除后才能重新生成" if File.file?(FLOW_YML_NAME)
+ File.open(FLOW_YML_NAME, "wb") do |file|
file.write(str)
end
@warning.call "yaml created...\n#{str}"
end
@@ -42,10 +47,15 @@
map ['v', '-v', '--version'] => :version
def version
puts VERSION
end
+ desc "upgrade", "upgrade flow-cli"
+ def upgrade
+ run_script "gem install flow-cli"
+ end
+
desc 'help', 'Describe available commands or one specific command (aliases: `h`).'
map Thor::HELP_MAPPINGS => :help
def help(command = nil, subcommand = false)
print_line
puts @error.call("VERSION ALPHA\n Support IOS project ONLY, temporarily.")
@@ -53,12 +63,12 @@
super
end
no_commands do
def select_yml_steps(step_name)
- raise YamlError, "Can not found flow.yml" unless File.file?("flow.yml")
- dict = YAML.safe_load(File.read("flow.yml"))
+ raise YamlError, "Can not found flow.yml" unless File.file?(FLOW_YML_NAME)
+ dict = YAML.safe_load(File.read(FLOW_YML_NAME))
the_steps = []
dict["flows"].map do |flow|
filtered_steps = flow["steps"].select { |step| step["name"] == step_name }
the_steps += filtered_steps
@@ -79,11 +89,11 @@
cmd = TTY::Command.new
cmd.run(script)
end
def yml_build_script
- if File.file?("flow.yml") == false
+ if File.file?(FLOW_YML_NAME) == false
return unless @prompt.yes?('no flow.yml found, need to build . y/n')
build_yaml_file
end
scripts = get_scripts(select_yml_steps("build"))
scripts.first if scripts.count > 0
@@ -95,9 +105,17 @@
private
def print_line
puts "*" * 30
+ end
+
+ def ask_gym_build_options
+ user_gym_config = {}
+ user_gym_config[:export_method] = @prompt.select("export_method? ", %w[development app-store ad-hoc package enterprise developer-id])
+ user_gym_config[:silent] = "" if @prompt.yes?("less log?")
+
+ user_gym_config
end
end
end
end