appleload 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 613ec0c85ab417de1f72c2a8505bc0bd5719ca78
4
+ data.tar.gz: 719a6e9c82daaa26b835fc0c74eff79b86e65df5
5
+ SHA512:
6
+ metadata.gz: 647017302e610a2cc0bff3db4e468acb8c4ea79c4338ebd0a3f57398fe9c97e1b83433604728096d7be0facea44d77f75b2d33bc371a5765c8c5ebc3e6be7bd6
7
+ data.tar.gz: 29af1cf741e17e7e5bcff3b3fdd397175bfc016e5a4e6e95274c0c74f3c65de80461b081cc6f48ea20d16e4dbba1977697693acfd0313343ebe69550b1cade64
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in appleload.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Turboprop Inc (https://usepropeller.com/)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # AppleLoad
2
+
3
+ A CLI & Ruby Library to control Apple's Application Loader app.
4
+
5
+ This is *experimental* - good enough for deploying apps made with [Propeller](http://usepropeller.com), but has not been exhaustively tested beyond our needs.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'appleload'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install appleload
20
+
21
+ ## Usage
22
+
23
+ AppleLoad generates AppleScript commands, which means that Application Loader will require window focus - in other words, you can't do anything else with your keyboard or mouse while it runs.
24
+
25
+ ### Commands
26
+
27
+ The following commands are supported:
28
+
29
+ - `list` - List all the apps which are waiting for an upload
30
+ - `upload TITLE IPA_PATH` - Upload the .ipa at IPA_PATH for app named TITLE
31
+
32
+ ### CLI
33
+
34
+ ```bash
35
+ $ appleload list
36
+ {"apps":[{"title":"My Awesome App","version":"1.0.0","type":"ios"}]}
37
+
38
+ $ appleload upload "My Awesome App" ./app.ipa
39
+ ```
40
+
41
+ ### Ruby
42
+
43
+ ```ruby
44
+ require 'appleload'
45
+
46
+ AppleLoad.list
47
+ # => [{title: "My Awesome App", version: "1.0.0", type: :is}]
48
+
49
+ AppleLoad.upload("My Awesome App", "./app.ipa")
50
+ # => true
51
+ ```
52
+
53
+ ## Contact
54
+
55
+ [Clay Allsopp](http://clayallsopp.com/)
56
+ - [clay@usepropeller.com](mailto:clay@usepropeller.com)
57
+ - [@clayallsopp](https://twitter.com/clayallsopp)
58
+
59
+ ## License
60
+
61
+ AppleLoad is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/appleload.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'appleload/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "appleload"
8
+ spec.version = AppleLoad::VERSION
9
+ spec.authors = ["Clay Allsopp"]
10
+ spec.email = ["clay@usepropeller.com"]
11
+ spec.summary = "A CLI & Ruby Library to control Apple's Application Loader app"
12
+ spec.homepage = "http://github.com/usepropeller/appleload"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "thor", ">= 0.19.0"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ end
data/bin/appleload ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+
4
+ require "thor"
5
+ require 'json'
6
+
7
+ appleload = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'appleload'))
8
+ require appleload
9
+
10
+ class AppleLoad::CLI < Thor
11
+ desc "list", "List apps awaiting an upload"
12
+ def list
13
+ apps = AppleLoad.new.list
14
+ data = {apps: apps}
15
+ puts JSON.generate(data)
16
+ true
17
+ end
18
+
19
+ desc "upload TITLE IPA_PATH", "Upload the .ipa at IPA_PATH for app named TITLE"
20
+ def upload(title, ipa_path)
21
+ AppleLoad.new.upload(title, ipa_path)
22
+ puts JSON.generate(success: true)
23
+ true
24
+ end
25
+ end
26
+
27
+ AppleLoad::CLI.start(ARGV)
@@ -0,0 +1,12 @@
1
+ class AppleLoad
2
+ module AppleScript
3
+ def applescript(script)
4
+ script = "osascript -e '#{script}'"
5
+ result = `#{script}`
6
+ if $?.to_i != 0
7
+ raise "AppleScript Error"
8
+ end
9
+ result
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ class AppleLoad
2
+ VERSION = "0.0.1"
3
+ end
data/lib/appleload.rb ADDED
@@ -0,0 +1,162 @@
1
+ require 'shellwords'
2
+
3
+ require_relative 'appleload/version'
4
+ require_relative 'appleload/applescript'
5
+
6
+ class AppleLoad
7
+ include AppleLoad::AppleScript
8
+
9
+ LOCATION = "/Applications/Xcode.app/Contents/Applications/Application Loader.app"
10
+ IOS_SUFFIX = " (iOS App)"
11
+
12
+ def self.list
13
+ new.list
14
+ end
15
+
16
+ def self.upload(*args)
17
+ new.upload(*args)
18
+ end
19
+
20
+ def initialize
21
+ enable_accessibility!
22
+ end
23
+
24
+ def enable_accessibility!
25
+ # see https://gist.github.com/lacostej/3868129
26
+ `sudo sh -c "/bin/echo -n \"a\" > /private/var/db/.AccessibilityAPIEnabled"`
27
+ `sudo chmod 444 /private/var/db/.AccessibilityAPIEnabled`
28
+
29
+ # see http://apple.stackexchange.com/a/122405
30
+ ["/Applications/iTerm.app", "/Applications/Utilities/Terminal.app"].each do |app|
31
+ bundle_id = `/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' #{app}/Contents/Info.plist`.strip
32
+ sql_cmd = %Q{sudo sqlite3 '/Library/Application Support/com.apple.TCC/TCC.db' "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_id}',0,1,1,NULL);" }
33
+ `#{sql_cmd}`
34
+ end
35
+ end
36
+
37
+ def with_gui(&block)
38
+ open_app!
39
+ begin
40
+ result = yield
41
+ quit_app!
42
+ result
43
+ rescue Exception => e
44
+ quit_app!
45
+ raise e
46
+ end
47
+ end
48
+
49
+ def open_app!
50
+ `open -a #{LOCATION.shellescape}`
51
+ sleep 2
52
+ end
53
+
54
+ def quit_app!
55
+ applescript('tell application "Application Loader" to quit')
56
+ sleep 2
57
+ end
58
+
59
+ def open_delivery
60
+ applescript %Q{
61
+ tell application "System Events"
62
+ activate
63
+ tell process "Application Loader"
64
+ tell radio group 1 of window 1
65
+ click button "Deliver Your App"
66
+ delay 3
67
+ end tell
68
+ end tell
69
+ end tell}
70
+ sleep 2
71
+ end
72
+
73
+ def list
74
+ with_gui do
75
+ self.open_delivery
76
+ titles = applescript(%Q{
77
+ set menuItemTitles to ""
78
+ activate application "Application Loader"
79
+ tell application "System Events"
80
+ tell process "Application Loader"
81
+ tell window 1
82
+ tell pop up button 1
83
+ delay 1
84
+ key code 49 # space bar
85
+ delay 1
86
+ count menu items of menu 1
87
+ set menuItemTitles to name of menu items of menu 1
88
+ end tell
89
+ end tell
90
+ end tell
91
+ end tell
92
+
93
+ return menuItemTitles
94
+ }).gsub("Choose..., ", "").split(", ").map(&:strip).map { |string|
95
+ without_suffix = string.split(IOS_SUFFIX).first
96
+ version = without_suffix.split(" ")[-1]
97
+ title = without_suffix.split(" ")[0..-1].join(" ")
98
+
99
+ {
100
+ title: title,
101
+ version: version,
102
+ type: :ios
103
+ }
104
+ }
105
+ end
106
+ end
107
+
108
+ def upload(title, ipa_path)
109
+ title = title[0..25] # only first 25 chars
110
+ with_gui do
111
+ self.open_delivery
112
+ applescript(%Q{
113
+ set menuItemTitles to ""
114
+ set menuItemToSelect to "#{title}"
115
+ set ipaPath to "#{ipa_path}"
116
+
117
+ activate application "Application Loader"
118
+ tell application "System Events"
119
+ tell process "Application Loader"
120
+ tell window 1
121
+
122
+ tell pop up button 1
123
+ delay 1
124
+ key code 49 # space bar
125
+ delay 1
126
+ click (menu item 1 where its name starts with menuItemToSelect) of menu 1
127
+ delay 1
128
+ end tell
129
+
130
+ click button "Next"
131
+ delay 1
132
+ click button "Choose..."
133
+
134
+ tell application "System Events"
135
+ keystroke "g" using {shift down, command down}
136
+ keystroke ipaPath
137
+ delay 3
138
+ keystroke return
139
+ delay 3
140
+ keystroke return
141
+ end tell
142
+
143
+ delay 2
144
+ click button "Send"
145
+
146
+ repeat until exists button "Next"
147
+ delay 1
148
+ end repeat
149
+ click button "Next"
150
+ repeat until exists button "Done"
151
+ delay 1
152
+ end repeat
153
+ click button "Done"
154
+
155
+ end tell
156
+ end tell
157
+ end tell
158
+ })
159
+ true
160
+ end
161
+ end
162
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appleload
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Clay Allsopp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - clay@usepropeller.com
58
+ executables:
59
+ - appleload
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - appleload.gemspec
69
+ - bin/appleload
70
+ - lib/appleload.rb
71
+ - lib/appleload/applescript.rb
72
+ - lib/appleload/version.rb
73
+ homepage: http://github.com/usepropeller/appleload
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: A CLI & Ruby Library to control Apple's Application Loader app
97
+ test_files: []
98
+ has_rdoc: