u3d 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.licenses.json +19 -0
- data/.rspec +1 -0
- data/.rubocop.yml +43 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +98 -0
- data/LICENSE +21 -0
- data/LICENSE.fastlane +22 -0
- data/LOG_RULES.md +170 -0
- data/README.md +72 -0
- data/Rakefile +28 -0
- data/TODO.md +15 -0
- data/build.sh +5 -0
- data/config/log_rules.json +230 -0
- data/examples/Example1/.gitignore +19 -0
- data/examples/Example1/Assets/Editor.meta +9 -0
- data/examples/Example1/Assets/Editor/EditorRun.cs +23 -0
- data/examples/Example1/Assets/Editor/EditorRun.cs.meta +12 -0
- data/examples/Example1/Assets/Editor/FileSystemUtil.cs +26 -0
- data/examples/Example1/Assets/Editor/FileSystemUtil.cs.meta +12 -0
- data/examples/Example1/Assets/Scene1.unity +264 -0
- data/examples/Example1/Assets/Scene1.unity.meta +8 -0
- data/examples/Example1/Gemfile +8 -0
- data/examples/Example1/Gemfile.lock +165 -0
- data/examples/Example1/ProjectSettings/AudioManager.asset +16 -0
- data/examples/Example1/ProjectSettings/ClusterInputManager.asset +6 -0
- data/examples/Example1/ProjectSettings/DynamicsManager.asset +18 -0
- data/examples/Example1/ProjectSettings/EditorBuildSettings.asset +7 -0
- data/examples/Example1/ProjectSettings/EditorSettings.asset +14 -0
- data/examples/Example1/ProjectSettings/GraphicsSettings.asset +61 -0
- data/examples/Example1/ProjectSettings/InputManager.asset +295 -0
- data/examples/Example1/ProjectSettings/NavMeshAreas.asset +89 -0
- data/examples/Example1/ProjectSettings/NetworkManager.asset +8 -0
- data/examples/Example1/ProjectSettings/Physics2DSettings.asset +35 -0
- data/examples/Example1/ProjectSettings/ProjectSettings.asset +591 -0
- data/examples/Example1/ProjectSettings/ProjectVersion.txt +1 -0
- data/examples/Example1/ProjectSettings/QualitySettings.asset +180 -0
- data/examples/Example1/ProjectSettings/TagManager.asset +43 -0
- data/examples/Example1/ProjectSettings/TimeManager.asset +9 -0
- data/examples/Example1/ProjectSettings/UnityConnectSettings.asset +32 -0
- data/examples/Example1/README.md +5 -0
- data/examples/Example1/Rakefile +5 -0
- data/examples/Example1/fastlane/Fastfile +4 -0
- data/examples/Example1/fastlane/Pluginfile +1 -0
- data/examples/Example1/run.sh +1 -0
- data/examples/Example2/.gitignore +20 -0
- data/examples/Example2/Assets/Editor.meta +9 -0
- data/examples/Example2/Assets/Editor/EditorRun.cs +33 -0
- data/examples/Example2/Assets/Editor/EditorRun.cs.meta +12 -0
- data/examples/Example2/Assets/Editor/PostprocessBuildPlayer.cs +92 -0
- data/examples/Example2/Assets/Editor/PostprocessBuildPlayer.cs.meta +8 -0
- data/examples/Example2/Assets/Editor/PostprocessBuildPlayer_log.sh +31 -0
- data/examples/Example2/Assets/Editor/PostprocessBuildPlayer_log.sh.meta +8 -0
- data/examples/Example2/Assets/Editor/SimpleBuildSetup.cs +20 -0
- data/examples/Example2/Assets/Editor/SimpleBuildSetup.cs.meta +12 -0
- data/examples/Example2/Assets/Scene.unity +278 -0
- data/examples/Example2/Assets/Scene.unity.meta +8 -0
- data/examples/Example2/Gemfile +8 -0
- data/examples/Example2/Gemfile.lock +165 -0
- data/examples/Example2/ProjectSettings/AudioManager.asset +17 -0
- data/examples/Example2/ProjectSettings/ClusterInputManager.asset +6 -0
- data/examples/Example2/ProjectSettings/DynamicsManager.asset +19 -0
- data/examples/Example2/ProjectSettings/EditorBuildSettings.asset +10 -0
- data/examples/Example2/ProjectSettings/EditorSettings.asset +14 -0
- data/examples/Example2/ProjectSettings/GraphicsSettings.asset +63 -0
- data/examples/Example2/ProjectSettings/InputManager.asset +295 -0
- data/examples/Example2/ProjectSettings/NavMeshAreas.asset +89 -0
- data/examples/Example2/ProjectSettings/NetworkManager.asset +8 -0
- data/examples/Example2/ProjectSettings/Physics2DSettings.asset +36 -0
- data/examples/Example2/ProjectSettings/ProjectSettings.asset +591 -0
- data/examples/Example2/ProjectSettings/ProjectVersion.txt +1 -0
- data/examples/Example2/ProjectSettings/QualitySettings.asset +193 -0
- data/examples/Example2/ProjectSettings/TagManager.asset +43 -0
- data/examples/Example2/ProjectSettings/TimeManager.asset +9 -0
- data/examples/Example2/ProjectSettings/UnityConnectSettings.asset +34 -0
- data/examples/Example2/README.md +10 -0
- data/examples/Example2/fastlane/Fastfile +4 -0
- data/examples/Example2/fastlane/Pluginfile +1 -0
- data/exe/u3d +7 -0
- data/fastlane-plugin-u3d/.gitignore +10 -0
- data/fastlane-plugin-u3d/.licenses.json +9 -0
- data/fastlane-plugin-u3d/.rspec +3 -0
- data/fastlane-plugin-u3d/.rubocop.yml +253 -0
- data/fastlane-plugin-u3d/.travis.yml +4 -0
- data/fastlane-plugin-u3d/Gemfile +6 -0
- data/fastlane-plugin-u3d/LICENSE +21 -0
- data/fastlane-plugin-u3d/README.md +52 -0
- data/fastlane-plugin-u3d/Rakefile +9 -0
- data/fastlane-plugin-u3d/circle.yml +9 -0
- data/fastlane-plugin-u3d/fastlane-plugin-u3d.gemspec +31 -0
- data/fastlane-plugin-u3d/fastlane/Fastfile +3 -0
- data/fastlane-plugin-u3d/fastlane/Pluginfile +1 -0
- data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d.rb +38 -0
- data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d/actions/u3d_action.rb +80 -0
- data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d/helper/u3d_helper.rb +34 -0
- data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d/version.rb +27 -0
- data/fastlane-plugin-u3d/spec/spec_helper.rb +32 -0
- data/lib/u3d.rb +33 -0
- data/lib/u3d/cache.rb +120 -0
- data/lib/u3d/commands.rb +307 -0
- data/lib/u3d/commands_generator.rb +163 -0
- data/lib/u3d/downloader.rb +363 -0
- data/lib/u3d/iniparser.rb +83 -0
- data/lib/u3d/installer.rb +445 -0
- data/lib/u3d/log_analyzer.rb +221 -0
- data/lib/u3d/unity_version_number.rb +71 -0
- data/lib/u3d/unity_versions.rb +207 -0
- data/lib/u3d/utils.rb +121 -0
- data/lib/u3d/version.rb +31 -0
- data/lib/u3d_core.rb +30 -0
- data/lib/u3d_core/command_executor.rb +134 -0
- data/lib/u3d_core/command_runner.rb +93 -0
- data/lib/u3d_core/credentials.rb +116 -0
- data/lib/u3d_core/globals.rb +84 -0
- data/lib/u3d_core/helper.rb +149 -0
- data/lib/u3d_core/ui/disable_colors.rb +40 -0
- data/lib/u3d_core/ui/implementations/shell.rb +157 -0
- data/lib/u3d_core/ui/interface.rb +182 -0
- data/lib/u3d_core/ui/ui.rb +49 -0
- data/local_gem_install.sh +6 -0
- data/scripts/be +14 -0
- data/u3d.gemspec +41 -0
- metadata +388 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2016-present WeWantToKnow AS
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
## --- END LICENSE BLOCK ---
|
23
|
+
|
24
|
+
module U3dCore
|
25
|
+
# all these attributes are false by default
|
26
|
+
# and can be set overriden temporarily using a
|
27
|
+
# with_attr(value) do
|
28
|
+
# something
|
29
|
+
# end
|
30
|
+
# construct
|
31
|
+
class Globals
|
32
|
+
class << self
|
33
|
+
attr_writer :verbose, :log_timestamps, :use_keychain, :do_not_login
|
34
|
+
|
35
|
+
def attributes
|
36
|
+
@attributes ||= ((methods - public_instance_methods).grep(/=$/) - [:<=, :>=]).map do |s|
|
37
|
+
a = s.to_s
|
38
|
+
a[0..(a.length - 2)] # remove the '='
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def with(attr, value)
|
43
|
+
orig_attr = send("#{attr}?")
|
44
|
+
send("#{attr}=", value)
|
45
|
+
yield if block_given?
|
46
|
+
ensure
|
47
|
+
send("#{attr}=", orig_attr)
|
48
|
+
end
|
49
|
+
|
50
|
+
def is?(attr)
|
51
|
+
instance_variable_get("@#{attr}")
|
52
|
+
end
|
53
|
+
|
54
|
+
def method_missing(method_sym, *arguments, &block)
|
55
|
+
if method_sym.to_s =~ /^with_(.*)$/
|
56
|
+
if attributes.include? Regexp.last_match(1)
|
57
|
+
with(Regexp.last_match(1).to_sym, arguments.first, &block)
|
58
|
+
else
|
59
|
+
super
|
60
|
+
end
|
61
|
+
elsif method_sym.to_s =~ /^(.*)\?$/
|
62
|
+
if attributes.include? Regexp.last_match(1)
|
63
|
+
is?(Regexp.last_match(1).to_sym)
|
64
|
+
else
|
65
|
+
super
|
66
|
+
end
|
67
|
+
else
|
68
|
+
super
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def respond_to?(method_sym, include_private = false)
|
73
|
+
if method_sym.to_s =~ /^with_(.*)$/
|
74
|
+
return attributes.include? Regexp.last_match(1)
|
75
|
+
elsif method_sym.to_s =~ /^(.*)\?$/
|
76
|
+
return attributes.include? Regexp.last_match(1)
|
77
|
+
else
|
78
|
+
super
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
private_class_method :is?, :with, :attributes
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2016-present WeWantToKnow AS
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
## --- END LICENSE BLOCK ---
|
23
|
+
|
24
|
+
require 'logger'
|
25
|
+
require 'colored'
|
26
|
+
|
27
|
+
module U3dCore
|
28
|
+
module Helper
|
29
|
+
# Runs a given command using backticks (`)
|
30
|
+
# and prints them out using the UI.command method
|
31
|
+
def self.backticks(command, print: true)
|
32
|
+
UI.command(command) if print
|
33
|
+
result = `#{command}`
|
34
|
+
UI.command_output(result) if print
|
35
|
+
return result
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return true if the currently running program is a unit test
|
39
|
+
def self.is_test?
|
40
|
+
defined? SpecHelper
|
41
|
+
end
|
42
|
+
|
43
|
+
# removes ANSI colors from string
|
44
|
+
def self.strip_ansi_colors(str)
|
45
|
+
str.gsub(/\e\[([;\d]+)?m/, '')
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [boolean] true if executing with bundler (like 'bundle exec fastlane [action]')
|
49
|
+
def self.bundler?
|
50
|
+
# Bundler environment variable
|
51
|
+
%w(BUNDLE_BIN_PATH BUNDLE_GEMFILE).each do |current|
|
52
|
+
return true if ENV.key?(current)
|
53
|
+
end
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
|
57
|
+
# Do we run from a bundled fastlane, which contains Ruby and OpenSSL?
|
58
|
+
# Usually this means the fastlane directory is ~/.fastlane/bin/
|
59
|
+
# We set this value via the environment variable `FASTLANE_SELF_CONTAINED`
|
60
|
+
def self.contained_fastlane?
|
61
|
+
ENV["FASTLANE_SELF_CONTAINED"].to_s == "true" && !homebrew?
|
62
|
+
end
|
63
|
+
|
64
|
+
# returns true if fastlane was installed from the Fabric Mac app
|
65
|
+
def self.mac_app?
|
66
|
+
ENV["FASTLANE_SELF_CONTAINED"].to_s == "false"
|
67
|
+
end
|
68
|
+
|
69
|
+
# returns true if fastlane was installed via Homebrew
|
70
|
+
def self.homebrew?
|
71
|
+
ENV["FASTLANE_INSTALLED_VIA_HOMEBREW"].to_s == "true"
|
72
|
+
end
|
73
|
+
|
74
|
+
# returns true if fastlane was installed via RubyGems
|
75
|
+
def self.rubygems?
|
76
|
+
!bundler? && !contained_fastlane? && !homebrew? && !mac_app?
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [boolean] true if building in a known CI environment
|
80
|
+
def self.ci?
|
81
|
+
# Check for Jenkins, Travis CI, ... environment variables
|
82
|
+
%w(JENKINS_HOME JENKINS_URL TRAVIS CIRCLECI CI TEAMCITY_VERSION GO_PIPELINE_NAME bamboo_buildKey GITLAB_CI XCS).each do |current|
|
83
|
+
return true if ENV.key?(current)
|
84
|
+
end
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.windows?
|
89
|
+
# taken from: http://stackoverflow.com/a/171011/1945875
|
90
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.linux?
|
94
|
+
(/linux/ =~ RUBY_PLATFORM) != nil
|
95
|
+
end
|
96
|
+
|
97
|
+
# Is the currently running computer a Mac?
|
98
|
+
def self.mac?
|
99
|
+
(/darwin/ =~ RUBY_PLATFORM) != nil
|
100
|
+
end
|
101
|
+
|
102
|
+
# the valid operating systems
|
103
|
+
def self.operating_systems
|
104
|
+
[:linux, :mac, :win]
|
105
|
+
end
|
106
|
+
|
107
|
+
# the current operating system
|
108
|
+
def self.operating_system
|
109
|
+
if linux?
|
110
|
+
return :linux
|
111
|
+
elsif mac?
|
112
|
+
return :mac
|
113
|
+
elsif windows?
|
114
|
+
return :win
|
115
|
+
else
|
116
|
+
raise 'Could not assume what OS you\'re running, please specify it as much as possible'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.win_64?
|
121
|
+
(/x64/ =~ RUBY_PLATFORM) != nil
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.win_32?
|
125
|
+
(/i386/ =~ RUBY_PLATFORM) != nil
|
126
|
+
end
|
127
|
+
|
128
|
+
# Do we want to disable the colored output?
|
129
|
+
def self.colors_disabled?
|
130
|
+
ENV["U3D_DISABLE_COLORS"]
|
131
|
+
end
|
132
|
+
|
133
|
+
# Does the user use the Mac stock terminal
|
134
|
+
def self.mac_stock_terminal?
|
135
|
+
!!ENV["TERM_PROGRAM_VERSION"]
|
136
|
+
end
|
137
|
+
|
138
|
+
# Does the user use iTerm?
|
139
|
+
def self.iterm?
|
140
|
+
!!ENV["ITERM_SESSION_ID"]
|
141
|
+
end
|
142
|
+
|
143
|
+
# Logs base directory
|
144
|
+
# def self.buildlog_path
|
145
|
+
# return ENV["FL_BUILDLOG_PATH"] || "~/Library/Logs"
|
146
|
+
# end
|
147
|
+
end
|
148
|
+
# rubocop:enable Metrics/ModuleLength
|
149
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2016-present WeWantToKnow AS
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
## --- END LICENSE BLOCK ---
|
23
|
+
|
24
|
+
# This code overwrites the methods from the colored gem
|
25
|
+
# via https://github.com/defunkt/colored/blob/master/lib/colored.rb
|
26
|
+
|
27
|
+
require 'colored'
|
28
|
+
|
29
|
+
class String
|
30
|
+
Colored::COLORS.keys.each do |color|
|
31
|
+
define_method(color) do
|
32
|
+
self # do nothing with the string, but return it
|
33
|
+
end
|
34
|
+
end
|
35
|
+
Colored::EXTRAS.keys.each do |extra|
|
36
|
+
define_method(extra) do
|
37
|
+
self # do nothing with the string, but return it
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2016-present WeWantToKnow AS
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
## --- END LICENSE BLOCK ---
|
23
|
+
|
24
|
+
module U3dCore
|
25
|
+
# Shell is the terminal output of things
|
26
|
+
# For documentation for each of the methods open `interface.rb`
|
27
|
+
class Shell < Interface
|
28
|
+
def log
|
29
|
+
return @log if @log
|
30
|
+
|
31
|
+
$stdout.sync = true
|
32
|
+
|
33
|
+
@log ||= if Helper.is_test?
|
34
|
+
Logger.new(nil) # don't show any logs when running tests
|
35
|
+
else
|
36
|
+
Logger.new($stdout)
|
37
|
+
end
|
38
|
+
|
39
|
+
@log.formatter = proc do |severity, datetime, _progname, msg|
|
40
|
+
"#{format_string(datetime, severity)}#{msg}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
require 'u3d_core/ui/disable_colors' if U3dCore::Helper.colors_disabled?
|
44
|
+
|
45
|
+
@log
|
46
|
+
end
|
47
|
+
|
48
|
+
def format_string(datetime = Time.now, severity = "")
|
49
|
+
if U3dCore::Globals.log_timestamps?
|
50
|
+
timestamp = ENV["U3D_UI_TIMESTAMP"]
|
51
|
+
# default timestamp if none specified
|
52
|
+
unless timestamp
|
53
|
+
timestamp = if U3dCore::Globals.verbose?
|
54
|
+
'%Y-%m-%d %H:%M:%S.%2N'
|
55
|
+
else
|
56
|
+
'%H:%M:%S'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
# hide has last word
|
61
|
+
timestamp = nil if ENV["U3D_HIDE_TIMESTAMP"]
|
62
|
+
s = []
|
63
|
+
s << "#{severity} " if U3dCore::Globals.verbose? && severity && !severity.empty?
|
64
|
+
s << "[#{datetime.strftime(timestamp)}] " if timestamp
|
65
|
+
s.join('')
|
66
|
+
end
|
67
|
+
|
68
|
+
#####################################################
|
69
|
+
# @!group Messaging: show text to the user
|
70
|
+
#####################################################
|
71
|
+
|
72
|
+
def error(message)
|
73
|
+
log.error(message.to_s.red)
|
74
|
+
end
|
75
|
+
|
76
|
+
def important(message)
|
77
|
+
log.warn(message.to_s.yellow)
|
78
|
+
end
|
79
|
+
|
80
|
+
def success(message)
|
81
|
+
log.info(message.to_s.green)
|
82
|
+
end
|
83
|
+
|
84
|
+
def message(message)
|
85
|
+
log.info(message.to_s)
|
86
|
+
end
|
87
|
+
|
88
|
+
def deprecated(message)
|
89
|
+
log.error(message.to_s.bold.blue)
|
90
|
+
end
|
91
|
+
|
92
|
+
def command(message)
|
93
|
+
log.info("$ #{message}".cyan.underline)
|
94
|
+
end
|
95
|
+
|
96
|
+
def command_output(message)
|
97
|
+
actual = (message.split("\r").last || "") # as clearing the line will remove the `>` and the time stamp
|
98
|
+
actual.split("\n").each do |msg|
|
99
|
+
prefix = msg.include?("▸") ? "" : "▸ "
|
100
|
+
log.info(prefix + "" + msg.magenta)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def verbose(message)
|
105
|
+
log.debug(message.to_s) if U3dCore::Globals.verbose?
|
106
|
+
end
|
107
|
+
|
108
|
+
def header(message)
|
109
|
+
i = message.length + 8
|
110
|
+
success("-" * i)
|
111
|
+
success("--- " + message + " ---")
|
112
|
+
success("-" * i)
|
113
|
+
end
|
114
|
+
|
115
|
+
#####################################################
|
116
|
+
# @!group Errors: Inputs
|
117
|
+
#####################################################
|
118
|
+
|
119
|
+
def interactive?
|
120
|
+
interactive = true
|
121
|
+
interactive = false if $stdout.isatty == false
|
122
|
+
interactive = false if Helper.ci?
|
123
|
+
return interactive
|
124
|
+
end
|
125
|
+
|
126
|
+
def input(message)
|
127
|
+
verify_interactive!(message)
|
128
|
+
ask("#{format_string}#{message.to_s.yellow}").to_s.strip
|
129
|
+
end
|
130
|
+
|
131
|
+
def confirm(message)
|
132
|
+
verify_interactive!(message)
|
133
|
+
agree("#{format_string}#{message.to_s.yellow} (y/n)", true)
|
134
|
+
end
|
135
|
+
|
136
|
+
def select(message, options)
|
137
|
+
verify_interactive!(message)
|
138
|
+
|
139
|
+
important(message)
|
140
|
+
choose(*options)
|
141
|
+
end
|
142
|
+
|
143
|
+
def password(message)
|
144
|
+
verify_interactive!(message)
|
145
|
+
|
146
|
+
ask("#{format_string}#{message.to_s.yellow}") { |q| q.echo = "*" }
|
147
|
+
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
def verify_interactive!(message)
|
152
|
+
return if interactive?
|
153
|
+
important(message)
|
154
|
+
crash!("Could not retrieve response as u3d runs in non-interactive mode")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2016-present WeWantToKnow AS
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
## --- END LICENSE BLOCK ---
|
23
|
+
|
24
|
+
module U3dCore
|
25
|
+
# Abstract super class
|
26
|
+
class Interface
|
27
|
+
#####################################################
|
28
|
+
# @!group Messaging: show text to the user
|
29
|
+
#####################################################
|
30
|
+
|
31
|
+
# Level Error: Can be used to show additional error
|
32
|
+
# information before actually raising an exception
|
33
|
+
# or can be used to just show an error from which
|
34
|
+
# u3d can recover (much magic)
|
35
|
+
#
|
36
|
+
# By default those messages are shown in red
|
37
|
+
def error(_message)
|
38
|
+
not_implemented(__method__)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Level Important: Can be used to show warnings to the user
|
42
|
+
# not necessarly negative, but something the user should
|
43
|
+
# be aware of.
|
44
|
+
#
|
45
|
+
# By default those messages are shown in yellow
|
46
|
+
def important(_message)
|
47
|
+
not_implemented(__method__)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Level Success: Show that something was successful
|
51
|
+
#
|
52
|
+
# By default those messages are shown in green
|
53
|
+
def success(_message)
|
54
|
+
not_implemented(__method__)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Level Message: Show a neutral message to the user
|
58
|
+
#
|
59
|
+
# By default those messages shown in white/black
|
60
|
+
def message(_message)
|
61
|
+
not_implemented(__method__)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Level Deprecated: Show that a particular function is deprecated
|
65
|
+
#
|
66
|
+
# By default those messages shown in strong blue
|
67
|
+
def deprecated(_message)
|
68
|
+
not_implemented(__method__)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Level Command: Print out a terminal command that is being
|
72
|
+
# executed.
|
73
|
+
#
|
74
|
+
# By default those messages shown in cyan
|
75
|
+
def command(_message)
|
76
|
+
not_implemented(__method__)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Level Command Output: Print the output of a command with
|
80
|
+
# this method
|
81
|
+
#
|
82
|
+
# By default those messages shown in magenta
|
83
|
+
def command_output(_message)
|
84
|
+
not_implemented(__method__)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Level Verbose: Print out additional information for the
|
88
|
+
# users that are interested. Will only be printed when
|
89
|
+
# $verbose = true
|
90
|
+
#
|
91
|
+
# By default those messages are shown in white
|
92
|
+
def verbose(_message)
|
93
|
+
not_implemented(__method__)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Print a header = a text in a box
|
97
|
+
# use this if this message is really important
|
98
|
+
def header(_message)
|
99
|
+
not_implemented(__method__)
|
100
|
+
end
|
101
|
+
|
102
|
+
#####################################################
|
103
|
+
# @!group Errors: Inputs
|
104
|
+
#####################################################
|
105
|
+
|
106
|
+
# Is is possible to ask the user questions?
|
107
|
+
def interactive?(_message)
|
108
|
+
not_implemented(__method__)
|
109
|
+
end
|
110
|
+
|
111
|
+
# get a standard text input (single line)
|
112
|
+
def input(_message)
|
113
|
+
not_implemented(__method__)
|
114
|
+
end
|
115
|
+
|
116
|
+
# A simple yes or no question
|
117
|
+
def confirm(_message)
|
118
|
+
not_implemented(__method__)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Let the user select one out of x items
|
122
|
+
# return value is the value of the option the user chose
|
123
|
+
def select(_message, _options)
|
124
|
+
not_implemented(__method__)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Password input for the user, text field shouldn't show
|
128
|
+
# plain text
|
129
|
+
def password(_message)
|
130
|
+
not_implemented(__method__)
|
131
|
+
end
|
132
|
+
|
133
|
+
#####################################################
|
134
|
+
# @!group Errors: Different kinds of exceptions
|
135
|
+
#####################################################
|
136
|
+
|
137
|
+
# raised from crash!
|
138
|
+
class UICrash < StandardError
|
139
|
+
end
|
140
|
+
|
141
|
+
# raised from user_error!
|
142
|
+
class UIError < StandardError
|
143
|
+
attr_reader :show_github_issues
|
144
|
+
|
145
|
+
def initialize(show_github_issues: false)
|
146
|
+
@show_github_issues = show_github_issues
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Pass an exception to this method to exit the program
|
151
|
+
# using the given exception
|
152
|
+
# Use this method instead of user_error! if this error is
|
153
|
+
# unexpected, e.g. an invalid server response that shouldn't happen
|
154
|
+
def crash!(exception)
|
155
|
+
raise UICrash.new, exception.to_s
|
156
|
+
end
|
157
|
+
|
158
|
+
# Use this method to exit the program because of an user error
|
159
|
+
# e.g. app doesn't exist on the given Developer Account
|
160
|
+
# or invalid user credentials
|
161
|
+
# or scan tests fail
|
162
|
+
# This will show the error message, but doesn't show the full
|
163
|
+
# stack trace
|
164
|
+
# Basically this should be used when you actively catch the error
|
165
|
+
# and want to show a nice error message to the user
|
166
|
+
def user_error!(error_message, options = {})
|
167
|
+
options = { show_github_issues: false }.merge(options)
|
168
|
+
raise UIError.new(show_github_issues: options[:show_github_issues]), error_message.to_s
|
169
|
+
end
|
170
|
+
|
171
|
+
#####################################################
|
172
|
+
# @!group Helpers
|
173
|
+
#####################################################
|
174
|
+
def not_implemented(method_name)
|
175
|
+
UI.user_error!("Current UI '#{self}' doesn't support method '#{method_name}'")
|
176
|
+
end
|
177
|
+
|
178
|
+
def to_s
|
179
|
+
self.class.name.split('::').last
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|