flow-cli 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24aa1cf518f2148d862cc0b5607e18471f5494e2
4
- data.tar.gz: ff58cc71bb78b8ec63c7aa5c8dff647385f1c405
3
+ metadata.gz: 21fd812ff71af588d84221a5db5edff651e5fe85
4
+ data.tar.gz: 83886130d5a88d1d594a425d6ab0db2aa427fae2
5
5
  SHA512:
6
- metadata.gz: 9942e1cb0598a931c901eb5bdbfd6775e278d1b6b49bf74959ad2968e237e8045868cd9176f51be82c80473060d58f4e401de4b9d6abe0a30f39a7b2546f76d9
7
- data.tar.gz: c6a5595d4ec972caedd40ffd63456814ee9aa8bc0746225283528598e0794c28e8311954488f61e609cfdb4d4fc9c3a130a4ed4eeef24327aa5b1f589ec0ef7c
6
+ metadata.gz: e312ff26145629f00ae94d5894561bb954c5359db18fde128eec3107da3d7cdd6aaa2d959ecd1e59478799d7172b39e2fa3f8a0675b766cd23a8598f0c356cc2
7
+ data.tar.gz: a9b08da5091376a43217d14c5018a5bd9a8e96dd192befec7a4e301f56927a15d45b6298d6043072fcb14dced5d47440aee4bc291ee7bb1a6e1b3e7b287bc45e
@@ -15,9 +15,14 @@ module Flow::Cli
15
15
  desc "build_yaml_file", "build flow ci project yaml"
16
16
  def build_yaml_file
17
17
  config = ProjectAnalytics.new.config
18
+
19
+ # 用来交互
20
+ # TODO: 优化点,以后放到其他地方
21
+ config[:gym_config] = ask_gym_build_options if config[:flow_language] == "objc" && ENV["FLOW_CLI_TEST"] != "TRUE"
22
+
18
23
  str = FlowYamlBuilder.new(config).build_yaml
19
- raise YamlError, "存在 flow.yml, 删除后才能重新生成" if File.file?("flow.yml")
20
- File.open("flow.yml", "wb") do |file|
24
+ raise YamlError, "存在 #{FLOW_YML_NAME}, 删除后才能重新生成" if File.file?(FLOW_YML_NAME)
25
+ File.open(FLOW_YML_NAME, "wb") do |file|
21
26
  file.write(str)
22
27
  end
23
28
  @warning.call "yaml created...\n#{str}"
@@ -44,6 +49,11 @@ module Flow::Cli
44
49
  puts VERSION
45
50
  end
46
51
 
52
+ desc "upgrade", "upgrade flow-cli"
53
+ def upgrade
54
+ run_script "gem install flow-cli"
55
+ end
56
+
47
57
  desc 'help', 'Describe available commands or one specific command (aliases: `h`).'
48
58
  map Thor::HELP_MAPPINGS => :help
49
59
  def help(command = nil, subcommand = false)
@@ -55,8 +65,8 @@ module Flow::Cli
55
65
 
56
66
  no_commands do
57
67
  def select_yml_steps(step_name)
58
- raise YamlError, "Can not found flow.yml" unless File.file?("flow.yml")
59
- dict = YAML.safe_load(File.read("flow.yml"))
68
+ raise YamlError, "Can not found flow.yml" unless File.file?(FLOW_YML_NAME)
69
+ dict = YAML.safe_load(File.read(FLOW_YML_NAME))
60
70
 
61
71
  the_steps = []
62
72
  dict["flows"].map do |flow|
@@ -81,7 +91,7 @@ module Flow::Cli
81
91
  end
82
92
 
83
93
  def yml_build_script
84
- if File.file?("flow.yml") == false
94
+ if File.file?(FLOW_YML_NAME) == false
85
95
  return unless @prompt.yes?('no flow.yml found, need to build . y/n')
86
96
  build_yaml_file
87
97
  end
@@ -98,6 +108,14 @@ module Flow::Cli
98
108
  def print_line
99
109
  puts "*" * 30
100
110
  end
