xcode-install 2.6.6 → 2.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cd94bd1afd9e9d5fc6d01b1f167635f58159086547a8d571e4f57a76b1761b8
4
- data.tar.gz: 0f4c8b091b0aef11748f63e2dc93f8245820083916c33107575c2a9cab80a4b0
3
+ metadata.gz: 0fea81231fe9d81aed11e53e9340d8749cb90b12b61cf455ef216c4659beaf85
4
+ data.tar.gz: d385404265a3453ff25f3f6c2c532235ca7ed9769e0c1b808c64749f930f6eca
5
5
  SHA512:
6
- metadata.gz: 64c8de1910492324f460a076e535f344c29f7ccde90e1e57221ec7ff08f497abccbf4c448526306cd9d5a81289cf1a74f851b092ac201a3a2037004cac4b9907
7
- data.tar.gz: 9861106b901b9ebdfb8b4cd2196e1469bedb401f9e00e9844149c935ca4d737cc4552a36f1bfe2f3605e146bcab79e92752c846a755bd7e25e526355a81a8603
6
+ metadata.gz: 4147ef290648e0f0ac2122be32a2cc0d4fd26d3c9509767661107527fe20e58534bab89c505d992a876202a40effa7913b3901e24f504952839e5f416d011503
7
+ data.tar.gz: fa470926afe6472b552bd7be37619542024913101997df6e00a47064714199594c6c0dafbf1a41c07aa79ea1cb22e35f3cca75a1bbce8bb068b9453ec7bc6a6d
@@ -25,13 +25,15 @@ module XcodeInstall
25
25
  # @param progress: parse and show the progress?
26
26
  # @param progress_block: A block that's called whenever we have an updated progress %
27
27
  # the parameter is a single number that's literally percent (e.g. 1, 50, 80 or 100)
28
+ # @param retry_download_count: A count to retry the downloading Xcode dmg/xip
28
29
  # rubocop:disable Metrics/AbcSize
29
30
  def fetch(url: nil,
30
31
  directory: nil,
31
32
  cookies: nil,
32
33
  output: nil,
33
34
  progress: nil,
34
- progress_block: nil)
35
+ progress_block: nil,
36
+ retry_download_count: 3)
35
37
  options = cookies.nil? ? [] : ['--cookie', cookies, '--cookie-jar', COOKIES_PATH]
36
38
 
37
39
  uri = URI.parse(url)
@@ -78,7 +80,7 @@ module XcodeInstall
78
80
  # "Partial file. Only a part of the file was transferred."
79
81
  # https://curl.haxx.se/mail/archive-2008-07/0098.html
80
82
  # https://github.com/KrauseFx/xcode-install/issues/210
81
- 3.times do
83
+ retry_download_count.times do
82
84
  # Non-blocking call of Open3
83
85
  # We're not using the block based syntax, as the bacon testing
84
86
  # library doesn't seem to support writing tests for it
@@ -135,7 +137,7 @@ module XcodeInstall
135
137
  File.symlink?(SYMLINK_PATH) ? SYMLINK_PATH : nil
136
138
  end
137
139
 
138
- def download(version, progress, url = nil, progress_block = nil)
140
+ def download(version, progress, url = nil, progress_block = nil, retry_download_count = 3)
139
141
  xcode = find_xcode_version(version) if url.nil?
140
142
  return if url.nil? && xcode.nil?
141
143
 
@@ -147,7 +149,8 @@ module XcodeInstall
147
149
  cookies: url ? nil : spaceship.cookie,
148
150
  output: dmg_file,
149
151
  progress: progress,
150
- progress_block: progress_block
152
+ progress_block: progress_block,
153
+ retry_download_count: retry_download_count
151
154
  )
152
155
  result ? CACHE_DIR + dmg_file : nil
153
156
  end
@@ -280,8 +283,8 @@ HELP
280
283
  end
281
284
 
282
285
  # rubocop:disable Metrics/ParameterLists
