@stacksjs/buddy 0.70.96 → 0.70.98

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.
@@ -813,11 +813,40 @@ async function unregisterRpxProxies(ids) {
813
813
  await removeEntry(id).catch(() => {});
814
814
  } catch {}
815
815
  }
816
+ async function removeStalePublicDomainOverrides(domain, includeDashboard, verbose) {
817
+ const { checkHosts, removeHosts, resolverFilePath, contentLooksLikeRpxResolver } = await importDevelopmentRpx(), hosts = [domain, ...includeDashboard ? [`dashboard.${domain}`] : []], present = await checkHosts(hosts, verbose).catch(() => hosts.map(() => !1)), staleHosts = hosts.filter((_, i) => present[i] === !0);
818
+ if (staleHosts.length > 0) {
819
+ await removeHosts(staleHosts, verbose).catch(() => {});
820
+ if ((await checkHosts(staleHosts, verbose).catch(() => staleHosts.map(() => !0))).some(Boolean))
821
+ log.warn(`Stale /etc/hosts entries still point ${staleHosts.join(", ")} at loopback. Remove them with: sudo nano /etc/hosts`);
822
+ else
823
+ log.info(`Removed stale /etc/hosts entries for ${staleHosts.join(", ")} (left by a previous dev session)`);
824
+ }
825
+ if (process.platform !== "darwin")
826
+ return;
827
+ const labels = domain.split("."), basename = labels.length >= 2 ? labels.slice(-2).join(".") : domain, resolverPath = resolverFilePath(basename);
828
+ let isRpxManaged = !1;
829
+ try {
830
+ isRpxManaged = contentLooksLikeRpxResolver(readFileSync(resolverPath, "utf8"));
831
+ } catch {}
832
+ if (!isRpxManaged)
833
+ return;
834
+ const quotedPath = `'${resolverPath.replace(/'/g, "'\\''")}'`, rm = process.env.SUDO_PASSWORD ? `printf '%s
835
+ ' "$SUDO_PASSWORD" | sudo -S rm -f ${quotedPath}` : `sudo -n rm -f ${quotedPath}`;
836
+ try {
837
+ execSync(rm, { stdio: ["pipe", "ignore", "ignore"] });
838
+ log.info(`Removed stale rpx DNS resolver ${resolverPath} (left by a previous dev session)`);
839
+ execSync("sudo -n dscacheutil -flushcache; sudo -n killall -HUP mDNSResponder; true", { stdio: ["pipe", "ignore", "ignore"] });
840
+ } catch {
841
+ log.warn(`A stale rpx DNS resolver still hijacks ${domain}. Remove it with: sudo rm ${resolverPath}`);
842
+ }
843
+ }
816
844
  async function prepareRpxTlsForDev(input) {
817
845
  const { domain, includeDashboard, options } = input, verbose = options.verbose ?? !1;
818
846
  if (process.env.STACKS_DEV_ALLOW_PUBLIC_DOMAIN !== "1") {
819
847
  if ((await dns.resolve4(domain).catch(() => [])).some((address) => !address.startsWith("127."))) {
820
848
  log.warn(`Skipping local DNS override for public domain ${domain}; use a .localhost/.test domain for development`);
849
+ await removeStalePublicDomainOverrides(domain, includeDashboard, verbose);
821
850
  return;
822
851
  }
823
852
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.96",
5
+ "version": "0.70.98",
6
6
  "description": "Meet Buddy. The Stacks runtime.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [