Method: Fastlane::Setup.start
- Defined in:
- fastlane/lib/fastlane/setup/setup.rb
.start(user: nil, is_swift_fastfile: false) ⇒ Object
Start the setup process rubocop:disable Metrics/BlockNesting
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'fastlane/lib/fastlane/setup/setup.rb', line 36 def self.start(user: nil, is_swift_fastfile: false) if FastlaneCore::FastlaneFolder.setup? && !Helper.test? # If Fastfile.swift exists, but the swift sources folder does not, rebuild it setup_swift_support if is_swift_fastfile require 'fastlane/lane_list' Fastlane::LaneList.output(FastlaneCore::FastlaneFolder.fastfile_path) UI.important("------------------") UI.important("fastlane is already set up at path `#{FastlaneCore::FastlaneFolder.path}`, see the available lanes above") UI.("") setup_ios = self.new setup_ios.add_or_update_gemfile(update_gemfile_if_needed: false) setup_ios.suggest_next_steps return end # this is used by e.g. configuration.rb to not show warnings when running produce ENV["FASTLANE_ONBOARDING_IN_PROCESS"] = 1.to_s spinner = TTY::Spinner.new("[:spinner] Looking for iOS and Android projects in current directory...", format: :dots) spinner.auto_spin ios_projects = Dir["**/*.xcodeproj"] + Dir["**/*.xcworkspace"] ios_projects.delete_if do |path| Gem.path.any? { |gem_path| File.(path).start_with?(gem_path) } end ios_projects.delete_if { |path| path.match("fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj") } android_projects = Dir["**/*.gradle"] + Dir["**/*.gradle.kts"] spinner.success FastlaneCore::FastlaneFolder.create_folder! # Currently we prefer iOS app projects, as the `init` process is # more intelligent and does more things. The user can easily add # the `:android` platform to the resulting Fastfile if ios_projects.count > 0 current_directory = ios_projects.find_all do |current_project_path| current_project_path.split(File::Separator).count == 1 end chosen_project = nil had_multiple_projects_to_choose_from = false if current_directory.count == 1 chosen_project = current_directory.first elsif current_directory.count > 1 if current_directory.count == 2 # This is a common case (e.g. with CocoaPods), where the project has an xcodeproj and an xcworkspace file extensions = [File.extname(current_directory[0]), File.extname(current_directory[1])] if extensions.sort == [".xcodeproj", ".xcworkspace"].sort # Yep, that's this kind of setup chosen_project = current_directory.find { |d| d.end_with?(".xcworkspace") } end end chosen_project ||= UI.select("Multiple iOS projects found in current directory", current_directory) had_multiple_projects_to_choose_from = true else UI.error("It looks like there is no iOS project in the current directory, though we did find one in a sub-directory") UI.error("Please `cd` into the directory of the intended Xcode project you wish to use.") UI.user_error!("Please `cd` into the directory of the intended Xcode project you wish to use and run `fastlane init` again") end if chosen_project == "Pods.xcodeproj" unless UI.confirm("Found '#{chosen_project}', which usually isn't normally what you want. Make sure to switch to the directory containing your intended Xcode project. Would you still like to continue with #{chosen_project}?") UI.user_error!("Make sure to `cd` into the directory containing the Xcode project you intend to use and then use `fastlane init` again") end end UI.("Detected an iOS/macOS project in the current directory: '#{chosen_project}'") SetupIos.new( is_swift_fastfile: is_swift_fastfile, user: user, project_path: chosen_project, had_multiple_projects_to_choose_from: had_multiple_projects_to_choose_from ).setup_ios elsif android_projects.count > 0 UI.("Detected an Android project in the current directory...") SetupAndroid.new.setup_android else UI.error("No iOS or Android projects were found in directory '#{Dir.pwd}'") UI.error("Make sure to `cd` into the directory containing your iOS or Android app") if UI.confirm("Alternatively, would you like to manually setup a fastlane config in the current directory instead?") SetupIos.new( is_swift_fastfile: is_swift_fastfile, user: user, project_path: chosen_project, had_multiple_projects_to_choose_from: had_multiple_projects_to_choose_from, preferred_setup_method: :ios_manual ).setup_ios else UI.user_error!("Make sure to `cd` into the directory containing your project and then use `fastlane init` again") end end end |