expo-build-properties 0.5.0 → 0.5.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 +6 -0
- package/README.md +5 -3
- package/build/android.d.ts +1 -0
- package/build/android.js +26 -1
- package/build/ios.js +9 -0
- package/build/pluginConfig.d.ts +19 -0
- package/build/pluginConfig.js +14 -1
- package/build/withBuildProperties.js +1 -0
- package/package.json +2 -2
- package/src/android.ts +42 -1
- package/src/ios.ts +9 -0
- package/src/pluginConfig.ts +40 -1
- package/src/withBuildProperties.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.5.1 — 2023-02-09
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Add support for enabling [Flipper](https://fbflipper.com/) as bundled with react-native. ([#20890](https://github.com/expo/expo/pull/20861) by [@jakobo](https://github.com/jakobo))
|
|
18
|
+
|
|
13
19
|
## 0.5.0 — 2023-02-03
|
|
14
20
|
|
|
15
21
|
### 🎉 New features
|
package/README.md
CHANGED
|
@@ -27,10 +27,12 @@ Add plugin to `app.json`. For example:
|
|
|
27
27
|
"android": {
|
|
28
28
|
"compileSdkVersion": 31,
|
|
29
29
|
"targetSdkVersion": 31,
|
|
30
|
-
"buildToolsVersion": "31.0.0"
|
|
30
|
+
"buildToolsVersion": "31.0.0",
|
|
31
|
+
"flipper": true
|
|
31
32
|
},
|
|
32
33
|
"ios": {
|
|
33
|
-
"deploymentTarget": "13.0"
|
|
34
|
+
"deploymentTarget": "13.0",
|
|
35
|
+
"flipper": true
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
]
|
|
@@ -41,7 +43,7 @@ Add plugin to `app.json`. For example:
|
|
|
41
43
|
|
|
42
44
|
## Contributing
|
|
43
45
|
|
|
44
|
-
Contributions are very welcome! Please refer to guidelines described in the [contributing guide][contributing].
|
|
46
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide][../../contributing.md].
|
|
45
47
|
|
|
46
48
|
[docs-main]: https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/build-properties.mdx
|
|
47
49
|
[docs-stable]: https://docs.expo.dev/versions/latest/sdk/build-properties/
|
package/build/android.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
2
|
import type { PluginConfigType } from './pluginConfig';
|
|
3
3
|
export declare const withAndroidBuildProperties: ConfigPlugin<PluginConfigType>;
|
|
4
|
+
export declare const withAndroidFlipper: ConfigPlugin<PluginConfigType>;
|
|
4
5
|
/**
|
|
5
6
|
* Appends `props.android.extraProguardRules` content into `android/app/proguard-rules.pro`
|
|
6
7
|
*/
|
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.withAndroidBuildProperties = void 0;
|
|
6
|
+
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"));
|
|
@@ -55,6 +55,31 @@ exports.withAndroidBuildProperties = createBuildGradlePropsConfigPlugin([
|
|
|
55
55
|
propValueGetter: (config) => config.android?.enableProguardInReleaseBuilds?.toString(),
|
|
56
56
|
},
|
|
57
57
|
], 'withAndroidBuildProperties');
|
|
58
|
+
const withAndroidFlipper = (config, props) => {
|
|
59
|
+
const ANDROID_FLIPPER_KEY = 'FLIPPER_VERSION';
|
|
60
|
+
const FLIPPER_FALLBACK = '0.125.0';
|
|
61
|
+
// when not set, make no changes
|
|
62
|
+
if (props.android?.flipper === undefined) {
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
return (0, config_plugins_1.withGradleProperties)(config, (c) => {
|
|
66
|
+
// check for Flipper version in package. If set, use that
|
|
67
|
+
let existing;
|
|
68
|
+
const found = c.modResults.find((item) => item.type === 'property' && item.key === ANDROID_FLIPPER_KEY);
|
|
69
|
+
if (found && found.type === 'property') {
|
|
70
|
+
existing = found.value;
|
|
71
|
+
}
|
|
72
|
+
// strip key and re-add based on setting
|
|
73
|
+
c.modResults = c.modResults.filter((item) => !(item.type === 'property' && item.key === ANDROID_FLIPPER_KEY));
|
|
74
|
+
c.modResults.push({
|
|
75
|
+
type: 'property',
|
|
76
|
+
key: ANDROID_FLIPPER_KEY,
|
|
77
|
+
value: (props.android?.flipper ?? existing ?? FLIPPER_FALLBACK),
|
|
78
|
+
});
|
|
79
|
+
return c;
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.withAndroidFlipper = withAndroidFlipper;
|
|
58
83
|
/**
|
|
59
84
|
* Appends `props.android.extraProguardRules` content into `android/app/proguard-rules.pro`
|
|
60
85
|
*/
|
package/build/ios.js
CHANGED
|
@@ -12,6 +12,15 @@ exports.withIosBuildProperties = createBuildPodfilePropsConfigPlugin([
|
|
|
12
12
|
propName: 'ios.useFrameworks',
|
|
13
13
|
propValueGetter: (config) => config.ios?.useFrameworks,
|
|
14
14
|
},
|
|
15
|
+
{
|
|
16
|
+
propName: 'ios.flipper',
|
|
17
|
+
propValueGetter: (config) => {
|
|
18
|
+
if (typeof config.ios?.flipper === 'string' || typeof config.ios?.flipper === 'boolean') {
|
|
19
|
+
return config.ios.flipper.toString();
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
},
|
|
23
|
+
},
|
|
15
24
|
], 'withIosBuildProperties');
|
|
16
25
|
const withIosDeploymentTarget = (config, props) => {
|
|
17
26
|
const deploymentTarget = props.ios?.deploymentTarget;
|
package/build/pluginConfig.d.ts
CHANGED
|
@@ -54,6 +54,13 @@ export interface PluginConfigTypeAndroid {
|
|
|
54
54
|
* 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).
|
|
55
55
|
*/
|
|
56
56
|
packagingOptions?: PluginConfigTypeAndroidPackagingOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Change the [Flipper](https://fbflipper.com/) version when running your app on Android.
|
|
59
|
+
* Flipper is by default enabled with the version that comes bundled with react-native.
|
|
60
|
+
* However, you can set the `flipper` property to a semver string and specify an
|
|
61
|
+
* alternate Flipper version.
|
|
62
|
+
*/
|
|
63
|
+
flipper?: string;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* Interface representing available configuration for iOS native build properties.
|
|
@@ -73,8 +80,20 @@ export interface PluginConfigTypeIos {
|
|
|
73
80
|
/**
|
|
74
81
|
* Enable [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang)
|
|
75
82
|
* in `Podfile` to use frameworks instead of static libraries for Pods.
|
|
83
|
+
*
|
|
84
|
+
* Note: You cannot use `useFrameworks` and `flipper` at the same time
|
|
76
85
|
*/
|
|
77
86
|
useFrameworks?: 'static' | 'dynamic';
|
|
87
|
+
/**
|
|
88
|
+
* Enable [Flipper](https://fbflipper.com/) when running your app on iOS in
|
|
89
|
+
* Debug mode. Setting `true` enables the default version of Flipper, while
|
|
90
|
+
* setting a semver string will enable a specific version of Flipper you've
|
|
91
|
+
* declared in your package.json. The default for this configuration is `false`.
|
|
92
|
+
*
|
|
93
|
+
* Note: You cannot use `flipper` at the same time as `useFrameworks`, and
|
|
94
|
+
* doing so will generate an error.
|
|
95
|
+
*/
|
|
96
|
+
flipper?: boolean | string;
|
|
78
97
|
}
|
|
79
98
|
/**
|
|
80
99
|
* 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).
|
package/build/pluginConfig.js
CHANGED
|
@@ -35,6 +35,10 @@ const schema = {
|
|
|
35
35
|
kotlinVersion: { type: 'string', nullable: true },
|
|
36
36
|
enableProguardInReleaseBuilds: { type: 'boolean', nullable: true },
|
|
37
37
|
extraProguardRules: { type: 'string', nullable: true },
|
|
38
|
+
flipper: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
nullable: true,
|
|
41
|
+
},
|
|
38
42
|
packagingOptions: {
|
|
39
43
|
type: 'object',
|
|
40
44
|
properties: {
|
|
@@ -54,6 +58,10 @@ const schema = {
|
|
|
54
58
|
newArchEnabled: { type: 'boolean', nullable: true },
|
|
55
59
|
deploymentTarget: { type: 'string', pattern: '\\d+\\.\\d+', nullable: true },
|
|
56
60
|
useFrameworks: { type: 'string', enum: ['static', 'dynamic'], nullable: true },
|
|
61
|
+
flipper: {
|
|
62
|
+
type: ['boolean', 'string'],
|
|
63
|
+
nullable: true,
|
|
64
|
+
},
|
|
57
65
|
},
|
|
58
66
|
nullable: true,
|
|
59
67
|
},
|
|
@@ -112,11 +120,16 @@ function maybeThrowInvalidVersions(config) {
|
|
|
112
120
|
* @ignore
|
|
113
121
|
*/
|
|
114
122
|
function validateConfig(config) {
|
|
115
|
-
const validate = new ajv_1.default().compile(schema);
|
|
123
|
+
const validate = new ajv_1.default({ allowUnionTypes: true }).compile(schema);
|
|
116
124
|
if (!validate(config)) {
|
|
117
125
|
throw new Error('Invalid expo-build-properties config: ' + JSON.stringify(validate.errors));
|
|
118
126
|
}
|
|
119
127
|
maybeThrowInvalidVersions(config);
|
|
128
|
+
// explicitly block using use_frameworks and Flipper in iOS
|
|
129
|
+
// https://github.com/facebook/flipper/issues/2414
|
|
130
|
+
if (config?.ios?.flipper !== undefined && config?.ios?.useFrameworks !== undefined) {
|
|
131
|
+
throw new Error('`ios.flipper` cannot be enabled when `ios.useFrameworks` is set.');
|
|
132
|
+
}
|
|
120
133
|
return config;
|
|
121
134
|
}
|
|
122
135
|
exports.validateConfig = validateConfig;
|
|
@@ -20,6 +20,7 @@ const withBuildProperties = (config, props) => {
|
|
|
20
20
|
//
|
|
21
21
|
// plugins order matter: the later one would run first
|
|
22
22
|
config = (0, android_1.withAndroidPurgeProguardRulesOnce)(config);
|
|
23
|
+
config = (0, android_1.withAndroidFlipper)(config, pluginConfig);
|
|
23
24
|
config = (0, ios_1.withIosBuildProperties)(config, pluginConfig);
|
|
24
25
|
config = (0, ios_1.withIosDeploymentTarget)(config, pluginConfig);
|
|
25
26
|
return config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-build-properties",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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": "
|
|
43
|
+
"gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
|
|
44
44
|
}
|
package/src/android.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AndroidConfig,
|
|
3
|
+
ConfigPlugin,
|
|
4
|
+
History,
|
|
5
|
+
withDangerousMod,
|
|
6
|
+
withGradleProperties,
|
|
7
|
+
} from 'expo/config-plugins';
|
|
2
8
|
import fs from 'fs';
|
|
3
9
|
import path from 'path';
|
|
4
10
|
|
|
@@ -57,6 +63,41 @@ export const withAndroidBuildProperties = createBuildGradlePropsConfigPlugin<Plu
|
|
|
57
63
|
'withAndroidBuildProperties'
|
|
58
64
|
);
|
|
59
65
|
|
|
66
|
+
export const withAndroidFlipper: ConfigPlugin<PluginConfigType> = (config, props) => {
|
|
67
|
+
const ANDROID_FLIPPER_KEY = 'FLIPPER_VERSION';
|
|
68
|
+
const FLIPPER_FALLBACK = '0.125.0';
|
|
69
|
+
|
|
70
|
+
// when not set, make no changes
|
|
71
|
+
if (props.android?.flipper === undefined) {
|
|
72
|
+
return config;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return withGradleProperties(config, (c) => {
|
|
76
|
+
// check for Flipper version in package. If set, use that
|
|
77
|
+
let existing: string | undefined;
|
|
78
|
+
|
|
79
|
+
const found = c.modResults.find(
|
|
80
|
+
(item) => item.type === 'property' && item.key === ANDROID_FLIPPER_KEY
|
|
81
|
+
);
|
|
82
|
+
if (found && found.type === 'property') {
|
|
83
|
+
existing = found.value;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// strip key and re-add based on setting
|
|
87
|
+
c.modResults = c.modResults.filter(
|
|
88
|
+
(item) => !(item.type === 'property' && item.key === ANDROID_FLIPPER_KEY)
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
c.modResults.push({
|
|
92
|
+
type: 'property',
|
|
93
|
+
key: ANDROID_FLIPPER_KEY,
|
|
94
|
+
value: (props.android?.flipper ?? existing ?? FLIPPER_FALLBACK) as string,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return c;
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
60
101
|
/**
|
|
61
102
|
* Appends `props.android.extraProguardRules` content into `android/app/proguard-rules.pro`
|
|
62
103
|
*/
|
package/src/ios.ts
CHANGED
|
@@ -14,6 +14,15 @@ export const withIosBuildProperties = createBuildPodfilePropsConfigPlugin<Plugin
|
|
|
14
14
|
propName: 'ios.useFrameworks',
|
|
15
15
|
propValueGetter: (config) => config.ios?.useFrameworks,
|
|
16
16
|
},
|
|
17
|
+
{
|
|
18
|
+
propName: 'ios.flipper',
|
|
19
|
+
propValueGetter: (config) => {
|
|
20
|
+
if (typeof config.ios?.flipper === 'string' || typeof config.ios?.flipper === 'boolean') {
|
|
21
|
+
return config.ios.flipper.toString();
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
17
26
|
],
|
|
18
27
|
'withIosBuildProperties'
|
|
19
28
|
);
|
package/src/pluginConfig.ts
CHANGED
|
@@ -74,6 +74,14 @@ export interface PluginConfigTypeAndroid {
|
|
|
74
74
|
* 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).
|
|
75
75
|
*/
|
|
76
76
|
packagingOptions?: PluginConfigTypeAndroidPackagingOptions;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Change the [Flipper](https://fbflipper.com/) version when running your app on Android.
|
|
80
|
+
* Flipper is by default enabled with the version that comes bundled with react-native.
|
|
81
|
+
* However, you can set the `flipper` property to a semver string and specify an
|
|
82
|
+
* alternate Flipper version.
|
|
83
|
+
*/
|
|
84
|
+
flipper?: string;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
/**
|
|
@@ -91,11 +99,25 @@ export interface PluginConfigTypeIos {
|
|
|
91
99
|
* - `PBXNativeTarget` with "com.apple.product-type.application" `productType` in the app project.
|
|
92
100
|
*/
|
|
93
101
|
deploymentTarget?: string;
|
|
102
|
+
|
|
94
103
|
/**
|
|
95
104
|
* Enable [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang)
|
|
96
105
|
* in `Podfile` to use frameworks instead of static libraries for Pods.
|
|
106
|
+
*
|
|
107
|
+
* Note: You cannot use `useFrameworks` and `flipper` at the same time
|
|
97
108
|
*/
|
|
98
109
|
useFrameworks?: 'static' | 'dynamic';
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Enable [Flipper](https://fbflipper.com/) when running your app on iOS in
|
|
113
|
+
* Debug mode. Setting `true` enables the default version of Flipper, while
|
|
114
|
+
* setting a semver string will enable a specific version of Flipper you've
|
|
115
|
+
* declared in your package.json. The default for this configuration is `false`.
|
|
116
|
+
*
|
|
117
|
+
* Note: You cannot use `flipper` at the same time as `useFrameworks`, and
|
|
118
|
+
* doing so will generate an error.
|
|
119
|
+
*/
|
|
120
|
+
flipper?: boolean | string;
|
|
99
121
|
}
|
|
100
122
|
|
|
101
123
|
/**
|
|
@@ -137,6 +159,11 @@ const schema: JSONSchemaType<PluginConfigType> = {
|
|
|
137
159
|
enableProguardInReleaseBuilds: { type: 'boolean', nullable: true },
|
|
138
160
|
extraProguardRules: { type: 'string', nullable: true },
|
|
139
161
|
|
|
162
|
+
flipper: {
|
|
163
|
+
type: 'string',
|
|
164
|
+
nullable: true,
|
|
165
|
+
},
|
|
166
|
+
|
|
140
167
|
packagingOptions: {
|
|
141
168
|
type: 'object',
|
|
142
169
|
properties: {
|
|
@@ -156,6 +183,11 @@ const schema: JSONSchemaType<PluginConfigType> = {
|
|
|
156
183
|
newArchEnabled: { type: 'boolean', nullable: true },
|
|
157
184
|
deploymentTarget: { type: 'string', pattern: '\\d+\\.\\d+', nullable: true },
|
|
158
185
|
useFrameworks: { type: 'string', enum: ['static', 'dynamic'], nullable: true },
|
|
186
|
+
|
|
187
|
+
flipper: {
|
|
188
|
+
type: ['boolean', 'string'],
|
|
189
|
+
nullable: true,
|
|
190
|
+
},
|
|
159
191
|
},
|
|
160
192
|
nullable: true,
|
|
161
193
|
},
|
|
@@ -221,11 +253,18 @@ function maybeThrowInvalidVersions(config: PluginConfigType) {
|
|
|
221
253
|
* @ignore
|
|
222
254
|
*/
|
|
223
255
|
export function validateConfig(config: any): PluginConfigType {
|
|
224
|
-
const validate = new Ajv().compile(schema);
|
|
256
|
+
const validate = new Ajv({ allowUnionTypes: true }).compile(schema);
|
|
225
257
|
if (!validate(config)) {
|
|
226
258
|
throw new Error('Invalid expo-build-properties config: ' + JSON.stringify(validate.errors));
|
|
227
259
|
}
|
|
228
260
|
|
|
229
261
|
maybeThrowInvalidVersions(config);
|
|
262
|
+
|
|
263
|
+
// explicitly block using use_frameworks and Flipper in iOS
|
|
264
|
+
// https://github.com/facebook/flipper/issues/2414
|
|
265
|
+
if (config?.ios?.flipper !== undefined && config?.ios?.useFrameworks !== undefined) {
|
|
266
|
+
throw new Error('`ios.flipper` cannot be enabled when `ios.useFrameworks` is set.');
|
|
267
|
+
}
|
|
268
|
+
|
|
230
269
|
return config;
|
|
231
270
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
withAndroidBuildProperties,
|
|
5
5
|
withAndroidProguardRules,
|
|
6
6
|
withAndroidPurgeProguardRulesOnce,
|
|
7
|
+
withAndroidFlipper,
|
|
7
8
|
} from './android';
|
|
8
9
|
import { withIosBuildProperties, withIosDeploymentTarget } from './ios';
|
|
9
10
|
import { PluginConfigType, validateConfig } from './pluginConfig';
|
|
@@ -27,6 +28,7 @@ export const withBuildProperties: ConfigPlugin<PluginConfigType> = (config, prop
|
|
|
27
28
|
// plugins order matter: the later one would run first
|
|
28
29
|
config = withAndroidPurgeProguardRulesOnce(config);
|
|
29
30
|
|
|
31
|
+
config = withAndroidFlipper(config, pluginConfig);
|
|
30
32
|
config = withIosBuildProperties(config, pluginConfig);
|
|
31
33
|
config = withIosDeploymentTarget(config, pluginConfig);
|
|
32
34
|
|