xref: /expo/packages/@expo/cli/src/config/index.ts (revision dfd15ebd)
1#!/usr/bin/env node
2import chalk from 'chalk';
3
4import { Command } from '../../bin/cli';
5import { assertArgs, getProjectRoot, printHelp } from '../utils/args';
6
7export const expoConfig: Command = async (argv) => {
8  const args = assertArgs(
9    {
10      // Types
11      '--help': Boolean,
12      '--full': Boolean,
13      '--json': Boolean,
14      '--type': String,
15      // Aliases
16      '-h': '--help',
17      '-t': '--type',
18    },
19    argv
20  );
21
22  if (args['--help']) {
23    printHelp(
24      `Show the project config`,
25      chalk`npx expo config {dim <dir>}`,
26      [
27        chalk`<dir>                                    Directory of the Expo project. {dim Default: Current working directory}`,
28        `--full                                   Include all project config data`,
29        `--json                                   Output in JSON format`,
30        `-t, --type <public|prebuild|introspect>  Type of config to show`,
31        `-h, --help                               Usage info`,
32      ].join('\n')
33    );
34  }
35
36  // Load modules after the help prompt so `npx expo config -h` shows as fast as possible.
37  const [
38    // ./configAsync
39    { configAsync },
40    // ../utils/errors
41    { logCmdError },
42  ] = await Promise.all([import('./configAsync'), import('../utils/errors')]);
43
44  return configAsync(getProjectRoot(args), {
45    // Parsed options
46    full: args['--full'],
47    json: args['--json'],
48    type: args['--type'],
49  }).catch(logCmdError);
50};
51