@recur-tw/cli 0.1.2 → 0.1.4
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/cli.mjs +23 -15
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -920,7 +920,7 @@ var RecurClient = class {
|
|
|
920
920
|
}
|
|
921
921
|
const headers = {
|
|
922
922
|
Authorization: `Bearer ${this.secretKey}`,
|
|
923
|
-
"User-Agent": `@recur-tw/cli/0.1.
|
|
923
|
+
"User-Agent": `@recur-tw/cli/0.1.4`
|
|
924
924
|
};
|
|
925
925
|
const hasBody = opts?.body !== void 0;
|
|
926
926
|
if (hasBody) headers["Content-Type"] = "application/json";
|
|
@@ -1226,8 +1226,8 @@ function registerLoginCommand(program) {
|
|
|
1226
1226
|
secretKey: key
|
|
1227
1227
|
});
|
|
1228
1228
|
try {
|
|
1229
|
-
await client.get("/v1/
|
|
1230
|
-
console.error(pc.green(
|
|
1229
|
+
const me = await client.get("/v1/me");
|
|
1230
|
+
console.error(pc.green(`✓ API key verified (${me.organization.name})`));
|
|
1231
1231
|
} catch {
|
|
1232
1232
|
console.error(pc.yellow("⚠ Could not verify API key (saved anyway)"));
|
|
1233
1233
|
}
|
|
@@ -1253,25 +1253,33 @@ function registerLoginCommand(program) {
|
|
|
1253
1253
|
handleError(err);
|
|
1254
1254
|
}
|
|
1255
1255
|
});
|
|
1256
|
-
program.command("whoami").description("Show current profile and
|
|
1256
|
+
program.command("whoami").description("Show current profile, API key, and organization info").action(async () => {
|
|
1257
1257
|
try {
|
|
1258
|
-
const
|
|
1258
|
+
const globalOpts = program.opts();
|
|
1259
1259
|
const active = listProfiles().find((p) => p.active);
|
|
1260
1260
|
if (!active) {
|
|
1261
1261
|
console.error(pc.yellow("No profiles configured. Run: recur login"));
|
|
1262
1262
|
process.exit(1);
|
|
1263
1263
|
}
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1264
|
+
const info = {
|
|
1265
|
+
profile: active.name,
|
|
1266
|
+
environment: active.environment
|
|
1267
|
+
};
|
|
1266
1268
|
try {
|
|
1267
1269
|
const key = resolveSecretKey(globalOpts);
|
|
1268
|
-
|
|
1270
|
+
const prefixEnd = key.lastIndexOf("_") + 1;
|
|
1271
|
+
info["key"] = key.slice(0, prefixEnd) + key.slice(prefixEnd, prefixEnd + 4) + "...";
|
|
1272
|
+
try {
|
|
1273
|
+
const data = await new RecurClient({
|
|
1274
|
+
baseUrl: resolveBaseUrl(globalOpts),
|
|
1275
|
+
secretKey: key
|
|
1276
|
+
}).get("/v1/me");
|
|
1277
|
+
info["org"] = data.organization.name;
|
|
1278
|
+
info["org_id"] = data.organization.id;
|
|
1279
|
+
info["org_slug"] = data.organization.slug;
|
|
1280
|
+
} catch {}
|
|
1269
1281
|
} catch {}
|
|
1270
|
-
render({
|
|
1271
|
-
profile: active.name,
|
|
1272
|
-
environment: active.environment,
|
|
1273
|
-
...maskedKey && { key: maskedKey }
|
|
1274
|
-
}, { format: opts.output });
|
|
1282
|
+
render(info, { format: globalOpts.output });
|
|
1275
1283
|
} catch (err) {
|
|
1276
1284
|
handleError(err);
|
|
1277
1285
|
}
|
|
@@ -2556,7 +2564,7 @@ Requires a Secret Key (sk_test_* or sk_live_*) via --key, RECUR_SECRET_KEY, or r
|
|
|
2556
2564
|
});
|
|
2557
2565
|
const server = new McpServer({
|
|
2558
2566
|
name: "recur",
|
|
2559
|
-
version: "0.1.
|
|
2567
|
+
version: "0.1.4"
|
|
2560
2568
|
}, { capabilities: { tools: {} } });
|
|
2561
2569
|
registerTools(server, client);
|
|
2562
2570
|
const transport = new StdioServerTransport();
|
|
@@ -2572,7 +2580,7 @@ Requires a Secret Key (sk_test_* or sk_live_*) via --key, RECUR_SECRET_KEY, or r
|
|
|
2572
2580
|
//#endregion
|
|
2573
2581
|
//#region src/cli.ts
|
|
2574
2582
|
const program = new Command();
|
|
2575
|
-
program.name("recur").description("Recur CLI — Taiwan subscription payment platform.\nManage products, customers, subscriptions, webhooks, and more.\nAll commands require a Secret Key (sk_test_* or sk_live_*).").version("0.1.
|
|
2583
|
+
program.name("recur").description("Recur CLI — Taiwan subscription payment platform.\nManage products, customers, subscriptions, webhooks, and more.\nAll commands require a Secret Key (sk_test_* or sk_live_*).").version("0.1.4").option("--key <secret-key>", "API secret key (sk_test_* or sk_live_*)").option("--profile <name>", "Use a named profile from ~/.recur/credentials.json").option("--base-url <url>", "API base URL (default: https://api.recur.tw)").option("--output <format>", "Output format: json, table, csv, ndjson (default: json when piped, table otherwise)").hook("preAction", (thisCommand) => {
|
|
2576
2584
|
const opts = thisCommand.opts();
|
|
2577
2585
|
if (!opts.output) opts.output = process.stdout.isTTY ? "table" : "json";
|
|
2578
2586
|
if (![
|