fix(cli): improve cli dependency error clarity

This commit is contained in:
Ruben Fiszel
2025-02-20 01:51:47 +01:00
parent ba187a0953
commit 97f2f8733c
2 changed files with 23 additions and 6 deletions
+22 -5
View File
@@ -49,6 +49,13 @@ import { FlowFile, replaceInlineScripts } from "./flow.ts";
import { getIsWin } from "./main.ts";
import { FlowValue } from "./gen/types.gen.ts";
export class LockfileGenerationError extends Error {
constructor(message: string) {
super(message);
this.name = 'LockfileGenerationError';
}
}
export async function generateAllMetadata() { }
function findClosestRawReqs(
@@ -376,9 +383,16 @@ async function updateScriptLock(
const response = JSON.parse(responseText);
const lock = response.lock;
if (lock === undefined) {
throw new Error(
`Failed to generate lockfile. Full response was: ${JSON.stringify(
response
if (response?.["error"]?.["message"]) {
throw new LockfileGenerationError(
`Failed to generate lockfile: ${response?.["error"]?.["message"]}`
);
}
throw new LockfileGenerationError(
`Failed to generate lockfile: ${JSON.stringify(
response,
null,
2
)}`
);
}
@@ -395,8 +409,11 @@ async function updateScriptLock(
metadataContent.lock = "";
}
} catch (e) {
throw new Error(
`Failed to generate lockfile. Status was: ${rawResponse.statusText}, ${responseText}, ${e}`
if (e instanceof LockfileGenerationError) {
throw e;
}
throw new LockfileGenerationError(
`Failed to generate lockfile:${rawResponse.statusText}, ${responseText}, ${e}`
);
}
}
+1 -1
View File
@@ -990,7 +990,7 @@ const command = new Command()
.action(bootstrap as any)
.command(
"generate-metadata",
"re-generate the metadata file updating the lock and the script schema (for flows, use `wmill flow generate - locks`)"
"re-generate the metadata file updating the lock and the script schema (for flows, use `wmill flow generate-locks`)"
)
.arguments("[script:file]")
.option("--yes", "Skip confirmation prompt")