fastlane 2.75.0.beta.20180109010003 → 2.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/credentials_manager/lib/credentials_manager/account_manager.rb +11 -9
  3. data/deliver/lib/assets/DeliverfileDefault +2 -9
  4. data/deliver/lib/assets/DeliverfileDefault.swift +2 -12
  5. data/deliver/lib/deliver/setup.rb +1 -4
  6. data/fastlane/lib/.DS_Store +0 -0
  7. data/fastlane/lib/assets/.DS_Store +0 -0
  8. data/fastlane/lib/assets/AppfileTemplate +5 -6
  9. data/fastlane/lib/assets/AppfileTemplate.swift +3 -4
  10. data/fastlane/lib/assets/DefaultFastfileTemplate +10 -67
  11. data/fastlane/lib/assets/DefaultFastfileTemplate.swift +8 -66
  12. data/fastlane/lib/fastlane/.DS_Store +0 -0
  13. data/fastlane/lib/fastlane/actions/.DS_Store +0 -0
  14. data/fastlane/lib/fastlane/actions/docs/.DS_Store +0 -0
  15. data/fastlane/lib/fastlane/actions/get_build_number.rb +7 -1
  16. data/fastlane/lib/fastlane/commands_generator.rb +11 -19
  17. data/fastlane/lib/fastlane/setup/.DS_Store +0 -0
  18. data/fastlane/lib/fastlane/setup/setup.rb +247 -34
  19. data/fastlane/lib/fastlane/setup/setup_android.rb +65 -39
  20. data/fastlane/lib/fastlane/setup/setup_ios.rb +419 -280
  21. data/fastlane/lib/fastlane/version.rb +1 -1
  22. data/fastlane/swift/Deliverfile.swift +1 -1
  23. data/fastlane/swift/Gymfile.swift +1 -1
  24. data/fastlane/swift/Matchfile.swift +1 -1
  25. data/fastlane/swift/Precheckfile.swift +1 -1
  26. data/fastlane/swift/Scanfile.swift +1 -1
  27. data/fastlane/swift/Screengrabfile.swift +1 -1
  28. data/fastlane/swift/Snapshotfile.swift +1 -1
  29. data/fastlane_core/lib/.DS_Store +0 -0
  30. data/fastlane_core/lib/fastlane_core/.DS_Store +0 -0
  31. data/fastlane_core/lib/fastlane_core/configuration/configuration.rb +3 -1
  32. data/sigh/lib/assets/resign.sh +0 -1
  33. data/snapshot/lib/assets/SnapfileTemplate +9 -12
  34. data/snapshot/lib/snapshot/commands_generator.rb +2 -0
  35. data/snapshot/lib/snapshot/setup.rb +20 -9
  36. data/spaceship/lib/spaceship.rb +4 -0
  37. data/spaceship/lib/spaceship/portal/ui/select_team.rb +3 -3
  38. data/spaceship/lib/spaceship/tunes/tunes_client.rb +15 -11
  39. metadata +24 -17
  40. data/fastlane/lib/assets/FastfileTemplateAndroid +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 068043183fb1c67f72a848d2c925a7459802ba1d
4
- data.tar.gz: 8e7d05dec8d9dc85f93fb78c5dc60180fd686770
3
+ metadata.gz: 2d4ac71197859bfb32444f719155c8f963a3c535
4
+ data.tar.gz: ddd3618377eb5fe2163219be25c97b7f23a355eb
5
5
  SHA512:
6
- metadata.gz: 04131a7558ce3285bb43529bdf19a783729f1d58d81c49197e27da9359e87afc7202f55cadb3d969815c2fb16129370ffa2cfd96bf08a9df0c5382d3de2948a2
7
- data.tar.gz: 2b4aa1e49fff2b5839f4c4eff2d4ba0aec1b2a91b8981443829a1911519ae7cb1154b15fb38c575bafccbb4dc29aca8d185be05d96634519d75fa591e2a3415d
6
+ metadata.gz: 195e9f71c3f29866ae73af8c48c391e87794869166bf97d30398dc9e6b95ce5c1439e6733311de96087bd07a5df5bcfbf0879232fb2fe5a70744df8665501573
7
+ data.tar.gz: 7ac81f1c8a2235db9d27750240a2e71a5352996f67d52a3257164e4d2cb55ac4aea0b9e8d3f89a92d3cc62acd66f24d6e4fa2e203687707b4e0af868ef1e11dc
@@ -104,16 +104,18 @@ module CredentialsManager
104
104
  private
