cocoapods-git-private-repo 0.1.0
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/.gitignore +7 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +13 -0
- data/cocoapods-git-private-repo.gemspec +23 -0
- data/lib/cocoapods-git-private-repo/cocoapods-downloader.rb +17 -0
- data/lib/cocoapods-git-private-repo/gem_version.rb +3 -0
- data/lib/cocoapods-git-private-repo/git_private_repo_downloader.rb +44 -0
- data/lib/cocoapods-git-private-repo.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/spec_helper.rb +50 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3ff5c4e93840f1161b09dd5da1842c0aae39b6ac4a619276bbf668c0bdc66291
|
4
|
+
data.tar.gz: 4696f5de97fdc6c5475d02042f550d6bda142566839f4f6567a04b0c43628381
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3388bc8153eb6b1750a537d12ac05d05b015a6244d1bf2818776a710f70597344cdb5204c4ead2bef365a52420b6eda50912d93a617ad0680340ad372982aa6
|
7
|
+
data.tar.gz: cd0b2433bfbfc32f452229d14783e4d0c76ecd62819f1a6e0aa286224f1ae01ecca2b329b85066f7951aa4fc0987b574b2e637f91d8de7b3ce7dc7cee7410073
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2025 Nonthawat Srichad <nonthz@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# CocoaPods Git Private Repo
|
2
|
+
|
3
|
+
A CocoaPods plugin that simplifies accessing private git repositories using SSH keys during pod installation. This plugin enables seamless authentication with private git repositories by automatically applying the correct SSH key for each repository.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- Automatically uses specified SSH keys for private git repositories
|
8
|
+
- Supports different SSH keys for different repositories
|
9
|
+
- Configurable via a simple JSON file
|
10
|
+
- Works with standard CocoaPods installation workflow
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
```bash
|
15
|
+
$ gem install cocoapods-git-private-repo
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
### Configuration File
|
21
|
+
|
22
|
+
For managing multiple private repositories with different keys, create a `keys.json` file in your project root with the following format:
|
23
|
+
|
24
|
+
```json
|
25
|
+
[
|
26
|
+
{
|
27
|
+
"url": "git@github.com:organization/repo-1.git",
|
28
|
+
"key_path": "~/.ssh/id_rsa"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"url": "git@github.com:organization/repo-2.git",
|
32
|
+
"key_path": "~/.ssh/custom_key"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
```
|
36
|
+
|
37
|
+
The plugin will automatically:
|
38
|
+
1. Read the configuration file
|
39
|
+
2. Match repository URLs against the configuration
|
40
|
+
3. Use the appropriate SSH key for each repository
|
41
|
+
|
42
|
+
## How It Works
|
43
|
+
|
44
|
+
The plugin extends CocoaPods' Git downloader to:
|
45
|
+
|
46
|
+
1. Check for a repository URL match in your configuration
|
47
|
+
2. Override the git command to use the specified SSH key
|
48
|
+
3. Handle the authentication process automatically
|
49
|
+
|
50
|
+
This approach avoids the need to:
|
51
|
+
- Modify your SSH config for each repository
|
52
|
+
- Use different SSH clients for different repositories
|
53
|
+
- Manually handle key-based authentication
|
54
|
+
|
55
|
+
## Troubleshooting
|
56
|
+
|
57
|
+
If you encounter issues:
|
58
|
+
|
59
|
+
1. Ensure your SSH keys have the correct permissions
|
60
|
+
2. Verify the key paths in your configuration are correct and accessible
|
61
|
+
3. Check that the repository URLs in your configuration exactly match those in your Podfile
|
62
|
+
4. Enable verbose CocoaPods output for debugging:
|
63
|
+
|
64
|
+
```bash
|
65
|
+
$ pod install --verbose
|
66
|
+
```
|
67
|
+
|
68
|
+
## Development
|
69
|
+
|
70
|
+
1. Clone this repository
|
71
|
+
2. Run `bundle install` to install dependencies
|
72
|
+
3. Run `bundle exec rake spec` to run the tests
|
73
|
+
4. Create your feature branch (`git checkout -b my-new-feature`)
|
74
|
+
5. Commit your changes (`git commit -am 'Add some feature'`)
|
75
|
+
6. Push to the branch (`git push origin my-new-feature`)
|
76
|
+
7. Create a new Pull Request
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
This project is licensed under the MIT License - see the LICENSE.txt file for details
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-git-private-repo/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-git-private-repo'
|
8
|
+
spec.version = CocoapodsGitPrivateRepo::VERSION
|
9
|
+
spec.authors = ['Nonthawat Srichad']
|
10
|
+
spec.email = ['nonthz@gmail.com']
|
11
|
+
spec.description = %q{A CocoaPods plugin that enhances Git downloader to support SSH private key authentication for private repositories. This plugin allows specifying a private key file path directly in your Podfile or through a JSON configuration file.}
|
12
|
+
spec.summary = %q{CocoaPods plugin for authenticating with private Git repositories using SSH private keys.}
|
13
|
+
spec.homepage = 'https://github.com/nonth/cocoapods-git-private-repo'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'cocoapods-git-private-repo/git_private_repo_downloader'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
module Downloader
|
5
|
+
class <<self
|
6
|
+
alias_method :real_downloader_class_by_key, :downloader_class_by_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.downloader_class_by_key
|
10
|
+
original = self.real_downloader_class_by_key
|
11
|
+
original[:git] = GitPrivateRepoDownloader
|
12
|
+
|
13
|
+
original
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pod
|
2
|
+
module Downloader
|
3
|
+
class GitPrivateRepoDownloader < Git
|
4
|
+
def initialize(target_path, url, options)
|
5
|
+
super(target_path, url, options)
|
6
|
+
|
7
|
+
# Check if a JSON configuration file exists with private key mappings
|
8
|
+
json_config_path = 'keys.json'
|
9
|
+
|
10
|
+
puts "file path: #{json_config_path}"
|
11
|
+
|
12
|
+
# Only proceed with JSON processing if the file exists
|
13
|
+
return unless File.exist?(json_config_path)
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'json'
|
17
|
+
private_key_configs = JSON.parse(File.read(json_config_path))
|
18
|
+
|
19
|
+
# Find a matching URL in the array of objects and no private_key_path is already set
|
20
|
+
if !options[:private_key_path] && private_key_configs.is_a?(Array)
|
21
|
+
matching_config = private_key_configs.find { |config| config["url"] == url }
|
22
|
+
|
23
|
+
if matching_config && matching_config["key_path"]
|
24
|
+
options[:private_key_path] = matching_config["key_path"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute_command(executable, command, raise_on_failure = false)
|
31
|
+
puts "Executing command: #{executable} #{command.inspect}"
|
32
|
+
puts "Options: #{self.options.inspect}"
|
33
|
+
|
34
|
+
if executable == 'git' && options[:private_key_path]
|
35
|
+
private_key = options[:private_key_path]
|
36
|
+
|
37
|
+
command = command + ['-c', "core.sshCommand=ssh -i #{private_key}"]
|
38
|
+
end
|
39
|
+
|
40
|
+
super(executable, command, raise_on_failure)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-git-private-repo/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-git-private-repo/cocoapods-downloader'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
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 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-git-private-repo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nonthawat Srichad
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: bundler
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.3'
|
19
|
+
type: :development
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '1.3'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
description: A CocoaPods plugin that enhances Git downloader to support SSH private
|
41
|
+
key authentication for private repositories. This plugin allows specifying a private
|
42
|
+
key file path directly in your Podfile or through a JSON configuration file.
|
43
|
+
email:
|
44
|
+
- nonthz@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- cocoapods-git-private-repo.gemspec
|
55
|
+
- lib/cocoapods-git-private-repo.rb
|
56
|
+
- lib/cocoapods-git-private-repo/cocoapods-downloader.rb
|
57
|
+
- lib/cocoapods-git-private-repo/gem_version.rb
|
58
|
+
- lib/cocoapods-git-private-repo/git_private_repo_downloader.rb
|
59
|
+
- lib/cocoapods_plugin.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: https://github.com/nonth/cocoapods-git-private-repo
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.6.9
|
80
|
+
specification_version: 4
|
81
|
+
summary: CocoaPods plugin for authenticating with private Git repositories using SSH
|
82
|
+
private keys.
|
83
|
+
test_files:
|
84
|
+
- spec/spec_helper.rb
|