expo-manifests 0.7.1 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -10,7 +10,17 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 0.7.1 — 2023-06-30
13
+ ## 0.8.0 — 2023-07-28
14
+
15
+ ### 🎉 New features
16
+
17
+ - [iOS] Expose getMetadata method to match android. ([#23445](https://github.com/expo/expo/pull/23445) by [@wschurman](https://github.com/wschurman))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - [iOS] Fix error in handling nested array. ([#23562](https://github.com/expo/expo/pull/23562) by [@douglowder](https://github.com/douglowder))
22
+
23
+ ## 0.7.1 - 2023-06-30
14
24
 
15
25
  ### 🐛 Bug fixes
16
26
 
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '0.7.1'
6
+ version = '0.8.0'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -67,7 +67,7 @@ android {
67
67
  minSdkVersion safeExtGet("minSdkVersion", 21)
68
68
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
69
  versionCode 31
70
- versionName '0.7.1'
70
+ versionName '0.8.0'
71
71
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
72
72
  }
73
73
  lintOptions {
@@ -270,12 +270,19 @@ internal sealed class PluginType {
270
270
  private fun fromRawValue(value: Any): PluginType? {
271
271
  return when (value) {
272
272
  is JSONArray -> {
273
- if (value.length() != 2) {
273
+ if (value.length() == 0) {
274
274
  throw IllegalArgumentException("Value for (key = plugins) has incorrect type")
275
275
  }
276
276
  val name = value.get(0) as? String ?: return null
277
- val props = value.get(1) as? JSONObject ?: return null
278
- WithProps(name to props.toMap())
277
+ when (value.length()) {
278
+ 2 -> {
279
+ val props = value.get(1) as? JSONObject ?: return null
280
+ WithProps(name to props.toMap())
281
+ }
282
+ else -> {
283
+ WithoutProps(name)
284
+ }
285
+ }
279
286
  }
280
287
  is String -> {
281
288
  WithoutProps(value)
@@ -9,28 +9,35 @@ import org.junit.Test
9
9
  class ManifestTest {
10
10
  @Test
11
11
  fun getPluginProperties_emptyManifest_returnsNull() {
12
- val manifestJson = JSONObject(emptyMap<String, Any>())
12
+ val manifestJson = JSONObject("{}")
13
13
  val manifest = Manifest.fromManifestJson(manifestJson)
14
14
  Truth.assertThat(manifest.getPluginProperties("test")).isNull()
15
15
  }
16
16
 
17
17
  @Test
18
18
  fun getPluginProperties_emptyPlugins_returnsNull() {
19
- val manifestJson = JSONObject(mapOf<String, Any>("plugins" to emptyArray<Any>()))
19
+ val manifestJson = JSONObject("{\"plugins\": []}")
20
20
  val manifest = Manifest.fromManifestJson(manifestJson)
21
21
  Truth.assertThat(manifest.getPluginProperties("test")).isNull()
22
22
  }
23
23
 
24
24
  @Test
25
25
  fun getPluginProperties_nonMatchedPlugins_returnsNull() {
26
- val manifestJson = JSONObject(mapOf<String, Any>("plugins" to arrayOf("hello")))
26
+ val manifestJson = JSONObject("{\"plugins\": [\"hello\"]}")
27
27
  val manifest = Manifest.fromManifestJson(manifestJson)
28
28
  Truth.assertThat(manifest.getPluginProperties("test")).isNull()
29
29
  }
30
30
 
31
31
  @Test
32
32
  fun getPluginProperties_matchedPluginWithoutProps_returnsNull() {
33
- val manifestJson = JSONObject(mapOf<String, Any>("plugins" to arrayOf("test")))
33
+ val manifestJson = JSONObject("{\"plugins\": [\"test\"]}")
34
+ val manifest = Manifest.fromManifestJson(manifestJson)
35
+ Truth.assertThat(manifest.getPluginProperties("test")).isNull()
36
+ }
37
+
38
+ @Test
39
+ fun getPluginProperties_matchedPluginWithoutPropsAsNestedArray_returnsNull() {
40
+ val manifestJson = JSONObject("{\"plugins\": [[\"test\"]]}")
34
41
  val manifest = Manifest.fromManifestJson(manifestJson)
35
42
  Truth.assertThat(manifest.getPluginProperties("test")).isNull()
36
43
  }
@@ -38,8 +45,7 @@ class ManifestTest {
38
45
  @Test
39
46
  fun getPluginProperties_matchedPluginWithProps_returnsProps() {
40
47
  val props = mapOf<String, Any>("foo" to "bar")
41
- val pluginWithProp = arrayOf("test", props)
42
- val manifestJson = JSONObject(mapOf<String, Any>("plugins" to arrayOf(pluginWithProp)))
48
+ val manifestJson = JSONObject("{\"plugins\": [ [\"test\", {\"foo\":\"bar\"}] ]}")
43
49
  val manifest = Manifest.fromManifestJson(manifestJson)
44
50
  val result = manifest.getPluginProperties("test")
45
51
  Truth.assertThat(result).isNotNull()
@@ -49,8 +55,7 @@ class ManifestTest {
49
55
  @Test
50
56
  fun getPluginProperties_matchedPluginWithNestedProps_returnsNestedProps() {
51
57
  val props = mapOf<String, Any>("nested" to mapOf<String, Any>("insideNested" to true))
52
- val pluginWithProp = arrayOf("test", props)
53
- val manifestJson = JSONObject(mapOf<String, Any>("plugins" to arrayOf(pluginWithProp)))
58
+ val manifestJson = JSONObject("{\"plugins\":[[\"test\",{\"nested\":{\"insideNested\":true}}]]}")
54
59
  val manifest = Manifest.fromManifestJson(manifestJson)
55
60
  val result = manifest.getPluginProperties("test")
56
61
  Truth.assertThat(result).isNotNull()
@@ -5,11 +5,11 @@ import Foundation
5
5
  @objc(EXManifestBaseLegacyManifest)
6
6
  @objcMembers
7
7
  public class BaseLegacyManifest: Manifest {
8
- override func expoClientConfigRootObject() -> [String: Any]? {
8
+ public override func expoClientConfigRootObject() -> [String: Any]? {
9
9
  return rawManifestJSON()
10
10
  }
11
11
 
12
- override func expoGoConfigRootObject() -> [String: Any]? {
12
+ public override func expoGoConfigRootObject() -> [String: Any]? {
13
13
  return rawManifestJSON()
14
14
  }
15
15
 
@@ -3,8 +3,6 @@
3
3
  // this uses abstract class patterns
4
4
  // swiftlint:disable unavailable_function
5
5
 
6
- // swiftlint:disable type_body_length file_length
7
-
8
6
  import Foundation
9
7
  import UIKit
10
8
 
@@ -121,11 +119,11 @@ public class Manifest: NSObject {
121
119
  preconditionFailure("Must override in concrete class")
122
120
  }
123
121
 
124
- func expoGoConfigRootObject() -> [String: Any]? {
122
+ public func expoGoConfigRootObject() -> [String: Any]? {
125
123
  preconditionFailure("Must override in concrete class")
126
124
  }
127
125
 
128
- func expoClientConfigRootObject() -> [String: Any]? {
126
+ public func expoClientConfigRootObject() -> [String: Any]? {
129
127
  preconditionFailure("Must override in concrete class")
130
128
  }
131
129
 
@@ -150,6 +148,10 @@ public class Manifest: NSObject {
150
148
  return expoClientConfigRootObject()?.optionalValue(forKey: "revisionId")
151
149
  }
152
150
 
151
+ public func getMetadata() -> [String: Any]? {
152
+ return rawManifestJSONInternal.optionalValue(forKey: "metadata")
153
+ }
154
+
153
155
  public func slug() -> String? {
154
156
  return expoClientConfigRootObject()?.optionalValue(forKey: "slug")
155
157
  }
@@ -315,9 +317,8 @@ public class Manifest: NSObject {
315
317
  let sdkMajorVersion = expoGoSDKMajorVersion()
316
318
  if sdkMajorVersion > 0 && sdkMajorVersion < 48 {
317
319
  return "jsc"
318
- } else {
319
- return "hermes"
320
320
  }
321
+ return "hermes"
321
322
  }
322
323
  return jsEngine
323
324
  }
@@ -337,8 +338,14 @@ public class Manifest: NSObject {
337
338
  return nil
338
339
  }
339
340
  if let valueArray = value as? [Any],
340
- let name = valueArray[0] as? String, let props = valueArray[1] as? [String: Any] {
341
- return .withProps((name, props))
341
+ let name = valueArray[0] as? String {
342
+ if valueArray.count > 1 {
343
+ guard let props = valueArray[1] as? [String: Any] else {
344
+ return .withoutProps((name))
345
+ }
346
+ return .withProps((name, props))
347
+ }
348
+ return .withoutProps((name))
342
349
  }
343
350
  if let value = value as? String {
344
351
  return .withoutProps(value)
@@ -411,3 +418,5 @@ public class Manifest: NSObject {
411
418
  return nil
412
419
  }
413
420
  }
421
+
422
+ // swiftlint:enable unavailable_function
@@ -73,11 +73,11 @@ public class NewManifest: Manifest {
73
73
  return launchAsset().requiredValue(forKey: "url")
74
74
  }
75
75
 
76
- override func expoClientConfigRootObject() -> [String: Any]? {
76
+ public override func expoClientConfigRootObject() -> [String: Any]? {
77
77
  return extra()?.optionalValue(forKey: "expoClient")
78
78
  }
79
79
 
80
- override func expoGoConfigRootObject() -> [String: Any]? {
80
+ public override func expoGoConfigRootObject() -> [String: Any]? {
81
81
  return extra()?.optionalValue(forKey: "expoGo")
82
82
  }
83
83
  }
@@ -12,7 +12,7 @@ final class ManifestSpec: ExpoSpec {
12
12
  var manifest = ManifestFactory.manifest(forManifestJSON: manifestJson)
13
13
  expect(manifest.getPluginProperties(packageName: "test")).to(beNil())
14
14
 
15
- manifestJson = ["plugins": []]
15
+ manifestJson = ["plugins": [] as [Any]]
16
16
  manifest = ManifestFactory.manifest(forManifestJSON: manifestJson)
17
17
  expect(manifest.getPluginProperties(packageName: "test")).to(beNil())
18
18
 
@@ -28,11 +28,17 @@ final class ManifestSpec: ExpoSpec {
28
28
  }
29
29
 
30
30
  it("should return matched plugin properties") {
31
- let manifestJson = ["plugins": [["test", ["foo": "bar"]]]]
31
+ let manifestJson = ["plugins": [["test", ["foo": "bar"]] as [Any]]]
32
32
  let manifest = ManifestFactory.manifest(forManifestJSON: manifestJson)
33
33
  let props = manifest.getPluginProperties(packageName: "test")
34
34
  expect(props as? [String: String]) == ["foo": "bar"]
35
35
  }
36
+
37
+ it("should not crash with array with name and no props") {
38
+ let manifestJson = ["plugins": [["test"]]]
39
+ let manifest = ManifestFactory.manifest(forManifestJSON: manifestJson)
40
+ expect(manifest.getPluginProperties(packageName: "test")).to(beNil())
41
+ }
36
42
  }
37
43
  }
38
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-manifests",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Code to parse and use Expo and Expo Updates manifests.",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://docs.expo.dev/versions/latest/sdk/module-template",
22
22
  "dependencies": {
23
- "expo-json-utils": "~0.7.0"
23
+ "expo-json-utils": "~0.8.0"
24
24
  },
25
- "gitHead": "554e8b88a1a5d7f54c67cdb66e928a0adfb8731d"
25
+ "gitHead": "663654577a7068c641b5e9474efbc502e3f334ea"
26
26
  }