fastlane-plugin-apprepo 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +0 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +4 -0
  6. data/Gemfile +7 -1
  7. data/README.md +9 -2
  8. data/assets/RepofileDefault +34 -0
  9. data/assets/apprepo.png +0 -0
  10. data/assets/circle.key +27 -0
  11. data/assets/fastlane.png +0 -0
  12. data/assets/manifest.png +0 -0
  13. data/circle.yml +11 -9
  14. data/coverage/.last_run.json +5 -0
  15. data/coverage/.resultset.json +1244 -0
  16. data/coverage/.resultset.json.lock +0 -0
  17. data/fastlane-plugin-apprepo.gemspec +6 -2
  18. data/fastlane/Appfile +1 -0
  19. data/fastlane/Fastfile +42 -0
  20. data/fastlane/Pluginfile +1 -0
  21. data/fastlane/Repofile +33 -0
  22. data/greeter.rb +6 -0
  23. data/lib/fastlane/plugin/apprepo.rb +26 -7
  24. data/lib/fastlane/plugin/apprepo/actions/apprepo_action.rb +106 -92
  25. data/lib/fastlane/plugin/apprepo/actions/download_manifest.rb +40 -0
  26. data/lib/fastlane/plugin/apprepo/actions/init.rb +46 -0
  27. data/lib/fastlane/plugin/apprepo/actions/rubocop.rb +29 -0
  28. data/lib/fastlane/plugin/apprepo/actions/run.rb +69 -0
  29. data/lib/fastlane/plugin/apprepo/actions/submit.rb +41 -0
  30. data/lib/fastlane/plugin/apprepo/analyser.rb +35 -0
  31. data/lib/fastlane/plugin/apprepo/command.rb +17 -0
  32. data/lib/fastlane/plugin/apprepo/commands_generator.rb +121 -0
  33. data/lib/fastlane/plugin/apprepo/detect_values.rb +29 -0
  34. data/lib/fastlane/plugin/apprepo/helper/analyser.rb +35 -0
  35. data/lib/fastlane/plugin/apprepo/helper/commands_generator.rb +121 -0
  36. data/lib/fastlane/plugin/apprepo/helper/detect_values.rb +29 -0
  37. data/lib/fastlane/plugin/apprepo/helper/loader.rb +15 -0
  38. data/lib/fastlane/plugin/apprepo/helper/manifest.rb +44 -0
  39. data/lib/fastlane/plugin/apprepo/helper/options.rb +120 -0
  40. data/lib/fastlane/plugin/apprepo/helper/runner.rb +68 -0
  41. data/lib/fastlane/plugin/apprepo/helper/setup.rb +49 -0
  42. data/lib/fastlane/plugin/apprepo/helper/uploader.rb +301 -0
  43. data/lib/fastlane/plugin/apprepo/loader.rb +15 -0
  44. data/lib/fastlane/plugin/apprepo/manifest.rb +44 -0
  45. data/lib/fastlane/plugin/apprepo/options.rb +120 -0
  46. data/lib/fastlane/plugin/apprepo/runner.rb +68 -0
  47. data/lib/fastlane/plugin/apprepo/setup.rb +49 -0
  48. data/lib/fastlane/plugin/apprepo/uploader.rb +301 -0
  49. data/lib/fastlane/plugin/apprepo/version.rb +4 -3
  50. data/manifest.json +10 -0
  51. data/sampleapp.ipa +1 -0
  52. data/test +0 -0
  53. metadata +46 -2
@@ -0,0 +1,29 @@
1
+ module Fastlane
2
+ module Actions
3
+ class RubocopAction < Action
4
+ def self.run(_params)
5
+ sh 'bundle exec rubocop -D'
6
+ end
7
+
8
+ #####################################################
9
+ # @!group Documentation
10
+ #####################################################
11
+
12
+ def self.description
13
+ 'Runs the code style checks'
14
+ end
15
+
16
+ def self.available_options
17
+ []
18
+ end
19
+
20
+ def self.authors
21
+ ['KrauseFx']
22
+ end
23
+
24
+ def self.is_supported?(_platform)
25
+ true
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,69 @@
1
+ require_relative '../version.rb'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class RunAction < Action
6
+ def self.run(_params)
7
+ program :version, Apprepo::VERSION
8
+ program :description, Apprepo::DESCRIPTION
9
+ program :help, 'Author', 'Matej Sychra <suculent@me.com>'
10
+ program :help, 'Website', 'https://github.com/suculent/apprepo'
11
+ program :help, 'GitHub', 'https://github.com/suculent/apprepo/tree/master/apprepo'
12
+ program :help_formatter, :compact
13
+
14
+ generator = FastlaneCore::CommanderGenerator.new
15
+ generator.generate(Apprepo::Options.available_options)
16
+
17
+ global_option('--verbose') { $verbose = true }
18
+
19
+ always_trace!
20
+
21
+ puts _params
22
+
23
+ command :run do |c|
24
+ c.syntax = 'apprepo'
25
+ c.description = 'Upload IPA and metadata to SFTP (e.g. Apprepo)'
26
+ c.action do |_args, options|
27
+ config = FastlaneCore::Configuration
28
+ available_opts = Apprepo::Options.available_options
29
+ options = config.create(available_opts, options.__hash__)
30
+ loaded = options.load_configuration_file('Repofile')
31
+ loaded = true if options[:repo_description] || options[:ipa]
32
+
33
+ unless loaded
34
+ UI.message('[Apprepo::CommandsGenerator] configuration file not loaded')
35
+ if UI.confirm('No Repofile found. Do you want to setup apprepo?')
36
+ require 'apprepo/setup'
37
+ Apprepo::Setup.new.run(options)
38
+ return 0
39
+ end
40
+ end
41
+
42
+ Apprepo::Runner.new(options).run
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ #####################################################
49
+ # @!group Documentation
50
+ #####################################################
51
+
52
+ def self.description
53
+ 'Runs the default Apprepo action'
54
+ end
55
+
56
+ def self.available_options
57
+ []
58
+ end
59
+
60
+ def self.authors
61
+ ['suculent@me.com']
62
+ end
63
+
64
+ def self.is_supported?(_platform)
65
+ true
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,41 @@
1
+ module Fastlane
2
+ module Actions
3
+ class SubmitAction < Action
4
+ def self.run(_params)
5
+ #sh 'bundle exec rubocop -D'
6
+ puts _params
7
+ command :submit do |c|
8
+ c.syntax = 'apprepo submit'
9
+ c.description = 'Submit a specific build-nr, use latest.'
10
+ c.action do |_args, options|
11
+ config = FastlaneCore::Configuration
12
+ available_opts = Apprepo::Options.available_options
13
+ options = config.create(available_opts, options.__hash__)
14
+ options.load_configuration_file('Repofile')
15
+ Apprepo::Runner.new(options).run
16
+ end
17
+ end
18
+ end
19
+
20
+ #####################################################
21
+ # @!group Documentation
22
+ #####################################################
23
+
24
+ def self.description
25
+ 'Submits IPA to Apprepo'
26
+ end
27
+
28
+ def self.available_options
29
+ []
30
+ end
31
+
32
+ def self.authors
33
+ ['suculent@me.com']
34
+ end
35
+
36
+ def self.is_supported?(_platform)
37
+ true
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'net/ssh'
4
+ require 'net/sftp'
5
+ require 'fastlane_core'
6
+
7
+ require_relative 'uploader'
8
+
9
+ module Fastlane
10
+ module Apprepo
11
+ # Should provide metadata for current appcode
12
+ class Analyser
13
+ attr_accessor :options
14
+
15
+ def initialize(options)
16
+ self.options = options
17
+ end
18
+
19
+ # Fetches remote app version from metadata
20
+ def fetch_app_version(options)
21
+ metadata = Apprepo::Uploader.new(options).download_manifest_only
22
+ FastlaneCore::UI.command_output('TODO: Parse version out from metadata')
23
+ puts JSON.pretty_generate(metadata) unless metadata.nil?
24
+ FastlaneCore::UI.important('TODO: parse out the bundle-version')
25
+ metadata['bundle-version']
26
+ end
27
+
28
+ # only for testing, should be empty
29
+ def run
30
+ FastlaneCore::UI.message('Analyser run, will fetch_app_version...')
31
+ fetch_app_version(options)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module Apprepo
2
+ # Responsible for performing commands
3
+ # will replace contents of commands-generator.
4
+ module Command
5
+ # Command class
6
+ class Make
7
+ def run
8
+ fputs 'make run executed'
9
+ end
10
+ end
11
+
12
+ # Legacy classless run method
13
+ def run
14
+ fputs 'legacy run executed'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,121 @@
1
+ require 'commander'
2
+
3
+ HighLine.track_eof = false
4
+
5
+ module Fastlane
6
+ module Apprepo
7
+ # This class is responsible for providing commands with respective actions
8
+ class CommandsGenerator
9
+ include Commander::Methods
10
+
11
+ def self.start
12
+ FastlaneCore::UpdateChecker.start_looking_for_update('Apprepo')
13
+ new.run
14
+ ensure
15
+ checker = FastlaneCore::UpdateChecker
16
+ checker.show_update_status('Apprepo', Apprepo::VERSION)
17
+ end
18
+
19
+ def download_manifest
20
+ command :download_manifest
21
+ end
22
+
23
+ def init
24
+ command :init
25
+ end
26
+
27
+ # rubocop:disable Metrics/AbcSize
28
+ # rubocop:disable Metrics/MethodLength
29
+ # rubocop:disable Metrics/CyclomaticComplexity
30
+ # rubocop:disable Metrics/PerceivedComplexity
31
+ # rubocop:disable Style/GlobalVars
32
+ def run
33
+ program :version, Apprepo::VERSION
34
+ program :description, Apprepo::DESCRIPTION
35
+ program :help, 'Author', 'Matej Sychra <suculent@me.com>'
36
+ program :help, 'Website', 'https://github.com/suculent/apprepo'
37
+ program :help, 'GitHub', 'https://github.com/suculent/apprepo/tree/master/apprepo'
38
+ program :help_formatter, :compact
39
+
40
+ generator = FastlaneCore::CommanderGenerator.new
41
+ generator.generate(Apprepo::Options.available_options)
42
+
43
+ global_option('--verbose') { $verbose = true }
44
+
45
+ always_trace!
46
+
47
+ command :run do |c|
48
+ c.syntax = 'Apprepo'
49
+ c.description = 'Upload IPA and metadata to SFTP (e.g. Apprepo)'
50
+ c.action do |_args, options|
51
+ config = FastlaneCore::Configuration
52
+ available_opts = Apprepo::Options.available_options
53
+ options = config.create(available_opts, options.__hash__)
54
+ loaded = options.load_configuration_file('Repofile')
55
+ loaded = true if options[:repo_description] || options[:ipa]
56
+
57
+ unless loaded
58
+ UI.message('[Apprepo::CommandsGenerator] configuration file not loaded')
59
+ if UI.confirm('No Repofile found. Do you want to setup Apprepo?')
60
+ require 'Apprepo/setup'
61
+ Apprepo::Setup.new.run(options)
62
+ return 0
63
+ end
64
+ end
65
+
66
+ Apprepo::Runner.new(options).run
67
+ end
68
+ end
69
+
70
+ command :download_manifest do |c|
71
+ c.syntax = 'Apprepo download_manifest'
72
+ c.description = 'Download metadata only'
73
+ c.action do |_args, options|
74
+ config = FastlaneCore::Configuration
75
+ available_opts = Apprepo::Options.available_options
76
+ options = config.create(available_opts, options.__hash__)
77
+ options.load_configuration_file('Repofile')
78
+ Apprepo::Runner.new(options).download_manifest
79
+ end
80
+ end
81
+
82
+ command :submit do |c|
83
+ c.syntax = 'Apprepo submit'
84
+ c.description = 'Submit a specific build-nr, use latest.'
85
+ c.action do |_args, options|
86
+ config = FastlaneCore::Configuration
87
+ available_opts = Apprepo::Options.available_options
88
+ options = config.create(available_opts, options.__hash__)
89
+ options.load_configuration_file('Repofile')
90
+ Apprepo::Runner.new(options).run
91
+ end
92
+ end
93
+
94
+ command :init do |c|
95
+ c.syntax = 'Apprepo init'
96
+ c.description = 'Create the initial `Apprepo` configuration'
97
+ c.action do |_args, options|
98
+ if File.exist?('Repofile') || File.exist?('fastlane/Repofile')
99
+ UI.important('You already got a running Apprepo setup.')
100
+ return 0
101
+ end
102
+
103
+ require 'Apprepo/setup'
104
+ config = FastlaneCore::Configuration
105
+ available_opts = Apprepo::Options.available_options
106
+ options = config.create(available_opts, options.__hash__)
107
+ Apprepo::Runner.new(options)
108
+ Apprepo::Setup.new.run(options)
109
+ end
110
+ end
111
+
112
+ # rubocop:enable Metrics/AbcSize
113
+ # rubocop:enable Metrics/MethodLength
114
+
115
+ default_command :run
116
+
117
+ run!
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,29 @@
1
+
2
+ module Fastlane
3
+ module Apprepo
4
+ # This class is responsible for detecting values from IPA.
5
+ class DetectValues
6
+ def run!(options)
7
+ find_app_identifier(options)
8
+ find_version(options)
9
+ end
10
+
11
+ def find_app_identifier(options)
12
+ return if options[:app_identifier]
13
+ if options[:ipa]
14
+ # identifier = Apprepo::Analyser.fetch_app_identifier(options[:ipa])
15
+ end
16
+ options[:app_identifier] = identifier unless identifier.to_s.empty?
17
+ input_message = 'The Bundle Identifier of your App: '
18
+ options[:app_identifier] ||= UI.input(input_message)
19
+ end
20
+
21
+ def find_version(options)
22
+ unless options[:ipa].nil?
23
+ opt = Apprepo::Analyser.new(options)
24
+ options[:app_version] ||= opt.fetch_app_version(options[:ipa])
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'net/ssh'
4
+ require 'net/sftp'
5
+ require 'fastlane_core'
6
+
7
+ require_relative 'uploader'
8
+
9
+ module Fastlane
10
+ module Apprepo
11
+ # Should provide metadata for current appcode
12
+ class Analyser
13
+ attr_accessor :options
14
+
15
+ def initialize(options)
16
+ self.options = options
17
+ end
18
+
19
+ # Fetches remote app version from metadata
20
+ def fetch_app_version(options)
21
+ metadata = Apprepo::Uploader.new(options).download_manifest_only
22
+ FastlaneCore::UI.command_output('TODO: Parse version out from metadata')
23
+ puts JSON.pretty_generate(metadata) unless metadata.nil?
24
+ FastlaneCore::UI.important('TODO: parse out the bundle-version')
25
+ metadata['bundle-version']
26
+ end
27
+
28
+ # only for testing, should be empty
29
+ def run
30
+ FastlaneCore::UI.message('Analyser run, will fetch_app_version...')
31
+ fetch_app_version(options)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,121 @@
1
+ require 'commander'
2
+
3
+ HighLine.track_eof = false
4
+
5
+ module Fastlane
6
+ module Apprepo
7
+ # This class is responsible for providing commands with respective actions
8
+ class CommandsGenerator
9
+ include Commander::Methods
10
+
11
+ def self.start
12
+ FastlaneCore::UpdateChecker.start_looking_for_update('apprepo')
13
+ new.run
14
+ ensure
15
+ checker = FastlaneCore::UpdateChecker
16
+ checker.show_update_status('apprepo', Apprepo::VERSION)
17
+ end
18
+
19
+ def download_manifest
20
+ command :download_manifest
21
+ end
22
+
23
+ def init
24
+ command :init
25
+ end
26
+
27
+ # rubocop:disable Metrics/AbcSize
28
+ # rubocop:disable Metrics/MethodLength
29
+ # rubocop:disable Metrics/CyclomaticComplexity
30
+ # rubocop:disable Metrics/PerceivedComplexity
31
+ # rubocop:disable Style/GlobalVars
32
+ def run
33
+ program :version, Apprepo::VERSION
34
+ program :description, Apprepo::DESCRIPTION
35
+ program :help, 'Author', 'Matej Sychra <suculent@me.com>'
36
+ program :help, 'Website', 'https://github.com/suculent/apprepo'
37
+ program :help, 'GitHub', 'https://github.com/suculent/apprepo/tree/master/apprepo'
38
+ program :help_formatter, :compact
39
+
40
+ generator = FastlaneCore::CommanderGenerator.new
41
+ generator.generate(Apprepo::Options.available_options)
42
+
43
+ global_option('--verbose') { $verbose = true }
44
+
45
+ always_trace!
46
+
47
+ command :run do |c|
48
+ c.syntax = 'apprepo'
49
+ c.description = 'Upload IPA and metadata to SFTP (e.g. Apprepo)'
50
+ c.action do |_args, options|
51
+ config = FastlaneCore::Configuration
52
+ available_opts = Apprepo::Options.available_options
53
+ options = config.create(available_opts, options.__hash__)
54
+ loaded = options.load_configuration_file('Repofile')
55
+ loaded = true if options[:repo_description] || options[:ipa]
56
+
57
+ unless loaded
58
+ UI.message('[Apprepo::CommandsGenerator] configuration file not loaded')
59
+ if UI.confirm('No Repofile found. Do you want to setup apprepo?')
60
+ require 'apprepo/setup'
61
+ Apprepo::Setup.new.run(options)
62
+ return 0
63
+ end
64
+ end
65
+
66
+ Apprepo::Runner.new(options).run
67
+ end
68
+ end
69
+
70
+ command :download_manifest do |c|
71
+ c.syntax = 'apprepo download_manifest'
72
+ c.description = 'Download metadata only'
73
+ c.action do |_args, options|
74
+ config = FastlaneCore::Configuration
75
+ available_opts = Apprepo::Options.available_options
76
+ options = config.create(available_opts, options.__hash__)
77
+ options.load_configuration_file('Repofile')
78
+ Apprepo::Runner.new(options).download_manifest
79
+ end
80
+ end
81
+
82
+ command :submit do |c|
83
+ c.syntax = 'apprepo submit'
84
+ c.description = 'Submit a specific build-nr, use latest.'
85
+ c.action do |_args, options|
86
+ config = FastlaneCore::Configuration
87
+ available_opts = Apprepo::Options.available_options
88
+ options = config.create(available_opts, options.__hash__)
89
+ options.load_configuration_file('Repofile')
90
+ Apprepo::Runner.new(options).run
91
+ end
92
+ end
93
+
94
+ command :init do |c|
95
+ c.syntax = 'apprepo init'
96
+ c.description = 'Create the initial `apprepo` configuration'
97
+ c.action do |_args, options|
98
+ if File.exist?('Repofile') || File.exist?('fastlane/Repofile')
99
+ UI.important('You already got a running apprepo setup.')
100
+ return 0
101
+ end
102
+
103
+ require 'apprepo/setup'
104
+ config = FastlaneCore::Configuration
105
+ available_opts = Apprepo::Options.available_options
106
+ options = config.create(available_opts, options.__hash__)
107
+ Apprepo::Runner.new(options)
108
+ Apprepo::Setup.new.run(options)
109
+ end
110
+ end
111
+
112
+ # rubocop:enable Metrics/AbcSize
113
+ # rubocop:enable Metrics/MethodLength
114
+
115
+ default_command :run
116
+
117
+ run!
118
+ end
119
+ end
120
+ end
121
+ end