@ooneex/cli 1.24.0 → 1.25.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
@@ -33598,6 +33598,127 @@ var ensureModule = async (module) => {
33598
33598
  };
33599
33599
 
33600
33600
  // src/commands/BenchmarkRunCommand.ts
33601
+ var dim = (s) => `\x1B[2m${s}\x1B[22m`;
33602
+ var bold = (s) => `\x1B[1m${s}\x1B[22m`;
33603
+ var cyan = (s) => `\x1B[36m${s}\x1B[39m`;
33604
+ var green = (s) => `\x1B[32m${s}\x1B[39m`;
33605
+ var yellow = (s) => `\x1B[33m${s}\x1B[39m`;
33606
+ var red = (s) => `\x1B[31m${s}\x1B[39m`;
33607
+ var magenta = (s) => `\x1B[35m${s}\x1B[39m`;
33608
+ function formatBytes(bytes) {
33609
+ if (bytes >= 1073741824)
33610
+ return `${(bytes / 1073741824).toFixed(2)} GB`;
33611
+ if (bytes >= 1048576)
33612
+ return `${(bytes / 1048576).toFixed(2)} MB`;
33613
+ if (bytes >= 1024)
33614
+ return `${(bytes / 1024).toFixed(2)} KB`;
33615
+ return `${bytes} B`;
33616
+ }
33617
+ function formatNumber(n) {
33618
+ return n.toLocaleString("en-US");
33619
+ }
33620
+ function formatLatency(ms) {
33621
+ if (ms >= 1000)
33622
+ return `${(ms / 1000).toFixed(2)} s`;
33623
+ return `${ms.toFixed(2)} ms`;
33624
+ }
33625
+ function printHeader(config, url, connections, duration) {
33626
+ const method = (config.method ?? "GET").toUpperCase();
33627
+ const title = config.name || "Benchmark";
33628
+ process.stdout.write(`
33629
+ `);
33630
+ process.stdout.write(` ${bold(cyan(title))}
33631
+ `);
33632
+ if (config.description) {
33633
+ process.stdout.write(` ${dim(config.description)}
33634
+ `);
33635
+ }
33636
+ process.stdout.write(` ${bold(method)} ${cyan(url)}
33637
+ `);
33638
+ process.stdout.write(` ${dim(`${connections} connections`)} ${dim("|")} ${dim(`${duration}s duration`)}
33639
+ `);
33640
+ process.stdout.write(`
33641
+ `);
33642
+ }
33643
+ function printResults(result) {
33644
+ const w = process.stdout.write.bind(process.stdout);
33645
+ const line = dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
33646
+ w(` ${bold(magenta("Latency"))}
33647
+ `);
33648
+ w(`${line}
33649
+ `);
33650
+ w(` ${dim("Avg")} ${bold(formatLatency(result.latency.average))}
33651
+ `);
33652
+ w(` ${dim("p50")} ${formatLatency(result.latency.p50)}
33653
+ `);
33654
+ w(` ${dim("p90")} ${formatLatency(result.latency.p90)}
33655
+ `);
33656
+ w(` ${dim("p97.5")} ${yellow(formatLatency(result.latency.p97_5))}
33657
+ `);
33658
+ w(` ${dim("p99")} ${yellow(formatLatency(result.latency.p99))}
33659
+ `);
33660
+ w(` ${dim("Max")} ${red(formatLatency(result.latency.max))}
33661
+ `);
33662
+ w(` ${dim("StdDev")} ${formatLatency(result.latency.stddev)}
33663
+ `);
33664
+ w(`
33665
+ `);
33666
+ w(` ${bold(magenta("Throughput"))}
33667
+ `);
33668
+ w(`${line}
33669
+ `);
33670
+ w(` ${dim("Req/Sec")} ${bold(formatNumber(Math.round(result.requests.average)))} avg`);
33671
+ w(` ${dim("(")}${formatNumber(result.requests.min)} ${dim("\u2014")} ${formatNumber(result.requests.max)}${dim(")")}
33672
+ `);
33673
+ w(` ${dim("Bytes/Sec")} ${bold(formatBytes(result.throughput.average))} avg`);
33674
+ w(` ${dim("(")}${formatBytes(result.throughput.min)} ${dim("\u2014")} ${formatBytes(result.throughput.max)}${dim(")")}
33675
+ `);
33676
+ w(`
33677
+ `);
33678
+ w(` ${bold(magenta("Summary"))}
33679
+ `);
33680
+ w(`${line}
33681
+ `);
33682
+ const totalRequests = result.requests.sent;
33683
+ const totalData = result.throughput.total;
33684
+ const dur = result.duration;
33685
+ w(` ${dim("URL")} ${cyan(result.url)}
33686
+ `);
33687
+ w(` ${dim("Total Requests")} ${bold(green(formatNumber(totalRequests)))}
33688
+ `);
33689
+ w(` ${dim("Total Data")} ${formatBytes(totalData)}
33690
+ `);
33691
+ w(` ${dim("Duration")} ${dur.toFixed(2)}s
33692
+ `);
33693
+ if (result.errors > 0) {
33694
+ w(` ${dim("Errors")} ${red(String(result.errors))}
33695
+ `);
33696
+ } else {
33697
+ w(` ${dim("Errors")} ${green("0")}
33698
+ `);
33699
+ }
33700
+ if (result.timeouts > 0) {
33701
+ w(` ${dim("Timeouts")} ${red(String(result.timeouts))}
33702
+ `);
33703
+ } else {
33704
+ w(` ${dim("Timeouts")} ${green("0")}
33705
+ `);
33706
+ }
33707
+ if (result.non2xx > 0) {
33708
+ w(` ${dim("Non-2xx")} ${red(formatNumber(result.non2xx))}
33709
+ `);
33710
+ } else {
33711
+ w(` ${dim("Non-2xx")} ${green("0")}
33712
+ `);
33713
+ }
33714
+ if (result.mismatches > 0) {
33715
+ w(` ${dim("Mismatches")} ${red(String(result.mismatches))}
33716
+ `);
33717
+ }
33718
+ w(`
33719
+ `);
33720
+ }
33721
+
33601
33722
  class BenchmarkRunCommand {
33602
33723
  getName() {
33603
33724
  return "benchmark:run";
@@ -33628,7 +33749,7 @@ class BenchmarkRunCommand {
33628
33749
  logger.error("Target is required. Use --target to specify the benchmark target.", undefined, {
33629
33750
  showTimestamp: false,
33630
33751
  showArrow: false,
33631
- useSymbol: false
33752
+ useSymbol: true
33632
33753
  });
33633
33754
  return;
33634
33755
  }
@@ -33647,7 +33768,7 @@ class BenchmarkRunCommand {
33647
33768
  logger.error(`No benchmark configuration found for target "${target}" in ${controllersLocalDir}`, undefined, {
33648
33769
  showTimestamp: false,
33649
33770
  showArrow: false,
33650
- useSymbol: false
33771
+ useSymbol: true
33651
33772
  });
33652
33773
  return;
33653
33774
  }
@@ -33661,36 +33782,40 @@ class BenchmarkRunCommand {
33661
33782
  const urlPath = this.buildUrl(config);
33662
33783
  const port = Bun.env.PORT ?? "80";
33663
33784
  const url = `http://localhost:${port}${urlPath}`;
33664
- logger.info(`Running benchmark: ${config.name || benchFile}`, undefined, {
33665
- showTimestamp: false,
33666
- showArrow: false,
33667
- useSymbol: false
33668
- });
33669
- if (config.description) {
33670
- logger.info(`Description: ${config.description}`, undefined, {
33671
- showTimestamp: false,
33672
- showArrow: false,
33673
- useSymbol: false
33674
- });
33675
- }
33785
+ const connections = config.connections ?? 10;
33786
+ const duration = config.duration ?? 10;
33787
+ printHeader(config, url, connections, duration);
33676
33788
  const opts = {
33677
33789
  url,
33678
- connections: config.connections ?? 10,
33679
- duration: config.duration ?? 10,
33790
+ connections,
33791
+ duration,
33680
33792
  method: config.method ?? "GET"
33681
33793
  };
33682
33794
  if (config.payload && Object.keys(config.payload).length > 0) {
33683
33795
  opts.body = JSON.stringify(config.payload);
33684
33796
  opts.headers = { "Content-Type": "application/json" };
33685
33797
  }
33686
- const result = await import_autocannon.default(opts);
33687
- logger.success(`Benchmark completed: ${config.name || benchFile}`, undefined, {
33688
- showTimestamp: false,
33689
- showArrow: false,
33690
- useSymbol: false
33798
+ const result = await new Promise((resolve, reject) => {
33799
+ const instance = import_autocannon.default(opts, (err, result2) => {
33800
+ if (err) {
33801
+ reject(err);
33802
+ } else {
33803
+ resolve(result2);
33804
+ }
33805
+ });
33806
+ import_autocannon.default.track(instance, {
33807
+ renderProgressBar: true,
33808
+ renderResultsTable: false,
33809
+ renderLatencyTable: false,
33810
+ progressBarString: ` ${dim("Progress")} [:bar] :percent ${dim(":elapsed/:eta")}`
33811
+ });
33812
+ process.once("SIGINT", () => {
33813
+ instance.stop();
33814
+ });
33691
33815
  });
33692
- process.stdout.write(`${import_autocannon.default.printResult(result)}
33816
+ process.stdout.write(`
33693
33817
  `);
33818
+ printResults(result);
33694
33819
  }
33695
33820
  }
33696
33821
  }
@@ -34419,7 +34544,7 @@ class MakeBenchmarkCommand {
34419
34544
  logger2.error(`Controller not found: ${controllerFilePath}`, undefined, {
34420
34545
  showTimestamp: false,
34421
34546
  showArrow: false,
34422
- useSymbol: false
34547
+ useSymbol: true
34423
34548
  });
34424
34549
  return;
34425
34550
  }
@@ -34451,7 +34576,7 @@ class MakeBenchmarkCommand {
34451
34576
  logger.success(`${join10(controllersLocalDir, benchmarkFileName)} created successfully`, undefined, {
34452
34577
  showTimestamp: false,
34453
34578
  showArrow: false,
34454
- useSymbol: false
34579
+ useSymbol: true
34455
34580
  });
34456
34581
  }
34457
34582
  }
@@ -50230,7 +50355,7 @@ class MigrationUpCommand {
50230
50355
  logger.warn("No modules with migrations found", undefined, {
50231
50356
  showTimestamp: false,
50232
50357
  showArrow: false,
50233
- useSymbol: false
50358
+ useSymbol: true
50234
50359
  });
50235
50360
  return;
50236
50361
  }
@@ -50249,7 +50374,7 @@ class MigrationUpCommand {
50249
50374
  logger.warn("No modules with migrations found", undefined, {
50250
50375
  showTimestamp: false,
50251
50376
  showArrow: false,
50252
- useSymbol: false
50377
+ useSymbol: true
50253
50378
  });
50254
50379
  return;
50255
50380
  }
@@ -50258,7 +50383,7 @@ class MigrationUpCommand {
50258
50383
  logger.info(`Running migrations for ${name}...`, undefined, {
50259
50384
  showTimestamp: false,
50260
50385
  showArrow: false,
50261
- useSymbol: false
50386
+ useSymbol: true
50262
50387
  });
50263
50388
  const args = ["bun", "run", migrationUpPath];
50264
50389
  if (options.drop) {
@@ -50274,13 +50399,13 @@ class MigrationUpCommand {
50274
50399
  logger.success(`Migrations completed for ${name}`, undefined, {
50275
50400
  showTimestamp: false,
50276
50401
  showArrow: false,
50277
- useSymbol: false
50402
+ useSymbol: true
50278
50403
  });
50279
50404
  } else {
50280
50405
  logger.error(`Migrations failed for ${name} (exit code: ${exitCode})`, undefined, {
50281
50406
  showTimestamp: false,
50282
50407
  showArrow: false,
50283
- useSymbol: false
50408
+ useSymbol: true
50284
50409
  });
50285
50410
  }
50286
50411
  }
@@ -50435,7 +50560,7 @@ class SeedRunCommand {
50435
50560
  logger.warn("No modules with seeds found", undefined, {
50436
50561
  showTimestamp: false,
50437
50562
  showArrow: false,
50438
- useSymbol: false
50563
+ useSymbol: true
50439
50564
  });
50440
50565
  return;
50441
50566
  }
@@ -50454,7 +50579,7 @@ class SeedRunCommand {
50454
50579
  logger.warn("No modules with seeds found", undefined, {
50455
50580
  showTimestamp: false,
50456
50581
  showArrow: false,
50457
- useSymbol: false
50582
+ useSymbol: true
50458
50583
  });
50459
50584
  return;
50460
50585
  }
@@ -50463,7 +50588,7 @@ class SeedRunCommand {
50463
50588
  logger.info(`Running seeds for ${name}...`, undefined, {
50464
50589
  showTimestamp: false,
50465
50590
  showArrow: false,
50466
- useSymbol: false
50591
+ useSymbol: true
50467
50592
  });
50468
50593
  const args = ["bun", "run", seedRunPath];
50469
50594
  if (options.drop) {
@@ -50479,13 +50604,13 @@ class SeedRunCommand {
50479
50604
  logger.success(`Seeds completed for ${name}`, undefined, {
50480
50605
  showTimestamp: false,
50481
50606
  showArrow: false,
50482
- useSymbol: false
50607
+ useSymbol: true
50483
50608
  });
50484
50609
  } else {
50485
50610
  logger.error(`Seeds failed for ${name} (exit code: ${exitCode})`, undefined, {
50486
50611
  showTimestamp: false,
50487
50612
  showArrow: false,
50488
- useSymbol: false
50613
+ useSymbol: true
50489
50614
  });
50490
50615
  }
50491
50616
  }
@@ -50497,4 +50622,4 @@ SeedRunCommand = __legacyDecorateClassTS([
50497
50622
  // src/index.ts
50498
50623
  await run();
50499
50624
 
50500
- //# debugId=41F87182B7D4D33B64756E2164756E21
50625
+ //# debugId=C8D32DBA97979F1764756E2164756E21