fastlane-plugin-act 1.0.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 876f0124992cbea483d868bbe3f231427aaa8b74
4
- data.tar.gz: 4b3dc634f953d828e05c1033f24fb62e52a6259f
3
+ metadata.gz: c3c85f25174252ee8a3222d7d89316d10a6e74bb
4
+ data.tar.gz: 5a0f10f3ffc1488ba580f79ebb95557c0f026869
5
5
  SHA512:
6
- metadata.gz: 0738ad6fb21f5696cdf6f58803b4f0a553869d87bc8b035e082a758474436b05ecd8b46a4a4d390d32f63ffb76d592e3d1f454de3949279e4bc0490d79b7556c
7
- data.tar.gz: e7fc4841b02bdd2b6c4e9aebd1cc7cfcd1fd33388817a56b305889a39bba70422d094b26135f98efff8b0ea7e83b16e1fe53bd3beaf54052433dd92d3342aab9
6
+ metadata.gz: a6e008201ba9a2b4308aaadd89df3bb69bd23754b60c9b77f527109e09b4490c7be9810e045646eb1eaa9bf3523fa433869718457cd82634ed8c6f2f45126dde
7
+ data.tar.gz: 138f0a0797933188e07d97d7c6c4e9eaf5fc82c68f27583cdeb0df2a6f8a67b31a28abaa6f8788d9524c676f360756e338b17ca74f9ad8bf23636429b289e450
data/README.md CHANGED
@@ -12,7 +12,7 @@ fastlane add_plugin act
12
12
 
13
13
  ## About act
14
14
 
15
- Applies changes to plists and app icons inside a compiled IPA, combined with sigh's `resign` it makes it easy to release an IPA with different configurations 🎭
15
+ Applies changes to plists and app icons inside an xcarchive bundle or compiled IPA, making it easy to build once and release multiple times with different configurations 🎭
16
16
 
17
17
  ## Example
18
18
 
@@ -21,9 +21,9 @@ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plu
21
21
  Here's some usage scenarios:
22
22
 
23
23
  ```ruby
24
- # Modify Info.plist
24
+ # Modify the application Info.plist
25
25
  act(
26
- ipa: "example/Example.ipa",
26
+ archive_path: "example/Example.xcarchive",
27
27
 
28
28
  iconset: "example/Blue.appiconset",
29
29
 
@@ -38,15 +38,46 @@ act(
38
38
  ]
39
39
  )
40
40
 
41
- # Modify a different plist
41
+ # Modify a different application plist
42
42
  act(
43
- ipa: "example/Example.ipa",
43
+ archive_path: "example/Example.xcarchive",
44
+
45
+ # Using a relative path indicates a plist file inside the .app
44
46
  plist_file: "GoogleService-Info.plist",
45
47
 
46
48
  plist_values: {
47
49
  ":TRACKING_ID" => "UA-22222222-22"
48
50
  }
49
51
  )
52
+
53
+ # Modify the xcarchive manifest plist
54
+ act(
55
+ archive_path: "example/Example.xcarchive",
56
+
57
+ # Prefixing with a / allows you to target any plist in the archive
58
+ plist_file: "/Info.plist",
59
+
60
+ plist_values: {
61
+ ":TRACKING_ID" => "UA-22222222-22"
62
+ }
63
+ )
64
+
65
+ # Modify Info.plist in an IPA
66
+ act(
67
+ archive_path: "example/Example.ipa",
68
+
69
+ iconset: "example/Blue.appiconset",
70
+
71
+ # Set a hash of plist values
72
+ plist_values: {
73
+ ":CustomApplicationKey" => "Replaced!"
74
+ },
75
+
76
+ # Run a list of PlistBuddy commands
77
+ plist_commands: [
78
+ "Delete :DebugApplicationKey"
79
+ ]
80
+ )
50
81
  ```
51
82
 
52
83
  ## Run tests for this plugin
@@ -2,20 +2,28 @@ module Fastlane
2
2
  module Actions
3
3
  class ActAction < Action
4
4
  def self.run(params)
