@expo/config 0.0.0-canary-20231122-1af9191

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.
Files changed (56) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +16 -0
  3. package/build/Config.d.ts +76 -0
  4. package/build/Config.js +533 -0
  5. package/build/Config.js.map +1 -0
  6. package/build/Config.types.d.ts +166 -0
  7. package/build/Config.types.js +26 -0
  8. package/build/Config.types.js.map +1 -0
  9. package/build/Errors.d.ts +11 -0
  10. package/build/Errors.js +20 -0
  11. package/build/Errors.js.map +1 -0
  12. package/build/Serialize.d.ts +3 -0
  13. package/build/Serialize.js +92 -0
  14. package/build/Serialize.js.map +1 -0
  15. package/build/environment.d.ts +1 -0
  16. package/build/environment.js +9 -0
  17. package/build/environment.js.map +1 -0
  18. package/build/evalConfig.d.ts +31 -0
  19. package/build/evalConfig.js +183 -0
  20. package/build/evalConfig.js.map +1 -0
  21. package/build/getAccountUsername.d.ts +9 -0
  22. package/build/getAccountUsername.js +33 -0
  23. package/build/getAccountUsername.js.map +1 -0
  24. package/build/getConfig.d.ts +4 -0
  25. package/build/getConfig.js +72 -0
  26. package/build/getConfig.js.map +1 -0
  27. package/build/getExpoSDKVersion.d.ts +6 -0
  28. package/build/getExpoSDKVersion.js +60 -0
  29. package/build/getExpoSDKVersion.js.map +1 -0
  30. package/build/getUserState.d.ts +23 -0
  31. package/build/getUserState.js +63 -0
  32. package/build/getUserState.js.map +1 -0
  33. package/build/index.d.ts +5 -0
  34. package/build/index.js +70 -0
  35. package/build/index.js.map +1 -0
  36. package/build/paths/extensions.d.ts +8 -0
  37. package/build/paths/extensions.js +73 -0
  38. package/build/paths/extensions.js.map +1 -0
  39. package/build/paths/index.d.ts +2 -0
  40. package/build/paths/index.js +28 -0
  41. package/build/paths/index.js.map +1 -0
  42. package/build/paths/paths.d.ts +9 -0
  43. package/build/paths/paths.js +135 -0
  44. package/build/paths/paths.js.map +1 -0
  45. package/build/plugins/withConfigPlugins.d.ts +8 -0
  46. package/build/plugins/withConfigPlugins.js +45 -0
  47. package/build/plugins/withConfigPlugins.js.map +1 -0
  48. package/build/plugins/withInternal.d.ts +13 -0
  49. package/build/plugins/withInternal.js +35 -0
  50. package/build/plugins/withInternal.js.map +1 -0
  51. package/build/resolvePackageJson.d.ts +1 -0
  52. package/build/resolvePackageJson.js +35 -0
  53. package/build/resolvePackageJson.js.map +1 -0
  54. package/package.json +56 -0
  55. package/paths/index.d.ts +1 -0
  56. package/paths/index.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ <!-- Title -->
2
+ <h1 align="center">
3
+ 👋 Welcome to <br><code>@expo/config</code>
4
+ </h1>
5
+
6
+ <p align="center">A library for interacting with the <code>app.json</code>.</p>
7
+
8
+ <p align="center">
9
+ <img src="https://flat.badgen.net/packagephobia/install/@expo/config">
10
+
11
+ <a href="https://www.npmjs.com/package/@expo/config">
12
+ <img src="https://flat.badgen.net/npm/dw/@expo/config" target="_blank" />
13
+ </a>
14
+ </p>
15
+
16
+ <!-- Body -->
@@ -0,0 +1,76 @@
1
+ import { AppJSONConfig, ConfigFilePaths, ExpoConfig, GetConfigOptions, PackageJSONConfig, ProjectConfig, ProjectTarget, WriteConfigOptions } from './Config.types';
2
+ /**
3
+ * Evaluate the config for an Expo project.
4
+ * If a function is exported from the `app.config.js` then a partial config will be passed as an argument.
5
+ * The partial config is composed from any existing app.json, and certain fields from the `package.json` like name and description.
6
+ *
7
+ * If options.isPublicConfig is true, the Expo config will include only public-facing options (omitting private keys).
8
+ * The resulting config should be suitable for hosting or embedding in a publicly readable location.
9
+ *
10
+ * **Example**
11
+ * ```js
12
+ * module.exports = function({ config }) {
13
+ * // mutate the config before returning it.
14
+ * config.slug = 'new slug'
15
+ * return { expo: config };
16
+ * }
17
+ * ```
18
+ *
19
+ * **Supports**
20
+ * - `app.config.ts`
21
+ * - `app.config.js`
22
+ * - `app.config.json`
23
+ * - `app.json`
24
+ *
25
+ * @param projectRoot the root folder containing all of your application code
26
+ * @param options enforce criteria for a project config
27
+ */
28
+ export declare function getConfig(projectRoot: string, options?: GetConfigOptions): ProjectConfig;
29
+ export declare function getPackageJson(projectRoot: string): PackageJSONConfig;
30
+ /**
31
+ * Get the static and dynamic config paths for a project. Also accounts for custom paths.
32
+ *
33
+ * @param projectRoot
34
+ */
35
+ export declare function getConfigFilePaths(projectRoot: string): ConfigFilePaths;
36
+ /**
37
+ * Attempt to modify an Expo project config.
38
+ * This will only fully work if the project is using static configs only.
39
+ * Otherwise 'warn' | 'fail' will return with a message about why the config couldn't be updated.
40
+ * The potentially modified config object will be returned for testing purposes.
41
+ *
42
+ * @param projectRoot
43
+ * @param modifications modifications to make to an existing config
44
+ * @param readOptions options for reading the current config file
45
+ * @param writeOptions If true, the static config file will not be rewritten
46
+ */
47
+ export declare function modifyConfigAsync(projectRoot: string, modifications: Partial<ExpoConfig>, readOptions?: GetConfigOptions, writeOptions?: WriteConfigOptions): Promise<{
48
+ type: 'success' | 'warn' | 'fail';
49
+ message?: string;
50
+ config: AppJSONConfig | null;
51
+ }>;
52
+ export declare function getWebOutputPath(config?: {
53
+ [key: string]: any;
54
+ }): string;
55
+ export declare function getNameFromConfig(exp?: Record<string, any>): {
56
+ appName?: string;
57
+ webName?: string;
58
+ };
59
+ export declare function getDefaultTarget(projectRoot: string, exp?: Pick<ExpoConfig, 'sdkVersion'>): ProjectTarget;
60
+ /**
61
+ * Return a useful name describing the project config.
62
+ * - dynamic: app.config.js
63
+ * - static: app.json
64
+ * - custom path app config relative to root folder
65
+ * - both: app.config.js or app.json
66
+ */
67
+ export declare function getProjectConfigDescription(projectRoot: string): string;
68
+ /**
69
+ * Returns a string describing the configurations used for the given project root.
70
+ * Will return null if no config is found.
71
+ *
72
+ * @param projectRoot
73
+ * @param projectConfig
74
+ */
75
+ export declare function getProjectConfigDescriptionWithPaths(projectRoot: string, projectConfig: ConfigFilePaths): string;
76
+ export * from './Config.types';
@@ -0,0 +1,533 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ getConfig: true,
8
+ getPackageJson: true,
9
+ getConfigFilePaths: true,
10
+ modifyConfigAsync: true,
11
+ getWebOutputPath: true,
12
+ getNameFromConfig: true,
13
+ getDefaultTarget: true,
14
+ getProjectConfigDescription: true,
15
+ getProjectConfigDescriptionWithPaths: true
16
+ };
17
+ exports.getConfig = getConfig;
18
+ exports.getConfigFilePaths = getConfigFilePaths;
19
+ exports.getDefaultTarget = getDefaultTarget;
20
+ exports.getNameFromConfig = getNameFromConfig;
21
+ exports.getPackageJson = getPackageJson;
22
+ exports.getProjectConfigDescription = getProjectConfigDescription;
23
+ exports.getProjectConfigDescriptionWithPaths = getProjectConfigDescriptionWithPaths;
24
+ exports.getWebOutputPath = getWebOutputPath;
25
+ exports.modifyConfigAsync = modifyConfigAsync;
26
+ function _jsonFile() {
27
+ const data = _interopRequireDefault(require("@expo/json-file"));
28
+ _jsonFile = function () {
29
+ return data;
30
+ };
31
+ return data;
32
+ }
33
+ function _fs() {
34
+ const data = _interopRequireDefault(require("fs"));
35
+ _fs = function () {
36
+ return data;
37
+ };
38
+ return data;
39
+ }
40
+ function _glob() {
41
+ const data = require("glob");
42
+ _glob = function () {
43
+ return data;
44
+ };
45
+ return data;
46
+ }
47
+ function _path() {
48
+ const data = _interopRequireDefault(require("path"));
49
+ _path = function () {
50
+ return data;
51
+ };
52
+ return data;
53
+ }
54
+ function _resolveFrom() {
55
+ const data = _interopRequireDefault(require("resolve-from"));
56
+ _resolveFrom = function () {
57
+ return data;
58
+ };
59
+ return data;
60
+ }
61
+ function _semver() {
62
+ const data = _interopRequireDefault(require("semver"));
63
+ _semver = function () {
64
+ return data;
65
+ };
66
+ return data;
67
+ }
68
+ function _slugify() {
69
+ const data = _interopRequireDefault(require("slugify"));
70
+ _slugify = function () {
71
+ return data;
72
+ };
73
+ return data;
74
+ }
75
+ function _getConfig() {
76
+ const data = require("./getConfig");
77
+ _getConfig = function () {
78
+ return data;
79
+ };
80
+ return data;
81
+ }
82
+ function _getExpoSDKVersion() {
83
+ const data = require("./getExpoSDKVersion");
84
+ _getExpoSDKVersion = function () {
85
+ return data;
86
+ };
87
+ return data;
88
+ }
89
+ function _withConfigPlugins() {
90
+ const data = require("./plugins/withConfigPlugins");
91
+ _withConfigPlugins = function () {
92
+ return data;
93
+ };
94
+ return data;
95
+ }
96
+ function _withInternal() {
97
+ const data = require("./plugins/withInternal");
98
+ _withInternal = function () {
99
+ return data;
100
+ };
101
+ return data;
102
+ }
103
+ function _resolvePackageJson() {
104
+ const data = require("./resolvePackageJson");
105
+ _resolvePackageJson = function () {
106
+ return data;
107
+ };
108
+ return data;
109
+ }
110
+ var _Config = require("./Config.types");
111
+ Object.keys(_Config).forEach(function (key) {
112
+ if (key === "default" || key === "__esModule") return;
113
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
114
+ if (key in exports && exports[key] === _Config[key]) return;
115
+ Object.defineProperty(exports, key, {
116
+ enumerable: true,
117
+ get: function () {
118
+ return _Config[key];
119
+ }
120
+ });
121
+ });
122
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
123
+ /**
124
+ * If a config has an `expo` object then that will be used as the config.
125
+ * This method reduces out other top level values if an `expo` object exists.
126
+ *
127
+ * @param config Input config object to reduce
128
+ */
129
+ function reduceExpoObject(config) {
130
+ var _config$expo;
131
+ if (!config) return config === undefined ? null : config;
132
+ const {
133
+ mods,
134
+ ...expo
135
+ } = (_config$expo = config.expo) !== null && _config$expo !== void 0 ? _config$expo : config;
136
+ return {
137
+ expo,
138
+ mods
139
+ };
140
+ }
141
+
142
+ /**
143
+ * Get all platforms that a project is currently capable of running.
144
+ *
145
+ * @param projectRoot
146
+ * @param exp
147
+ */
148
+ function getSupportedPlatforms(projectRoot) {
149
+ const platforms = [];
150
+ if (_resolveFrom().default.silent(projectRoot, 'react-native')) {
151
+ platforms.push('ios', 'android');
152
+ }
153
+ if (_resolveFrom().default.silent(projectRoot, 'react-native-web')) {
154
+ platforms.push('web');
155
+ }
156
+ return platforms;
157
+ }
158
+
159
+ /**
160
+ * Evaluate the config for an Expo project.
161
+ * If a function is exported from the `app.config.js` then a partial config will be passed as an argument.
162
+ * The partial config is composed from any existing app.json, and certain fields from the `package.json` like name and description.
163
+ *
164
+ * If options.isPublicConfig is true, the Expo config will include only public-facing options (omitting private keys).
165
+ * The resulting config should be suitable for hosting or embedding in a publicly readable location.
166
+ *
167
+ * **Example**
168
+ * ```js
169
+ * module.exports = function({ config }) {
170
+ * // mutate the config before returning it.
171
+ * config.slug = 'new slug'
172
+ * return { expo: config };
173
+ * }
174
+ * ```
175
+ *
176
+ * **Supports**
177
+ * - `app.config.ts`
178
+ * - `app.config.js`
179
+ * - `app.config.json`
180
+ * - `app.json`
181
+ *
182
+ * @param projectRoot the root folder containing all of your application code
183
+ * @param options enforce criteria for a project config
184
+ */
185
+ function getConfig(projectRoot, options = {}) {
186
+ const paths = getConfigFilePaths(projectRoot);
187
+ const rawStaticConfig = paths.staticConfigPath ? (0, _getConfig().getStaticConfig)(paths.staticConfigPath) : null;
188
+ // For legacy reasons, always return an object.
189
+ const rootConfig = rawStaticConfig || {};
190
+ const staticConfig = reduceExpoObject(rawStaticConfig) || {};
191
+
192
+ // Can only change the package.json location if an app.json or app.config.json exists
193
+ const [packageJson, packageJsonPath] = getPackageJsonAndPath(projectRoot);
194
+ function fillAndReturnConfig(config, dynamicConfigObjectType, mayHaveUnusedStaticConfig = false) {
195
+ const configWithDefaultValues = {
196
+ ...ensureConfigHasDefaultValues({
197
+ projectRoot,
198
+ exp: config.expo,
199
+ pkg: packageJson,
200
+ skipSDKVersionRequirement: options.skipSDKVersionRequirement,
201
+ paths,
202
+ packageJsonPath
203
+ }),
204
+ mods: config.mods,
205
+ dynamicConfigObjectType,
206
+ rootConfig,
207
+ dynamicConfigPath: paths.dynamicConfigPath,
208
+ staticConfigPath: paths.staticConfigPath,
209
+ hasUnusedStaticConfig: !!paths.staticConfigPath && !!paths.dynamicConfigPath && mayHaveUnusedStaticConfig
210
+ };
211
+ if (options.isModdedConfig) {
212
+ var _config$mods;
213
+ // @ts-ignore: Add the mods back to the object.
214
+ configWithDefaultValues.exp.mods = (_config$mods = config.mods) !== null && _config$mods !== void 0 ? _config$mods : null;
215
+ }
216
+
217
+ // Apply static json plugins, should be done after _internal
218
+ configWithDefaultValues.exp = (0, _withConfigPlugins().withConfigPlugins)(configWithDefaultValues.exp, !!options.skipPlugins);
219
+ if (!options.isModdedConfig) {
220
+ // @ts-ignore: Delete mods added by static plugins when they won't have a chance to be evaluated
221
+ delete configWithDefaultValues.exp.mods;
222
+ }
223
+ if (options.isPublicConfig) {
224
+ var _configWithDefaultVal, _configWithDefaultVal2, _configWithDefaultVal3, _configWithDefaultVal4;
225
+ // TODD(EvanBacon): Drop plugins array after it's been resolved.
226
+
227
+ // Remove internal values with references to user's file paths from the public config.
228
+ delete configWithDefaultValues.exp._internal;
229
+ if (configWithDefaultValues.exp.hooks) {
230
+ delete configWithDefaultValues.exp.hooks;
231
+ }
232
+ if ((_configWithDefaultVal = configWithDefaultValues.exp.ios) !== null && _configWithDefaultVal !== void 0 && _configWithDefaultVal.config) {
233
+ delete configWithDefaultValues.exp.ios.config;
234
+ }
235
+ if ((_configWithDefaultVal2 = configWithDefaultValues.exp.android) !== null && _configWithDefaultVal2 !== void 0 && _configWithDefaultVal2.config) {
236
+ delete configWithDefaultValues.exp.android.config;
237
+ }
238
+ (_configWithDefaultVal3 = configWithDefaultValues.exp.updates) === null || _configWithDefaultVal3 === void 0 ? true : delete _configWithDefaultVal3.codeSigningCertificate;
239
+ (_configWithDefaultVal4 = configWithDefaultValues.exp.updates) === null || _configWithDefaultVal4 === void 0 ? true : delete _configWithDefaultVal4.codeSigningMetadata;
240
+ }
241
+ return configWithDefaultValues;
242
+ }
243
+
244
+ // Fill in the static config
245
+ function getContextConfig(config) {
246
+ return ensureConfigHasDefaultValues({
247
+ projectRoot,
248
+ exp: config.expo,
249
+ pkg: packageJson,
250
+ skipSDKVersionRequirement: true,
251
+ paths,
252
+ packageJsonPath
253
+ }).exp;
254
+ }
255
+ if (paths.dynamicConfigPath) {
256
+ // No app.config.json or app.json but app.config.js
257
+ const {
258
+ exportedObjectType,
259
+ config: rawDynamicConfig,
260
+ mayHaveUnusedStaticConfig
261
+ } = (0, _getConfig().getDynamicConfig)(paths.dynamicConfigPath, {
262
+ projectRoot,
263
+ staticConfigPath: paths.staticConfigPath,
264
+ packageJsonPath,
265
+ config: getContextConfig(staticConfig)
266
+ });
267
+ // Allow for the app.config.js to `export default null;`
268
+ // Use `dynamicConfigPath` to detect if a dynamic config exists.
269
+ const dynamicConfig = reduceExpoObject(rawDynamicConfig) || {};
270
+ return fillAndReturnConfig(dynamicConfig, exportedObjectType, mayHaveUnusedStaticConfig);
271
+ }
272
+
273
+ // No app.config.js but json or no config
274
+ return fillAndReturnConfig(staticConfig || {}, null);
275
+ }
276
+ function getPackageJson(projectRoot) {
277
+ const [pkg] = getPackageJsonAndPath(projectRoot);
278
+ return pkg;
279
+ }
280
+ function getPackageJsonAndPath(projectRoot) {
281
+ const packageJsonPath = (0, _resolvePackageJson().getRootPackageJsonPath)(projectRoot);
282
+ return [_jsonFile().default.read(packageJsonPath), packageJsonPath];
283
+ }
284
+
285
+ /**
286
+ * Get the static and dynamic config paths for a project. Also accounts for custom paths.
287
+ *
288
+ * @param projectRoot
289
+ */
290
+ function getConfigFilePaths(projectRoot) {
291
+ return {
292
+ dynamicConfigPath: getDynamicConfigFilePath(projectRoot),
293
+ staticConfigPath: getStaticConfigFilePath(projectRoot)
294
+ };
295
+ }
296
+ function getDynamicConfigFilePath(projectRoot) {
297
+ for (const fileName of ['app.config.ts', 'app.config.js']) {
298
+ const configPath = _path().default.join(projectRoot, fileName);
299
+ if (_fs().default.existsSync(configPath)) {
300
+ return configPath;
301
+ }
302
+ }
303
+ return null;
304
+ }
305
+ function getStaticConfigFilePath(projectRoot) {
306
+ for (const fileName of ['app.config.json', 'app.json']) {
307
+ const configPath = _path().default.join(projectRoot, fileName);
308
+ if (_fs().default.existsSync(configPath)) {
309
+ return configPath;
310
+ }
311
+ }
312
+ return null;
313
+ }
314
+
315
+ /**
316
+ * Attempt to modify an Expo project config.
317
+ * This will only fully work if the project is using static configs only.
318
+ * Otherwise 'warn' | 'fail' will return with a message about why the config couldn't be updated.
319
+ * The potentially modified config object will be returned for testing purposes.
320
+ *
321
+ * @param projectRoot
322
+ * @param modifications modifications to make to an existing config
323
+ * @param readOptions options for reading the current config file
324
+ * @param writeOptions If true, the static config file will not be rewritten
325
+ */
326
+ async function modifyConfigAsync(projectRoot, modifications, readOptions = {}, writeOptions = {}) {
327
+ const config = getConfig(projectRoot, readOptions);
328
+ if (config.dynamicConfigPath) {
329
+ // We cannot automatically write to a dynamic config.
330
+ /* Currently we should just use the safest approach possible, informing the user that they'll need to manually modify their dynamic config.
331
+ if (config.staticConfigPath) {
332
+ // Both a dynamic and a static config exist.
333
+ if (config.dynamicConfigObjectType === 'function') {
334
+ // The dynamic config exports a function, this means it possibly extends the static config.
335
+ } else {
336
+ // Dynamic config ignores the static config, there isn't a reason to automatically write to it.
337
+ // Instead we should warn the user to add values to their dynamic config.
338
+ }
339
+ }
340
+ */
341
+ return {
342
+ type: 'warn',
343
+ message: `Cannot automatically write to dynamic config at: ${_path().default.relative(projectRoot, config.dynamicConfigPath)}`,
344
+ config: null
345
+ };
346
+ } else if (config.staticConfigPath) {
347
+ // Static with no dynamic config, this means we can append to the config automatically.
348
+ let outputConfig;
349
+ // If the config has an expo object (app.json) then append the options to that object.
350
+ if (config.rootConfig.expo) {
351
+ outputConfig = {
352
+ ...config.rootConfig,
353
+ expo: {
354
+ ...config.rootConfig.expo,
355
+ ...modifications
356
+ }
357
+ };
358
+ } else {
359
+ // Otherwise (app.config.json) just add the config modification to the top most level.
360
+ outputConfig = {
361
+ ...config.rootConfig,
362
+ ...modifications
363
+ };
364
+ }
365
+ if (!writeOptions.dryRun) {
366
+ await _jsonFile().default.writeAsync(config.staticConfigPath, outputConfig, {
367
+ json5: false
368
+ });
369
+ }
370
+ return {
371
+ type: 'success',
372
+ config: outputConfig
373
+ };
374
+ }
375
+ return {
376
+ type: 'fail',
377
+ message: 'No config exists',
378
+ config: null
379
+ };
380
+ }
381
+ function ensureConfigHasDefaultValues({
382
+ projectRoot,
383
+ exp,
384
+ pkg,
385
+ paths,
386
+ packageJsonPath,
387
+ skipSDKVersionRequirement = false
388
+ }) {
389
+ var _exp$name, _exp$slug, _exp$version;
390
+ if (!exp) {
391
+ exp = {};
392
+ }
393
+ exp = (0, _withInternal().withInternal)(exp, {
394
+ projectRoot,
395
+ ...(paths !== null && paths !== void 0 ? paths : {}),
396
+ packageJsonPath
397
+ });
398
+ // Defaults for package.json fields
399
+ const pkgName = typeof pkg.name === 'string' ? pkg.name : _path().default.basename(projectRoot);
400
+ const pkgVersion = typeof pkg.version === 'string' ? pkg.version : '1.0.0';
401
+ const pkgWithDefaults = {
402
+ ...pkg,
403
+ name: pkgName,
404
+ version: pkgVersion
405
+ };
406
+
407
+ // Defaults for app.json/app.config.js fields
408
+ const name = (_exp$name = exp.name) !== null && _exp$name !== void 0 ? _exp$name : pkgName;
409
+ const slug = (_exp$slug = exp.slug) !== null && _exp$slug !== void 0 ? _exp$slug : (0, _slugify().default)(name.toLowerCase());
410
+ const version = (_exp$version = exp.version) !== null && _exp$version !== void 0 ? _exp$version : pkgVersion;
411
+ let description = exp.description;
412
+ if (!description && typeof pkg.description === 'string') {
413
+ description = pkg.description;
414
+ }
415
+ const expWithDefaults = {
416
+ ...exp,
417
+ name,
418
+ slug,
419
+ version,
420
+ description
421
+ };
422
+ let sdkVersion;
423
+ try {
424
+ sdkVersion = (0, _getExpoSDKVersion().getExpoSDKVersion)(projectRoot, expWithDefaults);
425
+ } catch (error) {
426
+ if (!skipSDKVersionRequirement) throw error;
427
+ }
428
+ let platforms = exp.platforms;
429
+ if (!platforms) {
430
+ platforms = getSupportedPlatforms(projectRoot);
431
+ }
432
+ return {
433
+ exp: {
434
+ ...expWithDefaults,
435
+ sdkVersion,
436
+ platforms
437
+ },
438
+ pkg: pkgWithDefaults
439
+ };
440
+ }
441
+ const DEFAULT_BUILD_PATH = `web-build`;
442
+ function getWebOutputPath(config = {}) {
443
+ var _expo$web, _expo$web$build;
444
+ if (process.env.WEBPACK_BUILD_OUTPUT_PATH) {
445
+ return process.env.WEBPACK_BUILD_OUTPUT_PATH;
446
+ }
447
+ const expo = config.expo || config || {};
448
+ return (expo === null || expo === void 0 ? void 0 : (_expo$web = expo.web) === null || _expo$web === void 0 ? void 0 : (_expo$web$build = _expo$web.build) === null || _expo$web$build === void 0 ? void 0 : _expo$web$build.output) || DEFAULT_BUILD_PATH;
449
+ }
450
+ function getNameFromConfig(exp = {}) {
451
+ // For RN CLI support
452
+ const appManifest = exp.expo || exp;
453
+ const {
454
+ web = {}
455
+ } = appManifest;
456
+
457
+ // rn-cli apps use a displayName value as well.
458
+ const appName = exp.displayName || appManifest.displayName || appManifest.name;
459
+ const webName = web.name || appName;
460
+ return {
461
+ appName,
462
+ webName
463
+ };
464
+ }
465
+ function getDefaultTarget(projectRoot, exp) {
466
+ var _exp;
467
+ (_exp = exp) !== null && _exp !== void 0 ? _exp : exp = getConfig(projectRoot, {
468
+ skipSDKVersionRequirement: true
469
+ }).exp;
470
+
471
+ // before SDK 37, always default to managed to preserve previous behavior
472
+ if (exp.sdkVersion && exp.sdkVersion !== 'UNVERSIONED' && _semver().default.lt(exp.sdkVersion, '37.0.0')) {
473
+ return 'managed';
474
+ }
475
+ return isBareWorkflowProject(projectRoot) ? 'bare' : 'managed';
476
+ }
477
+ function isBareWorkflowProject(projectRoot) {
478
+ const [pkg] = getPackageJsonAndPath(projectRoot);
479
+
480
+ // TODO: Drop this
481
+ if (pkg.dependencies && pkg.dependencies.expokit) {
482
+ return false;
483
+ }
484
+ const xcodeprojFiles = (0, _glob().sync)('ios/**/*.xcodeproj', {
485
+ absolute: true,
486
+ cwd: projectRoot
487
+ });
488
+ if (xcodeprojFiles.length) {
489
+ return true;
490
+ }
491
+ const gradleFiles = (0, _glob().sync)('android/**/*.gradle', {
492
+ absolute: true,
493
+ cwd: projectRoot
494
+ });
495
+ if (gradleFiles.length) {
496
+ return true;
497
+ }
498
+ return false;
499
+ }
500
+
501
+ /**
502
+ * Return a useful name describing the project config.
503
+ * - dynamic: app.config.js
504
+ * - static: app.json
505
+ * - custom path app config relative to root folder
506
+ * - both: app.config.js or app.json
507
+ */
508
+ function getProjectConfigDescription(projectRoot) {
509
+ const paths = getConfigFilePaths(projectRoot);
510
+ return getProjectConfigDescriptionWithPaths(projectRoot, paths);
511
+ }
512
+
513
+ /**
514
+ * Returns a string describing the configurations used for the given project root.
515
+ * Will return null if no config is found.
516
+ *
517
+ * @param projectRoot
518
+ * @param projectConfig
519
+ */
520
+ function getProjectConfigDescriptionWithPaths(projectRoot, projectConfig) {
521
+ if (projectConfig.dynamicConfigPath) {
522
+ const relativeDynamicConfigPath = _path().default.relative(projectRoot, projectConfig.dynamicConfigPath);
523
+ if (projectConfig.staticConfigPath) {
524
+ return `${relativeDynamicConfigPath} or ${_path().default.relative(projectRoot, projectConfig.staticConfigPath)}`;
525
+ }
526
+ return relativeDynamicConfigPath;
527
+ } else if (projectConfig.staticConfigPath) {
528
+ return _path().default.relative(projectRoot, projectConfig.staticConfigPath);
529
+ }
530
+ // If a config doesn't exist, our tooling will generate a static app.json
531
+ return 'app.json';
532
+ }
533
+ //# sourceMappingURL=Config.js.map