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,81 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ GIT_REPO_WAS_CLEAN_ON_START = :GIT_REPO_WAS_CLEAN_ON_START
5
+ end
6
+
7
+ # Raises an exception and stop the lane execution if the repo is not in a clean state
8
+ class EnsureGitStatusCleanAction < Action
9
+ def self.run(params)
10
+ repo_status = Actions.sh("git status --porcelain")
11
+ repo_clean = repo_status.empty?
12
+
13
+ if repo_clean
14
+ UI.success('Git status is clean, all good! 💪')
15
+ Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
16
+ else
17
+ error_message = "Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first."
18
+ error_message += "\nUncommitted changes:\n#{repo_status}" if params[:show_uncommitted_changes]
19
+ if params[:show_diff]
20
+ repo_diff = Actions.sh("git diff")
21
+ error_message += "\nGit diff: \n#{repo_diff}"
22
+ end
23
+ UI.user_error!(error_message)
24
+ end
25
+ end
26
+
27
+ def self.description
28
+ "Raises an exception if there are uncommitted git changes"
29
+ end
30
+
31
+ def self.details
32
+ [
33
+ "A sanity check to make sure you are working in a repo that is clean.",
34
+ "Especially useful to put at the beginning of your Pantfile in the `before_all` block, if some of your other actions will touch your filesystem, do things to your git repo, or just as a general reminder to save your work.",
35
+ "Also needed as a prerequisite for some other actions like `reset_git_repo`."
36
+ ].join("\n")
37
+ end
38
+
39
+ def self.output
40
+ [
41
+ ['GIT_REPO_WAS_CLEAN_ON_START', 'Stores the fact that the git repo was clean at some point']
42
+ ]
43
+ end
44
+
45
+ def self.author
46
+ ["lmirosevic", "antondomashnev"]
47
+ end
48
+
49
+ def self.example_code
50
+ [
51
+ 'ensure_git_status_clean'
52
+ ]
53
+ end
54
+
55
+ def self.available_options
56
+ [
57
+ PantographCore::ConfigItem.new(key: :show_uncommitted_changes,
58
+ env_name: "FL_ENSURE_GIT_STATUS_CLEAN_SHOW_UNCOMMITTED_CHANGES",
59
+ description: "The flag whether to show uncommitted changes if the repo is dirty",
60
+ optional: true,
61
+ default_value: false,
62
+ is_string: false),
63
+ PantographCore::ConfigItem.new(key: :show_diff,
64
+ env_name: "FL_ENSURE_GIT_STATUS_CLEAN_SHOW_DIFF",
65
+ description: "The flag whether to show the git diff if the repo is dirty",
66
+ optional: true,
67
+ default_value: false,
68
+ is_string: false)
69
+ ]
70
+ end
71
+
72
+ def self.category
73
+ :source_control
74
+ end
75
+
76
+ def self.is_supported?(platform)
77
+ true
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,88 @@
1
+ module Pantograph
2
+ module Actions
3
+ class ErbAction < Action
4
+ def self.run(params)
5
+ template = File.read(params[:template])
6
+ result = ERB.new(template).result(OpenStruct.new(params[:placeholders]).instance_eval { binding })
7
+ File.open(params[:destination], 'w') { |file| file.write(result) } if params[:destination]
8
+ UI.message("Successfully parsed template: '#{params[:template]}' and rendered output to: #{params[:destination]}") if params[:destination]
9
+ result
10
+ end
11
+
12
+ #####################################################
13
+ # @!group Documentation
14
+ #####################################################
15
+
16
+ def self.description
17
+ "Allows to Generate output files based on ERB templates"
18
+ end
19
+
20
+ def self.details
21
+ [
22
+ "Renders an ERB template with `:placeholders` given as a hash via parameter.",
23
+ "If no `:destination` is set, it returns the rendered template as string."
24
+ ].join("\n")
25
+ end
26
+
27
+ def self.available_options
28
+ [
29
+
30
+ PantographCore::ConfigItem.new(key: :template,
31
+ short_option: "-T",
32
+ env_name: "FL_ERB_SRC",
33
+ description: "ERB Template File",
34
+ optional: false,
35
+ is_string: true),
36
+ PantographCore::ConfigItem.new(key: :destination,
37
+ short_option: "-D",
38
+ env_name: "FL_ERB_DST",
39
+ description: "Destination file",
40
+ optional: true,
41
+ is_string: true),
42
+ PantographCore::ConfigItem.new(key: :placeholders,
43
+ short_option: "-p",
44
+ env_name: "FL_ERB_PLACEHOLDERS",
45
+ description: "Placeholders given as a hash",
46
+ default_value: {},
47
+ is_string: false,
48
+ type: Hash)
49
+
50
+ ]
51
+ end
52
+
53
+ def self.authors
54
+ ["hjanuschka"]
55
+ end
56
+
57
+ def self.example_code
58
+ [
59
+ '# Example `erb` template:
60
+
61
+ # Variable1 <%= var1 %>
62
+ # Variable2 <%= var2 %>
63
+ # <% for item in var3 %>
64
+ # <%= item %>
65
+ # <% end %>
66
+
67
+ erb(
68
+ template: "1.erb",
69
+ destination: "/tmp/rendered.out",
70
+ placeholders: {
71
+ :var1 => 123,
72
+ :var2 => "string",
73
+ :var3 => ["element1", "element2"]
74
+ }
75
+ )'
76
+ ]
77
+ end
78
+
79
+ def self.category
80
+ :misc
81
+ end
82
+
83
+ def self.is_supported?(platform)
84
+ true
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,120 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ BUILD_NUMBER_REPOSITORY = :BUILD_NUMBER_REPOSITORY
5
+ end
6
+
7
+ class GetBuildNumberRepositoryAction < Action
8
+ def self.is_svn?
9
+ Actions.sh('svn info')
10
+ return true
11
+ rescue
12
+ return false
13
+ end
14
+
15
+ def self.is_git?
16
+ Actions.sh('git rev-parse HEAD')
17
+ return true
18
+ rescue
19
+ return false
20
+ end
21
+
22
+ def self.is_git_svn?
23
+ Actions.sh('git svn info')
24
+ return true
25
+ rescue
26
+ return false
27
+ end
28
+
29
+ def self.is_hg?
30
+ Actions.sh('hg status')
31
+ return true
32
+ rescue
33
+ return false
34
+ end
35
+
36
+ def self.command(use_hg_revision_number)
37
+ if is_svn?
38
+ UI.message("Detected repo: svn")
39
+ return 'svn info | grep Revision | egrep -o "[0-9]+"'
40
+ elsif is_git_svn?
41
+ UI.message("Detected repo: git-svn")
42
+ return 'git svn info | grep Revision | egrep -o "[0-9]+"'
43
+ elsif is_git?
44
+ UI.message("Detected repo: git")
45
+ return 'git rev-parse --short HEAD'
46
+ elsif is_hg?
47
+ UI.message("Detected repo: hg")
48
+ if use_hg_revision_number
49
+ return 'hg parent --template {rev}'
50
+ else
51
+ return 'hg parent --template "{node|short}"'
52
+ end
53
+ else
54
+ UI.user_error!("No repository detected")
55
+ end
56
+ end
57
+
58
+ def self.run(params)
59
+ build_number = Action.sh(command(params[:use_hg_revision_number])).strip
60
+ Actions.lane_context[SharedValues::BUILD_NUMBER_REPOSITORY] = build_number
61
+ return build_number
62
+ end
63
+
64
+ #####################################################
65
+ # @!group Documentation
66
+ #####################################################
67
+
68
+ def self.description
69
+ "Get the build number from the current repository"
70
+ end
71
+
72
+ def self.details
73
+ [
74
+ "This action will get the **build number** according to what the SCM HEAD reports.",
75
+ "Currently supported SCMs are svn (uses root revision), git-svn (uses svn revision), git (uses short hash) and mercurial (uses short hash or revision number).",
76
+ "There is an option, `:use_hg_revision_number`, which allows to use mercurial revision number instead of hash."
77
+ ].join("\n")
78
+ end
79
+
80
+ def self.available_options
81
+ [
82
+ PantographCore::ConfigItem.new(key: :use_hg_revision_number,
83
+ env_name: "USE_HG_REVISION_NUMBER",
84
+ description: "Use hg revision number instead of hash (ignored for non-hg repos)",
85
+ optional: true,
86
+ is_string: false,
87
+ default_value: false)
88
+ ]
89
+ end
90
+
91
+ def self.output
92
+ [
93
+ ['BUILD_NUMBER_REPOSITORY', 'The build number from the current repository']
94
+ ]
95
+ end
96
+
97
+ def self.return_value
98
+ "The build number from the current repository"
99
+ end
100
+
101
+ def self.authors
102
+ ["bartoszj", "pbrooks", "armadsen"]
103
+ end
104
+
105
+ def self.is_supported?(platform)
106
+ [:ios, :mac].include?(platform)
107
+ end
108
+
109
+ def self.example_code
110
+ [
111
+ 'get_build_number_repository'
112
+ ]
113
+ end
114
+
115
+ def self.category
116
+ :source_control
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,163 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ GET_GITHUB_RELEASE_INFO = :GET_GITHUB_RELEASE_INFO
5
+ end
6
+
7
+ class GetGithubReleaseAction < Action
8
+ def self.run(params)
9
+ UI.message("Getting release on GitHub (#{params[:server_url]}/#{params[:url]}: #{params[:version]})")
10
+
11
+ GithubApiAction.run(
12
+ server_url: params[:server_url],
13
+ api_token: params[:api_token],
14
+ http_method: 'GET',
15
+ path: "repos/#{params[:url]}/releases",
16
+ error_handlers: {
17
+ 404 => proc do |result|
18
+ UI.error("Repository #{params[:url]} cannot be found, please double check its name and that you provided a valid API token (if it's a private repository).")
19
+ return nil
20
+ end,
21
+ 401 => proc do |result|
22
+ UI.error("You are not authorized to access #{params[:url]}, please make sure you provided a valid API token.")
23
+ return nil
24
+ end,
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
+ json.each do |current|
33
+ next unless current['tag_name'] == params[:version]
34
+
35
+ # Found it
36
+ Actions.lane_context[SharedValues::GET_GITHUB_RELEASE_INFO] = current
37
+ UI.message("Version is already live on GitHub.com 🚁")
38
+ return current
39
+ end
40
+ end
41
+
42
+ UI.important("Couldn't find GitHub release #{params[:version]}")
43
+ return nil
44
+ end
45
+
46
+ #####################################################
47
+ # @!group Documentation
48
+ #####################################################
49
+
50
+ def self.description
51
+ "This will verify if a given release version is available on GitHub"
52
+ end
53
+
54
+ def self.details
55
+ sample = <<-SAMPLE.markdown_sample
56
+ ```no-highlight
57
+ {
58
+ "url"=>"https://api.github.com/repos/KrauseFx/pantograph/releases/1537713",
59
+ "assets_url"=>"https://api.github.com/repos/KrauseFx/pantograph/releases/1537713/assets",
60
+ "upload_url"=>"https://uploads.github.com/repos/KrauseFx/pantograph/releases/1537713/assets{?name}",
61
+ "html_url"=>"https://github.com/pantograph/pantograph/releases/tag/1.8.0",
62
+ "id"=>1537713,
63
+ "tag_name"=>"1.8.0",
64
+ "target_commitish"=>"master",
65
+ "name"=>"1.8.0 Switch Lanes & Pass Parameters",
66
+ "draft"=>false,
67
+ "author"=>
68
+ {"login"=>"KrauseFx",
69
+ "id"=>869950,
70
+ "avatar_url"=>"https://avatars.githubusercontent.com/u/869950?v=3",
71
+ "gravatar_id"=>"",
72
+ "url"=>"https://api.github.com/users/KrauseFx",
73
+ "html_url"=>"https://github.com/pantograph",
74
+ "followers_url"=>"https://api.github.com/users/KrauseFx/followers",
75
+ "following_url"=>"https://api.github.com/users/KrauseFx/following{/other_user}",
76
+ "gists_url"=>"https://api.github.com/users/KrauseFx/gists{/gist_id}",
77
+ "starred_url"=>"https://api.github.com/users/KrauseFx/starred{/owner}{/repo}",
78
+ "subscriptions_url"=>"https://api.github.com/users/KrauseFx/subscriptions",
79
+ "organizations_url"=>"https://api.github.com/users/KrauseFx/orgs",
80
+ "repos_url"=>"https://api.github.com/users/KrauseFx/repos",
81
+ "events_url"=>"https://api.github.com/users/KrauseFx/events{/privacy}",
82
+ "received_events_url"=>"https://api.github.com/users/KrauseFx/received_events",
83
+ "type"=>"User",
84
+ "site_admin"=>false},
85
+ "prerelease"=>false,
86
+ "created_at"=>"2015-07-14T23:33:01Z",
87
+ "published_at"=>"2015-07-14T23:44:10Z",
88
+ "assets"=>[],
89
+ "tarball_url"=>"https://api.github.com/repos/KrauseFx/pantograph/tarball/1.8.0",
90
+ "zipball_url"=>"https://api.github.com/repos/KrauseFx/pantograph/zipball/1.8.0",
91
+ "body"=> ...Markdown...
92
+ "This is one of the biggest updates of _pantograph_ yet"
93
+ }
94
+ ```
95
+ SAMPLE
96
+
97
+ [
98
+ "This will return all information about a release. For example:".markdown_preserve_newlines,
99
+ sample
100
+ ].join("\n")
101
+ end
102
+
103
+ def self.output
104
+ [
105
+ ['GET_GITHUB_RELEASE_INFO', 'Contains all the information about this release']
106
+ ]
107
+ end
108
+
109
+ def self.available_options
110
+ [
111
+ PantographCore::ConfigItem.new(key: :url,
112
+ env_name: "FL_GET_GITHUB_RELEASE_URL",
113
+ description: "The path to your repo, e.g. 'KrauseFx/pantograph'",
114
+ verify_block: proc do |value|
115
+ UI.user_error!("Please only pass the path, e.g. 'KrauseFx/pantograph'") if value.include?("github.com")
116
+ UI.user_error!("Please only pass the path, e.g. 'KrauseFx/pantograph'") if value.split('/').count != 2
117
+ end),
118
+ PantographCore::ConfigItem.new(key: :server_url,
119
+ env_name: "FL_GITHUB_RELEASE_SERVER_URL",
120
+ description: "The server url. e.g. 'https://your.github.server/api/v3' (Default: 'https://api.github.com')",
121
+ default_value: "https://api.github.com",
122
+ optional: true,
123
+ verify_block: proc do |value|
124
+ UI.user_error!("Please include the protocol in the server url, e.g. https://your.github.server") unless value.include?("//")
125
+ end),
126
+ PantographCore::ConfigItem.new(key: :version,
127
+ env_name: "FL_GET_GITHUB_RELEASE_VERSION",
128
+ description: "The version tag of the release to check"),
129
+ PantographCore::ConfigItem.new(key: :api_token,
130
+ env_name: "FL_GITHUB_RELEASE_API_TOKEN",
131
+ sensitive: true,
132
+ description: "GitHub Personal Token (required for private repositories)",
133
+ optional: true)
134
+ ]
135
+ end
136
+
137
+ def self.authors
138
+ ["KrauseFx", "czechboy0", "jaleksynas", "tommeier"]
139
+ end
140
+
141
+ def self.is_supported?(platform)
142
+ true
143
+ end
144
+
145
+ def self.example_code
146
+ [
147
+ 'release = get_github_release(url: "pantograph/pantograph", version: "1.0.0")
148
+ puts release["name"]'
149
+ ]
150
+ end
151
+
152
+ def self.sample_return_value
153
+ {
154
+ "name" => "name"
155
+ }
156
+ end
157
+
158
+ def self.category
159
+ :source_control
160
+ end
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,93 @@
1
+ module Pantograph
2
+ module Actions
3
+ class GitAddAction < Action
4
+ def self.run(params)
5
+ should_escape = params[:shell_escape]
6
+
7
+ if params[:pathspec]
8
+ paths = params[:pathspec]
9
+ success_message = "Successfully added from \"#{paths}\" 💾."
10
+ elsif params[:path]
11
+ if params[:path].kind_of?(String)
12
+ paths = shell_escape(params[:path], should_escape)
13
+ elsif params[:path].kind_of?(Array)
14
+ paths = params[:path].map do |p|
15
+ shell_escape(p, should_escape)
16
+ end.join(' ')
17
+ end
18
+ success_message = "Successfully added \"#{paths}\" 💾."
19
+ else
20
+ paths = "."
21
+ success_message = "Successfully added all files 💾."
22
+ end
23
+
24
+ result = Actions.sh("git add #{paths}", log: PantographCore::Globals.verbose?).chomp
25
+ UI.success(success_message)
26
+ return result
27
+ end
28
+
29
+ def self.shell_escape(path, should_escape)
30
+ path = path.shellescape if should_escape
31
+ path
32
+ end
33
+
34
+ #####################################################
35
+ # @!group Documentation
36
+ #####################################################
37
+
38
+ def self.description
39
+ "Directly add the given file or all files"
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ PantographCore::ConfigItem.new(key: :path,
45
+ description: "The file(s) and path(s) you want to add",
46
+ is_string: false,
47
+ conflicting_options: [:pathspec],
48
+ optional: true),
49
+ PantographCore::ConfigItem.new(key: :shell_escape,
50
+ description: "Shell escapes paths (set to false if using wildcards or manually escaping spaces in :path)",
51
+ is_string: false,
52
+ default_value: true,
53
+ optional: true),
54
+ # Deprecated
55
+ PantographCore::ConfigItem.new(key: :pathspec,
56
+ description: "The pathspec you want to add files from",
57
+ is_string: true,
58
+ conflicting_options: [:path],
59
+ optional: true,
60
+ deprecated: "Use `--path` instead")
61
+ ]
62
+ end
63
+
64
+ def self.return_value
65
+ nil
66
+ end
67
+
68
+ def self.authors
69
+ ["4brunu", "antondomashnev"]
70
+ end
71
+
72
+ def self.is_supported?(platform)
73
+ true
74
+ end
75
+
76
+ def self.example_code
77
+ [
78
+ 'git_add',
79
+ 'git_add(path: "./version.txt")',
80
+ 'git_add(path: ["./version.txt", "./changelog.txt"])',
81
+ 'git_add(path: "./Frameworks/*", shell_escape: false)',
82
+ 'git_add(path: ["*.h", "*.m"], shell_escape: false)',
83
+ 'git_add(path: "./Frameworks/*", shell_escape: false)',
84
+ 'git_add(path: "*.txt", shell_escape: false)'
85
+ ]
86
+ end
87
+
88
+ def self.category
89
+ :source_control
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,58 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ GIT_BRANCH_ENV_VARS = %w(GIT_BRANCH BRANCH_NAME TRAVIS_BRANCH BITRISE_GIT_BRANCH CI_BUILD_REF_NAME CI_COMMIT_REF_NAME WERCKER_GIT_BRANCH BUILDKITE_BRANCH).freeze
5
+ end
6
+
7
+ class GitBranchAction < Action
8
+ def self.run(params)
9
+ env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| PantographCore::Env.truthy?(env_var) }
10
+ ENV.fetch(env_name.to_s) { `git symbolic-ref HEAD --short 2>/dev/null`.strip }
11
+ end
12
+
13
+ #####################################################
14
+ # @!group Documentation
15
+ #####################################################
16
+
17
+ def self.description
18
+ "Returns the name of the current git branch, possibly as managed by CI ENV vars"
19
+ end
20
+
21
+ def self.details
22
+ "If no branch could be found, this action will return an empty string"
23
+ end
24
+
25
+ def self.available_options
26
+ []
27
+ end
28
+
29
+ def self.output
30
+ [
31
+ ['GIT_BRANCH_ENV_VARS', 'The git branch environment variables']
32
+ ]
33
+ end
34
+
35
+ def self.authors
36
+ ["KrauseFx"]
37
+ end
38
+
39
+ def self.is_supported?(platform)
40
+ true
41
+ end
42
+
43
+ def self.example_code
44
+ [
45
+ 'git_branch'
46
+ ]
47
+ end
48
+
49
+ def self.return_type
50
+ :string
51
+ end
52
+
53
+ def self.category
54
+ :source_control
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,80 @@
1
+ module Pantograph
2
+ module Actions
3
+ class GitCommitAction < Action
4
+ def self.run(params)
5
+ if params[:path].kind_of?(String)
6
+ paths = params[:path].shellescape
7
+ else
8
+ paths = params[:path].map(&:shellescape).join(' ')
9
+ end
10
+
11
+ skip_git_hooks = params[:skip_git_hooks] ? '--no-verify' : ''
12
+
13
+ if params[:allow_nothing_to_commit]
14
+ repo_clean = Actions.sh("git status --porcelain").empty?
15
+ UI.success("Nothing to commit, working tree clean ✅.") if repo_clean
16
+ return if repo_clean
17
+ end
18
+
19
+ command = "git commit -m #{params[:message].shellescape} #{paths} #{skip_git_hooks}".strip
20
+ result = Actions.sh(command)
21
+ UI.success("Successfully committed \"#{params[:path]}\" 💾.")
22
+ return result
23
+ end
24
+
25
+ #####################################################
26
+ # @!group Documentation
27
+ #####################################################
28
+
29
+ def self.description
30
+ "Directly commit the given file with the given message"
31
+ end
32
+
33
+ def self.available_options
34
+ [
35
+ PantographCore::ConfigItem.new(key: :path,
36
+ description: "The file you want to commit",
37
+ is_string: false),
38
+ PantographCore::ConfigItem.new(key: :message,
39
+ description: "The commit message that should be used"),
40
+ PantographCore::ConfigItem.new(key: :skip_git_hooks,
41
+ description: "Set to true to pass --no-verify to git",
42
+ type: Boolean,
43
+ optional: true),
44
+ PantographCore::ConfigItem.new(key: :allow_nothing_to_commit,
45
+ description: "Set to true to allow commit without any git changes",
46
+ type: Boolean,
47
+ optional: true)
48
+ ]
49
+ end
50
+
51
+ def self.output
52
+ end
53
+
54
+ def self.return_value
55
+ nil
56
+ end
57
+
58
+ def self.authors
59
+ ["KrauseFx"]
60
+ end
61
+
62
+ def self.is_supported?(platform)
63
+ true
64
+ end
65
+
66
+ def self.example_code
67
+ [
68
+ 'git_commit(path: "./version.txt", message: "Version Bump")',
69
+ 'git_commit(path: ["./version.txt", "./changelog.txt"], message: "Version Bump")',
70
+ 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation")',
71
+ 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation", skip_git_hooks: true)'
72
+ ]
73
+ end
74
+
75
+ def self.category
76
+ :source_control
77
+ end
78
+ end
79
+ end
80
+ end