cocoapods-sync-podspecs 0.1.1 → 0.1.7

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: 9949236d4bb1f4a045d5934ad00958169104d8400d298efacbd1dd0c223c03bc
4
- data.tar.gz: 7f04ff086bfed0345253b3e4b157e62a3702770ba579ed3303f039c0745f15b6
3
+ metadata.gz: dfc8e42e680dd38829c65f59424181ca505c9fc3e7f052c8bc93a84dee0b4609
4
+ data.tar.gz: c3296f5cb47eda5c14f5107413b0d6b1edd79ad58c938875d63eb332769c16df
5
5
  SHA512:
6
- metadata.gz: 6d57137ff8c2aa78984021d5f83b940537f7cb695997d366bb40c1a9451d8640e419d89da76b204af0931c59173d0f6d82960a40aaf99e2e614f86814b7d0ce2
7
- data.tar.gz: 91041205968787ae2ee05e9aa3e9450b901c605b7c704fa53dec6b9323fda3da7bea7aa8d0faa3aada42d9fe9de06caf371f49248790fcef9e3eef3e55e4c560
6
+ metadata.gz: db993638153b0c4215666eacaae095784462dcf7b79d521e4e312ba4fb4d20c07ecfcd9b9944b1a55320b9fea8c55d5f4ee355b1584c30996a579bbadd7087bc
7
+ data.tar.gz: f733256a0f7d53759555df4ffc1b64818572a6208c572f71dba84691f983ff481486875c939c3326cdcf72d6b0cc382d7837b2bd73dffccec1672328dd35dffc
@@ -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,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.1
4
+ version: 0.1.7
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
@@ -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: