xref: /expo/packages/@expo/cli/src/export/web/index.ts (revision bb5069cd)
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 expoExportWeb: Command = async (argv) => {
9  const args = assertArgs(
10    {
11      // Types
12      '--help': Boolean,
13      '--clear': Boolean,
14      '--dev': Boolean,
15      // Aliases
16      '-h': '--help',
17      '-c': '--clear',
18    },
19    argv
20  );
21
22  if (args['--help']) {
23    printHelp(
24      `Export the static files of the web app for hosting on a web server`,
25      chalk`npx expo export:web {dim <dir>}`,
26      [
27        chalk`<dir>                         Directory of the Expo project. {dim Default: Current working directory}`,
28        `--dev                         Bundle in development mode`,
29        `-c, --clear                   Clear the bundler cache`,
30        `-h, --help                    Usage info`,
31      ].join('\n')
32    );
33  }
34
35  const projectRoot = getProjectRoot(args);
36  const { resolveOptionsAsync } = await import('./resolveOptions');
37  const options = await resolveOptionsAsync(args).catch(logCmdError);
38
39  const { exportWebAsync } = await import('./exportWebAsync');
40  return exportWebAsync(projectRoot, options).catch(logCmdError);
41};
42