#!/usr/bin/env node "use strict"; var _arg = _interopRequireDefault(require("arg")); var _chalk = _interopRequireDefault(require("chalk")); var _debug = _interopRequireDefault(require("debug")); var _getenv = require("getenv"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for(var key in obj){ if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } // Setup before requiring `debug`. if ((0, _getenv).boolish("EXPO_DEBUG", false)) { _debug.default.enable("expo:*"); } else if (_debug.default.enabled("expo:")) { process.env.EXPO_DEBUG = "1"; } const defaultCmd = "start"; const commands = { // Add a new command here "run:ios": ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/run/ios")); }).then((i)=>i.expoRunIos ) , "run:android": ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/run/android")); }).then((i)=>i.expoRunAndroid ) , start: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/start")); }).then((i)=>i.expoStart ) , prebuild: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/prebuild")); }).then((i)=>i.expoPrebuild ) , config: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/config")); }).then((i)=>i.expoConfig ) , export: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/export")); }).then((i)=>i.expoExport ) , "export:web": ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/export/web")); }).then((i)=>i.expoExportWeb ) , // Auxiliary commands install: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/install")); }).then((i)=>i.expoInstall ) , customize: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/customize")); }).then((i)=>i.expoCustomize ) , // Auth login: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/login")); }).then((i)=>i.expoLogin ) , logout: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/logout")); }).then((i)=>i.expoLogout ) , register: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/register")); }).then((i)=>i.expoRegister ) , whoami: ()=>Promise.resolve().then(function() { return _interopRequireWildcard(require("../src/whoami")); }).then((i)=>i.expoWhoami ) }; const args = (0, _arg).default({ // Types "--version": Boolean, "--help": Boolean, // NOTE(EvanBacon): This is here to silence warnings from processes that // expect the global expo-cli. "--non-interactive": Boolean, // Aliases "-v": "--version", "-h": "--help" }, { permissive: true }); if (args["--version"]) { // Version is added in the build script. console.log("0.4.11"); process.exit(0); } if (args["--non-interactive"]) { console.warn(_chalk.default.yellow` {bold --non-interactive} is not supported, use {bold $CI=1} instead`); } // Check if we are running `npx expo ` or `npx expo` const isSubcommand = Boolean(commands[args._[0]]); // Handle `--help` flag if (!isSubcommand && args["--help"]) { const { login , logout , whoami , register , start , install , export: _export , config , customize , prebuild , "run:ios": runIos , "run:android": runAndroid , ...others } = commands; console.log(_chalk.default` {bold Usage} {dim $} npx expo {bold Commands} ${Object.keys({ start, export: _export, ...others }).join(", ")} ${Object.keys({ "run:ios": runIos, "run:android": runAndroid, prebuild }).join(", ")} ${Object.keys({ install, customize, config }).join(", ")} {dim ${Object.keys({ login, logout, whoami, register }).join(", ")}} {bold Options} --version, -v Version number --help, -h Usage info For more info run a command with the {bold --help} flag {dim $} npx expo start --help `); process.exit(0); } // NOTE(EvanBacon): Squat some directory names to help with migration, // users can still use folders named "send" or "eject" by using the fully qualified `npx expo start ./send`. if (!isSubcommand) { const migrationMap = { init: "npx create-expo-app", eject: "npx expo prebuild", web: "npx expo start --web", "start:web": "npx expo start --web", "build:ios": "eas build -p ios", "build:android": "eas build -p android", "client:install:ios": "npx expo start --ios", "client:install:android": "npx expo start --android", doctor: "expo-cli doctor", upgrade: "expo-cli upgrade", "customize:web": "npx expo customize", publish: "eas update", "publish:set": "eas update", "publish:rollback": "eas update", "publish:history": "eas update", "publish:details": "eas update", "build:web": "npx expo export:web", "credentials:manager": `eas credentials`, "fetch:ios:certs": `eas credentials`, "fetch:android:keystore": `eas credentials`, "fetch:android:hashes": `eas credentials`, "fetch:android:upload-cert": `eas credentials`, "push:android:upload": `eas credentials`, "push:android:show": `eas credentials`, "push:android:clear": `eas credentials`, url: `eas build:list`, "url:ipa": `eas build:list`, "url:apk": `eas build:list`, webhooks: `eas webhook`, "webhooks:add": `eas webhook:create`, "webhooks:remove": `eas webhook:delete`, "webhooks:update": `eas webhook:update`, "build:status": `eas build:list`, "upload:android": `eas submit -p android`, "upload:ios": `eas submit -p ios` }; // TODO: Log telemetry about invalid command used. const subcommand = args._[0]; if (subcommand in migrationMap) { const replacement = migrationMap[subcommand]; console.log(); console.log(_chalk.default.yellow` {gray $} {bold expo ${subcommand}} is not supported in the local CLI, please use {bold ${replacement}} instead`); console.log(); process.exit(1); } const deprecated = [ "send", "client:ios" ]; if (deprecated.includes(subcommand)) { console.log(); console.log(_chalk.default.yellow` {gray $} {bold expo ${subcommand}} is deprecated`); console.log(); process.exit(1); } } const command = isSubcommand ? args._[0] : defaultCmd; const commandArgs = isSubcommand ? args._.slice(1) : args._; // Push the help flag to the subcommand args. if (args["--help"]) { commandArgs.push("--help"); } // Install exit hooks process.on("SIGINT", ()=>process.exit(0) ); process.on("SIGTERM", ()=>process.exit(0) ); commands[command]().then((exec)=>{ exec(commandArgs); // NOTE(EvanBacon): Track some basic telemetry events indicating the command // that was run. This can be disabled with the $EXPO_NO_TELEMETRY environment variable. // We do this to determine how well deprecations are going before removing a command. const { logEventAsync } = require("../src/utils/analytics/rudderstackClient"); logEventAsync("action", { action: `expo ${command}`, source: "expo/cli", source_version: "0.4.11" }); }); //# sourceMappingURL=cli.map