@smoothdeploy/playwright 1.58.3 → 1.60.0-beta-1780662356000

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 (182) hide show
  1. package/ThirdPartyNotices.txt +8 -5036
  2. package/lib/agents/agentParser.js +2 -2
  3. package/lib/agents/generateAgents.js +21 -22
  4. package/lib/agents/playwright-test-healer.agent.md +1 -0
  5. package/lib/agents/playwright-test-planner.agent.md +2 -1
  6. package/lib/cli/reportActions.js +78 -0
  7. package/lib/cli/testActions.js +211 -0
  8. package/lib/common/index.js +2898 -0
  9. package/lib/common/index.js.txt +35 -0
  10. package/lib/errorContext.js +130 -0
  11. package/lib/index.js +283 -206
  12. package/lib/{isomorphic/testServerConnection.js → isomorphic.js} +70 -35
  13. package/lib/isomorphic.js.txt +9 -0
  14. package/lib/loader/loaderProcessEntry.js +34 -0
  15. package/lib/loader/loaderProcessEntry.js.txt +9 -0
  16. package/lib/matchers/expect.js +12988 -249
  17. package/lib/matchers/expect.js.LICENSE +693 -0
  18. package/lib/matchers/expect.js.txt +72 -0
  19. package/lib/mcp/test/browserBackend.js +49 -22
  20. package/lib/mcp/test/generatorTools.js +16 -16
  21. package/lib/mcp/test/plannerTools.js +25 -20
  22. package/lib/mcp/test/seed.js +7 -7
  23. package/lib/mcp/test/testBackend.js +30 -30
  24. package/lib/mcp/test/testContext.js +50 -33
  25. package/lib/mcp/test/testTools.js +15 -25
  26. package/lib/{internalsForTest.js → package.js} +13 -8
  27. package/lib/program.js +63 -263
  28. package/lib/runner/index.js +8339 -0
  29. package/lib/runner/index.js.txt +60 -0
  30. package/lib/transform/babelBundle.js +71002 -18
  31. package/lib/transform/babelBundle.js.LICENSE +2359 -0
  32. package/lib/transform/babelBundle.js.txt +325 -0
  33. package/lib/transform/esmLoader.js +5884 -30
  34. package/lib/transform/esmLoader.js.LICENSE +335 -0
  35. package/lib/transform/esmLoader.js.txt +55 -0
  36. package/lib/util.js +37 -34
  37. package/lib/worker/workerProcessEntry.js +3251 -0
  38. package/lib/worker/workerProcessEntry.js.txt +24 -0
  39. package/package.json +5 -16
  40. package/test.mjs +1 -0
  41. package/types/test.d.ts +173 -12
  42. package/types/testReporter.d.ts +7 -5
  43. package/lib/common/config.js +0 -282
  44. package/lib/common/configLoader.js +0 -344
  45. package/lib/common/esmLoaderHost.js +0 -104
  46. package/lib/common/expectBundle.js +0 -28
  47. package/lib/common/expectBundleImpl.js +0 -407
  48. package/lib/common/fixtures.js +0 -302
  49. package/lib/common/ipc.js +0 -60
  50. package/lib/common/poolBuilder.js +0 -85
  51. package/lib/common/process.js +0 -132
  52. package/lib/common/suiteUtils.js +0 -140
  53. package/lib/common/test.js +0 -321
  54. package/lib/common/testLoader.js +0 -101
  55. package/lib/common/testType.js +0 -298
  56. package/lib/common/validators.js +0 -68
  57. package/lib/fsWatcher.js +0 -67
  58. package/lib/isomorphic/events.js +0 -77
  59. package/lib/isomorphic/folders.js +0 -30
  60. package/lib/isomorphic/stringInternPool.js +0 -69
  61. package/lib/isomorphic/teleReceiver.js +0 -521
  62. package/lib/isomorphic/teleSuiteUpdater.js +0 -157
  63. package/lib/isomorphic/testServerInterface.js +0 -16
  64. package/lib/isomorphic/testTree.js +0 -329
  65. package/lib/isomorphic/types.d.js +0 -16
  66. package/lib/loader/loaderMain.js +0 -59
  67. package/lib/matchers/matcherHint.js +0 -44
  68. package/lib/matchers/matchers.js +0 -383
  69. package/lib/matchers/toBeTruthy.js +0 -75
  70. package/lib/matchers/toEqual.js +0 -100
  71. package/lib/matchers/toHaveURL.js +0 -101
  72. package/lib/matchers/toMatchAriaSnapshot.js +0 -159
  73. package/lib/matchers/toMatchSnapshot.js +0 -342
  74. package/lib/matchers/toMatchText.js +0 -99
  75. package/lib/mcp/browser/browserContextFactory.js +0 -329
  76. package/lib/mcp/browser/browserServerBackend.js +0 -84
  77. package/lib/mcp/browser/config.js +0 -421
  78. package/lib/mcp/browser/context.js +0 -244
  79. package/lib/mcp/browser/response.js +0 -278
  80. package/lib/mcp/browser/sessionLog.js +0 -75
  81. package/lib/mcp/browser/tab.js +0 -343
  82. package/lib/mcp/browser/tools/common.js +0 -65
  83. package/lib/mcp/browser/tools/console.js +0 -46
  84. package/lib/mcp/browser/tools/dialogs.js +0 -60
  85. package/lib/mcp/browser/tools/evaluate.js +0 -61
  86. package/lib/mcp/browser/tools/files.js +0 -58
  87. package/lib/mcp/browser/tools/form.js +0 -63
  88. package/lib/mcp/browser/tools/install.js +0 -72
  89. package/lib/mcp/browser/tools/keyboard.js +0 -107
  90. package/lib/mcp/browser/tools/mouse.js +0 -107
  91. package/lib/mcp/browser/tools/navigate.js +0 -71
  92. package/lib/mcp/browser/tools/network.js +0 -63
  93. package/lib/mcp/browser/tools/open.js +0 -57
  94. package/lib/mcp/browser/tools/pdf.js +0 -49
  95. package/lib/mcp/browser/tools/runCode.js +0 -78
  96. package/lib/mcp/browser/tools/screenshot.js +0 -93
  97. package/lib/mcp/browser/tools/snapshot.js +0 -173
  98. package/lib/mcp/browser/tools/tabs.js +0 -67
  99. package/lib/mcp/browser/tools/tool.js +0 -47
  100. package/lib/mcp/browser/tools/tracing.js +0 -74
  101. package/lib/mcp/browser/tools/utils.js +0 -94
  102. package/lib/mcp/browser/tools/verify.js +0 -143
  103. package/lib/mcp/browser/tools/wait.js +0 -63
  104. package/lib/mcp/browser/tools.js +0 -84
  105. package/lib/mcp/browser/watchdog.js +0 -44
  106. package/lib/mcp/config.d.js +0 -16
  107. package/lib/mcp/extension/cdpRelay.js +0 -351
  108. package/lib/mcp/extension/extensionContextFactory.js +0 -76
  109. package/lib/mcp/extension/protocol.js +0 -28
  110. package/lib/mcp/index.js +0 -61
  111. package/lib/mcp/log.js +0 -35
  112. package/lib/mcp/program.js +0 -111
  113. package/lib/mcp/sdk/exports.js +0 -28
  114. package/lib/mcp/sdk/http.js +0 -152
  115. package/lib/mcp/sdk/inProcessTransport.js +0 -71
  116. package/lib/mcp/sdk/server.js +0 -223
  117. package/lib/mcp/sdk/tool.js +0 -47
  118. package/lib/mcp/terminal/cli.js +0 -296
  119. package/lib/mcp/terminal/command.js +0 -56
  120. package/lib/mcp/terminal/commands.js +0 -333
  121. package/lib/mcp/terminal/daemon.js +0 -129
  122. package/lib/mcp/terminal/help.json +0 -32
  123. package/lib/mcp/terminal/helpGenerator.js +0 -88
  124. package/lib/mcp/terminal/socketConnection.js +0 -80
  125. package/lib/plugins/gitCommitInfoPlugin.js +0 -198
  126. package/lib/plugins/index.js +0 -28
  127. package/lib/plugins/webServerPlugin.js +0 -237
  128. package/lib/reporters/base.js +0 -634
  129. package/lib/reporters/blob.js +0 -138
  130. package/lib/reporters/dot.js +0 -99
  131. package/lib/reporters/empty.js +0 -32
  132. package/lib/reporters/github.js +0 -128
  133. package/lib/reporters/html.js +0 -633
  134. package/lib/reporters/internalReporter.js +0 -138
  135. package/lib/reporters/json.js +0 -254
  136. package/lib/reporters/junit.js +0 -232
  137. package/lib/reporters/line.js +0 -131
  138. package/lib/reporters/list.js +0 -253
  139. package/lib/reporters/listModeReporter.js +0 -69
  140. package/lib/reporters/markdown.js +0 -144
  141. package/lib/reporters/merge.js +0 -558
  142. package/lib/reporters/multiplexer.js +0 -112
  143. package/lib/reporters/reporterV2.js +0 -102
  144. package/lib/reporters/smoothdeploy.js +0 -333
  145. package/lib/reporters/teleEmitter.js +0 -317
  146. package/lib/reporters/versions/blobV1.js +0 -16
  147. package/lib/runner/dispatcher.js +0 -531
  148. package/lib/runner/failureTracker.js +0 -72
  149. package/lib/runner/lastRun.js +0 -77
  150. package/lib/runner/loadUtils.js +0 -334
  151. package/lib/runner/loaderHost.js +0 -89
  152. package/lib/runner/processHost.js +0 -180
  153. package/lib/runner/projectUtils.js +0 -241
  154. package/lib/runner/rebase.js +0 -189
  155. package/lib/runner/reporters.js +0 -140
  156. package/lib/runner/sigIntWatcher.js +0 -96
  157. package/lib/runner/storage.js +0 -91
  158. package/lib/runner/taskRunner.js +0 -127
  159. package/lib/runner/tasks.js +0 -410
  160. package/lib/runner/testGroups.js +0 -125
  161. package/lib/runner/testRunner.js +0 -398
  162. package/lib/runner/testServer.js +0 -269
  163. package/lib/runner/uiModeReporter.js +0 -30
  164. package/lib/runner/vcs.js +0 -72
  165. package/lib/runner/watchMode.js +0 -396
  166. package/lib/runner/workerHost.js +0 -104
  167. package/lib/third_party/pirates.js +0 -62
  168. package/lib/third_party/tsconfig-loader.js +0 -103
  169. package/lib/transform/babelBundleImpl.js +0 -461
  170. package/lib/transform/compilationCache.js +0 -274
  171. package/lib/transform/md.js +0 -221
  172. package/lib/transform/portTransport.js +0 -67
  173. package/lib/transform/transform.js +0 -303
  174. package/lib/utilsBundle.js +0 -50
  175. package/lib/utilsBundleImpl.js +0 -103
  176. package/lib/worker/fixtureRunner.js +0 -262
  177. package/lib/worker/testInfo.js +0 -536
  178. package/lib/worker/testTracing.js +0 -345
  179. package/lib/worker/timeoutManager.js +0 -174
  180. package/lib/worker/util.js +0 -31
  181. package/lib/worker/workerMain.js +0 -530
  182. /package/lib/{common/globals.js → globals.js} +0 -0
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var daemon_exports = {};
30
- __export(daemon_exports, {
31
- startMcpDaemonServer: () => startMcpDaemonServer
32
- });
33
- module.exports = __toCommonJS(daemon_exports);
34
- var import_promises = __toESM(require("fs/promises"));
35
- var import_net = __toESM(require("net"));
36
- var import_os = __toESM(require("os"));
37
- var import_path = __toESM(require("path"));
38
- var import_url = __toESM(require("url"));
39
- var import_utilsBundle = require("playwright-core/lib/utilsBundle");
40
- var import_socketConnection = require("./socketConnection");
41
- var import_commands = require("./commands");
42
- var import_command = require("./command");
43
- const daemonDebug = (0, import_utilsBundle.debug)("pw:daemon");
44
- async function socketExists(socketPath) {
45
- try {
46
- const stat = await import_promises.default.stat(socketPath);
47
- if (stat?.isSocket())
48
- return true;
49
- } catch (e) {
50
- }
51
- return false;
52
- }
53
- async function startMcpDaemonServer(socketPath, serverBackendFactory) {
54
- if (import_os.default.platform() !== "win32" && await socketExists(socketPath)) {
55
- daemonDebug(`Socket already exists, removing: ${socketPath}`);
56
- try {
57
- await import_promises.default.unlink(socketPath);
58
- } catch (error) {
59
- daemonDebug(`Failed to remove existing socket: ${error}`);
60
- throw error;
61
- }
62
- }
63
- const backend = serverBackendFactory.create();
64
- const cwd = import_url.default.pathToFileURL(process.cwd()).href;
65
- await backend.initialize?.({
66
- name: "playwright-cli",
67
- version: "1.0.0",
68
- roots: [{
69
- uri: cwd,
70
- name: "cwd"
71
- }],
72
- timestamp: Date.now()
73
- });
74
- await import_promises.default.mkdir(import_path.default.dirname(socketPath), { recursive: true });
75
- const server = import_net.default.createServer((socket) => {
76
- daemonDebug("new client connection");
77
- const connection = new import_socketConnection.SocketConnection(socket);
78
- connection.onclose = () => {
79
- daemonDebug("client disconnected");
80
- };
81
- connection.onmessage = async (message) => {
82
- const { id, method, params } = message;
83
- try {
84
- daemonDebug("received command", method);
85
- if (method === "runCliCommand") {
86
- const { toolName, toolParams } = parseCliCommand(params.args);
87
- const response = await backend.callTool(toolName, toolParams, () => {
88
- });
89
- await connection.send({ id, result: formatResult(response) });
90
- } else {
91
- throw new Error(`Unknown method: ${method}`);
92
- }
93
- } catch (e) {
94
- daemonDebug("command failed", e);
95
- await connection.send({ id, error: e.message });
96
- }
97
- };
98
- });
99
- return new Promise((resolve, reject) => {
100
- server.on("error", (error) => {
101
- daemonDebug(`server error: ${error.message}`);
102
- reject(error);
103
- });
104
- server.listen(socketPath, () => {
105
- daemonDebug(`daemon server listening on ${socketPath}`);
106
- resolve(socketPath);
107
- });
108
- });
109
- }
110
- function formatResult(result) {
111
- const lines = [];
112
- for (const content of result.content) {
113
- if (content.type === "text")
114
- lines.push(content.text);
115
- else
116
- lines.push(`<${content.type} content>`);
117
- }
118
- return lines.join("\n");
119
- }
120
- function parseCliCommand(args) {
121
- const command = import_commands.commands[args._[0]];
122
- if (!command)
123
- throw new Error("Command is required");
124
- return (0, import_command.parseCommand)(command, args);
125
- }
126
- // Annotate the CommonJS export names for ESM import in node:
127
- 0 && (module.exports = {
128
- startMcpDaemonServer
129
- });
@@ -1,32 +0,0 @@
1
- {
2
- "global": "Usage: playwright-cli <command> [options]\nCommands:\n click <ref> perform click on a web page\n close close the page\n dblclick <ref> perform double click on a web page\n console <level> returns all console messages\n drag <startRef> <endRef> perform drag and drop between two elements\n evaluate <function> <ref> evaluate javascript expression on page or element\n upload-file upload one or multiple files\n handle-dialog <accept> <promptText> handle a dialog\n hover <ref> hover over element on page\n open <url> open url\n go-back go back to the previous page\n network-requests returns all network requests since loading the page\n press <key> press a key on the keyboard\n resize <width> <height> resize the browser window\n run-code <code> run playwright code snippet\n select-option <ref> <values> select an option in a dropdown\n snapshot capture accessibility snapshot of the current page, this is better than screenshot\n screenshot <ref> take a screenshot of the current page. you can't perform actions based on the screenshot, use browser_snapshot for actions.\n type <text> type text into editable element\n wait-for wait for text to appear or disappear or a specified time to pass\n tab <action> <index> close a browser tab\n mouse-click-xy <x> <y> click left mouse button at a given position\n mouse-drag-xy <startX> <startY> <endX> <endY> drag left mouse button to a given position\n mouse-move-xy <x> <y> move mouse to a given position\n pdf-save save page as pdf\n start-tracing start trace recording\n stop-tracing stop trace recording",
3
- "commands": {
4
- "click": "playwright-cli click <ref>\n\nPerform click on a web page\n\nArguments:\n <ref>\tExact target element reference from the page snapshot\nOptions:\n --button\tbutton to click, defaults to left\n --modifiers\tmodifier keys to press",
5
- "close": "playwright-cli close \n\nClose the page\n",
6
- "dblclick": "playwright-cli dblclick <ref>\n\nPerform double click on a web page\n\nArguments:\n <ref>\tExact target element reference from the page snapshot\nOptions:\n --button\tbutton to click, defaults to left\n --modifiers\tmodifier keys to press",
7
- "console": "playwright-cli console <level>\n\nReturns all console messages\n\nArguments:\n <level>\tLevel of the console messages to return. Each level includes the messages of more severe levels. Defaults to \"info\".",
8
- "drag": "playwright-cli drag <startRef> <endRef>\n\nPerform drag and drop between two elements\n\nArguments:\n <startRef>\tExact source element reference from the page snapshot\n <endRef>\tExact target element reference from the page snapshot\nOptions:\n --headed\trun browser in headed mode",
9
- "evaluate": "playwright-cli evaluate <function> <ref>\n\nEvaluate JavaScript expression on page or element\n\nArguments:\n <function>\t() => { /* code */ } or (element) => { /* code */ } when element is provided\n <ref>\tExact target element reference from the page snapshot",
10
- "upload-file": "playwright-cli upload-file \n\nUpload one or multiple files\n\nOptions:\n --paths\tthe absolute paths to the files to upload. can be single file or multiple files. if omitted, file chooser is cancelled.",
11
- "handle-dialog": "playwright-cli handle-dialog <accept> <promptText>\n\nHandle a dialog\n\nArguments:\n <accept>\tWhether to accept the dialog.\n <promptText>\tThe text of the prompt in case of a prompt dialog.",
12
- "hover": "playwright-cli hover <ref>\n\nHover over element on page\n\nArguments:\n <ref>\tExact target element reference from the page snapshot",
13
- "open": "playwright-cli open <url>\n\nOpen URL\n\nArguments:\n <url>\tThe URL to navigate to\nOptions:\n --headed\trun browser in headed mode",
14
- "go-back": "playwright-cli go-back \n\nGo back to the previous page\n",
15
- "network-requests": "playwright-cli network-requests \n\nReturns all network requests since loading the page\n\nOptions:\n --includeStatic\twhether to include successful static resources like images, fonts, scripts, etc. defaults to false.",
16
- "press": "playwright-cli press <key>\n\nPress a key on the keyboard\n\nArguments:\n <key>\tName of the key to press or a character to generate, such as `ArrowLeft` or `a`",
17
- "resize": "playwright-cli resize <width> <height>\n\nResize the browser window\n\nArguments:\n <width>\tWidth of the browser window\n <height>\tHeight of the browser window",
18
- "run-code": "playwright-cli run-code <code>\n\nRun Playwright code snippet\n\nArguments:\n <code>\tA JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction.",
19
- "select-option": "playwright-cli select-option <ref> <values>\n\nSelect an option in a dropdown\n\nArguments:\n <ref>\tExact target element reference from the page snapshot\n <values>\tArray of values to select in the dropdown. This can be a single value or multiple values.",
20
- "snapshot": "playwright-cli snapshot \n\nCapture accessibility snapshot of the current page, this is better than screenshot\n\nOptions:\n --filename\tsave snapshot to markdown file instead of returning it in the response.",
21
- "screenshot": "playwright-cli screenshot <ref>\n\nTake a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.\n\nArguments:\n <ref>\tExact target element reference from the page snapshot.\nOptions:\n --filename\tfile name to save the screenshot to. defaults to `page-{timestamp}.{png|jpeg}` if not specified.\n --fullPage\twhen true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.",
22
- "type": "playwright-cli type <text>\n\nType text into editable element\n\nArguments:\n <text>\tText to type into the element\nOptions:\n --submit\twhether to submit entered text (press enter after)",
23
- "wait-for": "playwright-cli wait-for \n\nWait for text to appear or disappear or a specified time to pass\n\nOptions:\n --time\tthe time to wait in seconds\n --text\tthe text to wait for\n --textGone\tthe text to wait for to disappear",
24
- "tab": "playwright-cli tab <action> <index>\n\nClose a browser tab\n\nArguments:\n <action>\tAction to perform on tabs, 'list' | 'new' | 'close' | 'select'\n <index>\tTab index. If omitted, current tab is closed.",
25
- "mouse-click-xy": "playwright-cli mouse-click-xy <x> <y>\n\nClick left mouse button at a given position\n\nArguments:\n <x>\tX coordinate\n <y>\tY coordinate",
26
- "mouse-drag-xy": "playwright-cli mouse-drag-xy <startX> <startY> <endX> <endY>\n\nDrag left mouse button to a given position\n\nArguments:\n <startX>\tStart X coordinate\n <startY>\tStart Y coordinate\n <endX>\tEnd X coordinate\n <endY>\tEnd Y coordinate",
27
- "mouse-move-xy": "playwright-cli mouse-move-xy <x> <y>\n\nMove mouse to a given position\n\nArguments:\n <x>\tX coordinate\n <y>\tY coordinate",
28
- "pdf-save": "playwright-cli pdf-save \n\nSave page as PDF\n\nOptions:\n --filename\tfile name to save the pdf to. defaults to `page-{timestamp}.pdf` if not specified.",
29
- "start-tracing": "playwright-cli start-tracing \n\nStart trace recording\n",
30
- "stop-tracing": "playwright-cli stop-tracing \n\nStop trace recording\n"
31
- }
32
- }
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var import_fs = __toESM(require("fs"));
25
- var import_path = __toESM(require("path"));
26
- var import_commands = require("./commands");
27
- function generateCommandHelp(command) {
28
- const args = [];
29
- const shape = command.args ? command.args.shape : {};
30
- for (const [name, schema] of Object.entries(shape)) {
31
- const zodSchema = schema;
32
- const description = zodSchema.description ?? "";
33
- args.push({ name, description });
34
- }
35
- const lines = [
36
- `playwright-cli ${command.name} ${Object.keys(shape).map((k) => `<${k}>`).join(" ")}`,
37
- "",
38
- command.description,
39
- ""
40
- ];
41
- if (args.length) {
42
- lines.push("Arguments:");
43
- lines.push(...args.map(({ name, description }) => ` <${name}> ${description}`));
44
- }
45
- if (command.options) {
46
- lines.push("Options:");
47
- const optionsShape = command.options.shape;
48
- for (const [name, schema] of Object.entries(optionsShape)) {
49
- const zodSchema = schema;
50
- const description = (zodSchema.description ?? "").toLowerCase();
51
- lines.push(` --${name} ${description}`);
52
- }
53
- }
54
- return lines.join("\n");
55
- }
56
- function generateHelp() {
57
- const lines = [];
58
- lines.push("Usage: playwright-cli <command> [options]");
59
- lines.push("Commands:");
60
- for (const command of Object.values(import_commands.commands))
61
- lines.push(" " + generateHelpEntry(command));
62
- return lines.join("\n");
63
- }
64
- function generateHelpEntry(command) {
65
- const args = [];
66
- const shape = command.args.shape;
67
- for (const [name, schema] of Object.entries(shape)) {
68
- const zodSchema = schema;
69
- const description = zodSchema.description ?? "";
70
- args.push({ name, description });
71
- }
72
- const prefix = `${command.name} ${Object.keys(shape).map((k) => `<${k}>`).join(" ")}`;
73
- const suffix = command.description.toLowerCase();
74
- const padding = " ".repeat(Math.max(1, 40 - prefix.length));
75
- return prefix + padding + suffix;
76
- }
77
- async function main() {
78
- const help = {
79
- global: generateHelp(),
80
- commands: Object.fromEntries(
81
- Object.entries(import_commands.commands).map(([name, command]) => [name, generateCommandHelp(command)])
82
- )
83
- };
84
- const fileName = import_path.default.resolve(__dirname, "help.json").replace("lib", "src");
85
- console.log("Writing ", import_path.default.relative(process.cwd(), fileName));
86
- await import_fs.default.promises.writeFile(fileName, JSON.stringify(help, null, 2));
87
- }
88
- void main();
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var socketConnection_exports = {};
20
- __export(socketConnection_exports, {
21
- SocketConnection: () => SocketConnection
22
- });
23
- module.exports = __toCommonJS(socketConnection_exports);
24
- var import_utilsBundle = require("playwright-core/lib/utilsBundle");
25
- const daemonDebug = (0, import_utilsBundle.debug)("pw:daemon");
26
- class SocketConnection {
27
- constructor(socket) {
28
- this._pendingBuffers = [];
29
- this._socket = socket;
30
- socket.on("data", (buffer) => this._onData(buffer));
31
- socket.on("close", () => {
32
- this.onclose?.();
33
- });
34
- socket.on("error", (e) => daemonDebug(`error: ${e.message}`));
35
- }
36
- async send(message) {
37
- await new Promise((resolve, reject) => {
38
- this._socket.write(`${JSON.stringify(message)}
39
- `, (error) => {
40
- if (error)
41
- reject(error);
42
- else
43
- resolve(void 0);
44
- });
45
- });
46
- }
47
- close() {
48
- this._socket.destroy();
49
- }
50
- _onData(buffer) {
51
- let end = buffer.indexOf("\n");
52
- if (end === -1) {
53
- this._pendingBuffers.push(buffer);
54
- return;
55
- }
56
- this._pendingBuffers.push(buffer.slice(0, end));
57
- const message = Buffer.concat(this._pendingBuffers).toString();
58
- this._dispatchMessage(message);
59
- let start = end + 1;
60
- end = buffer.indexOf("\n", start);
61
- while (end !== -1) {
62
- const message2 = buffer.toString(void 0, start, end);
63
- this._dispatchMessage(message2);
64
- start = end + 1;
65
- end = buffer.indexOf("\n", start);
66
- }
67
- this._pendingBuffers = [buffer.slice(start)];
68
- }
69
- _dispatchMessage(message) {
70
- try {
71
- this.onmessage?.(JSON.parse(message));
72
- } catch (e) {
73
- daemonDebug("failed to dispatch message", e);
74
- }
75
- }
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- SocketConnection
80
- });
@@ -1,198 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var gitCommitInfoPlugin_exports = {};
30
- __export(gitCommitInfoPlugin_exports, {
31
- addGitCommitInfoPlugin: () => addGitCommitInfoPlugin
32
- });
33
- module.exports = __toCommonJS(gitCommitInfoPlugin_exports);
34
- var fs = __toESM(require("fs"));
35
- var import_utils = require("playwright-core/lib/utils");
36
- const GIT_OPERATIONS_TIMEOUT_MS = 3e3;
37
- const addGitCommitInfoPlugin = (fullConfig) => {
38
- fullConfig.plugins.push({ factory: gitCommitInfoPlugin.bind(null, fullConfig) });
39
- };
40
- function print(s, ...args) {
41
- console.log("GitCommitInfo: " + s, ...args);
42
- }
43
- function debug(s, ...args) {
44
- if (!process.env.DEBUG_GIT_COMMIT_INFO)
45
- return;
46
- print(s, ...args);
47
- }
48
- const gitCommitInfoPlugin = (fullConfig) => {
49
- return {
50
- name: "playwright:git-commit-info",
51
- setup: async (config, configDir) => {
52
- const metadata = config.metadata;
53
- const ci = await ciInfo();
54
- if (!metadata.ci && ci) {
55
- debug("ci info", ci);
56
- metadata.ci = ci;
57
- }
58
- if (fullConfig.captureGitInfo?.commit || fullConfig.captureGitInfo?.commit === void 0 && ci) {
59
- const git = await gitCommitInfo(configDir).catch((e) => print("failed to get git commit info", e));
60
- if (git) {
61
- debug("commit info", git);
62
- metadata.gitCommit = git;
63
- }
64
- }
65
- if (fullConfig.captureGitInfo?.diff || fullConfig.captureGitInfo?.diff === void 0 && ci) {
66
- const diffResult = await gitDiff(configDir, ci).catch((e) => print("failed to get git diff", e));
67
- if (diffResult) {
68
- debug(`diff length ${diffResult.length}`);
69
- metadata.gitDiff = diffResult;
70
- }
71
- }
72
- }
73
- };
74
- };
75
- async function ciInfo() {
76
- if (process.env.GITHUB_ACTIONS) {
77
- let pr;
78
- try {
79
- const json = JSON.parse(await fs.promises.readFile(process.env.GITHUB_EVENT_PATH, "utf8"));
80
- pr = { title: json.pull_request.title, number: json.pull_request.number, baseHash: json.pull_request.base.sha };
81
- } catch {
82
- }
83
- return {
84
- commitHref: `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/commit/${process.env.GITHUB_SHA}`,
85
- commitHash: process.env.GITHUB_SHA,
86
- prHref: pr ? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/pull/${pr.number}` : void 0,
87
- prTitle: pr?.title,
88
- prBaseHash: pr?.baseHash,
89
- buildHref: `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
90
- };
91
- }
92
- if (process.env.GITLAB_CI) {
93
- return {
94
- commitHref: `${process.env.CI_PROJECT_URL}/-/commit/${process.env.CI_COMMIT_SHA}`,
95
- commitHash: process.env.CI_COMMIT_SHA,
96
- buildHref: process.env.CI_JOB_URL,
97
- branch: process.env.CI_COMMIT_REF_NAME
98
- };
99
- }
100
- if (process.env.JENKINS_URL && process.env.BUILD_URL) {
101
- return {
102
- commitHref: process.env.BUILD_URL,
103
- commitHash: process.env.GIT_COMMIT,
104
- branch: process.env.GIT_BRANCH
105
- };
106
- }
107
- }
108
- async function gitCommitInfo(gitDir) {
109
- const separator = `---786eec917292---`;
110
- const tokens = [
111
- "%H",
112
- // commit hash
113
- "%h",
114
- // abbreviated commit hash
115
- "%s",
116
- // subject
117
- "%B",
118
- // raw body (unwrapped subject and body)
119
- "%an",
120
- // author name
121
- "%ae",
122
- // author email
123
- "%at",
124
- // author date, UNIX timestamp
125
- "%cn",
126
- // committer name
127
- "%ce",
128
- // committer email
129
- "%ct",
130
- // committer date, UNIX timestamp
131
- ""
132
- // branch
133
- ];
134
- const output = await runGit(`git log -1 --pretty=format:"${tokens.join(separator)}" && git rev-parse --abbrev-ref HEAD`, gitDir);
135
- if (!output)
136
- return void 0;
137
- const [hash, shortHash, subject, body, authorName, authorEmail, authorTime, committerName, committerEmail, committerTime, branch] = output.split(separator);
138
- return {
139
- shortHash,
140
- hash,
141
- subject,
142
- body,
143
- author: {
144
- name: authorName,
145
- email: authorEmail,
146
- time: +authorTime * 1e3
147
- },
148
- committer: {
149
- name: committerName,
150
- email: committerEmail,
151
- time: +committerTime * 1e3
152
- },
153
- branch: branch.trim()
154
- };
155
- }
156
- async function gitDiff(gitDir, ci) {
157
- const diffLimit = 1e5;
158
- if (ci?.prBaseHash) {
159
- await runGit(`git fetch origin ${ci.prBaseHash} --depth=1 --no-auto-maintenance --no-auto-gc --no-tags --no-recurse-submodules`, gitDir);
160
- const diff2 = await runGit(`git diff ${ci.prBaseHash} HEAD`, gitDir);
161
- if (diff2)
162
- return diff2.substring(0, diffLimit);
163
- }
164
- if (ci)
165
- return;
166
- const uncommitted = await runGit("git diff", gitDir);
167
- if (uncommitted === void 0) {
168
- return;
169
- }
170
- if (uncommitted)
171
- return uncommitted.substring(0, diffLimit);
172
- const diff = await runGit("git diff HEAD~1", gitDir);
173
- return diff?.substring(0, diffLimit);
174
- }
175
- async function runGit(command, cwd) {
176
- debug(`running "${command}"`);
177
- const start = (0, import_utils.monotonicTime)();
178
- const result = await (0, import_utils.spawnAsync)(
179
- command,
180
- [],
181
- { stdio: "pipe", cwd, timeout: GIT_OPERATIONS_TIMEOUT_MS, shell: true }
182
- );
183
- if ((0, import_utils.monotonicTime)() - start > GIT_OPERATIONS_TIMEOUT_MS) {
184
- print(`timeout of ${GIT_OPERATIONS_TIMEOUT_MS}ms exceeded while running "${command}"`);
185
- return;
186
- }
187
- if (result.code)
188
- debug(`failure, code=${result.code}
189
-
190
- ${result.stderr}`);
191
- else
192
- debug(`success`);
193
- return result.code ? void 0 : result.stdout.trim();
194
- }
195
- // Annotate the CommonJS export names for ESM import in node:
196
- 0 && (module.exports = {
197
- addGitCommitInfoPlugin
198
- });
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var plugins_exports = {};
20
- __export(plugins_exports, {
21
- webServer: () => import_webServerPlugin.webServer
22
- });
23
- module.exports = __toCommonJS(plugins_exports);
24
- var import_webServerPlugin = require("./webServerPlugin");
25
- // Annotate the CommonJS export names for ESM import in node:
26
- 0 && (module.exports = {
27
- webServer
28
- });