xref: /expo/packages/@expo/cli/src/customize/index.ts (revision bb5069cd)
1#!/usr/bin/env node
2import chalk from 'chalk';
3
4import { Command } from '../../bin/cli';
5import { assertWithOptionsArgs, printHelp } from '../utils/args';
6
7export const expoCustomize: Command = async (argv) => {
8  const args = assertWithOptionsArgs(
9    {
10      // Other options are parsed manually.
11      '--help': Boolean,
12      // Aliases
13      '-h': '--help',
14    },
15    {
16      argv,
17      // Allow other options, we'll throw an error if unexpected values are passed.
18      permissive: true,
19    }
20  );
21
22  if (args['--help']) {
23    printHelp(
24      `Generate static project files`,
25      chalk`npx expo customize {dim [files...] -- [options]}`,
26      [
27        chalk`[files...]  List of files to generate`,
28        chalk`[options]   Options to pass to the install command`,
29        `-h, --help  Usage info`,
30      ].join('\n')
31    );
32  }
33
34  // Load modules after the help prompt so `npx expo install -h` shows as fast as possible.
35  const { customizeAsync } = require('./customizeAsync') as typeof import('./customizeAsync');
36  const { logCmdError } = require('../utils/errors') as typeof import('../utils/errors');
37  const { resolveArgsAsync } = require('./resolveOptions') as typeof import('./resolveOptions');
38
39  const { variadic, options, extras } = await resolveArgsAsync(process.argv.slice(3)).catch(
40    logCmdError
41  );
42  return customizeAsync(variadic, options, extras).catch(logCmdError);
43};
44