pantograph 0.1.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 (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,156 @@
1
+ module Pantograph
2
+ module Actions
3
+ class BundleInstallAction < Action
4
+ # rubocop:disable Metrics/PerceivedComplexity
5
+ def self.run(params)
6
+ if gemfile_exists?(params)
7
+ cmd = ['bundle install']
8
+
9
+ cmd << "--binstubs #{params[:binstubs]}" if params[:binstubs]
10
+ cmd << "--clean" if params[:clean]
11
+ cmd << "--full-index" if params[:full_index]
12
+ cmd << "--gemfile #{params[:gemfile]}" if params[:gemfile]
13
+ cmd << "--jobs #{params[:jobs]}" if params[:jobs]
14
+ cmd << "--local" if params[:local]
15
+ cmd << "--deployment" if params[:deployment]
16
+ cmd << "--no-cache" if params[:no_cache]
17
+ cmd << "--no_prune" if params[:no_prune]
18
+ cmd << "--path #{params[:path]}" if params[:path]
19
+ cmd << "--system" if params[:system]
20
+ cmd << "--quiet" if params[:quiet]
21
+ cmd << "--retry #{params[:retry]}" if params[:retry]
22
+ cmd << "--shebang" if params[:shebang]
23
+ cmd << "--standalone #{params[:standalone]}" if params[:standalone]
24
+ cmd << "--trust-policy" if params[:trust_policy]
25
+ cmd << "--without #{params[:without]}" if params[:without]
26
+ cmd << "--with #{params[:with]}" if params[:with]
27
+
28
+ return sh(cmd.join(' '))
29
+ else
30
+ UI.message("No Gemfile found")
31
+ end
32
+ end
33
+ # rubocop:enable Metrics/PerceivedComplexity
34
+
35
+ def self.gemfile_exists?(params)
36
+ possible_gemfiles = ['Gemfile', 'gemfile']
37
+ possible_gemfiles.insert(0, params[:gemfile]) if params[:gemfile]
38
+ possible_gemfiles.each do |gemfile|
39
+ gemfile = File.absolute_path(gemfile)
40
+ return true if File.exist?(gemfile)
41
+ UI.message("Gemfile not found at: '#{gemfile}'")
42
+ end
43
+ return false
44
+ end
45
+
46
+ def self.description
47
+ 'This action runs `bundle install` (if available)'
48
+ end
49
+
50
+ def self.is_supported?(platform)
51
+ true
52
+ end
53
+
54
+ def self.author
55
+ ["birmacher", "koglinjg"]
56
+ end
57
+
58
+ def self.example_code
59
+ nil
60
+ end
61
+
62
+ def self.category
63
+ :misc
64
+ end
65
+
66
+ def self.available_options
67
+ [
68
+ PantographCore::ConfigItem.new(key: :binstubs,
69
+ env_name: "FL_BUNDLE_INSTALL_BINSTUBS",
70
+ description: "Generate bin stubs for bundled gems to ./bin",
71
+ optional: true),
72
+ PantographCore::ConfigItem.new(key: :clean,
73
+ env_name: "FL_BUNDLE_INSTALL_CLEAN",
74
+ description: "Run bundle clean automatically after install",
75
+ is_string: false,
76
+ default_value: false),
77
+ PantographCore::ConfigItem.new(key: :full_index,
78
+ env_name: "FL_BUNDLE_INSTALL_FULL_INDEX",
79
+ description: "Use the rubygems modern index instead of the API endpoint",
80
+ is_string: false,
81
+ default_value: false),
82
+ PantographCore::ConfigItem.new(key: :gemfile,
83
+ env_name: "FL_BUNDLE_INSTALL_GEMFILE",
84
+ description: "Use the specified gemfile instead of Gemfile",
85
+ optional: true),
86
+ PantographCore::ConfigItem.new(key: :jobs,
87
+ env_name: "FL_BUNDLE_INSTALL_JOBS",
88
+ description: "Install gems using parallel workers",
89
+ is_string: false,
90
+ type: Boolean,
91
+ optional: true),
92
+ PantographCore::ConfigItem.new(key: :local,
93
+ env_name: "FL_BUNDLE_INSTALL_LOCAL",
94
+ description: "Do not attempt to fetch gems remotely and use the gem cache instead",
95
+ is_string: false,
96
+ default_value: false),
97
+ PantographCore::ConfigItem.new(key: :deployment,
98
+ env_name: "FL_BUNDLE_INSTALL_DEPLOYMENT",
99
+ description: "Install using defaults tuned for deployment and CI environments",
100
+ is_string: false,
101
+ default_value: false),
102
+ PantographCore::ConfigItem.new(key: :no_cache,
103
+ env_name: "FL_BUNDLE_INSTALL_NO_CACHE",
104
+ description: "Don't update the existing gem cache",
105
+ is_string: false,
106
+ default_value: false),
107
+ PantographCore::ConfigItem.new(key: :no_prune,
108
+ env_name: "FL_BUNDLE_INSTALL_NO_PRUNE",
109
+ description: "Don't remove stale gems from the cache",
110
+ is_string: false,
111
+ default_value: false),
112
+ PantographCore::ConfigItem.new(key: :path,
113
+ env_name: "FL_BUNDLE_INSTALL_PATH",
114
+ description: "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine",
115
+ optional: true),
116
+ PantographCore::ConfigItem.new(key: :system,
117
+ env_name: "FL_BUNDLE_INSTALL_SYSTEM",
118
+ description: "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application",
119
+ is_string: false,
120
+ default_value: false),
121
+ PantographCore::ConfigItem.new(key: :quiet,
122
+ env_name: "FL_BUNDLE_INSTALL_QUIET",
123
+ description: "Only output warnings and errors",
124
+ is_string: false,
125
+ default_value: false),
126
+ PantographCore::ConfigItem.new(key: :retry,
127
+ env_name: "FL_BUNDLE_INSTALL_RETRY",
128
+ description: "Retry network and git requests that have failed",
129
+ is_string: false,
130
+ type: Boolean,
131
+ optional: true),
132
+ PantographCore::ConfigItem.new(key: :shebang,
133
+ env_name: "FL_BUNDLE_INSTALL_SHEBANG",
134
+ description: "Specify a different shebang executable name than the default (usually 'ruby')",
135
+ optional: true),
136
+ PantographCore::ConfigItem.new(key: :standalone,
137
+ env_name: "FL_BUNDLE_INSTALL_STANDALONE",
138
+ description: "Make a bundle that can work without the Bundler runtime",
139
+ optional: true),
140
+ PantographCore::ConfigItem.new(key: :trust_policy,
141
+ env_name: "FL_BUNDLE_INSTALL_TRUST_POLICY",
142
+ description: "Sets level of security when dealing with signed gems. Accepts `LowSecurity`, `MediumSecurity` and `HighSecurity` as values",
143
+ optional: true),
144
+ PantographCore::ConfigItem.new(key: :without,
145
+ env_name: "FL_BUNDLE_INSTALL_WITHOUT",
146
+ description: "Exclude gems that are part of the specified named group",
147
+ optional: true),
148
+ PantographCore::ConfigItem.new(key: :with,
149
+ env_name: "FL_BUNDLE_INSTALL_WITH",
150
+ description: "Include gems that are part of the specified named group",
151
+ optional: true)
152
+ ]
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,197 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ FL_CHANGELOG ||= :FL_CHANGELOG
5
+ end
6
+
7
+ class ChangelogFromGitCommitsAction < Action
8
+ def self.run(params)
9
+ if params[:commits_count]
10
+ UI.success("Collecting the last #{params[:commits_count]} Git commits")
11
+ else
12
+ if params[:between]
13
+ if params[:between].kind_of?(String) && params[:between].include?(",") # :between is string
14
+ from, to = params[:between].split(",", 2)
15
+ elsif params[:between].kind_of?(Array)
16
+ from, to = params[:between]
17
+ end
18
+ else
19
+ from = Actions.last_git_tag_name(params[:match_lightweight_tag], params[:tag_match_pattern])
20
+ UI.verbose("Found the last Git tag: #{from}")
21
+ to = 'HEAD'
22
+ end
23
+ UI.success("Collecting Git commits between #{from} and #{to}")
24
+ end
25
+
26
+ # Normally it is not good practice to take arbitrary input and convert it to a symbol
27
+ # because prior to Ruby 2.2, symbols are never garbage collected. However, we've
28
+ # already validated that the input matches one of our allowed values, so this is OK
29
+ merge_commit_filtering = params[:merge_commit_filtering].to_sym
30
+
31
+ # We want to be specific and exclude nil for this comparison
32
+ if params[:include_merges] == false
33
+ merge_commit_filtering = :exclude_merges
34
+ end
35
+
36
+ params[:path] = './' unless params[:path]
37
+
38
+ Dir.chdir(params[:path]) do
39
+ if params[:commits_count]
40
+ changelog = Actions.git_log_last_commits(params[:pretty], params[:commits_count], merge_commit_filtering, params[:date_format], params[:ancestry_path])
41
+ else
42
+ changelog = Actions.git_log_between(params[:pretty], from, to, merge_commit_filtering, params[:date_format], params[:ancestry_path])
43
+ end
44
+
45
+ changelog = changelog.gsub("\n\n", "\n") if changelog # as there are duplicate newlines
46
+ Actions.lane_context[SharedValues::FL_CHANGELOG] = changelog
47
+
48
+ if params[:quiet] == false
49
+ puts("")
50
+ puts(changelog)
51
+ puts("")
52
+ end
53
+
54
+ changelog
55
+ end
56
+ end
57
+
58
+ #####################################################
59
+ # @!group Documentation
60
+ #####################################################
61
+
62
+ def self.description
63
+ "Collect git commit messages into a changelog"
64
+ end
65
+
66
+ def self.details
67
+ "By default, messages will be collected back to the last tag, but the range can be controlled"
68
+ end
69
+
70
+ def self.output
71
+ [
72
+ ['FL_CHANGELOG', 'The changelog string generated from the collected git commit messages']
73
+ ]
74
+ end
75
+
76
+ def self.available_options
77
+ [
78
+ PantographCore::ConfigItem.new(key: :between,
79
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_BETWEEN',
80
+ description: 'Array containing two Git revision values between which to collect messages, you mustn\'t use it with :commits_count key at the same time',
81
+ optional: true,
82
+ is_string: false,
83
+ conflicting_options: [:commits_count],
84
+ verify_block: proc do |value|
85
+ if value.kind_of?(String)
86
+ UI.user_error!(":between must contain comma") unless value.include?(',')
87
+ else
88
+ UI.user_error!(":between must be of type array") unless value.kind_of?(Array)
89
+ UI.user_error!(":between must not contain nil values") if value.any?(&:nil?)
90
+ UI.user_error!(":between must be an array of size 2") unless (value || []).size == 2
91
+ end
92
+ end),
93
+ PantographCore::ConfigItem.new(key: :commits_count,
94
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_COUNT',
95
+ description: 'Number of commits to include in changelog, you mustn\'t use it with :between key at the same time',
96
+ optional: true,
97
+ is_string: false,
98
+ conflicting_options: [:between],
99
+ type: Integer,
100
+ verify_block: proc do |value|
101
+ UI.user_error!(":commits_count must be >= 1") unless value.to_i >= 1
102
+ end),
103
+ PantographCore::ConfigItem.new(key: :path,
104
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_PATH',
105
+ description: 'Path of the git repository',
106
+ optional: true,
107
+ default_value: './'),
108
+ PantographCore::ConfigItem.new(key: :pretty,
109
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_PRETTY',
110
+ description: 'The format applied to each commit while generating the collected value',
111
+ optional: true,
112
+ default_value: '%B',
113
+ is_string: true),
114
+ PantographCore::ConfigItem.new(key: :date_format,
115
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_DATE_FORMAT',
116
+ description: 'The date format applied to each commit while generating the collected value',
117
+ optional: true,
118
+ is_string: true),
119
+ PantographCore::ConfigItem.new(key: :ancestry_path,
120
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_ANCESTRY_PATH',
121
+ description: 'Whether or not to use ancestry-path param',
122
+ optional: true,
123
+ default_value: false,
124
+ is_string: false),
125
+ PantographCore::ConfigItem.new(key: :tag_match_pattern,
126
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_TAG_MATCH_PATTERN',
127
+ description: 'A glob(7) pattern to match against when finding the last git tag',
128
+ optional: true),
129
+ PantographCore::ConfigItem.new(key: :match_lightweight_tag,
130
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_MATCH_LIGHTWEIGHT_TAG',
131
+ description: 'Whether or not to match a lightweight tag when searching for the last one',
132
+ optional: true,
133
+ default_value: true,
134
+ is_string: false),
135
+ PantographCore::ConfigItem.new(key: :quiet,
136
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_TAG_QUIET',
137
+ description: 'Whether or not to disable changelog output',
138
+ optional: true,
139
+ default_value: false,
140
+ is_string: false),
141
+ PantographCore::ConfigItem.new(key: :include_merges,
142
+ deprecated: "Use `:merge_commit_filtering` instead",
143
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_INCLUDE_MERGES',
144
+ description: "Whether or not to include any commits that are merges",
145
+ optional: true,
146
+ is_string: false,
147
+ type: Boolean,
148
+ verify_block: proc do |value|
149
+ UI.important("The :include_merges option is deprecated. Please use :merge_commit_filtering instead") unless value.nil?
150
+ end),
151
+ PantographCore::ConfigItem.new(key: :merge_commit_filtering,
152
+ env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_MERGE_COMMIT_FILTERING',
153
+ description: "Controls inclusion of merge commits when collecting the changelog. Valid values: #{GIT_MERGE_COMMIT_FILTERING_OPTIONS.map { |o| "`:#{o}`" }.join(', ')}",
154
+ optional: true,
155
+ default_value: 'include_merges',
156
+ verify_block: proc do |value|
157
+ matches_option = GIT_MERGE_COMMIT_FILTERING_OPTIONS.any? { |opt| opt.to_s == value }
158
+ UI.user_error!("Valid values for :merge_commit_filtering are #{GIT_MERGE_COMMIT_FILTERING_OPTIONS.map { |o| "'#{o}'" }.join(', ')}") unless matches_option
159
+ end)
160
+ ]
161
+ end
162
+
163
+ def self.return_value
164
+ "Returns a String containing your formatted git commits"
165
+ end
166
+
167
+ def self.return_type
168
+ :string
169
+ end
170
+
171
+ def self.author
172
+ ['mfurtak', 'asfalcone', 'SiarheiFedartsou', 'allewun']
173
+ end
174
+
175
+ def self.is_supported?(platform)
176
+ true
177
+ end
178
+
179
+ def self.example_code
180
+ [
181
+ 'changelog_from_git_commits',
182
+ 'changelog_from_git_commits(
183
+ between: ["7b092b3", "HEAD"], # Optional, lets you specify a revision/tag range between which to collect commit info
184
+ pretty: "- (%ae) %s", # Optional, lets you provide a custom format to apply to each commit when generating the changelog text
185
+ date_format: "short", # Optional, lets you provide an additional date format to dates within the pretty-formatted string
186
+ match_lightweight_tag: false, # Optional, lets you ignore lightweight (non-annotated) tags when searching for the last tag
187
+ merge_commit_filtering: "exclude_merges" # Optional, lets you filter out merge commits
188
+ )'
189
+ ]
190
+ end
191
+
192
+ def self.category
193
+ :source_control
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,52 @@
1
+ module Pantograph
2
+ module Actions
3
+ class ClipboardAction < Action
4
+ def self.run(params)
5
+ value = params[:value]
6
+
7
+ truncated_value = value[0..800].gsub(/\s\w+\s*$/, '...')
8
+ UI.message("Storing '#{truncated_value}' in the clipboard 🎨")
9
+
10
+ if PantographCore::Helper.mac?
11
+ require 'open3'
12
+ Open3.popen3('pbcopy') { |input, _, _| input << value }
13
+ end
14
+ end
15
+
16
+ #####################################################
17
+ # @!group Documentation
18
+ #####################################################
19
+
20
+ def self.description
21
+ "Copies a given string into the clipboard. Works only on macOS"
22
+ end
23
+
24
+ def self.available_options
25
+ [
26
+ PantographCore::ConfigItem.new(key: :value,
27
+ env_name: "FL_CLIPBOARD_VALUE",
28
+ description: "The string that should be copied into the clipboard")
29
+ ]
30
+ end
31
+
32
+ def self.authors
33
+ ["KrauseFx", "joshdholtz"]
34
+ end
35
+
36
+ def self.is_supported?(platform)
37
+ true
38
+ end
39
+
40
+ def self.example_code
41
+ [
42
+ 'clipboard(value: "https://docs.pantograph.tools/")',
43
+ 'clipboard(value: lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK] || "")'
44
+ ]
45
+ end
46
+
47
+ def self.category
48
+ :misc
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,89 @@
1
+ module Pantograph
2
+ module Actions
3
+ class ClocAction < Action
4
+ def self.run(params)
5
+ cloc_binary = params[:binary_path]
6
+ exclude_dirs = params[:exclude_dir].nil? ? '' : "--exclude-dir=#{params[:exclude_dir]}"
7
+ xml_format = params[:xml]
8
+ out_dir = params[:output_directory]
9
+ output_file = xml_format ? "#{out_dir}/cloc.xml" : "#{out_dir}/cloc.txt"
10
+ source_directory = params[:source_directory]
11
+
12
+ command = [
13
+ cloc_binary,
14
+ exclude_dirs,
15
+ '--by-file',
16
+ xml_format ? '--xml ' : '',
17
+ "--out=#{output_file}",
18
+ source_directory
19
+ ].join(' ').strip
20
+
21
+ Actions.sh(command)
22
+ end
23
+
24
+ def self.description
25
+ "Generates a Code Count that can be read by Jenkins (xml format)"
26
+ end
27
+
28
+ def self.details
29
+ [
30
+ "This action will run cloc to generate a SLOC report that the Jenkins SLOCCount plugin can read.",
31
+ "See [https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin](https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin) and [https://github.com/AlDanial/cloc](https://github.com/AlDanial/cloc) for more information."
32
+ ].join("\n")
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ PantographCore::ConfigItem.new(key: :binary_path,
38
+ env_name: "FL_CLOC_BINARY_PATH",
39
+ description: "Where the cloc binary lives on your system (full path including 'cloc')",
40
+ optional: true,
41
+ is_string: true,
42
+ default_value: '/usr/local/bin/cloc'),
43
+ PantographCore::ConfigItem.new(key: :exclude_dir,
44
+ env_name: "FL_CLOC_EXCLUDE_DIR",
45
+ description: "Comma separated list of directories to exclude", # a short description of this parameter
46
+ optional: true,
47
+ is_string: true),
48
+ PantographCore::ConfigItem.new(key: :output_directory,
49
+ env_name: "FL_CLOC_OUTPUT_DIRECTORY",
50
+ description: "Where to put the generated report file",
51
+ is_string: true,
52
+ default_value: "build"),
53
+ PantographCore::ConfigItem.new(key: :source_directory,
54
+ env_name: "FL_CLOC_SOURCE_DIRECTORY",
55
+ description: "Where to look for the source code (relative to the project root folder)",
56
+ is_string: true,
57
+ default_value: ""),
58
+ PantographCore::ConfigItem.new(key: :xml,
59
+ env_name: "FL_CLOC_XML",
60
+ description: "Should we generate an XML File (if false, it will generate a plain text file)?",
61
+ is_string: false,
62
+ default_value: true)
63
+ ]
64
+ end
65
+
66
+ def self.authors
67
+ ["intere"]
68
+ end
69
+
70
+ def self.is_supported?(platform)
71
+ [:ios, :mac].include?(platform)
72
+ end
73
+
74
+ def self.example_code
75
+ [
76
+ 'cloc(
77
+ exclude_dir: "ThirdParty,Resources",
78
+ output_directory: "reports",
79
+ source_directory: "MyCoolApp"
80
+ )'
81
+ ]
82
+ end
83
+
84
+ def self.category
85
+ :misc
86
+ end
87
+ end
88
+ end
89
+ end