expo-build-properties 0.7.0 → 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,6 +10,21 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.8.1 — 2023-06-23
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 0.8.0 — 2023-06-21
18
+
19
+ ### 🛠 Breaking changes
20
+
21
+ - Replaced `unstable_networkInspector` as `networkInspector` and enabled the feature by default. ([#22994](https://github.com/expo/expo/pull/22994) by [@kudo](https://github.com/kudo))
22
+
23
+ ### 🎉 New features
24
+
25
+ - Added `android.extraMavenRepos` and `ios.extraPods` support. ([#22785](https://github.com/expo/expo/pull/22785) by [@kudo](https://github.com/kudo))
26
+ - Added `android.usesCleartextTraffic` support. ([#23043](https://github.com/expo/expo/pull/23043) by [@alanjhughes](https://github.com/alanjhughes))
27
+
13
28
  ## 0.7.0 — 2023-05-08
14
29
 
15
30
  ### 🐛 Bug fixes
@@ -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"));
@@ -60,7 +60,7 @@ exports.withAndroidBuildProperties = createBuildGradlePropsConfigPlugin([
60
60
  },
61
61
  {
62
62
  propName: 'EX_DEV_CLIENT_NETWORK_INSPECTOR',
63
- propValueGetter: (config) => config.android?.unstable_networkInspector?.toString(),
63
+ propValueGetter: (config) => (config.android?.networkInspector ?? true).toString(),
64
64
  },
65
65
  ], 'withAndroidBuildProperties');
66
66
  const withAndroidFlipper = (config, props) => {
@@ -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
+ }
package/build/ios.js CHANGED
@@ -23,7 +23,7 @@ exports.withIosBuildProperties = createBuildPodfilePropsConfigPlugin([
23
23
  },
24
24
  {
25
25
  propName: 'EX_DEV_CLIENT_NETWORK_INSPECTOR',
26
- propValueGetter: (config) => config.ios?.unstable_networkInspector?.toString(),
26
+ propValueGetter: (config) => (config.ios?.networkInspector ?? true).toString(),
27
27
  },
28
28
  ], 'withIosBuildProperties');
29
29
  const withIosDeploymentTarget = (config, props) => {
@@ -68,10 +68,37 @@ export interface PluginConfigTypeAndroid {
68
68
  */
69
69
  flipper?: string;
70
70
  /**
71
- * Enable the experimental Network Inspector for [Development builds](https://docs.expo.dev/develop/development-builds/introduction/).
72
- * SDK 49+ is required.
71
+ * Enable the Network Inspector.
72
+ *
73
+ * @default true
74
+ */
75
+ networkInspector?: boolean;
76
+ /**
77
+ * Add extra maven repositories to all gradle projects.
78
+ *
79
+ * This acts like to add the following code to **android/build.gradle**:
80
+ * ```groovy
81
+ * allprojects {
82
+ * repositories {
83
+ * maven {
84
+ * url [THE_EXTRA_MAVEN_REPOSITORY]
85
+ * }
86
+ * }
87
+ * }
88
+ * ```
89
+ *
90
+ * @hide For the implementation details,
91
+ * this property is actually handled by `expo-modules-autolinking` but not the config-plugins inside expo-build-properties.
73
92
  */
74
- unstable_networkInspector?: boolean;
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;
75
102
  }
76
103
  /**
77
104
  * Interface representing available configuration for iOS native build properties.
@@ -107,10 +134,97 @@ export interface PluginConfigTypeIos {
107
134
  */
108
135
  flipper?: boolean | string;
109
136
  /**
110
- * Enable the experimental Network Inspector for [Development builds](https://docs.expo.dev/develop/development-builds/introduction/).
111
- * SDK 49+ is required.
137
+ * Enable the Network Inspector.
138
+ *
139
+ * @default true
140
+ */
141
+ networkInspector?: boolean;
142
+ /**
143
+ * Add extra CocoaPods dependencies for all targets.
144
+ *
145
+ * This acts like to add the following code to **ios/Podfile**:
146
+ * ```
147
+ * pod '[EXTRA_POD_NAME]', '~> [EXTRA_POD_VERSION]'
148
+ * # e.g.
149
+ * pod 'Protobuf', '~> 3.14.0'
150
+ * ```
151
+ *
152
+ * @hide For the implementation details,
153
+ * this property is actually handled by `expo-modules-autolinking` but not the config-plugins inside expo-build-properties.
154
+ */
155
+ extraPods?: ExtraIosPodDependency[];
156
+ }
157
+ /**
158
+ * Interface representing extra CocoaPods dependency.
159
+ * @see [Podfile syntax reference](https://guides.cocoapods.org/syntax/podfile.html#pod)
160
+ * @platform ios
161
+ */
162
+ export interface ExtraIosPodDependency {
163
+ /**
164
+ * Name of the pod.
165
+ */
166
+ name: string;
167
+ /**
168
+ * Version of the pod.
169
+ * CocoaPods supports various [versioning options](https://guides.cocoapods.org/using/the-podfile.html#pod).
170
+ * @example `~> 0.1.2`
171
+ */
172
+ version?: string;
173
+ /**
174
+ * Build configurations for which the pod should be installed.
175
+ * @example `['Debug', 'Release']`
176
+ */
177
+ configurations?: string[];
178
+ /**
179
+ * Whether this pod should use modular headers.
180
+ */
181
+ modular_headers?: boolean;
182
+ /**
183
+ * Custom source to search for this dependency.
184
+ * @example `https://github.com/CocoaPods/Specs.git`
185
+ */
186
+ source?: string;
187
+ /**
188
+ * Custom local filesystem path to add the dependency.
189
+ * @example `~/Documents/AFNetworking`
190
+ */
191
+ path?: string;
192
+ /**
193
+ * Custom podspec path.
194
+ * @example `https://example.com/JSONKit.podspec`
195
+ */
196
+ podspec?: string;
197
+ /**
198
+ * Test specs can be optionally included via the :testspecs option. By default, none of a Pod's test specs are included.
199
+ * @example `['UnitTests', 'SomeOtherTests']`
200
+ */
201
+ testspecs?: string[];
202
+ /**
203
+ * Use the bleeding edge version of a Pod.
204
+ *
205
+ * @example
206
+ * ```
207
+ * { "name": "AFNetworking", "git": "https://github.com/gowalla/AFNetworking.git", "tag": "0.7.0" }
208
+ * ```
209
+ *
210
+ * This acts like to add this pod dependency statement:
211
+ * ```
212
+ * pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
213
+ * ```
214
+ */
215
+ git?: string;
216
+ /**
217
+ * The git branch to fetch. See the {@link git} property for more information.
218
+ */
219
+ branch?: string;
220
+ /**
221
+ * The git tag to fetch. See the {@link git} property for more information.
222
+ */
223
+ tag?: string;
224
+ /**
225
+ * The git commit to fetch. See the {@link git} property for more information.
112
226
  */
113
- unstable_networkInspector?: boolean;
227
+ commit?: string;
114
228
  }
115
229
  /**
116
230
  * Interface representing available configuration for Android Gradle plugin [PackagingOptions](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/dsl/PackagingOptions).
@@ -50,7 +50,9 @@ const schema = {
50
50
  },
51
51
  nullable: true,
52
52
  },
53
- unstable_networkInspector: { type: 'boolean', nullable: true },
53
+ networkInspector: { type: 'boolean', nullable: true },
54
+ extraMavenRepos: { type: 'array', items: { type: 'string' }, nullable: true },
55
+ usesCleartextTraffic: { type: 'boolean', nullable: true },
54
56
  },
55
57
  nullable: true,
56
58
  },
@@ -64,7 +66,29 @@ const schema = {
64
66
  type: ['boolean', 'string'],
65
67
  nullable: true,
66
68
  },
67
- unstable_networkInspector: { type: 'boolean', nullable: true },
69
+ networkInspector: { type: 'boolean', nullable: true },
70
+ extraPods: {
71
+ type: 'array',
72
+ items: {
73
+ type: 'object',
74
+ required: ['name'],
75
+ properties: {
76
+ name: { type: 'string' },
77
+ version: { type: 'string', nullable: true },
78
+ configurations: { type: 'array', items: { type: 'string' }, nullable: true },
79
+ modular_headers: { type: 'boolean', nullable: true },
80
+ source: { type: 'string', nullable: true },
81
+ path: { type: 'string', nullable: true },
82
+ podspec: { type: 'string', nullable: true },
83
+ testspecs: { type: 'array', items: { type: 'string' }, nullable: true },
84
+ git: { type: 'string', nullable: true },
85
+ branch: { type: 'string', nullable: true },
86
+ tag: { type: 'string', nullable: true },
87
+ commit: { type: 'string', nullable: true },
88
+ },
89
+ },
90
+ nullable: true,
91
+ },
68
92
  },
69
93
  nullable: true,
70
94
  },
@@ -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.7.0",
3
+ "version": "0.8.1",
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",
@@ -40,5 +40,5 @@
40
40
  "peerDependencies": {
41
41
  "expo": "*"
42
42
  },
43
- "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
43
+ "gitHead": "a72ae33519fe54eaf195dc3e61a49db8345103db"
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';
@@ -65,7 +66,7 @@ export const withAndroidBuildProperties = createBuildGradlePropsConfigPlugin<Plu
65
66
  },
66
67
  {
67
68
  propName: 'EX_DEV_CLIENT_NETWORK_INSPECTOR',
68
- propValueGetter: (config) => config.android?.unstable_networkInspector?.toString(),
69
+ propValueGetter: (config) => (config.android?.networkInspector ?? true).toString(),
69
70
  },
70
71
  ],
71
72
  'withAndroidBuildProperties'
@@ -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
+ }
package/src/ios.ts CHANGED
@@ -25,7 +25,7 @@ export const withIosBuildProperties = createBuildPodfilePropsConfigPlugin<Plugin
25
25
  },
26
26
  {
27
27
  propName: 'EX_DEV_CLIENT_NETWORK_INSPECTOR',
28
- propValueGetter: (config) => config.ios?.unstable_networkInspector?.toString(),
28
+ propValueGetter: (config) => (config.ios?.networkInspector ?? true).toString(),
29
29
  },
30
30
  ],
31
31
  'withIosBuildProperties'
@@ -90,10 +90,38 @@ export interface PluginConfigTypeAndroid {
90
90
  flipper?: string;
91
91
 
92
92
  /**
93
- * Enable the experimental Network Inspector for [Development builds](https://docs.expo.dev/develop/development-builds/introduction/).
94
- * SDK 49+ is required.
93
+ * Enable the Network Inspector.
94
+ *
95
+ * @default true
96
+ */
97
+ networkInspector?: boolean;
98
+
99
+ /**
100
+ * Add extra maven repositories to all gradle projects.
101
+ *
102
+ * This acts like to add the following code to **android/build.gradle**:
103
+ * ```groovy
104
+ * allprojects {
105
+ * repositories {
106
+ * maven {
107
+ * url [THE_EXTRA_MAVEN_REPOSITORY]
108
+ * }
109
+ * }
110
+ * }
111
+ * ```
112
+ *
113
+ * @hide For the implementation details,
114
+ * this property is actually handled by `expo-modules-autolinking` but not the config-plugins inside expo-build-properties.
115
+ */
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)
95
123
  */
96
- unstable_networkInspector?: boolean;
124
+ usesCleartextTraffic?: boolean;
97
125
  }
98
126
 
99
127
  /**
@@ -133,10 +161,99 @@ export interface PluginConfigTypeIos {
133
161
  flipper?: boolean | string;
134
162
 
135
163
  /**
136
- * Enable the experimental Network Inspector for [Development builds](https://docs.expo.dev/develop/development-builds/introduction/).
137
- * SDK 49+ is required.
164
+ * Enable the Network Inspector.
165
+ *
166
+ * @default true
138
167
  */
139
- unstable_networkInspector?: boolean;
168
+ networkInspector?: boolean;
169
+
170
+ /**
171
+ * Add extra CocoaPods dependencies for all targets.
172
+ *
173
+ * This acts like to add the following code to **ios/Podfile**:
174
+ * ```
175
+ * pod '[EXTRA_POD_NAME]', '~> [EXTRA_POD_VERSION]'
176
+ * # e.g.
177
+ * pod 'Protobuf', '~> 3.14.0'
178
+ * ```
179
+ *
180
+ * @hide For the implementation details,
181
+ * this property is actually handled by `expo-modules-autolinking` but not the config-plugins inside expo-build-properties.
182
+ */
183
+ extraPods?: ExtraIosPodDependency[];
184
+ }
185
+
186
+ /**
187
+ * Interface representing extra CocoaPods dependency.
188
+ * @see [Podfile syntax reference](https://guides.cocoapods.org/syntax/podfile.html#pod)
189
+ * @platform ios
190
+ */
191
+ export interface ExtraIosPodDependency {
192
+ /**
193
+ * Name of the pod.
194
+ */
195
+ name: string;
196
+ /**
197
+ * Version of the pod.
198
+ * CocoaPods supports various [versioning options](https://guides.cocoapods.org/using/the-podfile.html#pod).
199
+ * @example `~> 0.1.2`
200
+ */
201
+ version?: string;
202
+ /**
203
+ * Build configurations for which the pod should be installed.
204
+ * @example `['Debug', 'Release']`
205
+ */
206
+ configurations?: string[];
207
+ /**
208
+ * Whether this pod should use modular headers.
209
+ */
210
+ modular_headers?: boolean;
211
+ /**
212
+ * Custom source to search for this dependency.
213
+ * @example `https://github.com/CocoaPods/Specs.git`
214
+ */
215
+ source?: string;
216
+ /**
217
+ * Custom local filesystem path to add the dependency.
218
+ * @example `~/Documents/AFNetworking`
219
+ */
220
+ path?: string;
221
+ /**
222
+ * Custom podspec path.
223
+ * @example `https://example.com/JSONKit.podspec`
224
+ */
225
+ podspec?: string;
226
+ /**
227
+ * Test specs can be optionally included via the :testspecs option. By default, none of a Pod's test specs are included.
228
+ * @example `['UnitTests', 'SomeOtherTests']`
229
+ */
230
+ testspecs?: string[];
231
+ /**
232
+ * Use the bleeding edge version of a Pod.
233
+ *
234
+ * @example
235
+ * ```
236
+ * { "name": "AFNetworking", "git": "https://github.com/gowalla/AFNetworking.git", "tag": "0.7.0" }
237
+ * ```
238
+ *
239
+ * This acts like to add this pod dependency statement:
240
+ * ```
241
+ * pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
242
+ * ```
243
+ */
244
+ git?: string;
245
+ /**
246
+ * The git branch to fetch. See the {@link git} property for more information.
247
+ */
248
+ branch?: string;
249
+ /**
250
+ * The git tag to fetch. See the {@link git} property for more information.
251
+ */
252
+ tag?: string;
253
+ /**
254
+ * The git commit to fetch. See the {@link git} property for more information.
255
+ */
256
+ commit?: string;
140
257
  }
141
258
 
142
259
  /**
@@ -195,7 +312,11 @@ const schema: JSONSchemaType<PluginConfigType> = {
195
312
  nullable: true,
196
313
  },
197
314
 
198
- unstable_networkInspector: { type: 'boolean', nullable: true },
315
+ networkInspector: { type: 'boolean', nullable: true },
316
+
317
+ extraMavenRepos: { type: 'array', items: { type: 'string' }, nullable: true },
318
+
319
+ usesCleartextTraffic: { type: 'boolean', nullable: true },
199
320
  },
200
321
  nullable: true,
201
322
  },
@@ -211,7 +332,30 @@ const schema: JSONSchemaType<PluginConfigType> = {
211
332
  nullable: true,
212
333
  },
213
334
 
214
- unstable_networkInspector: { type: 'boolean', nullable: true },
335
+ networkInspector: { type: 'boolean', nullable: true },
336
+
337
+ extraPods: {
338
+ type: 'array',
339
+ items: {
340
+ type: 'object',
341
+ required: ['name'],
342
+ properties: {
343
+ name: { type: 'string' },
344
+ version: { type: 'string', nullable: true },
345
+ configurations: { type: 'array', items: { type: 'string' }, nullable: true },
346
+ modular_headers: { type: 'boolean', nullable: true },
347
+ source: { type: 'string', nullable: true },
348
+ path: { type: 'string', nullable: true },
349
+ podspec: { type: 'string', nullable: true },
350
+ testspecs: { type: 'array', items: { type: 'string' }, nullable: true },
351
+ git: { type: 'string', nullable: true },
352
+ branch: { type: 'string', nullable: true },
353
+ tag: { type: 'string', nullable: true },
354
+ commit: { type: 'string', nullable: true },
355
+ },
356
+ },
357
+ nullable: true,
358
+ },
215
359
  },
216
360
  nullable: true,
217
361
  },
@@ -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.