@alwaysmeticulous/cli 2.45.1 → 2.45.3

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.
@@ -1,21 +1,5 @@
1
1
  /// <reference types="yargs" />
2
- import { Replay, ScreenshotDiffOptions } from "@alwaysmeticulous/api";
3
- import { ReplayExecutionOptions, ReplayTarget } from "@alwaysmeticulous/sdk-bundles-api";
4
- export interface RawReplayCommandHandlerOptions extends ScreenshotDiffOptions, Omit<ReplayExecutionOptions, "maxDurationMs" | "maxEventCount"> {
5
- screenshot: boolean;
6
- appUrl: string | null | undefined;
7
- simulationIdForAssets: string | null | undefined;
8
- maxDurationMs: number | null | undefined;
9
- maxEventCount: number | null | undefined;
10
- storyboard: boolean;
11
- apiToken: string | null | undefined;
12
- commitSha: string | null | undefined;
13
- sessionId: string;
14
- cookiesFile: string | null | undefined;
15
- debugger: boolean;
16
- baseReplayId: string | null | undefined;
17
- }
18
- export declare const rawReplayCommandHandler: ({ apiToken, commitSha, sessionId, appUrl, simulationIdForAssets, headless, devTools, bypassCSP, screenshot, baseReplayId, diffThreshold, diffPixelThreshold, shiftTime, networkStubbing, moveBeforeClick, cookiesFile, disableRemoteFonts, noSandbox, skipPauses, maxDurationMs, maxEventCount, storyboard, essentialFeaturesOnly, debugger: enableStepThroughDebugger, }: RawReplayCommandHandlerOptions) => Promise<Replay>;
2
+ import { ReplayTarget } from "@alwaysmeticulous/sdk-bundles-api";
19
3
  export declare const getReplayTarget: ({ appUrl, simulationIdForAssets, }: {
20
4
  appUrl: string | null;
21
5
  simulationIdForAssets: string | null;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replayCommand = exports.getReplayTarget = exports.rawReplayCommandHandler = void 0;
3
+ exports.replayCommand = exports.getReplayTarget = void 0;
4
4
  const common_1 = require("@alwaysmeticulous/common");
5
5
  const replay_orchestrator_launcher_1 = require("@alwaysmeticulous/replay-orchestrator-launcher");
6
6
  const command_builder_1 = require("../../command-utils/command-builder");
7
7
  const common_options_1 = require("../../command-utils/common-options");
8
8
  const out_of_date_client_error_1 = require("../../utils/out-of-date-client-error");
9
9
  const replay_debugger_ui_1 = require("./utils/replay-debugger.ui");
10
- const rawReplayCommandHandler = async ({ apiToken, commitSha, sessionId, appUrl, simulationIdForAssets, headless, devTools, bypassCSP, screenshot, baseReplayId, diffThreshold, diffPixelThreshold, shiftTime, networkStubbing, moveBeforeClick, cookiesFile, disableRemoteFonts, noSandbox, skipPauses, maxDurationMs, maxEventCount, storyboard, essentialFeaturesOnly, debugger: enableStepThroughDebugger, }) => {
10
+ const replayCommandHandler = async ({ apiToken, commitSha, sessionId, appUrl, simulationIdForAssets, headless, devTools, bypassCSP, screenshot, baseReplayId, diffThreshold, diffPixelThreshold, shiftTime, networkStubbing, moveBeforeClick, cookiesFile, disableRemoteFonts, noSandbox, skipPauses, maxDurationMs, maxEventCount, storyboard, essentialFeaturesOnly, debugger: enableStepThroughDebugger, }) => {
11
11
  if (!screenshot && storyboard) {
12
12
  throw new Error("Cannot take storyboard screenshots without taking end state screenshots. Please set '--screenshot' to true, or '--storyboard' to false.");
13
13
  }
@@ -81,8 +81,7 @@ const rawReplayCommandHandler = async ({ apiToken, commitSha, sessionId, appUrl,
81
81
  getOnBeforeUserEventCallback.resolve(stepThroughDebuggerUI.onBeforeUserEvent);
82
82
  getOnClosePageCallback.resolve(stepThroughDebuggerUI.close);
83
83
  }
84
- const { replay } = await replayExecution.finalResult;
85
- return replay;
84
+ await replayExecution.finalResult;
86
85
  }
87
86
  catch (error) {
88
87
  if ((0, out_of_date_client_error_1.isOutOfDateClientError)(error)) {
@@ -93,7 +92,6 @@ const rawReplayCommandHandler = async ({ apiToken, commitSha, sessionId, appUrl,
93
92
  }
94
93
  }
95
94
  };
96
- exports.rawReplayCommandHandler = rawReplayCommandHandler;
97
95
  const getReplayTarget = ({ appUrl, simulationIdForAssets, }) => {
98
96
  if (simulationIdForAssets) {
99
97
  return { type: "snapshotted-assets", simulationIdForAssets };
@@ -149,5 +147,5 @@ exports.replayCommand = (0, command_builder_1.buildCommand)("simulate")
149
147
  ...common_options_1.SCREENSHOT_DIFF_OPTIONS,
150
148
  })
151
149
  .handler(async (options) => {
152
- await (0, exports.rawReplayCommandHandler)(options);
150
+ await replayCommandHandler(options);
153
151
  });
@@ -36,15 +36,42 @@ const openStepThroughDebuggerUI = async ({ onCloseReplayedPage, onLogEventTarget
36
36
  index: 0,
37
37
  loading: false,
38
38
  };
39
+ let readyPromiseResolve;
40
+ const readyPromise = new Promise((resolve) => {
41
+ readyPromiseResolve = resolve;
42
+ });
43
+ // This function is called by the UI itself
44
+ await debuggerPage.exposeFunction("__meticulous__replayDebuggerDispatchEvent", (eventType, data) => {
45
+ if (eventType === "ready") {
46
+ return onReady();
47
+ }
48
+ if (eventType === "check-next-target") {
49
+ if (state.index >= replayableEvents.length) {
50
+ logger.info("End of replay!");
51
+ return;
52
+ }
53
+ const nextEvent = state.events[state.index];
54
+ return onLogEventTarget(nextEvent);
55
+ }
56
+ if (eventType === "play-next-event") {
57
+ return onPlayNextEvent();
58
+ }
59
+ if (eventType === "set-index") {
60
+ return onAdvanceToIndex(data.index || 0);
61
+ }
62
+ logger.info(`[debugger-ui] Warning: received unknown event "${eventType}"`);
63
+ });
64
+ const onReady = async () => {
65
+ readyPromiseResolve();
66
+ await setState(state);
67
+ };
39
68
  const setState = async (newState) => {
69
+ await readyPromise;
40
70
  state = { ...state, ...newState };
41
71
  await debuggerPage.evaluate((state) => {
42
72
  window.__meticulous__replayDebuggerSetState(state);
43
73
  }, state);
44
74
  };
45
- const onReady = async () => {
46
- await setState(state);
47
- };
48
75
  let advanceToEvent = null;
49
76
  const onBeforeUserEvent = async ({ userEventIndex, }) => {
50
77
  await setState({
@@ -72,27 +99,6 @@ const openStepThroughDebuggerUI = async ({ onCloseReplayedPage, onLogEventTarget
72
99
  await setState({ loading: true });
73
100
  advanceToEvent === null || advanceToEvent === void 0 ? void 0 : advanceToEvent({ nextEventIndexToPauseBefore: targetIndex });
74
101
  };
75
- // This function is called by the UI itself
76
- await debuggerPage.exposeFunction("__meticulous__replayDebuggerDispatchEvent", (eventType, data) => {
77
- if (eventType === "ready") {
78
- return onReady();
79
- }
80
- if (eventType === "check-next-target") {
81
- if (state.index >= replayableEvents.length) {
82
- logger.info("End of replay!");
83
- return;
84
- }
85
- const nextEvent = state.events[state.index];
86
- return onLogEventTarget(nextEvent);
87
- }
88
- if (eventType === "play-next-event") {
89
- return onPlayNextEvent();
90
- }
91
- if (eventType === "set-index") {
92
- return onAdvanceToIndex(data.index || 0);
93
- }
94
- logger.info(`[debugger-ui] Warning: received unknown event "${eventType}"`);
95
- });
96
102
  logger.info(`[debugger-ui] Navigating to ${uiServer.url}...`);
97
103
  const res = await debuggerPage.goto(uiServer.url, {
98
104
  waitUntil: "domcontentloaded",
@@ -38,13 +38,17 @@ exports.setOptions = setOptions;
38
38
  const wrapHandler = function wrapHandler_(handler) {
39
39
  return async (args) => {
40
40
  await handler(args)
41
- .then(() => {
41
+ .then(async () => {
42
42
  var _a;
43
43
  const transaction = (_a = Sentry.getCurrentHub().getScope()) === null || _a === void 0 ? void 0 : _a.getTransaction();
44
44
  if (transaction !== undefined) {
45
45
  transaction.setStatus("ok");
46
46
  transaction.finish();
47
47
  }
48
+ await Sentry.flush(sentry_1.SENTRY_FLUSH_TIMEOUT.toMillis());
49
+ // This is required: otherwise the process will hang for a while,
50
+ // presumably waiting on some setTimeout to trigger
51
+ process.exit(0);
48
52
  })
49
53
  .catch(async (error) => {
50
54
  var _a;
@@ -54,6 +58,7 @@ const wrapHandler = function wrapHandler_(handler) {
54
58
  transaction.setStatus("unknown_error");
55
59
  transaction.finish();
56
60
  }
61
+ await Sentry.flush(sentry_1.SENTRY_FLUSH_TIMEOUT.toMillis());
57
62
  // Don't display the help text which can obscure the error
58
63
  process.exit(1);
59
64
  });
@@ -67,5 +72,4 @@ const reportHandlerError = async (error) => {
67
72
  logger.info("");
68
73
  logger.info("Tip: run `meticulous <command> --help` for help on a particular command, or `meticulous --help` for a list of the available commands.");
69
74
  Sentry.captureException(error);
70
- await Sentry.flush(sentry_1.SENTRY_FLUSH_TIMEOUT.toMillis());
71
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwaysmeticulous/cli",
3
- "version": "2.45.1",
3
+ "version": "2.45.3",
4
4
  "description": "The Meticulous CLI",
5
5
  "license": "ISC",
6
6
  "main": "dist/index.js",
@@ -32,9 +32,9 @@
32
32
  "@alwaysmeticulous/common": "^2.44.1",
33
33
  "@alwaysmeticulous/downloading-helpers": "^2.44.1",
34
34
  "@alwaysmeticulous/record": "^2.44.1",
35
- "@alwaysmeticulous/replay-debugger-ui": "^2.45.1",
36
- "@alwaysmeticulous/replay-orchestrator-launcher": "^2.45.0",
37
- "@alwaysmeticulous/sdk-bundles-api": "^2.45.0",
35
+ "@alwaysmeticulous/replay-debugger-ui": "^2.45.2",
36
+ "@alwaysmeticulous/replay-orchestrator-launcher": "^2.45.3",
37
+ "@alwaysmeticulous/sdk-bundles-api": "^2.45.3",
38
38
  "@alwaysmeticulous/sentry": "^2.40.0",
39
39
  "@sentry/node": "^7.36.0",
40
40
  "axios": "^1.2.6",
@@ -79,5 +79,5 @@
79
79
  "coverageDirectory": "../coverage",
80
80
  "testEnvironment": "node"
81
81
  },
82
- "gitHead": "05823c058b305c65ca379238d5a8ddf475681a61"
82
+ "gitHead": "d4e536d8ea889e75077bb9889399016d35082339"
83
83
  }