5
- params[:ipa] = File.expand_path params[:ipa]
6
- raise "IPA #{params[:ipa]} does not exist" unless File.exist? params[:ipa]
5
+ raise "You must supply an :archive_path" unless params[:archive_path] || params[:ipa]
7
6
 
8
- params[:app_name] = (File.basename params[:ipa], ".*") + ".app" unless params[:app_name]
9
-
10
- create_temp_dir = params[:temp_dir].nil?
11
- params[:temp_dir] = Dir.mktmpdir if create_temp_dir
12
- UI.verbose("Working in temp dir: #{params[:temp_dir]}")
13
-
14
- archive = ActHelper::IPAArchive.new params[:ipa], params[:app_name], params[:temp_dir]
15
-
16
- raise "IPA does not contain Payload/#{params[:app_name]}. Rename the .ipa to match the .app, or provide an app_name option value" unless archive.contains
7
+ if params[:ipa] then
8
+ warn "The ipa parameter has been superceded by archive_path and may be removed in a future release"
9
+ params[:archive_path] = params[:ipa]
10
+ end
11
+
12
+ params[:archive_path] = File.expand_path params[:archive_path]
13
+ raise "Archive path #{params[:arhive_path]} does not exist" unless File.exist? params[:archive_path]
14
+
15
+ if File.directory? params[:archive_path] then
16
+ archive = ActHelper::XCArchive.new params[:archive_path], params[:app_name]
17
+ else
18
+ archive = ActHelper::IPAArchive.new params[:archive_path], params[:app_name], params[:temp_dir]
19
+ end
17
20
 
18
- params[:plist_file] = "Info.plist" unless params[:plist_file]
21
+ if params[:plist_file] then
22
+ params[:plist_file] = archive.app_path(params[:plist_file]) unless params[:plist_file].start_with?("/")
23
+ params[:plist_file][0] = '' if params[:plist_file].start_with?("/")
24
+ else
25
+ params[:plist_file] = archive.app_path("Info.plist")
26
+ end
19
27
 
20
28
  ActHelper::PlistPatcher.patch(
21
29
  archive,
@@ -29,11 +37,6 @@ module Fastlane
29
37
  params[:iconset],
30
38
  !params[:skip_delete_icons]
31
39
  ) if params[:iconset]
32
-
33
- if create_temp_dir
34
- UI.verbose("Removing temp dir")
35
- `rm -rf #{params[:temp_dir]}`
36
- end
37
40
  end
38
41
 
39
42
  def self.description
