expo-manifests 0.7.1 → 0.8.1

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,23 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 0.7.1 — 2023-06-30
13
+ ## 0.8.1 — 2023-08-02
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Drop support for `logUrl` which sent console logs to the legacy `expo-cli`. ([#18596](https://github.com/expo/expo/pull/18596) by [@EvanBacon](https://github.com/EvanBacon))
18
+
19
+ ## 0.8.0 — 2023-07-28
20
+
21
+ ### 🎉 New features
22
+
23
+ - [iOS] Expose getMetadata method to match android. ([#23445](https://github.com/expo/expo/pull/23445) by [@wschurman](https://github.com/wschurman))
24
+
25
+ ### 🐛 Bug fixes
26
+
27
+ - [iOS] Fix error in handling nested array. ([#23562](https://github.com/expo/expo/pull/23562) by [@douglowder](https://github.com/douglowder))
28
+
29
+ ## 0.7.1 - 2023-06-30
14
30
 
15
31
  ### 🐛 Bug fixes
16
32
 
@@ -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.1'
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.1'
71
71
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
72
72
  }
73
73
  lintOptions {
@@ -105,7 +105,6 @@ abstract class Manifest(protected val json: JSONObject) {
105
105
 
106
106
  fun getDebuggerHost(): String = getExpoGoConfigRootObject()!!.require("debuggerHost")
107
107
  fun getMainModuleName(): String = getExpoGoConfigRootObject()!!.require("mainModuleName")
108
- fun getLogUrl(): String? = getExpoGoConfigRootObject()?.getNullable("logUrl")
109
108
  fun getHostUri(): String? = getExpoClientConfigRootObject()?.getNullable("hostUri")
110
109
 
111
110
  fun isVerified(): Boolean = json.getNullable("isVerified") ?: false
@@ -270,12 +269,19 @@ internal sealed class PluginType {
270
269
  private fun fromRawValue(value: Any): PluginType? {
271
270
  return when (value) {
272
271
  is JSONArray -> {
273
- if (value.length() != 2) {
272
+ if (value.length() == 0) {
274
273
  throw IllegalArgumentException("Value for (key = plugins) has incorrect type")
275
274
  }
276
275
  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())
276
+ when (value.length()) {
277
+ 2 -> {
278
+ val props = value.get(1) as? JSONObject ?: return null
279
+ WithProps(name to props.toMap())
280
+ }
281
+ else -> {
282
+ WithoutProps(name)
283
+ }
284
+ }
279
285
  }
280
286
  is String -> {
281
287
  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
  }
@@ -198,10 +200,6 @@ public class Manifest: NSObject {
198
200
  return expoGoConfigRootObject()?.optionalValue(forKey: "developer")
199
201
  }
200
202
 
201
- public func logUrl() -> String? {
202
- return expoGoConfigRootObject()?.optionalValue(forKey: "logUrl")
203
- }
204
-
205
203
  public func facebookAppId() -> String? {
206
204
  return expoClientConfigRootObject()?.optionalValue(forKey: "facebookAppId")
207
205
  }
@@ -315,9 +313,8 @@ public class Manifest: NSObject {
315
313
  let sdkMajorVersion = expoGoSDKMajorVersion()
316
314
  if sdkMajorVersion > 0 && sdkMajorVersion < 48 {
317
315
  return "jsc"
318
- } else {
319
- return "hermes"
320
316
  }
317
+ return "hermes"
321
318
  }
322
319
  return jsEngine
323
320
  }
@@ -337,8 +334,14 @@ public class Manifest: NSObject {
337
334
  return nil
338
335
  }
339
336
  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))
337
+ let name = valueArray[0] as? String {
338
+ if valueArray.count > 1 {
339
+ guard let props = valueArray[1] as? [String: Any] else {
340
+ return .withoutProps((name))
341
+ }
342
+ return .withProps((name, props))
343
+ }
344
+ return .withoutProps((name))
342
345
  }
343
346
  if let value = value as? String {
344
347
  return .withoutProps(value)
@@ -411,3 +414,5 @@ public class Manifest: NSObject {
411
414
  return nil
412
415
  }
413
416
  }
417
+
418
+ // 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
  }
@@ -48,7 +48,6 @@ class BareManifestSpec : ExpoSpec {
48
48
  expect(manifest.orientation()).to(beNil())
49
49
  expect(manifest.experiments()).to(beNil())
50
50
  expect(manifest.developer()).to(beNil())
51
- expect(manifest.logUrl()).to(beNil())
52
51
  expect(manifest.facebookAppId()).to(beNil())
53
52
  expect(manifest.facebookApplicationName()).to(beNil())
54
53
  expect(manifest.facebookAutoInitEnabled()) == false
@@ -48,7 +48,6 @@ class LegacyManifestSpec : ExpoSpec {
48
48
  expect(manifest.orientation()).to(beNil())
49
49
  expect(manifest.experiments()).to(beNil())
50
50
  expect(manifest.developer()).to(beNil())
51
- expect(manifest.logUrl()).to(beNil())
52
51
  expect(manifest.facebookAppId()).to(beNil())
53
52
  expect(manifest.facebookApplicationName()).to(beNil())
54
53
  expect(manifest.facebookAutoInitEnabled()) == false
@@ -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
  }
@@ -43,7 +43,6 @@ class NewManifestSpec : ExpoSpec {
43
43
  expect(manifest.orientation()).to(beNil())
44
44
  expect(manifest.experiments()).to(beNil())
45
45
  expect(manifest.developer()).to(beNil())
46
- expect(manifest.logUrl()).to(beNil())
47
46
  expect(manifest.facebookAppId()).to(beNil())
48
47
  expect(manifest.facebookApplicationName()).to(beNil())
49
48
  expect(manifest.facebookAutoInitEnabled()) == false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-manifests",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
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": "2240630a92eb79a4e4bf73e1439916c394876478"
26
26
  }