diff --git a/.changeset/tame-ravens-fly.md b/.changeset/tame-ravens-fly.md new file mode 100644 index 00000000..37f36eda --- /dev/null +++ b/.changeset/tame-ravens-fly.md @@ -0,0 +1,5 @@ +--- +"@plutolang/cli": patch +--- + +feat(cli): beautify deployment outputs diff --git a/apps/cli/src/commands/deploy.ts b/apps/cli/src/commands/deploy.ts index 34f240e8..181754ef 100644 --- a/apps/cli/src/commands/deploy.ts +++ b/apps/cli/src/commands/deploy.ts @@ -161,20 +161,35 @@ async function buildArchRefAndInfraEntrypoint( return { archRef, infraEntrypoint }; } -async function deployWithAdapter( - adapter: core.Adapter, - stack: config.Stack, - force: boolean = false -) { +export async function deployWithAdapter(adapter: core.Adapter, stack: config.Stack, force = false) { logger.info("Applying..."); const applyResult = await adapter.deploy({ force }); stack.setDeployed(); logger.info("Successfully applied!"); - logger.info("Here are the resource outputs:"); + if (applyResult.outputs.length === 0) { + return; + } + + const tableData = [["Resource ID", "Output"]]; for (const key in applyResult.outputs) { - logger.info(`${key}:`, applyResult.outputs[key]); + tableData.push([key, applyResult.outputs[key]]); } + const tableConfig: TableUserConfig = { + drawHorizontalLine: (lineIndex: number, rowCount: number) => { + return lineIndex === 0 || lineIndex === 2 || lineIndex === 1 || lineIndex === rowCount; + }, + header: { + content: "Deployment Outputs", + }, + columns: { + 1: { + wrapWord: true, + }, + }, + }; + + console.log(table(tableData, tableConfig)); } async function confirmArch(archRef: arch.Architecture, confirmed: boolean): Promise { diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index b99a01cb..a4d5bf1f 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -1,10 +1,11 @@ import fs from "fs"; import path from "path"; -import { PlatformType, ProvisionType, config, core } from "@plutolang/base"; +import { PlatformType, ProvisionType, config } from "@plutolang/base"; import logger from "../log"; import { prepareStackDirs } from "../utils"; import { loadDotEnvs } from "./env"; import { loadAndDeduce } from "./compile"; +import { deployWithAdapter } from "./deploy"; import { buildAdapterByProvisionType, getDefaultDeducerPkg, @@ -60,15 +61,3 @@ export async function run(entrypoint: string) { }); await deployWithAdapter(adapter, stack); } - -async function deployWithAdapter(adapter: core.Adapter, stack: config.Stack) { - logger.info("Applying..."); - const applyResult = await adapter.deploy(); - stack.setDeployed(); - logger.info("Successfully applied!"); - - logger.info("Here are the resource outputs:"); - for (const key in applyResult.outputs) { - logger.info(`${key}:`, applyResult.outputs[key]); - } -}