bindler 1.6.1 → 1.6.2

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
@@ -1629,6 +1629,10 @@ async function statusCommand() {
1629
1629
 
1630
1630
  // src/commands/start.ts
1631
1631
  import chalk6 from "chalk";
1632
+ var CRASH_CHECK_DELAY = 2500;
1633
+ function sleep(ms) {
1634
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
1635
+ }
1632
1636
  async function startCommand(name, options) {
1633
1637
  if (options.all) {
1634
1638
  const projects = listProjects();
@@ -1646,9 +1650,23 @@ async function startCommand(name, options) {
1646
1650
  console.log(chalk6.red(` \u2717 ${result2.name}: ${result2.error}`));
1647
1651
  }
1648
1652
  }
1649
- const succeeded = results.filter((r) => r.success).length;
1650
- console.log(chalk6.dim(`
1651
- ${succeeded}/${results.length} started successfully`));
1653
+ console.log(chalk6.dim("\nChecking for crashes..."));
1654
+ await sleep(CRASH_CHECK_DELAY);
1655
+ const crashed = [];
1656
+ for (const project2 of npmProjects) {
1657
+ const process2 = getProcessByName(project2.name);
1658
+ if (process2 && process2.status !== "online") {
1659
+ crashed.push(project2.name);
1660
+ }
1661
+ }
1662
+ if (crashed.length > 0) {
1663
+ console.log(chalk6.red(`
1664
+ \u2717 ${crashed.length} project(s) crashed: ${crashed.join(", ")}`));
1665
+ console.log(chalk6.dim(` Run: bindler logs <name> to see errors`));
1666
+ } else {
1667
+ const succeeded = results.filter((r) => r.success).length;
1668
+ console.log(chalk6.green(`\u2713 ${succeeded}/${results.length} running`));
1669
+ }
1652
1670
  return;
1653
1671
  }
1654
1672
  if (!name) {
@@ -1667,14 +1685,27 @@ ${succeeded}/${results.length} started successfully`));
1667
1685
  }
1668
1686
  console.log(chalk6.blue(`Starting ${name}...`));
1669
1687
  const result = startProject(project);
1670
- if (result.success) {
1671
- console.log(chalk6.green(`\u2713 ${name} started successfully`));
1672
- console.log(chalk6.dim(` Port: ${project.port}`));
1673
- console.log(chalk6.dim(` URL: https://${project.hostname}`));
1674
- } else {
1688
+ if (!result.success) {
1675
1689
  console.error(chalk6.red(`\u2717 Failed to start ${name}: ${result.error}`));
1676
1690
  process.exit(1);
1677
1691
  }
1692
+ console.log(chalk6.dim("Waiting for process to stabilize..."));
1693
+ await sleep(CRASH_CHECK_DELAY);
1694
+ const processStatus = getProcessByName(name);
1695
+ if (!processStatus || processStatus.status !== "online") {
1696
+ console.error(chalk6.red(`
1697
+ \u2717 ${name} crashed immediately after starting`));
1698
+ console.log(chalk6.dim("\nShowing recent logs:\n"));
1699
+ console.log(chalk6.dim("\u2500".repeat(50)));
1700
+ await showLogs(name, false, 30);
1701
+ console.log(chalk6.dim("\u2500".repeat(50)));
1702
+ console.log(chalk6.yellow(`
1703
+ Fix the error and try again: bindler start ${name}`));
1704
+ process.exit(1);
1705
+ }
1706
+ console.log(chalk6.green(`\u2713 ${name} started successfully`));
1707
+ console.log(chalk6.dim(` Port: ${project.port}`));
1708
+ console.log(chalk6.dim(` URL: https://${project.hostname}`));
1678
1709
  }
1679
1710
 
1680
1711
  // src/commands/stop.ts
@@ -2338,7 +2369,7 @@ async function infoCommand() {
2338
2369
  `));
2339
2370
  console.log(chalk15.white(" Manage multiple projects behind Cloudflare Tunnel"));
2340
2371
  console.log(chalk15.white(" with Nginx and PM2\n"));
2341
- console.log(chalk15.dim(" Version: ") + chalk15.white("1.6.1"));
2372
+ console.log(chalk15.dim(" Version: ") + chalk15.white("1.6.2"));
2342
2373
  console.log(chalk15.dim(" Author: ") + chalk15.white("alfaoz"));
2343
2374
  console.log(chalk15.dim(" License: ") + chalk15.white("MIT"));
2344
2375
  console.log(chalk15.dim(" GitHub: ") + chalk15.cyan("https://github.com/alfaoz/bindler"));
@@ -4080,28 +4111,28 @@ async function checkForUpdates() {
4080
4111
  const cache = readCache();
4081
4112
  const now = Date.now();
4082
4113
  if (now - cache.lastCheck < CHECK_INTERVAL) {
4083
- if (cache.latestVersion && compareVersions("1.6.1", cache.latestVersion) > 0) {
4114
+ if (cache.latestVersion && compareVersions("1.6.2", cache.latestVersion) > 0) {
4084
4115
  showUpdateMessage(cache.latestVersion);
4085
4116
  }
4086
4117
  return;
4087
4118
  }
4088
4119
  fetchLatestVersion().then((latestVersion) => {
4089
4120
  writeCache({ lastCheck: now, latestVersion });
4090
- if (latestVersion && compareVersions("1.6.1", latestVersion) > 0) {
4121
+ if (latestVersion && compareVersions("1.6.2", latestVersion) > 0) {
4091
4122
  showUpdateMessage(latestVersion);
4092
4123
  }
4093
4124
  });
4094
4125
  }
4095
4126
  function showUpdateMessage(latestVersion) {
4096
4127
  console.log("");
4097
- console.log(chalk30.yellow(` Update available: ${"1.6.1"} \u2192 ${latestVersion}`));
4128
+ console.log(chalk30.yellow(` Update available: ${"1.6.2"} \u2192 ${latestVersion}`));
4098
4129
  console.log(chalk30.dim(` Run: npm update -g bindler`));
4099
4130
  console.log("");
4100
4131
  }
4101
4132
 
4102
4133
  // src/cli.ts
4103
4134
  var program = new Command();
4104
- program.name("bindler").description("Manage multiple projects behind Cloudflare Tunnel with Nginx and PM2").version("1.6.1");
4135
+ program.name("bindler").description("Manage multiple projects behind Cloudflare Tunnel with Nginx and PM2").version("1.6.2");
4105
4136
  program.hook("preAction", async () => {
4106
4137
  try {
4107
4138
  initConfig();