@workbuddy/cli-edge 1.0.3 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +42 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2141,6 +2141,9 @@ var {
2141
2141
  Help
2142
2142
  } = import__.default;
2143
2143
 
2144
+ // src/index.ts
2145
+ import * as readline from "readline";
2146
+
2144
2147
  // src/secure-store.ts
2145
2148
  import { execFileSync, spawnSync } from "node:child_process";
2146
2149
  import * as fs from "fs";
@@ -7967,6 +7970,34 @@ function isPlainObject2(value) {
7967
7970
 
7968
7971
  // src/index.ts
7969
7972
  var OUTPUT_FORMATS = new Set(["json", "table", "raw"]);
7973
+ function prompt(question, mask = false) {
7974
+ return new Promise((resolve) => {
7975
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
7976
+ if (mask) {
7977
+ const stdout = process.stdout;
7978
+ const onData = (char) => {
7979
+ const c = char.toString();
7980
+ if (c === `
7981
+ ` || c === "\r" || c === "\x04")
7982
+ return;
7983
+ stdout.clearLine(0);
7984
+ stdout.cursorTo(0);
7985
+ stdout.write(question + "*".repeat(rl.line.length));
7986
+ };
7987
+ process.stdin.on("data", onData);
7988
+ rl.question(question, (answer) => {
7989
+ process.stdin.removeListener("data", onData);
7990
+ rl.close();
7991
+ resolve(answer.trim());
7992
+ });
7993
+ } else {
7994
+ rl.question(question, (answer) => {
7995
+ rl.close();
7996
+ resolve(answer.trim());
7997
+ });
7998
+ }
7999
+ });
8000
+ }
7970
8001
  async function main() {
7971
8002
  const program2 = new Command;
7972
8003
  program2.name("workbuddy").description("WorkBuddy CLI").version(packageVersion);
@@ -7976,12 +8007,19 @@ async function main() {
7976
8007
  }
7977
8008
  function registerAuthCommands(program2) {
7978
8009
  const auth = program2.command("auth").description("Manage WorkBuddy CLI credentials");
7979
- auth.command("login").description("Store WorkBuddy API credentials locally").requiredOption("--base-url <url>", "Tenant base URL").requiredOption("--client-id <id>", "OAuth2 client ID").requiredOption("--client-secret <secret>", "OAuth2 client secret").option("--api-version <version>", "WorkBuddy API version header", "2026-01").option("--profile <name>", "Profile name", getActiveProfileName()).action(async (options) => {
8010
+ auth.command("login").description("Store WorkBuddy API credentials locally").option("--base-url <url>", "Tenant base URL (required)").option("--client-id <id>", "OAuth2 client ID (required)").option("--client-secret <secret>", "OAuth2 client secret (required, prompted if omitted)").option("--api-version <version>", "WorkBuddy API version header", "2026-01").option("--profile <name>", "Profile name", getActiveProfileName()).action(async (options) => {
8011
+ const baseUrl = options.baseUrl || await prompt("Tenant URL (e.g. https://yourcompany.workbuddy.com): ");
8012
+ const clientId = options.clientId || await prompt("Client ID: ");
8013
+ const clientSecret = options.clientSecret || await prompt("Client Secret: ", true);
8014
+ if (!baseUrl || !clientId || !clientSecret) {
8015
+ throw new Error("base-url, client-id, and client-secret are required");
8016
+ }
8017
+ console.log("");
7980
8018
  const config = resolveConfig({
7981
8019
  profile: options.profile,
7982
- baseUrl: options.baseUrl,
7983
- clientId: options.clientId,
7984
- clientSecret: options.clientSecret,
8020
+ baseUrl,
8021
+ clientId,
8022
+ clientSecret,
7985
8023
  apiVersion: options.apiVersion,
7986
8024
  accessToken: undefined
7987
8025
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workbuddy/cli-edge",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "WorkBuddy command line interface",
5
5
  "license": "MIT",
6
6
  "type": "module",