283
- def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil, show_release_notes = true, progress_block = nil)
284
- dmg_path = get_dmg(version, progress, url, progress_block)
286
+ def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil, show_release_notes = true, progress_block = nil, retry_download_count = 3)
287
+ dmg_path = get_dmg(version, progress, url, progress_block, retry_download_count)
285
288
  fail Informative, "Failed to download Xcode #{version}." if dmg_path.nil?
286
289
 
287
290
  if install
@@ -314,7 +317,7 @@ HELP
314
317
  end
315
318
 
316
319
  def list
317
- list_annotated(list_versions.sort_by(&:to_f))
320
+ list_annotated(list_versions.sort { |first, second| compare_versions(first, second) })
318
321
  end
319
322
 
320
323
  def rm_list_cache
@@ -370,7 +373,7 @@ HELP
370
373
  `sudo /usr/sbin/dseditgroup -o edit -t group -a staff _developer`
371
374
  end
372
375
 
373
- def get_dmg(version, progress = true, url = nil, progress_block = nil)
376
+ def get_dmg(version, progress = true, url = nil, progress_block = nil, retry_download_count = 3)
374
377
  if url
375
378
  path = Pathname.new(url)
376
379
  return path if path.exist?
@@ -381,7 +384,7 @@ HELP
381
384
  end
382
385
  end
383
386
 
384
- download(version, progress, url, progress_block)
387
+ download(version, progress, url, progress_block, retry_download_count)
385
388
  end
386
389
 
387
390
  def fetch_seedlist
@@ -461,6 +464,27 @@ HELP
461
464
  links
462
465
  end
463
466
 
467
+ def compare_versions(first, second)
468
+ # Sort by version number
469
+ numeric_comparation = first.to_f <=> second.to_f
470
+ return numeric_comparation if numeric_comparation != 0
471
+
472
+ # Return beta versions before others
473
+ is_first_beta = first.include?('beta')
474
+ is_second_beta = second.include?('beta')
475
+ return -1 if is_first_beta && !is_second_beta
476
+ return 1 if !is_first_beta && is_second_beta
477
+
478
+ # Return GM versions before others
479
+ is_first_gm = first.include?('GM')
480
+ is_second_gm = second.include?('GM')
481
+ return -1 if is_first_gm && !is_second_gm
482
+ return 1 if !is_first_gm && is_second_gm
483
+
484
+ # Sort alphabetically
485
+ first <=> second
486
+ end
487
+
464
488
  def hdiutil(*args)
465
489
  io = IO.popen(['hdiutil', *args])
466
490
  result = io.read
@@ -512,12 +536,13 @@ HELP
512
536
  end
513
537
  end
514
538
 
515
- def download(progress, progress_block = nil)
539
+ def download(progress, progress_block = nil, retry_download_count = 3)
516
540
  result = Curl.new.fetch(
517
541
  url: source,
518
542
  directory: CACHE_DIR,
519
543
  progress: progress,
520
- progress_block: progress_block
544
+ progress_block: progress_block,
545
+ retry_download_count: retry_download_count
521
546
  )
522
547
  result ? dmg_path : nil
523
548
  end
@@ -17,7 +17,8 @@ module XcodeInstall
17
17
  ['--no-install', 'Only download DMG, but do not install it.'],
18
18
  ['--no-progress', 'Don’t show download progress.'],
19
19
  ['--no-clean', 'Don’t delete DMG after installation.'],
20
- ['--no-show-release-notes', 'Don’t open release notes in browser after installation.']].concat(super)
20
+ ['--no-show-release-notes', 'Don’t open release notes in browser after installation.'],
21
+ ['--retry-download-count', 'Count of retrying download when curl is failed.']].concat(super)
21
22
  end
22
23
 
23
24
  def initialize(argv)
@@ -31,6 +32,7 @@ module XcodeInstall
31
32
  @should_switch = argv.flag?('switch', true)
32
33
  @progress = argv.flag?('progress', true)
33
34
  @show_release_notes = argv.flag?('show-release-notes', true)
35
+ @retry_download_count = argv.option('retry-download-count', '3')
34
36
  super
35
37
  end
36
38
 
