cocoapods-sync-podspecs 0.1.4 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c21e68ee6943762c059a0f42ad5ed18804a3cfa65f6889780afc454d8925a57
4
- data.tar.gz: a28e4866e2192d2ce7d8e988921cb36456f53e55c96de246e945bad7df0e4e7f
3
+ metadata.gz: 1bc4299d0cf481c90f94ce883854a33422a784fe7198839d73d3aea38cc9c484
4
+ data.tar.gz: d728a82ab94e78bc206e02f68dad9c5aa64d8c3852f4542a191835db55885249
5
5
  SHA512:
6
- metadata.gz: 8dfd65526f0e54d6008a7113b361fd6994372602ceb2c32a0697f665c5874ccb87a253cfa8b2d91f9180a55465e68069b6b0994cdd32043ffe1666efcdcbd4cc
7
- data.tar.gz: 6c902c1d12b6221ed474612bd0cb1d5cd759d1c19b398fdb051a1dd4703632c7766ab1eed1def716bf8e5d2be13ae5d8788b22dbf437ae23d8a4320e1464ceaf
6
+ metadata.gz: 3404d5303a94a6747df3d4678805ac6e14e27c051e6731310335cf1ad9fd5d3b9c8b3bdf243899f55a01d834159499f059aaaf42bd562a47452584a1ef5133e5
7
+ data.tar.gz: f2094f2d8f1234db3f820cab0a21cec3e7e6866a019847e6b1f662c18ec35a17051868cb8dc9ac651eb1ae17d12fb93e6f2a8aafe7c79581a96cb76a9a865134
@@ -1,2 +1,3 @@
1
1
  require 'pod/command/sync-podspec'
2
2
  require 'pod/command/bump-version'
3
+ require 'pod/command/push-tag'
@@ -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
- @podspec = argv.shift_argument
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 --tag 0.1.0`.'
35
+ '`pod repo bump 0.1.0`.'
35
36
  end
36
37
  end
37
38
 
@@ -39,43 +40,19 @@ 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
- @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
- message = "Bump version #{@tag_version}"
48
- podspec_name = "#{spec.name}.podspec"
49
-
50
- raise Informative, "#{spec.name}: tag #{@tag_version} already exists" unless !pod_repo_git('tag').include?(@tag_version)
51
-
52
- modify_podspec(spec_file, @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)
75
- unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/
76
- UI.puts "s.version: not found"
51
+ unless version =~ /^(\d+\.)?(\d+\.)?(\*|\d+)$/
52
+ UI.puts "Invalid version #{version}"
77
53
  return
78
54
  end
55
+
79
56
  unless File.exist?path
80
57
  UI.puts "Podspec file not found"
81
58
  return
@@ -84,13 +61,8 @@ module Pod
84
61
  File.open(path, "r+") do |f|
85
62
  s = ""
86
63
  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|
64
+ if line.to_s =~ /s\.version\s*=\s*'|"(\d+\.)?(\d+\.)?(\*|\d+)'|"/
65
+ line = line.sub(/(\d+\.)?(\d+\.)?(\*|\d+)/) do |match|
94
66
  version.to_s
95
67
  end
96
68
  end
@@ -98,80 +70,26 @@ module Pod
98
70
  end
99
71
  File.open(path, "w+") do |f| f.write(s) end
100
72
  end
101
-
102
73
  end
103
74
 
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
75
  # @return [Array<Pathname>] The path of the specifications to push.
164
76
  #
77
+ # def podspec_files
78
+ # if @podspec
79
+ # path = Pathname(@podspec)
80
+ # raise Informative, "Couldn't find #{@podspec}" unless path.exist?
81
+ # [path]
82
+ # else
83
+ # files = Pathname.glob('**/*.podspec')
84
+ # raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
85
+ # files
86
+ # end
87
+ # end
88
+
165
89
  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
90
+ files = Pathname.glob('**/*.podspec')
91
+ raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
92
+ files
175
93
  end
176
94
 
177
95
  #---------------------------------------------------------------------#
@@ -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
4
+ version: 0.1.10
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-04 00:00:00.000000000 Z
11
+ date: 2021-01-06 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: