pantograph 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -0
  3. data/LICENSE +21 -0
  4. data/README.md +197 -0
  5. data/bin/bin-proxy +19 -0
  6. data/bin/pantograph +23 -0
  7. data/pantograph/README.md +11 -0
  8. data/pantograph/lib/assets/ActionDetails.md.erb +106 -0
  9. data/pantograph/lib/assets/Actions.md.erb +43 -0
  10. data/pantograph/lib/assets/DefaultPantfileTemplate +20 -0
  11. data/pantograph/lib/assets/completions/completion.bash +23 -0
  12. data/pantograph/lib/assets/completions/completion.fish +39 -0
  13. data/pantograph/lib/assets/completions/completion.sh +12 -0
  14. data/pantograph/lib/assets/completions/completion.zsh +23 -0
  15. data/pantograph/lib/assets/custom_action_template.rb +80 -0
  16. data/pantograph/lib/assets/report_template.xml.erb +15 -0
  17. data/pantograph/lib/pantograph/action.rb +194 -0
  18. data/pantograph/lib/pantograph/action_collector.rb +35 -0
  19. data/pantograph/lib/pantograph/actions/README.md +3 -0
  20. data/pantograph/lib/pantograph/actions/actions_helper.rb +166 -0
  21. data/pantograph/lib/pantograph/actions/add_extra_platforms.rb +45 -0
  22. data/pantograph/lib/pantograph/actions/artifactory.rb +157 -0
  23. data/pantograph/lib/pantograph/actions/bundle_install.rb +156 -0
  24. data/pantograph/lib/pantograph/actions/changelog_from_git_commits.rb +197 -0
  25. data/pantograph/lib/pantograph/actions/clipboard.rb +52 -0
  26. data/pantograph/lib/pantograph/actions/cloc.rb +89 -0
  27. data/pantograph/lib/pantograph/actions/create_pull_request.rb +190 -0
  28. data/pantograph/lib/pantograph/actions/danger.rb +131 -0
  29. data/pantograph/lib/pantograph/actions/debug.rb +32 -0
  30. data/pantograph/lib/pantograph/actions/default_platform.rb +47 -0
  31. data/pantograph/lib/pantograph/actions/download.rb +76 -0
  32. data/pantograph/lib/pantograph/actions/echo.rb +14 -0
  33. data/pantograph/lib/pantograph/actions/ensure_bundle_exec.rb +59 -0
  34. data/pantograph/lib/pantograph/actions/ensure_env_vars.rb +58 -0
  35. data/pantograph/lib/pantograph/actions/ensure_git_branch.rb +69 -0
  36. data/pantograph/lib/pantograph/actions/ensure_git_status_clean.rb +81 -0
  37. data/pantograph/lib/pantograph/actions/erb.rb +88 -0
  38. data/pantograph/lib/pantograph/actions/get_build_number_repository.rb +120 -0
  39. data/pantograph/lib/pantograph/actions/get_github_release.rb +163 -0
  40. data/pantograph/lib/pantograph/actions/git_add.rb +93 -0
  41. data/pantograph/lib/pantograph/actions/git_branch.rb +58 -0
  42. data/pantograph/lib/pantograph/actions/git_commit.rb +80 -0
  43. data/pantograph/lib/pantograph/actions/git_pull.rb +53 -0
  44. data/pantograph/lib/pantograph/actions/git_submodule_update.rb +52 -0
  45. data/pantograph/lib/pantograph/actions/git_tag_exists.rb +74 -0
  46. data/pantograph/lib/pantograph/actions/github_api.rb +262 -0
  47. data/pantograph/lib/pantograph/actions/gradle.rb +278 -0
  48. data/pantograph/lib/pantograph/actions/import.rb +49 -0
  49. data/pantograph/lib/pantograph/actions/import_from_git.rb +71 -0
  50. data/pantograph/lib/pantograph/actions/is_ci.rb +51 -0
  51. data/pantograph/lib/pantograph/actions/jira.rb +115 -0
  52. data/pantograph/lib/pantograph/actions/lane_context.rb +60 -0
  53. data/pantograph/lib/pantograph/actions/last_git_commit.rb +58 -0
  54. data/pantograph/lib/pantograph/actions/last_git_tag.rb +51 -0
  55. data/pantograph/lib/pantograph/actions/make_changelog_from_jenkins.rb +81 -0
  56. data/pantograph/lib/pantograph/actions/min_pantograph_version.rb +57 -0
  57. data/pantograph/lib/pantograph/actions/nexus_upload.rb +230 -0
  58. data/pantograph/lib/pantograph/actions/notification.rb +75 -0
  59. data/pantograph/lib/pantograph/actions/number_of_commits.rb +75 -0
  60. data/pantograph/lib/pantograph/actions/opt_out_usage.rb +40 -0
  61. data/pantograph/lib/pantograph/actions/pantograph_version.rb +15 -0
  62. data/pantograph/lib/pantograph/actions/println.rb +14 -0
  63. data/pantograph/lib/pantograph/actions/prompt.rb +119 -0
  64. data/pantograph/lib/pantograph/actions/push_git_tags.rb +76 -0
  65. data/pantograph/lib/pantograph/actions/push_to_git_remote.rb +127 -0
  66. data/pantograph/lib/pantograph/actions/puts.rb +68 -0
  67. data/pantograph/lib/pantograph/actions/reset_git_repo.rb +121 -0
  68. data/pantograph/lib/pantograph/actions/rocket.rb +83 -0
  69. data/pantograph/lib/pantograph/actions/rsync.rb +74 -0
  70. data/pantograph/lib/pantograph/actions/ruby_version.rb +56 -0
  71. data/pantograph/lib/pantograph/actions/say.rb +56 -0
  72. data/pantograph/lib/pantograph/actions/scp.rb +114 -0
  73. data/pantograph/lib/pantograph/actions/set_github_release.rb +274 -0
  74. data/pantograph/lib/pantograph/actions/sh.rb +71 -0
  75. data/pantograph/lib/pantograph/actions/skip_docs.rb +52 -0
  76. data/pantograph/lib/pantograph/actions/slack.rb +288 -0
  77. data/pantograph/lib/pantograph/actions/sonar.rb +156 -0
  78. data/pantograph/lib/pantograph/actions/ssh.rb +162 -0
  79. data/pantograph/lib/pantograph/actions/twitter.rb +89 -0
  80. data/pantograph/lib/pantograph/actions/update_pantograph.rb +177 -0
  81. data/pantograph/lib/pantograph/actions/zip.rb +120 -0
  82. data/pantograph/lib/pantograph/auto_complete.rb +82 -0
  83. data/pantograph/lib/pantograph/boolean.rb +5 -0
  84. data/pantograph/lib/pantograph/cli_tools_distributor.rb +183 -0
  85. data/pantograph/lib/pantograph/command_line_handler.rb +43 -0
  86. data/pantograph/lib/pantograph/commands_generator.rb +344 -0
  87. data/pantograph/lib/pantograph/configuration_helper.rb +26 -0
  88. data/pantograph/lib/pantograph/core_ext/bundler_monkey_patch.rb +14 -0
  89. data/pantograph/lib/pantograph/documentation/actions_list.rb +214 -0
  90. data/pantograph/lib/pantograph/documentation/docs_generator.rb +95 -0
  91. data/pantograph/lib/pantograph/documentation/markdown_docs_generator.rb +221 -0
  92. data/pantograph/lib/pantograph/environment_printer.rb +282 -0
  93. data/pantograph/lib/pantograph/erb_template_helper.rb +30 -0
  94. data/pantograph/lib/pantograph/features.rb +4 -0
  95. data/pantograph/lib/pantograph/helper/README.md +29 -0
  96. data/pantograph/lib/pantograph/helper/dotenv_helper.rb +50 -0
  97. data/pantograph/lib/pantograph/helper/gem_helper.rb +26 -0
  98. data/pantograph/lib/pantograph/helper/git_helper.rb +135 -0
  99. data/pantograph/lib/pantograph/helper/gradle_helper.rb +62 -0
  100. data/pantograph/lib/pantograph/helper/sh_helper.rb +134 -0
  101. data/pantograph/lib/pantograph/junit_generator.rb +27 -0
  102. data/pantograph/lib/pantograph/lane.rb +97 -0
  103. data/pantograph/lib/pantograph/lane_list.rb +77 -0
  104. data/pantograph/lib/pantograph/lane_manager.rb +140 -0
  105. data/pantograph/lib/pantograph/lane_manager_base.rb +92 -0
  106. data/pantograph/lib/pantograph/markdown_table_formatter.rb +62 -0
  107. data/pantograph/lib/pantograph/new_action.rb +47 -0
  108. data/pantograph/lib/pantograph/one_off.rb +45 -0
  109. data/pantograph/lib/pantograph/other_action.rb +29 -0
  110. data/pantograph/lib/pantograph/pant_file.rb +377 -0
  111. data/pantograph/lib/pantograph/pantograph_require.rb +75 -0
  112. data/pantograph/lib/pantograph/plugins/plugin_fetcher.rb +55 -0
  113. data/pantograph/lib/pantograph/plugins/plugin_generator.rb +86 -0
  114. data/pantograph/lib/pantograph/plugins/plugin_generator_ui.rb +19 -0
  115. data/pantograph/lib/pantograph/plugins/plugin_info.rb +49 -0
  116. data/pantograph/lib/pantograph/plugins/plugin_info_collector.rb +159 -0
  117. data/pantograph/lib/pantograph/plugins/plugin_manager.rb +387 -0
  118. data/pantograph/lib/pantograph/plugins/plugin_search.rb +46 -0
  119. data/pantograph/lib/pantograph/plugins/plugin_update_manager.rb +70 -0
  120. data/pantograph/lib/pantograph/plugins/plugins.rb +12 -0
  121. data/pantograph/lib/pantograph/plugins/template/%gem_name%.gemspec.erb +35 -0
  122. data/pantograph/lib/pantograph/plugins/template/.circleci/config.yml +43 -0
  123. data/pantograph/lib/pantograph/plugins/template/.gitignore +12 -0
  124. data/pantograph/lib/pantograph/plugins/template/.rspec +5 -0
  125. data/pantograph/lib/pantograph/plugins/template/.rubocop.yml +179 -0
  126. data/pantograph/lib/pantograph/plugins/template/.travis.yml +4 -0
  127. data/pantograph/lib/pantograph/plugins/template/Gemfile +6 -0
  128. data/pantograph/lib/pantograph/plugins/template/LICENSE.erb +21 -0
  129. data/pantograph/lib/pantograph/plugins/template/README.md.erb +52 -0
  130. data/pantograph/lib/pantograph/plugins/template/Rakefile +9 -0
  131. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/actions/%plugin_name%_action.rb.erb +47 -0
  132. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/helper/%plugin_name%_helper.rb.erb +16 -0
  133. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/version.rb.erb +5 -0
  134. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%.rb.erb +16 -0
  135. data/pantograph/lib/pantograph/plugins/template/pantograph/Pantfile.erb +3 -0
  136. data/pantograph/lib/pantograph/plugins/template/pantograph/Pluginfile.erb +1 -0
  137. data/pantograph/lib/pantograph/plugins/template/spec/%plugin_name%_action_spec.rb.erb +9 -0
  138. data/pantograph/lib/pantograph/plugins/template/spec/spec_helper.rb.erb +15 -0
  139. data/pantograph/lib/pantograph/runner.rb +371 -0
  140. data/pantograph/lib/pantograph/server/action_command.rb +61 -0
  141. data/pantograph/lib/pantograph/server/action_command_return.rb +14 -0
  142. data/pantograph/lib/pantograph/server/command_executor.rb +7 -0
  143. data/pantograph/lib/pantograph/server/command_parser.rb +36 -0
  144. data/pantograph/lib/pantograph/server/control_command.rb +23 -0
  145. data/pantograph/lib/pantograph/server/json_return_value_processor.rb +72 -0
  146. data/pantograph/lib/pantograph/server/socket_server.rb +232 -0
  147. data/pantograph/lib/pantograph/server/socket_server_action_command_executor.rb +101 -0
  148. data/pantograph/lib/pantograph/setup/setup.rb +290 -0
  149. data/pantograph/lib/pantograph/setup/setup_android.rb +64 -0
  150. data/pantograph/lib/pantograph/setup/setup_ios.rb +412 -0
  151. data/pantograph/lib/pantograph/shells.rb +6 -0
  152. data/pantograph/lib/pantograph/supported_platforms.rb +28 -0
  153. data/pantograph/lib/pantograph/tools.rb +10 -0
  154. data/pantograph/lib/pantograph/version.rb +5 -0
  155. data/pantograph/lib/pantograph.rb +51 -0
  156. data/pantograph_core/README.md +79 -0
  157. data/pantograph_core/lib/assets/XMLTemplate.xml.erb +12 -0
  158. data/pantograph_core/lib/pantograph_core/analytics/action_completion_context.rb +34 -0
  159. data/pantograph_core/lib/pantograph_core/analytics/action_launch_context.rb +38 -0
  160. data/pantograph_core/lib/pantograph_core/analytics/analytics_event_builder.rb +23 -0
  161. data/pantograph_core/lib/pantograph_core/analytics/analytics_ingester_client.rb +54 -0
  162. data/pantograph_core/lib/pantograph_core/analytics/analytics_session.rb +71 -0
  163. data/pantograph_core/lib/pantograph_core/cert_checker.rb +116 -0
  164. data/pantograph_core/lib/pantograph_core/command_executor.rb +99 -0
  165. data/pantograph_core/lib/pantograph_core/configuration/commander_generator.rb +103 -0
  166. data/pantograph_core/lib/pantograph_core/configuration/config_item.rb +314 -0
  167. data/pantograph_core/lib/pantograph_core/configuration/configuration.rb +332 -0
  168. data/pantograph_core/lib/pantograph_core/configuration/configuration_file.rb +182 -0
  169. data/pantograph_core/lib/pantograph_core/core_ext/shellwords.rb +63 -0
  170. data/pantograph_core/lib/pantograph_core/core_ext/string.rb +17 -0
  171. data/pantograph_core/lib/pantograph_core/env.rb +9 -0
  172. data/pantograph_core/lib/pantograph_core/feature/feature.rb +51 -0
  173. data/pantograph_core/lib/pantograph_core/features.rb +4 -0
  174. data/pantograph_core/lib/pantograph_core/globals.rb +27 -0
  175. data/pantograph_core/lib/pantograph_core/helper.rb +409 -0
  176. data/pantograph_core/lib/pantograph_core/keychain_importer.rb +74 -0
  177. data/pantograph_core/lib/pantograph_core/languages.rb +14 -0
  178. data/pantograph_core/lib/pantograph_core/module.rb +29 -0
  179. data/pantograph_core/lib/pantograph_core/pantograph_folder.rb +39 -0
  180. data/pantograph_core/lib/pantograph_core/pantograph_pty.rb +57 -0
  181. data/pantograph_core/lib/pantograph_core/pkg_file_analyser.rb +44 -0
  182. data/pantograph_core/lib/pantograph_core/print_table.rb +131 -0
  183. data/pantograph_core/lib/pantograph_core/string_filters.rb +51 -0
  184. data/pantograph_core/lib/pantograph_core/swag.rb +85 -0
  185. data/pantograph_core/lib/pantograph_core/tag_version.rb +31 -0
  186. data/pantograph_core/lib/pantograph_core/test_parser.rb +107 -0
  187. data/pantograph_core/lib/pantograph_core/ui/disable_colors.rb +17 -0
  188. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_common_error.rb +19 -0
  189. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_crash.rb +11 -0
  190. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_error.rb +25 -0
  191. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_exception.rb +19 -0
  192. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_shell_error.rb +11 -0
  193. data/pantograph_core/lib/pantograph_core/ui/errors.rb +1 -0
  194. data/pantograph_core/lib/pantograph_core/ui/github_issue_inspector_reporter.rb +62 -0
  195. data/pantograph_core/lib/pantograph_core/ui/implementations/shell.rb +159 -0
  196. data/pantograph_core/lib/pantograph_core/ui/interface.rb +205 -0
  197. data/pantograph_core/lib/pantograph_core/ui/pantograph_runner.rb +276 -0
  198. data/pantograph_core/lib/pantograph_core/ui/ui.rb +26 -0
  199. data/pantograph_core/lib/pantograph_core/update_checker/changelog.rb +37 -0
  200. data/pantograph_core/lib/pantograph_core/update_checker/update_checker.rb +107 -0
  201. data/pantograph_core/lib/pantograph_core.rb +45 -0
  202. metadata +987 -0