105
105
 
106
106
  def ask_for_login
107
- puts("-------------------------------------------------------------------------------------".green)
108
- puts("Please provide your Apple Developer Program account credentials".green)
109
- puts("The login information you enter will be stored in your macOS Keychain".green)
110
- if default_prefix?
111
- # We don't want to show this message, if we ask for the application specific password
112
- # which has a different prefix
113
- puts("You can also pass the password using the `FASTLANE_PASSWORD` environment variable".green)
114
- puts("More information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager".green)
107
+ if ENV["FASTLANE_HIDE_LOGIN_INFORMATION"].to_s.length == 0
108
+ puts("-------------------------------------------------------------------------------------".green)
109
+ puts("Please provide your Apple Developer Program account credentials".green)
110
+ puts("The login information you enter will be stored in your macOS Keychain".green)
111
+ if default_prefix?
112
+ # We don't want to show this message, if we ask for the application specific password
113
+ # which has a different prefix
114
+ puts("You can also pass the password using the `FASTLANE_PASSWORD` environment variable".green)
115
+ puts("See more information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager".green)
116
+ end
117
+ puts("-------------------------------------------------------------------------------------".green)
115
118
  end
116
- puts("-------------------------------------------------------------------------------------".green)
117
119
 
118
120
  if @user.to_s.length == 0
119
121
  raise "Missing username, and running in non-interactive shell" if $stdout.isatty == false
@@ -1,10 +1,3 @@
1
- ###################### More Options ######################
2
- # If you want to have even more control, check out the documentation
1
+ # The Deliverfile allows you to store various iTunes Connect metadata
2
+ # For more information, check out the docs
3
3
  # https://docs.fastlane.tools/actions/deliver
4
-
5
-
6
- ###################### Automatically generated ######################
7
- # Feel free to remove the following line if you use fastlane (which you should)
8
-
9
- app_identifier "[[APP_IDENTIFIER]]" # The bundle identifier of your app
10
- username "[[USERNAME]]" # your Apple ID user
@@ -1,13 +1,3 @@
1
- /************************ More Options ************************/
2
- // If you want to have even more control, check out the documentation
1
+ // The Deliverfile allows you to store various iTunes Connect metadata
2
+ // For more information, check out the docs
3
3
  // https://docs.fastlane.tools/actions/deliver
4
-
5
-
6
- /************************ Automatically generated ************************/
7
-
8
- class Deliverfile: DeliverfileProtocol {
9
- // Feel free to remove the following lines
10
- // These values can go in Appfile.swift
11
- var appIdentifier: String { return "[[APP_IDENTIFIER]]" } // The bundle identifier of your app
12
- var username: String { return "[[USERNAME]]" } // your Apple ID user
13
- }
@@ -42,10 +42,7 @@ module Deliver
42
42
  generate_metadata_files(v, File.join(deliver_path, 'metadata'))
43
43
 
44
44
  # Generate the final Deliverfile here
45
- deliver = File.read(deliverfile_path)
46
- deliver.gsub!("[[APP_IDENTIFIER]]", options[:app].bundle_id)
47
- deliver.gsub!("[[USERNAME]]", Spaceship::Tunes.client.user)
48
- return deliver
45
+ return File.read(deliverfile_path)
49
46
  end
50
47
 
51
48
  def deliverfile_path
Binary file
@@ -1,7 +1,6 @@
1
- app_identifier "[[APP_IDENTIFIER]]" # The bundle identifier of your app
2
- apple_id "[[APPLE_ID]]" # Your Apple email address
1
+ # app_identifier "[[APP_IDENTIFIER]]" # The bundle identifier of your app
2
+ # apple_id "[[APPLE_ID]]" # Your Apple email address
3
3
 
4
- team_id "[[DEV_PORTAL_TEAM_ID]]" # Developer Portal Team ID
5
- [[ITC_TEAM]]
6
- # you can even provide different app identifiers, Apple IDs and team names per lane:
7
- # More information: https://docs.fastlane.tools/advanced/#appfile
4
+ [[TEAMS]]
5
+ # For more information about the Appfile, see:
6
+ # https://docs.fastlane.tools/advanced/#appfile
@@ -1,8 +1,7 @@
1
1
  var appIdentifier: String { return "[[APP_IDENTIFIER]]" } // The bundle identifier of your app
