cocoapods-deploy 0.0.4 → 0.0.5

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
2
  SHA1:
3
- metadata.gz: 4e393bffd3f9f720bb14107de16e6416afcedf96
4
- data.tar.gz: 7c5d1553e864ceba8b972deb89ed3267559d6ad8
3
+ metadata.gz: b70cac794d9f1c7862a1a4644a649e081c2f1aac
4
+ data.tar.gz: 8f211a9467688033e5fa7e1af318eb452f46e532
5
5
  SHA512:
6
- metadata.gz: ef4d929e745cb8747cce8989110da15d1769b682c12213d4dac27edc095333fd3b16557f9e980c32789c6bf732683404f5d6bf876a2334c0cf5d5d553b4c349b
7
- data.tar.gz: 93852374b9c64cb900be51b2b6affaff18e18c081f3b38c0d9286dbc3dfc77af8adca9751a168589a17dc1290b58ec39f2ff16ab9b2ff1a92dbddbd27876aeb7
6
+ metadata.gz: 7746f4b0a171776a8903db8aff4c1874cb84c59085271ca3bb2f6a1eb012a5ec5eaa42a565f6ce150f74029e66a9d79ff1b25e845a2e1f1becd445555c57c96f
7
+ data.tar.gz: 1f9d932936d28309dd668484597a69e95191bd6ce2e374335728732321943e6e83f633d785281500980f2ee33e391f5576778f6bd5c51ca9260ca131211dd701
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: cocoapods-deploy 0.0.4 ruby lib
2
+ # stub: cocoapods-deploy 0.0.5 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "cocoapods-deploy"
6
- s.version = "0.0.4"
6
+ s.version = "0.0.5"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.date = "2016-03-07"
12
12
  s.description = "Implement's bundler's --deployment functionality in CocoaPods."
13
13
  s.email = ["james@supmenow.com"]
14
- s.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "cocoapods-deploy.gemspec", "lib/cocoapods-deploy/command.rb", "lib/cocoapods-deploy/command/deploy.rb", "lib/cocoapods-deploy/dependency.rb", "lib/cocoapods-deploy/deploy_analyzer.rb", "lib/cocoapods-deploy/deploy_installer.rb", "lib/cocoapods-deploy/gem_version.rb", "lib/cocoapods-deploy.rb", "lib/cocoapods_plugin.rb", "spec/spec_helper.rb"]
14
+ s.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "cocoapods-deploy.gemspec", "lib/cocoapods-deploy/command.rb", "lib/cocoapods-deploy/command/deploy.rb", "lib/cocoapods-deploy/deploy_transformer.rb", "lib/cocoapods-deploy/deploy_analyzer.rb", "lib/cocoapods-deploy/deploy_installer.rb", "lib/cocoapods-deploy/gem_version.rb", "lib/cocoapods-deploy.rb", "lib/cocoapods_plugin.rb", "spec/spec_helper.rb"]
15
15
  s.homepage = "https://github.com/jcampbell05/cocoapods-deploy"
16
16
  s.licenses = ["MIT"]
17
17
  s.rubygems_version = "2.4.8"
@@ -1,36 +1,5 @@
1
- def podspec_url(pod, version)
2
- "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/#{pod}/#{version}/#{pod}.podspec.json"
3
- end
4
-
5
1
  module Pod
6
2
  class Command
7
-
8
- #Hack to help transform target dependencies
9
- class DeployTransformer
10
-
11
- def self.lockfile=(lockfile)
12
- @@lockfile = lockfile
13
- end
14
-
15
- #TODO: Remove Workaround resolver trying to pull down invalid pods
16
- def self.in_lockfile(dep)
17
- @@lockfile.pod_names.include? dep.root_name
18
- end
19
-
20
- #TODO: Remove lockfile modifications
21
- def self.transform_dependency_to_sandbox_podspec(dep)
22
- unless dep.external_source
23
- version = @@lockfile.version(dep)
24
- checkout = { :podspec => podspec_url(dep.root_name, version) }
25
- dep.external_source = checkout
26
- dep.specific_version = nil
27
- dep.requirement = Requirement.create(checkout)
28
- end
29
-
30
- dep
31
- end
32
- end
33
-
34
3
  class Deploy < Command
35
4
 
36
5
  include Project
@@ -41,123 +10,111 @@ module Pod
41
10
  Install project dependencies to Podfile.lock versions without pulling down full podspec repo.
42
11
  DESC
43
12
 
44
- #TODO: Remove Hack to transform podfile dependencies to podspec ones - we should find
45
- #a way of removing some of these
46
- def apply_dependency_patches
47
-
48
- DeployTransformer.lockfile = config.lockfile
49
-
50
- Specification.class_eval do
51
-
52
- alias_method :original_all_dependencies, :all_dependencies
53
-
54
- def all_dependencies(platform = nil)
55
- deps = original_all_dependencies(platform = nil).select do |dep|
56
- DeployTransformer.in_lockfile(dep)
57
- end
13
+ # This method sets up the environment to be optimised
14
+ # for CocoaPod Deployment.
15
+ #
16
+ # Turning off things like repo cloning, clean-up and statistics.
17
+ def setup_environment
18
+ # Disable Cocoapods Stats - Due to
19
+ # https://github.com/CocoaPods/cocoapods-stats/issues/28
20
+ ENV['COCOAPODS_DISABLE_STATS'] = "1"
21
+
22
+ # Disable updating of the CocoaPods Repo since we are directly
23
+ # deploying using Podspecs
24
+ config.skip_repo_update = true
25
+
26
+ # Disable cleaning of the source file since we are deploying
27
+ # and we don't need to keep things clean.
28
+ config.clean = false
29
+ end
58
30
 
59
- deps.map do |dep|
31
+ # Verify the environment is ready for deployment
32
+ # i.e Do we have a podfile and lockfile.
33
+ def verify_environment
34
+ verify_podfile_exists!
35
+ verify_lockfile_exists!
36
+ end
60
37
 
61
- unless dep.external_source
62
- DeployTransformer.transform_dependency_to_sandbox_podspec(dep)
63
- else
64
- dep
65
- end
66
- end
67
- end
68
- end
38
+ # This prepares the Podfile and Lockfile for deployment
39
+ # by transforming Repo depedencies to Poddpec based dependencies
40
+ # and making sure we have eveything we need for Subspecs which
41
+ # typially don't work with Podspec based depedencies.
42
+ def transform_podfile
43
+ transformer = DeployTransformer.new(config.lockfile, config.sandbox)
44
+ transformer.transform_podfile(config.podfile)
45
+ end
69
46
 
47
+ # Applies patch to resolver as it needs help being pointed to use the
48
+ # local podspecs due to limitations in CocoaPods. We may be able to remove
49
+ # this in the future.
50
+ #
51
+ # In the future passing the lockfile into the resolve is hacked
52
+ # potentially we could have a special deploy subclass.
53
+ #
54
+ # TODO: BDD
55
+ def apply_resolver_patch
70
56
  Resolver.class_eval do
71
57
 
72
- alias_method :original_locked_dependencies, :locked_dependencies
58
+ def find_cached_set(dependency)
59
+ name = dependency.root_name
73
60
 
74
- def dependencies
75
- original_locked_dependencies.map do |dep|
76
-
77
- unless dep.external_source
78
- DeployTransformer.transform_dependency_to_sandbox_podspec(dep)
79
- else
80
- dep
61
+ unless cached_sets[name]
62
+ spec = sandbox.specification(name)
63
+ set = Specification::Set::External.new(spec)
64
+ cached_sets[name] = set
65
+ unless set
66
+ raise Molinillo::NoSuchDependencyError.new(dependency) # rubocop:disable Style/RaiseArgs
81
67
  end
82
68
  end
83
- end
84
- end
85
-
86
- Podfile::TargetDefinition.class_eval do
87
69
 
88
- alias_method :original_dependencies, :dependencies
70
+ cached_sets[name]
71
+ end
89
72
 
90
- def dependencies
91
- original_dependencies.map do |dep|
73
+ def dependencies_for(specification)
74
+ dependencies = specification.all_dependencies.select { |dep|
75
+ Config.instance.lockfile.version(dep.root_name) != nil
76
+ }
92
77
 
93
- unless dep.external_source
94
- DeployTransformer.transform_dependency_to_sandbox_podspec(dep)
78
+ dependencies.map do |dependency|
79
+ if dependency.root_name == Specification.root_name(specification.name)
80
+ dependency.dup.tap { |d| d.specific_version = specification.version }
95
81
  else
96
- dep
82
+ dependency
97
83
  end
98
84
  end
99
85
  end
100
86
  end
101
87
  end
102
88
 
103
- def transform_dependency_and_version_to_remote_podspec(dep, version)
104
- unless dep.external_source
105
- checkout = { :podspec => podspec_url(dep.root_name, version) }
106
- dep.external_source = checkout
107
- dep.specific_version = nil
108
- dep.requirement = Requirement.create(checkout)
109
- end
110
-
111
- dep
112
- end
113
-
114
- def dependency_for_pod_and_version(pod, version)
115
- dep = config.lockfile.dependencies.detect { |d| d.root_name == pod }
116
-
117
- unless dep
118
- dep = Dependency.new(pod, version)
89
+ # Installs required sources for lockfile - TODO: Simplify code
90
+ def install_sources_for_lockfile
91
+ config.lockfile.pod_names.each do |pod|
92
+ install_sources_for_pod(pod)
119
93
  end
120
-
121
- dep
122
94
  end
123
95
 
124
- def download_dependency(dep)
96
+ # Installs required sources for pod.
97
+ def install_sources_for_pod(pod)
98
+ transformer = DeployTransformer.new(config.lockfile, config.sandbox)
99
+ dep = transformer.transform_dependency_name(pod)
125
100
  source = ExternalSources.from_dependency(dep, config.podfile.defined_in_file)
126
101
  source.fetch(config.sandbox)
127
102
  end
128
103
 
129
- def transform_pod_and_version(pod, version)
130
- dep = dependency_for_pod_and_version(pod, version)
131
- transform_dependency_and_version_to_remote_podspec(dep, version)
132
- download_dependency(dep)
104
+ # Triggers the CocoaPods install process
105
+ def install(podfile)
106
+ installer = DeployInstaller.new(config.sandbox, podfile, nil)
107
+ installer.install!
133
108
  end
134
109
 
135
110
  def run
136
- verify_podfile_exists!
137
- verify_lockfile_exists!
111
+ setup_environment
112
+ verify_environment
138
113
 
139
- UI.puts("- Deploying Pods")
114
+ apply_resolver_patch
140
115
 
141
- config.lockfile.pod_names.each do |pod|
142
- version = config.lockfile.version(pod)
143
- UI.puts("- Deploying #{pod} #{version}")
144
- transform_pod_and_version(pod, version)
145
- end
146
-
147
- run_install_with_update(false)
148
- end
149
-
150
- def run_install_with_update(update)
151
- ENV['COCOAPODS_DISABLE_STATS'] = "true" #Disable Cocoapods Stats
152
- config.skip_repo_update = true #Force this to be true so it is always skipped
153
- config.clean = false #Disable source files from being cleaned
154
-
155
- #TODO: Work out way of transforming dependencies without patch
156
- apply_dependency_patches
157
-
158
- installer = DeployInstaller.new(config.sandbox, config.podfile, config.lockfile)
159
- installer.update = update
160
- installer.install!
116
+ install_sources_for_lockfile
117
+ install(transform_podfile)
161
118
  end
162
119
  end
163
120
  end
