fastlane-plugin-plist_surgeon 0.1.0 → 0.1.2
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 +11 -0
- data/lib/fastlane/plugin/plist_surgeon/actions/entitlements_surgeon_action.rb +3 -3
- data/lib/fastlane/plugin/plist_surgeon/actions/plist_surgeon_action.rb +3 -3
- data/lib/fastlane/plugin/plist_surgeon/actions/privacy_surgeon_action.rb +3 -3
- data/lib/fastlane/plugin/plist_surgeon/helper/plist_surgeon_helper.rb +53 -4
- data/lib/fastlane/plugin/plist_surgeon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a4c842111d0642840d28e07781a460e50c2391ece4591051efea52033861617
|
|
4
|
+
data.tar.gz: f6065508091457bee57180beb14181b688771f0f16c6198fa9723226c001b3d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d94f7e8ac67bfa10333845e5dc07694dd741c1f22f5d8729218d52517a3e4cee8cd9a00a2c7fb106f760db685f350fbc0418958ff8a802ca6397c02b21548f17
|
|
7
|
+
data.tar.gz: 3e14d8221bf389634e6352d5be9a257eeeabf8d9aa7b318f901844840eb3f1f60899fc90d7e3e138818c930763b57593e958ac8cdcf223839324c6a38b802d32
|
data/README.md
CHANGED
|
@@ -71,6 +71,17 @@ 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
|
+
### Complex Values
|
|
75
|
+
|
|
76
|
+
You can set complex values (Arrays or Hashes) by passing a JSON string. This is especially useful when running from the command line.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
fastlane run plist_surgeon \
|
|
80
|
+
path:"Info.plist" \
|
|
81
|
+
key:"CFBundleIcons" \
|
|
82
|
+
value:'{"CFBundlePrimaryIcon":{"CFBundleIconFiles":["AppIcon"]}}'
|
|
83
|
+
```
|
|
84
|
+
|
|
74
85
|
### Run tests for this plugin
|
|
75
86
|
|
|
76
87
|
To run both the tests, and code style validation, run
|
|
@@ -19,17 +19,17 @@ module Fastlane
|
|
|
19
19
|
def self.available_options
|
|
20
20
|
[
|
|
21
21
|
FastlaneCore::ConfigItem.new(key: :path,
|
|
22
|
-
env_name: "
|
|
22
|
+
env_name: "PLIST_SURGEON_ENTITLEMENTS_PATH",
|
|
23
23
|
description: "The path to the entitlements file",
|
|
24
24
|
optional: false,
|
|
25
25
|
type: String),
|
|
26
26
|
FastlaneCore::ConfigItem.new(key: :key,
|
|
27
|
-
env_name: "
|
|
27
|
+
env_name: "PLIST_SURGEON_ENTITLEMENTS_KEY",
|
|
28
28
|
description: "The key to update (supports dot notation for nested keys)",
|
|
29
29
|
optional: false,
|
|
30
30
|
type: String),
|
|
31
31
|
FastlaneCore::ConfigItem.new(key: :value,
|
|
32
|
-
env_name: "
|
|
32
|
+
env_name: "PLIST_SURGEON_ENTITLEMENTS_VALUE",
|
|
33
33
|
description: "The value to set",
|
|
34
34
|
optional: false)
|
|
35
35
|
]
|
|
@@ -19,17 +19,17 @@ module Fastlane
|
|
|
19
19
|
def self.available_options
|
|
20
20
|
[
|
|
21
21
|
FastlaneCore::ConfigItem.new(key: :path,
|
|
22
|
-
env_name: "
|
|
22
|
+
env_name: "PLIST_SURGEON_PLIST_PATH",
|
|
23
23
|
description: "The path to the plist file",
|
|
24
24
|
optional: false,
|
|
25
25
|
type: String),
|
|
26
26
|
FastlaneCore::ConfigItem.new(key: :key,
|
|
27
|
-
env_name: "
|
|
27
|
+
env_name: "PLIST_SURGEON_PLIST_KEY",
|
|
28
28
|
description: "The key to update (supports dot notation for nested keys)",
|
|
29
29
|
optional: false,
|
|
30
30
|
type: String),
|
|
31
31
|
FastlaneCore::ConfigItem.new(key: :value,
|
|
32
|
-
env_name: "
|
|
32
|
+
env_name: "PLIST_SURGEON_PLIST_VALUE",
|
|
33
33
|
description: "The value to set",
|
|
34
34
|
optional: false)
|
|
35
35
|
]
|
|
@@ -19,17 +19,17 @@ module Fastlane
|
|
|
19
19
|
def self.available_options
|
|
20
20
|
[
|
|
21
21
|
FastlaneCore::ConfigItem.new(key: :path,
|
|
22
|
-
env_name: "
|
|
22
|
+
env_name: "PLIST_SURGEON_PRIVACY_PATH",
|
|
23
23
|
description: "The path to the xcprivacy file",
|
|
24
24
|
optional: false,
|
|
25
25
|
type: String),
|
|
26
26
|
FastlaneCore::ConfigItem.new(key: :key,
|
|
27
|
-
env_name: "
|
|
27
|
+
env_name: "PLIST_SURGEON_PRIVACY_KEY",
|
|
28
28
|
description: "The key to update (supports dot notation for nested keys)",
|
|
29
29
|
optional: false,
|
|
30
30
|
type: String),
|
|
31
31
|
FastlaneCore::ConfigItem.new(key: :value,
|
|
32
|
-
env_name: "
|
|
32
|
+
env_name: "PLIST_SURGEON_PRIVACY_VALUE",
|
|
33
33
|
description: "The value to set",
|
|
34
34
|
optional: false)
|
|
35
35
|
]
|
|
@@ -15,20 +15,69 @@ module Fastlane
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
set_value(plist, key, value)
|
|
18
|
-
|
|
19
|
-
File.write(path,
|
|
18
|
+
plist_content = plist.to_plist
|
|
19
|
+
File.write(path, plist_content)
|
|
20
|
+
"#{File.basename(path)} saved with #{key} change."
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def self.set_value(plist, key, value)
|
|
23
|
-
|
|
24
|
+
value = parse_json_if_needed(value)
|
|
25
|
+
|
|
26
|
+
if plist.kind_of?(Hash) && plist.key?(key)
|
|
27
|
+
plist[key] = value
|
|
28
|
+
elsif key.include?('.')
|
|
24
29
|
set_nested_value(plist, key, value)
|
|
30
|
+
else
|
|
31
|
+
set_direct_value(plist, key, value)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.set_direct_value(plist, key, value)
|
|
36
|
+
if plist.kind_of?(Array)
|
|
37
|
+
plist[key.to_i] = value
|
|
25
38
|
else
|
|
26
39
|
plist[key] = value
|
|
27
40
|
end
|
|
28
41
|
end
|
|
29
42
|
|
|
43
|
+
def self.parse_json_if_needed(value)
|
|
44
|
+
if value.kind_of?(String) && value.start_with?('{', '[')
|
|
45
|
+
begin
|
|
46
|
+
require 'json'
|
|
47
|
+
return JSON.parse(value)
|
|
48
|
+
rescue JSON::ParserError
|
|
49
|
+
# Not JSON, keep as string
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
value
|
|
53
|
+
end
|
|
54
|
+
|
|
30
55
|
def self.set_nested_value(plist, key, value)
|
|
31
|
-
|
|
56
|
+
# Attempt to find if any prefix of the key exists as a literal key
|
|
57
|
+
parts = key.split('.')
|
|
58
|
+
prefix_key = find_prefix_key(plist, parts)
|
|
59
|
+
|
|
60
|
+
if prefix_key
|
|
61
|
+
prefix, remainder = prefix_key
|
|
62
|
+
set_value(plist[prefix], remainder, value)
|
|
63
|
+
else
|
|
64
|
+
set_deep_nested_value(plist, parts, value)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.find_prefix_key(plist, parts)
|
|
69
|
+
return nil unless plist.kind_of?(Hash)
|
|
70
|
+
|
|
71
|
+
(parts.size - 1).downto(1) do |i|
|
|
72
|
+
prefix = parts[0...i].join('.')
|
|
73
|
+
if plist.key?(prefix)
|
|
74
|
+
return [prefix, parts[i..-1].join('.')]
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.set_deep_nested_value(plist, keys, value)
|
|
32
81
|
last_key = keys.pop
|
|
33
82
|
current = plist
|
|
34
83
|
keys.each do |k|
|