@localskills/cli 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1199,11 +1199,20 @@ var ApiClient = class {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
return h;
|
|
1201
1201
|
}
|
|
1202
|
+
async handleResponse(res) {
|
|
1203
|
+
if (res.status === 401) {
|
|
1204
|
+
return {
|
|
1205
|
+
success: false,
|
|
1206
|
+
error: "Unauthorized. Run `localskills login` to authenticate."
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
return res.json();
|
|
1210
|
+
}
|
|
1202
1211
|
async get(path) {
|
|
1203
1212
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
1204
1213
|
headers: this.headers()
|
|
1205
1214
|
});
|
|
1206
|
-
return
|
|
1215
|
+
return this.handleResponse(res);
|
|
1207
1216
|
}
|
|
1208
1217
|
async post(path, body) {
|
|
1209
1218
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
@@ -1211,7 +1220,7 @@ var ApiClient = class {
|
|
|
1211
1220
|
headers: this.headers(),
|
|
1212
1221
|
body: body ? JSON.stringify(body) : void 0
|
|
1213
1222
|
});
|
|
1214
|
-
return
|
|
1223
|
+
return this.handleResponse(res);
|
|
1215
1224
|
}
|
|
1216
1225
|
async put(path, body) {
|
|
1217
1226
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
@@ -1219,14 +1228,14 @@ var ApiClient = class {
|
|
|
1219
1228
|
headers: this.headers(),
|
|
1220
1229
|
body: JSON.stringify(body)
|
|
1221
1230
|
});
|
|
1222
|
-
return
|
|
1231
|
+
return this.handleResponse(res);
|
|
1223
1232
|
}
|
|
1224
1233
|
async delete(path) {
|
|
1225
1234
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
1226
1235
|
method: "DELETE",
|
|
1227
1236
|
headers: this.headers()
|
|
1228
1237
|
});
|
|
1229
|
-
return
|
|
1238
|
+
return this.handleResponse(res);
|
|
1230
1239
|
}
|
|
1231
1240
|
async getRaw(path) {
|
|
1232
1241
|
return fetch(`${this.baseUrl}${path}`, {
|
|
@@ -2288,6 +2297,13 @@ var installCommand = new Command2("install").description("Install a skill locall
|
|
|
2288
2297
|
const explicitScope = opts.global ? "global" : opts.project !== void 0 ? "project" : null;
|
|
2289
2298
|
const explicitMethod = opts.copy ? "copy" : opts.symlink ? "symlink" : null;
|
|
2290
2299
|
if (!slugArg) {
|
|
2300
|
+
if (!client.isAuthenticated()) {
|
|
2301
|
+
console.error(
|
|
2302
|
+
"Authentication required to browse skills. Run `localskills login` first.\nTo install a public skill directly, use: localskills install <slug>"
|
|
2303
|
+
);
|
|
2304
|
+
process.exit(1);
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2291
2307
|
const spinner2 = bt2();
|
|
2292
2308
|
spinner2.start("Fetching available skills...");
|
|
2293
2309
|
const res2 = await client.get("/api/skills");
|
|
@@ -2322,7 +2338,12 @@ var installCommand = new Command2("install").description("Install a skill locall
|
|
|
2322
2338
|
`/api/skills/${encodeURIComponent(slug)}/content`
|
|
2323
2339
|
);
|
|
2324
2340
|
if (!res.success || !res.data) {
|
|
2325
|
-
spinner.stop(
|
|
2341
|
+
spinner.stop("Failed.");
|
|
2342
|
+
if (res.error?.includes("Unauthorized")) {
|
|
2343
|
+
console.error("This skill is private. Run `localskills login` to access it.");
|
|
2344
|
+
} else {
|
|
2345
|
+
console.error(res.error || "Skill not found.");
|
|
2346
|
+
}
|
|
2326
2347
|
process.exit(1);
|
|
2327
2348
|
return;
|
|
2328
2349
|
}
|
|
@@ -2435,6 +2456,10 @@ var uninstallCommand = new Command3("uninstall").description("Uninstall a skill"
|
|
|
2435
2456
|
import { Command as Command4 } from "commander";
|
|
2436
2457
|
var listCommand = new Command4("list").description("List available skills").option("--public", "Show public skills only").action(async (opts) => {
|
|
2437
2458
|
const client = new ApiClient();
|
|
2459
|
+
if (!client.isAuthenticated()) {
|
|
2460
|
+
console.error("Not authenticated. Run `localskills login` first.");
|
|
2461
|
+
process.exit(1);
|
|
2462
|
+
}
|
|
2438
2463
|
const path = opts.public ? "/api/skills?visibility=public" : "/api/skills";
|
|
2439
2464
|
const res = await client.get(path);
|
|
2440
2465
|
if (!res.success || !res.data) {
|