fix(cli): improve result printing of the CLI

This commit is contained in:
Ruben Fiszel
2025-09-23 15:31:10 +00:00
parent 2de7134b85
commit a7cbc289af
3 changed files with 53 additions and 19 deletions
+31 -7
View File
@@ -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
);
}
}
}
+21 -11
View File
@@ -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<LanguageWithRawReqsSupport, Record<string, string>>;
export type GlobalDeps = Map<
LanguageWithRawReqsSupport,
Record<string, string>
>;
export async function findGlobalDeps(): Promise<GlobalDeps> {
var globalDeps: GlobalDeps = new Map();
@@ -895,9 +904,8 @@ export async function findGlobalDeps(): Promise<GlobalDeps> {
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<GlobalDeps> {
// 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);
}
});
+1 -1
View File
@@ -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,
}),
},