branch_io_cli 0.4.1 → 0.4.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/lib/branch_io_cli/helper/configuration_helper.rb +54 -47
- data/lib/branch_io_cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b2291799982aa8205535d5f28f0b4b372c2726b
|
4
|
+
data.tar.gz: 9986e2a7e85b74827fda5c4abd30a6b979d1b137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e51e2863451a8deebb9fad4046a797893dcc776ec1eaa88c80fc13d2ea2af6f59fd9594fd88dc0a92a5dc1514b27b73d56bad4f0ab0f8f772e6ef5f8d7707e3a
|
7
|
+
data.tar.gz: 06e4ecb04f1c65eee5636eb1d1dc7f6776ac50d73b511bfd7d47b50f415465d7f24d105c419c7506823a00a18039d28f161371bfd6ffc90f6c6f0b733b1c1e85
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "json"
|
2
2
|
require "net/http"
|
3
3
|
require "pathname"
|
4
|
+
require "tmpdir"
|
4
5
|
require "xcodeproj"
|
5
6
|
require "zip"
|
6
7
|
|
@@ -57,7 +58,6 @@ EOF
|
|
57
58
|
|
58
59
|
def print_setup_configuration
|
59
60
|
say <<EOF
|
60
|
-
|
61
61
|
<%= color('Configuration:', BOLD) %>
|
62
62
|
|
63
63
|
<%= color('Xcode project:', BOLD) %> #{@xcodeproj_path}
|
@@ -291,7 +291,7 @@ EOF
|
|
291
291
|
|
292
292
|
# If no CocoaPods or Carthage, check to see if the framework is linked.
|
293
293
|
target = BranchHelper.target_from_project @xcodeproj, options.target
|
294
|
-
return if target.frameworks_build_phase.files.map(&:file_ref).map(&:path).any? { |p| p =~
|
294
|
+
return if target.frameworks_build_phase.files.map(&:file_ref).map(&:path).any? { |p| p =~ /Branch.framework$/ }
|
295
295
|
|
296
296
|
# --podfile, --cartfile not specified. No Podfile found. No Cartfile found. No Branch.framework in project.
|
297
297
|
# Prompt the user:
|
@@ -388,12 +388,12 @@ EOF
|
|
388
388
|
end
|
389
389
|
|
390
390
|
def add_direct(options)
|
391
|
-
#
|
392
|
-
|
393
|
-
File.
|
394
|
-
|
391
|
+
# Put the framework in the path for any existing Frameworks group in the project.
|
392
|
+
frameworks_group = @xcodeproj.frameworks_group
|
393
|
+
framework_path = File.join frameworks_group.real_path, "Branch.framework"
|
394
|
+
raise "#{framework_path} exists." if File.exist? framework_path
|
395
395
|
|
396
|
-
say "Finding current framework release
|
396
|
+
say "Finding current framework release"
|
397
397
|
|
398
398
|
# Find the latest release from GitHub.
|
399
399
|
releases = JSON.parse fetch "https://api.github.com/repos/BranchMetrics/ios-branch-deep-linking/releases"
|
@@ -402,50 +402,52 @@ EOF
|
|
402
402
|
framework_asset = current_release["assets"][0]
|
403
403
|
framework_url = framework_asset["browser_download_url"]
|
404
404
|
|
405
|
-
say "Downloading Branch.framework v. #{current_release['tag_name']} (#{framework_asset['size']} bytes zipped)
|
405
|
+
say "Downloading Branch.framework v. #{current_release['tag_name']} (#{framework_asset['size']} bytes zipped)"
|
406
|
+
|
407
|
+
Dir.mktmpdir do |download_folder|
|
408
|
+
zip_path = File.join download_folder, "Branch.framework.zip"
|
406
409
|
|
407
|
-
|
408
|
-
download framework_url, "Branch.framework.zip"
|
410
|
+
File.unlink zip_path if File.exist? zip_path
|
409
411
|
|
410
|
-
|
412
|
+
# Download the framework zip
|
413
|
+
download framework_url, zip_path
|
411
414
|
|
412
|
-
|
413
|
-
|
414
|
-
#
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
415
|
+
say "Unzipping Branch.framework"
|
416
|
+
|
417
|
+
# Unzip
|
418
|
+
Zip::File.open zip_path do |zip_file|
|
419
|
+
# Start with just the framework and add dSYM, etc., later
|
420
|
+
zip_file.glob "Carthage/Build/iOS/Branch.framework/**/*" do |entry|
|
421
|
+
filename = entry.name.sub %r{^Carthage/Build/iOS}, frameworks_group.real_path.to_s
|
422
|
+
ensure_directory File.dirname filename
|
423
|
+
entry.extract filename
|
424
|
+
end
|
419
425
|
end
|
420
426
|
end
|
421
427
|
|
422
|
-
#
|
423
|
-
File.unlink "Branch.framework.zip"
|
428
|
+
# Now the current framework is in framework_path
|
424
429
|
|
425
|
-
|
426
|
-
|
427
|
-
say "Adding to #{@xcodeproj_path}..."
|
430
|
+
say "Adding to #{@xcodeproj_path}"
|
428
431
|
|
429
432
|
# Add as a dependency in the Frameworks group
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
setting << "$(SRCROOT)"
|
442
|
-
config.build_settings["FRAMEWORK_SEARCH_PATHS"] = setting
|
433
|
+
framework = frameworks_group.new_file "Branch.framework" # relative to frameworks_group.real_path
|
434
|
+
@target.frameworks_build_phase.add_file_reference framework, true
|
435
|
+
|
436
|
+
# Make sure this is in the FRAMEWORK_SEARCH_PATHS if we just added it.
|
437
|
+
if frameworks_group.files.count == 1
|
438
|
+
@target.build_configurations.each do |config|
|
439
|
+
paths = config.build_settings["FRAMEWORK_SEARCH_PATHS"] || []
|
440
|
+
next if paths.any? { |p| p == '$(SRCROOT)' || p == '$(SRCROOT)/**' }
|
441
|
+
paths << '$(SRCROOT)'
|
442
|
+
config.build_settings["FRAMEWORK_SEARCH_PATHS"] = paths
|
443
|
+
end
|
443
444
|
end
|
445
|
+
# If it already existed, it's almost certainly already in FRAMEWORK_SEARCH_PATHS.
|
444
446
|
|
445
447
|
@xcodeproj.save
|
446
448
|
|
447
|
-
BranchHelper.add_change
|
448
|
-
`git add
|
449
|
+
BranchHelper.add_change framework_path
|
450
|
+
`git add #{framework_path}` if options.commit
|
449
451
|
|
450
452
|
say "Done. ✅"
|
451
453
|
end
|
@@ -472,11 +474,25 @@ EOF
|
|
472
474
|
http.request request do |response|
|
473
475
|
case response
|
474
476
|
when Net::HTTPSuccess
|
477
|
+
bytes_downloaded = 0
|
478
|
+
dots_reported = 0
|
479
|
+
# report a dot every 100 kB
|
480
|
+
per_dot = 102_400
|
481
|
+
|
475
482
|
File.open dest, 'w' do |io|
|
476
483
|
response.read_body do |chunk|
|
477
484
|
io.write chunk
|
485
|
+
|
486
|
+
# print progress
|
487
|
+
bytes_downloaded += chunk.length
|
488
|
+
while (bytes_downloaded - per_dot * dots_reported) >= per_dot
|
489
|
+
print "."
|
490
|
+
dots_reported += 1
|
491
|
+
end
|
492
|
+
STDOUT.flush
|
478
493
|
end
|
479
494
|
end
|
495
|
+
say "\n"
|
480
496
|
when Net::HTTPRedirection
|
481
497
|
download response['location'], dest
|
482
498
|
else
|
@@ -494,15 +510,6 @@ EOF
|
|
494
510
|
Dir.mkdir path
|
495
511
|
end
|
496
512
|
|
497
|
-
def remove_directory(path)
|
498
|
-
return unless File.exist? path
|
499
|
-
|
500
|
-
Dir["#{path}/*"].each do |file|
|
501
|
-
remove_directory(file) and next if File.directory?(file)
|
502
|
-
File.unlink file
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
513
|
SDK_OPTIONS =
|
507
514
|
{
|
508
515
|
"Set this project up to use CocoaPods and add the Branch SDK." => :cocoapods,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: branch_io_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Branch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-10-
|
12
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|