@todesktop/cli 1.7.0-2 → 1.7.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.
package/dist/cli.js CHANGED
@@ -4437,6 +4437,8 @@ function SmokeTestView({
4437
4437
  case "build-error": {
4438
4438
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(BuildError, { build: state.build, message: (_a = state.error) == null ? void 0 : _a.message });
4439
4439
  }
4440
+ case "canceled":
4441
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_ink36.Text, { children: "Smoke test canceled." });
4440
4442
  case "complete":
4441
4443
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_ink36.Text, { bold: true, color: "greenBright", children: "Smoke test passed." });
4442
4444
  case "error":
@@ -4494,6 +4496,64 @@ function isBuildTestable(build) {
4494
4496
  return false;
4495
4497
  }
4496
4498
  }
4499
+ function isTestRunning(build) {
4500
+ const { isFinished } = makeProgress(build);
4501
+ return !isFinished;
4502
+ }
4503
+ function makeProgress(build) {
4504
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
4505
+ const def = {
4506
+ progress: 0,
4507
+ state: "progress",
4508
+ shouldSkip: false
4509
+ };
4510
+ const linux = {
4511
+ ...((_a = build.smokeTest) == null ? void 0 : _a.linux) || def,
4512
+ shouldSkip: ((_b = build.linux) == null ? void 0 : _b.shouldSkip) || false,
4513
+ message: ((_d = (_c = build.smokeTest) == null ? void 0 : _c.linux) == null ? void 0 : _d.message) || "Starting"
4514
+ };
4515
+ const mac = {
4516
+ ...((_e = build.smokeTest) == null ? void 0 : _e.mac) || def,
4517
+ shouldSkip: ((_f = build.mac) == null ? void 0 : _f.shouldSkip) || false,
4518
+ message: ((_h = (_g = build.smokeTest) == null ? void 0 : _g.mac) == null ? void 0 : _h.message) || "Starting"
4519
+ };
4520
+ const windows = {
4521
+ ...((_i = build.smokeTest) == null ? void 0 : _i.windows) || def,
4522
+ shouldSkip: ((_j = build.windows) == null ? void 0 : _j.shouldSkip) || false,
4523
+ message: ((_l = (_k = build.smokeTest) == null ? void 0 : _k.windows) == null ? void 0 : _l.message) || "Starting"
4524
+ };
4525
+ const platforms = [linux, mac, windows].filter(
4526
+ (p) => !p.shouldSkip && p.state !== "skipped"
4527
+ );
4528
+ const platformArr = ["mac", "windows", "linux"];
4529
+ const isRunning = platformArr.some(
4530
+ (platform) => {
4531
+ var _a2;
4532
+ return Boolean(
4533
+ build.smokeTest && ((_a2 = build.smokeTest[platform]) == null ? void 0 : _a2.state) === "progress" && !build.smokeTest.isCanceled
4534
+ );
4535
+ }
4536
+ );
4537
+ const isFinished = !isRunning;
4538
+ let totalState = "progress";
4539
+ if ((_m = build.smokeTest) == null ? void 0 : _m.isCanceled) {
4540
+ totalState = "canceled";
4541
+ } else if (platforms.every((p) => p.state === "done")) {
4542
+ totalState = "done";
4543
+ } else if (isFinished && platforms.some((p) => p.state === "error")) {
4544
+ totalState = "error";
4545
+ }
4546
+ return {
4547
+ isFinished,
4548
+ linux,
4549
+ mac,
4550
+ windows,
4551
+ total: {
4552
+ error: platforms.filter((p) => p.state === "error").map((p) => p.message).join("\n\n"),
4553
+ state: totalState
4554
+ }
4555
+ };
4556
+ }
4497
4557
  function validateBuild(build) {
4498
4558
  if (build.status !== "succeeded") {
4499
4559
  throw new SmokeError(
@@ -4605,46 +4665,6 @@ async function waitUntilFinished({
4605
4665
  );
4606
4666
  });
4607
4667
  }
4608
- function makeProgress(build) {
4609
- var _a, _b, _c, _d, _e, _f;
4610
- const def = {
4611
- progress: 0,
4612
- state: "progress",
4613
- shouldSkip: false
4614
- };
4615
- const linux = {
4616
- ...((_a = build.smokeTest) == null ? void 0 : _a.linux) || def,
4617
- shouldSkip: ((_b = build.linux) == null ? void 0 : _b.shouldSkip) || false
4618
- };
4619
- const mac = {
4620
- ...((_c = build.smokeTest) == null ? void 0 : _c.mac) || def,
4621
- shouldSkip: ((_d = build.mac) == null ? void 0 : _d.shouldSkip) || false
4622
- };
4623
- const windows = {
4624
- ...((_e = build.smokeTest) == null ? void 0 : _e.windows) || def,
4625
- shouldSkip: ((_f = build.windows) == null ? void 0 : _f.shouldSkip) || false
4626
- };
4627
- const platforms = [linux, mac, windows].filter(
4628
- (p) => !p.shouldSkip && p.state !== "skipped"
4629
- );
4630
- const isFinished = platforms.every((p) => p.state !== "progress");
4631
- let totalState = "progress";
4632
- if (platforms.every((p) => p.state === "done")) {
4633
- totalState = "done";
4634
- } else if (isFinished && platforms.some((p) => p.state === "error")) {
4635
- totalState = "error";
4636
- }
4637
- return {
4638
- isFinished,
4639
- linux,
4640
- mac,
4641
- windows,
4642
- total: {
4643
- error: platforms.filter((p) => p.state === "error").map((p) => p.message).join("\n\n"),
4644
- state: totalState
4645
- }
4646
- };
4647
- }
4648
4668
 
4649
4669
  // src/commands/smoke-test/SmokeTestCommand.tsx
4650
4670
  var import_jsx_runtime42 = require("react/jsx-runtime");
@@ -4679,7 +4699,10 @@ function SmokeTestContainer({
4679
4699
  configPath
4680
4700
  }) {
4681
4701
  const exit = useExit_default();
4682
- const [state, setState] = (0, import_react22.useState)({ buildId, state: "loading" });
4702
+ const [state, setState] = (0, import_react22.useState)({
4703
+ buildId,
4704
+ state: "loading"
4705
+ });
4683
4706
  const [abortController] = (0, import_react22.useState)(new AbortController());
4684
4707
  const abortSignal = abortController.signal;
4685
4708
  (0, import_react22.useEffect)(() => {
@@ -4719,7 +4742,7 @@ async function smokeTestWorkflow({
4719
4742
  const build = await fetchBuild({ appId, buildId, userId });
4720
4743
  updateState({ appId, build, userId });
4721
4744
  validateBuild(build);
4722
- if (!abortSignal.aborted) {
4745
+ if (!abortSignal.aborted && !isTestRunning(build)) {
4723
4746
  await queueSmokeTest({ appId, buildId, nodeVersion, userId });
4724
4747
  }
4725
4748
  updateState({ state: "progress" });
@@ -4729,9 +4752,13 @@ async function smokeTestWorkflow({
4729
4752
  userId,
4730
4753
  onProgress: (progress) => updateState({ progress })
4731
4754
  });
4732
- updateState({
4733
- state: total.state == "error" ? "progress-error" : "complete"
4734
- });
4755
+ const stateMap = {
4756
+ done: "complete",
4757
+ progress: "complete",
4758
+ error: "progress-error",
4759
+ canceled: "canceled"
4760
+ };
4761
+ updateState({ state: stateMap[total.state] });
4735
4762
  } catch (error) {
4736
4763
  updateState({ error, state: error.type || "error" });
4737
4764
  }
@@ -4741,10 +4768,7 @@ function buildCanBeCanceled(build) {
4741
4768
  if ((_a = build == null ? void 0 : build.smokeTest) == null ? void 0 : _a.isCanceled) {
4742
4769
  return false;
4743
4770
  }
4744
- if (!((_b = build == null ? void 0 : build.smokeTest) == null ? void 0 : _b.buildServerExecutionId)) {
4745
- return false;
4746
- }
4747
- return true;
4771
+ return Boolean((_b = build == null ? void 0 : build.smokeTest) == null ? void 0 : _b.buildServerExecutionId);
4748
4772
  }
4749
4773
  function isCancelable(state) {
4750
4774
  const cancelableStates = ["loading", "progress"];
@@ -4811,7 +4835,7 @@ var package_default = {
4811
4835
  access: "public"
4812
4836
  },
4813
4837
  name: "@todesktop/cli",
4814
- version: "1.7.0-1",
4838
+ version: "1.7.0-3",
4815
4839
  license: "MIT",
4816
4840
  author: "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
4817
4841
  homepage: "https://todesktop.com/cli",