1#!/usr/bin/env node 2import chalk from 'chalk'; 3 4import { Command } from '../../bin/cli'; 5import { assertArgs, getProjectRoot, printHelp } from '../utils/args'; 6import { logCmdError } from '../utils/errors'; 7 8export const expoExport: Command = async (argv) => { 9 const args = assertArgs( 10 { 11 // Types 12 '--help': Boolean, 13 '--clear': Boolean, 14 '--dump-assetmap': Boolean, 15 '--dev': Boolean, 16 '--dump-sourcemap': Boolean, 17 '--max-workers': Number, 18 '--output-dir': String, 19 '--platform': [String], 20 '--no-minify': Boolean, 21 22 // Hack: This is added because EAS CLI always includes the flag. 23 // If supplied, we'll do nothing with the value, but at least the process won't crash. 24 // Note that we also don't show this value in the `--help` prompt since we don't want people to use it. 25 '--experimental-bundle': Boolean, 26 27 // Aliases 28 '-h': '--help', 29 // '-s': '--dump-sourcemap', 30 // '-d': '--dump-assetmap', 31 '-c': '--clear', 32 '-p': '--platform', 33 // Interop with Metro docs and RedBox errors. 34 '--reset-cache': '--clear', 35 }, 36 argv 37 ); 38 39 if (args['--help']) { 40 printHelp( 41 `Export the static files of the app for hosting it on a web server`, 42 chalk`npx expo export {dim <dir>}`, 43 [ 44 chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`, 45 `--dev Configure static files for developing locally using a non-https server`, 46 chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`, 47 `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`, 48 `--dump-assetmap Dump the asset map for further processing`, 49 `--dump-sourcemap Dump the source map for debugging the JS bundle`, 50 chalk`-p, --platform <platform> Options: android, ios, web, all. {dim Default: all}`, 51 `--no-minify Prevent minifying source`, 52 `-c, --clear Clear the bundler cache`, 53 `-h, --help Usage info`, 54 ].join('\n') 55 ); 56 } 57 58 const projectRoot = getProjectRoot(args); 59 const { resolveOptionsAsync } = await import('./resolveOptions'); 60 const options = await resolveOptionsAsync(projectRoot, args).catch(logCmdError); 61 62 const { exportAsync } = await import('./exportAsync'); 63 return exportAsync(projectRoot, options).catch(logCmdError); 64}; 65