fix: requirements.txt modifications

This commit is contained in:
Space-Banane
2026-03-27 16:50:04 +01:00
parent a1f80d38f2
commit 37f6d50034
3 changed files with 11 additions and 27 deletions
+5 -13
View File
@@ -63,18 +63,10 @@ export const reqAddDefinition = {
}
content += pkg + "\n";
// 3. Get function details to find storageId
const funcResponse = await client.get(`/api/function/${functionId}`);
const func = funcResponse.data.data;
if (!func || !func.namespace || !func.namespace.storageId) {
throw new Error("Could not determine storage ID for function.");
}
const storageId = func.namespace.storageId;
// 4. Overwrite/Create requirements.txt
await client.put(`/api/storage/${storageId}/files`, {
path: "requirements.txt",
content: content
// 3. Overwrite/Create requirements.txt using function-based API
await client.put(`/api/function/${functionId}/file`, {
filename: "requirements.txt",
code: content,
});
console.log(`${chalk.green("✓")} Added ${chalk.cyan(pkg)} to requirements.txt for function ${chalk.yellow(functionId)}.`);
@@ -86,7 +78,7 @@ export const reqAddDefinition = {
function handleError(error: any, task: string) {
if (error.response) {
console.error(`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(error.response.data?.message || error.message)}`);
console.error(`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(error.response.data?.message || (error.response.data ? JSON.stringify(error.response.data) : error.message))}`);
} else if (error.request) {
console.error(
`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(