#!/usr/bin/env node 'use strict'; var chalk = require('chalk'); var fs = require('fs'); require('get-port'); require('ink'); var meow = require('meow'); require('react'); require('update-check'); var path = require('path'); var os = require('os'); require('node-fetch'); require('cli-spinners'); require('ink-select-input'); require('ink-text-input'); require('ink-link'); require('http'); require('open'); require('tar'); require('has-yarn'); require('child_process'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var meow__default = /*#__PURE__*/_interopDefaultLegacy(meow); var path__default = /*#__PURE__*/_interopDefaultLegacy(path); var os__default = /*#__PURE__*/_interopDefaultLegacy(os); var isDevMode = Boolean(process.env.RAILWAY_DEV); var dir = "./.railway"; var railwayPath = path__default['default'].resolve(dir); var paths = { railwayPath: railwayPath, configFilePath: path__default['default'].resolve(railwayPath, "./config.json"), gitIgnoreFilePath: path__default['default'].resolve(railwayPath, "./.gitignore"), railwayEnvFilePath: path__default['default'].resolve(railwayPath, "./env.json"), nodeEnvFilePath: path__default['default'].resolve(__dirname, "../pg/env.json"), }; var globalConfigDir = path__default['default'].resolve(os__default['default'].homedir(), ".railway"); var globalConfigFile = path__default['default'].join(globalConfigDir, "config.json"); var railwayProductionToken = process.env.RAILWAY_PRODUCTION_TOKEN; var tasks = [ { cmd: "run", title: "run ", description: "Run command using Railway environment", }, { cmd: "build", title: "build", description: "Generate env file for running Railway in production", }, { cmd: "status", description: "View status of project", }, { cmd: "init", description: "Get started with Railway", }, { cmd: "use", description: "Select an environment to use", }, { cmd: "open", description: "Open project in browser", }, { cmd: "new", description: "Create a new project", }, { cmd: "list", description: "Show all of your projects", }, { cmd: "login", description: "Login to Railway", }, { cmd: "logout", description: "Logout of Railway", }, { cmd: "whoami", description: "Show the currently logged in user", }, { cmd: "env", description: "Show Railway environment", }, { cmd: "up", description: "Instantly deploy a cloud environment", }, ]; var options = [ { long: "help", description: "Show the usage information", }, { long: "version", alias: "v", description: "Show the version number", }, { long: "force", alias: "f", description: "Overwrite existing project if it exists", }, ]; var padding = 18; var taskHelp = function (task) { return " " + (task.title || task.cmd).padEnd(padding, " ") + task.description; }; var optionHelp = function (opt) { var left = (opt.alias != null ? "-" + opt.alias + ", " : "") + "--" + opt.long; return " " + left.padEnd(padding, " ") + opt.description; }; var helpMessage = function () { return "\n " + chalk__default['default'].dim("Usage") + "\n\n railway [options]\n\n " + chalk__default['default'].dim("Commands") + "\n\n" + tasks.map(taskHelp).join("\n") + "\n\n " + chalk__default['default'].dim("Options") + "\n\n" + options.map(optionHelp).join("\n") + "\n"; }; var cli = meow__default['default'](helpMessage(), { autoVersion: true, description: "🚂 Railway. Infrastructure, Instantly.", flags: { force: { type: "boolean", alias: "f", }, }, }); // Catch unhandled rejections process.on("unhandledRejection", function () { process.exit(); }); // Catch uncaught exceptions process.on("uncaughtException", function (error) { fs__default['default'].writeSync(1, error + "\n\n"); }); // End process on ctrl+c or ESC process.stdin.on("data", function (key) { if (["\u0003", "\u001B"].includes(key)) { process.exit(); } }); if (cli.input.length === 0) { cli.showHelp(); process.exit(0); } var command = cli.input[0]; var args = cli.input.slice(1); var task = tasks.find(function (t) { return t.cmd === command; }); if (task == null) { console.log("\n Command `" + command + "` not recognized."); cli.showHelp(); process.exit(1); } // go(); console.log("This version of the CLI has been deprecated."); console.log("Install the Railway CLI from @railway/cli"); console.log("View the docs for more information: https://railway.app/docs"); process.exit(1);