@@ -48,8 +51,22 @@ module Fastlane
48
51
  [
49
52
  FastlaneCore::ConfigItem.new(key: :ipa,
50
53
  env_name: "FACELIFT_IPA",
51
- description: "Path of the IPA file being modified",
52
- optional: false,
54
+ description: "Path of the IPA file being modified. Deprecated, use archive_path",
55
+ optional: true,
56
+ conflicting_options: [:archive_path],
57
+ conflict_block: proc do |value|
58
+ UI.user_error!("You can't use 'ipa' and 'archive_path' options in one run")
59
+ end,
60
+ type: String),
61
+
62
+ FastlaneCore::ConfigItem.new(key: :archive_path,
63
+ env_name: "FACELIFT_ARCHIVE_PATH",
64
+ description: "Path of the IPA or XCARCHIVE being modified",
65
+ optional: true,
66
+ conflicting_options: [:ipa],
67
+ conflict_block: proc do |value|
68
+ UI.user_error!("You can't use 'ipa' and 'archive_path' options in one run")
69
+ end,
53
70
  type: String),
54
71
 
55
72
  FastlaneCore::ConfigItem.new(key: :iconset,
@@ -79,7 +96,7 @@ module Fastlane
79
96
  # Very optional
80
97
  FastlaneCore::ConfigItem.new(key: :app_name,
81
98
  env_name: "FACELIFT_APP_NAME",
82
- description: "The name of the .app file (including extension), if not the same as the IPA",
99
+ description: "The name of the .app file (including extension), will be extracted if not supplied",
83
100
  optional: true,
84
101
  type: String),
85
102
 
@@ -91,7 +108,7 @@ module Fastlane
91
108
 
92
109
  FastlaneCore::ConfigItem.new(key: :skip_delete_icons,
93
110
  env_name: "FACELIFT_SKIP_DELETE_ICONS",
94
- description: "When true, the old icon files will not be deleted from the IPA",
111
+ description: "When true, the old icon files will not be deleted from the archive",
95
112
  optional: true,
96
113
  default_value: false,
97
114
  type: [TrueClass, FalseClass])
@@ -2,7 +2,7 @@ module Fastlane
2
2
  module ActHelper
3
3
  class IconPatcher
4
4
  def self.patch(archive, iconset_path, delete_old_iconset)
5
- plist_path = "Info.plist"
5
+ plist_path = archive.app_path("Info.plist")
6
6
  archive.extract(plist_path)
7
7
 
8
8
  UI.message("Patching icons from: #{iconset_path}")
@@ -19,7 +19,7 @@ module Fastlane
19
19
  plist_buddy.exec("Add #{icons_plist_key} array")
20
20
 
21
21
  icons.each do |i|
22
- relative_path = (i[:target]).to_s
22
+ relative_path = archive.app_path( (i[:target]).to_s )
23
23
  local_path = archive.local_path(relative_path)
24
24
  `cp #{i[:source]} #{local_path}`
25
25
  archive.replace(relative_path)
@@ -77,7 +77,7 @@ module Fastlane
77
77
  existing_icons = plist_buddy.parse_scalar_array(icon_files_value)
78
78
 
79
79
  if existing_icons.size && delete_old_iconset
80
- icons_to_delete = existing_icons.map { |name| "#{name}#{idiom_suffix}*" }
80
+ icons_to_delete = existing_icons.map { |name| archive.app_path("#{name}#{idiom_suffix}*") }
81
81
 
82
82
  icons_to_delete.each do |icon_to_delete|
83
83
  archive.delete icon_to_delete
@@ -1,23 +1,35 @@
1
1
  module Fastlane
2
2
  module ActHelper
3
3
  class IPAArchive
4
- def initialize(ipa_file, app_name, temp_dir)
4
+ def initialize(ipa_file, app_name = null, temp_dir = null)
5
5
  @ipa_file = ipa_file
6
- @app_path = "Payload/#{app_name}"
7
- @temp_dir = temp_dir
6
+
7
+ @create_temp_dir = temp_dir.nil?
8
+ @temp_dir = Dir.mktmpdir if @create_temp_dir
9
+ UI.verbose("Working in temp dir: #{@temp_dir}")
10
+
11
+ @app_path = "Payload/#{app_name}" if app_name
12
+ @app_path = IPAArchive.extract_app_path(@ipa_file) unless app_name
13
+
14
+ raise "IPA does not contain #{@app_path}" unless contains("#{@app_path}/")
8
15
  end
9
16
 
10
- # Returns the full path to the given file within the temp dir
17
+ # Returns the full path to the given file that can be modified
11
18
  def local_path(path)
12
- "#{@temp_dir}/#{@app_path}/#{path}"
19
+ "#{@temp_dir}/#{path}"
20
+ end
21
+
22
+ # Returns an archive-relative path to the given application file
23
+ def app_path(path)
24
+ "#{@app_path}/#{path}"
13
25
  end
14
26
 
15
27
  # Extract files to the temp dir
16
28
  def extract(path)
17
- UI.verbose("Extracting #{@app_path}/#{path}")
29
+ UI.verbose("Extracting #{path}")
18
30
 
19
31
  Dir.chdir(@temp_dir) do
20
- result = `unzip -o -q #{@ipa_file} #{@app_path}/#{path}`
32
+ result = `unzip -o -q #{@ipa_file} #{path}`
21
33
 
22
34
  if $?.exitstatus.nonzero?
23
35
  UI.important result
@@ -28,27 +40,32 @@ module Fastlane
28
40
 
29
41
  # Restore extracted files from the temp dir
30
42
  def replace(path)
31
- UI.verbose("Replacing #{@app_path}/#{path}")
43
+ UI.verbose("Replacing #{path}")
32
44
  Dir.chdir(@temp_dir) do
33
- `zip -q #{@ipa_file} #{@app_path}/#{path}`
45
+ `zip -q #{@ipa_file} #{path}`
34
46
  end
35
47
  end
36
48
 
37
49
  # Delete path inside the ipa
38
50
  def delete(path)
39
- UI.verbose("Deleting #{@app_path}/#{path}")
51
+ UI.verbose("Deleting #{path}")
40
52
  Dir.chdir(@temp_dir) do
41
- `zip -dq #{@ipa_file} #{@app_path}/#{path}`
53
+ `zip -dq #{@ipa_file} #{path}`
42
54
  end
43
55
  end
44
56
 
45
57
  def contains(path = nil)
46
- `zipinfo -1 #{@ipa_file} #{@app_path}/#{path}`
58
+ `zipinfo -1 #{@ipa_file} #{path}`
47
59
  $?.exitstatus.zero?
48
60
  end
49
61
 
50
62
  def clean
51
- `rm -rf #{temp_dir}/*`
63
+ `rm -rf #{temp_dir}` if @create_temp_dir
64
+ `rm -rf #{temp_dir}/*` unless @create_temp_dir
65
+ end
66
+
67
+ def self.extract_app_path(archive_path)
68
+ `zipinfo -1 #{archive_path} "Payload/*.app/" | sed -n '1 p'`.strip().chomp('/')
52
69
  end
53
70
  end
54
71
  end
@@ -0,0 +1,51 @@
1
+ module Fastlane
2
+ module ActHelper
3
+ class XCArchive
4
+ def initialize(xcarchive_path, app_name)
5
+ @xcarchive_path = xcarchive_path
6
+
7
+ @app_path = "Products/Applications/#{app_name}" if app_name
8
+ @app_path = "Products/#{XCArchive.extract_app_path(xcarchive_path)}" unless app_name
9
+ end
10
+
11
+ # Returns the full path to the given file that can be modified
12
+ def local_path(path)
13
+ "#{@xcarchive_path}/#{path}"
14
+ end
15
+
16
+ # Returns an archive-relative path to the given application file
17
+ def app_path(path)
18
+ "#{@app_path}/#{path}"
19
+ end
20
+
21
+ # Extract files to the temp dir
22
+ def extract(path)
23
+ end
24
+
25
+ # Restore extracted files from the temp dir
26
+ def replace(path)
27
+ end
28
+
29
+ # Delete path inside the ipa
30
+ def delete(path)
31
+ UI.verbose("Deleting #{path}")
32
+
33
+ Dir.glob(local_path(path)).each { |f| File.delete(f) }
34
+ end
35
+
36
+ def contains(path = nil)
37
+ File.exist? local_path(path)
38
+ end
39
+
40
+ def clean
41
+ `rm -rf #{temp_dir}/*`
42
+ end
43
+
44
+ def self.extract_app_path(archive_path)
45
+ plist_buddy = PlistBuddy.new "#{archive_path}/Info.plist"
46
+
47
+ (plist_buddy.exec "Print :ApplicationProperties:ApplicationPath").strip
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Act
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-act
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Szalay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.99.0
89
+ version: 1.111.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.99.0
96
+ version: 1.111.0
97
97
  description:
98
98
  email: richard@richardszalay.com
99
99
  executables: []
@@ -108,6 +108,7 @@ files:
108
108
  - lib/fastlane/plugin/act/helper/ipa_archive.rb
109
109
  - lib/fastlane/plugin/act/helper/plist_buddy.rb
110
110
  - lib/fastlane/plugin/act/helper/plist_patcher.rb
111
+ - lib/fastlane/plugin/act/helper/xc_archive.rb
111
112
  - lib/fastlane/plugin/act/version.rb
112
113
  homepage: https://github.com/richardszalay/fastlane-plugin-act
113
114
  licenses:
@@ -129,9 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  version: '0'
130
131
  requirements: []
131
132
  rubyforge_project:
132
- rubygems_version: 2.6.7
133
+ rubygems_version: 2.6.11
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: Applies changes to plists and app icons inside a compiled IPA
136
137
  test_files: []
137
- has_rdoc: