UNPKG

@gluestack-seal/cli

Version:
56 lines (45 loc) 1.37 kB
import { join } from "path"; import { exists } from "../helpers/fs-exists"; import { parseYAML } from "../helpers/parse-yaml"; import { exitWithMsg } from "../helpers/exit-with-msg"; import { isEmpty } from "lodash"; import { validateSeal } from "../validations/seal"; import { Seal } from "../typings/seal"; import * as os from "os"; import { ConsoleTable } from "@gluestack/helpers"; import { readfile } from "../helpers/fs-readfile-json"; import getStore from "../helpers/get-store"; export default async (): Promise<void> => { const _yamlPath = join("seal.yaml"); if (!(await exists(_yamlPath))) { await exitWithMsg(`> "${_yamlPath}" doesn't exists`); } const _yamlContent: Seal = await validateSeal(await parseYAML(_yamlPath)); if ( !_yamlContent || !_yamlContent.services || isEmpty(_yamlContent.services) ) { await exitWithMsg(`> "seal.yaml" services does not exists`); } const store = await getStore(); const data: any = store.get("services") || []; const head: string[] = [ "#", "Service Name", "Status", "Platform", "Port", ]; const rows: any = []; data.map((item: any, index: number) => { rows.push([ index + 1, item.service || "NA", item.status || "NA", item.platform || "NA", item.port || "NA", ]); }); ConsoleTable.print(head, rows); };