@bugbug-io/cli 13.39.3 → 14.0.0

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
@@ -1,10 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- render
4
- } from "./chunk-UZVYEMEZ.js";
5
- import {
6
- BaseSuiteRunDetails,
7
- BaseTestRunDetails,
8
3
  EXIT_GENERAL_ERROR,
9
4
  EXIT_USAGE_ERROR,
10
5
  PLUGIN_PACKAGE_NAME,
@@ -23,6 +18,7 @@ import {
23
18
  formatErrorMessage,
24
19
  formatInlineRunReport,
25
20
  getCliConfig,
21
+ getIdentity,
26
22
  getSuite,
27
23
  getSuiteRun,
28
24
  getSuiteRunJunitReport,
@@ -36,6 +32,7 @@ import {
36
32
  importTest,
37
33
  initProject,
38
34
  initSentry,
35
+ isCompletedStatus,
39
36
  listProfiles,
40
37
  listSuites,
41
38
  listTests,
@@ -54,7 +51,7 @@ import {
54
51
  waitForSuiteRun,
55
52
  waitForTestRun,
56
53
  writeReportXml
57
- } from "./chunk-GNCJ7Y4W.js";
54
+ } from "./chunk-4IJVD32G.js";
58
55
  import "./chunk-BSHFIPEX.js";
59
56
  import "./chunk-PR4QN5HX.js";
60
57
 
@@ -78,7 +75,8 @@ var registerLoginCommand = (program2, commandName = "login") => program2.command
78
75
  if (mode === "json") {
79
76
  printJson(result);
80
77
  } else {
81
- process.stdout.write(`Logged in. Token saved to "${result.credentialsFile}"
78
+ process.stdout.write(`
79
+ Logged in. Token saved to "${result.credentialsFile}"
82
80
  `);
83
81
  }
84
82
  const shouldBackfillSessionStart = !analytics.get().isEnabled;
@@ -593,7 +591,6 @@ var registerSuiteRunsCommand = (program2) => {
593
591
  };
594
592
 
595
593
  // src/utils/runAction.ts
596
- import { createElement } from "react";
597
594
  var collectRunVariableOption = (val, prev = []) => prev.concat(val);
598
595
  var parseTimeoutMinutes = (value) => {
599
596
  const minutes = Number(value);
@@ -603,14 +600,11 @@ var parseTimeoutMinutes = (value) => {
603
600
  return minutes * 6e4;
604
601
  };
605
602
  var runResourceAction = async (resourceId, opts, adapter) => {
606
- const mode = resolveOutputMode();
603
+ const configuredMode = resolveOutputMode();
604
+ const mode = configuredMode === "interactive" ? "plain" : configuredMode;
607
605
  try {
608
606
  const reporter = validateReporterOptions(opts);
609
607
  const variables = getVariablesMap(opts.variables ?? []);
610
- const runResult = await adapter.runResource(resourceId, {
611
- profile: opts.profile,
612
- variables: Object.keys(variables).length ? variables : void 0
613
- });
614
608
  if (mode === "plain") {
615
609
  process.stdout.write(
616
610
  `Starting ${adapter.runLabel} for ${adapter.entityLabel} id: ${resourceId}
@@ -622,6 +616,12 @@ var runResourceAction = async (resourceId, opts, adapter) => {
622
616
  process.stdout.write(`Variables: ${JSON.stringify(variables)}
623
617
  `);
624
618
  }
619
+ }
620
+ const runResult = await adapter.runResource(resourceId, {
621
+ profile: opts.profile,
622
+ variables: Object.keys(variables).length ? variables : void 0
623
+ });
624
+ if (mode === "plain") {
625
625
  process.stdout.write(`${capitalize(adapter.runLabel)} id: ${runResult.id}
626
626
  `);
627
627
  }
@@ -631,52 +631,21 @@ var runResourceAction = async (resourceId, opts, adapter) => {
631
631
  }
632
632
  return;
633
633
  }
634
- let finalState;
635
- if (mode === "interactive") {
636
- let interactiveState;
637
- let interactiveError;
638
- const RunDetailsComponent = adapter.kind === "suite" ? BaseSuiteRunDetails : BaseTestRunDetails;
639
- const { waitUntilExit } = await render(
640
- createElement(RunDetailsComponent, {
641
- runId: runResult.id,
642
- headless: true,
643
- timeoutMs: opts.timeout,
644
- onComplete: (status) => {
645
- interactiveState = status;
646
- },
647
- onError: (err) => {
648
- interactiveError = err;
649
- }
650
- })
651
- );
652
- await waitUntilExit();
653
- if (interactiveError) {
654
- const error = interactiveError;
655
- throw error;
656
- }
657
- if (!interactiveState) {
658
- throw new Error(
659
- `${capitalize(adapter.runLabel)} ${runResult.id} finished without a final status.`
660
- );
661
- }
662
- finalState = interactiveState;
663
- } else {
664
- let lastStatus = "";
665
- finalState = await adapter.waitForRun(
666
- runResult.id,
667
- 4e3,
668
- (status) => {
669
- if (status.status !== lastStatus) {
670
- lastStatus = status.status;
671
- if (mode === "plain") {
672
- process.stdout.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] status: ${status.status}
634
+ let lastStatus = "";
635
+ const finalState = await adapter.waitForRun(
636
+ runResult.id,
637
+ 4e3,
638
+ (status) => {
639
+ if (status.status !== lastStatus) {
640
+ lastStatus = status.status;
641
+ if (mode === "plain" && !isCompletedStatus(status.status)) {
642
+ process.stdout.write(`Status changed to: ${status.status}
673
643
  `);
674
- }
675
644
  }
676
- },
677
- opts.timeout
678
- );
679
- }
645
+ }
646
+ },
647
+ opts.timeout
648
+ );
680
649
  let reportResult;
681
650
  if (reporter === "junit") {
682
651
  const xml = await adapter.getJunitReport(runResult.id);
@@ -689,20 +658,18 @@ var runResourceAction = async (resourceId, opts, adapter) => {
689
658
  if (mode === "json") {
690
659
  const payload = reportResult ? { ...finalState, report: { kind: "junit", ...reportResult } } : finalState;
691
660
  printJson(payload);
692
- } else if (mode === "plain" || mode === "interactive") {
661
+ } else if (mode === "plain") {
662
+ process.stdout.write(`Final status: ${finalState.status}
663
+ ----
664
+ `);
693
665
  if (reportResult?.outPath) {
694
666
  process.stdout.write(
695
667
  `Saved JUnit report for ${adapter.runLabel} ${runResult.id} to ${reportResult.outPath} (${reportResult.size} chars)
696
668
  `
697
669
  );
698
670
  }
699
- if (mode === "plain") {
700
- if (reporter === "inline") {
701
- process.stdout.write(formatInlineRunReport(adapter.kind, finalState));
702
- } else {
703
- process.stdout.write(`Final status: ${finalState.status}
704
- `);
705
- }
671
+ if (mode === "plain" && reporter === "inline") {
672
+ process.stdout.write(formatInlineRunReport(adapter.kind, finalState));
706
673
  }
707
674
  }
708
675
  const code = exitCodeForStatus(finalState.status);
@@ -1024,6 +991,25 @@ var getFullCommandPath = (command) => {
1024
991
  return names.join(" ");
1025
992
  };
1026
993
 
994
+ // src/utils/prompt.ts
995
+ import { createInterface } from "readline";
996
+
997
+ // src/utils/sessionAuth.ts
998
+ var resolveTokenProjectId = async () => {
999
+ try {
1000
+ const identity = await getIdentity();
1001
+ return identity.tokenType === "project" ? identity.projectId ?? void 0 : void 0;
1002
+ } catch {
1003
+ return void 0;
1004
+ }
1005
+ };
1006
+ var hasUsableSession = async () => {
1007
+ const config = getCliConfig();
1008
+ if (!config.token?.trim()) return false;
1009
+ if (config.projectId?.trim()) return true;
1010
+ return await resolveTokenProjectId() !== void 0;
1011
+ };
1012
+
1027
1013
  // src/utils/startup.ts
1028
1014
  var GLOBAL_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["-t", "--token", "-p", "--project-id"]);
1029
1015
  var GLOBAL_FLAGS = /* @__PURE__ */ new Set(["-v", "--verbose", "--disable-telemetry", "--ci", "--json"]);
@@ -1144,13 +1130,12 @@ var isAuthRedirectExemptCommand = (positionals) => {
1144
1130
  if (AUTH_REDIRECT_EXEMPT_TOP_LEVEL_COMMANDS.has(command)) return true;
1145
1131
  return command === "project" && subcommand === "init";
1146
1132
  };
1147
- var shouldRedirectUnauthenticatedCommandToInit = (argv, authenticated) => {
1148
- if (authenticated) return false;
1133
+ var shouldRedirectUnauthenticatedCommandToInit = async (argv, hasSession) => {
1149
1134
  const args = parseStartupArgs(argv);
1150
1135
  if (args.hasExplicitHelpOrVersion || !isInteractiveStartup(args)) return false;
1151
1136
  if (args.positionals.length === 0) return false;
1152
1137
  if (isAuthRedirectExemptCommand(args.positionals)) return false;
1153
- return true;
1138
+ return !await hasSession();
1154
1139
  };
1155
1140
  var getStartupMode = (argv) => {
1156
1141
  const args = parseStartupArgs(argv);
@@ -1222,11 +1207,8 @@ program.exitOverride();
1222
1207
  startupMode: startupMode.type
1223
1208
  });
1224
1209
  analytics.trackEvent("cli_session_started");
1225
- if (startupMode.type === "commandline" && shouldRedirectUnauthenticatedCommandToInit(
1226
- process.argv,
1227
- Boolean(config.token && config.projectId)
1228
- )) {
1229
- const { startNavigator } = await import("./app-L5OYLEKP.js");
1210
+ if (startupMode.type === "commandline" && await shouldRedirectUnauthenticatedCommandToInit(process.argv, hasUsableSession)) {
1211
+ const { startNavigator } = await import("./app-UMUDDKR3.js");
1230
1212
  await startNavigator({
1231
1213
  initialRoute: "/init",
1232
1214
  initialRouteState: {
@@ -1238,7 +1220,7 @@ program.exitOverride();
1238
1220
  return;
1239
1221
  }
1240
1222
  if (startupMode.type === "navigator") {
1241
- const { startNavigator } = await import("./app-L5OYLEKP.js");
1223
+ const { startNavigator } = await import("./app-UMUDDKR3.js");
1242
1224
  await startNavigator({
1243
1225
  initialRoute: startupMode.route,
1244
1226
  token: config.token,
@@ -1,3 +1,5 @@
1
+ import "./chunk-PR4QN5HX.js";
2
+
1
3
  // src/features/tui/render.ts
2
4
  var ENTER_ALTERNATIVE_SCREEN = "\x1B[?1049h";
3
5
  var EXIT_ALTERNATIVE_SCREEN = "\x1B[?1049l";
@@ -30,8 +32,7 @@ var render = async (node) => {
30
32
  clear: instance.clear
31
33
  };
32
34
  };
33
-
34
35
  export {
35
36
  render
36
37
  };
37
- //# sourceMappingURL=chunk-UZVYEMEZ.js.map
38
+ //# sourceMappingURL=render-U36YSDSA.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugbug-io/cli",
3
- "version": "13.39.3",
3
+ "version": "14.0.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "bugbug": "bin/bugbug.mjs"
@@ -59,4 +59,4 @@
59
59
  "engines": {
60
60
  "node": ">=24"
61
61
  }
62
- }
62
+ }
@@ -1,8 +0,0 @@
1
- import {
2
- render
3
- } from "./chunk-UZVYEMEZ.js";
4
- import "./chunk-PR4QN5HX.js";
5
- export {
6
- render
7
- };
8
- //# sourceMappingURL=render-RAJK5JCO.js.map