Class: Pindo::Command::Utils::Renewproj
- Inherits:
-
Pindo::Command::Utils
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Utils
- Pindo::Command::Utils::Renewproj
- Includes:
- DeployOptions
- Defined in:
- lib/pindo/command/utils/renewproj.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes included from DeployOptions
#additional_args, #apple_id, #args_adhoc_flag, #args_appconfig, #args_appconfig_dir, #args_appconfig_fullname, #args_apple_id, #args_appstore_flag, #args_array, #args_bundle_id, #args_dev_flag, #args_macos_flag, #args_repo_name, #argv_temp, #bundle_id, #bundle_id_extension, #bundle_id_extensionad, #bundle_id_extensionporn, #bundle_id_imessage, #bundle_id_keyboard, #bundle_id_pushcontent, #bundle_id_pushservice, #bundle_id_siri, #bundle_id_siriui, #bundle_id_watchapp, #bundle_id_watchapp_extension, #bundle_id_widget, #config_json, #deploy_acount_id, #deploy_group_id, #deploy_icloud_id, #deploy_identifier, #deploy_identifier_extension, #deploy_identifier_extensionad, #deploy_identifier_extensionporn, #deploy_identifier_imessage, #deploy_identifier_keyboard, #deploy_identifier_pushcontent, #deploy_identifier_pushservice, #deploy_identifier_siri, #deploy_identifier_siriui, #deploy_identifier_watchapp, #deploy_identifier_watchapp_extension, #deploy_identifier_widget, #deploy_repo_name, #group_id, #icloud_id, #newconfuse_flag, #oldconfuse_flag
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
- #create_project(new_proj_name: nil, new_proj_path: nil, old_proj_name: nil, old_proj_path: nil) ⇒ Object
- #get_new_proj_path ⇒ Object
- #get_old_proj_name(old_proj_path: nil) ⇒ Object
-
#initialize(argv) ⇒ Renewproj
constructor
A new instance of Renewproj.
- #run ⇒ Object
- #validate! ⇒ Object
Methods included from DeployOptions
#check_config_version, #get_build_type_args, #get_bundle_id_map, #get_confuse_type_args, #init_deploy_params, #init_develop_params, #print_params_info
Methods inherited from Pindo::Command
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, which, which!
Constructor Details
#initialize(argv) ⇒ Renewproj
Returns a new instance of Renewproj.
62 63 64 65 66 |
# File 'lib/pindo/command/utils/renewproj.rb', line 62 def initialize(argv) @project_name = argv.option('n') @args_nocreate_flag = argv.flag?('nocreate') super end |
Class Method Details
.options ⇒ Object
55 56 57 58 59 60 |
# File 'lib/pindo/command/utils/renewproj.rb', line 55 def self. [ ['--n=', 'input project name'], ['--nocreate', 'no create xcode project'], ].concat(super) end |
Instance Method Details
#create_project(new_proj_name: nil, new_proj_path: nil, old_proj_name: nil, old_proj_path: nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/pindo/command/utils/renewproj.rb', line 87 def create_project(new_proj_name:nil, new_proj_path:nil, old_proj_name:nil, old_proj_path:nil) new_proj_fullname = File.join(new_proj_path, new_proj_name) + ".xcodeproj" Xcodeproj::Project.new(new_proj_fullname).save new_proj_obj = Xcodeproj::Project.open(new_proj_fullname) old_proj_fullname = File.join(old_proj_path, old_proj_name) + ".xcodeproj" old_proj_obj = Xcodeproj::Project.open(old_proj_fullname) Pindo::XcodeProjectHelper.copy_to_newproject(new_proj_path:new_proj_path, new_proj_name:new_proj_name, old_proj_path:old_proj_path, old_proj_name:old_proj_name) Pindo::XcodeProjectHelper.create_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj) Pindo::XcodeProjectHelper.add_file_to_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj) Pindo::XcodeProjectHelper.config_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj) Pindo::XcodeProjectHelper.setting_new_project(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj) end |
#get_new_proj_path ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/pindo/command/utils/renewproj.rb', line 140 def get_new_proj_path current_dir = Dir.pwd temp_dir_name = @project_name + '_' +Time.now.strftime('%y%m%d_%H%M%S') new_project_dir = File.join(File::(current_dir + "/../") , temp_dir_name) if File.exist?(new_project_dir) system 'sh rm -rf ' + new_project_dir FileUtils.rm_rf(new_project_dir) end FileUtils.mkdir(new_project_dir) return new_project_dir end |
#get_old_proj_name(old_proj_path: nil) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/pindo/command/utils/renewproj.rb', line 156 def get_old_proj_name(old_proj_path:nil) old_project_fullname = "" Dir.foreach(old_proj_path) do |file| if file =~ /(.*).xcodeproj/ old_project_fullname = file break; end end old_proj_name = File.basename(old_project_fullname, ".xcodeproj") return old_proj_name end |
#run ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/pindo/command/utils/renewproj.rb', line 109 def run system 'pod deintegrate' current_dir = Dir.pwd old_project_dir = current_dir old_proj_name = get_old_proj_name(old_proj_path:current_dir) if @args_nocreate_flag puts "2==================" new_proj_name = old_proj_name new_project_dir = old_project_dir ENV['pindo_new_project_dir'] = old_project_dir else new_proj_name = @project_name if new_proj_name.nil? puts "Please input a new project name." return end new_project_dir = get_new_proj_path ENV['pindo_new_project_dir'] = new_project_dir create_project(new_proj_name:new_proj_name, new_proj_path:new_project_dir, old_proj_name:old_proj_name, old_proj_path:old_project_dir) end if File.exist?(File.join(new_project_dir, 'Podfile.lock')) FileUtils.rm_rf(File.join(new_project_dir, 'Podfile.lock')) end system "open #{new_project_dir}" puts "New Project Dir: #{new_project_dir}" puts "Done !" end |
#validate! ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/pindo/command/utils/renewproj.rb', line 68 def validate! super if @project_name.nil? || @project_name.empty? if @config_json['project_info'] && @config_json['project_info']['project_name'] @project_name = @config_json['project_info']['project_name'] end end if @project_name.nil? @project_name = ask('Project Name: ') end @project_name = "Example" if @project_name.nil? || @project_name.empty? @project_name = @project_name.gsub(/ /, ''); @project_name = @project_name.gsub(/\'/, ''); puts "project_name = #{@project_name}" end |