2
2
  var appleID: String { return "[[APPLE_ID]]" } // Your Apple email address
3
3
 
4
- var teamID: String { return "[[DEV_PORTAL_TEAM_ID]]" } // Developer Portal Team ID
5
- var itcTeam: String? { return [[ITC_TEAM]] } // iTunes Connect Team ID (may be nil if no team)
4
+ [[TEAMS]]
6
5
 
7
- // you can even provide different app identifiers, Apple IDs and team names per lane:
8
- // More information: https://docs.fastlane.tools/advanced/#appfile
6
+ // For more information about the Appfile, see:
7
+ // https://docs.fastlane.tools/advanced/#appfile
@@ -1,73 +1,16 @@
1
- # Customize this file, documentation can be found here:
2
- # https://docs.fastlane.tools/actions/
3
- # All available actions: https://docs.fastlane.tools/actions
4
- # can also be listed using the `fastlane actions` command
5
-
6
- # Change the syntax highlighting to Ruby
7
- # All lines starting with a # are ignored when running `fastlane`
8
-
9
- # If you want to automatically update fastlane if a new version is available:
1
+ # This file contains the fastlane.tools configuration
2
+ # You can find the documentation at https://docs.fastlane.tools
3
+ #
4
+ # For a list of all available actions, check out
5
+ #
6
+ # https://docs.fastlane.tools/actions
7
+ #
8
+
9
+ # Uncomment the line if you want fastlane to automatically update itself
10
10
  # update_fastlane
11
11
 
12
- # This is the minimum version number required.
13
- # Update this, if you use features of a newer version
14
- min_fastlane_version("[[FASTLANE_VERSION]]")
15
-
16
12
  default_platform(:ios)
17
13
 
18
14
  platform :ios do
19
- before_all do
20
- # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
21
- cocoapods
22
- carthage
23
- end
24
-
25
- desc "Runs all the tests"
26
- lane :test do
27
- run_tests
28
- end
29
-
30
- desc "Submit a new Beta Build to Apple TestFlight"
31
- desc "This will also make sure the profile is up to date"
32
- lane :beta do
33
- # sync_code_signing(type: "appstore") # more information: https://codesigning.guide
34
- build_app[[SCHEME]] # more options available
35
- upload_to_testflight
36
-
37
- # sh "your_script.sh"
38
- # You can also use other beta testing services here (run `fastlane actions`)
39
- end
40
-
41
- desc "Deploy a new version to the App Store"
42
- lane :release do
43
- # sync_code_signing(type: "appstore")
44
- capture_screenshots
45
- build_app[[SCHEME]] # more options available
46
- upload_to_app_store(force: true)
47
- # frame_screenshots
48
- end
49
-
50
- # You can define as many lanes as you want
51
-
52
- after_all do |lane|
53
- # This block is called, only if the executed lane was successful
54
-
55
- # slack(
56
- # message: "Successfully deployed new App Update."
57
- # )
58
- end
59
-
60
- error do |lane, exception|
61
- # slack(
62
- # message: exception.message,
63
- # success: false
64
- # )
65
- end
15
+ [[LANES]]
66
16
  end
67
-
68
-
69
- # More information about multiple platforms in fastlane: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
70
- # All available actions: https://docs.fastlane.tools/actions
71
-
72
- # fastlane reports which actions are used. No personal data is recorded.
73
- # Learn more at https://docs.fastlane.tools/#metrics
@@ -1,71 +1,13 @@
1
- // Customize this file, documentation can be found here:
2
- // https://docs.fastlane.tools/
3
- // All available actions: https://docs.fastlane.tools/actions
4
- // can also be listed using the `fastlane actions` command
5
-
6
- // Change the syntax highlighting to Swift
7
- // All lines starting with // are ignored when running `fastlane`
8
-
9
- // If you want to automatically update fastlane if a new version is available:
10
- // updateFastlane()
1
+ // This file contains the fastlane.tools configuration
2
+ // You can find the documentation at https://docs.fastlane.tools
3
+ //
4
+ // For a list of all available actions, check out
5
+ //
6
+ // https://docs.fastlane.tools/actions
7
+ //
11
8
 
