UNPKG

ecus-cli

Version:

A Command line interface of ECUS

65 lines (64 loc) 2.91 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.initCommand = void 0; const inquirer_1 = __importDefault(require("inquirer")); const lodash_1 = __importDefault(require("lodash")); const config_1 = require("../utils/config"); const zx_1 = require("zx"); exports.initCommand = { command: "init", describe: "login with apikey and set url", builder: (yargs) => yargs .option("url", { description: "url of self host server url", }) .option("projectId", { description: "project id of this project", }) .option("apikey", { description: "api key of ecus", }), handler(args) { return __awaiter(this, void 0, void 0, function* () { const config = yield (0, config_1.getFileConfig)(); const { url = args.url, projectId = args.projectId, apikey = args.apikey, } = yield inquirer_1.default.prompt(lodash_1.default.compact([ !args.url && { name: "url", type: "input", default: config.url, message: "please input your self hosted ecus service url, example: https://update.example.com", }, !args.projectId && { name: "projectId", type: "input", default: config.projectId, message: "please input your project id", }, !args.apikey && { name: "apikey", type: "input", default: config.apikey, message: "please input your api key from ecus admin, you can check it from: https://update.example.com/admin/apikey", }, ])); (0, config_1.updateFileConfig)({ url: url, projectId: projectId, apikey: apikey, }); console.log(zx_1.chalk.green("config has been update into"), zx_1.chalk.green.bold(".ecus/config.json")); }); }, };