111
+
112
+ def ask_gym_build_options
113
+ user_gym_config = {}
114
+ user_gym_config[:export_method] = @prompt.select("export_method? ", %w[development app-store ad-hoc package enterprise developer-id])
115
+ user_gym_config[:silent] = "" if @prompt.yes?("less log?")
116
+
117
+ user_gym_config
118
+ end
101
119
  end
102
120
  end
103
121
  end
@@ -0,0 +1,5 @@
1
+ module Flow
2
+ module Cli
3
+ FLOW_YML_NAME = "flow.yml".freeze
4
+ end
5
+ end
@@ -49,7 +49,7 @@ module Flow::Cli
49
49
 
50
50
  # 生成编译脚本
51
51
  def generate_custom_build_step
52
- script = IosBuildStepGenerator.new(flow_cli_config[:gym_config]).generate_gym_script
52
+ script = IosBuildStepGenerator.new(flow_cli_config).generate_gym_script
53
53
  {
54
54
  name: "build",
55
55
  scripts: [script]
@@ -3,40 +3,35 @@ require 'gym'
3
3
 
4
4
  module Flow::Cli
5
5
  class IosBuildStepGenerator
6
- attr_accessor :config
7
- attr_accessor :debug
8
- def initialize(default_config = nil)
9
- if default_config.nil? && ENV["FLOW_CLI_TEST"] != "TRUE"
6
+ attr_accessor :cli_config
7
+ def initialize(cli_config = {})
8
+ self.cli_config = cli_config
9
+ if ENV["FLOW_CLI_TEST"] != "TRUE"
10
10
  Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, {})
11
11
  config = Gym.config.values(ask: false).reject { |_k, v| v.nil? }
12
12
  allowed_params = %i[workspace project scheme clean output_name configuration
13
13
  codesigning_identity include_symbols include_bitcode
14
14
  export_method export_options export_xcargs]
15
- default_config = config.select { |k, _v| allowed_params.include? k }
15
+ @gym_config = config.select { |k, _v| allowed_params.include? k }
16
16
  else
17
- default_config = {}
17
+ @gym_config = {}
18
18
  end
19
-
20
- self.config = default_config
21
19
  end
22
20
 
23
- def generate_gym_script(category = 'ad-hoc', force = false)
24
- set_export_params(category, force)
21
+ def generate_gym_script
22
+ merge_user_cli_gym_config
25
23
  "fastlane gym build #{build_gym_params}"
26
24
  end
27
25
 
28
26
  # 返回 由 gym 调用的 core 的生成的相关参数
29
- def set_export_params(category = 'ad-hoc', force = false)
30
- raise ParamsError, "#{category} not exists" unless %w[app-store ad-hoc package enterprise development
31
- developer-id].include? category
32
- return config if config[:export_method] && force == false
33
-
34
- config[:export_method] = category
35
- config
27
+ def merge_user_cli_gym_config
28
+ user_gym_config = { export_method: 'ad-hoc' }.merge(cli_config[:gym_config] || {} )
29
+ @gym_config.merge!(user_gym_config)
30
+ @gym_config
36
31
  end
37
32
 
38
33
  def build_gym_params
39
- config.map { |k, v| "--#{k} #{v}" }.join(' ')
34
+ @gym_config.map { |k, v| "--#{k} #{v}".rstrip }.join(' ')
40
35
  end
41
36
  end
42
37
  end
@@ -1,5 +1,5 @@
1
1
  module Flow
2
2
  module Cli
3
- VERSION = "0.0.1".freeze
3
+ VERSION = "0.0.2".freeze
4
4
  end
5
5
  end
data/lib/flow/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative "./cli/version"
2
+ require_relative "./cli/constant"
2
3
  require_relative "./cli/vendors/all"
3
4
  require_relative "./cli/exception"
4
5
  require_relative "./cli/project_analytics"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flow-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - atpking
@@ -159,6 +159,7 @@ files:
159
159
  - flow-cli.gemspec
160
160
  - lib/flow/cli.rb
161
161
  - lib/flow/cli/cmd_manager.rb
162
+ - lib/flow/cli/constant.rb
162
163
  - lib/flow/cli/exception.rb
163
164
  - lib/flow/cli/flow_yaml_builder.rb
164
165
  - lib/flow/cli/ios_build_step_generator.rb