@@ -0,0 +1,51 @@
1
+ module Pantograph
2
+ module Actions
3
+ class LastGitTagAction < Action
4
+ def self.run(params)
5
+ Actions.last_git_tag_name
6
+ end
7
+
8
+ #####################################################
9
+ # @!group Documentation
10
+ #####################################################
11
+
12
+ def self.description
13
+ "Get the most recent git tag"
14
+ end
15
+
16
+ def self.available_options
17
+ []
18
+ end
19
+
20
+ def self.output
21
+ []
22
+ end
23
+
24
+ def self.return_type
25
+ :string
26
+ end
27
+
28
+ def self.authors
29
+ ["KrauseFx"]
30
+ end
31
+
32
+ def self.is_supported?(platform)
33
+ true
34
+ end
35
+
36
+ def self.details
37
+ "If you are using this action on a **shallow clone**, *the default with some CI systems like Bamboo*, you need to ensure that you have also pulled all the git tags appropriately. Assuming your git repo has the correct remote set you can issue `sh('git fetch --tags')`."
38
+ end
39
+
40
+ def self.example_code
41
+ [
42
+ 'last_git_tag'
43
+ ]
44
+ end
45
+
46
+ def self.category
47
+ :source_control
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,81 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ FL_CHANGELOG ||= :FL_CHANGELOG # originally defined in ChangelogFromGitCommitsAction
5
+ end
6
+
7
+ class MakeChangelogFromJenkinsAction < Action
8
+ def self.run(params)
9
+ require 'json'
10
+ require 'net/http'
11
+
12
+ changelog = ""
13
+
14
+ if Helper.ci? || Helper.test?
15
+ # The "BUILD_URL" environment variable is set automatically by Jenkins in every build
16
+ jenkins_api_url = URI(ENV["BUILD_URL"] + "api/json\?wrapper\=changes\&xpath\=//changeSet//comment")
17
+ begin
18
+ json = JSON.parse(Net::HTTP.get(jenkins_api_url))
19
+ json['changeSet']['items'].each do |item|
20
+ comment = params[:include_commit_body] ? item['comment'] : item['msg']
21
+ changelog << comment.strip + "\n"
22
+ end
23
+ rescue => ex
24
+ UI.error("Unable to read/parse changelog from jenkins: #{ex.message}")
25
+ end
26
+ end
27
+
28
+ Actions.lane_context[SharedValues::FL_CHANGELOG] = changelog.strip.length > 0 ? changelog : params[:fallback_changelog]
29
+ end
30
+
31
+ def self.description
32
+ "Generate a changelog using the Changes section from the current Jenkins build"
33
+ end
34
+
35
+ def self.details
36
+ "This is useful when deploying automated builds. The changelog from Jenkins lists all the commit messages since the last build."
37
+ end
38
+
39
+ def self.available_options
40
+ [
41
+ PantographCore::ConfigItem.new(key: :fallback_changelog,
42
+ description: "Fallback changelog if there is not one on Jenkins, or it couldn't be read",
43
+ optional: true,
44
+ default_value: ""),
45
+ PantographCore::ConfigItem.new(key: :include_commit_body,
46
+ description: "Include the commit body along with the summary",
47
+ optional: true,
48
+ is_string: false,
49
+ default_value: true)
50
+ ]
51
+ end
52
+
53
+ def self.output
54
+ [
55
+ ['FL_CHANGELOG', 'The changelog generated by Jenkins']
56
+ ]
57
+ end
58
+
59
+ def self.authors
60
+ ["mandrizzle"]
61
+ end
62
+
63
+ def self.is_supported?(platform)
64
+ true
65
+ end
66
+
67
+ def self.example_code
68
+ [
69
+ 'make_changelog_from_jenkins(
70
+ # Optional, lets you set a changelog in the case is not generated on Jenkins or if ran outside of Jenkins
71
+ fallback_changelog: "Bug fixes and performance enhancements"
72
+ )'
73
+ ]
74
+ end
75
+
76
+ def self.category
77
+ :misc
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,57 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ end
5
+
6
+ class MinPantographVersionAction < Action
7
+ def self.run(params)
8
+ params = nil unless params.kind_of?(Array)
9
+ value = (params || []).first
10
+ defined_version = Gem::Version.new(value) if value
11
+
12
+ UI.user_error!("Please pass minimum pantograph version as parameter to min_pantograph_version") unless defined_version
13
+
14
+ if Gem::Version.new(Pantograph::VERSION) < defined_version
15
+ PantographCore::UpdateChecker.show_update_message('pantograph', Pantograph::VERSION)
16
+ error_message = "The Pantfile requires a pantograph version of >= #{defined_version}. You are on #{Pantograph::VERSION}."
17
+ UI.user_error!(error_message)
18
+ end
19
+
20
+ UI.message("Your pantograph version #{Pantograph::VERSION} matches the minimum requirement of #{defined_version} ✅")
21
+ end
22
+
23
+ def self.step_text
24
+ "Verifying pantograph version"
25
+ end
26
+
27
+ def self.author
28
+ "KrauseFx"
29
+ end
30
+
31
+ def self.description
32
+ "Verifies the minimum pantograph version required"
33
+ end
34
+
35
+ def self.example_code
36
+ [
37
+ 'min_pantograph_version("1.50.0")'
38
+ ]
39
+ end
40
+
41
+ def self.details
42
+ [
43
+ "Add this to your `Pantfile` to require a certain version of _pantograph_.",
44
+ "Use it if you use an action that just recently came out and you need it."
45
+ ].join("\n")
46
+ end
47
+
48
+ def self.category
49
+ :misc
50
+ end
51
+
52
+ def self.is_supported?(platform)
53
+ true
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,230 @@
1
+ module Pantograph
2
+ module Actions
3
+ class NexusUploadAction < Action
4
+ def self.run(params)
5
+ command = []
6
+ command << "curl"
7
+ command << verbose(params)
8
+ command += ssl_options(params)
9
+ command += proxy_options(params)
10
+ command += upload_options(params)
11
+ command << upload_url(params)
12
+
13
+ Pantograph::Actions.sh(command.join(' '), log: params[:verbose])
14
+ end
15
+
16
+ def self.upload_url(params)
17
+ url = "#{params[:endpoint]}#{params[:mount_path]}"
18
+
19
+ if params[:nexus_version] == 2
20
+ url << "/service/local/artifact/maven/content"
21
+ else
22
+ file_extension = File.extname(params[:file]).shellescape
23
+
24
+ url << "/repository/#{params[:repo_id]}"
25
+ url << "/#{params[:repo_group_id].gsub('.', '/')}"
26
+ url << "/#{params[:repo_project_name]}"
27
+ url << "/#{params[:repo_project_version]}"
28
+ url << "/#{params[:repo_project_name]}-#{params[:repo_project_version]}"
29
+ url << "-#{params[:repo_classifier]}" if params[:repo_classifier]
30
+ url << file_extension.to_s
31
+ end
32
+
33
+ url.shellescape
34
+ end
35
+
36
+ def self.verbose(params)
37
+ params[:verbose] ? "--verbose" : "--silent"
38
+ end
39
+
40
+ def self.upload_options(params)
41
+ file_path = File.expand_path(params[:file]).shellescape
42
+ file_extension = file_path.split('.').last.shellescape
43
+
44
+ options = []
45
+ if params[:nexus_version] == 2
46
+ options << "-F p=zip"
47
+ options << "-F hasPom=false"
48
+ options << "-F r=#{params[:repo_id].shellescape}"
49
+ options << "-F g=#{params[:repo_group_id].shellescape}"
50
+ options << "-F a=#{params[:repo_project_name].shellescape}"
51
+ options << "-F v=#{params[:repo_project_version].shellescape}"
52
+
53
+ if params[:repo_classifier]
54
+ options << "-F c=#{params[:repo_classifier].shellescape}"
55
+ end
56
+
57
+ options << "-F e=#{file_extension}"
58
+ options << "-F file=@#{file_path}"
59
+ else
60
+ options << "--upload-file #{file_path}"
61
+ end
62
+
63
+ options << "-u #{params[:username].shellescape}:#{params[:password].shellescape}"
64
+
65
+ options
66
+ end
67
+
68
+ def self.ssl_options(params)
69
+ options = []
70
+ unless params[:ssl_verify]
71
+ options << "--insecure"
72
+ end
73
+
74
+ options
75
+ end
76
+
77
+ def self.proxy_options(params)
78
+ options = []
79
+ if params[:proxy_address] && params[:proxy_port] && params[:proxy_username] && params[:proxy_password]
80
+ options << "-x #{params[:proxy_address].shellescape}:#{params[:proxy_port].shellescape}"
81
+ options << "--proxy-user #{params[:proxy_username].shellescape}:#{params[:proxy_password].shellescape}"
82
+ end
83
+
84
+ options
85
+ end
86
+
87
+ #####################################################
88
+ # @!group Documentation
89
+ #####################################################
90
+
91
+ def self.description
92
+ "Upload a file to [Sonatype Nexus platform](https://www.sonatype.com)"
93
+ end
94
+
95
+ def self.available_options
96
+ [
97
+ PantographCore::ConfigItem.new(key: :file,
98
+ env_name: "FL_NEXUS_FILE",
99
+ description: "File to be uploaded to Nexus",
100
+ optional: false,
101
+ verify_block: proc do |value|
102
+ file_path = File.expand_path(value)
103
+ UI.user_error!("Couldn't find file at path '#{file_path}'") unless File.exist?(file_path)
104
+ end),
105
+ PantographCore::ConfigItem.new(key: :repo_id,
106
+ env_name: "FL_NEXUS_REPO_ID",
107
+ description: "Nexus repository id e.g. artefacts",
108
+ optional: false),
109
+ PantographCore::ConfigItem.new(key: :repo_group_id,
110
+ env_name: "FL_NEXUS_REPO_GROUP_ID",
111
+ description: "Nexus repository group id e.g. com.company",
112
+ optional: false),
113
+ PantographCore::ConfigItem.new(key: :repo_project_name,
114
+ env_name: "FL_NEXUS_REPO_PROJECT_NAME",
115
+ description: "Nexus repository commandect name. Only letters, digits, underscores(_), hyphens(-), and dots(.) are allowed",
116
+ optional: false),
117
+ PantographCore::ConfigItem.new(key: :repo_project_version,
118
+ env_name: "FL_NEXUS_REPO_PROJECT_VERSION",
119
+ description: "Nexus repository commandect version",
120
+ optional: false),
121
+ PantographCore::ConfigItem.new(key: :repo_classifier,
122
+ env_name: "FL_NEXUS_REPO_CLASSIFIER",
123
+ description: "Nexus repository artifact classifier (optional)",
124
+ optional: true),
125
+ PantographCore::ConfigItem.new(key: :endpoint,
126
+ env_name: "FL_NEXUS_ENDPOINT",
127
+ description: "Nexus endpoint e.g. http://nexus:8081",
128
+ optional: false),
129
+ PantographCore::ConfigItem.new(key: :mount_path,
130
+ env_name: "FL_NEXUS_MOUNT_PATH",
131
+ description: "Nexus mount path (Nexus 3 instances have this configured as empty by default)",
132
+ default_value: "/nexus",
133
+ optional: true),
134
+ PantographCore::ConfigItem.new(key: :username,
135
+ env_name: "FL_NEXUS_USERNAME",
136
+ description: "Nexus username",
137
+ optional: false),
138
+ PantographCore::ConfigItem.new(key: :password,
139
+ env_name: "FL_NEXUS_PASSWORD",
140
+ description: "Nexus password",
141
+ optional: false),
142
+ PantographCore::ConfigItem.new(key: :ssl_verify,
143
+ env_name: "FL_NEXUS_SSL_VERIFY",
144
+ description: "Verify SSL",
145
+ is_string: false,
146
+ default_value: true,
147
+ optional: true),
148
+ PantographCore::ConfigItem.new(key: :nexus_version,
149
+ env_name: "FL_NEXUS_MAJOR_VERSION",
150
+ description: "Nexus major version",
151
+ type: Integer,
152
+ default_value: 2,
153
+ optional: true,
154
+ verify_block: proc do |value|
155
+ min_version = 2
156
+ max_version = 3
157
+ UI.user_error!("Unsupported version (#{value}) min. supported version: #{min_version}") unless value >= min_version
158
+ UI.user_error!("Unsupported version (#{value}) max. supported version: #{max_version}") unless value <= max_version
159
+ end),
160
+ PantographCore::ConfigItem.new(key: :verbose,
161
+ env_name: "FL_NEXUS_VERBOSE",
162
+ description: "Make detailed output",
163
+ is_string: false,
164
+ default_value: false,
165
+ optional: true),
166
+ PantographCore::ConfigItem.new(key: :proxy_username,
167
+ env_name: "FL_NEXUS_PROXY_USERNAME",
168
+ description: "Proxy username",
169
+ optional: true),
170
+ PantographCore::ConfigItem.new(key: :proxy_password,
171
+ env_name: "FL_NEXUS_PROXY_PASSWORD",
172
+ sensitive: true,
173
+ description: "Proxy password",
174
+ optional: true),
175
+ PantographCore::ConfigItem.new(key: :proxy_address,
176
+ env_name: "FL_NEXUS_PROXY_ADDRESS",
177
+ description: "Proxy address",
178
+ optional: true),
179
+ PantographCore::ConfigItem.new(key: :proxy_port,
180
+ env_name: "FL_NEXUS_PROXY_PORT",
181
+ description: "Proxy port",
182
+ optional: true)
183
+ ]
184
+ end
185
+
186
+ def self.authors
187
+ ["xfreebird", "mdio"]
188
+ end
189
+
190
+ def self.is_supported?(platform)
191
+ true
192
+ end
193
+
194
+ def self.example_code
195
+ [
196
+ '# for Nexus 2
197
+ nexus_upload(
198
+ file: "/path/to/file.ipa",
199
+ repo_id: "artefacts",
200
+ repo_group_id: "com.pantograph",
201
+ repo_project_name: "ipa",
202
+ repo_project_version: "1.13",
203
+ repo_classifier: "dSYM", # Optional
204
+ endpoint: "http://localhost:8081",
205
+ username: "admin",
206
+ password: "admin123"
207
+ )',
208
+ '# for Nexus 3
209
+ nexus_upload(
210
+ nexus_version: 3,
211
+ mount_path: "",
212
+ file: "/path/to/file.ipa",
213
+ repo_id: "artefacts",
214
+ repo_group_id: "com.pantograph",
215
+ repo_project_name: "ipa",
216
+ repo_project_version: "1.13",
217
+ repo_classifier: "dSYM", # Optional
218
+ endpoint: "http://localhost:8081",
219
+ username: "admin",
220
+ password: "admin123"
221
+ )'
222
+ ]
223
+ end
224
+
225
+ def self.category
226
+ :beta
227
+ end
228
+ end
229
+ end
230
+ end
@@ -0,0 +1,75 @@
1
+ module Pantograph
2
+ module Actions
3
+ class NotificationAction < Action
4
+ def self.run(params)
5
+ require 'terminal-notifier'
6
+
7
+ options = params.values
8
+ # :message is non-optional
9
+ message = options.delete(:message)
10
+ # remove nil keys, since `notify` below does not ignore them and instead translates them into empty strings in output, which looks ugly
11
+ options = options.select { |_, v| v }
12
+ option_map = {
13
+ app_icon: :appIcon,
14
+ content_image: :contentImage
15
+ }
16
+ options = Hash[options.map { |k, v| [option_map.fetch(k, k), v] }]
17
+ TerminalNotifier.notify(message, options)
18
+ end
19
+
20
+ def self.description
21
+ "Display a macOS notification with custom message and title"
22
+ end
23
+
24
+ def self.author
25
+ ["champo", "cbowns", "KrauseFx", "amarcadet", "dusek"]
26
+ end
27
+
28
+ def self.available_options
29
+ [
30
+ PantographCore::ConfigItem.new(key: :title,
31
+ description: "The title to display in the notification",
32
+ default_value: 'pantograph'),
33
+ PantographCore::ConfigItem.new(key: :subtitle,
34
+ description: "A subtitle to display in the notification",
35
+ optional: true),
36
+ PantographCore::ConfigItem.new(key: :message,
37
+ description: "The message to display in the notification",
38
+ optional: false),
39
+ PantographCore::ConfigItem.new(key: :sound,
40
+ description: "The name of a sound to play when the notification appears (names are listed in Sound Preferences)",
41
+ optional: true),
42
+ PantographCore::ConfigItem.new(key: :activate,
43
+ description: "Bundle identifier of application to be opened when the notification is clicked",
44
+ optional: true),
45
+ PantographCore::ConfigItem.new(key: :app_icon,
46
+ description: "The URL of an image to display instead of the application icon (Mavericks+ only)",
47
+ optional: true),
48
+ PantographCore::ConfigItem.new(key: :content_image,
49
+ description: "The URL of an image to display attached to the notification (Mavericks+ only)",
50
+ optional: true),
51
+ PantographCore::ConfigItem.new(key: :open,
52
+ description: "URL of the resource to be opened when the notification is clicked",
53
+ optional: true),
54
+ PantographCore::ConfigItem.new(key: :execute,
55
+ description: "Shell command to run when the notification is clicked",
56
+ optional: true)
57
+ ]
58
+ end
59
+
60
+ def self.is_supported?(platform)
61
+ Helper.mac?
62
+ end
63
+
64
+ def self.example_code
65
+ [
66
+ 'notification(subtitle: "Finished Building", message: "Ready to upload...")'
67
+ ]
68
+ end
69
+
70
+ def self.category
71
+ :notifications
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,75 @@
1
+ module Pantograph
2
+ module Actions
3
+ class NumberOfCommitsAction < Action
4
+ def self.is_git?
5
+ Actions.sh('git rev-parse HEAD')
6
+ return true
7
+ rescue
8
+ return false
9
+ end
10
+
11
+ def self.run(params)
12
+ if is_git?
13
+ if params[:all]
14
+ command = 'git rev-list --all --count'
15
+ else
16
+ command = 'git rev-list HEAD --count'
17
+ end
18
+ else
19
+ UI.user_error!("Not in a git repository.")
20
+ end
21
+ return Actions.sh(command).strip.to_i
22
+ end
23
+
24
+ #####################################################
25
+ # @!group Documentation
26
+ #####################################################
27
+
28
+ def self.description
29
+ "Return the number of commits in current git branch"
30
+ end
31
+
32
+ def self.return_value
33
+ "The total number of all commits in current git branch"
34
+ end
35
+
36
+ def self.return_type
37
+ :int
38
+ end
39
+
40
+ def self.available_options
41
+ [
42
+ PantographCore::ConfigItem.new(key: :all,
43
+ env_name: "FL_NUMBER_OF_COMMITS_ALL",
44
+ optional: true,
45
+ is_string: false,
46
+ description: "Returns number of all commits instead of current branch")
47
+ ]
48
+ end
49
+
50
+ def self.details
51
+ "You can use this action to get the number of commits of this branch. This is useful if you want to set the build number to the number of commits. See `pantograph actions number_of_commits` for more details."
52
+ end
53
+
54
+ def self.authors
55
+ ["onevcat", "samuelbeek"]
56
+ end
57
+
58
+ def self.is_supported?(platform)
59
+ true
60
+ end
61
+
62
+ def self.example_code
63
+ [
64
+ 'increment_build_number(build_number: number_of_commits)',
65
+ 'build_number = number_of_commits(all: true)
66
+ increment_build_number(build_number: build_number)'
67
+ ]
68
+ end
69
+
70
+ def self.category
71
+ :source_control
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,40 @@
1
+ module Pantograph
2
+ module Actions
3
+ class OptOutUsageAction < Action
4
+ def self.run(params)
5
+ ENV['PANTOGRAPH_OPT_OUT_USAGE'] = "YES"
6
+ UI.message("Disabled upload of used actions")
7
+ end
8
+
9
+ def self.description
10
+ "This will stop uploading the information which actions were run"
11
+ end
12
+
13
+ def self.details
14
+ [
15
+ "By default, _pantograph_ will track what actions are being used. No personal/sensitive information is recorded.",
16
+ "Learn more at [https://docs.pantograph.tools/#metrics](https://docs.pantograph.tools/#metrics).",
17
+ "Add `opt_out_usage` at the top of your Pantfile to disable metrics collection."
18
+ ].join("\n")
19
+ end
20
+
21
+ def self.author
22
+ "KrauseFx"
23
+ end
24
+
25
+ def self.is_supported?(platform)
26
+ true
27
+ end
28
+
29
+ def self.example_code
30
+ [
31
+ 'opt_out_usage # add this to the top of your Pantfile'
32
+ ]
33
+ end
34
+
35
+ def self.category
36
+ :misc
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ require "pantograph/actions/min_pantograph_version"
2
+
3
+ module Pantograph
4
+ module Actions
5
+ class PantographVersionAction < MinPantographVersionAction
6
+ #####################################################
7
+ # @!group Documentation
8
+ #####################################################
9
+
10
+ def self.description
11
+ "Alias for the `min_pantograph_version` action"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Pantograph
2
+ module Actions
3
+ require 'pantograph/actions/puts'
4
+ class PrintlnAction < PutsAction
5
+ #####################################################
6
+ # @!group Documentation
7
+ #####################################################
8
+
9
+ def self.description
10
+ "Alias for the `puts` action"
11
+ end
12
+ end
13
+ end
14
+ end