mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-16 23:41:19 +00:00
Fixed the issue where the --registry command-line parameter was defined but not actually used by any commands. Changes: - Added loadConfigFromProgram() helper in config.ts to read registry from program.opts() - Updated all 21 command files to use loadConfigFromProgram() instead of loadConfig() - Ensured correct priority: CLI args > env vars > config file > defaults Priority order: 1. --registry <url> (command-line flag) - highest priority 2. SKILLHUB_REGISTRY (environment variable) 3. ~/.skillhub/config.json (config file) 4. http://localhost:8080 (default value) This allows users to temporarily override the registry without modifying environment variables or config files, providing better flexibility for: - Testing against different registries - Multi-project/multi-environment setups - CI/CD automation scripts Updated commands: - install, download, update, check, sync, uninstall - explore, search - publish, delete, archive, versions - inspect, resolve, rating, rate, star, report, reviews - whoami, me, namespaces, notifications - transfer, hide, unhide Fixes issue where `npx motovis-skillhub install <skill> --registry <url>` would ignore the --registry parameter and use env vars or defaults instead.
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { Command } from "commander";
|
|
import { ApiClient } from "../core/api-client.js";
|
|
import { requireToken } from "../core/auth-token.js";
|
|
import { loadConfig, loadConfigFromProgram } from "../core/config.js";
|
|
import { success, error, info, dim } from "../utils/logger.js";
|
|
|
|
export interface ReviewSubmission {
|
|
id: number;
|
|
skillSlug: string;
|
|
skillDisplayName: string;
|
|
namespace: string;
|
|
version: string;
|
|
status: string;
|
|
createdAt: string;
|
|
}
|
|
|
|
export function registerReviews(program: Command) {
|
|
const reviews = program.command("reviews").description("Manage skill reviews");
|
|
|
|
reviews
|
|
.command("my")
|
|
.alias("submissions")
|
|
.description("List your review submissions")
|
|
.action(async () => {
|
|
try {
|
|
const token = await requireToken();
|
|
const config = loadConfigFromProgram(program);
|
|
const client = new ApiClient({ baseUrl: config.registry, token });
|
|
const submissions = await client.get<ReviewSubmission[]>("/api/v1/reviews/my-submissions");
|
|
if (!submissions || submissions.length === 0) {
|
|
console.log("No review submissions.");
|
|
return;
|
|
}
|
|
for (const r of submissions) {
|
|
info(`${r.skillDisplayName} (${r.skillSlug})`);
|
|
dim(` ${r.namespace} · v${r.version} · ${r.status} · ${r.createdAt}`);
|
|
}
|
|
} catch (e: any) {
|
|
error(`Failed: ${e.message}`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
}
|