12
9
  import Foundation
13
10
 
14
11
  class Fastfile: LaneFile {
15
- // This is the minimum version number required.
16
- // Update this, if you use features of a newer version
17
- var fastlaneVersion: String { return "[[FASTLANE_VERSION]]" }
18
-
19
- func beforeAll() {
20
- // environmentVariables["SLACK_URL"] = "https://hooks.slack.com/services/..."
21
- cocoapods()
22
- carthage()
23
- }
24
-
25
- func testLane() {
26
- desc("Runs all the tests")
27
- runTests()
28
- }
29
-
30
- func betaLane() {
31
- desc("Submit a new Beta Build to Apple TestFlight. This will also make sure the profile is up to date")
32
-
33
- // syncCodeSigning(gitUrl: "gitUrl", appIdentifier: [appIdentifier], username: appleID)
34
- buildApp([[SCHEME]]) // more options available
35
- uploadToTestflight(username: appleID)
36
- // You can also use other beta testing services here (run `fastlane actions`)
37
- }
38
-
39
- func releaseLane() {
40
- desc("Deploy a new version to the App Store")
41
-
42
- // syncCodeSigning(gitUrl: "gitUrl", type: "appstore", appIdentifier: [appIdentifier], username: appleID)
43
- captureScreenshots()
44
- buildApp([[SCHEME]]) // more options available
45
- uploadToAppStore(username: appleID, app: appIdentifier, force: true)
46
- // frameScreenshots()
47
- }
48
-
49
- // You can define as many lanes as you want
50
-
51
- func afterAll(currentLane: String) {
52
- // This block is called, only if the executed lane was successful
53
- // slack(
54
- // message: "Successfully deployed new App Update.",
55
- // slackUrl: "slackURL"
56
- // )
57
- }
58
-
59
- func onError(currentLane: String, errorInfo: String) {
60
- // slack(
61
- // message: errorInfo,
62
- // slackUrl: "slackUrl",
63
- // success: false
64
- // )
65
- }
66
-
67
- // All available actions: https://docs.fastlane.tools/actions
68
-
69
- // fastlane reports which actions are used. No personal data is recorded.
70
- // Learn more at https://github.com/fastlane/fastlane/#metrics
12
+ [[LANES]]
71
13
  }
@@ -32,6 +32,7 @@ module Fastlane
32
32
  end
33
33
  return build_number
34
34
  rescue => ex
35
+ return false if params[:hide_error_when_versioning_disabled]
35
36
  UI.error('Before being able to increment and read the version number from your Xcode project, you first need to setup your project properly. Please follow the guide at https://developer.apple.com/library/content/qa/qa1827/_index.html')
36
37
  raise ex
37
38
  end
@@ -61,7 +62,12 @@ module Fastlane
61
62
  verify_block: proc do |value|
62
63
  UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with?(".xcworkspace")
63
64
  UI.user_error!("Could not find Xcode project") if !File.exist?(value) and !Helper.is_test?
64
- end)
65
+ end),
66
+ FastlaneCore::ConfigItem.new(key: :hide_error_when_versioning_disabled,
67
+ env_name: "FL_BUILD_NUMBER_HIDE_ERROR_WHEN_VERSIONING_DISABLED",
68
+ description: "Used during `fastlane init` to hide the error message",
69
+ default_value: false,
70
+ type: Boolean)
65
71
  ]
66
72
  end
67
73
 
@@ -115,26 +115,16 @@ module Fastlane
115
115
 
116
116
  c.option('-u STRING', '--user STRING', String, 'iOS projects only: Your Apple ID')
117
117
 
118
- CrashlyticsBetaCommandLineHandler.apply_options(c)
118
+ # CrashlyticsBetaCommandLineHandler.apply_options(c)
119
119
 
120
120
  c.action do |args, options|
