@expo/config 7.0.2 → 8.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.
Files changed (46) hide show
  1. package/build/Config.d.ts +1 -13
  2. package/build/Config.js +56 -363
  3. package/build/Config.js.map +1 -1
  4. package/build/Config.types.d.ts +18 -21
  5. package/build/Config.types.js +0 -5
  6. package/build/Config.types.js.map +1 -1
  7. package/build/Errors.js +3 -7
  8. package/build/Errors.js.map +1 -1
  9. package/build/Serialize.js +4 -24
  10. package/build/Serialize.js.map +1 -1
  11. package/build/evalConfig.d.ts +2 -2
  12. package/build/evalConfig.js +12 -44
  13. package/build/evalConfig.js.map +1 -1
  14. package/build/getConfig.js +2 -23
  15. package/build/getConfig.js.map +1 -1
  16. package/build/getExpoSDKVersion.d.ts +6 -0
  17. package/build/getExpoSDKVersion.js +60 -0
  18. package/build/getExpoSDKVersion.js.map +1 -0
  19. package/build/getFullName.js +3 -11
  20. package/build/getFullName.js.map +1 -1
  21. package/build/getUserState.d.ts +3 -3
  22. package/build/getUserState.js +0 -20
  23. package/build/getUserState.js.map +1 -1
  24. package/build/index.d.ts +1 -1
  25. package/build/index.js +4 -15
  26. package/build/index.js.map +1 -1
  27. package/build/paths/extensions.d.ts +1 -2
  28. package/build/paths/extensions.js +8 -35
  29. package/build/paths/extensions.js.map +1 -1
  30. package/build/paths/index.js +0 -4
  31. package/build/paths/index.js.map +1 -1
  32. package/build/paths/paths.js +37 -67
  33. package/build/paths/paths.js.map +1 -1
  34. package/build/plugins/withConfigPlugins.js +2 -13
  35. package/build/plugins/withConfigPlugins.js.map +1 -1
  36. package/build/plugins/withInternal.js +1 -8
  37. package/build/plugins/withInternal.js.map +1 -1
  38. package/build/resolvePackageJson.js +1 -21
  39. package/build/resolvePackageJson.js.map +1 -1
  40. package/package.json +5 -5
  41. package/build/Project.d.ts +0 -2
  42. package/build/Project.js +0 -64
  43. package/build/Project.js.map +0 -1
  44. package/build/isLegacyImportsEnabled.d.ts +0 -7
  45. package/build/isLegacyImportsEnabled.js +0 -61
  46. package/build/isLegacyImportsEnabled.js.map +0 -1
package/build/Config.js CHANGED
@@ -6,24 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  getConfig: true,
8
8
  getPackageJson: true,
9
- readConfigJson: true,
10
9
  getConfigFilePaths: true,
11
- findConfigFile: true,
12
- configFilename: true,
13
- readExpRcAsync: true,
14
- resetCustomConfigPaths: true,
15
- setCustomConfigPath: true,
16
10
  modifyConfigAsync: true,
17
- writeConfigJsonAsync: true,
18
11
  getWebOutputPath: true,
19
12
  getNameFromConfig: true,
20
13
  getDefaultTarget: true,
21
14
  getProjectConfigDescription: true,
22
- getProjectConfigDescriptionWithPaths: true,
23
- isLegacyImportsEnabled: true
15
+ getProjectConfigDescriptionWithPaths: true
24
16
  };
25
- exports.configFilename = configFilename;
26
- exports.findConfigFile = findConfigFile;
27
17
  exports.getConfig = getConfig;
28
18
  exports.getConfigFilePaths = getConfigFilePaths;
29
19
  exports.getDefaultTarget = getDefaultTarget;
@@ -32,161 +22,99 @@ exports.getPackageJson = getPackageJson;
32
22
  exports.getProjectConfigDescription = getProjectConfigDescription;
33
23
  exports.getProjectConfigDescriptionWithPaths = getProjectConfigDescriptionWithPaths;
34
24
  exports.getWebOutputPath = getWebOutputPath;
35
- Object.defineProperty(exports, "isLegacyImportsEnabled", {
36
- enumerable: true,
37
- get: function () {
38
- return _isLegacyImportsEnabled().isLegacyImportsEnabled;
39
- }
40
- });
41
25
  exports.modifyConfigAsync = modifyConfigAsync;
42
- exports.readConfigJson = readConfigJson;
43
- exports.readExpRcAsync = readExpRcAsync;
44
- exports.resetCustomConfigPaths = resetCustomConfigPaths;
45
- exports.setCustomConfigPath = setCustomConfigPath;
46
- exports.writeConfigJsonAsync = writeConfigJsonAsync;
47
-
48
26
  function _jsonFile() {
49
27
  const data = _interopRequireDefault(require("@expo/json-file"));
50
-
51
28
  _jsonFile = function () {
52
29
  return data;
53
30
  };
54
-
55
31
  return data;
56
32
  }
57
-
58
33
  function _fs() {
59
34
  const data = _interopRequireDefault(require("fs"));
60
-
61
35
  _fs = function () {
62
36
  return data;
63
37
  };
64
-
65
38
  return data;
66
39
  }
67
-
68
40
  function _glob() {
69
41
  const data = require("glob");
70
-
71
42
  _glob = function () {
72
43
  return data;
73
44
  };
74
-
75
45
  return data;
76
46
  }
77
-
78
47
  function _path() {
79
48
  const data = _interopRequireDefault(require("path"));
80
-
81
49
  _path = function () {
82
50
  return data;
83
51
  };
84
-
85
52
  return data;
86
53
  }
87
-
88
54
  function _resolveFrom() {
89
55
  const data = _interopRequireDefault(require("resolve-from"));
90
-
91
56
  _resolveFrom = function () {
92
57
  return data;
93
58
  };
94
-
95
59
  return data;
96
60
  }
97
-
98
61
  function _semver() {
99
62
  const data = _interopRequireDefault(require("semver"));
100
-
101
63
  _semver = function () {
102
64
  return data;
103
65
  };
104
-
105
66
  return data;
106
67
  }
107
-
108
68
  function _slugify() {
109
69
  const data = _interopRequireDefault(require("slugify"));
110
-
111
70
  _slugify = function () {
112
71
  return data;
113
72
  };
114
-
115
- return data;
116
- }
117
-
118
- function _Errors() {
119
- const data = require("./Errors");
120
-
121
- _Errors = function () {
122
- return data;
123
- };
124
-
125
73
  return data;
126
74
  }
127
-
128
- function _Project() {
129
- const data = require("./Project");
130
-
131
- _Project = function () {
75
+ function _getConfig() {
76
+ const data = require("./getConfig");
77
+ _getConfig = function () {
132
78
  return data;
133
79
  };
134
-
135
80
  return data;
136
81
  }
137
-
138
- function _getConfig() {
139
- const data = require("./getConfig");
140
-
141
- _getConfig = function () {
82
+ function _getExpoSDKVersion() {
83
+ const data = require("./getExpoSDKVersion");
84
+ _getExpoSDKVersion = function () {
142
85
  return data;
143
86
  };
144
-
145
87
  return data;
146
88
  }
147
-
148
89
  function _getFullName() {
149
90
  const data = require("./getFullName");
150
-
151
91
  _getFullName = function () {
152
92
  return data;
153
93
  };
154
-
155
94
  return data;
156
95
  }
157
-
158
96
  function _withConfigPlugins() {
159
97
  const data = require("./plugins/withConfigPlugins");
160
-
161
98
  _withConfigPlugins = function () {
162
99
  return data;
163
100
  };
164
-
165
101
  return data;
166
102
  }
167
-
168
103
  function _withInternal() {
169
104
  const data = require("./plugins/withInternal");
170
-
171
105
  _withInternal = function () {
172
106
  return data;
173
107
  };
174
-
175
108
  return data;
176
109
  }
177
-
178
110
  function _resolvePackageJson() {
179
111
  const data = require("./resolvePackageJson");
180
-
181
112
  _resolvePackageJson = function () {
182
113
  return data;
183
114
  };
184
-
185
115
  return data;
186
116
  }
187
-
188
117
  var _Config = require("./Config.types");
189
-
190
118
  Object.keys(_Config).forEach(function (key) {
191
119
  if (key === "default" || key === "__esModule") return;
192
120
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -198,19 +126,7 @@ Object.keys(_Config).forEach(function (key) {
198
126
  }
199
127
  });
200
128
  });
201
-
202
- function _isLegacyImportsEnabled() {
203
- const data = require("./isLegacyImportsEnabled");
204
-
205
- _isLegacyImportsEnabled = function () {
206
- return data;
207
- };
208
-
209
- return data;
210
- }
211
-
212
129
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
213
-
214
130
  /**
215
131
  * If a config has an `expo` object then that will be used as the config.
216
132
  * This method reduces out other top level values if an `expo` object exists.
@@ -219,7 +135,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
219
135
  */
220
136
  function reduceExpoObject(config) {
221
137
  var _config$expo;
222
-
223
138
  if (!config) return config === undefined ? null : config;
224
139
  const {
225
140
  mods,
@@ -230,27 +145,24 @@ function reduceExpoObject(config) {
230
145
  mods
231
146
  };
232
147
  }
148
+
233
149
  /**
234
150
  * Get all platforms that a project is currently capable of running.
235
151
  *
236
152
  * @param projectRoot
237
153
  * @param exp
238
154
  */
239
-
240
-
241
155
  function getSupportedPlatforms(projectRoot) {
242
156
  const platforms = [];
243
-
244
157
  if (_resolveFrom().default.silent(projectRoot, 'react-native')) {
245
158
  platforms.push('ios', 'android');
246
159
  }
247
-
248
160
  if (_resolveFrom().default.silent(projectRoot, 'react-native-web')) {
249
161
  platforms.push('web');
250
162
  }
251
-
252
163
  return platforms;
253
164
  }
165
+
254
166
  /**
255
167
  * Evaluate the config for an Expo project.
256
168
  * If a function is exported from the `app.config.js` then a partial config will be passed as an argument.
@@ -277,19 +189,18 @@ function getSupportedPlatforms(projectRoot) {
277
189
  * @param projectRoot the root folder containing all of your application code
278
190
  * @param options enforce criteria for a project config
279
191
  */
280
-
281
-
282
192
  function getConfig(projectRoot, options = {}) {
283
193
  const paths = getConfigFilePaths(projectRoot);
284
- const rawStaticConfig = paths.staticConfigPath ? (0, _getConfig().getStaticConfig)(paths.staticConfigPath) : null; // For legacy reasons, always return an object.
285
-
194
+ const rawStaticConfig = paths.staticConfigPath ? (0, _getConfig().getStaticConfig)(paths.staticConfigPath) : null;
195
+ // For legacy reasons, always return an object.
286
196
  const rootConfig = rawStaticConfig || {};
287
- const staticConfig = reduceExpoObject(rawStaticConfig) || {}; // Can only change the package.json location if an app.json or app.config.json exists
197
+ const staticConfig = reduceExpoObject(rawStaticConfig) || {};
288
198
 
199
+ // Can only change the package.json location if an app.json or app.config.json exists
289
200
  const [packageJson, packageJsonPath] = getPackageJsonAndPath(projectRoot);
290
-
291
201
  function fillAndReturnConfig(config, dynamicConfigObjectType) {
292
- const configWithDefaultValues = { ...ensureConfigHasDefaultValues({
202
+ const configWithDefaultValues = {
203
+ ...ensureConfigHasDefaultValues({
293
204
  projectRoot,
294
205
  exp: config.expo,
295
206
  pkg: packageJson,
@@ -303,53 +214,46 @@ function getConfig(projectRoot, options = {}) {
303
214
  dynamicConfigPath: paths.dynamicConfigPath,
304
215
  staticConfigPath: paths.staticConfigPath
305
216
  };
306
-
307
217
  if (options.isModdedConfig) {
308
218
  var _config$mods;
309
-
310
219
  // @ts-ignore: Add the mods back to the object.
311
220
  configWithDefaultValues.exp.mods = (_config$mods = config.mods) !== null && _config$mods !== void 0 ? _config$mods : null;
312
- } // Apply static json plugins, should be done after _internal
313
-
221
+ }
314
222
 
223
+ // Apply static json plugins, should be done after _internal
315
224
  configWithDefaultValues.exp = (0, _withConfigPlugins().withConfigPlugins)(configWithDefaultValues.exp, !!options.skipPlugins);
316
-
317
225
  if (!options.isModdedConfig) {
318
226
  // @ts-ignore: Delete mods added by static plugins when they won't have a chance to be evaluated
319
227
  delete configWithDefaultValues.exp.mods;
320
228
  }
321
-
322
229
  if (options.isPublicConfig) {
323
230
  var _configWithDefaultVal, _configWithDefaultVal2, _configWithDefaultVal3, _configWithDefaultVal4;
231
+ // TODD(EvanBacon): Drop plugins array after it's been resolved.
324
232
 
325
233
  // Remove internal values with references to user's file paths from the public config.
326
234
  delete configWithDefaultValues.exp._internal;
327
-
328
235
  if (configWithDefaultValues.exp.hooks) {
329
236
  delete configWithDefaultValues.exp.hooks;
330
237
  }
331
-
332
238
  if ((_configWithDefaultVal = configWithDefaultValues.exp.ios) !== null && _configWithDefaultVal !== void 0 && _configWithDefaultVal.config) {
333
239
  delete configWithDefaultValues.exp.ios.config;
334
240
  }
335
-
336
241
  if ((_configWithDefaultVal2 = configWithDefaultValues.exp.android) !== null && _configWithDefaultVal2 !== void 0 && _configWithDefaultVal2.config) {
337
242
  delete configWithDefaultValues.exp.android.config;
338
- } // These value will be overwritten when the manifest is being served from the host (i.e. not completely accurate).
339
- // @ts-ignore: currentFullName not on type yet.
340
-
341
-
342
- configWithDefaultValues.exp.currentFullName = (0, _getFullName().getFullName)(configWithDefaultValues.exp); // @ts-ignore: originalFullName not on type yet.
243
+ }
343
244
 
245
+ // These value will be overwritten when the manifest is being served from the host (i.e. not completely accurate).
246
+ // @ts-ignore: currentFullName not on type yet.
247
+ configWithDefaultValues.exp.currentFullName = (0, _getFullName().getFullName)(configWithDefaultValues.exp);
248
+ // @ts-ignore: originalFullName not on type yet.
344
249
  configWithDefaultValues.exp.originalFullName = (0, _getFullName().getFullName)(configWithDefaultValues.exp);
345
250
  (_configWithDefaultVal3 = configWithDefaultValues.exp.updates) === null || _configWithDefaultVal3 === void 0 ? true : delete _configWithDefaultVal3.codeSigningCertificate;
346
251
  (_configWithDefaultVal4 = configWithDefaultValues.exp.updates) === null || _configWithDefaultVal4 === void 0 ? true : delete _configWithDefaultVal4.codeSigningMetadata;
347
252
  }
348
-
349
253
  return configWithDefaultValues;
350
- } // Fill in the static config
351
-
254
+ }
352
255
 
256
+ // Fill in the static config
353
257
  function getContextConfig(config) {
354
258
  return ensureConfigHasDefaultValues({
355
259
  projectRoot,
@@ -360,7 +264,6 @@ function getConfig(projectRoot, options = {}) {
360
264
  packageJsonPath
361
265
  }).exp;
362
266
  }
363
-
364
267
  if (paths.dynamicConfigPath) {
365
268
  // No app.config.json or app.json but app.config.js
366
269
  const {
@@ -371,190 +274,55 @@ function getConfig(projectRoot, options = {}) {
371
274
  staticConfigPath: paths.staticConfigPath,
372
275
  packageJsonPath,
373
276
  config: getContextConfig(staticConfig)
374
- }); // Allow for the app.config.js to `export default null;`
277
+ });
278
+ // Allow for the app.config.js to `export default null;`
375
279
  // Use `dynamicConfigPath` to detect if a dynamic config exists.
376
-
377
280
  const dynamicConfig = reduceExpoObject(rawDynamicConfig) || {};
378
281
  return fillAndReturnConfig(dynamicConfig, exportedObjectType);
379
- } // No app.config.js but json or no config
380
-
282
+ }
381
283
 
284
+ // No app.config.js but json or no config
382
285
  return fillAndReturnConfig(staticConfig || {}, null);
383
286
  }
384
-
385
287
  function getPackageJson(projectRoot) {
386
288
  const [pkg] = getPackageJsonAndPath(projectRoot);
387
289
  return pkg;
388
290
  }
389
-
390
291
  function getPackageJsonAndPath(projectRoot) {
391
292
  const packageJsonPath = (0, _resolvePackageJson().getRootPackageJsonPath)(projectRoot);
392
293
  return [_jsonFile().default.read(packageJsonPath), packageJsonPath];
393
294
  }
394
295
 
395
- function readConfigJson(projectRoot, skipValidation = false, skipSDKVersionRequirement = false) {
396
- const paths = getConfigFilePaths(projectRoot);
397
- const rawStaticConfig = paths.staticConfigPath ? (0, _getConfig().getStaticConfig)(paths.staticConfigPath) : null;
398
-
399
- const getConfigName = () => {
400
- if (paths.staticConfigPath) return ` \`${_path().default.basename(paths.staticConfigPath)}\``;
401
- return '';
402
- };
403
-
404
- let outputRootConfig = rawStaticConfig;
405
-
406
- if (outputRootConfig === null || typeof outputRootConfig !== 'object') {
407
- if (skipValidation) {
408
- outputRootConfig = {
409
- expo: {}
410
- };
411
- } else {
412
- throw new (_Errors().ConfigError)(`Project at path ${_path().default.resolve(projectRoot)} does not contain a valid Expo config${getConfigName()}`, 'NOT_OBJECT');
413
- }
414
- }
415
-
416
- let exp = outputRootConfig.expo;
417
-
418
- if (exp === null || typeof exp !== 'object') {
419
- throw new (_Errors().ConfigError)(`Property 'expo' in${getConfigName()} for project at path ${_path().default.resolve(projectRoot)} is not an object. Please make sure${getConfigName()} includes a managed Expo app config like this: ${APP_JSON_EXAMPLE}`, 'NO_EXPO');
420
- }
421
-
422
- exp = { ...exp
423
- };
424
- const [pkg, packageJsonPath] = getPackageJsonAndPath(projectRoot);
425
- return { ...ensureConfigHasDefaultValues({
426
- projectRoot,
427
- exp,
428
- pkg,
429
- skipSDKVersionRequirement,
430
- paths,
431
- packageJsonPath
432
- }),
433
- mods: null,
434
- dynamicConfigObjectType: null,
435
- rootConfig: { ...outputRootConfig
436
- },
437
- ...paths
438
- };
439
- }
440
296
  /**
441
297
  * Get the static and dynamic config paths for a project. Also accounts for custom paths.
442
298
  *
443
299
  * @param projectRoot
444
300
  */
445
-
446
-
447
301
  function getConfigFilePaths(projectRoot) {
448
- const customPaths = getCustomConfigFilePaths(projectRoot);
449
-
450
- if (customPaths) {
451
- return customPaths;
452
- }
453
-
454
302
  return {
455
303
  dynamicConfigPath: getDynamicConfigFilePath(projectRoot),
456
304
  staticConfigPath: getStaticConfigFilePath(projectRoot)
457
305
  };
458
306
  }
459
-
460
- function getCustomConfigFilePaths(projectRoot) {
461
- if (!customConfigPaths[projectRoot]) {
462
- return null;
463
- } // If the user picks a custom config path, we will only use that and skip searching for a secondary config.
464
-
465
-
466
- if (isDynamicFilePath(customConfigPaths[projectRoot])) {
467
- return {
468
- dynamicConfigPath: customConfigPaths[projectRoot],
469
- staticConfigPath: null
470
- };
471
- } // Anything that's not js or ts will be treated as json.
472
-
473
-
474
- return {
475
- staticConfigPath: customConfigPaths[projectRoot],
476
- dynamicConfigPath: null
477
- };
478
- }
479
-
480
307
  function getDynamicConfigFilePath(projectRoot) {
481
308
  for (const fileName of ['app.config.ts', 'app.config.js']) {
482
309
  const configPath = _path().default.join(projectRoot, fileName);
483
-
484
310
  if (_fs().default.existsSync(configPath)) {
485
311
  return configPath;
486
312
  }
487
313
  }
488
-
489
314
  return null;
490
315
  }
491
-
492
316
  function getStaticConfigFilePath(projectRoot) {
493
317
  for (const fileName of ['app.config.json', 'app.json']) {
494
318
  const configPath = _path().default.join(projectRoot, fileName);
495
-
496
319
  if (_fs().default.existsSync(configPath)) {
497
320
  return configPath;
498
321
  }
499
322
  }
500
-
501
323
  return null;
502
- } // TODO: This should account for dynamic configs
503
-
504
-
505
- function findConfigFile(projectRoot) {
506
- let configPath; // Check for a custom config path first.
507
-
508
- if (customConfigPaths[projectRoot]) {
509
- configPath = customConfigPaths[projectRoot]; // We shouldn't verify if the file exists because
510
- // the user manually specified that this path should be used.
511
-
512
- return {
513
- configPath,
514
- configName: _path().default.basename(configPath),
515
- configNamespace: 'expo'
516
- };
517
- } else {
518
- // app.config.json takes higher priority over app.json
519
- configPath = _path().default.join(projectRoot, 'app.config.json');
520
-
521
- if (!_fs().default.existsSync(configPath)) {
522
- configPath = _path().default.join(projectRoot, 'app.json');
523
- }
524
- }
525
-
526
- return {
527
- configPath,
528
- configName: _path().default.basename(configPath),
529
- configNamespace: 'expo'
530
- };
531
- } // TODO: deprecate
532
-
533
-
534
- function configFilename(projectRoot) {
535
- return findConfigFile(projectRoot).configName;
536
324
  }
537
325
 
538
- async function readExpRcAsync(projectRoot) {
539
- const expRcPath = _path().default.join(projectRoot, '.exprc');
540
-
541
- return await _jsonFile().default.readAsync(expRcPath, {
542
- json5: true,
543
- cantReadFileDefault: {}
544
- });
545
- }
546
-
547
- const customConfigPaths = {};
548
-
549
- function resetCustomConfigPaths() {
550
- for (const key of Object.keys(customConfigPaths)) {
551
- delete customConfigPaths[key];
552
- }
553
- }
554
-
555
- function setCustomConfigPath(projectRoot, configPath) {
556
- customConfigPaths[projectRoot] = configPath;
557
- }
558
326
  /**
559
327
  * Attempt to modify an Expo project config.
560
328
  * This will only fully work if the project is using static configs only.
@@ -566,14 +334,10 @@ function setCustomConfigPath(projectRoot, configPath) {
566
334
  * @param readOptions options for reading the current config file
567
335
  * @param writeOptions If true, the static config file will not be rewritten
568
336
  */
569
-
570
-
571
337
  async function modifyConfigAsync(projectRoot, modifications, readOptions = {}, writeOptions = {}) {
572
338
  const config = getConfig(projectRoot, readOptions);
573
-
574
339
  if (config.dynamicConfigPath) {
575
340
  // We cannot automatically write to a dynamic config.
576
-
577
341
  /* Currently we should just use the safest approach possible, informing the user that they'll need to manually modify their dynamic config.
578
342
  if (config.staticConfigPath) {
579
343
  // Both a dynamic and a static config exist.
@@ -592,48 +356,39 @@ async function modifyConfigAsync(projectRoot, modifications, readOptions = {}, w
592
356
  };
593
357
  } else if (config.staticConfigPath) {
594
358
  // Static with no dynamic config, this means we can append to the config automatically.
595
- let outputConfig; // If the config has an expo object (app.json) then append the options to that object.
596
-
359
+ let outputConfig;
360
+ // If the config has an expo object (app.json) then append the options to that object.
597
361
  if (config.rootConfig.expo) {
598
- outputConfig = { ...config.rootConfig,
599
- expo: { ...config.rootConfig.expo,
362
+ outputConfig = {
363
+ ...config.rootConfig,
364
+ expo: {
365
+ ...config.rootConfig.expo,
600
366
  ...modifications
601
367
  }
602
368
  };
603
369
  } else {
604
370
  // Otherwise (app.config.json) just add the config modification to the top most level.
605
- outputConfig = { ...config.rootConfig,
371
+ outputConfig = {
372
+ ...config.rootConfig,
606
373
  ...modifications
607
374
  };
608
375
  }
609
-
610
376
  if (!writeOptions.dryRun) {
611
377
  await _jsonFile().default.writeAsync(config.staticConfigPath, outputConfig, {
612
378
  json5: false
613
379
  });
614
380
  }
615
-
616
381
  return {
617
382
  type: 'success',
618
383
  config: outputConfig
619
384
  };
620
385
  }
621
-
622
386
  return {
623
387
  type: 'fail',
624
388
  message: 'No config exists',
625
389
  config: null
626
390
  };
627
391
  }
628
-
629
- const APP_JSON_EXAMPLE = JSON.stringify({
630
- expo: {
631
- name: 'My app',
632
- slug: 'my-app',
633
- sdkVersion: '...'
634
- }
635
- });
636
-
637
392
  function ensureConfigHasDefaultValues({
638
393
  projectRoot,
639
394
  exp,
@@ -643,114 +398,74 @@ function ensureConfigHasDefaultValues({
643
398
  skipSDKVersionRequirement = false
644
399
  }) {
645
400
  var _exp$name, _exp$slug, _exp$version;
646
-
647
401
  if (!exp) {
648
402
  exp = {};
649
403
  }
650
-
651
404
  exp = (0, _withInternal().withInternal)(exp, {
652
405
  projectRoot,
653
406
  ...(paths !== null && paths !== void 0 ? paths : {}),
654
407
  packageJsonPath
655
- }); // Defaults for package.json fields
656
-
408
+ });
409
+ // Defaults for package.json fields
657
410
  const pkgName = typeof pkg.name === 'string' ? pkg.name : _path().default.basename(projectRoot);
658
411
  const pkgVersion = typeof pkg.version === 'string' ? pkg.version : '1.0.0';
659
- const pkgWithDefaults = { ...pkg,
412
+ const pkgWithDefaults = {
413
+ ...pkg,
660
414
  name: pkgName,
661
415
  version: pkgVersion
662
- }; // Defaults for app.json/app.config.js fields
416
+ };
663
417
 
418
+ // Defaults for app.json/app.config.js fields
664
419
  const name = (_exp$name = exp.name) !== null && _exp$name !== void 0 ? _exp$name : pkgName;
665
420
  const slug = (_exp$slug = exp.slug) !== null && _exp$slug !== void 0 ? _exp$slug : (0, _slugify().default)(name.toLowerCase());
666
421
  const version = (_exp$version = exp.version) !== null && _exp$version !== void 0 ? _exp$version : pkgVersion;
667
422
  let description = exp.description;
668
-
669
423
  if (!description && typeof pkg.description === 'string') {
670
424
  description = pkg.description;
671
425
  }
672
-
673
- const expWithDefaults = { ...exp,
426
+ const expWithDefaults = {
427
+ ...exp,
674
428
  name,
675
429
  slug,
676
430
  version,
677
431
  description
678
432
  };
679
433
  let sdkVersion;
680
-
681
434
  try {
682
- sdkVersion = (0, _Project().getExpoSDKVersion)(projectRoot, expWithDefaults);
435
+ sdkVersion = (0, _getExpoSDKVersion().getExpoSDKVersion)(projectRoot, expWithDefaults);
683
436
  } catch (error) {
684
437
  if (!skipSDKVersionRequirement) throw error;
685
438
  }
686
-
687
439
  let platforms = exp.platforms;
688
-
689
440
  if (!platforms) {
690
441
  platforms = getSupportedPlatforms(projectRoot);
691
442
  }
692
-
693
443
  return {
694
- exp: { ...expWithDefaults,
444
+ exp: {
445
+ ...expWithDefaults,
695
446
  sdkVersion,
696
447
  platforms
697
448
  },
698
449
  pkg: pkgWithDefaults
699
450
  };
700
451
  }
701
-
702
- async function writeConfigJsonAsync(projectRoot, options) {
703
- const paths = getConfigFilePaths(projectRoot);
704
- let {
705
- exp,
706
- pkg,
707
- rootConfig,
708
- dynamicConfigObjectType
709
- } = readConfigJson(projectRoot);
710
- exp = { ...rootConfig.expo,
711
- ...options
712
- };
713
- rootConfig = { ...rootConfig,
714
- expo: exp
715
- };
716
-
717
- if (paths.staticConfigPath) {
718
- await _jsonFile().default.writeAsync(paths.staticConfigPath, rootConfig, {
719
- json5: false
720
- });
721
- } else {
722
- console.log('Failed to write to config: ', options);
723
- }
724
-
725
- return {
726
- exp,
727
- pkg,
728
- rootConfig,
729
- dynamicConfigObjectType,
730
- ...paths
731
- };
732
- }
733
-
734
452
  const DEFAULT_BUILD_PATH = `web-build`;
735
-
736
453
  function getWebOutputPath(config = {}) {
737
454
  var _expo$web, _expo$web$build;
738
-
739
455
  if (process.env.WEBPACK_BUILD_OUTPUT_PATH) {
740
456
  return process.env.WEBPACK_BUILD_OUTPUT_PATH;
741
457
  }
742
-
743
458
  const expo = config.expo || config || {};
744
459
  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;
745
460
  }
746
-
747
461
  function getNameFromConfig(exp = {}) {
748
462
  // For RN CLI support
749
463
  const appManifest = exp.expo || exp;
750
464
  const {
751
465
  web = {}
752
- } = appManifest; // rn-cli apps use a displayName value as well.
466
+ } = appManifest;
753
467
 
468
+ // rn-cli apps use a displayName value as well.
754
469
  const appName = exp.displayName || appManifest.displayName || appManifest.name;
755
470
  const webName = web.name || appName;
756
471
  return {
@@ -758,58 +473,42 @@ function getNameFromConfig(exp = {}) {
758
473
  webName
759
474
  };
760
475
  }
761
-
762
476
  function getDefaultTarget(projectRoot, exp) {
763
477
  var _exp;
764
-
765
478
  (_exp = exp) !== null && _exp !== void 0 ? _exp : exp = getConfig(projectRoot, {
766
479
  skipSDKVersionRequirement: true
767
- }).exp; // before SDK 37, always default to managed to preserve previous behavior
480
+ }).exp;
768
481
 
482
+ // before SDK 37, always default to managed to preserve previous behavior
769
483
  if (exp.sdkVersion && exp.sdkVersion !== 'UNVERSIONED' && _semver().default.lt(exp.sdkVersion, '37.0.0')) {
770
484
  return 'managed';
771
485
  }
772
-
773
486
  return isBareWorkflowProject(projectRoot) ? 'bare' : 'managed';
774
487
  }
775
-
776
488
  function isBareWorkflowProject(projectRoot) {
777
489
  const [pkg] = getPackageJsonAndPath(projectRoot);
778
490
 
491
+ // TODO: Drop this
779
492
  if (pkg.dependencies && pkg.dependencies.expokit) {
780
493
  return false;
781
494
  }
782
-
783
495
  const xcodeprojFiles = (0, _glob().sync)('ios/**/*.xcodeproj', {
784
496
  absolute: true,
785
497
  cwd: projectRoot
786
498
  });
787
-
788
499
  if (xcodeprojFiles.length) {
789
500
  return true;
790
501
  }
791
-
792
502
  const gradleFiles = (0, _glob().sync)('android/**/*.gradle', {
793
503
  absolute: true,
794
504
  cwd: projectRoot
795
505
  });
796
-
797
506
  if (gradleFiles.length) {
798
507
  return true;
799
508
  }
800
-
801
509
  return false;
802
510
  }
803
- /**
804
- * true if the file is .js or .ts
805
- *
806
- * @param filePath
807
- */
808
511
 
809
-
810
- function isDynamicFilePath(filePath) {
811
- return !!filePath.match(/\.[j|t]s$/);
812
- }
813
512
  /**
814
513
  * Return a useful name describing the project config.
815
514
  * - dynamic: app.config.js
@@ -817,12 +516,11 @@ function isDynamicFilePath(filePath) {
817
516
  * - custom path app config relative to root folder
818
517
  * - both: app.config.js or app.json
819
518
  */
820
-
821
-
822
519
  function getProjectConfigDescription(projectRoot) {
823
520
  const paths = getConfigFilePaths(projectRoot);
824
521
  return getProjectConfigDescriptionWithPaths(projectRoot, paths);
825
522
  }
523
+
826
524
  /**
827
525
  * Returns a string describing the configurations used for the given project root.
828
526
  * Will return null if no config is found.
@@ -830,22 +528,17 @@ function getProjectConfigDescription(projectRoot) {
830
528
  * @param projectRoot
831
529
  * @param projectConfig
832
530
  */
833
-
834
-
835
531
  function getProjectConfigDescriptionWithPaths(projectRoot, projectConfig) {
836
532
  if (projectConfig.dynamicConfigPath) {
837
533
  const relativeDynamicConfigPath = _path().default.relative(projectRoot, projectConfig.dynamicConfigPath);
838
-
839
534
  if (projectConfig.staticConfigPath) {
840
535
  return `${relativeDynamicConfigPath} or ${_path().default.relative(projectRoot, projectConfig.staticConfigPath)}`;
841
536
  }
842
-
843
537
  return relativeDynamicConfigPath;
844
538
  } else if (projectConfig.staticConfigPath) {
845
539
  return _path().default.relative(projectRoot, projectConfig.staticConfigPath);
846
- } // If a config doesn't exist, our tooling will generate a static app.json
847
-
848
-
540
+ }
541
+ // If a config doesn't exist, our tooling will generate a static app.json
849
542
  return 'app.json';
850
543
  }
851
544
  //# sourceMappingURL=Config.js.map