fix: requirements.txt modifications
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shsf-cli",
|
"name": "shsf-cli",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
+5
-13
@@ -63,18 +63,10 @@ export const reqAddDefinition = {
|
|||||||
}
|
}
|
||||||
content += pkg + "\n";
|
content += pkg + "\n";
|
||||||
|
|
||||||
// 3. Get function details to find storageId
|
// 3. Overwrite/Create requirements.txt using function-based API
|
||||||
const funcResponse = await client.get(`/api/function/${functionId}`);
|
await client.put(`/api/function/${functionId}/file`, {
|
||||||
const func = funcResponse.data.data;
|
filename: "requirements.txt",
|
||||||
if (!func || !func.namespace || !func.namespace.storageId) {
|
code: content,
|
||||||
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
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`${chalk.green("✓")} Added ${chalk.cyan(pkg)} to requirements.txt for function ${chalk.yellow(functionId)}.`);
|
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) {
|
function handleError(error: any, task: string) {
|
||||||
if (error.response) {
|
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) {
|
} else if (error.request) {
|
||||||
console.error(
|
console.error(
|
||||||
`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(
|
`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(
|
||||||
|
|||||||
@@ -69,18 +69,10 @@ export const reqRemoveDefinition = {
|
|||||||
|
|
||||||
const newContent = newLines.join("\n");
|
const newContent = newLines.join("\n");
|
||||||
|
|
||||||
// 2. Get function details to find storageId
|
// 2. Overwrite requirements.txt using function-based API
|
||||||
const funcResponse = await client.get(`/api/function/${functionId}`);
|
await client.put(`/api/function/${functionId}/file`, {
|
||||||
const func = funcResponse.data.data;
|
filename: "requirements.txt",
|
||||||
if (!func || !func.namespace || !func.namespace.storageId) {
|
code: newContent,
|
||||||
throw new Error("Could not determine storage ID for function.");
|
|
||||||
}
|
|
||||||
const storageId = func.namespace.storageId;
|
|
||||||
|
|
||||||
// 3. Overwrite requirements.txt
|
|
||||||
await client.put(`/api/storage/${storageId}/files`, {
|
|
||||||
path: "requirements.txt",
|
|
||||||
content: newContent
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`${chalk.green("✓")} Removed ${chalk.cyan(pkgToRemove)} from requirements.txt for function ${chalk.yellow(functionId)}.`);
|
console.log(`${chalk.green("✓")} Removed ${chalk.cyan(pkgToRemove)} from requirements.txt for function ${chalk.yellow(functionId)}.`);
|
||||||
@@ -92,7 +84,7 @@ export const reqRemoveDefinition = {
|
|||||||
|
|
||||||
function handleError(error: any, task: string) {
|
function handleError(error: any, task: string) {
|
||||||
if (error.response) {
|
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) {
|
} else if (error.request) {
|
||||||
console.error(
|
console.error(
|
||||||
`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(
|
`${chalk.red("✗")} Failed to ${task}: ${chalk.yellow(
|
||||||
|
|||||||
Reference in New Issue
Block a user