@braid-cloud/cli 0.1.17 → 0.1.18

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 CHANGED
@@ -478,8 +478,13 @@ var init_config = __esm({
478
478
  saveProjectConfigAsync = (config, startDir) => Effect3.runPromise(saveProjectConfig(config, startDir));
479
479
  getApiKeyAsync = () => Effect3.runPromise(getApiKey());
480
480
  setApiKeyAsync = (apiKey) => Effect3.runPromise(setApiKey(apiKey));
481
- persistApiKeyAsync = async (apiKey) => {
482
- await setApiKeyAsync(apiKey);
481
+ persistApiKeyAsync = async (apiKey, serverUrl) => {
482
+ const config = await loadConfigAsync();
483
+ await saveConfigAsync({
484
+ ...config,
485
+ apiKey,
486
+ ...serverUrl ? { serverUrl } : {}
487
+ });
483
488
  const existingUserConfig = await loadUserConfigAsync();
484
489
  if (existingUserConfig?.token) {
485
490
  await saveUserConfigAsync({ ...existingUserConfig, token: apiKey });
@@ -510,7 +515,8 @@ var init_api = __esm({
510
515
  const parsed = new URL(serverUrl);
511
516
  const hostname2 = parsed.hostname;
512
517
  const isBraidHost = hostname2 === "braid.cloud" || hostname2.endsWith(".braid.cloud");
513
- if (parsed.protocol === "https:" && isBraidHost) {
518
+ const isConvexSite = hostname2.endsWith(".convex.site");
519
+ if (parsed.protocol === "https:" && (isBraidHost || isConvexSite)) {
514
520
  return true;
515
521
  }
516
522
  if (parsed.protocol === "http:" && isLocalHost(hostname2)) {
@@ -2989,7 +2995,7 @@ async function deviceFlow(serverUrl, timeoutSeconds, options) {
2989
2995
  pollSpinner.stop("Authentication failed");
2990
2996
  handlePollingError(error);
2991
2997
  }
2992
- await persistApiKeyAsync(session.sessionToken);
2998
+ await persistApiKeyAsync(session.sessionToken, authConfig.convexSiteUrl);
2993
2999
  if (options.scope !== false) {
2994
3000
  await configureDefaultScopeAsync(authConfig.convexSiteUrl);
2995
3001
  }
@@ -5003,7 +5009,7 @@ var requestJson = (url, options) => pipe9(
5003
5009
  const payload = await response.json().catch(() => null);
5004
5010
  if (!response.ok) {
5005
5011
  throw new MarketplaceApiError({
5006
- message: payload?.error ?? payload?.message ?? "Request failed",
5012
+ message: payload?.error ?? payload?.message ?? `Request failed (HTTP ${response.status} from ${new URL(url).origin})`,
5007
5013
  status: response.status,
5008
5014
  code: payload?.code ?? "REQUEST_ERROR"
5009
5015
  });
@@ -6296,7 +6302,10 @@ async function startManageServer(options = {}) {
6296
6302
  pendingRequest.expiresIn,
6297
6303
  MANAGE_AUTH_TIMEOUT_SECONDS
6298
6304
  );
6299
- await persistApiKeyAsync(session.sessionToken);
6305
+ await persistApiKeyAsync(
6306
+ session.sessionToken,
6307
+ pendingRequest.convexSiteUrl
6308
+ );
6300
6309
  return {
6301
6310
  authenticated: true,
6302
6311
  expiresAt: session.expiresAt,
@@ -9174,10 +9183,16 @@ async function updateCommand(options) {
9174
9183
  }
9175
9184
 
9176
9185
  // src/index.ts
9186
+ init_tui();
9177
9187
  var require2 = createRequire(import.meta.url);
9178
9188
  var { version: PACKAGE_VERSION } = require2("../package.json");
9189
+ var COMMANDER_ERROR_PREFIX = /^error:\s*/i;
9179
9190
  var program = new Command();
9180
- program.name("braid").description("Install and manage braid prompt artifacts locally").version(PACKAGE_VERSION);
9191
+ program.name("braid").description("Install and manage braid prompt artifacts locally").version(PACKAGE_VERSION).configureOutput({
9192
+ outputError: (str) => {
9193
+ log.error(str.replace(COMMANDER_ERROR_PREFIX, "").trim());
9194
+ }
9195
+ });
9181
9196
  var auth = program.command("auth").description("Configure API key for braid authentication");
9182
9197
  auth.command("login", { isDefault: true }).description("Authenticate with braid via browser login or API key").option("-s, --server <url>", "braid server URL (for review apps, local dev)").option(
9183
9198
  "--token <token>",