xcode-install 2.6.2 → 2.6.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4e45dbf2c73f7fe5538235f1d0e2a15133cbdcf3
4
- data.tar.gz: 10b891505b95ca2aae2ec5fbf5c81efd6670fa24
2
+ SHA256:
3
+ metadata.gz: 24b5d7d3549fb76b669aa736ff9c2cf5e0892131d2c8624e38555cac486f35e1
4
+ data.tar.gz: 0e2e82a56b815efe8659d3b00c26e426e720877fa7107fd3cc47e56ed7532ce3
5
5
  SHA512:
6
- metadata.gz: 13db8601597f362be77d74d9db24ccacbb5f8226f8c07da95491e940e44f71cc56936dc18a209ce8f81909c19ae2c30381b8fa92bfe10332ddebc9fcac2d0632
7
- data.tar.gz: 9f417f5336ca75d6c34b48154be3a8d9d6e066f1631fd98b02398756fe49fc3c78fb9f292ba580f3f43c40d099b5977c483ff6259f4477a45532ac9f16d80150
6
+ metadata.gz: e0924a4c6ab8e04733f66797cd52753e7f829cfc7d2e190ee9dfb0afe3b74d52e2bd5b835cecc038612417d82713ea96eb718a561ec3fb135c0e5a0519f0893a
7
+ data.tar.gz: b4664fae73d216b4e2b6a6ef82bd67ffdfd642f5420ed04b22fbb2706de6159a87bf236d2e9b1c1c622f559d053a26f6a56ed0133e002a8584577c1c6226afdc
data/.circleci/config.yml CHANGED
@@ -3,7 +3,7 @@ version: 2
3
3
  jobs:
4
4
  build:
5
5
  macos:
6
- xcode: "9.0"
6
+ xcode: "9.4.1"
7
7
  working_directory: ~/xcode-install
8
8
  shell: /bin/bash --login -eo pipefail
9
9
  steps:
@@ -0,0 +1,36 @@
1
+ name: "CI"
2
+ on: [pull_request]
3
+
4
+ jobs:
5
+ build:
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ ruby: ["2.5", "2.6"]
10
+
11
+ runs-on: macos-latest
12
+ steps:
13
+ # Setup env
14
+ - uses: actions/checkout@v2
15
+ - uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: "${{ matrix.ruby }}"
18
+
19
+ # Show env
20
+ - name: Show macOS version
21
+ run: sw_vers
22
+ - name: Show ruby version
23
+ run: |
24
+ ruby --version
25
+ bundler --version
26
+
27
+ # Prepare
28
+ - name: Install bundler 1.7
29
+ run: gem install bundler -v "~> 1.7"
30
+ - name: Install ruby dependencies
31
+ run: bundle install -j4 --clean --path=vendor
32
+
33
+ - name: Run test
34
+ run: bundle exec rake spec
35
+ - name: Run lint
36
+ run: bundle exec rake rubocop
@@ -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.2'.freeze
2
+ VERSION = '2.6.8'.freeze
3
3
  end
data/lib/xcode/install.rb CHANGED
@@ -8,8 +8,10 @@ require 'xcode/install/command'
8
8
  require 'xcode/install/version'
9
9
  require 'shellwords'
10
10
  require 'open3'
11
+ require 'fastlane'
12
+ require 'fastlane/helper/sh_helper'
11
13
  require 'fastlane/action'
12
- require 'fastlane/actions/verify_build'
14
+ require 'fastlane/actions/verify_xcode'
13
15
 
14
16
  module XcodeInstall
15
17
  CACHE_DIR = Pathname.new("#{ENV['HOME']}/Library/Caches/XcodeInstall")
@@ -23,13 +25,15 @@ module XcodeInstall
23
25
  # @param progress: parse and show the progress?
24
26
  # @param progress_block: A block that's called whenever we have an updated progress %
25
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
26
29
  # rubocop:disable Metrics/AbcSize
27
30
  def fetch(url: nil,
28
31
  directory: nil,
29
32
  cookies: nil,
30
33
  output: nil,
31
34
  progress: nil,
32
- progress_block: nil)
35
+ progress_block: nil,
36
+ retry_download_count: 3)
33
37
  options = cookies.nil? ? [] : ['--cookie', cookies, '--cookie-jar', COOKIES_PATH]
34
38
 
35
39
  uri = URI.parse(url)
@@ -76,7 +80,7 @@ module XcodeInstall
76
80
  # "Partial file. Only a part of the file was transferred."
77
81
  # https://curl.haxx.se/mail/archive-2008-07/0098.html
78
82
  # https://github.com/KrauseFx/xcode-install/issues/210
79
- 3.times do
83
+ retry_download_count.times do
80
84
  # Non-blocking call of Open3
81
85
  # We're not using the block based syntax, as the bacon testing
82
86
  # library doesn't seem to support writing tests for it
@@ -133,7 +137,7 @@ module XcodeInstall
133
137
  File.symlink?(SYMLINK_PATH) ? SYMLINK_PATH : nil
134
138
  end
135
139
 
136
- def download(version, progress, url = nil, progress_block = nil)
140
+ def download(version, progress, url = nil, progress_block = nil, retry_download_count = 3)
137
141
  xcode = find_xcode_version(version) if url.nil?
138
142
  return if url.nil? && xcode.nil?
139
143
 
@@ -145,7 +149,8 @@ module XcodeInstall
145
149
  cookies: url ? nil : spaceship.cookie,
146
150
  output: dmg_file,
147
151
  progress: progress,
148
- progress_block: progress_block
152
+ progress_block: progress_block,
153
+ retry_download_count: retry_download_count
149
154
  )
150
155
  result ? CACHE_DIR + dmg_file : nil
151
156
  end
@@ -166,8 +171,12 @@ module XcodeInstall
166
171
 
167
172
  seedlist.each do |current_seed|
168
173
  return current_seed if current_seed.name == version
174
+ end
175
+
176
+ seedlist.each do |current_seed|
169
177
  return current_seed if parsed_version && current_seed.version == parsed_version
170
178
  end
179
+
171
180
  nil
172
181
  end
173
182
 
@@ -208,7 +217,7 @@ module XcodeInstall
208
217
  current_xcode.installed = cached_installed_versions.include?(current_xcode.version)
209
218
  end
210
219
 
211
- all_xcodes.sort_by(&:version)
220
+ all_xcodes.sort_by { |seed| [seed.version, -seed.date_modified] }.reverse
212
221
  end
213
222
 
214
223
  def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
@@ -274,8 +283,8 @@ HELP
274
283
  end
275
284
 
276
285
  # rubocop:disable Metrics/ParameterLists
277
- def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil, show_release_notes = true, progress_block = nil)
278
- 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)
279
288
  fail Informative, "Failed to download Xcode #{version}." if dmg_path.nil?
280
289
 
281
290
  if install
@@ -294,17 +303,21 @@ HELP
294
303
  end
295
304
 
296
305
  def list_annotated(xcodes_list)
297
- installed = installed_versions.map(&:version)
306
+ installed = installed_versions.map(&:appname_version)
307
+
298
308
  xcodes_list.map do |x|
299
- xcode_version = x.split(' ').first # exclude "beta N", "for Lion".
300
- xcode_version << '.0' unless xcode_version.include?('.')
309
+ xcode_version = x.split(' ') # split version and "beta N", "for Lion"
310
+ xcode_version[0] << '.0' unless xcode_version[0].include?('.')
301
311
 
302
- installed.include?(xcode_version) ? "#{x} (installed)" : x
312
+ # to match InstalledXcode.appname_version format
313
+ version = Gem::Version.new(xcode_version.join('.'))
314
+
315
+ installed.include?(version) ? "#{x} (installed)" : x
303
316
  end.join("\n")
304
317
  end
305
318
 
306
319
  def list
307
- list_annotated(list_versions.sort_by(&:to_f))
320
+ list_annotated(list_versions.sort { |first, second| compare_versions(first, second) })
308
321
  end
309
322
 
310
323
  def rm_list_cache
@@ -360,7 +373,7 @@ HELP
360
373
  `sudo /usr/sbin/dseditgroup -o edit -t group -a staff _developer`
361
374
  end
362
375
 
363
- 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)
364
377
  if url
365
378
  path = Pathname.new(url)
366
379
  return path if path.exist?
@@ -371,7 +384,7 @@ HELP
371
384
  end
372
385
  end
373
386
 
374
- download(version, progress, url, progress_block)
387
+ download(version, progress, url, progress_block, retry_download_count)
375
388
  end
376
389
 
377
390
  def fetch_seedlist
@@ -451,6 +464,35 @@ HELP
451
464
  links
452
465
  end
453
466
 
467
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
468
+ def compare_versions(first, second)
469
+ # Sort by version number
470
+ numeric_comparation = first.to_f <=> second.to_f
471
+ return numeric_comparation if numeric_comparation != 0
472
+
473
+ # Return beta versions before others
474
+ is_first_beta = first.include?('beta')
475
+ is_second_beta = second.include?('beta')
476
+ return -1 if is_first_beta && !is_second_beta
477
+ return 1 if !is_first_beta && is_second_beta
478
+
479
+ # Return GM versions before others
480
+ is_first_gm = first.include?('GM')
481
+ is_second_gm = second.include?('GM')
482
+ return -1 if is_first_gm && !is_second_gm
483
+ return 1 if !is_first_gm && is_second_gm
484
+
485
+ # Return Release Candidate versions before others
486
+ is_first_rc = first.include?('RC') || first.include?('Release Candidate')
487
+ is_second_rc = second.include?('RC') || second.include?('Release Candidate')
488
+ return -1 if is_first_rc && !is_second_rc
489
+ return 1 if !is_first_rc && is_second_rc
490
+
491
+ # Sort alphabetically
492
+ first <=> second
493
+ end
494
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
495
+
454
496
  def hdiutil(*args)
