phase 0.0.10 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee563e5e3a3ca6f2ff9187a9ddef4f6bb84b1061
4
- data.tar.gz: 1a1f931136fbf9a259cfed4c90530728c2af02c3
3
+ metadata.gz: efb7ef15efc3d89bc0e365884c2aade6a215cf70
4
+ data.tar.gz: a352b3bfd0a672d6ce01062263b758251df76023
5
5
  SHA512:
6
- metadata.gz: 1b02945a1a184c772ee8c7aedb72f71d55b0809504b24fdf67eae93bc7e2e6622e87c78b83884e1e3f8b38ee440a181ce69453b097643df05010eaa75b856ce0
7
- data.tar.gz: 3255427e99a5c8560c350278203924d6b8cb98da4d11ddd1d760a9481670ac205826cc09cd7d0dc2e148c783dba48e8558b4ac9c37fa104c93999629a2d218ed
6
+ metadata.gz: 08044e4ea70d6421c0005306de605bdcd7c03b10d6e3b2723db3a5cd1db463094f11a6b785850d170495279b1aa43c5d6832563d00c725f4bf34f66a8b12cd77
7
+ data.tar.gz: 217a1d8005beb9e7aeedfd00be6e51b022f3c483534826f8dcb5957056038e5d7f7ae527513d085379ab66bdef9045e8b815199edd9b0e77133c62c7f0a22b35
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.10
1
+ 0.0.11
data/lib/phase/cli/ipa.rb CHANGED
@@ -25,12 +25,12 @@ module Phase
25
25
  fail "invalid syntax: phase ipa [--version version_number] [filename|glob_pattern]..."
26
26
  end
27
27
 
28
- if Phase.config.bundle_id_prefix.blank?
29
- fail "missing setting: set `Phase.config.bundle_id_prefix = [PREFIX] in Phasefile"
30
- elsif Phase.config.ipa_bucket_name.blank?
31
- fail "missing setting: set `Phase.config.ipa_bucket_name = [BUCKET]` in Phasefile"
32
- elsif Phase.config.ipa_directory_prefix.blank?
33
- fail "missing setting: set `Phase.config.ipa_directory_prefix = [PREFIX] in Phasefile"
28
+ if Phase.config.ipa.bundle_id_prefix.blank?
29
+ fail "missing setting: set `Phase.config.ipa.bundle_id_prefix = [PREFIX] in Phasefile"
30
+ elsif Phase.config.ipa.bucket_name.blank?
31
+ fail "missing setting: set `Phase.config.ipa.bucket_name = [BUCKET]` in Phasefile"
32
+ elsif Phase.config.ipa.directory_prefix.blank?
33
+ fail "missing setting: set `Phase.config.ipa.directory_prefix = [PREFIX] in Phasefile"
34
34
  end
35
35
 
36
36
  super
@@ -2,8 +2,7 @@ module Phase
2
2
  class Configuration
3
3
 
4
4
  attr_accessor :bastions_enabled, :bastion_role, :bastion_user, :public_subnet_name,
5
- :private_subnet_name, :aws_region, :adapter, :backend,
6
- :bundle_id_prefix, :ipa_directory_prefix, :ipa_bucket_name
5
+ :private_subnet_name, :aws_region, :adapter, :backend
7
6
 
8
7
  def initialize
9
8
  @bastions_enabled = false
@@ -14,10 +13,6 @@ module Phase
14
13
  @aws_region = "us-east-1"
15
14
  @adapter = ::Phase::Adapters::AWS
16
15
 
17
- @bundle_id_prefix = ""
18
- @ipa_directory_prefix = ""
19
- @ipa_bucket_name = ""
20
-
21
16
  self.backend = ::Phase::SSH::Backend
22
17
  set_aws_credentials!
23
18
  end
@@ -27,6 +22,17 @@ module Phase
27
22
  ::SSHKit.config.backend = @backend
28
23
  end
29
24
 
25
+ # Available options:
26
+ # * bundle_id_prefix
27
+ # * directory_prefix
28
+ # * bucket_name
29
+ # * company_name
30
+ # * full_image_url
31
+ # * icon_image_url
32
+ def ipa
33
+ @ipa ||= ::ActiveSupport::OrderedOptions.new
34
+ end
35
+
30
36
  def load_phasefile!
31
37
  if ::File.exist?(phasefile_path)
32
38
  load phasefile_path
@@ -18,54 +18,36 @@ module Phase
18
18
  end
