cocoapods-repo-tal 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b48182a1812013b3f4b06681daf5cc4c7f79febe98f3599914dea7feb4116517
4
+ data.tar.gz: 93db2df31ac59ced5259034e8ac223a4c3ae4d1b0b976b5c7cf9e88dca49c27f
5
+ SHA512:
6
+ metadata.gz: d87698c3ee44242d03b8d29aa8d0b3d0241c414874bce100d220e2844b1776af90bf8d927f8e295c09861f977027218b0422b1009b39ac0592a82aa5f46d3547
7
+ data.tar.gz: 0c39ce02788ec019b1005a71e5350370a9c7560fe3afbe65c0032fa432e36c480bfae0198d0e51b1607d55a5ab1ed01ee8c65d4e408b1b951168e2d2f9dbab88
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-repo-tal.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-repo-tal (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.1)
10
+ activesupport (4.2.11.1)
11
+ i18n (~> 0.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ atomos (0.1.3)
16
+ bacon (1.2.0)
17
+ claide (1.0.3)
18
+ cocoapods (1.7.3)
19
+ activesupport (>= 4.0.2, < 5)
20
+ claide (>= 1.0.2, < 2.0)
21
+ cocoapods-core (= 1.7.3)
22
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
23
+ cocoapods-downloader (>= 1.2.2, < 2.0)
24
+ cocoapods-plugins (>= 1.0.0, < 2.0)
25
+ cocoapods-search (>= 1.0.0, < 2.0)
26
+ cocoapods-stats (>= 1.0.0, < 2.0)
27
+ cocoapods-trunk (>= 1.3.1, < 2.0)
28
+ cocoapods-try (>= 1.1.0, < 2.0)
29
+ colored2 (~> 3.1)
30
+ escape (~> 0.0.4)
31
+ fourflusher (>= 2.3.0, < 3.0)
32
+ gh_inspector (~> 1.0)
33
+ molinillo (~> 0.6.6)
34
+ nap (~> 1.0)
35
+ ruby-macho (~> 1.4)
36
+ xcodeproj (>= 1.10.0, < 2.0)
37
+ cocoapods-core (1.7.3)
38
+ activesupport (>= 4.0.2, < 6)
39
+ fuzzy_match (~> 2.0.4)
40
+ nap (~> 1.0)
41
+ cocoapods-deintegrate (1.0.4)
42
+ cocoapods-downloader (1.2.2)
43
+ cocoapods-plugins (1.0.0)
44
+ nap
45
+ cocoapods-search (1.0.0)
46
+ cocoapods-stats (1.1.0)
47
+ cocoapods-trunk (1.4.0)
48
+ nap (>= 0.8, < 2.0)
49
+ netrc (~> 0.11)
50
+ cocoapods-try (1.1.0)
51
+ colored2 (3.1.2)
52
+ concurrent-ruby (1.1.5)
53
+ escape (0.0.4)
54
+ fourflusher (2.3.1)
55
+ fuzzy_match (2.0.4)
56
+ gh_inspector (1.1.3)
57
+ i18n (0.9.5)
58
+ concurrent-ruby (~> 1.0)
59
+ metaclass (0.0.4)
60
+ minitest (5.11.3)
61
+ mocha (1.9.0)
62
+ metaclass (~> 0.0.1)
63
+ mocha-on-bacon (0.2.3)
64
+ mocha (>= 0.13.0)
65
+ molinillo (0.6.6)
66
+ nanaimo (0.2.6)
67
+ nap (1.1.0)
68
+ netrc (0.11.0)
69
+ prettybacon (0.0.2)
70
+ bacon (~> 1.2)
71
+ rake (12.3.2)
72
+ ruby-macho (1.4.0)
73
+ thread_safe (0.3.6)
74
+ tzinfo (1.2.5)
75
+ thread_safe (~> 0.1)
76
+ xcodeproj (1.12.0)
77
+ CFPropertyList (>= 2.3.3, < 4.0)
78
+ atomos (~> 0.1.3)
79
+ claide (>= 1.0.2, < 2.0)
80
+ colored2 (~> 3.1)
81
+ nanaimo (~> 0.2.6)
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ bacon
88
+ bundler (~> 1.3)
89
+ cocoapods
90
+ cocoapods-repo-tal!
91
+ mocha
92
+ mocha-on-bacon
93
+ prettybacon
94
+ rake
95
+
96
+ BUNDLED WITH
97
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 yuanhang <yuanhang1@100tal.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,11 @@
1
+ # cocoapods-repo-tal
2
+
3
+ A description of cocoapods-repo-tal.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-repo-tal
8
+
9
+ ## Usage
10
+
11
+ $ pod spec repo-tal POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -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-repo-tal/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-repo-tal'
8
+ spec.version = CocoapodsRepoTal::VERSION
9
+ spec.authors = ['yuanhang']
10
+ spec.email = ['yuanhang1@100tal.com']
11
+ spec.description = %q{A short description of cocoapods-repo-tal.}
12
+ spec.summary = %q{A longer description of cocoapods-repo-tal.}
13
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-repo-tal'
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 @@
1
+ require 'cocoapods-repo-tal/gem_version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-repo-tal/command/repo_tal'
@@ -0,0 +1,102 @@
1
+ module Pod
2
+ class Command
3
+ class RepoTal < Command
4
+ class Add < RepoTal
5
+ self.summary = 'Add a spec repo'
6
+
7
+ self.description = <<-DESC
8
+ Clones `URL` in the local spec-repos directory at `#{Config.instance.repos_dir}`. The
9
+ remote can later be referred to by `NAME`.
10
+ DESC
11
+
12
+ self.arguments = [
13
+ CLAide::Argument.new('NAME', true),
14
+ CLAide::Argument.new('URL', true),
15
+ CLAide::Argument.new('BRANCH', false),
16
+ ]
17
+
18
+ def self.options
19
+ [
20
+ ['--progress', 'Show the progress of cloning the spec repository'],
21
+ ].concat(super)
22
+ end
23
+
24
+ def initialize(argv)
25
+ @name = argv.shift_argument
26
+ @url = argv.shift_argument
27
+ @branch = argv.shift_argument
28
+ @progress = argv.flag?('progress')
29
+ super
30
+ end
31
+
32
+ def validate!
33
+ super
34
+ unless @name && @url
35
+ help! 'Adding a repo needs a `NAME` and a `URL`.'
36
+ end
37
+ if @name == 'master' || @url =~ %r{github.com[:/]+cocoapods/specs}i
38
+ raise Informative,
39
+ 'To setup the master specs repo, please run `pod setup`.'
40
+ end
41
+ end
42
+
43
+ def run
44
+ section = "Cloning spec repo `#{@name}` from `#{@url}`"
45
+ section << " (branch `#{@branch}`)" if @branch
46
+ UI.section(section) do
47
+ create_repos_dir
48
+ clone_repo
49
+ checkout_branch
50
+ config.sources_manager.sources([dir.basename.to_s]).each(&:verify_compatibility!)
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # Creates the repos directory specified in the configuration by
57
+ # `config.repos_dir`.
58
+ #
59
+ # @return [void]
60
+ #
61
+ # @raise If the directory cannot be created due to a system error.
62
+ #
63
+ def create_repos_dir
64
+ config.repos_dir.mkpath
65
+ rescue => e
66
+ raise Informative, "Could not create '#{config.repos_dir}', the CocoaPods repo cache directory.\n" \
67
+ "#{e.class.name}: #{e.message}"
68
+ end
69
+
70
+ # Clones the git spec-repo according to parameters passed to the
71
+ # command.
72
+ #
73
+ # @return [void]
74
+ #
75
+ def clone_repo
76
+ changes = if @progress
77
+ { :verbose => true }
78
+ else
79
+ {}
80
+ end
81
+
82
+ config.with_changes(changes) do
83
+ Dir.chdir(config.repos_dir) do
84
+ command = ['clone', @url]
85
+ command << '--progress' if @progress
86
+ command << '--' << @name
87
+ git!(command)
88
+ end
89
+ end
90
+ end
91
+
92
+ # Checks out the branch of the git spec-repo if provided.
93
+ #
94
+ # @return [void]
95
+ #
96
+ def checkout_branch
97
+ Dir.chdir(dir) { git!('checkout', @branch) } if @branch
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,58 @@
1
+ module Pod
2
+ class Command
3
+ class RepoTal < Command
4
+ class AddCDN < RepoTal
5
+ self.summary = 'Add a spec repo backed by a CDN'
6
+
7
+ self.description = <<-DESC
8
+ Add `URL` to the local spec-repos directory at `#{Config.instance.repos_dir}`. The
9
+ remote can later be referred to by `NAME`.
10
+ DESC
11
+
12
+ self.arguments = [
13
+ CLAide::Argument.new('NAME', true),
14
+ CLAide::Argument.new('URL', true),
15
+ ]
16
+
17
+ def initialize(argv)
18
+ @name = argv.shift_argument
19
+ @url = argv.shift_argument
20
+ super
21
+ end
22
+
23
+ def validate!
24
+ super
25
+ unless @name && @url
26
+ help! 'Adding a repo needs a `NAME` and a `URL`.'
27
+ end
28
+ if @name == 'master'
29
+ raise Informative,
30
+ 'To setup the master specs repo, please run `pod setup`.'
31
+ end
32
+ end
33
+
34
+ def run
35
+ section = "Adding spec repo `#{@name}` with CDN `#{@url}`"
36
+ UI.section(section) do
37
+ save_url
38
+ config.sources_manager.sources([dir.basename.to_s]).each(&:verify_compatibility!)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ # Saves the spec-repo URL to a '.url' file.
45
+ #
46
+ # @return [void]
47
+ #
48
+ def save_url
49
+ dir.mkpath
50
+ File.open(dir + '.url', 'w') { |file| file.write(@url) }
51
+ rescue => e
52
+ raise Informative, "Could not create '#{config.repos_dir}', the CocoaPods repo cache directory.\n" \
53
+ "#{e.class.name}: #{e.message}"
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,82 @@
1
+ module Pod
2
+ class Command
3
+ class RepoTal < Command
4
+ class Lint < RepoTal
5
+ self.summary = 'Validates all specs in a repo'
6
+
7
+ self.description = <<-DESC
8
+ Lints the spec-repo `NAME`. If a directory is provided it is assumed
9
+ to be the root of a repo. Finally, if `NAME` is not provided this
10
+ will lint all the spec-repos known to CocoaPods.
11
+ DESC
12
+
13
+ self.arguments = [
14
+ CLAide::Argument.new(%w(NAME DIRECTORY), false),
15
+ ]
16
+
17
+ def self.options
18
+ [
19
+ ['--only-errors', 'Lint presents only the errors'],
20
+ ].concat(super)
21
+ end
22
+
23
+ def initialize(argv)
24
+ @name = argv.shift_argument
25
+ @only_errors = argv.flag?('only-errors')
26
+ super
27
+ end
28
+
29
+ # Run the command
30
+ #
31
+ # @todo Part of this logic needs to be ported to cocoapods-core so web
32
+ # services can validate the repo.
33
+ #
34
+ # @todo add UI.print and enable print statements again.
35
+ #
36
+ def run
37
+ sources = if @name
38
+ if File.exist?(@name)
39
+ [Source.new(Pathname(@name))]
40
+ else
41
+ config.sources_manager.sources([@name])
42
+ end
43
+ else
44
+ config.sources_manager.all
45
+ end
46
+
47
+ sources.each do |source|
48
+ source.verify_compatibility!
49
+ UI.puts "\nLinting spec repo `#{source.name}`\n".yellow
50
+
51
+ validator = Source::HealthReporter.new(source.repo)
52
+ validator.pre_check do |_name, _version|
53
+ UI.print '.'
54
+ end
55
+ report = validator.analyze
56
+ UI.puts
57
+ UI.puts
58
+
59
+ report.pods_by_warning.each do |message, versions_by_name|
60
+ UI.puts "-> #{message}".yellow
61
+ versions_by_name.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
62
+ UI.puts
63
+ end
64
+
65
+ report.pods_by_error.each do |message, versions_by_name|
66
+ UI.puts "-> #{message}".red
67
+ versions_by_name.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
68
+ UI.puts
69
+ end
70
+
71
+ UI.puts "Analyzed #{report.analyzed_paths.count} podspecs files.\n\n"
72
+ if report.pods_by_error.count.zero?
73
+ UI.puts 'All the specs passed validation.'.green << "\n\n"
74
+ else
75
+ raise Informative, "#{report.pods_by_error.count} podspecs failed validation."
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,92 @@
1
+ module Pod
2
+ class Command
3
+ class RepoTal < Command
4
+ class List < RepoTal
5
+ self.summary = 'List repos'
6
+
7
+ self.description = <<-DESC
8
+ List the repos from the local spec-repos directory at `#{Config.instance.repos_dir}`.
9
+ DESC
10
+
11
+ def self.options
12
+ [['--count-only', 'Show the total number of repos']].concat(super)
13
+ end
14
+
15
+ def initialize(argv)
16
+ @count_only = argv.flag?('count-only')
17
+ super
18
+ end
19
+
20
+ # @output Examples:
21
+ #
22
+ # master
23
+ # - type: git (master)
24
+ # - URL: https://github.com/CocoaPods/Specs.git
25
+ # - path: /Users/lascorbe/.cocoapods/repos/master
26
+ #
27
+ # test
28
+ # - type: local copy
29
+ # - URL: file:///Users/lascorbe/.cocoapods/repos/test
30
+ # - path: /Users/lascorbe/.cocoapods/repos/test
31
+ #
32
+ def run
33
+ sources = config.sources_manager.all
34
+ print_sources(sources) unless @count_only
35
+ print_count_of_sources(sources)
36
+ end
37
+
38
+ private
39
+
40
+ # Pretty-prints the source at the given path.
41
+ #
42
+ # @param [Source] source
43
+ # The source repository to be printed.
44
+ #
45
+ # @return [void]
46
+ #
47
+ def print_source(source)
48
+ if source.git?
49
+ branch_name, = Executable.capture_command('git', %w(name-rev --name-only HEAD), :capture => :out, :chdir => source.repo)
50
+ branch_name.strip!
51
+ branch_name = 'unknown' if branch_name.empty?
52
+ UI.puts "- Type: git (#{branch_name})"
53
+ else
54
+ UI.puts "- Type: #{source.type}"
55
+ end
56
+
57
+ UI.puts "- URL: #{source.url}"
58
+ UI.puts "- Path: #{source.repo}"
59
+ end
60
+
61
+ # Pretty-prints the given sources.
62
+ #
63
+ # @param [Array<Source>] sources
64
+ # The sources that should be printed.
65
+ #
66
+ # @return [void]
67
+ #
68
+ def print_sources(sources)
69
+ sources.each do |source|
70
+ UI.title source.name do
71
+ print_source(source)
72
+ end
73
+ end
74
+ UI.puts "\n"
75
+ end
76
+
77
+ # Pretty-prints the number of sources.
78
+ #
79
+ # @param [Array<Source>] sources
80
+ # The sources whose count should be printed.
81
+ #
82
+ # @return [void]
83
+ #
84
+ def print_count_of_sources(sources)
85
+ number_of_repos = sources.length
86
+ repo_string = number_of_repos != 1 ? 'repos' : 'repo'
87
+ UI.puts "#{number_of_repos} #{repo_string}".green
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,293 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module Pod
6
+ class Command
7
+ class RepoTal < Command
8
+ class Push < RepoTal
9
+ self.summary = 'Push new specifications to a spec-repo'
10
+
11
+ self.description = <<-DESC
12
+ Validates `NAME.podspec` or `*.podspec` in the current working dir,
13
+ creates a directory and version folder for the pod in the local copy of
14
+ `REPO` (#{Config.instance.repos_dir}/[REPO]), copies the podspec file into the
15
+ version directory, and finally it pushes `REPO` to its remote.
16
+ DESC
17
+
18
+ self.arguments = [
19
+ CLAide::Argument.new('REPO', true),
20
+ CLAide::Argument.new('NAME.podspec', false),
21
+ ]
22
+
23
+ def self.options
24
+ [
25
+ ['--allow-warnings', 'Allows pushing even if there are warnings'],
26
+ ['--use-libraries', 'Linter uses static libraries to install the spec'],
27
+ ['--use-modular-headers', 'Lint uses modular headers during installation'],
28
+ ['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependent pods ' \
29
+ '(defaults to all available repos). ' \
30
+ 'Multiple sources must be comma-delimited.'],
31
+ ['--local-only', 'Does not perform the step of pushing REPO to its remote'],
32
+ ['--no-private', 'Lint includes checks that apply only to public repos'],
33
+ ['--skip-import-validation', 'Lint skips validating that the pod can be imported'],
34
+ ['--skip-tests', 'Lint skips building and running tests during validation'],
35
+ ['--commit-message="Fix bug in pod"', 'Add custom commit message. ' \
36
+ 'Opens default editor if no commit message is specified.'],
37
+ ['--use-json', 'Push JSON spec to repo'],
38
+ ['--swift-version=VERSION', 'The SWIFT_VERSION that should be used when linting the spec. ' \
39
+ 'This takes precedence over the Swift versions specified by the spec or a `.swift-version` file.'],
40
+ ['--no-overwrite', 'Disallow pushing that would overwrite an existing spec.'],
41
+ ['--validate-podspec', 'Disallow pushing that would overwrite an existing spec.']
42
+ ].concat(super)
43
+ end
44
+
45
+ def initialize(argv)
46
+ @allow_warnings = argv.flag?('allow-warnings')
47
+ @local_only = argv.flag?('local-only')
48
+ @repo = argv.shift_argument
49
+ @source = source_for_repo
50
+ @source_urls = argv.option('sources', config.sources_manager.all.map(&:url).join(',')).split(',')
51
+ @podspec = argv.shift_argument
52
+ @use_frameworks = !argv.flag?('use-libraries')
53
+ @use_modular_headers = argv.flag?('use-modular-headers', false)
54
+ @private = argv.flag?('private', true)
55
+ @message = argv.option('commit-message')
56
+ @commit_message = argv.flag?('commit-message', false)
57
+ @use_json = argv.flag?('use-json')
58
+ @swift_version = argv.option('swift-version', nil)
59
+ @skip_import_validation = argv.flag?('skip-import-validation', false)
60
+ @skip_tests = argv.flag?('skip-tests', false)
61
+ @allow_overwrite = argv.flag?('overwrite', true)
62
+ @validate_podspec = argv.flag?('validate-podspec', false)
63
+ super
64
+ end
65
+
66
+ def validate!
67
+ super
68
+ help! 'A spec-repo name or url is required.' unless @repo
69
+ unless @source && @source.repo.directory?
70
+ raise Informative,
71
+ "Unable to find the `#{@repo}` repo. " \
72
+ 'If it has not yet been cloned, add it via `pod repo add`.'
73
+ end
74
+ end
75
+
76
+ def run
77
+ open_editor if @commit_message && @message.nil?
78
+ check_if_master_repo
79
+ if @validate_podspec
80
+ validate_podspec_files
81
+ else
82
+ UI.puts "\n Pass Validate #{'spec'.pluralize(count)}".yellow
83
+ end
84
+ check_repo_status
85
+ update_repo
86
+ add_specs_to_repo
87
+ push_repo unless @local_only
88
+ end
89
+
90
+ #---------------------------------------------------------------------#
91
+
92
+ private
93
+
94
+ # @!group Push sub-steps
95
+
96
+ extend Executable
97
+ executable :git
98
+
99
+ # Open default editor to allow users to enter commit message
100
+ #
101
+ def open_editor
102
+ return if ENV['EDITOR'].nil?
103
+
104
+ file = Tempfile.new('cocoapods')
105
+ File.chmod(0777, file.path)
106
+ file.close
107
+
108
+ system("#{ENV['EDITOR']} #{file.path}")
109
+ @message = File.read file.path
110
+ end
111
+
112
+ # Temporary check to ensure that users do not push accidentally private
113
+ # specs to the master repo.
114
+ #
115
+ def check_if_master_repo
116
+ remotes, = Executable.capture_command('git', %w(remote --verbose), :capture => :merge, :chdir => repo_dir)
117
+ master_repo_urls = [
118
+ 'git@github.com:CocoaPods/Specs.git',
119
+ 'https://github.com/CocoaPods/Specs.git',
120
+ ]
121
+ is_master_repo = master_repo_urls.any? do |url|
122
+ remotes.include?(url)
123
+ end
124
+
125
+ if is_master_repo
126
+ raise Informative, 'To push to the CocoaPods master repo use ' \
127
+ "the `pod trunk push` command.\n\nIf you are using a fork of " \
128
+ 'the master repo for private purposes we recommend to migrate ' \
129
+ 'to a clean private repo. To disable this check remove the ' \
130
+ 'remote pointing to the CocoaPods master repo.'
131
+ end
132
+ end
133
+
134
+ # Performs a full lint against the podspecs.
135
+ #
136
+ def validate_podspec_files
137
+ UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
138
+ podspec_files.each do |podspec|
139
+ validator = Validator.new(podspec, @source_urls)
140
+ validator.allow_warnings = @allow_warnings
141
+ validator.use_frameworks = @use_frameworks
142
+ validator.use_modular_headers = @use_modular_headers
143
+ validator.ignore_public_only_results = @private
144
+ validator.swift_version = @swift_version
145
+ validator.skip_import_validation = @skip_import_validation
146
+ validator.skip_tests = @skip_tests
147
+ begin
148
+ validator.validate
149
+ rescue => e
150
+ raise Informative, "The `#{podspec}` specification does not validate." \
151
+ "\n\n#{e.message}"
152
+ end
153
+ raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated?
154
+ end
155
+ end
156
+
157
+ # Checks that the repo is clean.
158
+ #
159
+ # @raise If the repo is not clean.
160
+ #
161
+ # @todo Add specs for staged and unstaged files.
162
+ #
163
+ # @todo Gracefully handle the case where source is not under git
164
+ # source control.
165
+ #
166
+ # @return [void]
167
+ #
168
+ def check_repo_status
169
+ porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => repo_dir)
170
+ clean = porcelain_status == ''
171
+ raise Informative, "The repo `#{@repo}` at #{UI.path repo_dir} is not clean" unless clean
172
+ end
173
+
174
+ # Updates the git repo against the remote.
175
+ #
176
+ # @return [void]
177
+ #
178
+ def update_repo
179
+ UI.puts "Updating the `#{@repo}' repo\n".yellow
180
+ git!(%W(-C #{repo_dir} pull))
181
+ end
182
+
183
+ # Commits the podspecs to the source, which should be a git repo.
184
+ #
185
+ # @note The pre commit hook of the repo is skipped as the podspecs have
186
+ # already been linted.
187
+ #
188
+ # @return [void]
189
+ #
190
+ def add_specs_to_repo
191
+ UI.puts "\nAdding the #{'spec'.pluralize(count)} to the `#{@repo}' repo\n".yellow
192
+ podspec_files.each do |spec_file|
193
+ spec = Pod::Specification.from_file(spec_file)
194
+ output_path = @source.pod_path(spec.name) + spec.version.to_s
195
+ message = if @message && !@message.empty?
196
+ @message
197
+ elsif output_path.exist?
198
+ "[Fix] #{spec}"
199
+ elsif output_path.dirname.directory?
200
+ "[Update] #{spec}"
201
+ else
202
+ "[Add] #{spec}"
203
+ end
204
+
205
+ if output_path.exist? && !@allow_overwrite
206
+ raise Informative, "#{spec} already exists and overwriting has been disabled."
207
+ end
208
+
209
+ FileUtils.mkdir_p(output_path)
210
+
211
+ if @use_json
212
+ json_file_name = "#{spec.name}.podspec.json"
213
+ json_file = File.join(output_path, json_file_name)
214
+ File.open(json_file, 'w') { |file| file.write(spec.to_pretty_json) }
215
+ else
216
+ FileUtils.cp(spec_file, output_path)
217
+ end
218
+
219
+ # only commit if modified
220
+ if repo_git('status', '--porcelain').include?(spec.name)
221
+ UI.puts " - #{message}"
222
+ repo_git('add', spec.name)
223
+ repo_git('commit', '--no-verify', '-m', message)
224
+ else
225
+ UI.puts " - [No change] #{spec}"
226
+ end
227
+ end
228
+ end
229
+
230
+ # Pushes the git repo against the remote.
231
+ #
232
+ # @return [void]
233
+ #
234
+ def push_repo
235
+ UI.puts "\nPushing the `#{@repo}' repo\n".yellow
236
+ repo_git('push', 'origin', 'master')
237
+ end
238
+
239
+ #---------------------------------------------------------------------#
240
+
241
+ private
242
+
243
+ # @!group Private helpers
244
+
245
+ # @return result of calling the git! with args in repo_dir
246
+ #
247
+ def repo_git(*args)
248
+ git!(['-C', repo_dir] + args)
249
+ end
250
+
251
+ # @return [Pathname] The directory of the repository.
252
+ #
253
+ def repo_dir
254
+ @source.specs_dir
255
+ end
256
+
257
+ # @return [Array<Pathname>] The path of the specifications to push.
258
+ #
259
+ def podspec_files
260
+ if @podspec
261
+ path = Pathname(@podspec)
262
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
263
+ [path]
264
+ else
265
+ files = Pathname.glob('*.podspec{,.json}')
266
+ raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
267
+ files
268
+ end
269
+ end
270
+
271
+ # @return [Integer] The number of the podspec files to push.
272
+ #
273
+ def count
274
+ podspec_files.count
275
+ end
276
+
277
+ # Returns source for @repo
278
+ #
279
+ # @note If URL is invalid or repo doesn't exist, validate! will throw the error
280
+ #
281
+ # @return [Source]
282
+ #
283
+ def source_for_repo
284
+ config.sources_manager.source_with_name_or_url(@repo) unless @repo.nil?
285
+ rescue
286
+ nil
287
+ end
288
+
289
+ #---------------------------------------------------------------------#
290
+ end
291
+ end
292
+ end
293
+ end
@@ -0,0 +1,36 @@
1
+ module Pod
2
+ class Command
3
+ class RepoTal < Command
4
+ class Remove < RepoTal
5
+ self.summary = 'Remove a spec repo'
6
+
7
+ self.description = <<-DESC
8
+ Deletes the remote named `NAME` from the local spec-repos directory at `#{Config.instance.repos_dir}`.
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('NAME', true),
13
+ ]
14
+
15
+ def initialize(argv)
16
+ @name = argv.shift_argument
17
+ super
18
+ end
19
+
20
+ def validate!
21
+ super
22
+ help! 'Deleting a repo needs a `NAME`.' unless @name
23
+ help! "repo #{@name} does not exist" unless File.directory?(dir)
24
+ help! "You do not have permission to delete the #{@name} repository." \
25
+ 'Perhaps try prefixing this command with sudo.' unless File.writable?(dir)
26
+ end
27
+
28
+ def run
29
+ UI.section("Removing spec repo `#{@name}`") do
30
+ FileUtils.rm_rf(dir)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ module Pod
2
+ class Command
3
+ class RepoTal < Command
4
+ class Update < RepoTal
5
+ self.summary = 'Update a spec repo'
6
+
7
+ self.description = <<-DESC
8
+ Updates the local clone of the spec-repo `NAME`. If `NAME` is omitted
9
+ this will update all spec-repos in `#{Config.instance.repos_dir}`.
10
+ DESC
11
+
12
+ self.arguments = [
13
+ CLAide::Argument.new('NAME', false),
14
+ ]
15
+
16
+ def initialize(argv)
17
+ @name = argv.shift_argument
18
+ super
19
+ end
20
+
21
+ def run
22
+ show_output = !config.silent?
23
+ config.sources_manager.update(@name, show_output)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ require 'fileutils'
2
+ require 'cocoapods-repo-tal/command/repo/add'
3
+ require 'cocoapods-repo-tal/command/repo/add_cdn'
4
+ require 'cocoapods-repo-tal/command/repo/lint'
5
+ require 'cocoapods-repo-tal/command/repo/list'
6
+ require 'cocoapods-repo-tal/command/repo/push'
7
+ require 'cocoapods-repo-tal/command/repo/remove'
8
+ require 'cocoapods-repo-tal/command/repo/update'
9
+
10
+ module Pod
11
+ class Command
12
+ class RepoTal < Command
13
+ self.abstract_command = true
14
+
15
+ # @todo should not show a usage banner!
16
+ #
17
+ self.summary = 'Manage spec-repositories'
18
+ self.default_subcommand = 'list'
19
+
20
+ #-----------------------------------------------------------------------#
21
+
22
+ extend Executable
23
+ executable :git
24
+
25
+ def dir
26
+ config.repos_dir + @name
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsRepoTal
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-repo-tal/command'
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::repo-tal do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w{ repo-tal }).should.be.instance_of Command::repo-tal
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -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,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-repo-tal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - yuanhang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A short description of cocoapods-repo-tal.
42
+ email:
43
+ - yuanhang1@100tal.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-repo-tal.gemspec
55
+ - lib/cocoapods-repo-tal.rb
56
+ - lib/cocoapods-repo-tal/command.rb
57
+ - lib/cocoapods-repo-tal/command/repo/add.rb
58
+ - lib/cocoapods-repo-tal/command/repo/add_cdn.rb
59
+ - lib/cocoapods-repo-tal/command/repo/lint.rb
60
+ - lib/cocoapods-repo-tal/command/repo/list.rb
61
+ - lib/cocoapods-repo-tal/command/repo/push.rb
62
+ - lib/cocoapods-repo-tal/command/repo/remove.rb
63
+ - lib/cocoapods-repo-tal/command/repo/update.rb
64
+ - lib/cocoapods-repo-tal/command/repo_tal.rb
65
+ - lib/cocoapods-repo-tal/gem_version.rb
66
+ - lib/cocoapods_plugin.rb
67
+ - spec/command/repo_push_tal_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: https://github.com/EXAMPLE/cocoapods-repo-tal
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.0.4
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A longer description of cocoapods-repo-tal.
92
+ test_files:
93
+ - spec/command/repo_push_tal_spec.rb
94
+ - spec/spec_helper.rb