1dc51e206SEvan Bacon#!/usr/bin/env node 2dc51e206SEvan Baconimport chalk from 'chalk'; 3dc51e206SEvan Bacon 4dc51e206SEvan Baconimport { Command } from '../../bin/cli'; 583d464dcSEvan Baconimport { assertArgs, getProjectRoot, printHelp } from '../utils/args'; 6dc51e206SEvan Baconimport { logCmdError } from '../utils/errors'; 7dc51e206SEvan Bacon 8dc51e206SEvan Baconexport const expoExport: Command = async (argv) => { 9dc51e206SEvan Bacon const args = assertArgs( 10dc51e206SEvan Bacon { 11dc51e206SEvan Bacon // Types 12dc51e206SEvan Bacon '--help': Boolean, 13dc51e206SEvan Bacon '--clear': Boolean, 14dc51e206SEvan Bacon '--dump-assetmap': Boolean, 15dc51e206SEvan Bacon '--dev': Boolean, 16dc51e206SEvan Bacon '--dump-sourcemap': Boolean, 17dc51e206SEvan Bacon '--max-workers': Number, 18dc51e206SEvan Bacon '--output-dir': String, 198eba27a6SCedric van Putten '--platform': [String], 201a3d836eSEvan Bacon '--no-minify': Boolean, 21d0ad06c2SEvan Bacon 22d0ad06c2SEvan Bacon // Hack: This is added because EAS CLI always includes the flag. 23d0ad06c2SEvan Bacon // If supplied, we'll do nothing with the value, but at least the process won't crash. 24d0ad06c2SEvan Bacon // Note that we also don't show this value in the `--help` prompt since we don't want people to use it. 25d0ad06c2SEvan Bacon '--experimental-bundle': Boolean, 26d0ad06c2SEvan Bacon 27dc51e206SEvan Bacon // Aliases 28dc51e206SEvan Bacon '-h': '--help', 29dc51e206SEvan Bacon // '-s': '--dump-sourcemap', 30dc51e206SEvan Bacon // '-d': '--dump-assetmap', 31dc51e206SEvan Bacon '-c': '--clear', 32185ef548SEvan Bacon '-p': '--platform', 33cd7195d3SEvan Bacon // Interop with Metro docs and RedBox errors. 34cd7195d3SEvan Bacon '--reset-cache': '--clear', 35dc51e206SEvan Bacon }, 36dc51e206SEvan Bacon argv 37dc51e206SEvan Bacon ); 38dc51e206SEvan Bacon 39dc51e206SEvan Bacon if (args['--help']) { 4083d464dcSEvan Bacon printHelp( 4183d464dcSEvan Bacon `Export the static files of the app for hosting it on a web server`, 4283d464dcSEvan Bacon chalk`npx expo export {dim <dir>}`, 4383d464dcSEvan Bacon [ 4483d464dcSEvan Bacon chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`, 4583d464dcSEvan Bacon `--dev Configure static files for developing locally using a non-https server`, 4683d464dcSEvan Bacon chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`, 4783d464dcSEvan Bacon `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`, 4883d464dcSEvan Bacon `--dump-assetmap Dump the asset map for further processing`, 4983d464dcSEvan Bacon `--dump-sourcemap Dump the source map for debugging the JS bundle`, 50185ef548SEvan Bacon chalk`-p, --platform <platform> Options: android, ios, web, all. {dim Default: all}`, 511a3d836eSEvan Bacon `--no-minify Prevent minifying source`, 5283d464dcSEvan Bacon `-c, --clear Clear the bundler cache`, 5383d464dcSEvan Bacon `-h, --help Usage info`, 5483d464dcSEvan Bacon ].join('\n') 55dc51e206SEvan Bacon ); 56dc51e206SEvan Bacon } 57dc51e206SEvan Bacon 58dc51e206SEvan Bacon const projectRoot = getProjectRoot(args); 59*1a3a1db5SEvan Bacon const { resolveOptionsAsync } = await import('./resolveOptions.js'); 606d6b81f9SEvan Bacon const options = await resolveOptionsAsync(projectRoot, args).catch(logCmdError); 61dc51e206SEvan Bacon 62*1a3a1db5SEvan Bacon const { exportAsync } = await import('./exportAsync.js'); 63dc51e206SEvan Bacon return exportAsync(projectRoot, options).catch(logCmdError); 64dc51e206SEvan Bacon}; 65