cocoapods-sync-podspecs 0.1.3 → 0.1.9
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 +4 -4
- data/lib/cocoapods_plugin.rb +1 -0
- data/lib/pod/command/bump-version.rb +24 -101
- data/lib/pod/command/push-tag.rb +188 -0
- data/lib/pod/command/sync-podspec.rb +0 -14
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b1b2b81372c2ca12b4259f1a260873f3de93e8649945c39ae3cb891787d65ea
|
4
|
+
data.tar.gz: 6b1372504d4f1e31b1f124da1a32a4c7fa117b53b89cfffc707c4f1c00bfeab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0413886e0cccff9a7bb3d669a90df6c1f34e28d432b19c117f8b4cd1c9fd5d2089468bfd908538271c37089f1f504c39afaf1002e372b5d1cd4531bf24c131c9'
|
7
|
+
data.tar.gz: d5b2d4d06718c4f40614b87932270f3ee7b9cc2b48f9c596b37c5a53e1994cad8b8b85ee607e21749defcb9c14b42a13fba96ce17f5755d6c6abcf6ff566bb08
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
|
1
5
|
module Pod
|
2
6
|
class Command
|
3
7
|
class Repo < Command
|
@@ -6,6 +10,7 @@ module Pod
|
|
6
10
|
|
7
11
|
self.description = <<-DESC
|
8
12
|
Validates `NAME.podspec` or `*.podspec` in the current working dir
|
13
|
+
`pod repo bump 0.1.0`
|
9
14
|
DESC
|
10
15
|
|
11
16
|
self.arguments = [
|
@@ -13,15 +18,11 @@ module Pod
|
|
13
18
|
]
|
14
19
|
|
15
20
|
def self.options
|
16
|
-
[
|
17
|
-
['--tag=VERSION', 'The `tag` that should be used when pushing. ']
|
18
|
-
].concat(super)
|
21
|
+
[].concat(super)
|
19
22
|
end
|
20
23
|
|
21
24
|
def initialize(argv)
|
22
|
-
@
|
23
|
-
@tag_version = argv.option('tag', nil)
|
24
|
-
@current_repo_dir = ''
|
25
|
+
@tag_version = argv.shift_argument
|
25
26
|
super
|
26
27
|
end
|
27
28
|
|
@@ -31,7 +32,7 @@ module Pod
|
|
31
32
|
unless @tag_version
|
32
33
|
raise Informative,
|
33
34
|
"A bump version is required." \
|
34
|
-
'`pod repo bump
|
35
|
+
'`pod repo bump 0.1.0`.'
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -39,36 +40,11 @@ module Pod
|
|
39
40
|
podspec_files.each do |spec_file|
|
40
41
|
spec = Pod::Specification.from_file(spec_file)
|
41
42
|
if @tag_version.to_s != spec.version.to_s
|
42
|
-
|
43
|
-
|
44
|
-
check_repo_status(spec.name, Pathname(spec_file).dirname)
|
45
|
-
update_repo(spec.name, Pathname(spec_file).dirname)
|
46
|
-
|
47
|
-
modify_podspec(spec_file, @tag_version)
|
48
|
-
|
49
|
-
message = "Bump version #{@tag_version}"
|
50
|
-
podspec_name = "#{spec.name}.podspec"
|
51
|
-
|
52
|
-
raise Informative, "#{spec.name}: tag #{@tag_version} already exists" unless !pod_repo_git('tag').include?(@tag_version)
|
53
|
-
|
54
|
-
# only commit if modified
|
55
|
-
if pod_repo_git('status', '--porcelain').include?(podspec_name)
|
56
|
-
pod_repo_git('add', podspec_name)
|
57
|
-
pod_repo_git('commit', '--no-verify', '-m', message)
|
58
|
-
push_pod_repo(spec.name)
|
59
|
-
|
60
|
-
pod_repo_git('tag', '-a', @tag_version, '-m', message)
|
61
|
-
push_tag_repo
|
62
|
-
else
|
63
|
-
UI.puts " - [No change] #{spec.name}: #{@tag_version}"
|
64
|
-
end
|
43
|
+
modify_podspec(spec_file, @tag_version)
|
65
44
|
else
|
66
45
|
UI.puts " - [No change] #{spec.name}: #{@tag_version}"
|
67
46
|
end
|
68
|
-
|
69
47
|
end
|
70
|
-
|
71
|
-
|
72
48
|
end
|
73
49
|
|
74
50
|
def modify_podspec(path, version)
|
@@ -101,77 +77,24 @@ module Pod
|
|
101
77
|
|
102
78
|
end
|
103
79
|
|
104
|
-
#---------------------------------------------------------------------#
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
# @!group Push sub-steps
|
109
|
-
|
110
|
-
extend Executable
|
111
|
-
executable :git
|
112
|
-
|
113
|
-
|
114
|
-
# Checks that the repo is clean.
|
115
|
-
#
|
116
|
-
# @raise If the repo is not clean.
|
117
|
-
#
|
118
|
-
# @todo Add specs for staged and unstaged files.
|
119
|
-
#
|
120
|
-
# @todo Gracefully handle the case where source is not under git
|
121
|
-
# source control.
|
122
|
-
#
|
123
|
-
# @return [void]
|
124
|
-
#
|
125
|
-
def check_repo_status(name, dir)
|
126
|
-
porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => dir)
|
127
|
-
clean = porcelain_status == ''
|
128
|
-
raise Informative, "The repo `#{name}` is not clean" unless clean
|
129
|
-
end
|
130
|
-
|
131
|
-
# Updates the git repo against the remote.
|
132
|
-
#
|
133
|
-
# @return [void]
|
134
|
-
#
|
135
|
-
def update_repo(name, dir)
|
136
|
-
UI.puts "Updating the `#{name}' repo\n".yellow
|
137
|
-
git!(%W(-C #{dir} pull))
|
138
|
-
end
|
139
|
-
|
140
|
-
# Pushes the git repo against the remote.
|
141
|
-
#
|
142
|
-
# @return [void]
|
143
|
-
#
|
144
|
-
def push_pod_repo(name)
|
145
|
-
UI.puts "\nPushing the `#{name}' repo\n".yellow
|
146
|
-
pod_repo_git('push', 'origin', 'HEAD')
|
147
|
-
end
|
148
|
-
|
149
|
-
def push_tag_repo
|
150
|
-
UI.puts "\nPushing the `#{@tag_version}' tag\n".yellow
|
151
|
-
pod_repo_git('push', 'origin', @tag_version)
|
152
|
-
end
|
153
|
-
|
154
|
-
#---------------------------------------------------------------------#
|
155
|
-
|
156
|
-
private
|
157
|
-
|
158
|
-
def pod_repo_git(*args)
|
159
|
-
git!(['-C', @current_repo_dir] + args)
|
160
|
-
end
|
161
|
-
|
162
|
-
|
163
80
|
# @return [Array<Pathname>] The path of the specifications to push.
|
164
81
|
#
|
82
|
+
# def podspec_files
|
83
|
+
# if @podspec
|
84
|
+
# path = Pathname(@podspec)
|
85
|
+
# raise Informative, "Couldn't find #{@podspec}" unless path.exist?
|
86
|
+
# [path]
|
87
|
+
# else
|
88
|
+
# files = Pathname.glob('**/*.podspec')
|
89
|
+
# raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
|
90
|
+
# files
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
|
165
94
|
def podspec_files
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
[path]
|
170
|
-
else
|
171
|
-
files = Pathname.glob('**/*.podspec')
|
172
|
-
raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
|
173
|
-
files
|
174
|
-
end
|
95
|
+
files = Pathname.glob('**/*.podspec')
|
96
|
+
raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
|
97
|
+
files
|
175
98
|
end
|
176
99
|
|
177
100
|
#---------------------------------------------------------------------#
|
@@ -0,0 +1,188 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Push < Command
|
4
|
+
class Tag < Push
|
5
|
+
self.summary = 'Bump the version number'
|
6
|
+
|
7
|
+
self.description = <<-DESC
|
8
|
+
Validates `NAME.podspec` or `*.podspec` in the current working dir
|
9
|
+
`pod push tag [VERSION]`
|
10
|
+
DESC
|
11
|
+
|
12
|
+
self.arguments = [
|
13
|
+
CLAide::Argument.new('Version', false),
|
14
|
+
]
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
['--local-only', 'Does not perform the step of pushing REPO to its remote'],
|
19
|
+
['--ignore-exists', 'Ignore exists tag'],
|
20
|
+
['--force', 'Force create new tag'],
|
21
|
+
].concat(super)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@force_create_tag = argv.flag?('force')
|
26
|
+
@ignore_exists = argv.flag?('ignore-exists')
|
27
|
+
@local_only = argv.flag?('local-only')
|
28
|
+
@tag_version = argv.shift_argument
|
29
|
+
@current_repo_dir = ''
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!
|
34
|
+
super
|
35
|
+
# help! 'A bump version is required.' unless @tag_version
|
36
|
+
# unless @tag_version
|
37
|
+
# raise Informative,
|
38
|
+
# "A tag version is required." \
|
39
|
+
# '`pod push tag 0.1.0`.'
|
40
|
+
# end
|
41
|
+
end
|
42
|
+
|
43
|
+
def run
|
44
|
+
podspec_files.each do |spec_file|
|
45
|
+
spec = Pod::Specification.from_file(spec_file)
|
46
|
+
|
47
|
+
@tag_version = spec.version.to_s unless !@tag_version.nil?
|
48
|
+
@current_repo_dir = Pathname(spec_file).dirname
|
49
|
+
|
50
|
+
# check_repo_status(spec.name, Pathname(spec_file).dirname)
|
51
|
+
# update_repo(spec.name, Pathname(spec_file).dirname)
|
52
|
+
|
53
|
+
exists_tag = pod_repo_git('tag').include?(@tag_version)
|
54
|
+
if exists_tag && !@ignore_exists
|
55
|
+
raise Informative, "#{spec.name}: tag #{@tag_version} already exists"
|
56
|
+
end
|
57
|
+
|
58
|
+
UI.puts "#{spec.name}: tag #{@tag_version} already exists".red unless !exists_tag
|
59
|
+
commit_then_push(spec.name) unless exists_tag
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def commit_then_push(name)
|
65
|
+
message = "[#{name}] Bump version #{@tag_version}"
|
66
|
+
podspec_name = "#{name}.podspec"
|
67
|
+
|
68
|
+
# only commit if modified
|
69
|
+
if pod_repo_git('status', '--porcelain').include?(podspec_name)
|
70
|
+
pod_repo_git('add', '*.podspec')
|
71
|
+
pod_repo_git('commit', '--no-verify', '-m', message)
|
72
|
+
push_pod_repo(name) unless @local_only
|
73
|
+
|
74
|
+
pod_repo_git('tag', '-a', @tag_version, '-m', message)
|
75
|
+
push_tag_repo
|
76
|
+
elsif @force_create_tag
|
77
|
+
check_repo_status(name, @current_repo_dir)
|
78
|
+
update_repo(name, @current_repo_dir)
|
79
|
+
|
80
|
+
pod_repo_git('tag', '-a', @tag_version, '-m', message)
|
81
|
+
push_tag_repo
|
82
|
+
else
|
83
|
+
UI.puts " - [No change] #{name}: #{@tag_version}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def modify_podspec(path, version)
|
88
|
+
unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/
|
89
|
+
UI.puts "s.version: not found"
|
90
|
+
return
|
91
|
+
end
|
92
|
+
unless File.exist?path
|
93
|
+
UI.puts "Podspec file not found"
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
File.open(path, "r+") do |f|
|
98
|
+
s = ""
|
99
|
+
f.each_line do |line|
|
100
|
+
if line.to_s =~ /s\.version\s*=\s*"(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})"/
|
101
|
+
line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
|
102
|
+
version.to_s
|
103
|
+
end
|
104
|
+
end
|
105
|
+
if line.to_s =~ /s\.version\s*=\s*'(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})'/
|
106
|
+
line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
|
107
|
+
version.to_s
|
108
|
+
end
|
109
|
+
end
|
110
|
+
s += line
|
111
|
+
end
|
112
|
+
File.open(path, "w+") do |f| f.write(s) end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
#---------------------------------------------------------------------#
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
# @!group Push sub-steps
|
122
|
+
|
123
|
+
extend Executable
|
124
|
+
executable :git
|
125
|
+
|
126
|
+
|
127
|
+
# Checks that the repo is clean.
|
128
|
+
#
|
129
|
+
# @raise If the repo is not clean.
|
130
|
+
#
|
131
|
+
# @todo Add specs for staged and unstaged files.
|
132
|
+
#
|
133
|
+
# @todo Gracefully handle the case where source is not under git
|
134
|
+
# source control.
|
135
|
+
#
|
136
|
+
# @return [void]
|
137
|
+
#
|
138
|
+
def check_repo_status(name, dir)
|
139
|
+
porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => dir)
|
140
|
+
clean = porcelain_status == ''
|
141
|
+
raise Informative, "The repo `#{name}` is not clean" unless clean
|
142
|
+
end
|
143
|
+
|
144
|
+
# Updates the git repo against the remote.
|
145
|
+
#
|
146
|
+
# @return [void]
|
147
|
+
#
|
148
|
+
def update_repo(name, dir)
|
149
|
+
UI.puts "Updating the `#{name}' repo\n".yellow
|
150
|
+
git!(%W(-C #{dir} pull))
|
151
|
+
end
|
152
|
+
|
153
|
+
# Pushes the git repo against the remote.
|
154
|
+
#
|
155
|
+
# @return [void]
|
156
|
+
#
|
157
|
+
def push_pod_repo(name)
|
158
|
+
UI.puts "\nPushing the `#{name}' repo\n".yellow
|
159
|
+
pod_repo_git('push', 'origin', 'HEAD')
|
160
|
+
end
|
161
|
+
|
162
|
+
def push_tag_repo
|
163
|
+
UI.puts "\nPushing the `#{@tag_version}' tag\n".yellow
|
164
|
+
pod_repo_git('push', 'origin', @tag_version)
|
165
|
+
end
|
166
|
+
|
167
|
+
#---------------------------------------------------------------------#
|
168
|
+
|
169
|
+
private
|
170
|
+
|
171
|
+
def pod_repo_git(*args)
|
172
|
+
git!(['-C', @current_repo_dir] + args)
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
# @return [Array<Pathname>] The path of the specifications to push.
|
177
|
+
#
|
178
|
+
def podspec_files
|
179
|
+
files = Pathname.glob('**/*.podspec')
|
180
|
+
raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
|
181
|
+
files
|
182
|
+
end
|
183
|
+
|
184
|
+
#---------------------------------------------------------------------#
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -22,40 +22,26 @@ module Pod
|
|
22
22
|
|
23
23
|
def self.options
|
24
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
25
|
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to pull dependent pods ' \
|
29
26
|
'(defaults to all available repos). Multiple sources must be comma-delimited'],
|
30
27
|
['--local-only', 'Does not perform the step of pushing REPO to its remote'],
|
31
|
-
['--no-private', 'Lint includes checks that apply only to public repos'],
|
32
|
-
['--skip-import-validation', 'Lint skips validating that the pod can be imported'],
|
33
|
-
['--skip-tests', 'Lint skips building and running tests during validation'],
|
34
28
|
['--commit-message="Fix bug in pod"', 'Add custom commit message. Opens default editor if no commit ' \
|
35
29
|
'message is specified'],
|
36
30
|
['--use-json', 'Convert the podspec to JSON before pushing it to the repo'],
|
37
|
-
['--swift-version=VERSION', 'The `SWIFT_VERSION` that should be used when linting the spec. ' \
|
38
|
-
'This takes precedence over the Swift versions specified by the spec or a `.swift-version` file'],
|
39
31
|
['--no-overwrite', 'Disallow pushing that would overwrite an existing spec'],
|
40
32
|
].concat(super)
|
41
33
|
end
|
42
34
|
|
43
35
|
def initialize(argv)
|
44
|
-
@allow_warnings = argv.flag?('allow-warnings')
|
45
36
|
@local_only = argv.flag?('local-only')
|
46
37
|
@repo = argv.shift_argument
|
47
38
|
@source = source_for_repo
|
48
39
|
@source_urls = argv.option('sources', config.sources_manager.all.map(&:url).join(',')).split(',')
|
49
40
|
@podspec = argv.shift_argument
|
50
|
-
@use_frameworks = !argv.flag?('use-libraries')
|
51
|
-
@use_modular_headers = argv.flag?('use-modular-headers', false)
|
52
41
|
@private = argv.flag?('private', true)
|
53
42
|
@message = argv.option('commit-message')
|
54
43
|
@commit_message = argv.flag?('commit-message', false)
|
55
44
|
@use_json = argv.flag?('use-json')
|
56
|
-
@swift_version = argv.option('swift-version', nil)
|
57
|
-
@skip_import_validation = argv.flag?('skip-import-validation', false)
|
58
|
-
@skip_tests = argv.flag?('skip-tests', false)
|
59
45
|
@allow_overwrite = argv.flag?('overwrite', true)
|
60
46
|
super
|
61
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-sync-podspecs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- quangmv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- lib/cocoapods_plugin.rb
|
35
35
|
- lib/pod/command/bump-version.rb
|
36
|
+
- lib/pod/command/push-tag.rb
|
36
37
|
- lib/pod/command/sync-podspec.rb
|
37
38
|
homepage: https://github.com/quangmv
|
38
39
|
licenses:
|