u3d 1.2.1 → 1.2.2
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 +4 -4
- data/.circleci/config.yml +11 -1
- data/.github_changelog_generator +1 -1
- data/CHANGELOG.md +20 -0
- data/DEVELOPMENT_PROCESS.md +1 -0
- data/Gemfile.lock +5 -5
- data/Rakefile +41 -0
- data/examples/Example1/Gemfile.lock +6 -3
- data/lib/u3d/commands.rb +7 -6
- data/lib/u3d/commands_generator.rb +3 -0
- data/lib/u3d/installer.rb +4 -1
- data/lib/u3d/version.rb +1 -1
- data/lib/u3d_core.rb +3 -0
- data/lib/u3d_core/env.rb +32 -0
- data/lib/u3d_core/update_checker/changelog.rb +63 -0
- data/lib/u3d_core/update_checker/update_checker.rb +130 -0
- data/u3d.gemspec +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80cbd75cc31f765c99ad5045c7bc4a4aedef530decb41e694554b8d85ad2ce36
|
4
|
+
data.tar.gz: acf532a7231f8a75e2287f9c533feb71b4d8370c298f44bb8878041e7be91bec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9fd958b3178ee339b2ed5dba30ffc83b0c03394dd6cab19e5885059bdddd7ec1e91ef33014fde1a1d2b45ef276db38df6a4d42f313111be8bf4322b8dd05ea5
|
7
|
+
data.tar.gz: de18a2ef437ec324d85906b27e568315e5bf09144308cff7849f27ed14212258a2c10fee9a0a5ae78e3040f5127d200e45ac24e7978fe494fcfb4699824fe3bb
|
data/.circleci/config.yml
CHANGED
@@ -26,10 +26,18 @@ jobs:
|
|
26
26
|
# fallback to using the latest cache if no exact match is found
|
27
27
|
- v1-dependencies-
|
28
28
|
|
29
|
+
- run:
|
30
|
+
name: Configure Bundler
|
31
|
+
command: |
|
32
|
+
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
|
33
|
+
source $BASH_ENV
|
34
|
+
gem install bundler
|
35
|
+
bundle config set path '.bundle'
|
36
|
+
|
29
37
|
- run:
|
30
38
|
name: install dependencies
|
31
39
|
command: |
|
32
|
-
bundle install --jobs=4 --retry=3
|
40
|
+
bundle install --jobs=4 --retry=3
|
33
41
|
|
34
42
|
- save_cache:
|
35
43
|
paths:
|
@@ -44,6 +52,8 @@ jobs:
|
|
44
52
|
- run:
|
45
53
|
name: run tests
|
46
54
|
command: |
|
55
|
+
echo $BUNDLER_VERSION
|
56
|
+
bundle --version
|
47
57
|
bundle exec rake
|
48
58
|
|
49
59
|
# collect reports
|
data/.github_changelog_generator
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v1.2.2](https://github.com/DragonBox/u3d/tree/v1.2.2) (2020-02-21)
|
4
|
+
[Full Changelog](https://github.com/DragonBox/u3d/compare/v1.2.1...v1.2.2)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- Error management in invalid modules at least on macOS [\#385](https://github.com/DragonBox/u3d/issues/385)
|
9
|
+
- U3D\_EXTRA\_PATHS is improperly interpreted on Windows [\#383](https://github.com/DragonBox/u3d/issues/383)
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- github releases are not marked as latest nor contain changelogs [\#389](https://github.com/DragonBox/u3d/issues/389)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Bump Example1 dependencies that trigger security warning on github [\#396](https://github.com/DragonBox/u3d/pull/396) ([lacostej](https://github.com/lacostej))
|
18
|
+
- Create Github releases. Required for \#390. \[Fixes \#389\] [\#395](https://github.com/DragonBox/u3d/pull/395) ([lacostej](https://github.com/lacostej))
|
19
|
+
- Support displaying u3d updates [\#390](https://github.com/DragonBox/u3d/pull/390) ([lacostej](https://github.com/lacostej))
|
20
|
+
- u3d/install: convert Windows paths to ruby paths when treating U3D\_EXTRA\_PATHS [\#388](https://github.com/DragonBox/u3d/pull/388) ([lacostej](https://github.com/lacostej))
|
21
|
+
- u3d/install: verify package names before we ensure setup coherence \(fixes \#385\) \(regression from 1.2.0\) [\#387](https://github.com/DragonBox/u3d/pull/387) ([lacostej](https://github.com/lacostej))
|
22
|
+
|
3
23
|
## [v1.2.1](https://github.com/DragonBox/u3d/tree/v1.2.1) (2019-11-15)
|
4
24
|
[Full Changelog](https://github.com/DragonBox/u3d/compare/v1.2.0...v1.2.1)
|
5
25
|
|
data/DEVELOPMENT_PROCESS.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
u3d (1.2.
|
4
|
+
u3d (1.2.2)
|
5
5
|
colored (>= 1.2, < 2.0.0)
|
6
6
|
commander (>= 4.4.0, < 5.0.0)
|
7
7
|
file-tail (>= 1.2.0)
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
byebug (10.0.2)
|
27
27
|
coderay (1.1.2)
|
28
28
|
colored (1.2)
|
29
|
-
commander (4.
|
29
|
+
commander (4.5.0)
|
30
30
|
highline (~> 2.0.0)
|
31
31
|
concurrent-ruby (1.0.5)
|
32
32
|
coveralls (0.8.21)
|
@@ -100,7 +100,7 @@ GEM
|
|
100
100
|
ruby-progressbar (~> 1.7)
|
101
101
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
102
102
|
ruby-progressbar (1.9.0)
|
103
|
-
rubyzip (2.
|
103
|
+
rubyzip (2.2.0)
|
104
104
|
sawyer (0.8.1)
|
105
105
|
addressable (>= 2.3.5, < 2.6)
|
106
106
|
faraday (~> 0.8, < 1.0)
|
@@ -125,7 +125,7 @@ PLATFORMS
|
|
125
125
|
x86-mingw32
|
126
126
|
|
127
127
|
DEPENDENCIES
|
128
|
-
bundler (~>
|
128
|
+
bundler (~> 2.0)
|
129
129
|
coveralls
|
130
130
|
github_changelog_generator
|
131
131
|
pry-byebug
|
@@ -136,4 +136,4 @@ DEPENDENCIES
|
|
136
136
|
u3d!
|
137
137
|
|
138
138
|
BUNDLED WITH
|
139
|
-
1.
|
139
|
+
2.1.4
|
data/Rakefile
CHANGED
@@ -24,6 +24,7 @@ require "bundler/gem_tasks"
|
|
24
24
|
require "rspec/core/rake_task"
|
25
25
|
require 'rubocop/rake_task'
|
26
26
|
require 'u3d'
|
27
|
+
|
27
28
|
UI = U3dCore::UI
|
28
29
|
|
29
30
|
# doesn't yet support dot file
|
@@ -207,4 +208,44 @@ task :test_all do
|
|
207
208
|
sh "rspec #{rspec_args}"
|
208
209
|
end
|
209
210
|
|
211
|
+
def parse_changelog
|
212
|
+
releases = {}
|
213
|
+
buffer = nil
|
214
|
+
version = nil
|
215
|
+
File.readlines("CHANGELOG.md").each do |line|
|
216
|
+
if (m = line.match(/^## \[(.*)\]/))
|
217
|
+
releases[version] = buffer if buffer
|
218
|
+
version = m[1]
|
219
|
+
buffer = version + "\n\n"
|
220
|
+
else
|
221
|
+
next unless version # skip first lines
|
222
|
+
buffer += line if line != "\n"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
releases[version] = buffer
|
226
|
+
releases
|
227
|
+
end
|
228
|
+
|
229
|
+
desc 'Create missing Github releases from changelog'
|
230
|
+
task :create_missing_github_releases do
|
231
|
+
releases = parse_changelog
|
232
|
+
|
233
|
+
known_releases = `hub release`.split("\n")
|
234
|
+
|
235
|
+
releases.keys.reverse.each do |version|
|
236
|
+
if known_releases.include? version
|
237
|
+
puts "Skipping existing version #{version}"
|
238
|
+
next
|
239
|
+
end
|
240
|
+
changelog = releases[version]
|
241
|
+
puts "Creating version #{version}"
|
242
|
+
require "tempfile"
|
243
|
+
Tempfile.create("githubchangelog") do |changelog_file|
|
244
|
+
File.write(changelog_file, changelog)
|
245
|
+
command = "hub release create #{version} -F #{changelog_file.path}"
|
246
|
+
`#{command}`
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
210
251
|
task default: %i[rubocop test_all]
|
@@ -7,13 +7,14 @@ PATH
|
|
7
7
|
PATH
|
8
8
|
remote: /Users/lacostej/Code/OSS/u3d
|
9
9
|
specs:
|
10
|
-
u3d (1.1
|
10
|
+
u3d (1.2.1)
|
11
11
|
colored (>= 1.2, < 2.0.0)
|
12
12
|
commander (>= 4.4.0, < 5.0.0)
|
13
13
|
file-tail (>= 1.2.0)
|
14
14
|
filesize (>= 0.1.1)
|
15
15
|
inifile (>= 3.0.0, < 4.0.0)
|
16
16
|
plist (>= 3.1.0, < 4.0.0)
|
17
|
+
rubyzip (>= 1.0.0)
|
17
18
|
security (= 0.1.3)
|
18
19
|
|
19
20
|
GEM
|
@@ -38,7 +39,7 @@ GEM
|
|
38
39
|
unf (>= 0.0.5, < 1.0.0)
|
39
40
|
dotenv (2.7.5)
|
40
41
|
emoji_regex (1.0.1)
|
41
|
-
excon (0.
|
42
|
+
excon (0.72.0)
|
42
43
|
faraday (0.17.0)
|
43
44
|
multipart-post (>= 1.2, < 3)
|
44
45
|
faraday-cookie_jar (0.0.6)
|
@@ -149,10 +150,12 @@ GEM
|
|
149
150
|
CFPropertyList
|
150
151
|
naturally
|
151
152
|
slack-notifier (2.3.2)
|
153
|
+
sync (0.5.0)
|
152
154
|
terminal-notifier (2.0.0)
|
153
155
|
terminal-table (1.8.0)
|
154
156
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
155
|
-
tins (1.
|
157
|
+
tins (1.24.1)
|
158
|
+
sync
|
156
159
|
tty-cursor (0.7.0)
|
157
160
|
tty-screen (0.7.0)
|
158
161
|
tty-spinner (0.9.1)
|
data/lib/u3d/commands.rb
CHANGED
@@ -152,7 +152,8 @@ module U3d
|
|
152
152
|
|
153
153
|
definition = UnityVersionDefinition.new(version, os, cache_versions)
|
154
154
|
unity = check_unity_presence(version: version)
|
155
|
-
|
155
|
+
|
156
|
+
packages = verify_package_names(options[:packages], definition) || ['Unity']
|
156
157
|
|
157
158
|
begin
|
158
159
|
packages = enforce_setup_coherence(packages, options, unity, definition)
|
@@ -160,8 +161,6 @@ module U3d
|
|
160
161
|
return
|
161
162
|
end
|
162
163
|
|
163
|
-
verify_package_names(definition, packages)
|
164
|
-
|
165
164
|
get_administrative_privileges(options) if options[:install]
|
166
165
|
|
167
166
|
files = Downloader.fetch_modules(definition, packages: packages, download: options[:download])
|
@@ -274,10 +273,12 @@ module U3d
|
|
274
273
|
cache_versions
|
275
274
|
end
|
276
275
|
|
277
|
-
def verify_package_names(
|
278
|
-
packages.
|
279
|
-
|
276
|
+
def verify_package_names(packages, definition)
|
277
|
+
unless packages.nil?
|
278
|
+
invalid_packages = packages.reject { |package| definition.available_package? package }
|
279
|
+
raise ArgumentError, "Package(s) '#{invalid_packages.join(',')}' are not known. Use #{definition.available_packages.join(',')}" unless invalid_packages.empty?
|
280
280
|
end
|
281
|
+
packages
|
281
282
|
end
|
282
283
|
|
283
284
|
def specified_or_current_project_version(version)
|
@@ -36,8 +36,11 @@ module U3d
|
|
36
36
|
UNICODE_FILE = File.expand_path('../../assets/utf8.txt', __FILE__)
|
37
37
|
|
38
38
|
def self.start
|
39
|
+
U3dCore::UpdateChecker.start_looking_for_update('u3d')
|
39
40
|
check_locale
|
40
41
|
new.run
|
42
|
+
ensure
|
43
|
+
U3dCore::UpdateChecker.show_update_status('u3d', U3d::VERSION)
|
41
44
|
end
|
42
45
|
|
43
46
|
def self.check_locale
|
data/lib/u3d/installer.rb
CHANGED
@@ -146,9 +146,12 @@ module U3d
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
# extra installation paths are stored in U3D_EXTRA_PATHS environment variable,
|
150
|
+
# following a standard PATH variable format.
|
151
|
+
# Returns an array of ruby style paths
|
149
152
|
def extra_installation_paths
|
150
153
|
return [] if ENV['U3D_EXTRA_PATHS'].nil?
|
151
|
-
ENV['U3D_EXTRA_PATHS'].strip.split(File::PATH_SEPARATOR)
|
154
|
+
ENV['U3D_EXTRA_PATHS'].strip.split(File::PATH_SEPARATOR).map { |p| File.expand_path p }
|
152
155
|
end
|
153
156
|
|
154
157
|
def find_installations_with_path(default_root_path: '', postfix: [])
|
data/lib/u3d/version.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
## --- END LICENSE BLOCK ---
|
22
22
|
|
23
23
|
module U3d
|
24
|
-
VERSION = '1.2.
|
24
|
+
VERSION = '1.2.2'.freeze
|
25
25
|
DESCRIPTION = 'Provides numerous tools for installing, managing and running the Unity game engine from command line.'.freeze
|
26
26
|
UNITY_VERSIONS_NOTE = "Unity uses the following version formatting: 0.0.0x0. The \'x\' can takes different values:\n"\
|
27
27
|
"\t. 'f' are the main release candidates for Unity\n"\
|
data/lib/u3d_core.rb
CHANGED
@@ -27,5 +27,8 @@ require 'u3d_core/credentials'
|
|
27
27
|
require 'u3d_core/ui/ui'
|
28
28
|
require 'u3d_core/command_executor'
|
29
29
|
require 'u3d_core/command_runner'
|
30
|
+
require 'u3d_core/env'
|
31
|
+
require 'u3d_core/update_checker/changelog'
|
32
|
+
require 'u3d_core/update_checker/update_checker'
|
30
33
|
require 'colored'
|
31
34
|
require 'commander'
|
data/lib/u3d_core/env.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2019-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
|
+
class Env
|
26
|
+
def self.truthy?(env)
|
27
|
+
return false unless ENV[env]
|
28
|
+
return false if %w[no false off 0].include?(ENV[env].to_s)
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2019-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_relative '../../u3d/utils'
|
25
|
+
|
26
|
+
module U3dCore
|
27
|
+
class Changelog
|
28
|
+
class << self
|
29
|
+
def show_changes(gem_name, current_version, update_gem_command: "bundle update")
|
30
|
+
did_show_changelog = false
|
31
|
+
|
32
|
+
releases(gem_name).each_with_index do |release, index|
|
33
|
+
next unless Gem::Version.new(to_version(release['tag_name'])) > Gem::Version.new(current_version)
|
34
|
+
puts("")
|
35
|
+
puts(release['name'].green)
|
36
|
+
puts(release['body'])
|
37
|
+
did_show_changelog = true
|
38
|
+
|
39
|
+
next unless index == 2
|
40
|
+
puts("")
|
41
|
+
puts("To see all new releases, open https://github.com/DragonBox/#{gem_name}/releases".green)
|
42
|
+
break
|
43
|
+
end
|
44
|
+
|
45
|
+
puts("")
|
46
|
+
puts("Please update using `#{update_gem_command}`".green) if did_show_changelog
|
47
|
+
rescue StandardError => e
|
48
|
+
# Something went wrong, we don't care so much about this
|
49
|
+
UI.error("Unable to show_changes: #{e}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_version(tag_name)
|
53
|
+
tag_name = tag_name[1..-1] if tag_name[0] == 'v'
|
54
|
+
tag_name
|
55
|
+
end
|
56
|
+
|
57
|
+
def releases(gem_name)
|
58
|
+
url = "https://api.github.com/repos/DragonBox/#{gem_name}/releases"
|
59
|
+
JSON.parse(U3d::Utils.page_content(url))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
## --- BEGIN LICENSE BLOCK ---
|
2
|
+
# Original work Copyright (c) 2015-present the fastlane authors
|
3
|
+
# Modified work Copyright 2019-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_relative 'changelog'
|
25
|
+
require_relative '../ui/ui'
|
26
|
+
require_relative '../../u3d/utils'
|
27
|
+
|
28
|
+
module U3dCore
|
29
|
+
# Verifies the user runs the latest version of this gem
|
30
|
+
class UpdateChecker
|
31
|
+
def self.start_looking_for_update(gem_name)
|
32
|
+
return if Helper.test?
|
33
|
+
return if U3dCore::Env.truthy?("U3D_SKIP_UPDATE_CHECK")
|
34
|
+
|
35
|
+
@start_time = Time.now
|
36
|
+
|
37
|
+
Thread.new do
|
38
|
+
begin
|
39
|
+
server_results[gem_name] = fetch_latest(gem_name)
|
40
|
+
# rubocop:disable Lint/HandleExceptions
|
41
|
+
rescue StandardError
|
42
|
+
# rubocop:enable Lint/HandleExceptions
|
43
|
+
# we don't want to show a stack trace if something goes wrong
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.server_results
|
49
|
+
@results ||= {}
|
50
|
+
end
|
51
|
+
|
52
|
+
class << self
|
53
|
+
attr_reader :start_time
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.update_available?(gem_name, current_version)
|
57
|
+
latest = server_results[gem_name]
|
58
|
+
return (latest && (Gem::Version.new(latest) > Gem::Version.new(current_version)))
|
59
|
+
end
|
60
|
+
|
61
|
+
# wait a abit for results when commands run real quick
|
62
|
+
def self.wait_for_results
|
63
|
+
sleep([0, 0.4 - (Time.now - @start_time)].max) if @start_time
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.show_update_status(gem_name, current_version)
|
67
|
+
wait_for_results unless update_available?(gem_name, current_version)
|
68
|
+
show_update_message(gem_name, current_version) if update_available?(gem_name, current_version)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Show a message to the user to update to a new version of u3d
|
72
|
+
# Use this method, as this will detect the current Ruby environment and show an
|
73
|
+
# appropriate message to the user
|
74
|
+
def self.show_update_message(gem_name, current_version)
|
75
|
+
available = server_results[gem_name]
|
76
|
+
puts("")
|
77
|
+
puts('#######################################################################')
|
78
|
+
if available
|
79
|
+
puts("# #{gem_name} #{available} is available. You are on #{current_version}.")
|
80
|
+
else
|
81
|
+
puts("# An update for #{gem_name} is available. You are on #{current_version}.")
|
82
|
+
end
|
83
|
+
puts("# You should use the latest version.")
|
84
|
+
puts("# Please update using `#{update_command(gem_name: gem_name)}`.")
|
85
|
+
|
86
|
+
# this could be fetched from the gem
|
87
|
+
puts("# To see what's new, open https://github.com/DragonBox/#{gem_name}/releases.") if U3dCore::Env.truthy?("U3D_HIDE_CHANGELOG")
|
88
|
+
|
89
|
+
if !Helper.bundler? && Random.rand(5) == 1
|
90
|
+
# We want to show this message from time to time, if the user doesn't use bundler
|
91
|
+
puts('#######################################################################')
|
92
|
+
puts("# Run `sudo gem cleanup` from time to time to speed up u3d")
|
93
|
+
end
|
94
|
+
puts('#######################################################################')
|
95
|
+
Changelog.show_changes(gem_name, current_version, update_gem_command: UpdateChecker.update_command(gem_name)) unless U3dCore::Env.truthy?("U3D_HIDE_CHANGELOG")
|
96
|
+
|
97
|
+
ensure_rubygems_source
|
98
|
+
end
|
99
|
+
|
100
|
+
# The command that the user should use to update the gem
|
101
|
+
def self.update_command(gem_name)
|
102
|
+
if Helper.bundler?
|
103
|
+
"bundle update #{gem_name.downcase}"
|
104
|
+
else
|
105
|
+
"sudo gem install #{gem_name.downcase}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Check if RubyGems is set as a gem source
|
110
|
+
# on some machines that might not be the case
|
111
|
+
# and then users can't find the update when
|
112
|
+
# running the specified command
|
113
|
+
def self.ensure_rubygems_source
|
114
|
+
return if `gem sources`.include?("https://rubygems.org")
|
115
|
+
puts("")
|
116
|
+
UI.error("RubyGems is not listed as your Gem source")
|
117
|
+
UI.error("You can run `gem sources` to see all your sources")
|
118
|
+
UI.error("Please run the following command to fix this:")
|
119
|
+
UI.command("gem sources --add https://rubygems.org")
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.fetch_latest(gem_name)
|
123
|
+
JSON.parse(U3d::Utils.page_content(generate_fetch_url(gem_name)))["version"]
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.generate_fetch_url(gem_name)
|
127
|
+
"https://rubygems.org/api/v1/gems/#{gem_name}.json"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/u3d.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency 'rubyzip', '>= 1.0.0' # Installation of .zip files
|
33
33
|
spec.add_dependency 'security', '= 0.1.3' # macOS Keychain manager, a dead project, no updates expected
|
34
34
|
# Development only
|
35
|
-
spec.add_development_dependency "bundler", "~>
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
36
36
|
spec.add_development_dependency "coveralls"
|
37
37
|
spec.add_development_dependency "github_changelog_generator"
|
38
38
|
spec.add_development_dependency "pry-byebug"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: u3d
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerome Lacoste
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colored
|
@@ -153,14 +153,14 @@ dependencies:
|
|
153
153
|
requirements:
|
154
154
|
- - "~>"
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: '
|
156
|
+
version: '2.0'
|
157
157
|
type: :development
|
158
158
|
prerelease: false
|
159
159
|
version_requirements: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
161
|
- - "~>"
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '
|
163
|
+
version: '2.0'
|
164
164
|
- !ruby/object:Gem::Dependency
|
165
165
|
name: coveralls
|
166
166
|
requirement: !ruby/object:Gem::Requirement
|
@@ -420,12 +420,15 @@ files:
|
|
420
420
|
- lib/u3d_core/core_ext/operating_system_symbol.rb
|
421
421
|
- lib/u3d_core/core_ext/string.rb
|
422
422
|
- lib/u3d_core/credentials.rb
|
423
|
+
- lib/u3d_core/env.rb
|
423
424
|
- lib/u3d_core/globals.rb
|
424
425
|
- lib/u3d_core/helper.rb
|
425
426
|
- lib/u3d_core/ui/disable_colors.rb
|
426
427
|
- lib/u3d_core/ui/implementations/shell.rb
|
427
428
|
- lib/u3d_core/ui/interface.rb
|
428
429
|
- lib/u3d_core/ui/ui.rb
|
430
|
+
- lib/u3d_core/update_checker/changelog.rb
|
431
|
+
- lib/u3d_core/update_checker/update_checker.rb
|
429
432
|
- lib/u3d_core/version.rb
|
430
433
|
- local_gem_install.sh
|
431
434
|
- scripts/be
|
@@ -449,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
449
452
|
- !ruby/object:Gem::Version
|
450
453
|
version: '0'
|
451
454
|
requirements: []
|
452
|
-
rubygems_version: 3.
|
455
|
+
rubygems_version: 3.1.2
|
453
456
|
signing_key:
|
454
457
|
specification_version: 4
|
455
458
|
summary: U3d
|