Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
524abbfa
Commit
524abbfa
authored
May 31, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3540 from orta/pre_install
Add a pre-install hook
parents
03c60f3c
132a29f2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
18 deletions
+92
-18
CHANGELOG.md
CHANGELOG.md
+7
-1
installer.rb
lib/cocoapods/installer.rb
+15
-4
post_install_hooks_context.rb
lib/cocoapods/installer/post_install_hooks_context.rb
+2
-2
pre_install_hooks_context.rb
lib/cocoapods/installer/pre_install_hooks_context.rb
+35
-0
post_install_hooks_context_spec.rb
spec/unit/installer/post_install_hooks_context_spec.rb
+15
-0
pre_install_hooks_context_spec.rb
spec/unit/installer/pre_install_hooks_context_spec.rb
+3
-3
installer_spec.rb
spec/unit/installer_spec.rb
+15
-8
No files found.
CHANGELOG.md
View file @
524abbfa
...
...
@@ -39,6 +39,13 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
Samuel Giddins
](
https://github.com/segiddins
)
[
cocoapods-try#31
](
https://github.com/CocoaPods/cocoapods-try/issues/31
)
*
Supports running pre-install hooks in plugins. This happens before the resolver
does its work, and offers easy access to the sandbox, podfile and lockfile via a
`PreInstallHooksContext`
object. This also renames the post-install hooks from
`HooksContext`
to
`PostInstallHooksContext`
.
[
Orta Therox
](
https://github.com/orta
)
[
cocoapods#3540
](
https://github.com/CocoaPods/cocoapods/issues/3409
)
##### Bug Fixes
*
`pod repo push`
will now find and push JSON podspecs.
...
...
@@ -49,7 +56,6 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
Boris Bügling
](
https://github.com/neonichu
)
[
#3500
](
https://github.com/CocoaPods/CocoaPods/issues/3500
)
## 0.37.1
##### Bug Fixes
...
...
lib/cocoapods/installer.rb
View file @
524abbfa
...
...
@@ -31,7 +31,8 @@ module Pod
autoload
:AggregateTargetInstaller
,
'cocoapods/installer/target_installer/aggregate_target_installer'
autoload
:Analyzer
,
'cocoapods/installer/analyzer'
autoload
:FileReferencesInstaller
,
'cocoapods/installer/file_references_installer'
autoload
:HooksContext
,
'cocoapods/installer/hooks_context'
autoload
:PostInstallHooksContext
,
'cocoapods/installer/post_install_hooks_context'
autoload
:PreInstallHooksContext
,
'cocoapods/installer/pre_install_hooks_context'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodSourcePreparer
,
'cocoapods/installer/pod_source_preparer'
...
...
@@ -106,6 +107,7 @@ module Pod
sandbox
.
prepare
ensure_plugins_are_installed!
Migrator
.
migrate
(
sandbox
)
run_plugins_pre_install_hooks
end
end
...
...
@@ -128,7 +130,7 @@ module Pod
UI
.
section
'Downloading dependencies'
do
create_file_accessors
install_pod_sources
run_pre_install_hooks
run_p
odfile_p
re_install_hooks
clean_pod_sources
lock_pod_sources
end
...
...
@@ -401,6 +403,15 @@ module Pod
end
end
# Runs the registered callbacks for the plugins pre install hooks.
#
# @return [void]
#
def
run_plugins_pre_install_hooks
context
=
PreInstallHooksContext
.
generate
(
sandbox
,
podfile
,
lockfile
)
HooksManager
.
run
(
:pre_install
,
context
,
podfile
.
plugins
)
end
# Performs any post-installation actions
#
# @return [void]
...
...
@@ -413,7 +424,7 @@ module Pod
# Runs the registered callbacks for the plugins post install hooks.
#
def
run_plugins_post_install_hooks
context
=
HooksContext
.
generate
(
sandbox
,
aggregate_targets
)
context
=
PostInstall
HooksContext
.
generate
(
sandbox
,
aggregate_targets
)
HooksManager
.
run
(
:post_install
,
context
,
podfile
.
plugins
)
end
...
...
@@ -669,7 +680,7 @@ module Pod
#
# @return [void]
#
def
run_pre_install_hooks
def
run_p
odfile_p
re_install_hooks
UI
.
message
'- Running pre install hooks'
do
executed
=
run_podfile_pre_install_hook
UI
.
message
'- Podfile'
if
executed
...
...
lib/cocoapods/installer/hooks_context.rb
→
lib/cocoapods/installer/
post_install_
hooks_context.rb
View file @
524abbfa
...
...
@@ -3,7 +3,7 @@ module Pod
# Context object designed to be used with the HooksManager which describes
# the context of the installer.
#
class
HooksContext
class
PostInstall
HooksContext
# @return [String] The path to the sandbox root (`Pods` directory).
#
attr_accessor
:sandbox_root
...
...
@@ -13,7 +13,7 @@ module Pod
#
attr_accessor
:umbrella_targets
#
Generate a {HooksContext}.
#
@return [PostInstallHooksContext] Convenience class generator method
#
# @param [Sandbox] sandbox
# The sandbox
...
...
lib/cocoapods/installer/pre_install_hooks_context.rb
0 → 100644
View file @
524abbfa
module
Pod
class
Installer
# Context object designed to be used with the HooksManager which describes
# the context of the installer before analysis has been completed.
#
class
PreInstallHooksContext
# @return [String] The path to the sandbox root (`Pods` directory).
#
attr_accessor
:sandbox_root
# @return [Podfile] The Podfile for the project.
#
attr_accessor
:podfile
# @return [Sandbox] The Sandbox for the project.
#
attr_accessor
:sandbox
# @return [Lockfile] The Lockfile for the project.
#
attr_accessor
:lockfile
# @return [PreInstallHooksContext] Convenience class method to generate the
# static context.
#
def
self
.
generate
(
sandbox
,
podfile
,
lockfile
)
result
=
new
result
.
podfile
=
podfile
result
.
sandbox
=
sandbox
result
.
lockfile
=
lockfile
result
end
end
end
end
spec/unit/installer/post_install_hooks_context_spec.rb
0 → 100644
View file @
524abbfa
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
PreInstallHooksContext
do
it
'offers a convenience method to be generated'
do
sandbox
,
podfile
,
lockfile
=
stub
,
stub
,
stub
result
=
Installer
::
PreInstallHooksContext
.
generate
(
sandbox
,
podfile
,
lockfile
)
result
.
class
.
should
==
Installer
::
PreInstallHooksContext
result
.
sandbox
.
should
==
sandbox
result
.
podfile
.
should
==
podfile
result
.
lockfile
.
should
==
lockfile
end
end
end
spec/unit/installer/hooks_context_spec.rb
→
spec/unit/installer/
pre_install_
hooks_context_spec.rb
View file @
524abbfa
...
...
@@ -2,7 +2,7 @@
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
HooksContext
do
describe
Installer
::
PostInstall
HooksContext
do
it
'offers a convenience method to be generated'
do
sandbox
=
stub
(
:root
=>
'/path'
)
...
...
@@ -15,8 +15,8 @@ module Pod
umbrella
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'8.0'
))
umbrella
.
pod_targets
=
[
pod_target
]
result
=
Installer
::
HooksContext
.
generate
(
sandbox
,
[
umbrella
])
result
.
class
.
should
==
Installer
::
HooksContext
result
=
Installer
::
PostInstall
HooksContext
.
generate
(
sandbox
,
[
umbrella
])
result
.
class
.
should
==
Installer
::
PostInstall
HooksContext
result
.
sandbox_root
.
should
==
'/path'
result
.
umbrella_targets
.
count
.
should
==
1
umbrella_target
=
result
.
umbrella_targets
.
first
...
...
spec/unit/installer_spec.rb
View file @
524abbfa
...
...
@@ -63,7 +63,7 @@ module Pod
@installer
.
unstub
(
:download_dependencies
)
@installer
.
stubs
(
:create_file_accessors
)
@installer
.
stubs
(
:install_pod_sources
)
def
@installer
.
run_pre_install_hooks
def
@installer
.
run_p
odfile_p
re_install_hooks
@hook_called
=
true
end
def
@installer
.
clean_pod_sources
...
...
@@ -74,7 +74,7 @@ module Pod
it
'in runs the post-install hooks before serializing the Pods project'
do
@installer
.
stubs
(
:prepare_pods_project
)
@installer
.
stubs
(
:run_pre_install_hooks
)
@installer
.
stubs
(
:run_p
odfile_p
re_install_hooks
)
@installer
.
stubs
(
:install_file_references
)
@installer
.
stubs
(
:install_libraries
)
@installer
.
stubs
(
:set_target_dependencies
)
...
...
@@ -685,16 +685,23 @@ module Pod
@installer
.
stubs
(
:installed_specs
).
returns
(
@specs
)
end
it
'runs plugins pre install hook'
do
context
=
stub
Installer
::
PreInstallHooksContext
.
expects
(
:generate
).
returns
(
context
)
HooksManager
.
expects
(
:run
).
with
(
:pre_install
,
context
,
{})
@installer
.
send
(
:run_plugins_pre_install_hooks
)
end
it
'runs plugins post install hook'
do
context
=
stub
Installer
::
HooksContext
.
expects
(
:generate
).
returns
(
context
)
Installer
::
PostInstall
HooksContext
.
expects
(
:generate
).
returns
(
context
)
HooksManager
.
expects
(
:run
).
with
(
:post_install
,
context
,
{})
@installer
.
send
(
:run_plugins_post_install_hooks
)
end
it
'only runs the podfile-specified
post-install
hooks'
do
it
'only runs the podfile-specified hooks'
do
context
=
stub
Installer
::
HooksContext
.
expects
(
:generate
).
returns
(
context
)
Installer
::
PostInstall
HooksContext
.
expects
(
:generate
).
returns
(
context
)
plugins_hash
=
{
'cocoapods-keys'
=>
{
'keyring'
=>
'Eidolon'
}
}
@installer
.
podfile
.
stubs
(
:plugins
).
returns
(
plugins_hash
)
HooksManager
.
expects
(
:run
).
with
(
:post_install
,
context
,
plugins_hash
)
...
...
@@ -722,7 +729,7 @@ module Pod
#-------------------------------------------------------------------------#
describe
'Hooks'
do
describe
'
Podfile
Hooks'
do
before
do
@installer
.
send
(
:analyze
)
@specs
=
@installer
.
pod_targets
.
map
(
&
:specs
).
flatten
...
...
@@ -736,7 +743,7 @@ module Pod
@installer
.
expects
(
:installer_rep
).
returns
(
installer_rep
)
@installer
.
podfile
.
expects
(
:pre_install!
).
with
(
installer_rep
)
@installer
.
send
(
:run_pre_install_hooks
)
@installer
.
send
(
:run_p
odfile_p
re_install_hooks
)
end
it
'run_podfile_post_install_hooks'
do
...
...
@@ -756,7 +763,7 @@ module Pod
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target_ios
,
pod_target_osx
])
@installer
.
stubs
(
:installer_rep
).
returns
(
stub
)
@installer
.
podfile
.
expects
(
:pre_install!
)
@installer
.
send
(
:run_pre_install_hooks
)
@installer
.
send
(
:run_p
odfile_p
re_install_hooks
)
@installer
.
send
(
:run_podfile_post_install_hooks
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment