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.
- checksums.yaml +7 -0
- data/.yardopts +1 -0
- data/LICENSE +21 -0
- data/README.md +197 -0
- data/bin/bin-proxy +19 -0
- data/bin/pantograph +23 -0
- data/pantograph/README.md +11 -0
- data/pantograph/lib/assets/ActionDetails.md.erb +106 -0
- data/pantograph/lib/assets/Actions.md.erb +43 -0
- data/pantograph/lib/assets/DefaultPantfileTemplate +20 -0
- data/pantograph/lib/assets/completions/completion.bash +23 -0
- data/pantograph/lib/assets/completions/completion.fish +39 -0
- data/pantograph/lib/assets/completions/completion.sh +12 -0
- data/pantograph/lib/assets/completions/completion.zsh +23 -0
- data/pantograph/lib/assets/custom_action_template.rb +80 -0
- data/pantograph/lib/assets/report_template.xml.erb +15 -0
- data/pantograph/lib/pantograph/action.rb +194 -0
- data/pantograph/lib/pantograph/action_collector.rb +35 -0
- data/pantograph/lib/pantograph/actions/README.md +3 -0
- data/pantograph/lib/pantograph/actions/actions_helper.rb +166 -0
- data/pantograph/lib/pantograph/actions/add_extra_platforms.rb +45 -0
- data/pantograph/lib/pantograph/actions/artifactory.rb +157 -0
- data/pantograph/lib/pantograph/actions/bundle_install.rb +156 -0
- data/pantograph/lib/pantograph/actions/changelog_from_git_commits.rb +197 -0
- data/pantograph/lib/pantograph/actions/clipboard.rb +52 -0
- data/pantograph/lib/pantograph/actions/cloc.rb +89 -0
- data/pantograph/lib/pantograph/actions/create_pull_request.rb +190 -0
- data/pantograph/lib/pantograph/actions/danger.rb +131 -0
- data/pantograph/lib/pantograph/actions/debug.rb +32 -0
- data/pantograph/lib/pantograph/actions/default_platform.rb +47 -0
- data/pantograph/lib/pantograph/actions/download.rb +76 -0
- data/pantograph/lib/pantograph/actions/echo.rb +14 -0
- data/pantograph/lib/pantograph/actions/ensure_bundle_exec.rb +59 -0
- data/pantograph/lib/pantograph/actions/ensure_env_vars.rb +58 -0
- data/pantograph/lib/pantograph/actions/ensure_git_branch.rb +69 -0
- data/pantograph/lib/pantograph/actions/ensure_git_status_clean.rb +81 -0
- data/pantograph/lib/pantograph/actions/erb.rb +88 -0
- data/pantograph/lib/pantograph/actions/get_build_number_repository.rb +120 -0
- data/pantograph/lib/pantograph/actions/get_github_release.rb +163 -0
- data/pantograph/lib/pantograph/actions/git_add.rb +93 -0
- data/pantograph/lib/pantograph/actions/git_branch.rb +58 -0
- data/pantograph/lib/pantograph/actions/git_commit.rb +80 -0
- data/pantograph/lib/pantograph/actions/git_pull.rb +53 -0
- data/pantograph/lib/pantograph/actions/git_submodule_update.rb +52 -0
- data/pantograph/lib/pantograph/actions/git_tag_exists.rb +74 -0
- data/pantograph/lib/pantograph/actions/github_api.rb +262 -0
- data/pantograph/lib/pantograph/actions/gradle.rb +278 -0
- data/pantograph/lib/pantograph/actions/import.rb +49 -0
- data/pantograph/lib/pantograph/actions/import_from_git.rb +71 -0
- data/pantograph/lib/pantograph/actions/is_ci.rb +51 -0
- data/pantograph/lib/pantograph/actions/jira.rb +115 -0
- data/pantograph/lib/pantograph/actions/lane_context.rb +60 -0
- data/pantograph/lib/pantograph/actions/last_git_commit.rb +58 -0
- data/pantograph/lib/pantograph/actions/last_git_tag.rb +51 -0
- data/pantograph/lib/pantograph/actions/make_changelog_from_jenkins.rb +81 -0
- data/pantograph/lib/pantograph/actions/min_pantograph_version.rb +57 -0
- data/pantograph/lib/pantograph/actions/nexus_upload.rb +230 -0
- data/pantograph/lib/pantograph/actions/notification.rb +75 -0
- data/pantograph/lib/pantograph/actions/number_of_commits.rb +75 -0
- data/pantograph/lib/pantograph/actions/opt_out_usage.rb +40 -0
- data/pantograph/lib/pantograph/actions/pantograph_version.rb +15 -0
- data/pantograph/lib/pantograph/actions/println.rb +14 -0
- data/pantograph/lib/pantograph/actions/prompt.rb +119 -0
- data/pantograph/lib/pantograph/actions/push_git_tags.rb +76 -0
- data/pantograph/lib/pantograph/actions/push_to_git_remote.rb +127 -0
- data/pantograph/lib/pantograph/actions/puts.rb +68 -0
- data/pantograph/lib/pantograph/actions/reset_git_repo.rb +121 -0
- data/pantograph/lib/pantograph/actions/rocket.rb +83 -0
- data/pantograph/lib/pantograph/actions/rsync.rb +74 -0
- data/pantograph/lib/pantograph/actions/ruby_version.rb +56 -0
- data/pantograph/lib/pantograph/actions/say.rb +56 -0
- data/pantograph/lib/pantograph/actions/scp.rb +114 -0
- data/pantograph/lib/pantograph/actions/set_github_release.rb +274 -0
- data/pantograph/lib/pantograph/actions/sh.rb +71 -0
- data/pantograph/lib/pantograph/actions/skip_docs.rb +52 -0
- data/pantograph/lib/pantograph/actions/slack.rb +288 -0
- data/pantograph/lib/pantograph/actions/sonar.rb +156 -0
- data/pantograph/lib/pantograph/actions/ssh.rb +162 -0
- data/pantograph/lib/pantograph/actions/twitter.rb +89 -0
- data/pantograph/lib/pantograph/actions/update_pantograph.rb +177 -0
- data/pantograph/lib/pantograph/actions/zip.rb +120 -0
- data/pantograph/lib/pantograph/auto_complete.rb +82 -0
- data/pantograph/lib/pantograph/boolean.rb +5 -0
- data/pantograph/lib/pantograph/cli_tools_distributor.rb +183 -0
- data/pantograph/lib/pantograph/command_line_handler.rb +43 -0
- data/pantograph/lib/pantograph/commands_generator.rb +344 -0
- data/pantograph/lib/pantograph/configuration_helper.rb +26 -0
- data/pantograph/lib/pantograph/core_ext/bundler_monkey_patch.rb +14 -0
- data/pantograph/lib/pantograph/documentation/actions_list.rb +214 -0
- data/pantograph/lib/pantograph/documentation/docs_generator.rb +95 -0
- data/pantograph/lib/pantograph/documentation/markdown_docs_generator.rb +221 -0
- data/pantograph/lib/pantograph/environment_printer.rb +282 -0
- data/pantograph/lib/pantograph/erb_template_helper.rb +30 -0
- data/pantograph/lib/pantograph/features.rb +4 -0
- data/pantograph/lib/pantograph/helper/README.md +29 -0
- data/pantograph/lib/pantograph/helper/dotenv_helper.rb +50 -0
- data/pantograph/lib/pantograph/helper/gem_helper.rb +26 -0
- data/pantograph/lib/pantograph/helper/git_helper.rb +135 -0
- data/pantograph/lib/pantograph/helper/gradle_helper.rb +62 -0
- data/pantograph/lib/pantograph/helper/sh_helper.rb +134 -0
- data/pantograph/lib/pantograph/junit_generator.rb +27 -0
- data/pantograph/lib/pantograph/lane.rb +97 -0
- data/pantograph/lib/pantograph/lane_list.rb +77 -0
- data/pantograph/lib/pantograph/lane_manager.rb +140 -0
- data/pantograph/lib/pantograph/lane_manager_base.rb +92 -0
- data/pantograph/lib/pantograph/markdown_table_formatter.rb +62 -0
- data/pantograph/lib/pantograph/new_action.rb +47 -0
- data/pantograph/lib/pantograph/one_off.rb +45 -0
- data/pantograph/lib/pantograph/other_action.rb +29 -0
- data/pantograph/lib/pantograph/pant_file.rb +377 -0
- data/pantograph/lib/pantograph/pantograph_require.rb +75 -0
- data/pantograph/lib/pantograph/plugins/plugin_fetcher.rb +55 -0
- data/pantograph/lib/pantograph/plugins/plugin_generator.rb +86 -0
- data/pantograph/lib/pantograph/plugins/plugin_generator_ui.rb +19 -0
- data/pantograph/lib/pantograph/plugins/plugin_info.rb +49 -0
- data/pantograph/lib/pantograph/plugins/plugin_info_collector.rb +159 -0
- data/pantograph/lib/pantograph/plugins/plugin_manager.rb +387 -0
- data/pantograph/lib/pantograph/plugins/plugin_search.rb +46 -0
- data/pantograph/lib/pantograph/plugins/plugin_update_manager.rb +70 -0
- data/pantograph/lib/pantograph/plugins/plugins.rb +12 -0
- data/pantograph/lib/pantograph/plugins/template/%gem_name%.gemspec.erb +35 -0
- data/pantograph/lib/pantograph/plugins/template/.circleci/config.yml +43 -0
- data/pantograph/lib/pantograph/plugins/template/.gitignore +12 -0
- data/pantograph/lib/pantograph/plugins/template/.rspec +5 -0
- data/pantograph/lib/pantograph/plugins/template/.rubocop.yml +179 -0
- data/pantograph/lib/pantograph/plugins/template/.travis.yml +4 -0
- data/pantograph/lib/pantograph/plugins/template/Gemfile +6 -0
- data/pantograph/lib/pantograph/plugins/template/LICENSE.erb +21 -0
- data/pantograph/lib/pantograph/plugins/template/README.md.erb +52 -0
- data/pantograph/lib/pantograph/plugins/template/Rakefile +9 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/actions/%plugin_name%_action.rb.erb +47 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/helper/%plugin_name%_helper.rb.erb +16 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/version.rb.erb +5 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%.rb.erb +16 -0
- data/pantograph/lib/pantograph/plugins/template/pantograph/Pantfile.erb +3 -0
- data/pantograph/lib/pantograph/plugins/template/pantograph/Pluginfile.erb +1 -0
- data/pantograph/lib/pantograph/plugins/template/spec/%plugin_name%_action_spec.rb.erb +9 -0
- data/pantograph/lib/pantograph/plugins/template/spec/spec_helper.rb.erb +15 -0
- data/pantograph/lib/pantograph/runner.rb +371 -0
- data/pantograph/lib/pantograph/server/action_command.rb +61 -0
- data/pantograph/lib/pantograph/server/action_command_return.rb +14 -0
- data/pantograph/lib/pantograph/server/command_executor.rb +7 -0
- data/pantograph/lib/pantograph/server/command_parser.rb +36 -0
- data/pantograph/lib/pantograph/server/control_command.rb +23 -0
- data/pantograph/lib/pantograph/server/json_return_value_processor.rb +72 -0
- data/pantograph/lib/pantograph/server/socket_server.rb +232 -0
- data/pantograph/lib/pantograph/server/socket_server_action_command_executor.rb +101 -0
- data/pantograph/lib/pantograph/setup/setup.rb +290 -0
- data/pantograph/lib/pantograph/setup/setup_android.rb +64 -0
- data/pantograph/lib/pantograph/setup/setup_ios.rb +412 -0
- data/pantograph/lib/pantograph/shells.rb +6 -0
- data/pantograph/lib/pantograph/supported_platforms.rb +28 -0
- data/pantograph/lib/pantograph/tools.rb +10 -0
- data/pantograph/lib/pantograph/version.rb +5 -0
- data/pantograph/lib/pantograph.rb +51 -0
- data/pantograph_core/README.md +79 -0
- data/pantograph_core/lib/assets/XMLTemplate.xml.erb +12 -0
- data/pantograph_core/lib/pantograph_core/analytics/action_completion_context.rb +34 -0
- data/pantograph_core/lib/pantograph_core/analytics/action_launch_context.rb +38 -0
- data/pantograph_core/lib/pantograph_core/analytics/analytics_event_builder.rb +23 -0
- data/pantograph_core/lib/pantograph_core/analytics/analytics_ingester_client.rb +54 -0
- data/pantograph_core/lib/pantograph_core/analytics/analytics_session.rb +71 -0
- data/pantograph_core/lib/pantograph_core/cert_checker.rb +116 -0
- data/pantograph_core/lib/pantograph_core/command_executor.rb +99 -0
- data/pantograph_core/lib/pantograph_core/configuration/commander_generator.rb +103 -0
- data/pantograph_core/lib/pantograph_core/configuration/config_item.rb +314 -0
- data/pantograph_core/lib/pantograph_core/configuration/configuration.rb +332 -0
- data/pantograph_core/lib/pantograph_core/configuration/configuration_file.rb +182 -0
- data/pantograph_core/lib/pantograph_core/core_ext/shellwords.rb +63 -0
- data/pantograph_core/lib/pantograph_core/core_ext/string.rb +17 -0
- data/pantograph_core/lib/pantograph_core/env.rb +9 -0
- data/pantograph_core/lib/pantograph_core/feature/feature.rb +51 -0
- data/pantograph_core/lib/pantograph_core/features.rb +4 -0
- data/pantograph_core/lib/pantograph_core/globals.rb +27 -0
- data/pantograph_core/lib/pantograph_core/helper.rb +409 -0
- data/pantograph_core/lib/pantograph_core/keychain_importer.rb +74 -0
- data/pantograph_core/lib/pantograph_core/languages.rb +14 -0
- data/pantograph_core/lib/pantograph_core/module.rb +29 -0
- data/pantograph_core/lib/pantograph_core/pantograph_folder.rb +39 -0
- data/pantograph_core/lib/pantograph_core/pantograph_pty.rb +57 -0
- data/pantograph_core/lib/pantograph_core/pkg_file_analyser.rb +44 -0
- data/pantograph_core/lib/pantograph_core/print_table.rb +131 -0
- data/pantograph_core/lib/pantograph_core/string_filters.rb +51 -0
- data/pantograph_core/lib/pantograph_core/swag.rb +85 -0
- data/pantograph_core/lib/pantograph_core/tag_version.rb +31 -0
- data/pantograph_core/lib/pantograph_core/test_parser.rb +107 -0
- data/pantograph_core/lib/pantograph_core/ui/disable_colors.rb +17 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_common_error.rb +19 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_crash.rb +11 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_error.rb +25 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_exception.rb +19 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_shell_error.rb +11 -0
- data/pantograph_core/lib/pantograph_core/ui/errors.rb +1 -0
- data/pantograph_core/lib/pantograph_core/ui/github_issue_inspector_reporter.rb +62 -0
- data/pantograph_core/lib/pantograph_core/ui/implementations/shell.rb +159 -0
- data/pantograph_core/lib/pantograph_core/ui/interface.rb +205 -0
- data/pantograph_core/lib/pantograph_core/ui/pantograph_runner.rb +276 -0
- data/pantograph_core/lib/pantograph_core/ui/ui.rb +26 -0
- data/pantograph_core/lib/pantograph_core/update_checker/changelog.rb +37 -0
- data/pantograph_core/lib/pantograph_core/update_checker/update_checker.rb +107 -0
- data/pantograph_core/lib/pantograph_core.rb +45 -0
- metadata +987 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
unless Object.const_defined?("Faraday")
|
2
|
+
# We create these empty error classes if we didn't require Faraday
|
3
|
+
# so that we can use it in the rescue block below even if we didn't
|
4
|
+
# require Faraday or didn't use it
|
5
|
+
module Faraday
|
6
|
+
class Error < StandardError; end
|
7
|
+
class ClientError < Error; end
|
8
|
+
class SSLError < ClientError; end
|
9
|
+
class ConnectionFailed < ClientError; end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
unless Object.const_defined?("OpenSSL")
|
14
|
+
module OpenSSL
|
15
|
+
module SSL
|
16
|
+
class SSLError < StandardError; end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'commander'
|
22
|
+
|
23
|
+
require_relative '../env'
|
24
|
+
require_relative '../globals'
|
25
|
+
require_relative '../analytics/action_completion_context'
|
26
|
+
require_relative '../analytics/action_launch_context'
|
27
|
+
require_relative 'errors'
|
28
|
+
|
29
|
+
module Commander
|
30
|
+
# This class override the run method with our custom stack trace handling
|
31
|
+
# In particular we want to distinguish between user_error! and crash! (one with, one without stack trace)
|
32
|
+
class Runner
|
33
|
+
# Code taken from https://github.com/commander-rb/commander/blob/master/lib/commander/runner.rb#L50
|
34
|
+
|
35
|
+
attr_accessor :collector
|
36
|
+
|
37
|
+
def run!
|
38
|
+
require_program(:version, :description)
|
39
|
+
trap('INT') { abort(program(:int_message)) } if program(:int_message)
|
40
|
+
trap('INT') { program(:int_block).call } if program(:int_block)
|
41
|
+
global_option('-h', '--help', 'Display help documentation') do
|
42
|
+
args = @args - %w(-h --help)
|
43
|
+
command(:help).run(*args)
|
44
|
+
return
|
45
|
+
end
|
46
|
+
global_option('-v', '--version', 'Display version information') do
|
47
|
+
say(version)
|
48
|
+
return
|
49
|
+
end
|
50
|
+
parse_global_options
|
51
|
+
remove_global_options(options, @args)
|
52
|
+
|
53
|
+
begin
|
54
|
+
pantograph_client_language = :ruby
|
55
|
+
action_launch_context = PantographCore::ActionLaunchContext.context_for_action_name(@program[:name], pantograph_client_language: pantograph_client_language, args: ARGV)
|
56
|
+
PantographCore.session.action_launched(launch_context: action_launch_context)
|
57
|
+
|
58
|
+
return_value = run_active_command
|
59
|
+
|
60
|
+
action_completed(@program[:name], status: PantographCore::ActionCompletionStatus::SUCCESS)
|
61
|
+
return return_value
|
62
|
+
rescue Commander::Runner::InvalidCommandError => e
|
63
|
+
# calling `abort` makes it likely that tests stop without failing, so
|
64
|
+
# we'll disable that during tests.
|
65
|
+
if PantographCore::Helper.test?
|
66
|
+
raise e
|
67
|
+
else
|
68
|
+
abort("#{e}. Use --help for more information")
|
69
|
+
end
|
70
|
+
rescue Interrupt => e
|
71
|
+
# We catch it so that the stack trace is hidden by default when using ctrl + c
|
72
|
+
if PantographCore::Globals.verbose?
|
73
|
+
raise e
|
74
|
+
else
|
75
|
+
action_completed(@program[:name], status: PantographCore::ActionCompletionStatus::INTERRUPTED, exception: e)
|
76
|
+
abort("\nCancelled... use --verbose to show the stack trace")
|
77
|
+
end
|
78
|
+
rescue \
|
79
|
+
OptionParser::InvalidOption,
|
80
|
+
OptionParser::InvalidArgument,
|
81
|
+
OptionParser::MissingArgument => e
|
82
|
+
# calling `abort` makes it likely that tests stop without failing, so
|
83
|
+
# we'll disable that during tests.
|
84
|
+
if PantographCore::Helper.test?
|
85
|
+
raise e
|
86
|
+
else
|
87
|
+
if self.active_command.name == "help" && @default_command == :help # need to access directly via @
|
88
|
+
# This is a special case, for example for pilot
|
89
|
+
# when the user runs `pantograph pilot -u user@google.com`
|
90
|
+
# This would be confusing, as the user probably wanted to use `pilot list`
|
91
|
+
# or some other command. Because `-u` isn't available for the `pilot --help`
|
92
|
+
# command it would show this very confusing error message otherwise
|
93
|
+
abort("Please ensure to use one of the available commands (#{self.commands.keys.join(', ')})".red)
|
94
|
+
else
|
95
|
+
# This would print something like
|
96
|
+
#
|
97
|
+
# invalid option: -u
|
98
|
+
#
|
99
|
+
abort(e.to_s)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
rescue PantographCore::Interface::PantographCommonException => e # these are exceptions that we dont count as crashes
|
103
|
+
display_user_error!(e, e.to_s)
|
104
|
+
rescue PantographCore::Interface::PantographError => e # user_error!
|
105
|
+
rescue_pantograph_error(e)
|
106
|
+
rescue Errno::ENOENT => e
|
107
|
+
rescue_file_error(e)
|
108
|
+
rescue Faraday::SSLError, OpenSSL::SSL::SSLError => e # SSL issues are very common
|
109
|
+
handle_ssl_error!(e)
|
110
|
+
rescue Faraday::ConnectionFailed => e
|
111
|
+
rescue_connection_failed_error(e)
|
112
|
+
rescue => e # high chance this is actually PantographCore::Interface::PantographCrash, but can be anything else
|
113
|
+
rescue_unknown_error(e)
|
114
|
+
ensure
|
115
|
+
PantographCore.session.finalize_session
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def action_completed(action_name, status: nil, exception: nil)
|
120
|
+
# https://github.com/pantograph/pantograph/issues/11913
|
121
|
+
# if exception.nil? || exception.pantograph_should_report_metrics?
|
122
|
+
# action_completion_context = PantographCore::ActionCompletionContext.context_for_action_name(action_name, args: ARGV, status: status)
|
123
|
+
# PantographCore.session.action_completed(completion_context: action_completion_context)
|
124
|
+
# end
|
125
|
+
end
|
126
|
+
|
127
|
+
def rescue_file_error(e)
|
128
|
+
# We're also printing the new-lines, as otherwise the message is not very visible in-between the error and the stack trace
|
129
|
+
puts("")
|
130
|
+
PantographCore::UI.important("Error accessing file, this might be due to pantograph's directory handling")
|
131
|
+
PantographCore::UI.important("Check out https://docs.pantograph.tools/advanced/#directory-behavior for more details")
|
132
|
+
puts("")
|
133
|
+
raise e
|
134
|
+
end
|
135
|
+
|
136
|
+
def rescue_connection_failed_error(e)
|
137
|
+
if e.message.include?('Connection reset by peer - SSL_connect')
|
138
|
+
handle_tls_error!(e)
|
139
|
+
else
|
140
|
+
handle_unknown_error!(e)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def rescue_unknown_error(e)
|
145
|
+
action_completed(@program[:name], status: PantographCore::ActionCompletionStatus::FAILED, exception: e)
|
146
|
+
|
147
|
+
handle_unknown_error!(e)
|
148
|
+
end
|
149
|
+
|
150
|
+
def rescue_pantograph_error(e)
|
151
|
+
action_completed(@program[:name], status: PantographCore::ActionCompletionStatus::USER_ERROR, exception: e)
|
152
|
+
|
153
|
+
show_github_issues(e.message) if e.show_github_issues
|
154
|
+
display_user_error!(e, e.message)
|
155
|
+
end
|
156
|
+
|
157
|
+
def handle_tls_error!(e)
|
158
|
+
# Apple has upgraded its App Store Connect servers to require TLS 1.2, but
|
159
|
+
# system Ruby 2.0 does not support it. We want to suggest that users upgrade
|
160
|
+
# their Ruby version
|
161
|
+
suggest_ruby_reinstall(e)
|
162
|
+
display_user_error!(e, e.to_s)
|
163
|
+
end
|
164
|
+
|
165
|
+
def handle_ssl_error!(e)
|
166
|
+
# SSL errors are very common when the Ruby or OpenSSL installation is somehow broken
|
167
|
+
# We want to show a nice error message to the user here
|
168
|
+
# We have over 20 GitHub issues just for this one error:
|
169
|
+
# https://github.com/pantograph/pantograph/search?q=errno%3D0+state%3DSSLv3+read+server&type=Issues
|
170
|
+
suggest_ruby_reinstall(e)
|
171
|
+
display_user_error!(e, e.to_s)
|
172
|
+
end
|
173
|
+
|
174
|
+
def suggest_ruby_reinstall(e)
|
175
|
+
ui = PantographCore::UI
|
176
|
+
ui.error("-----------------------------------------------------------------------")
|
177
|
+
ui.error(e.to_s)
|
178
|
+
ui.error("")
|
179
|
+
ui.error("SSL errors can be caused by various components on your local machine.")
|
180
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
|
181
|
+
ui.error("Apple has recently changed their servers to require TLS 1.2, which may")
|
182
|
+
ui.error("not be available to your system installed Ruby (#{RUBY_VERSION})")
|
183
|
+
end
|
184
|
+
ui.error("")
|
185
|
+
ui.error("The best solution is to use the self-contained pantograph version.")
|
186
|
+
ui.error("Which ships with a bundled OpenSSL,ruby and all gems - so you don't depend on system libraries")
|
187
|
+
ui.error(" - Use Homebrew")
|
188
|
+
ui.error(" - update brew with `brew update`")
|
189
|
+
ui.error(" - install pantograph using:")
|
190
|
+
ui.error(" - `brew cask install pantograph`")
|
191
|
+
ui.error(" - Use One-Click-Installer:")
|
192
|
+
ui.error(" - download pantograph at https://download.pantograph.tools")
|
193
|
+
ui.error(" - extract the archive and double click the `install`")
|
194
|
+
ui.error("-----------------------------------------------------------")
|
195
|
+
ui.error("for more details on ways to install pantograph please refer the documentation:")
|
196
|
+
ui.error("-----------------------------------------------------------")
|
197
|
+
ui.error(" 🚀 https://docs.pantograph.tools 🚀 ")
|
198
|
+
ui.error("-----------------------------------------------------------")
|
199
|
+
ui.error("")
|
200
|
+
ui.error("You can also install a new version of Ruby")
|
201
|
+
ui.error("")
|
202
|
+
ui.error("- Make sure OpenSSL is installed with Homebrew: `brew update && brew upgrade openssl`")
|
203
|
+
ui.error("- If you use system Ruby:")
|
204
|
+
ui.error(" - Run `brew update && brew install ruby`")
|
205
|
+
ui.error("- If you use rbenv with ruby-build:")
|
206
|
+
ui.error(" - Run `brew update && brew upgrade ruby-build && rbenv install 2.3.1`")
|
207
|
+
ui.error(" - Run `rbenv global 2.3.1` to make it the new global default Ruby version")
|
208
|
+
ui.error("- If you use rvm:")
|
209
|
+
ui.error(" - First run `rvm osx-ssl-certs update all`")
|
210
|
+
ui.error(" - Then run `rvm reinstall ruby-2.3.1 --with-openssl-dir=/usr/local`")
|
211
|
+
ui.error("")
|
212
|
+
ui.error("If that doesn't fix your issue, please google for the following error message:")
|
213
|
+
ui.error(" '#{e}'")
|
214
|
+
ui.error("-----------------------------------------------------------------------")
|
215
|
+
end
|
216
|
+
|
217
|
+
def handle_unknown_error!(e)
|
218
|
+
# Some spaceship exception classes implement #preferred_error_info in order to share error info
|
219
|
+
# that we'd rather display instead of crashing with a stack trace. However, pantograph_core and
|
220
|
+
# spaceship can not know about each other's classes! To make this information passing work, we
|
221
|
+
# use a bit of Ruby duck-typing to check whether the unknown exception type implements the right
|
222
|
+
# method. If so, we'll present any returned error info in the manner of a user_error!
|
223
|
+
error_info = e.respond_to?(:preferred_error_info) ? e.preferred_error_info : nil
|
224
|
+
should_show_github_issues = e.respond_to?(:show_github_issues) ? e.show_github_issues : true
|
225
|
+
|
226
|
+
if error_info
|
227
|
+
error_info = error_info.join("\n\t") if error_info.kind_of?(Array)
|
228
|
+
|
229
|
+
show_github_issues(error_info) if should_show_github_issues
|
230
|
+
|
231
|
+
display_user_error!(e, error_info)
|
232
|
+
else
|
233
|
+
# Pass the error instead of a message so that the inspector can do extra work to simplify the query
|
234
|
+
show_github_issues(e) if should_show_github_issues
|
235
|
+
|
236
|
+
# From https://stackoverflow.com/a/4789702/445598
|
237
|
+
# We do this to make the actual error message red and therefore more visible
|
238
|
+
reraise_formatted!(e, e.message)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def display_user_error!(e, message)
|
243
|
+
if PantographCore::Globals.verbose?
|
244
|
+
# with stack trace
|
245
|
+
reraise_formatted!(e, message)
|
246
|
+
else
|
247
|
+
# without stack trace
|
248
|
+
action_completed(@program[:name], status: PantographCore::ActionCompletionStatus::USER_ERROR, exception: e)
|
249
|
+
abort("\n[!] #{message}".red)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def reraise_formatted!(e, message)
|
254
|
+
backtrace = PantographCore::Env.truthy?("PANTOGRAPH_HIDE_BACKTRACE") ? [] : e.backtrace
|
255
|
+
raise e, "[!] #{message}".red, backtrace
|
256
|
+
end
|
257
|
+
|
258
|
+
def show_github_issues(message_or_error)
|
259
|
+
return if PantographCore::Env.truthy?("PANTOGRAPH_HIDE_GITHUB_ISSUES")
|
260
|
+
return if PantographCore::Helper.test?
|
261
|
+
|
262
|
+
require 'gh_inspector'
|
263
|
+
require 'pantograph_core/ui/github_issue_inspector_reporter'
|
264
|
+
|
265
|
+
inspector = GhInspector::Inspector.new("pantograph", "pantograph", verbose: PantographCore::Globals.verbose?)
|
266
|
+
delegate = Pantograph::InspectorReporter.new
|
267
|
+
if message_or_error.kind_of?(String)
|
268
|
+
inspector.search_query(message_or_error, delegate)
|
269
|
+
else
|
270
|
+
inspector.search_exception(message_or_error, delegate)
|
271
|
+
end
|
272
|
+
rescue => ex
|
273
|
+
PantographCore::UI.error("Error finding relevant GitHub issues: #{ex}") if PantographCore::Globals.verbose?
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module PantographCore
|
2
|
+
class UI
|
3
|
+
class << self
|
4
|
+
attr_accessor(:ui_object)
|
5
|
+
|
6
|
+
def ui_object
|
7
|
+
require_relative 'implementations/shell'
|
8
|
+
@ui_object ||= Shell.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(method_sym, *args, &_block)
|
12
|
+
# not using `responds` because we don't care about methods like .to_s and so on
|
13
|
+
require_relative 'interface'
|
14
|
+
interface_methods = PantographCore::Interface.instance_methods - Object.instance_methods
|
15
|
+
UI.user_error!("Unknown method '#{method_sym}', supported #{interface_methods}") unless interface_methods.include?(method_sym)
|
16
|
+
|
17
|
+
self.ui_object.send(method_sym, *args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Import all available implementations
|
24
|
+
Dir[File.dirname(__FILE__) + '/implementations/*.rb'].each do |file|
|
25
|
+
require_relative file
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'excon'
|
2
|
+
|
3
|
+
module PantographCore
|
4
|
+
class Changelog
|
5
|
+
class << self
|
6
|
+
def show_changes(gem_name, current_version, update_gem_command: "bundle update")
|
7
|
+
did_show_changelog = false
|
8
|
+
|
9
|
+
self.releases(gem_name).each_with_index do |release, index|
|
10
|
+
next unless Gem::Version.new(release['tag_name']) > Gem::Version.new(current_version)
|
11
|
+
puts("")
|
12
|
+
puts(release['name'].green)
|
13
|
+
puts(release['body'])
|
14
|
+
did_show_changelog = true
|
15
|
+
|
16
|
+
next unless index == 2
|
17
|
+
puts("")
|
18
|
+
puts("To see all new releases, open https://github.com/johnknapprs/#{gem_name}/releases".green)
|
19
|
+
break
|
20
|
+
end
|
21
|
+
|
22
|
+
puts("")
|
23
|
+
puts("Please update using `#{update_gem_command}`".green) if did_show_changelog
|
24
|
+
rescue
|
25
|
+
# Something went wrong, we don't care so much about this
|
26
|
+
end
|
27
|
+
|
28
|
+
def releases(gem_name)
|
29
|
+
url = "https://api.github.com/repos/johnknapprs/#{gem_name}/releases"
|
30
|
+
# We have to follow redirects, since some repos were moved away into a separate org
|
31
|
+
server_response = Excon.get(url,
|
32
|
+
middlewares: Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower])
|
33
|
+
JSON.parse(server_response.body)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'excon'
|
2
|
+
require 'digest'
|
3
|
+
|
4
|
+
require_relative 'changelog'
|
5
|
+
# require_relative '../analytics/app_identifier_guesser'
|
6
|
+
require_relative '../helper'
|
7
|
+
require_relative '../ui/ui'
|
8
|
+
|
9
|
+
module PantographCore
|
10
|
+
# Verifies, the user runs the latest version of this gem
|
11
|
+
class UpdateChecker
|
12
|
+
def self.start_looking_for_update(gem_name)
|
13
|
+
return if Helper.test?
|
14
|
+
return if PantographCore::Env.truthy?("PANTOGRAPH_SKIP_UPDATE_CHECK")
|
15
|
+
|
16
|
+
@start_time = Time.now
|
17
|
+
|
18
|
+
Thread.new do
|
19
|
+
begin
|
20
|
+
server_results[gem_name] = fetch_latest(gem_name)
|
21
|
+
rescue
|
22
|
+
# we don't want to show a stack trace if something goes wrong
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.server_results
|
28
|
+
@results ||= {}
|
29
|
+
end
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_reader :start_time
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.update_available?(gem_name, current_version)
|
36
|
+
latest = server_results[gem_name]
|
37
|
+
return (latest and Gem::Version.new(latest) > Gem::Version.new(current_version))
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.show_update_status(gem_name, current_version)
|
41
|
+
if update_available?(gem_name, current_version)
|
42
|
+
show_update_message(gem_name, current_version)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Show a message to the user to update to a new version of pantograph (or a sub-gem)
|
47
|
+
# Use this method, as this will detect the current Ruby environment and show an
|
48
|
+
# appropriate message to the user
|
49
|
+
def self.show_update_message(gem_name, current_version)
|
50
|
+
available = server_results[gem_name]
|
51
|
+
puts("")
|
52
|
+
puts('#######################################################################')
|
53
|
+
if available
|
54
|
+
puts("# #{gem_name} #{available} is available. You are on #{current_version}.")
|
55
|
+
else
|
56
|
+
puts("# An update for #{gem_name} is available. You are on #{current_version}.")
|
57
|
+
end
|
58
|
+
puts("# You should use the latest version.")
|
59
|
+
puts("# Please update using `#{self.update_command(gem_name: gem_name)}`.")
|
60
|
+
|
61
|
+
puts("# To see what's new, open https://github.com/johnknapprs/#{gem_name}/releases.") if PantographCore::Env.truthy?("PANTOGRAPH_HIDE_CHANGELOG")
|
62
|
+
|
63
|
+
if !Helper.bundler? && !Helper.contained_pantograph? && Random.rand(5) == 1
|
64
|
+
# We want to show this message from time to time, if the user doesn't use bundler, nor bundled pantograph
|
65
|
+
puts('#######################################################################')
|
66
|
+
puts("# Run `gem cleanup` from time to time to speed up pantograph")
|
67
|
+
end
|
68
|
+
puts('#######################################################################')
|
69
|
+
Changelog.show_changes(gem_name, current_version, update_gem_command: UpdateChecker.update_command(gem_name: gem_name)) unless PantographCore::Env.truthy?("PANTOGRAPH_HIDE_CHANGELOG")
|
70
|
+
|
71
|
+
ensure_rubygems_source
|
72
|
+
end
|
73
|
+
|
74
|
+
# The command that the user should use to update their mac
|
75
|
+
def self.update_command(gem_name: "pantograph")
|
76
|
+
if Helper.bundler?
|
77
|
+
"bundle update #{gem_name.downcase}"
|
78
|
+
elsif Helper.contained_pantograph? || Helper.homebrew?
|
79
|
+
"pantograph update_pantograph"
|
80
|
+
else
|
81
|
+
"gem install #{gem_name.downcase}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Check if RubyGems is set as a gem source
|
86
|
+
# on some machines that might not be the case
|
87
|
+
# and then users can't find the update when
|
88
|
+
# running the specified command
|
89
|
+
def self.ensure_rubygems_source
|
90
|
+
return if Helper.contained_pantograph?
|
91
|
+
return if `gem sources`.include?("https://rubygems.org")
|
92
|
+
puts("")
|
93
|
+
UI.error("RubyGems is not listed as your Gem source")
|
94
|
+
UI.error("You can run `gem sources` to see all your sources")
|
95
|
+
UI.error("Please run the following command to fix this:")
|
96
|
+
UI.command("gem sources --add https://rubygems.org")
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.fetch_latest(gem_name)
|
100
|
+
JSON.parse(Excon.get(generate_fetch_url(gem_name)).body)["version"]
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.generate_fetch_url(gem_name)
|
104
|
+
"https://rubygems.org/api/v1/gems/#{gem_name}.json"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative 'pantograph_core/globals'
|
2
|
+
# Ruby monkey-patches - should be before almost all else
|
3
|
+
require_relative 'pantograph_core/core_ext/string'
|
4
|
+
require_relative 'pantograph_core/core_ext/shellwords'
|
5
|
+
|
6
|
+
require_relative 'pantograph_core/env'
|
7
|
+
require_relative 'pantograph_core/feature/feature'
|
8
|
+
require_relative 'pantograph_core/features'
|
9
|
+
require_relative 'pantograph_core/helper'
|
10
|
+
require_relative 'pantograph_core/configuration/configuration'
|
11
|
+
require_relative 'pantograph_core/update_checker/update_checker'
|
12
|
+
require_relative 'pantograph_core/languages'
|
13
|
+
# require_relative 'pantograph_core/cert_checker'
|
14
|
+
# require_relative 'pantograph_core/ipa_file_analyser'
|
15
|
+
# require_relative 'pantograph_core/itunes_transporter'
|
16
|
+
# require_relative 'pantograph_core/provisioning_profile'
|
17
|
+
# require_relative 'pantograph_core/pkg_file_analyser'
|
18
|
+
# require_relative 'pantograph_core/pkg_upload_package_builder'
|
19
|
+
require_relative 'pantograph_core/command_executor'
|
20
|
+
# require_relative 'pantograph_core/ipa_upload_package_builder'
|
21
|
+
require_relative 'pantograph_core/print_table'
|
22
|
+
# require_relative 'pantograph_core/project'
|
23
|
+
# require_relative 'pantograph_core/device_manager'
|
24
|
+
require_relative 'pantograph_core/ui/ui'
|
25
|
+
require_relative 'pantograph_core/pantograph_folder'
|
26
|
+
require_relative 'pantograph_core/keychain_importer'
|
27
|
+
require_relative 'pantograph_core/swag'
|
28
|
+
require_relative 'pantograph_core/ui/errors'
|
29
|
+
require_relative 'pantograph_core/test_parser'
|
30
|
+
require_relative 'pantograph_core/analytics/action_completion_context'
|
31
|
+
require_relative 'pantograph_core/analytics/action_launch_context'
|
32
|
+
require_relative 'pantograph_core/analytics/analytics_event_builder'
|
33
|
+
require_relative 'pantograph_core/analytics/analytics_ingester_client'
|
34
|
+
require_relative 'pantograph_core/analytics/analytics_session'
|
35
|
+
require_relative 'pantograph_core/tag_version'
|
36
|
+
require_relative 'pantograph_core/pantograph_pty'
|
37
|
+
|
38
|
+
# Third Party code
|
39
|
+
require 'colored'
|
40
|
+
require 'commander'
|
41
|
+
|
42
|
+
# after commander import
|
43
|
+
require_relative 'pantograph_core/ui/pantograph_runner' # monkey patch
|
44
|
+
|
45
|
+
require_relative 'pantograph_core/module'
|