UNPKG

@metacall/deploy

Version:

Tool for deploying into MetaCall FaaS platform.

140 lines (139 loc) 3.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InspectFormat = void 0; const plan_1 = require("@metacall/protocol/plan"); const path_1 = require("path"); const ts_command_line_args_1 = require("ts-command-line-args"); var InspectFormat; (function (InspectFormat) { InspectFormat["Invalid"] = "Invalid"; InspectFormat["Table"] = "Table"; InspectFormat["Raw"] = "Raw"; InspectFormat["OpenAPIv3"] = "OpenAPIv3"; })(InspectFormat = exports.InspectFormat || (exports.InspectFormat = {})); const parsePlan = (planType) => { if (Object.keys(plan_1.Plans).includes(planType)) { return plan_1.Plans[planType]; } }; const parseInspectFormat = (inspectFormatType) => { if (inspectFormatType === '') { return InspectFormat.Table; } if (Object.keys(InspectFormat).includes(inspectFormatType)) { return InspectFormat[inspectFormatType]; } return InspectFormat.Invalid; }; const optionsDefinition = { version: { type: Boolean, optional: true, alias: 'v' }, addrepo: { type: String, optional: true, alias: 'a' }, workdir: { type: String, defaultValue: '', alias: 'w' }, dev: { type: Boolean, defaultValue: false, alias: 'd' }, projectName: { type: String, defaultValue: '', alias: 'n' }, email: { type: String, alias: 'e', optional: true }, password: { type: String, alias: 'p', optional: true }, token: { type: String, alias: 't', optional: true }, force: { type: Boolean, alias: 'f', defaultValue: false }, plan: { type: parsePlan, alias: 'P', optional: true }, inspect: { type: parseInspectFormat, alias: 'i', optional: true }, delete: { type: Boolean, alias: 'D', defaultValue: false, optional: true }, logout: { type: Boolean, alias: 'l', defaultValue: false, optional: true }, listPlans: { type: Boolean, alias: 'r', defaultValue: false, optional: true }, serverUrl: { type: String, alias: 'u', optional: true }, confDir: { type: String, alias: 'c', optional: true } }; const parseOptions = { helpArg: 'help', headerContentSections: [ { header: 'Official CLI for metacall-deploy', content: 'Usage: metacall-deploy [--args]' } ], partial: true }; const args = (() => { const parsedArgs = (0, ts_command_line_args_1.parse)(optionsDefinition, parseOptions); // Adding this here because the CLI integration tests execute API // methods either from the child process (runCLI) to the parent // process, the one running mocha, so if we just add --dev in the child // it fails on the parent process, this is is also fine here because it // is executed only once at the startup of the program if (process.env.TEST_DEPLOY_LOCAL === 'true') { parsedArgs['dev'] = true; } // Initialize default working directory if (parsedArgs['workdir'] === '') { parsedArgs['workdir'] = process.cwd(); } // Initialize default project name if (parsedArgs['projectName'] === '') { parsedArgs['projectName'] = (0, path_1.basename)(parsedArgs['workdir']); } return { _unknown: [], ...parsedArgs }; })(); exports.default = args;