xcode-install 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -10
- data/.rubocop_todo.yml +30 -0
- data/.travis.yml +3 -1
- data/Gemfile +1 -0
- data/README.md +10 -10
- data/Rakefile +5 -1
- data/lib/xcode/install.rb +54 -37
- data/lib/xcode/install/install.rb +2 -5
- data/lib/xcode/install/select.rb +1 -1
- data/lib/xcode/install/simulators.rb +7 -6
- data/lib/xcode/install/uninstall.rb +3 -4
- data/lib/xcode/install/version.rb +1 -1
- data/spec/cli_spec.rb +1 -1
- data/spec/curl_spec.rb +26 -0
- data/spec/fixtures/hdiutil.plist +31 -0
- data/spec/install_spec.rb +36 -26
- data/xcode-install.gemspec +2 -0
- metadata +8 -5
- data/bin/xcode-install +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43d37a17db67d22edd50424ccf56a2e88fdfe46a
|
4
|
+
data.tar.gz: 5a5adb23dc67519d513176a1ed796c9aa54e5c1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc978f5f136e1a621e3a7cbf293d2292dc0e9e00d20f9b0338daa28c37c849742a5c3b8d7f7a9e831f12eca4ac892faacdf938117d8a8100446b42c1467b5a8
|
7
|
+
data.tar.gz: 39ed9aa06b63e5d65c357752898783a80095eb6e1f3311079371a650c6e37e959d5f27575ab9f21b781c5f853af1d21470dbf3fcd670dbce2f623a906b5f3bd8
|
data/.rubocop.yml
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
2
|
-
Max: 18
|
3
|
-
|
4
|
-
Metrics/ClassLength:
|
5
|
-
Max: 130
|
6
|
-
|
7
|
-
Metrics/CyclomaticComplexity:
|
8
|
-
Max: 7
|
1
|
+
inherit_from: .rubocop_todo.yml
|
9
2
|
|
10
3
|
Metrics/LineLength:
|
11
4
|
Max: 215
|
12
5
|
|
13
|
-
|
14
|
-
|
6
|
+
Style/AsciiComments:
|
7
|
+
Enabled: false
|
15
8
|
|
16
9
|
Style/Documentation:
|
17
10
|
Enabled: false
|
18
11
|
|
12
|
+
Style/FileName:
|
13
|
+
Exclude:
|
14
|
+
- bin/🎉
|
15
|
+
- bin/xcode-install
|
16
|
+
|
17
|
+
Style/SpecialGlobalVars:
|
18
|
+
Enabled: false
|
19
|
+
|
19
20
|
Lint/Void:
|
20
21
|
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2015-11-04 13:49:25 +0100 using RuboCop version 0.34.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 11
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 36
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: CountComments.
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Max: 250
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Max: 7
|
21
|
+
|
22
|
+
# Offense count: 10
|
23
|
+
# Configuration parameters: CountComments.
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 30
|
26
|
+
|
27
|
+
# Offense count: 1
|
28
|
+
# Configuration parameters: CountKeywordArgs.
|
29
|
+
Metrics/ParameterLists:
|
30
|
+
Max: 6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -7,15 +7,15 @@
|
|
7
7
|
|
8
8
|
Install and update your Xcodes automatically.
|
9
9
|
|
10
|
-
```
|
10
|
+
```
|
11
11
|
$ gem install xcode-install
|
12
12
|
$ xcversion install 6.3
|
13
13
|
```
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
17
|
-
```
|
18
|
-
$ gem install
|
17
|
+
```
|
18
|
+
$ gem install xcode-install
|
19
19
|
```
|
20
20
|
|
21
21
|
## Usage
|
@@ -30,7 +30,7 @@ XCODE_INSTALL_PASSWORD
|
|
30
30
|
|
31
31
|
To list available versions:
|
32
32
|
|
33
|
-
```
|
33
|
+
```
|
34
34
|
$ xcversion list
|
35
35
|
6.0.1
|
36
36
|
6.1
|
@@ -43,7 +43,7 @@ By default, only the latest major version is listed.
|
|
43
43
|
|
44
44
|
To install a certain version, simply:
|
45
45
|
|
46
|
-
```
|
46
|
+
```
|
47
47
|
$ xcversion install 6.3
|
48
48
|
########################################################### 82.1%
|
49
49
|
######################################################################## 100.0%
|
@@ -57,7 +57,7 @@ This will download and install that version of Xcode. It will also be automatica
|
|
57
57
|
|
58
58
|
Note: GMs and beta versions usually have special names, e.g.
|
59
59
|
|
60
|
-
```
|
60
|
+
```
|
61
61
|
$ xcversion list
|
62
62
|
7 GM seed
|
63
63
|
7.1 beta
|
@@ -73,8 +73,8 @@ XcodeInstall can also install Xcode's Command Line Tools by calling `xcversion i
|
|
73
73
|
|
74
74
|
XcodeInstall can also manage your local simulators using the `simulators` command.
|
75
75
|
|
76
|
-
```
|
77
|
-
$
|
76
|
+
```
|
77
|
+
$ xcversion simulators
|
78
78
|
Xcode 6.4.0 (/Applications/Xcode.app)
|
79
79
|
iOS 7.1 Simulator (installed)
|
80
80
|
iOS 8.1 Simulator (not installed)
|
@@ -89,8 +89,8 @@ iOS 8.4 Simulator (installed)
|
|
89
89
|
|
90
90
|
To install a simulator, simply:
|
91
91
|
|
92
|
-
```
|
93
|
-
$
|
92
|
+
```
|
93
|
+
$ xcversion simulators --install=8.4
|
94
94
|
########################################################### 82.1%
|
95
95
|
######################################################################## 100.0%
|
96
96
|
Please authenticate to install iOS 8.4 Simulator...
|
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
+
require 'rubocop/rake_task'
|
2
3
|
|
3
4
|
def specs(dir)
|
4
5
|
FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
|
@@ -9,4 +10,7 @@ task :spec do
|
|
9
10
|
sh "bundle exec bacon #{specs('**')}"
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
+
desc 'Lints all the files'
|
14
|
+
RuboCop::RakeTask.new(:rubocop)
|
15
|
+
|
16
|
+
task default: [:spec, :rubocop]
|
data/lib/xcode/install.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'pathname'
|
3
|
+
require 'rexml/document'
|
3
4
|
require 'spaceship'
|
4
5
|
require 'json'
|
5
6
|
require 'rubygems/version'
|
@@ -12,19 +13,20 @@ module XcodeInstall
|
|
12
13
|
COOKIES_PATH = Pathname.new('/tmp/curl-cookies.txt')
|
13
14
|
|
14
15
|
def fetch(url, directory = nil, cookies = nil, output = nil, progress = true)
|
15
|
-
options = cookies.nil? ?
|
16
|
-
# options
|
16
|
+
options = cookies.nil? ? [] : ['--cookie', cookies, '--cookie-jar', COOKIES_PATH]
|
17
|
+
# options << ' -vvv'
|
17
18
|
|
18
19
|
uri = URI.parse(url)
|
19
20
|
output ||= File.basename(uri.path)
|
20
21
|
output = (Pathname.new(directory) + Pathname.new(output)) if directory
|
21
22
|
|
22
|
-
progress = progress ? '
|
23
|
-
command =
|
24
|
-
IO.popen(command)
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
progress = progress ? '--progress-bar' : '--silent'
|
24
|
+
command = ['curl', *options, '--location', '--continue-at', '-', progress, '--output', output, url].map(&:to_s)
|
25
|
+
io = IO.popen(command)
|
26
|
+
io.each { |line| puts line }
|
27
|
+
io.close
|
28
|
+
|
29
|
+
result = $?.exitstatus == 0
|
28
30
|
|
29
31
|
FileUtils.rm_f(COOKIES_PATH)
|
30
32
|
result
|
@@ -69,27 +71,27 @@ module XcodeInstall
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
72
|
-
def install_dmg(
|
74
|
+
def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
|
73
75
|
xcode_path = "/Applications/Xcode#{suffix}.app"
|
74
76
|
|
75
|
-
|
77
|
+
mount_dir = mount(dmg_path)
|
76
78
|
puts 'Please authenticate for Xcode installation...'
|
77
|
-
source =
|
79
|
+
source = Dir.glob(File.join(mount_dir, 'Xcode*.app')).first
|
78
80
|
|
79
81
|
if source.nil?
|
80
|
-
out <<-HELP
|
81
|
-
No `Xcode.app` found in DMG. Please remove #{
|
82
|
+
out = <<-HELP
|
83
|
+
No `Xcode.app` found in DMG. Please remove #{dmg_path} if you suspect a corrupted
|
82
84
|
download or run `xcversion update` to see if the version you tried to install
|
83
85
|
has been pulled by Apple. If none of this is true, please open a new GH issue.
|
84
86
|
HELP
|
85
|
-
$stderr.puts out.
|
87
|
+
$stderr.puts out.tr("\n", ' ')
|
86
88
|
return
|
87
89
|
end
|
88
90
|
|
89
91
|
`sudo ditto "#{source}" "#{xcode_path}"`
|
90
92
|
`umount "/Volumes/Xcode"`
|
91
93
|
|
92
|
-
|
94
|
+
unless verify_integrity(xcode_path)
|
93
95
|
`sudo rm -f #{xcode_path}`
|
94
96
|
return
|
95
97
|
end
|
@@ -107,7 +109,7 @@ HELP
|
|
107
109
|
puts `xcodebuild -version`
|
108
110
|
end
|
109
111
|
|
110
|
-
FileUtils.rm_f(
|
112
|
+
FileUtils.rm_f(dmg_path) if clean
|
111
113
|
end
|
112
114
|
|
113
115
|
def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil)
|
@@ -154,7 +156,7 @@ HELP
|
|
154
156
|
def spaceship
|
155
157
|
@spaceship ||= begin
|
156
158
|
begin
|
157
|
-
Spaceship.login(ENV[
|
159
|
+
Spaceship.login(ENV['XCODE_INSTALL_USER'], ENV['XCODE_INSTALL_PASSWORD'])
|
158
160
|
rescue Spaceship::Client::InvalidUserCredentialsError
|
159
161
|
$stderr.puts 'The specified Apple developer account credentials are incorrect.'
|
160
162
|
exit(1)
|
@@ -166,8 +168,8 @@ HELP
|
|
166
168
|
exit(1)
|
167
169
|
end
|
168
170
|
|
169
|
-
if ENV.key?(
|
170
|
-
Spaceship.client.team_id = ENV[
|
171
|
+
if ENV.key?('XCODE_INSTALL_TEAM_ID')
|
172
|
+
Spaceship.client.team_id = ENV['XCODE_INSTALL_TEAM_ID']
|
171
173
|
end
|
172
174
|
Spaceship.client
|
173
175
|
end
|
@@ -196,15 +198,15 @@ HELP
|
|
196
198
|
end
|
197
199
|
|
198
200
|
def fetch_seedlist
|
199
|
-
@xcodes = parse_seedlist(spaceship.send(:request, :get,
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
201
|
+
@xcodes = parse_seedlist(spaceship.send(:request, :get,
|
202
|
+
'/services-account/QH65B2/downloadws/listDownloads.action',
|
203
|
+
start: '0',
|
204
|
+
limit: '1000',
|
205
|
+
sort: 'dateModified',
|
206
|
+
dir: 'DESC',
|
207
|
+
searchTextField: '',
|
208
|
+
searchCategories: '',
|
209
|
+
search: 'false').body)
|
208
210
|
|
209
211
|
names = @xcodes.map(&:name)
|
210
212
|
@xcodes += prereleases.reject { |pre| names.include?(pre.name) }
|
@@ -243,15 +245,15 @@ HELP
|
|
243
245
|
end
|
244
246
|
|
245
247
|
def prereleases
|
246
|
-
body=spaceship.send(:request, :get, '/xcode/download/').body
|
247
|
-
links=body.scan(
|
248
|
+
body = spaceship.send(:request, :get, '/xcode/download/').body
|
249
|
+
links = body.scan(%r{<a.+?href="(.+?.dmg)".*>(.*)</a>})
|
248
250
|
links = links.map do |link|
|
249
|
-
parent = link[0].scan(
|
251
|
+
parent = link[0].scan(%r{path=(/.*/.*/)}).first.first
|
250
252
|
match = body.scan(/#{Regexp.quote(parent)}(.+?.pdf)/).first
|
251
253
|
if match
|
252
|
-
link
|
254
|
+
link + [parent + match.first]
|
253
255
|
else
|
254
|
-
link
|
256
|
+
link + [nil]
|
255
257
|
end
|
256
258
|
end
|
257
259
|
links.map { |pre| Xcode.new_prerelease(pre[1].strip.gsub(/.*Xcode /, ''), pre[0], pre[2]) }
|
@@ -266,6 +268,22 @@ HELP
|
|
266
268
|
puts `/usr/sbin/spctl --assess --verbose=4 --type execute #{path}`
|
267
269
|
$?.exitstatus == 0
|
268
270
|
end
|
271
|
+
|
272
|
+
def hdiutil(*args)
|
273
|
+
io = IO.popen(['hdiutil', *args])
|
274
|
+
result = io.read
|
275
|
+
io.close
|
276
|
+
fail Informative, 'Failed to invoke hdiutil.' unless $?.exitstatus == 0
|
277
|
+
result
|
278
|
+
end
|
279
|
+
|
280
|
+
def mount(dmg_path)
|
281
|
+
plist = hdiutil('mount', '-plist', '-nobrowse', '-noverify', dmg_path.to_s)
|
282
|
+
document = REXML::Document.new(plist)
|
283
|
+
node = REXML::XPath.first(document, "//key[.='mount-point']/following-sibling::*[1]")
|
284
|
+
fail Informative, 'Failed to mount image.' unless node
|
285
|
+
node.text
|
286
|
+
end
|
269
287
|
end
|
270
288
|
|
271
289
|
class Simulator
|
@@ -327,7 +345,7 @@ HELP
|
|
327
345
|
|
328
346
|
def prepare_package
|
329
347
|
puts 'Mounting DMG'
|
330
|
-
mount_location =
|
348
|
+
mount_location = mount(dmg_path)
|
331
349
|
puts 'Expanding pkg'
|
332
350
|
expanded_pkg_path = CACHE_DIR + identifier
|
333
351
|
FileUtils.rm_rf(expanded_pkg_path)
|
@@ -382,7 +400,7 @@ HELP
|
|
382
400
|
end
|
383
401
|
|
384
402
|
def version
|
385
|
-
@version ||=
|
403
|
+
@version ||= fetch_version
|
386
404
|
end
|
387
405
|
|
388
406
|
def bundle_version
|
@@ -426,7 +444,7 @@ HELP
|
|
426
444
|
`/usr/libexec/PlistBuddy -c "Print :#{keypath}" "#{path}/Contents/Info.plist"`.chomp
|
427
445
|
end
|
428
446
|
|
429
|
-
def
|
447
|
+
def fetch_version
|
430
448
|
output = `DEVELOPER_DIR='' "#{@path}/Contents/Developer/usr/bin/xcodebuild" -version`
|
431
449
|
return '0.0' if output.nil? # ¯\_(ツ)_/¯
|
432
450
|
output.split("\n").first.split(' ')[1]
|
@@ -467,7 +485,6 @@ HELP
|
|
467
485
|
|
468
486
|
def self.new_prerelease(version, url, release_notes_path)
|
469
487
|
new('name' => version,
|
470
|
-
'dateModified' => Time.now.to_i,
|
471
488
|
'files' => [{ 'remotePath' => url.split('=').last }],
|
472
489
|
'release_notes_path' => release_notes_path)
|
473
490
|
end
|
@@ -35,15 +35,12 @@ module XcodeInstall
|
|
35
35
|
return if @version.nil?
|
36
36
|
fail Informative, "Version #{@version} already installed." if @installer.installed?(@version)
|
37
37
|
fail Informative, "Version #{@version} doesn't exist." unless @installer.exist?(@version)
|
38
|
-
|
39
|
-
if @url
|
40
|
-
fail Informative, "Invalid URL: `#{@url}`" unless @url =~ /\A#{URI::regexp}\z/
|
41
|
-
end
|
38
|
+
fail Informative, "Invalid URL: `#{@url}`" unless !@url || @url =~ /\A#{URI.regexp}\z/
|
42
39
|
end
|
43
40
|
|
44
41
|
def run
|
45
42
|
@installer.install_version(@version, @should_switch, @should_clean, @should_install,
|
46
|
-
|
43
|
+
@progress, @url)
|
47
44
|
end
|
48
45
|
end
|
49
46
|
end
|
data/lib/xcode/install/select.rb
CHANGED
@@ -17,7 +17,7 @@ module XcodeInstall
|
|
17
17
|
def validate!
|
18
18
|
super
|
19
19
|
|
20
|
-
fail Informative,
|
20
|
+
fail Informative, 'Please specify a version to select.' if @version.nil?
|
21
21
|
fail Informative, "Version #{@version} not installed." unless @installer.installed?(@version)
|
22
22
|
end
|
23
23
|
|
@@ -24,23 +24,24 @@ module XcodeInstall
|
|
24
24
|
:private
|
25
25
|
|
26
26
|
def install
|
27
|
-
filtered_simulators = @installed_xcodes.map
|
27
|
+
filtered_simulators = @installed_xcodes.map(&:available_simulators).flatten.select do |sim|
|
28
28
|
sim.version.to_s.start_with?(@install)
|
29
29
|
end
|
30
|
-
|
30
|
+
case filtered_simulators.count
|
31
|
+
when 0
|
31
32
|
puts "[!] No simulator matching #{@install} was found. Please specify a version from the following available simulators:".ansi.red
|
32
33
|
list
|
33
34
|
exit 1
|
34
|
-
|
35
|
+
when 1
|
35
36
|
simulator = filtered_simulators.first
|
36
37
|
fail Informative, "#{simulator.name} is already installed." if simulator.installed?
|
37
38
|
puts "Installing #{simulator.name} for Xcode #{simulator.xcode.bundle_version}..."
|
38
39
|
simulator.install
|
39
40
|
else
|
40
41
|
puts "[!] More than one simulator matching #{@install} was found. Please specify the full version.".ansi.red
|
41
|
-
filtered_simulators.each do |
|
42
|
-
puts "Xcode #{
|
43
|
-
puts "xcode-install
|
42
|
+
filtered_simulators.each do |candidate|
|
43
|
+
puts "Xcode #{candidate.xcode.bundle_version} (#{candidate.xcode.path})".ansi.green
|
44
|
+
puts "xcode-install candidate --install=#{candidate.version}"
|
44
45
|
end
|
45
46
|
exit 1
|
46
47
|
end
|
@@ -25,10 +25,9 @@ module XcodeInstall
|
|
25
25
|
|
26
26
|
`sudo rm -rf #{installed_path.path}`
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
28
|
+
return unless @installer.symlinks_to == installed_path.path
|
29
|
+
newest_version = @installer.installed_versions.last
|
30
|
+
@installer.symlink(newest_version)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -4,7 +4,7 @@ module XcodeInstall
|
|
4
4
|
describe Command::InstallCLITools do
|
5
5
|
it 'fails if tools are already installed' do
|
6
6
|
Command::InstallCLITools.any_instance.expects(:installed?).returns(true)
|
7
|
-
|
7
|
+
-> { Command::InstallCLITools.run }.should.raise(SystemExit)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'runs if tools are not installed' do
|
data/spec/curl_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module XcodeInstall
|
4
|
+
def self.silence_stderr
|
5
|
+
begin
|
6
|
+
orig_stderr = $stderr.clone
|
7
|
+
$stderr.reopen File.new('/dev/null', 'w')
|
8
|
+
retval = yield
|
9
|
+
ensure
|
10
|
+
$stderr.reopen orig_stderr
|
11
|
+
end
|
12
|
+
retval
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Curl do
|
16
|
+
it 'reports failure' do
|
17
|
+
`true`
|
18
|
+
curl = XcodeInstall::Curl.new
|
19
|
+
result = nil
|
20
|
+
XcodeInstall.silence_stderr do
|
21
|
+
result = curl.fetch('http://0.0.0.0/test')
|
22
|
+
end
|
23
|
+
result.should == false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<plist version="1.0">
|
2
|
+
<dict>
|
3
|
+
<key>system-entities</key>
|
4
|
+
<array>
|
5
|
+
<dict>
|
6
|
+
<key>content-hint</key>
|
7
|
+
<string>GUID_partition_scheme</string>
|
8
|
+
<key>dev-entry</key>
|
9
|
+
<string>/dev/disk2</string>
|
10
|
+
<key>potentially-mountable</key>
|
11
|
+
<false/>
|
12
|
+
<key>unmapped-content-hint</key>
|
13
|
+
<string>GUID_partition_scheme</string>
|
14
|
+
</dict>
|
15
|
+
<dict>
|
16
|
+
<key>content-hint</key>
|
17
|
+
<string>Apple_HFS</string>
|
18
|
+
<key>dev-entry</key>
|
19
|
+
<string>/dev/disk2s1</string>
|
20
|
+
<key>mount-point</key>
|
21
|
+
<string>/Volumes/XcodeME</string>
|
22
|
+
<key>potentially-mountable</key>
|
23
|
+
<true/>
|
24
|
+
<key>unmapped-content-hint</key>
|
25
|
+
<string>48465300-0000-11AA-AA11-00306543ECAC</string>
|
26
|
+
<key>volume-kind</key>
|
27
|
+
<string>hfs</string>
|
28
|
+
</dict>
|
29
|
+
</array>
|
30
|
+
</dict>
|
31
|
+
</plist>
|
data/spec/install_spec.rb
CHANGED
@@ -2,37 +2,47 @@ require File.expand_path('../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module XcodeInstall
|
4
4
|
describe Command::Install do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
describe 'when invoked' do
|
6
|
+
before do
|
7
|
+
Installer.any_instance.stubs(:exists).returns(true)
|
8
|
+
Installer.any_instance.stubs(:installed).returns([])
|
9
|
+
fixture = Pathname.new('spec/fixtures/xcode_63.json').read
|
10
|
+
xcode = Xcode.new(JSON.parse(fixture))
|
11
|
+
Installer.any_instance.stubs(:seedlist).returns([xcode])
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
it 'downloads and installs' do
|
15
|
+
Installer.any_instance.expects(:download).with('6.3', true, nil).returns('/some/path')
|
16
|
+
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
|
17
|
+
Command::Install.run(['6.3'])
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
it 'downloads and installs with custom HTTP URL' do
|
21
|
+
url = 'http://yolo.com/xcode.dmg'
|
22
|
+
Installer.any_instance.expects(:download).with('6.3', true, url).returns('/some/path')
|
23
|
+
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
|
24
|
+
Command::Install.run(['6.3', "--url=#{url}"])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'downloads and installs and does not switch if --no-switch given' do
|
28
|
+
Installer.any_instance.expects(:download).with('6.3', true, nil).returns('/some/path')
|
29
|
+
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', false, true)
|
30
|
+
Command::Install.run(['6.3', '--no-switch'])
|
31
|
+
end
|
25
32
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
it 'downloads without progress if switch --no-progress is given' do
|
34
|
+
Installer.any_instance.expects(:download).with('6.3', false, nil).returns('/some/path')
|
35
|
+
Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
|
36
|
+
Command::Install.run(['6.3', '--no-progress'])
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
|
-
it '
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
it 'parses hdiutil output' do
|
41
|
+
installer = Installer.new
|
42
|
+
fixture = Pathname.new('spec/fixtures/hdiutil.plist').read
|
43
|
+
installer.expects(:hdiutil).with('mount', '-plist', '-nobrowse', '-noverify', '/some/path').returns(fixture)
|
44
|
+
location = installer.send(:mount, Pathname.new('/some/path'))
|
45
|
+
location.should == '/Volumes/XcodeME'
|
36
46
|
end
|
37
47
|
end
|
38
48
|
end
|
data/xcode-install.gemspec
CHANGED
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = 'https://github.com/neonichu/xcode-install'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
+
spec.required_ruby_version = '>= 2.0.0'
|
17
|
+
|
16
18
|
spec.files = `git ls-files -z`.split("\x0")
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcode-install
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Bügling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -76,7 +76,6 @@ description: Download, install and upgrade Xcodes with ease.
|
|
76
76
|
email:
|
77
77
|
- boris@icculus.org
|
78
78
|
executables:
|
79
|
-
- xcode-install
|
80
79
|
- xcversion
|
81
80
|
- "\U0001F389"
|
82
81
|
extensions: []
|
@@ -85,12 +84,12 @@ files:
|
|
85
84
|
- ".gitattributes"
|
86
85
|
- ".gitignore"
|
87
86
|
- ".rubocop.yml"
|
87
|
+
- ".rubocop_todo.yml"
|
88
88
|
- ".travis.yml"
|
89
89
|
- Gemfile
|
90
90
|
- LICENSE.txt
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
|
-
- bin/xcode-install
|
94
93
|
- bin/xcversion
|
95
94
|
- "bin/\U0001F389"
|
96
95
|
- lib/xcode/install.rb
|
@@ -107,6 +106,7 @@ files:
|
|
107
106
|
- lib/xcode/install/update.rb
|
108
107
|
- lib/xcode/install/version.rb
|
109
108
|
- spec/cli_spec.rb
|
109
|
+
- spec/curl_spec.rb
|
110
110
|
- spec/fixtures/devcenter/xcode-20150414.html
|
111
111
|
- spec/fixtures/devcenter/xcode-20150427.html
|
112
112
|
- spec/fixtures/devcenter/xcode-20150508.html
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- spec/fixtures/devcenter/xcode-20150608.html
|
115
115
|
- spec/fixtures/devcenter/xcode-20150624.html
|
116
116
|
- spec/fixtures/devcenter/xcode-20150909.html
|
117
|
+
- spec/fixtures/hdiutil.plist
|
117
118
|
- spec/fixtures/xcode.json
|
118
119
|
- spec/fixtures/xcode_63.json
|
119
120
|
- spec/fixtures/yolo.json
|
@@ -136,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
137
|
requirements:
|
137
138
|
- - ">="
|
138
139
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
140
|
+
version: 2.0.0
|
140
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
142
|
requirements:
|
142
143
|
- - ">="
|
@@ -150,6 +151,7 @@ specification_version: 4
|
|
150
151
|
summary: Xcode installation manager.
|
151
152
|
test_files:
|
152
153
|
- spec/cli_spec.rb
|
154
|
+
- spec/curl_spec.rb
|
153
155
|
- spec/fixtures/devcenter/xcode-20150414.html
|
154
156
|
- spec/fixtures/devcenter/xcode-20150427.html
|
155
157
|
- spec/fixtures/devcenter/xcode-20150508.html
|
@@ -157,6 +159,7 @@ test_files:
|
|
157
159
|
- spec/fixtures/devcenter/xcode-20150608.html
|
158
160
|
- spec/fixtures/devcenter/xcode-20150624.html
|
159
161
|
- spec/fixtures/devcenter/xcode-20150909.html
|
162
|
+
- spec/fixtures/hdiutil.plist
|
160
163
|
- spec/fixtures/xcode.json
|
161
164
|
- spec/fixtures/xcode_63.json
|
162
165
|
- spec/fixtures/yolo.json
|