19
19
 
20
20
  def plist_xml
21
- <<-EOXML.strip_heredoc
22
- <?xml version="1.0" encoding="UTF-8"?>
23
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
24
- <plist version="1.0">
25
- <dict>
26
- <key>items</key>
27
- <array>
28
- <dict>
29
- <key>assets</key>
30
- <array>
31
- <dict>
32
- <key>kind</key>
33
- <string>software-package</string>
34
- <key>url</key>
35
- <string>https://s3.amazonaws.com/orca-static-assets/apps/#{ipa_filename}</string>
36
- </dict>
37
- </array>
38
- <key>metadata</key>
39
- <dict>
40
- <key>bundle-identifier</key>
41
- <string>#{bundle_id_prefix}.#{bundle_name}</string>
42
- <key>bundle-version</key>
43
- <string>#{version}</string>
44
- <key>kind</key>
45
- <string>software</string>
46
- <key>title</key>
47
- <string>#{human_name}</string>
48
- </dict>
49
- </dict>
50
- </array>
51
- </dict>
52
- </plist>
53
- EOXML
21
+ xml = ::File.read( ::File.expand_path("../../templates/ipa_xml.plist", __dir__) )
22
+ ::ERB.new(xml).result(binding)
54
23
  end
55
24
 
56
25
  private
57
26
 
58
- def human_name
59
- name.titleize
60
- end
61
-
62
27
  def bundle_name
63
28
  name
64
29
  end
65
30
 
66
31
  def bundle_id_prefix
67
- Phase.config.bundle_id_prefix
32
+ Phase.config.ipa.bundle_id_prefix
33
+ end
34
+
35
+ def company_name
36
+ Phase.config.ipa.company_name
37
+ end
38
+
39
+ def full_image_url
40
+ Phase.config.ipa.full_image_url
68
41
  end
42
+
43
+ def human_name
44
+ name.titleize
45
+ end
46
+
47
+ def icon_image_url
48
+ Phase.config.ipa.icon_image_url
49
+ end
50
+
69
51
  end
70
52
  end
71
53
  end
@@ -15,8 +15,8 @@ module Phase
15
15
  @file_paths.uniq!
16
16
 
17
17
  @aws = ::Fog::Storage::AWS.new(region: Phase.config.aws_region)
18
- @bucket = aws.directories.get(Phase.config.ipa_bucket_name)
19
- @prefix = ::Pathname.new(Phase.config.ipa_directory_prefix)
18
+ @bucket = aws.directories.get(Phase.config.ipa.bucket_name)
19
+ @prefix = ::Pathname.new(Phase.config.ipa.directory_prefix)
20
20
 
21
21
  @apps = []
22
22
  end
@@ -24,47 +24,36 @@ module Phase
24
24
  def run!
25
25
  ::FileUtils.mkdir(version) rescue nil
26
26
 
27
- @apps = file_paths.map do |path|
28
- app = App.new(path, version)
29
- write_plist!(app)
30
- copy_ipa!(app)
31
- upload!(app)
27
+ manifest_path = ::File.join(::Dir.pwd, version, "manifest.txt")
28
+ ::File.open(manifest_path, 'w') do |manifest|
29
+ file_paths.map do |path|
30
+ app = App.new(path, version)
31
+ app.download_url = download_url(app)
32
32
 
33
- log "...done"
34
- log ""
33
+ log "#{app.name}: writing .plist..."
34
+ write_plist!(app)
35
35
 
36
- app
37
- end
36
+ log "#{app.name}: copying .ipa..."
37
+ copy_ipa!(app)
38
38
 
39
- write_manifest!
40
- end
39
+ log "#{app.name}: uploading files..."
40
+ upload!(app)
41
41
 
42
- def write_manifest!
43
- log "writing manifest"
42
+ log "#{app.name}: updating manifest..."
43
+ manifest << manifest_url(app)
44
+ manifest << "\n"
44
45
 
45
- manifest_path = ::File.join(::Dir.pwd, version, "manifest.txt")
46
- ::File.open(manifest_path, 'w') do |file|
47
- apps.each do |app|
48
- url = [
49
- "itms-services://?action=download-manifest&url=https://s3.amazonaws.com",
50
- bucket.key,
51
- prefix,
52
- app.plist_filename
53
- ].join("/")
54
-
55
- file << url
56
- file << "\n"
46
+ log "#{app.name}: done"
47
+ log ""
57
48
  end
