From a7cbc289af1eaacbb50d53f2bcb4a14f50d420ef Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 23 Sep 2025 15:31:10 +0000 Subject: [PATCH] fix(cli): improve result printing of the CLI --- cli/src/commands/flow/flow.ts | 38 +++++++++++++++++++++++++------ cli/src/commands/script/script.ts | 32 +++++++++++++++++--------- cli/src/main.ts | 2 +- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/cli/src/commands/flow/flow.ts b/cli/src/commands/flow/flow.ts index 93938e6254..b6a59f95e1 100644 --- a/cli/src/commands/flow/flow.ts +++ b/cli/src/commands/flow/flow.ts @@ -14,7 +14,6 @@ import { FSFSElement, elementsToMap, ignoreF } from "../sync/sync.ts"; import { Flow } from "../../../gen/types.gen.ts"; import { replaceInlineScripts } from "../../../windmill-utils-internal/src/inline-scripts/replacer.ts"; - export interface FlowFile { summary: string; description?: string; @@ -55,7 +54,7 @@ export async function pushFlow( async (path: string) => await Deno.readTextFile(localPath + path), log, localPath, - SEP, + SEP ); if (flow) { @@ -191,7 +190,7 @@ async function run( workspace: workspace.workspaceId, id, }); - log.info(jobInfo.result ?? {}); + log.info(JSON.stringify(jobInfo.result ?? {}, null, 2)); } async function generateLocks( @@ -201,14 +200,23 @@ async function generateLocks( } & SyncOptions, folder: string | undefined ) { - const useRawReqs = opts.useRawRequirements || Deno.env.get("USE_RAW_REQUIREMENTS") === "true"; + const useRawReqs = + opts.useRawRequirements || Deno.env.get("USE_RAW_REQUIREMENTS") === "true"; const workspace = await resolveWorkspace(opts); await requireLogin(opts); opts = await mergeConfigWithConfigFile(opts); if (folder) { // read script metadata file - await generateFlowLockInternal(folder, false, workspace, opts, undefined, undefined, useRawReqs); + await generateFlowLockInternal( + folder, + false, + workspace, + opts, + undefined, + undefined, + useRawReqs + ); } else { const ignore = await ignoreF(opts); const elems = Object.keys( @@ -229,7 +237,15 @@ async function generateLocks( let hasAny = false; for (const folder of elems) { - const candidate = await generateFlowLockInternal(folder, true, workspace, opts, undefined, undefined, useRawReqs); + const candidate = await generateFlowLockInternal( + folder, + true, + workspace, + opts, + undefined, + undefined, + useRawReqs + ); if (candidate) { hasAny = true; log.info(colors.green(`+ ${candidate}`)); @@ -251,7 +267,15 @@ async function generateLocks( return; } for (const folder of elems) { - await generateFlowLockInternal(folder, false, workspace, opts,undefined, undefined, useRawReqs); + await generateFlowLockInternal( + folder, + false, + workspace, + opts, + undefined, + undefined, + useRawReqs + ); } } } diff --git a/cli/src/commands/script/script.ts b/cli/src/commands/script/script.ts index 9c4171a97e..f719a008a3 100644 --- a/cli/src/commands/script/script.ts +++ b/cli/src/commands/script/script.ts @@ -29,7 +29,7 @@ import { parseMetadataFile, } from "../../utils/metadata.ts"; import { - LanguageWithRawReqsSupport, + LanguageWithRawReqsSupport, ScriptLanguage, inferContentTypeFromFilePath, languagesWithRawReqsSupport, @@ -114,8 +114,14 @@ export async function findResourceFile(path: string) { if (currentBranch) { // Add branch-specific candidates at the beginning (higher priority) - const branchSpecificJSON = specificItems.toBranchSpecificPath(contentBasePathJSON, currentBranch); - const branchSpecificYAML = specificItems.toBranchSpecificPath(contentBasePathYAML, currentBranch); + const branchSpecificJSON = specificItems.toBranchSpecificPath( + contentBasePathJSON, + currentBranch + ); + const branchSpecificYAML = specificItems.toBranchSpecificPath( + contentBasePathYAML, + currentBranch + ); candidates.unshift(branchSpecificJSON, branchSpecificYAML); } @@ -624,7 +630,7 @@ export const exts = [ ".nu", ".playbook.yml", ".java", - ".rb" + ".rb", // for related places search: ADD_NEW_LANG ]; @@ -727,7 +733,7 @@ async function run( if (opts.silent) { console.log(result); } else { - log.info(result); + log.info(JSON.stringify(result, null, 2)); } break; @@ -885,7 +891,10 @@ async function bootstrap( ); } -export type GlobalDeps = Map>; +export type GlobalDeps = Map< + LanguageWithRawReqsSupport, + Record +>; export async function findGlobalDeps(): Promise { var globalDeps: GlobalDeps = new Map(); @@ -895,9 +904,8 @@ export async function findGlobalDeps(): Promise { return ( !isDir && // Skip if the filename is not one of lockfile names - !(languagesWithRawReqsSupport.some( - lockfile => - p.endsWith(SEP + lockfile.rrFilename)) + !languagesWithRawReqsSupport.some((lockfile) => + p.endsWith(SEP + lockfile.rrFilename) ) ); }, els)) { @@ -906,9 +914,11 @@ export async function findGlobalDeps(): Promise { // Iterate over available languages to find which lockfile languagesWithRawReqsSupport.map((lock) => { - if (entry.path.endsWith(lock.rrFilename)){ + if (entry.path.endsWith(lock.rrFilename)) { const current = globalDeps.get(lock) ?? {}; - current[entry.path.substring(0, entry.path.length - lock.rrFilename.length)] = content; + current[ + entry.path.substring(0, entry.path.length - lock.rrFilename.length) + ] = content; globalDeps.set(lock, current); } }); diff --git a/cli/src/main.ts b/cli/src/main.ts index 30fad224ee..baf76a3dba 100644 --- a/cli/src/main.ts +++ b/cli/src/main.ts @@ -187,7 +187,7 @@ async function main() { log.setup({ handlers: { console: new log.ConsoleHandler(LOG_LEVEL, { - formatter: ({ msg }) => `${msg}`, + formatter: ({ msg }) => msg, useColors: isWin ? false : true, }), },