@expo/cli 0.2.6 → 0.2.9

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 (43) hide show
  1. package/build/bin/cli +2 -2
  2. package/build/src/install/checkPackages.js +2 -2
  3. package/build/src/install/checkPackages.js.map +1 -1
  4. package/build/src/prebuild/clearNativeFolder.js +5 -2
  5. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  6. package/build/src/register/registerAsync.js +2 -2
  7. package/build/src/register/registerAsync.js.map +1 -1
  8. package/build/src/run/hints.js +2 -2
  9. package/build/src/run/hints.js.map +1 -1
  10. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +2 -2
  11. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
  12. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +2 -2
  13. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
  14. package/build/src/run/startBundler.js +2 -2
  15. package/build/src/run/startBundler.js.map +1 -1
  16. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +2 -2
  17. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  18. package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
  19. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  20. package/build/src/start/platforms/PlatformManager.js +1 -1
  21. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  22. package/build/src/start/platforms/ios/AppleDeviceManager.js +12 -1
  23. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  24. package/build/src/start/server/DevelopmentSession.js +11 -6
  25. package/build/src/start/server/DevelopmentSession.js.map +1 -1
  26. package/build/src/start/server/UrlCreator.js +7 -2
  27. package/build/src/start/server/UrlCreator.js.map +1 -1
  28. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  29. package/build/src/start/startAsync.js +8 -8
  30. package/build/src/start/startAsync.js.map +1 -1
  31. package/build/src/utils/analytics/rudderstackClient.js +24 -38
  32. package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
  33. package/build/src/utils/env.js +16 -0
  34. package/build/src/utils/env.js.map +1 -1
  35. package/build/src/utils/git.js +2 -1
  36. package/build/src/utils/git.js.map +1 -1
  37. package/build/src/utils/interactive.js +11 -0
  38. package/build/src/utils/interactive.js.map +1 -0
  39. package/build/src/utils/ora.js +2 -1
  40. package/build/src/utils/ora.js.map +1 -1
  41. package/build/src/utils/prompts.js +2 -2
  42. package/build/src/utils/prompts.js.map +1 -1
  43. package/package.json +5 -5
package/build/bin/cli CHANGED
@@ -121,7 +121,7 @@ const args = (0, _arg).default({
121
121
  });
122
122
  if (args["--version"]) {
123
123
  // Version is added in the build script.
124
- console.log("0.2.6");
124
+ console.log("0.2.9");
125
125
  process.exit(0);
126
126
  }
127
127
  if (args["--non-interactive"]) {
@@ -248,7 +248,7 @@ commands[command]().then((exec)=>{
248
248
  logEventAsync("action", {
249
249
  action: `expo ${command}`,
250
250
  source: "expo/cli",
251
- source_version: "0.2.6"
251
+ source_version: "0.2.9"
252
252
  });
253
253
  });
254
254
 
@@ -7,7 +7,7 @@ var _config = require("@expo/config");
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var Log = _interopRequireWildcard(require("../log"));
9
9
  var _validateDependenciesVersions = require("../start/doctor/dependencies/validateDependenciesVersions");
10
- var _env = require("../utils/env");
10
+ var _interactive = require("../utils/interactive");
11
11
  var _prompts = require("../utils/prompts");
12
12
  var _installAsync = require("./installAsync");
13
13
  function _interopRequireDefault(obj) {
@@ -51,7 +51,7 @@ async function checkPackagesAsync(projectRoot, { packages , packageManager , opt
51
51
  (0, _validateDependenciesVersions).logIncorrectDependencies(dependencies);
52
52
  const value = // If `--fix` then always fix.
53
53
  fix || // Otherwise prompt to fix when not running in CI.
54
- (!_env.env.CI && await (0, _prompts).confirmAsync({
54
+ ((0, _interactive).isInteractive() && await (0, _prompts).confirmAsync({
55
55
  message: "Fix dependencies?"
56
56
  }).catch(()=>false
57
57
  ));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/install/checkPackages.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport {\n getVersionedDependenciesAsync,\n logIncorrectDependencies,\n} from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { env } from '../utils/env';\nimport { confirmAsync } from '../utils/prompts';\nimport { installPackagesAsync } from './installAsync';\nimport { Options } from './resolveOptions';\n\nconst debug = require('debug')('expo:install:check') as typeof console.log;\n\n// Exposed for testing.\nexport async function checkPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n options: { fix },\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager:\n | PackageManager.NpmPackageManager\n | PackageManager.YarnPackageManager\n | PackageManager.PnpmPackageManager;\n\n /** How the check should resolve */\n options: Pick<Options, 'fix'>;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n) {\n // Read the project Expo config without plugins.\n const { exp, pkg } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n const dependencies = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packages);\n\n if (!dependencies.length) {\n Log.exit(chalk.greenBright('Dependencies are up to date'), 0);\n }\n\n logIncorrectDependencies(dependencies);\n\n const value =\n // If `--fix` then always fix.\n fix ||\n // Otherwise prompt to fix when not running in CI.\n (!env.CI && (await confirmAsync({ message: 'Fix dependencies?' }).catch(() => false)));\n\n if (value) {\n // Just pass in the names, the install function will resolve the versions again.\n const fixedDependencies = dependencies.map((dependency) => dependency.packageName);\n debug('Installing fixed dependencies:', fixedDependencies);\n // Install the corrected dependencies.\n return installPackagesAsync(projectRoot, {\n packageManager,\n packages: fixedDependencies,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n }\n // Exit with non-zero exit code if any of the dependencies are out of date.\n Log.exit(chalk.red('Found outdated dependencies'), 1);\n}\n"],"names":["checkPackagesAsync","Log","debug","require","projectRoot","packages","packageManager","options","fix","packageManagerArguments","exp","pkg","getConfig","skipPlugins","dependencies","getVersionedDependenciesAsync","length","exit","chalk","greenBright","logIncorrectDependencies","value","env","CI","confirmAsync","message","catch","fixedDependencies","map","dependency","packageName","installPackagesAsync","sdkVersion","red"],"mappings":"AAAA;;;;QAiBsBA,kBAAkB,GAAlBA,kBAAkB;AAjBd,IAAA,OAAc,WAAd,cAAc,CAAA;AAEtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAIR,IAAA,6BAA2D,WAA3D,2DAA2D,CAAA;AAC9C,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACV,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAGpE,eAAeH,kBAAkB,CACtCI,WAAmB,EACnB,EACEC,QAAQ,CAAA,EACRC,cAAc,CAAA,EACdC,OAAO,EAAE,EAAEC,GAAG,CAAA,EAAE,CAAA,EAChBC,uBAAuB,CAAA,EAoBxB,EACD;IACA,gDAAgD;IAChD,MAAM,EAAEC,GAAG,CAAA,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAI5B,CAAA,UAJ4B,CAACR,WAAW,EAAE;QAC1C,iFAAiF;QACjF,yEAAyE;QACzES,WAAW,EAAE,IAAI;KAClB,CAAC,AAAC;IAEH,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,6BAA6B,AAAiC,CAAA,8BAAjC,CAACX,WAAW,EAAEM,GAAG,EAAEC,GAAG,EAAEN,QAAQ,CAAC,AAAC;IAE1F,IAAI,CAACS,YAAY,CAACE,MAAM,EAAE;QACxBf,GAAG,CAACgB,IAAI,CAACC,MAAK,QAAA,CAACC,WAAW,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;KAC/D;IAEDC,CAAAA,GAAAA,6BAAwB,AAAc,CAAA,yBAAd,CAACN,YAAY,CAAC,CAAC;IAEvC,MAAMO,KAAK,GACT,8BAA8B;IAC9Bb,GAAG,IACH,kDAAkD;IAClD,CAAC,CAACc,IAAG,IAAA,CAACC,EAAE,IAAK,MAAMC,CAAAA,GAAAA,QAAY,AAAkC,CAAA,aAAlC,CAAC;QAAEC,OAAO,EAAE,mBAAmB;KAAE,CAAC,CAACC,KAAK,CAAC,IAAM,KAAK;IAAA,CAAC,AAAC,CAAC,AAAC;IAEzF,IAAIL,KAAK,EAAE;QACT,gFAAgF;QAChF,MAAMM,iBAAiB,GAAGb,YAAY,CAACc,GAAG,CAAC,CAACC,UAAU,GAAKA,UAAU,CAACC,WAAW;QAAA,CAAC,AAAC;QACnF5B,KAAK,CAAC,gCAAgC,EAAEyB,iBAAiB,CAAC,CAAC;QAC3D,sCAAsC;QACtC,OAAOI,CAAAA,GAAAA,aAAoB,AAKzB,CAAA,qBALyB,CAAC3B,WAAW,EAAE;YACvCE,cAAc;YACdD,QAAQ,EAAEsB,iBAAiB;YAC3BlB,uBAAuB;YACvBuB,UAAU,EAAEtB,GAAG,CAACsB,UAAU;SAC3B,CAAC,CAAC;KACJ;IACD,2EAA2E;IAC3E/B,GAAG,CAACgB,IAAI,CAACC,MAAK,QAAA,CAACe,GAAG,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;CACvD"}
1
+ {"version":3,"sources":["../../../src/install/checkPackages.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport {\n getVersionedDependenciesAsync,\n logIncorrectDependencies,\n} from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { isInteractive } from '../utils/interactive';\nimport { confirmAsync } from '../utils/prompts';\nimport { installPackagesAsync } from './installAsync';\nimport { Options } from './resolveOptions';\n\nconst debug = require('debug')('expo:install:check') as typeof console.log;\n\n// Exposed for testing.\nexport async function checkPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n options: { fix },\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager:\n | PackageManager.NpmPackageManager\n | PackageManager.YarnPackageManager\n | PackageManager.PnpmPackageManager;\n\n /** How the check should resolve */\n options: Pick<Options, 'fix'>;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n) {\n // Read the project Expo config without plugins.\n const { exp, pkg } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n const dependencies = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packages);\n\n if (!dependencies.length) {\n Log.exit(chalk.greenBright('Dependencies are up to date'), 0);\n }\n\n logIncorrectDependencies(dependencies);\n\n const value =\n // If `--fix` then always fix.\n fix ||\n // Otherwise prompt to fix when not running in CI.\n (isInteractive() && (await confirmAsync({ message: 'Fix dependencies?' }).catch(() => false)));\n\n if (value) {\n // Just pass in the names, the install function will resolve the versions again.\n const fixedDependencies = dependencies.map((dependency) => dependency.packageName);\n debug('Installing fixed dependencies:', fixedDependencies);\n // Install the corrected dependencies.\n return installPackagesAsync(projectRoot, {\n packageManager,\n packages: fixedDependencies,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n }\n // Exit with non-zero exit code if any of the dependencies are out of date.\n Log.exit(chalk.red('Found outdated dependencies'), 1);\n}\n"],"names":["checkPackagesAsync","Log","debug","require","projectRoot","packages","packageManager","options","fix","packageManagerArguments","exp","pkg","getConfig","skipPlugins","dependencies","getVersionedDependenciesAsync","length","exit","chalk","greenBright","logIncorrectDependencies","value","isInteractive","confirmAsync","message","catch","fixedDependencies","map","dependency","packageName","installPackagesAsync","sdkVersion","red"],"mappings":"AAAA;;;;QAiBsBA,kBAAkB,GAAlBA,kBAAkB;AAjBd,IAAA,OAAc,WAAd,cAAc,CAAA;AAEtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAIR,IAAA,6BAA2D,WAA3D,2DAA2D,CAAA;AACpC,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACV,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAGpE,eAAeH,kBAAkB,CACtCI,WAAmB,EACnB,EACEC,QAAQ,CAAA,EACRC,cAAc,CAAA,EACdC,OAAO,EAAE,EAAEC,GAAG,CAAA,EAAE,CAAA,EAChBC,uBAAuB,CAAA,EAoBxB,EACD;IACA,gDAAgD;IAChD,MAAM,EAAEC,GAAG,CAAA,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAI5B,CAAA,UAJ4B,CAACR,WAAW,EAAE;QAC1C,iFAAiF;QACjF,yEAAyE;QACzES,WAAW,EAAE,IAAI;KAClB,CAAC,AAAC;IAEH,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,6BAA6B,AAAiC,CAAA,8BAAjC,CAACX,WAAW,EAAEM,GAAG,EAAEC,GAAG,EAAEN,QAAQ,CAAC,AAAC;IAE1F,IAAI,CAACS,YAAY,CAACE,MAAM,EAAE;QACxBf,GAAG,CAACgB,IAAI,CAACC,MAAK,QAAA,CAACC,WAAW,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;KAC/D;IAEDC,CAAAA,GAAAA,6BAAwB,AAAc,CAAA,yBAAd,CAACN,YAAY,CAAC,CAAC;IAEvC,MAAMO,KAAK,GACT,8BAA8B;IAC9Bb,GAAG,IACH,kDAAkD;IAClD,CAACc,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,IAAK,MAAMC,CAAAA,GAAAA,QAAY,AAAkC,CAAA,aAAlC,CAAC;QAAEC,OAAO,EAAE,mBAAmB;KAAE,CAAC,CAACC,KAAK,CAAC,IAAM,KAAK;IAAA,CAAC,AAAC,CAAC,AAAC;IAEjG,IAAIJ,KAAK,EAAE;QACT,gFAAgF;QAChF,MAAMK,iBAAiB,GAAGZ,YAAY,CAACa,GAAG,CAAC,CAACC,UAAU,GAAKA,UAAU,CAACC,WAAW;QAAA,CAAC,AAAC;QACnF3B,KAAK,CAAC,gCAAgC,EAAEwB,iBAAiB,CAAC,CAAC;QAC3D,sCAAsC;QACtC,OAAOI,CAAAA,GAAAA,aAAoB,AAKzB,CAAA,qBALyB,CAAC1B,WAAW,EAAE;YACvCE,cAAc;YACdD,QAAQ,EAAEqB,iBAAiB;YAC3BjB,uBAAuB;YACvBsB,UAAU,EAAErB,GAAG,CAACqB,UAAU;SAC3B,CAAC,CAAC;KACJ;IACD,2EAA2E;IAC3E9B,GAAG,CAACgB,IAAI,CAACC,MAAK,QAAA,CAACc,GAAG,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC,CAAC;CACvD"}
@@ -13,7 +13,7 @@ var _fs = _interopRequireDefault(require("fs"));
13
13
  var _path = _interopRequireDefault(require("path"));
14
14
  var Log = _interopRequireWildcard(require("../log"));
15
15
  var _dir = require("../utils/dir");
16
- var _env = require("../utils/env");
16
+ var _interactive = require("../utils/interactive");
17
17
  var _ora = require("../utils/ora");
18
18
  var _prompts = require("../utils/prompts");
19
19
  function _interopRequireDefault(obj) {
@@ -122,11 +122,14 @@ async function promptToClearMalformedNativeProjectsAsync(projectRoot, checkPlatf
122
122
  const message = platforms.length > 1 ? `The ${displayPlatforms[0]} and ${displayPlatforms[1]} projects are malformed` : `The ${displayPlatforms[0]} project is malformed`;
123
123
  if (// If the process is non-interactive, default to clearing the malformed native project.
124
124
  // This would only happen on re-running eject.
125
- _env.env.CI || // Prompt to clear the native folders.
125
+ !(0, _interactive).isInteractive() || // Prompt to clear the native folders.
126
126
  (await (0, _prompts).confirmAsync({
127
127
  message: `${message}, would you like to clear the project files and reinitialize them?`,
128
128
  initial: true
129
129
  }))) {
130
+ if (!(0, _interactive).isInteractive()) {
131
+ Log.warn(`${message}, project files will be cleared and reinitialized.`);
132
+ }
130
133
  await clearNativeFolder(projectRoot, platforms);
131
134
  } else {
132
135
  // Warn the user that the process may fail.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/clearNativeFolder.ts"],"sourcesContent":["import { AndroidConfig, IOSConfig, ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { directoryExistsAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { logNewSection } from '../utils/ora';\nimport { confirmAsync } from '../utils/prompts';\n\n/** Delete the input native folders and print a loading step. */\nexport async function clearNativeFolder(projectRoot: string, folders: string[]) {\n const step = logNewSection(`Clearing ${folders.join(', ')}`);\n try {\n await Promise.all(\n folders.map((folderName) =>\n fs.promises.rm(path.join(projectRoot, folderName), {\n recursive: true,\n force: true,\n })\n )\n );\n step.succeed(`Cleared ${folders.join(', ')} code`);\n } catch (error: any) {\n step.fail(`Failed to delete ${folders.join(', ')} code: ${error.message}`);\n throw error;\n }\n}\n\n/**\n * Returns `true` if a certain subset of required Android project files are intact.\n *\n * This isn't perfect but it serves the purpose of indicating that the user should\n * be warned to nuke the project files, most commonly when git is cleared and the root folder\n * remains in memory.\n */\nexport async function hasRequiredAndroidFilesAsync(projectRoot: string): Promise<boolean> {\n try {\n await Promise.all([\n AndroidConfig.Paths.getAppBuildGradleAsync(projectRoot),\n AndroidConfig.Paths.getProjectBuildGradleAsync(projectRoot),\n AndroidConfig.Paths.getAndroidManifestAsync(projectRoot),\n AndroidConfig.Paths.getMainApplicationAsync(projectRoot),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Returns `true` if a certain subset of required iOS project files are intact. */\nexport async function hasRequiredIOSFilesAsync(projectRoot: string) {\n try {\n // If any of the following required files are missing, then the project is malformed.\n await Promise.all([\n IOSConfig.Paths.getAppDelegate(projectRoot),\n IOSConfig.Paths.getAllXcodeProjectPaths(projectRoot),\n IOSConfig.Paths.getAllInfoPlistPaths(projectRoot),\n IOSConfig.Paths.getAllPBXProjectPaths(projectRoot),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Filter out platforms that do not have an existing platform folder.\n * If the user wants to validate that neither of ['ios', 'android'] are malformed then we should\n * first check that both `ios` and `android` folders exist.\n *\n * This optimization prevents us from prompting to clear a \"malformed\" project that doesn't exist yet.\n */\nasync function filterPlatformsThatDoNotExistAsync(\n projectRoot: string,\n platforms: ModPlatform[]\n): Promise<ModPlatform[]> {\n const valid = await Promise.all(\n platforms.map(async (platform) => {\n if (await directoryExistsAsync(path.join(projectRoot, platform))) {\n return platform;\n }\n return null;\n })\n );\n return valid.filter(Boolean) as ModPlatform[];\n}\n\n/** Get a list of native platforms that have existing directories which contain malformed projects. */\nexport async function getMalformedNativeProjectsAsync(\n projectRoot: string,\n platforms: ModPlatform[]\n): Promise<ModPlatform[]> {\n const VERIFIERS: Record<ModPlatform, (root: string) => Promise<boolean>> = {\n android: hasRequiredAndroidFilesAsync,\n ios: hasRequiredIOSFilesAsync,\n };\n\n const checkPlatforms = await filterPlatformsThatDoNotExistAsync(projectRoot, platforms);\n return (\n await Promise.all(\n checkPlatforms.map(async (platform) => {\n if (await VERIFIERS[platform](projectRoot)) {\n return false;\n }\n return platform;\n })\n )\n ).filter(Boolean) as ModPlatform[];\n}\n\nexport async function promptToClearMalformedNativeProjectsAsync(\n projectRoot: string,\n checkPlatforms: ModPlatform[]\n) {\n const platforms = await getMalformedNativeProjectsAsync(projectRoot, checkPlatforms);\n\n if (!platforms.length) {\n return;\n }\n\n const displayPlatforms = platforms.map((platform) => chalk.cyan(platform));\n // Prompt which platforms to reset.\n const message =\n platforms.length > 1\n ? `The ${displayPlatforms[0]} and ${displayPlatforms[1]} projects are malformed`\n : `The ${displayPlatforms[0]} project is malformed`;\n\n if (\n // If the process is non-interactive, default to clearing the malformed native project.\n // This would only happen on re-running eject.\n env.CI ||\n // Prompt to clear the native folders.\n (await confirmAsync({\n message: `${message}, would you like to clear the project files and reinitialize them?`,\n initial: true,\n }))\n ) {\n await clearNativeFolder(projectRoot, platforms);\n } else {\n // Warn the user that the process may fail.\n Log.warn('Continuing with malformed native projects');\n }\n}\n"],"names":["clearNativeFolder","hasRequiredAndroidFilesAsync","hasRequiredIOSFilesAsync","getMalformedNativeProjectsAsync","promptToClearMalformedNativeProjectsAsync","Log","projectRoot","folders","step","logNewSection","join","Promise","all","map","folderName","fs","promises","rm","path","recursive","force","succeed","error","fail","message","AndroidConfig","Paths","getAppBuildGradleAsync","getProjectBuildGradleAsync","getAndroidManifestAsync","getMainApplicationAsync","IOSConfig","getAppDelegate","getAllXcodeProjectPaths","getAllInfoPlistPaths","getAllPBXProjectPaths","filterPlatformsThatDoNotExistAsync","platforms","valid","platform","directoryExistsAsync","filter","Boolean","VERIFIERS","android","ios","checkPlatforms","length","displayPlatforms","chalk","cyan","env","CI","confirmAsync","initial","warn"],"mappings":"AAAA;;;;QAYsBA,iBAAiB,GAAjBA,iBAAiB;QAyBjBC,4BAA4B,GAA5BA,4BAA4B;QAe5BC,wBAAwB,GAAxBA,wBAAwB;QAsCxBC,+BAA+B,GAA/BA,+BAA+B;QAsB/BC,yCAAyC,G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C,CAAC,CAAC,qBAAqB,CAAC,AAAC;IAExD,IACE,uFAAuF;IACvF,8CAA8C;IAC9CG,IAAG,IAAA,CAACC,EAAE,IACN,sCAAsC;IACtC,CAAC,MAAMC,CAAAA,GAAAA,QAAY,AAGjB,CAAA,aAHiB,CAAC;QAClB7B,OAAO,EAAE,CAAC,EAAEA,OAAO,CAAC,kEAAkE,CAAC;QACvF8B,OAAO,EAAE,IAAI;KACd,CAAC,CAAC,EACH;QACA,MAAMtD,iBAAiB,CAACM,WAAW,EAAE+B,SAAS,CAAC,CAAC;KACjD,MAAM;QACL,2CAA2C;QAC3ChC,GAAG,CAACkD,IAAI,CAAC,2CAA2C,CAAC,CAAC;KACvD;CACF"}
1
+ {"version":3,"sources":["../../../src/prebuild/clearNativeFolder.ts"],"sourcesContent":["import { AndroidConfig, IOSConfig, ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { directoryExistsAsync } from '../utils/dir';\nimport { isInteractive } from '../utils/interactive';\nimport { logNewSection } from '../utils/ora';\nimport { confirmAsync } from '../utils/prompts';\n\n/** Delete the input native folders and print a loading step. */\nexport async function clearNativeFolder(projectRoot: string, folders: string[]) {\n const step = logNewSection(`Clearing ${folders.join(', ')}`);\n try {\n await Promise.all(\n folders.map((folderName) =>\n fs.promises.rm(path.join(projectRoot, folderName), {\n recursive: true,\n force: true,\n })\n )\n );\n step.succeed(`Cleared ${folders.join(', ')} code`);\n } catch (error: any) {\n step.fail(`Failed to delete ${folders.join(', ')} code: ${error.message}`);\n throw error;\n }\n}\n\n/**\n * Returns `true` if a certain subset of required Android project files are intact.\n *\n * This isn't perfect but it serves the purpose of indicating that the user should\n * be warned to nuke the project files, most commonly when git is cleared and the root folder\n * remains in memory.\n */\nexport async function hasRequiredAndroidFilesAsync(projectRoot: string): Promise<boolean> {\n try {\n await Promise.all([\n AndroidConfig.Paths.getAppBuildGradleAsync(projectRoot),\n AndroidConfig.Paths.getProjectBuildGradleAsync(projectRoot),\n AndroidConfig.Paths.getAndroidManifestAsync(projectRoot),\n AndroidConfig.Paths.getMainApplicationAsync(projectRoot),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Returns `true` if a certain subset of required iOS project files are intact. */\nexport async function hasRequiredIOSFilesAsync(projectRoot: string) {\n try {\n // If any of the following required files are missing, then the project is malformed.\n await Promise.all([\n IOSConfig.Paths.getAppDelegate(projectRoot),\n IOSConfig.Paths.getAllXcodeProjectPaths(projectRoot),\n IOSConfig.Paths.getAllInfoPlistPaths(projectRoot),\n IOSConfig.Paths.getAllPBXProjectPaths(projectRoot),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Filter out platforms that do not have an existing platform folder.\n * If the user wants to validate that neither of ['ios', 'android'] are malformed then we should\n * first check that both `ios` and `android` folders exist.\n *\n * This optimization prevents us from prompting to clear a \"malformed\" project that doesn't exist yet.\n */\nasync function filterPlatformsThatDoNotExistAsync(\n projectRoot: string,\n platforms: ModPlatform[]\n): Promise<ModPlatform[]> {\n const valid = await Promise.all(\n platforms.map(async (platform) => {\n if (await directoryExistsAsync(path.join(projectRoot, platform))) {\n return platform;\n }\n return null;\n })\n );\n return valid.filter(Boolean) as ModPlatform[];\n}\n\n/** Get a list of native platforms that have existing directories which contain malformed projects. */\nexport async function getMalformedNativeProjectsAsync(\n projectRoot: string,\n platforms: ModPlatform[]\n): Promise<ModPlatform[]> {\n const VERIFIERS: Record<ModPlatform, (root: string) => Promise<boolean>> = {\n android: hasRequiredAndroidFilesAsync,\n ios: hasRequiredIOSFilesAsync,\n };\n\n const checkPlatforms = await filterPlatformsThatDoNotExistAsync(projectRoot, platforms);\n return (\n await Promise.all(\n checkPlatforms.map(async (platform) => {\n if (await VERIFIERS[platform](projectRoot)) {\n return false;\n }\n return platform;\n })\n )\n ).filter(Boolean) as ModPlatform[];\n}\n\nexport async function promptToClearMalformedNativeProjectsAsync(\n projectRoot: string,\n checkPlatforms: ModPlatform[]\n) {\n const platforms = await getMalformedNativeProjectsAsync(projectRoot, checkPlatforms);\n\n if (!platforms.length) {\n return;\n }\n\n const displayPlatforms = platforms.map((platform) => chalk.cyan(platform));\n // Prompt which platforms to reset.\n const message =\n platforms.length > 1\n ? `The ${displayPlatforms[0]} and ${displayPlatforms[1]} projects are malformed`\n : `The ${displayPlatforms[0]} project is malformed`;\n\n if (\n // If the process is non-interactive, default to clearing the malformed native project.\n // This would only happen on re-running eject.\n !isInteractive() ||\n // Prompt to clear the native folders.\n (await confirmAsync({\n message: `${message}, would you like to clear the project files and reinitialize them?`,\n initial: true,\n }))\n ) {\n if (!isInteractive()) {\n Log.warn(`${message}, project files will be cleared and reinitialized.`);\n }\n await clearNativeFolder(projectRoot, platforms);\n } else {\n // Warn the user that the process may fail.\n Log.warn('Continuing with malformed native projects');\n }\n}\n"],"names":["clearNativeFolder","hasRequiredAndroidFilesAsync","hasRequiredIOSFilesAsync","getMalformedNativeProjectsAsync","promptToClearMalformedNativeProjectsAsync","Log","projectRoot","folders","step","logNewSection","join","Promise","all","map","folderName","fs","promises","rm","path","recursive","force","succeed","error","fail","message","AndroidConfig","Paths","getAppBuildGradleAsync","getProjectBuildGradleAsync","getAndroidManifestAsync","getMainApplicationAsync","IOSConfig","getAppDelegate","getAllXcodeProjectPaths","getAllInfoPlistPaths","getAllPBXProjectPaths","filterPlatformsThatDoNotExistAsync","platforms","valid","platform","directoryExistsAsync","filter","Boolean","VERIFIERS","android","ios","checkPlatforms","length","displayPlatforms","chalk","cyan","isInteractive","confirmAsync","initial","warn"],"mappings":"AAAA;;;;QAYsBA,iBAAiB,GAAjBA,iBAAiB;QAyBjBC,4BAA4B,GAA5BA,4BAA4B;QAe5BC,wBAAwB,GAAxBA,wBAAwB;QAsCxBC,+BAA+B,GAA/BA,+BAA+B;QAsB/BC,yCAAyC,GAAzCA,yCAAyC;AAhHT,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1D,IAAA,MAAO,kCAA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ACG,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,IAChB,sCAAsC;IACtC,CAAC,MAAMC,CAAAA,GAAAA,QAAY,AAGjB,CAAA,aAHiB,CAAC;QAClB5B,OAAO,EAAE,CAAC,EAAEA,OAAO,CAAC,kEAAkE,CAAC;QACvF6B,OAAO,EAAE,IAAI;KACd,CAAC,CAAC,EACH;QACA,IAAI,CAACF,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,EAAE;YACpB9C,GAAG,CAACiD,IAAI,CAAC,CAAC,EAAE9B,OAAO,CAAC,kDAAkD,CAAC,CAAC,CAAC;SAC1E;QACD,MAAMxB,iBAAiB,CAACM,WAAW,EAAE+B,SAAS,CAAC,CAAC;KACjD,MAAM;QACL,2CAA2C;QAC3ChC,GAAG,CAACiD,IAAI,CAAC,2CAA2C,CAAC,CAAC;KACvD;CACF"}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.registerAsync = registerAsync;
6
6
  var _betterOpn = _interopRequireDefault(require("better-opn"));
7
- var _env = require("../utils/env");
8
7
  var _errors = require("../utils/errors");
8
+ var _interactive = require("../utils/interactive");
9
9
  var _link = require("../utils/link");
10
10
  var _ora = require("../utils/ora");
11
11
  function _interopRequireDefault(obj) {
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) {
14
14
  };
15
15
  }
16
16
  async function registerAsync() {
17
- if (_env.env.CI) {
17
+ if (!(0, _interactive).isInteractive()) {
18
18
  throw new _errors.CommandError("NON_INTERACTIVE", `Cannot register an account in CI. Use the EXPO_TOKEN environment variable to authenticate in CI (${(0, _link).learnMore("https://docs.expo.dev/accounts/programmatic-access/")})`);
19
19
  }
20
20
  const registrationUrl = `https://expo.dev/signup`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/register/registerAsync.ts"],"sourcesContent":["import openBrowserAsync from 'better-opn';\n\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { learnMore } from '../utils/link';\nimport { ora } from '../utils/ora';\n\nexport async function registerAsync() {\n if (env.CI) {\n throw new CommandError(\n 'NON_INTERACTIVE',\n `Cannot register an account in CI. Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`\n );\n }\n\n const registrationUrl = `https://expo.dev/signup`;\n const failedMessage = `Unable to open a web browser. Register an account at: ${registrationUrl}`;\n const spinner = ora(`Opening ${registrationUrl}`).start();\n try {\n const opened = await openBrowserAsync(registrationUrl);\n\n if (opened) {\n spinner.succeed(`Opened ${registrationUrl}`);\n } else {\n spinner.fail(failedMessage);\n }\n return;\n } catch (error) {\n spinner.fail(failedMessage);\n throw error;\n }\n}\n"],"names":["registerAsync","env","CI","CommandError","learnMore","registrationUrl","failedMessage","spinner","ora","start","opened","openBrowserAsync","succeed","fail","error"],"mappings":"AAAA;;;;QAOsBA,aAAa,GAAbA,aAAa;AAPN,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAErB,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACpB,IAAA,KAAe,WAAf,eAAe,CAAA;AACrB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAE3B,eAAeA,aAAa,GAAG;IACpC,IAAIC,IAAG,IAAA,CAACC,EAAE,EAAE;QACV,MAAM,IAAIC,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,iGAAiG,EAAEC,CAAAA,GAAAA,KAAS,AAE5G,CAAA,UAF4G,CAC3G,qDAAqD,CACtD,CAAC,CAAC,CAAC,CACL,CAAC;KACH;IAED,MAAMC,eAAe,GAAG,CAAC,uBAAuB,CAAC,AAAC;IAClD,MAAMC,aAAa,GAAG,CAAC,sDAAsD,EAAED,eAAe,CAAC,CAAC,AAAC;IACjG,MAAME,OAAO,GAAGC,CAAAA,GAAAA,IAAG,AAA8B,CAAA,IAA9B,CAAC,CAAC,QAAQ,EAAEH,eAAe,CAAC,CAAC,CAAC,CAACI,KAAK,EAAE,AAAC;IAC1D,IAAI;QACF,MAAMC,MAAM,GAAG,MAAMC,CAAAA,GAAAA,UAAgB,AAAiB,CAAA,QAAjB,CAACN,eAAe,CAAC,AAAC;QAEvD,IAAIK,MAAM,EAAE;YACVH,OAAO,CAACK,OAAO,CAAC,CAAC,OAAO,EAAEP,eAAe,CAAC,CAAC,CAAC,CAAC;SAC9C,MAAM;YACLE,OAAO,CAACM,IAAI,CAACP,aAAa,CAAC,CAAC;SAC7B;QACD,OAAO;KACR,CAAC,OAAOQ,KAAK,EAAE;QACdP,OAAO,CAACM,IAAI,CAACP,aAAa,CAAC,CAAC;QAC5B,MAAMQ,KAAK,CAAC;KACb;CACF"}
1
+ {"version":3,"sources":["../../../src/register/registerAsync.ts"],"sourcesContent":["import openBrowserAsync from 'better-opn';\n\nimport { CommandError } from '../utils/errors';\nimport { isInteractive } from '../utils/interactive';\nimport { learnMore } from '../utils/link';\nimport { ora } from '../utils/ora';\n\nexport async function registerAsync() {\n if (!isInteractive()) {\n throw new CommandError(\n 'NON_INTERACTIVE',\n `Cannot register an account in CI. Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`\n );\n }\n\n const registrationUrl = `https://expo.dev/signup`;\n const failedMessage = `Unable to open a web browser. Register an account at: ${registrationUrl}`;\n const spinner = ora(`Opening ${registrationUrl}`).start();\n try {\n const opened = await openBrowserAsync(registrationUrl);\n\n if (opened) {\n spinner.succeed(`Opened ${registrationUrl}`);\n } else {\n spinner.fail(failedMessage);\n }\n return;\n } catch (error) {\n spinner.fail(failedMessage);\n throw error;\n }\n}\n"],"names":["registerAsync","isInteractive","CommandError","learnMore","registrationUrl","failedMessage","spinner","ora","start","opened","openBrowserAsync","succeed","fail","error"],"mappings":"AAAA;;;;QAOsBA,aAAa,GAAbA,aAAa;AAPN,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAEZ,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAChB,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,KAAe,WAAf,eAAe,CAAA;AACrB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAE3B,eAAeA,aAAa,GAAG;IACpC,IAAI,CAACC,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,EAAE;QACpB,MAAM,IAAIC,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,iGAAiG,EAAEC,CAAAA,GAAAA,KAAS,AAE5G,CAAA,UAF4G,CAC3G,qDAAqD,CACtD,CAAC,CAAC,CAAC,CACL,CAAC;KACH;IAED,MAAMC,eAAe,GAAG,CAAC,uBAAuB,CAAC,AAAC;IAClD,MAAMC,aAAa,GAAG,CAAC,sDAAsD,EAAED,eAAe,CAAC,CAAC,AAAC;IACjG,MAAME,OAAO,GAAGC,CAAAA,GAAAA,IAAG,AAA8B,CAAA,IAA9B,CAAC,CAAC,QAAQ,EAAEH,eAAe,CAAC,CAAC,CAAC,CAACI,KAAK,EAAE,AAAC;IAC1D,IAAI;QACF,MAAMC,MAAM,GAAG,MAAMC,CAAAA,GAAAA,UAAgB,AAAiB,CAAA,QAAjB,CAACN,eAAe,CAAC,AAAC;QAEvD,IAAIK,MAAM,EAAE;YACVH,OAAO,CAACK,OAAO,CAAC,CAAC,OAAO,EAAEP,eAAe,CAAC,CAAC,CAAC,CAAC;SAC9C,MAAM;YACLE,OAAO,CAACM,IAAI,CAACP,aAAa,CAAC,CAAC;SAC7B;QACD,OAAO;KACR,CAAC,OAAOQ,KAAK,EAAE;QACdP,OAAO,CAACM,IAAI,CAACP,aAAa,CAAC,CAAC;QAC5B,MAAMQ,KAAK,CAAC;KACb;CACF"}
@@ -6,7 +6,7 @@ exports.logDeviceArgument = logDeviceArgument;
6
6
  exports.logProjectLogsLocation = logProjectLogsLocation;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _log = require("../log");
9
- var _env = require("../utils/env");
9
+ var _interactive = require("../utils/interactive");
10
10
  function _interopRequireDefault(obj) {
11
11
  return obj && obj.__esModule ? obj : {
12
12
  default: obj
@@ -16,7 +16,7 @@ function logDeviceArgument(id) {
16
16
  _log.Log.log(_chalk.default.dim`› Using --device ${id}`);
17
17
  }
18
18
  function logProjectLogsLocation() {
19
- _log.Log.log(_chalk.default`\n› Logs for your project will appear below.${_env.env.CI ? "" : _chalk.default.dim(` Press Ctrl+C to exit.`)}`);
19
+ _log.Log.log(_chalk.default`\n› Logs for your project will appear below.${(0, _interactive).isInteractive() ? _chalk.default.dim(` Press Ctrl+C to exit.`) : ""}`);
20
20
  }
21
21
 
22
22
  //# sourceMappingURL=hints.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/run/hints.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { Log } from '../log';\nimport { env } from '../utils/env';\n\n/** Log the device argument to use for the next run: `Using --device foobar` */\nexport function logDeviceArgument(id: string) {\n Log.log(chalk.dim`› Using --device ${id}`);\n}\n\nexport function logProjectLogsLocation() {\n Log.log(\n chalk`\\n› Logs for your project will appear below.${\n env.CI ? '' : chalk.dim(` Press Ctrl+C to exit.`)\n }`\n );\n}\n"],"names":["logDeviceArgument","logProjectLogsLocation","id","Log","log","chalk","dim","env","CI"],"mappings":"AAAA;;;;QAMgBA,iBAAiB,GAAjBA,iBAAiB;QAIjBC,sBAAsB,GAAtBA,sBAAsB;AAVpB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEL,IAAA,IAAQ,WAAR,QAAQ,CAAA;AACR,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAG3B,SAASD,iBAAiB,CAACE,EAAU,EAAE;IAC5CC,IAAG,IAAA,CAACC,GAAG,CAACC,MAAK,QAAA,CAACC,GAAG,CAAC,mBAAmB,EAAEJ,EAAE,CAAC,CAAC,CAAC,CAAC;CAC9C;AAEM,SAASD,sBAAsB,GAAG;IACvCE,IAAG,IAAA,CAACC,GAAG,CACLC,MAAK,QAAA,CAAC,8CAA4C,EAChDE,IAAG,IAAA,CAACC,EAAE,GAAG,EAAE,GAAGH,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAClD,CAAC,CACH,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../src/run/hints.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { Log } from '../log';\nimport { isInteractive } from '../utils/interactive';\n\n/** Log the device argument to use for the next run: `Using --device foobar` */\nexport function logDeviceArgument(id: string) {\n Log.log(chalk.dim`› Using --device ${id}`);\n}\n\nexport function logProjectLogsLocation() {\n Log.log(\n chalk`\\n› Logs for your project will appear below.${\n isInteractive() ? chalk.dim(` Press Ctrl+C to exit.`) : ''\n }`\n );\n}\n"],"names":["logDeviceArgument","logProjectLogsLocation","id","Log","log","chalk","dim","isInteractive"],"mappings":"AAAA;;;;QAMgBA,iBAAiB,GAAjBA,iBAAiB;QAIjBC,sBAAsB,GAAtBA,sBAAsB;AAVpB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEL,IAAA,IAAQ,WAAR,QAAQ,CAAA;AACE,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;;;;;;AAG7C,SAASD,iBAAiB,CAACE,EAAU,EAAE;IAC5CC,IAAG,IAAA,CAACC,GAAG,CAACC,MAAK,QAAA,CAACC,GAAG,CAAC,mBAAmB,EAAEJ,EAAE,CAAC,CAAC,CAAC,CAAC;CAC9C;AAEM,SAASD,sBAAsB,GAAG;IACvCE,IAAG,IAAA,CAACC,GAAG,CACLC,MAAK,QAAA,CAAC,8CAA4C,EAChDE,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,GAAGF,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,GAAG,EAAE,CAC3D,CAAC,CACH,CAAC;CACH"}
@@ -8,8 +8,8 @@ var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _os = _interopRequireDefault(require("os"));
9
9
  var _path = _interopRequireDefault(require("path"));
10
10
  var _dir = require("../../../utils/dir");
11
- var _env = require("../../../utils/env");
12
11
  var _errors = require("../../../utils/errors");
12
+ var _interactive = require("../../../utils/interactive");
13
13
  var _ora = require("../../../utils/ora");
14
14
  var _prompts = require("../../../utils/prompts");
15
15
  var AppleDevice = _interopRequireWildcard(require("./AppleDevice"));
@@ -75,7 +75,7 @@ async function installOnDeviceAsync(props) {
75
75
  var ref;
76
76
  // Get the app name from the binary path.
77
77
  const appName = (ref = _path.default.basename(bundle).split(".")[0]) != null ? ref : "app";
78
- if (!_env.env.CI && await (0, _prompts).confirmAsync({
78
+ if ((0, _interactive).isInteractive() && await (0, _prompts).confirmAsync({
79
79
  message: `Cannot launch ${appName} because the device is locked. Unlock ${deviceName} to continue...`,
80
80
  initial: true
81
81
  })) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/run/ios/appleDevice/installOnDeviceAsync.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Ora } from 'ora';\nimport os from 'os';\nimport path from 'path';\n\nimport { ensureDirectory } from '../../../utils/dir';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { ora } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\nimport * as AppleDevice from './AppleDevice';\n\n/** Get the app_delta folder for faster subsequent rebuilds on devices. */\nexport function getAppDeltaDirectory(bundleId: string): string {\n // TODO: Maybe use .expo folder instead for debugging\n // TODO: Reuse existing folder from xcode?\n const deltaFolder = path.join(os.tmpdir(), 'ios', 'app-delta', bundleId);\n ensureDirectory(deltaFolder);\n return deltaFolder;\n}\n\n/**\n * Wraps the apple device method for installing and running an app,\n * adds indicator and retry loop for when the device is locked.\n */\nexport async function installOnDeviceAsync(props: {\n bundle: string;\n bundleIdentifier: string;\n appDeltaDirectory: string;\n udid: string;\n deviceName: string;\n}): Promise<void> {\n const { bundle, bundleIdentifier, appDeltaDirectory, udid, deviceName } = props;\n let indicator: Ora | undefined;\n\n try {\n // TODO: Connect for logs\n await AppleDevice.runOnDevice({\n udid,\n appPath: bundle,\n bundleId: bundleIdentifier,\n waitForApp: false,\n deltaPath: appDeltaDirectory,\n onProgress({\n status,\n isComplete,\n progress,\n }: {\n status: string;\n isComplete: boolean;\n progress: number;\n }) {\n if (!indicator) {\n indicator = ora(status).start();\n }\n indicator.text = `${chalk.bold(status)} ${progress}%`;\n if (isComplete) {\n indicator.succeed();\n }\n },\n });\n } catch (error: any) {\n if (indicator) {\n indicator.fail();\n }\n if (error.code === 'APPLE_DEVICE_LOCKED') {\n // Get the app name from the binary path.\n const appName = path.basename(bundle).split('.')[0] ?? 'app';\n if (\n !env.CI &&\n (await confirmAsync({\n message: `Cannot launch ${appName} because the device is locked. Unlock ${deviceName} to continue...`,\n initial: true,\n }))\n ) {\n return installOnDeviceAsync(props);\n }\n throw new CommandError(\n `Cannot launch ${appName} on ${deviceName} because the device is locked.`\n );\n }\n throw error;\n }\n}\n"],"names":["getAppDeltaDirectory","installOnDeviceAsync","AppleDevice","bundleId","deltaFolder","path","join","os","tmpdir","ensureDirectory","props","bundle","bundleIdentifier","appDeltaDirectory","udid","deviceName","indicator","runOnDevice","appPath","waitForApp","deltaPath","onProgress","status","isComplete","progress","ora","start","text","chalk","bold","succeed","error","fail","code","appName","basename","split","env","CI","confirmAsync","message","initial","CommandError"],"mappings":"AAAA;;;;QAagBA,oBAAoB,GAApBA,oBAAoB;QAYdC,oBAAoB,GAApBA,oBAAoB;AAzBxB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAES,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAChC,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAChC,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,QAAwB,WAAxB,wBAAwB,CA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CAAC,CAAC;KACJ,CAAC,OAAOC,KAAK,EAAO;QACnB,IAAIf,SAAS,EAAE;YACbA,SAAS,CAACgB,IAAI,EAAE,CAAC;SAClB;QACD,IAAID,KAAK,CAACE,IAAI,KAAK,qBAAqB,EAAE;gBAExB5B,GAAmC;YADnD,yCAAyC;YACzC,MAAM6B,OAAO,GAAG7B,CAAAA,GAAmC,GAAnCA,KAAI,QAAA,CAAC8B,QAAQ,CAACxB,MAAM,CAAC,CAACyB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAnC/B,GAAmC,GAAI,KAAK,AAAC;YAC7D,IACE,CAACgC,IAAG,IAAA,CAACC,EAAE,IACN,MAAMC,CAAAA,GAAAA,QAAY,AAGjB,CAAA,aAHiB,CAAC;gBAClBC,OAAO,EAAE,CAAC,cAAc,EAAEN,OAAO,CAAC,sCAAsC,EAAEnB,UAAU,CAAC,eAAe,CAAC;gBACrG0B,OAAO,EAAE,IAAI;aACd,CAAC,AAAC,EACH;gBACA,OAAOxC,oBAAoB,CAACS,KAAK,CAAC,CAAC;aACpC;YACD,MAAM,IAAIgC,OAAY,aAAA,CACpB,CAAC,cAAc,EAAER,OAAO,CAAC,IAAI,EAAEnB,UAAU,CAAC,8BAA8B,CAAC,CAC1E,CAAC;SACH;QACD,MAAMgB,KAAK,CAAC;KACb;CACF"}
1
+ {"version":3,"sources":["../../../../../src/run/ios/appleDevice/installOnDeviceAsync.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Ora } from 'ora';\nimport os from 'os';\nimport path from 'path';\n\nimport { ensureDirectory } from '../../../utils/dir';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { ora } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\nimport * as AppleDevice from './AppleDevice';\n\n/** Get the app_delta folder for faster subsequent rebuilds on devices. */\nexport function getAppDeltaDirectory(bundleId: string): string {\n // TODO: Maybe use .expo folder instead for debugging\n // TODO: Reuse existing folder from xcode?\n const deltaFolder = path.join(os.tmpdir(), 'ios', 'app-delta', bundleId);\n ensureDirectory(deltaFolder);\n return deltaFolder;\n}\n\n/**\n * Wraps the apple device method for installing and running an app,\n * adds indicator and retry loop for when the device is locked.\n */\nexport async function installOnDeviceAsync(props: {\n bundle: string;\n bundleIdentifier: string;\n appDeltaDirectory: string;\n udid: string;\n deviceName: string;\n}): Promise<void> {\n const { bundle, bundleIdentifier, appDeltaDirectory, udid, deviceName } = props;\n let indicator: Ora | undefined;\n\n try {\n // TODO: Connect for logs\n await AppleDevice.runOnDevice({\n udid,\n appPath: bundle,\n bundleId: bundleIdentifier,\n waitForApp: false,\n deltaPath: appDeltaDirectory,\n onProgress({\n status,\n isComplete,\n progress,\n }: {\n status: string;\n isComplete: boolean;\n progress: number;\n }) {\n if (!indicator) {\n indicator = ora(status).start();\n }\n indicator.text = `${chalk.bold(status)} ${progress}%`;\n if (isComplete) {\n indicator.succeed();\n }\n },\n });\n } catch (error: any) {\n if (indicator) {\n indicator.fail();\n }\n if (error.code === 'APPLE_DEVICE_LOCKED') {\n // Get the app name from the binary path.\n const appName = path.basename(bundle).split('.')[0] ?? 'app';\n if (\n isInteractive() &&\n (await confirmAsync({\n message: `Cannot launch ${appName} because the device is locked. Unlock ${deviceName} to continue...`,\n initial: true,\n }))\n ) {\n return installOnDeviceAsync(props);\n }\n throw new CommandError(\n `Cannot launch ${appName} on ${deviceName} because the device is locked.`\n );\n }\n throw error;\n }\n}\n"],"names":["getAppDeltaDirectory","installOnDeviceAsync","AppleDevice","bundleId","deltaFolder","path","join","os","tmpdir","ensureDirectory","props","bundle","bundleIdentifier","appDeltaDirectory","udid","deviceName","indicator","runOnDevice","appPath","waitForApp","deltaPath","onProgress","status","isComplete","progress","ora","start","text","chalk","bold","succeed","error","fail","code","appName","basename","split","isInteractive","confirmAsync","message","initial","CommandError"],"mappings":"AAAA;;;;QAagBA,oBAAoB,GAApBA,oBAAoB;QAYdC,oBAAoB,GAApBA,oBA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
7
  exports.selectDevelopmentTeamAsync = selectDevelopmentTeamAsync;
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
9
  var Log = _interopRequireWildcard(require("../../../log"));
10
- var _env = require("../../../utils/env");
11
10
  var _errors = require("../../../utils/errors");
11
+ var _interactive = require("../../../utils/interactive");
12
12
  var _link = require("../../../utils/link");
13
13
  var _prompts = require("../../../utils/prompts");
14
14
  var Security = _interopRequireWildcard(require("./Security"));
@@ -69,7 +69,7 @@ async function resolveCertificateSigningIdentityAsync(ids) {
69
69
  // One ID available 🤝 Program is not interactive
70
70
  //
71
71
  // using the the first available option
72
- if (ids.length === 1 || _env.env.CI) {
72
+ if (ids.length === 1 || !(0, _interactive).isInteractive()) {
73
73
  // This method is cheaper than `resolveIdentitiesAsync` and checking the
74
74
  // cached user preference so we should use this as early as possible.
75
75
  return Security.resolveCertificateSigningInfoAsync(ids[0]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/run/ios/codeSigning/resolveCertificateSigningIdentity.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { learnMore } from '../../../utils/link';\nimport { selectAsync } from '../../../utils/prompts';\nimport * as Security from './Security';\nimport { getLastDeveloperCodeSigningIdAsync, setLastDeveloperCodeSigningIdAsync } from './settings';\n\n/**\n * Sort the code signing items so the last selected item (user's default) is the first suggested.\n */\nexport async function sortDefaultIdToBeginningAsync(\n identities: Security.CertificateSigningInfo[]\n): Promise<[Security.CertificateSigningInfo[], string | null]> {\n const lastSelected = await getLastDeveloperCodeSigningIdAsync();\n\n if (lastSelected) {\n let iterations = 0;\n while (identities[0].signingCertificateId !== lastSelected && iterations < identities.length) {\n identities.push(identities.shift()!);\n iterations++;\n }\n }\n return [identities, lastSelected];\n}\n\n/**\n * Assert that the computer needs code signing setup.\n * This links to an FYI page that was user tested internally.\n */\nfunction assertCodeSigningSetup(): never {\n // TODO: We can probably do this too automatically.\n Log.log(\n `\\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\\n ${chalk.bold(\n learnMore('https://expo.fyi/setup-xcode-signing')\n )}`\n );\n\n throw new CommandError('No code signing certificates are available to use.');\n}\n\n/**\n * Resolve the best certificate signing identity from a given list of IDs.\n * - If no IDs: Assert that the user has to setup code signing.\n * - If one ID: Return the first ID.\n * - If multiple IDs: Ask the user to select one, then store the value to be suggested first next time (since users generally use the same ID).\n */\nexport async function resolveCertificateSigningIdentityAsync(\n ids: string[]\n): Promise<Security.CertificateSigningInfo> {\n // The user has no valid code signing identities.\n if (!ids.length) {\n assertCodeSigningSetup();\n }\n\n // One ID available 🤝 Program is not interactive\n //\n // using the the first available option\n if (ids.length === 1 || env.CI) {\n // This method is cheaper than `resolveIdentitiesAsync` and checking the\n // cached user preference so we should use this as early as possible.\n return Security.resolveCertificateSigningInfoAsync(ids[0]);\n }\n\n // Get identities and sort by the one that the user is most likely to choose.\n const [identities, preferred] = await sortDefaultIdToBeginningAsync(\n await Security.resolveIdentitiesAsync(ids)\n );\n\n const selected = await selectDevelopmentTeamAsync(identities, preferred);\n\n // Store the last used value and suggest it as the first value\n // next time the user has to select a code signing identity.\n await setLastDeveloperCodeSigningIdAsync(selected.signingCertificateId);\n\n return selected;\n}\n\n/** Prompt the user to select a development team, highlighting the preferred value based on the user history. */\nexport async function selectDevelopmentTeamAsync(\n identities: Security.CertificateSigningInfo[],\n preferredId: string | null\n): Promise<Security.CertificateSigningInfo> {\n const index = await selectAsync(\n 'Development team for signing the app',\n identities.map((value, i) => {\n const format =\n value.signingCertificateId === preferredId ? chalk.bold : (message: string) => message;\n return {\n // Formatted like: `650 Industries, Inc. (A1BCDEF234) - Apple Development: Evan Bacon (AA00AABB0A)`\n title: format(\n [value.appleTeamName, `(${value.appleTeamId}) -`, value.codeSigningInfo].join(' ')\n ),\n value: i,\n };\n })\n );\n\n return identities[index];\n}\n"],"names":["sortDefaultIdToBeginningAsync","resolveCertificateSigningIdentityAsync","selectDevelopmentTeamAsync","Log","Security","identities","lastSelected","getLastDeveloperCodeSigningIdAsync","iterations","signingCertificateId","length","push","shift","assertCodeSigningSetup","log","chalk","bold","learnMore","CommandError","ids","env","CI","resolveCertificateSigningInfoAsync","preferred","resolveIdentitiesAsync","selected","setLastDeveloperCodeSigningIdAsync","preferredId","index","selectAsync","map","value","i","format","message","title","appleTeamName","appleTeamId","codeSigningInfo","join"],"mappings":"AAAA;;;;QAasBA,6BAA6B,GAA7BA,6BAA6B;QAoC7BC,sCAAsC,GAAtCA,sCAAsC;QAgCtCC,0BAA0B,GAA1BA,0BAA0B;AAjF9B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACxCC,IAAAA,QAAQ,mCAAM,YAAY,EAAlB;AACmE,IAAA,SAAY,WAAZ,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK5F,eAAeJ,6BAA6B,CACjDK,UAA6C,EACgB;IAC7D,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,SAAkC,AAAE,CAAA,mCAAF,EAAE,AAAC;IAEhE,IAAID,YAAY,EAAE;QAChB,IAAIE,UAAU,GAAG,CAAC,AAAC;QACnB,MAAOH,UAAU,CAAC,CAAC,CAAC,CAACI,oBAAoB,KAAKH,YAAY,IAAIE,UAAU,GAAGH,UAAU,CAACK,MAAM,CAAE;YAC5FL,UAAU,CAACM,IAAI,CAACN,UAAU,CAACO,KAAK,EAAE,CAAE,CAAC;YACrCJ,UAAU,EAAE,CAAC;SACd;KACF;IACD,OAAO;QAACH,UAAU;QAAEC,YAAY;KAAC,CAAC;CACnC;AAED;;;GAGG,CACH,SAASO,sBAAsB,GAA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,GAAK;QAC3B,MAAMC,MAAM,GACVF,KAAK,CAACtB,oBAAoB,KAAKkB,WAAW,GAAGZ,MAAK,QAAA,CAACC,IAAI,GAAG,CAACkB,OAAe,GAAKA,OAAO;QAAC;QACzF,OAAO;YACL,mGAAmG;YACnGC,KAAK,EAAEF,MAAM,CACX;gBAACF,KAAK,CAACK,aAAa;gBAAE,CAAC,CAAC,EAAEL,KAAK,CAACM,WAAW,CAAC,GAAG,CAAC;gBAAEN,KAAK,CAACO,eAAe;aAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CACnF;YACDR,KAAK,EAAEC,CAAC;SACT,CAAC;KACH,CAAC,CACH,AAAC;IAEF,OAAO3B,UAAU,CAACuB,KAAK,CAAC,CAAC;CAC1B"}
1
+ {"version":3,"sources":["../../../../../src/run/ios/codeSigning/resolveCertificateSigningIdentity.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { learnMore } from '../../../utils/link';\nimport { selectAsync } from '../../../utils/prompts';\nimport * as Security from './Security';\nimport { getLastDeveloperCodeSigningIdAsync, setLastDeveloperCodeSigningIdAsync } from './settings';\n\n/**\n * Sort the code signing items so the last selected item (user's default) is the first suggested.\n */\nexport async function sortDefaultIdToBeginningAsync(\n identities: Security.CertificateSigningInfo[]\n): Promise<[Security.CertificateSigningInfo[], string | null]> {\n const lastSelected = await getLastDeveloperCodeSigningIdAsync();\n\n if (lastSelected) {\n let iterations = 0;\n while (identities[0].signingCertificateId !== lastSelected && iterations < identities.length) {\n identities.push(identities.shift()!);\n iterations++;\n }\n }\n return [identities, lastSelected];\n}\n\n/**\n * Assert that the computer needs code signing setup.\n * This links to an FYI page that was user tested internally.\n */\nfunction assertCodeSigningSetup(): never {\n // TODO: We can probably do this too automatically.\n Log.log(\n `\\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\\n ${chalk.bold(\n learnMore('https://expo.fyi/setup-xcode-signing')\n )}`\n );\n\n throw new CommandError('No code signing certificates are available to use.');\n}\n\n/**\n * Resolve the best certificate signing identity from a given list of IDs.\n * - If no IDs: Assert that the user has to setup code signing.\n * - If one ID: Return the first ID.\n * - If multiple IDs: Ask the user to select one, then store the value to be suggested first next time (since users generally use the same ID).\n */\nexport async function resolveCertificateSigningIdentityAsync(\n ids: string[]\n): Promise<Security.CertificateSigningInfo> {\n // The user has no valid code signing identities.\n if (!ids.length) {\n assertCodeSigningSetup();\n }\n\n // One ID available 🤝 Program is not interactive\n //\n // using the the first available option\n if (ids.length === 1 || !isInteractive()) {\n // This method is cheaper than `resolveIdentitiesAsync` and checking the\n // cached user preference so we should use this as early as possible.\n return Security.resolveCertificateSigningInfoAsync(ids[0]);\n }\n\n // Get identities and sort by the one that the user is most likely to choose.\n const [identities, preferred] = await sortDefaultIdToBeginningAsync(\n await Security.resolveIdentitiesAsync(ids)\n );\n\n const selected = await selectDevelopmentTeamAsync(identities, preferred);\n\n // Store the last used value and suggest it as the first value\n // next time the user has to select a code signing identity.\n await setLastDeveloperCodeSigningIdAsync(selected.signingCertificateId);\n\n return selected;\n}\n\n/** Prompt the user to select a development team, highlighting the preferred value based on the user history. */\nexport async function selectDevelopmentTeamAsync(\n identities: Security.CertificateSigningInfo[],\n preferredId: string | null\n): Promise<Security.CertificateSigningInfo> {\n const index = await selectAsync(\n 'Development team for signing the app',\n identities.map((value, i) => {\n const format =\n value.signingCertificateId === preferredId ? chalk.bold : (message: string) => message;\n return {\n // Formatted like: `650 Industries, Inc. (A1BCDEF234) - Apple Development: Evan Bacon (AA00AABB0A)`\n title: format(\n [value.appleTeamName, `(${value.appleTeamId}) -`, value.codeSigningInfo].join(' ')\n ),\n value: i,\n };\n })\n );\n\n return identities[index];\n}\n"],"names":["sortDefaultIdToBeginningAsync","resolveCertificateSigningIdentityAsync","selectDevelopmentTeamAsync","Log","Security","identities","lastSelected","getLastDeveloperCodeSigningIdAsync","iterations","signingCertificateId","length","push","shift","assertCodeSigningSetup","log","chalk","bold","learnMore","CommandError","ids","isInteractive","resolveCertificateSigningInfoAsync","preferred","resolveIdentitiesAsync","selected","setLastDeveloperCodeSigningIdAsync","preferredId","index","selectAsync","map","value","i","format","message","title","appleTeamName","appleTeamId","codeSigningInfo","join"],"mappings":"AAAA;;;;QAasBA,6BAA6B,GAA7BA,6BAA6B;QAoC7BC,sCAAsC,GAAtCA,sCAAsC;QAgCtCC,0BAA0B,GAA1BA,0BAA0B;AAjF9B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACtB,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACnB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACxCC,IAAAA,QAAQ,mCAAM,YAAY,EAAlB;AACmE,IAAA,SAAY,WAAZ,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK5F,eAAeJ,6BAA6B,CACjDK,UAA6C,EACgB;IAC7D,MAAMC,YAAY,GAAG,MAAMC,CAAAA,GAAAA,SAAkC,AAAE,CAAA,mCAAF,EAAE,AAAC;IAEhE,IAAID,YAAY,EAAE;QAChB,IAAIE,UAAU,GAAG,CAAC,AAAC;QACnB,MAAOH,UAAU,CAAC,CAAC,CAAC,CAACI,oBAAoB,KAAKH,YAAY,IAAIE,UAAU,GAAGH,UAAU,CAACK,MAAM,CAAE;YAC5FL,UAAU,CAACM,IAAI,CAACN,UAAU,CAACO,KAAK,EAAE,CAAE,CAAC;YACrCJ,UAAU,EAAE,CAAC;SACd;KACF;IACD,OAAO;QAACH,UAAU;QAAEC,YAAY;KAAC,CAAC;CACnC;AAED;;;GAGG,CACH,SAASO,sBAAsB,GAAU;IACvC,mDAAmD;IACnDV,GAAG,CAACW,GAAG,CACL,CAAC,uGAAuG,EAAEC,MAAK,QAAA,CAACC,I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AAW,GAAGX,MAAK,QAAA,CAACC,IAAI,GAAG,CAACiB,OAAe,GAAKA,OAAO;QAAC;QACzF,OAAO;YACL,mGAAmG;YACnGC,KAAK,EAAEF,MAAM,CACX;gBAACF,KAAK,CAACK,aAAa;gBAAE,CAAC,CAAC,EAAEL,KAAK,CAACM,WAAW,CAAC,GAAG,CAAC;gBAAEN,KAAK,CAACO,eAAe;aAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CACnF;YACDR,KAAK,EAAEC,CAAC;SACT,CAAC;KACH,CAAC,CACH,AAAC;IAEF,OAAO1B,UAAU,CAACsB,KAAK,CAAC,CAAC;CAC1B"}
@@ -8,7 +8,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var Log = _interopRequireWildcard(require("../log"));
9
9
  var _startInterface = require("../start/interface/startInterface");
10
10
  var _devServerManager = require("../start/server/DevServerManager");
11
- var _env = require("../utils/env");
11
+ var _interactive = require("../utils/interactive");
12
12
  function _interopRequireDefault(obj) {
13
13
  return obj && obj.__esModule ? obj : {
14
14
  default: obj
@@ -53,7 +53,7 @@ async function startBundlerAsync(projectRoot, { port , headless , scheme }) {
53
53
  },
54
54
  ]);
55
55
  // Present the Terminal UI.
56
- if (!headless && !_env.env.CI) {
56
+ if (!headless && (0, _interactive).isInteractive()) {
57
57
  // Only read the config if we are going to use the results.
58
58
  const { exp } = (0, _config).getConfig(projectRoot, {
59
59
  // We don't need very many fields here, just use the lightest possible read.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/run/startBundler.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { startInterfaceAsync } from '../start/interface/startInterface';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { env } from '../utils/env';\n\nexport async function startBundlerAsync(\n projectRoot: string,\n {\n port,\n headless,\n scheme,\n }: {\n port: number;\n headless?: boolean;\n scheme?: string;\n }\n): Promise<DevServerManager> {\n const options = {\n port,\n headless,\n devClient: true,\n\n location: {\n scheme,\n },\n };\n\n const devServerManager = new DevServerManager(projectRoot, options);\n\n await devServerManager.startAsync([\n {\n // TODO: Allow swapping this value for another bundler.\n type: 'metro',\n options,\n },\n ]);\n\n // Present the Terminal UI.\n if (!headless && !env.CI) {\n // Only read the config if we are going to use the results.\n const { exp } = getConfig(projectRoot, {\n // We don't need very many fields here, just use the lightest possible read.\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n await startInterfaceAsync(devServerManager, {\n platforms: exp.platforms ?? [],\n });\n } else {\n // Display the server location in CI...\n const url = devServerManager.getDefaultDevServer()?.getDevServerUrl();\n if (url) {\n Log.log(chalk`Waiting on {underline ${url}}`);\n }\n }\n return devServerManager;\n}\n"],"names":["startBundlerAsync","Log","projectRoot","port","headless","scheme","options","devClient","location","devServerManager","DevServerManager","startAsync","type","env","CI","exp","getConfig","skipSDKVersionRequirement","skipPlugins","startInterfaceAsync","platforms","url","getDefaultDevServer","getDevServerUrl","log","chalk"],"mappings":"AAAA;;;;QAQsBA,iBAAiB,GAAjBA,iBAAiB;AARb,IAAA,OAAc,WAAd,cAAc,CAAA;AACtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACqB,IAAA,eAAmC,WAAnC,mCAAmC,CAAA;AACtC,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;AAC/C,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3B,eAAeD,iBAAiB,CACrCE,WAAmB,EACnB,EACEC,IAAI,CAAA,EACJC,QAAQ,CAAA,EACRC,MAAM,CAAA,EAKP,EAC0B;IAC3B,MAAMC,OAAO,GAAG;QACdH,IAAI;QACJC,QAAQ;QACRG,SAAS,EAAE,IAAI;QAEfC,QAAQ,EAAE;YACRH,MAAM;SACP;KACF,AAAC;IAEF,MAAMI,gBAAgB,GAAG,IAAIC,iBAAgB,iBAAA,CAACR,WAAW,EAAEI,OAAO,CAAC,AAAC;IAEpE,MAAMG,gBAAgB,CAACE,UAAU,CAAC;QAChC;YACE,uDAAuD;YACvDC,IAAI,EAAE,OAAO;YACbN,OAAO;SACR;KACF,CAAC,CAAC;IAEH,2BAA2B;IAC3B,IAAI,CAACF,QAAQ,IAAI,CAACS,IAAG,IAAA,CAACC,EAAE,EAAE;QACxB,2DAA2D;QAC3D,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAIvB,CAAA,UAJuB,CAACd,WAAW,EAAE;YACrC,4EAA4E;YAC5Ee,yBAAyB,EAAE,IAAI;YAC/BC,WAAW,EAAE,IAAI;SAClB,CAAC,AAAC;YAEUH,UAAa;QAD1B,MAAMI,CAAAA,GAAAA,eAAmB,AAEvB,CAAA,oBAFuB,CAACV,gBAAgB,EAAE;YAC1CW,SAAS,EAAEL,CAAAA,UAAa,GAAbA,GAAG,CAACK,SAAS,YAAbL,UAAa,GAAI,EAAE;SAC/B,CAAC,CAAC;KACJ,MAAM;YAEON,GAAsC;QADlD,uCAAuC;QACvC,MAAMY,GAAG,GAAGZ,CAAAA,GAAsC,GAAtCA,gBAAgB,CAACa,mBAAmB,EAAE,SAAiB,GAAvDb,KAAAA,CAAuD,GAAvDA,GAAsC,CAAEc,eAAe,EAAE,AAAC;QACtE,IAAIF,GAAG,EAAE;YACPpB,GAAG,CAACuB,GAAG,CAACC,MAAK,QAAA,CAAC,sBAAsB,EAAEJ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/C;KACF;IACD,OAAOZ,gBAAgB,CAAC;CACzB"}
1
+ {"version":3,"sources":["../../../src/run/startBundler.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { startInterfaceAsync } from '../start/interface/startInterface';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { isInteractive } from '../utils/interactive';\n\nexport async function startBundlerAsync(\n projectRoot: string,\n {\n port,\n headless,\n scheme,\n }: {\n port: number;\n headless?: boolean;\n scheme?: string;\n }\n): Promise<DevServerManager> {\n const options = {\n port,\n headless,\n devClient: true,\n\n location: {\n scheme,\n },\n };\n\n const devServerManager = new DevServerManager(projectRoot, options);\n\n await devServerManager.startAsync([\n {\n // TODO: Allow swapping this value for another bundler.\n type: 'metro',\n options,\n },\n ]);\n\n // Present the Terminal UI.\n if (!headless && isInteractive()) {\n // Only read the config if we are going to use the results.\n const { exp } = getConfig(projectRoot, {\n // We don't need very many fields here, just use the lightest possible read.\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n await startInterfaceAsync(devServerManager, {\n platforms: exp.platforms ?? [],\n });\n } else {\n // Display the server location in CI...\n const url = devServerManager.getDefaultDevServer()?.getDevServerUrl();\n if (url) {\n Log.log(chalk`Waiting on {underline ${url}}`);\n }\n }\n return devServerManager;\n}\n"],"names":["startBundlerAsync","Log","projectRoot","port","headless","scheme","options","devClient","location","devServerManager","DevServerManager","startAsync","type","isInteractive","exp","getConfig","skipSDKVersionRequirement","skipPlugins","startInterfaceAsync","platforms","url","getDefaultDevServer","getDevServerUrl","log","chalk"],"mappings":"AAAA;;;;QAQsBA,iBAAiB,GAAjBA,iBAAiB;AARb,IAAA,OAAc,WAAd,cAAc,CAAA;AACtB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACqB,IAAA,eAAmC,WAAnC,mCAAmC,CAAA;AACtC,IAAA,iBAAkC,WAAlC,kCAAkC,CAAA;AACrC,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,eAAeD,iBAAiB,CACrCE,WAAmB,EACnB,EACEC,IAAI,CAAA,EACJC,QAAQ,CAAA,EACRC,MAAM,CAAA,EAKP,EAC0B;IAC3B,MAAMC,OAAO,GAAG;QACdH,IAAI;QACJC,QAAQ;QACRG,SAAS,EAAE,IAAI;QAEfC,QAAQ,EAAE;YACRH,MAAM;SACP;KACF,AAAC;IAEF,MAAMI,gBAAgB,GAAG,IAAIC,iBAAgB,iBAAA,CAACR,WAAW,EAAEI,OAAO,CAAC,AAAC;IAEpE,MAAMG,gBAAgB,CAACE,UAAU,CAAC;QAChC;YACE,uDAAuD;YACvDC,IAAI,EAAE,OAAO;YACbN,OAAO;SACR;KACF,CAAC,CAAC;IAEH,2BAA2B;IAC3B,IAAI,CAACF,QAAQ,IAAIS,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,EAAE;QAChC,2DAA2D;QAC3D,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAIvB,CAAA,UAJuB,CAACb,WAAW,EAAE;YACrC,4EAA4E;YAC5Ec,yBAAyB,EAAE,IAAI;YAC/BC,WAAW,EAAE,IAAI;SAClB,CAAC,AAAC;YAEUH,UAAa;QAD1B,MAAMI,CAAAA,GAAAA,eAAmB,AAEvB,CAAA,oBAFuB,CAACT,gBAAgB,EAAE;YAC1CU,SAAS,EAAEL,CAAAA,UAAa,GAAbA,GAAG,CAACK,SAAS,YAAbL,UAAa,GAAI,EAAE;SAC/B,CAAC,CAAC;KACJ,MAAM;YAEOL,GAAsC;QADlD,uCAAuC;QACvC,MAAMW,GAAG,GAAGX,CAAAA,GAAsC,GAAtCA,gBAAgB,CAACY,mBAAmB,EAAE,SAAiB,GAAvDZ,KAAAA,CAAuD,GAAvDA,GAAsC,CAAEa,eAAe,EAAE,AAAC;QACtE,IAAIF,GAAG,EAAE;YACPnB,GAAG,CAACsB,GAAG,CAACC,MAAK,QAAA,CAAC,sBAAsB,EAAEJ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/C;KACF;IACD,OAAOX,gBAAgB,CAAC;CACzB"}
@@ -9,8 +9,8 @@ var _chalk = _interopRequireDefault(require("chalk"));
9
9
  var _wrapAnsi = _interopRequireDefault(require("wrap-ansi"));
10
10
  var _installAsync = require("../../../install/installAsync");
11
11
  var Log = _interopRequireWildcard(require("../../../log"));
12
- var _env = require("../../../utils/env");
13
12
  var _errors = require("../../../utils/errors");
13
+ var _interactive = require("../../../utils/interactive");
14
14
  var _ora = require("../../../utils/ora");
15
15
  var _prompts = require("../../../utils/prompts");
16
16
  var _getMissingPackages = require("./getMissingPackages");
@@ -41,7 +41,7 @@ function _interopRequireWildcard(obj) {
41
41
  }
42
42
  }
43
43
  async function ensureDependenciesAsync(projectRoot, { exp =(0, _config).getConfig(projectRoot).exp , requiredPackages , warningMessage , installMessage , // Don't prompt in CI
44
- skipPrompt =_env.env.CI }) {
44
+ skipPrompt =!(0, _interactive).isInteractive() }) {
45
45
  const { missing } = await (0, _getMissingPackages).getMissingPackagesAsync(projectRoot, {
46
46
  sdkVersion: exp.sdkVersion,
47
47
  requiredPackages
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/doctor/dependencies/ensureDependenciesAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nimport { installAsync } from '../../../install/installAsync';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { logNewSection } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\nimport { getMissingPackagesAsync, ResolvedPackage } from './getMissingPackages';\n\nexport async function ensureDependenciesAsync(\n projectRoot: string,\n {\n exp = getConfig(projectRoot).exp,\n requiredPackages,\n warningMessage,\n installMessage,\n // Don't prompt in CI\n skipPrompt = env.CI,\n }: {\n exp?: ExpoConfig;\n installMessage: string;\n warningMessage: string;\n requiredPackages: ResolvedPackage[];\n skipPrompt?: boolean;\n }\n): Promise<boolean> {\n const { missing } = await getMissingPackagesAsync(projectRoot, {\n sdkVersion: exp.sdkVersion,\n requiredPackages,\n });\n if (!missing.length) {\n return true;\n }\n\n // Prompt to install or bail out...\n const readableMissingPackages = missing\n .map(({ pkg, version }) => (version ? [pkg, version].join('@') : pkg))\n .join(', ');\n\n let title = installMessage;\n\n if (skipPrompt) {\n title += '\\n\\n';\n } else {\n const confirm = await confirmAsync({\n message: wrapForTerminal(\n title + ` Would you like to install ${chalk.cyan(readableMissingPackages)}?`\n ),\n initial: true,\n });\n\n if (confirm) {\n // Format with version if available.\n const packages = missing.map(({ pkg, version }) =>\n version ? [pkg, version].join('@') : pkg\n );\n // Install packages with versions\n await installPackagesAsync(projectRoot, {\n packages,\n });\n // Try again but skip prompting twice, simply fail if the packages didn't install correctly.\n return await ensureDependenciesAsync(projectRoot, {\n skipPrompt: true,\n installMessage,\n warningMessage,\n requiredPackages,\n });\n }\n\n // Reset the title so it doesn't print twice in interactive mode.\n title = '';\n }\n\n const installCommand = createInstallCommand({\n packages: missing,\n });\n\n const disableMessage = warningMessage;\n\n const solution = `Please install ${chalk.bold(\n readableMissingPackages\n )} by running:\\n\\n ${chalk.reset.bold(installCommand)}\\n\\n`;\n\n // This prevents users from starting a misconfigured JS or TS project by default.\n throw new CommandError(wrapForTerminal(title + solution + disableMessage + '\\n'));\n}\n\n/** Wrap long messages to fit smaller terminals. */\nfunction wrapForTerminal(message: string): string {\n return wrapAnsi(message, process.stdout.columns || 80);\n}\n\n/** Create the bash install command from a given set of packages and settings. */\nexport function createInstallCommand({\n packages,\n}: {\n packages: {\n file: string;\n pkg: string;\n version?: string | undefined;\n }[];\n}) {\n return (\n 'npx expo install ' +\n packages\n .map(({ pkg, version }) => {\n if (version) {\n return [pkg, version].join('@');\n }\n return pkg;\n })\n .join(' ')\n );\n}\n\n/** Install packages in the project. */\nasync function installPackagesAsync(projectRoot: string, { packages }: { packages: string[] }) {\n const packagesStr = chalk.bold(packages.join(', '));\n Log.log();\n const installingPackageStep = logNewSection(`Installing ${packagesStr}`);\n try {\n await installAsync(packages, { projectRoot });\n } catch (e: any) {\n installingPackageStep.fail(`Failed to install ${packagesStr} with error: ${e.message}`);\n throw e;\n }\n installingPackageStep.succeed(`Installed ${packagesStr}`);\n}\n"],"names":["ensureDependenciesAsync","createInstallCommand","Log","projectRoot","exp","getConfig","requiredPackages","warningMessage","installMessage","skipPrompt","env","CI","missing","getMissingPackagesAsync","sdkVersion","length","readableMissingPackages","map","pkg","version","join","title","confirm","confirmAsync","message","wrapForTerminal","chalk","cyan","initial","packages","installPackagesAsync","installCommand","disableMessage","solution","bold","reset","CommandError","wrapAnsi","process","stdout","columns","packagesStr","log","installingPackageStep","logNewSection","installAsync","e","fail","succeed"],"mappings":"AAAA;;;;QAYsBA,uBAAuB,GAAvBA,uBAAuB;QAoF7BC,oBAAoB,GAApBA,oBAAoB;AAhGE,IAAA,OAAc,WAAd,cAAc,CAAA;AAClC,IAAA,MAAO,kCAAP,OAAO,EAAA;AACJ,IAAA,SAAW,kCAAX,WAAW,EAAA;AAEH,IAAA,aAA+B,WAA/B,+BAA+B,CAAA;AAChDC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACtB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACrB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACI,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExE,eAAeF,uBAAuB,CAC3CG,WAAmB,EACnB,EACEC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAa,CAAA,UAAb,CAACF,WAAW,CAAC,CAACC,GAAG,CAAA,EAChCE,gBAAgB,CAAA,EAChBC,cAAc,CAAA,EACdC,cAAc,CAAA,EACd,qBAAqB;AACrBC,UAAU,EAAGC,IAAG,IAAA,CAACC,EAAE,CAAA,EAOpB,EACiB;IAClB,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAG,MAAMC,CAAAA,GAAAA,mBAAuB,AAG/C,CAAA,wBAH+C,CAACV,WAAW,EAAE;QAC7DW,UAAU,EAAEV,GAAG,CAACU,UAAU;QAC1B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I,CAAC,CAAC,AAAC;IACpDlB,GAAG,CAACwC,GAAG,EAAE,CAAC;IACV,MAAMC,qBAAqB,GAAGC,CAAAA,GAAAA,IAAa,AAA6B,CAAA,cAA7B,CAAC,CAAC,WAAW,EAAEH,WAAW,CAAC,CAAC,CAAC,AAAC;IACzE,IAAI;QACF,MAAMI,CAAAA,GAAAA,aAAY,AAA2B,CAAA,aAA3B,CAAChB,QAAQ,EAAE;YAAE1B,WAAW;SAAE,CAAC,CAAC;KAC/C,CAAC,OAAO2C,CAAC,EAAO;QACfH,qBAAqB,CAACI,IAAI,CAAC,CAAC,kBAAkB,EAAEN,WAAW,CAAC,aAAa,EAAEK,CAAC,CAACtB,OAAO,CAAC,CAAC,CAAC,CAAC;QACxF,MAAMsB,CAAC,CAAC;KACT;IACDH,qBAAqB,CAACK,OAAO,CAAC,CAAC,UAAU,EAAEP,WAAW,CAAC,CAAC,CAAC,CAAC;CAC3D"}
1
+ {"version":3,"sources":["../../../../../src/start/doctor/dependencies/ensureDependenciesAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nimport { installAsync } from '../../../install/installAsync';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { logNewSection } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\nimport { getMissingPackagesAsync, ResolvedPackage } from './getMissingPackages';\n\nexport async function ensureDependenciesAsync(\n projectRoot: string,\n {\n exp = getConfig(projectRoot).exp,\n requiredPackages,\n warningMessage,\n installMessage,\n // Don't prompt in CI\n skipPrompt = !isInteractive(),\n }: {\n exp?: ExpoConfig;\n installMessage: string;\n warningMessage: string;\n requiredPackages: ResolvedPackage[];\n skipPrompt?: boolean;\n }\n): Promise<boolean> {\n const { missing } = await getMissingPackagesAsync(projectRoot, {\n sdkVersion: exp.sdkVersion,\n requiredPackages,\n });\n if (!missing.length) {\n return true;\n }\n\n // Prompt to install or bail out...\n const readableMissingPackages = missing\n .map(({ pkg, version }) => (version ? [pkg, version].join('@') : pkg))\n .join(', ');\n\n let title = installMessage;\n\n if (skipPrompt) {\n title += '\\n\\n';\n } else {\n const confirm = await confirmAsync({\n message: wrapForTerminal(\n title + ` Would you like to install ${chalk.cyan(readableMissingPackages)}?`\n ),\n initial: true,\n });\n\n if (confirm) {\n // Format with version if available.\n const packages = missing.map(({ pkg, version }) =>\n version ? [pkg, version].join('@') : pkg\n );\n // Install packages with versions\n await installPackagesAsync(projectRoot, {\n packages,\n });\n // Try again but skip prompting twice, simply fail if the packages didn't install correctly.\n return await ensureDependenciesAsync(projectRoot, {\n skipPrompt: true,\n installMessage,\n warningMessage,\n requiredPackages,\n });\n }\n\n // Reset the title so it doesn't print twice in interactive mode.\n title = '';\n }\n\n const installCommand = createInstallCommand({\n packages: missing,\n });\n\n const disableMessage = warningMessage;\n\n const solution = `Please install ${chalk.bold(\n readableMissingPackages\n )} by running:\\n\\n ${chalk.reset.bold(installCommand)}\\n\\n`;\n\n // This prevents users from starting a misconfigured JS or TS project by default.\n throw new CommandError(wrapForTerminal(title + solution + disableMessage + '\\n'));\n}\n\n/** Wrap long messages to fit smaller terminals. */\nfunction wrapForTerminal(message: string): string {\n return wrapAnsi(message, process.stdout.columns || 80);\n}\n\n/** Create the bash install command from a given set of packages and settings. */\nexport function createInstallCommand({\n packages,\n}: {\n packages: {\n file: string;\n pkg: string;\n version?: string | undefined;\n }[];\n}) {\n return (\n 'npx expo install ' +\n packages\n .map(({ pkg, version }) => {\n if (version) {\n return [pkg, version].join('@');\n }\n return pkg;\n })\n .join(' ')\n );\n}\n\n/** Install packages in the project. */\nasync function installPackagesAsync(projectRoot: string, { packages }: { packages: string[] }) {\n const packagesStr = chalk.bold(packages.join(', '));\n Log.log();\n const installingPackageStep = logNewSection(`Installing ${packagesStr}`);\n try {\n await installAsync(packages, { projectRoot });\n } catch (e: any) {\n installingPackageStep.fail(`Failed to install ${packagesStr} with error: ${e.message}`);\n throw e;\n }\n installingPackageStep.succeed(`Installed ${packagesStr}`);\n}\n"],"names":["ensureDependenciesAsync","createInstallCommand","Log","projectRoot","exp","getConfig","requiredPackages","warningMessage","installMessage","skipPrompt","isInteractive","missing","getMissingPackagesAsync","sdkVersion","length","readableMissingPackages","map","pkg","version","join","title","confirm","confirmAsync","message","wrapForTerminal","chalk","cyan","initial","packages","installPackagesAsync","installCommand","disableMessage","solution","bold","reset","CommandError","wrapAnsi","process","stdout","columns","packagesStr","log","installingPackageStep","logNewSection","installAsync","e","fail","succeed"],"mappings":"AAAA;;;;QAYsBA,uBAAuB,GAAvBA,uBAAuB;QAoF7BC,oBAAoB,GAApBA,oBAAoB;AAhGE,IAAA,OAAc,WAAd,cAAc,CAAA;AAClC,IAAA,MAAO,kCAAP,OAAO,EAAA;AACJ,IAAA,SAAW,kCAAX,WAAW,EAAA;AAEH,IAAA,aAA+B,WAA/B,+BAA+B,CAAA;AAChDC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACtB,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AAC5B,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACrB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACI,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExE,eAAeF,uBAAuB,CAC3CG,WAAmB,EACnB,EACEC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAa,CAAA,UAAb,CAACF,WAAW,CAAC,CAACC,GAAG,CAAA,EAChCE,gBAAgB,CAAA,EAChBC,cAAc,CAAA,EACdC,cAAc,CAAA,EACd,qBAAqB;AACrBC,UAAU,EAAG,CAACC,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,CAAA,EAO9B,EACiB;IAClB,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAG,MAAMC,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,CAAA,EAA0B,EAAE;IAC7F,MAAMY,WAAW,GAAGf,MAAK,QAAA,CAACQ,IAAI,CAACL,QAAQ,CAACT,IAAI,CAAC,IAAI,CAAC,CAAC,AAAC;IACpDjB,GAAG,CAACuC,GAAG,EAAE,CAAC;IACV,MAAMC,qBAAqB,GAAGC,CAAAA,GAAAA,IAAa,AAA6B,CAAA,cAA7B,CAAC,CAAC,WAAW,EAAEH,WAAW,CAAC,CAAC,CAAC,AAAC;IACzE,IAAI;QACF,MAAMI,CAAAA,GAAAA,aAAY,AAA2B,CAAA,aAA3B,CAAChB,QAAQ,EAAE;YAAEzB,WAAW;SAAE,CAAC,CAAC;KAC/C,CAAC,OAAO0C,CAAC,EAAO;QACfH,qBAAqB,CAACI,IAAI,CAAC,CAAC,kBAAkB,EAAEN,WAAW,CAAC,aAAa,EAAEK,CAAC,CAACtB,OAAO,CAAC,CAAC,CAAC,CAAC;QACxF,MAAMsB,CAAC,CAAC;KACT;IACDH,qBAAqB,CAACK,OAAO,CAAC,CAAC,UAAU,EAAEP,WAAW,CAAC,CAAC,CAAC,CAAC;CAC3D"}
@@ -65,11 +65,12 @@ class ExpoGoInstaller {
65
65
  /** Returns a boolean indicating if Expo Go should be installed. Returns `true` if the app was uninstalled. */ async uninstallExpoGoIfOutdatedAsync(deviceManager) {
66
66
  const cacheId = `${this.platform}-${deviceManager.identifier}`;
67
67
  if (ExpoGoInstaller.cache[cacheId]) {
68
+ debug("skipping subsequent upgrade check");
68
69
  return false;
69
70
  }
71
+ ExpoGoInstaller.cache[cacheId] = true;
70
72
  if (await this.isClientOutdatedAsync(deviceManager)) {
71
73
  // Only prompt once per device, per run.
72
- ExpoGoInstaller.cache[cacheId] = true;
73
74
  const confirm = await (0, _prompts).confirmAsync({
74
75
  initial: true,
75
76
  message: `Expo Go on ${deviceManager.name} is outdated, would you like to upgrade?`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/platforms/ExpoGoInstaller.ts"],"sourcesContent":["import semver from 'semver';\n\nimport { getVersionsAsync } from '../../api/getVersions';\nimport * as Log from '../../log';\nimport { downloadExpoGoAsync } from '../../utils/downloadExpoGoAsync';\nimport { logNewSection } from '../../utils/ora';\nimport { confirmAsync } from '../../utils/prompts';\nimport type { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:utils:ExpoGoInstaller') as typeof console.log;\n\n/** Given a platform, appId, and sdkVersion, this module will ensure that Expo Go is up-to-date on the provided device. */\nexport class ExpoGoInstaller<IDevice> {\n // Keep a list of [platform-deviceId] so we can prevent asking multiple times if a user wants to upgrade.\n // This can prevent annoying interactions when they don't want to upgrade for whatever reason.\n static cache: Record<string, boolean> = {};\n\n constructor(\n private platform: 'ios' | 'android',\n // Ultimately this should be inlined since we know the platform.\n private appId: string,\n private sdkVersion?: string\n ) {}\n\n /** Returns true if the installed app matching the previously provided `appId` is outdated. */\n async isClientOutdatedAsync(device: DeviceManager<IDevice>): Promise<boolean> {\n const installedVersion = await device.getAppVersionAsync(this.appId);\n if (!installedVersion) {\n return true;\n }\n const version = await this._getExpectedClientVersionAsync();\n debug(`Expected Expo Go version: ${version}, installed version: ${installedVersion}`);\n return version ? !semver.eq(installedVersion, version) : true;\n }\n\n /** Returns the expected version of Expo Go given the project SDK Version. Exposed for testing. */\n async _getExpectedClientVersionAsync(): Promise<string | null> {\n const versions = await getVersionsAsync();\n // Like `sdkVersions['44.0.0']['androidClientVersion'] = '1.0.0'`\n const specificVersion =\n versions?.sdkVersions?.[this.sdkVersion!]?.[`${this.platform}ClientVersion`];\n const latestVersion = versions[`${this.platform}Version`];\n return specificVersion ?? latestVersion ?? null;\n }\n\n /** Returns a boolean indicating if Expo Go should be installed. Returns `true` if the app was uninstalled. */\n async uninstallExpoGoIfOutdatedAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n const cacheId = `${this.platform}-${deviceManager.identifier}`;\n\n if (ExpoGoInstaller.cache[cacheId]) {\n return false;\n }\n if (await this.isClientOutdatedAsync(deviceManager)) {\n // Only prompt once per device, per run.\n ExpoGoInstaller.cache[cacheId] = true;\n const confirm = await confirmAsync({\n initial: true,\n message: `Expo Go on ${deviceManager.name} is outdated, would you like to upgrade?`,\n });\n if (confirm) {\n // Don't need to uninstall to update on iOS.\n if (this.platform !== 'ios') {\n Log.log(`Uninstalling Expo Go from ${this.platform} device ${deviceManager.name}.`);\n await deviceManager.uninstallAppAsync(this.appId);\n }\n return true;\n }\n }\n return false;\n }\n\n /** Check if a given device has Expo Go installed, if not then download and install it. */\n async ensureAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n let shouldInstall = !(await deviceManager.isAppInstalledAsync(this.appId));\n\n if (!shouldInstall) {\n shouldInstall = await this.uninstallExpoGoIfOutdatedAsync(deviceManager);\n }\n\n if (shouldInstall) {\n // Download the Expo Go app from the Expo servers.\n const binaryPath = await downloadExpoGoAsync(this.platform, { sdkVersion: this.sdkVersion });\n // Install the app on the device.\n const ora = logNewSection(`Installing Expo Go on ${deviceManager.name}`);\n try {\n await deviceManager.installAppAsync(binaryPath);\n } finally {\n ora.stop();\n }\n return true;\n }\n return false;\n }\n}\n"],"names":["Log","debug","require","ExpoGoInstaller","cache","constructor","platform","appId","sdkVersion","isClientOutdatedAsync","device","installedVersion","getAppVersionAsync","version","_getExpectedClientVersionAsync","semver","eq","versions","getVersionsAsync","specificVersion","sdkVersions","latestVersion","uninstallExpoGoIfOutdatedAsync","deviceManager","cacheId","identifier","confirm","confirmAsync","initial","message","name","log","uninstallAppAsync","ensureAsync","shouldInstall","isAppInstalledAsync","binaryPath","downloadExpoGoAsync","ora","logNewSection","installAppAsync","stop"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEM,IAAA,YAAuB,WAAvB,uBAAuB,CAAA;AAC5CA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACqB,IAAA,oBAAiC,WAAjC,iCAAiC,CAAA;AACvC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACl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AACzB,KAAK,CAAC,CAAC;iBACnD;gBACD,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;KACd;IAED,0FAA0F,CAC1F,MAAM0B,WAAW,CAACV,aAAqC,EAAoB;QACzE,IAAIW,aAAa,GAAG,CAAE,MAAMX,aAAa,CAACY,mBAAmB,CAAC,IAAI,CAAC5B,KAAK,CAAC,AAAC,AAAC;QAE3E,IAAI,CAAC2B,aAAa,EAAE;YAClBA,aAAa,GAAG,MAAM,IAAI,CAACZ,8BAA8B,CAACC,aAAa,CAAC,CAAC;SAC1E;QAED,IAAIW,aAAa,EAAE;YACjB,kDAAkD;YAClD,MAAME,UAAU,GAAG,MAAMC,CAAAA,GAAAA,oBAAmB,AAAgD,CAAA,oBAAhD,CAAC,IAAI,CAAC/B,QAAQ,EAAE;gBAAEE,UAAU,EAAE,IAAI,CAACA,UAAU;aAAE,CAAC,AAAC;YAC7F,iCAAiC;YACjC,MAAM8B,GAAG,GAAGC,CAAAA,GAAAA,IAAa,AAA+C,CAAA,cAA/C,CAAC,CAAC,sBAAsB,EAAEhB,aAAa,CAACO,IAAI,CAAC,CAAC,CAAC,AAAC;YACzE,IAAI;gBACF,MAAMP,aAAa,CAACiB,eAAe,CAACJ,UAAU,CAAC,CAAC;aACjD,QAAS;gBACRE,GAAG,CAACG,IAAI,EAAE,CAAC;aACZ;YACD,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;KACd;CACF;QAjFYtC,eAAe,GAAfA,eAAe"}
1
+ {"version":3,"sources":["../../../../src/start/platforms/ExpoGoInstaller.ts"],"sourcesContent":["import semver from 'semver';\n\nimport { getVersionsAsync } from '../../api/getVersions';\nimport * as Log from '../../log';\nimport { downloadExpoGoAsync } from '../../utils/downloadExpoGoAsync';\nimport { logNewSection } from '../../utils/ora';\nimport { confirmAsync } from '../../utils/prompts';\nimport type { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:utils:ExpoGoInstaller') as typeof console.log;\n\n/** Given a platform, appId, and sdkVersion, this module will ensure that Expo Go is up-to-date on the provided device. */\nexport class ExpoGoInstaller<IDevice> {\n // Keep a list of [platform-deviceId] so we can prevent asking multiple times if a user wants to upgrade.\n // This can prevent annoying interactions when they don't want to upgrade for whatever reason.\n static cache: Record<string, boolean> = {};\n\n constructor(\n private platform: 'ios' | 'android',\n // Ultimately this should be inlined since we know the platform.\n private appId: string,\n private sdkVersion?: string\n ) {}\n\n /** Returns true if the installed app matching the previously provided `appId` is outdated. */\n async isClientOutdatedAsync(device: DeviceManager<IDevice>): Promise<boolean> {\n const installedVersion = await device.getAppVersionAsync(this.appId);\n if (!installedVersion) {\n return true;\n }\n const version = await this._getExpectedClientVersionAsync();\n debug(`Expected Expo Go version: ${version}, installed version: ${installedVersion}`);\n return version ? !semver.eq(installedVersion, version) : true;\n }\n\n /** Returns the expected version of Expo Go given the project SDK Version. Exposed for testing. */\n async _getExpectedClientVersionAsync(): Promise<string | null> {\n const versions = await getVersionsAsync();\n // Like `sdkVersions['44.0.0']['androidClientVersion'] = '1.0.0'`\n const specificVersion =\n versions?.sdkVersions?.[this.sdkVersion!]?.[`${this.platform}ClientVersion`];\n const latestVersion = versions[`${this.platform}Version`];\n return specificVersion ?? latestVersion ?? null;\n }\n\n /** Returns a boolean indicating if Expo Go should be installed. Returns `true` if the app was uninstalled. */\n async uninstallExpoGoIfOutdatedAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n const cacheId = `${this.platform}-${deviceManager.identifier}`;\n\n if (ExpoGoInstaller.cache[cacheId]) {\n debug('skipping subsequent upgrade check');\n return false;\n }\n ExpoGoInstaller.cache[cacheId] = true;\n if (await this.isClientOutdatedAsync(deviceManager)) {\n // Only prompt once per device, per run.\n const confirm = await confirmAsync({\n initial: true,\n message: `Expo Go on ${deviceManager.name} is outdated, would you like to upgrade?`,\n });\n if (confirm) {\n // Don't need to uninstall to update on iOS.\n if (this.platform !== 'ios') {\n Log.log(`Uninstalling Expo Go from ${this.platform} device ${deviceManager.name}.`);\n await deviceManager.uninstallAppAsync(this.appId);\n }\n return true;\n }\n }\n return false;\n }\n\n /** Check if a given device has Expo Go installed, if not then download and install it. */\n async ensureAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n let shouldInstall = !(await deviceManager.isAppInstalledAsync(this.appId));\n\n if (!shouldInstall) {\n shouldInstall = await this.uninstallExpoGoIfOutdatedAsync(deviceManager);\n }\n\n if (shouldInstall) {\n // Download the Expo Go app from the Expo servers.\n const binaryPath = await downloadExpoGoAsync(this.platform, { sdkVersion: this.sdkVersion });\n // Install the app on the device.\n const ora = logNewSection(`Installing Expo Go on ${deviceManager.name}`);\n try {\n await deviceManager.installAppAsync(binaryPath);\n } finally {\n ora.stop();\n }\n return true;\n }\n return false;\n }\n}\n"],"names":["Log","debug","require","ExpoGoInstaller","cache","constructor","platform","appId","sdkVersion","isClientOutdatedAsync","device","installedVersion","getAppVersionAsync","version","_getExpectedClientVersionAsync","semver","eq","versions","getVersionsAsync","specificVersion","sdkVersions","latestVersion","uninstallExpoGoIfOutdatedAsync","deviceManager","cacheId","identifier","confirm","confirmAsync","initial","message","name","log","uninstallAppAsync","ensureAsync","shouldInstall","isAppInstalledAsync","binaryPath","downloadExpoGoAsync","ora","logNewSection","installAppAsync","stop"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEM,IAAA,YAAuB,WAAvB,uBAAuB,CAAA;AAC5CA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACqB,IAAA,oBAAiC,WAAjC,iCAAiC,CAAA;AACvC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGlD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,AAAsB,AAAC;AAG5E,MAAMC,eAAe;IAC1B,yGAAyG;IACzG,8FAA8F;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aAAa,GAAG,CAAE,MAAMX,aAAa,CAACY,mBAAmB,CAAC,IAAI,CAAC5B,KAAK,CAAC,AAAC,AAAC;QAE3E,IAAI,CAAC2B,aAAa,EAAE;YAClBA,aAAa,GAAG,MAAM,IAAI,CAACZ,8BAA8B,CAACC,aAAa,CAAC,CAAC;SAC1E;QAED,IAAIW,aAAa,EAAE;YACjB,kDAAkD;YAClD,MAAME,UAAU,GAAG,MAAMC,CAAAA,GAAAA,oBAAmB,AAAgD,CAAA,oBAAhD,CAAC,IAAI,CAAC/B,QAAQ,EAAE;gBAAEE,UAAU,EAAE,IAAI,CAACA,UAAU;aAAE,CAAC,AAAC;YAC7F,iCAAiC;YACjC,MAAM8B,GAAG,GAAGC,CAAAA,GAAAA,IAAa,AAA+C,CAAA,cAA/C,CAAC,CAAC,sBAAsB,EAAEhB,aAAa,CAACO,IAAI,CAAC,CAAC,CAAC,AAAC;YACzE,IAAI;gBACF,MAAMP,aAAa,CAACiB,eAAe,CAACJ,UAAU,CAAC,CAAC;aACjD,QAAS;gBACRE,GAAG,CAACG,IAAI,EAAE,CAAC;aACZ;YACD,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;KACd;CACF;QAlFYtC,eAAe,GAAfA,eAAe"}
@@ -30,7 +30,7 @@ class PlatformManager {
30
30
  // TODO: Expensive, we should only do this once.
31
31
  const { exp } = (0, _config).getConfig(this.projectRoot);
32
32
  const installedExpo = await deviceManager.ensureExpoGoAsync(exp.sdkVersion);
33
- await deviceManager.activateWindowAsync();
33
+ deviceManager.activateWindowAsync();
34
34
  await deviceManager.openUrlAsync(url);
35
35
  await (0, _rudderstackClient).logEventAsync("Open Url on Device", {
36
36
  platform: this.props.platform,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\n\nimport { logEventAsync } from '../../utils/analytics/rudderstackClient';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const url = this.props.getExpoGoUrl();\n // This should never happen, but just in case...\n assert(url, 'Could not get dev server URL');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const installedExpo = await deviceManager.ensureExpoGoAsync(exp.sdkVersion);\n\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo,\n });\n\n return { url };\n }\n\n private async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAsync(applicationId))) {\n throw new CommandError(\n `The development client (${applicationId}) for this project is not installed. ` +\n `Please build and install the client on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n // TODO: Rethink analytics\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo: false,\n });\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["debug","require","PlatformManager","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","openProjectInExpoGoAsync","resolveSettings","url","getExpoGoUrl","assert","deviceManager","resolveDeviceAsync","logOpeningUrl","exp","getConfig","installedExpo","ensureExpoGoAsync","sdkVersion","activateWindowAsync","openUrlAsync","logEventAsync","platform","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","applicationId","getAppIdAsync","isAppInstalledAsync","CommandError","learnMore","_resolveAlternativeLaunchUrl","openAsync","options","runtime","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":"AAAA;;;;AAA0B,IAAA,OAAc,WAAd,cAAc,CAAA;AACrB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEG,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AACtB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAC3C,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;;;;;;AAI5C,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAetF,MAAMC,eAAe;IAK1BC,YACYC,WAAmB,EACnBC,KAYT,CACD;aAdUD,WAAmB,GAAnBA,WAAmB;aACnBC,KAYT,GAZSA,KAYT;KACC;IAEJ,0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,CAAC,AAAC;QAC3EI,aAAa,CAACE,aAAa,CAACL,GAAG,CAAC,CAAC;QACjC,MAAMG,aAAa,CAACQ,mBAAmB,EAAE,CAAC;QAC1C,MAAMR,aAAa,CAACS,YAAY,CAACZ,GAAG,CAAC,CAAC;QAEtC,OAAO;YAAEA,GAAG;SAAE,CAAC;KAChB;IAED,8LAA8L,CAC9L6B,4BAA4B,CAC1BL,aAAqB,EACrB7B,KAAkC,GAAG,EAAE,EAC/B;QACR,MAAM,IAAIE,OAAkB,mBAAA,EAAE,CAAC;KAChC;CACF;QAlJYL,eAAe,GAAfA,eAAe"}
1
+ {"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\n\nimport { logEventAsync } from '../../utils/analytics/rudderstackClient';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const url = this.props.getExpoGoUrl();\n // This should never happen, but just in case...\n assert(url, 'Could not get dev server URL');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const installedExpo = await deviceManager.ensureExpoGoAsync(exp.sdkVersion);\n\n deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo,\n });\n\n return { url };\n }\n\n private async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAsync(applicationId))) {\n throw new CommandError(\n `The development client (${applicationId}) for this project is not installed. ` +\n `Please build and install the client on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n // TODO: Rethink analytics\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo: false,\n });\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["debug","require","PlatformManager","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","openProjectInExpoGoAsync","resolveSettings","url","getExpoGoUrl","assert","deviceManager","resolveDeviceAsync","logOpeningUrl","exp","getConfig","installedExpo","ensureExpoGoAsync","sdkVersion","activateWindowAsync","openUrlAsync","logEventAsync","platform","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","applicationId","getAppIdAsync","isAppInstalledAsync","CommandError","learnMore","_resolveAlternativeLaunchUrl","openAsync","options","runtime","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":"AAAA;;;;AAA0B,IAAA,OAAc,WAAd,cAAc,CAAA;AACrB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEG,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AACtB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAC3C,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;;;;;;AAI5C,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAetF,MAAMC,eAAe;IAK1BC,YACYC,WAAmB,EACnBC,KAYT,CACD;aAdUD,WAAmB,GAAnBA,WAAmB;aACnBC,KAYT,GAZSA,KAYT;KACC;IAEJ,0GAA0G,CAC1GC,iBAAiB,GAAkB;QACjC,MAAM,IAAIC,OAAkB,mBAAA,EAAE,CAAC;KAChC;IAED,MAAgBC,wBAAwB,CACtCC,eAA6C,GAAG,EAAE,EACxB;QAC1B,MAAMC,GAAG,GAAG,IAAI,CAACL,KAAK,CAACM,YAAY,EAAE,AAAC;QACtC,gDAAgD;QAChDC,CAAAA,GAAAA,OAAM,AAAqC,CAAA,QAArC,CAACF,GAAG,EAAE,8BAA8B,CAAC,CAAC;QAE5C,MAAMG,aAAa,GAAG,MAAM,IAAI,CAACR,KAAK,CAACS,kBAAkB,CAACL,eAAe,CAAC,AAAC;QAC3EI,aAAa,CAACE,aAAa,CAACL,GAAG,CAAC,CAAC;QAEjC,gDAAgD;QAChD,MAAM,EAAEM,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAAkB,CAAA,UAAlB,CAAC,IAAI,CAACb,WAAW,CAAC,AAAC;QAC5C,MAAMc,aAAa,GAAG,MAAML,aAAa,CAACM,iBAAiB,CAACH,GAAG,CAACI,UAAU,CAAC,AAAC;QAE5EP,aAAa,CAACQ,mB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