fastlane-plugin-plist_surgeon 0.2.0 → 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.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/fastlane/plugin/plist_surgeon/actions/plist_surgeon_action.rb +1 -5
- data/lib/fastlane/plugin/plist_surgeon/actions/plist_surgeon_delete_action.rb +39 -0
- data/lib/fastlane/plugin/plist_surgeon/helper/plist_surgeon_helper.rb +75 -0
- data/lib/fastlane/plugin/plist_surgeon/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82054adab900dcfce44257cf14ca8424b4b67d88aa91d199b0a4dc9fea582b54
|
|
4
|
+
data.tar.gz: ac5dc48534e943bbbd5e904ae0d11d391bb11a912cd21126d727e5209dd02606
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be055a5d05b355171d0e8957e4d3ecfdeb1d643478acba8eed57576d3c85dad31463a12bae4621a4c6fd1b03af2c0f9428d17fe035c50c868b7e8149170f0a3b
|
|
7
|
+
data.tar.gz: d721daa745390daff18e8a40329c18f2014c05b9f3b4dd7372b86c5309f28dd76e65ff63019222e2df1bd9b6509266ae410eeb4d1497109d8356fd7c166bf297
|
data/README.md
CHANGED
|
@@ -71,6 +71,22 @@ privacy_surgeon(
|
|
|
71
71
|
| `key` | The key to update (supports dot notation for nested keys) | Yes | |
|
|
72
72
|
| `value` | The value to set | Yes | |
|
|
73
73
|
|
|
74
|
+
### plist_surgeon_delete
|
|
75
|
+
|
|
76
|
+
Delete a key from a `.plist` file.
|
|
77
|
+
|
|
78
|
+
```rb
|
|
79
|
+
plist_surgeon_delete(
|
|
80
|
+
path: "./Info.plist",
|
|
81
|
+
key: "CFBundleAlternateIcons"
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Parameter | Description | Required | Default |
|
|
86
|
+
|-----------|-----------------------------------------------------------|----------|---------|
|
|
87
|
+
| `path` | The path to the plist file | Yes | |
|
|
88
|
+
| `key` | The key to delete (supports dot notation for nested keys) | Yes | |
|
|
89
|
+
|
|
74
90
|
### Complex Values
|
|
75
91
|
|
|
76
92
|
You can set complex values (Arrays or Hashes) by passing a JSON string. This is especially useful when running from the command line.
|
|
@@ -36,11 +36,7 @@ module Fastlane
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def self.is_supported?(platform)
|
|
39
|
-
|
|
40
|
-
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
|
41
|
-
#
|
|
42
|
-
# [:ios, :mac, :android].include?(platform)
|
|
43
|
-
true
|
|
39
|
+
[:ios, :mac].include?(platform)
|
|
44
40
|
end
|
|
45
41
|
end
|
|
46
42
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'fastlane/action'
|
|
2
|
+
require_relative '../helper/plist_surgeon_helper'
|
|
3
|
+
|
|
4
|
+
module Fastlane
|
|
5
|
+
module Actions
|
|
6
|
+
class PlistSurgeonDeleteAction < Action
|
|
7
|
+
def self.run(params)
|
|
8
|
+
Helper::PlistSurgeonHelper.delete(params[:path], params[:key])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.description
|
|
12
|
+
"Delete a key from a .plist file."
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.authors
|
|
16
|
+
["Connor Tumbleson"]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.available_options
|
|
20
|
+
[
|
|
21
|
+
FastlaneCore::ConfigItem.new(key: :path,
|
|
22
|
+
env_name: "PLIST_SURGEON_PLIST_PATH",
|
|
23
|
+
description: "The path to the plist file",
|
|
24
|
+
optional: false,
|
|
25
|
+
type: String),
|
|
26
|
+
FastlaneCore::ConfigItem.new(key: :key,
|
|
27
|
+
env_name: "PLIST_SURGEON_PLIST_KEY",
|
|
28
|
+
description: "The key to delete (supports dot notation for nested keys)",
|
|
29
|
+
optional: false,
|
|
30
|
+
type: String)
|
|
31
|
+
]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.is_supported?(platform)
|
|
35
|
+
[:ios, :mac].include?(platform)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -20,6 +20,22 @@ module Fastlane
|
|
|
20
20
|
"#{File.basename(path)} saved with #{key} change."
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def self.delete(path, key)
|
|
24
|
+
unless File.exist?(path)
|
|
25
|
+
FastlaneCore::UI.user_error!("File not found at path: #{path}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
plist = Plist.parse_xml(path)
|
|
29
|
+
if plist.nil?
|
|
30
|
+
FastlaneCore::UI.user_error!("Failed to parse plist at path: #{path}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
delete_key(plist, key)
|
|
34
|
+
plist_content = plist.to_plist
|
|
35
|
+
File.write(path, plist_content)
|
|
36
|
+
"#{File.basename(path)} saved after deleting #{key}."
|
|
37
|
+
end
|
|
38
|
+
|
|
23
39
|
def self.set_value(plist, key, value)
|
|
24
40
|
value = parse_json_if_needed(value)
|
|
25
41
|
|
|
@@ -110,6 +126,65 @@ module Fastlane
|
|
|
110
126
|
current[last_key] = value
|
|
111
127
|
end
|
|
112
128
|
end
|
|
129
|
+
|
|
130
|
+
def self.delete_key(plist, key)
|
|
131
|
+
if plist.kind_of?(Hash) && plist.key?(key)
|
|
132
|
+
plist.delete(key)
|
|
133
|
+
elsif key.include?('.')
|
|
134
|
+
delete_nested_value(plist, key)
|
|
135
|
+
else
|
|
136
|
+
delete_direct_value(plist, key)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.delete_direct_value(plist, key)
|
|
141
|
+
if plist.kind_of?(Array)
|
|
142
|
+
index = find_index_for_key(plist, key)
|
|
143
|
+
plist.delete_at(index) if index
|
|
144
|
+
else
|
|
145
|
+
plist.delete(key)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.delete_nested_value(plist, key)
|
|
150
|
+
parts = key.split('.')
|
|
151
|
+
prefix_key = find_prefix_key(plist, parts)
|
|
152
|
+
|
|
153
|
+
if prefix_key
|
|
154
|
+
prefix, remainder = prefix_key
|
|
155
|
+
delete_key(plist[prefix], remainder)
|
|
156
|
+
else
|
|
157
|
+
delete_deep_nested_value(plist, parts)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def self.delete_deep_nested_value(plist, keys)
|
|
162
|
+
last_key = keys.pop
|
|
163
|
+
current = navigate_to_container(plist, keys)
|
|
164
|
+
|
|
165
|
+
return unless current
|
|
166
|
+
|
|
167
|
+
if current.kind_of?(Array)
|
|
168
|
+
index = find_index_for_key(current, last_key)
|
|
169
|
+
current.delete_at(index) if index
|
|
170
|
+
elsif current.kind_of?(Hash)
|
|
171
|
+
current.delete(last_key)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def self.navigate_to_container(plist, keys)
|
|
176
|
+
current = plist
|
|
177
|
+
keys.each do |k|
|
|
178
|
+
current = if current.kind_of?(Array)
|
|
179
|
+
index = find_index_for_key(current, k)
|
|
180
|
+
current[index]
|
|
181
|
+
else
|
|
182
|
+
current[k]
|
|
183
|
+
end
|
|
184
|
+
break unless current
|
|
185
|
+
end
|
|
186
|
+
current
|
|
187
|
+
end
|
|
113
188
|
end
|
|
114
189
|
end
|
|
115
190
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fastlane-plugin-plist_surgeon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sourcetoad
|
|
@@ -33,6 +33,7 @@ files:
|
|
|
33
33
|
- lib/fastlane/plugin/plist_surgeon.rb
|
|
34
34
|
- lib/fastlane/plugin/plist_surgeon/actions/entitlements_surgeon_action.rb
|
|
35
35
|
- lib/fastlane/plugin/plist_surgeon/actions/plist_surgeon_action.rb
|
|
36
|
+
- lib/fastlane/plugin/plist_surgeon/actions/plist_surgeon_delete_action.rb
|
|
36
37
|
- lib/fastlane/plugin/plist_surgeon/actions/privacy_surgeon_action.rb
|
|
37
38
|
- lib/fastlane/plugin/plist_surgeon/helper/plist_surgeon_helper.rb
|
|
38
39
|
- lib/fastlane/plugin/plist_surgeon/version.rb
|