podspecpush 0.5.0 → 0.9.0
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 +4 -4
- data/lib/podspecpush/version.rb +1 -1
- data/lib/podspecpush.rb +124 -79
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 460568fb63be21ba9618be857fe0a35272fe11d3
|
4
|
+
data.tar.gz: ad3614c557b408e525cfed115bdbf32281422477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6e283b1f7fc12a758d6229b1ede14164b83f28cbf345db9cee3ea3d06a18e863e615d8b09756c22ab8f4223d30da16e38d11b7df5d2b03cd45b09f5b9da7093
|
7
|
+
data.tar.gz: 7a8fc7db807d5819714d5608d10773bb4fc6ceec4519d78189dcce2908b009c92958c942e8460e10b120dd4241737deb27fefd26bcb4695f0d3e2d031c5c0495
|
data/lib/podspecpush/version.rb
CHANGED
data/lib/podspecpush.rb
CHANGED
@@ -1,106 +1,151 @@
|
|
1
1
|
require "podspecpush/version"
|
2
|
+
require 'colorize'
|
2
3
|
require 'trollop'
|
3
4
|
|
4
5
|
module Podspecpush
|
5
6
|
class PodPush
|
6
|
-
def push
|
7
|
-
opts = Trollop::options do
|
8
|
-
opt :repo, "Repo name", :type => :string
|
9
|
-
opt :sources, "List of private repo sources to consider when linting private repo", :type => :string
|
10
|
-
opt :force, "Pod verify & push with warnings"
|
11
|
-
opt :privateRepo, "If set, assume repo is private and skip public checks"
|
12
|
-
end
|
13
|
-
Trollop::die :repo, "Repo must be provided" if opts[:repo] == nil
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
def specfile
|
9
|
+
Dir["*.podspec"].first
|
10
|
+
end
|
11
|
+
|
12
|
+
def shouldUseBundleExec
|
13
|
+
File.exist?('Gemfile')
|
14
|
+
end
|
19
15
|
|
20
|
-
|
16
|
+
def ensureSpecfile
|
17
|
+
podspecFile = specfile
|
21
18
|
|
22
|
-
|
19
|
+
puts "No spec file found".red unless podspecFile != nil
|
20
|
+
exit unless podspecFile != nil
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
def ensureGitClean
|
24
|
+
if `git status --porcelain`.length != 0
|
25
|
+
puts "Repo is not clean; will not push new version".red
|
26
26
|
exit
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
idx = / s.version/ =~ line
|
35
|
-
if idx != nil && idx >= 0
|
36
|
-
startIdx = line.index("\'")
|
37
|
-
endIdx = line.index("\'", startIdx + 1)
|
38
|
-
currentVersion = line[startIdx + 1...endIdx]
|
39
|
-
if currentVersion == version
|
40
|
-
puts "Can't push same version silly!"
|
41
|
-
exit
|
42
|
-
end
|
43
|
-
line[startIdx +1 ...endIdx] = version
|
44
|
-
end
|
45
|
-
|
46
|
-
newFile += line
|
47
|
-
end
|
29
|
+
cmd = []
|
30
|
+
cmd << ['bundle exec'] if shouldUseBundleExec
|
31
|
+
cmd << ['pod cache clean --all'] if shouldUseBundleExec
|
32
|
+
system cmd.join(' ')
|
33
|
+
end
|
48
34
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
disallowWarningsLint = "pod spec lint #{podspecName}" + isPrivateFlag + sourcesFlag
|
54
|
-
allowWarningsLint = disallowWarningsLint + " --allow-warnings"
|
55
|
-
|
56
|
-
lintCmd = (force == true ? allowWarningsLint : disallowWarningsLint)
|
57
|
-
lint = system(lintCmd)
|
58
|
-
|
59
|
-
if lint == false
|
60
|
-
puts "Linting failed, try again by allowing warnings? [Y/n]"
|
61
|
-
decision = gets.chomp.downcase
|
62
|
-
if decision == "y"
|
63
|
-
tryAgainCmd = allowWarningsLint
|
64
|
-
tryAgain = system(tryAgainCmd)
|
65
|
-
|
66
|
-
if tryAgain == false
|
67
|
-
puts "Even with warnings, something is wrong. Look for any errors"
|
68
|
-
exit
|
69
|
-
else
|
70
|
-
puts "Proceeding by allowing warnings"
|
71
|
-
end
|
72
|
-
else
|
73
|
-
exit
|
74
|
-
end
|
75
|
-
end
|
35
|
+
def makeLintCmd(opts)
|
36
|
+
lintCmd = []
|
37
|
+
lintCmd << ['bundle exec'] if shouldUseBundleExec
|
38
|
+
lintCmd = ["pod spec lint"]
|
76
39
|
|
77
|
-
|
78
|
-
|
40
|
+
# Build sources
|
41
|
+
sources = ["https://github.com/CocoaPods/Specs.git"]
|
42
|
+
sources << opts[:sources] unless opts[:sources] == nil
|
43
|
+
sourcesArg = "--sources=" + sources.join(",")
|
79
44
|
|
80
|
-
|
81
|
-
|
82
|
-
|
45
|
+
# Build lintCmd
|
46
|
+
lintCmd << specfile
|
47
|
+
lintCmd << sourcesArg
|
48
|
+
lintCmd << ["--private"] unless opts[:private] == false
|
49
|
+
|
50
|
+
# finalize
|
51
|
+
lintCmd.join(' ')
|
52
|
+
end
|
53
|
+
|
54
|
+
def makePushCmd(opts)
|
55
|
+
cmd = []
|
56
|
+
cmd << ['bundle exec'] if shouldUseBundleExec
|
57
|
+
cmd << ["pod repo push #{opts[:specRepo]} #{specfile} --allow-warnings"]
|
58
|
+
|
59
|
+
cmd.join(' ')
|
60
|
+
end
|
61
|
+
|
62
|
+
def updateVersion
|
63
|
+
puts "Please enter new version of the pod so we can tag, lint and push it! (e.g. 1.2.0)".blue
|
64
|
+
@podVersion = gets.chomp.downcase
|
65
|
+
|
66
|
+
puts "Please enter new a brief message to put in the git tag describing what's changed".blue
|
67
|
+
@podVersionMessage = gets.chomp.downcase
|
68
|
+
|
69
|
+
system "git tag -a #{@podVersion} -m #{@podVersionMessage}"
|
70
|
+
system "git push --tags"
|
71
|
+
|
72
|
+
contents = File.read(specfile)
|
73
|
+
oldVersion = Regexp.new('[0-9.]{2,6}').match(Regexp.new('(s.version)\s*=.*\n').match(contents).to_s).to_s
|
74
|
+
File.write(specfile, contents.gsub!(oldVersion, @podVersion))
|
75
|
+
end
|
76
|
+
|
77
|
+
def rollbackTag
|
78
|
+
puts "Rolling back git tags".green
|
79
|
+
system "git tag -d #{@podVersion}"
|
80
|
+
system "git push -d origin #{@podVersion}"
|
81
|
+
exit
|
82
|
+
end
|
83
|
+
|
84
|
+
def executeLint(withWarnings)
|
85
|
+
cmd = [@lintCmd]
|
86
|
+
cmd << "--allow-warnings" unless withWarnings == false
|
87
|
+
|
88
|
+
command = cmd.join(' ')
|
89
|
+
|
90
|
+
puts "Executing: #{command}".green
|
91
|
+
success = system command
|
92
|
+
|
93
|
+
if success == false && withWarnings == false
|
94
|
+
# Try again?
|
95
|
+
puts "Linting failed, try again by allowing warnings? [Y/n]".blue
|
96
|
+
gets.chomp.downcase == "y" ? executeLint(true) : rollbackTag
|
97
|
+
elsif success == false && withWarnings == true
|
98
|
+
puts "Even with warnings, something is wrong. Look for any errors".red
|
99
|
+
rollbackTag
|
83
100
|
end
|
101
|
+
end
|
84
102
|
|
85
|
-
|
103
|
+
def executePush
|
104
|
+
puts "Executing: #{@pushCmd}".green
|
105
|
+
success = system @pushCmd
|
86
106
|
|
87
|
-
if
|
88
|
-
puts "
|
89
|
-
|
107
|
+
if success == false
|
108
|
+
puts "Push failed, see errors.".red
|
109
|
+
rollbackTag
|
90
110
|
end
|
111
|
+
end
|
91
112
|
|
92
|
-
|
113
|
+
def commitThisRepo
|
114
|
+
puts "Congrats! The pod has been linted and successfully push to the spec repo! All that is left is to commit the podspec here!".green
|
93
115
|
|
94
|
-
|
95
|
-
|
96
|
-
|
116
|
+
puts "Could not commit files, consider finishing by hand by performing a git commit and push. Your spec repo should be up to date".red unless system('git commit -am "[Versioning] Updating podspec"') == true
|
117
|
+
puts "Could not push to server, consider finishing by hand by performing a git push. Your spec repo should be up to date".red unless system('git push origin master')
|
118
|
+
end
|
119
|
+
|
120
|
+
def push
|
121
|
+
opts = Trollop::options do
|
122
|
+
opt :specRepo, "Name of the repo to push to. See pod repo list for available repos", :type => :string
|
123
|
+
opt :workspace, "Path to cocoapod workspace", :type => :string
|
124
|
+
opt :sources, "Comma delimited list of private repo sources to consider when linting private repo. Master is included by default so private repos can source master", :type => :string
|
125
|
+
opt :private, "If set, assume the cocoapod is private and skip public checks"
|
97
126
|
end
|
127
|
+
# Need these two
|
128
|
+
Trollop::die :specRepo, "Spec Repo must be provided" if opts[:specRepo] == nil
|
129
|
+
Trollop::die :workspace, "Workspace path must be provided" if opts[:workspace] == nil
|
98
130
|
|
99
|
-
|
131
|
+
Dir.chdir(opts[:workspace]) do
|
132
|
+
# Check
|
133
|
+
ensureGitClean
|
134
|
+
ensureSpecfile
|
100
135
|
|
101
|
-
|
102
|
-
|
103
|
-
|
136
|
+
# User input
|
137
|
+
updateVersion
|
138
|
+
|
139
|
+
# Cmds
|
140
|
+
@lintCmd = makeLintCmd(opts)
|
141
|
+
@pushCmd = makePushCmd(opts)
|
142
|
+
|
143
|
+
# execute
|
144
|
+
executeLint(false)
|
145
|
+
executePush
|
146
|
+
|
147
|
+
# Tidy up this repo!!
|
148
|
+
commitThisRepo
|
104
149
|
end
|
105
150
|
end
|
106
151
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: podspecpush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Carroll
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|