@expo/config-plugins 5.0.3 → 6.0.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/build/Plugin.types.d.ts +7 -7
- package/build/Plugin.types.js +0 -9
- package/build/Plugin.types.js.map +1 -1
- package/build/android/AllowBackup.js +0 -15
- package/build/android/AllowBackup.js.map +1 -1
- package/build/android/BuildProperties.js +2 -16
- package/build/android/BuildProperties.js.map +1 -1
- package/build/android/Colors.js +3 -25
- package/build/android/Colors.js.map +1 -1
- package/build/android/EasBuild.js +2 -22
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/EasBuildGradleScript.js.map +1 -1
- package/build/android/GoogleMapsApiKey.js +0 -12
- package/build/android/GoogleMapsApiKey.js.map +1 -1
- package/build/android/GoogleServices.js +10 -48
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/IntentFilters.d.ts +1 -1
- package/build/android/IntentFilters.js +8 -24
- package/build/android/IntentFilters.js.map +1 -1
- package/build/android/Manifest.d.ts +19 -19
- package/build/android/Manifest.js +7 -66
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Name.js +6 -27
- package/build/android/Name.js.map +1 -1
- package/build/android/Orientation.js +2 -12
- package/build/android/Orientation.js.map +1 -1
- package/build/android/Package.js +26 -111
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.d.ts +2 -2
- package/build/android/Paths.js +0 -47
- package/build/android/Paths.js.map +1 -1
- package/build/android/Permissions.js +8 -52
- package/build/android/Permissions.js.map +1 -1
- package/build/android/PrimaryColor.js +0 -18
- package/build/android/PrimaryColor.js.map +1 -1
- package/build/android/Properties.d.ts +1 -1
- package/build/android/Properties.js +0 -9
- package/build/android/Properties.js.map +1 -1
- package/build/android/Resources.d.ts +4 -4
- package/build/android/Resources.js +9 -29
- package/build/android/Resources.js.map +1 -1
- package/build/android/Scheme.d.ts +1 -1
- package/build/android/Scheme.js +13 -66
- package/build/android/Scheme.js.map +1 -1
- package/build/android/StatusBar.js +5 -33
- package/build/android/StatusBar.js.map +1 -1
- package/build/android/Strings.js +0 -14
- package/build/android/Strings.js.map +1 -1
- package/build/android/Styles.js +7 -34
- package/build/android/Styles.js.map +1 -1
- package/build/android/Updates.d.ts +2 -0
- package/build/android/Updates.js +50 -47
- package/build/android/Updates.js.map +1 -1
- package/build/android/Version.js +3 -29
- package/build/android/Version.js.map +1 -1
- package/build/android/WindowSoftInputMode.js +0 -14
- package/build/android/WindowSoftInputMode.js.map +1 -1
- package/build/android/codeMod.js +6 -22
- package/build/android/codeMod.js.map +1 -1
- package/build/android/index.js +0 -94
- package/build/android/index.js.map +1 -1
- package/build/index.js +2 -65
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +1 -1
- package/build/ios/Bitcode.js +8 -28
- package/build/ios/Bitcode.js.map +1 -1
- package/build/ios/BuildProperties.js +2 -14
- package/build/ios/BuildProperties.js.map +1 -1
- package/build/ios/BuildScheme.js +2 -34
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +13 -72
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/DeviceFamily.js +6 -24
- package/build/ios/DeviceFamily.js.map +1 -1
- package/build/ios/Entitlements.js +4 -45
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +2 -2
- package/build/ios/Google.js +11 -66
- package/build/ios/Google.js.map +1 -1
- package/build/ios/IosConfig.types.d.ts +6 -11
- package/build/ios/IosConfig.types.js.map +1 -1
- package/build/ios/Locales.d.ts +3 -3
- package/build/ios/Locales.js +12 -43
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +15 -53
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.js +7 -31
- package/build/ios/Name.js.map +1 -1
- package/build/ios/Orientation.js +2 -10
- package/build/ios/Orientation.js.map +1 -1
- package/build/ios/Paths.d.ts +2 -2
- package/build/ios/Paths.js +8 -73
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Permissions.js +1 -16
- package/build/ios/Permissions.js.map +1 -1
- package/build/ios/ProvisioningProfile.d.ts +1 -1
- package/build/ios/ProvisioningProfile.js +0 -18
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/RequiresFullScreen.js +19 -31
- package/build/ios/RequiresFullScreen.js.map +1 -1
- package/build/ios/Scheme.js +12 -34
- package/build/ios/Scheme.js.map +1 -1
- package/build/ios/Swift.js +16 -50
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.js +0 -30
- package/build/ios/Target.js.map +1 -1
- package/build/ios/Updates.js +10 -49
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/UsesNonExemptEncryption.js +4 -10
- package/build/ios/UsesNonExemptEncryption.js.map +1 -1
- package/build/ios/Version.js +4 -11
- package/build/ios/Version.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -23
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/codeMod.js +19 -60
- package/build/ios/codeMod.js.map +1 -1
- package/build/ios/index.js +0 -97
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +6 -6
- package/build/ios/utils/Xcodeproj.js +15 -101
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/ios/utils/getInfoPlistPath.js +2 -15
- package/build/ios/utils/getInfoPlistPath.js.map +1 -1
- package/build/ios/utils/string.js +0 -1
- package/build/ios/utils/string.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +2 -2
- package/build/plugins/android-plugins.js +11 -42
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/createBaseMod.d.ts +3 -3
- package/build/plugins/createBaseMod.js +8 -25
- package/build/plugins/createBaseMod.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +2 -2
- package/build/plugins/ios-plugins.js +8 -48
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/mod-compiler.js +21 -72
- package/build/plugins/mod-compiler.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +1 -1
- package/build/plugins/withAndroidBaseMods.js +4 -89
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withDangerousMod.js +0 -5
- package/build/plugins/withDangerousMod.js.map +1 -1
- package/build/plugins/withIosBaseMods.d.ts +1 -1
- package/build/plugins/withIosBaseMods.js +26 -118
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/plugins/withMod.d.ts +1 -1
- package/build/plugins/withMod.js +24 -59
- package/build/plugins/withMod.js.map +1 -1
- package/build/plugins/withPlugins.js +0 -9
- package/build/plugins/withPlugins.js.map +1 -1
- package/build/plugins/withRunOnce.js +3 -9
- package/build/plugins/withRunOnce.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +21 -43
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +2 -2
- package/build/utils/BuildProperties.types.js.map +1 -1
- package/build/utils/Updates.d.ts +3 -1
- package/build/utils/Updates.js +18 -77
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -1
- package/build/utils/XML.js +7 -44
- package/build/utils/XML.js.map +1 -1
- package/build/utils/commonCodeMod.js +2 -10
- package/build/utils/commonCodeMod.js.map +1 -1
- package/build/utils/errors.d.ts +1 -1
- package/build/utils/errors.js +3 -11
- package/build/utils/errors.js.map +1 -1
- package/build/utils/fs.js +1 -12
- package/build/utils/fs.js.map +1 -1
- package/build/utils/generateCode.d.ts +1 -1
- package/build/utils/generateCode.js +8 -25
- package/build/utils/generateCode.js.map +1 -1
- package/build/utils/history.d.ts +1 -1
- package/build/utils/history.js +0 -6
- package/build/utils/history.js.map +1 -1
- package/build/utils/matchBrackets.d.ts +3 -3
- package/build/utils/matchBrackets.js +2 -17
- package/build/utils/matchBrackets.js.map +1 -1
- package/build/utils/modules.js +0 -10
- package/build/utils/modules.js.map +1 -1
- package/build/utils/obj.js +0 -4
- package/build/utils/obj.js.map +1 -1
- package/build/utils/plugin-resolver.js +25 -69
- package/build/utils/plugin-resolver.js.map +1 -1
- package/build/utils/sortObject.js +4 -10
- package/build/utils/sortObject.js.map +1 -1
- package/build/utils/versions.js +0 -10
- package/build/utils/versions.js.map +1 -1
- package/build/utils/warnings.js +1 -9
- package/build/utils/warnings.js.map +1 -1
- package/package.json +5 -5
package/build/plugins/withMod.js
CHANGED
|
@@ -5,41 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.withBaseMod = withBaseMod;
|
|
7
7
|
exports.withMod = withMod;
|
|
8
|
-
|
|
9
8
|
function _chalk() {
|
|
10
9
|
const data = _interopRequireDefault(require("chalk"));
|
|
11
|
-
|
|
12
10
|
_chalk = function () {
|
|
13
11
|
return data;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
return data;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
function _getenv() {
|
|
20
16
|
const data = require("getenv");
|
|
21
|
-
|
|
22
17
|
_getenv = function () {
|
|
23
18
|
return data;
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
return data;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
function _errors() {
|
|
30
23
|
const data = require("../utils/errors");
|
|
31
|
-
|
|
32
24
|
_errors = function () {
|
|
33
25
|
return data;
|
|
34
26
|
};
|
|
35
|
-
|
|
36
27
|
return data;
|
|
37
28
|
}
|
|
38
|
-
|
|
39
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
|
|
41
30
|
const EXPO_DEBUG = (0, _getenv().boolish)('EXPO_DEBUG', false);
|
|
42
|
-
|
|
43
31
|
/**
|
|
44
32
|
* Plugin to intercept execution of a given `mod` with the given `action`.
|
|
45
33
|
* If an action was already set on the given `config` config for `mod`, then it
|
|
@@ -64,48 +52,41 @@ function withBaseMod(config, {
|
|
|
64
52
|
saveToInternal
|
|
65
53
|
}) {
|
|
66
54
|
var _config$_internal$isD, _config$_internal;
|
|
67
|
-
|
|
68
55
|
if (!config.mods) {
|
|
69
56
|
config.mods = {};
|
|
70
57
|
}
|
|
71
|
-
|
|
72
58
|
if (!config.mods[platform]) {
|
|
73
59
|
config.mods[platform] = {};
|
|
74
60
|
}
|
|
61
|
+
let interceptedMod = config.mods[platform][mod];
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
// No existing mod to intercept
|
|
78
64
|
if (!interceptedMod) {
|
|
79
65
|
if (skipEmptyMod) {
|
|
80
66
|
// Skip running the action
|
|
81
67
|
return config;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
}
|
|
69
|
+
// Use a noop mod and continue
|
|
85
70
|
const noopMod = config => config;
|
|
86
|
-
|
|
87
71
|
interceptedMod = noopMod;
|
|
88
|
-
}
|
|
89
|
-
|
|
72
|
+
}
|
|
90
73
|
|
|
91
|
-
|
|
74
|
+
// Create a stack trace for debugging ahead of time
|
|
75
|
+
let debugTrace = '';
|
|
76
|
+
// Use the possibly user defined value. Otherwise fallback to the env variable.
|
|
92
77
|
// We support the env variable because user mods won't have _internal defined in time.
|
|
93
|
-
|
|
94
78
|
const isDebug = (_config$_internal$isD = (_config$_internal = config._internal) === null || _config$_internal === void 0 ? void 0 : _config$_internal.isDebug) !== null && _config$_internal$isD !== void 0 ? _config$_internal$isD : EXPO_DEBUG;
|
|
95
|
-
|
|
96
79
|
if (isDebug) {
|
|
97
80
|
// Get a stack trace via the Error API
|
|
98
|
-
const stack = new Error().stack;
|
|
99
|
-
|
|
81
|
+
const stack = new Error().stack;
|
|
82
|
+
// Format the stack trace to create the debug log
|
|
100
83
|
debugTrace = getDebugPluginStackFromStackTrace(stack);
|
|
101
|
-
|
|
102
84
|
const modStack = _chalk().default.bold(`${platform}.${mod}`);
|
|
103
|
-
|
|
104
85
|
debugTrace = `${modStack}: ${debugTrace}`;
|
|
105
|
-
}
|
|
106
|
-
// Base mods that provide files ignore any incoming modResults and therefore shouldn't have provider mods as parents.
|
|
107
|
-
|
|
86
|
+
}
|
|
108
87
|
|
|
88
|
+
// Prevent adding multiple providers to a mod.
|
|
89
|
+
// Base mods that provide files ignore any incoming modResults and therefore shouldn't have provider mods as parents.
|
|
109
90
|
if (interceptedMod.isProvider) {
|
|
110
91
|
if (isProvider) {
|
|
111
92
|
throw new (_errors().PluginError)(`Cannot set provider mod for "${platform}.${mod}" because another is already being used.`, 'CONFLICTING_PROVIDER');
|
|
@@ -113,7 +94,6 @@ function withBaseMod(config, {
|
|
|
113
94
|
throw new (_errors().PluginError)(`Cannot add mod to "${platform}.${mod}" because the provider has already been added. Provider must be the last mod added.`, 'INVALID_MOD_ORDER');
|
|
114
95
|
}
|
|
115
96
|
}
|
|
116
|
-
|
|
117
97
|
async function interceptingMod({
|
|
118
98
|
modRequest,
|
|
119
99
|
...config
|
|
@@ -122,57 +102,47 @@ function withBaseMod(config, {
|
|
|
122
102
|
// In debug mod, log the plugin stack in the order which they were invoked
|
|
123
103
|
console.log(debugTrace);
|
|
124
104
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
modRequest: {
|
|
105
|
+
const results = await action({
|
|
106
|
+
...config,
|
|
107
|
+
modRequest: {
|
|
108
|
+
...modRequest,
|
|
128
109
|
nextMod: interceptedMod
|
|
129
110
|
}
|
|
130
111
|
});
|
|
131
|
-
|
|
132
112
|
if (saveToInternal) {
|
|
133
113
|
saveToInternalObject(results, platform, mod, results.modResults);
|
|
134
114
|
}
|
|
135
|
-
|
|
136
115
|
return results;
|
|
137
|
-
}
|
|
138
|
-
|
|
116
|
+
}
|
|
139
117
|
|
|
118
|
+
// Ensure this base mod is registered as the provider.
|
|
140
119
|
interceptingMod.isProvider = isProvider;
|
|
141
|
-
|
|
142
120
|
if (isIntrospective) {
|
|
143
121
|
// Register the mode as idempotent so introspection doesn't remove it.
|
|
144
122
|
interceptingMod.isIntrospective = isIntrospective;
|
|
145
123
|
}
|
|
146
|
-
|
|
147
124
|
config.mods[platform][mod] = interceptingMod;
|
|
148
125
|
return config;
|
|
149
126
|
}
|
|
150
|
-
|
|
151
127
|
function saveToInternalObject(config, platformName, modName, results) {
|
|
152
128
|
if (!config._internal) config._internal = {};
|
|
153
129
|
if (!config._internal.modResults) config._internal.modResults = {};
|
|
154
130
|
if (!config._internal.modResults[platformName]) config._internal.modResults[platformName] = {};
|
|
155
131
|
config._internal.modResults[platformName][modName] = results;
|
|
156
132
|
}
|
|
157
|
-
|
|
158
133
|
function getDebugPluginStackFromStackTrace(stacktrace) {
|
|
159
134
|
if (!stacktrace) {
|
|
160
135
|
return '';
|
|
161
136
|
}
|
|
162
|
-
|
|
163
137
|
const treeStackLines = [];
|
|
164
|
-
|
|
165
138
|
for (const line of stacktrace.split('\n')) {
|
|
166
139
|
const [first, second] = line.trim().split(' ');
|
|
167
|
-
|
|
168
140
|
if (first === 'at') {
|
|
169
141
|
treeStackLines.push(second);
|
|
170
142
|
}
|
|
171
143
|
}
|
|
172
|
-
|
|
173
144
|
const plugins = treeStackLines.map(first => {
|
|
174
145
|
var _ref, _first$match$1$trim, _first$match, _first$match$, _first$match2, _first$match2$;
|
|
175
|
-
|
|
176
146
|
// Match the first part of the stack trace against the plugin naming convention
|
|
177
147
|
// "with" followed by a capital letter.
|
|
178
148
|
return (_ref = (_first$match$1$trim = first === null || first === void 0 ? void 0 : (_first$match = first.match(/^(\bwith[A-Z].*?\b)/)) === null || _first$match === void 0 ? void 0 : (_first$match$ = _first$match[1]) === null || _first$match$ === void 0 ? void 0 : _first$match$.trim()) !== null && _first$match$1$trim !== void 0 ? _first$match$1$trim : first === null || first === void 0 ? void 0 : (_first$match2 = first.match(/\.(\bwith[A-Z].*?\b)/)) === null || _first$match2 === void 0 ? void 0 : (_first$match2$ = _first$match2[1]) === null || _first$match2$ === void 0 ? void 0 : _first$match2$.trim()) !== null && _ref !== void 0 ? _ref : null;
|
|
@@ -185,25 +155,24 @@ function getDebugPluginStackFromStackTrace(stacktrace) {
|
|
|
185
155
|
// Base mods indicate a logical section.
|
|
186
156
|
if (pluginName.includes('BaseMod')) {
|
|
187
157
|
pluginName = _chalk().default.bold(pluginName);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
158
|
+
}
|
|
159
|
+
// highlight dangerous mods
|
|
191
160
|
if (pluginName.toLowerCase().includes('dangerous')) {
|
|
192
161
|
pluginName = _chalk().default.red(pluginName);
|
|
193
162
|
}
|
|
194
|
-
|
|
195
163
|
if (index === 0) {
|
|
196
164
|
return _chalk().default.blue(pluginName);
|
|
197
165
|
} else if (commonPlugins.includes(pluginName)) {
|
|
198
166
|
// Common mod names often clutter up the logs, dim them out
|
|
199
167
|
return _chalk().default.dim(pluginName);
|
|
200
168
|
}
|
|
201
|
-
|
|
202
169
|
return pluginName;
|
|
203
|
-
})
|
|
170
|
+
})
|
|
171
|
+
// Join the results:
|
|
204
172
|
// withAndroidExpoPlugins ➜ withPlugins ➜ withIcons ➜ withDangerousMod ➜ withMod
|
|
205
173
|
.join(' ➜ ');
|
|
206
174
|
}
|
|
175
|
+
|
|
207
176
|
/**
|
|
208
177
|
* Plugin to extend a mod function in the plugins config.
|
|
209
178
|
*
|
|
@@ -212,8 +181,6 @@ function getDebugPluginStackFromStackTrace(stacktrace) {
|
|
|
212
181
|
* @param mod name of the platform function to extend
|
|
213
182
|
* @param action method to run on the mod when the config is compiled
|
|
214
183
|
*/
|
|
215
|
-
|
|
216
|
-
|
|
217
184
|
function withMod(config, {
|
|
218
185
|
platform,
|
|
219
186
|
mod,
|
|
@@ -223,7 +190,6 @@ function withMod(config, {
|
|
|
223
190
|
platform,
|
|
224
191
|
mod,
|
|
225
192
|
isProvider: false,
|
|
226
|
-
|
|
227
193
|
async action({
|
|
228
194
|
modRequest: {
|
|
229
195
|
nextMod,
|
|
@@ -239,7 +205,6 @@ function withMod(config, {
|
|
|
239
205
|
});
|
|
240
206
|
return nextMod(results);
|
|
241
207
|
}
|
|
242
|
-
|
|
243
208
|
});
|
|
244
209
|
}
|
|
245
210
|
//# sourceMappingURL=withMod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMod.js","names":["EXPO_DEBUG","boolish","withBaseMod","config","platform","mod","action","skipEmptyMod","isProvider","isIntrospective","saveToInternal","mods","interceptedMod","noopMod","debugTrace","isDebug","_internal","stack","Error","getDebugPluginStackFromStackTrace","modStack","chalk","bold","PluginError","interceptingMod","modRequest","console","log","results","nextMod","saveToInternalObject","modResults","platformName","modName","stacktrace","treeStackLines","line","split","first","second","trim","push","plugins","map","match","filter","Boolean","plugin","includes","commonPlugins","reverse","pluginName","index","toLowerCase","red","blue","dim","join","withMod"],"sources":["../../src/plugins/withMod.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { JSONObject } from '@expo/json-file';\nimport chalk from 'chalk';\nimport { boolish } from 'getenv';\n\nimport { ExportedConfig, ExportedConfigWithProps, Mod, ModPlatform } from '../Plugin.types';\nimport { PluginError } from '../utils/errors';\n\nconst EXPO_DEBUG = boolish('EXPO_DEBUG', false);\n\nexport type BaseModOptions = {\n platform: ModPlatform;\n mod: string;\n isProvider?: boolean;\n skipEmptyMod?: boolean;\n saveToInternal?: boolean;\n /**\n * If the mod supports introspection, and avoids making any filesystem modifications during compilation.\n * By enabling, this mod, and all of its descendants will be run in introspection mode.\n * This should only be used for static files like JSON or XML, and not for application files that require regexes,\n * or complex static files that require other files to be generated like Xcode `.pbxproj`.\n */\n isIntrospective?: boolean;\n};\n\n/**\n * Plugin to intercept execution of a given `mod` with the given `action`.\n * If an action was already set on the given `config` config for `mod`, then it\n * will be provided to the `action` as `nextMod` when it's evaluated, otherwise\n * `nextMod` will be an identity function.\n *\n * @param config exported config\n * @param platform platform to target (ios or android)\n * @param mod name of the platform function to intercept\n * @param skipEmptyMod should skip running the action if there is no existing mod to intercept\n * @param saveToInternal should save the results to `_internal.modResults`, only enable this when the results are pure JSON.\n * @param isProvider should provide data up to the other mods.\n * @param action method to run on the mod when the config is compiled\n */\nexport function withBaseMod<T>(\n config: ExportedConfig,\n {\n platform,\n mod,\n action,\n skipEmptyMod,\n isProvider,\n isIntrospective,\n saveToInternal,\n }: BaseModOptions & { action: Mod<T> }\n): ExportedConfig {\n if (!config.mods) {\n config.mods = {};\n }\n if (!config.mods[platform]) {\n config.mods[platform] = {};\n }\n\n let interceptedMod: Mod<T> = (config.mods[platform] as Record<string, any>)[mod];\n\n // No existing mod to intercept\n if (!interceptedMod) {\n if (skipEmptyMod) {\n // Skip running the action\n return config;\n }\n // Use a noop mod and continue\n const noopMod: Mod<T> = (config) => config;\n interceptedMod = noopMod;\n }\n\n // Create a stack trace for debugging ahead of time\n let debugTrace: string = '';\n // Use the possibly user defined value. Otherwise fallback to the env variable.\n // We support the env variable because user mods won't have _internal defined in time.\n const isDebug = config._internal?.isDebug ?? EXPO_DEBUG;\n if (isDebug) {\n // Get a stack trace via the Error API\n const stack = new Error().stack;\n // Format the stack trace to create the debug log\n debugTrace = getDebugPluginStackFromStackTrace(stack);\n const modStack = chalk.bold(`${platform}.${mod}`);\n\n debugTrace = `${modStack}: ${debugTrace}`;\n }\n\n // Prevent adding multiple providers to a mod.\n // Base mods that provide files ignore any incoming modResults and therefore shouldn't have provider mods as parents.\n if (interceptedMod.isProvider) {\n if (isProvider) {\n throw new PluginError(\n `Cannot set provider mod for \"${platform}.${mod}\" because another is already being used.`,\n 'CONFLICTING_PROVIDER'\n );\n } else {\n throw new PluginError(\n `Cannot add mod to \"${platform}.${mod}\" because the provider has already been added. Provider must be the last mod added.`,\n 'INVALID_MOD_ORDER'\n );\n }\n }\n\n async function interceptingMod({ modRequest, ...config }: ExportedConfigWithProps<T>) {\n if (isDebug) {\n // In debug mod, log the plugin stack in the order which they were invoked\n console.log(debugTrace);\n }\n const results = await action({\n ...config,\n modRequest: { ...modRequest, nextMod: interceptedMod },\n });\n\n if (saveToInternal) {\n saveToInternalObject(results, platform, mod, results.modResults as unknown as JSONObject);\n }\n return results;\n }\n\n // Ensure this base mod is registered as the provider.\n interceptingMod.isProvider = isProvider;\n\n if (isIntrospective) {\n // Register the mode as idempotent so introspection doesn't remove it.\n interceptingMod.isIntrospective = isIntrospective;\n }\n\n (config.mods[platform] as any)[mod] = interceptingMod;\n\n return config;\n}\n\nfunction saveToInternalObject(\n config: Pick<ExpoConfig, '_internal'>,\n platformName: ModPlatform,\n modName: string,\n results: JSONObject\n) {\n if (!config._internal) config._internal = {};\n if (!config._internal.modResults) config._internal.modResults = {};\n if (!config._internal.modResults[platformName]) config._internal.modResults[platformName] = {};\n config._internal.modResults[platformName][modName] = results;\n}\n\nfunction getDebugPluginStackFromStackTrace(stacktrace?: string): string {\n if (!stacktrace) {\n return '';\n }\n\n const treeStackLines: string[] = [];\n for (const line of stacktrace.split('\\n')) {\n const [first, second] = line.trim().split(' ');\n if (first === 'at') {\n treeStackLines.push(second);\n }\n }\n\n const plugins = treeStackLines\n .map((first) => {\n // Match the first part of the stack trace against the plugin naming convention\n // \"with\" followed by a capital letter.\n return (\n first?.match(/^(\\bwith[A-Z].*?\\b)/)?.[1]?.trim() ??\n first?.match(/\\.(\\bwith[A-Z].*?\\b)/)?.[1]?.trim() ??\n null\n );\n })\n .filter(Boolean)\n .filter((plugin) => {\n // redundant as all debug logs are captured in withBaseMod\n return !['withMod', 'withBaseMod', 'withExtendedMod'].includes(plugin!);\n });\n\n const commonPlugins = ['withPlugins', 'withRunOnce', 'withStaticPlugin'];\n\n return (\n (plugins as string[])\n .reverse()\n .map((pluginName, index) => {\n // Base mods indicate a logical section.\n if (pluginName.includes('BaseMod')) {\n pluginName = chalk.bold(pluginName);\n }\n // highlight dangerous mods\n if (pluginName.toLowerCase().includes('dangerous')) {\n pluginName = chalk.red(pluginName);\n }\n\n if (index === 0) {\n return chalk.blue(pluginName);\n } else if (commonPlugins.includes(pluginName)) {\n // Common mod names often clutter up the logs, dim them out\n return chalk.dim(pluginName);\n }\n return pluginName;\n })\n // Join the results:\n // withAndroidExpoPlugins ➜ withPlugins ➜ withIcons ➜ withDangerousMod ➜ withMod\n .join(' ➜ ')\n );\n}\n\n/**\n * Plugin to extend a mod function in the plugins config.\n *\n * @param config exported config\n * @param platform platform to target (ios or android)\n * @param mod name of the platform function to extend\n * @param action method to run on the mod when the config is compiled\n */\nexport function withMod<T>(\n config: ExportedConfig,\n {\n platform,\n mod,\n action,\n }: {\n platform: ModPlatform;\n mod: string;\n action: Mod<T>;\n }\n): ExportedConfig {\n return withBaseMod(config, {\n platform,\n mod,\n isProvider: false,\n async action({ modRequest: { nextMod, ...modRequest }, modResults, ...config }) {\n const results = await action({ modRequest, modResults: modResults as T, ...config });\n return nextMod!(results as any);\n },\n });\n}\n"],"mappings":";;;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAEA,MAAMA,UAAU,GAAG,IAAAC,iBAAA,EAAQ,YAAR,EAAsB,KAAtB,CAAnB;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAT,CACLC,MADK,EAEL;EACEC,QADF;EAEEC,GAFF;EAGEC,MAHF;EAIEC,YAJF;EAKEC,UALF;EAMEC,eANF;EAOEC;AAPF,CAFK,EAWW;EAAA;;EAChB,IAAI,CAACP,MAAM,CAACQ,IAAZ,EAAkB;IAChBR,MAAM,CAACQ,IAAP,GAAc,EAAd;EACD;;EACD,IAAI,CAACR,MAAM,CAACQ,IAAP,CAAYP,QAAZ,CAAL,EAA4B;IAC1BD,MAAM,CAACQ,IAAP,CAAYP,QAAZ,IAAwB,EAAxB;EACD;;EAED,IAAIQ,cAAsB,GAAIT,MAAM,CAACQ,IAAP,CAAYP,QAAZ,CAAD,CAA+CC,GAA/C,CAA7B,CARgB,CAUhB;;EACA,IAAI,CAACO,cAAL,EAAqB;IACnB,IAAIL,YAAJ,EAAkB;MAChB;MACA,OAAOJ,MAAP;IACD,CAJkB,CAK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BH,EAoBE;EACA;EArBF,CAsBGM,IAtBH,CAsBQ,KAtBR,CADF;AAyBD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,OAAT,CACLvD,MADK,EAEL;EACEC,QADF;EAEEC,GAFF;EAGEC;AAHF,CAFK,EAWW;EAChB,OAAOJ,WAAW,CAACC,MAAD,EAAS;IACzBC,QADyB;IAEzBC,GAFyB;IAGzBG,UAAU,EAAE,KAHa;;IAIzB,MAAMF,MAAN,CAAa;MAAEmB,UAAU,EAAE;QAAEI,OAAF;QAAW,GAAGJ;MAAd,CAAd;MAA0CM,UAA1C;MAAsD,GAAG5B;IAAzD,CAAb,EAAgF;MAC9E,MAAMyB,OAAO,GAAG,MAAMtB,MAAM,CAAC;QAAEmB,UAAF;QAAcM,UAAU,EAAEA,UAA1B;QAA2C,GAAG5B;MAA9C,CAAD,CAA5B;MACA,OAAO0B,OAAO,CAAED,OAAF,CAAd;IACD;;EAPwB,CAAT,CAAlB;AASD"}
|
|
1
|
+
{"version":3,"file":"withMod.js","names":["EXPO_DEBUG","boolish","withBaseMod","config","platform","mod","action","skipEmptyMod","isProvider","isIntrospective","saveToInternal","mods","interceptedMod","noopMod","debugTrace","isDebug","_internal","stack","Error","getDebugPluginStackFromStackTrace","modStack","chalk","bold","PluginError","interceptingMod","modRequest","console","log","results","nextMod","saveToInternalObject","modResults","platformName","modName","stacktrace","treeStackLines","line","split","first","second","trim","push","plugins","map","match","filter","Boolean","plugin","includes","commonPlugins","reverse","pluginName","index","toLowerCase","red","blue","dim","join","withMod"],"sources":["../../src/plugins/withMod.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { JSONObject } from '@expo/json-file';\nimport chalk from 'chalk';\nimport { boolish } from 'getenv';\n\nimport { ExportedConfig, ExportedConfigWithProps, Mod, ModPlatform } from '../Plugin.types';\nimport { PluginError } from '../utils/errors';\n\nconst EXPO_DEBUG = boolish('EXPO_DEBUG', false);\n\nexport type BaseModOptions = {\n platform: ModPlatform;\n mod: string;\n isProvider?: boolean;\n skipEmptyMod?: boolean;\n saveToInternal?: boolean;\n /**\n * If the mod supports introspection, and avoids making any filesystem modifications during compilation.\n * By enabling, this mod, and all of its descendants will be run in introspection mode.\n * This should only be used for static files like JSON or XML, and not for application files that require regexes,\n * or complex static files that require other files to be generated like Xcode `.pbxproj`.\n */\n isIntrospective?: boolean;\n};\n\n/**\n * Plugin to intercept execution of a given `mod` with the given `action`.\n * If an action was already set on the given `config` config for `mod`, then it\n * will be provided to the `action` as `nextMod` when it's evaluated, otherwise\n * `nextMod` will be an identity function.\n *\n * @param config exported config\n * @param platform platform to target (ios or android)\n * @param mod name of the platform function to intercept\n * @param skipEmptyMod should skip running the action if there is no existing mod to intercept\n * @param saveToInternal should save the results to `_internal.modResults`, only enable this when the results are pure JSON.\n * @param isProvider should provide data up to the other mods.\n * @param action method to run on the mod when the config is compiled\n */\nexport function withBaseMod<T>(\n config: ExportedConfig,\n {\n platform,\n mod,\n action,\n skipEmptyMod,\n isProvider,\n isIntrospective,\n saveToInternal,\n }: BaseModOptions & { action: Mod<T> }\n): ExportedConfig {\n if (!config.mods) {\n config.mods = {};\n }\n if (!config.mods[platform]) {\n config.mods[platform] = {};\n }\n\n let interceptedMod: Mod<T> = (config.mods[platform] as Record<string, any>)[mod];\n\n // No existing mod to intercept\n if (!interceptedMod) {\n if (skipEmptyMod) {\n // Skip running the action\n return config;\n }\n // Use a noop mod and continue\n const noopMod: Mod<T> = (config) => config;\n interceptedMod = noopMod;\n }\n\n // Create a stack trace for debugging ahead of time\n let debugTrace: string = '';\n // Use the possibly user defined value. Otherwise fallback to the env variable.\n // We support the env variable because user mods won't have _internal defined in time.\n const isDebug = config._internal?.isDebug ?? EXPO_DEBUG;\n if (isDebug) {\n // Get a stack trace via the Error API\n const stack = new Error().stack;\n // Format the stack trace to create the debug log\n debugTrace = getDebugPluginStackFromStackTrace(stack);\n const modStack = chalk.bold(`${platform}.${mod}`);\n\n debugTrace = `${modStack}: ${debugTrace}`;\n }\n\n // Prevent adding multiple providers to a mod.\n // Base mods that provide files ignore any incoming modResults and therefore shouldn't have provider mods as parents.\n if (interceptedMod.isProvider) {\n if (isProvider) {\n throw new PluginError(\n `Cannot set provider mod for \"${platform}.${mod}\" because another is already being used.`,\n 'CONFLICTING_PROVIDER'\n );\n } else {\n throw new PluginError(\n `Cannot add mod to \"${platform}.${mod}\" because the provider has already been added. Provider must be the last mod added.`,\n 'INVALID_MOD_ORDER'\n );\n }\n }\n\n async function interceptingMod({ modRequest, ...config }: ExportedConfigWithProps<T>) {\n if (isDebug) {\n // In debug mod, log the plugin stack in the order which they were invoked\n console.log(debugTrace);\n }\n const results = await action({\n ...config,\n modRequest: { ...modRequest, nextMod: interceptedMod },\n });\n\n if (saveToInternal) {\n saveToInternalObject(results, platform, mod, results.modResults as unknown as JSONObject);\n }\n return results;\n }\n\n // Ensure this base mod is registered as the provider.\n interceptingMod.isProvider = isProvider;\n\n if (isIntrospective) {\n // Register the mode as idempotent so introspection doesn't remove it.\n interceptingMod.isIntrospective = isIntrospective;\n }\n\n (config.mods[platform] as any)[mod] = interceptingMod;\n\n return config;\n}\n\nfunction saveToInternalObject(\n config: Pick<ExpoConfig, '_internal'>,\n platformName: ModPlatform,\n modName: string,\n results: JSONObject\n) {\n if (!config._internal) config._internal = {};\n if (!config._internal.modResults) config._internal.modResults = {};\n if (!config._internal.modResults[platformName]) config._internal.modResults[platformName] = {};\n config._internal.modResults[platformName][modName] = results;\n}\n\nfunction getDebugPluginStackFromStackTrace(stacktrace?: string): string {\n if (!stacktrace) {\n return '';\n }\n\n const treeStackLines: string[] = [];\n for (const line of stacktrace.split('\\n')) {\n const [first, second] = line.trim().split(' ');\n if (first === 'at') {\n treeStackLines.push(second);\n }\n }\n\n const plugins = treeStackLines\n .map((first) => {\n // Match the first part of the stack trace against the plugin naming convention\n // \"with\" followed by a capital letter.\n return (\n first?.match(/^(\\bwith[A-Z].*?\\b)/)?.[1]?.trim() ??\n first?.match(/\\.(\\bwith[A-Z].*?\\b)/)?.[1]?.trim() ??\n null\n );\n })\n .filter(Boolean)\n .filter((plugin) => {\n // redundant as all debug logs are captured in withBaseMod\n return !['withMod', 'withBaseMod', 'withExtendedMod'].includes(plugin!);\n });\n\n const commonPlugins = ['withPlugins', 'withRunOnce', 'withStaticPlugin'];\n\n return (\n (plugins as string[])\n .reverse()\n .map((pluginName, index) => {\n // Base mods indicate a logical section.\n if (pluginName.includes('BaseMod')) {\n pluginName = chalk.bold(pluginName);\n }\n // highlight dangerous mods\n if (pluginName.toLowerCase().includes('dangerous')) {\n pluginName = chalk.red(pluginName);\n }\n\n if (index === 0) {\n return chalk.blue(pluginName);\n } else if (commonPlugins.includes(pluginName)) {\n // Common mod names often clutter up the logs, dim them out\n return chalk.dim(pluginName);\n }\n return pluginName;\n })\n // Join the results:\n // withAndroidExpoPlugins ➜ withPlugins ➜ withIcons ➜ withDangerousMod ➜ withMod\n .join(' ➜ ')\n );\n}\n\n/**\n * Plugin to extend a mod function in the plugins config.\n *\n * @param config exported config\n * @param platform platform to target (ios or android)\n * @param mod name of the platform function to extend\n * @param action method to run on the mod when the config is compiled\n */\nexport function withMod<T>(\n config: ExportedConfig,\n {\n platform,\n mod,\n action,\n }: {\n platform: ModPlatform;\n mod: string;\n action: Mod<T>;\n }\n): ExportedConfig {\n return withBaseMod(config, {\n platform,\n mod,\n isProvider: false,\n async action({ modRequest: { nextMod, ...modRequest }, modResults, ...config }) {\n const results = await action({ modRequest, modResults: modResults as T, ...config });\n return nextMod!(results as any);\n },\n });\n}\n"],"mappings":";;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8C;AAE9C,MAAMA,UAAU,GAAG,IAAAC,iBAAO,EAAC,YAAY,EAAE,KAAK,CAAC;AAiB/C;AACA;AACA;AACA;AACA;AACA;AACA;A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H,QAAQ,CAAC,SAAS,CAAC,EAAE;MAClCG,UAAU,GAAG9B,gBAAK,CAACC,IAAI,CAAC6B,UAAU,CAAC;IACrC;IACA;IACA,IAAIA,UAAU,CAACE,WAAW,EAAE,CAACL,QAAQ,CAAC,WAAW,CAAC,EAAE;MAClDG,UAAU,GAAG9B,gBAAK,CAACiC,GAAG,CAACH,UAAU,CAAC;IACpC;IAEA,IAAIC,KAAK,KAAK,CAAC,EAAE;MACf,OAAO/B,gBAAK,CAACkC,IAAI,CAACJ,UAAU,CAAC;IAC/B,CAAC,MAAM,IAAIF,aAAa,CAACD,QAAQ,CAACG,UAAU,CAAC,EAAE;MAC7C;MACA,OAAO9B,gBAAK,CAACmC,GAAG,CAACL,UAAU,CAAC;IAC9B;IACA,OAAOA,UAAU;EACnB,CAAC;EACD;EACA;EAAA,CACCM,IAAI,CAAC,KAAK,CAAC;AAElB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAO,CACrBvD,MAAsB,EACtB;EACEC,QAAQ;EACRC,GAAG;EACHC;AAKF,CAAC,EACe;EAChB,OAAOJ,WAAW,CAACC,MAAM,EAAE;IACzBC,QAAQ;IACRC,GAAG;IACHG,UAAU,EAAE,KAAK;IACjB,MAAMF,MAAM,CAAC;MAAEmB,UAAU,EAAE;QAAEI,OAAO;QAAE,GAAGJ;MAAW,CAAC;MAAEM,UAAU;MAAE,GAAG5B;IAAO,CAAC,EAAE;MAC9E,MAAMyB,OAAO,GAAG,MAAMtB,MAAM,CAAC;QAAEmB,UAAU;QAAEM,UAAU,EAAEA,UAAe;QAAE,GAAG5B;MAAO,CAAC,CAAC;MACpF,OAAO0B,OAAO,CAAED,OAAO,CAAQ;IACjC;EACF,CAAC,CAAC;AACJ"}
|
|
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withPlugins = void 0;
|
|
7
|
-
|
|
8
7
|
function _assert() {
|
|
9
8
|
const data = _interopRequireDefault(require("assert"));
|
|
10
|
-
|
|
11
9
|
_assert = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _withStaticPlugin() {
|
|
19
15
|
const data = require("./withStaticPlugin");
|
|
20
|
-
|
|
21
16
|
_withStaticPlugin = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
30
22
|
/**
|
|
31
23
|
* Resolves a list of plugins.
|
|
32
24
|
*
|
|
@@ -39,6 +31,5 @@ const withPlugins = (config, plugins) => {
|
|
|
39
31
|
plugin
|
|
40
32
|
}), config);
|
|
41
33
|
};
|
|
42
|
-
|
|
43
34
|
exports.withPlugins = withPlugins;
|
|
44
35
|
//# sourceMappingURL=withPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPlugins.js","names":["withPlugins","config","plugins","assert","Array","isArray","reduce","prev","plugin","withStaticPlugin"],"sources":["../../src/plugins/withPlugins.ts"],"sourcesContent":["import assert from 'assert';\n\nimport { ConfigPlugin, StaticPlugin } from '../Plugin.types';\nimport { withStaticPlugin } from './withStaticPlugin';\n\n/**\n * Resolves a list of plugins.\n *\n * @param config exported config\n * @param plugins list of config config plugins to apply to the exported config\n */\nexport const withPlugins: ConfigPlugin<(StaticPlugin | ConfigPlugin | string)[]> = (\n config,\n plugins\n) => {\n assert(\n Array.isArray(plugins),\n 'withPlugins expected a valid array of plugins or plugin module paths'\n );\n return plugins.reduce((prev, plugin) => withStaticPlugin(prev, { plugin }), config);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withPlugins.js","names":["withPlugins","config","plugins","assert","Array","isArray","reduce","prev","plugin","withStaticPlugin"],"sources":["../../src/plugins/withPlugins.ts"],"sourcesContent":["import assert from 'assert';\n\nimport { ConfigPlugin, StaticPlugin } from '../Plugin.types';\nimport { withStaticPlugin } from './withStaticPlugin';\n\n/**\n * Resolves a list of plugins.\n *\n * @param config exported config\n * @param plugins list of config config plugins to apply to the exported config\n */\nexport const withPlugins: ConfigPlugin<(StaticPlugin | ConfigPlugin | string)[]> = (\n config,\n plugins\n) => {\n assert(\n Array.isArray(plugins),\n 'withPlugins expected a valid array of plugins or plugin module paths'\n );\n return plugins.reduce((prev, plugin) => withStaticPlugin(prev, { plugin }), config);\n};\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAsD;AAEtD;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAmE,GAAG,CACjFC,MAAM,EACNC,OAAO,KACJ;EACH,IAAAC,iBAAM,EACJC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,EACtB,sEAAsE,CACvE;EACD,OAAOA,OAAO,CAACI,MAAM,CAAC,CAACC,IAAI,EAAEC,MAAM,KAAK,IAAAC,oCAAgB,EAACF,IAAI,EAAE;IAAEC;EAAO,CAAC,CAAC,EAAEP,MAAM,CAAC;AACrF,CAAC;AAAC"}
|
|
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createRunOncePlugin = createRunOncePlugin;
|
|
7
7
|
exports.withRunOnce = void 0;
|
|
8
|
-
|
|
9
8
|
function _history() {
|
|
10
9
|
const data = require("../utils/history");
|
|
11
|
-
|
|
12
10
|
_history = function () {
|
|
13
11
|
return data;
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
return data;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
/**
|
|
20
16
|
* Prevents the same plugin from being run twice.
|
|
21
17
|
* Used for migrating from unversioned expo config plugins to versioned plugins.
|
|
@@ -31,24 +27,22 @@ const withRunOnce = (config, {
|
|
|
31
27
|
// Detect if a plugin has already been run on this config.
|
|
32
28
|
if ((0, _history().getHistoryItem)(config, name)) {
|
|
33
29
|
return config;
|
|
34
|
-
}
|
|
35
|
-
|
|
30
|
+
}
|
|
36
31
|
|
|
32
|
+
// Push the history item so duplicates cannot be run.
|
|
37
33
|
config = (0, _history().addHistoryItem)(config, {
|
|
38
34
|
name,
|
|
39
35
|
version
|
|
40
36
|
});
|
|
41
37
|
return plugin(config);
|
|
42
38
|
};
|
|
39
|
+
|
|
43
40
|
/**
|
|
44
41
|
* Helper method for creating mods from existing config functions.
|
|
45
42
|
*
|
|
46
43
|
* @param action
|
|
47
44
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
45
|
exports.withRunOnce = withRunOnce;
|
|
51
|
-
|
|
52
46
|
function createRunOncePlugin(plugin, name, version) {
|
|
53
47
|
return (config, props) => {
|
|
54
48
|
return withRunOnce(config, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withRunOnce.js","names":["withRunOnce","config","plugin","name","version","getHistoryItem","addHistoryItem","createRunOncePlugin","props"],"sources":["../../src/plugins/withRunOnce.ts"],"sourcesContent":["import { ConfigPlugin } from '../Plugin.types';\nimport { addHistoryItem, getHistoryItem, PluginHistoryItem } from '../utils/history';\n\n/**\n * Prevents the same plugin from being run twice.\n * Used for migrating from unversioned expo config plugins to versioned plugins.\n *\n * @param config\n * @param name\n */\nexport const withRunOnce: ConfigPlugin<{\n plugin: ConfigPlugin<void>;\n name: PluginHistoryItem['name'];\n version?: PluginHistoryItem['version'];\n}> = (config, { plugin, name, version }) => {\n // Detect if a plugin has already been run on this config.\n if (getHistoryItem(config, name)) {\n return config;\n }\n\n // Push the history item so duplicates cannot be run.\n config = addHistoryItem(config, { name, version });\n\n return plugin(config);\n};\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createRunOncePlugin<T>(\n plugin: ConfigPlugin<T>,\n name: string,\n version?: string\n): ConfigPlugin<T> {\n return (config, props) => {\n return withRunOnce(config, { plugin: (config) => plugin(config, props), name, version });\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withRunOnce.js","names":["withRunOnce","config","plugin","name","version","getHistoryItem","addHistoryItem","createRunOncePlugin","props"],"sources":["../../src/plugins/withRunOnce.ts"],"sourcesContent":["import { ConfigPlugin } from '../Plugin.types';\nimport { addHistoryItem, getHistoryItem, PluginHistoryItem } from '../utils/history';\n\n/**\n * Prevents the same plugin from being run twice.\n * Used for migrating from unversioned expo config plugins to versioned plugins.\n *\n * @param config\n * @param name\n */\nexport const withRunOnce: ConfigPlugin<{\n plugin: ConfigPlugin<void>;\n name: PluginHistoryItem['name'];\n version?: PluginHistoryItem['version'];\n}> = (config, { plugin, name, version }) => {\n // Detect if a plugin has already been run on this config.\n if (getHistoryItem(config, name)) {\n return config;\n }\n\n // Push the history item so duplicates cannot be run.\n config = addHistoryItem(config, { name, version });\n\n return plugin(config);\n};\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createRunOncePlugin<T>(\n plugin: ConfigPlugin<T>,\n name: string,\n version?: string\n): ConfigPlugin<T> {\n return (config, props) => {\n return withRunOnce(config, { plugin: (config) => plugin(config, props), name, version });\n };\n}\n"],"mappings":";;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAIX,GAAG,CAACC,MAAM,EAAE;EAAEC,MAAM;EAAEC,IAAI;EAAEC;AAAQ,CAAC,KAAK;EAC1C;EACA,IAAI,IAAAC,yBAAc,EAACJ,MAAM,EAAEE,IAAI,CAAC,EAAE;IAChC,OAAOF,MAAM;EACf;;EAEA;EACAA,MAAM,GAAG,IAAAK,yBAAc,EAACL,MAAM,EAAE;IAAEE,IAAI;IAAEC;EAAQ,CAAC,CAAC;EAElD,OAAOF,MAAM,CAACD,MAAM,CAAC;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,SAASM,mBAAmB,CACjCL,MAAuB,EACvBC,IAAY,EACZC,OAAgB,EACC;EACjB,OAAO,CAACH,MAAM,EAAEO,KAAK,KAAK;IACxB,OAAOR,WAAW,CAACC,MAAM,EAAE;MAAEC,MAAM,EAAGD,MAAM,IAAKC,MAAM,CAACD,MAAM,EAAEO,KAAK,CAAC;MAAEL,IAAI;MAAEC;IAAQ,CAAC,CAAC;EAC1F,CAAC;AACH"}
|
|
@@ -4,74 +4,59 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withStaticPlugin = void 0;
|
|
7
|
-
|
|
8
7
|
function _assert() {
|
|
9
8
|
const data = _interopRequireDefault(require("assert"));
|
|
10
|
-
|
|
11
9
|
_assert = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _getenv() {
|
|
19
15
|
const data = require("getenv");
|
|
20
|
-
|
|
21
16
|
_getenv = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _errors() {
|
|
29
22
|
const data = require("../utils/errors");
|
|
30
|
-
|
|
31
23
|
_errors = function () {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _pluginResolver() {
|
|
39
29
|
const data = require("../utils/plugin-resolver");
|
|
40
|
-
|
|
41
30
|
_pluginResolver = function () {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
+
const EXPO_DEBUG = (0, _getenv().boolish)('EXPO_DEBUG', false);
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
// Show all error info related to plugin resolution.
|
|
39
|
+
const EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS = (0, _getenv().boolish)('EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS', false);
|
|
40
|
+
// Force using the fallback unversioned plugin instead of a local versioned copy,
|
|
53
41
|
// this should only be used for testing the CLI.
|
|
54
|
-
|
|
55
42
|
const EXPO_USE_UNVERSIONED_PLUGINS = (0, _getenv().boolish)('EXPO_USE_UNVERSIONED_PLUGINS', false);
|
|
56
|
-
|
|
57
43
|
function isModuleMissingError(name, error) {
|
|
58
44
|
// @ts-ignore
|
|
59
45
|
if (['MODULE_NOT_FOUND', 'PLUGIN_NOT_FOUND'].includes(error.code)) {
|
|
60
46
|
return true;
|
|
61
47
|
}
|
|
62
|
-
|
|
63
48
|
return error.message.includes(`Cannot find module '${name}'`);
|
|
64
49
|
}
|
|
65
|
-
|
|
66
50
|
function isUnexpectedTokenError(error) {
|
|
67
51
|
if (error instanceof SyntaxError || error instanceof _errors().PluginError && error.code === 'INVALID_PLUGIN_IMPORT') {
|
|
68
|
-
return (
|
|
52
|
+
return (
|
|
53
|
+
// These are the most common errors that'll be thrown when a package isn't transpiled correctly.
|
|
69
54
|
!!error.message.match(/Unexpected token/) || !!error.message.match(/Cannot use import statement/)
|
|
70
55
|
);
|
|
71
56
|
}
|
|
72
|
-
|
|
73
57
|
return false;
|
|
74
58
|
}
|
|
59
|
+
|
|
75
60
|
/**
|
|
76
61
|
* Resolves static module plugin and potentially falls back on a provided plugin if the module cannot be resolved
|
|
77
62
|
*
|
|
@@ -80,34 +65,29 @@ function isUnexpectedTokenError(error) {
|
|
|
80
65
|
* @param projectRoot optional project root, fallback to _internal.projectRoot. Used for testing.
|
|
81
66
|
* @param _isLegacyPlugin Used to suppress errors thrown by plugins that are applied automatically
|
|
82
67
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
68
|
const withStaticPlugin = (config, props) => {
|
|
86
69
|
var _pluginProps;
|
|
87
|
-
|
|
88
70
|
let projectRoot = props.projectRoot;
|
|
89
|
-
|
|
90
71
|
if (!projectRoot) {
|
|
91
72
|
var _config$_internal;
|
|
92
|
-
|
|
93
73
|
projectRoot = (_config$_internal = config._internal) === null || _config$_internal === void 0 ? void 0 : _config$_internal.projectRoot;
|
|
94
74
|
(0, _pluginResolver().assertInternalProjectRoot)(projectRoot);
|
|
95
75
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
let [pluginResolve, pluginProps] = (0, _pluginResolver().normalizeStaticPlugin)(props.plugin);
|
|
77
|
+
// Ensure no one uses this property by accident.
|
|
99
78
|
(0, _assert().default)(!((_pluginProps = pluginProps) !== null && _pluginProps !== void 0 && _pluginProps._resolverError), `Plugin property '_resolverError' is a reserved property of \`withStaticPlugin\``);
|
|
100
79
|
let withPlugin;
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
if (
|
|
81
|
+
// Function was provided, no need to resolve: [withPlugin, {}]
|
|
103
82
|
typeof pluginResolve === 'function') {
|
|
104
83
|
withPlugin = pluginResolve;
|
|
105
84
|
} else if (typeof pluginResolve === 'string') {
|
|
106
85
|
try {
|
|
107
86
|
// Resolve and evaluate plugins.
|
|
108
|
-
withPlugin = (0, _pluginResolver().resolveConfigPluginFunction)(projectRoot, pluginResolve);
|
|
109
|
-
// This helps see which plugins are being skipped.
|
|
87
|
+
withPlugin = (0, _pluginResolver().resolveConfigPluginFunction)(projectRoot, pluginResolve);
|
|
110
88
|
|
|
89
|
+
// Only force if the project has the versioned plugin, otherwise use default behavior.
|
|
90
|
+
// This helps see which plugins are being skipped.
|
|
111
91
|
if (EXPO_USE_UNVERSIONED_PLUGINS && !!withPlugin && !!props._isLegacyPlugin && !!props.fallback) {
|
|
112
92
|
console.log(`Force "${pluginResolve}" to unversioned plugin`);
|
|
113
93
|
withPlugin = props.fallback;
|
|
@@ -121,7 +101,6 @@ const withStaticPlugin = (config, props) => {
|
|
|
121
101
|
console.log();
|
|
122
102
|
} else {
|
|
123
103
|
const shouldMuteWarning = props._isLegacyPlugin && (isModuleMissingError(pluginResolve, error) || isUnexpectedTokenError(error));
|
|
124
|
-
|
|
125
104
|
if (!shouldMuteWarning) {
|
|
126
105
|
if (isModuleMissingError(pluginResolve, error)) {
|
|
127
106
|
// Prevent causing log spew for basic resolution errors.
|
|
@@ -134,14 +113,14 @@ const withStaticPlugin = (config, props) => {
|
|
|
134
113
|
}
|
|
135
114
|
}
|
|
136
115
|
}
|
|
137
|
-
}
|
|
116
|
+
}
|
|
117
|
+
// TODO: Maybe allow for `PluginError`s to be thrown so external plugins can assert invalid options.
|
|
118
|
+
|
|
138
119
|
// If the static module failed to resolve, attempt to use a fallback.
|
|
139
120
|
// This enables support for built-in plugins with versioned variations living in other packages.
|
|
140
|
-
|
|
141
|
-
|
|
142
121
|
if (props.fallback) {
|
|
143
|
-
if (!pluginProps) pluginProps = {};
|
|
144
|
-
|
|
122
|
+
if (!pluginProps) pluginProps = {};
|
|
123
|
+
// Pass this to the fallback plugin for potential warnings about needing to install a versioned package.
|
|
145
124
|
pluginProps._resolverError = error;
|
|
146
125
|
withPlugin = props.fallback;
|
|
147
126
|
} else {
|
|
@@ -151,12 +130,11 @@ const withStaticPlugin = (config, props) => {
|
|
|
151
130
|
}
|
|
152
131
|
} else {
|
|
153
132
|
throw new (_errors().PluginError)(`Plugin is an unexpected type: ${typeof pluginResolve}`, 'INVALID_PLUGIN_TYPE');
|
|
154
|
-
}
|
|
155
|
-
|
|
133
|
+
}
|
|
156
134
|
|
|
135
|
+
// Execute the plugin.
|
|
157
136
|
config = withPlugin(config, pluginProps);
|
|
158
137
|
return config;
|
|
159
138
|
};
|
|
160
|
-
|
|
161
139
|
exports.withStaticPlugin = withStaticPlugin;
|
|
162
140
|
//# sourceMappingURL=withStaticPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withStaticPlugin.js","names":["EXPO_DEBUG","boolish","EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS","EXPO_USE_UNVERSIONED_PLUGINS","isModuleMissingError","name","error","includes","code","message","isUnexpectedTokenError","SyntaxError","PluginError","match","withStaticPlugin","config","props","projectRoot","_internal","assertInternalProjectRoot","pluginResolve","pluginProps","normalizeStaticPlugin","plugin","assert","_resolverError","withPlugin","resolveConfigPluginFunction","_isLegacyPlugin","fallback","console","log","shouldMuteWarning"],"sources":["../../src/plugins/withStaticPlugin.ts"],"sourcesContent":["import assert from 'assert';\nimport { boolish } from 'getenv';\n\nimport { ConfigPlugin, StaticPlugin } from '../Plugin.types';\nimport { PluginError } from '../utils/errors';\nimport {\n assertInternalProjectRoot,\n normalizeStaticPlugin,\n resolveConfigPluginFunction,\n} from '../utils/plugin-resolver';\n\nconst EXPO_DEBUG = boolish('EXPO_DEBUG', false);\n\n// Show all error info related to plugin resolution.\nconst EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS = boolish('EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS', false);\n// Force using the fallback unversioned plugin instead of a local versioned copy,\n// this should only be used for testing the CLI.\nconst EXPO_USE_UNVERSIONED_PLUGINS = boolish('EXPO_USE_UNVERSIONED_PLUGINS', false);\n\nfunction isModuleMissingError(name: string, error: Error): boolean {\n // @ts-ignore\n if (['MODULE_NOT_FOUND', 'PLUGIN_NOT_FOUND'].includes(error.code)) {\n return true;\n }\n return error.message.includes(`Cannot find module '${name}'`);\n}\n\nfunction isUnexpectedTokenError(error: Error): boolean {\n if (\n error instanceof SyntaxError ||\n (error instanceof PluginError && error.code === 'INVALID_PLUGIN_IMPORT')\n ) {\n return (\n // These are the most common errors that'll be thrown when a package isn't transpiled correctly.\n !!error.message.match(/Unexpected token/) ||\n !!error.message.match(/Cannot use import statement/)\n );\n }\n return false;\n}\n\n/**\n * Resolves static module plugin and potentially falls back on a provided plugin if the module cannot be resolved\n *\n * @param config\n * @param fallback Plugin with `_resolverError` explaining why the module couldn't be used\n * @param projectRoot optional project root, fallback to _internal.projectRoot. Used for testing.\n * @param _isLegacyPlugin Used to suppress errors thrown by plugins that are applied automatically\n */\nexport const withStaticPlugin: ConfigPlugin<{\n plugin: StaticPlugin | ConfigPlugin | string;\n fallback?: ConfigPlugin<{ _resolverError: Error } & any>;\n projectRoot?: string;\n _isLegacyPlugin?: boolean;\n}> = (config, props) => {\n let projectRoot = props.projectRoot;\n if (!projectRoot) {\n projectRoot = config._internal?.projectRoot;\n assertInternalProjectRoot(projectRoot);\n }\n\n let [pluginResolve, pluginProps] = normalizeStaticPlugin(props.plugin);\n // Ensure no one uses this property by accident.\n assert(\n !pluginProps?._resolverError,\n `Plugin property '_resolverError' is a reserved property of \\`withStaticPlugin\\``\n );\n\n let withPlugin: ConfigPlugin<unknown>;\n\n if (\n // Function was provided, no need to resolve: [withPlugin, {}]\n typeof pluginResolve === 'function'\n ) {\n withPlugin = pluginResolve;\n } else if (typeof pluginResolve === 'string') {\n try {\n // Resolve and evaluate plugins.\n withPlugin = resolveConfigPluginFunction(projectRoot, pluginResolve);\n\n // Only force if the project has the versioned plugin, otherwise use default behavior.\n // This helps see which plugins are being skipped.\n if (\n EXPO_USE_UNVERSIONED_PLUGINS &&\n !!withPlugin &&\n !!props._isLegacyPlugin &&\n !!props.fallback\n ) {\n console.log(`Force \"${pluginResolve}\" to unversioned plugin`);\n withPlugin = props.fallback;\n }\n } catch (error: any) {\n if (EXPO_DEBUG) {\n if (EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS) {\n // Log the error in debug mode for plugins with fallbacks (like the Expo managed plugins).\n console.log(`Error resolving plugin \"${pluginResolve}\"`);\n console.log(error);\n console.log();\n } else {\n const shouldMuteWarning =\n props._isLegacyPlugin &&\n (isModuleMissingError(pluginResolve, error) || isUnexpectedTokenError(error));\n if (!shouldMuteWarning) {\n if (isModuleMissingError(pluginResolve, error)) {\n // Prevent causing log spew for basic resolution errors.\n console.log(`Could not find plugin \"${pluginResolve}\"`);\n } else {\n // Log the error in debug mode for plugins with fallbacks (like the Expo managed plugins).\n console.log(`Error resolving plugin \"${pluginResolve}\"`);\n console.log(error);\n console.log();\n }\n }\n }\n }\n // TODO: Maybe allow for `PluginError`s to be thrown so external plugins can assert invalid options.\n\n // If the static module failed to resolve, attempt to use a fallback.\n // This enables support for built-in plugins with versioned variations living in other packages.\n if (props.fallback) {\n if (!pluginProps) pluginProps = {};\n // Pass this to the fallback plugin for potential warnings about needing to install a versioned package.\n pluginProps._resolverError = error;\n withPlugin = props.fallback;\n } else {\n // If no fallback, throw the resolution error.\n throw error;\n }\n }\n } else {\n throw new PluginError(\n `Plugin is an unexpected type: ${typeof pluginResolve}`,\n 'INVALID_PLUGIN_TYPE'\n );\n }\n\n // Execute the plugin.\n config = withPlugin(config, pluginProps);\n return config;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withStaticPlugin.js","names":["EXPO_DEBUG","boolish","EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS","EXPO_USE_UNVERSIONED_PLUGINS","isModuleMissingError","name","error","includes","code","message","isUnexpectedTokenError","SyntaxError","PluginError","match","withStaticPlugin","config","props","projectRoot","_internal","assertInternalProjectRoot","pluginResolve","pluginProps","normalizeStaticPlugin","plugin","assert","_resolverError","withPlugin","resolveConfigPluginFunction","_isLegacyPlugin","fallback","console","log","shouldMuteWarning"],"sources":["../../src/plugins/withStaticPlugin.ts"],"sourcesContent":["import assert from 'assert';\nimport { boolish } from 'getenv';\n\nimport { ConfigPlugin, StaticPlugin } from '../Plugin.types';\nimport { PluginError } from '../utils/errors';\nimport {\n assertInternalProjectRoot,\n normalizeStaticPlugin,\n resolveConfigPluginFunction,\n} from '../utils/plugin-resolver';\n\nconst EXPO_DEBUG = boolish('EXPO_DEBUG', false);\n\n// Show all error info related to plugin resolution.\nconst EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS = boolish('EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS', false);\n// Force using the fallback unversioned plugin instead of a local versioned copy,\n// this should only be used for testing the CLI.\nconst EXPO_USE_UNVERSIONED_PLUGINS = boolish('EXPO_USE_UNVERSIONED_PLUGINS', false);\n\nfunction isModuleMissingError(name: string, error: Error): boolean {\n // @ts-ignore\n if (['MODULE_NOT_FOUND', 'PLUGIN_NOT_FOUND'].includes(error.code)) {\n return true;\n }\n return error.message.includes(`Cannot find module '${name}'`);\n}\n\nfunction isUnexpectedTokenError(error: Error): boolean {\n if (\n error instanceof SyntaxError ||\n (error instanceof PluginError && error.code === 'INVALID_PLUGIN_IMPORT')\n ) {\n return (\n // These are the most common errors that'll be thrown when a package isn't transpiled correctly.\n !!error.message.match(/Unexpected token/) ||\n !!error.message.match(/Cannot use import statement/)\n );\n }\n return false;\n}\n\n/**\n * Resolves static module plugin and potentially falls back on a provided plugin if the module cannot be resolved\n *\n * @param config\n * @param fallback Plugin with `_resolverError` explaining why the module couldn't be used\n * @param projectRoot optional project root, fallback to _internal.projectRoot. Used for testing.\n * @param _isLegacyPlugin Used to suppress errors thrown by plugins that are applied automatically\n */\nexport const withStaticPlugin: ConfigPlugin<{\n plugin: StaticPlugin | ConfigPlugin | string;\n fallback?: ConfigPlugin<{ _resolverError: Error } & any>;\n projectRoot?: string;\n _isLegacyPlugin?: boolean;\n}> = (config, props) => {\n let projectRoot = props.projectRoot;\n if (!projectRoot) {\n projectRoot = config._internal?.projectRoot;\n assertInternalProjectRoot(projectRoot);\n }\n\n let [pluginResolve, pluginProps] = normalizeStaticPlugin(props.plugin);\n // Ensure no one uses this property by accident.\n assert(\n !pluginProps?._resolverError,\n `Plugin property '_resolverError' is a reserved property of \\`withStaticPlugin\\``\n );\n\n let withPlugin: ConfigPlugin<unknown>;\n\n if (\n // Function was provided, no need to resolve: [withPlugin, {}]\n typeof pluginResolve === 'function'\n ) {\n withPlugin = pluginResolve;\n } else if (typeof pluginResolve === 'string') {\n try {\n // Resolve and evaluate plugins.\n withPlugin = resolveConfigPluginFunction(projectRoot, pluginResolve);\n\n // Only force if the project has the versioned plugin, otherwise use default behavior.\n // This helps see which plugins are being skipped.\n if (\n EXPO_USE_UNVERSIONED_PLUGINS &&\n !!withPlugin &&\n !!props._isLegacyPlugin &&\n !!props.fallback\n ) {\n console.log(`Force \"${pluginResolve}\" to unversioned plugin`);\n withPlugin = props.fallback;\n }\n } catch (error: any) {\n if (EXPO_DEBUG) {\n if (EXPO_CONFIG_PLUGIN_VERBOSE_ERRORS) {\n // Log the error in debug mode for plugins with fallbacks (like the Expo managed plugins).\n console.log(`Error resolving plugin \"${pluginResolve}\"`);\n console.log(error);\n console.log();\n } else {\n const shouldMuteWarning =\n props._isLegacyPlugin &&\n (isModuleMissingError(pluginResolve, error) || isUnexpectedTokenError(error));\n if (!shouldMuteWarning) {\n if (isModuleMissingError(pluginResolve, error)) {\n // Prevent causing log spew for basic resolution errors.\n console.log(`Could not find plugin \"${pluginResolve}\"`);\n } else {\n // Log the error in debug mode for plugins with fallbacks (like the Expo managed plugins).\n console.log(`Error resolving plugin \"${pluginResolve}\"`);\n console.log(error);\n console.log();\n }\n }\n }\n }\n // TODO: Maybe allow for `PluginError`s to be thrown so external plugins can assert invalid options.\n\n // If the static module failed to resolve, attempt to use a fallback.\n // This enables support for built-in plugins with versioned variations living in other packages.\n if (props.fallback) {\n if (!pluginProps) pluginProps = {};\n // Pass this to the fallback plugin for potential warnings about needing to install a versioned package.\n pluginProps._resolverError = error;\n withPlugin = props.fallback;\n } else {\n // If no fallback, throw the resolution error.\n throw error;\n }\n }\n } else {\n throw new PluginError(\n `Plugin is an unexpected type: ${typeof pluginResolve}`,\n 'INVALID_PLUGIN_TYPE'\n );\n }\n\n // Execute the plugin.\n config = withPlugin(config, pluginProps);\n return config;\n};\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAA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ACzB,KAAK,CAAC;cAClBwB,OAAO,CAACC,GAAG,EAAE;YACf;UACF;QACF;MACF;MACA;;MAEA;MACA;MACA,IAAIf,KAAK,CAACa,QAAQ,EAAE;QAClB,IAAI,CAACR,WAAW,EAAEA,WAAW,GAAG,CAAC,CAAC;QAClC;QACAA,WAAW,CAACI,cAAc,GAAGnB,KAAK;QAClCoB,UAAU,GAAGV,KAAK,CAACa,QAAQ;MAC7B,CAAC,MAAM;QACL;QACA,MAAMvB,KAAK;MACb;IACF;EACF,CAAC,MAAM;IACL,MAAM,KAAIM,qBAAW,EAClB,iCAAgC,OAAOQ,aAAc,EAAC,EACvD,qBAAqB,CACtB;EACH;;EAEA;EACAL,MAAM,GAAGW,UAAU,CAACX,MAAM,EAAEM,WAAW,CAAC;EACxC,OAAON,MAAM;AACf,CAAC;AAAC"}
|
|
@@ -6,7 +6,7 @@ import type { ExpoConfig } from '@expo/config-types';
|
|
|
6
6
|
* ```ts
|
|
7
7
|
* {
|
|
8
8
|
* propName: 'expo.jsEngine',
|
|
9
|
-
* propValueGetter: (config) => config.android?.jsEngine ?? config.jsEngine ?? '
|
|
9
|
+
* propValueGetter: (config) => config.android?.jsEngine ?? config.jsEngine ?? 'hermes',
|
|
10
10
|
* }
|
|
11
11
|
* ```
|
|
12
12
|
* Will lookup a value through the `propValueGetter` and update to `android/gradle.properties` / `ios/Podfile.properties.json`
|
|
@@ -16,7 +16,7 @@ import type { ExpoConfig } from '@expo/config-types';
|
|
|
16
16
|
/**
|
|
17
17
|
* Source config can be either expo config or generic config
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type BuildPropertiesConfig = ExpoConfig | Record<string, any>;
|
|
20
20
|
export interface ConfigToPropertyRuleType<SourceConfigType extends BuildPropertiesConfig> {
|
|
21
21
|
/** Property name in `android/gradle.properties` or `ios/Podfile.properties.json` */
|
|
22
22
|
propName: string;
|