bindler 1.3.0 → 1.4.1

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
@@ -1649,11 +1649,33 @@ async function removeCommand(name, options) {
1649
1649
  try {
1650
1650
  removeProject(name);
1651
1651
  console.log(chalk11.green(`\u2713 Project "${name}" removed from registry`));
1652
- console.log(chalk11.dim(`
1652
+ if (options.apply) {
1653
+ console.log(chalk11.dim("\nApplying nginx configuration..."));
1654
+ const config = readConfig();
1655
+ try {
1656
+ writeNginxConfig(config);
1657
+ const testResult = testNginxConfig();
1658
+ if (testResult.success) {
1659
+ reloadNginx();
1660
+ console.log(chalk11.green("\u2713 Nginx configuration updated"));
1661
+ } else {
1662
+ console.log(chalk11.yellow("! Nginx config test failed, reload skipped"));
1663
+ }
1664
+ } catch (err) {
1665
+ console.log(chalk11.yellow(`! Failed to update nginx: ${err}`));
1666
+ console.log(chalk11.dim(" Try running: sudo bindler apply"));
1667
+ }
1668
+ } else {
1669
+ console.log(chalk11.dim(`
1653
1670
  Run ${chalk11.cyan("sudo bindler apply")} to update nginx configuration.`));
1654
- console.log(chalk11.yellow("\nNote: The project files and Cloudflare DNS routes were not removed."));
1655
- console.log(chalk11.dim(` Project path: ${project.path}`));
1656
- console.log(chalk11.dim(` To remove DNS route manually: cloudflared tunnel route dns --remove ${project.hostname}`));
1671
+ }
1672
+ console.log(chalk11.yellow("\nNote: Project files were not deleted."));
1673
+ console.log(chalk11.dim(` Path: ${project.path}`));
1674
+ if (!project.local) {
1675
+ console.log(chalk11.yellow("\nCloudflare DNS route was not removed."));
1676
+ console.log(chalk11.dim(" Remove it manually from the Cloudflare dashboard:"));
1677
+ console.log(chalk11.dim(" https://dash.cloudflare.com \u2192 DNS \u2192 Records \u2192 Delete the CNAME for " + project.hostname));
1678
+ }
1657
1679
  } catch (error) {
1658
1680
  console.error(chalk11.red(`Error: ${error instanceof Error ? error.message : error}`));
1659
1681
  process.exit(1);
@@ -1784,12 +1806,9 @@ async function applyCommand(options) {
1784
1806
  const envProjects = listProjectsForEnv(options.env);
1785
1807
  config = { ...config, projects: envProjects };
1786
1808
  }
1787
- if (config.projects.length === 0) {
1788
- console.log(chalk12.yellow("No projects registered. Nothing to apply."));
1789
- return;
1790
- }
1809
+ const hasProjects = config.projects.length > 0;
1791
1810
  console.log(chalk12.blue("Applying configuration...\n"));
1792
- if (!options.skipChecks) {
1811
+ if (hasProjects && !options.skipChecks) {
1793
1812
  console.log(chalk12.dim("Running preflight checks..."));
1794
1813
  const checkResult = runPreflightChecks(config);
1795
1814
  if (!checkResult.valid) {
@@ -1861,7 +1880,8 @@ Try running with sudo: ${chalk12.cyan("sudo bindler apply")}`));
1861
1880
  console.log(chalk12.yellow(" - Skipped nginx reload (--no-reload)"));
1862
1881
  }
1863
1882
  const isDirectMode = defaults.mode === "direct";
1864
- if (isDirectMode) {
1883
+ if (!hasProjects) {
1884
+ } else if (isDirectMode) {
1865
1885
  console.log(chalk12.dim("\n - Direct mode: skipping Cloudflare DNS routes"));
1866
1886
  } else if (!options.noCloudflare && defaults.applyCloudflareDnsRoutes) {
1867
1887
  console.log(chalk12.dim("\nConfiguring Cloudflare DNS routes..."));
@@ -1887,7 +1907,7 @@ Try running with sudo: ${chalk12.cyan("sudo bindler apply")}`));
1887
1907
  } else if (options.noCloudflare) {
1888
1908
  console.log(chalk12.dim("\n - Skipped Cloudflare DNS routes (--no-cloudflare)"));
1889
1909
  }
1890
- if (isDirectMode && defaults.sslEnabled && options.ssl !== false) {
1910
+ if (hasProjects && isDirectMode && defaults.sslEnabled && options.ssl !== false) {
1891
1911
  console.log(chalk12.dim("\nSetting up SSL certificates..."));
1892
1912
  const hostnames = config.projects.filter((p) => p.enabled !== false && !p.local).map((p) => p.hostname);
1893
1913
  if (hostnames.length === 0) {
@@ -1917,11 +1937,15 @@ Try running with sudo: ${chalk12.cyan("sudo bindler apply")}`));
1917
1937
  }
1918
1938
  }
1919
1939
  console.log(chalk12.green("\n\u2713 Configuration applied successfully!"));
1920
- console.log(chalk12.dim(`
1940
+ if (hasProjects) {
1941
+ console.log(chalk12.dim(`
1921
1942
  ${config.projects.length} project(s) configured:`));
1922
- for (const project of config.projects) {
1923
- const status = project.enabled !== false ? chalk12.green("enabled") : chalk12.yellow("disabled");
1924
- console.log(chalk12.dim(` - ${project.name} \u2192 ${project.hostname} (${status})`));
1943
+ for (const project of config.projects) {
1944
+ const status = project.enabled !== false ? chalk12.green("enabled") : chalk12.yellow("disabled");
1945
+ console.log(chalk12.dim(` - ${project.name} \u2192 ${project.hostname} (${status})`));
1946
+ }
1947
+ } else {
1948
+ console.log(chalk12.dim("\nNo projects configured. Nginx config cleared."));
1925
1949
  }
1926
1950
  }
1927
1951
 
@@ -2234,7 +2258,7 @@ async function infoCommand() {
2234
2258
  `));
2235
2259
  console.log(chalk15.white(" Manage multiple projects behind Cloudflare Tunnel"));
2236
2260
  console.log(chalk15.white(" with Nginx and PM2\n"));
2237
- console.log(chalk15.dim(" Version: ") + chalk15.white("1.3.0"));
2261
+ console.log(chalk15.dim(" Version: ") + chalk15.white("1.4.1"));
2238
2262
  console.log(chalk15.dim(" Author: ") + chalk15.white("alfaoz"));
2239
2263
  console.log(chalk15.dim(" License: ") + chalk15.white("MIT"));
2240
2264
  console.log(chalk15.dim(" GitHub: ") + chalk15.cyan("https://github.com/alfaoz/bindler"));
@@ -3876,28 +3900,28 @@ async function checkForUpdates() {
3876
3900
  const cache = readCache();
3877
3901
  const now = Date.now();
3878
3902
  if (now - cache.lastCheck < CHECK_INTERVAL) {
3879
- if (cache.latestVersion && compareVersions("1.3.0", cache.latestVersion) < 0) {
3903
+ if (cache.latestVersion && compareVersions("1.4.1", cache.latestVersion) < 0) {
3880
3904
  showUpdateMessage(cache.latestVersion);
3881
3905
  }
3882
3906
  return;
3883
3907
  }
3884
3908
  fetchLatestVersion().then((latestVersion) => {
3885
3909
  writeCache({ lastCheck: now, latestVersion });
3886
- if (latestVersion && compareVersions("1.3.0", latestVersion) < 0) {
3910
+ if (latestVersion && compareVersions("1.4.1", latestVersion) < 0) {
3887
3911
  showUpdateMessage(latestVersion);
3888
3912
  }
3889
3913
  });
3890
3914
  }
3891
3915
  function showUpdateMessage(latestVersion) {
3892
3916
  console.log("");
3893
- console.log(chalk29.yellow(` Update available: ${"1.3.0"} \u2192 ${latestVersion}`));
3917
+ console.log(chalk29.yellow(` Update available: ${"1.4.1"} \u2192 ${latestVersion}`));
3894
3918
  console.log(chalk29.dim(` Run: npm update -g bindler`));
3895
3919
  console.log("");
3896
3920
  }
3897
3921
 
3898
3922
  // src/cli.ts
3899
3923
  var program = new Command();
3900
- program.name("bindler").description("Manage multiple projects behind Cloudflare Tunnel with Nginx and PM2").version("1.3.0");
3924
+ program.name("bindler").description("Manage multiple projects behind Cloudflare Tunnel with Nginx and PM2").version("1.4.1");
3901
3925
  program.hook("preAction", async () => {
3902
3926
  try {
3903
3927
  initConfig();