Class: Pod::Command::Vemars::Create
- Inherits:
-
Pod::Command::Vemars
- Object
- Pod::Command
- Pod::Command::Vemars
- Pod::Command::Vemars::Create
- Defined in:
- lib/cocoapods-vemars/command/vemars/create.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Create
constructor
A new instance of Create.
- #openXcodeWorkSpace ⇒ Object
- #podInstallIfNeeded ⇒ Object
- #run ⇒ Object
- #runXcodeTest ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pod::Command::Vemars
Constructor Details
#initialize(argv) ⇒ Create
Returns a new instance of Create.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 35 def initialize(argv) @name = argv.shift_argument @version = argv.shift_argument @language = argv.option('language', 'objc') git_url = argv.option('git', 'https://github.com/volcengine/ve_Template_iOS.git') @silent = argv.flag?('silent', false) @test = argv.flag?('test', false) @repo_no_update = argv.flag?('pod_repo_no_update',false) @appkey = argv.option('appkey', '') @bundle_id = argv.option('bundle_id', nil) @selected_components = argv.option('com', "").split(',') @config_json = argv.option('config', nil) service_url = argv.option('service_url',nil) sources = argv.option('sources','https://github.com/volcengine/volcengine-specs.git,https://cdn.cocoapods.org/') @project = VemarsProject.new(@appkey, @selected_components, @config_json, @version, @bundle_id, @name, @language, git_url,service_url,sources) super @additional_args = argv.remainder! end |
Class Method Details
.options ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 19 def self. = [ ['--language=LANGUAGE', 'language should be objc or swift'], ['--silent', 'do not run pod install'], ['--bundle_id=bundle_id', 'the bundle_id from Vemars'], ['--com=COM1,COM2', 'Selected components in vemars.'], ['--config=CONFIG_PATH', 'config path of vemars.'], ['--service_url=SERVICE_URL', 'url of vemars CLI service.'], ['--git=GIT_URL', 'git url of demo repo'], ['--pod_repo_no_update', 'do not run pod repo update'], ['--sources','pod repos sources'], ['--test','should run test'] ] .concat(super.reject { |option, _| option == '--silent' }) end |
Instance Method Details
#openXcodeWorkSpace ⇒ Object
102 103 104 105 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 102 def openXcodeWorkSpace workspace_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project","'#{@project.basicInfo.name}'.xcworkspace"]) system("open -a /Applications/Xcode.app '#{workspace_dir}'") end |
#podInstallIfNeeded ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 78 def podInstallIfNeeded puts "Current dir: #{Dir.pwd}" project_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project"]) puts "Pod install directory: #{project_dir}" if @silent puts "Pod install skipped!" puts "You can run Pod install in '#{project_dir}' later!" puts "You can run Pod install in '#{project_dir}' later!" puts "You can run Pod install in '#{project_dir}' later!" return end Dir.chdir(project_dir) do # system('bundle install') # system('bundle exec pod install --repo-update') if @repo_no_update puts "pod install with no repo update" system('pod install --no-repo-update') else system('pod install --repo-update') end end end |
#run ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 67 def run puts 'Hi, welcome to vemars!' @project.generate podInstallIfNeeded if @test runXcodeTest else openXcodeWorkSpace end end |
#runXcodeTest ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 108 def runXcodeTest puts "run test with xcode build" workspace_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project"]) Dir.chdir(workspace_dir) do cmd = "xcodebuild clean build -workspace '#{@project.basicInfo.name}'.xcworkspace -scheme '#{@project.basicInfo.name}'_InHouse -configuration Debug -destination generic/platform=iOS -sdk iphonesimulator ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO" system cmd end end |
#validate! ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cocoapods-vemars/command/vemars/create.rb', line 54 def validate! super if !@test if @config_json.nil? || @config_json.empty? help! 'An config.json for the project is required.' end unless File.exist? @config_json help! "onekit-config.json is not found at #{Dir.pwd}" end end # help! '信息有误' unless @project.validate? end |