Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ en:
login:
description: 'Log in to DeployGate'
terminal: 'Login in terminal'
error: 'Commands::Login Error: %{e}'
deploy:
description: 'Build and upload a new build'
message: 'Build description message'
Expand All @@ -16,14 +15,12 @@ en:
scheme: 'Set Xcode build scheme (iOS app only)'
open: 'Open a browser after the build uploaded (OS X only)'
disable_notify: 'Disable email notification (iOS app only)'
error: 'Commands::Deploy Error: %{e}'
add_devices:
description: 'Register devices to your Apple Developer account and refresh your provisioning profile. (iOS only) By default, it automatically finds new devices added to your application on DeployGate and ask you which device to register. You can also specify which device to register via command line options.'
user: 'Owner user or organization name'
udid: 'UDID to be registered'
device_name: 'Device name to be registered'
distribution_key: 'If you also want to update distribution page, set the last part of the URL of the page'
error: 'Commands::AddDevices Error: %{e}'
server:
description: 'Start the add-devices server. When added new device automatically run add-devices command.'
connecting: 'Connecting...'
Expand All @@ -32,17 +29,15 @@ en:
finish_build: 'add-devices completed successfully.'
logout:
description: 'Log out current session'
error: 'Commands::Logout Error: %{e}'
config:
description: "Configure login session of `dg` command. Usually, the session automatically created on the installation process so you don't need to use this command."
json: 'Set output format to JSON'
name: 'DeployGate user name'
token: 'DeployGate API token'
error: 'Commands::Config Error: %{e}'
error_handling:
message: 'Error: %{message}'
agree: 'Do you want to report this issue on GitHub? (y/n) '
please_open: 'Please open GitHub issue: %{url}'
agree: 'Do you want to this error report to DeployGate? (y/n) '
thanks: 'Thank you feedback! We will improve based on it.'
show_update_message: |
#################################################################
# %{gem_name} %{latest_version} is available. You are on %{current_version}.
Expand Down
2 changes: 1 addition & 1 deletion deploygate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ POST_INSTALL_MESSAGE
spec.add_runtime_dependency 'commander', '~> 4.4'
spec.add_runtime_dependency 'plist', '~> 3.1'
spec.add_runtime_dependency 'xcodeproj', '~> 1.7'
spec.add_runtime_dependency 'github_issue_request', '~> 0.1'
spec.add_runtime_dependency 'highline', '~> 1.7'
spec.add_runtime_dependency 'uuid', '~> 2.3'
spec.add_runtime_dependency 'gem_update_checker', '~> 0.2'
Expand All @@ -36,6 +35,7 @@ POST_INSTALL_MESSAGE
spec.add_runtime_dependency 'net-ping', '~> 2.0'
spec.add_runtime_dependency 'socket.io-client-simple', '~> 1.2'
spec.add_runtime_dependency 'workers', '~> 0.6'
spec.add_runtime_dependency 'sentry-raven', '~> 2.8'

# ios build
spec.add_runtime_dependency 'fastlane', '~> 2.57.2'
Expand Down
6 changes: 4 additions & 2 deletions lib/deploygate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
require "openssl"
require "plist"
require "find"
require "github_issue_request"
require "highline"
require "uuid"
require "gem_update_checker"
require "active_support/core_ext/time"
require "active_support/core_ext/hash"
require "locale"
require "tempfile"
require "open3"
Expand All @@ -21,6 +21,7 @@
require "net/ping"
require "socket.io-client-simple"
require "workers"
require "sentry-raven"

require "i18n"
I18n.load_path = Dir[File.join(File.dirname(__FILE__), '../config/locales/*.yml')]
Expand All @@ -34,7 +35,7 @@
module DeployGate
end

require "deploygate/not_issue_error"
require "deploygate/raven_ignore_exception"
require "deploygate/api/v1/base"
require "deploygate/api/v1/session"
require "deploygate/api/v1/push"
Expand All @@ -55,6 +56,7 @@ module DeployGate
require "deploygate/session"
require "deploygate/deploy"
require "deploygate/project"
require "deploygate/raven_ignore_exception"
require "deploygate/user"
require "deploygate/browser_login"
require "deploygate/add_devices_server"
Expand Down
111 changes: 54 additions & 57 deletions lib/deploygate/command_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CommandBuilder
include Commander::Methods
attr_reader :arguments

