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 // Aliases 21 '-h': '--help', 22 // '-s': '--dump-sourcemap', 23 // '-d': '--dump-assetmap', 24 '-c': '--clear', 25 }, 26 argv 27 ); 28 29 if (args['--help']) { 30 printHelp( 31 `Export the static files of the app for hosting it on a web server`, 32 chalk`npx expo export {dim <dir>}`, 33 [ 34 chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`, 35 chalk`--platform <all|android|ios> Platforms: android, ios, all. {dim Default: all}`, 36 `--dev Configure static files for developing locally using a non-https server`, 37 chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`, 38 `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`, 39 `--dump-assetmap Dump the asset map for further processing`, 40 `--dump-sourcemap Dump the source map for debugging the JS bundle`, 41 `-c, --clear Clear the bundler cache`, 42 `-h, --help Usage info`, 43 ].join('\n') 44 ); 45 } 46 47 const projectRoot = getProjectRoot(args); 48 const { resolveOptionsAsync } = await import('./resolveOptions'); 49 const options = await resolveOptionsAsync(args).catch(logCmdError); 50 51 const { exportAsync } = await import('./exportAsync'); 52 return exportAsync(projectRoot, options).catch(logCmdError); 53}; 54