@@ -44,11 +46,12 @@ module XcodeInstall
44
46
  end
45
47
  fail Informative, "Version #{@version} doesn't exist." unless @url || @installer.exist?(@version)
46
48
  fail Informative, "Invalid URL: `#{@url}`" unless !@url || @url =~ /\A#{URI.regexp}\z/
49
+ fail Informative, "Invalid Retry: `#{@retry_download_count} is not positive number.`" if (@retry_download_count =~ /\A[0-9]*\z/).nil?
47
50
  end
48
51
 
49
52
  def run
50
53
  @installer.install_version(@version, @should_switch, @should_clean, @should_install,
51
- @progress, @url, @show_release_notes)
54
+ @progress, @url, @show_release_notes, nil, @retry_download_count.to_i)
52
55
  end
53
56
  end
54
57
  end
@@ -1,3 +1,3 @@
1
1
  module XcodeInstall
2
- VERSION = '2.6.6'.freeze
2
+ VERSION = '2.6.7'.freeze
3
3
  end
@@ -12,32 +12,32 @@ module XcodeInstall
12
12
  end
13
13
 
14
14
  it 'downloads and installs' do
15
- Installer.any_instance.expects(:download).with('6.3', true, nil, nil).returns('/some/path')
15
+ Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
16
16
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
17
17
  Command::Install.run(['6.3'])
18
18
  end
19
19
 
20
20
  it 'downloads and installs with custom HTTP URL' do
21
21
  url = 'http://yolo.com/xcode.dmg'
22
- Installer.any_instance.expects(:download).with('6.3', true, url, nil).returns('/some/path')
22
+ Installer.any_instance.expects(:download).with('6.3', true, url, nil, 3).returns('/some/path')
23
23
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
24
24
  Command::Install.run(['6.3', "--url=#{url}"])
25
25
  end
26
26
 
27
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, nil).returns('/some/path')
28
+ Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
29
29
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', false, true)
30
30
  Command::Install.run(['6.3', '--no-switch'])
31
31
  end
32
32
 
33
33
  it 'downloads without progress if switch --no-progress is given' do
34
- Installer.any_instance.expects(:download).with('6.3', false, nil, nil).returns('/some/path')
34
+ Installer.any_instance.expects(:download).with('6.3', false, nil, nil, 3).returns('/some/path')
35
35
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
36
36
  Command::Install.run(['6.3', '--no-progress'])
37
37
  end
38
38
 
39
39
  it 'reads .xcode-version' do
40
- Installer.any_instance.expects(:download).with('6.3', true, nil, nil).returns('/some/path')
40
+ Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
41
41
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
42
42
  File.expects(:exist?).with('.xcode-version').returns(true)
43
43
  File.expects(:read).returns('6.3')
@@ -20,14 +20,14 @@ module XcodeInstall
20
20
  installer.stubs(:xcodes).returns(seedlist)
21
21
 
22
22
  versions = [
23
- '4.3 for Lion', '4.3.1 for Lion', '4.3.2 for Lion', '4.3.3 for Lion', '4.4.1', '4.5', '4.6.2', '4.6', '4.6.1', '4.6.3',
24
- '5.0.1', '5', '5.0.2', '5.1', '5.1.1',
23
+ '4.3 for Lion', '4.3.1 for Lion', '4.3.2 for Lion', '4.3.3 for Lion', '4.4.1', '4.5', '4.6', '4.6.1', '4.6.2', '4.6.3',
24
+ '5', '5.0.1', '5.0.2', '5.1', '5.1.1',
25
25
  '6.0.1', '6.1', '6.1.1', '6.2', '6.3', '6.3.1', '6.3.2', '6.4',
26
- '7', '7.0.1', '7.1', '7.1.1', '7.2.1', '7.2', '7.3', '7.3.1',
27
- '8', '8.1', '8.2', '8.2.1', '8.3.2', '8.3.3', '8.3',
26
+ '7', '7.0.1', '7.1', '7.1.1', '7.2', '7.2.1', '7.3', '7.3.1',
27
+ '8', '8.1', '8.2', '8.2.1', '8.3', '8.3.2', '8.3.3',
28
28
  '9', '9.0.1', '9.1', '9.2', '9.3', '9.3.1', '9.4', '9.4.1',
29
- '10', '10.1', '10.2.1', '10.2', '10.3',
30
- '11', '11.1', '11.2', '11.2.1', '11.3 beta', '11.3', '11.3.1', '11.4 beta', '11.4', '11.4 beta 3', '11.4 beta 2', '11.4.1', '11.5 beta 2', '11.5', '11.5 GM Seed', '11.5 beta'
29
+ '10', '10.1', '10.2', '10.2.1', '10.3',
30
+ '11', '11.1', '11.2', '11.2.1', '11.3 beta', '11.3', '11.3.1', '11.4 beta', '11.4 beta 2', '11.4 beta 3', '11.4', '11.4.1', '11.5 beta', '11.5 beta 2', '11.5 GM Seed', '11.5'
31
31
  ]