121
- if args[0] == 'beta'
122
- beta_info = CrashlyticsBetaCommandLineHandler.info_from_options(options)
123
- Fastlane::CrashlyticsBeta.new(beta_info, Fastlane::CrashlyticsBetaUi.new).run
124
- else
125
- is_swift_fastfile = args.include?("swift")
126
- Fastlane::Setup.new.run(user: options.user, is_swift_fastfile: is_swift_fastfile)
127
- end
128
- end
129
- end
130
-
131
- command :init_swift do |c|
132
- c.syntax = 'fastlane init_swift'
133
- c.description = 'Helps you with your initial fastlane setup for Swift'
134
- c.option('-u STRING', '--user STRING', String, 'iOS projects only: Your Apple ID')
135
-
136
- c.action do |args, options|
137
- Fastlane::Setup.new.run(user: options.user, is_swift_fastfile: true)
121
+ # if args[0] == 'beta'
122
+ # beta_info = CrashlyticsBetaCommandLineHandler.info_from_options(options)
123
+ # Fastlane::CrashlyticsBeta.new(beta_info, Fastlane::CrashlyticsBetaUi.new).run
124
+ # else
125
+ is_swift_fastfile = args.include?("swift")
126
+ Fastlane::Setup.start(user: options.user, is_swift_fastfile: is_swift_fastfile)
127
+ # end
138
128
  end
139
129
  end
140
130
 
@@ -354,7 +344,9 @@ module Fastlane
354
344
  return true if FastlaneCore::FastlaneFolder.setup?
355
345
 
356
346
  create = UI.confirm('Could not find fastlane in current directory. Make sure to have your fastlane configuration files inside a folder called "fastlane". Would you like to set fastlane up?')
357
- Fastlane::Setup.new.run if create
347
+ if create
348
+ Fastlane::Setup.start
349
+ end
358
350
  return false
359
351
  end
360
352
  end
@@ -1,60 +1,273 @@
1
+ require "tty-spinner"
2
+
1
3
  module Fastlane
2
4
  class Setup
5
+ # Is the current `setup` using a swift based configuration file
6
+ attr_accessor :is_swift_fastfile
7
+
8
+ # :ios or :android
9
+ attr_accessor :platform
10
+
11
+ # Path to the xcodeproj or xcworkspace
12
+ attr_accessor :project_path
13
+
14
+ # Used for :manual sometimes
15
+ attr_accessor :preferred_setup_method
16
+
17
+ # remember if there were multiple projects
18
+ # if so, we set it as part of the Fastfile
19
+ attr_accessor :had_multiple_projects_to_choose_from
20
+
21
+ # The current content of the generated Fastfile
22
+ attr_accessor :fastfile_content
23
+
24
+ # Appfile
25
+ attr_accessor :appfile_content
26
+
27
+ # For iOS projects that's the Apple ID email
28
+ attr_accessor :user
29
+
30
+ # This is the lane that we tell the user to run to try the new fastlane setup
31
+ # This needs to be setup by each setup
32
+ attr_accessor :lane_to_mention
33
+
3
34
  # Start the setup process
4
- def run(user: nil, is_swift_fastfile: false)
35
+ # rubocop:disable Metrics/BlockNesting
36
+ def self.start(user: nil, is_swift_fastfile: false)
5
37
  if FastlaneCore::FastlaneFolder.setup? and !Helper.is_test?
6
- UI.important("fastlane is already set up at path #{FastlaneCore::FastlaneFolder.path}")
38
+ require 'fastlane/lane_list'
39
+ Fastlane::LaneList.output(FastlaneCore::FastlaneFolder.fastfile_path)
40
+ UI.important("------------------")
41
+ UI.important("fastlane is already set up at path `#{FastlaneCore::FastlaneFolder.path}`, see the available lanes above")
42
+ UI.message("")
43
+ self.new.suggest_next_steps
7
44
  return
8
45
  end
9
46
 
