cocoapods-sync-podspecs 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9949236d4bb1f4a045d5934ad00958169104d8400d298efacbd1dd0c223c03bc
4
- data.tar.gz: 7f04ff086bfed0345253b3e4b157e62a3702770ba579ed3303f039c0745f15b6
3
+ metadata.gz: 1c6aaec1f4c6f969d9d06ce4cf3acfce34a1afec39fab20e9b5b3224cd611991
4
+ data.tar.gz: 4c31d3d2b22e83c26cd0265bc8a6c26f91d99c9a1379e4dcb24464a53660d462
5
5
  SHA512:
6
- metadata.gz: 6d57137ff8c2aa78984021d5f83b940537f7cb695997d366bb40c1a9451d8640e419d89da76b204af0931c59173d0f6d82960a40aaf99e2e614f86814b7d0ce2
7
- data.tar.gz: 91041205968787ae2ee05e9aa3e9450b901c605b7c704fa53dec6b9323fda3da7bea7aa8d0faa3aada42d9fe9de06caf371f49248790fcef9e3eef3e55e4c560
6
+ metadata.gz: 59d1102c84e62de4c2d5104891b96b969b3c34a9d0b8cc37756387e46cfc12d768cfece8aabdc42e59203d38e84a46ded89a0adaf5ed9905377585c7c887ebd3
7
+ data.tar.gz: 8a5b9155f333f7c408d9e0e163368ea82349a29397075af30adbdb3e54fbb4f471c3b1508aa1f66736217bfea98526b6b346ce1f4b8691e0623050ed231dfac9
@@ -1 +1,2 @@
1
1
  require 'pod/command/sync-podspec'
2
+ require 'pod/command/bump-version'
@@ -0,0 +1,181 @@
1
+ module Pod
2
+ class Command
3
+ class Repo < Command
4
+ class Bump < Repo
5
+ self.summary = 'Bump the version number'
6
+
7
+ self.description = <<-DESC
8
+ Validates `NAME.podspec` or `*.podspec` in the current working dir
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('NAME.podspec', false),
13
+ ]
14
+
15
+ def self.options
16
+ [
17
+ ['--tag=VERSION', 'The `tag` that should be used when pushing. ']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @podspec = argv.shift_argument
23
+ @tag_version = argv.option('tag', nil)
24
+ @current_repo_dir = ''
25
+ super
26
+ end
27
+
28
+ def validate!
29
+ super
30
+ help! 'A bump version is required.' unless @tag_version
31
+ unless @tag_version
32
+ raise Informative,
33
+ "A bump version is required." \
34
+ '`pod repo bump --tag 0.1.0`.'
35
+ end
36
+ end
37
+
38
+ def run
39
+ podspec_files.each do |spec_file|
40
+ spec = Pod::Specification.from_file(spec_file)
41
+ if @tag_version.to_s != spec.version.to_s
42
+ @current_repo_dir = Pathname(spec_file).dirname
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
65
+ else
66
+ UI.puts " - [No change] #{spec.name}: #{@tag_version}"
67
+ end
68
+
69
+ end
70
+
71
+
72
+ end
73
+
74
+ def modify_podspec(path, version)
75
+ unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/
76
+ UI.puts "s.version: not found"
77
+ return
78
+ end
79
+ unless File.exist?path
80
+ UI.puts "Podspec file not found"
81
+ return
82
+ end
83
+
84
+ File.open(path, "r+") do |f|
85
+ s = ""
86
+ f.each_line do |line|
87
+ if line.to_s =~ /s\.version\s*=\s*"(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})"/
88
+ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
89
+ version.to_s
90
+ end
91
+ end
92
+ if line.to_s =~ /s\.version\s*=\s*'(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})'/
93
+ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
94
+ version.to_s
95
+ end
96
+ end
97
+ s += line
98
+ end
99
+ File.open(path, "w+") do |f| f.write(s) end
100
+ end
101
+
102
+ end
103
+
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
+ # @return [Array<Pathname>] The path of the specifications to push.
164
+ #
165
+ def podspec_files
166
+ if @podspec
167
+ path = Pathname(@podspec)
168
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
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
175
+ end
176
+
177
+ #---------------------------------------------------------------------#
178
+ end
179
+ end
180
+ end
181
+ 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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - quangmv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-28 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -32,6 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/cocoapods_plugin.rb
35
+ - lib/pod/command/bump-version.rb
35
36
  - lib/pod/command/sync-podspec.rb
36
37
  homepage: https://github.com/quangmv
37
38
  licenses: