freerouting
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -9,12 +9,11 @@ #!/usr/bin/env node | ||
import Conf from "conf"; | ||
import { randomUUID } from "crypto"; | ||
import { exec } from "child_process"; | ||
import { promisify } from "util"; | ||
import { randomUUID } from "node:crypto"; | ||
import { exec } from "node:child_process"; | ||
import { promisify } from "node:util"; | ||
var execAsync = promisify(exec); | ||
var handleApiError = (error) => { | ||
console.error("API Error:"); | ||
console.log(error); | ||
if (error.data) { | ||
console.error(`Status: ${error.status}`); | ||
console.error("Response data:", error.data); | ||
console.log("Response data:", error.data); | ||
} else if (error.request) { | ||
@@ -71,3 +70,3 @@ console.error("No response received from server"); | ||
headers: getHeaders() | ||
}); | ||
}).catch((error) => handleApiError(error)); | ||
config.set("lastSessionId", response.data.id); | ||
@@ -79,3 +78,3 @@ console.log(response.data); | ||
headers: getHeaders() | ||
}); | ||
}).catch((error) => handleApiError(error)); | ||
console.log(response.data); | ||
@@ -93,3 +92,3 @@ }); | ||
headers: getHeaders() | ||
}); | ||
}).catch((error) => handleApiError(error)); | ||
console.log(response.data); | ||
@@ -126,2 +125,7 @@ }); | ||
).option("-n, --name <name>", "Job name", "untitled").option("-p, --priority <priority>", "Job priority", "NORMAL").action(async (opts) => { | ||
console.log({ | ||
session_id: opts.sessionId ?? config.get("lastSessionId"), | ||
name: opts.name, | ||
priority: opts.priority | ||
}); | ||
const response = await axios.post( | ||
@@ -135,3 +139,3 @@ `${API_BASE}/v1/jobs/enqueue`, | ||
{ headers: getHeaders() } | ||
); | ||
).catch((error) => handleApiError(error)); | ||
config.set("lastJobId", response.data.id); | ||
@@ -144,3 +148,3 @@ console.log(response.data); | ||
headers: getHeaders() | ||
}); | ||
}).catch((error) => handleApiError(error)); | ||
console.log(response.data); | ||
@@ -152,3 +156,3 @@ }); | ||
headers: getHeaders() | ||
}); | ||
}).catch((error) => handleApiError(error)); | ||
console.log(response.data); | ||
@@ -181,3 +185,3 @@ }); | ||
headers: getHeaders() | ||
}); | ||
}).catch((error) => handleApiError(error)); | ||
console.log(response.data); | ||
@@ -211,3 +215,3 @@ }); | ||
systemCommand.command("status").description("Get system status").action(async () => { | ||
const response = await axios.get(`${API_BASE}/v1/system/status`); | ||
const response = await axios.get(`${API_BASE}/v1/system/status`).catch((error) => handleApiError(error)); | ||
console.log(response.data); | ||
@@ -214,0 +218,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"main": "./dist/cli.js", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"files": [ | ||
@@ -8,0 +8,0 @@ "dist" |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
32003
234
0