expo-build-properties 0.8.0 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.8.2 — 2023-06-27
14
+
15
+ ### 💡 Others
16
+
17
+ - Upgrade `semver` lib. ([#23113](https://github.com/expo/expo/pull/23113) by [@felipemillhouse](https://github.com/felipemillhouse))
18
+
19
+ ## 0.8.1 — 2023-06-23
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
13
23
  ## 0.8.0 — 2023-06-21
14
24
 
15
25
  ### 🛠 Breaking changes
@@ -19,6 +29,7 @@
19
29
  ### 🎉 New features
20
30
 
21
31
  - Added `android.extraMavenRepos` and `ios.extraPods` support. ([#22785](https://github.com/expo/expo/pull/22785) by [@kudo](https://github.com/kudo))
32
+ - Added `android.usesCleartextTraffic` support. ([#23043](https://github.com/expo/expo/pull/23043) by [@alanjhughes](https://github.com/alanjhughes))
22
33
 
23
34
  ## 0.7.0 — 2023-05-08
24
35
 
@@ -19,3 +19,4 @@ export declare const withAndroidPurgeProguardRulesOnce: ConfigPlugin;
19
19
  * @returns return updated contents
20
20
  */
21
21
  export declare function updateAndroidProguardRules(contents: string, newProguardRules: string | null, updateMode: 'append' | 'overwrite'): string;
22
+ export declare const withAndroidCleartextTraffic: ConfigPlugin<PluginConfigType>;
package/build/android.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateAndroidProguardRules = exports.withAndroidPurgeProguardRulesOnce = exports.withAndroidProguardRules = exports.withAndroidFlipper = exports.withAndroidBuildProperties = void 0;
6
+ exports.withAndroidCleartextTraffic = exports.updateAndroidProguardRules = exports.withAndroidPurgeProguardRulesOnce = exports.withAndroidProguardRules = exports.withAndroidFlipper = exports.withAndroidBuildProperties = void 0;
7
7
  const config_plugins_1 = require("expo/config-plugins");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -174,3 +174,20 @@ function updateAndroidProguardRules(contents, newProguardRules, updateMode) {
174
174
  return newContents;
175
175
  }
176
176
  exports.updateAndroidProguardRules = updateAndroidProguardRules;
177
+ const withAndroidCleartextTraffic = (config, props) => {
178
+ return (0, config_plugins_1.withAndroidManifest)(config, (config) => {
179
+ if (props.android?.usesCleartextTraffic == null) {
180
+ return config;
181
+ }
182
+ config.modResults = setUsesCleartextTraffic(config.modResults, props.android?.usesCleartextTraffic);
183
+ return config;
184
+ });
185
+ };
186
+ exports.withAndroidCleartextTraffic = withAndroidCleartextTraffic;
187
+ function setUsesCleartextTraffic(androidManifest, value) {
188
+ const mainApplication = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);
189
+ if (mainApplication?.$) {
190
+ mainApplication.$['android:usesCleartextTraffic'] = String(value);
191
+ }
192
+ return androidManifest;
193
+ }
@@ -91,6 +91,14 @@ export interface PluginConfigTypeAndroid {
91
91
  * this property is actually handled by `expo-modules-autolinking` but not the config-plugins inside expo-build-properties.
92
92
  */
93
93
  extraMavenRepos?: string[];
94
+ /**
95
+ * Indicates whether the app intends to use cleartext network traffic.
96
+ *
97
+ * @default false
98
+ *
99
+ * @see [Android documentation](https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic)
100
+ */
101
+ usesCleartextTraffic?: boolean;
94
102
  }
95
103
  /**
96
104
  * Interface representing available configuration for iOS native build properties.
@@ -52,6 +52,7 @@ const schema = {
52
52
  },
53
53
  networkInspector: { type: 'boolean', nullable: true },
54
54
  extraMavenRepos: { type: 'array', items: { type: 'string' }, nullable: true },
55
+ usesCleartextTraffic: { type: 'boolean', nullable: true },
55
56
  },
56
57
  nullable: true,
57
58
  },
@@ -13,6 +13,7 @@ const withBuildProperties = (config, props) => {
13
13
  const pluginConfig = (0, pluginConfig_1.validateConfig)(props || {});
14
14
  config = (0, android_1.withAndroidBuildProperties)(config, pluginConfig);
15
15
  config = (0, android_1.withAndroidProguardRules)(config, pluginConfig);
16
+ config = (0, android_1.withAndroidCleartextTraffic)(config, pluginConfig);
16
17
  // Assuming `withBuildProperties` could be called multiple times from different config-plugins,
17
18
  // the `withAndroidProguardRules` always appends new rules by default.
18
19
  // That is not ideal if we leave generated contents from previous prebuild there.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-build-properties",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Config plugin to customize native build properties on prebuild",
5
5
  "main": "build/withBuildProperties.js",
6
6
  "types": "build/withBuildProperties.d.ts",
@@ -32,7 +32,7 @@
32
32
  "homepage": "https://docs.expo.dev/versions/latest/sdk/build-properties",
33
33
  "dependencies": {
34
34
  "ajv": "^8.11.0",
35
- "semver": "^7.3.5"
35
+ "semver": "^7.5.3"
36
36
  },
37
37
  "devDependencies": {
38
38
  "expo-module-scripts": "^3.0.0"
@@ -40,5 +40,5 @@
40
40
  "peerDependencies": {
41
41
  "expo": "*"
42
42
  },
43
- "gitHead": "fa5ecca8251986b9f197cc14074eec0ab6dfb6db"
43
+ "gitHead": "aa6bda733cef821234c77a19bbe6008b72c1c594"
44
44
  }
package/src/android.ts CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  AndroidConfig,
3
3
  ConfigPlugin,
4
4
  History,
5
+ withAndroidManifest,
5
6
  withDangerousMod,
6
7
  withGradleProperties,
7
8
  } from 'expo/config-plugins';
@@ -207,3 +208,33 @@ export function updateAndroidProguardRules(
207
208
  }
208
209
  return newContents;
209
210
  }
211
+
212
+ export const withAndroidCleartextTraffic: ConfigPlugin<PluginConfigType> = (config, props) => {
213
+ return withAndroidManifest(config, (config) => {
214
+ if (props.android?.usesCleartextTraffic == null) {
215
+ return config;
216
+ }
217
+
218
+ config.modResults = setUsesCleartextTraffic(
219
+ config.modResults,
220
+ props.android?.usesCleartextTraffic
221
+ );
222
+
223
+ return config;
224
+ });
225
+ };
226
+
227
+ function setUsesCleartextTraffic(
228
+ androidManifest: AndroidConfig.Manifest.AndroidManifest,
229
+ value: boolean
230
+ ) {
231
+ const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);
232
+
233
+ if (mainApplication?.$) {
234
+ mainApplication.$['android:usesCleartextTraffic'] = String(
235
+ value
236
+ ) as AndroidConfig.Manifest.StringBoolean;
237
+ }
238
+
239
+ return androidManifest;
240
+ }
@@ -114,6 +114,14 @@ export interface PluginConfigTypeAndroid {
114
114
  * this property is actually handled by `expo-modules-autolinking` but not the config-plugins inside expo-build-properties.
115
115
  */
116
116
  extraMavenRepos?: string[];
117
+ /**
118
+ * Indicates whether the app intends to use cleartext network traffic.
119
+ *
120
+ * @default false
121
+ *
122
+ * @see [Android documentation](https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic)
123
+ */
124
+ usesCleartextTraffic?: boolean;
117
125
  }
118
126
 
119
127
  /**
@@ -307,6 +315,8 @@ const schema: JSONSchemaType<PluginConfigType> = {
307
315
  networkInspector: { type: 'boolean', nullable: true },
308
316
 
309
317
  extraMavenRepos: { type: 'array', items: { type: 'string' }, nullable: true },
318
+
319
+ usesCleartextTraffic: { type: 'boolean', nullable: true },
310
320
  },
311
321
  nullable: true,
312
322
  },
@@ -5,6 +5,7 @@ import {
5
5
  withAndroidProguardRules,
6
6
  withAndroidPurgeProguardRulesOnce,
7
7
  withAndroidFlipper,
8
+ withAndroidCleartextTraffic,
8
9
  } from './android';
9
10
  import { withIosBuildProperties, withIosDeploymentTarget } from './ios';
10
11
  import { PluginConfigType, validateConfig } from './pluginConfig';
@@ -20,6 +21,7 @@ export const withBuildProperties: ConfigPlugin<PluginConfigType> = (config, prop
20
21
  config = withAndroidBuildProperties(config, pluginConfig);
21
22
 
22
23
  config = withAndroidProguardRules(config, pluginConfig);
24
+ config = withAndroidCleartextTraffic(config, pluginConfig);
23
25
  // Assuming `withBuildProperties` could be called multiple times from different config-plugins,
24
26
  // the `withAndroidProguardRules` always appends new rules by default.
25
27
  // That is not ideal if we leave generated contents from previous prebuild there.