10
- platform = nil
11
- if is_ios?
12
- UI.message("Detected iOS/Mac project in current directory...")
13
- platform = :ios
14
- elsif is_android?
15
- UI.message("Detected Android project in current directory...")
16
- platform = :android
17
- elsif is_react_native?
18
- UI.important("Detected react-native app. To set up fastlane, please run")
19
- UI.command("fastlane init")
20
- UI.important("in the sub-folder for each platform (\"ios\" or \"android\")")
21
- UI.user_error!("Please navigate to the platform subfolder and run `fastlane init` again")
47
+ # this is used by e.g. configuration.rb to not show warnings when running produce
48
+ ENV["FASTLANE_ONBOARDING_IN_PROCESS"] = 1.to_s
49
+
50
+ spinner = TTY::Spinner.new("[:spinner] Looking for iOS and Android projects in current directory...", format: :dots)
51
+ spinner.auto_spin
52
+
53
+ ios_projects = Dir["**/*.xcodeproj"] + Dir["**/*.xcworkspace"]
54
+ android_projects = Dir["**/*.gradle"]
55
+
56
+ spinner.success
57
+
58
+ FastlaneCore::FastlaneFolder.create_folder!
59
+
60
+ # Currently we prefer iOS app projects, as the `init` process is
61
+ # more intelligent and does more things. The user can easily add
62
+ # the `:android` platform to the resulting Fastfile
63
+ if ios_projects.count > 0
64
+ current_directory = ios_projects.find_all do |current_project_path|
65
+ current_project_path.split(File::Separator).count == 1
66
+ end
67
+ chosen_project = nil
68
+ had_multiple_projects_to_choose_from = false
69
+
70
+ if current_directory.count == 1
71
+ chosen_project = current_directory.first
72
+ elsif current_directory.count > 1
73
+ if current_directory.count == 2
74
+ # This is a common case (e.g. with CocoaPods), where the project has an xcodeproj and an xcworkspace file
75
+ extensions = [File.extname(current_directory[0]), File.extname(current_directory[1])]
76
+ if extensions.sort == [".xcodeproj", ".xcworkspace"].sort
77
+ # Yep, that's this kind of setup
78
+ chosen_project = current_directory.find { |d| d.end_with?(".xcworkspace") }
79
+ end
80
+ end
81
+ chosen_project ||= UI.select("Multiple iOS projects found in current directory", current_directory)
82
+ had_multiple_projects_to_choose_from = true
83
+ else
84
+ UI.error("It looks like there is no iOS project in the current directory, though we did find one in a sub-directory")
85
+ UI.error("Please `cd` into the directory of the intended Xcode project you wish to use.")
86
+ UI.user_error!("Please `cd` into the directory of the intended Xcode project you wish to use and run `fastlane init` again")
87
+ end
88
+
89
+ if chosen_project == "Pods.xcodeproj"
90
+ 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}?")
91
+ UI.user_error!("Make sure to `cd` into the directory containing the Xcode project you intend to use and then use `fastlane init` again")
92
+ end
93
+ end
94
+ UI.message("Detected an iOS/macOS project in the current directory: '#{chosen_project}'")
95
+
96
+ SetupIos.new(
97
+ is_swift_fastfile: is_swift_fastfile,
98
+ user: user,
99
+ project_path: chosen_project,
100
+ had_multiple_projects_to_choose_from: had_multiple_projects_to_choose_from
101
+ ).setup_ios
102
+ elsif android_projects.count > 0
103
+ UI.message("Detected an Android project in the current directory...")
104
+ SetupAndroid.new.setup_android
105
+ else
106
+ UI.error("No iOS or Android projects were found in directory '#{Dir.pwd}'")
107
+ UI.error("Make sure to `cd` into the directory containing your iOS or Android app")
108
+ if UI.confirm("Alternatively, would you like to manually setup a fastlane config in the current directory instead?")
109
+ SetupIos.new(
110
+ is_swift_fastfile: is_swift_fastfile,
111
+ user: user,
112
+ project_path: chosen_project,
113
+ had_multiple_projects_to_choose_from: had_multiple_projects_to_choose_from,
114
+ preferred_setup_method: :ios_manual
115
+ ).setup_ios
116
+ else
117
+ UI.user_error!("Make sure to `cd` into the directory containing your project and then use `fastlane init` again")
118
+ end
119
+ end
120
+ end
121
+ # rubocop:enable Metrics/BlockNesting
122
+
123
+ def initialize(is_swift_fastfile: nil, user: nil, project_path: nil, had_multiple_projects_to_choose_from: nil, preferred_setup_method: nil)
124
+ self.is_swift_fastfile = is_swift_fastfile
125
+ self.user = user
126
+ self.project_path = project_path
127
+ self.had_multiple_projects_to_choose_from = had_multiple_projects_to_choose_from
128
+ self.preferred_setup_method = preferred_setup_method
129
+ end
130
+
131
+ # Helpers
132
+ def welcome_to_fastlane
133
+ UI.header("Welcome to fastlane 🚀")
134
+ UI.message("fastlane can help you with all kinds of automation for your mobile app")
135
+ UI.message("We recommend automating one task first, and then gradually automating more over time")
136
+ end
137
+
138
+ # Append a lane to the current Fastfile template we're generating
139
+ def append_lane(lane)
140
+ lane.compact! # remove nil values
141
+
142
+ new_lines = "\n\n"
143
+ if self.is_swift_fastfile
144
+ new_lines = "" unless self.fastfile_content.include?("lane() {") # the first lane we don't want new lines
145
+ self.fastfile_content.gsub!("[[LANES]]", "#{new_lines}\t#{lane.join("\n\t")}[[LANES]]")
22
146
  else
23
- UI.important("Couldn't automatically detect the platform")
24
- val = UI.confirm("Is this project an iOS project?")
25
- platform = (val ? :ios : :android)
147
+ new_lines = "" unless self.fastfile_content.include?("lane :") # the first lane we don't want new lines
148
+ self.fastfile_content.gsub!("[[LANES]]", "#{new_lines} #{lane.join("\n ")}[[LANES]]")
26
149
  end
150
+ end
151
+
152
+ # Append a team to the Appfile
153
+ def append_team(team)
154
+ self.appfile_content.gsub!("[[TEAMS]]", "#{team}\n[[TEAMS]]")
155
+ end
156
+
157
+ def write_fastfile!
158
+ # Write the Fastfile
159
+ fastfile_file_name = "Fastfile"
160
+ fastfile_file_name += ".swift" if self.is_swift_fastfile
161
+
162
+ fastfile_path = File.join(FastlaneCore::FastlaneFolder.path, fastfile_file_name)
163
+ self.fastfile_content.gsub!("[[LANES]]", "") # since we always keep it until writing out
164
+ File.write(fastfile_path, self.fastfile_content) # remove trailing spaces before platform ends
27
165
 
28
- if platform == :ios
29
- SetupIos.new.run(user: user, is_swift_fastfile: is_swift_fastfile)
30
- elsif platform == :android
31
- SetupAndroid.new.run
166
+ appfile_file_name = "Appfile"
167
+ appfile_file_name += ".swift" if self.is_swift_fastfile
168
+ appfile_path = File.join(FastlaneCore::FastlaneFolder.path, appfile_file_name)
169
+ self.appfile_content.gsub!("[[TEAMS]]", "")
170
+
171
+ File.write(appfile_path, self.appfile_content)
172
+
173
+ UI.header("✅ Successfully generated fastlane configuration")
174
+ UI.message("Generated Fastfile at path `#{fastfile_path}`")
175
+ UI.message("Generated Appfile at path `#{appfile_path}`")
176
+
177
+ UI.message("Please check the newly generated configuration files into git along with your project")
178
+ UI.message("This way everyone in your team can benefit from your fastlane setup")
179
+ continue_with_enter
180
+ end
181
+
182
+ def finish_up
183
+ write_fastfile!
184
+ setup_swift_support if is_swift_fastfile
185
+ show_analytics_note
186
+ explain_concepts
187
+ suggest_next_steps
188
+ end
189
+
190
+ def setup_swift_support
191
+ runner_source_resources = "#{Fastlane::ROOT}/swift/."
192
+ destination_path = File.expand_path('swift', FastlaneCore::FastlaneFolder.path)
193
+ FileUtils.cp_r(runner_source_resources, destination_path)
194
+ UI.success("Copied Swift fastlane runner project to '#{destination_path}'.")
195
+
196
+ Fastlane::SwiftLaneManager.first_time_setup
197
+ end
198
+
199
+ def fastfile_template_content
200
+ if self.is_swift_fastfile
201
+ path = "#{Fastlane::ROOT}/lib/assets/DefaultFastfileTemplate.swift"
32
202
  else
33
- UI.user_error!("Couldn't find platform '#{platform}'")
203
+ path = "#{Fastlane::ROOT}/lib/assets/DefaultFastfileTemplate"
34
204
  end
35
205
 
36
- # Now that we've setup all the things, if we're using Swift, do the first time setup
37
- if is_swift_fastfile
38
- Fastlane::SwiftLaneManager.first_time_setup
206
+ return File.read(path)
207
+ end
208
+
209
+ def appfile_template_content
210
+ if self.platform == :ios
211
+ if self.is_swift_fastfile
212
+ path = "#{Fastlane::ROOT}/lib/assets/AppfileTemplate.swift"
213
+ else
214
+ path = "#{Fastlane::ROOT}/lib/assets/AppfileTemplate"
215
+ end
216
+ else
217
+ path = "#{Fastlane::ROOT}/lib/assets/AppfileTemplateAndroid"
39
218
  end
219
+
220
+ return File.read(path)
40
221
  end
41
222
 
42
- def is_ios?
43
- (Dir["*.xcodeproj"] + Dir["*.xcworkspace"]).count > 0
223
+ def explain_concepts
224
+ UI.header("fastlane lanes")
225
+ UI.message("fastlane uses a " + "`Fastfile`".yellow + " to store the automation configuration")
226
+ UI.message("Within that, you'll see different " + "lanes".yellow + ".")
227
+ UI.message("Each is there to automate a different task, like screenshots, code signing, or pushing new releases")
228
+ continue_with_enter
229
+
230
+ UI.header("How to customize your Fastfile")
231
+ UI.message("Use a text editor of your choice to open the newly created Fastfile and take a look")
232
+ UI.message("You can now edit the available lanes and actions to customize the setup to fit your needs")
233
+ UI.message("To get a list of all the available actions, open " + "https://docs.fastlane.tools/actions".cyan)
234
+ continue_with_enter
44
235
  end
45
236
 
46
- def is_android?
47
- Dir["*.gradle"].count > 0
237
+ def continue_with_enter
238
+ UI.input("Continue by pressing Enter ⏎")
48
239
  end
49
240
 
50
- def is_react_native?
51
- SetupIos.project_uses_react_native?(path: "./ios")
241
+ def suggest_next_steps
242
+ UI.header("Where to go from here?")
243
+ if self.platform == :android
244
+ UI.message("📸 Learn more about how to automatically generate localized Google Play screenshots:")
245
+ UI.message("\t\thttps://docs.fastlane.tools/getting-started/android/screenshots/".cyan)
246
+ UI.message("👩‍✈️ Learn more about distribution to beta testing services:")
247
+ UI.message("\t\thttps://docs.fastlane.tools/getting-started/android/beta-deployment/".cyan)
248
+ UI.message("🚀 Learn more about how to automate the Google Play release process:")
249
+ UI.message("\t\thttps://docs.fastlane.tools/getting-started/android/release-deployment/".cyan)
250
+ else
251
+ UI.message("📸 Learn more about how to automatically generate localized App Store screenshots:")
252
+ UI.message("\t\thttps://docs.fastlane.tools/getting-started/ios/screenshots/".cyan)
253
+ UI.message("👩‍✈️ Learn more about distribution to beta testing services:")
254
+ UI.message("\t\thttps://docs.fastlane.tools/getting-started/ios/beta-deployment/".cyan)
255
+ UI.message("🚀 Learn more about how to automate the App Store release process:")
256
+ UI.message("\t\thttps://docs.fastlane.tools/getting-started/ios/appstore-deployment/".cyan)
257
+ UI.message("👩‍⚕️ Lern more about how to setup code signing with fastlane")
258
+ UI.message("\t\thttps://docs.fastlane.tools/codesigning/getting-started/".cyan)
259
+ end
260
+
261
+ # we crash here, so that this never happens when a new setup method is added
262
+ return if self.lane_to_mention.to_s.length == 0
263
+ UI.message("")
264
+ UI.message("To try your new fastlane setup, just enter and run")
265
+ UI.command("fastlane #{self.lane_to_mention}")
52
266
  end
53
267
 
54
- def show_analytics
268
+ def show_analytics_note
55
269
  UI.message("fastlane will collect the number of errors for each action to detect integration issues")
56
- UI.message("No sensitive/private information will be uploaded")
57
- UI.message("Learn more at https://github.com/fastlane/fastlane#metrics")
270
+ UI.message("No sensitive/private information will be uploaded, more information: " + "https://docs.fastlane.tools/#metrics".cyan)
58
271
  end
59
272
  end
60
273
  end