@expo/cli 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/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.4.1");
124
+ console.log("0.4.3");
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.4.1"
251
+ source_version: "0.4.3"
252
252
  });
253
253
  });
254
254
 
@@ -94,7 +94,7 @@ async function exportAppAsync(projectRoot, { platforms , outputDir , clear , dev
94
94
  const saveAssets = (0, _resolveFromProject).importCliSaveAssetsFromProject(projectRoot);
95
95
  await Promise.all(Object.entries(bundles).map(([platform, bundle])=>{
96
96
  return saveAssets(// @ts-expect-error: tolerable type mismatches: unused `readonly` (common in Metro) and `undefined` instead of `null`.
97
- bundle.assets, platform, outputPath);
97
+ bundle.assets, platform, outputPath, undefined);
98
98
  }));
99
99
  }
100
100
  const { assets } = await (0, _exportAssets).exportAssetsAsync(projectRoot, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { importCliSaveAssetsFromProject } from '../start/server/metro/resolveFromProject';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync } from './exportAssets';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n }: Pick<Options, 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms'>\n): Promise<void> {\n const exp = await getPublicExpoManifestAsync(projectRoot);\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const assetsPath = path.join(outputPath, 'assets');\n const bundlesPath = path.join(outputPath, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, outputDir);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n dev,\n useDevServer: true,\n // TODO: Disable source map generation if we aren't outputting them.\n }\n );\n\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n Object.entries(bundles).map(([key, value]) => {\n if (!dumpSourcemap) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({ bundles, outputDir: bundlesPath });\n\n Log.log('Finished saving JS Bundles');\n\n if (fileNames.web) {\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(\n path.join(outputPath, 'index.html'),\n await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`/bundles/${fileNames.web}`],\n })\n );\n\n // Save assets like a typical bundler, preserving the file paths on web.\n const saveAssets = importCliSaveAssetsFromProject(projectRoot);\n await Promise.all(\n Object.entries(bundles).map(([platform, bundle]) => {\n return saveAssets(\n // @ts-expect-error: tolerable type mismatches: unused `readonly` (common in Metro) and `undefined` instead of `null`.\n bundle.assets,\n platform,\n outputPath\n );\n })\n );\n }\n\n const { assets } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: outputPath,\n bundles,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: outputPath, assets });\n }\n\n // build source maps\n if (dumpSourcemap) {\n Log.log('Dumping source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: outputPath,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir, bundles, fileNames });\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","dumpSourcemap","exp","getPublicExpoManifestAsync","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","resetCache","useDevServer","printBundleSizes","Object","fromEntries","entries","key","value","undefined","hashes","fileNames","writeBundlesAsync","log","web","fs","promises","writeFile","createTemplateHtmlFromExpoConfigAsync","scripts","saveAssets","importCliSaveAssetsFromProject","platform","bundle","assets","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","publicFolder","outputFolder","existsSync","copyAsync"],"mappings":"AAAA;;;;QAiCsBA,cAAc,GAAdA,cAAc;AAjCrB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,mBAA0C,WAA1C,0CAA0C,CAAA;AACnC,IAAA,YAA6B,WAA7B,6BAA6B,CAAA;AACnC,IAAA,IAAc,WAAd,cAAc,CAAA;AAC1C,IAAA,IAAc,WAAd,cAAc,CAAA;AACC,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AACP,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AACnC,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAQ9C,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcjB,eAAeD,cAAc,CAClCE,WAAmB,EACnB,EACEC,SAAS,CAAA,EACTC,SAAS,CAAA,EACTC,KAAK,CAAA,EACLC,GAAG,CAAA,EACHC,YAAY,CAAA,EACZC,aAAa,CAAA,EACiF,EACjF;IACf,MAAMC,GAAG,GAAG,MAAMC,CAAAA,GAAAA,sBAA0B,AAAa,CAAA,2BAAb,CAACR,WAAW,CAAC,AAAC;IAE1D,MAAMS,UAAU,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACX,WAAW,EAAEY,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;IAErE,MAAMC,UAAU,GAAGJ,KAAI,QAAA,CAACC,OAAO,CAACX,WAAW,EAAEE,SAAS,CAAC,AAAC;IACxD,MAAMa,UAAU,GAAGL,KAAI,QAAA,CAACM,IAAI,CAACF,UAAU,EAAE,QAAQ,CAAC,AAAC;I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,SAAS,EAAEe,WAAW;YACtBkB,SAAS;SACV,CAAC,CAAC;QAEHpC,GAAG,CAACsC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAChD,kFAAkF;QAClF,kDAAkD;QAClD,MAAMe,CAAAA,GAAAA,cAAmB,AAGvB,CAAA,oBAHuB,CAAC;YACxBlD,SAAS,EAAEY,UAAU;YACrBqB,SAAS;SACV,CAAC,CAAC;KACJ;IAED,yDAAyD;IACzD,MAAMkB,CAAAA,GAAAA,cAAsB,AAAmC,CAAA,uBAAnC,CAAC;QAAEnD,SAAS;QAAEqB,OAAO;QAAEY,SAAS;KAAE,CAAC,CAAC;CACjE;AAED;;;;;;;GAOG,CACH,eAAeb,qBAAqB,CAACgC,YAAoB,EAAEC,YAAoB,EAAE;IAC/E,IAAIhB,GAAE,QAAA,CAACiB,UAAU,CAACF,YAAY,CAAC,EAAE;QAC/B,MAAMG,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACH,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}
1
+ {"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { importCliSaveAssetsFromProject } from '../start/server/metro/resolveFromProject';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { copyAsync, ensureDirectoryAsync } from '../utils/dir';\nimport { env } from '../utils/env';\nimport { createBundlesAsync } from './createBundles';\nimport { exportAssetsAsync } from './exportAssets';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { printBundleSizes } from './printBundleSizes';\nimport { Options } from './resolveOptions';\nimport {\n writeAssetMapAsync,\n writeBundlesAsync,\n writeDebugHtmlAsync,\n writeMetadataJsonAsync,\n writeSourceMapsAsync,\n} from './writeContents';\n\n/**\n * The structure of the outputDir will be:\n *\n * ```\n * ├── assets\n * │ └── *\n * ├── bundles\n * │ ├── android-01ee6e3ab3e8c16a4d926c91808d5320.js\n * │ └── ios-ee8206cc754d3f7aa9123b7f909d94ea.js\n * └── metadata.json\n * ```\n */\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n dumpSourcemap,\n }: Pick<Options, 'dumpAssetmap' | 'dumpSourcemap' | 'dev' | 'clear' | 'outputDir' | 'platforms'>\n): Promise<void> {\n const exp = await getPublicExpoManifestAsync(projectRoot);\n\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n const outputPath = path.resolve(projectRoot, outputDir);\n const assetsPath = path.join(outputPath, 'assets');\n const bundlesPath = path.join(outputPath, 'bundles');\n\n await Promise.all([assetsPath, bundlesPath].map(ensureDirectoryAsync));\n\n await copyPublicFolderAsync(publicPath, outputDir);\n\n // Run metro bundler and create the JS bundles/source maps.\n const bundles = await createBundlesAsync(\n projectRoot,\n { resetCache: !!clear },\n {\n platforms,\n dev,\n useDevServer: true,\n // TODO: Disable source map generation if we aren't outputting them.\n }\n );\n\n // Log bundle size info to the user\n printBundleSizes(\n Object.fromEntries(\n Object.entries(bundles).map(([key, value]) => {\n if (!dumpSourcemap) {\n return [\n key,\n {\n ...value,\n // Remove source maps from the bundles if they aren't going to be written.\n map: undefined,\n },\n ];\n }\n\n return [key, value];\n })\n )\n );\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n const { hashes, fileNames } = await writeBundlesAsync({ bundles, outputDir: bundlesPath });\n\n Log.log('Finished saving JS Bundles');\n\n if (fileNames.web) {\n // If web exists, then write the template HTML file.\n await fs.promises.writeFile(\n path.join(outputPath, 'index.html'),\n await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [`/bundles/${fileNames.web}`],\n })\n );\n\n // Save assets like a typical bundler, preserving the file paths on web.\n const saveAssets = importCliSaveAssetsFromProject(projectRoot);\n await Promise.all(\n Object.entries(bundles).map(([platform, bundle]) => {\n return saveAssets(\n // @ts-expect-error: tolerable type mismatches: unused `readonly` (common in Metro) and `undefined` instead of `null`.\n bundle.assets,\n platform,\n outputPath,\n undefined\n );\n })\n );\n }\n\n const { assets } = await exportAssetsAsync(projectRoot, {\n exp,\n outputDir: outputPath,\n bundles,\n });\n\n if (dumpAssetmap) {\n Log.log('Dumping asset map');\n await writeAssetMapAsync({ outputDir: outputPath, assets });\n }\n\n // build source maps\n if (dumpSourcemap) {\n Log.log('Dumping source maps');\n await writeSourceMapsAsync({\n bundles,\n hashes,\n outputDir: bundlesPath,\n fileNames,\n });\n\n Log.log('Preparing additional debugging files');\n // If we output source maps, then add a debug HTML file which the user can open in\n // the web browser to inspect the output like web.\n await writeDebugHtmlAsync({\n outputDir: outputPath,\n fileNames,\n });\n }\n\n // Generate a `metadata.json` and the export is complete.\n await writeMetadataJsonAsync({ outputDir, bundles, fileNames });\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nasync function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["exportAppAsync","Log","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","dumpSourcemap","exp","getPublicExpoManifestAsync","publicPath","path","resolve","env","EXPO_PUBLIC_FOLDER","outputPath","assetsPath","join","bundlesPath","Promise","all","map","ensureDirectoryAsync","copyPublicFolderAsync","bundles","createBundlesAsync","resetCache","useDevServer","printBundleSizes","Object","fromEntries","entries","key","value","undefined","hashes","fileNames","writeBundlesAsync","log","web","fs","promises","writeFile","createTemplateHtmlFromExpoConfigAsync","scripts","saveAssets","importCliSaveAssetsFromProject","platform","bundle","assets","exportAssetsAsync","writeAssetMapAsync","writeSourceMapsAsync","writeDebugHtmlAsync","writeMetadataJsonAsync","publicFolder","outputFolder","existsSync","copyAsync"],"mappings":"AAAA;;;;QAi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ClD,MAAMe,CAAAA,GAAAA,cAAmB,AAGvB,CAAA,oBAHuB,CAAC;YACxBlD,SAAS,EAAEY,UAAU;YACrBqB,SAAS;SACV,CAAC,CAAC;KACJ;IAED,yDAAyD;IACzD,MAAMkB,CAAAA,GAAAA,cAAsB,AAAmC,CAAA,uBAAnC,CAAC;QAAEnD,SAAS;QAAEqB,OAAO;QAAEY,SAAS;KAAE,CAAC,CAAC;CACjE;AAED;;;;;;;GAOG,CACH,eAAeb,qBAAqB,CAACgC,YAAoB,EAAEC,YAAoB,EAAE;IAC/E,IAAIhB,GAAE,QAAA,CAACiB,UAAU,CAACF,YAAY,CAAC,EAAE;QAC/B,MAAMG,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACH,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}
@@ -52,19 +52,20 @@ const expoExport = async (argv)=>{
52
52
  "-h": "--help",
53
53
  // '-s': '--dump-sourcemap',
54
54
  // '-d': '--dump-assetmap',
55
- "-c": "--clear"
55
+ "-c": "--clear",
56
+ "-p": "--platform"
56
57
  }, argv);
57
58
  if (args["--help"]) {
58
59
  (0, _args).printHelp(`Export the static files of the app for hosting it on a web server`, _chalk.default`npx expo export {dim <dir>}`, [
59
- _chalk.default`<dir> Directory of the Expo project. {dim Default: Current working directory}`,
60
- _chalk.default`--platform <platform> Options: android, ios, web, all. {dim Default: all}`,
61
- `--dev Configure static files for developing locally using a non-https server`,
62
- _chalk.default`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,
63
- `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,
64
- `--dump-assetmap Dump the asset map for further processing`,
65
- `--dump-sourcemap Dump the source map for debugging the JS bundle`,
66
- `-c, --clear Clear the bundler cache`,
67
- `-h, --help Usage info`,
60
+ _chalk.default`<dir> Directory of the Expo project. {dim Default: Current working directory}`,
61
+ `--dev Configure static files for developing locally using a non-https server`,
62
+ _chalk.default`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,
63
+ `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,
64
+ `--dump-assetmap Dump the asset map for further processing`,
65
+ `--dump-sourcemap Dump the source map for debugging the JS bundle`,
66
+ _chalk.default`-p, --platform <platform> Options: android, ios, web, all. {dim Default: all}`,
67
+ `-c, --clear Clear the bundler cache`,
68
+ `-h, --help Usage info`,
68
69
  ].join("\n"));
69
70
  }
70
71
  const projectRoot = (0, _args).getProjectRoot(args);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoExport: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clear': Boolean,\n '--dump-assetmap': Boolean,\n '--dev': Boolean,\n '--dump-sourcemap': Boolean,\n '--max-workers': Number,\n '--output-dir': String,\n '--platform': String,\n\n // Hack: This is added because EAS CLI always includes the flag.\n // If supplied, we'll do nothing with the value, but at least the process won't crash.\n // Note that we also don't show this value in the `--help` prompt since we don't want people to use it.\n '--experimental-bundle': Boolean,\n\n // Aliases\n '-h': '--help',\n // '-s': '--dump-sourcemap',\n // '-d': '--dump-assetmap',\n '-c': '--clear',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Export the static files of the app for hosting it on a web server`,\n chalk`npx expo export {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n chalk`--platform <platform> Options: android, ios, web, all. {dim Default: all}`,\n `--dev Configure static files for developing locally using a non-https server`,\n chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,\n `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,\n `--dump-assetmap Dump the asset map for further processing`,\n `--dump-sourcemap Dump the source map for debugging the JS bundle`,\n `-c, --clear Clear the bundler cache`,\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const projectRoot = getProjectRoot(args);\n const { resolveOptionsAsync } = await import('./resolveOptions');\n const options = await resolveOptionsAsync(projectRoot, args).catch(logCmdError);\n\n const { exportAsync } = await import('./exportAsync');\n return exportAsync(projectRoot, options).catch(logCmdError);\n};\n"],"names":["expoExport","argv","args","assertArgs","Boolean","Number","String","printHelp","chalk","join","projectRoot","getProjectRoot","resolveOptionsAsync","options","catch","logCmdError","exportAsync"],"mappings":"AAAA;;;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAG6B,IAAA,KAAe,WAAf,eAAe,CAAA;AACzC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMA,UAAU,GAAY,OAAOC,IAAI,GAAK;IACjD,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAU,AAwBtB,CAAA,WAxBsB,CACrB;QACE,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,SAAS,EAAEA,OAAO;QAClB,iBAAiB,EAAEA,OAAO;QAC1B,OAAO,EAAEA,OAAO;QAChB,kBAAkB,EAAEA,OAAO;QAC3B,eAAe,EAAEC,MAAM;QACvB,cAAc,EAAEC,MAAM;QACtB,YAAY,EAAEA,MAAM;QAEpB,gEAAgE;QAChE,sFAAsF;QACtF,uGAAuG;QACvG,uBAAuB,EAAEF,OAAO;QAEhC,UAAU;QACV,IAAI,EAAE,QAAQ;QACd,4BAA4B;QAC5B,2BAA2B;QAC3B,IAAI,EAAE,SAAS;KAChB,EACDH,IAAI,CACL,AAAC;IAEF,IAAIC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClBK,CAAAA,GAAAA,KAAS,AAcR,CAAA,UAdQ,CACP,CAAC,iEAAiE,CAAC,EACnEC,MAAK,QAAA,CAAC,2BAA2B,CAAC,EAClC;YACEA,MAAK,QAAA,CAAC,+FAA+F,CAAC;YACtGA,MAAK,QAAA,CAAC,2EAA2E,CAAC;YAClF,CAAC,8FAA8F,CAAC;YAChGA,MAAK,QAAA,CAAC,wFAAwF,CAAC;YAC/F,CAAC,6EAA6E,CAAC;YAC/E,CAAC,iEAAiE,CAAC;YACnE,CAAC,uEAAuE,CAAC;YACzE,CAAC,+CAA+C,CAAC;YACjD,CAAC,kCAAkC,CAAC;SACrC,CAACC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;KACH;IAED,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,KAAc,AAAM,CAAA,eAAN,CAACT,IAAI,CAAC,AAAC;IACzC,MAAM,EAAEU,mBAAmB,CAAA,EAAE,GAAG,MAAM;+CAAO,kBAAkB;MAAC,AAAC;IACjE,MAAMC,OAAO,GAAG,MAAMD,mBAAmB,CAACF,WAAW,EAAER,IAAI,CAAC,CAACY,KAAK,CAACC,OAAW,YAAA,CAAC,AAAC;IAEhF,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAG,MAAM;+CAAO,eAAe;MAAC,AAAC;IACtD,OAAOA,WAAW,CAACN,WAAW,EAAEG,OAAO,CAAC,CAACC,KAAK,CAACC,OAAW,YAAA,CAAC,CAAC;CAC7D,AAAC;QAnDWf,UAAU,GAAVA,UAAU"}
1
+ {"version":3,"sources":["../../../src/export/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoExport: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clear': Boolean,\n '--dump-assetmap': Boolean,\n '--dev': Boolean,\n '--dump-sourcemap': Boolean,\n '--max-workers': Number,\n '--output-dir': String,\n '--platform': String,\n\n // Hack: This is added because EAS CLI always includes the flag.\n // If supplied, we'll do nothing with the value, but at least the process won't crash.\n // Note that we also don't show this value in the `--help` prompt since we don't want people to use it.\n '--experimental-bundle': Boolean,\n\n // Aliases\n '-h': '--help',\n // '-s': '--dump-sourcemap',\n // '-d': '--dump-assetmap',\n '-c': '--clear',\n '-p': '--platform',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Export the static files of the app for hosting it on a web server`,\n chalk`npx expo export {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n `--dev Configure static files for developing locally using a non-https server`,\n chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,\n `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,\n `--dump-assetmap Dump the asset map for further processing`,\n `--dump-sourcemap Dump the source map for debugging the JS bundle`,\n chalk`-p, --platform <platform> Options: android, ios, web, all. {dim Default: all}`,\n `-c, --clear Clear the bundler cache`,\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const projectRoot = getProjectRoot(args);\n const { resolveOptionsAsync } = await import('./resolveOptions');\n const options = await resolveOptionsAsync(projectRoot, args).catch(logCmdError);\n\n const { exportAsync } = await import('./exportAsync');\n return exportAsync(projectRoot, options).catch(logCmdError);\n};\n"],"names":["expoExport","argv","args","assertArgs","Boolean","Number","String","printHelp","chalk","join","projectRoot","getProjectRoot","resolveOptionsAsync","options","catch","logCmdError","exportAsync"],"mappings":"AAAA;;;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAG6B,IAAA,KAAe,WAAf,eAAe,CAAA;AACzC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMA,UAAU,GAAY,OAAOC,IAAI,GAAK;IACjD,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAU,AAyBtB,CAAA,WAzBsB,CACrB;QACE,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,SAAS,EAAEA,OAAO;QAClB,iBAAiB,EAAEA,OAAO;QAC1B,OAAO,EAAEA,OAAO;QAChB,kBAAkB,EAAEA,OAAO;QAC3B,eAAe,EAAEC,MAAM;QACvB,cAAc,EAAEC,MAAM;QACtB,YAAY,EA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asRequiredIOSFilesAsync(projectRoot) {
73
73
  try {
74
74
  // If any of the following required files are missing, then the project is malformed.
75
75
  await Promise.all([
76
- _configPlugins.IOSConfig.Paths.getAppDelegate(projectRoot),
77
76
  _configPlugins.IOSConfig.Paths.getAllXcodeProjectPaths(projectRoot),
78
- _configPlugins.IOSConfig.Paths.getAllInfoPlistPaths(projectRoot),
79
77
  _configPlugins.IOSConfig.Paths.getAllPBXProjectPaths(projectRoot),
80
78
  ]);
81
79
  return true;
@@ -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 { 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,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAA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C;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"}
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.getAllXcodeProjectPaths(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","getAllXcodeProjectPaths","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;QAoCxBC,+BAA+B,GAA/BA,+BAA+B;QAsB/BC,yCAAyC,GAAzCA,yCAAyC;AA9GT,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1D,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAA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,CAACF,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,EAAE;YACpB5C,GAAG,CAAC+C,IAAI,CAAC,CAAC,EAAE5B,OAAO,CAAC,kDAAkD,CAAC,CAAC,CAAC;SAC1E;QACD,MAAMxB,iBAAiB,CAACM,WAAW,EAAE6B,SAAS,CAAC,CAAC;KACjD,MAAM;QACL,2CAA2C;QAC3C9B,GAAG,CAAC+C,IAAI,CAAC,2CAA2C,CAAC,CAAC;KACvD;CACF"}
@@ -4,11 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.createCopyFilesSuccessMessage = createCopyFilesSuccessMessage;
6
6
  exports.copyTemplateFilesAsync = copyTemplateFilesAsync;
7
+ exports.resolveBareEntryFile = resolveBareEntryFile;
8
+ var _paths = require("@expo/config/paths");
7
9
  var _chalk = _interopRequireDefault(require("chalk"));
8
10
  var _fs = _interopRequireDefault(require("fs"));
9
11
  var _path = _interopRequireDefault(require("path"));
10
12
  var _dir = require("../utils/dir");
11
13
  var _mergeGitIgnorePaths = require("../utils/mergeGitIgnorePaths");
14
+ var _updatePackageJson = require("./updatePackageJson");
12
15
  function _interopRequireDefault(obj) {
13
16
  return obj && obj.__esModule ? obj : {
14
17
  default: obj
@@ -39,14 +42,11 @@ function createCopyFilesSuccessMessage(platforms, { skippedPaths , gitignore })
39
42
  }
40
43
  return message;
41
44
  }
42
- async function copyTemplateFilesAsync(projectRoot, { templateDirectory , platforms }) {
45
+ async function copyTemplateFilesAsync(projectRoot, { pkg , templateDirectory , platforms }) {
46
+ const copyFilePaths = getFilePathsToCopy(projectRoot, pkg, platforms);
43
47
  const copyResults = await copyPathsFromTemplateAsync(projectRoot, {
44
48
  templateDirectory,
45
- copyFilePaths: [
46
- // Just copy over the native folders from the template
47
- // we copy the metro file in a different way.
48
- ...platforms,
49
- ]
49
+ copyFilePaths
50
50
  });
51
51
  const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(templateDirectory, platforms);
52
52
  debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);
@@ -75,5 +75,32 @@ async function copyPathsFromTemplateAsync(/** File path to the project. */ proje
75
75
  skippedPaths
76
76
  };
77
77
  }
78
+ /** Get a list of relative file paths to copy from the template folder. Example: `['ios', 'android', 'index.js']` */ function getFilePathsToCopy(projectRoot, pkg, platforms) {
79
+ const targetPaths = [
80
+ ...platforms
81
+ ];
82
+ const bareEntryFile = resolveBareEntryFile(projectRoot, pkg.main);
83
+ // Only create index.js if we cannot resolve the existing entry point (after replacing the expo entry).
84
+ if (!bareEntryFile) {
85
+ targetPaths.push("index.js");
86
+ }
87
+ debug(`Files to copy:`, targetPaths);
88
+ return targetPaths;
89
+ }
90
+ function resolveBareEntryFile(projectRoot, main) {
91
+ // expo app entry is not needed for bare projects.
92
+ if ((0, _updatePackageJson).isPkgMainExpoAppEntry(main)) {
93
+ return null;
94
+ }
95
+ // Look at the `package.json`s `main` field for the main file.
96
+ const resolvedMainField = main != null ? main : "./index";
97
+ // Get a list of possible extensions for the main file.
98
+ const extensions = (0, _paths).getBareExtensions([
99
+ "ios",
100
+ "android"
101
+ ]);
102
+ // Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path.
103
+ return (0, _paths).getFileWithExtensions(projectRoot, resolvedMainField, extensions);
104
+ }
78
105
 
79
106
  //# sourceMappingURL=copyTemplateFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/copyTemplateFiles.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport { MergeResults } from '@expo/config-plugins/build/utils/generateCode';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { copySync, directoryExistsAsync } from '../utils/dir';\nimport { mergeGitIgnorePaths } from '../utils/mergeGitIgnorePaths';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\ntype CopyFilesResults = {\n /** Merge results for the root `.gitignore` file */\n gitignore: MergeResults | null;\n /** List of file paths that were copied from the template into the project. */\n copiedPaths: string[];\n /** List of file paths that were skipped due to a number of factors. */\n skippedPaths: string[];\n};\n\n/**\n * Return true if the given platforms all have an internal `.gitignore` file.\n *\n * @param projectRoot\n * @param platforms\n */\nfunction hasAllPlatformSpecificGitIgnores(projectRoot: string, platforms: ModPlatform[]): boolean {\n return platforms.reduce<boolean>(\n (p, platform) => p && fs.existsSync(path.join(projectRoot, platform, '.gitignore')),\n true\n );\n}\n\n/** Create a custom log message based on the copy file results. */\nexport function createCopyFilesSuccessMessage(\n platforms: ModPlatform[],\n { skippedPaths, gitignore }: CopyFilesResults\n): string {\n let message = `Created native project${platforms.length > 1 ? 's' : ''}`;\n\n if (skippedPaths.length) {\n message += chalk.dim(\n ` | ${skippedPaths.map((path) => chalk.bold(`/${path}`)).join(', ')} already created`\n );\n }\n if (!gitignore) {\n message += chalk.dim(` | gitignore skipped`);\n } else if (!gitignore.didMerge) {\n message += chalk.dim(` | gitignore already synced`);\n } else if (gitignore.didMerge && gitignore.didClear) {\n message += chalk.dim(` | synced gitignore`);\n }\n return message;\n}\n\n/** Copy template files into the project and possibly merge the `.gitignore` files. */\nexport async function copyTemplateFilesAsync(\n projectRoot: string,\n {\n templateDirectory,\n platforms,\n }: {\n /** File path to the template directory. */\n templateDirectory: string;\n /** List of platforms to copy against. */\n platforms: ModPlatform[];\n }\n): Promise<CopyFilesResults> {\n const copyResults = await copyPathsFromTemplateAsync(projectRoot, {\n templateDirectory,\n copyFilePaths: [\n // Just copy over the native folders from the template\n // we copy the metro file in a different way.\n ...platforms,\n ],\n });\n\n const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(\n templateDirectory,\n platforms\n );\n debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);\n const gitignore = hasPlatformSpecificGitIgnores\n ? null\n : mergeGitIgnorePaths(\n path.join(projectRoot, '.gitignore'),\n path.join(templateDirectory, '.gitignore')\n );\n\n return { ...copyResults, gitignore };\n}\n\nasync function copyPathsFromTemplateAsync(\n /** File path to the project. */\n projectRoot: string,\n {\n templateDirectory,\n copyFilePaths,\n }: {\n /** File path to the template project. */\n templateDirectory: string;\n /** List of relative paths to copy from the template to the project. */\n copyFilePaths: string[];\n }\n): Promise<Pick<CopyFilesResults, 'copiedPaths' | 'skippedPaths'>> {\n const copiedPaths = [];\n const skippedPaths = [];\n for (const copyFilePath of copyFilePaths) {\n const projectPath = path.join(projectRoot, copyFilePath);\n if (!(await directoryExistsAsync(projectPath))) {\n copiedPaths.push(copyFilePath);\n copySync(path.join(templateDirectory, copyFilePath), projectPath);\n } else {\n skippedPaths.push(copyFilePath);\n }\n }\n debug(`Copied files:`, copiedPaths);\n debug(`Skipped files:`, copiedPaths);\n return { copiedPaths, skippedPaths };\n}\n"],"names":["createCopyFilesSuccessMessage","copyTemplateFilesAsync","debug","require","hasAllPlatformSpecificGitIgnores","projectRoot","platforms","reduce","p","platform","fs","existsSync","path","join","skippedPaths","gitignore","message","length","chalk","dim","map","bold","didMerge","didClear","templateDirectory","copyResults","copyPathsFromTemplateAsync","copyFilePaths","hasPlatformSpecificGitIgnores","mergeGitIgnorePaths","copiedPaths","copyFilePath","projectPath","directoryExistsAsync","push","copySync"],"mappings":"AAAA;;;;QAkCgBA,6BAA6B,GAA7BA,6BAA6B;QAsBvBC,sBAAsB,GAAtBA,sBAAsB;AAtD1B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEwB,IAAA,IAAc,WAAd,cAAc,CAAA;AACzB,IAAA,oBAA8B,WAA9B,8BAA8B,CAAA;;;;;;AAElE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAWxF;;;;;GAKG,CACH,SAASC,gCAAgC,CAACC,WAAmB,EAAEC,SAAwB,EA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,EAAEO,YAAY,CAAC,EAAEC,WAAW,CAAC,CAAC;SACnE,MAAM;YACLlB,YAAY,CAACoB,IAAI,CAACH,YAAY,CAAC,CAAC;SACjC;KACF;IACD7B,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE4B,WAAW,CAAC,CAAC;IACpC5B,KAAK,CAAC,CAAC,cAAc,CAAC,EAAE4B,WAAW,CAAC,CAAC;IACrC,OAAO;QAAEA,WAAW;QAAEhB,YAAY;KAAE,CAAC;CACtC"}
1
+ {"version":3,"sources":["../../../src/prebuild/copyTemplateFiles.ts"],"sourcesContent":["import { PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport { MergeResults } from '@expo/config-plugins/build/utils/generateCode';\nimport { getBareExtensions, getFileWithExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { copySync, directoryExistsAsync } from '../utils/dir';\nimport { mergeGitIgnorePaths } from '../utils/mergeGitIgnorePaths';\nimport { isPkgMainExpoAppEntry } from './updatePackageJson';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\ntype CopyFilesResults = {\n /** Merge results for the root `.gitignore` file */\n gitignore: MergeResults | null;\n /** List of file paths that were copied from the template into the project. */\n copiedPaths: string[];\n /** List of file paths that were skipped due to a number of factors. */\n skippedPaths: string[];\n};\n\n/**\n * Return true if the given platforms all have an internal `.gitignore` file.\n *\n * @param projectRoot\n * @param platforms\n */\nfunction hasAllPlatformSpecificGitIgnores(projectRoot: string, platforms: ModPlatform[]): boolean {\n return platforms.reduce<boolean>(\n (p, platform) => p && fs.existsSync(path.join(projectRoot, platform, '.gitignore')),\n true\n );\n}\n\n/** Create a custom log message based on the copy file results. */\nexport function createCopyFilesSuccessMessage(\n platforms: ModPlatform[],\n { skippedPaths, gitignore }: CopyFilesResults\n): string {\n let message = `Created native project${platforms.length > 1 ? 's' : ''}`;\n\n if (skippedPaths.length) {\n message += chalk.dim(\n ` | ${skippedPaths.map((path) => chalk.bold(`/${path}`)).join(', ')} already created`\n );\n }\n if (!gitignore) {\n message += chalk.dim(` | gitignore skipped`);\n } else if (!gitignore.didMerge) {\n message += chalk.dim(` | gitignore already synced`);\n } else if (gitignore.didMerge && gitignore.didClear) {\n message += chalk.dim(` | synced gitignore`);\n }\n return message;\n}\n\n/** Copy template files into the project and possibly merge the `.gitignore` files. */\nexport async function copyTemplateFilesAsync(\n projectRoot: string,\n {\n pkg,\n templateDirectory,\n platforms,\n }: {\n /** Project `package.json` as JSON. */\n pkg: PackageJSONConfig;\n /** File path to the template directory. */\n templateDirectory: string;\n /** List of platforms to copy against. */\n platforms: ModPlatform[];\n }\n): Promise<CopyFilesResults> {\n const copyFilePaths = getFilePathsToCopy(projectRoot, pkg, platforms);\n\n const copyResults = await copyPathsFromTemplateAsync(projectRoot, {\n templateDirectory,\n copyFilePaths,\n });\n\n const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(\n templateDirectory,\n platforms\n );\n debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);\n const gitignore = hasPlatformSpecificGitIgnores\n ? null\n : mergeGitIgnorePaths(\n path.join(projectRoot, '.gitignore'),\n path.join(templateDirectory, '.gitignore')\n );\n\n return { ...copyResults, gitignore };\n}\n\nasync function copyPathsFromTemplateAsync(\n /** File path to the project. */\n projectRoot: string,\n {\n templateDirectory,\n copyFilePaths,\n }: {\n /** File path to the template project. */\n templateDirectory: string;\n /** List of relative paths to copy from the template to the project. */\n copyFilePaths: string[];\n }\n): Promise<Pick<CopyFilesResults, 'copiedPaths' | 'skippedPaths'>> {\n const copiedPaths = [];\n const skippedPaths = [];\n for (const copyFilePath of copyFilePaths) {\n const projectPath = path.join(projectRoot, copyFilePath);\n if (!(await directoryExistsAsync(projectPath))) {\n copiedPaths.push(copyFilePath);\n copySync(path.join(templateDirectory, copyFilePath), projectPath);\n } else {\n skippedPaths.push(copyFilePath);\n }\n }\n debug(`Copied files:`, copiedPaths);\n debug(`Skipped files:`, copiedPaths);\n return { copiedPaths, skippedPaths };\n}\n\n/** Get a list of relative file paths to copy from the template folder. Example: `['ios', 'android', 'index.js']` */\nfunction getFilePathsToCopy(projectRoot: string, pkg: PackageJSONConfig, platforms: ModPlatform[]) {\n const targetPaths: string[] = [...platforms];\n\n const bareEntryFile = resolveBareEntryFile(projectRoot, pkg.main);\n // Only create index.js if we cannot resolve the existing entry point (after replacing the expo entry).\n if (!bareEntryFile) {\n targetPaths.push('index.js');\n }\n\n debug(`Files to copy:`, targetPaths);\n return targetPaths;\n}\n\nexport function resolveBareEntryFile(projectRoot: string, main: any) {\n // expo app entry is not needed for bare projects.\n if (isPkgMainExpoAppEntry(main)) {\n return null;\n }\n // Look at the `package.json`s `main` field for the main file.\n const resolvedMainField = main ?? './index';\n // Get a list of possible extensions for the main file.\n const extensions = getBareExtensions(['ios', 'android']);\n // Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path.\n return getFileWithExtensions(projectRoot, resolvedMainField, extensions);\n}\n"],"names":["createCopyFilesSuccessMessage","copyTemplateFilesAsync","resolveBareEntryFile","debug","require","hasAllPlatformSpecificGitIgnores","projectRoot","platforms","reduce","p","platform","fs","existsSync","path","join","skippedPaths","gitignore","message","length","chalk","dim","map","bold","didMerge","didClear","pkg","templateDirectory","copyFilePaths","getFilePathsToCopy","copyResults","copyPathsFromTemplateAsync","hasPlatformSpecificGitIgnores","mergeGitIgnorePaths","copiedPaths","copyFilePath","projectPath","directoryExistsAsync","push","copySync","targetPaths","bareEntryFile","main","isPkgMainExpoAppEntry","resolvedMainField","extensions","getBareExtensions","getFileWithExtensions"],"mappings":"AAAA;;;;QAqCgBA,6BAA6B,GAA7BA,6BAA6B;QAsBvBC,sBAAsB,GAAtBA,sBAAsB;QAgF5BC,oBAAoB,GAApBA,oBAAoB;AAxIqB,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AAC3D,IAA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D;IAClD,IAAIC,CAAAA,GAAAA,kBAAqB,AAAM,CAAA,sBAAN,CAACD,IAAI,CAAC,EAAE;QAC/B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,MAAME,iBAAiB,GAAGF,IAAI,WAAJA,IAAI,GAAI,SAAS,AAAC;IAC5C,uDAAuD;IACvD,MAAMG,UAAU,GAAGC,CAAAA,GAAAA,MAAiB,AAAoB,CAAA,kBAApB,CAAC;QAAC,KAAK;QAAE,SAAS;KAAC,CAAC,AAAC;IACzD,oOAAoO;IACpO,OAAOC,CAAAA,GAAAA,MAAqB,AAA4C,CAAA,sBAA5C,CAACxC,WAAW,EAAEqC,iBAAiB,EAAEC,UAAU,CAAC,CAAC;CAC1E"}
@@ -50,6 +50,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
50
50
  template,
51
51
  templateDirectory,
52
52
  exp,
53
+ pkg,
53
54
  platforms
54
55
  });
55
56
  (0, _profile).profile(_writeMetroConfig.writeMetroConfig)(projectRoot, {
@@ -72,7 +73,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
72
73
  * Extract the template and copy the ios and android directories over to the project directory.
73
74
  *
74
75
  * @return `true` if any project files were created.
75
- */ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp , platforms }) {
76
+ */ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp , pkg , platforms }) {
76
77
  const ora = (0, _ora).logNewSection("Creating native project directories (./ios and ./android) and updating .gitignore");
77
78
  try {
78
79
  await (0, _resolveTemplate).cloneTemplateAsync({
@@ -82,6 +83,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
82
83
  ora
83
84
  });
84
85
  const results = await (0, _copyTemplateFiles).copyTemplateFilesAsync(projectRoot, {
86
+ pkg,
85
87
  templateDirectory,
86
88
  platforms
87
89
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { writeMetroConfig } from './writeMetroConfig';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is ejecting, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n profile(writeMetroConfig)(projectRoot, { pkg, templateDirectory });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall:\n copiedPaths.includes('ios') ||\n depsResults.hasNewDependencies ||\n depsResults.hasNewDevDependencies,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nasync function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n platforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n platforms: ModPlatform[];\n}): Promise<string[]> {\n const ora = logNewSection(\n 'Creating native project directories (./ios and ./android) and updating .gitignore'\n );\n\n try {\n await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const results = await copyTemplateFilesAsync(projectRoot, {\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return results.copiedPaths;\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail('Failed to create the native project.');\n Log.log(\n chalk.yellow(\n 'You may want to delete the `./ios` and/or `./android` directories before trying again.'\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","profile","cloneTemplateAndCopyToProjectAsync","writeMetroConfig","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","hasNewDependencies","hasNewDevDependencies","ora","logNewSection","cloneTemplateAsync","results","copyTemplateFilesAsync","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;AAhB3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc,CAAA;AACpB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AAC4B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA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eF,kCAAkC,CAAC,EAChDX,WAAW,CAAA,EACXI,iBAAiB,CAAA,EACjBD,QAAQ,CAAA,EACRF,GAAG,CAAA,EACHI,SAAS,CAAA,EAOV,EAAqB;IACpB,MAAMgB,GAAG,GAAGC,CAAAA,GAAAA,IAAa,AAExB,CAAA,cAFwB,CACvB,mFAAmF,CACpF,AAAC;IAEF,IAAI;QACF,MAAMC,CAAAA,GAAAA,gBAAkB,AAA2C,CAAA,mBAA3C,CAAC;YAAEnB,iBAAiB;YAAED,QAAQ;YAAEF,GAAG;YAAEoB,GAAG;SAAE,CAAC,CAAC;QAEpE,MAAMG,OAAO,GAAG,MAAMC,CAAAA,GAAAA,kBAAsB,AAG1C,CAAA,uBAH0C,CAACzB,WAAW,EAAE;YACxDI,iBAAiB;YACjBC,SAAS;SACV,CAAC,AAAC;QAEHgB,GAAG,CAACK,OAAO,CAACC,CAAAA,GAAAA,kBAA6B,AAAoB,CAAA,8BAApB,CAACtB,SAAS,EAAEmB,OAAO,CAAC,CAAC,CAAC;QAE/D,OAAOA,OAAO,CAACf,WAAW,CAAC;KAC5B,CAAC,OAAOmB,CAAC,EAAO;QACf,IAAI,CAAC,CAACA,CAAC,YAAYC,OAAiB,kBAAA,CAAC,EAAE;YACrC9B,GAAG,CAAC+B,KAAK,CAACF,CAAC,CAACG,OAAO,CAAC,CAAC;SACtB;QACDV,GAAG,CAACW,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACjDjC,GAAG,CAACkC,GAAG,CACLC,MAAK,QAAA,CAACC,MAAM,CACV,wFAAwF,CACzF,CACF,CAAC;QACF,MAAM,IAAIC,OAAW,YAAA,CAACR,CAAC,CAAC,CAAC;KAC1B;CACF"}
1
+ {"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { writeMetroConfig } from './writeMetroConfig';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is ejecting, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n pkg,\n platforms,\n });\n\n profile(writeMetroConfig)(projectRoot, { pkg, templateDirectory });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall:\n copiedPaths.includes('ios') ||\n depsResults.hasNewDependencies ||\n depsResults.hasNewDevDependencies,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nasync function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n pkg,\n platforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n pkg: PackageJSONConfig;\n platforms: ModPlatform[];\n}): Promise<string[]> {\n const ora = logNewSection(\n 'Creating native project directories (./ios and ./android) and updating .gitignore'\n );\n\n try {\n await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const results = await copyTemplateFilesAsync(projectRoot, {\n pkg,\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return results.copiedPaths;\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail('Failed to create the native project.');\n Log.log(\n chalk.yellow(\n 'You may want to delete the `./ios` and/or `./android` directories before trying again.'\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","profile","cloneTemplateAndCopyToProjectAsync","writeMetroConfig","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","hasNewDependencies","hasNewDevDependencies","ora","logNewSection","cloneTemplateAsync","results","copyTemplateFilesAsync","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;AAhB3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc,CAAA;AACpB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AAC4B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACxD,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACkB,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AAC5D,IAAA,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AAG,CAAA,EACHC,GAAG,CAAA,EACHG,SAAS,CAAA,EAQV,EAAqB;IACpB,MAAMgB,GAAG,GAAGC,CAAAA,GAAAA,IAAa,AAExB,CAAA,cAFwB,CACvB,mFAAmF,CACpF,AAAC;IAEF,IAAI;QACF,MAAMC,CAAAA,GAAAA,gBAAkB,AAA2C,CAAA,mBAA3C,CAAC;YAAEnB,iBAAiB;YAAED,QAAQ;YAAEF,GAAG;YAAEoB,GAAG;SAAE,CAAC,CAAC;QAEpE,MAAMG,OAAO,GAAG,MAAMC,CAAAA,GAAAA,kBAAsB,AAI1C,CAAA,uBAJ0C,CAACzB,WAAW,EAAE;YACxDE,GAAG;YACHE,iBAAiB;YACjBC,SAAS;SACV,CAAC,AAAC;QAEHgB,GAAG,CAACK,OAAO,CAACC,CAAAA,GAAAA,kBAA6B,AAAoB,CAAA,8BAApB,CAACtB,SAAS,EAAEmB,OAAO,CAAC,CAAC,CAAC;QAE/D,OAAOA,OAAO,CAACf,WAAW,CAAC;KAC5B,CAAC,OAAOmB,CAAC,EAAO;QACf,IAAI,CAAC,CAACA,CAAC,YAAYC,OAAiB,kBAAA,CAAC,EAAE;YACrC9B,GAAG,CAAC+B,KAAK,CAACF,CAAC,CAACG,OAAO,CAAC,CAAC;SACtB;QACDV,GAAG,CAACW,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACjDjC,GAAG,CAACkC,GAAG,CACLC,MAAK,QAAA,CAACC,MAAM,CACV,wFAAwF,CACzF,CACF,CAAC;QACF,MAAM,IAAIC,OAAW,YAAA,CAACR,CAAC,CAAC,CAAC;KAC1B;CACF"}
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.updatePackageJSONAsync = updatePackageJSONAsync;
6
6
  exports.updatePkgDependencies = updatePkgDependencies;
7
7
  exports.createDependenciesMap = createDependenciesMap;
8
+ exports.isPkgMainExpoAppEntry = isPkgMainExpoAppEntry;
8
9
  exports.hashForDependencyMap = hashForDependencyMap;
9
10
  exports.createFileHash = createFileHash;
11
+ exports.shouldDeleteMainField = shouldDeleteMainField;
10
12
  var _config = require("@expo/config");
11
13
  var _chalk = _interopRequireDefault(require("chalk"));
12
14
  var _crypto = _interopRequireDefault(require("crypto"));
@@ -42,7 +44,7 @@ function _interopRequireWildcard(obj) {
42
44
  }
43
45
  }
44
46
  async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , skipDependencyUpdate }) {
45
- const updatingPackageJsonStep = (0, _ora).logNewSection("Updating your package.json scripts, and dependencies");
47
+ const updatingPackageJsonStep = (0, _ora).logNewSection("Updating your package.json scripts, dependencies, and main file");
46
48
  const templatePkg = (0, _config).getPackageJson(templateDirectory);
47
49
  const results = modifyPackageJson(projectRoot, {
48
50
  templatePkg,
@@ -52,7 +54,10 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
52
54
  await _fs.default.promises.writeFile(_path.default.resolve(projectRoot, "package.json"), // Add new line to match the format of running yarn.
53
55
  // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.
54
56
  JSON.stringify(pkg, null, 2) + "\n");
55
- updatingPackageJsonStep.succeed("Updated package.json");
57
+ updatingPackageJsonStep.succeed("Updated package.json and added index.js entry point for iOS and Android");
58
+ if (results.removedMainField) {
59
+ Log.log(`\u203A Removed ${_chalk.default.bold(`"main": "${results.removedMainField}"`)} from package.json because we recommend using index.js as main instead\n`);
60
+ }
56
61
  return results;
57
62
  }
58
63
  /**
@@ -60,6 +65,7 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
60
65
  *
61
66
  * 1. Update `package.json` `scripts`.
62
67
  * 2. Update `package.json` `dependencies` and `devDependencies`.
68
+ * 3. Update `package.json` `main`.
63
69
  *
64
70
  * @param projectRoot The root directory of the project.
65
71
  * @param props.templatePkg Template project package.json as JSON.
@@ -70,11 +76,18 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
70
76
  updatePkgScripts({
71
77
  pkg
72
78
  });
73
- return updatePkgDependencies(projectRoot, {
79
+ const results = updatePkgDependencies(projectRoot, {
74
80
  pkg,
75
81
  templatePkg,
76
82
  skipDependencyUpdate
77
83
  });
84
+ const removedMainField = updatePkgMain({
85
+ pkg
86
+ });
87
+ return {
88
+ ...results,
89
+ removedMainField
90
+ };
78
91
  }
79
92
  function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDependencyUpdate =[] }) {
80
93
  if (!pkg1.devDependencies) {
@@ -176,6 +189,30 @@ function createDependenciesMap(dependencies) {
176
189
  pkg.scripts.ios = "expo run:ios";
177
190
  }
178
191
  }
192
+ /**
193
+ * Add new app entry points
194
+ */ function updatePkgMain({ pkg }) {
195
+ let removedPkgMain = null;
196
+ // Check that the pkg.main doesn't match:
197
+ // - ./node_modules/expo/AppEntry
198
+ // - ./node_modules/expo/AppEntry.js
199
+ // - node_modules/expo/AppEntry.js
200
+ // - expo/AppEntry.js
201
+ // - expo/AppEntry
202
+ if (shouldDeleteMainField(pkg.main)) {
203
+ // Save the custom
204
+ removedPkgMain = pkg.main;
205
+ delete pkg.main;
206
+ }
207
+ return removedPkgMain;
208
+ }
209
+ function isPkgMainExpoAppEntry(input) {
210
+ const main = input || "";
211
+ if (main.startsWith("./")) {
212
+ return main.includes("node_modules/expo/AppEntry");
213
+ }
214
+ return main.includes("expo/AppEntry");
215
+ }
179
216
  function normalizeDependencyMap(deps) {
180
217
  return Object.keys(deps).map((dependency)=>`${dependency}@${deps[dependency]}`
181
218
  ).sort();
@@ -189,5 +226,11 @@ function createFileHash(contents) {
189
226
  // this doesn't need to be secure, the shorter the better.
190
227
  return _crypto.default.createHash("sha1").update(contents).digest("hex");
191
228
  }
229
+ function shouldDeleteMainField(main) {
230
+ if (!main || !isPkgMainExpoAppEntry(main)) {
231
+ return false;
232
+ }
233
+ return !(main == null ? void 0 : main.startsWith("index."));
234
+ }
192
235
 
193
236
  //# sourceMappingURL=updatePackageJson.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/updatePackageJson.ts"],"sourcesContent":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, and dependencies'\n );\n\n const templatePkg = getPackageJson(templateDirectory);\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n\n updatingPackageJsonStep.succeed('Updated package.json');\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` and `devDependencies`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n) {\n updatePkgScripts({ pkg });\n\n return updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n if (\n // If the local package.json defined the dependency that we want to overwrite...\n pkg.dependencies?.[dependenciesKey]\n ) {\n if (\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })\n ) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n }\n combinedDependencies[dependenciesKey] = defaultDependencies[dependenciesKey];\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.start?.includes('--dev-client')) {\n pkg.scripts.start = 'expo start --dev-client';\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","hashForDependencyMap","createFileHash","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","updatePkgScripts","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","length","log","map","chalk","bold","join","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","start","android","ios","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest"],"mappings":"AAAA;;;;QAoBsBA,sBAAsB,GAAtBA,sBAAsB;QAkF5BC,qBAAqB,GAArBA,qBAAqB;QAyFrBC,qBAAqB,GAArBA,qBAAqB;QAiDrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;AAtPoB,IAAA,OAAc,WAAd,cAAc,CAAA;AAC9C,IAAA,MAAO,kCAAP,OAAO,EAAA;AACN,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,K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":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type PackageJsonModificationResults = DependenciesModificationResults & {\n removedMainField: string | null;\n};\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, dependencies, and main file'\n );\n\n const templatePkg = getPackageJson(templateDirectory);\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n\n updatingPackageJsonStep.succeed(\n 'Updated package.json and added index.js entry point for iOS and Android'\n );\n\n if (results.removedMainField) {\n Log.log(\n `\\u203A Removed ${chalk.bold(\n `\"main\": \"${results.removedMainField}\"`\n )} from package.json because we recommend using index.js as main instead\\n`\n );\n }\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` and `devDependencies`.\n * 3. Update `package.json` `main`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): PackageJsonModificationResults {\n updatePkgScripts({ pkg });\n\n const results = updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n\n const removedMainField = updatePkgMain({ pkg });\n\n return { ...results, removedMainField };\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n if (\n // If the local package.json defined the dependency that we want to overwrite...\n pkg.dependencies?.[dependenciesKey]\n ) {\n if (\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })\n ) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n }\n combinedDependencies[dependenciesKey] = defaultDependencies[dependenciesKey];\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.start?.includes('--dev-client')) {\n pkg.scripts.start = 'expo start --dev-client';\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\n/**\n * Add new app entry points\n */\nfunction updatePkgMain({ pkg }: { pkg: PackageJSONConfig }): string | null {\n let removedPkgMain: null | string = null;\n // Check that the pkg.main doesn't match:\n // - ./node_modules/expo/AppEntry\n // - ./node_modules/expo/AppEntry.js\n // - node_modules/expo/AppEntry.js\n // - expo/AppEntry.js\n // - expo/AppEntry\n if (shouldDeleteMainField(pkg.main)) {\n // Save the custom\n removedPkgMain = pkg.main;\n delete pkg.main;\n }\n\n return removedPkgMain;\n}\n\n/**\n * Returns true if the input string matches the default expo main field.\n *\n * - ./node_modules/expo/AppEntry\n * - ./node_modules/expo/AppEntry.js\n * - node_modules/expo/AppEntry.js\n * - expo/AppEntry.js\n * - expo/AppEntry\n *\n * @param input package.json main field\n */\nexport function isPkgMainExpoAppEntry(input?: string): boolean {\n const main = input || '';\n if (main.startsWith('./')) {\n return main.includes('node_modules/expo/AppEntry');\n }\n return main.includes('expo/AppEntry');\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n\nexport function shouldDeleteMainField(main?: any): boolean {\n if (!main || !isPkgMainExpoAppEntry(main)) {\n return false;\n }\n\n return !main?.startsWith('index.');\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","isPkgMainExpoAppEntry","hashForDependencyMap","createFileHash","shouldDeleteMainField","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","removedMainField","log","chalk","bold","updatePkgScripts","updatePkgMain","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","length","map","join","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","start","android","ios","removedPkgMain","main","input","startsWith","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest"],"mappings":"AAAA;;;;QAwBsBA,sBAAsB,GAAtBA,sBAAsB;QAiG5BC,qBAAqB,GAArBA,qBAAqB;QAyFrBC,qBAAqB,GAArBA,qBAAqB;QA0ErBC,qBAAqB,GAArBA,qBAAqB;QAcrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;QAKdC,qBAAqB,GAArBA,qBAAqB;AArTa,IAAA,OAAc,WAAd,cAAc,CAAA;AAC9C,IAAA,MAAO,kCAAP,OAAO,EAAA;AACN,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;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CAACE,UAAU,CAAC,IAAI,CAAC,EAAE;QACzB,OAAOF,IAAI,CAACnB,QAAQ,CAAC,4BAA4B,CAAC,CAAC;KACpD;IACD,OAAOmB,IAAI,CAACnB,QAAQ,CAAC,eAAe,CAAC,CAAC;CACvC;AAED,SAASsB,sBAAsB,CAACC,IAAqB,EAAY;IAC/D,OAAOhB,MAAM,CAACK,IAAI,CAACW,IAAI,CAAC,CACrBrB,GAAG,CAAC,CAACsB,UAAU,GAAK,CAAC,EAAEA,UAAU,CAAC,CAAC,EAAED,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC;IAAA,CAAC,CACxDC,IAAI,EAAE,CAAC;CACX;AAEM,SAASnE,oBAAoB,CAACiE,IAAqB,GAAG,EAAE,EAAU;IACvE,MAAMG,QAAQ,GAAGJ,sBAAsB,CAACC,IAAI,CAAC,AAAC;IAC9C,MAAMI,UAAU,GAAGD,QAAQ,CAACvB,IAAI,CAAC,IAAI,CAAC,AAAC;IACvC,OAAO5C,cAAc,CAACoE,UAAU,CAAC,CAAC;CACnC;AAEM,SAASpE,cAAc,CAACqE,QAAgB,EAAU;IACvD,0DAA0D;IAC1D,OAAOC,OAAM,QAAA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACH,QAAQ,CAAC,CAACI,MAAM,CAAC,KAAK,CAAC,CAAC;CACjE;AAEM,SAASxE,qBAAqB,CAAC2D,IAAU,EAAW;IACzD,IAAI,CAACA,IAAI,IAAI,CAAC9D,qBAAqB,CAAC8D,IAAI,CAAC,EAAE;QACzC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,EAACA,IAAI,QAAY,GAAhBA,KAAAA,CAAgB,GAAhBA,IAAI,CAAEE,UAAU,CAAC,QAAQ,CAAC,CAAA,CAAC;CACpC"}
@@ -16,10 +16,10 @@ class AppleAppIdResolver extends _appIdResolver.AppIdResolver {
16
16
  constructor(projectRoot){
17
17
  super(projectRoot, "ios", "ios.bundleIdentifier");
18
18
  }
19
- async hasNativeProjectAsync() {
19
+ /** @return `true` if the app has valid `*.pbxproj` file */ async hasNativeProjectAsync() {
20
20
  try {
21
21
  // Never returns nullish values.
22
- return !!_configPlugins.IOSConfig.Paths.getAppDelegateFilePath(this.projectRoot);
22
+ return !!_configPlugins.IOSConfig.Paths.getAllPBXProjectPaths(this.projectRoot).length;
23
23
  } catch (error) {
24
24
  debug("Expected error checking for native project:", error);
25
25
  return false;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/AppleAppIdResolver.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport plist from '@expo/plist';\nimport fs from 'fs';\n\nimport { AppIdResolver } from '../AppIdResolver';\n\nconst debug = require('debug')('expo:start:platforms:ios:AppleAppIdResolver') as typeof console.log;\n\n/** Resolves the iOS bundle identifier from the Expo config or native files. */\nexport class AppleAppIdResolver extends AppIdResolver {\n constructor(projectRoot: string) {\n super(projectRoot, 'ios', 'ios.bundleIdentifier');\n }\n\n async hasNativeProjectAsync(): Promise<boolean> {\n try {\n // Never returns nullish values.\n return !!IOSConfig.Paths.getAppDelegateFilePath(this.projectRoot);\n } catch (error: any) {\n debug('Expected error checking for native project:', error);\n return false;\n }\n }\n\n async resolveAppIdFromNativeAsync(): Promise<string | null> {\n // Check xcode project\n try {\n const bundleId = IOSConfig.BundleIdentifier.getBundleIdentifierFromPbxproj(this.projectRoot);\n if (bundleId) {\n return bundleId;\n }\n } catch (error: any) {\n debug('Expected error resolving the bundle identifier from the pbxproj:', error);\n }\n\n // Check Info.plist\n try {\n const infoPlistPath = IOSConfig.Paths.getInfoPlistPath(this.projectRoot);\n const data = await plist.parse(fs.readFileSync(infoPlistPath, 'utf8'));\n if (data.CFBundleIdentifier && !data.CFBundleIdentifier.startsWith('$(')) {\n return data.CFBundleIdentifier;\n }\n } catch (error) {\n debug('Expected error resolving the bundle identifier from the project Info.plist:', error);\n }\n\n return null;\n }\n}\n"],"names":["debug","require","AppleAppIdResolver","AppIdResolver","constructor","projectRoot","hasNativeProjectAsync","IOSConfig","Paths","getAppDelegateFilePath","error","resolveAppIdFromNativeAsync","bundleId","BundleIdentifier","getBundleIdentifierFromPbxproj","infoPlistPath","getInfoPlistPath","data","plist","parse","fs","readFileSync","CFBundleIdentifier","startsWith"],"mappings":"AAAA;;;;AAA0B,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC9B,IAAA,MAAa,kCAAb,aAAa,EAAA;AAChB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEW,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;;;;;;AAEhD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,AAAsB,AAAC;AAG7F,MAAMC,kBAAkB,SAASC,cAAa,cAAA;IACnDC,YAAYC,WAAmB,CAAE;QAC/B,KAAK,CAACA,WAAW,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;KACnD;IAED,MAAMC,qBAAqB,GAAqB;QAC9C,IAAI;YACF,gCAAgC;YAChC,OAAO,CAAC,CAACC,cAAS,UAAA,CAACC,KAAK,CAACC,sBAAsB,CAAC,IAAI,CAACJ,WAAW,CAAC,CAAC;SACnE,CAAC,OAAOK,KAAK,EAAO;YACnBV,KAAK,CAAC,6CAA6C,EAAEU,KAAK,CAAC,CAAC;YAC5D,OAAO,KAAK,CAAC;SACd;KACF;IAED,MAAMC,2BAA2B,GAA2B;QAC1D,sBAAsB;QACtB,IAAI;YACF,MAAMC,QAAQ,GAAGL,cAAS,UAAA,CAACM,gBAAgB,CAACC,8BAA8B,CAAC,IAAI,CAACT,WAAW,CAAC,AAAC;YAC7F,IAAIO,QAAQ,EAAE;gBACZ,OAAOA,QAAQ,CAAC;aACjB;SACF,CAAC,OAAOF,KAAK,EAAO;YACnBV,KAAK,CAAC,kEAAkE,EAAEU,KAAK,CAAC,CAAC;SAClF;QAED,mBAAmB;QACnB,IAAI;YACF,MAAMK,aAAa,GAAGR,cAAS,UAAA,CAACC,KAAK,CAACQ,gBAAgB,CAAC,IAAI,CAACX,WAAW,CAAC,AAAC;YACzE,MAAMY,IAAI,GAAG,MAAMC,MAAK,QAAA,CAACC,KAAK,CAACC,GAAE,QAAA,CAACC,YAAY,CAACN,aAAa,EAAE,MAAM,CAAC,CAAC,AAAC;YACvE,IAAIE,IAAI,CAACK,kBAAkB,IAAI,CAACL,IAAI,CAACK,kBAAkB,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACxE,OAAON,IAAI,CAACK,kBAAkB,CAAC;aAChC;SACF,CAAC,OAAOZ,MAAK,EAAE;YACdV,KAAK,CAAC,6EAA6E,EAAEU,MAAK,CAAC,CAAC;SAC7F;QAED,OAAO,IAAI,CAAC;KACb;CACF;QAvCYR,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/AppleAppIdResolver.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport plist from '@expo/plist';\nimport fs from 'fs';\n\nimport { AppIdResolver } from '../AppIdResolver';\n\nconst debug = require('debug')('expo:start:platforms:ios:AppleAppIdResolver') as typeof console.log;\n\n/** Resolves the iOS bundle identifier from the Expo config or native files. */\nexport class AppleAppIdResolver extends AppIdResolver {\n constructor(projectRoot: string) {\n super(projectRoot, 'ios', 'ios.bundleIdentifier');\n }\n\n /** @return `true` if the app has valid `*.pbxproj` file */\n async hasNativeProjectAsync(): Promise<boolean> {\n try {\n // Never returns nullish values.\n return !!IOSConfig.Paths.getAllPBXProjectPaths(this.projectRoot).length;\n } catch (error: any) {\n debug('Expected error checking for native project:', error);\n return false;\n }\n }\n\n async resolveAppIdFromNativeAsync(): Promise<string | null> {\n // Check xcode project\n try {\n const bundleId = IOSConfig.BundleIdentifier.getBundleIdentifierFromPbxproj(this.projectRoot);\n if (bundleId) {\n return bundleId;\n }\n } catch (error: any) {\n debug('Expected error resolving the bundle identifier from the pbxproj:', error);\n }\n\n // Check Info.plist\n try {\n const infoPlistPath = IOSConfig.Paths.getInfoPlistPath(this.projectRoot);\n const data = await plist.parse(fs.readFileSync(infoPlistPath, 'utf8'));\n if (data.CFBundleIdentifier && !data.CFBundleIdentifier.startsWith('$(')) {\n return data.CFBundleIdentifier;\n }\n } catch (error) {\n debug('Expected error resolving the bundle identifier from the project Info.plist:', error);\n }\n\n return null;\n }\n}\n"],"names":["debug","require","AppleAppIdResolver","AppIdResolver","constructor","projectRoot","hasNativeProjectAsync","IOSConfig","Paths","getAllPBXProjectPaths","length","error","resolveAppIdFromNativeAsync","bundleId","BundleIdentifier","getBundleIdentifierFromPbxproj","infoPlistPath","getInfoPlistPath","data","plist","parse","fs","readFileSync","CFBundleIdentifier","startsWith"],"mappings":"AAAA;;;;AAA0B,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC9B,IAAA,MAAa,kCAAb,aAAa,EAAA;AAChB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEW,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;;;;;;AAEhD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,AAAsB,AAAC;AAG7F,MAAMC,kBAAkB,SAASC,cAAa,cAAA;IACnDC,YAAYC,WAAmB,CAAE;QAC/B,KAAK,CAACA,WAAW,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC;KACnD;IAED,2DAA2D,CAC3D,MAAMC,qBAAqB,GAAqB;QAC9C,IAAI;YACF,gCAAgC;YAChC,OAAO,CAAC,CAACC,cAAS,UAAA,CAACC,KAAK,CAACC,qBAAqB,CAAC,IAAI,CAACJ,WAAW,CAAC,CAACK,MAAM,CAAC;SACzE,CAAC,OAAOC,KAAK,EAAO;YACnBX,KAAK,CAAC,6CAA6C,EAAEW,KAAK,CAAC,CAAC;YAC5D,OAAO,KAAK,CAAC;SACd;KACF;IAED,MAAMC,2BAA2B,GAA2B;QAC1D,sBAAsB;QACtB,IAAI;YACF,MAAMC,QAAQ,GAAGN,cAAS,UAAA,CAACO,gBAAgB,CAACC,8BAA8B,CAAC,IAAI,CAACV,WAAW,CAAC,AAAC;YAC7F,IAAIQ,QAAQ,EAAE;gBACZ,OAAOA,QAAQ,CAAC;aACjB;SACF,CAAC,OAAOF,KAAK,EAAO;YACnBX,KAAK,CAAC,kEAAkE,EAAEW,KAAK,CAAC,CAAC;SAClF;QAED,mBAAmB;QACnB,IAAI;YACF,MAAMK,aAAa,GAAGT,cAAS,UAAA,CAACC,KAAK,CAACS,gBAAgB,CAAC,IAAI,CAACZ,WAAW,CAAC,AAAC;YACzE,MAAMa,IAAI,GAAG,MAAMC,MAAK,QAAA,CAACC,KAAK,CAACC,GAAE,QAAA,CAACC,YAAY,CAACN,aAAa,EAAE,MAAM,CAAC,CAAC,AAAC;YACvE,IAAIE,IAAI,CAACK,kBAAkB,IAAI,CAACL,IAAI,CAACK,kBAAkB,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACxE,OAAON,IAAI,CAACK,kBAAkB,CAAC;aAChC;SACF,CAAC,OAAOZ,MAAK,EAAE;YACdX,KAAK,CAAC,6EAA6E,EAAEW,MAAK,CAAC,CAAC;SAC7F;QAED,OAAO,IAAI,CAAC;KACb;CACF;QAxCYT,kBAAkB,GAAlBA,kBAAkB"}
@@ -130,7 +130,7 @@ async function createHostInfoAsync() {
130
130
  host: await _userSettings.default.getAnonymousIdentifierAsync(),
131
131
  server: "expo",
132
132
  // Defined in the build step
133
- serverVersion: "0.4.1",
133
+ serverVersion: "0.4.3",
134
134
  serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
135
135
  serverOS: _os.default.platform(),
136
136
  serverOSVersion: _os.default.release()
@@ -94,7 +94,7 @@ async function logEventAsync(event, properties = {}) {
94
94
  }
95
95
  const { userId , deviceId } = identifyData;
96
96
  const commonEventProperties = {
97
- source_version: "0.4.1",
97
+ source_version: "0.4.3",
98
98
  source: "expo"
99
99
  };
100
100
  const identity = {
@@ -135,7 +135,7 @@ function getContext() {
135
135
  },
136
136
  app: {
137
137
  name: "expo",
138
- version: "0.4.1"
138
+ version: "0.4.3"
139
139
  },
140
140
  ci: ciInfo.isCI ? {
141
141
  name: ciInfo.name,
@@ -7,8 +7,10 @@ exports.getSchemesForAndroidAsync = getSchemesForAndroidAsync;
7
7
  exports.getOptionalDevClientSchemeAsync = getOptionalDevClientSchemeAsync;
8
8
  var _config = require("@expo/config");
9
9
  var _configPlugins = require("@expo/config-plugins");
10
+ var _getInfoPlistPath = require("@expo/config-plugins/build/ios/utils/getInfoPlistPath");
10
11
  var _plist = _interopRequireDefault(require("@expo/plist"));
11
12
  var _fs = _interopRequireDefault(require("fs"));
13
+ var _path = _interopRequireDefault(require("path"));
12
14
  var _resolveFrom = _interopRequireDefault(require("resolve-from"));
13
15
  var Log = _interopRequireWildcard(require("../log"));
14
16
  var _clearNativeFolder = require("../prebuild/clearNativeFolder");
@@ -39,6 +41,7 @@ function _interopRequireWildcard(obj) {
39
41
  return newObj;
40
42
  }
41
43
  }
44
+ const debug = require("debug")("expo:utils:scheme");
42
45
  // sort longest to ensure uniqueness.
43
46
  // this might be undesirable as it causes the QR code to be longer.
44
47
  function sortLongest(obj) {
@@ -47,21 +50,31 @@ function sortLongest(obj) {
47
50
  }
48
51
  async function getSchemesForIosAsync(projectRoot) {
49
52
  try {
50
- const configPath = _configPlugins.IOSConfig.Paths.getInfoPlistPath(projectRoot);
51
- const rawPlist = _fs.default.readFileSync(configPath, "utf8");
52
- const plistObject = _plist.default.parse(rawPlist);
53
- return sortLongest(_configPlugins.IOSConfig.Scheme.getSchemesFromPlist(plistObject));
54
- } catch {
55
- // No ios folder or some other error
56
- return [];
53
+ const infoPlistBuildProperty = (0, _getInfoPlistPath).getInfoPlistPathFromPbxproj(projectRoot);
54
+ debug(`ios application Info.plist path:`, infoPlistBuildProperty);
55
+ if (infoPlistBuildProperty) {
56
+ const configPath = _path.default.join(projectRoot, "ios", infoPlistBuildProperty);
57
+ const rawPlist = _fs.default.readFileSync(configPath, "utf8");
58
+ const plistObject = _plist.default.parse(rawPlist);
59
+ const schemes = _configPlugins.IOSConfig.Scheme.getSchemesFromPlist(plistObject);
60
+ debug(`ios application schemes:`, schemes);
61
+ return sortLongest(schemes);
62
+ }
63
+ } catch (error) {
64
+ debug(`expected error collecting ios application schemes for the main target:`, error);
57
65
  }
66
+ // No ios folder or some other error
67
+ return [];
58
68
  }
59
69
  async function getSchemesForAndroidAsync(projectRoot) {
60
70
  try {
61
71
  const configPath = await _configPlugins.AndroidConfig.Paths.getAndroidManifestAsync(projectRoot);
62
72
  const manifest = await _configPlugins.AndroidConfig.Manifest.readAndroidManifestAsync(configPath);
63
- return sortLongest(await _configPlugins.AndroidConfig.Scheme.getSchemesFromManifest(manifest));
64
- } catch {
73
+ const schemes = await _configPlugins.AndroidConfig.Scheme.getSchemesFromManifest(manifest);
74
+ debug(`android application schemes:`, schemes);
75
+ return sortLongest(schemes);
76
+ } catch (error) {
77
+ debug(`expected error collecting android application schemes for the main activity:`, error);
65
78
  // No android folder or some other error
66
79
  return [];
67
80
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/scheme.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { AndroidConfig, IOSConfig } from '@expo/config-plugins';\nimport plist from '@expo/plist';\nimport fs from 'fs';\nimport resolveFrom from 'resolve-from';\n\nimport * as Log from '../log';\nimport {\n hasRequiredAndroidFilesAsync,\n hasRequiredIOSFilesAsync,\n} from '../prebuild/clearNativeFolder';\nimport { intersecting } from './array';\n\n// sort longest to ensure uniqueness.\n// this might be undesirable as it causes the QR code to be longer.\nfunction sortLongest(obj: string[]): string[] {\n return obj.sort((a, b) => b.length - a.length);\n}\n\n// TODO: Revisit and test after run code is merged.\nexport async function getSchemesForIosAsync(projectRoot: string) {\n try {\n const configPath = IOSConfig.Paths.getInfoPlistPath(projectRoot);\n const rawPlist = fs.readFileSync(configPath, 'utf8');\n const plistObject = plist.parse(rawPlist);\n return sortLongest(IOSConfig.Scheme.getSchemesFromPlist(plistObject));\n } catch {\n // No ios folder or some other error\n return [];\n }\n}\n\n// TODO: Revisit and test after run code is merged.\nexport async function getSchemesForAndroidAsync(projectRoot: string) {\n try {\n const configPath = await AndroidConfig.Paths.getAndroidManifestAsync(projectRoot);\n const manifest = await AndroidConfig.Manifest.readAndroidManifestAsync(configPath);\n return sortLongest(await AndroidConfig.Scheme.getSchemesFromManifest(manifest));\n } catch {\n // No android folder or some other error\n return [];\n }\n}\n\n// TODO: Revisit and test after run code is merged.\nasync function getManagedDevClientSchemeAsync(projectRoot: string): Promise<string | null> {\n const { exp } = getConfig(projectRoot);\n try {\n const getDefaultScheme = require(resolveFrom(projectRoot, 'expo-dev-client/getDefaultScheme'));\n const scheme = getDefaultScheme(exp);\n return scheme;\n } catch {\n Log.warn(\n '\\nDevelopment build: Unable to get the default URI scheme for the project. Please make sure the expo-dev-client package is installed.'\n );\n return null;\n }\n}\n\n// TODO: Revisit and test after run code is merged.\nexport async function getOptionalDevClientSchemeAsync(projectRoot: string): Promise<string | null> {\n const [hasIos, hasAndroid] = await Promise.all([\n hasRequiredIOSFilesAsync(projectRoot),\n hasRequiredAndroidFilesAsync(projectRoot),\n ]);\n\n const [ios, android] = await Promise.all([\n getSchemesForIosAsync(projectRoot),\n getSchemesForAndroidAsync(projectRoot),\n ]);\n\n // Allow managed projects\n if (!hasIos && !hasAndroid) {\n return getManagedDevClientSchemeAsync(projectRoot);\n }\n\n let matching: string;\n // Allow for only one native project to exist.\n if (!hasIos) {\n matching = android[0];\n } else if (!hasAndroid) {\n matching = ios[0];\n } else {\n [matching] = intersecting(ios, android);\n }\n return matching ?? null;\n}\n"],"names":["getSchemesForIosAsync","getSchemesForAndroidAsync","getOptionalDevClientSchemeAsync","Log","sortLongest","obj","sort","a","b","length","projectRoot","configPath","IOSConfig","Paths","getInfoPlistPath","rawPlist","fs","readFileSync","plistObject","plist","parse","Scheme","getSchemesFromPlist","AndroidConfig","getAndroidManifestAsync","manifest","Manifest","readAndroidManifestAsync","getSchemesFromManifest","getManagedDevClientSchemeAsync","exp","getConfig","getDefaultScheme","require","resolveFrom","scheme","warn","hasIos","hasAndroid","Promise","all","hasRequiredIOSFilesAsync","hasRequiredAndroidFilesAsync","ios","android","matching","intersecting"],"mappings":"AAAA;;;;QAoBsBA,qBAAqB,GAArBA,qBAAqB;QAarBC,yBAAyB,GAAzBA,yBAAyB;QA2BzBC,+BAA+B,GAA/BA,+BAA+B;AA5D3B,IAAA,OAAc,WAAd,cAAc,CAAA;AACC,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC7C,IAAA,MAAa,kCAAb,aAAa,EAAA;AAChB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACK,IAAA,YAAc,kCAAd,cAAc,EAAA;AAE1BC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAIR,IAAA,kBAA+B,WAA/B,+BAA+B,CAAA;AACT,IAAA,MAAS,WAAT,SAAS,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,qCAAqC;AACrC,mEAAmE;AACnE,SAASC,WAAW,CAACC,GAAa,EAAY;IAC5C,OAAOA,GAAG,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,GAAKA,CAAC,CAACC,MAAM,GAAGF,CAAC,CAACE,MAAM;IAAA,CAAC,CAAC;CAChD;AAGM,eAAeT,qBAAqB,CAACU,WAAmB,EAAE;IAC/D,IAAI;QACF,MAAMC,UAAU,GAAGC,cAAS,UAAA,CAACC,KAAK,CAACC,gBAAgB,CAACJ,WAAW,CAAC,AAAC;QACjE,MAAMK,QAAQ,GAAGC,GAAE,QAAA,CAACC,YAAY,CAACN,UAAU,EAAE,MAAM,CAAC,AAAC;QACrD,MAAMO,WAAW,GAAGC,MAAK,QAAA,CAACC,KAAK,CAACL,QAAQ,CAAC,AAAC;QAC1C,OAAOX,WAAW,CAACQ,cAAS,UAAA,CAACS,MAAM,CAACC,mBAAmB,CAACJ,WAAW,CAAC,CAAC,CAAC;KACvE,CAAC,OAAM;Q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,AAAC;IAEH,MAAM,CAACiC,GAAG,EAAEC,OAAO,CAAC,GAAG,MAAML,OAAO,CAACC,GAAG,CAAC;QACvCxC,qBAAqB,CAACU,WAAW,CAAC;QAClCT,yBAAyB,CAACS,WAAW,CAAC;KACvC,CAAC,AAAC;IAEH,yBAAyB;IACzB,IAAI,CAAC2B,MAAM,IAAI,CAACC,UAAU,EAAE;QAC1B,OAAOT,8BAA8B,CAACnB,WAAW,CAAC,CAAC;KACpD;IAED,IAAImC,QAAQ,AAAQ,AAAC;IACrB,8CAA8C;IAC9C,IAAI,CAACR,MAAM,EAAE;QACXQ,QAAQ,GAAGD,OAAO,CAAC,CAAC,CAAC,CAAC;KACvB,MAAM,IAAI,CAACN,UAAU,EAAE;QACtBO,QAAQ,GAAGF,GAAG,CAAC,CAAC,CAAC,CAAC;KACnB,MAAM;QACL,CAACE,QAAQ,CAAC,GAAGC,CAAAA,GAAAA,MAAY,AAAc,CAAA,aAAd,CAACH,GAAG,EAAEC,OAAO,CAAC,CAAC;KACzC;IACD,OAAOC,QAAQ,WAARA,QAAQ,GAAI,IAAI,CAAC;CACzB"}
1
+ {"version":3,"sources":["../../../src/utils/scheme.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { AndroidConfig, IOSConfig } from '@expo/config-plugins';\nimport { getInfoPlistPathFromPbxproj } from '@expo/config-plugins/build/ios/utils/getInfoPlistPath';\nimport plist from '@expo/plist';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport * as Log from '../log';\nimport {\n hasRequiredAndroidFilesAsync,\n hasRequiredIOSFilesAsync,\n} from '../prebuild/clearNativeFolder';\nimport { intersecting } from './array';\n\nconst debug = require('debug')('expo:utils:scheme') as typeof console.log;\n\n// sort longest to ensure uniqueness.\n// this might be undesirable as it causes the QR code to be longer.\nfunction sortLongest(obj: string[]): string[] {\n return obj.sort((a, b) => b.length - a.length);\n}\n\n// TODO: Revisit and test after run code is merged.\nexport async function getSchemesForIosAsync(projectRoot: string): Promise<string[]> {\n try {\n const infoPlistBuildProperty = getInfoPlistPathFromPbxproj(projectRoot);\n debug(`ios application Info.plist path:`, infoPlistBuildProperty);\n if (infoPlistBuildProperty) {\n const configPath = path.join(projectRoot, 'ios', infoPlistBuildProperty);\n const rawPlist = fs.readFileSync(configPath, 'utf8');\n const plistObject = plist.parse(rawPlist);\n const schemes = IOSConfig.Scheme.getSchemesFromPlist(plistObject);\n debug(`ios application schemes:`, schemes);\n return sortLongest(schemes);\n }\n } catch (error) {\n debug(`expected error collecting ios application schemes for the main target:`, error);\n }\n // No ios folder or some other error\n return [];\n}\n\n// TODO: Revisit and test after run code is merged.\nexport async function getSchemesForAndroidAsync(projectRoot: string): Promise<string[]> {\n try {\n const configPath = await AndroidConfig.Paths.getAndroidManifestAsync(projectRoot);\n const manifest = await AndroidConfig.Manifest.readAndroidManifestAsync(configPath);\n const schemes = await AndroidConfig.Scheme.getSchemesFromManifest(manifest);\n debug(`android application schemes:`, schemes);\n return sortLongest(schemes);\n } catch (error) {\n debug(`expected error collecting android application schemes for the main activity:`, error);\n // No android folder or some other error\n return [];\n }\n}\n\n// TODO: Revisit and test after run code is merged.\nasync function getManagedDevClientSchemeAsync(projectRoot: string): Promise<string | null> {\n const { exp } = getConfig(projectRoot);\n try {\n const getDefaultScheme = require(resolveFrom(projectRoot, 'expo-dev-client/getDefaultScheme'));\n const scheme = getDefaultScheme(exp);\n return scheme;\n } catch {\n Log.warn(\n '\\nDevelopment build: Unable to get the default URI scheme for the project. Please make sure the expo-dev-client package is installed.'\n );\n return null;\n }\n}\n\n// TODO: Revisit and test after run code is merged.\nexport async function getOptionalDevClientSchemeAsync(projectRoot: string): Promise<string | null> {\n const [hasIos, hasAndroid] = await Promise.all([\n hasRequiredIOSFilesAsync(projectRoot),\n hasRequiredAndroidFilesAsync(projectRoot),\n ]);\n\n const [ios, android] = await Promise.all([\n getSchemesForIosAsync(projectRoot),\n getSchemesForAndroidAsync(projectRoot),\n ]);\n\n // Allow managed projects\n if (!hasIos && !hasAndroid) {\n return getManagedDevClientSchemeAsync(projectRoot);\n }\n\n let matching: string;\n // Allow for only one native project to exist.\n if (!hasIos) {\n matching = android[0];\n } else if (!hasAndroid) {\n matching = ios[0];\n } else {\n [matching] = intersecting(ios, android);\n }\n return matching ?? null;\n}\n"],"names":["getSchemesForIosAsync","getSchemesForAndroidAsync","getOptionalDevClientSchemeAsync","Log","debug","require","sortLongest","obj","sort","a","b","length","projectRoot","infoPlistBuildProperty","getInfoPlistPathFromPbxproj","configPath","path","join","rawPlist","fs","readFileSync","plistObject","plist","parse","schemes","IOSConfig","Scheme","getSchemesFromPlist","error","AndroidConfig","Paths","getAndroidManifestAsync","manifest","Manifest","readAndroidManifestAsync","getSchemesFromManifest","getManagedDevClientSchemeAsync","exp","getConfig","getDefaultScheme","resolveFrom","scheme","warn","hasIos","hasAndroid","Promise","all","hasRequiredIOSFilesAsync","hasRequiredAndroidFilesAsync","ios","android","matching","intersecting"],"mappings":"AAAA;;;;QAwBsBA,qBAAqB,GAArBA,qBAAqB;QAoBrBC,yBAAyB,GAAzBA,yBAAyB;QA8BzBC,+BAA+B,GAA/BA,+BAA+B;AA1E3B,IAAA,OAAc,WAAd,cAAc,CAAA;AACC,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AACnB,IAAA,iBAAuD,WAAvD,uDAAuD,CAAA;AACjF,IAAA,MAAa,kCAAb,aAAa,EAAA;AAChB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAE1BC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAIR,IAAA,kBAA+B,WAA/B,+BAA+B,CAAA;AACT,IAAA,MAAS,WAAT,SAAS,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,AAAsB,AAAC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EH,MAAM,CAACqC,GAAG,EAAEC,OAAO,CAAC,GAAG,MAAML,OAAO,CAACC,GAAG,CAAC;QACvC9C,qBAAqB,CAACY,WAAW,CAAC;QAClCX,yBAAyB,CAACW,WAAW,CAAC;KACvC,CAAC,AAAC;IAEH,yBAAyB;IACzB,IAAI,CAAC+B,MAAM,IAAI,CAACC,UAAU,EAAE;QAC1B,OAAOR,8BAA8B,CAACxB,WAAW,CAAC,CAAC;KACpD;IAED,IAAIuC,QAAQ,AAAQ,AAAC;IACrB,8CAA8C;IAC9C,IAAI,CAACR,MAAM,EAAE;QACXQ,QAAQ,GAAGD,OAAO,CAAC,CAAC,CAAC,CAAC;KACvB,MAAM,IAAI,CAACN,UAAU,EAAE;QACtBO,QAAQ,GAAGF,GAAG,CAAC,CAAC,CAAC,CAAC;KACnB,MAAM;QACL,CAACE,QAAQ,CAAC,GAAGC,CAAAA,GAAAA,MAAY,AAAc,CAAA,aAAd,CAACH,GAAG,EAAEC,OAAO,CAAC,CAAC;KACzC;IACD,OAAOC,QAAQ,WAARA,QAAQ,GAAI,IAAI,CAAC;CACzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -47,7 +47,7 @@
47
47
  "@expo/osascript": "^2.0.31",
48
48
  "@expo/package-manager": "~0.0.53",
49
49
  "@expo/plist": "^0.0.18",
50
- "@expo/prebuild-config": "~5.0.3",
50
+ "@expo/prebuild-config": "~5.0.5",
51
51
  "@expo/rudder-sdk-node": "1.1.1",
52
52
  "@expo/spawn-async": "1.5.0",
53
53
  "@expo/xcpretty": "^4.2.1",
@@ -138,5 +138,5 @@
138
138
  "structured-headers": "^0.4.1",
139
139
  "taskr": "1.1.0"
140
140
  },
141
- "gitHead": "5ff3a7e56ae21f002da3d699cc95bc98d784cd77"
141
+ "gitHead": "0e26dbddd4119a23dbe163f7fe8c70de3a5a9ac2"
142
142
  }