32
32
  installer.list.split("\n").should == versions
33
33
  end
@@ -43,7 +43,23 @@ module XcodeInstall
43
43
  it 'lists all versions' do
44
44
  fake_xcodes '1', '2.3', '2.3.1', '2.3.2', '3 some', '4 beta', '10 beta'
45
45
  fake_installed_xcodes
46
- installer.list.should == "1\n2.3.2\n2.3.1\n2.3\n3 some\n4 beta\n10 beta"
46
+ installer.list.should == "1\n2.3\n2.3.1\n2.3.2\n3 some\n4 beta\n10 beta"
47
+ end
48
+
49
+ it 'lists all versions in the correct order' do
50
+ fake_xcodes(
51
+ '12 beta 4', '12 beta 3', '12 beta 2', '12 for macOS Universal Apps beta 2',
52
+ '12 beta', '12 for macOS Universal Apps beta', '12.0.1', '12', '12 beta 6',
53
+ '12 beta 5', '12.1 GM seed', '12.2 beta 3', '12.2 beta', '12.2 beta 2'
54
+ )
55
+ fake_installed_xcodes
56
+
57
+ versions = [
58
+ '12 beta', '12 beta 2', '12 beta 3', '12 beta 4', '12 beta 5', '12 beta 6',
59
+ '12 for macOS Universal Apps beta', '12 for macOS Universal Apps beta 2',
60
+ '12', '12.0.1', '12.1 GM seed', '12.2 beta', '12.2 beta 2', '12.2 beta 3'
61
+ ]
62
+ installer.list.split("\n").should == versions
47
63
  end
48
64
  end
49
65
 
@@ -51,7 +67,7 @@ module XcodeInstall
51
67
  it 'lists all versions with annotations' do
52
68
  fake_xcodes '1', '2.3', '2.3.1', '2.3.2', '3 some', '4.3.1 for Lion', '9.4.1', '10 beta'
53
69
  fake_installed_xcodes '2.3', '4.3.1 for Lion', '10 beta'
54
- installer.list.should == "1\n2.3.2\n2.3.1\n2.3 (installed)\n3 some\n4.3.1 for Lion (installed)\n9.4.1\n10 beta (installed)"
70
+ installer.list.should == "1\n2.3 (installed)\n2.3.1\n2.3.2\n3 some\n4.3.1 for Lion (installed)\n9.4.1\n10 beta (installed)"
55
71
  end
56
72
 
57
73
  it 'distinguish between beta and official_version' do
@@ -61,9 +77,9 @@ module XcodeInstall
61
77
  end
62
78
 
63
79
  it 'distinguish each beta versions' do
64
- fake_xcodes '11.4 beta', '11.4 beta 3'
80
+ fake_xcodes '11.4 beta 3', '11.4 beta'
65
81
  fake_installed_xcodes '11.4 beta'
66
- installer.list.should == "11.4 beta 3\n11.4 beta (installed)"
82
+ installer.list.should == "11.4 beta (installed)\n11.4 beta 3"
67
83
  end
68
84
  end
69
85
  end
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: 2.6.6
4
+ version: 2.6.7
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: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide