motion-steward 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/motion-steward +65 -20
- data/lib/motion-steward/app_store_research.rb +1 -1
- data/lib/motion-steward/app_store_search.rb +1 -0
- data/lib/motion-steward.rb +143 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4baf404a06c1d862ec52721dbe7102d97fff4f1
|
4
|
+
data.tar.gz: c53cafba15b1bed39052eda9ff5dff5e4ad54840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baa98c59d8fe8246e6de1df050199e7f460432d1efde54c862380a9532d37906c98af0d3b8687bb580df8c1b0233b84a86c3ea8a28947a686cca4c84d041c743
|
7
|
+
data.tar.gz: 68b9d95ba8e76bb03388671e610c05c220964763c803ac31de98701d87195e4a5021d7365eb0b93520020d12872775a4317659979b18403d34fc4472fa04793f
|
data/bin/motion-steward
CHANGED
@@ -4,7 +4,7 @@ require 'fastlane'
|
|
4
4
|
require 'motion-steward'
|
5
5
|
|
6
6
|
def options
|
7
|
-
[:research]
|
7
|
+
[:research, :audit, :create_dev_profile, :add_device_to_profile, :download_dev_profile]
|
8
8
|
end
|
9
9
|
|
10
10
|
def list_apps
|
@@ -18,25 +18,6 @@ def go_to_apps
|
|
18
18
|
system 'open https://developer.apple.com/account/ios/identifier/bundle/'
|
19
19
|
end
|
20
20
|
|
21
|
-
def get_udid_of_connected_devices
|
22
|
-
script = <<~SCRIPT
|
23
|
-
i=0
|
24
|
-
for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'); do
|
25
|
-
UDID=${line}
|
26
|
-
echo $UDID
|
27
|
-
udid_array[i]=${line}
|
28
|
-
i=$(($i+1))
|
29
|
-
done
|
30
|
-
|
31
|
-
cnt=${#udid_array[@]}
|
32
|
-
for ((i=0;i<cnt;i++)); do
|
33
|
-
echo ${udid_array[i]}
|
34
|
-
done
|
35
|
-
SCRIPT
|
36
|
-
|
37
|
-
system script
|
38
|
-
end
|
39
|
-
|
40
21
|
def gets
|
41
22
|
STDIN.gets.chomp
|
42
23
|
end
|
@@ -47,12 +28,76 @@ def prompt_for_response message
|
|
47
28
|
gets
|
48
29
|
end
|
49
30
|
|
31
|
+
def download_dev_profile
|
32
|
+
login_if_needed
|
33
|
+
puts "Here are the apps I've found without development profiles:\n\n"
|
34
|
+
|
35
|
+
MotionSteward.development_profiles.each do |p|
|
36
|
+
puts "- #{p.app.name}: #{p.app.bundle_id}"
|
37
|
+
end
|
38
|
+
|
39
|
+
selected_app = prompt_for_response "\nWhich app do you want to download the profile for?"
|
40
|
+
to_path = 'development.mobileprovision'
|
41
|
+
|
42
|
+
MotionSteward.download_development_profile selected_app, to_path
|
43
|
+
puts "Development profile for #{selected_app} has been downloaded to #{to_path}.\n"
|
44
|
+
audit
|
45
|
+
end
|
46
|
+
|
50
47
|
def research
|
51
48
|
term = prompt_for_response "Enter a search term or app name, and I'll return what people will see when they search for that term in the App Store (along with some fancy data):"
|
52
49
|
puts ''
|
53
50
|
MotionSteward::AppStoreResearch.analyze(term)
|
54
51
|
end
|
55
52
|
|
53
|
+
def create_dev_profile
|
54
|
+
login_if_needed
|
55
|
+
puts "Here are the apps I've found without development profiles:\n\n"
|
56
|
+
|
57
|
+
MotionSteward.apps_without_development_profiles.each do |p|
|
58
|
+
puts "- #{p.name}: #{p.bundle_id}"
|
59
|
+
end
|
60
|
+
|
61
|
+
selected_app = prompt_for_response "\nWhich app do you want to create a profile for?"
|
62
|
+
|
63
|
+
MotionSteward.create_development_profile selected_app
|
64
|
+
puts "\n"
|
65
|
+
audit
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_device_to_profile
|
69
|
+
login_if_needed
|
70
|
+
puts "Here are the profiles I've found that do not have the currently connected device:\n\n"
|
71
|
+
|
72
|
+
MotionSteward.development_profiles_without_device(MotionSteward.udid_of_connected_device).each do |p|
|
73
|
+
puts " - #{p.app.name}'s development profile"
|
74
|
+
end
|
75
|
+
|
76
|
+
selected_app = prompt_for_response "\nWhich app's profile do you want to add the device to?"
|
77
|
+
|
78
|
+
MotionSteward.add_device_to_app selected_app, MotionSteward.udid_of_connected_device
|
79
|
+
puts "\n"
|
80
|
+
audit
|
81
|
+
end
|
82
|
+
|
83
|
+
def login_if_needed
|
84
|
+
stored_login = `cat ~/.motion-steward-login`.chomp
|
85
|
+
if stored_login.length.zero?
|
86
|
+
email = prompt_for_response 'First, we need to log into your Apple Developer account. I need your email:'
|
87
|
+
system "echo #{email} >> ~/.motion-steward-login"
|
88
|
+
else
|
89
|
+
email = stored_login
|
90
|
+
end
|
91
|
+
|
92
|
+
Spaceship.login email
|
93
|
+
end
|
94
|
+
|
95
|
+
def audit
|
96
|
+
login_if_needed
|
97
|
+
MotionSteward.audit_device
|
98
|
+
MotionSteward.audit_provisioning_profiles
|
99
|
+
end
|
100
|
+
|
56
101
|
def help_with_certificates
|
57
102
|
production = Spaceship.certificate.all.find_all { |c| c.is_a? Spaceship::Portal::Certificate::Production }.first
|
58
103
|
|
@@ -37,7 +37,7 @@ class MotionSteward::AppStoreResearch
|
|
37
37
|
if user_rating_count < 99
|
38
38
|
puts ' - App has very few ratings, which usually means very few downloads.'
|
39
39
|
elsif user_rating_count < 300
|
40
|
-
puts
|
40
|
+
puts " - App has a moderate number of reviews (#{user_rating_count.commas}). If the app has been recently updated, then this is probably a new app."
|
41
41
|
elsif user_rating_count > 10_000
|
42
42
|
puts " - App has an astronomical number of reviews (#{user_rating_count.commas}). If your app is similar to this one, you probably shouldn't build yours because you have little to no chance of \"beating them\"."
|
43
43
|
elsif user_rating_count > 5_000
|
data/lib/motion-steward.rb
CHANGED
@@ -1,16 +1,153 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'fastlane'
|
3
|
+
|
1
4
|
class MotionSteward
|
2
|
-
def self.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def self.udid_of_connected_device
|
6
|
+
script = <<~SCRIPT
|
7
|
+
i=0
|
8
|
+
for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'); do
|
9
|
+
UDID=${line}
|
10
|
+
echo $UDID
|
11
|
+
udid_array[i]=${line}
|
12
|
+
i=$(($i+1))
|
13
|
+
done
|
14
|
+
|
15
|
+
cnt=${#udid_array[@]}
|
16
|
+
for ((i=0;i<cnt;i++)); do
|
17
|
+
echo ${udid_array[i]}
|
18
|
+
done
|
19
|
+
SCRIPT
|
20
|
+
|
21
|
+
result = `#{script}`.chomp
|
22
|
+
return nil if result.chomp.length.zero?
|
23
|
+
result.split("\n").first.chomp
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.invalidate_cache
|
27
|
+
@apps = nil
|
28
|
+
@profiles = nil
|
29
|
+
@development_profiles = nil
|
30
|
+
@distribution_profiles = nil
|
31
|
+
@development_certificates = nil
|
32
|
+
@production_certificates = nil
|
33
|
+
@devices = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.devices
|
37
|
+
@devices ||= Spaceship.device.all
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.apps
|
41
|
+
@apps ||= Spaceship.app.all
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.profiles
|
45
|
+
@profiles ||= Spaceship.provisioning_profile.all
|
46
|
+
end
|
7
47
|
|
8
|
-
|
48
|
+
def self.apps_without_development_profiles
|
49
|
+
apps.map do |a|
|
9
50
|
{
|
10
51
|
app: a,
|
11
52
|
development_profile: development_profiles.find_all { |d| d.app.app_id == a.app_id },
|
12
53
|
distribution_profile: distribution_profiles.find_all { |d| d.app.app_id == a.app_id }
|
13
54
|
}
|
55
|
+
end.find_all do |a|
|
56
|
+
a[:development_profile].count.zero?
|
57
|
+
end.map { |a| a[:app] }
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.development_profiles_without_device udid
|
61
|
+
development_profiles.find_all { |p| p.devices.none? { |d| d.udid == udid } }
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.development_profiles
|
65
|
+
@development_profiles ||= profiles.find_all { |p| p.is_a? Spaceship::Portal::ProvisioningProfile::Development }
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.distribution_profiles
|
69
|
+
@distribution_profiles ||= profiles.find_all { |p| p.is_a? Spaceship::Portal::ProvisioningProfile::AppStore }
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.development_certificates
|
73
|
+
@development_certificates ||= Spaceship.certificate.all.find_all { |c| c.is_a? Spaceship::Portal::Certificate::Development }
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.production_certificates
|
77
|
+
@production_certificates ||= Spaceship.certificate.all.find_all { |c| c.is_a? Spaceship::Portal::Certificate::Production }
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.create_development_profile app_name_or_bundle_id
|
81
|
+
app = apps.find { |a| a.name == app_name_or_bundle_id || a.bundle_id == app_name_or_bundle_id }
|
82
|
+
|
83
|
+
unless app
|
84
|
+
puts "App/Bundle Id #{app_name_or_bundle_id} not found."
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
Spaceship::Portal::ProvisioningProfile::Development.create!(
|
89
|
+
name: "Development: #{app.name}",
|
90
|
+
bundle_id: app.bundle_id,
|
91
|
+
certificate: development_certificates.first,
|
92
|
+
devices: [],
|
93
|
+
mac: false,
|
94
|
+
sub_platform: nil
|
95
|
+
)
|
96
|
+
|
97
|
+
invalidate_cache
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.download_development_profile app_name_or_bundle_id, to
|
101
|
+
profile = development_profiles.find { |p| p.app.name == app_name_or_bundle_id }
|
102
|
+
File.write(to, profile.download)
|
103
|
+
invalidate_cache
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.add_device_to_app app_name_or_bundle_id, udid
|
107
|
+
profile = development_profiles_without_device(udid).find { |p| p.app.name == app_name_or_bundle_id }
|
108
|
+
profile.devices << devices.find { |d| d.udid == udid }
|
109
|
+
profile.update!
|
110
|
+
invalidate_cache
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.audit_device
|
114
|
+
currently_connected_device = udid_of_connected_device
|
115
|
+
|
116
|
+
if devices.none? { |d| d.udid == currently_connected_device }
|
117
|
+
puts 'The currently connected device is not part of your developer account.'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.audit_provisioning_profiles
|
122
|
+
lookup = apps.map do |a|
|
123
|
+
{
|
124
|
+
app: a,
|
125
|
+
development_profile: development_profiles.find_all { |d| d.app.app_id == a.app_id },
|
126
|
+
distribution_profile: distribution_profiles.find_all { |d| d.app.app_id == a.app_id }
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
130
|
+
currently_connected_device = udid_of_connected_device
|
131
|
+
|
132
|
+
lookup.each do |a|
|
133
|
+
puts "#{a[:app].name}:"
|
134
|
+
if a[:development_profile].any?
|
135
|
+
if a[:development_profile].first.devices.none? { |d| d.udid == currently_connected_device }
|
136
|
+
if currently_connected_device
|
137
|
+
puts ' ✗ Development profile is missing the device that is currently connected.'
|
138
|
+
end
|
139
|
+
else
|
140
|
+
puts ' ✔ All is good with the development profile.'
|
141
|
+
end
|
142
|
+
else
|
143
|
+
puts ' ✗ Development profile missing.'
|
144
|
+
end
|
145
|
+
|
146
|
+
if a[:distribution_profile].any?
|
147
|
+
puts ' ✔ All is good with the distribution profile.'
|
148
|
+
else
|
149
|
+
puts ' ✗ Distribution profile missing.'
|
150
|
+
end
|
14
151
|
end
|
15
152
|
end
|
16
153
|
end
|