UNPKG

esa-cli

Version:

A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).

48 lines (47 loc) 2.16 kB
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()); }); }; import logger from '../../libs/logger.js'; import { checkIsLoginSuccess } from '../utils.js'; import chalk from 'chalk'; import { ApiService } from '../../libs/apiService.js'; import t from '../../i18n/index.js'; const list = { command: 'list', describe: `📋 ${t('site_describe_list').d('List all your sites')}`, builder: (yargs) => { return yargs.usage(`${t('common_usage').d('Usage')}: \$0 list []`); }, handler: (argv) => __awaiter(void 0, void 0, void 0, function* () { handleList(argv); }) }; export default list; export function handleList(argv) { return __awaiter(this, void 0, void 0, function* () { // const { site, ...args } = argv; var _a; const isSuccess = yield checkIsLoginSuccess(); if (!isSuccess) return; const server = yield ApiService.getInstance(); const req = { SiteSearchType: 'fuzzy', Status: 'active', PageNumber: 1, PageSize: 50 }; const res = yield server.listSites(req); const siteList = (_a = res === null || res === void 0 ? void 0 : res.data.Sites) !== null && _a !== void 0 ? _a : []; const siteNameList = siteList === null || siteList === void 0 ? void 0 : siteList.map((item) => item.SiteName); logger.log(chalk.bold.bgGray(`📃 ${t('list_site_name_title').d('List all of site names')}:`)); logger.tree(siteNameList); return; }); }