@stacksjs/buddy 0.70.97 → 0.70.99
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/commands/dev.js +36 -9
- package/package.json +1 -1
package/dist/commands/dev.js
CHANGED
|
@@ -187,7 +187,7 @@ export function dev(buddy) {
|
|
|
187
187
|
onUnknownSubcommand(buddy, "dev");
|
|
188
188
|
}
|
|
189
189
|
export async function startDevelopmentServer(_options, _startTime) {
|
|
190
|
-
const options = _options, startedAt = _startTime, appUrl = process.env.APP_URL, nativeMode = options.native === !0, proxyManagedExternally = process.env.STACKS_PROXY_MANAGED === "1", frontendPort = Number(process.env.PORT) || 3000, apiPort = Number(process.env.PORT_API) || 3008, docsPort = Number(process.env.PORT_DOCS) || 3006, dashboardPort = Number(process.env.PORT_ADMIN) || 3002, includeDashboard = process.env.STACKS_DEV_DASHBOARD === "1", appLooksCustom = !nativeMode && appUrl && appUrl !== "localhost" && !appUrl.includes("localhost:"), domain = appLooksCustom ? appUrl.replace(/^https?:\/\//, "") : null, hasCustomDomain = appLooksCustom && !proxyManagedExternally, dashboardDomain = domain ? `dashboard.${domain}` : null, frontendUrl = domain ? `https://${domain}` : `http://localhost:${frontendPort}`, apiUrl = domain ? `https://${domain}/api` : `http://localhost:${apiPort}`, docsUrl = domain ? `https://${domain}/docs` : `http://localhost:${docsPort}`, dashboardUrl = dashboardDomain ? `https://${dashboardDomain}` : `http://localhost:${dashboardPort}`, managedPorts = [
|
|
190
|
+
const options = _options, startedAt = _startTime, appUrl = process.env.APP_URL, nativeMode = options.native === !0, proxyManagedExternally = process.env.STACKS_PROXY_MANAGED === "1", frontendPort = Number(process.env.PORT) || 3000, apiPort = Number(process.env.PORT_API) || 3008, docsPort = Number(process.env.PORT_DOCS) || 3006, dashboardPort = Number(process.env.PORT_ADMIN) || 3002, includeDashboard = process.env.STACKS_DEV_DASHBOARD === "1", appLooksCustom = !nativeMode && appUrl && appUrl !== "localhost" && !appUrl.includes("localhost:"), domain = appLooksCustom ? appUrl.replace(/^https?:\/\//, "") : null, isLocalDevTld = (host) => host === "localhost" || host.endsWith(".localhost") || host.endsWith(".test") || host.endsWith(".invalid"), domainIsPublic = Boolean(domain) && process.env.STACKS_DEV_ALLOW_PUBLIC_DOMAIN !== "1" && !isLocalDevTld(domain) && (await dns.resolve4(domain).catch(() => [])).some((address) => !address.startsWith("127.")), hasCustomDomain = appLooksCustom && !proxyManagedExternally && !domainIsPublic, dashboardDomain = domain ? `dashboard.${domain}` : null, frontendUrl = domain ? `https://${domain}` : `http://localhost:${frontendPort}`, apiUrl = domain ? `https://${domain}/api` : `http://localhost:${apiPort}`, docsUrl = domain ? `https://${domain}/docs` : `http://localhost:${docsPort}`, dashboardUrl = dashboardDomain ? `https://${dashboardDomain}` : `http://localhost:${dashboardPort}`, managedPorts = [
|
|
191
191
|
frontendPort,
|
|
192
192
|
apiPort,
|
|
193
193
|
docsPort,
|
|
@@ -354,23 +354,21 @@ function printDevReadyBanner(input) {
|
|
|
354
354
|
domain,
|
|
355
355
|
dashboardPort,
|
|
356
356
|
dashboardDomain
|
|
357
|
-
} = input, verbose = options.verbose ?? !1,
|
|
357
|
+
} = input, verbose = options.verbose ?? !1, useProxy = hasCustomDomain && proxyReachable, feUrl = `http://localhost:${frontendPort}`, apUrl = `http://localhost:${apiPort}`, dcUrl = `http://localhost:${docsPort}`, dbUrl = `http://localhost:${dashboardPort}`, blogUrl = `${feUrl}/blog`;
|
|
358
358
|
console.log();
|
|
359
359
|
console.log(` ${green("\u279C")} ${bold("Frontend")}: ${cyan(feUrl)}`);
|
|
360
|
-
if (showLocalUrls && useProxy)
|
|
361
|
-
console.log(` ${dim("\u279C")} ${dim("Local")}: ${dim(`http://localhost:${frontendPort}`)}`);
|
|
362
360
|
if (nativeMode)
|
|
363
361
|
console.log(` ${green("\u279C")} ${bold("Native")}: ${cyan(`Craft \u2192 http://localhost:${frontendPort}`)}`);
|
|
364
362
|
console.log(` ${green("\u279C")} ${bold("API")}: ${cyan(apUrl)}`);
|
|
365
|
-
if (showLocalUrls && useProxy)
|
|
366
|
-
console.log(` ${dim("\u279C")} ${dim("Local API")}: ${dim(`http://localhost:${apiPort}`)}`);
|
|
367
363
|
console.log(` ${green("\u279C")} ${bold("Docs")}: ${cyan(dcUrl)}`);
|
|
368
|
-
if (showLocalUrls && useProxy)
|
|
369
|
-
console.log(` ${dim("\u279C")} ${dim("Local docs")}: ${dim(`http://localhost:${docsPort}`)}`);
|
|
370
364
|
if (blogIsConfigured())
|
|
371
365
|
console.log(` ${green("\u279C")} ${bold("Blog")}: ${cyan(blogUrl)}`);
|
|
372
366
|
if (includeDashboard)
|
|
373
|
-
console.log(` ${green("\u279C")} ${bold("Dashboard")}: ${cyan(
|
|
367
|
+
console.log(` ${green("\u279C")} ${bold("Dashboard")}: ${cyan(dbUrl)}`);
|
|
368
|
+
if (useProxy && domain)
|
|
369
|
+
console.log(` ${dim("\u279C")} ${dim("Proxy")}: ${dim(`${frontendUrl} (local HTTPS via rpx)`)}`);
|
|
370
|
+
if (useProxy && includeDashboard && dashboardDomain)
|
|
371
|
+
console.log(` ${dim("\u279C")} ${dim("Proxy")}: ${dim(`${dashboardUrl} (local HTTPS via rpx)`)}`);
|
|
374
372
|
if (isComingSoonMode()) {
|
|
375
373
|
console.log();
|
|
376
374
|
console.log(` ${yellow("\u25CF")} ${bold(yellow("Coming soon mode"))} ${dim("\u2014 visitors see the holding page; bypass with the coming-soon secret.")}`);
|
|
@@ -813,11 +811,40 @@ async function unregisterRpxProxies(ids) {
|
|
|
813
811
|
await removeEntry(id).catch(() => {});
|
|
814
812
|
} catch {}
|
|
815
813
|
}
|
|
814
|
+
async function removeStalePublicDomainOverrides(domain, includeDashboard, verbose) {
|
|
815
|
+
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);
|
|
816
|
+
if (staleHosts.length > 0) {
|
|
817
|
+
await removeHosts(staleHosts, verbose).catch(() => {});
|
|
818
|
+
if ((await checkHosts(staleHosts, verbose).catch(() => staleHosts.map(() => !0))).some(Boolean))
|
|
819
|
+
log.warn(`Stale /etc/hosts entries still point ${staleHosts.join(", ")} at loopback. Remove them with: sudo nano /etc/hosts`);
|
|
820
|
+
else
|
|
821
|
+
log.info(`Removed stale /etc/hosts entries for ${staleHosts.join(", ")} (left by a previous dev session)`);
|
|
822
|
+
}
|
|
823
|
+
if (process.platform !== "darwin")
|
|
824
|
+
return;
|
|
825
|
+
const labels = domain.split("."), basename = labels.length >= 2 ? labels.slice(-2).join(".") : domain, resolverPath = resolverFilePath(basename);
|
|
826
|
+
let isRpxManaged = !1;
|
|
827
|
+
try {
|
|
828
|
+
isRpxManaged = contentLooksLikeRpxResolver(readFileSync(resolverPath, "utf8"));
|
|
829
|
+
} catch {}
|
|
830
|
+
if (!isRpxManaged)
|
|
831
|
+
return;
|
|
832
|
+
const quotedPath = `'${resolverPath.replace(/'/g, "'\\''")}'`, rm = process.env.SUDO_PASSWORD ? `printf '%s
|
|
833
|
+
' "$SUDO_PASSWORD" | sudo -S rm -f ${quotedPath}` : `sudo -n rm -f ${quotedPath}`;
|
|
834
|
+
try {
|
|
835
|
+
execSync(rm, { stdio: ["pipe", "ignore", "ignore"] });
|
|
836
|
+
log.info(`Removed stale rpx DNS resolver ${resolverPath} (left by a previous dev session)`);
|
|
837
|
+
execSync("sudo -n dscacheutil -flushcache; sudo -n killall -HUP mDNSResponder; true", { stdio: ["pipe", "ignore", "ignore"] });
|
|
838
|
+
} catch {
|
|
839
|
+
log.warn(`A stale rpx DNS resolver still hijacks ${domain}. Remove it with: sudo rm ${resolverPath}`);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
816
842
|
async function prepareRpxTlsForDev(input) {
|
|
817
843
|
const { domain, includeDashboard, options } = input, verbose = options.verbose ?? !1;
|
|
818
844
|
if (process.env.STACKS_DEV_ALLOW_PUBLIC_DOMAIN !== "1") {
|
|
819
845
|
if ((await dns.resolve4(domain).catch(() => [])).some((address) => !address.startsWith("127."))) {
|
|
820
846
|
log.warn(`Skipping local DNS override for public domain ${domain}; use a .localhost/.test domain for development`);
|
|
847
|
+
await removeStalePublicDomainOverrides(domain, includeDashboard, verbose);
|
|
821
848
|
return;
|
|
822
849
|
}
|
|
823
850
|
}
|