shenzhen 0.2.5 → 0.3.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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shenzhen (0.2.5)
4
+ shenzhen (0.3.0)
5
5
  commander (~> 4.1.2)
6
6
  faraday (~> 0.8.0)
7
7
  faraday_middleware (~> 0.8.7)
data/README.md CHANGED
@@ -26,6 +26,7 @@ $ ipa
26
26
  build Create a new .ipa file for your app
27
27
  distribute:testflight Distribute an .ipa file over TestFlight
28
28
  distribute:hockeyapp Distribute an .ipa file over HockeyApp
29
+ distribute:ftp Distribute an .ipa file over FTP
29
30
  help Display global or [command] help documentation.
30
31
 
31
32
  Aliases:
data/bin/ipa CHANGED
@@ -14,7 +14,6 @@ program :help, 'Author', 'Mattt Thompson <m@mattt.me>'
14
14
  program :help, 'Website', 'http://mattt.me'
15
15
  program :help_formatter, :compact
16
16
 
17
- # global_option '--verbose'
18
17
  default_command :help
19
18
 
20
19
  require 'shenzhen/commands'
@@ -1,6 +1,7 @@
1
1
  module Shenzhen
2
- VERSION = '0.2.5'
2
+ VERSION = '0.3.0'
3
3
  end
4
4
 
5
5
  require 'shenzhen/agvtool'
6
6
  require 'shenzhen/xcodebuild'
7
+ require 'shenzhen/plistbuddy'
@@ -2,6 +2,7 @@ $:.push File.expand_path('../', __FILE__)
2
2
 
3
3
  require 'plugins/testflight'
4
4
  require 'plugins/hockeyapp'
5
+ require 'plugins/ftp'
5
6
 
6
7
  require 'commands/build'
7
8
  require 'commands/distribute'
@@ -9,7 +9,6 @@ command :build do |c|
9
9
  c.option '-s', '--scheme SCHEME', 'Scheme used to build app'
10
10
  c.option '--[no-]clean', 'Clean project before building'
11
11
  c.option '--[no-]archive', 'Archive project after building'
12
- c.option '-q', '--quiet', 'Silence warning and success messages'
13
12
 
14
13
  c.action do |args, options|
15
14
  validate_xcode_version!
@@ -0,0 +1,9 @@
1
+ module Shenzhen::PlistBuddy
2
+ class << self
3
+ def print(file, key)
4
+ output = `/usr/libexec/PlistBuddy -c "Print :#{key}" "#{file}" 2> /dev/null`
5
+
6
+ !output || output.empty? || /Does Not Exist/ === output ? nil : output.strip
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,130 @@
1
+ require 'net/ftp'
2
+
3
+ module Shenzhen::Plugins
4
+ module FTP
5
+ class Client
6
+
7
+ def initialize(host, user, pass)
8
+ @host, @user, @password = host, user, pass
9
+
10
+ @connection = Net::FTP.new
11
+ @connection.passive = true
12
+ @connection.connect(@host)
13
+ end
14
+
15
+ def upload_build(ipa, options)
16
+ path = expand_path_with_substitutions_from_ipa_plist(ipa, options[:path])
17
+
18
+ begin
19
+ @connection.login(@user, @password) rescue raise "Login authentication failed"
20
+
21
+ if options[:mkdir]
22
+ components, pwd = path.split(/\//), nil
23
+ components.each do |component|
24
+ pwd = File.join(*[pwd, component].compact)
25
+
26
+ begin
27
+ @connection.mkdir pwd
28
+ rescue => exception
29
+ raise exception unless /File exists/ === exception.message
30
+ end
31
+ end
32
+ end
33
+
34
+ @connection.chdir path unless path.empty?
35
+ @connection.putbinaryfile ipa, File.basename(ipa)
36
+
37
+ if dsym = options.delete(:dsym)
38
+ @connection.putbinaryfile dsym, File.basename(dsym)
39
+ end
40
+
41
+ ensure
42
+ @connection.close
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def expand_path_with_substitutions_from_ipa_plist(ipa, path)
49
+ components = []
50
+
51
+ substitutions = path.scan(/\{CFBundle[^}]+\}/)
52
+ return path if substitutions.empty?
53
+
54
+ Dir.mktmpdir do |dir|
55
+ system "unzip -q #{ipa} -d #{dir} 2> /dev/null"
56
+
57
+ plist = Dir["#{dir}/**/Info.plist"].last
58
+
59
+ substitutions.uniq.each do |substitution|
60
+ key = substitution[1...-1]
61
+ value = Shenzhen::PlistBuddy.print(plist, key)
62
+
63
+ path.gsub!(Regexp.new(substitution), value) if value
64
+ end
65
+ end
66
+
67
+ return path
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ command :'distribute:ftp' do |c|
74
+ c.syntax = "ipa distribute:ftp [options]"
75
+ c.summary = "Distribute an .ipa file over FTP"
76
+ c.description = ""
77
+
78
+ c.example '', '$ ipa distribute:ftp --host 127.0.0.1 -f ./file.ipa -u username --path "/path/to/folder/{CFBundleVersion}/" --mkdir'
79
+
80
+ c.option '-f', '--file FILE', ".ipa file for the build"
81
+ c.option '-d', '--dsym FILE', "zipped .dsym package for the build"
82
+ c.option '-h', '--host HOST', "FTP host"
83
+ c.option '-u', '--user USER', "FTP user"
84
+ c.option '-p', '--password PASS', "FTP password"
85
+ c.option '-P', '--path PATH', "FTP path. Values from Info.plist will be substituded for keys wrapped in {} \n\t\t eg. \"/path/to/folder/{CFBundleVersion}/\" could be evaluated as \"/path/to/folder/1.0.0/\""
86
+ c.option '--[no-]mkdir', "Create directories on FTP if they don't already exist"
87
+
88
+ c.action do |args, options|
89
+
90
+ determine_file! unless @file = options.file
91
+ say_error "Missing or unspecified .ipa file" and abort unless @file and File.exist?(@file)
92
+
93
+ determine_dsym! unless @dsym = options.dsym
94
+ say_error "Specified dSYM.zip file doesn't exist" unless @dsym and File.exist?(@dsym)
95
+
96
+ determine_host! unless @host = options.host
97
+ say_error "Missing FTP host" and abort unless @host
98
+
99
+ determine_user! unless @user = options.user
100
+ say_error "Missing FTP user" and abort unless @user
101
+
102
+ determine_password! unless @password = options.password
103
+ say_error "Missing FTP password" and abort unless @password
104
+
105
+ @path = options.path || ""
106
+
107
+ client = Shenzhen::Plugins::FTP::Client.new(@host, @user, @password)
108
+
109
+ begin
110
+ client.upload_build @file, {:path => @path, :dsym => @dsym, :mkdir => !!options.mkdir}
111
+ say_ok "Build successfully uploaded to FTP" unless options.quiet
112
+ rescue => exception
113
+ say_error "Error while uploading to FTP: #{exception}"
114
+ end
115
+ end
116
+
117
+ private
118
+
119
+ def determine_host!
120
+ @host ||= ask "FTP Host:"
121
+ end
122
+
123
+ def determine_user!
124
+ @user ||= ask "Username:"
125
+ end
126
+
127
+ def determine_password!
128
+ @password ||= password "Password:"
129
+ end
130
+ end
@@ -54,9 +54,6 @@ command :'distribute:hockeyapp' do |c|
54
54
  c.option '--tags TAGS', "Comma separated list of tags which will receive access to the build"
55
55
  c.option '--notify', "Notify permitted teammates to install the build"
56
56
  c.option '--downloadOff', "Upload but don't allow download of this version just yet"
57
-
58
- c.option '-q', '--quiet', "Silence warning and success messages"
59
-
60
57
 
61
58
  c.action do |args, options|
62
59
  determine_file! unless @file = options.file
@@ -49,7 +49,6 @@ command :'distribute:testflight' do |c|
49
49
  c.option '-l', '--lists LISTS', "Comma separated distribution list names which will receive access to the build"
50
50
  c.option '--notify', "Notify permitted teammates to install the build"
51
51
  c.option '--replace', "Replace binary for an existing build if one is found with the same name/bundle version"
52
- c.option '-q', '--quiet', "Silence warning and success messages"
53
52
 
54
53
  c.action do |args, options|
55
54
  determine_file! unless @file = options.file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shenzhen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-05 00:00:00.000000000 Z
12
+ date: 2012-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -120,6 +120,8 @@ files:
120
120
  - ./lib/shenzhen/commands/build.rb
121
121
  - ./lib/shenzhen/commands/distribute.rb
122
122
  - ./lib/shenzhen/commands.rb
123
+ - ./lib/shenzhen/plistbuddy.rb
124
+ - ./lib/shenzhen/plugins/ftp.rb
123
125
  - ./lib/shenzhen/plugins/hockeyapp.rb
124
126
  - ./lib/shenzhen/plugins/testflight.rb
125
127
  - ./lib/shenzhen/xcodebuild.rb
@@ -127,6 +129,7 @@ files:
127
129
  - ./LICENSE
128
130
  - ./Rakefile
129
131
  - ./README.md
132
+ - ./shenzhen-0.2.5.gem
130
133
  - ./shenzhen.gemspec
131
134
  - bin/ipa
132
135
  homepage: http://github.com/mattt/shenzhen
@@ -143,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
146
  version: '0'
144
147
  segments:
145
148
  - 0
146
- hash: 1284257327817803531
149
+ hash: 4330203540217877831
147
150
  required_rubygems_version: !ruby/object:Gem::Requirement
148
151
  none: false
149
152
  requirements:
@@ -152,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
155
  version: '0'
153
156
  segments:
154
157
  - 0
155
- hash: 1284257327817803531
158
+ hash: 4330203540217877831
156
159
  requirements: []
157
160
  rubyforge_project:
158
161
  rubygems_version: 1.8.24