58
49
  end
59
50
  end
60
51
 
61
52
  def write_plist!(app)
62
- log "#{app.name}: writing .plist"
63
53
  ::File.open(plist_path(app), 'w') { |file| file << app.plist_xml }
64
54
  end
65
55
 
66
56
  def copy_ipa!(app)
67
- log "#{app.name}: copying .ipa"
68
57
  ::FileUtils.cp(app.qualified_path, ipa_path(app))
69
58
  end
70
59
 
@@ -81,15 +70,30 @@ module Phase
81
70
  acl: "public-read"
82
71
  })
83
72
 
84
- log "#{app.name}: uploading .ipa"
85
73
  ipa.save
86
-
87
- log "#{app.name}: uploading .plist"
88
74
  plist.save
89
75
  end
90
76
 
91
77
  private
92
78
 
79
+ def download_url(app)
80
+ [
81
+ "https://s3.amazonaws.com",
82
+ bucket.key,
83
+ prefix,
84
+ app.ipa_filename
85
+ ].join("/")
86
+ end
87
+
88
+ def manifest_url(app)
89
+ [
90
+ "itms-services://?action=download-manifest&url=https://s3.amazonaws.com",
91
+ bucket.key,
92
+ prefix,
93
+ app.plist_filename
94
+ ].join("/")
95
+ end
96
+
93
97
  def plist_path(app)
94
98
  ::File.join(::Dir.pwd, version, app.plist_filename)
95
99
  end
@@ -0,0 +1,65 @@
1
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2
+ <plist version="1.0">
3
+ <dict>
4
+ <key>items</key>
5
+ <array>
6
+ <dict>
7
+ <key>assets</key>
8
+ <array>
9
+ <dict>
10
+ <key>kind</key>
11
+ <string>software-package</string>
12
+ <!-- optional. md5 every n bytes. -->
13
+ <!-- will restart a chunk if md5 fails. -->
14
+ <!-- <key>md5-size</key>
15
+ <integer>10485760</integer> -->
16
+
17
+ <!-- optional. array of md5 hashes -->
18
+ <!-- <key>md5s</key>
19
+ <array>
20
+ <string>41fa64bb7a7cae5a46bfb45821ac8bba</string>
21
+ <string>51fa64bb7a7cae5a46bfb45821ac8bba</string>
22
+ </array> -->
23
+ <key>url</key>
24
+ <string><%= download_url %></string>
25
+ </dict>
26
+
27
+ <dict>
28
+ <key>kind</key>
29
+ <string>display-image</string>
30
+ <key>needs-shine</key>
31
+ <false/>
32
+ <key>url</key>
33
+ <string><%= icon_image_url %></string>
34
+ </dict>
35
+
36
+ <dict>
37
+ <key>kind</key>
38
+ <string>full-size-image</string>
39
+ <!-- <key>md5</key>
40
+ <string>61fa64bb7a7cae5a46bfb45821ac8bba</string> -->
41
+ <key>needs-shine</key>
42
+ <false/>
43
+ <key>url</key>
44
+ <string><%= full_image_url %></string>
45
+ </dict>
46
+ </array>
47
+
48
+ <key>metadata</key>
49
+ <dict>
50
+
51
+ <key>bundle-identifier</key>
52
+ <string><%= "#{bundle_id_prefix}.#{bundle_name}" %></string>
53
+ <key>bundle-version</key>
54
+ <string><%= version %></string>
55
+ <key>kind</key>
56
+ <string>software</string>
57
+ <key>subtitle</key>
58
+ <string><%= company_name %></string>
59
+ <key>title</key>
60
+ <string><%= human_name %></string>
61
+ </dict>
62
+ </dict>
63
+ </array>
64
+ </dict>
65
+ </plist>
data/lib/phase/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Phase
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/lib/phase.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'active_support/all'
2
2
  require 'capistrano'
3
3
  require 'colorize'
4
+ require 'erb'
4
5
  require 'fog'
5
6
  require 'progressbar'
6
7
  require 'sshkit'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piers Mainwaring
@@ -230,6 +230,7 @@ files:
230
230
  - lib/phase/kit/ssh/command.rb
231
231
  - lib/phase/kit/ssh/runners.rb
232
232
  - lib/phase/tasks/deploy.rb
233
+ - lib/phase/templates/ipa_xml.plist
233
234
  - lib/phase/util/console.rb
234
235
  - lib/phase/version.rb
235
236
  - phase.gemspec