cocoapods-sync-podspecs 0.1.4 → 0.1.6

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: e90ef066f8454bf69a1636caae64c7c701821a356f96778a34eaf13dec211755
4
+ data.tar.gz: 1c063803b6d5dd488ee08316983dabf5ec1b4439da2977d9b9d656636585caa5
5
5
  SHA512:
6
- metadata.gz: 8dfd65526f0e54d6008a7113b361fd6994372602ceb2c32a0697f665c5874ccb87a253cfa8b2d91f9180a55465e68069b6b0994cdd32043ffe1666efcdcbd4cc
7
- data.tar.gz: 6c902c1d12b6221ed474612bd0cb1d5cd759d1c19b398fdb051a1dd4703632c7766ab1eed1def716bf8e5d2be13ae5d8788b22dbf437ae23d8a4320e1464ceaf
6
+ metadata.gz: 26a43c8410fabb3393bd6af42907690a9c22d80ea2aff366640ddc3e16ea3eaf52d8d168612527e5ffe0422f7331bce44287519d12835d8a13499896589479b3
7
+ data.tar.gz: 3a00ca062f8effd6559486c45ebbe5eac96c680b2ae550c32cfc44859ccf7e3a26023b1776489c8c96a91ab5c913cdb4e165636d2d65bab7d280a8c19f0c0d54
@@ -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,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
- @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)
@@ -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
- 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
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,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
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.6
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-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: