1#!/usr/bin/env node 2import chalk from 'chalk'; 3 4import { Command } from '../../bin/cli'; 5import * as Log from '../log'; 6import { assertWithOptionsArgs } from '../utils/args'; 7 8export const expoInstall: Command = async (argv) => { 9 const args = assertWithOptionsArgs( 10 { 11 // Other options are parsed manually. 12 '--help': Boolean, 13 // Aliases 14 '-h': '--help', 15 }, 16 { 17 argv, 18 // Allow other options, we'll throw an error if unexpected values are passed. 19 permissive: true, 20 } 21 ); 22 23 if (args['--help']) { 24 Log.exit( 25 chalk` 26 {bold Description} 27 Install a module or other package to a project 28 29 {bold Usage} 30 $ npx expo install {dim [packages...] [options]} 31 32 {bold Options} 33 --check Check which installed packages need to be updated. 34 --fix Automatically update any invalid package versions. 35 --npm Use npm to install dependencies. {dim Default when package-lock.json exists} 36 --yarn Use Yarn to install dependencies. {dim Default when yarn.lock exists} 37 -h, --help Output usage information 38 39 Additional options can be passed to the underlying install command by using {bold --} 40 $ expo install react -- --verbose 41 {dim >} yarn add react --verbose 42 `, 43 0 44 ); 45 } 46 47 // Load modules after the help prompt so `npx expo install -h` shows as fast as possible. 48 const { installAsync } = require('./installAsync') as typeof import('./installAsync'); 49 const { logCmdError } = require('../utils/errors') as typeof import('../utils/errors'); 50 const { resolveArgsAsync } = require('./resolveOptions') as typeof import('./resolveOptions'); 51 52 const { variadic, options, extras } = await resolveArgsAsync(process.argv.slice(3)).catch( 53 logCmdError 54 ); 55 return installAsync(variadic, options, extras).catch(logCmdError); 56}; 57