mirror of
https://github.com/plebbit/seedit.git
synced 2026-05-19 14:19:24 -04:00
chore(portless): upgrade local dev URLs
This commit is contained in:
@@ -19,7 +19,7 @@ If either is missing, report back asking for the missing information.
|
||||
|
||||
### Step 1: Use the Existing Dev Server
|
||||
|
||||
Use the already-running local dev server at `http://seedit.localhost:1355` unless the parent agent gives you a different URL.
|
||||
Use the already-running local dev server at `https://seedit.localhost` unless the parent agent gives you a different URL.
|
||||
|
||||
Do not start, restart, or stop the dev server yourself. If the app is unreachable, report the failure and stop.
|
||||
|
||||
@@ -28,9 +28,9 @@ Do not start, restart, or stop the dev server yourself. If the app is unreachabl
|
||||
Use playwright-cli to check the relevant page in all three browser engines with separate sessions:
|
||||
|
||||
```bash
|
||||
playwright-cli -s=verify-chrome open http://seedit.localhost:1355 --browser=chrome
|
||||
playwright-cli -s=verify-firefox open http://seedit.localhost:1355 --browser=firefox
|
||||
playwright-cli -s=verify-webkit open http://seedit.localhost:1355 --browser=webkit
|
||||
playwright-cli -s=verify-chrome open https://seedit.localhost --browser=chrome
|
||||
playwright-cli -s=verify-firefox open https://seedit.localhost --browser=firefox
|
||||
playwright-cli -s=verify-webkit open https://seedit.localhost --browser=webkit
|
||||
```
|
||||
|
||||
Navigate each engine session to the specific page/route where the change should be visible.
|
||||
@@ -60,7 +60,7 @@ playwright-cli -s=verify-webkit snapshot
|
||||
## Browser Check Results
|
||||
|
||||
### Page Tested
|
||||
- URL: http://seedit.localhost:1355/...
|
||||
- URL: https://seedit.localhost/...
|
||||
|
||||
### What Was Checked
|
||||
- description of each verification
|
||||
|
||||
@@ -4,7 +4,7 @@ model: haiku
|
||||
description: Performance profiler that browses seedit routes via playwright-cli, collecting Web Vitals and React rerender data via react-scan. Returns a structured issues list for a batch of routes. Use proactively when profiling browsing performance, finding bottlenecks, or diagnosing excessive React rerenders.
|
||||
---
|
||||
|
||||
You are a performance profiling agent for the seedit React app at http://seedit.localhost:1355. You use playwright-cli to automate browsing and collect both browser-level (Web Vitals) and React-level (commit counts, per-component render data via react-scan) performance metrics.
|
||||
You are a performance profiling agent for the seedit React app at https://seedit.localhost. You use playwright-cli to automate browsing and collect both browser-level (Web Vitals) and React-level (commit counts, per-component render data via react-scan) performance metrics.
|
||||
|
||||
**MUST: Never start a dev server.** The orchestrator guarantees one is already running. If the app is unreachable, report the error and stop — do not run `yarn start` or any other server command.
|
||||
|
||||
@@ -49,7 +49,7 @@ playwright-cli -s=SESSION run-code "async page => await page.addInitScript(() =>
|
||||
`window.__PROFILING__=true` tells react-scan to disable its toolbar and sounds during automated profiling.
|
||||
|
||||
```bash
|
||||
playwright-cli -s=SESSION goto http://seedit.localhost:1355
|
||||
playwright-cli -s=SESSION goto https://seedit.localhost
|
||||
playwright-cli -s=SESSION tracing-start
|
||||
```
|
||||
|
||||
@@ -62,7 +62,7 @@ For each route, navigate, interact, and **collect data before moving to the next
|
||||
```bash
|
||||
# Navigate
|
||||
playwright-cli -s=SESSION eval "performance.mark('pre-ROUTE')"
|
||||
playwright-cli -s=SESSION goto http://seedit.localhost:1355/ROUTE
|
||||
playwright-cli -s=SESSION goto https://seedit.localhost/ROUTE
|
||||
playwright-cli -s=SESSION snapshot
|
||||
playwright-cli -s=SESSION eval "performance.mark('post-ROUTE');performance.measure('ROUTE','pre-ROUTE','post-ROUTE')"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Use this skill to jump from a concrete DOM node in the running seedit app to the
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Dev server running at `http://seedit.localhost:1355`
|
||||
- Dev server running at `https://seedit.localhost`
|
||||
- `playwright-cli` installed
|
||||
- Use the local dev app, not production. The element-source helpers are only exposed in dev mode.
|
||||
|
||||
@@ -33,8 +33,8 @@ The result includes:
|
||||
## Session setup
|
||||
|
||||
```bash
|
||||
playwright-cli -s=inspect open http://seedit.localhost:1355
|
||||
playwright-cli -s=inspect goto http://seedit.localhost:1355/all
|
||||
playwright-cli -s=inspect open https://seedit.localhost
|
||||
playwright-cli -s=inspect goto https://seedit.localhost/all
|
||||
playwright-cli -s=inspect eval "window.__ELEMENT_SOURCE__?.ready ?? false"
|
||||
playwright-cli -s=inspect snapshot
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ Two-layer profiling: browser-level symptoms (Web Vitals, long tasks, scroll jank
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Dev server running at http://seedit.localhost:1355 (`yarn start` via Portless)
|
||||
- Dev server running at https://seedit.localhost (`yarn start` via Portless)
|
||||
- `playwright-cli` installed (`npm install -g @playwright/cli@latest`)
|
||||
|
||||
**IMPORTANT:** The orchestrator (you) is responsible for ensuring exactly ONE dev server is running. Profiler subagents must NEVER start a dev server themselves.
|
||||
|
||||
@@ -3,7 +3,7 @@ model_reasoning_effort = "medium"
|
||||
sandbox_mode = "read-only"
|
||||
developer_instructions = """
|
||||
Verify only the route, user flow, and acceptance criteria the parent agent gives you.
|
||||
Use playwright-cli against the already-running local app at http://seedit.localhost:1355 unless the parent agent gives a different URL. Never start, restart, or stop the dev server.
|
||||
Use playwright-cli against the already-running local app at https://seedit.localhost unless the parent agent gives a different URL. Never start, restart, or stop the dev server.
|
||||
Default to a fresh isolated playwright-cli browser session. If verification depends on auth, cookies, extensions, open tabs, or other existing browser state and the parent agent did not specify session mode, stop and ask whether to use a fresh browser or the contributor's current browser session.
|
||||
Never attach to a live personal browser session without explicit permission. If current-session reuse is requested, use the supported attach path only when available; otherwise report the limitation instead of silently switching modes.
|
||||
Run the requested verification flow in all three main browser engines: chrome/Blink, firefox/Gecko, and webkit/Safari. Use separate named playwright-cli sessions per engine unless the parent agent explicitly requires a different attach mode.
|
||||
|
||||
@@ -9,7 +9,7 @@ Use this skill to jump from a concrete DOM node in the running seedit app to the
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Dev server running at `http://seedit.localhost:1355`
|
||||
- Dev server running at `https://seedit.localhost`
|
||||
- `playwright-cli` installed
|
||||
- Use the local dev app, not production. The element-source helpers are only exposed in dev mode.
|
||||
|
||||
@@ -33,8 +33,8 @@ The result includes:
|
||||
## Session setup
|
||||
|
||||
```bash
|
||||
playwright-cli -s=inspect open http://seedit.localhost:1355
|
||||
playwright-cli -s=inspect goto http://seedit.localhost:1355/all
|
||||
playwright-cli -s=inspect open https://seedit.localhost
|
||||
playwright-cli -s=inspect goto https://seedit.localhost/all
|
||||
playwright-cli -s=inspect eval "window.__ELEMENT_SOURCE__?.ready ?? false"
|
||||
playwright-cli -s=inspect snapshot
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ Two-layer profiling: browser-level symptoms (Web Vitals, long tasks, scroll jank
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Dev server running at http://seedit.localhost:1355 (`yarn start`)
|
||||
- Dev server running at https://seedit.localhost (`yarn start`)
|
||||
- `playwright-cli` installed (`npm install -g @playwright/cli@latest`)
|
||||
|
||||
**IMPORTANT:** The orchestrator (you) is responsible for ensuring exactly ONE dev server is running. Profiler subagents must NEVER start a dev server themselves.
|
||||
@@ -31,7 +31,7 @@ Before spawning any profiler subagents, verify exactly one dev server is availab
|
||||
|
||||
```bash
|
||||
# Check if the dev server is reachable
|
||||
curl -sf http://seedit.localhost:1355 -o /dev/null && echo "OK" || echo "NOT RUNNING"
|
||||
curl -sf https://seedit.localhost -o /dev/null && echo "OK" || echo "NOT RUNNING"
|
||||
```
|
||||
|
||||
- If **OK**: proceed to Step 1.
|
||||
|
||||
@@ -19,7 +19,7 @@ If either is missing, report back asking for the missing information.
|
||||
|
||||
### Step 1: Use the Existing Dev Server
|
||||
|
||||
Use the already-running local dev server at `http://seedit.localhost:1355` unless the parent agent gives you a different URL.
|
||||
Use the already-running local dev server at `https://seedit.localhost` unless the parent agent gives you a different URL.
|
||||
|
||||
Do not start, restart, or stop the dev server yourself. If the app is unreachable, report the failure and stop.
|
||||
|
||||
@@ -28,9 +28,9 @@ Do not start, restart, or stop the dev server yourself. If the app is unreachabl
|
||||
Use playwright-cli to check the relevant page in all three browser engines with separate sessions:
|
||||
|
||||
```bash
|
||||
playwright-cli -s=verify-chrome open http://seedit.localhost:1355 --browser=chrome
|
||||
playwright-cli -s=verify-firefox open http://seedit.localhost:1355 --browser=firefox
|
||||
playwright-cli -s=verify-webkit open http://seedit.localhost:1355 --browser=webkit
|
||||
playwright-cli -s=verify-chrome open https://seedit.localhost --browser=chrome
|
||||
playwright-cli -s=verify-firefox open https://seedit.localhost --browser=firefox
|
||||
playwright-cli -s=verify-webkit open https://seedit.localhost --browser=webkit
|
||||
```
|
||||
|
||||
Navigate each engine session to the specific page/route where the change should be visible.
|
||||
@@ -60,7 +60,7 @@ playwright-cli -s=verify-webkit snapshot
|
||||
## Browser Check Results
|
||||
|
||||
### Page Tested
|
||||
- URL: http://seedit.localhost:1355/...
|
||||
- URL: https://seedit.localhost/...
|
||||
|
||||
### What Was Checked
|
||||
- description of each verification
|
||||
|
||||
@@ -3,7 +3,7 @@ name: profiler
|
||||
description: Performance profiler that browses seedit routes via playwright-cli, collecting Web Vitals and React rerender data via react-scan. Returns a structured issues list for a batch of routes. Use proactively when profiling browsing performance, finding bottlenecks, or diagnosing excessive React rerenders.
|
||||
---
|
||||
|
||||
You are a performance profiling agent for the seedit React app at http://seedit.localhost:1355. You use playwright-cli to automate browsing and collect both browser-level (Web Vitals) and React-level (commit counts, per-component render data via react-scan) performance metrics.
|
||||
You are a performance profiling agent for the seedit React app at https://seedit.localhost. You use playwright-cli to automate browsing and collect both browser-level (Web Vitals) and React-level (commit counts, per-component render data via react-scan) performance metrics.
|
||||
|
||||
**MUST: Never start a dev server.** The orchestrator guarantees one is already running. If the app is unreachable, report the error and stop — do not run `yarn start` or any other server command.
|
||||
|
||||
@@ -48,7 +48,7 @@ playwright-cli -s=SESSION run-code "async page => await page.addInitScript(() =>
|
||||
`window.__PROFILING__=true` tells react-scan to disable its toolbar and sounds during automated profiling.
|
||||
|
||||
```bash
|
||||
playwright-cli -s=SESSION goto http://seedit.localhost:1355
|
||||
playwright-cli -s=SESSION goto https://seedit.localhost
|
||||
playwright-cli -s=SESSION tracing-start
|
||||
```
|
||||
|
||||
@@ -61,7 +61,7 @@ For each route, navigate, interact, and **collect data before moving to the next
|
||||
```bash
|
||||
# Navigate
|
||||
playwright-cli -s=SESSION eval "performance.mark('pre-ROUTE')"
|
||||
playwright-cli -s=SESSION goto http://seedit.localhost:1355/ROUTE
|
||||
playwright-cli -s=SESSION goto https://seedit.localhost/ROUTE
|
||||
playwright-cli -s=SESSION snapshot
|
||||
playwright-cli -s=SESSION eval "performance.mark('post-ROUTE');performance.measure('ROUTE','pre-ROUTE','post-ROUTE')"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Use this skill to jump from a concrete DOM node in the running seedit app to the
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Dev server running at `http://seedit.localhost:1355`
|
||||
- Dev server running at `https://seedit.localhost`
|
||||
- `playwright-cli` installed
|
||||
- Use the local dev app, not production. The element-source helpers are only exposed in dev mode.
|
||||
|
||||
@@ -33,8 +33,8 @@ The result includes:
|
||||
## Session setup
|
||||
|
||||
```bash
|
||||
playwright-cli -s=inspect open http://seedit.localhost:1355
|
||||
playwright-cli -s=inspect goto http://seedit.localhost:1355/all
|
||||
playwright-cli -s=inspect open https://seedit.localhost
|
||||
playwright-cli -s=inspect goto https://seedit.localhost/all
|
||||
playwright-cli -s=inspect eval "window.__ELEMENT_SOURCE__?.ready ?? false"
|
||||
playwright-cli -s=inspect snapshot
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ Two-layer profiling: browser-level symptoms (Web Vitals, long tasks, scroll jank
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Dev server running at http://seedit.localhost:1355 (`yarn start`)
|
||||
- Dev server running at https://seedit.localhost (`yarn start`)
|
||||
- `playwright-cli` installed (`npm install -g @playwright/cli@latest`)
|
||||
|
||||
**IMPORTANT:** The orchestrator (you) is responsible for ensuring exactly ONE dev server is running. Profiler subagents must NEVER start a dev server themselves.
|
||||
@@ -31,7 +31,7 @@ Before spawning any profiler subagents, verify exactly one dev server is availab
|
||||
|
||||
```bash
|
||||
# Check if the dev server is reachable
|
||||
curl -sf http://seedit.localhost:1355 -o /dev/null && echo "OK" || echo "NOT RUNNING"
|
||||
curl -sf https://seedit.localhost -o /dev/null && echo "OK" || echo "NOT RUNNING"
|
||||
```
|
||||
|
||||
- If **OK**: proceed to Step 1.
|
||||
|
||||
@@ -174,14 +174,14 @@ src/
|
||||
|
||||
## Local Development URL
|
||||
|
||||
This project uses [Portless](https://github.com/vercel-labs/portless) for the normal web dev flow. The canonical web dev URL is `http://seedit.localhost:1355`, and non-`master` branches can automatically fall back to a branch-scoped `*.seedit.localhost:1355` route when needed so parallel worktrees do not collide. Browser automation and local smoke/bootstrap helpers should target that URL unless the caller explicitly bypasses Portless with `PORTLESS=0`.
|
||||
This project uses [Portless](https://github.com/vercel-labs/portless) for the normal web dev flow. The canonical web dev URL is `https://seedit.localhost`, and non-`master` branches can automatically fall back to a branch-scoped `*.seedit.localhost` route when needed so parallel worktrees do not collide. Browser automation and local smoke/bootstrap helpers should target that URL unless the caller explicitly bypasses Portless with `PORTLESS=0`.
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
corepack enable
|
||||
corepack yarn install
|
||||
yarn start # http://seedit.localhost:1355
|
||||
yarn start # https://seedit.localhost
|
||||
yarn build
|
||||
yarn lint
|
||||
yarn type-check
|
||||
|
||||
@@ -43,11 +43,11 @@ The default list of communities, used on s/all on Seedit, is bitsocial's [defaul
|
||||
1. `yarn install` to install Seedit dependencies
|
||||
2. `yarn start` to run the web client
|
||||
|
||||
The default web dev server runs at `http://seedit.localhost:1355` via [Portless](https://port1355.dev/), so it can share the same proxy as other Bitsocial projects without colliding on raw Vite ports. On non-`master` branches, or when another legacy process is already holding the canonical route, `yarn start` automatically uses a branch-scoped `*.seedit.localhost:1355` URL instead of failing, and repeated branch-scoped runs keep suffixing (`-2`, `-3`, ...) until they find a free route. To bypass Portless and use plain Vite directly, run `PORTLESS=0 yarn start`; it will probe from port `3000` unless you pin `PORT` yourself.
|
||||
The default web dev server runs at `https://seedit.localhost` via [Portless](https://github.com/vercel-labs/portless), so it can share the same proxy as other Bitsocial projects without colliding on raw Vite ports. On non-`master` branches, or when another legacy process is already holding the canonical route, `yarn start` automatically uses a branch-scoped `*.seedit.localhost` URL instead of failing, and repeated branch-scoped runs keep suffixing (`-2`, `-3`, ...) until they find a free route. To bypass Portless and use plain Vite directly, run `PORTLESS=0 yarn start`; it will probe from port `3000` unless you pin `PORT` yourself.
|
||||
|
||||
### Scripts:
|
||||
|
||||
- Web client: `yarn start` (`http://seedit.localhost:1355`)
|
||||
- Web client: `yarn start` (`https://seedit.localhost`)
|
||||
- Electron client (must start web client first): `yarn electron`
|
||||
- Electron client and don't delete data: `yarn electron:no-delete-data`
|
||||
- Web client and electron client: `yarn electron:start` (forces `PORTLESS=0 PORT=3000` and uses `http://localhost:3000`)
|
||||
|
||||
@@ -63,9 +63,9 @@ If uncertain, ask the developer before adding an entry.
|
||||
- **Date:** 2026-03-30
|
||||
- **Observed by:** Codex
|
||||
- **Context:** Normal `yarn start` runs alongside other local Bitsocial projects
|
||||
- **What was surprising:** The repo historically assumed `http://localhost:3000`, but the normal web dev flow now runs through Portless at `http://seedit.localhost:1355` so multiple Bitsocial apps can coexist without raw-port collisions.
|
||||
- **What was surprising:** The repo historically assumed `http://localhost:3000`, but the normal web dev flow now runs through Portless at `https://seedit.localhost` so multiple Bitsocial apps can coexist without raw-port collisions.
|
||||
- **Impact:** Agents can point browser automation, health checks, or local smoke scripts at the wrong URL and conclude the app is down when it is healthy.
|
||||
- **Mitigation:** Use `http://seedit.localhost:1355` for standard web dev and agent smoke flows. Only rely on `http://localhost:3000` when a script intentionally forces both `PORTLESS=0` and `PORT=3000`, such as the combined Electron dev commands.
|
||||
- **Mitigation:** Use `https://seedit.localhost` for standard web dev and agent smoke flows. Only rely on `http://localhost:3000` when a script intentionally forces both `PORTLESS=0` and `PORT=3000`, such as the combined Electron dev commands.
|
||||
- **Status:** confirmed
|
||||
|
||||
### Fixed Portless app names collide across seedit worktrees
|
||||
@@ -75,7 +75,7 @@ If uncertain, ask the developer before adding an entry.
|
||||
- **Context:** Starting `yarn start` in one seedit worktree while another seedit worktree was already serving through Portless
|
||||
- **What was surprising:** Using the literal Portless app name `seedit` in every worktree makes the route itself collide, even when the backing ports are different, so the second process fails because `seedit.localhost` is already registered.
|
||||
- **Impact:** Parallel seedit branches can block each other even though Portless is meant to let them coexist safely.
|
||||
- **Mitigation:** Keep Portless startup behind `scripts/start-dev.js`, which now uses a branch-scoped `*.seedit.localhost:1355` route outside the canonical case, suffixes repeated branch routes (`-2`, `-3`, ...) until it finds a free Portless name, and falls back to the next free direct-Vite port when `PORTLESS=0` is used without an explicit `PORT`.
|
||||
- **Mitigation:** Keep Portless startup behind `scripts/start-dev.js`, which now uses a branch-scoped `*.seedit.localhost` route outside the canonical case, suffixes repeated branch routes (`-2`, `-3`, ...) until it finds a free Portless name, and falls back to the next free direct-Vite port when `PORTLESS=0` is used without an explicit `PORT`.
|
||||
- **Status:** confirmed
|
||||
|
||||
### Toolchain model names are not interchangeable
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
"wait-on": "9.0.4"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"portless": "0.7.0"
|
||||
"portless": "0.11.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"axios": "1.15.0",
|
||||
|
||||
@@ -4,7 +4,7 @@ These rules apply to `scripts/**`. Follow the repo-root `AGENTS.md` first, then
|
||||
|
||||
- Keep scripts non-interactive and idempotent. Print the command, URL, branch, or path being acted on so failures are diagnosable.
|
||||
- Use repo-relative paths and environment variables instead of user-specific absolute paths.
|
||||
- For dev-server helpers, default to `http://seedit.localhost:1355`, but allow a branch-scoped `*.seedit.localhost:1355` route when the launcher is avoiding a Portless name collision. Respect the existing `PORTLESS=0` fallback instead of hard-coding alternate ports. If a flow intentionally bypasses Portless, override `AGENT_APP_URL` explicitly.
|
||||
- For dev-server helpers, default to `https://seedit.localhost`, but allow a branch-scoped `*.seedit.localhost` route when the launcher is avoiding a Portless name collision. Respect the existing `PORTLESS=0` fallback instead of hard-coding alternate ports. If a flow intentionally bypasses Portless, override `AGENT_APP_URL` explicitly.
|
||||
- Keep shell helpers thin. When logic becomes stateful or cross-platform, prefer a Node script.
|
||||
- Git and worktree helpers must validate input and default to safe operations.
|
||||
- If a helper deletes local branches automatically, document the exact eligibility checks and keep the behavior conservative.
|
||||
|
||||
@@ -8,7 +8,7 @@ if [ "$#" -ne 0 ]; then
|
||||
fi
|
||||
|
||||
wait_timeout="${AGENT_INIT_TIMEOUT_SECONDS:-60}"
|
||||
app_url="${AGENT_APP_URL:-http://seedit.localhost:1355}"
|
||||
app_url="${AGENT_APP_URL:-https://seedit.localhost}"
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel)"
|
||||
log_dir="$repo_root/.playwright-cli"
|
||||
@@ -18,7 +18,7 @@ mkdir -p "$log_dir"
|
||||
cd "$repo_root"
|
||||
|
||||
is_server_up() {
|
||||
curl -fsS "$app_url" >/dev/null 2>&1
|
||||
curl -fsSk "$app_url" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
wait_for_server() {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { spawn, spawnSync } from 'node:child_process';
|
||||
import { get } from 'node:http';
|
||||
import { get as httpGet } from 'node:http';
|
||||
import { get as httpsGet } from 'node:https';
|
||||
import { resolvePort } from './dev-server-utils.mjs';
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
@@ -35,7 +36,7 @@ function getCurrentBranch() {
|
||||
return result.stdout.trim() || null;
|
||||
}
|
||||
|
||||
function getActivePortlessRoutes() {
|
||||
function getActivePortlessRouteHosts() {
|
||||
const result = spawnSync(portlessBin, ['list'], {
|
||||
cwd: process.cwd(),
|
||||
encoding: 'utf8',
|
||||
@@ -46,16 +47,16 @@ function getActivePortlessRoutes() {
|
||||
return new Set();
|
||||
}
|
||||
|
||||
const matches = result.stdout.match(/http:\/\/[a-z0-9.-]+\.localhost:1355/g) || [];
|
||||
const matches = result.stdout.match(/https?:\/\/[a-z0-9.-]+\.localhost(?::\d+)?/g) || [];
|
||||
|
||||
return new Set(matches);
|
||||
return new Set(matches.map((url) => new URL(url).hostname));
|
||||
}
|
||||
|
||||
function isRouteBusy(activeRoutes, appName) {
|
||||
return activeRoutes.has(`http://${appName}.localhost:1355`);
|
||||
function isRouteBusy(activeRouteHosts, appName) {
|
||||
return activeRouteHosts.has(`${appName}.localhost`);
|
||||
}
|
||||
|
||||
function getPreferredPortlessAppName(activeRoutes) {
|
||||
function getPreferredPortlessAppName(activeRouteHosts) {
|
||||
const branch = getCurrentBranch();
|
||||
const branchLabel = sanitizeLabel(branch || 'current');
|
||||
|
||||
@@ -63,7 +64,7 @@ function getPreferredPortlessAppName(activeRoutes) {
|
||||
return `${branchLabel}.seedit`;
|
||||
}
|
||||
|
||||
if (isRouteBusy(activeRoutes, 'seedit')) {
|
||||
if (isRouteBusy(activeRouteHosts, 'seedit')) {
|
||||
return `${branchLabel}.seedit`;
|
||||
}
|
||||
|
||||
@@ -71,17 +72,17 @@ function getPreferredPortlessAppName(activeRoutes) {
|
||||
}
|
||||
|
||||
function getPortlessAppName() {
|
||||
const activeRoutes = getActivePortlessRoutes();
|
||||
const preferredAppName = getPreferredPortlessAppName(activeRoutes);
|
||||
const activeRouteHosts = getActivePortlessRouteHosts();
|
||||
const preferredAppName = getPreferredPortlessAppName(activeRouteHosts);
|
||||
|
||||
if (!isRouteBusy(activeRoutes, preferredAppName)) {
|
||||
if (!isRouteBusy(activeRouteHosts, preferredAppName)) {
|
||||
return preferredAppName;
|
||||
}
|
||||
|
||||
for (let suffix = 2; suffix < 1000; suffix += 1) {
|
||||
const candidate = `${preferredAppName}-${suffix}`;
|
||||
|
||||
if (!isRouteBusy(activeRoutes, candidate)) {
|
||||
if (!isRouteBusy(activeRouteHosts, candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +97,7 @@ let publicUrl = null;
|
||||
if (command === portlessBin) {
|
||||
const appName = getPortlessAppName();
|
||||
|
||||
publicUrl = `http://${appName}.localhost:1355`;
|
||||
publicUrl = `https://${appName}.localhost`;
|
||||
args = [appName, 'vite'];
|
||||
|
||||
if (appName !== 'seedit') {
|
||||
@@ -125,7 +126,7 @@ const child = spawn(command, args, {
|
||||
});
|
||||
|
||||
if (publicUrl && process.env.BROWSER !== 'none') {
|
||||
waitForHttpReady(publicUrl, 30_000)
|
||||
waitForUrlReady(publicUrl, 30_000)
|
||||
.then(() => {
|
||||
console.log(`Opening ${publicUrl} in browser...`);
|
||||
openInBrowser(publicUrl);
|
||||
@@ -144,16 +145,19 @@ child.on('exit', (code, signal) => {
|
||||
process.exit(code ?? 0);
|
||||
});
|
||||
|
||||
async function waitForHttpReady(url, timeoutMs) {
|
||||
async function waitForUrlReady(url, timeoutMs) {
|
||||
const startedAt = Date.now();
|
||||
|
||||
while (Date.now() - startedAt < timeoutMs) {
|
||||
const ready = await new Promise((resolve) => {
|
||||
const request = get(url, (response) => {
|
||||
const parsedUrl = new URL(url);
|
||||
const getUrl = parsedUrl.protocol === 'https:' ? httpsGet : httpGet;
|
||||
const onResponse = (response) => {
|
||||
response.resume();
|
||||
const statusCode = response.statusCode ?? 500;
|
||||
resolve(statusCode >= 200 && statusCode < 400);
|
||||
});
|
||||
};
|
||||
const request = parsedUrl.protocol === 'https:' ? getUrl(parsedUrl, { rejectUnauthorized: false }, onResponse) : getUrl(parsedUrl, onResponse);
|
||||
|
||||
request.on('error', () => resolve(false));
|
||||
request.setTimeout(2_000, () => {
|
||||
@@ -174,9 +178,11 @@ async function waitForHttpReady(url, timeoutMs) {
|
||||
|
||||
function openInBrowser(url) {
|
||||
const opener =
|
||||
process.platform === 'darwin' ? { cmd: 'open', args: [url] }
|
||||
: process.platform === 'win32' ? { cmd: 'cmd', args: ['/c', 'start', '""', url] }
|
||||
: { cmd: 'xdg-open', args: [url] };
|
||||
process.platform === 'darwin'
|
||||
? { cmd: 'open', args: [url] }
|
||||
: process.platform === 'win32'
|
||||
? { cmd: 'cmd', args: ['/c', 'start', '""', url] }
|
||||
: { cmd: 'xdg-open', args: [url] };
|
||||
|
||||
spawn(opener.cmd, opener.args, { stdio: 'ignore', detached: true }).unref();
|
||||
}
|
||||
|
||||
10
yarn.lock
10
yarn.lock
@@ -16517,11 +16517,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"portless@npm:0.7.0":
|
||||
version: 0.7.0
|
||||
resolution: "portless@npm:0.7.0"
|
||||
dependencies:
|
||||
chalk: "npm:^5.3.0"
|
||||
"portless@npm:0.11.1":
|
||||
version: 0.11.1
|
||||
resolution: "portless@npm:0.11.1"
|
||||
bin:
|
||||
portless: dist/cli.js
|
||||
conditions: (os=darwin | os=linux | os=win32)
|
||||
@@ -18004,7 +18002,7 @@ __metadata:
|
||||
node-fetch: "npm:2"
|
||||
oxfmt: "npm:0.24.0"
|
||||
oxlint: "npm:1.39.0"
|
||||
portless: "npm:0.7.0"
|
||||
portless: "npm:0.11.1"
|
||||
progress: "npm:2.0.3"
|
||||
react: "npm:19.1.2"
|
||||
react-ace: "npm:14.0.1"
|
||||
|
||||
Reference in New Issue
Block a user