browsermation 0.0.67 → 0.0.69

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/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  This is the PUBLIC NPM package for Browsermation's testing utilities.
4
4
 
5
+ ## Dev
6
+
7
+ ```bash
8
+ npm run build:start -- tunnel -- --port 8080
9
+ ```
10
+
5
11
  ## Installation
6
12
 
7
13
  To install the package, run:
package/dist/bin/cli.js CHANGED
@@ -13417,7 +13417,7 @@ var require_form_data = __commonJS({
13417
13417
  var parseUrl = require("url").parse;
13418
13418
  var fs = require("fs");
13419
13419
  var Stream2 = require("stream").Stream;
13420
- var crypto3 = require("crypto");
13420
+ var crypto2 = require("crypto");
13421
13421
  var mime = require_mime_types();
13422
13422
  var asynckit = require_asynckit();
13423
13423
  var setToStringTag = require_es_set_tostringtag();
@@ -13623,7 +13623,7 @@ var require_form_data = __commonJS({
13623
13623
  return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
13624
13624
  };
13625
13625
  FormData3.prototype._generateBoundary = function() {
13626
- this._boundary = "--------------------------" + crypto3.randomBytes(12).toString("hex");
13626
+ this._boundary = "--------------------------" + crypto2.randomBytes(12).toString("hex");
13627
13627
  };
13628
13628
  FormData3.prototype.getLengthSync = function() {
13629
13629
  var knownLength = this._overheadLength + this._valueLength;
@@ -42258,7 +42258,7 @@ var {
42258
42258
  // package.json
42259
42259
  var package_default = {
42260
42260
  name: "browsermation",
42261
- version: "0.0.67",
42261
+ version: "0.0.69",
42262
42262
  description: "The testing platform for Playwright by Browsermation.",
42263
42263
  main: "./dist/index.js",
42264
42264
  types: "./dist/index.d.ts",
@@ -46633,10 +46633,10 @@ async function upload(zipBuffer, shardNumber, totalShards, playwrightConfig, opt
46633
46633
  // src/tunnel.ts
46634
46634
  var import_node_child_process = require("node:child_process");
46635
46635
  function startTunnel(tunnelProcess, options) {
46636
- if (!process.env.BM_API_KEY) {
46636
+ if (!process.env.BM_API_TOKEN) {
46637
46637
  console.error(
46638
46638
  source_default.red.bold(
46639
- "\u274C Error: BM_API_KEY environment variable is not set. Please set it to your tunnel token."
46639
+ "\u274C Error: BM_API_TOKEN environment variable is not set. Please set it to your tunnel token."
46640
46640
  )
46641
46641
  );
46642
46642
  process.exit(1);
@@ -46644,17 +46644,13 @@ function startTunnel(tunnelProcess, options) {
46644
46644
  if (!options?.port) {
46645
46645
  console.error(
46646
46646
  source_default.red.bold(
46647
- "\u274C Error: Please provide a port to expose via the tunnel using the --tunnel or --port option."
46647
+ "\u274C Error: Please provide a port to expose via the tunnel using the --port option."
46648
46648
  )
46649
46649
  );
46650
46650
  process.exit(1);
46651
46651
  }
46652
- let defaultDomain = "browsermationtunnel.com";
46653
- if (options?.region === "eu") {
46654
- defaultDomain = "browsermationtunnel.eu";
46655
- }
46656
- const tunnelDomain = `${options.subdomain || crypto.randomUUID()}.${defaultDomain}`;
46657
- tunnelProcess = (0, import_node_child_process.spawn)("ssh", [
46652
+ const defaultDomain = "browsermationtunnel.com";
46653
+ const args = [
46658
46654
  "-o",
46659
46655
  "StrictHostKeyChecking=no",
46660
46656
  "-o",
@@ -46665,13 +46661,13 @@ function startTunnel(tunnelProcess, options) {
46665
46661
  "-p",
46666
46662
  "2200",
46667
46663
  "http",
46668
- "--proxy_name",
46669
- tunnelDomain,
46670
- "--custom_domain",
46671
- tunnelDomain,
46672
46664
  "--user",
46673
- process.env.BM_API_KEY || ""
46674
- ]);
46665
+ process.env.BM_API_TOKEN || ""
46666
+ ];
46667
+ if (options.host) {
46668
+ args.push("--host-header-rewrite", options.host);
46669
+ }
46670
+ tunnelProcess = (0, import_node_child_process.spawn)("ssh", args);
46675
46671
  process.on("SIGINT", function() {
46676
46672
  console.log("\nGracefully shutting down from SIGINT (Ctrl+C)");
46677
46673
  if (tunnelProcess) {
@@ -46684,17 +46680,31 @@ function startTunnel(tunnelProcess, options) {
46684
46680
  if (process.env.BM_DEBUG) {
46685
46681
  console.log(`stdout: ${data}`);
46686
46682
  }
46683
+ if (data.toString().includes("RemoteAddress:")) {
46684
+ const domain = data.toString().split("\n").map((line) => line.trim()).find((line) => line.startsWith("RemoteAddress:")).replace("RemoteAddress: ", "");
46685
+ if (domain) {
46686
+ console.log(
46687
+ source_default.green.bold(
46688
+ `\u2705 Tunnel is running! Access your application at: https://${domain}`
46689
+ )
46690
+ );
46691
+ }
46692
+ }
46687
46693
  });
46688
46694
  tunnelProcess?.stderr?.on("data", (data) => {
46695
+ if (data.toString().includes("Permanently added")) {
46696
+ return;
46697
+ }
46698
+ if (data.toString().includes("closed by remote host.")) {
46699
+ console.error(
46700
+ source_default.red.bold(
46701
+ "\u274C Error: Please check that your BM_API_TOKEN is correct and has permissions to create tunnels."
46702
+ )
46703
+ );
46704
+ process.exit(1);
46705
+ }
46689
46706
  console.error(`stderr: ${data}`);
46690
46707
  });
46691
- const tunnelUrl = `https://${tunnelDomain}`;
46692
- console.log(
46693
- source_default.green.bold(
46694
- `\u2705 Tunnel setup complete. You can now access your project at: ${tunnelUrl}`
46695
- )
46696
- );
46697
- return { tunnelProcess, tunnelUrl };
46698
46708
  }
46699
46709
 
46700
46710
  // src/bin/cli.ts
@@ -46734,7 +46744,7 @@ async function downloadFile(fileUrl, outputLocationPath) {
46734
46744
 
46735
46745
  // src/bin/cli.ts
46736
46746
  var program2 = new Command().name("browsermation").version(package_default.version).description(package_default.description);
46737
- program2.command("tunnel").option("-p, --port <port>").action(async (options) => {
46747
+ program2.command("tunnel").option("-p, --port <port>").option("-h, --host <host>").action(async (options) => {
46738
46748
  console.log(source_default.blue(`\u{1F680} Starting BrowserMation Tunnel...`));
46739
46749
  let tunnelProcess = null;
46740
46750
  await startTunnel(tunnelProcess, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browsermation",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "description": "The testing platform for Playwright by Browsermation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",