455
497
  io = IO.popen(['hdiutil', *args])
456
498
  result = io.read
@@ -502,12 +544,13 @@ HELP
502
544
  end
503
545
  end
504
546
 
505
- def download(progress, progress_block = nil)
547
+ def download(progress, progress_block = nil, retry_download_count = 3)
506
548
  result = Curl.new.fetch(
507
549
  url: source,
508
550
  directory: CACHE_DIR,
509
551
  progress: progress,
510
- progress_block: progress_block
552
+ progress_block: progress_block,
553
+ retry_download_count: retry_download_count
511
554
  )
512
555
  result ? dmg_path : nil
513
556
  end
@@ -576,9 +619,6 @@ HELP
576
619
  end
577
620
 
578
621
  class InstalledXcode
579
- TEAM_IDENTIFIER = '59GAB85EFG'.freeze
580
- AUTHORITY = 'Software Signing'.freeze
581
-
582
622
  attr_reader :path
583
623
  attr_reader :version
584
624
  attr_reader :bundle_version
@@ -598,6 +638,17 @@ HELP
598
638
  @bundle_version ||= Gem::Version.new(bundle_version_string)
599
639
  end
600
640
 
641
+ def appname_version
642
+ appname = @path.basename('.app').to_s
643
+ version_string = appname.split('-').last
644
+ begin
645
+ Gem::Version.new(version_string)
646
+ rescue ArgumentError
647
+ puts 'Unable to determine Xcode version from path name, installed list may not correctly identify installed betas'
648
+ Gem::Version.new(nil)
649
+ end
650
+ end
651
+
601
652
  def uuid
602
653
  @uuid ||= plist_entry(':DVTPlugInCompatibilityUUID')
603
654
  end
@@ -687,10 +738,10 @@ HELP
687
738
  end
688
739
 
689
740
  def verify_app_cert
690
- cert_info = Fastlane::Actions::VerifyBuildAction.gather_cert_info(@path.to_s)
691
- apple_team_identifier_result = cert_info['team_identifier'] == TEAM_IDENTIFIER
692
- apple_authority_result = cert_info['authority'].include?(AUTHORITY)
693
- apple_team_identifier_result && apple_authority_result
741
+ Fastlane::Actions::VerifyXcodeAction.run(xcode_path: @path.to_s)
742
+ true
743
+ rescue
744
+ false
694
745
  end
695
746
  end
696
747
 
@@ -699,7 +750,7 @@ HELP
699
750
  #
700
751
  # Sample object:
701
752
  # <XcodeInstall::Xcode:0x007fa1d451c390
702
- # @date_modified=2015,
753
+ # @date_modified=1573661580,
703
754
  # @name="6.4",
704
755
  # @path="/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg",
705
756
  # @url=
@@ -722,7 +773,7 @@ HELP
722
773
 
723
774
  def initialize(json, url = nil, release_notes_url = nil)
724
775
  if url.nil?
725
- @date_modified = json['dateModified'].to_i
776
+ @date_modified = DateTime.strptime(json['dateModified'], '%m/%d/%y %H:%M').strftime('%s').to_i
726
777
  @name = json['name'].gsub(/^Xcode /, '')
727
778
  @path = json['files'].first['remotePath']
728
779
  url_prefix = 'https://developer.apple.com/devcenter/download.action?path='
@@ -754,6 +805,7 @@ HELP
754
805
 
755
806
  def self.new_prerelease(version, url, release_notes_path)
756
807
  new('name' => version,
808
+ 'dateModified' => '01/01/70 00:00',
757
809
  'files' => [{ 'remotePath' => url.split('=').last }],
758
810
  'release_notes_path' => release_notes_path)
759
811
  end
@@ -1 +1,30 @@
1
- {"active":true,"availableInMemberSite":true,"categories":[{"active":null,"dateCreated":1052825460000,"dateModified":1079108316000,"enabled":true,"id":187,"name":"Developer Tools","sortOrder":28}],"dateAvailable":null,"dateCreated":1413472373000,"dateDisabled":null,"dateModified":1413472373000,"description":"This package enables UNIX-style development via Terminal by installing command line developer tools, as well as Mac OS X SDK frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these tools are also embedded within the Xcode IDE.","files":[{"active":true,"dateCreated":1413472373000,"dateModified":1413472373000,"fileSize":107698152,"format":{"active":null,"dateCreated":1066327569000,"dateModified":null,"description":"Disk Image","extension":".dmg","id":12},"id":33285,"name":"Command Line Tools for OSX 10.9 for Xcode 6.1","remotePath":"/Developer_Tools/command_line_tools_os_x_10.9_for_xcode__xcode_6.1/command_line_tools_for_osx_10.9_for_xcode_6.1.dmg","sortOrder":1,"state":"ENABLED"}],"id":21958,"name":"Command Line Tools (OS X 10.9) for Xcode - Xcode 6.1","prerelease":false,"releasedSeed":true,"state":"ENABLED"}
1
+ {
2
+ "name": "Xcode 9.3",
3
+ "description": "This is the complete Xcode developer toolset for Apple Watch, Apple TV, iPhone, iPad, and Mac. It includes the Xcode IDE, iOS Simulator, and all required tools and frameworks for building iOS, watchOS, tvOS and macOS apps.",
4
+ "isReleased": 1,
5
+ "datePublished": "03/23/18 09:47",
6
+ "dateCreated": "11/01/19 12:00",
7
+ "dateModified": "11/01/19 12:58",
8
+ "categories": [
9
+ {
10
+ "id": 187,
11
+ "name": "Developer Tools",
12
+ "sortOrder": 28
13
+ }
14
+ ],
15
+ "files": [
16
+ {
17
+ "filename": "Xcode 9.3.xip",
18
+ "displayName": "Xcode 9.3",
19
+ "remotePath": "/Developer_Tools/Xcode_9.3/Xcode_9.3.xip",
20
+ "fileSize": 5235094775,
21
+ "sortOrder": 0,
22
+ "dateCreated": "11/01/19 19:00",
23
+ "dateModified": "11/01/19 19:58",
24
+ "fileFormat": {
25
+ "extension": ".xip",
26
+ "description": "XIP"
27
+ }
28
+ }
29
+ ]
30
+ }
@@ -1,46 +1,30 @@
1
1
  {
2
- "active": true,
3
- "availableInMemberSite": true,
4
- "categories": [
5
- {
6
- "active": null,
7
- "dateCreated": 1052825460000,
8
- "dateModified": 1079108316000,
9
- "enabled": true,
10
- "id": 187,
11
- "name": "Developer Tools",
12
- "sortOrder": 28
13
- }
14
- ],
15
- "dateAvailable": null,
16
- "dateCreated": 1425695047000,
17
- "dateDisabled": null,
18
- "dateModified": 1425943753000,
19
- "description": "This is the complete Xcode developer toolset for Mac, iPhone, and iPad. It includes the Xcode IDE, iOS Simulator, and all required tools and frameworks for building OS X and iOS apps.",
20
- "files": [
21
- {
22
- "active": true,
23
- "dateCreated": 1425696402000,
24
- "dateModified": 1425929405000,
25
- "fileSize": 2778059898,
26
- "format": {
27
- "active": null,
28
- "dateCreated": 1066327569000,
29
- "dateModified": null,
30
- "description": "Disk Image",
31
- "extension": ".dmg",
32
- "id": 12
33
- },
34
- "id": 35240,
35
- "name": "Xcode 6.3",
36
- "remotePath": "/Developer_Tools/Xcode_6.2/Xcode_6.2.dmg",
37
- "sortOrder": null,
38
- "state": "ENABLED"
39
- }
40
- ],
41
- "id": 23600,
42
- "name": "Xcode 6.3",
43
- "prerelease": false,
44
- "releasedSeed": true,
45
- "state": "ENABLED"
2
+ "name": "Xcode 6.3",
3
+ "description": "This is the complete Xcode developer toolset for Apple Watch, iPhone, iPad, and Mac. It includes the Xcode IDE, iOS Simulator, and all required tools and frameworks for building OS X and iOS apps.",
4
+ "isReleased": 1,
5
+ "datePublished": "04/08/15 14:36",
6
+ "dateCreated": "12/11/19 13:41",
7
+ "dateModified": "12/11/19 14:28",
8
+ "categories": [
9
+ {
10
+ "id": 187,
11
+ "name": "Developer Tools",
12
+ "sortOrder": 28
13
+ }
14
+ ],
15
+ "files": [
16
+ {
17
+ "filename": "Xcode 6.3.dmg",
18
+ "displayName": "Xcode 6.3",
19
+ "remotePath": "/Developer_Tools/Xcode_6.3/Xcode_6.3.dmg",
20
+ "fileSize": 2685818165,
21
+ "sortOrder": 0,
22
+ "dateCreated": "12/11/19 21:41",
23
+ "dateModified": "12/11/19 22:28",
24
+ "fileFormat": {
25
+ "extension": ".dmg",
26
+ "description": "Disk Image"
27
+ }
28
+ }
29
+ ]
46
30
  }