UNPKG

@expo/cli

Version:
235 lines (234 loc) 6.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { BLT: ()=>BLT, printHelp: ()=>printHelp, printQRCode: ()=>printQRCode, getTerminalColumns: ()=>getTerminalColumns, printItem: ()=>printItem, printUsage: ()=>printUsage }); function _chalk() { const data = /*#__PURE__*/ _interopRequireDefault(require("chalk")); _chalk = function() { return data; }; return data; } function _qrcodeTerminal() { const data = /*#__PURE__*/ _interopRequireDefault(require("qrcode-terminal")); _qrcodeTerminal = function() { return data; }; return data; } function _wrapAnsi() { const data = /*#__PURE__*/ _interopRequireDefault(require("wrap-ansi")); _wrapAnsi = function() { return data; }; return data; } const _log = /*#__PURE__*/ _interopRequireWildcard(require("../../log")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for(var key in obj){ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const BLT = "›"; const printHelp = ()=>{ logCommandsTable([ { key: "?", msg: "show all commands" } ]); }; function printQRCode(url) { _qrcodeTerminal().default.generate(url, { small: true }, (code)=>_log.log(code)); } const getTerminalColumns = ()=>process.stdout.columns || 80; const printItem = (text)=>`${BLT} ` + (0, _wrapAnsi().default)(text, getTerminalColumns()).trimStart(); function printUsage(options, { verbose }) { const isMac = process.platform === "darwin"; const { platforms =[ "ios", "android", "web" ] } = options; const isAndroidDisabled = !platforms.includes("android"); const isIosDisabled = !platforms.includes("ios"); const isWebDisable = !platforms.includes("web"); const switchMsg = `switch to ${options.devClient === false ? "development build" : "Expo Go"}`; const target = options.devClient === false ? `Expo Go` : "development build"; _log.log(); _log.log(printItem((0, _chalk().default)`Using {cyan ${target}}`)); if (verbose) { logCommandsTable([ { key: "s", msg: switchMsg }, {}, { key: "a", msg: "open Android", disabled: isAndroidDisabled }, { key: "shift+a", msg: "select a device or emulator", disabled: isAndroidDisabled }, isMac && { key: "i", msg: "open iOS simulator", disabled: isIosDisabled }, isMac && { key: "shift+i", msg: "select a simulator", disabled: isIosDisabled }, { key: "w", msg: "open web", disabled: isWebDisable }, {}, { key: "r", msg: "reload app" }, !!options.isWebSocketsEnabled && { key: "j", msg: "open debugger" }, !!options.isWebSocketsEnabled && { key: "m", msg: "toggle menu" }, !!options.isWebSocketsEnabled && { key: "shift+m", msg: "more tools" }, { key: "o", msg: "open project code in your editor" }, { key: "c", msg: "show project QR" }, {}, ]); } else { logCommandsTable([ { key: "s", msg: switchMsg }, {}, { key: "a", msg: "open Android", disabled: isAndroidDisabled }, isMac && { key: "i", msg: "open iOS simulator", disabled: isIosDisabled }, { key: "w", msg: "open web", disabled: isWebDisable }, {}, { key: "j", msg: "open debugger" }, { key: "r", msg: "reload app" }, !!options.isWebSocketsEnabled && { key: "m", msg: "toggle menu" }, { key: "o", msg: "open project code in your editor" }, {}, ]); } } function logCommandsTable(ui) { _log.log(ui.filter(Boolean)// @ts-ignore: filter doesn't work .map(({ key , msg , status , disabled })=>{ if (!key) return ""; let view = `${BLT} `; if (key.length === 1) view += "Press "; view += (0, _chalk().default)`{bold ${key}} {dim │} `; view += msg; if (status) { view += ` ${_chalk().default.dim(`(${_chalk().default.italic(status)})`)}`; } if (disabled) { view = _chalk().default.dim(view); } return view; }).join("\n")); } //# sourceMappingURL=commandsTable.js.map