cocoapods-repo-update 0.0.1
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 +7 -0
- data/README.md +47 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/lib/cocoapods_repo_update.rb +3 -0
- data/lib/cocoapods_repo_update/gem_version.rb +4 -0
- data/lib/cocoapods_repo_update/helper.rb +17 -0
- data/lib/cocoapods_repo_update/hooks.rb +27 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/unit/hooks_spec.rb +40 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bbb043ea50d89bc27de5e9e2ec8e128041ffb0db
|
4
|
+
data.tar.gz: b04ee056bf6db73ebd468cc4250544419ced1d18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52bcf6dec093bbe31be33b62a49b4f96897b79433a387184dc678469e306d3ad08ddce94e2b8afa83e562e092dd020ff4ea50796201e2bcfbdbca48f2ace1501
|
7
|
+
data.tar.gz: cee6bccc1488f001d939c174534822e5f57fb976b3ad8c08a256be97a41c9f7b6270bbddb55c2275910fabcb0a3fe3710e7dbad29c6ec3324bd236235f171706
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# cocoapods-repo-update
|
2
|
+
|
3
|
+
cocoapods-repo-update is a CocoaPods plugin that checks your dependencies when you run `pod install` and updates the local specs repositories if needed.
|
4
|
+
|
5
|
+
## Background
|
6
|
+
|
7
|
+
CocoaPods maintains a local mirror of the master specs repository at `~/.cocoapods/repos/master`. When you run `pod install`, CocoaPods checks your local mirror for all the specs you want and fetches them.
|
8
|
+
|
9
|
+
As of CocoaPods 1.0, `pod install` does not update the master specs repo every time it is run. This is because CocoaPods was [hammering Github](https://github.com/CocoaPods/CocoaPods/issues/4989#issuecomment-193772935) with this behavior. Now the specs repo must be explicitly updated with `pod repo update` or `pod install --repo-update`.
|
10
|
+
|
11
|
+
[In some cases](https://github.com/CocoaPods/CocoaPods/issues/6033), this change was a bit of an overcorrection. It can be particularly inconvenient when running changes on CI.
|
12
|
+
|
13
|
+
This plugin checks if your CocoaPods specs repo needs to be updated when `pod install` is run and updates it if needed. This eliminates the need to run `pod repo update` or `pod install --repo-update` when you change a pod.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Install with `gem install`:
|
18
|
+
|
19
|
+
$ gem install cocoapods-repo-update
|
20
|
+
|
21
|
+
Or add cocoapods-repo-update to your `Gemfile`:
|
22
|
+
|
23
|
+
gem 'cocoapods-repo-update'
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
cocoapods-repo-update is used by adding it to your `Podfile` like this:
|
28
|
+
|
29
|
+
```
|
30
|
+
source 'https://github.com/CocoaPods/Specs.git'
|
31
|
+
|
32
|
+
platform :ios, '11.0'
|
33
|
+
plugin 'cocoapods-repo-update'
|
34
|
+
|
35
|
+
target :MyTarget do
|
36
|
+
# Dependencies here
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
Source for the plugin is in `lib/`. Tests are run like this:
|
43
|
+
|
44
|
+
```
|
45
|
+
$ bundle install
|
46
|
+
$ bundle exec rspec spec/
|
47
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods_repo_update'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CocoapodsRepoUpdate
|
2
|
+
module Helper
|
3
|
+
|
4
|
+
# Suppress stdout & stderr while the block is run
|
5
|
+
#
|
6
|
+
# @yield invokes the block with output suppressed
|
7
|
+
def self.suppress_output
|
8
|
+
original_stdout, original_stderr = $stdout.clone, $stderr.clone
|
9
|
+
$stderr.reopen File.new('/dev/null', 'w')
|
10
|
+
$stdout.reopen File.new('/dev/null', 'w')
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
$stdout.reopen original_stdout
|
14
|
+
$stderr.reopen original_stderr
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods/resolver'
|
3
|
+
|
4
|
+
module CocoapodsRepoUpdate
|
5
|
+
# Registers for CocoaPods plugin hooks
|
6
|
+
module Hooks
|
7
|
+
Pod::HooksManager.register(CocoapodsRepoUpdate::NAME, :pre_install) do |installer_context, options|
|
8
|
+
analyzer = Pod::Installer::Analyzer.new(installer_context.sandbox,
|
9
|
+
installer_context.podfile,
|
10
|
+
installer_context.lockfile)
|
11
|
+
begin
|
12
|
+
Pod::UI.puts "Checking if specs repo should be updated"
|
13
|
+
|
14
|
+
# Analyze dependencies but suppress stdout/stderr so `pod install` output is not polluted
|
15
|
+
CocoapodsRepoUpdate::Helper.suppress_output do
|
16
|
+
analyzer.analyze
|
17
|
+
end
|
18
|
+
Pod::UI.puts "Not updating local specs repo"
|
19
|
+
rescue Pod::NoSpecFoundError
|
20
|
+
Pod::UI.puts "At least one Pod is not in the local specs repo. Updating specs repo..."
|
21
|
+
|
22
|
+
config = Pod::Config.new
|
23
|
+
config.sources_manager.update(nil, false) # Update all specs repos, silently
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'rspec'
|
7
|
+
require 'pathname'
|
8
|
+
require 'cocoapods'
|
9
|
+
|
10
|
+
require 'cocoapods_plugin'
|
11
|
+
|
12
|
+
#-----------------------------------------------------------------------------#
|
13
|
+
|
14
|
+
module Pod
|
15
|
+
|
16
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
17
|
+
#
|
18
|
+
UI.disable_wrap = true
|
19
|
+
|
20
|
+
# Redirects the messages to an internal store.
|
21
|
+
#
|
22
|
+
module UI
|
23
|
+
@output = ''
|
24
|
+
@warnings = ''
|
25
|
+
|
26
|
+
class << self
|
27
|
+
attr_accessor :output
|
28
|
+
attr_accessor :warnings
|
29
|
+
|
30
|
+
def puts(message = '')
|
31
|
+
@output << "#{message}\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
def warn(message = '', actions = [])
|
35
|
+
@warnings << "#{message}\n"
|
36
|
+
end
|
37
|
+
|
38
|
+
def print(message)
|
39
|
+
@output << message
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
#-----------------------------------------------------------------------------#
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
def trigger_pre_install(installer_context, options)
|
4
|
+
pre_install_hooks = Pod::HooksManager.registrations[:pre_install]
|
5
|
+
hook = pre_install_hooks.find { |h| h.plugin_name == CocoapodsRepoUpdate::NAME }
|
6
|
+
hook.block.call(installer_context, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe CocoapodsRepoUpdate::Hooks do
|
10
|
+
let(:options) { double('options') }
|
11
|
+
let(:installer_context) { double('Pod::Installer::Analyzer', sandbox: double('sandbox'),
|
12
|
+
podfile: double('podfile'),
|
13
|
+
lockfile: double('lockfile')) }
|
14
|
+
let(:analyzer) { double('analyzer') }
|
15
|
+
let(:sources_manager) { double('sources manager') }
|
16
|
+
let(:config) { double('config', sources_manager: sources_manager) }
|
17
|
+
|
18
|
+
before do
|
19
|
+
allow(Pod::Installer::Analyzer).to receive(:new).with(installer_context.sandbox,
|
20
|
+
installer_context.podfile,
|
21
|
+
installer_context.lockfile).and_return(analyzer)
|
22
|
+
allow(Pod::Config).to receive(:new).and_return(config)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'pre install' do
|
26
|
+
it 'runs the post install action without updating specs' do
|
27
|
+
allow(analyzer).to receive(:analyze)
|
28
|
+
expect(sources_manager).not_to receive(:update)
|
29
|
+
|
30
|
+
trigger_pre_install(installer_context, options)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'runs the post install action and updates specs' do
|
34
|
+
allow(analyzer).to receive(:analyze).and_raise(Pod::NoSpecFoundError)
|
35
|
+
expect(sources_manager).to receive(:update)
|
36
|
+
|
37
|
+
trigger_pre_install(installer_context, options)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-repo-update
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Treanor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cocoapods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.3.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.3.0
|
33
|
+
description: A CocoaPods plugin that updates your specs repos on pod install if needed.
|
34
|
+
email:
|
35
|
+
- jtreanor3@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files:
|
39
|
+
- README.md
|
40
|
+
files:
|
41
|
+
- README.md
|
42
|
+
- lib/cocoapods_plugin.rb
|
43
|
+
- lib/cocoapods_repo_update.rb
|
44
|
+
- lib/cocoapods_repo_update/gem_version.rb
|
45
|
+
- lib/cocoapods_repo_update/helper.rb
|
46
|
+
- lib/cocoapods_repo_update/hooks.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
- spec/unit/hooks_spec.rb
|
49
|
+
homepage: https://github.com/wordpress-mobile/cocoapods-repo-update
|
50
|
+
licenses:
|
51
|
+
- GPL-2.0
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.5.1
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: cocoapods-repo-update is a CocoaPods plugin that checks your dependencies
|
73
|
+
when you run `pod install` and updates the local specs repositories if needed.
|
74
|
+
test_files:
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
- spec/unit/hooks_spec.rb
|