@@ -0,0 +1,103 @@
1
+ module Pod
2
+ class DeployTransformer
3
+
4
+ attr_accessor :lockfile
5
+ attr_accessor :sandbox
6
+
7
+ def initialize(lockfile, sandbox)
8
+ @lockfile = lockfile
9
+ @sandbox = sandbox
10
+ end
11
+
12
+ def transform_podfile(podfile)
13
+ internal_hash = podfile.to_hash
14
+ new_hash = transform_internal_hash(internal_hash)
15
+
16
+ Podfile.from_hash(new_hash, podfile.defined_in_file)
17
+ end
18
+
19
+ def transform_dependency_name(name)
20
+ dependency_hash = transform_dependency(name)
21
+ parse_dependency(dependency_hash)
22
+ end
23
+
24
+ private
25
+
26
+ def transform_internal_hash(hash)
27
+ targets = hash["target_definitions"]
28
+ targets.map do |target|
29
+ transform_target_definition_hash(target)
30
+ end if targets
31
+
32
+ hash
33
+ end
34
+
35
+ def transform_target_definition_hash(hash)
36
+ dependencies = hash["dependencies"]
37
+ hash["dependencies"] = dependencies.map do |dep|
38
+ transform_dependency(dep)
39
+ end if dependencies
40
+
41
+ #Duplicate this to prevent infinte loop
42
+ dependencies = hash["dependencies"]
43
+ dependencies.dup.map do |dep|
44
+ podspec_dependencies = collect_podspec_dependencies(dep)
45
+ hash["dependencies"].concat(podspec_dependencies) if podspec_dependencies
46
+ end if dependencies && @sandbox
47
+
48
+ children = hash["children"]
49
+ hash["children"] = children.map do |target|
50
+ transform_target_definition_hash(target)
51
+ end if children
52
+
53
+ hash
54
+ end
55
+
56
+ def parse_dependency(name_or_hash)
57
+ if name_or_hash.is_a?(Hash)
58
+ name = name_or_hash.keys.first
59
+ requirements = name_or_hash.values.first
60
+ Dependency.new(name, *requirements)
61
+ else
62
+ Dependency.new(name_or_hash)
63
+ end
64
+ end
65
+
66
+ def podspec_url(pod, version)
67
+ "https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/#{pod}/#{version}/#{pod}.podspec.json"
68
+ end
69
+
70
+ def collect_podspec_dependencies(name_or_hash)
71
+ dependency = parse_dependency(name_or_hash)
72
+ specification = @sandbox.specification(dependency.root_name)
73
+
74
+ dependencies = specification.dependencies.map do |dep|
75
+ begin
76
+ transform_dependency(dep.name)
77
+ rescue Informative
78
+ nil
79
+ end
80
+ end if specification
81
+
82
+ dependencies.select { |dep|
83
+ dep != nil
84
+ }
85
+ end
86
+
87
+ def transform_dependency(name_or_hash)
88
+ dependency = parse_dependency(name_or_hash)
89
+ pod = dependency.name
90
+ checkout_options = @lockfile.checkout_options_for_pod_named(pod)
91
+
92
+ unless checkout_options
93
+ root_pod = dependency.root_name
94
+ version = @lockfile.version(pod)
95
+ raise Informative, "Missing dependency \"#{pod}\" in Lockfile please run `pod install` or `pod update`." unless version
96
+
97
+ ({ "#{pod}" => [{ :podspec => podspec_url(root_pod, version) }] })
98
+ else
99
+ ({ "#{pod}" => [checkout_options] })
100
+ end
101
+ end
102
+ end
103
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsDeploy
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'cocoapods-deploy/dependency'
2
1
  require 'cocoapods-deploy/deploy_analyzer'
3
2
  require 'cocoapods-deploy/deploy_installer'
3
+ require 'cocoapods-deploy/deploy_transformer'
4
4
  require 'cocoapods-deploy/command'
@@ -1,11 +1,151 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
+ class MockExternalSource
4
+ def initialize
5
+ end
6
+
7
+ def fetch
8
+ end
9
+ end
10
+
3
11
  module Pod
4
12
  describe Command::Deploy do
13
+
14
+ before do
15
+ @command = Command.parse(%w{ deploy })
16
+ @command.stubs(:verify_lockfile_exists!)
17
+ @command.stubs(:verify_podfile_exists!)
18
+
19
+ @podfile = Podfile.new
20
+ Config.instance.stubs(:podfile).returns(@podfile)
21
+
22
+ @lockfile = Lockfile.new({
23
+ "PODS" => [
24
+ "Google/Analytics (1.0)",
25
+ "Mixpanel (1.0)"
26
+ ]
27
+ })
28
+ Config.instance.stubs(:lockfile).returns(@lockfile)
29
+ end
30
+
5
31
  describe 'CLAide' do
6
32
  it 'registers it self' do
7
- Command.parse(%w{ deploy }).should.be.instance_of Command::Deploy
33
+ @command.should.be.instance_of Command::Deploy
34
+ end
35
+ end
36
+
37
+ describe 'setting up enviroment' do
38
+
39
+ before do
40
+ @command.stubs(:transform_podfile)
41
+ @command.stubs(:install_sources_for_lockfile)
42
+ @command.stubs(:install)
43
+ end
44
+
45
+ it 'should disable cocoapods-stats' do
46
+ ENV.expects(:[]=).with("COCOAPODS_DISABLE_STATS", "1")
47
+ @command.run
48
+ end
49
+
50
+ it 'should skip repo update' do
51
+ Config.instance.expects(:skip_repo_update=).with(true)
52
+ @command.run
53
+ end
54
+
55
+ it 'should skip source file clean' do
56
+ Config.instance.expects(:clean=).with(false)
57
+ @command.run
58
+ end
59
+
60
+ it 'should verify podfile' do
61
+ @command.expects(:verify_lockfile_exists!)
62
+ @command.run
63
+ end
64
+
65
+ it 'should verify lockfile' do
66
+ @command.expects(:verify_podfile_exists!)
67
+ @command.run
68
+ end
69
+ end
70
+
71
+ describe 'converting podfile dependencies' do
72
+
73
+ before do
74
+ @command.stubs(:install_sources_for_lockfile)
75
+ @command.stubs(:install)
76
+
77
+ @transformer = DeployTransformer.new(nil, nil)
8
78
  end
79
+
80
+ it 'should create transformer with lockfile' do
81
+ DeployTransformer.expects(:new).with(@lockfile, Config.instance.sandbox).returns(@transformer)
82
+ @command.run
83
+ end
84
+
85
+ it 'should create transform podfile' do
86
+ @transformer.expects(:transform_podfile).with(@podfile)
87
+
88
+ DeployTransformer.stubs(:new).returns(@transformer)
89
+ @command.run
90
+ end
91
+ end
92
+
93
+ describe 'when installing' do
94
+
95
+ before do
96
+ @command.stubs(:install_sources_for_lockfile)
97
+ @command.stubs(:transform_podfile).returns(@podfile)
98
+
99
+ @installer = DeployInstaller.new(@sandbox, @podfile, nil)
100
+ @installer.stubs(:install!)
101
+ DeployInstaller.stubs(:new).returns(@installer)
102
+ end
103
+
104
+ it 'should create new installer' do
105
+ DeployInstaller.expects(:new).with(Config.instance.sandbox, @podfile, nil).returns(@installer)
106
+ @command.run
107
+ end
108
+
109
+ it 'should invoke installer' do
110
+ @installer.expects(:install!)
111
+ @command.run
112
+ end
113
+ end
114
+
115
+ describe 'when downloading pod sources' do
116
+
117
+ before do
118
+ @dependency = Dependency.new("Google/Analytics")
119
+ @lockfile.stubs(:pod_names).returns(["Google/Analytics"])
120
+
121
+ @transformer = DeployTransformer.new(nil, nil)
122
+ @transformer.stubs(:transform_dependency_name).with("Google/Analytics").returns(@dependency)
123
+ DeployTransformer.stubs(:new).returns(@transformer)
124
+
125
+ @source = MockExternalSource.new
126
+ @command.stubs(:transform_podfile).returns(@podfile)
127
+ @command.stubs(:install)
128
+ end
129
+
130
+ it 'should create new external source' do
131
+ ExternalSources.expects(:from_dependency).with(@dependency, @podfile.defined_in_file).returns(@source)
132
+ @source.stubs(:fetch)
133
+ @command.run
134
+ end
135
+
136
+ it 'should fetch source' do
137
+ ExternalSources.stubs(:from_dependency).returns(@source)
138
+ @source.expects(:fetch)
139
+ @command.run
140
+ end
141
+
142
+ # TODO: Reducing duplicates
143
+
144
+ # TODO: Patches
145
+
146
+ # Figure out how to test external source here.
147
+
148
+ # Figure out how to handle location
9
149
  end
10
150
  end
11
151
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Campbell
@@ -54,9 +54,9 @@ files:
54
54
  - lib/cocoapods-deploy.rb
55
55
  - lib/cocoapods-deploy/command.rb
56
56
  - lib/cocoapods-deploy/command/deploy.rb
57
- - lib/cocoapods-deploy/dependency.rb
58
57
  - lib/cocoapods-deploy/deploy_analyzer.rb
59
58
  - lib/cocoapods-deploy/deploy_installer.rb
59
+ - lib/cocoapods-deploy/deploy_transformer.rb
60
60
  - lib/cocoapods-deploy/gem_version.rb
61
61
  - lib/cocoapods_plugin.rb
62
62
  - spec/command/deploy_spec.rb
@@ -1,11 +0,0 @@
1
- module Pod
2
- class Dependency
3
- def requirement=(requirement)
4
- @requirement = requirement
5
- end
6
-
7
- def external_source=(external_source)
8
- @external_source = external_source
9
- end
10
- end
11
- end