3 Commits

Author SHA1 Message Date
luna 9887ca3dcc chore: bump version to 2.1.5 and add versioning policy 2026-03-20 08:58:03 +01:00
luna ae82ba221b fix: improve error handling for pipinstall 2026-03-20 08:55:10 +01:00
luna 8428ed56b5 feat: add pipinstall command 2026-03-20 08:51:29 +01:00
3 changed files with 60 additions and 1 deletions
+3
View File
@@ -24,3 +24,6 @@
- **New Commands**: To add a command, create a new file in `src/commands/` (or a subfolder). It must export a definition object (default or named) with `name`, `description`, and `action`.
- **Error Handling**: Follow the pattern in [src/commands/health.ts](src/commands/health.ts) for handling Axios errors (check for `error.response`, `error.request`, etc.).
- **No Global Scope**: Keep command logic within the `action` function or extracted to utility modules to maintain testability.
## Versioning
- **Versioning**: Always increment the version number in package.json whenever a change is merged into main. The version format is major.minor.patch.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "shsf-cli",
"version": "2.1.0",
"version": "2.1.5",
"description": "",
"type": "module",
"files": [
+56
View File
@@ -0,0 +1,56 @@
import chalk from "chalk";
import { getApiClient } from "../../api.js";
export const pipInstallDefinition = {
name: "pipinstall",
description: "Install Python dependencies for a function using requirements.txt",
options: [
{
name: "--id <id>",
description: "The ID of the function.",
required: true,
},
],
action: async (options: { id: string }) => {
await pipInstallFunction(options.id);
},
};
async function pipInstallFunction(id: string) {
const client = await getApiClient();
try {
const response = await client.post(`/api/function/${id}/pip-install`);
if (response.status === 200) {
console.log(`${chalk.green("✓")} Dependencies installed successfully for function ${chalk.yellow(id)}.`);
if (response.data && response.data.status) {
console.log(`${chalk.gray("Status:")} ${response.data.status}`);
}
} else {
console.log(
`${chalk.yellow("!")} Unexpected response from server.`,
);
console.log(`Status Code: ${chalk.blue(response.status)}`);
}
} catch (error: any) {
if (error.response) {
console.error(
`${chalk.red("✗")} Failed to install dependencies.`,
);
console.error(`Status Code: ${chalk.red(error.response.status)}`);
console.error(
`Message: ${chalk.yellow(error.response.data?.message || "Unknown error from server")}`,
);
} else if (error.request) {
console.error(
`${chalk.red("✗")} Failed to install dependencies.`,
);
console.error(
`${chalk.yellow("Could not connect to the SHSF instance. Check your connection.")}`,
);
} else {
console.error(`${chalk.red("✗")} Error:`, error.message);
}
}
}