cocoapods-sync-podspecs 0.1.0 → 0.1.6

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: ee6b08678ab0ccf4ea0ef2f183b5ecafdad23377363f541d83e29c08881000dc
4
- data.tar.gz: e0abbd834a82136825c61461f2471f1f78e42d4a264eb05df22a83b38f817739
3
+ metadata.gz: e90ef066f8454bf69a1636caae64c7c701821a356f96778a34eaf13dec211755
4
+ data.tar.gz: 1c063803b6d5dd488ee08316983dabf5ec1b4439da2977d9b9d656636585caa5
5
5
  SHA512:
6
- metadata.gz: ae6beeefa61d9c3c9bdc7b5c5eb77a80ee5b70f52fb866f14d01945cf1e5a4ef59df1d742c6920f3b495ddab851cc3210c9ece33066e671d89b2e020fc9f5185
7
- data.tar.gz: 54a88c14faeaef50a24485184267211d824f125a133797738d0e0b4eb4d380872d29969b69dd5a611a2114cd6c0f4c75e058719a35ae2be4de8470bd8ea9e3c9
6
+ metadata.gz: 26a43c8410fabb3393bd6af42907690a9c22d80ea2aff366640ddc3e16ea3eaf52d8d168612527e5ffe0422f7331bce44287519d12835d8a13499896589479b3
7
+ data.tar.gz: 3a00ca062f8effd6559486c45ebbe5eac96c680b2ae550c32cfc44859ccf7e3a26023b1776489c8c96a91ab5c913cdb4e165636d2d65bab7d280a8c19f0c0d54
@@ -1 +1,3 @@
1
1
  require 'pod/command/sync-podspec'
2
+ require 'pod/command/bump-version'
3
+ require 'pod/command/push-tag'
@@ -0,0 +1,104 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module Pod
6
+ class Command
7
+ class Repo < Command
8
+ class Bump < Repo
9
+ self.summary = 'Bump the version number'
10
+
11
+ self.description = <<-DESC
12
+ Validates `NAME.podspec` or `*.podspec` in the current working dir
13
+ `pod repo bump 0.1.0`
14
+ DESC
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new('NAME.podspec', false),
18
+ ]
19
+
20
+ def self.options
21
+ [].concat(super)
22
+ end
23
+
24
+ def initialize(argv)
25
+ @tag_version = argv.shift_argument
26
+ super
27
+ end
28
+
29
+ def validate!
30
+ super
31
+ help! 'A bump version is required.' unless @tag_version
32
+ unless @tag_version
33
+ raise Informative,
34
+ "A bump version is required." \
35
+ '`pod repo bump 0.1.0`.'
36
+ end
37
+ end
38
+
39
+ def run
40
+ podspec_files.each do |spec_file|
41
+ spec = Pod::Specification.from_file(spec_file)
42
+ if @tag_version.to_s != spec.version.to_s
43
+ modify_podspec(spec_file, @tag_version)
44
+ else
45
+ UI.puts " - [No change] #{spec.name}: #{@tag_version}"
46
+ end
47
+ end
48
+ end
49
+
50
+ def modify_podspec(path, version)
51
+ unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/
52
+ UI.puts "s.version: not found"
53
+ return
54
+ end
55
+ unless File.exist?path
56
+ UI.puts "Podspec file not found"
57
+ return
58
+ end
59
+
60
+ File.open(path, "r+") do |f|
61
+ s = ""
62
+ f.each_line do |line|
63
+ if line.to_s =~ /s\.version\s*=\s*"(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})"/
64
+ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
65
+ version.to_s
66
+ end
67
+ end
68
+ if line.to_s =~ /s\.version\s*=\s*'(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})'/
69
+ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
70
+ version.to_s
71
+ end
72
+ end
73
+ s += line
74
+ end
75
+ File.open(path, "w+") do |f| f.write(s) end
76
+ end
77
+
78
+ end
79
+
80
+ # @return [Array<Pathname>] The path of the specifications to push.
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
+
94
+ def podspec_files
95
+ files = Pathname.glob('**/*.podspec')
96
+ raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
97
+ files
98
+ end
99
+
100
+ #---------------------------------------------------------------------#
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,180 @@
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
+ ].concat(super)
21
+ end
22
+
23
+ def initialize(argv)
24
+ @ignore_exists = argv.flag?('ignore-exists')
25
+ @local_only = argv.flag?('local-only')
26
+ @tag_version = argv.shift_argument
27
+ @current_repo_dir = ''
28
+ super
29
+ end
30
+
31
+ def validate!
32
+ super
33
+ # help! 'A bump version is required.' unless @tag_version
34
+ # unless @tag_version
35
+ # raise Informative,
36
+ # "A tag version is required." \
37
+ # '`pod push tag 0.1.0`.'
38
+ # end
39
+ end
40
+
41
+ def run
42
+ podspec_files.each do |spec_file|
43
+ spec = Pod::Specification.from_file(spec_file)
44
+
45
+ @tag_version = spec.version.to_s unless !@tag_version.nil?
46
+ @current_repo_dir = Pathname(spec_file).dirname
47
+
48
+ # check_repo_status(spec.name, Pathname(spec_file).dirname)
49
+ # update_repo(spec.name, Pathname(spec_file).dirname)
50
+
51
+ exists_tag = pod_repo_git('tag').include?(@tag_version)
52
+ if exists_tag && !@ignore_exists
53
+ raise Informative, "#{spec.name}: tag #{@tag_version} already exists"
54
+ end
55
+
56
+ UI.puts "#{spec.name}: tag #{@tag_version} already exists".red unless !exists_tag
57
+ commit_then_push(spec.name) unless exists_tag
58
+
59
+ end
60
+ end
61
+
62
+ def commit_then_push(name)
63
+ message = "[#{name}] Bump version #{@tag_version}"
64
+ podspec_name = "#{name}.podspec"
65
+
66
+ # only commit if modified
67
+ if pod_repo_git('status', '--porcelain').include?(podspec_name)
68
+ pod_repo_git('add', '*.podspec')
69
+ pod_repo_git('commit', '--no-verify', '-m', message)
70
+ push_pod_repo(name) unless @local_only
71
+
72
+ pod_repo_git('tag', '-a', @tag_version, '-m', message)
73
+ push_tag_repo
74
+ else
75
+ UI.puts " - [No change] #{name}: #{@tag_version}"
76
+ end
77
+ end
78
+
79
+ def modify_podspec(path, version)
80
+ unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/
81
+ UI.puts "s.version: not found"
82
+ return
83
+ end
84
+ unless File.exist?path
85
+ UI.puts "Podspec file not found"
86
+ return
87
+ end
88
+
89
+ File.open(path, "r+") do |f|
90
+ s = ""
91
+ f.each_line do |line|
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
+ if line.to_s =~ /s\.version\s*=\s*'(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})'/
98
+ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match|
99
+ version.to_s
100
+ end
101
+ end
102
+ s += line
103
+ end
104
+ File.open(path, "w+") do |f| f.write(s) end
105
+ end
106
+
107
+ end
108
+
109
+ #---------------------------------------------------------------------#
110
+
111
+ private
112
+
113
+ # @!group Push sub-steps
114
+
115
+ extend Executable
116
+ executable :git
117
+
118
+
119
+ # Checks that the repo is clean.
120
+ #
121
+ # @raise If the repo is not clean.
122
+ #
123
+ # @todo Add specs for staged and unstaged files.
124
+ #
125
+ # @todo Gracefully handle the case where source is not under git
126
+ # source control.
127
+ #
128
+ # @return [void]
129
+ #
130
+ def check_repo_status(name, dir)
131
+ porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => dir)
132
+ clean = porcelain_status == ''
133
+ raise Informative, "The repo `#{name}` is not clean" unless clean
134
+ end
135
+
136
+ # Updates the git repo against the remote.
137
+ #
138
+ # @return [void]
139
+ #
140
+ def update_repo(name, dir)
141
+ UI.puts "Updating the `#{name}' repo\n".yellow
142
+ git!(%W(-C #{dir} pull))
143
+ end
144
+
145
+ # Pushes the git repo against the remote.
146
+ #
147
+ # @return [void]
148
+ #
149
+ def push_pod_repo(name)
150
+ UI.puts "\nPushing the `#{name}' repo\n".yellow
151
+ pod_repo_git('push', 'origin', 'HEAD')
152
+ end
153
+
154
+ def push_tag_repo
155
+ UI.puts "\nPushing the `#{@tag_version}' tag\n".yellow
156
+ pod_repo_git('push', 'origin', @tag_version)
157
+ end
158
+
159
+ #---------------------------------------------------------------------#
160
+
161
+ private
162
+
163
+ def pod_repo_git(*args)
164
+ git!(['-C', @current_repo_dir] + args)
165
+ end
166
+
167
+
168
+ # @return [Array<Pathname>] The path of the specifications to push.
169
+ #
170
+ def podspec_files
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
+
176
+ #---------------------------------------------------------------------#
177
+ end
178
+ end
179
+ end
180
+ end
@@ -22,40 +22,27 @@ 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
31
  'This takes precedence over the Swift versions specified by the spec or a `.swift-version` file'],
39
32
  ['--no-overwrite', 'Disallow pushing that would overwrite an existing spec'],
40
33
  ].concat(super)
41
34
  end
42
35
 
43
36
  def initialize(argv)
44
- @allow_warnings = argv.flag?('allow-warnings')
45
37
  @local_only = argv.flag?('local-only')
46
38
  @repo = argv.shift_argument
47
39
  @source = source_for_repo
48
40
  @source_urls = argv.option('sources', config.sources_manager.all.map(&:url).join(',')).split(',')
49
41
  @podspec = argv.shift_argument
50
- @use_frameworks = !argv.flag?('use-libraries')
51
- @use_modular_headers = argv.flag?('use-modular-headers', false)
52
42
  @private = argv.flag?('private', true)
53
43
  @message = argv.option('commit-message')
54
44
  @commit_message = argv.flag?('commit-message', false)
55
45
  @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
46
  @allow_overwrite = argv.flag?('overwrite', true)
60
47
  super
61
48
  end
@@ -236,7 +223,7 @@ module Pod
236
223
  [path]
237
224
  else
238
225
  #files = Pathname.glob('*.podspec{,.json}')
239
- files = Pathname.glob('**/*.podspec{,.json}')
226
+ files = Pathname.glob('**/*.podspec')
240
227
  raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
241
228
  files
242
229
  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.0
4
+ version: 0.1.6
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-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.10.0
27
- description: Push new specifications to a spec-repo
27
+ description: Push new specifications to a spec-repo without lint validation
28
28
  email:
29
29
  - quang.app@gmail.com
30
30
  executables: []
@@ -32,6 +32,8 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/cocoapods_plugin.rb
35
+ - lib/pod/command/bump-version.rb
36
+ - lib/pod/command/push-tag.rb
35
37
  - lib/pod/command/sync-podspec.rb
36
38
  homepage: https://github.com/quangmv
37
39
  licenses:
@@ -55,5 +57,5 @@ requirements: []
55
57
  rubygems_version: 3.0.3
56
58
  signing_key:
57
59
  specification_version: 4
58
- summary: Push new specifications to a spec-repo without lint validation
60
+ summary: Push new specifications to a spec-repo
59
61
  test_files: []