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,190 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ CREATE_PULL_REQUEST_HTML_URL = :CREATE_PULL_REQUEST_HTML_URL
5
+ end
6
+
7
+ class CreatePullRequestAction < Action
8
+ def self.run(params)
9
+ UI.message("Creating new pull request from '#{params[:head]}' to branch '#{params[:base]}' of '#{params[:repo]}'")
10
+
11
+ payload = {
12
+ 'title' => params[:title],
13
+ 'head' => params[:head],
14
+ 'base' => params[:base]
15
+ }
16
+ payload['body'] = params[:body] if params[:body]
17
+
18
+ GithubApiAction.run(
19
+ server_url: params[:api_url],
20
+ api_token: params[:api_token],
21
+ http_method: 'POST',
22
+ path: "repos/#{params[:repo]}/pulls",
23
+ body: payload,
24
+ error_handlers: {
25
+ '*' => proc do |result|
26
+ UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
27
+ return nil
28
+ end
29
+ }
30
+ ) do |result|
31
+ json = result[:json]
32
+ number = json['number']
33
+ html_url = json['html_url']
34
+ UI.success("Successfully created pull request ##{number}. You can see it at '#{html_url}'")
35
+
36
+ # Add labels to pull request
37
+ add_labels(params, number) if params[:labels]
38
+
39
+ # Add assignees to pull request
40
+ add_assignees(params, number) if params[:assignees]
41
+
42
+ Actions.lane_context[SharedValues::CREATE_PULL_REQUEST_HTML_URL] = html_url
43
+ return html_url
44
+ end
45
+ end
46
+
47
+ def self.add_labels(params, number)
48
+ payload = {
49
+ 'labels' => params[:labels]
50
+ }
51
+ GithubApiAction.run(
52
+ server_url: params[:api_url],
53
+ api_token: params[:api_token],
54
+ http_method: 'PATCH',
55
+ path: "repos/#{params[:repo]}/issues/#{number}",
56
+ body: payload,
57
+ error_handlers: {
58
+ '*' => proc do |result|
59
+ UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
60
+ return nil
61
+ end
62
+ }
63
+ )
64
+ end
65
+
66
+ def self.add_assignees(params, number)
67
+ payload = {
68
+ 'assignees' => params[:assignees]
69
+ }
70
+ GithubApiAction.run(
71
+ server_url: params[:api_url],
72
+ api_token: params[:api_token],
73
+ http_method: 'POST',
74
+ path: "repos/#{params[:repo]}/issues/#{number}/assignees",
75
+ body: payload,
76
+ error_handlers: {
77
+ '*' => proc do |result|
78
+ UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
79
+ return nil
80
+ end
81
+ }
82
+ )
83
+ end
84
+
85
+ #####################################################
86
+ # @!group Documentation
87
+ #####################################################
88
+
89
+ def self.description
90
+ "This will create a new pull request on GitHub"
91
+ end
92
+
93
+ def self.output
94
+ [
95
+ ['CREATE_PULL_REQUEST_HTML_URL', 'The HTML URL to the created pull request']
96
+ ]
97
+ end
98
+
99
+ def self.available_options
100
+ [
101
+ PantographCore::ConfigItem.new(key: :api_token,
102
+ env_name: "GITHUB_PULL_REQUEST_API_TOKEN",
103
+ description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens",
104
+ sensitive: true,
105
+ code_gen_sensitive: true,
106
+ default_value: ENV["GITHUB_API_TOKEN"],
107
+ default_value_dynamic: true,
108
+ is_string: true,
109
+ optional: false),
110
+ PantographCore::ConfigItem.new(key: :repo,
111
+ env_name: "GITHUB_PULL_REQUEST_REPO",
112
+ description: "The name of the repository you want to submit the pull request to",
113
+ is_string: true,
114
+ optional: false),
115
+ PantographCore::ConfigItem.new(key: :title,
116
+ env_name: "GITHUB_PULL_REQUEST_TITLE",
117
+ description: "The title of the pull request",
118
+ is_string: true,
119
+ optional: false),
120
+ PantographCore::ConfigItem.new(key: :body,
121
+ env_name: "GITHUB_PULL_REQUEST_BODY",
122
+ description: "The contents of the pull request",
123
+ is_string: true,
124
+ optional: true),
125
+ PantographCore::ConfigItem.new(key: :labels,
126
+ env_name: "GITHUB_PULL_REQUEST_LABELS",
127
+ description: "The labels for the pull request",
128
+ type: Array,
129
+ optional: true),
130
+ PantographCore::ConfigItem.new(key: :head,
131
+ env_name: "GITHUB_PULL_REQUEST_HEAD",
132
+ description: "The name of the branch where your changes are implemented (defaults to the current branch name)",
133
+ is_string: true,
134
+ code_gen_sensitive: true,
135
+ default_value: Actions.git_branch,
136
+ default_value_dynamic: true,
137
+ optional: true),
138
+ PantographCore::ConfigItem.new(key: :base,
139
+ env_name: "GITHUB_PULL_REQUEST_BASE",
140
+ description: "The name of the branch you want your changes pulled into (defaults to `master`)",
141
+ is_string: true,
142
+ default_value: 'master',
143
+ optional: true),
144
+ PantographCore::ConfigItem.new(key: :api_url,
145
+ env_name: "GITHUB_PULL_REQUEST_API_URL",
146
+ description: "The URL of GitHub API - used when the Enterprise (default to `https://api.github.com`)",
147
+ is_string: true,
148
+ code_gen_default_value: 'https://api.github.com',
149
+ default_value: 'https://api.github.com',
150
+ optional: true),
151
+ PantographCore::ConfigItem.new(key: :assignees,
152
+ env_name: "GITHUB_PULL_REQUEST_ASSIGNEES",
153
+ description: "The assignees for the pull request",
154
+ type: Array,
155
+ optional: true)
156
+ ]
157
+ end
158
+
159
+ def self.author
160
+ ["seei", "tommeier", "marumemomo"]
161
+ end
162
+
163
+ def self.is_supported?(platform)
164
+ return true
165
+ end
166
+
167
+ def self.return_value
168
+ "The pull request URL when successful"
169
+ end
170
+
171
+ def self.example_code
172
+ [
173
+ 'create_pull_request(
174
+ api_token: "secret", # optional, defaults to ENV["GITHUB_API_TOKEN"]
175
+ repo: "pantograph/pantograph",
176
+ title: "Amazing new feature",
177
+ head: "my-feature", # optional, defaults to current branch name
178
+ base: "master", # optional, defaults to "master"
179
+ body: "Please pull this in!", # optional
180
+ api_url: "http://yourdomain/api/v3" # optional, for GitHub Enterprise, defaults to "https://api.github.com"
181
+ )'
182
+ ]
183
+ end
184
+
185
+ def self.category
186
+ :source_control
187
+ end
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,131 @@
1
+ module Pantograph
2
+ module Actions
3
+ class DangerAction < Action
4
+ def self.run(params)
5
+ Actions.verify_gem!('danger')
6
+ cmd = []
7
+
8
+ cmd << 'bundle exec' if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
9
+ cmd << 'danger'
10
+ cmd << '--verbose' if params[:verbose]
11
+
12
+ danger_id = params[:danger_id]
13
+ dangerfile = params[:dangerfile]
14
+ base = params[:base]
15
+ head = params[:head]
16
+ pr = params[:pr]
17
+ cmd << "--danger_id=#{danger_id}" if danger_id
18
+ cmd << "--dangerfile=#{dangerfile}" if dangerfile
19
+ cmd << "--fail-on-errors=true" if params[:fail_on_errors]
20
+ cmd << "--new-comment" if params[:new_comment]
21
+ cmd << "--remove-previous-comments" if params[:remove_previous_comments]
22
+ cmd << "--base=#{base}" if base
23
+ cmd << "--head=#{head}" if head
24
+ cmd << "pr #{pr}" if pr
25
+
26
+ ENV['DANGER_GITHUB_API_TOKEN'] = params[:github_api_token] if params[:github_api_token]
27
+
28
+ Actions.sh(cmd.join(' '))
29
+ end
30
+
31
+ def self.description
32
+ "Runs `danger` for the project"
33
+ end
34
+
35
+ def self.details
36
+ [
37
+ "Formalize your Pull Request etiquette.",
38
+ "More information: [https://github.com/danger/danger](https://github.com/danger/danger)."
39
+ ].join("\n")
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ PantographCore::ConfigItem.new(key: :use_bundle_exec,
45
+ env_name: "FL_DANGER_USE_BUNDLE_EXEC",
46
+ description: "Use bundle exec when there is a Gemfile presented",
47
+ is_string: false,
48
+ default_value: true),
49
+ PantographCore::ConfigItem.new(key: :verbose,
50
+ env_name: "FL_DANGER_VERBOSE",
51
+ description: "Show more debugging information",
52
+ is_string: false,
53
+ default_value: false),
54
+ PantographCore::ConfigItem.new(key: :danger_id,
55
+ env_name: "FL_DANGER_ID",
56
+ description: "The identifier of this Danger instance",
57
+ is_string: true,
58
+ optional: true),
59
+ PantographCore::ConfigItem.new(key: :dangerfile,
60
+ env_name: "FL_DANGER_DANGERFILE",
61
+ description: "The location of your Dangerfile",
62
+ is_string: true,
63
+ optional: true),
64
+ PantographCore::ConfigItem.new(key: :github_api_token,
65
+ env_name: "FL_DANGER_GITHUB_API_TOKEN",
66
+ description: "GitHub API token for danger",
67
+ sensitive: true,
68
+ is_string: true,
69
+ optional: true),
70
+ PantographCore::ConfigItem.new(key: :fail_on_errors,
71
+ env_name: "FL_DANGER_FAIL_ON_ERRORS",
72
+ description: "Should always fail the build process, defaults to false",
73
+ is_string: false,
74
+ optional: true,
75
+ default_value: false),
76
+ PantographCore::ConfigItem.new(key: :new_comment,
77
+ env_name: "FL_DANGER_NEW_COMMENT",
78
+ description: "Makes Danger post a new comment instead of editing its previous one",
79
+ is_string: false,
80
+ optional: true,
81
+ default_value: false),
82
+ PantographCore::ConfigItem.new(key: :remove_previous_comments,
83
+ env_name: "FL_DANGER_REMOVE_PREVIOUS_COMMENT",
84
+ description: "Makes Danger remove all previous comment and create a new one in the end of the list",
85
+ is_string: false,
86
+ optional: true,
87
+ default_value: false),
88
+ PantographCore::ConfigItem.new(key: :base,
89
+ env_name: "FL_DANGER_BASE",
90
+ description: "A branch/tag/commit to use as the base of the diff. [master|dev|stable]",
91
+ is_string: true,
92
+ optional: true),
93
+ PantographCore::ConfigItem.new(key: :head,
94
+ env_name: "FL_DANGER_HEAD",
95
+ description: "A branch/tag/commit to use as the head. [master|dev|stable]",
96
+ is_string: true,
97
+ optional: true),
98
+ PantographCore::ConfigItem.new(key: :pr,
99
+ env_name: "FL_DANGER_PR",
100
+ description: "Run danger on a specific pull request. e.g. \"https://github.com/danger/danger/pull/518\"",
101
+ is_string: true,
102
+ optional: true)
103
+ ]
104
+ end
105
+
106
+ def self.is_supported?(platform)
107
+ true
108
+ end
109
+
110
+ def self.example_code
111
+ [
112
+ 'danger',
113
+ 'danger(
114
+ danger_id: "unit-tests",
115
+ dangerfile: "tests/MyOtherDangerFile",
116
+ github_api_token: ENV["GITHUB_API_TOKEN"],
117
+ verbose: true
118
+ )'
119
+ ]
120
+ end
121
+
122
+ def self.category
123
+ :misc
124
+ end
125
+
126
+ def self.authors
127
+ ["KrauseFx"]
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,32 @@
1
+ module Pantograph
2
+ module Actions
3
+ class DebugAction < Action
4
+ def self.run(params)
5
+ puts("Lane Context".green)
6
+ puts(Actions.lane_context)
7
+ end
8
+
9
+ def self.description
10
+ "Print out an overview of the lane context values"
11
+ end
12
+
13
+ def self.is_supported?(platform)
14
+ true
15
+ end
16
+
17
+ def self.example_code
18
+ [
19
+ 'debug'
20
+ ]
21
+ end
22
+
23
+ def self.category
24
+ :misc
25
+ end
26
+
27
+ def self.author
28
+ "KrauseFx"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ DEFAULT_PLATFORM = :DEFAULT_PLATFORM
5
+ end
6
+
7
+ class DefaultPlatformAction < Action
8
+ def self.run(params)
9
+ UI.user_error!("You forgot to pass the default platform") if params.first.nil?
10
+
11
+ platform = params.first.to_sym
12
+
13
+ SupportedPlatforms.verify!(platform)
14
+
15
+ Actions.lane_context[SharedValues::DEFAULT_PLATFORM] = platform
16
+ end
17
+
18
+ def self.description
19
+ "Defines a default platform to not have to specify the platform"
20
+ end
21
+
22
+ def self.output
23
+ [
24
+ ['DEFAULT_PLATFORM', 'The default platform']
25
+ ]
26
+ end
27
+
28
+ def self.example_code
29
+ [
30
+ 'default_platform(:android)'
31
+ ]
32
+ end
33
+
34
+ def self.category
35
+ :misc
36
+ end
37
+
38
+ def self.author
39
+ "KrauseFx"
40
+ end
41
+
42
+ def self.is_supported?(platform)
43
+ true
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,76 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ DOWNLOAD_CONTENT = :DOWNLOAD_CONTENT
5
+ end
6
+
7
+ class DownloadAction < Action
8
+ def self.run(params)
9
+ require 'net/http'
10
+
11
+ begin
12
+ result = Net::HTTP.get(URI(params[:url]))
13
+ begin
14
+ result = JSON.parse(result) # try to parse and see if it's valid JSON data
15
+ rescue
16
+ # never mind, using standard text data instead
17
+ end
18
+ Actions.lane_context[SharedValues::DOWNLOAD_CONTENT] = result
19
+ rescue => ex
20
+ UI.user_error!("Error fetching remote file: #{ex}")
21
+ end
22
+ end
23
+
24
+ #####################################################
25
+ # @!group Documentation
26
+ #####################################################
27
+
28
+ def self.description
29
+ "Download a file from a remote server (e.g. JSON file)"
30
+ end
31
+
32
+ def self.details
33
+ [
34
+ "Specify the URL to download and get the content as a return value.",
35
+ "Automatically parses JSON into a Ruby data structure.",
36
+ "For more advanced networking code, use the Ruby functions instead: [http://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html](http://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html)."
37
+ ].join("\n")
38
+ end
39
+
40
+ def self.available_options
41
+ [
42
+ PantographCore::ConfigItem.new(key: :url,
43
+ env_name: "FL_DOWNLOAD_URL",
44
+ description: "The URL that should be downloaded",
45
+ verify_block: proc do |value|
46
+ UI.important("The URL doesn't start with http or https") unless value.start_with?("http")
47
+ end)
48
+ ]
49
+ end
50
+
51
+ def self.output
52
+ [
53
+ ['DOWNLOAD_CONTENT', 'The content of the file we just downloaded']
54
+ ]
55
+ end
56
+
57
+ def self.example_code
58
+ [
59
+ 'data = download(url: "https://host.com/api.json")'
60
+ ]
61
+ end
62
+
63
+ def self.category
64
+ :misc
65
+ end
66
+
67
+ def self.authors
68
+ ["KrauseFx"]
69
+ end
70
+
71
+ def self.is_supported?(platform)
72
+ true
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,14 @@
1
+ module Pantograph
2
+ module Actions
3
+ require 'pantograph/actions/puts'
4
+ class EchoAction < 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
@@ -0,0 +1,59 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ end
5
+
6
+ # Raises an exception and stop the lane execution if not using bundle exec to run pantograph
7
+ class EnsureBundleExecAction < Action
8
+ def self.run(params)
9
+ return if PluginManager.new.gemfile_path.nil?
10
+ if PantographCore::Helper.bundler?
11
+ UI.success("Using bundled pantograph ✅")
12
+ else
13
+ UI.user_error!("pantograph detected a Gemfile in the current directory. However it seems like you don't use `bundle exec`. Use `bundle exec pantograph #{ARGV.join(' ')}`")
14
+ end
15
+ end
16
+
17
+ #####################################################
18
+ # @!group Documentation
19
+ #####################################################
20
+
21
+ def self.description
22
+ "Raises an exception if not using `bundle exec` to run pantograph"
23
+ end
24
+
25
+ def self.details
26
+ [
27
+ "This action will check if you are using bundle exec to run pantograph.",
28
+ "You can put it into `before_all` and make sure that pantograph is run using `bundle exec pantograph` command."
29
+ ].join("\n")
30
+ end
31
+
32
+ def self.available_options
33
+ []
34
+ end
35
+
36
+ def self.output
37
+ []
38
+ end
39
+
40
+ def self.author
41
+ ['rishabhtayal']
42
+ end
43
+
44
+ def self.example_code
45
+ [
46
+ "ensure_bundle_exec"
47
+ ]
48
+ end
49
+
50
+ def self.category
51
+ :misc
52
+ end
53
+
54
+ def self.is_supported?(platform)
55
+ true
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ module Pantograph
2
+ module Actions
3
+ class EnsureEnvVarsAction < Action
4
+ def self.run(params)
5
+ variables = params[:env_vars]
6
+
7
+ variables.each do |variable|
8
+ next unless ENV[variable].to_s.strip.empty?
9
+
10
+ UI.user_error!("Missing environment variable '#{variable}'")
11
+ end
12
+
13
+ is_one = variables.length == 1
14
+
15
+ UI.success("Environment variable#{is_one ? '' : 's'} '#{variables.join('\', \'')}' #{is_one ? 'is' : 'are'} set!")
16
+ end
17
+
18
+ def self.description
19
+ 'Raises an exception if the specified env vars are not set'
20
+ end
21
+
22
+ def self.details
23
+ 'This action will check if some environment variables are set.'
24
+ end
25
+
26
+ def self.available_options
27
+ [
28
+ PantographCore::ConfigItem.new(key: :env_vars,
29
+ description: 'The environment variables names that should be checked',
30
+ type: Array,
31
+ verify_block: proc do |value|
32
+ UI.user_error!('Specify at least one environment variable name') if value.empty?
33
+ end)
34
+ ]
35
+ end
36
+
37
+ def self.authors
38
+ ['revolter']
39
+ end
40
+
41
+ def self.example_code
42
+ [
43
+ 'ensure_env_vars(
44
+ env_vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
45
+ )'
46
+ ]
47
+ end
48
+
49
+ def self.category
50
+ :misc
51
+ end
52
+
53
+ def self.is_supported?(platform)
54
+ true
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,69 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ end
5
+
6
+ # Raises an exception and stop the lane execution if the repo is not on a specific branch
7
+ class EnsureGitBranchAction < Action
8
+ def self.run(params)
9
+ branch = params[:branch]
10
+ branch_expr = /#{branch}/
11
+ if Actions.git_branch =~ branch_expr
12
+ UI.success("Git branch matches `#{branch}`, all good! 💪")
13
+ else
14
+ UI.user_error!("Git is not on a branch matching `#{branch}`. Current branch is `#{Actions.git_branch}`! Please ensure the repo is checked out to the correct branch.")
15
+ end
16
+ end
17
+
18
+ #####################################################
19
+ # @!group Documentation
20
+ #####################################################
21
+
22
+ def self.description
23
+ "Raises an exception if not on a specific git branch"
24
+ end
25
+
26
+ def self.details
27
+ [
28
+ "This action will check if your git repo is checked out to a specific branch.",
29
+ "You may only want to make releases from a specific branch, so `ensure_git_branch` will stop a lane if it was accidentally executed on an incorrect branch."
30
+ ].join("\n")
31
+ end
32
+
33
+ def self.available_options
34
+ [
35
+ PantographCore::ConfigItem.new(key: :branch,
36
+ env_name: "FL_ENSURE_GIT_BRANCH_NAME",
37
+ description: "The branch that should be checked for. String that can be either the full name of the branch or a regex to match",
38
+ is_string: true,
39
+ default_value: 'master')
40
+ ]
41
+ end
42
+
43
+ def self.output
44
+ []
45
+ end
46
+
47
+ def self.author
48
+ ['dbachrach', 'Liquidsoul']
49
+ end
50
+
51
+ def self.example_code
52
+ [
53
+ "ensure_git_branch # defaults to `master` branch",
54
+ "ensure_git_branch(
55
+ branch: 'develop'
56
+ )"
57
+ ]
58
+ end
59
+
60
+ def self.category
61
+ :source_control
62
+ end
63
+
64
+ def self.is_supported?(platform)
65
+ true
66
+ end
67
+ end
68
+ end
69
+ end