class NotInternetConnectionError < DeployGate::NotIssueError
class NotInternetConnectionError < DeployGate::RavenIgnoreException
end

PING_URL = 'https://deploygate.com'
Expand All @@ -15,6 +15,13 @@ class NotInternetConnectionError < DeployGate::NotIssueError
CONFIG = 'config'

def setup
# sentry config
Raven.configure do |config|
config.dsn = 'https://e0b4dda8fe2049a7b0d98c6d2759e067@sentry.io/1371610'
config.logger = Raven::Logger.new('/dev/null') # hide sentry log
config.excluded_exceptions = Raven::Configuration::IGNORE_DEFAULT + [DeployGate::RavenIgnoreException.name]
end

# set Ctrl-C trap
Signal.trap(:INT){
puts ''
Expand All @@ -27,8 +34,6 @@ def setup
exit
end

# check update
GithubIssueRequest::Url.config('deploygate', 'deploygate-cli')
check_update()
end

Expand All @@ -49,7 +54,7 @@ def run
Commands::Login.run(args, options)
rescue => e
error_handling(LOGIN, e)
raise e
exit 1
end
end
end
Expand All @@ -70,7 +75,7 @@ def run
Commands::Deploy.run(args, options)
rescue => e
error_handling(DEPLOY, e)
raise e
exit 1
end
end
end
Expand All @@ -91,7 +96,7 @@ def run
Commands::AddDevices.run(args, options)
rescue => e
error_handling(ADD_DEVICES, e)
raise e
exit 1
end
end
end
Expand All @@ -104,7 +109,7 @@ def run
Commands::Logout.run
rescue => e
error_handling(LOGOUT, e)
raise e
exit 1
end
end
end
Expand All @@ -120,70 +125,62 @@ def run
Commands::Config.run(args, options)
rescue => e
error_handling(CONFIG, e)
raise e
exit 1
end
end
end

run!
end

# @param [String] command
# @param [Exception] error
# @return [String]
def create_error_issue_body(error)
return <<EOF

# Status
deploygate-cli ver #{DeployGate::VERSION}
def error_handling(command, error)
STDERR.puts HighLine.color(I18n.t('command_builder.error_handling.message', message: error.message), HighLine::RED)
return if ENV['CI'] # When run ci server
return if error.kind_of?(DeployGate::RavenIgnoreException)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

READMEで「Sentryで送るよ」と書き、また環境変数で送信できないようにするとかの仕組みを入れた方が誠実な気がします 🤔  DISABLE_DEPLOYGATE_CLI_SENTRY とかですかね

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmatsu
ありがとうございます!
やはり自動でSentryにローカルの情報を送るのは誠実ではないですね

だとすると

  1. 提案してくれた方法
  2. Sentryにエラーを送るときに送ってもいいか聞く

のどちらかかなと考えているのですが、2の方はやり過ぎですかね?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GDPRとかそっちの考え方的には「収集はopt-in/outできること」なので、2なら安心安全ですね 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

では強めに2の方で行きます!ありがとうございます!


# Error message
#{error.message}
dg_version = DeployGate::VERSION
tags = {
command: command,
dg_version: dg_version
}
version = Gym::Xcode.xcode_version
tags[:xcode_version] = version if version.present?

# Backtrace
```
#{error.backtrace.join("\n")}
```
EOF
puts ''
puts error_report(error, version, dg_version)
if HighLine.agree(I18n.t('command_builder.error_handling.agree')) {|q| q.default = "y"}
tags = {
command: command,
dg_version: DeployGate::VERSION
}
version = Gym::Xcode.xcode_version
tags[:xcode_version] = version if version.present?

Raven.capture_exception(error, tags: tags)
puts HighLine.color(I18n.t('command_builder.error_handling.thanks'), HighLine::GREEN)
end
end

# @param [Symbol] command
# @param [Exception] error
# @return [String]
def create_issue_url(command, error)
title = case command
when LOGIN
I18n.t('command_builder.login.error', e: error.class)
when LOGOUT
I18n.t('command_builder.logout.error', e: error.class)
when DEPLOY
I18n.t('command_builder.deploy.error', e: error.class)
when ADD_DEVICES
I18n.t('command_builder.add_devices.error', e: error.class)
when CONFIG
I18n.t('command_builder.config.error', e: error.class)
end

options = {
:title => title,
:body => create_error_issue_body(error),
}
GithubIssueRequest::Url.new(options).to_s
end
def error_report(error, dg_version, xcode_version)
meta_info = "dg version: #{dg_version}"
meta_info += "\nXcode version: #{xcode_version}" if xcode_version.present?

# @param [Symbol] command
# @param [Exception] error
def error_handling(command, error)
STDERR.puts HighLine.color(I18n.t('command_builder.error_handling.message', message: error.message), HighLine::RED)
backtrace = error.backtrace.take(5).join("\n")
backtrace += "\nand more ..." if error.backtrace.count > 5

return if ENV['CI'] # When run ci server
return if error.kind_of?(DeployGate::NotIssueError)
puts ''
if HighLine.agree(I18n.t('command_builder.error_handling.agree')) {|q| q.default = "n"}
url = create_issue_url(command, error)
puts I18n.t('command_builder.error_handling.please_open', url: url)
system('open', url) if Commands::Deploy::Push.openable?
end
puts ''
<<EOF
------------------------
DeployGate Error Report

Title: #{error}
#{meta_info}

Stack trace:
#{backtrace}
------------------------
EOF
end

# @return [void]
Expand Down
6 changes: 3 additions & 3 deletions lib/deploygate/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module DeployGate
class Deploy
class NotLoginError < DeployGate::NotIssueError
class NotLoginError < DeployGate::RavenIgnoreException
end
class NotFileExistError < DeployGate::NotIssueError
class NotFileExistError < DeployGate::RavenIgnoreException
end
class UploadError < DeployGate::NotIssueError
class UploadError < DeployGate::RavenIgnoreException
end

class << self
Expand Down
4 changes: 0 additions & 4 deletions lib/deploygate/not_issue_error.rb

This file was deleted.

4 changes: 4 additions & 0 deletions lib/deploygate/raven_ignore_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module DeployGate
class RavenIgnoreException < StandardError
end
end
2 changes: 1 addition & 1 deletion lib/deploygate/session.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module DeployGate
class Session
class LoginError < DeployGate::NotIssueError
class LoginError < DeployGate::RavenIgnoreException
end

attr_reader :name, :token
Expand Down
2 changes: 1 addition & 1 deletion lib/deploygate/xcode/analyze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Analyze
PROVISIONING_STYLE_AUTOMATIC = 'Automatic'
PROVISIONING_STYLE_MANUAL = 'Manual'

class BundleIdentifierDifferentError < DeployGate::NotIssueError
class BundleIdentifierDifferentError < DeployGate::RavenIgnoreException
end

# @param [Array] workspaces
Expand Down
2 changes: 1 addition & 1 deletion lib/deploygate/xcode/ios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Ios
PROJECT_DIR_EXTNAME = '.xcodeproj'
IGNORE_DIRS = [ '.git', 'Carthage' ]

class NotSupportExportMethodError < DeployGate::NotIssueError
class NotSupportExportMethodError < DeployGate::RavenIgnoreException
end

class << self
Expand Down
4 changes: 2 additions & 2 deletions lib/deploygate/xcode/member_centers/provisioning_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module MemberCenters
class ProvisioningProfile
attr_reader :member_center, :app_identifier

class NotInstalledCertificateError < DeployGate::NotIssueError
class NotInstalledCertificateError < DeployGate::RavenIgnoreException
end
class NotExistUUIDProvisioningProfileError < DeployGate::NotIssueError
class NotExistUUIDProvisioningProfileError < DeployGate::RavenIgnoreException
end

OUTPUT_PATH = '/tmp/dg/provisioning_profile/'
Expand Down